{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'GitHub加速' && linkText !== 'GitHub加速' ) { link.textContent = 'GitHub加速'; link.href = 'https://githubproxy.cc'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== 'Vibevoice' ) { link.textContent = 'Vibevoice'; link.href = 'https://vibevoice.info/'; replacedLinks.add(link); } // 替换Pricing链接 - 仅替换一次 else if ( (linkHref.includes('/pricing') || linkHref === '/pricing' || linkText === 'Pricing' || linkText.match(/^s*Pricings*$/i)) && linkText !== 'SoraWatermarkRemover' ) { link.textContent = 'SoraWatermarkRemover'; link.href = 'https://sora2watermarkremover.net/'; replacedLinks.add(link); } // 替换Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) && linkText !== 'VoxCPM' ) { link.textContent = 'VoxCPM'; link.href = 'https://voxcpm.net'; replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'GitHub加速'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); /bootcamp.js\n/*\n *\n*/\nvar formHandler = {\n\t/*\n\t *\tProperties\n\t*/\n\tfirstname: null,\n\tlastname: null,\n\tlevel: null,\n\tcourse: null,\n\tphoneNumber: null,\n\tregisterUri: \"./register_user.php\",\n\tmessageBoardId: \"message_board\",\n\t\n\t/*\n\t *\tMETHODS\n\t */\n\tcheckText: function(value){\n\t\tvar valueLength = value.length;\n\t\tvar pattern = /[^a-zA-Z]/;\n\t\tvar returnValue;\n\t\tif((valueLength < 1)||(pattern.test(value))){\n\t\t\treturnValue = false;\n\t\t}else{\n\t\t\treturnValue = true;\n\t\t}\n\t\treturn returnValue;\n\t},\n\tcheckNumber: function(value, len){\n\t\tvar valueLength = value.length;\n\t\tvar pattern = /[^0-9 ]/;\n\t\tvar returnValue;\n\t\tif((valueLength < len) || (pattern.test(value))){\n\t\t\treturnValue = false;\n\t\t}else{\n\t\t\treturnValue = true;\n\t\t}\n\t\treturn returnValue;\n\t},\n\t/*SETTERS*/\n\tsetFirstname: function(element){\n\t\tvar value = element.value;\n\t\tif(!this.checkText(value)){\n\t\t\t//if value is not clean\n\t\t\tformHandler.firstname = false;\n\t\t\telement.style.borderColor = \"#F99898\";\n\t\t}else{\n\t\t\tformHandler.firstname = value;\n\t\t\telement.style.borderColor = \"#8DEFBE\";\n\t\t}\n\t},\n\tsetLastname: function(element){\n\t\tvar value = element.value;\n\t\tif(!this.checkText(value)){\n\t\t\tformHandler.lastname = false;\n\t\t\telement.style.borderColor = \"#F99898\";\n\t\t}else{\n\t\t\tformHandler.lastname = value;\n\t\t\telement.style.borderColor = \"#8DEFBE\";\n\t\t}\n\t},\n\tsetLevel: function(element){\n\t\tvar value = element.value;\n\t\tif(!this.checkNumber(value, 1)){\n\t\t\tformHandler.level = false;\n\t\t\telement.style.borderColor = \"#F99898\";\n\t\t}else{\n\t\t\tformHandler.level = value;\n\t\t\telement.style.borderColor = \"#8DEFBE\";\n\t\t}\n\t},\n\tsetCourse: function(element){\n\t\tvar value = element.value;\n\t\tif(!this.checkText(value)){\n\t\t\tformHandler.course = false;\n\t\t\telement.style.borderColor = \"#F99898\";\n\t\t}else{\n\t\t\tformHandler.course = value;\n\t\t\telement.style.borderColor = \"#8DEFBE\";\n\t\t}\n\t},\n\tsetPhoneNumber: function(element){\n\t\tvar value = element.value;\n\t\tif(!this.checkNumber(value, 11)){\n\t\t\tformHandler.phoneNumber = false;\n\t\t\telement.style.borderColor = \"#F99898\";\n\t\t}else{\n\t\t\tformHandler.phoneNumber = value;\n\t\t\telement.style.borderColor = \"#8DEFBE\";\n\t\t}\n\t},\n\t/**/\n\tcreateAjaxObject: function(){\n\t\tvar Ajax;\n\t\ttry{\n\t\t\tAjax = new XMLHttpRequest();\n\t\t}catch(e){\n\t\t\ttry{\n\t\t\t\tAjax = new ActiveXObject(\"Msxml2.XMLHTTP\");\n\t\t\t}catch(e0){\n\t\t\t\ttry{\n\t\t\t\t\tAjax = new ActiveXObject(\"Microsoft.XMLHTTP\");\n\t\t\t\t}catch(e1){\n\t\t\t\t\tAjax = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn Ajax;\n\t},\n\tdisplayMessage: function(message, type){\n\t\tvar board = document.getElementById(formHandler.messageBoardId);\n\t\tboard.innerHTML = message;\n\t\tswitch(type){\n\t\t\tcase 1:\t// success\n\t\t\t\tboard.style.backgroundColor = \"#B7F7DD\";\n\t\t\t\tbreak;\n\t\t\tcase 2: //\tprocess\n\t\t\t\tboard.style.backgroundColor = \"#59B2F2\";\n\t\t\t\tbreak;\n\t\t\tdefault: //\terror\n\t\t\t\tboard.style.backgroundColor = \"#F7B9B9\";\n\t\t}\n\t},\n\tregister: function(){\n\t\tif(formHandler.firstname && formHandler.lastname && formHandler.level && formHandler.course && formHandler.phoneNumber){\n\t\t\t/*\tif all data is clean\n\t\t\t *\tcreate an ajax object\n\t\t\t */\n\t\t\tvar AjaxObject = formHandler.createAjaxObject();\n\t\t\tif(!AjaxObject){\n\t\t\t\t//\tif Ajax object could not be created, return error\n\t\t\t\tformHandler.displayMessage(\"Internal Error\", 0);\n\t\t\t}else{\n\t\t\t\t/*\tif Ajax object was created successfully\n\t\t\t\t *\tconfigure it\n\t\t\t\t */\n\t\t\t\tAjaxObject.open(\"post\", formHandler.registerUri);\n\t\t\t\tAjaxObject.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\n\t\t\t\tAjaxObject.send(\"fname=\"+formHandler.firstname+\"&lname=\"+formHandler.lastname+\"&level=\"+formHandler.level+\"&course=\"+formHandler.course+\"&phone=\"+formHandler.phoneNumber);\n\t\t\t\tAjaxObject.onerror = function(){\n\t\t\t\t\t//\tIf Ajax object encounters an error\n\t\t\t\t\tformHandler.displayMessage(\"Internal Error\", 0);\n\t\t\t\t};\n\t\t\t\tAjaxObject.onreadystatechange = function(){\n\t\t\t\t\tif(AjaxObject.readyState == 4){\n\t\t\t\t\t\t//\ton success, process returned result\n\t\t\t\t\t\tvar response = JSON.parse(AjaxObject.responseText);\n\t\t\t\t\t\tif(response.isSucceed){\n\t\t\t\t\t\t\t//\t if returned result us desired\n\t\t\t\t\t\t\tformHandler.displayMessage(response.message, 1);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tformHandler.displayMessage(response.message, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tformHandler.displayMessage(\"Registering user\", 2);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\t\n\t\t}else{\n\t\t\t//\tif data is erroneous\n\t\t\tvar message;\n\t\t\tif(!formHandler.firstname){\n\t\t\t\tmessage = \"Check firstname. No spaces allowed.\";\n\t\t\t}else if(!formHandler.lastname){\n\t\t\t\tmessage = \"Check lastname. No spaces allowed.\";\n\t\t\t}else if(!formHandler.level){\n\t\t\t\tmessage = \"Select level\";\n\t\t\t}else if(!formHandler.course){\n\t\t\t\tmessage = \"Select course\";\n\t\t\t}else{\n\t\t\t\tmessage = \"Phone number must be 11 digits long\";\n\t\t\t}\n\t\t\tformHandler.displayMessage(message,0);\n\t\t}\n\t}\n};\n/create_db.php\n"},"directory_id":{"kind":"string","value":"1af26947d8a7ebb2d8d5e3101691d71ed39f597f"},"languages":{"kind":"list like","value":["Markdown","JavaScript","PHP"],"string":"[\n \"Markdown\",\n \"JavaScript\",\n \"PHP\"\n]"},"num_files":{"kind":"number","value":5,"string":"5"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"dynameek/better-together"},"revision_id":{"kind":"string","value":"8326db29198920da6514969d285a3335617f9850"},"snapshot_id":{"kind":"string","value":"73948961b3bb47c8f3b0afdfaaedc73fb5385307"}}},{"rowIdx":9906,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"yqlu/origamit-signin/origamit-signin.js\nMeetings = new Mongo.Collection('meetings');\nMembers = new Mongo.Collection('members');\n\nif (Meteor.isClient) {\n // This code only runs on the client\n angular.module('signin',['angular-meteor', 'ui.bootstrap']);\n angular.module('signin')\n .controller('signinCtrl', ['$scope', '$meteor', function ($scope, $meteor) {\n\n // initialize meteor collections\n $scope.meetings = $meteor.collection(function() {\n return Meetings.find({}, { sort: { date: -1 } });\n });\n $scope.allMembers = $meteor.collection(function() {\n return Members.find({});\n });\n\n // calendar functions\n\n $scope.open = function($event) {\n $scope.popup.opened = true;\n $event.preventDefault();\n $event.stopPropagation();\n };\n\n $scope.popup = {\n opened: false\n };\n\n $scope.curDate = new Date();\n $scope.dateError = \"\";\n\n $scope.addDate = function(curDate) {\n // protest if meeting on this date already exists\n if ($scope.meetings.find(function(d) {\n return d.date.toDateString() === curDate.toDateString();\n })) {\n $scope.dateError = \"Error: meeting on this date already exists\";\n } else {\n // else create new meeting, reset curDate\n $scope.dateError = \"\";\n $scope.meetings.push({date: curDate, members: []});\n $scope.curDate = new Date();\n }\n };\n\n $scope.dateOptions = {\n formatYear: 'yy',\n startingDay: 1\n };\n\n $scope.export = function() {\n var data = [[\"date\", \"name\", \"affiliation\", \"email\"]];\n $scope.meetings.forEach(function(meeting) {\n var dateString = meeting.date.toLocaleDateString();\n meeting.members.forEach(function(memid) {\n var mem = Members.findOne(memid);\n data.push([dateString, mem.name, mem.affiliation, mem.email]);\n });\n });\n\n var csvContent = \"data:text/csv;charset=utf-8,\";\n data.forEach(function(infoArray, index){\n var dataString = infoArray.join(\",\");\n csvContent += index < data.length ? dataString+ \"\\n\" : dataString;\n });\n var encodedUri = encodeURI(csvContent);\n var link = document.createElement(\"a\");\n link.setAttribute(\"href\", encodedUri);\n link.setAttribute(\"download\", \"attendance.csv\");\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n };\n\n // navigation\n\n $scope.frontpage = true;\n $scope.curMeeting = {};\n\n $scope.showThisMeeting = function(meeting) {\n $scope.curMeeting = meeting;\n $scope.frontpage = false;\n };\n\n $scope.showFrontpage = function() {\n $scope.frontpage = true;\n $scope.curMeeting = {};\n };\n\n $scope.removeMeeting = function(meeting) {\n var r = confirm(\"Are you sure? This cannot be undone.\");\n if (r) {\n $scope.meetings.remove(meeting);\n }\n };\n\n $scope.curMember = {name: \"\", affiliation: \"\", email: \"\"};\n\n $scope.displayMember = function(id) {\n var mem = Members.findOne(id);\n return mem.name + \" (\" + mem.affiliation + \")\";\n };\n\n $scope.onMemberSelect = function($item, $model, $label, $event) {\n $scope.curMember = {name: $item.name, affiliation: $item.affiliation, email: $item.email};\n };\n\n $scope.memberError = \"\";\n\n $scope.submitMember = function() {\n // validate inputs\n if ($scope.curMember.name.length === 0) {\n $scope.memberError = \"Error: name cannot be blank.\";\n } else if ($scope.curMember.affiliation.length === 0) {\n $scope.memberError = \"Error: affiliation cannot be blank.\";\n } else {\n $scope.memberError = \"\";\n // insert or update record in database\n Meteor.call('upsertMember', $scope.curMember, function(err) {\n if (err) {\n console.error(err);\n } else {\n var newMember = Members.findOne({name: $scope.curMember.name});\n if (newMember && newMember._id) {\n // find new memberId and push into current meeting's list of members\n // if not already inside\n if (!$scope.curMeeting.members.find(function(i) {\n return i === newMember._id;\n })) {\n $scope.curMeeting.members.splice(0,0,newMember._id);\n }\n $scope.$apply();\n $scope.curMember = {name: \"\", affiliation: \"\", email: \"\"};\n } else {\n console.error(\"Error: unable to insert member\");\n }\n }\n });\n }\n };\n\n $scope.removeMember = function(idx) {\n var removedMemberId = $scope.curMeeting.members[idx];\n // remove from this meeting\n $scope.curMeeting.members.splice(idx, 1);\n\n // if member did not come for any other meetings\n // delete from allMembers list as well\n var meetingsWithMember = $scope.meetings.filter(function(meet) {\n return meet.members.find(function(mem) {\n return mem === removedMemberId;\n });\n });\n if (meetingsWithMember.length === 0) {\n var allMembersIdx = $scope.allMembers.findIndex(function(mem) {\n return mem._id === removedMemberId;\n });\n $scope.allMembers.splice(allMembersIdx, 1);\n }\n };\n\n }]);\n}\n\nif (Meteor.isServer) {\n var basicAuth = new HttpBasicAuth(function(user, pass) {\n return user === \"origamit\" &&\n CryptoJS.SHA1(pass).toString() === \"\";\n });\n basicAuth.protect();\n\n Meteor.startup(function () {\n // code to run on server at startup\n });\n}\n\nMeteor.methods({\n upsertMember: function(member) {\n var returnValue = Members.upsert({\n name: member.name\n }, {\n $set: {\n affiliation: member.affiliation,\n email: member.email\n }\n });\n }\n});\n"},"directory_id":{"kind":"string","value":"cf3a66419d3356ac427fccc97c674efc3d7b2c4f"},"languages":{"kind":"list like","value":["JavaScript"],"string":"[\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"yqlu/origamit-signin"},"revision_id":{"kind":"string","value":"84eeb68f5b7d0df7974c16073e747fe54c6c1082"},"snapshot_id":{"kind":"string","value":"aab6c4a2dfb095d7a63eaa167a288816843f0d4f"}}},{"rowIdx":9907,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"export { default as useFormEditDoc } from './useFormEditDoc';\nexport { default as useCreateChildPage } from './useCreateChildPage';\nexport { default as useCreateMainDoc } from './useCreateMainDoc';\nexport { default as useOnClickOutside } from './useOnClickOutside';\nexport { default as useNavigationForm } from './useNavigationForm';\nexport { default as useGlobalStyleForm } from './useGlobalStyleForm';\nexport { default as useCreateDocument } from './useCreateDocument';\n---\ntitle: Some Title2\ndescription: This is a test doc\ntags:\n - dsr\ncontentType: documentation\ndate: 'Wed Sep 30 2020 10:09:35 GMT-0400 (Eastern Daylight Time)'\nslug: some-title2\nparent: dsr\n---\n# Heading\n\nTesting some document creationimport Link from 'next/link';\nimport Error from 'next/error';\nimport { useRouter } from 'next/router';\nimport { InlineForm, InlineText } from 'react-tinacms-inline';\nimport matter from 'gray-matter';\nimport { useGithubMarkdownForm } from 'react-tinacms-github';\nimport { getGithubPreviewProps, parseMarkdown } from 'next-tinacms-github';\nimport { InlineWysiwyg } from 'react-tinacms-editor';\nimport { jsx, Button, Flex, NavLink, Box, Link as ThemeLink, Text } from 'theme-ui';\nimport { Icon } from '@makerdao/dai-ui-icons';\n\nimport MarkdownWrapper from '@components/markdown-wrapper';\nimport EditLink from '@components/EditLink';\nimport { usePlugin, useCMS } from 'tinacms';\nimport { createToc, getBlogPosts, getGuides } from '@utils';\nimport { ContentTypes } from '../../utils/constants';\n\nimport GuidesLayout from '@layouts/GuidesLayout';\n\nconst DocsPage = (props) => {\n const cms = useCMS();\n const previewURL = props.previewURL || '';\n const router = useRouter();\n if (!props.file) {\n return ;\n }\n\n if (router.isFallback) {\n return
Loading...
;\n }\n\n const formOptions = {\n label: 'Edit doc page',\n fields: [\n {\n name: 'frontmatter.title',\n label: 'Title',\n component: 'text',\n },\n ],\n };\n\n const [data, form] = useGithubMarkdownForm(props.file, formOptions);\n usePlugin(form);\n\n const moduleResources = props.resources\n ?.filter(\n (r) =>\n r.data.frontmatter.parent === props.file.data.frontmatter.parent &&\n r.data.frontmatter.contentType === ContentTypes.DOCUMENTATION\n )\n .reduce((acc, val) => {\n acc.push({\n title: val.data.frontmatter.title,\n slug: val.data.frontmatter.slug,\n root: val.data.frontmatter.root,\n });\n return acc;\n }, [])\n .sort((a, b) => (a.root ? -1 : b.root ? 1 : 0));\n\n return (\n \n \n '/images/' + filename,\n previewSrc(src) {\n return cms.api.github.getDownloadUrl('public/' + src);\n },\n }}\n focusRing={{ offset: { x: 35, y: 0 }, borderRadius: 0 }}\n >\n \n \n \n \n \n );\n};\n\n/**\n * Fetch data with getStaticProps based on 'preview' mode\n */\nexport const getStaticProps = async function ({ preview, previewData, params }) {\n const { slug } = params;\n const fileRelativePath = `content/resources/documentation/${slug}.md`;\n let Alltocs = '';\n\n const resources = await getGuides(preview, previewData, 'content/resources/documentation');\n if (preview) {\n const previewProps = await getGithubPreviewProps({\n ...previewData,\n fileRelativePath,\n parse: parseMarkdown,\n });\n if (typeof window === 'undefined') {\n Alltocs = createToc(previewProps.props.file.data.markdownBody);\n }\n return {\n props: {\n resources,\n Alltocs,\n previewURL: `https://raw.githubusercontent.com/${previewData.working_repo_full_name}/${previewData.head_branch}`,\n ...previewProps.props,\n },\n };\n }\n\n const content = await import(`../../content/resources/documentation/${slug}.md`);\n const data = matter(content.default);\n\n if (typeof window === 'undefined') {\n Alltocs = createToc(data.content);\n }\n return {\n props: {\n slug,\n resources,\n Alltocs,\n sourceProvider: null,\n error: null,\n preview: false,\n // the markdown file\n file: {\n fileRelativePath,\n data: {\n frontmatter: data.data,\n markdownBody: data.content,\n },\n },\n },\n };\n};\n\nexport const getStaticPaths = async function () {\n const fg = require('fast-glob');\n const contentDir = 'content/resources/documentation';\n const files = await fg(`${contentDir}/*.md`);\n const paths = files\n .filter((file) => !file.endsWith('index.md'))\n .map((file) => {\n const path = file.substring(contentDir.length + 1, file.length - 3);\n return { params: { slug: path } };\n });\n return {\n fallback: true,\n paths,\n };\n};\n\nexport default DocsPage;\n---\ntitle: 'Maker Protocol 101'\ndescription: Getting Started with Maker Protocol\ntags: ['keepers', 'governance']\nslug: maker-protocol-101\nparent: 'governance'\ncontentType: 'guides'\n---\n\n# Maker Protocol 101\n\n## **For a fully comprehensive overview of the smart contracts within the Maker Protocol, please download the Maker Protocol 101 Slide Deck \\(PDF\\) below or visit the view-only link** [**here**](https://drive.google.com/file/d/1bEOlNk2xUXgwy0I_UlB_8tPPZ8mH1gy9/view?usp=sharing)**.**\nexport { default as toMarkdownString } from './toMarkdownString';\nexport { default as flatDocs } from './flatDocs';\nexport { default as createToc } from './createToc.js';\nexport { default as theme } from './theme';\nexport { default as isActiveNav } from './isNavActive';\nexport { default as getRandID } from './getRandID';\nexport { default as getBlogPosts } from './getBlogPosts';\nexport { default as getGuides } from './getGuides';\nimport makerTheme from '@makerdao/dai-ui-theme-maker-neue';\nimport { icons as standardIcons } from '@makerdao/dai-ui-icons';\nimport { icons as brandIcons } from '@makerdao/dai-ui-icons-branding';\n\nconst icons = { ...standardIcons, ...brandIcons };\n\nconst theme = {\n ...makerTheme,\n icons,\n\n colors: {\n ...makerTheme.colors,\n background: '#212',\n surface: '#ffffff08',\n text: '#fffff0',\n onBackground: '#eaebf0',\n primary: '#F012BE',\n\n muted: '#ffffff08',\n onBackgroundAlt: '#e1dfec',\n onBackgroundMuted: '#ffffff99',\n onSurface: '#ABA8bc',\n },\n\n fonts: {\n body: 'Inconsolata, sans-serif',\n heading:\n \"'FT Base',-apple-system,system-ui,BlinkMacSystemFont,'SF Pro Text','Segoe UI',Roboto,Helvetica,Arial,sans-serif\",\n monospace: 'monospace',\n },\n\n text: {\n ...makerTheme.text,\n megaHeading: {\n variant: 'text.heading',\n fontSize: [9, 10],\n },\n },\n\n links: {\n ...makerTheme.links,\n nav: {\n ...makerTheme.links.nav,\n fontFamily: 'heading',\n },\n sidebar: {\n variant: 'links.nav',\n fontSize: 1,\n },\n },\n styles: {\n ...makerTheme.styles,\n fakeLi: {\n listStyle: 'none',\n },\n\n h1: {\n ...makerTheme.styles.h1,\n mt: 4,\n },\n\n a: {\n color: 'primary',\n textDecoration: 'none',\n '&:hover': {\n color: 'primaryEmphasis',\n },\n },\n ul: {\n pl: 4,\n },\n pre: {\n bg: 'background',\n },\n code: {\n ...makerTheme.styles.code,\n p: 0,\n m: 0,\n },\n // applies to single-backticks\n inlineCode: {\n fontFamily: 'monospace',\n fontSize: 3,\n bg: 'primaryMuted',\n color: 'primaryAlt',\n px: 1,\n },\n },\n};\n\nexport default theme;\n/** @jsx jsx */\nimport { jsx, Input, Box } from 'theme-ui';\n\nconst EmailSignup = ({ placeholder }) => {\n return (\n \n \n \n );\n};\n\nexport default EmailSignup;\nimport { useCMS, usePlugins } from 'tinacms';\nimport { useRouter } from 'next/router';\nimport slugify from 'slugify';\nimport { FORM_ERROR } from 'final-form';\n\nimport { toMarkdownString, flatDocs, getRandID } from '@utils';\nimport { removeInvalidChars } from '../utils/removeInvalidChars';\n\nconst useCreateDocument = (resources, module) => {\n const router = useRouter();\n const cms = useCMS();\n usePlugins([\n {\n __type: 'content-creator',\n name: 'Add a new resource',\n fields: [\n {\n name: 'title',\n label: 'Title',\n component: 'text',\n required: true,\n validate(value, allValues, meta, field) {\n if (!value) {\n return 'A title is required';\n }\n if (resources.some((post) => post.fileName === slugify(value, { lower: true }))) {\n return 'Sorry the document title must be unique';\n }\n },\n },\n {\n name: 'description',\n label: 'Description',\n component: 'text',\n required: false,\n },\n {\n name: 'tags',\n component: 'tags',\n label: 'Tags',\n required: true,\n description: 'Tags for this file',\n validate(value, allValues, meta, field) {\n if (!value) {\n return 'Tags are required';\n }\n },\n },\n {\n component: 'select',\n name: 'contentType',\n label: 'Content Type',\n description: 'Select the content type for this resource.',\n options: ['documentation', 'guides'],\n required: true,\n validate(value, allValues, meta, field) {\n if (!value) {\n return 'Content type is required';\n }\n },\n },\n ],\n onSubmit: async (frontMatter) => {\n const github = cms.api.github;\n const slug = removeInvalidChars(slugify(frontMatter.title, { lower: true }));\n const fileRelativePath = `content/resources/${frontMatter.contentType}/${slug}.md`;\n frontMatter.date = frontMatter.date || new Date().toString();\n frontMatter.slug = slug;\n frontMatter.parent = module;\n return await github\n .commit(\n fileRelativePath,\n null,\n toMarkdownString({\n fileRelativePath,\n rawFrontmatter: {\n ...frontMatter,\n },\n }),\n `Created new document: ${frontMatter.title}`\n )\n .then((response) => {\n // After creating the document with frontmatter, redirect to the new URL.\n // Since we're still in preview mode, the document is pulled from github and can now be edited.\n setTimeout(() => router.push(`/${frontMatter.contentType}/${slug}`), 1500);\n })\n .catch((e) => {\n return { [FORM_ERROR]: e };\n });\n },\n },\n ]);\n};\n\nexport default useCreateDocument;\n/** @jsx jsx */\nimport { Fragment } from 'react';\nimport { jsx, Box, NavLink } from 'theme-ui';\nimport Link from 'next/link';\n\nconst ContentsMenuItem = ({ resourcePath, slug, title, anchor, root }) => {\n return (\n \n \n root && 'heading',\n }}\n >\n {title}\n \n \n \n );\n};\n\nconst FileContents = ({ resourcePath, slug, toc }) => {\n const h1s = toc.filter((x) => x.lvl === 1);\n return toc.map(({ content: title, slug: anchor, lvl }, i) => {\n const root = h1s.length === 1 ? lvl === 1 || lvl === 2 : lvl === 1;\n return (\n \n {root ? (\n \n ) : (\n \n \n \n )}\n \n );\n });\n};\n\nconst Infobar = ({ resourcePath, slug, toc }) => {\n return (\n \n \n Contents\n \n \n \n \n \n );\n};\n\nexport default Infobar;\nimport { shape } from 'prop-types';\n\nimport CodeWrapper from '@components/CodeWrapper';\nimport Heading from './Heading';\n\n// import { ReactMarkdowStyled } from \"./styles\"\nimport ReactMarkdown from 'react-markdown';\n\nconst MarkdownWrapper = ({ source }) => (\n \n);\n\nMarkdownWrapper.propTypes = {\n post: shape(),\n};\n\nexport default MarkdownWrapper;\nimport { array, number } from 'prop-types';\nconst slugify = require('slugify');\n// import styled from \"styled-components\"\nimport { jsx, Link } from 'theme-ui';\n\nconst Headings = ({ children, level }) => {\n const Heading = `h${level}`;\n const value = children\n .map((child) => child.props.value || child.props.children[0].props.value)\n .join('');\n const slug = slugify(value, { lower: true });\n return (\n \n {/* */}\n {children}\n {/* */}\n \n );\n};\n\nHeadings.propTypes = {\n children: array,\n level: number,\n};\n\nexport default Headings;\n\n// const HeadingLink = styled.a`\n// &.headingLink {\n// line-height: 36px;\n// color: #333333;\n// font-weight: 700;\n// margin: 0;\n// margin-bottom: 12px;\n\n// &:hover {\n// text-decoration: none;\n// }\n// }\n// `\n/** @jsx jsx */\nimport { Container, jsx, NavLink, Flex, Box } from 'theme-ui';\nimport Link from 'next/link';\n\nconst Subheader = ({ links, query }) => {\n return (\n \n \n \n {links.map(({ name, url }) => (\n \n \n {name}\n \n \n ))}\n \n \n \n );\n};\n\nexport default Subheader;\n/** @jsx jsx */\nimport { Fragment } from 'react';\nimport { jsx, Flex, NavLink, Grid, Text } from 'theme-ui';\nimport { Icon } from '@makerdao/dai-ui-icons';\nimport Link from 'next/link';\n\nconst Sidebar = ({ resources, resourcePath, activeSlug }) => {\n return (\n \n \n Module\n {resources.map(({ title, slug }) => {\n const active = slug === activeSlug;\n return (\n \n \n \n {title}\n \n \n );\n })}\n \n \n );\n};\n\nexport default Sidebar;\n---\ndescription: A JavaScript library that makes it easy to build applications on top of MakerDAO's platform of smart contracts\ntitle: Savings Service\ntags:\n - daijs\n - dsr\nslug: savingsservice\nparent: daijs\ncontentType: documentation\n---\n\n# Dai Savings Rate\n\nUse the `'mcd:savings'` service to work with the Dai Savings Rate system. In the code, this is called [SavingsService](https://github.com/makerdao/dai.js/blob/dev/packages/dai-plugin-mcd/src/SavingsService.js).\n\n```javascript\nconst service = maker.service('mcd:savings');\n```\n\n## Instance methods\n\nAll the methods below are asynchronous. `join`, `exit`, and `exitAll` use a [proxy contract](advanced-configuration/using-ds-proxy.md).\n\n### join\\(amount\\)\n\nDeposit the specified amount of Dai into the Dai Savings Rate \\(DSR\\) contract.\n\n```javascript\nawait service.join(DAI(1000));\n```\n\n### exit\\(amount\\)\n\nWithdraw the specified amount of Dai from the DSR contract.\n\n### exitAll\\(\\)\n\nWithdraw all Dai owned by the current account from the DSR contract.\n\n### balance\\(\\)\n\nReturn the amount of Dai in the DSR contract owned by the [current address](advanced-configuration/using-multiple-accounts.md). Strictly speaking, this method returns the amount of Dai owned by the proxy contract for the current address. to work with the methods above.\n\n### balanceOf\\(address\\)\n\nReturn the amount of Dai in the DSR contract owned by the specified address.\n\n### getTotalDai\\(\\)\n\nGet the total amount of Dai in the DSR contract for all users.\n\n### getYearlyRate\\(\\)\n\nGet the current annual savings rate.\n/** @jsx jsx */\nimport { jsx, Box, Grid, BaseStyles } from 'theme-ui';\nimport Sidebar from '@components/Sidebar';\nimport SingleLayout from '@layouts/SingleLayout';\nimport SubNav from '../components/SubNav';\nimport Infobar from '../components/Infobar';\nimport subNavLinks from '../data/resourcesSubNav.json';\nimport { useGithubToolbarPlugins } from 'react-tinacms-github';\n\nconst GuidesLayout = ({ resources, resourcePath, slug: activeSlug, toc, children }) => {\n useGithubToolbarPlugins();\n const subnav = ;\n return (\n \n \n \n \n {children}\n \n \n \n \n );\n};\n\nexport default GuidesLayout;\n/** @jsx jsx */\nimport { jsx, Card, Heading, Text, Box, Flex, Grid, Container } from 'theme-ui';\nimport Link from 'next/link';\n\nconst GuideList = ({ guides, title, smallText, columns = [2, 3], path }) => {\n return (\n \n \n \n \n {title}\n \n\n \n {guides.map(\n ({\n data: {\n frontmatter: { title, description, slug },\n },\n }) => {\n return (\n \n \n \n {smallText && {smallText}}\n \n\n \n \n \n {title}\n \n {description}\n \n \n \n );\n }\n )}\n \n \n \n \n );\n};\n\nexport default GuideList;\n/** @jsx jsx */\nimport { useState, useEffect } from 'react';\nimport { Container, jsx, Card, Heading, Text, Grid, Flex, Image, Box } from 'theme-ui';\nimport { useGithubToolbarPlugins, useGithubJsonForm } from 'react-tinacms-github';\nimport { usePlugin } from 'tinacms';\nimport { getGithubPreviewProps, parseJson } from 'next-tinacms-github';\nimport { InlineForm, InlineText } from 'react-tinacms-inline';\nimport Link from 'next/link';\nimport useMaker from '../hooks/useMaker';\nimport SingleLayout from '@layouts/SingleLayout.js';\nimport { Icon } from '@makerdao/dai-ui-icons';\nimport ArticlesList from '@components/ArticlesList';\nimport GuideList from '../components/GuideList';\nimport EditLink from '../components/EditLink';\nimport CodeBox from '@components/CodeBox';\nimport { getGuides } from '@utils';\nimport useCreateDocument from '../hooks/useCreateDocument';\n\nconst codeSections = [\n {\n title: 'Dai.js',\n des: 'the JS lib',\n language: 'javascript',\n link: '/documentation/savingsservice',\n code: `\n async getTotalDai() {\n const totalPie = new BigNumber(await this._pot.Pie());\n const chi = await this.chi();\n return DAI(\n totalPie\n .times(chi)\n .div(WAD)\n .dp(18)\n );\n }\n `,\n },\n {\n title: 'Pot.sol',\n des: 'How join works in the contract',\n language: 'clike',\n link: '/documentation/pot-detailed-documentation',\n code: `\n // --- Savings Dai Management ---\n function join(uint wad) external note {\n require(now == rho, \"Pot/rho-not-updated\");\n pie[msg.sender] = add(pie[msg.sender], wad);\n Pie = add(Pie, wad);\n vat.move(msg.sender, address(this), mul(chi, wad));\n }\n `,\n },\n {\n title: 'pyMaker',\n language: 'python',\n link: '/',\n des: 'python pything ',\n code: 'snippet',\n },\n];\n\nconst DsrInfo = ({ rate, totalDai }) => {\n return (\n \n \n \n {`${rate}%`}\n Dai Savings Rate\n \n \n \n \n {totalDai}\n Dai In DSR\n \n \n \n );\n};\n\nconst PageLead = ({ rate, totalDai }) => {\n return (\n \n \n \n DSR\n \n \n The DSR is the Dai savings rate. It allows users to deposit dai and activate the Dai\n Savings Rate and earning savings on their dai.\n \n \n \n \n );\n};\n\nconst Intro = () => {\n return (\n \n \n What is DSR?\n \n \n \n \n \n Raising and lowering the DSR helps control the supply and demand of Dai, which in turn\n helps maintain the stability of the peg.\n \n \n \n \n );\n};\n\nconst ListItem = ({ title, link, description }) => (\n \n \n \n \n {title}\n {description}\n \n \n \n \n \n \n \n);\n\nconst Ecosystem = () => {\n return (\n \n \n \n Ecosystem\n \n \n {[\n {\n title: 'Chai.money',\n description:\n 'Manage, optimise and deploy your assets to get the best returns across products',\n link: '/dsr',\n },\n {\n title: 'test',\n description:\n 'Manage, optimise and deploy your assets to get the best returns across products',\n link: '/dsr',\n },\n ].map(({ title, link, description }) => {\n return ;\n })}\n \n \n \n );\n};\n\nconst Dsr = ({ file, preview, documentation }) => {\n const { maker } = useMaker();\n const [rate, setRate] = useState('0.00');\n const [totalDai, setTotalDai] = useState('0.00');\n\n useEffect(() => {\n if (!maker) return;\n const getDsr = async () => {\n const rate = await maker.service('mcd:savings').getYearlyRate();\n setRate(rate.toFormat(2));\n };\n const getTotalDai = async () => {\n const total = await maker.service('mcd:savings').getTotalDai();\n setTotalDai(total._amount.toFormat(2));\n };\n getDsr();\n getTotalDai();\n }, [maker]);\n\n const formOptions = {\n label: 'home page',\n fields: [\n {\n name: 'subtext',\n component: 'text',\n },\n ],\n };\n\n const [data, form] = useGithubJsonForm(file, formOptions);\n usePlugin(form);\n useGithubToolbarPlugins();\n // TODO pass resources in\n useCreateDocument([], 'dsr');\n\n return (\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n};\n\nexport const getStaticProps = async function ({ preview, previewData }) {\n //TODO fix path:\n const documentation = await getGuides(preview, previewData, 'content/resources');\n const dsrDocs = documentation.filter(\n (g) => g.data.frontmatter.parent === 'dsr' || g.data.frontmatter.tags.includes('dsr')\n );\n\n if (preview) {\n const file = (\n await getGithubPreviewProps({\n ...previewData,\n fileRelativePath: 'data/dsrPage.json',\n parse: parseJson,\n })\n ).props;\n\n return {\n props: {\n ...file,\n documentation: dsrDocs,\n },\n };\n }\n\n return {\n props: {\n sourceProvider: null,\n error: null,\n preview: false,\n file: {\n fileRelativePath: 'data/dsrPage.json',\n data: (await import('../data/dsrPage.json')).default,\n },\n documentation: dsrDocs,\n },\n };\n};\n\nexport default Dsr;\nexport const ContentTypes = {\n DOCUMENTATION: 'documentation',\n GUIDE: 'guides',\n};\n"},"directory_id":{"kind":"string","value":"2d37841b1cf7d51c2add9482b792adb55499b55d"},"languages":{"kind":"list like","value":["Markdown","JavaScript"],"string":"[\n \"Markdown\",\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":18,"string":"18"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"b-pmcg/developer-portal"},"revision_id":{"kind":"string","value":"b3db046880a9e1bb55cd469c51d245af1163d3b6"},"snapshot_id":{"kind":"string","value":"9c8eb93bfcaf3878b80ef6d8b0db632b75cc09d0"}}},{"rowIdx":9908,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"tonyfraggins/tony.github.io/README.md\n# tony.github.io\n"},"directory_id":{"kind":"string","value":"cd500bfe8723b2772b639a96ff6ee3c385065385"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"tonyfraggins/tony.github.io"},"revision_id":{"kind":"string","value":"3d098eec5e550fd496e5bcff6688c622947e62f8"},"snapshot_id":{"kind":"string","value":"ddb8bd539773133e013cc2d5c4a1ff499ab3149c"}}},{"rowIdx":9909,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# Mr.CAD---Programming"},"directory_id":{"kind":"string","value":"20e27e9843c4b74ad17d3410f1d6e6ce7ca5cc28"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Mr-CAD/Mr.CAD---Programming"},"revision_id":{"kind":"string","value":"af4f0bbcd26abe41c12116fd644f85308fe5b9eb"},"snapshot_id":{"kind":"string","value":"8a767b48c0318e2c4b597de91b844d28c3924d28"}}},{"rowIdx":9910,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"plaban1981/Matplotlib_and_Seaborn/README.md\n# Matplotlib_and_Seaborn\nSeaborn and matplotlib excercises\n"},"directory_id":{"kind":"string","value":"18d62ca5ccd81477f9f51def7f5c921059794a44"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"plaban1981/Matplotlib_and_Seaborn"},"revision_id":{"kind":"string","value":"029bdbc1b66071fe17570febfd533d1cfb6676ea"},"snapshot_id":{"kind":"string","value":"2955e98d8832cfb4c14325d4286cad266741878f"}}},{"rowIdx":9911,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"IParameter.h\"\r\n\r\n\r\n#define BB_OBJECT_COPY CKGUID(0x3f6b0ac7,0x47d20f78)\r\n#define BB_OBJECT_DELETE CKGUID(0x74120ded,0x76524673)\r\n\r\nenum BB_COPY_SETTINGS\r\n{\r\n\r\n\tbbS_Dynamic,\r\n\tbbS_Awak,\r\n\tbbs_Flags,\r\n\tbbs_NewBodyFlags,\r\n\r\n};\r\n\r\nCKBEHAVIORFCT BBCopy;\r\nint BB_CopyNew(const CKBehaviorContext& context)\r\n{\r\n\r\n\r\n\tCKBehavior\t*beh = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBCopy(context);\r\n\r\n\t// Copy Objects\r\n\tint count = beh->GetInputParameterCount();\r\n\r\n\t// Dynamic ?\r\n\tBOOL dynamic = TRUE;\r\n\tbeh->GetLocalParameterValue(0,&dynamic);\r\n\r\n\tint flags = 0;\r\n\tbeh->GetLocalParameterValue(bbs_Flags,&flags);\r\n\r\n\tint newBodyFlags = 0;\r\n\tbeh->GetLocalParameterValue(bbs_NewBodyFlags,&newBodyFlags);\r\n\r\n\tCKDependencies* dep = *(CKDependencies**)beh->GetInputParameterReadDataPtr(0);\r\n\t\r\n\t\r\n\tXArraySrcObjects;\r\n\t\r\n\tint i;\r\n\tfor(i=1;iGetInputParameterObject(i);\r\n\t\tif (!srcObject) continue;\r\n\r\n\t\t// we do not want to to duplicate level\r\n\t\tif (CKIsChildClassOf(srcObject,CKCID_LEVEL)) continue;\r\n\t\t\r\n\t\tif (CKIsChildClassOf(srcObject,CKCID_3DENTITY))\r\n\t\t{\r\n\t\t\t\r\n\r\n\t\t\tCK3dEntity *src=(CK3dEntity*)srcObject;\r\n\t\t\tCK3dEntity *dst=(CK3dEntity*)(beh->GetOutputParameterObject(i-1));\r\n\r\n\t\t\tpObjectDescr oDescr;\r\n\t\t\tIParameter::Instance()->copyTo(oDescr,src,flags);\r\n\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// IC Data, we just save it out\r\n\t\t\t//\r\n\t\t\tif ( flags & PB_CF_COPY_IC )\r\n\t\t\t{\r\n\t\t\t\tCKScene *scene = ctx()->GetCurrentScene();\r\n\t\t\t\tif(scene && src->IsInScene(scene)) \r\n\t\t\t\t{\r\n\t\t\t\t\tCKStateChunk *chunk = scene->GetObjectInitialValue(src);\r\n\t\t\t\t\tif(chunk) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tCKStateChunk *chunkClone=CreateCKStateChunk(CKCID_OBJECT);\r\n\t\t\t\t\t\tchunkClone->Clone(chunk);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// copy and restore IC of parent object\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\tif(chunkClone)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tscene->SetObjectInitialValue(dst,chunkClone);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tCKERROR error = 0;\r\n\t\t\t\t\t\tif ( flags & PB_CF_RESTORE_IC )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\terror = CKReadObjectState(dst,chunkClone);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\t// copy and restore IC for children :\r\n\t\t\t\t\t\t//\r\n\t\t\t\t\t\tint a = ((*dep->At(CKCID_3DENTITY)) & CK_DEPENDENCIES_COPY_3DENTITY_CHILDREN);\r\n\t\t\t\t\t\tint a1 = (( flags & PB_CF_OVRRIDE_BODY_FLAGS ) && (newBodyFlags & BF_Hierarchy));\r\n\t\t\t\t\t\tint a2 = ( oDescr.flags & BF_Hierarchy);\r\n\r\n\t\t\t\t\t\tif ( ((*dep->At(CKCID_3DENTITY)) & CK_DEPENDENCIES_COPY_3DENTITY_CHILDREN) && \r\n\t\t\t\t\t\t\t( (( flags & PB_CF_OVRRIDE_BODY_FLAGS ) && (newBodyFlags & BF_Hierarchy)) ||\r\n\t\t\t\t\t\t\t( oDescr.flags & BF_Hierarchy) )\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tCK3dEntity* subEntity = NULL;\r\n\t\t\t\t\t\t\tSrcObjects.Clear();\r\n\r\n\t\t\t\t\t\t\twhile (subEntity= dst->HierarchyParser(subEntity) )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tSrcObjects.PushBack(subEntity);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tint dCount = dst->GetChildrenCount();\r\n\t\t\t\t\t\t\tint dCount2 = SrcObjects.Size();\r\n\r\n\t\t\t\t\t\t\tfor(i = 0;iGetObjectInitialValue(orginalObject);\r\n\t\t\t\t\t\t\t\t\tif (chunkSub)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tCKStateChunk *chunkCloneSub=CreateCKStateChunk(CKCID_OBJECT);\r\n\t\t\t\t\t\t\t\t\t\tchunkCloneSub->Clone(chunkSub);\r\n\t\t\t\t\t\t\t\t\t\tscene->SetObjectInitialValue(subEntity,chunkCloneSub);\r\n\t\t\t\t\t\t\t\t\t\tif ( flags & PB_CF_RESTORE_IC )\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tCKReadObjectState(subEntity,chunkCloneSub);\r\n\t\t\t\t\t\t\t\t\t\t\tsubEntity->SetParent(dst);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tpRigidBody *srcBody = GetPMan()->getBody((CK3dEntity*)src);\r\n\t\t\tNxShape *shape = NULL;\r\n\t\t\tif (srcBody)\r\n\t\t\t{\r\n\t\t\t\tshape = srcBody->getSubShape((CK3dEntity*)src);\r\n\t\t\t}\r\n //----------------------------------------------------------------\r\n //\r\n // copy sub shape ? \r\n //\r\n\t\t\tif (shape && shape!=srcBody->getMainShape())\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->cloneShape((CK3dEntity*)src,(CK3dEntity*)(beh->GetOutputParameterObject(i-1)),srcBody->GetVT3DObject(),flags,newBodyFlags);\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// copy body ?\r\n\t\t\t//\r\n\t\t\tif (srcBody)\r\n\t\t\t\tpFactory::Instance()->cloneRigidBody(src,dst,dep,flags,newBodyFlags);\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nCKERROR\r\nPhysicManager::_HookGenericBBs()\r\n{\r\n\tCKBehaviorManager *bm = m_Context->GetBehaviorManager();\r\n\t\r\n\tCKBehaviorPrototype *bproto = CKGetPrototypeFromGuid(BB_OBJECT_COPY);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Copy Flags\",VTF_PHYSIC_ACTOR_COPY_FLAGS,\"\");\r\n\t\tbproto->DeclareSetting(\"New Body Flags\",VTF_BODY_FLAGS,\"\");\r\n\r\n\t\tBBCopy = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_CopyNew);\r\n\t}\r\n\r\n\treturn CK_OK;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJIsBrokenDecl();\r\nCKERROR CreatePJIsBrokenProto(CKBehaviorPrototype **pproto);\r\nint PJIsBroken(const CKBehaviorContext& behcontext);\r\nCKERROR PJIsBrokenCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyB,\r\n\tbbI_Type,\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJIsBrokenDecl\r\n// FullName: FillBehaviorPJIsBrokenDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJIsBrokenDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJIsBroken\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Triggers when joint has been broken.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x17082b70,0x6eae5b38));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJIsBrokenProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJIsBrokenProto\r\n// FullName: CreatePJIsBrokenProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJIsBrokenProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJIsBroken\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJIsBroken \r\n\r\n\t
\r\n\tPJIsBroken is categorized in \\ref Joints\r\n\t
\r\n\t\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tActivates output trigger when a joint has been broken.\r\n\r\n\t
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJIsBroken.png\r\n\r\n\r\n\tIn: triggers the process.\r\n\t
\r\n\t
\r\n\t\r\n\tExit On: is activated when the building block has been started.\r\n\t
\r\n\r\n\tExit Off: is activated when the process is completed.\r\n\t
\r\n\r\n\tBroken: is activated when the joint has been broken.\r\n\t
\r\n\t
\r\n\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\r\n\tJoint Type: The joint type. This helps the building block to identify a joint constraint. As usual there can be only one joint of the type x between two bodies.\r\n\t
\r\n\t
\r\n\r\n\tBreaking Impulse: The impulse which broke the joint. This is clamped to the values of maxForce (or maxTorque, depending on what made the joint break) that was specified for the joint.\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\t*/\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"Broken\");\r\n\tproto->DeclareOutParameter(\"Break Impulse\",CKPGUID_FLOAT);\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PJIsBrokenCB );\r\n\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Joint Type\",VTE_JOINT_TYPE,\"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PJIsBroken);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJIsBroken\r\n// FullName: PJIsBroken\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJIsBroken(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\treturn CK_OK;\r\n\t}\r\n\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object A: \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bbI_BodyB);\r\n\t\r\n\tint jointType = GetInputParameterValue(beh,bbI_Type); \r\n\r\n\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,jointType))\r\n\t{\r\n\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\t// the world : \r\n\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\tif (!worldA)\r\n\t{\r\n\t\tworldA = worldB;\r\n\t}\r\n\tif (!worldA)\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\t\r\n\t// the physic object A : \r\n\tpRigidBody*bodyA= worldA->getBody(target);\r\n\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\tint size = GetPMan()->getJointFeedbackList().Size();\r\n\r\n\tif(bodyA || bodyB)\r\n\t{\r\n\t\tfor (int i = 0 ; i < GetPMan()->getJointFeedbackList().Size(); i++ )\r\n\t\t{\r\n\t\t\tpBrokenJointEntry *entry = *GetPMan()->getJointFeedbackList().At(i);\r\n\t\t\tif (entry)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tif ( entry->jType ==jointType )\r\n\t\t\t\t{\r\n\t\t\t\t\tCK3dEntity *bodyAEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mAEnt));\r\n\t\t\t\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mBEnt));\r\n\r\n\t\t\t\t\tif ( bodyAEnt == target && bodyBEnt ==targetB)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(2);\r\n\t\t\t\t\t\tSetOutputParameterValue(beh,0,entry->impulse);\r\n\t\t\t\t\t\tGetPMan()->getJointFeedbackList().EraseAt(i);\r\n\t\t\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (bodyBEnt == targetB && bodyAEnt==target)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(2);\r\n\t\t\t\t\t\tSetOutputParameterValue(beh,0,entry->impulse);\r\n\t\t\t\t\t\tGetPMan()->getJointFeedbackList().EraseAt(i);\r\n\t\t\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n//************************************\r\n// Method: PJIsBrokenCB\r\n// FullName: PJIsBrokenCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJIsBrokenCB(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#ifndef __VTCONNECTION_H_\r\n#define __VTCONNECTION_H_\r\n#include \"xNetTypes.h\"\r\n#include \"tnl.h\"\n#include \"tnlGhostConnection.h\"\r\n\r\nclass xNetInterface;\r\nclass xDistributedObject;\r\nclass xDistributedClient;\r\n\r\n\r\n\r\n\r\n\r\nclass vtConnection : public TNL::GhostConnection\n{\n\ttypedef TNL::GhostConnection Parent;\npublic:\n\n\tvtConnection();\n\tTNL_DECLARE_RPC(c2sDOCreate, (TNL::Int<16>userSrcID,TNL::StringPtr objectName,TNL::StringPtr className,TNL::Int<16>classType));\n\tTNL_DECLARE_RPC(c2sDODestroy, (TNL::Int<16>userSrcID,TNL::Int<16>serverID,TNL::StringPtr className,TNL::Int<16>classType));\n\tTNL_DECLARE_RPC(c2sDORequestOwnerShip, (TNL::S32 userSrcID,TNL::Int<16>serverID));\n\tTNL_DECLARE_RPC(s2cDOChangeOwnershipState, (TNL::Int<16>serverID,TNL::S32 newOwnerID,TNL::S32 state));\n\n\n\tTNL_DECLARE_RPC(s2cSetUserDetails, (TNL::Int<16>userID));\n\tTNL_DECLARE_RPC(c2sDeployDistributedClass,(\n\t\tTNL::StringPtr className,\n\t\tTNL::Int<16>entityType,\n\t\tTNL::VectorpropertyNames,\n\t\tTNL::Vector >propertyNativeTypes,\n\t\tTNL::Vector >propertyValueTypes,\n\t\tTNL::Vector >predictionTypes));\n\n\tTNL_DECLARE_RPC(s2cDeployDistributedClass,(\n\t\tTNL::StringPtr className,\n\t\tTNL::Int<16>entityType,\n\t\tTNL::VectorpropertyNames,\n\t\tTNL::Vector >propertyNativeTypes,\n\t\tTNL::Vector >propertyValueTypes,\n\t\tTNL::Vector >predictionTypes));\n \n\tvoid connect(TNL::NetInterface *theInterface, const TNL::Address &address, bool requestKeyExchange, bool requestCertificate);\n\tvoid onConnectTerminated(TNL::NetConnection::TerminationReason reason, const char *rejectionString);\n\tvoid onConnectionTerminated(TNL::NetConnection::TerminationReason reason, const char *string);\n\tvoid onConnectionEstablished(); \n\tbool isDataToTransmit();\n\tint getUserID() const { return m_UserID; }\r\n\tvoid setUserID(int val) { m_UserID = val; }\n\tconst char* GetUserName() const { return m_UserName.getString(); }\r\n\tvoid SetUserName(const char*val);\n\tvoid setClientName(const char *string) { mClientName = string; }\n\tint GetConnectionID() const { return m_ConnectionID; }\r\n\tvoid SetConnectionID(int val) { m_ConnectionID = val; }\n\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//overwrites : \n\tvoid writePacket(TNL::BitStream *bstream,TNL::NetConnection::PacketNotify *notify);\n\tvoid readPacket(TNL::BitStream *bstream);\n\t\n\tvoid packetReceived(TNL::GhostConnection::PacketNotify *notify);\n\tstruct GamePacketNotify : public TNL::GhostConnection::GhostPacketNotify\n\t{\n\t\tTNL::U32 firstUnsentMoveIndex;\n\t\tTNL::U32 updateType;\n\t\tGamePacketNotify() { firstUnsentMoveIndex = 0;updateType=0; }\n\t};\n\t PacketNotify *allocNotify() { return new GamePacketNotify; }\n\n\tTNL::U32 getControlCRC();\n\n\tint m_UserID;\n\txNString m_UserName;\r\n\tint m_ConnectionID;\r\n\tTNL::RefPtr m_NetInterface;\r\n\tTNL::Address localAddress;\n\tTNL::StringTableEntry mClientName;\n\tTNL_DECLARE_NETCONNECTION(vtConnection);\n\tTNL::SafePtrscopeObject;\n\n\tenum {\n\t\tGHOST_UPDATE = 61,\n\t\tNO_UPDATE = 58,\n\t};\n\tenum {\r\n\t\t\tMaxPendingMoves = 63,\r\n\t\t\tMaxMoveTimeCredit = 512,\r\n\t};\r\n\n\t\n\tint mWriteTypeTracker;\n\tint mReadType;\n\n\tint getWriteTypeTracker() const { return mWriteTypeTracker; }\r\n\tvoid setWriteTypeTracker(int val) { mWriteTypeTracker = val; }\r\n\n\tTNL::VectorpendingObjects;\n\tvoid addUpdateObject(xDistributedObject*object);\n\tTNL::SafePtr controlObject;\n\n\tTNL::U32 mLastClientControlCRC;\n\tbool mCompressPointsRelative;\n\n\tTNL::U32 firstMoveIndex;\n\tTNL::U32 highSendIndex[3];\n\tTNL::U32 mMoveTimeCredit;\n\n\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\n\n\t\n\n\tTNL_DECLARE_RPC(c2sCreateSession_RPC,(TNL::StringPtr name,TNL::Int<16>type,TNL::Int<16>maxUsers,TNL::StringPtr password));\n\tTNL_DECLARE_RPC(c2sDeleteSession_RPC,(TNL::Int<16>sessionID));\n\tTNL_DECLARE_RPC(c2sJoinSession_RPC,(TNL::Int<16>userID,TNL::Int<16>sessionID,TNL::StringPtr password));\n\tTNL_DECLARE_RPC(s2cUserJoinedSession_RPC,(TNL::Int<16>userID,TNL::Int<16>sessionID));\n\t\n\tTNL_DECLARE_RPC(c2sLeaveSession_RPC,(TNL::Int<16>userID,TNL::Int<16>sessionID,TNL::Int<16>destroy));\n\tTNL_DECLARE_RPC(s2cUserLeftSession_RPC,(TNL::Int<16>userID,TNL::Int<16>sessionID));\n\tTNL_DECLARE_RPC(c2sLockSession_RPC,(TNL::Int<16>sessionID));\n\n\tTNL_DECLARE_RPC(s2cAddServerLogEntry,(TNL::StringPtr entry));\n\n\n\n\tvirtual void disconnectFromServer();\n\n\t//////////////////////////////////////////////////////////////////////////\r\n\tint mSessionID;\n\tint getSessionID() const { return mSessionID; }\r\n\tvoid setSessionID(int val) { mSessionID = val; }\r\n\n\n\t\n};\r\n#endif\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"IParameter.h\"\r\n\r\n\r\nXString PhysicManager::_getConfigPath()\r\n{\r\n\r\n\tXString result;\r\n\r\n\r\n\tCKPathManager *pm = (CKPathManager*)this->m_Context->GetPathManager();\r\n\t\r\n\t//pm->OpenSubFile()\r\n\r\n\tXString configFile(\"DonglePaths.ini\");\r\n\tXString section(\"Paths\");\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *tsection = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open DonglePath.Ini in Virtools directory\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn XString(\"none\");\r\n\t}\r\n\r\n\tif ((tsection = config.GetSubSection((char*)section.Str(), FALSE)) != NULL)\r\n\t{\r\n\r\n\t\tConstEntryIt it = tsection->BeginChildEntry();\r\n\t\tVxConfigurationEntry *sEntry = NULL;\r\n\r\n\r\n\t\tchar newPath[MAX_PATH];\r\n\t\twhile (sEntry=tsection->GetNextChildEntry(it))\r\n\t\t{\r\n\t\t\tif (sEntry!=NULL)\r\n\t\t\t{\r\n\t\t\t\tconst char * value = sEntry->GetValue();\r\n\t\t\t\tXString path(value);\r\n\r\n\t\t\t\tFILE *file = fopen(path.CStr(),\"r\");\r\n\t\t\t\tif (file)\r\n\t\t\t\t{\r\n\t\t\t\t\tfclose(file);\r\n\t\t\t\t\treturn path;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tMessageBox(NULL,\"Couldnt find any valid license file in the DonglePaths.Ini\",0,MB_OK|MB_ICONERROR);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n\r\nvoid PhysicManager::bindVariables()\r\n{\r\n\r\n\tCKVariableManager* vm = m_Context->GetVariableManager();\r\n\tif( !vm )\r\n\t\treturn;\r\n\r\n\tpSDKParameters& p = getSDKParameters(); \r\n\t\t\r\n\tvm->Bind( \r\n\t\t\"Physic/Skin Width\", &p.SkinWidth, 0.025f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Default value for pShape::skinWidth.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Default Sleep Linear Velocity Squared\", &p.DefaultSleepLinVelSquared, 0.15f*0.15f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"The default linear velocity, squared, below which objects start going to sleep. Note: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Default Sleep Angular Velocity Squared\", &p.DefaultSleepAngVel_squared, 0.14f * 0.14f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"The default angular velocity, squared, below which objects start going to sleep. Note: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Bounce Threshold\", &p.BounceThreshold , -2.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"A contact with a relative velocity below this will not bounce.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Dynamic Friction Scaling\", &p.DynFrictScaling,1.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"This lets the user scale the magnitude of the dynamic friction applied to all objects. \");\r\n\r\n\t\r\n\tvm->Bind( \r\n\t\t\"Physic/Static Friction Scaling\", &p.StaFrictionScaling,1.0f,VxVar::COMPOSITIONBOUND,\r\n\t\t\"This lets the user scale the magnitude of the static friction applied to all objects.\");\r\n\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Maximum Angular Velocity\", &p.MaxAngularVelocity , 7.0f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"See the comment for pRigidBody::setMaxAngularVelocity() for details.\");\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Continuous Collision Detection\", &p.ContinuousCD ,0.0f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Enable/disable continuous collision detection (0.0f to disable).\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Adaptive Force\", &p.AdaptiveForce ,1.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Used to enable adaptive forces to accelerate convergence of the solver. \");\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Collision Veto Jointed\", &p.CollVetoJointed , 1.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Controls default filtering for jointed bodies. True means collision is disabled.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Trigger Trigger Callback\", &p.TriggerTriggerCallback, 1.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Controls whether two touching triggers generate a callback or not.\");\r\n\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/CCD Epsilon\", &p.CCDEpsilon,0.01f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Distance epsilon for the CCD algorithm.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Solver Convergence Threshold\", &p.SolverConvergenceThreshold, 0.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Used to accelerate solver.\");\r\n\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/BBox Noise Level\", &p.BBoxNoiseLevel, 0.001f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Used to accelerate HW Broad Phase. \");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Implicit Sweep Cache Size\", &p.ImplicitSweepCacheSize, 5.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Used to set the sweep cache size. \");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Default Sleep Energy\", &p.DefaultSleepEnergy, 0.005f, VxVar::COMPOSITIONBOUND,\r\n\t\t\"The default sleep energy threshold. Objects with an energy below this threshold are allowed to go to sleep. Note: Only used when the pSDKP_BF_ENERGY_SLEEP_TEST flag is set.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Constant Fluid Max Packets\", &p.ConstantFluidMaxPackets, 925, VxVar::COMPOSITIONBOUND,\r\n\t\t\" Constant for the maximum number of packets per fluid. Used to compute the fluid packet buffer size in NxFluidPacketData.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Constant Fluid Maximum Particles Per Step\", &p.ConstantFluidMaxParticlesPerStep, 4096, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Constant for the maximum number of new fluid particles per frame.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Improved Spring Solver\", &p.ImprovedSpringSolver,1.0f , VxVar::COMPOSITIONBOUND,\r\n\t\t\"Enable/disable improved spring solver for joints and wheel shapes.\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic/Disable Physics\", &p.disablePhysics,false, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Enable/disable physic calculation\");\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpRemoteDebuggerSettings &dbgSetup = getRemoteDebuggerSettings();\r\n\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Debugger/Host\", &dbgSetup.mHost,XString(\"localhost\"), VxVar::COMPOSITIONBOUND,\r\n\t\t\"Specifies the host running a debugger\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Debugger/Port\", &dbgSetup.port,5425, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Specifies the port of the remote debugger\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Debugger/Enabled\", &dbgSetup.enabled,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Enables/Disables the remote debugger\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Console Logger/Errors\", &_LogErrors,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Log Errors\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Console Logger/Infos\", &_LogInfo,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Log Infos\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Console Logger/Trace\", &_LogTrace,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Log Trace\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Console Logger/Warnings\", &_LogWarnings,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Log Warnings\");\r\n\r\n\tvm->Bind( \r\n\t\t\"Physic Console Logger/Console\", &_LogWarnings,0, VxVar::COMPOSITIONBOUND,\r\n\t\t\"Console\");\r\n\t\t\r\n\r\n}\r\n\r\nvoid PhysicManager::unBindVariables()\r\n{\r\n\r\n\r\n\tCKVariableManager* vm = m_Context->GetVariableManager();\r\n\tif( !vm )\r\n\t\treturn;\r\n\r\n\tpSDKParameters& p = getSDKParameters(); \r\n\r\n\r\n\tvm->UnBind( \"Physic Console Logger/Errors\" );\r\n\tvm->UnBind( \"Physic Console Logger/Infos\" );\r\n\tvm->UnBind( \"Physic Console Logger/Trace\" );\r\n\tvm->UnBind( \"Physic Console Logger/Warnings\" );\r\n\tvm->UnBind( \"Physic Console Logger/Console\" );\r\n\r\n\r\n\r\n\tvm->UnBind(\"Physic/Skin Width\");\r\n\tvm->UnBind(\"Physic/Default Sleep Linear Velocity Squared\");\r\n\tvm->UnBind( \"Physic/Default Sleep Angular Velocity Squared \");\r\n\tvm->UnBind( \"Physic/Bounce Threshold\");\r\n\tvm->UnBind( \"Physic/Dynamic Friction Scaling\");\r\n\tvm->UnBind( \"Physic/Static Friction Scaling\");\r\n\tvm->UnBind( \"Physic/Maximum Angular Velocity\");\r\n\tvm->UnBind( \"Physic/Continuous Collision Detection\");\r\n\tvm->UnBind( \"Physic/Adaptive Force \");\r\n\tvm->UnBind( \"Physic/Collision Veto Jointed \");\r\n\tvm->UnBind( \"Physic/Trigger Trigger Callback\");\r\n\tvm->UnBind( \"Physic/CCD Epsilon\");\r\n\tvm->UnBind( \"Physic/Solver Convergence Threshold\");\r\n\tvm->UnBind( \"Physic/BBox Noise Level\");\r\n\tvm->UnBind( \"Physic/Implicit Sweep Cache Size\");\r\n\tvm->UnBind( \"Physic/Default Sleep Energy\");\r\n\tvm->UnBind( \"Physic/Constant Fluid Max Packets\");\r\n\tvm->UnBind( \"Physic/Constant Fluid Maximum Particles Per Step\");\r\n\tvm->UnBind( \"Physic/Improved Spring Solver\" );\r\n\tvm->UnBind( \"Physic/Disable Physics\");\r\n\r\n\r\n\t\t\r\n\tvm->UnBind( \"Physic Debugger/Host\" );\r\n\tvm->UnBind( \"Physic Debugger/Port\" );\r\n\tvm->UnBind( \"Physic Debugger/Enabled\" );\r\n\r\n}\r\n\r\n\r\n\r\n#define\tPMANAGER_CHUNKID\t\t1005\r\n#define\tPMANAGER_SAVE_VERSION\t\t3\r\n#define\tPMANAGER_FLAGS\t\t0\r\n#define\tPMANAGER_USER_ENUM_IDENTIFIER\t\t11005\r\n\r\nint PhysicManager::_migrateOldCustomStructures(CKScene *scnene)\r\n{\r\n\r\n\tbool bIsLoading = ctx()->IsInLoad();\r\n\t//CKObject* o = ctx->GetObject(ol[CKCID_MESH]);\r\n\tint count = ctx()->GetObjectsCountByClassID(CKCID_3DOBJECT);\r\n\tif (!count)\r\n\t\treturn 0;\r\n\r\n\t\t\r\n//\tCK_ID* ol = ctx->GetObjectsListByClassID(i);\r\n\t\t\r\n\tXString errMessage;\r\n\tint nbOfObjects = 0 ;\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(GetPAttribute());\r\n\tnbOfObjects = Array.Size();\r\n\t\r\n\tif (nbOfObjects==0)\r\n\t\treturn 0;\r\n\r\n\t\r\n\r\n\tif (!scnene)\r\n\t\treturn 0;\r\n\r\n\tint attOld = GetPAttribute();\r\n\tint attNew = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\t\r\n\tint nbRecovered=0;\r\n\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\t\tint cCount = attman->GetAttributeListPtr(GetPAttribute()).Size();\r\n\t\tif (!cCount)\r\n\t\t\tbreak;\r\n\t\t\r\n\t\tCK3dEntity*target = static_cast(*it);\r\n\t\tif (!target)//shit happens\r\n\t\t\tbreak;\r\n\r\n\t\tCKParameterOut * pOld =target->GetAttributeParameter(attOld);\r\n\t\tif (!pOld)//shit happens\r\n\t\t\tbreak;\r\n\r\n\t\tpObjectDescr * oDescr = pFactory::Instance()->createPObjectDescrFromParameter(pOld);\r\n\t\tif (!oDescr)//shit happens\r\n\t\t\tcontinue;\r\n\t\t\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// fix up : \r\n\t\t//\r\n\r\n\t\t//hierarchy \r\n\t\tbool hierarchy =false;\r\n\t\tif( (oDescr->flags & BF_Hierarchy) || oDescr->hirarchy )\r\n\t\t\thierarchy = true;\r\n\r\n\t\tif (hierarchy)\r\n\t\t\toDescr->flags << BF_Hierarchy;\r\n\r\n\r\n\t\toDescr->massOffsetLinear = oDescr->massOffset;\r\n\t\toDescr->pivotOffsetLinear = oDescr->shapeOffset;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// attach new attribute parameter\r\n\t\t//\r\n\t\ttarget->SetAttribute(attNew);\r\n\t\tCKParameterOut *newPar = target->GetAttributeParameter(attNew);\r\n\t\tif (newPar)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(newPar,oDescr);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// clean old attribute\r\n\t\t//\r\n\t\ttarget->RemoveAttribute(attOld);\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// set IC\r\n\t\t//\r\n\t\t\r\n\t\t\r\n\t\t//----- Restore the IC\r\n\t\tif(target->IsInScene(scnene)) \r\n\t\t{\r\n\t\t\tCKStateChunk *chunk = scnene->GetObjectInitialValue(target);\t\t\t\t\r\n\t\t\tif(chunk) \r\n\t\t\t{\r\n\t\t\t\tCKStateChunk *chunk = CKSaveObjectState(target);\r\n\t\t\t\tscnene->SetObjectInitialValue(target,chunk);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tit = Array.Begin();\r\n\r\n\t\tSAFE_DELETE(oDescr);\r\n\r\n\t\tnbRecovered++;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// cleanup\r\n\t\t//\r\n\r\n\t}\r\n\tif (attman->GetAttributeListPtr(GetPAttribute()).Size() >0)\r\n\t{\r\n\t\t_migrateOldCustomStructures(GetContext()->GetCurrentScene());\r\n\t}\r\n\t\r\n\t/*\r\n\terrMessage.Format(\"nub of old objects recovered: %d\",nbRecovered);\r\n\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errMessage.Str());\r\n\r\n\t*/\r\n\treturn nbOfObjects;\r\n\r\n\r\n}\r\n\r\nCKERROR PhysicManager::PostLoad()\r\n{\r\n\tCKScene *scene = GetContext()->GetCurrentScene();\r\n\t_migrateOldCustomStructures(scene);\r\n\r\n\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Post Load\");\r\n\treturn true;\r\n}\r\n\r\n\r\nvoid PhysicManager::setPSDKParameters(pSDKParameters&param)\r\n{\r\n\r\n\tif (!getPhysicsSDK())\r\n\t\treturn ;\r\n\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_SkinWidth,param.SkinWidth);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_DefaultSleepLinVelSquared,param.DefaultSleepLinVelSquared);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_DefaultSleepAngVelSquared,param.DefaultSleepAngVel_squared);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_BounceThreshold,param.BounceThreshold);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_DynFrictScaling,param.DynFrictScaling);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_StaFrictionScaling,param.StaFrictionScaling);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_MaxAngularVelocity,param.MaxAngularVelocity);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_ContinuousCD,param.ContinuousCD);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_AdaptiveForce,param.AdaptiveForce);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_CollVetoJointed,param.CollVetoJointed);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_TriggerTriggerCallback,param.TriggerTriggerCallback);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_CCDEpsilon,param.CCDEpsilon);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_SolverConvergenceThreshold,param.SolverConvergenceThreshold);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_BBoxNoiseLevel,param.BBoxNoiseLevel);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_ImplicitSweepCacheSize,param.ImplicitSweepCacheSize);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_DefaultSleepEnergy,param.DefaultSleepEnergy);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_ConstantFluidMaxPackets,param.ConstantFluidMaxPackets);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_ConstantFluidMaxParticlesPerStep,param.ConstantFluidMaxParticlesPerStep);\r\n\tgetPhysicsSDK()->setParameter((NxParameter)pSDKP_ImprovedSpringSolver,param.ImprovedSpringSolver);\r\n\t\r\n\r\n\r\n\r\n\r\n}\r\n\r\nCKStateChunk* PhysicManager::SaveData(CKFile* SavedFile)\r\n{\r\n\r\n\tif (!getNbObjects())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tCKStateChunk *chunk = CreateCKStateChunk(PMANAGER_CHUNKID, SavedFile);\r\n\tif (!chunk)\r\n\t\treturn NULL;\r\n\tchunk->StartWrite();\r\n\tchunk->WriteIdentifier(PMANAGER_CHUNKID);\r\n\tchunk->WriteInt(PMANAGER_SAVE_VERSION);\r\n\tchunk->WriteInt(PMANAGER_FLAGS);\r\n\r\n\r\n\tCKVariableManager* vm = m_Context->GetVariableManager();\r\n\tif( !vm )\r\n\t\treturn NULL;\r\n\r\n\r\n\tpSDKParameters& p = getSDKParameters(); \r\n\r\n\r\n\tCKVariableManager::Variable *var = vm->GetVariable(\"Physic/Skin Width\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.SkinWidth);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Default Sleep Linear Velocity Squared\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.DefaultSleepLinVelSquared);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Default Sleep Angular Velocity Squared\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.DefaultSleepAngVel_squared);\r\n\t}\r\n\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Bounce Threshold\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.BounceThreshold);\r\n\t}\r\n\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Dynamic Friction Scaling\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.DynFrictScaling);\r\n\t}\r\n\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Static Friction Scaling\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.StaFrictionScaling);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Maximum Angular Velocity\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.MaxAngularVelocity);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Continuous Collision Detection\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.ContinuousCD);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Adaptive Force\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.AdaptiveForce);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Collision Veto Jointed\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.CollVetoJointed);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Trigger Trigger Callback\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.TriggerTriggerCallback);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/CCD Epsilon\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.CCDEpsilon);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Solver Convergence Threshold\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.SolverConvergenceThreshold);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/BBox Noise Level\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.BBoxNoiseLevel);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic/Implicit Sweep Cache Size\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.ImplicitSweepCacheSize);\r\n\t}\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Default Sleep Energy\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.DefaultSleepEnergy);\r\n\t}\r\n\r\n\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Constant Fluid Max Packets\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.ConstantFluidMaxPackets);\r\n\t}\r\n\r\n\r\n\r\n\tvar = vm->GetVariable(\"Physic/Constant Fluid Maximum Particles Per Step\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.ConstantFluidMaxParticlesPerStep);\r\n\t}\r\n\r\n\r\n\t\r\n\r\n\tvar = vm->GetVariable(\"Physic/Improved Spring Solver\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteFloat(p.ImprovedSpringSolver);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tpRemoteDebuggerSettings &dbgSetup = getRemoteDebuggerSettings();\r\n\r\n\tvar = vm->GetVariable(\"Physic Debugger/Host\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteString(dbgSetup.mHost.CStr());\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic Debugger/Port\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(dbgSetup.port);\r\n\t}\r\n\t\r\n\tvar = vm->GetVariable(\"Physic Debugger/Enabled\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(dbgSetup.enabled);\r\n\t}\r\n\r\n\r\n\t\r\n\tvar = vm->GetVariable(\"Physic Console Logger/Errors\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(_LogErrors);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic Console Logger/Infos\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(_LogInfo);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic Console Logger/Trace\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(_LogTrace);\r\n\t}\r\n\r\n\tvar = vm->GetVariable(\"Physic Console Logger/Warnings\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(_LogWarnings);\r\n\t}\r\n\r\n\t\r\n\t_saveUserEnumeration(chunk,SavedFile);\r\n\r\n\tvar = vm->GetVariable(\"Physic Console Logger/Console\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(_LogToConsole);\r\n\t}\r\n\r\n\r\n\t//**new\r\n\r\n\tvar = vm->GetVariable(\"Physic/Disable Physics\");\r\n\tif (var)\r\n\t{\r\n\t\tchunk->WriteInt(var->IsCompositionDepending());\r\n\t\tchunk->WriteInt(p.disablePhysics);\r\n\t}\r\n \r\n\tchunk->CloseChunk();\r\n\treturn chunk;\r\n}\r\n\r\nCKERROR PhysicManager::LoadData(CKStateChunk *chunk,CKFile* LoadedFile)\r\n{\r\n\r\n\r\n\tassert(LoadedFile != 0);\r\n\tif (!chunk)\r\n\t\treturn CKERR_INVALIDPARAMETER;\r\n\t\r\n\r\n\tchunk->StartRead();\r\n\r\n\tif (chunk->SeekIdentifier(PMANAGER_CHUNKID))\r\n\t{\r\n\r\n\t\t// Check the version\r\n\t\tint\tversion = chunk->ReadInt();\r\n\r\n\t\t// Check the flags\r\n\t\tint flags = chunk->ReadInt();\r\n\r\n\t\tCKVariableManager* vm = m_Context->GetVariableManager();\r\n\t\tif( !vm )\r\n\t\t\treturn NULL;\r\n\r\n\t\t\r\n\t\tpSDKParameters& p = getSDKParameters(); \r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint isInCMO = chunk->ReadInt();\r\n\t\tfloat v = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.SkinWidth = v;\r\n\t\t}\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.DefaultSleepLinVelSquared = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.DefaultSleepAngVel_squared = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.BounceThreshold = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.DynFrictScaling = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.StaFrictionScaling = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.MaxAngularVelocity = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.ContinuousCD = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.AdaptiveForce = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.CollVetoJointed = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.TriggerTriggerCallback = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.CCDEpsilon = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.SolverConvergenceThreshold = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.BBoxNoiseLevel = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.ImplicitSweepCacheSize = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.DefaultSleepEnergy = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.ConstantFluidMaxPackets = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.ConstantFluidMaxParticlesPerStep = v;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.ImprovedSpringSolver = v;\r\n\t\t}\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tpRemoteDebuggerSettings &dbgSetup = getRemoteDebuggerSettings();\r\n\t\t\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tXString host = chunk->ReadString();\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tdbgSetup.mHost = host;\r\n\t\t}\r\n\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tint port = chunk->ReadInt();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tdbgSetup.port= port;\r\n\t\t}\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tint enabled = chunk->ReadInt();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tdbgSetup.enabled= enabled;\r\n\t\t}\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tint val = chunk->ReadInt();\r\n\t\tif (isInCMO==1 && val >=-1000 )\r\n\t\t{\r\n\t\t\t_LogErrors=val;\r\n\t\t}\r\n\t\tif (isInCMO==0)\r\n\t\t{\r\n\t\t\t_LogErrors=1;\r\n\t\t}\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tval = chunk->ReadInt();\r\n\t\tif (isInCMO==1 && val >=-1000 )\r\n\t\t{\r\n\t\t\t_LogInfo=val;\r\n\t\t}\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tval = chunk->ReadInt();\r\n\t\tif (isInCMO==1&& val >=-1000)\r\n\t\t{ \r\n\t\t\t_LogTrace=val;\r\n\t\t}\r\n\t\t\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tval = chunk->ReadInt();\r\n\t\tif (isInCMO==1&& val >=-1000 )\r\n\t\t{\r\n\t\t\t_LogWarnings=val;\r\n\t\t}\r\n\r\n\t\t_loadUserEnumeration(chunk,LoadedFile);\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tval = chunk->ReadInt();\r\n\t\tif (isInCMO==1&& val >=-1000 )\r\n\t\t{\r\n\t\t\t_LogToConsole=val;\r\n\t\t}\r\n\r\n\t\tisInCMO = chunk->ReadInt();\r\n\t\tv = chunk->ReadFloat();\r\n\r\n\t\tif (isInCMO)\r\n\t\t{\r\n\t\t\tp.disablePhysics = v;\r\n\t\t}\r\n\r\n\t\tchunk->CloseChunk();\r\n\r\n\t\t//disable physics\r\n\t\t\r\n\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\nvoid PhysicManager::_saveUserEnumeration(CKStateChunk *chunk,CKFile* SavedFile)\r\n{\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//write a identifier, just to ensure due the load we are at right seek point !\r\n\t\r\n\tchunk->WriteInt(PMANAGER_USER_ENUM_IDENTIFIER);\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//write out the the user enumeration for pWDominanceGroups\r\n\tXString enumDescription = getEnumDescription(m_Context->GetParameterManager(),VTE_PHYSIC_DOMINANCE_GROUP);\r\n\tXString enumDescriptionCollGroup = getEnumDescription(m_Context->GetParameterManager(),VTE_PHYSIC_BODY_COLL_GROUP);\r\n\r\n\tXString errString;\r\n\terrString.Format(\"Writing dominance enum :%s\",enumDescription.Str());\r\n\r\n\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errString.CStr());\r\n\t\r\n\tchunk->WriteString(enumDescription.CStr());\r\n\tchunk->WriteString(enumDescriptionCollGroup.CStr());\r\n\r\n}\r\n\r\nvoid PhysicManager::_loadUserEnumeration(CKStateChunk *chunk,CKFile* LoadedFile)\r\n{\r\n\r\n\tint enumIdentfier = chunk->ReadInt();\r\n\t\r\n\tif (enumIdentfier!=PMANAGER_USER_ENUM_IDENTIFIER) return;\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we read our dominance group enumeration back :\r\n\t\r\n\tXString dominanceGroupEnumerationString;\r\n\tint strEnumDescSizeDG = chunk->ReadString(dominanceGroupEnumerationString);\r\n\r\n\tXString collisionGroupEnumerationString;\r\n\tint strEnumDescSizeCG = chunk->ReadString(collisionGroupEnumerationString);\r\n\r\n\tXString errString;\r\n\terrString.Format(\"Loading dominance enum :%s\",dominanceGroupEnumerationString.Str());\r\n\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,dominanceGroupEnumerationString.CStr());\r\n\r\n\tCKParameterType pType = pm->ParameterGuidToType(VTE_PHYSIC_DOMINANCE_GROUP);\r\n\tif (pType!=-1 && dominanceGroupEnumerationString.Length())\r\n\t{\r\n\t\tpm->ChangeEnumDeclaration(VTE_PHYSIC_DOMINANCE_GROUP,dominanceGroupEnumerationString.Str());\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// collision group \r\n\t//\r\n\tpType = pm->ParameterGuidToType(VTE_PHYSIC_BODY_COLL_GROUP);\r\n\tif (pType!=-1 && collisionGroupEnumerationString.Length())\r\n\t{\r\n\t\tXString enumDescriptionCollGroup = getEnumDescription(m_Context->GetParameterManager(),VTE_PHYSIC_BODY_COLL_GROUP);\r\n\t\t\r\n\t\tpm->ChangeEnumDeclaration(VTE_PHYSIC_BODY_COLL_GROUP,collisionGroupEnumerationString.Str());\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// \r\n\t\t//\r\n\t\tCKEnumStruct *eStruct = pm->GetEnumDescByType(pType);\r\n\t\tif (eStruct)\r\n\t\t{\r\n\t\t\tint a = eStruct->GetNumEnums();\r\n\t\t\tif (a)\r\n\t\t\t{\r\n\t\t\t\tXString enumString = eStruct->GetEnumDescription(0);\r\n\t\t\t\tif (!enumString.Length())\r\n\t\t\t\t{\r\n\t\t\t\t\tpm->ChangeEnumDeclaration(VTE_PHYSIC_BODY_COLL_GROUP,enumDescriptionCollGroup.Str());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tint ab = eStruct->GetNumEnums();\r\n\t\t\t\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n}\r\nCKERROR PhysicManager::PostSave()\r\n{\r\n\r\n\treturn CK_OK;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid PhysicManager::_RegisterVSLJoint()\r\n{\r\n\t\r\n\t\t\r\n\t\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\n\r\n\r\n\r\n/*\r\nvoid __newvtWorldSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pWorldSettings();\r\n}\r\nvoid __newvtSleepingSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pSleepingSettings();\r\n}\r\nvoid __newvtJointSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pJointSettings();\r\n}\r\n\r\n\r\nint TestWS(pWorldSettings pWS)\r\n{\r\nVxVector grav = pWS.Gravity();\r\nreturn 2;\r\n}\r\n\r\npFactory* GetPFactory();\r\n\r\n\r\npFactory* GetPFactory()\r\n{\r\nreturn pFactory::Instance();\r\n}\r\n\r\n\r\nextern pRigidBody*getBody(CK3dEntity*ent);\r\n*/#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJSetD6Decl();\r\nCKERROR CreateJSetD6Proto(CKBehaviorPrototype **pproto);\r\nint JSetD6(const CKBehaviorContext& behcontext);\r\nCKERROR JSetD6CB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyA=0,\r\n\tbbI_BodyB,\r\n\tbbI_Anchor,\r\n\tbbI_AnchorRef,\r\n\tbbI_Axis,\r\n\tbbI_AxisRef,\r\n\tbbI_Coll,\r\n\tbbI_PMode,\r\n\tbbI_PDistance,\r\n\tbbI_PAngle\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJSetD6Decl\r\n// FullName: FillBehaviorJSetD6Decl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJSetD6Decl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJD6\");\t\r\n\tod->SetCategory(\"Physic/D6\");\r\n\tod->SetDescription(\"Sets or modifies a D6 joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7456331,0xc6c58d6));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJSetD6Proto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJSetD6Proto\r\n// FullName: CreateJSetD6Proto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJSetD6Proto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJD6\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\t/*! \\page PJD6\r\n\r\n\t
\r\n\tPJD6 is categorized in \\ref Joints\r\n\t
\r\n\t
See PJD6.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a D6 joint.\r\n\t
\r\n\t
\r\n\tDOFs removed: 0-6
\r\n\tDOFs remaining: 0-6
\r\n\t
\r\n\t
\r\n\r\n\tThis joint type can be configured to model nearly any joint imaginable. Each degree of freedom - both linear and angular - can be selectively locked or freed, and separate limits can be applied to each. The 6 DOF joint provides motor drive on all axes independently, and also allows soft limits.\r\n\r\n\tThe joint axis (localAxis[]) defines the joint's local x-axis. The joint normal (localNormal[]) defines the joint's local y-axis. The local z-axis is computed as a cross product of the first two. \r\n\r\n\tWhen constraining the angular motion of the joint, rotation around the x-axis is referred to as twist, rotation around the y-axis as swing1, and rotation around the z-axis as swing2.\r\n\r\n\r\n\t\\image html 6dofaxis.png\r\n\r\n\t\r\n\t

Technical Information

\r\n\r\n\t\\image html PJD6.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\r\n\t
\r\n\r\n\tAnchor:A point in world space coordinates. See pJointD6::setGlobalAnchor().\r\n\t
\r\n\tAnchor Reference: A helper entity to transform a local anchor into the world space.\r\n\t
\r\n\r\n\t
\r\n\r\n\tAxis: An in world space. See pJointD6::setGlobalAxis().\r\n\t
\r\n\tAxis Up Reference: A helper entity to transform a local axis into the world space.\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\tCollision: Enable Collision. See pJointD6::enableCollision().\r\n\t
\r\n\r\n\t
\r\n\tProjection Mode: Joint projection mode. See pJointD6::setProjectionMode() and #ProjectionMode.\r\n\t
\r\n\r\n\tProjection Distance: If any joint projection is used, it is also necessary to set \r\n\tprojectionDistance to a small value greater than zero. When the joint error is larger than projectionDistance the SDK will change it so that the joint error is equal to projectionDistance. Setting projectionDistance too \r\n\tsmall will introduce unwanted oscillations into the simulation.See pJointD6::setProjectionDistance().\r\n\t
\r\n\r\n\tProjection Angle: Angle must be greater than 0.02f .If its smaller then current algo gets too close to a singularity. See pJointD6::setProjectionAngle().\r\n\t
\r\n\r\n\r\n\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include D6Creation.vsl\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createD6Joint().
\r\n\r\n\t*/\r\n\t\r\n\tproto->SetBehaviorCallbackFct( JSetD6CB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Anchor\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Anchor Reference\",CKPGUID_3DENTITY,\"0.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Axis\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Axis Up Reference\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->DeclareInParameter(\"Projection Mode\",VTE_JOINT_PROJECTION_MODE,\"0\");\r\n\tproto->DeclareInParameter(\"Projection Distance\",CKPGUID_FLOAT,\"0\");\r\n\tproto->DeclareInParameter(\"Projection Angle\",CKPGUID_FLOAT,\"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JSetD6);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JSetD6\r\n// FullName: JSetD6\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JSetD6(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointD6 *joint =static_cast(worldA->getJoint(target,targetB,JT_D6));\r\n\t\t\t//anchor : \r\n\t\t\tVxVector anchor = GetInputParameterValue(beh,1);\r\n\t\t\tVxVector anchorOut = anchor;\r\n\t\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(2);\r\n\r\n\t\t\tif (anchorReference)\r\n\t\t\t{\r\n\t\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t\t}\r\n\r\n\t\t\t//axis \r\n\t\t\tVxVector axis = GetInputParameterValue(beh,3);\r\n\t\t\tVxVector axisOut = axis;\r\n\t\t\tCK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(4);\r\n\r\n\t\t\tif (axisReference)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisReference->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisReference->TransformVector(&axisOut,&up);\r\n\t\t\t}\r\n\r\n\t\t\tint coll = GetInputParameterValue(beh,bbI_Coll);\r\n\r\n\t\t\tProjectionMode mode =GetInputParameterValue(beh,bbI_PMode); \r\n\t\t\tfloat distance = GetInputParameterValue(beh,bbI_PDistance); \r\n\t\t\tfloat angle= GetInputParameterValue(beh,bbI_PAngle); \r\n\r\n\t\t\t\r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createD6Joint(target,targetB,anchorOut,axisOut,coll));\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joints parameters : \r\n\t\t\t//set it up : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->setGlobalAnchor(anchorOut);\r\n\t\t\t\tjoint->setGlobalAxis(axisOut);\r\n\t\t\t\tjoint->enableCollision(coll);\r\n\t\t\t\tif (mode != 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setProjectionMode(mode);\r\n\t\t\t\t\tjoint->setProjectionDistance(distance);\r\n\t\t\t\t\tjoint->setProjectionAngle(angle);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JSetD6CB\r\n// FullName: JSetD6CB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JSetD6CB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tDWORD fmax;\r\n\t\t\tbeh->GetLocalParameterValue(0,&fmax);\r\n\t\t\tif (fmax )\r\n\t\t\t{\r\n\t\t\t\tbeh->EnableInputParameter(6,fmax);\r\n\t\t\t\tbeh->EnableInputParameter(7,fmax);\r\n\t\t\t\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tbeh->EnableInputParameter(6,fmax);\r\n\t\t\t\tbeh->EnableInputParameter(7,fmax);\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//the object A: \r\n\t\t\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\t\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\r\n\t\t\t\tif (target && targetB)\r\n\t\t\t\t{\r\n\t\t\t\t\t// the world : \r\n\t\t\t\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\t\t\t\tif (!world)\r\n\t\t\t\t\t\treturn CKBR_OK;\r\n\r\n\t\t\t\t\t// the physic object A and B : \r\n\t\t\t\t\tpRigidBody*bodyA= world->getBody(target);\r\n\t\t\t\t\tpRigidBody*bodyB= world->getBody(targetB);\r\n\r\n\t\t\t\t\tif(bodyA && bodyB)\r\n\t\t\t\t\t{\r\n//\t\t\t\t\t\tpJointHinge2 *joint = static_cast(bodyA->isConnected(targetB));\r\n\t\t\t\t\t\t/*\r\n\t\t\t\t\t\tif (joint && joint->GetFeedBack())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tjoint->SetFeedBack(NULL,0,0);\r\n\t\t\t\t\t\t}*/\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#ifndef __P_VEHICLE_MOTOR_H__\r\n#define __P_VEHICLE_MOTOR_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"pVehicleTypes.h\"\r\n#include \"pDriveline.h\"\r\n#include \"pEngine.h\"\r\n\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\nclass MODULE_API pVehicleMotorDesc \r\n{\r\npublic:\r\n\tpLinearInterpolation torqueCurve;\r\n\tfloat\t\t\t\t\t\tmaxRpmToGearUp;\r\n\tfloat\t\t\t\t\t\tminRpmToGearDown;\r\n\tfloat\t\t\t\t\t\tmaxRpm;\r\n\tfloat\t\t\t\t\t\tminRpm;\r\n\r\n\tvoid setToDefault();\r\n\tpVehicleMotorDesc() { setToDefault(); }\r\n\tvoid setToCorvette();\r\n\tbool isValid() const;\r\n};\r\n\r\nclass MODULE_API pVehicleMotor {\r\n\r\npublic:\r\n\r\n\tpLinearInterpolation _torqueCurve;\r\n\t\r\n\tfloat\t\t\t\t\t\t_rpm;\r\n\t\r\n\t\r\n\t\r\n\t\r\n\tfloat getMaxTorquePos() const { return _maxTorquePos; }\r\n\tvoid setMaxTorquePos(float val) { _maxTorquePos = val; }\r\n\r\n\t\r\n\t\r\n\tfloat getMaxRpmToGearUp() const { return _maxRpmToGearUp; }\r\n\tvoid setMaxRpmToGearUp(float val) { _maxRpmToGearUp = val; }\r\n\t\r\n\tfloat getMinRpmToGearDown() const { return _minRpmToGearDown; }\r\n\tvoid setMinRpmToGearDown(float val) { _minRpmToGearDown = val; }\r\n\t\r\n\t\r\n\tfloat getMaxTorque() const { return _maxTorque; }\r\n\tvoid setMaxTorque(float val) { _maxTorque = val; }\r\n\r\n\r\n\r\n\tfloat\t\t\t\t\t\t_maxTorquePos;\r\n\tfloat\t\t\t\t\t\t_maxTorque;\r\n\r\n\tfloat\t\t\t\t\t\t_maxRpm;\r\n\t\r\n\t\r\n\r\n\t\r\n\tfloat\t\t\t\t\t\t_minRpm;\r\n\t\r\n\t\r\n\t\r\n\tfloat\t\t\t\t\t\t_minRpmToGearDown;\r\n\tfloat\t\t\t\t\t\t_maxRpmToGearUp;\r\n\r\n\r\n\r\n\tpVehicleMotor() : _rpm(0) { }\r\n\r\n\tvoid setMaxRpm(float val) { _maxRpm = val; }\r\n\tvoid setMinRpm(float val) { _minRpm = val; }\r\n\r\n\t\r\n\tvoid\t\tsetRpm(float rpm) { _rpm = rpm; }\r\n\tfloat\t\tgetRpm() const { return _rpm; }\r\n\r\n\tfloat\t\tgetMinRpm() const { return _minRpm; }\r\n\tfloat\t\tgetMaxRpm() const { return _maxRpm; }\r\n\r\n\r\n\tint\t\tchangeGears(const pVehicleGears* gears, float threshold) const;\r\n\tfloat\t\tgetTorque() const { return _torqueCurve.getValue(_rpm); }\r\n\r\n\tint loadNewTorqueCurve(pLinearInterpolation newTCurve);\r\n\r\n\r\n\tint reload(pVehicleMotorDesc* descr);\r\n\r\n\r\n};\r\n\r\n\r\n\r\n/** @} */\r\n\r\n#endif#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xLogger.h\"\r\n\r\n#include \"vtLogTools.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDebugTextDecl();\r\nCKERROR CreateDebugTextProto(CKBehaviorPrototype **pproto);\r\nint DebugText(const CKBehaviorContext& behcontext);\r\nCKERROR DebugTextCallBackObject(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorDebugTextDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DebugText\");\t\r\n\tod->SetDescription(\"Displays a text on console\");\r\n\t\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x37852d34,0x27a84a90));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00020000);\r\n\tod->SetCreationFunction(CreateDebugTextProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"TNL/Misc\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDebugTextProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DebugText\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"On\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\t\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Component\", CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Level\", CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Text\", CKPGUID_STRING);\r\n\tproto->DeclareOutParameter(\"Text\", CKPGUID_STRING);\r\n\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(DebugText);\r\n\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\t\r\n\tproto->SetBehaviorCallbackFct(DebugTextCallBackObject);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint DebugText(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n\r\n\t\r\n int component=-1;\r\n beh->GetInputParameterValue(0,&component);\r\n int level=-1;\r\n beh->GetInputParameterValue(1,&level);\r\n\r\n \r\n CKParameterIn* pin;\r\n\tCKParameter* pout;\r\n\r\n\tXString buffer;\r\n\t\r\n\t// we construct the string\r\n\tint pinc = beh->GetInputParameterCount();\r\n\tfor(int i=2;iGetInputParameter(i);\r\n\t\tpout = pin->GetRealSource();\r\n\t\tif(pout) {\r\n\t\t\tint paramsize = pout->GetStringValue(NULL);\r\n\t\t\tif (paramsize) {\r\n\t\t\t\tXAP paramstring(new char[paramsize]);\r\n\t\t\t\tpout->GetStringValue(paramstring,FALSE);\r\n\r\n\t\t\t\tbuffer << (char*)paramstring;\r\n\t\t\t\tbuffer << \" \";\r\n\t\t\t} \r\n\t\t}\r\n\t}\r\n\t\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tSetOutputParameterValue(beh,0,buffer.Str());\r\n\r\n\txLogger::xLog(level,component,\"Dbg %s\",buffer.CStr());\r\n\tbeh->ActivateOutput(0);\r\n \r\n\r\n\r\n\treturn 0;\r\n}\r\n\r\n\r\nCKERROR \r\nDebugTextCallBackObject(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\treturn 0;\r\n\r\n}\r\n\r\n#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceeditor.h\"\r\n#include \"vtAgeiaInterfaceMenu.h\"\r\n\r\n//declaration of menu callback (for InitMenu function)\r\nvoid PluginMenuCallback(int commandID);\r\n\r\n//static main menu\r\nCMenu*\t\t\t\t\t\t\ts_MainMenu\t\t\t= NULL;\r\n\r\n#define PLUGINMENU_MAXENTRIES\t20\t//put there the max entries your menu may use\r\n\r\n\r\n\r\n\r\n\r\n//adds the menu to Virtools Dev main menu\r\nvoid InitMenu()\r\n{\r\n\tif (!s_Plugininterface)\r\n\t\treturn;\r\n\r\n\ts_MainMenu\t\t= s_Plugininterface->AddPluginMenu(STR_MAINMENUNAME,PLUGINMENU_MAXENTRIES,NULL,(VoidFunc1Param)PluginMenuCallback);\r\n}\r\n\r\n//removes the menu from Virtools Dev main menu\r\nvoid RemoveMenu()\r\n{\r\n\tif (!s_Plugininterface || !s_MainMenu)\r\n\t\treturn;\r\n\r\n\ts_Plugininterface->RemovePluginMenu(s_MainMenu);\r\n}\r\n\r\n//up to user.\r\n//(May be called on new composition notification for instance)\r\n//Note that first commandID can be 0\r\n//but last command ID must be lesser thanPLUGINMENU_MAXENTRIES\r\nvoid UpdateMenu()\r\n{\r\n\ts_Plugininterface->ClearPluginMenu(s_MainMenu);\t\t//clear menu\r\n\r\n\ts_Plugininterface->AddPluginMenuItem(s_MainMenu,0,\"item0\");\t\t//add simple item sample\r\n\ts_Plugininterface->AddPluginMenuItem(s_MainMenu,1,\"item1\");\t\t//add simple item sample\r\n\ts_Plugininterface->AddPluginMenuItem(s_MainMenu,-1,NULL,TRUE);\t//add separator sample\r\n\tCMenu* sub0 = s_Plugininterface->AddPluginMenuItem(s_MainMenu,2,\"SubMenu0\",FALSE,TRUE);\t//sub menu sample\r\n\tCMenu* sub1 = s_Plugininterface->AddPluginMenuItem(s_MainMenu,3,\"SubMenu1\",FALSE,TRUE);\t//sub menu sample\r\n\ts_Plugininterface->AddPluginMenuItem(sub0,4,\"item2\");\t\t//add simple item to sub menu sample\r\n\ts_Plugininterface->AddPluginMenuItem(sub0,5,\"item3\");\t\t//add simple item to sub menu sample\r\n\ts_Plugininterface->AddPluginMenuItem(sub1,6,\"item4\");\t\t//add simple item to sub menu sample\r\n\ts_Plugininterface->AddPluginMenuItem(sub1,7,\"item5\");\t\t//add simple item to sub menu sample\r\n\r\n\ts_Plugininterface->UpdatePluginMenu(s_MainMenu);\t//update menu,always needed when you finished to update the menu\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t//unless you want the menu not to have Virtools Dev main menu color scheme.\r\n}\r\n\r\n//fill with your command IDs and your actions\r\nvoid PluginMenuCallback(int commandID)\r\n{\r\n\t/*switch(commandID)\r\n\t{\r\n\t}*/\r\n}\r\n//\r\n// Cameras.cpp : Defines the initialization routines for the DLL.\r\n//\r\n#include \"CKAll.h\"\r\n\r\n\r\n#ifdef CK_LIB\r\n\t#define RegisterBehaviorDeclarations\tRegister_Cameras_BehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\t_Cameras_InitInstance\r\n\t#define ExitInstance\t\t\t\t\t_Cameras_ExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGet_Cameras_PluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGet_Cameras_PluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_Cameras_PluginInfo\r\n#else\r\n\t#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\tInitInstance\r\n\t#define ExitInstance\t\t\t\t\tExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\n\r\n\r\n\r\nCKERROR InitInstance(CKContext* context);\r\nCKERROR ExitInstance(CKContext* context);\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n#define CAMERA_BEHAVIOR\tCKGUID(0x12d94eba,0x47057415)\r\n#define CKPGUID_PROJECTIONTYPE\t\tCKDEFINEGUID(0x1ee22148, 0x602c1ca1)\r\n\r\nCKPluginInfo g_PluginInfo;\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount() { return 1; }\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tg_PluginInfo.m_Author\t\t\t= \"Virtools\";\r\n\tg_PluginInfo.m_Description\t\t= \"Camera building blocks\";\r\n\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\tg_PluginInfo.m_InitInstanceFct\t= InitInstance;\r\n\tg_PluginInfo.m_ExitInstanceFct\t= ExitInstance;\r\n\tg_PluginInfo.m_GUID\t\t\t\t= CAMERA_BEHAVIOR;\r\n\tg_PluginInfo.m_Summary\t\t\t= \"Cameras\";\r\n\treturn &g_PluginInfo;\r\n}\r\n\r\n\r\n/**********************************************************************************/\r\n/**********************************************************************************/\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tpm->RegisterNewEnum( CKPGUID_PROJECTIONTYPE,\"Projection Mode\",\"Perspective=1,Orthographic=2\" );\r\n\r\n\t// Mouse Camera Orbit\r\n\t#define CKPGUID_MOUSEBUTTON CKGUID(0x1ff24d5a,0x122f2c1f)\r\n\tpm->RegisterNewEnum(CKPGUID_MOUSEBUTTON,\"Mouse Button\",\"Left=0,Middle=2,Right=1\" );\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tpm->UnRegisterParameterType(CKPGUID_PROJECTIONTYPE);\r\n\tpm->UnRegisterParameterType(CKPGUID_MOUSEBUTTON);\r\n\treturn CK_OK;\r\n}\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\t// Cameras/Basic\r\n\tRegisterBehavior(reg, FillBehaviorDollyDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetOrthographicZoomDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetCameraTargetDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetClippingDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetFOVDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetProjectionDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetZoomDecl);\r\n\r\n\t// Cameras/FX\r\n\tRegisterBehavior(reg, FillBehaviorCameraColorFilterDecl);\r\n\tRegisterBehavior(reg, FillBehaviorVertigoDecl);\r\n\t\r\n\t// Cameras/Montage\r\n\tRegisterBehavior(reg, FillBehaviorGetCurrentCameraDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetAsActiveCameraDecl);\r\n\r\n\t// Cameras/Movement\r\n\tRegisterBehavior(reg, FillBehaviorOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorKeyboardCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorMouseCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorJoystickCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorGenericCameraOrbitDecl);\r\n}\r\n\r\n\r\n\r\n#ifndef __PLOGGER_H__\r\n#define __PLOGGER_H__\r\n#include \"pTypes.h\"\r\n\r\n\tclass pLogger\r\n\t{\r\n\r\n\tpublic:\r\n\t\tpLogger();\r\n\t\t~pLogger();\r\n\t\t\r\n\t\tpErrorStream * getErrorStream() const { return mErrorStream; }\r\n\t\tvoid setErrorStream(pErrorStream * val) { mErrorStream = val; }\r\n\r\n\t\r\n\t\tprotected:\r\n\t\t\tpErrorStream *mErrorStream;\r\n\t};\r\n\r\n\r\n#endif#include \r\n\r\n#ifndef __VT_PYTHON_EXT_H_\r\n\t#define __VT_PYTHON_EXT_H_\r\n\r\n\tPyObject* log_CaptureStdout(PyObject* self, PyObject* pArgs);\r\n\tPyObject* log_CaptureStderr(PyObject* self, PyObject* pArgs);\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetTriggerMaskDecl();\r\nCKERROR CreatePBSetTriggerMaskProto(CKBehaviorPrototype **pproto);\r\nint PBSetTriggerMask(const CKBehaviorContext& behcontext);\r\nCKERROR PBSetTriggerMaskCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_OnEnter,\r\n\tbbI_OnStay,\r\n\tbbI_OnLeave,\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPBSetTriggerMaskDecl\r\n// FullName: FillBehaviorPBSetTriggerMaskDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBSetTriggerMaskDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCSetTriggerMask\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Modifies trigger mask\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x27ae51d4,0x45bf2c6c));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBSetTriggerMaskProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBSetTriggerMaskProto\r\n// FullName: CreatePBSetTriggerMaskProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBSetTriggerMaskProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCSetTriggerMask\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PCSetTriggerMask \r\n\r\n\tPCSetTriggerMask is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies the trigger mask of a bodies or a sub shape of it.
\r\n\tSee pBTriggerEvent.cmo for example.\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSetTriggerMask.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The shape reference. Can be a sub shape or the initial mesh.\r\n\t
\r\n\t
\r\n\tOn Enter: Enables triggering if the body starts entering another shape.\r\n\t
\r\n\tOn Stay: Enables triggering if the body stays in another shape.\r\n\t
\r\n\tOn Leave: Enables triggering if the body leaves another shape.\r\n\t
\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PCSetTriggerMask.cpp\r\n\t\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBSetTriggerMaskCB );\r\n\tproto->DeclareInParameter(\"On Enter\",CKPGUID_BOOL,\"true\");\r\n\tproto->DeclareInParameter(\"On Stay\",CKPGUID_BOOL,\"true\");\r\n\tproto->DeclareInParameter(\"On Leave\",CKPGUID_BOOL,\"true\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBSetTriggerMask);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetTriggerMask\r\n// FullName: PBSetTriggerMask\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBSetTriggerMask(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\t\r\n\t\tpWorld *world = GetPMan()->getWorldByShapeReference(target);\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tNxShape *shape = world->getShapeByEntityID(target->GetID());\r\n\t\t\tif (shape)\r\n\t\t\t{\r\n\r\n\t\t\t\tint onEnter = GetInputParameterValue(beh,bbI_OnEnter);\r\n\t\t\t\tint onStay = GetInputParameterValue(beh,bbI_OnStay);\r\n\t\t\t\tint onLeave = GetInputParameterValue(beh,bbI_OnLeave);\r\n\r\n\t\t\t\tshape->setFlag(NX_TRIGGER_ON_ENTER,onEnter);\r\n\t\t\t\tshape->setFlag(NX_TRIGGER_ON_STAY,onStay);\r\n\t\t\t\tshape->setFlag(NX_TRIGGER_ON_LEAVE,onLeave);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetTriggerMaskCB\r\n// FullName: PBSetTriggerMaskCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBSetTriggerMaskCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\nstruct clist2\r\n{\r\n\r\n\tCK3dEntity *part;\r\n\tCK3dEntity *obstacle;\r\n\tCK3dEntity *sub_obstacle;\r\n\tVxVector pos;\r\n\tVxVector normal;\r\n\tfloat depth;\r\n\tclist2(CK3dEntity* p , CK3dEntity *o,CK3dEntity*so, VxVector po, VxVector n , float d ) :\r\n\tpart(p) , obstacle(o), sub_obstacle(so), pos(po) , normal (n) , depth (d){}\r\n\r\n};\r\n#include \r\n#include \r\n#include \r\n\r\n#include \r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n\r\n\r\n//#define WASSERT_VERIFY_PREFIX(Condition,bufferSize) xVerifyAndCorrect(Condition)\r\n\r\nstatic const xAssertInfo g_fiAssertInvalidInfo(AFS_ASSERT,NULL,NULL, 0 , NULL ,NULL,false);\r\nstatic xAssertInfo g_fiAssertLastInfo;\r\n\r\nvoid xCONVENTION_CALLBACK testAssertsAssertionFailure(E_ASSERTION_FAILURE_SEVERITY fsFailureSeverity, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t char *szAssertionExpression, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t char *szAssertionFileName, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t int uiAssertionSourceLine,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t char *assertionPostMessage,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t void* postAction,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t bool result\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ){\r\n\tg_fiAssertLastInfo.failureSeverity= fsFailureSeverity;\r\n\tg_fiAssertLastInfo.assertionExpression = szAssertionExpression;\r\n\tg_fiAssertLastInfo.assertionFileName = szAssertionFileName;\r\n\tg_fiAssertLastInfo.assertionSourceLine = uiAssertionSourceLine;\r\n\tg_fiAssertLastInfo.assertionPostMessage = assertionPostMessage;\r\n\tg_fiAssertLastInfo.postAction = postAction;\r\n\tg_fiAssertLastInfo.result = result;\r\n}\r\n\r\nxAssertInfo* assertFailed()\r\n{\r\n/*\r\n\r\n\tif (g_fiAssertLastInfo.assertionExpression == NULL\r\n\t\t|| g_fiAssertLastInfo.assertionFileName == NULL\r\n\t\t|| strcmp(g_fiAssertLastInfo.assertionFileName, __FILE__) != 0\r\n\t\t|| g_fiAssertLastInfo.assertionSourceLine == 0\r\n\t\t|| !g_fiAssertLastInfo.result)\r\n\t{*/\r\n\r\n\tif (!g_fiAssertLastInfo.result)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\treturn &g_fiAssertLastInfo;\r\n\r\n}\r\nxAssertInfo *getLastAssertInfo(){ return &g_fiAssertLastInfo; }\r\n\r\nvoid xCONVENTION_CALLBACK tickAssertHandlerData()\r\n{\r\n\r\n\tbool bResult = false;\r\n\r\n\txErrorHandlerFn fnAssertOldHandler = xAssertionEx::getErrorHandler();\r\n\txAssertionEx::updateErrorHandler(&updateAssertHandlerData);\r\n\r\n\r\n\r\n\treturn;\r\n\t/*\r\n\r\n\tdo\r\n\t{\r\n#if !defined(NDEBUG)\r\n\t\t// Only callback invocation is checked here.\r\n\t\t// Availability of functionality depending on preprocessor defines\r\n\t\t// is verified in OST_ASSERT subsystem.\r\n\r\n\t\tOU_ASSERT(false); // const unsigned int uiAssertToVerifyLines = 14; -- see further in code\r\n\r\n\t\tif (g_fiAssertLastInfo.m_fsFailureSeverity != AFS_ASSERT\r\n\t\t\t|| g_fiAssertLastInfo.m_szAssertionExpression == NULL\r\n\t\t\t|| g_fiAssertLastInfo.m_szAssertionFileName == NULL\r\n\t\t\t|| strcmp(g_fiAssertLastInfo.m_szAssertionFileName, __FILE__) != 0\r\n\t\t\t|| g_fiAssertLastInfo.m_uiAssertionSourceLine == 0)\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tCTestCustomizations_Asserts_FailureInfo fiAssertFailureInfoSave = g_fiAssertLastInfo;\r\n\t\tg_fiAssertLastInfo = g_fiAssertInvalidInfo;\r\n\r\n\t\tOU_VERIFY(false); const unsigned int uiAssertToVerifyLines = 14;\r\n\r\n\t\tif (g_fiAssertLastInfo.m_fsFailureSeverity != AFS_ASSERT\r\n\t\t\t|| g_fiAssertLastInfo.m_szAssertionExpression == NULL\r\n\t\t\t|| strcmp(g_fiAssertLastInfo.m_szAssertionExpression, fiAssertFailureInfoSave.m_szAssertionExpression) != 0\r\n\t\t\t|| g_fiAssertLastInfo.m_szAssertionFileName == NULL\r\n\t\t\t|| strcmp(g_fiAssertLastInfo.m_szAssertionFileName, __FILE__) != 0\r\n\t\t\t|| g_fiAssertLastInfo.m_uiAssertionSourceLine != fiAssertFailureInfoSave.m_uiAssertionSourceLine + uiAssertToVerifyLines)\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tg_fiAssertLastInfo = g_fiAssertInvalidInfo;\r\n\r\n\r\n#endif // #if !defined(NDEBUG)\r\n\r\n\t\t -- can't verify OU_CHECK() as it crashes the application on failure\r\n\t\tOU_CHECK(false);\r\n\r\n\t\tif (g_fiAssertLastInfo.m_fsFailureSeverity != AFS_CHECK\r\n\t\t|| g_fiAssertLastInfo.m_szAssertionExpression == NULL\r\n\t\t|| g_fiAssertLastInfo.m_szAssertionFileName == NULL\r\n\t\t|| strcmp(g_fiAssertLastInfo.m_szAssertionFileName, __FILE__) != 0\r\n\t\t|| g_fiAssertLastInfo.m_uiAssertionSourceLine == 0)\r\n\t\t{\r\n\t\tbreak;\r\n\t\t}\r\n\t\t\r\n\t\tbResult = true;\r\n\t}\r\n\twhile (false);\r\n\r\n\tCAssertionCheckCustomization::CustomizeAssertionChecks(fnAssertOldHandler);\r\n\r\n\treturn bResult;\r\n\t*/\r\n\r\n}\r\n\r\nvoid xCONVENTION_CALLBACK rotateAssertInfo(\r\n\r\n\t\t\t\t\t\t\t\t\t\t E_ASSERTION_FAILURE_SEVERITY failureSeverity,\r\n\t\t\t\t\t\t\t\t\t\t char *assertionExpression,\r\n\t\t\t\t\t\t\t\t\t\t char *assertionFileName,\r\n\t\t\t\t\t\t\t\t\t\t int assertionSourceLine,\r\n\t\t\t\t\t\t\t\t\t\t char *assertionPostMessage,\r\n\t\t\t\t\t\t\t\t\t\t void* postAction,\r\n\t\t\t\t\t\t\t\t\t\t bool result)\r\n{\r\n\tg_fiAssertLastInfo.failureSeverity\t\t= failureSeverity;\r\n\tg_fiAssertLastInfo.assertionExpression\t= assertionExpression;\r\n\tg_fiAssertLastInfo.assertionFileName\t= assertionFileName;\r\n\tg_fiAssertLastInfo.assertionSourceLine\t= assertionSourceLine;\r\n\r\n\tg_fiAssertLastInfo.assertionPostMessage\t= assertionPostMessage;\r\n\tg_fiAssertLastInfo.postAction\t= postAction;\r\n\r\n\r\n\txErrorHandlerFn fnAssertOldHandler = xAssertionEx::Instance()->getErrorHandler();\r\n\txAssertionEx::Instance()->updateErrorHandler(&updateAssertHandlerData);\r\n\r\n\r\n\r\n\r\n}\r\n\r\nvoid xCONVENTION_CALLBACK updateAssertHandlerData(\r\n\tE_ASSERTION_FAILURE_SEVERITY _failureSeverity,\r\n\tchar *_assertionExpression,\r\n\tchar *_assertionFileName,\r\n\tint _assertionSourceLine,\r\n\tchar *_assertionPostMessage,\r\n\tvoid* _postAction,\r\n\tbool _result)\r\n{\r\n\r\n\tg_fiAssertLastInfo.failureSeverity = _failureSeverity;\r\n\tg_fiAssertLastInfo.assertionExpression = _assertionExpression;\r\n\tg_fiAssertLastInfo.assertionFileName = _assertionFileName;\r\n\tg_fiAssertLastInfo.assertionSourceLine = _assertionSourceLine;\r\n\tg_fiAssertLastInfo.assertionPostMessage = _assertionPostMessage;\r\n\tg_fiAssertLastInfo.postAction = _postAction;\r\n\tg_fiAssertLastInfo.result = _result;\r\n\r\n}\r\n\r\nxAssertInfo createAssertInfo(\r\n\t\t\t\t\t\t\t E_ASSERTION_FAILURE_SEVERITY failureSeverity,\r\n\t\t\t\t\t\t\t char *assertionExpression,\r\n\t\t\t\t\t\t\t char *assertionFileName,\r\n\t\t\t\t\t\t\t int assertionSourceLine,\r\n\t\t\t\t\t\t\t char *assertionPostMessage,\r\n\t\t\t\t\t\t\t void* postAction,\r\n\t\t\t\t\t\t\t bool result)\r\n{\r\n\treturn xAssertInfo(failureSeverity,assertionExpression,assertionFileName,assertionSourceLine,assertionPostMessage,postAction,result);\r\n} \r\n\r\n\r\n\r\nbool customizeAsserts()\r\n{\r\n\r\n\r\n\r\n\tbool bResult = false;\r\n\r\n\txErrorHandlerFn fnAssertOldHandler = xAssertionEx::getErrorHandler();\r\n\txAssertionEx::updateErrorHandler(&testAssertsAssertionFailure);\r\n\r\n\treturn bResult;\r\n\r\n\r\n}\r\n\r\nbool TestCustomizations_Asserts()\r\n{\r\n\t\r\n\r\n\tbool bResult = false;\r\n\txErrorHandlerFn fnAssertOldHandler = xAssertionEx::getErrorHandler();\r\n\txAssertionEx::updateErrorHandler(&testAssertsAssertionFailure);\r\n\r\n\r\n\tdo\r\n\t{\r\n\r\n\t\t// Only callback invocation is checked here.\r\n\t\t\t// Availability of functionality depending on preprocessor defines\r\n\t\t\t// is verified in OST_ASSERT subsystem.\r\n\r\n\t\t\tfloat a = 10;\r\n\t\t\t//xAssert(1); // const unsigned int uiAssertToVerifyLines = 14; -- see further in code\r\n\t\t\tint test=0;\r\n\t\t\tbool resultAssert=false;\r\n\t\t\txAssertW( a < 5,test=10,\"reset value\",D_SO_NAME,resultAssert);\r\n\r\n\r\n\t\t\tif (g_fiAssertLastInfo.failureSeverity != AFS_ASSERT\r\n\t\t\t\t|| g_fiAssertLastInfo.assertionExpression == NULL\r\n\t\t\t\t|| g_fiAssertLastInfo.assertionFileName == NULL\r\n\t\t\t\t|| strcmp(g_fiAssertLastInfo.assertionFileName, __FILE__) != 0\r\n\t\t\t\t|| g_fiAssertLastInfo.assertionSourceLine == 0)\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\txAssertInfo fiAssertFailureInfoSave = g_fiAssertLastInfo;\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,fiAssertFailureInfoSave.assertionExpression);\r\n\r\n\r\n\r\n\t\t\tg_fiAssertLastInfo = g_fiAssertInvalidInfo;\r\n\r\n\t}\r\n\twhile (false);\r\n\r\n\r\n\txAssertionEx::updateErrorHandler(fnAssertOldHandler);\r\n\r\n\t\r\n\treturn false;\r\n\t\r\n}\r\n\r\n/*\t\t\txAssertInfo *last = getLastAssertInfo();\r\nif (last)\r\n{\r\nxLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,last->assertionExpression);\r\n}\r\n*/\r\n/*\t\t\txVerify(false); const unsigned int uiAssertToVerifyLines = 14;\r\n\r\nif (g_fiAssertLastInfo.failureSeverity != AFS_ASSERT\r\n|| g_fiAssertLastInfo.assertionExpression == NULL\r\n|| strcmp(g_fiAssertLastInfo.assertionExpression, fiAssertFailureInfoSave.assertionExpression) != 0\r\n|| g_fiAssertLastInfo.assertionFileName == NULL\r\n|| strcmp(g_fiAssertLastInfo.assertionFileName, __FILE__) != 0\r\n|| g_fiAssertLastInfo.assertionSourceLine != fiAssertFailureInfoSave.assertionSourceLine + uiAssertToVerifyLines)\r\n{\r\nbreak;\r\n}\r\n*/\r\n//g_fiAssertLastInfo = g_fiAssertInvalidInfo;\r\n\r\n\r\n/*xAssertInfo *last = getLastAssertInfo();\r\nif (last)\r\n{\r\nxLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,last->assertionExpression);\r\n}*/\r\n\r\n/*\r\n#endif \r\n//#if !defined(NDEBUG)\r\n\r\n\r\n//\t\t -- can't verify OU_CHECK() as it crashes the application on failure\r\n//xCheck(false);\r\n/*\r\nif (g_fiAssertLastInfo.failureSeverity != AFS_CHECK\r\n|| g_fiAssertLastInfo.assertionExpression == NULL\r\n|| g_fiAssertLastInfo.assertionFileName == NULL\r\n|| strcmp(g_fiAssertLastInfo.assertionFileName, __FILE__) != 0\r\n|| g_fiAssertLastInfo.assertionSourceLine == 0)\r\n{\r\nbreak;\r\n}*/#ifndef __VTMODULE_ERROR_CODES_H__\r\n#define __VTMODULE_ERROR_CODES_H__\r\n\r\n\r\n/*!\r\n * \\brief\r\n * Error codes to identifier common errors in the SDK with automatic \r\n * string conversion for building blocks\r\n*/\r\ntypedef enum E_BB_ERRORS\r\n{\r\n\tE_PE_NONE,\r\n\tE_PE_INTERN,\r\n\tE_PE_PAR,\r\n\tE_PE_REF,\r\n\tE_PE_XML,\r\n\tE_PE_FILE,\r\n\tE_PE_NoBody,\r\n\tE_PE_NoVeh,\r\n\tE_PE_NoWheel,\r\n\tE_PE_NoJoint,\r\n\tE_PE_NoCloth,\r\n\tE_PE_NoSDK,\r\n};\r\n\r\n#endif // __VTMODULEERRORCODES_H__#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"tinyxml.h\"\r\n\r\n\r\n\r\nstatic const TiXmlElement *getFirstOdeElement(const TiXmlElement *root);\r\nstatic const TiXmlElement *getFirstOdeElement(const TiXmlElement *root) \r\n{\r\n\t// should have some recursive algo \r\n\tif (!strcmp(root->Value(), \"vtPhysics\"))\r\n\t{\r\n\t\treturn root;\r\n\t}\r\n\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling())\r\n\t{\r\n\t\tif (child->Type() == TiXmlNode::ELEMENT)\r\n\t\t{\r\n\t\t\tconst TiXmlElement *res = getFirstOdeElement(child->ToElement ());\r\n\t\t\tif (res)\r\n\t\t\t\treturn res;\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\nTiXmlDocument*\r\nPhysicManager::loadDefaults(XString filename)\r\n{\r\n\r\n\t\r\n\t// load and check file\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,filename.CStr());\t\r\n\tXString name(Ini);\r\n\tname << '\\0';\r\n\r\n\tm_DefaultDocument = new TiXmlDocument(filename.Str());\r\n\tm_DefaultDocument ->LoadFile(Ini);\r\n\tm_DefaultDocument ->Parse(Ini);\r\n\t\r\n\tif (m_DefaultDocument->Error())\r\n\t{\r\n\t\t//xLogger::xLog(\"couldn't load default document\");\r\n\r\n\t\tdelete m_DefaultDocument;\r\n\t\tm_DefaultDocument = NULL;\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t// get the ogreode element.\r\n\tTiXmlNode* node = m_DefaultDocument->FirstChild( \"vtPhysics\" );\r\n\tif (!node)\r\n\t{\r\n\t\t//Ogre::LogManager::getSingleton().logMessage(\" cannot find ogreode root in XML file!\");\r\n\t\treturn NULL;\r\n\t}\r\n\treturn m_DefaultDocument;\r\n\r\n}#ifndef __MEMORY_FILE_MAPPING_TYPES_H__\r\n#define __MEMORY_FILE_MAPPING_TYPES_H__\r\n\r\nenum vtEventState\r\n{\r\n\tEEVT_STARTED,\r\n\tEEVT_FINISHED\r\n};\r\n\r\nstruct vtExternalEvent\r\n{\r\n\tunsigned long timeOfCreation;\r\n\t\r\n\tchar command[MAX_PATH];\r\n\tchar commandArg[MAX_PATH];\r\n\tvtEventState state;\r\n};\r\n\r\n#endif/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\nCKMessageType GetMessageByString(const char *msg)\r\n{\r\n\tCKMessageManager *mm = GetPlayer().m_MessageManager;\r\n\r\n\tfor (int i = 0 ; i < mm->GetMessageTypeCount() ; i++)\r\n\t{\r\n\t\tif (!strcmp(mm->GetMessageTypeName(i),msg) )\r\n\t\t{\r\n\t\t\treturn i;\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n//************************************\r\n// Method: SendMessage\r\n// FullName: CCustomPlayer::SendMessage\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: char *targetObject\r\n// Parameter: char *message\r\n// Parameter: int id0\r\n// Parameter: int id1\r\n// Parameter: int id2\r\n// Parameter: int value\r\n//************************************\r\nint CCustomPlayer::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,int value)\r\n{\r\n\r\n\tCKContext *ctx = m_CKContext;\r\n\tCKLevel *level = ctx->GetCurrentLevel();\r\n\tCKMessageManager *mm = GetPlayer().m_MessageManager;\r\n\r\n\tCKBeObject *obj = static_cast(ctx->GetObjectByName(targetObject));\r\n\tCKMessageType mType = GetMessageByString(message);\r\n\r\n\r\n\tif (level && mType)\r\n\t{\r\n\t\tif (mType)\r\n\t\t{\r\n\t\t\tCKMessage *msg = NULL;\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t//no target object specified, we send a broadcast message :\r\n\t\t\tif (!obj)\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageBroadcast(mType,CKCID_BEOBJECT,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}//target object ok, we send a single message : \r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageSingle(mType,obj,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// we attach our arguments as parameters : \r\n\r\n\t\t\t//id0\r\n\t\t\tCKParameter *parameter0 = ctx->CreateCKParameterLocal(\"msg0\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter0->SetValue(&id0);msg->AddParameter(parameter0,true);\r\n\t\t\t//id1\r\n\t\t\tCKParameter *parameter1 = ctx->CreateCKParameterLocal(\"msg1\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter1->SetValue(&id1);\tmsg->AddParameter(parameter1,true);\r\n\t\t\t//id2\r\n\t\t\tCKParameter *parameter2 = ctx->CreateCKParameterLocal(\"msg2\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter2->SetValue(&id2);msg->AddParameter(parameter2,true);\r\n\t\t\t//the value : \r\n\t\t\tCKParameter *valuex= ctx->CreateCKParameterLocal(\"msgValue\",CKPGUID_INT,FALSE);\r\n\t\t\tvaluex->SetValue(&value);msg->AddParameter(valuex,true);\r\n return 1;\r\n\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n//************************************\r\n// Method: SendMessage\r\n// FullName: CCustomPlayer::SendMessage\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: char *targetObject\r\n// Parameter: char *message\r\n// Parameter: int id0\r\n// Parameter: int id1\r\n// Parameter: int id2\r\n// Parameter: int value\r\n//************************************\r\nint CCustomPlayer::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,float value)\r\n{\r\n\r\n\tCKContext *ctx = m_CKContext;\r\n\tCKLevel *level = ctx->GetCurrentLevel();\r\n\tCKMessageManager *mm = GetPlayer().m_MessageManager;\r\n\r\n\tCKBeObject *obj = static_cast(ctx->GetObjectByName(targetObject));\r\n\tCKMessageType mType = GetMessageByString(message);\r\n\r\n\r\n\tif (level && mType)\r\n\t{\r\n\t\tif (mType)\r\n\t\t{\r\n\t\t\tCKMessage *msg = NULL;\r\n\r\n\r\n\t\t\t//no target object specified, we send a broadcast message :\r\n\t\t\tif (!obj)\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageBroadcast(mType,CKCID_BEOBJECT,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}//target object ok, we send a single message : \r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageSingle(mType,obj,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// we attach our arguments as parameters : \r\n\r\n\t\t\t//id0\r\n\t\t\tCKParameter *parameter0 = ctx->CreateCKParameterLocal(\"msg0\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter0->SetValue(&id0);msg->AddParameter(parameter0,true);\r\n\t\t\t//id1\r\n\t\t\tCKParameter *parameter1 = ctx->CreateCKParameterLocal(\"msg1\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter1->SetValue(&id1);\tmsg->AddParameter(parameter1,true);\r\n\t\t\t//id2\r\n\t\t\tCKParameter *parameter2 = ctx->CreateCKParameterLocal(\"msg2\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter2->SetValue(&id2);msg->AddParameter(parameter2,true);\r\n\t\t\t//the value : \r\n\t\t\tCKParameter *valuex= ctx->CreateCKParameterLocal(\"msgValue\",CKPGUID_FLOAT,FALSE);\r\n\t\t\tvaluex->SetValue(&value);msg->AddParameter(valuex,true);\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\nint CCustomPlayer::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,char* value)\r\n{\r\n\r\n\tCKContext *ctx = m_CKContext;\r\n\tCKLevel *level = ctx->GetCurrentLevel();\r\n\tCKMessageManager *mm = GetPlayer().m_MessageManager;\r\n\r\n\tCKBeObject *obj = static_cast(ctx->GetObjectByName(targetObject));\r\n\tCKMessageType mType = GetMessageByString(message);\r\n\r\n\r\n\tif (level && mType)\r\n\t{\r\n\t\tif (mType)\r\n\t\t{\r\n\t\t\tCKMessage *msg = NULL;\r\n\r\n\r\n\t\t\t\r\n\t\t\t//no target object specified, we send a broadcast message :\r\n\t\t\tif (!obj)\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageBroadcast(mType,CKCID_BEOBJECT,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}//target object ok, we send a single message : \r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tmsg = mm->SendMessageSingle(mType,obj,level);\r\n\t\t\t\tif(!msg)\r\n\t\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// we attach our arguments as parameters : \r\n\r\n\t\t\t//id0\r\n\t\t\tCKParameter *parameter0 = ctx->CreateCKParameterLocal(\"msg0\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter0->SetValue(&id0);msg->AddParameter(parameter0,true);\r\n\t\t\t//id1\r\n\t\t\tCKParameter *parameter1 = ctx->CreateCKParameterLocal(\"msg1\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter1->SetValue(&id1);\tmsg->AddParameter(parameter1,true);\r\n\t\t\t//id2\r\n\t\t\tCKParameter *parameter2 = ctx->CreateCKParameterLocal(\"msg2\",CKPGUID_INT,FALSE);\r\n\t\t\tparameter2->SetValue(&id2);msg->AddParameter(parameter2,true);\r\n\t\t\t//the value : \r\n\t\t\tCKParameter *valuex= ctx->CreateCKParameterLocal(\"msgValue\",CKPGUID_STRING,FALSE);\r\n\t\t\tvaluex->SetStringValue(value);msg->AddParameter(valuex,true);\r\n\t\t\treturn 1;\r\n\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n\r\n#include \r\n\r\n#include \r\n#include \r\n\r\n\r\n\r\n\r\nstd::ostream& base::_Debug = std::cerr;\r\nstd::ostream& base::_Log = std::cout;\r\nstd::ostream& base::_Console = std::cout;\r\n\r\n\r\n\r\n#ifdef DEBUG\r\nbool _outputExceptionOnConstruction = true;\r\nbool _abortOnAssertionFailure = false;\r\n#endif\r\n\r\n\r\n/*\r\nString base::intToString(Int i)\r\n{\r\n std::ostringstream oss;\r\n oss << i;\r\n return oss.str();\r\n}\r\n\r\n\r\nInt base::stringToInt(const String& s)\r\n{\r\n std::istringstream iss(s);\r\n Int v;\r\n iss >> v;\r\n return v;\r\n}\r\n\r\nReal base::stringToReal(const String& s)\r\n{\r\n std::istringstream iss(s);\r\n Real v;\r\n iss >> v;\r\n return v;\r\n}\r\n\r\nString base::realToString(Real r)\r\n{\r\n std::ostringstream oss;\r\n oss << r;\r\n return oss.str();\r\n}\r\n\r\n\r\n\r\n*/\r\n// racer/pacejka.h\n\n#ifndef __P_PACEJKA_H__\n#define __P_PACEJKA_H__\n\n#include \"vtPhysXBase.h\"\n\n#define RR_RAD_DEG_FACTOR\t57.29578f\t// From radians to degrees\"\n#define RR_RAD2DEG 57.29578f\t// A bit more descriptive\n\n#ifndef PI\n#define PI\t3.14159265358979f\n#endif\n\n// Near-zero definitions\n#define RR_EPSILON_VELOCITY\t0.001\t\t// Wheel velocity\n\n\nclass MODULE_API pPacejka\n// A Pacejka calculation engine\n// Uses SAE axis system for reference\n// (SAE X=Racer Z, SAE Y=Racer X, SAE Z=Racer -Y)\n{\n public:\n // Fx longitudinal force\n float a0,a1,a2,a3,a4,a5,a6,a7,a8,\n a9,a10,a111,a112,a12,a13;\n // Fy lateral force\n float b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10;\n // Mz aligning moment\n float c0,c1,c2,c3,c4,c5,c6,\n c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17;\n\n protected:\n // Input parameters\n float camber, // Angle of tire vs. surface (in degrees!)\n sideSlip, // Slip angle (in degrees!)\n slipPercentage, // Percentage slip ratio (in %)\n Fz; // Normal force (in kN!)\n // Output\n float Fx,Fy,Mz; // Longitudinal/lateral/aligning moment\n float longStiffness, // Longitudinal tire stiffness\n latStiffness; // Lateral or cornering stiffness\n VxVector maxForce; // Max. available tire force (friction ellipse)\n\n public:\n pPacejka();\n ~pPacejka();\n\n \n void setToDefault();\n\n // Attribs\n void SetCamber(float _camber){ camber=_camber*RR_RAD2DEG; }\n void SetSlipAngle(float sa){ sideSlip=sa*RR_RAD2DEG; }\n void SetSlipRatio(float sr){ slipPercentage=sr*100.0f; }\n void SetNormalForce(float force){ Fz=force/1000.0f; }\n\n // Physics\n void Calculate();\n protected:\n float CalcFx();\n float CalcFy();\n float CalcMz();\n public:\n float GetFx(){ return Fx; }\n float GetFy(){ return Fy; }\n float GetMz(){ return Mz; }\n // Adjust (used in combined slip)\n void SetFx(float v){ Fx=v; }\n void SetFy(float v){ Fy=v; }\n void SetMz(float v){ Mz=v; }\n\n // Extras\n float GetMaxLongForce(){ return maxForce.x; }\n float GetMaxLatForce(){ return maxForce.y; }\n // Adjust (used for surface and quick-adjust modifications)\n void SetMaxLongForce(float v){ maxForce.x=v; }\n void SetMaxLatForce(float v){ maxForce.x=v; }\n float GetLongitudinalStiffness(){ return longStiffness; }\n float GetCorneringStiffness(){ return latStiffness; }\n};\n\n#endif\n#ifndef __IDistributedClasses_h_\r\n#define __IDistributedClasses_h_\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nclass xNetInterface;\r\n\r\n\r\nclass IDistributedClasses\r\n{\r\n\r\npublic:\r\n\tIDistributedClasses(xNetInterface *netInterface);\r\n\tvirtual ~IDistributedClasses();\r\n\r\n\t\r\n\txDistributedClassesArrayType* getDistrutedClassesPtr();\r\n\txDistributedClass *createClass(const char* name,int templatetype);\r\n\txDistributedClass *get(const char* name);\r\n\txDistributedClass *get(const char* name,int entityType);\r\n\txDistributedClass *getByIndex(int index);\r\n\tint getNumClasses();\r\n\tint destroyClass(xDistributedClass* _class);\r\n\tvirtual void destroy();\r\n\txNetInterface*getNetInterface();\r\n\tvoid setNetInterface(xNetInterface*netInterface);\r\n\tvoid deployClass(xDistributedClass*_class);\r\nprivate:\r\n\t//TNL::SafePtrm_NetInterface;\r\n\txNetInterface *m_NetInterface;\r\n\txDistributedClassesArrayType *m_DistrutedClasses;\r\n\t\r\n};\r\n\r\n#endif\r\n#ifndef __xDistributedString_H\r\n#define __xDistributedString_H\r\n\r\n#include \"xDistributedProperty.h\"\r\n\r\nclass xDistributedString : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedString ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t\tmLastValue = xNString(\"\");\r\n\t\t\tmCurrentValue = xNString(\"\");\r\n\r\n\t\t}\r\n\r\n\t\t~xDistributedString(){}\r\n\r\n\t\txNString mLastValue;\r\n\t\txNString mCurrentValue;\r\n\t\t\r\n\t\tbool updateValue(xNString value,xTimeType currentTime);\r\n void pack(xNStream *bstream);\r\n\t\tvoid unpack(xNStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(xNStream *stream);\r\n\t\tvoid updateFromServer(xNStream *stream);\r\n virtual uxString print(TNL::BitSet32 flags);\r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n#ifndef NX_VEHICLE_DESC\r\n#define NX_VEHICLE_DESC\r\n\r\n#include \"NxWheelDesc.h\"\r\n#include \"NxVehicleMotorDesc.h\"\r\n#include \"NxVehicleGearDesc.h\"\r\n#include \r\n#include \r\n\r\nclass NxVehicleDesc\r\n{\r\npublic:\r\n\tNxArray\tcarShapes;\r\n\tNxArray\tcarWheels;\r\n\r\n\tNxArray children;\r\n\r\n\tNxVehicleMotorDesc*\t\tmotorDesc;\r\n\tNxVehicleGearDesc*\t\tgearDesc;\r\n\r\n\tNxVec3\t\t\t\t\tposition;\r\n\tNxReal\t\t\t\t\tmass;\r\n\tNxReal\t\t\t\t\tmotorForce;\r\n\tNxReal\t\t\t\t\ttransmissionEfficiency;\r\n\tNxReal\t\t\t\t\tdifferentialRatio;\r\n\r\n\tNxVec3\t\t\t\t\tsteeringTurnPoint;\r\n\tNxVec3\t\t\t\t\tsteeringSteerPoint;\r\n\tNxReal\t\t\t\t\tsteeringMaxAngle;\r\n\r\n\tNxVec3\t\t\t\t\tcenterOfMass;\r\n\r\n\tNxReal\t\t\t\t\tdigitalSteeringDelta;\r\n\r\n\tNxReal\t\t\t\t\tmaxVelocity;\r\n\tNxReal\t\t\t\t\tcameraDistance;\r\n\t//NxReal\t\t\t\t\tdigitalSteeringDeltaVelocityModifier;\r\n\r\n\tvoid*\t\t\t\t\tuserData;\r\n\r\n\tNX_INLINE NxVehicleDesc();\r\n\tNX_INLINE void setToDefault();\r\n\tNX_INLINE bool isValid() const;\r\n};\r\n\r\nNX_INLINE NxVehicleDesc::NxVehicleDesc()\t//constructor sets to default\r\n{\r\n\tsetToDefault();\r\n}\r\n\r\nNX_INLINE void NxVehicleDesc::setToDefault()\r\n{\r\n\tuserData = NULL;\r\n\tmotorDesc = NULL;\r\n\tgearDesc = NULL;\r\n\ttransmissionEfficiency = 1.0f;\r\n\tdifferentialRatio = 1.0f;\r\n\tmaxVelocity = 80;\r\n\tcameraDistance = 15.f;\r\n\tchildren.clear();\r\n\tcarWheels.clear();\r\n}\r\n\r\nNX_INLINE bool NxVehicleDesc::isValid() const\r\n{\r\n\tfor (NxU32 i = 0; i < carWheels.size(); i++) {\r\n\t\tif (!carWheels[i]->isValid())\r\n\t\t\treturn false;\r\n\t}\r\n\r\n\tif (mass < 0)\r\n\t\treturn false;\r\n\r\n\treturn true;\r\n}\r\n\r\n\r\n#endif\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSLeaveObjectDecl();\r\nCKERROR CreateNSLeaveObjectProto(CKBehaviorPrototype **);\r\nint NSLeaveObject(const CKBehaviorContext& behcontext);\r\nCKERROR NSLeaveObjectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 5\r\n#define BEH_OUT_MIN_COUNT 2\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_LEFT,\r\n\tBB_O_WAITING,\r\n\tBB_O_ERROR,\r\n\t\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_ERROR,\r\n};\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKObjectDeclaration\t*FillBehaviorNSLeaveObjectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSLeave\");\t\r\n\tod->SetDescription(\"Leaves a session\");\r\n\r\n\tod->SetCategory(\"TNL/Sessions\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x9904be3,0x46526de2));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNSLeaveObjectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR CreateNSLeaveObjectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSLeave\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\t\r\n\tproto->DeclareOutput(\"Left\");\r\n\tproto->DeclareOutput(\"Waiting For Answer\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\tproto->DeclareSetting(\"Wait For Answer\", CKPGUID_BOOL, \"0\");\r\n\tproto->DeclareSetting(\"Destroy Session\", CKPGUID_BOOL, \"TRUE\");\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(NSLeaveObject);\r\n\tproto->SetBehaviorCallbackFct(NSLeaveObjectCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\ntypedef std::vectorxSessions;\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\n\r\nint NSLeaveObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tbbNoError(E_NWE_OK);\r\n\t\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\t\t\t\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\t\t\t\t\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\t\t\r\n\tISession *sInterface = cin->getSessionInterface();\r\n\tint connectionID = GetInputParameterValue(beh,BB_IP_CONNECTION_ID);\r\n\tint deleteSession = 0;\r\n\tbeh->GetLocalParameterValue(1,&deleteSession);\r\n\r\n\tint waiting= 0;\r\n\tbeh->GetLocalParameterValue(0,&waiting);\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tCheck states : \r\n\t//\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\t\t\t\t\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\txDistributedSession *session = cin->getCurrentSession();\r\n\t\tif (!session)\r\n\t\t{\r\n\t\t\tbbError(E_NWE_NO_SUCH_SESSION);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tif (!myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED))\r\n\t\t{\r\n\t\t\tbbError(E_NWE_NO_SESSION);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\t\r\n\t\t\r\n\t\tsInterface->removeClient(myClient,session->getSessionID(),deleteSession);\r\n\t\tif (waiting)\r\n\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\telse \r\n\t\t{\r\n\t\t\tif (cin->getCurrentSession())\r\n\t\t\t{\r\n\t\t\t\tcin->setCurrentSession(NULL);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tvtConnection *con = cin->getConnection();\r\n\t\t\tif (con)\r\n\t\t\t{\r\n\t\t\t\tcon->setSessionID(-1);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif (waiting && !myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED))\r\n\t{\r\n\r\n\t\tif (cin->getCurrentSession())\r\n\t\t{\r\n\t\t\tcin->setCurrentSession(NULL);\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tvtConnection *con = cin->getConnection();\r\n\t\tif (con)\r\n\t\t{\r\n\t\t\tcon->setSessionID(-1);\r\n\t\t}\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tif (waiting)\r\n\t{\r\n\t\tbeh->ActivateOutput(BB_O_WAITING);\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR NSLeaveObjectCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\ndofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\n\r\n\r\nsolution \"vtPlayer\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\npackageConfig_XSplash =\r\n{\r\n\tName \t\t\t= \t\"xSplash\",\r\n\tType\t\t\t=\t\"SharedLib\",\r\n\tTargetSuffix \t= \"\",\r\n\tDefines \t\t= { DEF_STD_DIRECTIVES ; \"_AFXDLL\" ; \"WINVER=0x0500\" },\r\n\tFiles\t\t\t= { D_XSPLASH..\"src/**.cpp\"\t;\tD_XSPLASH..\"include/**.h\" },\r\n\tIncludes \t\t= { D_XSPLASH..\"include\" ; D_CORE_INCLUDES ; D_STD_INCLUDES },\r\n\tStaticOptions = { \"convert\" },\r\n\tOptions \t\t= { \"/W0\" ; }\r\n}\r\n\r\npackageConfig_XUtils =\r\n{\r\n\tName \t\t\t= \t\"xUtils\",\r\n\tType\t\t\t=\t\"SharedLib\",\r\n\tTargetSuffix \t= \"\",\r\n\tDefines \t\t= { DEF_STD_DIRECTIVES ; \"_AFXDLL\" ; \"WINVER=0x0500\"},\r\n\tFiles\t\t\t= { D_XUTILS..\"src/**.cpp\"\t;\tD_XUTILS..\"include/**.h\" },\r\n\tIncludes \t\t= { DDEPS..\"psdk/include\" ; D_STD_INCLUDES; D_XUTILS..\"include/3D\" ; D_CORE_INCLUDES ; D_DIRECTX9..\"Include\" },\r\n\tLibs\t\t\t= {\t\"Version\" },\r\n\tLibDirectories \t= { DDEPS..\"psdk/lib\" ; D_DIRECTX9..\"lib\" },\r\n\tStaticOptions = { \"convert\" },\r\n\tOptions \t\t= { \"/W0\" ; }\r\n}\r\n\r\n\r\n\r\n\r\n\r\npackageConfig_vtWindowLib =\r\n{\r\n\tName \t\t= \t\"vtWindowLib\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" ; },\r\n\tFiles\t\t= { DROOT..\"SDK/src/core/**.cpp\"\t;\tDROOT..\"SDK/include/core/**.h\" ; F_BASE_STD_INC ;F_VT_STD_INC; F_BASE_VT_SRC ;F_BASE_SRC;F_SHARED_SRC ; DROOT..\"SDK/src/core/*.rc\" },\r\n\tIncludes \t= { DDEPS..\"psdk/include\" ; D_STD_INCLUDES ; D_VT_BASE_INC; D_CORE_INCLUDES ; D_DIRECTX9..\"Include\" ;DROOT..\"SDK/src/core\" },\r\n\tLibs\t= {\t \"user32\" ; \"kernel32\" ; \"xSplash\" ; \"xUtils\"\t; \"dxguid\" ; \"Version\" ; },\r\n\tLibDirectories = { DDEPS..\"psdk/lib\" ; D_DIRECTX9..\"lib\" ; DROOT..\"SDK/lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tStaticOptions = { \"convert\" },\r\n\tStaticModules = { \"vtWidgets\" ; \"vtToolkit\" ; \"vtPhysX\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\npackageConfig_vtCSWindow =\r\n{\r\n\tName \t\t= \t\"vtCSWindow\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/CSharp/**.cxx\"\t;\tDROOT..\"SDK/src/CSharp/*.i\" ; F_BASE_VT_SRC },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_VT_BASE_INC; D_CORE_INCLUDES ; D_DIRECTX9..\"Include\" ;DROOT..\"SDK/src/core\" },\r\n\tLibs\t= {\t \"user32\" ; \"kernel32\" ; \"xSplash\" ; \"xUtils\"\t; \"dxguid\" ; \"Version\" ; \"vtWindowLib\" },\r\n\tLibDirectories = { D_DIRECTX9..\"lib\" ; DROOT..\"SDK/Include/Core\" ; DROOT..\"SDK/lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tStaticOptions = { \"vtstatic\" },\r\n\tStaticModules = { \"vtWidgets\" ; \"vtToolkit\" ; \"vtPhysX\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\npackageConfig_vtPlayerApp =\r\n{\r\n\tName \t\t= \t\"vtPlayer\",\r\n\tType\t\t=\t\"WindowedApp\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" ;\t},\r\n\tFiles\t\t= { DROOT..\"SDK/src/core/**.cpp\"\t;\tDROOT..\"SDK/include/core/**.h\" ; F_BASE_STD_INC ;F_VT_STD_INC; F_BASE_VT_SRC ;F_BASE_SRC;F_SHARED_SRC ; DROOT..\"SDK/src/core/*.rc\" },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_VT_BASE_INC; D_CORE_INCLUDES ; D_DIRECTX9..\"Include\" ;DROOT..\"SDK/src/core\" },\r\n\tLibs\t= {\t \"user32\" ; \"kernel32\" ; \"xSplash\" ; \"xUtils\"\t; \"dxguid\" ; \"Version\" },\r\n\tLibDirectories = { D_DIRECTX9..\"lib\" ; DROOT..\"SDK/Include/Core\" ; DROOT..\"SDK/lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tStaticOptions = { \"\" },\r\n\tStaticModules = { \"vtWidgets\" ; \"vtToolkit\" ; \"vtPhysX\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\npackageConfig_vtConsoleApp =\r\n{\r\n\tName \t\t= \t\"vtPlayerConsole\",\r\n\tType\t\t=\t\"ConsoleApp\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" ;\t},\r\n\tFiles\t\t= { DROOT..\"SDK/src/Console/**.cpp\"\t;\tDROOT..\"SDK/include/core/**.h\" ; F_BASE_STD_INC ;F_VT_STD_INC; F_BASE_VT_SRC ;F_BASE_SRC;F_SHARED_SRC ; DROOT..\"SDK/src/core/*.rc\"; DROOT..\"SDK/src/core/*.rc\" ; DROOT..\"SDK/src/core/vtWindow.cpp\" },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_VT_BASE_INC; D_CORE_INCLUDES ; D_DIRECTX9..\"Include\" ;DROOT..\"SDK/src/core\" },\r\n\tLibs\t= {\t \"user32\" ; \"kernel32\" ; \"xSplash\" ; \"xUtils\"\t; \"dxguid\" ; \"Version\" ; \"vtWindowLib\" },\r\n\tLibDirectories = { D_DIRECTX9..\"lib\" ; DROOT..\"SDK/Include/Core\" ; DROOT..\"SDK/lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tStaticOptions = { \"vtstatic\" },\r\n\tStaticModules = { \"vtWidgets\" ; \"vtToolkit\" ; \"vtPhysX\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\npackageConfig_vtCSPlayerApp =\r\n{\r\n\tName \t\t= \t\"vtPlayerCS\",\r\n\tType\t\t=\t\"WindowedApp\",\r\n\tTargetSuffix = \"\",\r\n\tLanguage = \"C#\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" },\r\n\tFiles\t\t= { DROOT..\"SDK/Src/CSharp/*.cs\" },\r\n\tIncludes \t= { },\r\n\tLibs\t= {\t\"vtCSWindow\" ; \"System\" ; \"System.Drawing\" ; \"System.Data\" ; \"System.Windows.Forms\" ; \"System.XML\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tStaticOptions = { \"\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\npackageConfig_vtCSharpBuildingBlocks =\r\n{\r\n\tName \t\t= \t\"vtCSharpBuildingBlocks\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/Behaviors/**.cpp\"\t; DROOT..\"SDK/src/Behaviors/*.rc\" ; DROOT..\"SDK/src/Behaviors/*.def\" ; F_BASE_STD_INC ;F_VT_STD_INC; F_BASE_VT_SRC ;F_BASE_SRC;F_SHARED_SRC },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDES ;},\r\n\tLibs\t= {\t\"user32\" ; \"kernel32\" ; \"Winmm\" },\r\n\tLibDirectories = { },\r\n\tStaticOptions = { \"convert\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n\r\n}\r\n\r\n\r\ncreateStaticPackage(packageConfig_vtCSWindow)\r\ncreateStaticPackage(packageConfig_XSplash)\r\ncreateStaticPackage(packageConfig_XUtils)\r\ncreateStaticPackage(packageConfig_vtWindowLib)\r\ncreateStaticPackage(packageConfig_vtPlayerApp)\r\ncreateStaticPackage(packageConfig_vtCSPlayerApp)\r\ncreateStaticPackage(packageConfig_vtCSharpBuildingBlocks)\r\ncreateStaticPackage(packageConfig_vtConsoleApp)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n--createStaticPackage(packageConfig_vtAgeiaReader)\r\n--createStaticPackage(packageConfig_vtAgeiaInterface)\r\n\r\n\r\n\r\n--include \"CppConsoleApp\"\r\n\r\nfunction onclean()\r\n\tos.rmdir(\"vs**\")\r\nend\r\n#include \"CPStdAfx.h\"\r\n//#include \"CustomPlayer.h\"\r\n#include \"vtWindow.h\"\r\n\r\n\r\nvtWindow *myWin=NULL;\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\n\r\n\tmyWin = new vtWindow();\r\n\tif (myWin->Init())\r\n\t{\r\n//\t\tCKInitCustomPlayer(false);\r\n\t\tCKStartUp();\r\n\r\n\t\t//\t\tmyWin->getPlayer()->m_hInstance\r\n\t\tmyWin->DoFrame();\r\n\t\tmyWin->Destroy();\r\n\t}\r\n\r\n}\r\ndofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\n\r\n\r\nsolution \"vtPhysX\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" ; \"ReleaseRedist\" ; \"ReleaseDemo\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\npackageConfig_Stream =\r\n{\r\n\tName \t\t= \t\"NxuStream2\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES },\r\n\tFiles\t\t= { D_NXSTREAM..\"*.cpp\"\t;\tD_NXSTREAM..\"*.h\"\t},\r\n\tIncludes \t= { D_PHYSX_INCLUDES },\r\n\tOptions = { \"/W0\"}\r\n\r\n}\r\n\r\n\r\npackageConfig_Common =\r\n{\r\n\tName \t\t= \t\"NxCommon\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES },\r\n\tFiles\t\t= { D_NXCOMMON..\"*.cpp\"\t;\tD_NXCOMMON..\"*.h\"\t},\r\n\tIncludes \t= { D_PHYSX_INCLUDES },\r\n\tOptions = { \"/W0\"}\r\n}\r\n\r\npackageConfig_Character =\r\n{\r\n\tName \t\t= \t\"NxCharacter\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES ; \"NX_USE_SDK_STATICLIBS\" ; \"NXCHARACTER_EXPORTS\" },\r\n\tFiles\t\t= { D_NXCHARACTER..\"**.cpp\"\t;\tD_NXCHARACTER..\"**.h\"\t},\r\n\tIncludes \t= { D_PHYSX_INCLUDES },\r\n\tOptions = { \"/W0\"}\r\n}\r\n\r\npackageConfig_TinyXML =\r\n{\r\n\tName \t\t= \t\"TinyXML\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES },\r\n\tFiles\t\t= { D_TINYXML..\"*.cpp\"\t;\tD_TINYXML..\"*.h\"\t},\r\n\tIncludes \t= { D_PHYSX_INCLUDES },\r\n\tOptions = { \"/W0\"}\r\n}\r\n\r\n\r\n--\tStatic library of the built-in camera building blocks\r\n--\r\n--\tThis package needs to be compiled for web player distributions.\r\n--\tCall createSolutions40Web2005.bat for instance\r\n--\r\npackageConfig_CameraRepack=\r\n{\r\n\tName \t\t= \t\"Camera\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" },\r\n\tFiles\t\t= { DDEPS..\"camera/behaviors/**.cpp\"\t},\r\n\tIncludes \t= { D_STD_INCLUDES ; },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\n--\tThe core vtPhysX SDK, compiled as DLL with exports. This is the entire base library for\r\n--\r\n--\t\t-\tbuilding blocks\r\n--\t\t-\tinterface plug-ins\r\n--\t\t-\tcustom parameter types\r\n--\t\t-\tcustom file readers\r\n--\r\n--\r\npackageConfig_vtAgeiaLib =\r\n{\r\n\tName \t\t= \t\"vtPhysXLib\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES ; \"NX_USE_SDK_STATICLIBS\" ; \"NXCHARACTER_EXPORTS\" ; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" ; },\r\n\tFiles\t\t= { DROOT..\"SDK/src/core/**.cpp\"\t;\tDROOT..\"SDK/include/core/**.h\" ; F_BASE_STD_INC ;F_VT_STD_INC; F_BASE_VT_SRC ;F_BASE_SRC;F_SHARED_SRC },\r\n\tIncludes \t= { D_PHYSX_INCLUDES ; D_STD_INCLUDES ; D_VT_BASE_INC; D_CORE_INCLUDES ; DDEPS..\"TinyXML\" },\r\n\tLibs\t= {\t\"TinyXML\" , \"NxCharacter\" , \"NxCommon\" , \"NxuStream2\"; \"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"PhysXLoader\" ; \"Winmm\" },\r\n\tLibDirectories = { D_PHYSX..\"SDKs/lib/Win32\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\n--\tThe building blocks for vtPhysX, depending on packageConfig_vtAgeiaLib\r\npackageConfig_vtAgeiaBeh =\r\n{\r\n\tName \t\t= \t\"vtPhysX\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES ; \"NX_USE_SDK_STATICLIBS\" ; \"NXCHARACTER_EXPORTS\" ; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/Behaviors/**.cpp\"\t; DROOT..\"SDK/src/Behaviors/*.def\" ; D_DOCS_PAGES..\"*.page\" ; F_SHARED_SRC ; DROOT..\"build4/**.lua\" ; F_EXTRA_BB_SRC ; F_BASE_SRC },\r\n\tIncludes \t= { D_PHYSX_INCLUDES ; D_STD_INCLUDES ; D_CORE_INCLUDES ; DDEPS..\"TinyXML\" ; DDEPS..\"dx/Include\" },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"vtPhysXLib\" ;\"Winmm\" ; \"dxerr\"; \"dinput8\";\"dxguid\" },\r\n\tLibDirectories = { D_PHYSX..\"SDKs/lib/Win32\" ; D_DX..\"lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n\r\n}\r\n\r\n--\tThe vtPhysX Reader plug-in supports NXU-Stream formats or collada, exporters for Maya and 3D-SMax\r\n--\tare avaiable. Depends on packageConfig_vtAgeiaLib\r\npackageConfig_vtAgeiaReader =\r\n{\r\n\tName \t\t= \t\"vtPhysXReader\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/Plugins\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES ; \"NX_USE_SDK_STATICLIBS\" ; \"NXCHARACTER_EXPORTS\" ; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" },\r\n\tFiles\t\t= { D_READER_SRC..\"*.cpp\" ; D_READER_SRC..\"*.def\" ; },\r\n\tIncludes \t= { D_PHYSX_INCLUDES ; D_STD_INCLUDES ; D_CORE_INCLUDES ; DDEPS..\"TinyXML\" },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"vtPhysXLib\"\t},\r\n\tLibDirectories = { D_PHYSX..\"SDKs/lib/Win32\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\Plugins\"\r\n}\r\n\r\n\r\n--\tAn interface plug-in to create dialogs for physic related parameters.\r\n-- Depends on packageConfig_vtAgeiaLib\r\npackageConfig_vtAgeiaInterface =\r\n{\r\n\tName \t\t= \t\"vtPhysXInterface\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/InterfacePlugins\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \tDEF_PHYSX_DIRECTIVES ; \"NX_USE_SDK_STATICLIBS\" ; \"NXCHARACTER_EXPORTS\" ; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" },\r\n\tFiles\t\t= { D_UI_SRC..\"*.cpp\" ; D_UI_SRC..\"*.def\" ; D_INCLUDE..\"Interface/*.h\" },\r\n\tIncludes \t= { D_PHYSX_INCLUDES ; D_STD_INCLUDES ; D_CORE_INCLUDES ; DDEPS..\"TinyXML\" ; D_INCLUDE..\"Interface\" },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"vtPhysXLib\" ; \"DllEditor\" ; \"InterfaceControls\" ; \"CKControls\" ; \"CK2Ui\"\t},\r\n\tLibDirectories = { D_PHYSX..\"SDKs/lib/Win32\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\InterfacePlugins\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\InterfacePlugins\"\r\n}\r\n\r\n\r\n\r\n--\tIf the command line contains --ExtraDefines=\"WebPack\" , we add \"WebPack\" to the\r\n--\tpre-processor directives and also create a package to include the camera building blocks\r\n--\tas defined in packageConfig_CameraRepack\r\nif _OPTIONS[\"ExtraDefines\"] then\r\n\r\n\tif _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\tcreateStaticPackage(packageConfig_CameraRepack)\r\n\tend\r\nend\r\n\r\ncreateStaticPackage(packageConfig_Common)\r\ncreateStaticPackage(packageConfig_Stream)\r\ncreateStaticPackage(packageConfig_Character)\r\ncreateStaticPackage(packageConfig_TinyXML)\r\ncreateStaticPackage(packageConfig_vtAgeiaLib)\r\ncreateStaticPackage(packageConfig_vtAgeiaBeh)\r\n\r\n--createStaticPackage(packageConfig_vtAgeiaReader)\r\n--createStaticPackage(packageConfig_vtAgeiaInterface)\r\n\r\n\r\n\r\n--include \"CppConsoleApp\"\r\n\r\nfunction onclean()\r\n\tos.rmdir(\"vs**\")\r\nend\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Vertigo\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorVertigoDecl();\r\nCKERROR CreateVertigoProto(CKBehaviorPrototype **pproto);\r\nint Vertigo(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorVertigoDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Vertigo\");\t\r\n\tod->SetDescription(\"Creates a 'Vertigo' effect on the Camera.\");\r\n\t/* rem:\r\n\tIn: triggers the process
\r\n\tLoop In: triggers the next step in the process loop.
\r\n\t
\r\n\tOut: is activated when the process is completed.
\r\n\tLoop Out:is activated when the process needs to loop.
\r\n\t
\r\n\tFocal Point: 3D Entity that determines the constant focal plane for the camera during the effect.
\r\n\tNumber of Frames: number of frames in which the effect will be performed.
\r\n\tForward: 'True' moves the camera forward, 'False' moves it backward.
\r\n\tDistortion Amount: amount of distorsion expressed in percentage.
\r\n\tProgression Curve: progression curve along the camera Z axis.
\r\n\t
\r\n\tThis behavior creates a 'Vertigo' effect by moving the camera forward (or backward) along its Z axis while adjusting the field of view so that the objects in its focal plan remain the same size on the screen (while the others are deformed).\r\n\tTypically, this is used to produce dizziness or to increase tension before a scary event... \r\n\t*/\r\n /* warning:\r\n - As a old stuff, this building block is not time based at all. Therefore it is frame rate dependant.
\r\n */\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xb00d010a, 0xc00d010a));\r\n\t\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateVertigoProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\tod->SetCategory(\"Cameras/FX\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateVertigoProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Vertigo\");\r\n\tif(!proto) \r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Loop In\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Loop Out\");\r\n\t\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_INT,0 );//\"stepsRemaining\"\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_FLOAT );//\"projectionPlaneSize\"\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_FLOAT );//\"curveLastX\"\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_FLOAT );//\"curveDeltaX\"\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_VECTOR );//\"goingVector\"\r\n\r\n\tproto->DeclareInParameter(\"Focal Point\", CKPGUID_3DENTITY );\r\n\tproto->DeclareInParameter(\"Number of Frames\", CKPGUID_INT ,\"100\");\r\n\tproto->DeclareInParameter(\"Forward\", CKPGUID_BOOL ,\"TRUE\");\r\n\tproto->DeclareInParameter(\"Distortion Amount\", CKPGUID_PERCENTAGE ,\"50\");\r\n\tproto->DeclareInParameter(\"Progression Curve\", CKPGUID_2DCURVE );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Vertigo);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n *pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint Vertigo(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n // we get the camera entity\r\n\tCKCamera *ent = (CKCamera *) beh->GetTarget();\r\n if( !ent ) return CKBR_OWNERERROR;\r\n\t\r\n\tVxVector goingVector;\r\n\r\n\t// we get the steps remaining (local parameter)\r\n\tint stepsRemaining;\r\n\tbeh->GetLocalParameterValue(0, &stepsRemaining);\r\n\t\r\n\tif(beh->IsInputActive(0)) { // first time in a loop vertigo is launched\r\n\t\t// we get the velocity (input parameter)\r\n\t\tint nb_frame = 100;\r\n\t\tbeh->GetInputParameterValue(1, &nb_frame);\r\n\t\t\r\n\t\t// we calculate the steps remaining\r\n\t\tstepsRemaining = nb_frame;\r\n\r\n\t\t// we get the object position\r\n\t\tCK3dEntity *e = (CK3dEntity *)beh->GetInputParameterObject(0);\r\n if(!e) return CKBR_PARAMETERERROR;\r\n\r\n VxVector objectPosition;\r\n\t\te->GetPosition(&objectPosition, ent);\r\n\r\n\t\t// we get the effect value\r\n\t\tfloat effectValue = 0.5f;\r\n\t\tbeh->GetInputParameterValue(3, &effectValue);\r\n\r\n\t\t// we get the direction\r\n\t\tCKBOOL direction = TRUE;\r\n\t\tbeh->GetInputParameterValue(2, &direction);\r\n\r\n\t\t// we calculate the goingVector\r\n\t\tif(direction) { // camera -> object\r\n\t\t\tgoingVector.x = 0;\r\n\t\t\tgoingVector.y = 0;\r\n\t\t\tgoingVector.z = objectPosition.z;\r\n\t\t} else { // <- camera object\r\n\t\t\tgoingVector.x = 0;\r\n\t\t\tgoingVector.y = 0;\r\n\t\t\tgoingVector.z = -objectPosition.z;\r\n\t\t\teffectValue = effectValue/(1.0f-effectValue);\r\n\t\t}\r\n\t\tfloat D=Magnitude(goingVector);\r\n\t\tgoingVector *= effectValue;\r\n\r\n\t\t// we calculate the planeProjectionSize\r\n\t\tfloat fov=ent->GetFov();\r\n\t\tfloat planeProjectionSize;\r\n\t\tplaneProjectionSize=(float)(D*tan(fov/2.0f));\r\n\r\n\r\n\t\t// we calculate the curveDeltaX\r\n\t\tfloat curveDeltaX;\r\n\t\tcurveDeltaX = 1.0f/stepsRemaining;\r\n\r\n\t\t///////////////////////////////\r\n\t\t// writing the local parameters\r\n\r\n\t\t// writing the stepsRemaining\r\n\t\tbeh->SetLocalParameterValue(0, &stepsRemaining);\r\n\r\n\t\t// writing the planeProjectionSize\r\n\t\tbeh->SetLocalParameterValue(1, &planeProjectionSize);\r\n\r\n\t\t// writing the curveLastX\r\n\t\tfloat clx=0.0;\r\n\t\tbeh->SetLocalParameterValue(2, &clx);\r\n\r\n\t\t// writing the curveDeltaX\r\n\t\tbeh->SetLocalParameterValue(3, &curveDeltaX);\r\n\r\n\t\t// writing the goingVector\r\n\t\tbeh->SetLocalParameterValue(4, &goingVector);\r\n\r\n\t\tbeh->ActivateInput(0, FALSE);\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn CKBR_OK;\r\n\t} else { // we are in the loop\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\t///////////////////////////////\r\n\t\t// getting the input parameters\r\n\r\n\t\t// getting the 2d curve\r\n\t\tCK2dCurve *accelerationCurve = NULL;\r\n\t\tbeh->GetInputParameterValue(4,&accelerationCurve);\r\n\t\t\r\n\t\t///////////////////////////////\r\n\t\t// getting the local parameters\r\n\r\n\t\t// getting the planeProjectionSize\r\n\t\tfloat planeProjectionSize;\r\n\t\tbeh->GetLocalParameterValue(1, &planeProjectionSize);\r\n\r\n\t\t// getting the curveLastX\r\n\t\tfloat curveLastX;\r\n\t\tbeh->GetLocalParameterValue(2, &curveLastX);\r\n\r\n\t\t// getting the curveDeltaX\r\n\t\tfloat curveDeltaX;\r\n\t\tbeh->GetLocalParameterValue(3, &curveDeltaX);\r\n\r\n\t\t// getting the goingVector\r\n\t\tVxVector goingVector;\r\n\t\tbeh->GetLocalParameterValue(4, &goingVector);\r\n\r\n\t\t// calculating the deltaY of the curve\r\n\t\tfloat deltaY = accelerationCurve->GetY(curveLastX+curveDeltaX) -\r\n\t\t\t accelerationCurve->GetY(curveLastX);\r\n\r\n\t\t// translating the camera\r\n\t\tVxVector trans = goingVector * deltaY;\r\n\t\tent->Translate(&trans, ent);\r\n\r\n\t\t// calculating the new D\r\n\t\t// we get the object position\r\n\t\tCK3dEntity *e = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\tVxVector objectPosition;\r\n\t\te->GetPosition( &objectPosition, ent );\r\n\t\tfloat D = (float) fabs( objectPosition.z );\r\n\r\n\t\t// calculating the fov\r\n\t\tfloat fov = 2.0f * atanf( planeProjectionSize / D );\r\n\r\n\t\t// changing the fov\r\n\t\tent->SetFov(fov);\r\n\r\n\t\t///////////////////////////////\r\n\t\t// writing the local parameters\r\n\r\n\t\t// writing the stepsRemaining\r\n\t\tstepsRemaining--;\r\n\t\tbeh->SetLocalParameterValue(0, &stepsRemaining);\r\n\r\n\t\t// writing the curveLastX\r\n\t\tcurveLastX += curveDeltaX;\r\n\t\tbeh->SetLocalParameterValue(2, &curveLastX);\r\n\r\n\t\tif(stepsRemaining) { // vertigo not finished\r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t\treturn CKBR_OK;\r\n\t\t} else { // loop accomplished\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\t\t\r\n}\r\n#include \r\n#define STRICT\r\n#define DIRECTINPUT_VERSION 0x0800\r\n\r\n#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }\r\n#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }\r\n#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\nstatic CKContext *ctx = NULL;\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// \r\n//\r\n#define HAS_CONFIG\r\n\r\n#ifdef HAS_CONFIG\r\n#include \"gConfig.h\"\r\n#endif // BB_TOOLS\r\n\r\n#ifdef BB_TOOLS\r\n\t\r\n\t#include \r\n\t#include \"vtLogTools.h\"\r\n\t#include \"vtCBBErrorHelper.h\"\r\n\t#include \r\n\t#include \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n#endif\r\n\r\n//-----------------------------------------------------------------------------\r\n// Defines, constants, and global variables\r\n//-----------------------------------------------------------------------------\r\nstruct EFFECTS_NODE\r\n{\r\n LPDIRECTINPUTEFFECT pDIEffect;\r\n DWORD dwPlayRepeatCount;\r\n EFFECTS_NODE* pNext;\r\n};\r\n\r\nLPDIRECTINPUT8 g_pDI = NULL; \r\nLPDIRECTINPUTDEVICE8 g_pFFDevice = NULL;\r\nEFFECTS_NODE g_EffectsList;\r\n\r\nstatic bool gInitiated = false;\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function-prototypes\r\n//-----------------------------------------------------------------------------\r\nINT_PTR CALLBACK MainDialogProc( HWND, UINT, WPARAM, LPARAM );\r\nBOOL CALLBACK EnumFFDevicesCallback2( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef );\r\nBOOL CALLBACK EnumAndCreateEffectsCallback2( LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef );\r\n\r\nHRESULT InitDirectInput2( HWND hDlg );\r\nHRESULT FreeDirectInput2();\r\nVOID EmptyEffectList2();\r\nHRESULT OnReadFile2( HWND hDlg,const char*file);\r\nHRESULT OnPlayEffects2( HWND hDlg );\r\n\r\nLPDIRECTINPUTEFFECT g_pEffect = NULL;\r\nBOOL g_bActive = TRUE;\r\n\r\nDWORD g_dwNumForceFeedbackAxis = 0;\r\nINT g_nXForce;\r\nINT g_nYForce;\r\nDWORD g_dwLastEffectSet; // Time of the previous force feedback effect set\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EnumAxesCallback()\r\n// Desc: Callback function for enumerating the axes on a joystick and counting\r\n// each force feedback enabled axis\r\n//-----------------------------------------------------------------------------\r\nBOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,\r\n\t\t\t\t\t\t\t VOID* pContext )\r\n{\r\n\tDWORD* pdwNumForceFeedbackAxis = ( DWORD* )pContext;\r\n\r\n\tif( ( pdidoi->dwFlags & DIDOI_FFACTUATOR ) != 0 )\r\n\t\t( *pdwNumForceFeedbackAxis )++;\r\n\r\n\treturn DIENUM_CONTINUE;\r\n}\r\n\r\nHRESULT InitDirectInput2( HWND hDlg )\r\n{\r\n HRESULT hr;\r\n\t \r\n\tDIPROPDWORD dipdw;\r\n\r\n // Setup the g_EffectsList circular linked list\r\n ZeroMemory( &g_EffectsList, sizeof( EFFECTS_NODE ) );\r\n g_EffectsList.pNext = &g_EffectsList;\r\n\r\n // Create a DInput object\r\n if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )\r\n\t{\r\n\t\tctx->OutputToConsole(\"PlayFFE :: DirectInput8Create\");\r\n\t return hr;\r\n\t}\r\n\r\n // Get the first enumerated force feedback device\r\n if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumFFDevicesCallback2, 0, \r\n DIEDFL_ATTACHEDONLY | \r\n DIEDFL_FORCEFEEDBACK ) ) )\r\n\t{\r\n\t\tctx->OutputToConsole(\"PlayFFE :: EnumDevices failed\");\t\t\r\n\t\treturn hr;\r\n\t}\r\n\r\n \r\n if( g_pFFDevice == NULL )\r\n {\r\n\r\n\t ctx->OutputToConsole(\"PlayFFE :: No force feedback device found.\");\r\n return -1;\r\n }\r\n\r\n\r\n // Set the data format\r\n if( FAILED( hr = g_pFFDevice->SetDataFormat( &c_dfDIJoystick ) ) )\r\n return hr;\r\n\r\n\r\n // Set the coop level\r\n //hr = g_pFFDevice->SetCooperativeLevel( hDlg , DISCL_EXCLUSIVE | DISCL_FOREGROUND) ;\r\n\thr = g_pFFDevice->SetCooperativeLevel( hDlg , DISCL_EXCLUSIVE | DISCL_BACKGROUND) ;\r\n\r\n\t\r\n\r\n\t//DISCL_NONEXCLUSIVE \r\n\r\n\t// Since we will be playing force feedback effects, we should disable the\r\n\t// auto-centering spring.\r\n\tdipdw.diph.dwSize = sizeof( DIPROPDWORD );\r\n\tdipdw.diph.dwHeaderSize = sizeof( DIPROPHEADER );\r\n\tdipdw.diph.dwObj = 0;\r\n\tdipdw.diph.dwHow = DIPH_DEVICE;\r\n\tdipdw.dwData = FALSE;\r\n\r\n\tif( FAILED( hr = g_pFFDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph ) ) )\r\n\t\treturn hr;\r\n\r\n\t// Enumerate and count the axes of the joystick \r\n\tif( FAILED( hr = g_pFFDevice->EnumObjects( EnumAxesCallback,\r\n\t\t( VOID* )&g_dwNumForceFeedbackAxis, DIDFT_AXIS ) ) )\r\n\t\treturn hr;\r\n\r\n\r\n\t// This simple sample only supports one or two axis joysticks\r\n\tif( g_dwNumForceFeedbackAxis > 2 )\r\n\t\tg_dwNumForceFeedbackAxis = 2;\r\n\r\n\t// This application needs only one effect: Applying raw forces.\r\n\tDWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y };\r\n\tLONG rglDirection[2] = { 0,0 };\r\n\tDICONSTANTFORCE cf = { 0 };\r\n\tcf.lMagnitude = 0;\r\n\r\n\r\n\tDIEFFECT eff;\r\n\tZeroMemory( &eff, sizeof( eff ) );\r\n\teff.dwSize = sizeof( DIEFFECT );\r\n\teff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;\r\n\teff.dwDuration = INFINITE;\r\n\teff.dwSamplePeriod = 0;\r\n\teff.dwGain = DI_FFNOMINALMAX;\r\n\teff.dwTriggerButton = DIEB_NOTRIGGER;\r\n\teff.dwTriggerRepeatInterval = 0;\r\n\teff.cAxes = g_dwNumForceFeedbackAxis;\r\n\teff.rgdwAxes = rgdwAxes;\r\n\teff.rglDirection = rglDirection;\r\n\teff.lpEnvelope = 0;\r\n\teff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );\r\n\teff.lpvTypeSpecificParams = &cf;\r\n\teff.dwStartDelay = 0;\r\n\t\r\n\t// Create the prepared effect\r\n\tif( FAILED( hr = g_pFFDevice->CreateEffect( GUID_ConstantForce,\r\n\t\t&eff, &g_pEffect, NULL ) ) )\r\n\t{\r\n\t\treturn hr;\r\n\t}\r\n\r\n\tif( NULL == g_pEffect )\r\n\t\treturn E_FAIL;\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EnumFFDevicesCallback2()\r\n// Desc: Get the first enumerated force feedback device\r\n//-----------------------------------------------------------------------------\r\nBOOL CALLBACK EnumFFDevicesCallback2( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef )\r\n{\r\n if( FAILED( g_pDI->CreateDevice( pDDI->guidInstance, &g_pFFDevice, NULL ) ) )\r\n return DIENUM_CONTINUE; // If failed, try again\r\n\r\n // Stop when a device was successfully found\r\n return DIENUM_STOP;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: FreeDirectInput2()\r\n// Desc: Initialize the DirectInput variables.\r\n//-----------------------------------------------------------------------------\r\nHRESULT FreeDirectInput2()\r\n{\r\n // Release any DirectInputEffect objects.\r\n if( g_pFFDevice ) \r\n {\r\n EmptyEffectList2();\r\n g_pFFDevice->Unacquire();\r\n SAFE_RELEASE( g_pFFDevice );\r\n }\r\n\r\n // Release any DirectInput objects.\r\n SAFE_RELEASE( g_pDI );\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EmptyEffectList2()\r\n// Desc: Goes through the circular linked list and releases the effects, \r\n// and deletes the nodes\r\n//-----------------------------------------------------------------------------\r\nVOID EmptyEffectList2()\r\n{\r\n EFFECTS_NODE* pEffectNode = g_EffectsList.pNext;\r\n EFFECTS_NODE* pEffectDelete;\r\n\r\n while ( pEffectNode != &g_EffectsList )\r\n {\r\n pEffectDelete = pEffectNode; \r\n pEffectNode = pEffectNode->pNext;\r\n\r\n SAFE_RELEASE( pEffectDelete->pDIEffect );\r\n SAFE_DELETE( pEffectDelete );\r\n }\r\n\r\n g_EffectsList.pNext = &g_EffectsList;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: OnReadFile2()\r\n// Desc: Reads a file contain a collection of DirectInput force feedback \r\n// effects. It creates each of effect read in and stores it \r\n// in the linked list, g_EffectsList.\r\n//-----------------------------------------------------------------------------\r\nHRESULT OnReadFile2( HWND hDlg,const char*file)\r\n{\r\n HRESULT hr;\r\n\r\n EmptyEffectList2();\r\n\r\n // Enumerate the effects in the file selected, and create them in the callback\r\n if( FAILED( hr = g_pFFDevice->EnumEffectsInFile( file,EnumAndCreateEffectsCallback2, \r\n NULL, DIFEF_MODIFYIFNEEDED ) ) )\r\n return hr;\r\n\r\n // If list of effects is empty, then we haven't been able to create any effects\r\n if( g_EffectsList.pNext == &g_EffectsList )\r\n {\r\n\t\tctx->OutputToConsole(\"Unable to create any effects.\");\r\n\r\n }\r\n else\r\n {\r\n // We have effects so enable the 'play effects' button\r\n\r\n }\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\nBOOL CALLBACK EnumAndCreateEffectsCallback2(LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef )\r\n{ \r\n HRESULT hr;\r\n LPDIRECTINPUTEFFECT pDIEffect = NULL;\r\n\r\n // Create the file effect\r\n if( FAILED( hr = g_pFFDevice->CreateEffect( pDIFileEffect->GuidEffect, \r\n pDIFileEffect->lpDiEffect, \r\n &pDIEffect, NULL ) ) )\r\n {\r\n ctx->OutputToConsole(\"Could not create force feedback effect on this device\");\r\n return DIENUM_CONTINUE;\r\n }\r\n\r\n // Create a new effect node\r\n EFFECTS_NODE* pEffectNode = new EFFECTS_NODE;\r\n if( NULL == pEffectNode )\r\n return DIENUM_STOP;\r\n\r\n // Fill the pEffectNode up\r\n ZeroMemory( pEffectNode, sizeof( EFFECTS_NODE ) );\r\n pEffectNode->pDIEffect = pDIEffect;\r\n pEffectNode->dwPlayRepeatCount = 1;\r\n\r\n // Add pEffectNode to the circular linked list, g_EffectsList\r\n pEffectNode->pNext = g_EffectsList.pNext;\r\n g_EffectsList.pNext = pEffectNode;\r\n\r\n return DIENUM_CONTINUE;\r\n}\r\n\r\n\r\n\r\n\r\nHRESULT OnPlayEffects2( HWND hDlg )\r\n{\r\n EFFECTS_NODE* pEffectNode = g_EffectsList.pNext;\r\n LPDIRECTINPUTEFFECT pDIEffect = NULL;\r\n HRESULT hr;\r\n\r\n // Stop all previous forces\r\n if( FAILED( hr = g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL ) ) )\r\n return hr;\r\n\r\n\t\r\n while ( pEffectNode != &g_EffectsList )\r\n {\r\n // Play all of the effects enumerated in the file \r\n pDIEffect = pEffectNode->pDIEffect;\r\n\r\n if( NULL != pDIEffect )\r\n {\r\n if( FAILED( hr = pDIEffect->Start( pEffectNode->dwPlayRepeatCount, 0 ) ) )\r\n return hr;\r\n }\r\n\r\n pEffectNode = pEffectNode->pNext;\r\n }\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJSetXYForceDecl();\r\nCKERROR CreateJSetXYForceProto(CKBehaviorPrototype **);\r\nint JSetXYForce(const CKBehaviorContext& behcontext);\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext);\r\nCKObjectDeclaration\t*FillBehaviorJSetXYForceDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"JSetXYForce\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6890534f,0x31c12074));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJSetXYForceProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Joystick\");\r\n\treturn od;\r\n}\r\n\r\n\r\n\r\nenum bbIO_Inputs\r\n{\r\n\tBB_I_DO,\r\n\tBB_I_RELEASE,\r\n};\r\n\r\nenum bbIO_Outputs\r\n{\r\n\tBB_O_DONE,\r\n\tBB_O_RELEASED,\r\n\tBB_O_ERROR,\r\n};\r\nCKERROR CreateJSetXYForceProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"JSetXYForce\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\t//proto->DeclareInput(\"stop\");\r\n\tproto->DeclareInput(\"release device\");\r\n\t\r\n\tproto->DeclareOutput(\"Done\");\r\n\t//proto->DeclareOutput(\"Stopped\");\r\n\tproto->DeclareOutput(\"Released\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Force Vector\",CKPGUID_2DVECTOR);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( JSetXYForce );\r\n\r\n\tproto->SetBehaviorCallbackFct(PlayFFECallBackObject);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nHRESULT SetDeviceForcesXY(float x,float y)\r\n{\r\n\t// Modifying an effect is basically the same as creating a new one, except\r\n\t// you need only specify the parameters you are modifying\r\n\tLONG rglDirection[2] = { 0, 0 };\r\n\r\n\tDICONSTANTFORCE cf;\r\n\r\n\tif( g_dwNumForceFeedbackAxis == 1 )\r\n\t{\r\n\t\t// If only one force feedback axis, then apply only one direction and \r\n\t\t// keep the direction at zero\r\n\t\tcf.lMagnitude = x;\r\n\t\trglDirection[0] = 0;\r\n\t}\r\n\telse\r\n\t{\r\n\t\t// If two force feedback axis, then apply magnitude from both directions \r\n\t\trglDirection[0] = x;\r\n\t\trglDirection[1] = y;\r\n\t\tcf.lMagnitude = ( DWORD )sqrt( x * x + y * y );\r\n\r\n\t}\r\n\r\n\tDIEFFECT eff;\r\n\tZeroMemory( &eff, sizeof( eff ) );\r\n\teff.dwSize = sizeof( DIEFFECT );\r\n\teff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;\r\n\teff.cAxes = g_dwNumForceFeedbackAxis;\r\n\teff.rglDirection = rglDirection;\r\n\teff.lpEnvelope = 0;\r\n\teff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );\r\n\teff.lpvTypeSpecificParams = &cf;\r\n\teff.dwStartDelay = 0;\r\n\r\n\t// Now set the new parameters and start the effect immediately.\r\n\tHRESULT hr = S_OK;\r\n\t\r\n\thr = g_pEffect->SetParameters( &eff, DIEP_DIRECTION |DIEP_TYPESPECIFICPARAMS |DIEP_START );\r\n\tHRESULT a1 = DIERR_INVALIDPARAM;\r\n\t\r\n\r\n\r\n\treturn hr;\r\n}\r\n\r\n\r\nint JSetXYForce(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx2 = behcontext.Context;\r\n\tif (!ctx)\r\n\t{\r\n\t\tctx = ctx2;\r\n\t}\r\n\t\r\n\tHWND mWin = (HWND )ctx->GetMainWindow();\r\n\tHRESULT hr = S_OK;\r\n\r\n\r\n\t//init and load effect\r\n\tif( beh->IsInputActive(BB_I_DO) )\r\n\t{\r\n\t\tbeh->ActivateInput(BB_I_DO,FALSE);\r\n\t\tif (!gInitiated)\r\n\t\t{\r\n\t\t\tif (!InitDirectInput2(mWin) == S_OK)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(BB_O_ERROR);\r\n\t\t\t\treturn CKBR_OK;\r\n\t\t\t}else{\r\n\r\n\t\t\t\thr = g_pFFDevice->Acquire();\r\n\t\t\t\thr =g_pEffect->Start( 1, 0 ); // Start the effect\r\n//\t\t\t\tE_ACCESSDENIED\r\n\r\n\t\t\t\tgInitiated = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tVx2DVector vectorForce;\r\n\t\tbeh->GetInputParameterValue(0,&vectorForce);\r\n\t\t\r\n\t\t\r\n\r\n\t\tSetDeviceForcesXY(vectorForce.x,vectorForce.y);\r\n\t\tbeh->ActivateOutput(BB_O_DONE);\r\n\t}\r\n\r\n\r\n\t//play\r\n\r\n\tif( beh->IsInputActive(BB_I_RELEASE))\r\n\t{\r\n\t\tbeh->ActivateInput(BB_I_RELEASE,FALSE);\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(BB_I_RELEASE);\r\n\t\t\tFreeDirectInput2();\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/*\r\n\t//stop the effect\r\n\tif( beh->IsInputActive(2) ){\r\n\t\tbeh->ActivateInput(2,FALSE);\r\n\r\n\t\t//g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn CKBR_OK;\r\n\t}*/\r\n\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORDETACH:\r\n\tcase CKM_BEHAVIORRESET:\r\n\t{\r\n\t\t\r\n\t\t\r\n\t\tgInitiated = false;\r\n\t\t\tif ( g_pFFDevice)\r\n\t\t\t\tg_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\t\tFreeDirectInput2();\r\n\r\n\t\t\t//Sleep(2000);\r\n\t\t\t\r\n\r\n\t}\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn CKBR_OK; \r\n}\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n\r\n\r\n#include \"ISession.h\"\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xMessageTypes.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDODistributedObjectCreatedDecl();\r\nCKERROR CreateDODistributedObjectCreatedProto(CKBehaviorPrototype **);\r\nint DODistributedObjectCreated(const CKBehaviorContext& behcontext);\r\nCKERROR DODistributedObjectCreatedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDODistributedObjectCreatedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOCreated\");\t\r\n\tod->SetDescription(\"Creates an distributed object\");\r\n\t\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x778b6a11,0x29892907));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDODistributedObjectCreatedProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\nenum bbIn\r\n{\r\n\r\n\tbbI_ON,\r\n\tbbI_OFF,\r\n\tbbI_NEXT\r\n};\r\n\r\nenum bbOut\r\n{\r\n\tBB_O_ON,\r\n\tBB_O_OFF,\r\n\tBB_O_OBJECT,\r\n\tBB_O_ERROR\r\n};\r\n\r\nenum bbPO_TIME\r\n{\r\n\tBB_OP_TIME,\r\n\tBB_OP_NAME,\r\n\tBB_OP_OID,\r\n\tBB_OP_UID,\r\n\tBB_OP_ERROR\r\n};\r\n\r\n\r\nCKERROR CreateDODistributedObjectCreatedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOCreated\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareInput(\"Next\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"Object\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Distributed Object Creation Time\", CKPGUID_TIME, \"0\");\r\n\tproto->DeclareOutParameter(\"Object Name\", CKPGUID_STRING, \"0\");\r\n\tproto->DeclareOutParameter(\"Distributed Object ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Owner ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\tproto->DeclareSetting(\"Class\", CKPGUID_STRING, \"My3DClass\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DODistributedObjectCreated);\r\n\tproto->SetBehaviorCallbackFct(DODistributedObjectCreatedCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DODistributedObjectCreated(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\t//we come in by input off : \r\n\tif (beh->IsInputActive(bbI_OFF))\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_OFF,FALSE);\r\n\t\tbeh->ActivateOutput(BB_O_OFF);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//we come in by input off : \r\n\tif (beh->IsInputActive(bbI_ON))\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_ON,FALSE);\r\n\t\tbeh->ActivateOutput(BB_O_ON);\r\n//\t\treturn 0;\r\n\t}\r\n\r\n\r\n\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\t\t\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tXString name(dobj->GetName().getString()); \r\n\r\n\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t{\r\n\t\t\t\t\t//we only output objects created by remote side :\r\n\t\t\t\t\tif (dobj->getUserID() != cin->getConnection()->getUserID() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tDWORD iFlags = dobj->getInterfaceFlags();\r\n\t\t\t\t\t\tif (!isFlagOn(dobj->getObjectStateFlags(),E_DOSF_SHOWN) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//output do's creation time\r\n\t\t\t\t\t\t\tenableFlag(dobj->getObjectStateFlags(),E_DOSF_SHOWN);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_TIME,dobj->getCreationTime()/1000.0f);\r\n\r\n\t\t\t\t\t\t\t//output do's name \r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_NAME,const_cast(dobj->GetName().getString()));\r\n\r\n\t\t \r\n\t\t\t\t\t\t\t//output do's network id \r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_OID,dobj->getServerID());\r\n\r\n\t\t\t\t\t\t\t//output do's network id \r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_UID,dobj->getUserID());\r\n\r\n\r\n\t\t\t\t\t\t\tbbNoError(E_NWE_OK);\r\n\t\t\t\t\t\t\tbeh->ActivateOutput(BB_O_OBJECT);\r\n\t\t\t\t\t\t\tdobj->setInterfaceFlags(E_DO_PROCESSED);\r\n\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"DObject created\");\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR DODistributedObjectCreatedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\t\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"xDistributedRect.h\"\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBAddShapeDecl();\r\nCKERROR CreatePBAddShapeProto(CKBehaviorPrototype **pproto);\r\nint PBAddShape(const CKBehaviorContext& behcontext);\r\nCKERROR PBAddShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBAddShapeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBAddShape\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Adds a sub shape given by a mesh or a reference object.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x55c61f90,0x2e512638));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBAddShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBAddShapeProto\r\n// FullName: CreatePBAddShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Mesh=0,\r\n\tbbI_PObject,\r\n\tbbI_Pos,\r\n\tbbI_Rot,\r\n\tbbI_Ref,\r\n\tbbI_Density,\r\n\tbbI_TotalMass,\r\n};\r\n\r\nCKERROR CreatePBAddShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBAddShape\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*\r\n\tPBAddShape \r\n\tPBAddShape is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAdds a sub shape. See also pRigidBody::addSubShape()\r\n\t.
\r\n\tSee PBAddShape.cmo for example.\r\n\t

Technical Information

\r\n\r\n\t\\image html PBAddShape.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\r\n\r\n\tTarget:The 3D Entity associated to the rigid body.
\r\n\r\n\tMesh:The mesh reference. If null then it’s using the current mesh of the reference 3D-entity object.
\r\n\t\r\n\tPhysic Properties: The hull type, new density and/or total mass are used only. You can overwrite these values if the source mesh or the reference object has a physic attribute.
\r\n\r\n\tLocal Position: Local position in the bodies’ space. This parameter is used when \r\n\r\n\tmesh !=null AND reference 3D-entity = null
\r\n\r\n\r\n\tLocal Orientation: Local rotation in the bodies’ space. This parameter is used when :\r\n\r\n\tMesh !=null AND reference 3D-entity = null
\r\n\r\n\tReference: If mesh != null and reference !=null ,then its adding the shape and using the reference only as transformation helper.\r\n\r\n\tIf mesh = null and reference !=null, then its adding reference’s current mesh. In that, the function will try to get the hull type from objects attribute. If there is no attribute, then it’s using the building blocks physic properties parameter.\r\n\r\n\r\n\t
\r\n\t

Note

\r\n\t\r\n\tPhysic Material Lookup: (it’s looking for the physic material attribute on the objects listed below)\r\n\t\r\n\t- Materials lookup order for the case reference is null AND mesh is not null : \r\n\t\t- mesh \r\n\t\t- mesh’s material (index = 0) \r\n\r\n\t- Materials lookup order for the case mesh is null AND reference is not null : \r\n\t\t-\treference object \r\n\t\t-\treference’s current mesh’s material (index = 0 ) \r\n\r\n\t- Materials lookup order for the case mesh is not null AND reference is not null: \r\n\t\t-\tmesh \r\n\t\t-\tmesh’s material (index = 0) \r\n\t\t-\treference’s current mesh’s material (index = 0 ) \r\n\r\n\r\n\tWhen it couldn’t find any material attribute until now, it’s using the target’s body material. This material is chosen or even created during the registration (\\ref PBPhysicalize).\r\n\tHere the lookup order during the registration of an entity in the physic engine: \r\n\t-\tentity\r\n\t-\tentity current mesh\r\n\t-\tentity current mesh’s material ( index = 0 )\r\n\t\r\n\tIf no material specified, it fails back the the holding world’s material ( retrieved from PhysicDefaults.xml/Default ) \r\n\r\n\r\n\t

Note


\r\n\t
\r\n\r\n\tYou can execute this function multiple times. \r\n\t\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager
\r\n\r\n\t\r\n\r\n\t*/\r\n\t\r\n\tproto->DeclareInParameter(\"Mesh\",CKPGUID_MESH);\r\n\tproto->DeclareInParameter(\"Physic Properties\",VTS_PHYSIC_PARAMETER);\r\n\tproto->DeclareInParameter(\"Local Position\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Local Rotation\",CKPGUID_QUATERNION);\r\n\tproto->DeclareInParameter(\"Reference\",CKPGUID_3DENTITY);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBAddShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddShape\r\n// FullName: PBAddShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBAddShape(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(!result)\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\tCKMesh *mesh = (CKMesh*)GetInputParameterValue(beh,bbI_Mesh);\r\n\t\tVxVector pos = GetInputParameterValue(beh,bbI_Pos);\r\n\t\tVxQuaternion rot = GetInputParameterValue(beh,bbI_Rot);\r\n\t\tpObjectDescr *descr = pFactory::Instance()->createPObjectDescrFromParameter(beh->GetInputParameter(bbI_PObject)->GetRealSource());\r\n\t\tCK3dEntity *ref = (CK3dEntity*)GetInputParameterValue(beh,bbI_Ref);\r\n\t\t//float density = GetInputParameterValue(beh,bbI_Density);\r\n\t\t//float totalMass = GetInputParameterValue(beh,bbI_TotalMass);\r\n\r\n\t\tresult->addSubShape(mesh,*descr,ref,pos,rot);\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddShapeCB\r\n// FullName: PBAddShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBAddShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPManagerDecl();\r\nCKERROR CreatePManagerProto(CKBehaviorPrototype **pproto);\r\nint PManager(const CKBehaviorContext& behcontext);\r\nCKERROR PManagerCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_ReloadXML,\r\n};\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMapM[] =\r\n{\r\n\r\n\r\n\tBB_SPIN(bbI_ReloadXML,CKPGUID_STRING,\"XML File\",\"None\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMapM\r\n\r\n//************************************\r\n// Method: FillBehaviorPManagerDecl\r\n// FullName: FillBehaviorPManagerDecl\r\n// Access: public\r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPManagerDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PManager\");\r\n\tod->SetCategory(\"Physic/Manager\");\r\n\tod->SetDescription(\"Calls various functions in the manager.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x57295d90,0x11da3970));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePManagerProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePManagerProto\r\n// FullName: CreatePManagerProto\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePManagerProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PManager\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PManagerCB );\r\n\r\n\tBB_EVALUATE_SETTINGS(gPIMAP)\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PManager);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PManager\r\n// FullName: PManager\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PManager(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/************************************************************************/\r\n\t\tBBSParameter(bbI_ReloadXML);\r\n\t\t\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve values */\r\n\t\t/************************************************************************/\r\n\r\n\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\tload some settings from XML\r\n\t\tif(sbbI_ReloadXML)\r\n\t\t{\r\n\t\t\tCKSTRING xmlFile = GetInputParameterValue(beh,BB_IP_INDEX(bbI_ReloadXML));\r\n\t\t\tpFactory::Instance()->reloadConfig(xmlFile);\r\n\r\n\t\t}\r\n\r\n\t\t\r\n\t\r\n\r\n\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PManagerCB\r\n// FullName: PManagerCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PManagerCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#ifndef _PhysicManager_H\r\n#define _PhysicManager_H\r\n\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"CKPhysicsManager.h\"\r\n#include \"pManagerTypes.h\"\r\n\r\n#include \"pWorldTypes.h\"\r\n\r\nclass xTime;\r\n\r\n/**\r\n\\brief PhysicManager is a Virtools manager and acts as singleton object. \r\n\r\nIts responsible for :\r\n\r\n-\tmaintaining of multiple worlds and all other physic objects\r\n-\tproviding quick access to physic objects beyond the world boundaries\r\n-\tholding default parameters\r\n\r\n*/\r\nclass MODULE_API PhysicManager : public CKPhysicManager\r\n{\r\n\r\npublic:\r\n\r\n\tint sceneWasChanged;\r\n\tvoid _removeObjectsFromOldScene(CKScene *lastScene);\r\n\tCKScene* _isSceneObject(CK3dEntity *object);\r\n\tvoid _registerNewScene(CKScene*newScene);\r\n\r\n\tJointFeedbackListType m_JointFeedbackList;\r\n\tJointFeedbackListType& getJointFeedbackList() { return m_JointFeedbackList; }\r\n\tvoid setJointFeedbackList(JointFeedbackListType val) { m_JointFeedbackList = val; }\r\n\r\n\tvoid _cleanOrphanedJoints();\r\n\r\n\tint physicFlags;\r\n\tint getPhysicFlags() const { return physicFlags; }\r\n\tvoid setPhysicFlags(int val) { physicFlags = val; }\r\n\r\n\tpTriggerArray mTriggers;\r\n\tpTriggerArray& getTriggers() { return mTriggers; }\r\n\r\n\tvoid _cleanTriggers();\r\n\r\n\tpBodyList bodyListRemove;\r\n\tint _checkRemovalList();\r\n\tpBodyList &getRemovalList(){ return bodyListRemove;}\r\n\r\n\tpBodyList bodyListCheck;\r\n\tint _checkListCheck();\r\n\tpBodyList &getCheckList(){ return bodyListCheck;}\r\n\r\n\r\n\tvoid copyToAttributes(pObjectDescr src,CK3dEntity *dst);\r\n\txTime *time;\r\n\tbool disablePhysics;\r\n\tbool checkPhysics;\r\n\r\n\tbool m_IsSimulating;\r\n\r\n\tpBodyList resetList;\r\n\tpBodyList& _getResetList(){return resetList;}\r\n\r\n\tpRestoreMap *restoreMap;\r\n\tpRestoreMap* _getRestoreMap();\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Friends\r\n\t//\r\n\tbool checkCallbackSignature(CKBehavior *beh,int type,XString& errMessage);\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Constructors,initialization,registration\r\n\t//\r\n\r\n\tXString m_LastLogEntry;\r\n\tXString GetLastLogEntry() const { return m_LastLogEntry; }\r\n\tvoid SetLastLogEntry(XString val) { m_LastLogEntry = val; }\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Constructors\r\n\t//\r\n\tPhysicManager(CKContext* ctx);\r\n\tvoid _construct(xBitSet flags = 0 );\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Initialization\r\n\t//\r\n\tint initPhysicEngine(int flags = 0);\r\n\tint initManager(int flags=0);\r\n\tint performInitialization();\r\n\r\n\tvoid _initResources(int flags);\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t//\tRegistration of attributes, custom structures, custom \r\n\t//\tenumeration and related\r\n\t//\r\n\tvoid _registerWatchers(CKContext*context);//not used\r\n\tvoid _unregisterWatchers();// not used\r\n\r\n\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Attaches functions per object type. Most \r\n\t//\ttypes are registered by attributes.\r\n\t//\r\n\tvoid _RegisterAttributeCallbacks();\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Registration of attribute types\r\n\t//\r\n\tvoid _RegisterAttributes();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Attribute help functions\r\n\t//\r\n\tint getAttributeTypeByGuid(CKGUID guid);\r\n\tint GetPAttribute(){ return att_physic_object;}\r\n\tint GetSSAttribute(){ return att_sleep_settings;}\r\n \r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Help function, not been used yet.\r\n\t//\tStub\r\n\tvoid registerCustomAttribute(XString attributeName,int attributeType);\r\n\r\n\r\n\ttypedef int (*ObjectConstructorFunction)(PhysicManager*, CK3dEntity*,int);\r\n\tvoid registerObjectByAttributeFunction(CK3dEntity *ent,int attributeID,ObjectRegisterFunction cFunc);\r\n\r\n\tAttributeFunctionArrayType& getAttributeFunctions() { return mAttributeFunctions; }\r\n\tvoid setAttributeFunctions(AttributeFunctionArrayType val) { mAttributeFunctions = val; }\r\n\r\n\tObjectRegisterFunction getAttributeFunction(CKGUID attributeParameterGuid);\r\n\r\n\tvoid populateAttributeFunctions();\r\n\tvoid cleanAttributePostObjects();\r\n\t\t\r\n\tAttributeFunctionArrayType mAttributeFunctions;\r\n\tPostRegistrationArrayType mPostCleanAttributeObjects;\r\n\tCustomParametersArrayType mCustomStructures;\r\n\t\r\n\tCustomParametersArrayType& _getCustomStructures() { return mCustomStructures; }\r\n\tvoid setCustomStructures(CustomParametersArrayType val) { mCustomStructures = val; }\r\n\r\n\r\n\r\n\tPostRegistrationArrayType& getAttributePostObjects() { return mPostCleanAttributeObjects; }\r\n\tvoid setAttributePostObjects(PostRegistrationArrayType val) { mPostCleanAttributeObjects = val; }\r\n\r\n\r\n\tObjectRegistration* getRegistrationTable();\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Registers all custom parameter, enumeration.\r\n\t//\r\n\tvoid _RegisterParameters();\r\n\t\tvoid _RegisterJointParameters();\r\n\t\tvoid _RegisterBodyParameters();\r\n\t\tvoid _RegisterBodyParameterFunctions();\r\n\t\tvoid _RegisterVehicleParameters();\r\n\t\tvoid _RegisterWorldParameters();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Help functions to register customer enumerations which\r\n\t//\tare changed by xml files. OnCKReset for instance, the default \r\n\t//\txml file will be re-parsed and the enumerations become update.\r\n\t//\r\n\t//\r\n\tvoid _RegisterDynamicParameters();\r\n\tvoid _RegisterDynamicEnumeration(XString file,XString enumerationName,CKGUID enumerationGuid,PFEnumStringFunction enumFunc,BOOL hidden);\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Parameter operations \r\n\t//\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Registers all parameter operations at once.\r\n\t//\r\n\tvoid _RegisterParameterOperations();\r\n\t\tvoid _RegisterParameterOperationsBody();\r\n\t\tvoid _RegisterParameterOperationsJoint();\r\n\t\tvoid _RegisterParameterOperationsMisc();\r\n\t\tvoid _RegisterParameterOperationsVehicle();\r\n\t\tvoid _RegisterParameterOperationsCollision();\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t//\tVSL Support\r\n\t//\r\n\tvoid _RegisterVSL();\r\n\tvoid _RegisterVSLCommon();\r\n\tvoid _RegisterVSLJoint();\r\n\tvoid _RegisterVSLRigidBody();\r\n\tvoid _RegisterVSLVehicle();\r\n\tvoid _RegisterVSLCloth();\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief The fluid SDK is not finished and is intended as \r\n\t//\tadditional component. \r\n\t\r\n#ifdef HAS_FLUID\r\n\tvoid _RegisterFluid_VSL();\r\n#endif \r\n\t\r\n\t\r\n\t\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Hooking building blocks, adds settings to built-in building blocks.\r\n\t//\r\n\tCKERROR _Hook3DBBs();\r\n\tCKERROR _HookGenericBBs();\r\n\tCKERROR _UnHookGenericBBs();\r\n\tCKERROR _UnHook3DBBs();\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Destruction\r\n\t//\r\n\t~PhysicManager();\t\r\n\tvoid _destruct(xBitSet flags = 0);\r\n\tvoid _UnRegister(xBitSet flags=0);\r\n\tvoid _UnRegisterAttributeCallbacks(xBitSet flags=0);\r\n\tvoid _UnRegisterParameters(xBitSet flags=0);\r\n\tvoid cleanAll();\r\n\tvoid destroyWorlds();\r\n\t\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Settings\r\n\t//\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief XML related help functions\r\n\t//\r\n\tvoid reloadXMLDefaultFile(const char*fName);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Flags to track the state of the manager. \r\n\t//\r\n\r\n\t\r\n\txBitSet& _getManagerFlags() { return mManagerFlags; }\r\n\tvoid _setManagerFlags(xBitSet val) { mManagerFlags = val; }\r\n\tbool isValid();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Common parameters for a world (NXScene) \r\n\t//\r\n\tpWorldSettings * getDefaultWorldSettings(){ return mDefaultWorldSettings; }\r\n\tvoid setDefaultWorldSettings(pWorldSettings * val) { mDefaultWorldSettings = val; }\r\n\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Dongle related functions and members\r\n\t//\r\n\tXString _getConfigPath();\r\n\tint DongleHasBasicVersion;\r\n\tint DongleHasAdvancedVersion;\r\n\r\n\tstatic void makeDongleTest();\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Periodic functions, called by frame. \r\n\t//\r\n\r\n\r\n\tvoid checkWorldsByType(CKGUID attributeParameterType);\r\n\t\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// Misc functions\r\n\t//\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief Logging\r\n\t//\r\n\tpLogger* getLogger(){ return mLogger; }\r\n\tvoid setLogger(pLogger* val) { mLogger = val; }\r\n\tvoid enableLogLevel(int type,int verbosity,int value);\r\n\r\n\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// PhysX related helpers \r\n\t//\r\n\t\r\n\tNxPhysicsSDK* getPhysicsSDK(){ return mPhysicsSDK; }\r\n\tvoid setPhysicsSDK(NxPhysicsSDK* val) { mPhysicsSDK = val; }\r\n\r\n\tint getHWVersion();\r\n\tint getNbPPUs();\r\n\tint getInternalVersion(int& apiRev, int& descRev, int& branchId);\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Object helpers\r\n\t//\r\n\r\n\tint getNbObjects(int flags =0);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//! \\brief World related \r\n\r\n\r\n\tpWorldMap* getWorlds(){ return m_Worlds; }\r\n\tpWorld *getWorld(CK_ID _o);\r\n\tpWorld *getWorld(CK3dEntity *_o,CK3dEntity *body=NULL);\r\n\tpWorld *getWorld(int index =0);\r\n\r\n\tpVehicle* getVehicle(CK3dEntity*bodyReference);\r\n\tpWheel2* getWheel(CK3dEntity*wheelReference);\r\n\r\n\r\n\tpWorld *getWorldByBody(CK3dEntity*ent);\r\n\tpWorld *getWorldByShapeReference(CK3dEntity *shapeReference);\r\n\r\n\tint getNbWorlds();\r\n\tvoid deleteWorld(CK_ID _o);\r\n\t\r\n\r\n\tvoid setWorlds(pWorldMap *val) { m_Worlds = val; }\r\n\r\n\tfloat timer;\r\n\tvoid advanceTime(float time);\r\n\r\n\tpWorld * getDefaultWorld() { return m_DefaultWorld; }\r\n\tvoid setDefaultWorld(pWorld * val) { m_DefaultWorld = val; }\r\n\r\n\r\n\t\r\n\t/************************************************************************************************/\r\n\t/** @name Joints\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief Finds a joint object within all existing worlds, identified by two references and its type.\r\n\t\r\n\t\\param[in] CK3dEntity * referenceA , r: the first object participating in the constraint. This argument must be non-zero.
\r\n\t\t-\tRange: [object range)
\r\n\t\t-\tDefault: NULL
\r\n\r\n\t\\param[in] CK3dEntity * referenceB , r: the second object participating in the constraint. This can be NULL because joint constraints can be created between a rigid body and the global world frame.
\r\n\t\t-\tRange: [object range)
\r\n\t\t-\tDefault: NULL
\r\n\t\r\n\t\\param[in] JType type, r:\tan additional hint to find the right joint object. Notice that one rigid body can have 1:n joints so it makes sense to pass the type to this function. By default its returning the first found joint on the given reference objects.
\r\n\t\t-\tRange: [joint type range)
\r\n\t\t-\tDefault: #JT_Any
\r\n\r\n\t\\return pJoint*\r\n\t\r\n\t@see deleteJoint()\r\n\t*/\r\n\tpJoint*getJoint(CK3dEntity*referenceA,CK3dEntity*referenceB=NULL,JType type=JT_Any);\r\n\r\n\r\n\t/**\r\n\t\\if internal2\r\n\t\t\r\n\t\t\\brief Checks 3D entities for attached joint attributes. If so, its registering the new constraint. \r\n\r\n\t\t\\return void\r\n\r\n\t\\endif \r\n\t*/\r\n\tvoid _checkObjectsByAttribute(CKScene *newScene = NULL);\r\n\tint _checkResetList();\r\n\r\n\t//@}\r\n\r\n\tvoid checkWorlds();\r\n\tvoid checkClothes();\r\n\t\r\n\tvoid checkBodies();\r\n\r\n\tvoid _RegisterObjectsByAttribute();\r\n\r\n\r\n\t\r\n\tvoid createWorlds(int flags);\r\n\tvoid destroy();\r\n\tBOOL checkDemo(CK3dEntity*);\r\n\r\n\r\n\r\n\tpFactory * getCurrentFactory(){ return m_currentFactory; }\r\n\tvoid setCurrentFactory(pFactory * val) { m_currentFactory = val; }\r\n\t\r\n\r\n\t/************************************************************************/\r\n\t/* xml document access */\r\n\t/************************************************************************/\r\n\r\n\tTiXmlDocument* loadDefaults(XString filename);\r\n\tTiXmlDocument* getDefaultConfig() const { return m_DefaultDocument; }\r\n\tvoid setDefaultConfig(TiXmlDocument* val) { m_DefaultDocument = val; }\r\n\r\n\t/************************************************************************/\r\n\t/* RigidBody */\r\n\t/************************************************************************/\r\n\t\r\n\tpRigidBody *getBody(CK3dEntity*ent,bool lookInSubshapes=false);\r\n\tpRigidBody *getBody(CK3dEntity*ent,pWorld* world);\r\n\tpRigidBody *getBody(const char*name,int flags=0);\r\n\tNxShape *getSubShape(CK3dEntity*referenceObject);\r\n\r\n\t/**\r\n\t\\brief Returns the givens entity's rigid body object to which the sub shape belongs to.\r\n\r\n\t\\param[in] CK3dEntity * ent ,the entity r: This argument must be non-zero.
\r\n\t-\tRange: [object range)
\r\n\t-\tDefault: NULL
\r\n\r\n\t\\return pRigidBody*\r\n\r\n\t@see deleteJoint()\r\n\t*/\r\n\tpRigidBody* isSubShape(CK3dEntity*ent);\r\n\r\n\r\n\tNxCCDSkeleton *getCCDSkeleton(CKBeObject *shapeReference);\r\n\tvoid doInit();\r\n\r\n\t/************************************************************************/\r\n\t/* Clothes : */\r\n\t/************************************************************************/\r\n\tpCloth *getCloth(CK_ID entityID);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Fluids : */\r\n\t/************************************************************************/\r\n\tpFluid *getFluid(CK3dEntity *entityReference);\r\n\tpFluidEmitter *getFluidEmitter(CK3dEntity *entityReferene);\r\n\r\n\r\n\t/**\r\n\t\\brief Function that lets you set global simulation parameters.\r\n\r\n\tReturns false if the value passed is out of range for usage specified by the enum.\r\n\r\n\tSleeping: Does NOT wake any actors which may be affected.\r\n\r\n\tSee #pSDKParameter for a description of parameters support by hardware.\r\n\r\n\t\\param[in] paramEnum Parameter to set. See #pSDKParameter\r\n\t\\param[in] paramValue The value to set, see #pSDKParameter for allowable values.\r\n\t\\return False if the parameter is out of range.\r\n\r\n\t\\note All parameters are available in the variable manager too.\r\n\r\n\t@see pSDKParameter getParameter\r\n\t*/\r\n\tvoid setParameter(pSDKParameter parm,float value);\r\n\r\n\t/**\r\n\t\\brief Function that lets you query global simulation parameters.\r\n\r\n\tSee #pSDKParameter for a description of parameters support by hardware.\r\n\r\n\t\\param[in] paramEnum The Parameter to retrieve.\r\n\t\\return The value of the parameter.\r\n\t@see setParameter pSDKParameter\r\n\t*/\r\n\tfloat getParameter(pSDKParameter parm,float value);\r\n\r\n\tvoid bindVariables();\r\n\tvoid unBindVariables();\r\n\r\n\tvoid setPSDKParameters(pSDKParameters&param);\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// character controller \r\n\t//\r\n\r\n\tUserAllocator * getUserAllocator() const { return mUserAllocator; }\r\n\tvoid setUserAllocator(UserAllocator * val) { mUserAllocator = val; }\r\n\t\r\n\r\n\tNxControllerManager* getControllerManager() const { return mControllerManager; }\r\n\tvoid setControllerManager(NxControllerManager* val) { mControllerManager = val; }\r\n\r\n\tvoid _createControllerManager();\r\n\tvoid _releaseControllerManager();\r\n\r\nprivate : \r\n\t\r\n\t\r\n\tUserAllocator *mUserAllocator;\r\n\tNxControllerManager* mControllerManager;\r\n\tTiXmlDocument* m_DefaultDocument;\r\n\tpWorld *m_DefaultWorld;\r\n\tpFactory *m_currentFactory;\r\n\tpWorldMap* m_Worlds;\r\n\t\r\n\r\n\t\r\n\tNxPhysicsSDK*\tmPhysicsSDK;\r\n\tpLogger*mLogger;\r\n\tpWorldSettings *mDefaultWorldSettings;\r\n\txBitSet mManagerFlags;\r\n\tNxRemoteDebugger* mRemoteDebugger;\r\n\r\n\tpSDKParameters m_SDKParameters;\r\n\tpRemoteDebuggerSettings mRemoteDebuggerSettings;\r\n\t\r\n\tpRemoteDebuggerSettings& getRemoteDebuggerSettings() { return mRemoteDebuggerSettings; }\r\n\tvoid setRemoteDebuggerSettings(pRemoteDebuggerSettings val) { mRemoteDebuggerSettings = val; }\r\n\r\n\r\n\tIParameter *mIParameter;\r\n\r\n\r\n\t\r\npublic:\r\n\tint att_physic_object;\tint att_hull_type;\tint att_mass;\tint att_surface_props;int att_physic_limit;\tBOOL m_DelOnReset;\r\n\tint att_world_object;int att_sleep_settings;int att_damping;int att_collMask;int att_update_world_flags;int att_update_body_flags;\r\n\tint att_heightField;int att_JBall;int att_JFixed;int att_JHinge;int att_JHinge2;int att_JSlider;int att_JUniversal;int att_JMotor;\r\n\tint att_wheelDescr;\r\n\tint att_clothDescr;\r\n\tint att_trigger;\r\n\tint att_deformable;\r\n\tint att_capsule;\r\n\t\r\n\tfloat mLastStepTime;\r\n\r\n\r\n\tint _LogInfo;\r\n\tint _LogTrace;\r\n\tint _LogWarnings;\r\n\tint _LogErrors;\r\n\tint _LogToConsole;\r\n\r\npublic : \r\n\r\n\r\n\t\r\n\t\r\n\tfloat getLastTimeStep(int flags);\r\n\r\n\r\n\tpSDKParameters& getSDKParameters() { return m_SDKParameters; }\r\n\tvoid setSDKParameters(pSDKParameters val) { m_SDKParameters = val; }\r\n\r\n\r\n\tNxRemoteDebugger* getRemoteDebugger();\r\n \r\n\t\r\n\r\n\tvoid Update();\r\n\tvoid update(float stepsize);\r\n\r\n\r\n\tstatic PhysicManager *GetInstance();\r\n\tstatic CKContext *GetContext();\r\n\r\n\t\r\n\r\n\tstatic PhysicManager * Cast(CKBaseManager* iM) { return GetInstance();}\r\n\tCKERROR OnCKInit(); \r\n\tCKERROR PostClearAll();\r\n\tCKERROR PreSave();\r\n\tCKERROR OnCKReset();\r\n\tCKERROR OnCKEnd();\r\n\tCKERROR PreProcess();\r\n\tCKERROR SequenceToBeDeleted(CK_ID *objids,int count);\r\n\tCKERROR OnCKPlay();\r\n\tCKERROR OnCKPause();\r\n\tCKERROR PostProcess();\r\n\tCKERROR SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count);\r\n\tCKERROR SequenceRemovedFromScene(CKScene *scn,CK_ID *objids,int count);\r\n\tCKERROR PreLaunchScene(CKScene* OldScene,CKScene* NewScene);\r\n\tCKERROR PostLaunchScene(CKScene* OldScene,CKScene* NewScene);\r\n\tCKERROR SequenceDeleted(CK_ID *objids,int count);\r\n\tCKERROR PreClearAll();\r\n\tCKERROR OnPostCopy(CKDependenciesContext& context);\r\n\t\r\n\tCKERROR PostLoad();\r\n\r\n\tint _migrateOldCustomStructures(CKScene *scnene);\r\n\r\n\r\n\t//--- Called to save manager data. return NULL if nothing to save...\r\n\tvirtual CKStateChunk* SaveData(CKFile* SavedFile);\r\n\tvoid _saveUserEnumeration(CKStateChunk *chunk,CKFile* SavedFile);\r\n\t\r\n\tvirtual CKERROR LoadData(CKStateChunk *chunk,CKFile* LoadedFile);\r\n\tvoid _loadUserEnumeration(CKStateChunk *chunk,CKFile* LoadedFile);\r\n\r\n\t//--- Called at the end of a save operation.\r\n\tCKERROR PostSave();\r\n\tfloat getLastDeltaTime(){return mLastStepTime;}\r\n\r\n\t\r\n\tvirtual CKDWORD GetValidFunctionsMask()\t\r\n\t{ \r\n\t\treturn \r\n\t\tCKMANAGER_FUNC_PreLaunchScene|\r\n\t\tCKMANAGER_FUNC_PostLaunchScene|\r\n\t\tCKMANAGER_FUNC_OnSequenceRemovedFromScene|\r\n\t\tCKMANAGER_FUNC_OnSequenceDeleted|\r\n\t\tCKMANAGER_FUNC_OnSequenceAddedToScene|\r\n\t\tCKMANAGER_FUNC_PreClearAll|\r\n\t\tCKMANAGER_FUNC_PostClearAll|\r\n\t\tCKMANAGER_FUNC_OnSequenceToBeDeleted|\r\n\t\tCKMANAGER_FUNC_OnCKPlay|\r\n\t\tCKMANAGER_FUNC_OnCKPause|\r\n\t\tCKMANAGER_FUNC_OnCKInit|\r\n\t\tCKMANAGER_FUNC_PreSave|\r\n\t\tCKMANAGER_FUNC_PostLoad|\r\n\t\tCKMANAGER_FUNC_OnPostCopy|\r\n\t\tCKMANAGER_FUNC_PostSave|\r\n\t\tCKMANAGER_FUNC_OnCKReset|\r\n\t\tCKMANAGER_FUNC_PostProcess|\r\n\t\tCKMANAGER_FUNC_PreProcess|\r\n\t\tCKMANAGER_FUNC_OnCKEnd;\r\n\t}\r\n\t\r\n\r\n\tint processOptions;\r\n\tvirtual int& getProcessOptions() { return processOptions; }\r\n\tvirtual void setProcessOptions(int val) { processOptions = val; }\r\n\r\n\r\n\r\n};\r\n\r\n#define GetPMan() PhysicManager::GetInstance()\r\n#define ctx() PhysicManager::GetInstance()->GetContext()\r\n#define lastStepTimeSec GetPMan()->GetContext()->GetTimeManager()->GetLastDeltaTimeFree() * 0.001f\r\n#define lastStepTimeMS GetPMan()->GetContext()->GetTimeManager()->GetLastDeltaTimeFree()\r\n\r\n\r\n\r\n#endif\r\n\r\n--/************************************************************************/\r\n\r\n\r\n\t--Build/Compiler Setup.\r\n\r\n\r\n--/************************************\r\n\r\n\t--Internal Paths Substion :\r\n\r\n\tFROOT \t= \"../../\"\r\n\tDROOT \t= \"../\"\r\n\tDDEPS \t= DROOT..\"Dependencies/\"\r\n\tDDOCS\t= DROOT..\"Docs\"\r\n\tD_INCLUDE\t= DROOT..\"SDK/Include/\"\r\n\tD_LIBS\t= DROOT..\"SDK/Lib/\"\r\n\tD_SRC\t= DROOT..\"SDK/Src/\"\r\n\tD_BB\t\t= DROOT..\"SDK/Behaviors/\"\r\n\tD_DX\t= DDEPS..\"dx/\"\r\n\r\n\tD_BASE_INC \t= \"../../usr/include/\"\r\n\tD_VT_BASE_INC \t= D_BASE_INC..\"virtools/\"\r\n\r\n\tD_BASE_SRC = \"../../usr/src/\"\r\n\tD_BASE_VT_SRC = D_BASE_SRC..\"virtools/\"\r\n\r\n\r\n\tD_DOCS_PAGES = DROOT..\"Doc/pages/\"\r\n\tD_READER_SRC = D_SRC..\"xmlstream/\"\r\n\tD_UI_SRC = D_SRC..\"Interface/\"\r\n\r\n\tD_PHYSX\t\t\t= DDEPS..\"NVIDIA.PhysX.SDK/\"\r\n D_NXSTREAM\t\t= D_PHYSX..\"Tools/NxuStream2/\"\r\n\tD_NXCOMMON\t\t= D_PHYSX..\"SDKs/Common/\"\r\n\tD_NXCHARACTER\t= D_PHYSX..\"SDKs/NxCharacter/\"\r\n\tD_TINYXML\t\t= DDEPS..\"TinyXML/\"\r\n\r\n\tD_CORE_INCLUDES =\r\n\t{\r\n\t\tDROOT..\"SDK/Include/Core/Common\";\r\n\t\tDROOT..\"SDK/Include/Core/Manager\";\r\n\t\tDROOT..\"SDK/Include/Core/pWorld\";\r\n\t\tDROOT..\"SDK/Include/Core/pCloth\";\r\n\t\tDROOT..\"SDK/Include/Core/pJoint\";\r\n\t\tDROOT..\"SDK/Include/Core/pVehicle\";\r\n\t\tDROOT..\"SDK/Include/Core/pRigidBody\";\r\n\t\tDROOT..\"SDK/Include/Core/pFactory\";\r\n\t\tDROOT..\"SDK/Include/Core/pFluid\";\r\n\t\tDROOT..\"SDK/Include/Core/pSerializer\";\r\n\t\tDROOT..\"SDK/Include/Core/pCharacter\";\r\n\t\tDROOT..\"SDK/Include/Core\";\r\n\t\tDROOT..\"SDK/Include/xmlstream\";\r\n\r\n\t}\r\n\r\n\tD_STD_INCLUDES =\r\n\t{\r\n\t\t\"../Shared\";\r\n\t\t\"../../usr/include\";\r\n\t\t\"../../usr/include/virtools\";\r\n\t}\r\n\r\n\r\n\r\n\tD_PHYSX_INCLUDES =\r\n\t{\r\n\t\tD_PHYSX..\"SDKs/Foundation/include\";\r\n\t D_PHYSX..\"SDKs/Physics/include\";\r\n\t D_PHYSX..\"SDKs/Physics/include/cloth\";\r\n\t D_PHYSX..\"SDKs/Physics/include/fluids\";\r\n\t D_PHYSX..\"SDKs/Physics/include/softbody\";\r\n\t D_PHYSX..\"SDKs/NxVehicle\";\r\n\t D_PHYSX..\"SDKs/Cooking/include\";\r\n\t D_PHYSX..\"SDKs/PhysXLoader/include\";\r\n\t D_PHYSX..\"SDKs/Common\";\r\n\t\tD_PHYSX..\"SDKs/NxCharacter/include\";\r\n\t D_PHYSX..\"Tools/NxuStream2\";\r\n\t}\r\n\r\n\tF_VT_STD_INC =\r\n\t{\r\n\t\tD_VT_BASE_INC..\"**.h\";\r\n\t\tDROOT..\"SDK/Include/xmlstream/XLoader.h\";\r\n\t}\r\n\r\n\tF_BASE_STD_INC =\r\n\t{\r\n\t\tD_BASE_INC..\"BaseMacros.h\";\r\n\t\tD_BASE_INC..\"DllTools.h\";\r\n\t\tD_BASE_INC..\"xBitSet.h\";\r\n\t\tD_BASE_INC..\"xLogger.h\";\r\n\t\tD_BASE_INC..\"uxString.h\";\r\n\t\tD_BASE_INC..\"pch.h\";\r\n\t}\r\n\r\n\tF_BASE_VT_SRC =\r\n\t{\r\n\t\tD_BASE_VT_SRC..\"vtTools.cpp\";\r\n\t}\r\n\r\n\tF_BASE_SRC =\r\n\t{\r\n\t\tD_BASE_SRC..\"xLogger.cpp\";\r\n\t\tD_BASE_SRC..\"xAssertion.cpp\";\r\n\t\tD_BASE_SRC..\"xAssertCustomization.cpp\";\r\n\t\tD_BASE_SRC..\"ConStream.cpp\";\r\n\t}\r\n\r\n\tF_EXTRA_BB_SRC =\r\n\t{\r\n\t\tD_BASE_VT_SRC..\"Behaviors/generic/GetSubBBId.cpp\";\r\n\t\tD_BASE_VT_SRC..\"Behaviors/joystick/hasFFe.cpp\";\r\n\t\tD_BASE_VT_SRC..\"Behaviors/joystick/JSetXYForce.cpp\";\r\n\r\n\t}\r\n\r\n\tF_SHARED_SRC =\r\n\t{\r\n\t\t\"../Shared/*.cpp\";\r\n\t}\r\n\r\n\r\n\r\n\r\n\r\n\tDEF_STD_DIRECTIVES \t=\r\n\t{\r\n\t\t\"WIN32\";\"_WINDOWS\";\r\n\t}\r\n\r\n\tDEF_PHYSX_DIRECTIVES\t=\r\n\t{\r\n\t\t\"NOMINMAX\";\"_USRDLL\";\r\n\t}\r\n\r\n\r\n\t--/************************************\r\n\r\n\t--~ \tVirtools SDK Paths. All files have to be inside the module path !\r\n\r\n\r\n\tDEV35DIR=DDEPS..\"vt/Dev35/\"\r\n\t--DEV40DIR=\"x:/sdk/dev4/SDK/\"\r\n\r\n\tDEV40DIR=DDEPS..\"vt/Dev40/\"\r\n\tDEV41DIR=DDEPS..\"vt/Dev41/\"\r\n\tDEV5DIR=DDEPS..\"vt/Dev5/\"\r\n\r\n\r\n\r\n\t--~ \tVirtools Real Paths. This paths will be used as deployment targets due the post build command\r\n\r\n\tDEV_40_BIN=\"x:\\\\sdk\\\\dev4\"\r\n\tDEV_41_BIN=\"x:\\\\sdk\\\\dev41\"\r\n\tDEV_35_BIN=\"x:\\\\sdk\\\\dev35\"\r\n\tDEV_5_BIN=\"x:\\\\sdk\\\\dev5\"\r\n\r\n\r\n\tOUTPUT_PATH_OFFSETT_TO_PROJECTFILES\t=\"../../Bin\"\r\n\tOUTPUT_PATH_OFFSETT_TO_PROJECTFILES_MINUS_ONE\t= \"../Bin\"\r\n\r\n\tOUTPUT_PATH_OFFSETT_TO_INTERNAL_LIBS=\"../SDK/Lib/\"\r\n\tOUTPUT_PATH_OFFSETT_TO_TMP=\"../TEMP\"\r\n\r\n\r\n--*********************************\r\n\r\n\t--\"Control how the outputs will be named and odererd in a filesystem\"\r\n\r\n\r\n\tPSTORE_PER_VS_VERSION = true\r\n\tPSTORE_PER_VT_VERSION = true\r\n\tPSTORE_PER_CONFIG= false\r\n\r\n\tPSTORE_NAME_VS_VERSION = false\r\n\tPSTORE_NAME_VT_VERSION = true\r\n\tPSTORE_NAME_CONFIG= false\r\n\r\n\r\n\r\n--/************************************\r\n\r\n\t--Internal Path Cache :\r\n\r\n\tMERGED_DST_PATH = OUTOUT_PATH_OFFSETT_TO_PROJECTFILES\r\n\r\n--/************************************************************************/\r\n\r\n\t--Feauteres :\r\n\r\n\r\n\tF_VC_DOC_PROJECT = \"true\"\r\n\tF_VC_PREMAKE_PROJECT = \"true\"\r\n\r\n--/************************************************************************/\r\n\r\n\r\n\t--POST COMPILE ROUTINES :\r\n\r\n\tDEPLOY_TO_DEV = 1\r\n\tDEPLOY_TO_ZIP = 0\r\n\r\n--/************************************************************************/\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n\r\n#include \"NXU_helper.h\" // NxuStream helper functions.\r\n#include \"NXU_PhysicsInstantiator.h\"\r\n\r\n#include \"IParameter.h\"\r\n\r\n#include \"xDebugTools.h\"\r\n\r\n\r\npRigidBody*pFactory::cloneRigidBody(CK3dEntity *src,CK3dEntity *dst,CKDependencies *deps,int copyFlags,int bodyFlags/* =0 */)\r\n{\r\n\t//src->Rest\r\n\tpRigidBody *result = GetPMan()->getBody(dst);\r\n\tpRigidBody *srcBody = GetPMan()->getBody(src);\r\n\tCK3dEntity *referenceObject = dst;\r\n\r\n\tXString errMsg;\r\n\tpObjectDescr oDescr;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t\tassert(dst);\r\n\t#endif // _DEBUG\r\n\r\n\tif (!(copyFlags & PB_CF_PHYSICS))\r\n\t{\r\n\t\terrMsg.Format(\"Nothing to copy, aborting\");\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errMsg.Str());\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//iAssertW(!result,\"\",\"Object :%s already physicalized\");\r\n\t\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// fill object description\r\n\t//\r\n\tif (!result && IParameter::Instance()->copyTo(oDescr,src,copyFlags))\r\n\t{\r\n\t\tpWorld *world = GetPMan()->getWorld(oDescr.worlReference) ? GetPMan()->getWorld(oDescr.worlReference) : GetPMan()->getDefaultWorld();\r\n\t\tif(world)\r\n\t\t{\r\n\r\n\t\t\tif ( (copyFlags && PB_CF_OVRRIDE_BODY_FLAGS) )\r\n\t\t\t\toDescr.flags = (BodyFlags)bodyFlags;\r\n\t\t\t\r\n\t\t\t//now create the final rigid body : \r\n\t\t\tresult = pFactory::Instance()->createRigidBody(dst,oDescr);\r\n\t\t}\r\n\t}\r\n\r\n\tif (!result){\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"cloning failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// clone joints\r\n\t//\r\n\tif ( (copyFlags & PB_CF_JOINTS) )\r\n\t{\r\n\t\tpFactory::cloneJoints(src,dst,copyFlags);\r\n\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy velocities\r\n\t//\r\n\tif ( (copyFlags & PB_CF_VELOCITIES) )\r\n\t{\r\n\t\tNxActor *actorSrc = srcBody->getActor();\r\n\t\tNxActor *actorDst = result->getActor();\r\n\r\n\t\tactorDst->setLinearVelocity( actorSrc->getLinearVelocity() );\r\n\t\tactorDst->setAngularVelocity( actorSrc->getAngularVelocity() );\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy forces\r\n\t//\r\n\tif ( (copyFlags & PB_CF_FORCE) )\r\n\t{\r\n\t\tNxActor *actorSrc = srcBody->getActor();\r\n\t\tNxActor *actorDst = result->getActor();\r\n\t\tactorDst->setLinearMomentum( actorSrc->getLinearMomentum() );\r\n\t\tactorDst->setAngularMomentum( actorSrc->getAngularMomentum() );\r\n\t}\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy sub shapes if : \r\n\t//\r\n\t//\t\t\"Copy Children In Dependencies\" &&\r\n\t//\t\t( copyFlags::OverrideBodyFlags & hierarchy && newBodyFlags & hierarchy ) ||\t\t\r\n\t//\t\t( oldBodyFlags & hierarchy )\r\n\tif ( ((*deps->At(CKCID_3DENTITY)) & CK_DEPENDENCIES_COPY_3DENTITY_CHILDREN) && \r\n\t\t ( (( copyFlags & PB_CF_OVRRIDE_BODY_FLAGS ) && (bodyFlags & BF_Hierarchy)) ||\r\n\t\t ( oDescr.flags & BF_Hierarchy) )\r\n\t\t)\r\n\t{\r\n\t\tint dCount = dst->GetChildrenCount();\r\n\t\tCK3dEntity* subEntity = NULL;\r\n\t\twhile (subEntity= dst->HierarchyParser(subEntity) )\r\n\t\t{\r\n\t\t\tif (subEntity==dst)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tCK3dEntity *orginalObject = findSimilarInSourceObject(src,dst,subEntity);\r\n\t\t\tif (orginalObject)\r\n\t\t\t{\r\n\t\t\t\tiAssertW(cloneShape(orginalObject,subEntity,dst,copyFlags,bodyFlags),\"\",\"clone of sub shape failed\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npRigidBody*pFactory::createRigidBody(CK3dEntity *referenceObject,pObjectDescr& oDescr)\r\n{\r\n\tCK3dEntity *worldReferenceObject = (CK3dEntity*)GetPMan()->GetContext()->GetObject(oDescr.worlReference);\r\n\r\n\tpWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject); \r\n\r\n\tif (!world)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"world object invalid, setting to default world\");\r\n\t\tworld = GetPMan()->getDefaultWorld();\r\n\t}\r\n\r\n\tpRigidBody*result = world->getBody(referenceObject);\r\n\r\n\t//\tcreate minimum object\r\n\tresult = createBody(referenceObject,worldReferenceObject);\r\n\r\n\tif (!result)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed\");\r\n\t\treturn NULL;\r\n\r\n\t}\r\n\tresult->setWorld(world);\r\n\tresult->setFlags(oDescr.flags);\r\n\tresult->setHullType(oDescr.hullType);\r\n\r\n\tif (oDescr.density <= 0.001f)\r\n\t\toDescr.density = 1.0f;\r\n\t\r\n\tif (oDescr.skinWidth <= 0.001f)\r\n\t\toDescr.skinWidth = 0.025f;\r\n\r\n\t\r\n\tresult->setDensity(oDescr.density);\r\n\r\n\tbool hierarchy = (oDescr.flags & BF_Hierarchy);\r\n\tbool isDeformable = oDescr.flags & BF_Deformable;\r\n\tbool trigger = oDescr.flags & BF_TriggerShape;\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Deformable ?\r\n\t//\r\n\r\n\r\n\tpCloth *cloth = NULL;\r\n\tpClothDesc cDescr;\r\n\r\n\tif (isDeformable)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"deformable feature disabled in this release\");\r\n\t\treturn NULL;\r\n\r\n\t\tcDescr.setToDefault();\r\n\t\tcDescr.worldReference = worldReferenceObject->GetID();\r\n\r\n\t\tif ( result->getFlags() & BF_Gravity )\r\n\t\t{\r\n\t\t\tcDescr.flags |= PCF_Gravity;\r\n\t\t}\r\n\r\n\t\tif ( result->getFlags() & BF_Collision )\r\n\t\t{\r\n\r\n\t\t}\r\n\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tcloth = pFactory::Instance()->createCloth(referenceObject,cDescr);\r\n\t\t\tif (!cloth)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : factory object failed !\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tfloat density = oDescr.density;\r\n\tVxVector box_s= BoxGetZero(referenceObject);\r\n\r\n\r\n\tVxMatrix v_matrix ;\r\n\tVxVector position,scale;\t\t\r\n\tVxQuaternion quat;\t\r\n\r\n\r\n\tv_matrix = referenceObject->GetWorldMatrix();\r\n\tVx3DDecomposeMatrix(v_matrix,quat,position,scale);\r\n\r\n\tNxVec3 pos = pMath::getFrom(position);\r\n\tNxQuat rot = pMath::getFrom(quat);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Fill NxActorDescr\r\n\t//\r\n\t\r\n\r\n\tNxActorDesc actorDesc;actorDesc.setToDefault();\r\n\tNxBodyDesc bodyDesc;bodyDesc.setToDefault();\r\n\r\n\t//\r\n\t//\tFix parameters to default values\r\n\r\n\t\r\n\tactorDesc.density = oDescr.density;\r\n\r\n\t//skin width\r\n\tif (oDescr.skinWidth<=0.0001f)\r\n\t\toDescr.skinWidth=0.025f;\r\n\r\n\r\n\tfloat radius = result->GetVT3DObject()->GetRadius();\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//\tCreate the physic mesh. Externalizing this procedure will corrupt the\r\n\t//\tactor description object.\r\n\t//\r\n\t\r\n\tswitch(oDescr.hullType)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Box:\r\n\t\t{\r\n\t\t\tNxBoxShapeDesc shape;\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t\t}\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Sphere:\r\n\t\t{\r\n\t\t\tNxSphereShapeDesc shape;\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.radius = radius;\r\n\t\t\t}\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Mesh:\r\n\t\t{\r\n\r\n\t\t\tNxTriangleMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\r\n\t\t\tpFactory::Instance()->createMesh(result->getWorld()->getScene(),result->GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxTriangleMeshShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookTriangleMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't cook mesh!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createTriangleMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.group = oDescr.collisionGroup;\r\n\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tCloseCooking();\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexMesh:\r\n\t\t{\r\n\t\t\r\n\t\t\tif (result->GetVT3DObject()->GetCurrentMesh())\r\n\t\t\t{\r\n\t\t\t\tif (result->GetVT3DObject()->GetCurrentMesh()->GetVertexCount()>=256 )\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Only 256 vertices for convex meshes allowed, by Ageia!\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Object has no mesh!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tNxConvexMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\t\t\tpFactory::Instance()->createConvexMesh(result->getWorld()->getScene(),result->GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookConvexMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't cook convex mesh!\");\r\n\t\t\t\treturn false;\r\n\r\n\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tint h = shape.isValid();\r\n\t\t\tCloseCooking();\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexCylinder:\r\n\t\t{\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tpConvexCylinderSettings &cSettings = oDescr.convexCylinder;\r\n\t\t\t\r\n\t\t\tiAssertW( (oDescr.mask & OD_ConvexCylinder),pFactory::Instance()->findSettings(cSettings,result->GetVT3DObject()),\r\n\t\t\t\t\"Hull type has been set to convex cylinder but there is no descriptions passed or activated in the pObjectDescr::mask.Trying object attributes....\");\r\n\t\t\t\r\n\t\t\tif (cSettings.radius.reference)\r\n\t\t\t\tcSettings.radius.evaluate(cSettings.radius.reference);\r\n\r\n\t\t\tif (cSettings.height.reference)\r\n\t\t\t\tcSettings.height.evaluate(cSettings.height.reference);\r\n\r\n\r\n\t\t\tiAssertW( cSettings.isValid() , cSettings.setToDefault(),\"\");\r\n\r\n\t\t\tcSettings.radius.value = cSettings.radius.value > 0.0f ? (cSettings.radius.value*0.5) : (box_s.v[cSettings.radius.referenceAxis] * 0.5f);\r\n\t\t\tcSettings.height.value = cSettings.height.value > 0.0f ? cSettings.height.value : (box_s.v[cSettings.height.referenceAxis] * 0.5f);\r\n\r\n\t\t\t\r\n\r\n\t\t\tbool resultAssert = true;\r\n\t\t\tiAssertWR( pFactory::Instance()->_createConvexCylinderMesh(&shape,cSettings,result->GetVT3DObject()),\"\",resultAssert);\r\n\t\t\t\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Capsule:\r\n\t\t{\r\n\r\n\t\t\tNxCapsuleShapeDesc shape;\r\n\t\t\tpCapsuleSettingsEx &cSettings = oDescr.capsule;\r\n\t\t\tif (!( oDescr.mask & OD_Capsule) )\r\n\t\t\t{\r\n\t\t\t\t// try over attribute :\r\n\t\t\t\tpFactory::Instance()->findSettings(cSettings,result->GetVT3DObject());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tbool resultAssert = true;\r\n\t\t\t\r\n\t\t\tif (cSettings.radius.reference)\r\n\t\t\t\tcSettings.radius.evaluate(cSettings.radius.reference);\r\n\r\n\t\t\tif (cSettings.height.reference)\r\n\t\t\t\tcSettings.height.evaluate(cSettings.height.reference);\r\n\r\n\t\t\tiAssertWR(cSettings.isValid(),cSettings.setToDefault(),resultAssert);\r\n\r\n\t\t\t\r\n\r\n\t\t\tshape.radius = cSettings.radius.value > 0.0f ? (cSettings.radius.value*0.5) : (box_s.v[cSettings.radius.referenceAxis] * 0.5f);\r\n\t\t\tshape.height = cSettings.height.value > 0.0f ? (cSettings.height.value-( 2*shape.radius)) : (box_s.v[cSettings.height.referenceAxis] - ( 2*shape.radius)) ;\r\n\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase HT_Wheel:\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Wheel shape can be sub shape only!\");\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tif ( !isDeformable)\r\n\t{\r\n\t\tactorDesc.globalPose.t = pos;\t\r\n\t\tactorDesc.globalPose.M = rot;\r\n\t}\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Create the final NxActor\r\n\t//\r\n\r\n\tif (oDescr.flags & BF_Moving)\r\n\t\tactorDesc.body = &bodyDesc;\r\n\r\n\tNxActor *actor = world->getScene()->createActor(actorDesc);\r\n\tif (!actor)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't create actor\");\r\n\t\tdelete result;\r\n\t\treturn NULL;\r\n\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\tresult->setActor(actor);\r\n\tactor->setName(referenceObject->GetName());\r\n\tresult->SetVT3DObject(referenceObject);\r\n\tactor->userData= result;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Deformable : \r\n\tif (isDeformable && cloth)\r\n\t{\r\n\r\n\t\tpDeformableSettings dSettings;\r\n\t\tdSettings.ImpulsThresold = 50.0f;\r\n\t\tdSettings.PenetrationDepth= 0.1f ;\r\n\t\tdSettings.MaxDeform = 2.0f;\r\n\r\n\t\tCKParameterOut *poutDS = referenceObject->GetAttributeParameter(GetPMan()->att_deformable);\r\n\t\tif (poutDS)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(dSettings,poutDS);\r\n\t\t}\r\n\t\tcloth->attachToCore(referenceObject,dSettings.ImpulsThresold,dSettings.PenetrationDepth,dSettings.MaxDeform);\r\n\t\tresult->setCloth(cloth);\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tExtra settings : \r\n\t//\r\n\r\n\tif (result->getFlags() & BF_Moving)\r\n\t{\r\n\t\tVxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&oDescr.massOffsetLinear);\r\n\t\tactor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));\r\n\t}\r\n\r\n\tif (result->getFlags() & BF_Kinematic)\r\n\t{\r\n\t\tresult->setKinematic(true);\r\n\t}\r\n\r\n\tif (result->getFlags() & BF_Moving )\r\n\t{\r\n\t\tresult->enableGravity(result->getFlags() & BF_Gravity);\r\n\t}\r\n\r\n\tif (result->getFlags() & BF_Sleep )\r\n\t{\r\n\t\tresult->setSleeping(true);\r\n\t}\r\n\r\n\tif (oDescr.worlReference == 0)\r\n\t{\r\n\t\tif (GetPMan()->getDefaultWorld())\r\n\t\t{\r\n\t\t\toDescr.worlReference = GetPMan()->getDefaultWorld()->getReference()->GetID();\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// store mesh meta info in the first main mesh\r\n\t//\r\n\tNxShape *shape = result->getShapeByIndex();\r\n\tif (shape)\r\n\t{\r\n\t\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\t\tsInfo->entID = referenceObject->GetID();\r\n\t\tsInfo->refObject = (CKBeObject*)referenceObject;\r\n\t\tshape->userData = (void*)sInfo;\r\n\t\tresult->setMainShape(shape);\r\n\t\tshape->setName(referenceObject->GetName());\r\n\r\n\t}\r\n\r\n\tresult->enableCollision( (result->getFlags() & BF_Collision), referenceObject );\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Adjust pivot \r\n\t//\r\n\r\n\tif ( (oDescr.mask & OD_Pivot) )\r\n\t{\r\n\t\tiAssertW1( oDescr.pivot.isValid(),oDescr.pivot.setToDefault());\r\n\t\tresult->updatePivotSettings(oDescr.pivot,referenceObject);\r\n\t}else if(pFactory::Instance()->findSettings(oDescr.collision,referenceObject))\r\n\t\tresult->updatePivotSettings(oDescr.pivot,referenceObject);\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Optimization \r\n\t//\r\n\tif ((oDescr.mask & OD_Optimization ))\r\n\t{\r\n\t\tiAssertW1( oDescr.optimization.isValid(),oDescr.optimization.setToDefault());\r\n\t\tresult->updateOptimizationSettings(oDescr.optimization);\r\n\t}\r\n\telse{\r\n\t\tif(pFactory::Instance()->findSettings(oDescr.optimization,referenceObject))\r\n\t\t{\r\n\t\t\tiAssertW1( oDescr.optimization.isValid(),oDescr.optimization.setToDefault());\r\n\t\t\tresult->updateOptimizationSettings(oDescr.optimization);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision\r\n\t//\r\n\tif ((oDescr.mask & OD_Collision))\r\n\t\tresult->updateCollisionSettings(oDescr.collision,referenceObject);\r\n\telse if(pFactory::Instance()->findSettings(oDescr.collision,referenceObject))\r\n\t\tresult->updateCollisionSettings(oDescr.collision,referenceObject);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Material \r\n\t//\r\n\r\n\tNxMaterialDesc *materialDescr = NULL;\r\n\tNxMaterial *material = NULL;\r\n\r\n\tpMaterial &bMaterial = oDescr.material;\r\n\r\n\tif (oDescr.mask & OD_Material)\r\n\t{\r\n\t\tresult->updateMaterialSettings(bMaterial,referenceObject);\r\n\t}else\r\n\t{\r\n\t\tbool hasMaterial = pFactory::Instance()->findSettings(bMaterial,referenceObject);\r\n\t\tif (!hasMaterial)\r\n\t\t{\r\n\t\t\tif (world->getDefaultMaterial())\r\n\t\t\t{\r\n\t\t\t\tint z = (int)world->getDefaultMaterial()->userData;\r\n\t\t\t\tshape->setMaterial(world->getDefaultMaterial()->getMaterialIndex());\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\t\r\n\t\t\tiAssertW( bMaterial.isValid(),bMaterial.setToDefault(),\r\n\t\t\t\t\"Material settings were still invalid : \");\r\n\r\n\t\t\tNxMaterialDesc nxMatDescr;\r\n\t\t\tpFactory::Instance()->copyTo(nxMatDescr,bMaterial);\r\n\t\t\tNxMaterial *nxMaterial = world->getScene()->createMaterial(nxMatDescr);\r\n\t\t\tif (nxMaterial)\r\n\t\t\t{\r\n\t\t\t\tshape->setMaterial(nxMaterial->getMaterialIndex());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\txLogger::xLog(ELOGINFO,E_LI_MANAGER,\"Rigid body creation successful : %s\",referenceObject->GetName());\r\n\r\n\tresult->setInitialDescription(&oDescr);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Hierarchy mode fix : \r\n\t//\r\n\tif ( (oDescr.flags & BF_Hierarchy) )\r\n\t\toDescr.hirarchy = true;\r\n\r\n\tif ( oDescr.hirarchy )\r\n\t\toDescr.flags << BF_Hierarchy;\r\n\r\n\r\n\tif ( (!oDescr.hirarchy) || !(oDescr.flags & BF_Hierarchy) ) \r\n\t\treturn result;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Parse hirarchy \r\n\t//\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= referenceObject->HierarchyParser(subEntity) )\r\n\t{\r\n\t\tpObjectDescr *subDescr = NULL;\r\n\t\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\t\tif (subEntity->HasAttribute(attTypePBSetup))\r\n\t\t{\r\n\t\t\tsubDescr = new pObjectDescr();\r\n\t\t\tCKParameterOut *par = subEntity->GetAttributeParameter(attTypePBSetup);\r\n\t\t\tIParameter::Instance()->copyTo(subDescr,par);\r\n\t\t\tsubDescr->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\t\t}\r\n\r\n\t\tif (!subDescr)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\tRegular Mesh : \r\n\t\t\t//\r\n\r\n\t\t\tif (subDescr->hullType != HT_Cloth)\r\n\t\t\t{\r\n\t\t\t\t//result->addSubShape(NULL,*subDescr,subEntity);\r\n\t\t\t\t\r\n\t\t\t\tVxQuaternion refQuad;subEntity->GetQuaternion(&refQuad,referenceObject);\r\n\t\t\t\tVxVector relPos;subEntity->GetPosition(&relPos,referenceObject);\r\n\t\t\t\t\r\n\t\t\t\tshape = pFactory::Instance()->createShape(referenceObject,*subDescr,subEntity,subEntity->GetCurrentMesh(),relPos,refQuad);\r\n\t\t\t\t\r\n\t\t\t\t//NxShape *shape = result->getSubShape(subEntity);\r\n\t\t\t\tif (shape)\r\n\t\t\t\t{\r\n\t\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// check for collision setup\r\n\t\t\t\t\t//\r\n\t\t\t\t\t\r\n\t\t\t\t\t//try to get get from child attributes first\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tif(pFactory::Instance()->findSettings(subDescr->collision,subEntity))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult->updateCollisionSettings(subDescr->collision,subEntity);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif ( (subDescr->mask & OD_Optimization) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//if (pFactory::Instance()->findSettings(subDescr->collision,subEntity))\r\n\t\t\t\t\t\tresult->updateCollisionSettings(subDescr->collision,subEntity);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if ( (oDescr.mask & OD_Optimization) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult->updateCollisionSettings(oDescr.collision,subEntity);\r\n\t\t\t\t\t}else if(pFactory::Instance()->findSettings(subDescr->collision,subEntity))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult->updateCollisionSettings(subDescr->collision,subEntity);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t*/\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\tCloth Mesh : \r\n\t\t\t//\r\n\t\t\tif (subDescr->hullType == HT_Cloth)\r\n\t\t\t{\r\n\t\t\t\t//pClothDesc *cloth = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Adjust mass \r\n\t//\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision\r\n\t//\r\n\tif ((oDescr.mask & OD_Mass))\r\n\t\tresult->updateMassSettings(oDescr.mass);\r\n\telse if(pFactory::Instance()->findSettings(oDescr.mass,referenceObject))\r\n\t\tresult->updateMassSettings(oDescr.mass);\r\n\r\n\r\n\treturn result;\r\n\t\r\n\t\tnothing:\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\npRigidBody*pFactory::createCapsule(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags)\r\n{\r\n\r\n\tpWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject); \r\n\tpRigidBody*result = world->getBody(referenceObject);\r\n\tif(result)\r\n\t{\r\n\t\tresult->destroy();\r\n\t\tdelete result;\r\n\t\tresult = NULL;\r\n\t}\r\n\t// we create our final body in the given world :\r\n\tresult = createBody(referenceObject,worldReferenceObject);\r\n\tif (result)\r\n\t{\r\n\t\tresult->setWorld(world);\r\n\r\n\t\tusing namespace vtTools::AttributeTools;\r\n\r\n\t\tresult->setFlags(descr->flags);\r\n\t\tresult->setHullType(descr->hullType);\r\n\t\tresult->setDataFlags(0x000);\r\n\t\tresult->checkDataFlags();\r\n\r\n\t\tif (result->getSkinWidth()==-1.0f)\r\n\t\t{\r\n\t\t\tresult->setSkinWidth(0.01f);\r\n\t\t}\r\n\r\n\t\tVxMatrix v_matrix ;\r\n\t\tVxVector position,scale;\t\t\r\n\t\tVxQuaternion quat;\t\r\n\r\n\r\n\t\tv_matrix = referenceObject->GetWorldMatrix();\r\n\t\tVx3DDecomposeMatrix(v_matrix,quat,position,scale);\r\n\t\tVxVector box_s= BoxGetZero(referenceObject);\r\n\r\n\t\tNxVec3 pos = pMath::getFrom(position);\r\n\t\tNxQuat rot = pMath::getFrom(quat);\r\n\r\n\t\tfloat density = result->getDensity();\r\n\t\tfloat radius = referenceObject->GetRadius();\r\n\t\tif (referenceObject->GetRadius() < 0.001f )\r\n\t\t{\r\n\t\t\tradius = 1.0f;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create actors description\r\n\t\tNxActorDesc actorDesc;actorDesc.setToDefault();\r\n\t\tNxBodyDesc bodyDesc;bodyDesc.setToDefault();\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tNxMaterialDesc *materialDescr = NULL;\r\n\t\tNxMaterial *material = NULL;\r\n\t\tif (isFlagOn(result->getDataFlags(),EDF_MATERIAL_PARAMETER))\r\n\t\t{\r\n\t\t\tNxMaterialDesc entMatNull;entMatNull.setToDefault();\r\n\t\t\tNxMaterialDesc *entMat = createMaterialFromEntity(referenceObject);\r\n\t\t\tmaterial = world->getScene()->createMaterial(entMatNull);\r\n\t\t\tmaterial->loadFromDesc(*entMat);\r\n\t\t\tresult->setMaterial(material);\r\n\t\t}else{\r\n\t\t\tif (world->getDefaultMaterial())\r\n\t\t\t{\r\n\t\t\t\tresult->setMaterial(world->getDefaultMaterial());\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tNxCapsuleShapeDesc capsuleShape;\r\n\r\n\t\tif ( creationFlags & E_OFC_DIMENSION )\r\n\t\t{\r\n\t\t\tcapsuleShape.height = box_s.y - ((box_s.x));\r\n\t\t\tcapsuleShape.radius = box_s.x*0.5f;\r\n\t\t}\r\n\t\t\r\n\t\tcapsuleShape.density = descr->density;\r\n\r\n\t\t\r\n\t\tcapsuleShape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\r\n\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\r\n\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\tcapsuleShape.skinWidth = result->getSkinWidth();\r\n\t\t\r\n\t\tactorDesc.shapes.pushBack(&capsuleShape);\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//dynamic object ? \r\n\t\tif (result->getFlags() & BF_Moving){\r\n\t\t\tactorDesc.body = &bodyDesc;\r\n\t\t}\r\n\t\telse\r\n\t\t\tactorDesc.body = NULL;\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set transformations\r\n\t\tactorDesc.density = descr->density;\r\n\r\n\t\tif (creationFlags & E_OFC_POSITION)\r\n\t\t{\r\n\t\t\tactorDesc.globalPose.t = pos;\t\r\n\t\t}\r\n\r\n\t\tif (creationFlags & E_OFC_POSITION)\r\n\t\t{\r\n\t\t\tactorDesc.globalPose.M = rot;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create the actor\r\n\r\n\t\tint v = actorDesc.isValid();\r\n\t\tNxActor *actor = world->getScene()->createActor(actorDesc);\r\n\t\tif (!actor)\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't create actor\");\r\n\t\t\tdelete result;\r\n\t\t\treturn NULL;\r\n\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set additional settings : \r\n\t\tresult->setActor(actor);\r\n\t\tactor->setName(referenceObject->GetName());\r\n\t\tactor->userData= result;\r\n\r\n\t\tif (result->getFlags() & BF_Moving)\r\n\t\t{\r\n\t\t\tVxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&result->getMassOffset());\r\n\t\t\tactor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));\r\n\t\t}\r\n\r\n\t\tif (result->getFlags() & BF_Kinematic)\r\n\t\t{\r\n\t\t\tactor->raiseBodyFlag(NX_BF_KINEMATIC);\r\n\t\t}\r\n\r\n\t\tresult->enableCollision((result->getFlags() & BF_Collision));\r\n\t\tif (result->getFlags() & BF_Moving)\r\n\t\t{\r\n\t\t\tif (!(result->getFlags() & BF_Gravity))\r\n\t\t\t{\r\n\t\t\t\tactor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tNxShape *shape = result->getShapeByIndex();\r\n\t\tif (shape)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\t\t\tsInfo->entID = referenceObject->GetID();\r\n\t\t\tsInfo->refObject = (CKBeObject*)referenceObject;\r\n\t\t\tshape->userData = (void*)sInfo;\r\n\t\t\tresult->setMainShape(shape);\r\n\t\t\tshape->setName(referenceObject->GetName());\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\npRigidBody*pFactory::createBox(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags)\r\n{\r\n\r\n\tpWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject); \r\n\tpRigidBody*result = world->getBody(referenceObject);\r\n\tif(result)\r\n\t{\r\n\t\tresult->destroy();\r\n\t\tdelete result;\r\n\t\tresult = NULL;\r\n\t}\r\n\t// we create our final body in the given world :\r\n\tresult = createBody(referenceObject,worldReferenceObject);\r\n\tif (result)\r\n\t{\r\n\t\tresult->setWorld(world);\r\n\r\n\t\tusing namespace vtTools::AttributeTools;\r\n\r\n\t\tresult->setFlags(descr->flags);\r\n\t\tresult->setHullType(descr->hullType);\r\n\t\tresult->setDataFlags(0x000);\r\n\t\tresult->checkDataFlags();\r\n\r\n\t\tif (result->getSkinWidth()==-1.0f)\r\n\t\t{\r\n\t\t\tresult->setSkinWidth(0.01f);\r\n\t\t}\r\n\r\n\t\tVxMatrix v_matrix ;\r\n\t\tVxVector position,scale;\t\t\r\n\t\tVxQuaternion quat;\t\r\n\r\n\r\n\t\tv_matrix = referenceObject->GetWorldMatrix();\r\n\t\tVx3DDecomposeMatrix(v_matrix,quat,position,scale);\r\n\t\tVxVector box_s= BoxGetZero(referenceObject);\r\n\r\n\t\tNxVec3 pos = pMath::getFrom(position);\r\n\t\tNxQuat rot = pMath::getFrom(quat);\r\n\r\n\t\tfloat density = result->getDensity();\r\n\t\tfloat radius = referenceObject->GetRadius();\r\n\t\tif (referenceObject->GetRadius() < 0.001f )\r\n\t\t{\r\n\t\t\tradius = 1.0f;\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create actors description\r\n\t\tNxActorDesc actorDesc;actorDesc.setToDefault();\r\n\t\tNxBodyDesc bodyDesc;bodyDesc.setToDefault();\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tNxMaterialDesc *materialDescr = NULL;\r\n\t\tNxMaterial *material = NULL;\r\n\t\tif (isFlagOn(result->getDataFlags(),EDF_MATERIAL_PARAMETER))\r\n\t\t{\r\n\t\t\tNxMaterialDesc entMatNull;entMatNull.setToDefault();\r\n\t\t\tNxMaterialDesc *entMat = createMaterialFromEntity(referenceObject);\r\n\t\t\tmaterial = world->getScene()->createMaterial(entMatNull);\r\n\t\t\tmaterial->loadFromDesc(*entMat);\r\n\t\t\tresult->setMaterial(material);\r\n\t\t}else{\r\n\t\t\tif (world->getDefaultMaterial())\r\n\t\t\t{\r\n\t\t\t\tresult->setMaterial(world->getDefaultMaterial());\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tNxBoxShapeDesc boxShape;\r\n\t\tif (creationFlags & E_OFC_DIMENSION )\r\n\t\t{\r\n\t\t\tboxShape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t}\r\n\t\tboxShape.density = descr->density;\r\n\t\tboxShape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\tboxShape.skinWidth = result->getSkinWidth();\r\n\r\n\t\tactorDesc.shapes.pushBack(&boxShape);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//dynamic object ? \r\n\t\tif (result->getFlags() & BF_Moving){\r\n\t\t\tactorDesc.body = &bodyDesc;\r\n\t\t}\r\n\t\telse\r\n\t\t\tactorDesc.body = NULL;\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set transformations\r\n\t\tactorDesc.density = descr->density;\r\n\r\n\t\tif (creationFlags & E_OFC_POSITION)\r\n\t\t{\r\n\t\t\tactorDesc.globalPose.t = pos;\t\r\n\t\t}\r\n\r\n\t\tif (creationFlags & E_OFC_POSITION)\r\n\t\t{\r\n\t\t\tactorDesc.globalPose.M = rot;\r\n\t\t}\r\n\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create the actor\r\n\r\n\t\tint v = actorDesc.isValid();\r\n\t\tNxActor *actor = world->getScene()->createActor(actorDesc);\r\n\t\tif (!actor)\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't create actor\");\r\n\t\t\tdelete result;\r\n\t\t\treturn NULL;\r\n\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set additional settings : \r\n\t\tresult->setActor(actor);\r\n\t\tactor->setName(referenceObject->GetName());\r\n\t\tactor->userData= result;\r\n\r\n\t\tif (result->getFlags() & BF_Moving)\r\n\t\t{\r\n\t\t\tVxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&result->getMassOffset());\r\n\t\t\tactor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));\r\n\t\t}\r\n\r\n\t\tif (result->getFlags() & BF_Kinematic)\r\n\t\t{\r\n\t\t\tactor->raiseBodyFlag(NX_BF_KINEMATIC);\r\n\t\t}\r\n\r\n\t\tresult->enableCollision((result->getFlags() & BF_Collision));\r\n\t\tif (result->getFlags() & BF_Moving)\r\n\t\t{\r\n\t\t\tif (!(result->getFlags() & BF_Gravity))\r\n\t\t\t{\r\n\t\t\t\tactor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tNxShape *shape = result->getShapeByIndex();\r\n\t\tif (shape)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\t\t\tsInfo->entID = referenceObject->GetID();\r\n\t\t\tsInfo->refObject = (CKBeObject*)referenceObject;\r\n\t\t\tshape->userData = (void*)sInfo;\r\n\t\t\tresult->setMainShape(shape);\r\n\t\t\tshape->setName(referenceObject->GetName());\r\n\t\t}\r\n\t}\r\n\t\t\r\n\treturn result;\r\n}\r\n\r\npRigidBody*pFactory::createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,NXU::NxActorDesc *desc,int flags)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert(referenceObject);\r\n\tassert(desc);\r\n#endif \r\n\t\r\n\t/************************************************************************/\r\n\t/* \r\n\t\r\n\r\n\r\n\r\n\t*/\r\n\t/************************************************************************/\r\n\tVxVector vpos;\r\n\treferenceObject->GetPosition(&vpos);\r\n\r\n\tVxQuaternion vquat;\r\n\treferenceObject->GetQuaternion(&vquat);\r\n\r\n\tNxQuat nrot = desc->globalPose.M;\r\n\tNxVec3 npos = desc->globalPose.t;\r\n\r\n\tNxMat33 rotX;\r\n\trotX.rotX( PI / 2.0f );\r\n\tNxMat33 rotZ;\r\n\trotZ.rotZ( PI );\r\n\r\n\tNxMat34 rotMat;\r\n\trotMat.M.multiply( rotZ, rotX );\r\n\r\n\tNxMat34 posMat( true );\r\n\r\n/*\tposMat.t.set( -mTerrain->getPosition().x,\r\n\t\tmTerrain->getPosition().y,\r\n\t\tmTerrain->getPosition().z );\r\n*/\r\n\tdesc->globalPose.multiply( posMat, rotMat );\r\n\r\n\r\n\tNxQuat nrot2 = desc->globalPose.M;\r\n\tNxVec3 npos2 = desc->globalPose.t;\r\n\r\n\tVxQuaternion nvm = getFromStream(nrot);\r\n\r\n\tVxVector nvpos = getFromStream(npos);\r\n\r\n\t\r\n\r\n\tfor (NxU32 k=0; kmShapes.size(); k++)\r\n\t{\r\n\t\tNXU::NxShapeDesc *shape = desc->mShapes[k];\r\n\t\tNxVec3 locPos = shape->localPose.t;\r\n\t\tNxQuat localQuad = shape->localPose.M;\r\n\t}\r\n\r\n\r\n\tint op = 2; \r\n\r\n\r\n\r\n\treturn NULL;\r\n}\r\n\r\n\r\n\r\npRigidBody*pFactory::createRigidBodyFull(CK3dEntity *referenceObject, CK3dEntity *worldReferenceObject)\r\n{\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\tpWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject); \r\n\tpRigidBody*result = world->getBody(referenceObject);\r\n\t\r\n\r\n\tif(result)\r\n\t{\r\n\t\tresult->destroy();\r\n\t\tdelete result;\r\n\t\tresult = NULL;\r\n\t}\r\n\t\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// Construct the result\r\n\t//\r\n\tresult = createBody(referenceObject,worldReferenceObject);\r\n\tif (result)\r\n\t{\r\n\r\n\r\n\t\tresult->setWorld(world);\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Handle different attribute types (Object or pBSetup)\r\n\t\t//\r\n\r\n\t\tint attTypeOld = GetPMan()->GetPAttribute();\r\n\t\tint attTypeNew = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\r\n\t\tpObjectDescr *oDescr = NULL;\r\n\t\t\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// the old way : \r\n\t\t//\r\n\r\n\t\tif (referenceObject->HasAttribute(attTypeOld))\r\n\t\t{\r\n\t\t\tresult->retrieveSettingsFromAttribute();\r\n\t\t\toDescr = pFactory::Instance()->createPObjectDescrFromParameter(referenceObject->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\r\n\t\t\t\r\n\r\n\t\t}\r\n\t\t\r\n\t\tbool hierarchy = result->getFlags() & BF_Hierarchy;\r\n\t\tbool isDeformable = result->getFlags() & BF_Deformable;\r\n\t\tbool trigger = (result->getFlags() & BF_TriggerShape);\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// the new way \r\n\t\t//\r\n\r\n\t\tif (referenceObject->HasAttribute(attTypeNew))\r\n\t\t{\r\n\t\t\toDescr = new pObjectDescr();\r\n\r\n\t\t}\r\n\r\n\t\t\r\n\t\tresult->checkDataFlags();\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t/*\r\n\t\tpObjectDescr *oDescr = \r\n\t\tif (!oDescr)\r\n\t\t\treturn result;\r\n\r\n\t\t*/\r\n\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t//\tOlder versions have the hierarchy mode settings not the body flags\r\n\t\t//\tWe migrate it :\r\n\t\t//\r\n\r\n\t\tif (oDescr->hirarchy)\r\n\t\t{\r\n\t\t\tresult->setFlags( (result->getFlags() | BF_Hierarchy ));\r\n\t\t}\r\n\t\tif (hierarchy)\r\n\t\t{\r\n\t\t\toDescr->hirarchy = hierarchy;\r\n\t\t}\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t// Deformable ?\r\n\t\t//\r\n\r\n\t\t\r\n\t\tpCloth *cloth = NULL;\r\n\t\tpClothDesc cDescr;\r\n\t\t\r\n\t\tif (isDeformable)\r\n\t\t{\r\n\t\t\tcDescr.setToDefault();\r\n\t\t\tcDescr.worldReference = worldReferenceObject->GetID();\r\n\r\n\t\t\tif ( result->getFlags() & BF_Gravity )\r\n\t\t\t{\r\n\t\t\t\tcDescr.flags |= PCF_Gravity;\r\n\t\t\t}\r\n\r\n\t\t\tif ( result->getFlags() & BF_Collision )\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (!cloth)\r\n\t\t\t{\r\n\t\t\t\tcloth = pFactory::Instance()->createCloth(referenceObject,cDescr);\r\n\t\t\t\tif (!cloth)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : factory object failed !\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t// Some settings\r\n\t\t//\r\n\t\tif (result->getSkinWidth()==-1.0f)\r\n\t\t{\r\n\t\t\tresult->setSkinWidth(0.01f);\r\n\t\t}\r\n\r\n\t\tfloat radius = referenceObject->GetRadius();\r\n\t\tif (referenceObject->GetRadius() < 0.001f )\r\n\t\t{\r\n\t\t\tradius = 1.0f;\r\n\t\t}\r\n\r\n\t\tfloat density = result->getDensity();\r\n\t\tVxVector box_s= BoxGetZero(referenceObject);\r\n\t\t\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t// Calculate destination matrix \r\n\t\t//\r\n\r\n\t\tVxMatrix v_matrix ;\r\n\t\tVxVector position,scale;\t\t\r\n\t\tVxQuaternion quat;\t\r\n\r\n\r\n\t\tv_matrix = referenceObject->GetWorldMatrix();\r\n\t\tVx3DDecomposeMatrix(v_matrix,quat,position,scale);\r\n\t\t\r\n\t\tNxVec3 pos = pMath::getFrom(position);\r\n\t\tNxQuat rot = pMath::getFrom(quat);\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create actors description\r\n\t\tNxActorDesc actorDesc;actorDesc.setToDefault();\r\n\t\tNxBodyDesc bodyDesc;bodyDesc.setToDefault();\r\n\r\n\t\t\r\n\t\tNxMaterialDesc *materialDescr = NULL;\r\n\t\tNxMaterial *material = NULL;\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\tswitch(result->getHullType())\r\n\t\t{\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_Box:\r\n\t\t\t{\r\n\t\t\t\tNxBoxShapeDesc shape;\r\n\r\n\t\t\t\tif (! isDeformable )\r\n\t\t\t\t{\r\n\t\t\t\t\tshape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tshape.density = density;\r\n\t\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\r\n\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_Sphere:\r\n\t\t\t{\r\n\t\t\t\tNxSphereShapeDesc shape;\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (! isDeformable )\r\n\t\t\t\t{\r\n\t\t\t\t\tshape.radius = radius;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tshape.density = density;\r\n\t\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_Mesh:\r\n\t\t\t{\r\n\r\n\t\t\t\tif (! (result->getFlags() & BF_Deformable) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t//xLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Can not use a mesh as de\");\r\n\t\t\t\t\t//return NULL;\r\n\r\n\t\t\t\t}\r\n\t\r\n\t\t\t\tNxTriangleMeshDesc myMesh;\r\n\t\t\t\tmyMesh.setToDefault();\r\n\r\n\t\t\t\tcreateMesh(world->getScene(),referenceObject->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\t\tNxTriangleMeshShapeDesc shape;\r\n\t\t\t\tbool status = InitCooking();\r\n\t\t\t\tif (!status) {\r\n\t\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\t\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\t\tstatus = CookTriangleMesh(myMesh, buf);\r\n\t\t\t\tif (!status) {\r\n\t\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't cook mesh!\");\r\n\t\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\t\t\t\tshape.meshData\t= getManager()->getPhysicsSDK()->createTriangleMesh(MemoryReadBuffer(buf.data));\r\n\t\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\t\t\t\tCloseCooking();\r\n\r\n\t\t\t\tif (myMesh.points)\r\n\t\t\t\t{\r\n\t\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (myMesh.triangles)\r\n\t\t\t\t{\r\n\t\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_ConvexMesh:\r\n\t\t\t{\r\n\t\t\t\tif (referenceObject->GetCurrentMesh())\r\n\t\t\t\t{\r\n\t\t\t\t\tif (referenceObject->GetCurrentMesh()->GetVertexCount()>=256 )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Only 256 vertices for convex meshs allowed, by Ageia!\");\r\n\t\t\t\t\t\tgoto nothing;\r\n\t\t\t\t\t}\r\n\t\t\t\t}else\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Object has no mesh!\");\r\n\t\t\t\t\tgoto nothing;\r\n\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t\tNxConvexMeshDesc myMesh;\r\n\t\t\t\tmyMesh.setToDefault();\r\n\t\t\t\tcreateConvexMesh(world->getScene(),referenceObject->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\t\tNxConvexShapeDesc shape;\r\n\t\t\t\tbool status = InitCooking();\r\n\t\t\t\tif (!status) {\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\t\t\tgoto nothing;\r\n\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\t\tstatus = CookConvexMesh(myMesh, buf);\r\n\t\t\t\tif (!status) {\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't cook convex mesh!\");\r\n\t\t\t\t\t\tgoto nothing;\r\n\t\t\t\t}\r\n\t\t\t\tshape.meshData\t= getManager()->getPhysicsSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\t\t\t\tint h = shape.isValid();\r\n\t\t\t\tCloseCooking();\r\n\r\n\r\n\t\t\t\tif (myMesh.points)\r\n\t\t\t\t{\r\n\t\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (myMesh.triangles)\r\n\t\t\t\t{\r\n\t\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_ConvexCylinder:\r\n\t\t\t{\r\n\t\t\t\tNxConvexShapeDesc shape;\r\n\t\t\t\tif (!_createConvexCylinder(&shape,referenceObject))\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\r\n\t\t\t\tshape.density = density;\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\t\t\t\t\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcase HT_Capsule:\r\n\t\t\t{\r\n\r\n\t\t\t\tNxCapsuleShapeDesc shape;\r\n\r\n\t\t\t\tif ( !isDeformable )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tpCapsuleSettings cSettings;\r\n\t\t\t\t\t\r\n\t\t\t\t\tpFactory::Instance()->findSettings(cSettings,referenceObject);\r\n\t\t\t\t\t\r\n\t\t\t\t\tshape.radius = cSettings.radius > 0.0f ? cSettings.radius : box_s.v[cSettings.localRadiusAxis] * 0.5f;\r\n\t\t\t\t\tshape.height = cSettings.height > 0.0f ? cSettings.height : box_s.v[cSettings.localLengthAxis] - ( 2*shape.radius) ;\r\n\t\t\t\t}\r\n\t\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\t//\tshape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tcase HT_Wheel:\r\n\t\t\t{\r\n\t\t\t\t//\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\r\n\r\n\t\t\t\t/*\r\n\t\t\t\tNxWheelShapeDesc shape;\r\n\t\t\t\tshape.radius = box_s.z*0.5f;\r\n\t\t\t\tshape.density = density;\r\n\t\t\t\tif (result->getSkinWidth()!=-1.0f)\r\n\t\t\t\t\tshape.skinWidth = result->getSkinWidth();\r\n\r\n\t\t\t\tif (referenceObject && referenceObject->HasAttribute(GetPMan()->att_wheelDescr ))\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameter *par = referenceObject->GetAttributeParameter(GetPMan()->att_wheelDescr );\r\n\t\t\t\t\tif (par)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tpWheelDescr *wheelDescr = pFactory::Instance()->copyTo(par);\r\n\t\t\t\t\t\tif (wheelDescr)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tfloat heightModifier = (wheelDescr->wheelSuspension + radius ) / wheelDescr->wheelSuspension;\r\n\t\t\t\t\t\t\tshape.suspension.damper = wheelDescr->springDamping * heightModifier;\r\n\t\t\t\t\t\t\tshape.suspension.targetValue = wheelDescr->springBias * heightModifier;\r\n\t\t\t\t\t\t\tshape.suspensionTravel = wheelDescr->wheelSuspension;\r\n\r\n\t\t\t\t\t\t\tshape.lateralTireForceFunction.stiffnessFactor *= wheelDescr->frictionToSide;\r\n\t\t\t\t\t\t\tshape.longitudalTireForceFunction.stiffnessFactor*=wheelDescr->frictionToFront;\r\n\t\t\t\t\t\t\tshape.inverseWheelMass = 0.1;\r\n\t\t\t\t\t\t\tint isValid = shape.isValid();\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tXString name = result->GetVT3DObject()->GetName();\r\n\t\t\t\t\t\tname << \" needs to have an additional wheel attribute attached ! \";\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,name.CStr());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t*/\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//dynamic object ? \r\n\t\tif (result->getFlags() & BF_Moving){\r\n\t\t\tactorDesc.body = &bodyDesc;\r\n\t\t}\r\n\t\telse\r\n\t\t\tactorDesc.body = NULL;\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set transformations\r\n\t\tactorDesc.density = result->getDensity();\r\n\r\n\r\n\t\tif ( !isDeformable)\r\n\t\t{\r\n\t\t\tactorDesc.globalPose.t = pos;\t\r\n\t\t\tactorDesc.globalPose.M = rot;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//create the actor\r\n\r\n\t\tint v = actorDesc.isValid();\r\n\t\tNxActor *actor = world->getScene()->createActor(actorDesc);\r\n\t\tif (!actor)\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't create actor\");\r\n\t\t\tdelete result;\r\n\t\t\treturn NULL;\r\n\t\t\t\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//set additional settings : \r\n\t\tresult->setActor(actor);\r\n\t\tactor->setName(referenceObject->GetName());\r\n\t\tactor->userData= result;\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//Deformable : \r\n\t\tif (isDeformable && cloth)\r\n\t\t{\r\n\r\n\t\t\tpDeformableSettings dSettings;\r\n\t\t\tdSettings.ImpulsThresold = 50.0f;\r\n\t\t\tdSettings.PenetrationDepth= 0.1f ;\r\n\t\t\tdSettings.MaxDeform = 2.0f;\r\n\r\n\t\t\tCKParameterOut *poutDS = referenceObject->GetAttributeParameter(GetPMan()->att_deformable);\r\n\t\t\tif (poutDS)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(dSettings,poutDS);\r\n\t\t\t}\r\n\t\t\tcloth->attachToCore(referenceObject,dSettings.ImpulsThresold,dSettings.PenetrationDepth,dSettings.MaxDeform);\r\n\t\t\tresult->setCloth(cloth);\r\n\t\t}\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\tExtra settings : \r\n\t\t//\r\n\r\n\t\tif (result->getFlags() & BF_Moving)\r\n\t\t{\r\n\t\t\tVxVector massOffsetOut;referenceObject->Transform(&massOffsetOut,&result->getMassOffset());\r\n\t\t\tactor->setCMassOffsetGlobalPosition(pMath::getFrom(massOffsetOut));\r\n\t\t}\r\n\r\n\t\t\r\n\t\tif (result->getFlags() & BF_Kinematic)\r\n\t\t{\r\n\t\t\tresult->setKinematic(true);\r\n\t\t}\r\n\r\n\t\t\r\n\t\t\r\n\t\tif (result->getFlags() & BF_Moving )\r\n\t\t{\r\n\t\t\tresult->enableGravity(result->getFlags() & BF_Gravity);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Special Parameters\r\n\t\t//\r\n\r\n\t\t//-\tlook for optimization attribute :\r\n\t\tresult->checkForOptimization();\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// store mesh meta info in the first main mesh\r\n\t\t//\r\n\t\tNxShape *shape = result->getShapeByIndex();\r\n\t\tif (shape)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\t\t\tsInfo->entID = referenceObject->GetID();\r\n\t\t\tsInfo->refObject = (CKBeObject*)referenceObject;\r\n\t\t\tshape->userData = (void*)sInfo;\r\n\t\t\tresult->setMainShape(shape);\r\n\t\t\tshape->setName(referenceObject->GetName());\r\n\r\n\t\t\tpMaterial bMaterial;\r\n\t\t\tbool hasMaterial = pFactory::Instance()->findSettings(bMaterial,referenceObject);\r\n\t\t\tif (!hasMaterial)\r\n\t\t\t{\r\n\t\t\t\tif (world->getDefaultMaterial())\r\n\t\t\t\t{\r\n\t\t\t\t\tint z = (int)world->getDefaultMaterial()->userData;\r\n\t\t\t\t\tshape->setMaterial(world->getDefaultMaterial()->getMaterialIndex());\r\n\t\t\t\t\t//pFactory::Instance()->copyTo(bMaterial,world->getDefaultMaterial());\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\t\r\n\t\t\t\tNxMaterialDesc nxMatDescr;\r\n\t\t\t\tpFactory::Instance()->copyTo(nxMatDescr,bMaterial);\r\n\t\t\t\tNxMaterial *nxMaterial = world->getScene()->createMaterial(nxMatDescr);\r\n\t\t\t\tif (nxMaterial)\r\n\t\t\t\t{\r\n\t\t\t\t\tshape->setMaterial(nxMaterial->getMaterialIndex());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tresult->enableCollision( (result->getFlags() & BF_Collision), referenceObject );\r\n\r\n \r\n\t\t//- handle collisions setup\r\n\t\tif (oDescr->version == pObjectDescr::E_OD_VERSION::OD_DECR_V1)\r\n\t\t\tresult->updateCollisionSettings(*oDescr,referenceObject);\r\n\r\n\r\n\r\n\r\n\r\n\t\txLogger::xLog(ELOGINFO,E_LI_MANAGER,\"Rigid body creation successful : %s\",referenceObject->GetName());\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Parse hierarchy \r\n\t\t//\r\n\t\tif (!oDescr->hirarchy)\r\n\t\t\treturn result;\r\n\r\n\t\tCK3dEntity* subEntity = NULL;\r\n\t\twhile (subEntity= referenceObject->HierarchyParser(subEntity) )\r\n\t\t{\r\n\t\t\tif (subEntity->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t\t\t{\r\n\t\t\t\tpObjectDescr *subDescr = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//\r\n\t\t\t\t\t//\t\t\tRegular Mesh : \r\n\t\t\t\t\t//\r\n\r\n\t\t\t\t\tif (subDescr->hullType != HT_Cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult->addSubShape(NULL,*oDescr,subEntity);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//\r\n\t\t\t\t\t//\t\t\tCloth Mesh : \r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (subDescr->hullType == HT_Cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//pClothDesc *cloth = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (oDescr->hirarchy)\r\n\t\t{\r\n\t\t\r\n\r\n\t\t\tif (oDescr->newDensity!=0.0f || oDescr->totalMass!=0.0f )\r\n\t\t\t{\r\n\t\t\t\tresult->updateMassFromShapes(oDescr->newDensity,oDescr->totalMass);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\treturn result;\r\n\r\n\t}\r\n\tnothing:\r\n\r\n\t\r\n\r\n\treturn result;\r\n}\r\npRigidBody*pFactory::createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject)\r\n{\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tPseudo code : \r\n\t//\r\n\t//\t1. check the passed world, otherwise use+create the physic managers default world :\r\n\t//\t1. \r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tif (!referenceObject)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpWorld *world=GetPMan()->getWorld(worldReferenceObject,referenceObject);\r\n\tif (world)\r\n\t{\r\n\t\tint p = 0; \r\n\t}\r\n\r\n\tif (!world)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *result = new pRigidBody(referenceObject,world);\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\npRigidBody*pFactory::createBody(CK3dEntity *referenceObject,pObjectDescr description,CK3dEntity *worldReferenceObject/* =NULL */)\r\n{\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\tpRigidBody *result = NULL;\r\n\r\n\tif (!referenceObject)\r\n\t\treturn result;\r\n\r\n\tpWorld *world=getManager()->getWorld(worldReferenceObject,referenceObject); \r\n\tif (!world)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif (referenceObject->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(GetPMan()->GetPAttribute());\r\n\t}\r\n\treferenceObject->SetAttribute(GetPMan()->GetPAttribute());\r\n\r\n\r\n\tint htype = description.hullType;\r\n\tint flags = description.flags;\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HIRARCHY,&description.hirarchy);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HULLTYPE,&htype);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_BODY_FLAGS,&flags);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_DENSITY,&description.density);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_NEW_DENSITY,&description.newDensity);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_TOTAL_MASS,&description.totalMass);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&description.massOffset);\r\n\r\n\tCK_ID wid = world->getReference()->GetID();\r\n\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_WORLD,&wid);\r\n\r\n\tresult = pFactory::Instance()->createRigidBodyFull(referenceObject,world->getReference());\r\n\tif (result)\r\n\t{\r\n\t\tresult->translateLocalShapePosition(description.shapeOffset);\r\n\t\tresult->setCMassOffsetLocalPosition(description.massOffset);\r\n\t}\r\n\r\n\tif ( ! (description.flags & BF_AddAttributes) )\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(GetPMan()->GetPAttribute());\r\n\t}\r\n\r\n\treturn result;\r\n\r\n\r\n}\r\n\r\nCK3dEntity *pFactory::getMostTopParent(CK3dEntity*ent)\r\n{\r\n\r\n\tif (!ent)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCK3dEntity *result = ent->GetParent();\r\n\tif (result)\r\n\t{\r\n\t\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\t\t//if ( (!result->HasAttribute(GetPMan()->GetPAttribute())) || !(result->HasAttribute(attTypePBSetup)))\r\n\t\tif ( (result->HasAttribute(GetPMan()->GetPAttribute())) || (result->HasAttribute(attTypePBSetup)))\r\n\t\t{\r\n\t\t\treturn ent;\r\n\t\t}\r\n\t\tif (result->GetParent())\r\n\t\t{\r\n\t\t\treturn getMostTopParent(result);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\treturn ent;\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\n/*\r\ntemplateclass MODULE_API xImplementationObject2\r\n{\r\npublic:\r\n\r\n//xLinkedObjectStorage() : mInternalId(-1) , mClassId(-1) {};\r\ntypedef void* xImplementationObject2::*StoragePtr;\r\nxImplementationObject2(){}\r\nxImplementationObject2(StoragePtr storage)\r\n{ \r\n\r\n} \r\nvoid setStorage(StoragePtr* stPtr)\r\n{\r\nmStorage = stPtr;\r\n}\r\nT getImpl() { return mObject; }\r\n\r\n\r\nprotected:\r\nprivate:\r\nT mObject;\r\nStoragePtr mStorage;\r\n};\r\n\r\n\r\n\r\nclass ATest : public xImplementationObject2\r\n{\r\n\r\npublic: \r\n\r\nATest();\r\n};\r\n\r\nNxActor *actor = NULL;\r\n\r\nATest::ATest() : xImplementationObject2(actor->userData)\r\n{\r\n\r\n\r\n//\tsetStorage(actor->userData);\r\n\r\n}\r\n*/#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBGetVelocitiesAndForcesDecl();\r\nCKERROR CreatePBGetVelocitiesAndForcesProto(CKBehaviorPrototype **pproto);\r\nint PBGetVelocitiesAndForces(const CKBehaviorContext& behcontext);\r\nCKERROR PBGetVelocitiesAndForcesCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools;\r\nusing namespace BehaviorTools;\r\n\r\n\r\n\r\nenum bbI_Inputs\r\n{\r\n\tbbI_BodyReference,\r\n\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbO_Vel,\r\n\tbbO_AVel,\r\n\tbbO_Momentum,\r\n\tbbO_Torque,\r\n};\r\nBBParameter pOutMapPBGetPar2[] = \r\n{\r\n\tBB_SPOUT(bbO_Vel,CKPGUID_VECTOR,\"Linear Velocity\",\"\"),\r\n\tBB_SPOUT(bbO_AVel,CKPGUID_VECTOR,\"Angular Velocity\",\"\"),\r\n\tBB_SPOUT(bbO_Torque,CKPGUID_VECTOR,\"Linear Momentum\",\"\"),\r\n\tBB_SPOUT(bbO_Momentum,CKPGUID_VECTOR,\"Angular Momentum\",\"\"),\r\n\r\n};\r\n\r\n#define gOPMap pOutMapPBGetPar2\r\n\r\n\r\nCKERROR PBGetVelocitiesAndForcesCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tint cb = behcontext.CallbackMessage;\r\n\tBB_DECLARE_PMAP;\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t\t{\r\n\t\t\t\tBB_LOAD_POMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\t\t\t\tBB_DESTROY_PMAP;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\t{\r\n\t\t\t\tBB_INIT_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t\t{\r\n\t\t\t\tBB_REMAP_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBGetVelocitiesAndForcesDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBGetParEx\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Retrieves forces and velocities\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x1076b62,0x1dea09ed));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBGetVelocitiesAndForcesProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBGetVelocitiesAndForcesProto\r\n// FullName: CreatePBGetVelocitiesAndForcesProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBGetVelocitiesAndForcesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBGetParEx\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*! \\page PBGetParEx \r\n\r\n\tPBGetParEx is categorized in \\ref Vehicle\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRetrieves velocities and forces.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBGetParEx.png\r\n\tIn:triggers the process\r\n\t
\r\n\tOut:is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tLinear Velocity: The linear velocity.See pRigidBody::getLinearVelocity().\r\n\t
\r\n\tAngular Velocity: The angular velocity.See pRigidBody::getAngularVelocity().\r\n\t
\r\n\tAgular Momentum: The angular momentum.See pRigidBody::getAngularMomentum().\r\n\t
\r\n\tLinear Momentum: The linear momentum.See pRigidBody::getLinearMomentum(). \r\n\t
\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\t\\include PBGetEx.cpp\r\n\t\r\n\t*/\r\n\tproto->SetBehaviorCallbackFct( PBGetVelocitiesAndForcesCB );\r\n\r\n\r\n\tBB_EVALUATE_SETTINGS(gOPMap);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBGetVelocitiesAndForces);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBGetVelocitiesAndForces\r\n// FullName: PBGetVelocitiesAndForces\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBGetVelocitiesAndForces(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tBB_DECLARE_PMAP;\r\n\r\n\t\tBBSParameter(bbO_Vel);\r\n\t\tBBSParameter(bbO_AVel);\r\n\t\t\r\n\t\tBBSParameter(bbO_Torque);\r\n\t\tBBSParameter(bbO_Momentum);\r\n\r\n \r\n\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_Vel,body->getLinearVelocity());\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_AVel,body->getAngularVelocity());\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_Momentum,body->getLinearMomentum());\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_Vel,body->getLinearVelocity());\r\n\t\t\r\n\t}\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBGetVelocitiesAndForcesCB\r\n// FullName: PBGetVelocitiesAndForcesCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnl.h\"\n#include \"tnlAsymmetricKey.h\"\n#include \"tnlNetConnection.h\"\n#include \"tnlNetInterface.h\"\n#include \"tnlBitStream.h\"\n#include \"tnlRandom.h\"\n#include \"tnlNetObject.h\"\n#include \"tnlClientPuzzle.h\"\n#include \"tnlCertificate.h\"\n#include \n\nnamespace TNL {\n\n//-----------------------------------------------------------------------------\n// NetInterface initialization/destruction\n//-----------------------------------------------------------------------------\n\nNetInterface::NetInterface(const Address &bindAddress) : mSocket(bindAddress)\n{\n NetClassRep::initialize(); // initialize the net class reps, if they haven't been initialized already.\n\n mLastTimeoutCheckTime = 0;\n mAllowConnections = true;\n mRequiresKeyExchange = false;\n\n Random::read(mRandomHashData, sizeof(mRandomHashData));\n\n mConnectionHashTable.setSize(129);\n for(S32 i = 0; i < mConnectionHashTable.size(); i++)\n mConnectionHashTable[i] = NULL;\n mSendPacketList = NULL;\n mCurrentTime = Platform::getRealMilliseconds();\n}\n\nNetInterface::~NetInterface()\n{\n // gracefully close all the connections on this NetInterface:\n while(mConnectionList.size())\n {\n NetConnection *c = mConnectionList[0];\n disconnect(c, NetConnection::ReasonSelfDisconnect, \"Shutdown\");\n }\n}\n\nAddress NetInterface::getFirstBoundInterfaceAddress()\n{\n Address theAddress = mSocket.getBoundAddress();\n\n if(theAddress.isEqualAddress(Address(IPProtocol, Address::Any, 0)))\n {\n Vector
interfaceAddresses;\n Socket::getInterfaceAddresses(&interfaceAddresses);\n U16 savePort = theAddress.port;\n if(interfaceAddresses.size())\n {\n theAddress = interfaceAddresses[0];\n theAddress.port = savePort;\n }\n }\n return theAddress;\n}\n\nvoid NetInterface::setPrivateKey(AsymmetricKey *theKey)\n{\n mPrivateKey = theKey;\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface packet sending functions\n//-----------------------------------------------------------------------------\n\nNetError NetInterface::sendto(const Address &address, BitStream *stream)\n{\n return mSocket.sendto(address, stream->getBuffer(), stream->getBytePosition());\n}\n\nvoid NetInterface::sendtoDelayed(const Address &address, BitStream *stream, U32 millisecondDelay)\n{\n U32 dataSize = stream->getBytePosition();\n\n // allocate the send packet, with the data size added on\n DelaySendPacket *thePacket = (DelaySendPacket *) malloc(sizeof(DelaySendPacket) + dataSize);\n thePacket->remoteAddress = address;\n thePacket->sendTime = getCurrentTime() + millisecondDelay;\n thePacket->packetSize = dataSize;\n memcpy(thePacket->packetData, stream->getBuffer(), dataSize);\n\n // insert it into the DelaySendPacket list, sorted by time\n DelaySendPacket **list;\n for(list = &mSendPacketList; *list && ((*list)->sendTime < thePacket->sendTime); list = &((*list)->nextPacket))\n ;\n thePacket->nextPacket = *list;\n *list = thePacket;\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface utility functions\n//-----------------------------------------------------------------------------\n\nU32 NetInterface::computeClientIdentityToken(const Address &address, const Nonce &theNonce)\n{\n hash_state hashState;\n U32 hash[8];\n\n sha256_init(&hashState);\n sha256_process(&hashState, (const U8 *) &address, sizeof(Address));\n sha256_process(&hashState, theNonce.data, Nonce::NonceSize);\n sha256_process(&hashState, mRandomHashData, sizeof(mRandomHashData));\n sha256_done(&hashState, (U8 *) hash);\n\n return hash[0];\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface pending connection list management\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::addPendingConnection(NetConnection *connection)\n{\n // make sure we're not already connected to the host at the\n // connection's Address\n findAndRemovePendingConnection(connection->getNetAddress());\n NetConnection *temp = findConnection(connection->getNetAddress());\n if(temp)\n disconnect(temp, NetConnection::ReasonSelfDisconnect, \"Reconnecting\");\n\n // hang on to the connection and add it to the pending connection list\n connection->incRef();\n mPendingConnections.push_back(connection);\n}\n\nvoid NetInterface::removePendingConnection(NetConnection *connection)\n{\n // search the pending connection list for the specified connection\n // and remove it.\n for(S32 i = 0; i < mPendingConnections.size(); i++)\n if(mPendingConnections[i] == connection)\n {\n connection->decRef();\n mPendingConnections.erase(i);\n return;\n }\n}\n\nNetConnection *NetInterface::findPendingConnection(const Address &address)\n{\n // Loop through all the pending connections and compare the NetAddresses\n for(S32 i = 0; i < mPendingConnections.size(); i++)\n if(address == mPendingConnections[i]->getNetAddress())\n return mPendingConnections[i];\n return NULL;\n}\n\nvoid NetInterface::findAndRemovePendingConnection(const Address &address)\n{\n // Search through the list by Address and remove any connection\n // that matches.\n for(S32 i = 0; i < mPendingConnections.size(); i++)\n if(address == mPendingConnections[i]->getNetAddress())\n {\n mPendingConnections[i]->decRef();\n mPendingConnections.erase(i);\n return;\n }\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface connection list management\n//-----------------------------------------------------------------------------\n\nNetConnection *NetInterface::findConnection(const Address &addr)\n{\n // The connection hash table is a single vector, with hash collisions\n // resolved to the next open space in the table.\n\n // Compute the hash index based on the network address\n U32 hashIndex = addr.hash() % mConnectionHashTable.size();\n\n // Search through the table for an address that matches the source\n // address. If the connection pointer is NULL, we've found an\n // empty space and a connection with that address is not in the table\n while(mConnectionHashTable[hashIndex] != NULL)\n {\n if(addr == mConnectionHashTable[hashIndex]->getNetAddress())\n return mConnectionHashTable[hashIndex];\n hashIndex++;\n if(hashIndex >= (U32) mConnectionHashTable.size())\n hashIndex = 0;\n }\n return NULL;\n}\n\nvoid NetInterface::removeConnection(NetConnection *conn)\n{\n for(S32 i = 0; i < mConnectionList.size(); i++)\n {\n if(mConnectionList[i] == conn)\n {\n mConnectionList.erase_fast(i);\n break;\n }\n }\n U32 index = conn->getNetAddress().hash() % mConnectionHashTable.size();\n U32 startIndex = index;\n\n while(mConnectionHashTable[index] != conn)\n {\n index++;\n if(index >= (U32) mConnectionHashTable.size())\n index = 0;\n TNLAssert(index != startIndex, \"Attempting to remove a connection that is not in the table.\") // not in the table\n if(index == startIndex)\n return;\n }\n mConnectionHashTable[index] = NULL;\n\n // rehash all subsequent entries until we find a NULL entry:\n for(;;)\n {\n index++;\n if(index >= (U32) mConnectionHashTable.size())\n index = 0;\n if(!mConnectionHashTable[index])\n break;\n NetConnection *rehashConn = mConnectionHashTable[index];\n mConnectionHashTable[index] = NULL;\n U32 realIndex = rehashConn->getNetAddress().hash() % mConnectionHashTable.size();\n while(mConnectionHashTable[realIndex] != NULL)\n {\n realIndex++;\n if(realIndex >= (U32) mConnectionHashTable.size())\n realIndex = 0;\n }\n mConnectionHashTable[realIndex] = rehashConn;\n }\n conn->decRef();\n}\n\nvoid NetInterface::addConnection(NetConnection *conn)\n{\n conn->incRef();\n mConnectionList.push_back(conn);\n S32 numConnections = mConnectionList.size();\n if(numConnections > mConnectionHashTable.size() / 2)\n {\n mConnectionHashTable.setSize(numConnections * 4 - 1);\n for(S32 i = 0; i < mConnectionHashTable.size(); i++)\n mConnectionHashTable[i] = NULL;\n for(S32 i = 0; i < numConnections; i++)\n {\n U32 index = mConnectionList[i]->getNetAddress().hash() % mConnectionHashTable.size();\n while(mConnectionHashTable[index] != NULL)\n {\n index++;\n if(index >= (U32) mConnectionHashTable.size())\n index = 0;\n }\n mConnectionHashTable[index] = mConnectionList[i];\n }\n }\n else\n {\n U32 index = mConnectionList[numConnections - 1]->getNetAddress().hash() % mConnectionHashTable.size();\n while(mConnectionHashTable[index] != NULL)\n {\n index++;\n if(index >= (U32) mConnectionHashTable.size())\n index = 0;\n }\n mConnectionHashTable[index] = mConnectionList[numConnections - 1];\n }\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface timeout and packet send processing\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::processConnections()\n{\n mCurrentTime = Platform::getRealMilliseconds();\n mPuzzleManager.tick(mCurrentTime);\n\n // first see if there are any delayed packets that need to be sent...\n while(mSendPacketList && mSendPacketList->sendTime < getCurrentTime())\n {\n DelaySendPacket *next = mSendPacketList->nextPacket;\n mSocket.sendto(mSendPacketList->remoteAddress,\n mSendPacketList->packetData, mSendPacketList->packetSize);\n free(mSendPacketList);\n mSendPacketList = next;\n }\n\n NetObject::collapseDirtyList(); // collapse all the mask bits...\n for(S32 i = 0; i < mConnectionList.size(); i++)\n mConnectionList[i]->checkPacketSend(false, getCurrentTime());\n\n if(getCurrentTime() > mLastTimeoutCheckTime + TimeoutCheckInterval)\n {\n for(S32 i = 0; i < mPendingConnections.size();)\n {\n NetConnection *pending = mPendingConnections[i];\n\n if(pending->getConnectionState() == NetConnection::AwaitingChallengeResponse &&\n getCurrentTime() > pending->mConnectLastSendTime + ChallengeRetryTime)\n {\n if(pending->mConnectSendCount > ChallengeRetryCount)\n {\n pending->setConnectionState(NetConnection::ConnectTimedOut);\n pending->onConnectTerminated(NetConnection::ReasonTimedOut, \"Timeout\");\n removePendingConnection(pending);\n continue;\n }\n else\n sendConnectChallengeRequest(pending);\n }\n else if(pending->getConnectionState() == NetConnection::AwaitingConnectResponse &&\n getCurrentTime() > pending->mConnectLastSendTime + ConnectRetryTime)\n {\n if(pending->mConnectSendCount > ConnectRetryCount)\n {\n pending->setConnectionState(NetConnection::ConnectTimedOut);\n pending->onConnectTerminated(NetConnection::ReasonTimedOut, \"Timeout\");\n removePendingConnection(pending);\n continue;\n }\n else\n {\n if(pending->getConnectionParameters().mIsArranged)\n sendArrangedConnectRequest(pending);\n else\n sendConnectRequest(pending);\n }\n }\n else if(pending->getConnectionState() == NetConnection::SendingPunchPackets &&\n getCurrentTime() > pending->mConnectLastSendTime + PunchRetryTime)\n {\n if(pending->mConnectSendCount > PunchRetryCount)\n {\n pending->setConnectionState(NetConnection::ConnectTimedOut);\n pending->onConnectTerminated(NetConnection::ReasonTimedOut, \"Timeout\");\n removePendingConnection(pending);\n continue;\n }\n else\n sendPunchPackets(pending);\n }\n else if(pending->getConnectionState() == NetConnection::ComputingPuzzleSolution &&\n getCurrentTime() > pending->mConnectLastSendTime + PuzzleSolutionTimeout)\n {\n pending->setConnectionState(NetConnection::ConnectTimedOut);\n pending->onConnectTerminated(NetConnection::ReasonTimedOut, \"Timeout\");\n removePendingConnection(pending);\n }\n i++;\n }\n mLastTimeoutCheckTime = getCurrentTime();\n\n for(S32 i = 0; i < mConnectionList.size();)\n {\n if(mConnectionList[i]->checkTimeout(getCurrentTime()))\n {\n mConnectionList[i]->setConnectionState(NetConnection::TimedOut);\n mConnectionList[i]->onConnectionTerminated(NetConnection::ReasonTimedOut, \"Timeout\");\n removeConnection(mConnectionList[i]);\n }\n else\n i++;\n }\n }\n\n // check if we're trying to solve any client connection puzzles\n for(S32 i = 0; i < mPendingConnections.size(); i++)\n {\n if(mPendingConnections[i]->getConnectionState() == NetConnection::ComputingPuzzleSolution)\n {\n continuePuzzleSolution(mPendingConnections[i]);\n break;\n }\n }\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface incoming packet dispatch\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::checkIncomingPackets()\n{\n PacketStream stream;\n NetError error;\n Address sourceAddress;\n\n mCurrentTime = Platform::getRealMilliseconds();\n\n // read out all the available packets:\n while((error = stream.recvfrom(mSocket, &sourceAddress)) == NoError)\n processPacket(sourceAddress, &stream);\n}\n\nvoid NetInterface::processPacket(const Address &sourceAddress, BitStream *pStream)\n{\n\n // Determine what to do with this packet:\n\n if(pStream->getBuffer()[0] & 0x80) // it's a protocol packet...\n {\n // if the LSB of the first byte is set, it's a game data packet\n // so pass it to the appropriate connection.\n\n // lookup the connection in the addressTable\n // if this packet causes a disconnection, keep the conn around until this function exits\n RefPtr conn = findConnection(sourceAddress);\n if(conn)\n conn->readRawPacket(pStream);\n }\n else\n {\n // Otherwise, it's either a game info packet or a\n // connection handshake packet.\n\n U8 packetType;\n pStream->read(&packetType);\n\n if(packetType >= FirstValidInfoPacketId)\n handleInfoPacket(sourceAddress, packetType, pStream);\n else\n {\n // check if there's a connection already:\n switch(packetType)\n {\n case ConnectChallengeRequest:\n handleConnectChallengeRequest(sourceAddress, pStream);\n break;\n case ConnectChallengeResponse:\n handleConnectChallengeResponse(sourceAddress, pStream);\n break;\n case ConnectRequest:\n handleConnectRequest(sourceAddress, pStream);\n break;\n case ConnectReject:\n handleConnectReject(sourceAddress, pStream);\n break;\n case ConnectAccept:\n handleConnectAccept(sourceAddress, pStream);\n break;\n case Disconnect:\n handleDisconnect(sourceAddress, pStream);\n break;\n case Punch:\n handlePunch(sourceAddress, pStream);\n break;\n case ArrangedConnectRequest:\n handleArrangedConnectRequest(sourceAddress, pStream);\n break;\n\t\t\tcase BroadcastMessage:\n\t\t\t\thandleBroadcastMessage(sourceAddress,pStream);\n\t\t\t\tbreak;\n }\n }\n }\n}\n\nvoid\nNetInterface::handleBroadcastMessage(const Address &theAddress, BitStream *stream)\n{\n\n}\n\nvoid NetInterface::handleInfoPacket(const Address &address, U8 packetType, BitStream *stream)\n{\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface connection handshake initiaton and processing\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::startConnection(NetConnection *conn)\n{\n TNLAssert(conn->getConnectionState() == NetConnection::NotConnected,\n \"Cannot start unless it is in the NotConnected state.\");\n\n addPendingConnection(conn);\n conn->mConnectSendCount = 0;\n conn->setConnectionState(NetConnection::AwaitingChallengeResponse);\n sendConnectChallengeRequest(conn);\n}\n\nvoid NetInterface::sendConnectChallengeRequest(NetConnection *conn)\n{\n TNLLogMessageV(LogNetInterface, (\"Sending Connect Challenge Request to %s\", conn->getNetAddress().toString()));\n PacketStream out;\n out.write(U8(ConnectChallengeRequest));\n ConnectionParameters &params = conn->getConnectionParameters();\n params.mNonce.write(&out);\n out.writeFlag(params.mRequestKeyExchange);\n out.writeFlag(params.mRequestCertificate);\n \n conn->mConnectSendCount++;\n conn->mConnectLastSendTime = getCurrentTime();\n out.sendto(mSocket, conn->getNetAddress());\n}\n\nvoid NetInterface::handleConnectChallengeRequest(const Address &addr, BitStream *stream)\n{\n TNLLogMessageV(LogNetInterface, (\"Received Connect Challenge Request from %s\", addr.toString()));\n\n if(!mAllowConnections)\n return;\n Nonce clientNonce;\n clientNonce.read(stream);\n bool wantsKeyExchange = stream->readFlag();\n bool wantsCertificate = stream->readFlag();\n\n sendConnectChallengeResponse(addr, clientNonce, wantsKeyExchange, wantsCertificate);\n}\n\nvoid NetInterface::sendConnectChallengeResponse(const Address &addr, Nonce &clientNonce, bool wantsKeyExchange, bool wantsCertificate)\n{\n PacketStream out;\n out.write(U8(ConnectChallengeResponse));\n clientNonce.write(&out);\n \n U32 identityToken = computeClientIdentityToken(addr, clientNonce);\n out.write(identityToken);\n\n // write out a client puzzle\n Nonce serverNonce = mPuzzleManager.getCurrentNonce();\n U32 difficulty = mPuzzleManager.getCurrentDifficulty();\n serverNonce.write(&out);\n out.write(difficulty);\n\n if(out.writeFlag(mRequiresKeyExchange || (wantsKeyExchange && !mPrivateKey.isNull())))\n {\n if(out.writeFlag(wantsCertificate && !mCertificate.isNull()))\n out.write(mCertificate);\n else\n out.write(mPrivateKey->getPublicKey());\n }\n TNLLogMessageV(LogNetInterface, (\"Sending Challenge Response: %8x\", identityToken));\n\n out.sendto(mSocket, addr);\n}\n\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::handleConnectChallengeResponse(const Address &address, BitStream *stream)\n{\n NetConnection *conn = findPendingConnection(address);\n if(!conn || conn->getConnectionState() != NetConnection::AwaitingChallengeResponse)\n return;\n \n Nonce theNonce;\n theNonce.read(stream);\n\n ConnectionParameters &theParams = conn->getConnectionParameters();\n if(theNonce != theParams.mNonce)\n return;\n\n stream->read(&theParams.mClientIdentity);\n\n // see if the server wants us to solve a client puzzle\n theParams.mServerNonce.read(stream);\n stream->read(&theParams.mPuzzleDifficulty);\n\n if(theParams.mPuzzleDifficulty > ClientPuzzleManager::MaxPuzzleDifficulty)\n return;\n\n // see if the connection needs to be authenticated or uses key exchange\n if(stream->readFlag())\n {\n if(stream->readFlag())\n {\n theParams.mCertificate = new Certificate(stream);\n if(!theParams.mCertificate->isValid() || !conn->validateCertficate(theParams.mCertificate, true))\n return; \n theParams.mPublicKey = theParams.mCertificate->getPublicKey();\n }\n else\n {\n theParams.mPublicKey = new AsymmetricKey(stream);\n if(!theParams.mPublicKey->isValid() || !conn->validatePublicKey(theParams.mPublicKey, true))\n return;\n }\n if(mPrivateKey.isNull() || mPrivateKey->getKeySize() != theParams.mPublicKey->getKeySize())\n {\n // we don't have a private key, so generate one for this connection\n theParams.mPrivateKey = new AsymmetricKey(theParams.mPublicKey->getKeySize());\n }\n else\n theParams.mPrivateKey = mPrivateKey;\n theParams.mSharedSecret = theParams.mPrivateKey->computeSharedSecretKey(theParams.mPublicKey);\n logprintf(\"shared secret (client) %s\", theParams.mSharedSecret->encodeBase64()->getBuffer());\n Random::read(theParams.mSymmetricKey, SymmetricCipher::KeySize);\n theParams.mUsingCrypto = true;\n }\n\n TNLLogMessageV(LogNetInterface, (\"Received Challenge Response: %8x\", theParams.mClientIdentity ));\n\n conn->setConnectionState(NetConnection::ComputingPuzzleSolution);\n conn->mConnectSendCount = 0;\n\n theParams.mPuzzleSolution = 0;\n conn->mConnectLastSendTime = getCurrentTime();\n continuePuzzleSolution(conn); \n}\n\nvoid NetInterface::continuePuzzleSolution(NetConnection *conn)\n{\n ConnectionParameters &theParams = conn->getConnectionParameters();\n bool solved = ClientPuzzleManager::solvePuzzle(&theParams.mPuzzleSolution, theParams.mNonce, theParams.mServerNonce, theParams.mPuzzleDifficulty, theParams.mClientIdentity);\n\n if(solved)\n {\n //logprintf(\"Client puzzle solved in %d ms.\", Platform::getRealMilliseconds() - conn->mConnectLastSendTime);\n conn->setConnectionState(NetConnection::AwaitingConnectResponse);\n sendConnectRequest(conn);\n }\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface connect request\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::sendConnectRequest(NetConnection *conn)\n{\n TNLLogMessageV(LogNetInterface, (\"Sending Connect Request\"));\n PacketStream out;\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n out.write(U8(ConnectRequest));\n theParams.mNonce.write(&out);\n theParams.mServerNonce.write(&out);\n out.write(theParams.mClientIdentity);\n out.write(theParams.mPuzzleDifficulty);\n out.write(theParams.mPuzzleSolution);\n\n U32 encryptPos = 0;\n\n if(out.writeFlag(theParams.mUsingCrypto))\n {\n out.write(theParams.mPrivateKey->getPublicKey());\n encryptPos = out.getBytePosition();\n out.setBytePosition(encryptPos);\n out.write(SymmetricCipher::KeySize, theParams.mSymmetricKey);\n }\n out.writeFlag(theParams.mDebugObjectSizes);\n out.write(conn->getInitialSendSequence());\n out.writeString(conn->getClassName());\n conn->writeConnectRequest(&out);\n\n if(encryptPos)\n {\n // if we're using crypto on this connection,\n // then write a hash of everything we wrote into the packet\n // key. Then we'll symmetrically encrypt the packet from\n // the end of the public key to the end of the signature.\n\n SymmetricCipher theCipher(theParams.mSharedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher); \n }\n\n conn->mConnectSendCount++;\n conn->mConnectLastSendTime = getCurrentTime();\n\n out.sendto(mSocket, conn->getNetAddress());\n}\n\nvoid NetInterface::handleConnectRequest(const Address &address, BitStream *stream)\n{\n if(!mAllowConnections)\n return;\n\n ConnectionParameters theParams;\n theParams.mNonce.read(stream);\n theParams.mServerNonce.read(stream);\n stream->read(&theParams.mClientIdentity);\n\n if(theParams.mClientIdentity != computeClientIdentityToken(address, theParams.mNonce))\n return;\n\n stream->read(&theParams.mPuzzleDifficulty);\n stream->read(&theParams.mPuzzleSolution);\n\n // see if the connection is in the main connection table.\n // If the connection is in the connection table and it has\n // the same initiatorSequence, we'll just resend the connect\n // acceptance packet, assuming that the last time we sent it\n // it was dropped.\n NetConnection *connect = findConnection(address);\n if(connect)\n {\n ConnectionParameters &cp = connect->getConnectionParameters();\n if(cp.mNonce == theParams.mNonce && cp.mServerNonce == theParams.mServerNonce)\n {\n sendConnectAccept(connect);\n return;\n }\n }\n\n // check the puzzle solution\n ClientPuzzleManager::ErrorCode result = mPuzzleManager.checkSolution(\n theParams.mPuzzleSolution, theParams.mNonce, theParams.mServerNonce,\n theParams.mPuzzleDifficulty, theParams.mClientIdentity);\n\n if(result != ClientPuzzleManager::Success)\n {\n sendConnectReject(&theParams, address, \"Puzzle\");\n return;\n }\n\n if(stream->readFlag())\n {\n if(mPrivateKey.isNull())\n return;\n\n theParams.mUsingCrypto = true;\n theParams.mPublicKey = new AsymmetricKey(stream);\n theParams.mPrivateKey = mPrivateKey;\n\n U32 decryptPos = stream->getBytePosition();\n\n stream->setBytePosition(decryptPos);\n theParams.mSharedSecret = theParams.mPrivateKey->computeSharedSecretKey(theParams.mPublicKey);\n logprintf(\"shared secret (server) %s\", theParams.mSharedSecret->encodeBase64()->getBuffer());\n\n SymmetricCipher theCipher(theParams.mSharedSecret);\n\n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, decryptPos, &theCipher))\n return;\n\n // now read the first part of the connection's symmetric key\n stream->read(SymmetricCipher::KeySize, theParams.mSymmetricKey);\n Random::read(theParams.mInitVector, SymmetricCipher::KeySize);\n }\n\n U32 connectSequence;\n theParams.mDebugObjectSizes = stream->readFlag();\n stream->read(&connectSequence);\n TNLLogMessageV(LogNetInterface, (\"Received Connect Request %8x\", theParams.mClientIdentity));\n\n if(connect)\n disconnect(connect, NetConnection::ReasonSelfDisconnect, \"NewConnection\");\n\n char connectionClass[256];\n stream->readString(connectionClass);\n\n NetConnection *conn = NetConnectionRep::create(connectionClass);\n\n if(!conn)\n return;\n\n RefPtr theConnection = conn;\n conn->getConnectionParameters() = theParams;\n\n conn->setNetAddress(address);\n conn->setInitialRecvSequence(connectSequence);\n conn->setInterface(this);\n\n if(theParams.mUsingCrypto)\n conn->setSymmetricCipher(new SymmetricCipher(theParams.mSymmetricKey, theParams.mInitVector));\n\n const char *errorString = NULL;\n if(!conn->readConnectRequest(stream, &errorString))\n {\n sendConnectReject(&theParams, address, errorString);\n return;\n }\n addConnection(conn);\n conn->setConnectionState(NetConnection::Connected);\n conn->onConnectionEstablished();\n sendConnectAccept(conn);\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface connection acceptance and handling\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::sendConnectAccept(NetConnection *conn)\n{\n TNLLogMessageV(LogNetInterface, (\"Sending Connect Accept - connection established.\"));\n\n PacketStream out;\n out.write(U8(ConnectAccept));\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n theParams.mNonce.write(&out);\n theParams.mServerNonce.write(&out);\n U32 encryptPos = out.getBytePosition();\n out.setBytePosition(encryptPos);\n\n out.write(conn->getInitialSendSequence());\n conn->writeConnectAccept(&out);\n\n if(theParams.mUsingCrypto)\n {\n out.write(SymmetricCipher::KeySize, theParams.mInitVector);\n SymmetricCipher theCipher(theParams.mSharedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher);\n }\n out.sendto(mSocket, conn->getNetAddress());\n}\n\nvoid NetInterface::handleConnectAccept(const Address &address, BitStream *stream)\n{\n Nonce nonce, serverNonce;\n\n nonce.read(stream);\n serverNonce.read(stream);\n U32 decryptPos = stream->getBytePosition();\n stream->setBytePosition(decryptPos);\n\n NetConnection *conn = findPendingConnection(address);\n if(!conn || conn->getConnectionState() != NetConnection::AwaitingConnectResponse)\n return;\n\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n if(theParams.mNonce != nonce || theParams.mServerNonce != serverNonce)\n return;\n\n if(theParams.mUsingCrypto)\n {\n SymmetricCipher theCipher(theParams.mSharedSecret);\n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, decryptPos, &theCipher))\n return;\n }\n U32 recvSequence;\n stream->read(&recvSequence);\n conn->setInitialRecvSequence(recvSequence);\n\n const char *errorString = NULL;\n if(!conn->readConnectAccept(stream, &errorString))\n {\n removePendingConnection(conn);\n return;\n }\n if(theParams.mUsingCrypto)\n {\n stream->read(SymmetricCipher::KeySize, theParams.mInitVector);\n conn->setSymmetricCipher(new SymmetricCipher(theParams.mSymmetricKey, theParams.mInitVector));\n }\n\n addConnection(conn); // first, add it as a regular connection\n removePendingConnection(conn); // remove from the pending connection list\n\n conn->setConnectionState(NetConnection::Connected);\n conn->onConnectionEstablished(); // notify the connection that it has been established\n TNLLogMessageV(LogNetInterface, (\"Received Connect Accept - connection established.\"));\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface connection rejection and handling\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::sendConnectReject(ConnectionParameters *conn, const Address &theAddress, const char *reason)\n{\n if(!reason)\n return; // if the stream is NULL, we reject silently\n\n PacketStream out;\n out.write(U8(ConnectReject));\n conn->mNonce.write(&out);\n conn->mServerNonce.write(&out);\n out.writeString(reason);\n out.sendto(mSocket, theAddress);\n}\n\nvoid NetInterface::handleConnectReject(const Address &address, BitStream *stream)\n{\n Nonce nonce;\n Nonce serverNonce;\n\n nonce.read(stream);\n serverNonce.read(stream);\n\n NetConnection *conn = findPendingConnection(address);\n if(!conn || (conn->getConnectionState() != NetConnection::AwaitingChallengeResponse &&\n conn->getConnectionState() != NetConnection::AwaitingConnectResponse))\n return;\n ConnectionParameters &p = conn->getConnectionParameters();\n if(p.mNonce != nonce || p.mServerNonce != serverNonce)\n return;\n\n char reason[256];\n stream->readString(reason);\n\n TNLLogMessageV(LogNetInterface, (\"Received Connect Reject - reason %s\", reason));\n // if the reason is a bad puzzle solution, try once more with a\n // new nonce.\n if(!strcmp(reason, \"Puzzle\") && !p.mPuzzleRetried)\n {\n p.mPuzzleRetried = true;\n conn->setConnectionState(NetConnection::AwaitingChallengeResponse);\n conn->mConnectSendCount = 0;\n p.mNonce.getRandom();\n sendConnectChallengeRequest(conn);\n return;\n }\n\n conn->setConnectionState(NetConnection::ConnectRejected);\n conn->onConnectTerminated(NetConnection::ReasonRemoteHostRejectedConnection, reason);\n removePendingConnection(conn);\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface arranged connection process\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::startArrangedConnection(NetConnection *conn)\n{\n\n conn->setConnectionState(NetConnection::SendingPunchPackets);\n addPendingConnection(conn);\n conn->mConnectSendCount = 0;\n conn->mConnectLastSendTime = getCurrentTime();\n sendPunchPackets(conn);\n}\n\nvoid NetInterface::sendPunchPackets(NetConnection *conn)\n{\n ConnectionParameters &theParams = conn->getConnectionParameters();\n PacketStream out;\n out.write(U8(Punch));\n\n if(theParams.mIsInitiator)\n theParams.mNonce.write(&out);\n else\n theParams.mServerNonce.write(&out);\n\n U32 encryptPos = out.getBytePosition();\n out.setBytePosition(encryptPos);\n\n if(theParams.mIsInitiator)\n theParams.mServerNonce.write(&out);\n else\n {\n theParams.mNonce.write(&out);\n if(out.writeFlag(mRequiresKeyExchange || (theParams.mRequestKeyExchange && !mPrivateKey.isNull())))\n {\n if(out.writeFlag(theParams.mRequestCertificate && !mCertificate.isNull()))\n out.write(mCertificate);\n else\n out.write(mPrivateKey->getPublicKey());\n }\n }\n SymmetricCipher theCipher(theParams.mArrangedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher);\n\n for(S32 i = 0; i < theParams.mPossibleAddresses.size(); i++)\n {\n out.sendto(mSocket, theParams.mPossibleAddresses[i]);\n\n TNLLogMessageV(LogNetInterface, (\"Sending punch packet (%s, %s) to %s\",\n ByteBuffer(theParams.mNonce.data, Nonce::NonceSize).encodeBase64()->getBuffer(),\n ByteBuffer(theParams.mServerNonce.data, Nonce::NonceSize).encodeBase64()->getBuffer(),\n theParams.mPossibleAddresses[i].toString()));\n }\n conn->mConnectSendCount++;\n conn->mConnectLastSendTime = getCurrentTime();\n}\n\nvoid NetInterface::handlePunch(const Address &theAddress, BitStream *stream)\n{\n S32 i, j;\n NetConnection *conn;\n\n Nonce firstNonce;\n firstNonce.read(stream);\n\n ByteBuffer b(firstNonce.data, Nonce::NonceSize);\n\n TNLLogMessageV(LogNetInterface, (\"Received punch packet from %s - %s\", theAddress.toString(), b.encodeBase64()->getBuffer()));\n\n for(i = 0; i < mPendingConnections.size(); i++)\n {\n conn = mPendingConnections[i];\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n if(conn->getConnectionState() != NetConnection::SendingPunchPackets)\n continue;\n\n if((theParams.mIsInitiator && firstNonce != theParams.mServerNonce) ||\n (!theParams.mIsInitiator && firstNonce != theParams.mNonce))\n continue;\n\n // first see if the address is in the possible addresses list:\n \n for(j = 0; j < theParams.mPossibleAddresses.size(); j++)\n if(theAddress == theParams.mPossibleAddresses[j])\n break;\n\n // if there was an exact match, just exit the loop, or\n // continue on to the next pending if this is not an initiator:\n if(j != theParams.mPossibleAddresses.size())\n {\n if(theParams.mIsInitiator)\n break;\n else\n continue;\n }\n\n // if there was no exact match, we may have a funny NAT in the\n // middle. But since a packet got through from the remote host\n // we'll want to send a punch to the address it came from, as long\n // as only the port is not an exact match:\n for(j = 0; j < theParams.mPossibleAddresses.size(); j++)\n if(theAddress.isEqualAddress(theParams.mPossibleAddresses[j]))\n break;\n\n // if the address wasn't even partially in the list, just exit out\n if(j == theParams.mPossibleAddresses.size())\n continue;\n\n // otherwise, as long as we don't have too many ping addresses,\n // add this one to the list:\n if(theParams.mPossibleAddresses.size() < 5)\n theParams.mPossibleAddresses.push_back(theAddress); \n\n // if this is the initiator of the arranged connection, then\n // process the punch packet from the remote host by issueing a\n // connection request.\n if(theParams.mIsInitiator)\n break;\n }\n if(i == mPendingConnections.size())\n return;\n\n ConnectionParameters &theParams = conn->getConnectionParameters();\n SymmetricCipher theCipher(theParams.mArrangedSecret);\n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, stream->getBytePosition(), &theCipher))\n return;\n\n Nonce nextNonce;\n nextNonce.read(stream);\n\n if(nextNonce != theParams.mNonce)\n return;\n\n // see if the connection needs to be authenticated or uses key exchange\n if(stream->readFlag())\n {\n if(stream->readFlag())\n {\n theParams.mCertificate = new Certificate(stream);\n if(!theParams.mCertificate->isValid() || !conn->validateCertficate(theParams.mCertificate, true))\n return; \n theParams.mPublicKey = theParams.mCertificate->getPublicKey();\n }\n else\n {\n theParams.mPublicKey = new AsymmetricKey(stream);\n if(!theParams.mPublicKey->isValid() || !conn->validatePublicKey(theParams.mPublicKey, true))\n return;\n }\n if(mPrivateKey.isNull() || mPrivateKey->getKeySize() != theParams.mPublicKey->getKeySize())\n {\n // we don't have a private key, so generate one for this connection\n theParams.mPrivateKey = new AsymmetricKey(theParams.mPublicKey->getKeySize());\n }\n else\n theParams.mPrivateKey = mPrivateKey;\n theParams.mSharedSecret = theParams.mPrivateKey->computeSharedSecretKey(theParams.mPublicKey);\n //logprintf(\"shared secret (client) %s\", theParams.mSharedSecret->encodeBase64()->getBuffer());\n Random::read(theParams.mSymmetricKey, SymmetricCipher::KeySize);\n theParams.mUsingCrypto = true;\n }\n conn->setNetAddress(theAddress);\n TNLLogMessageV(LogNetInterface, (\"Punch from %s matched nonces - connecting...\", theAddress.toString()));\n\n conn->setConnectionState(NetConnection::AwaitingConnectResponse);\n conn->mConnectSendCount = 0;\n conn->mConnectLastSendTime = getCurrentTime();\n\n sendArrangedConnectRequest(conn);\n}\n\nvoid NetInterface::sendArrangedConnectRequest(NetConnection *conn)\n{\n TNLLogMessageV(LogNetInterface, (\"Sending Arranged Connect Request\"));\n PacketStream out;\n\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n out.write(U8(ArrangedConnectRequest));\n theParams.mNonce.write(&out);\n U32 encryptPos = out.getBytePosition();\n U32 innerEncryptPos = 0;\n\n out.setBytePosition(encryptPos);\n\n theParams.mServerNonce.write(&out);\n if(out.writeFlag(theParams.mUsingCrypto))\n {\n out.write(theParams.mPrivateKey->getPublicKey());\n innerEncryptPos = out.getBytePosition();\n out.setBytePosition(innerEncryptPos);\n out.write(SymmetricCipher::KeySize, theParams.mSymmetricKey);\n }\n out.writeFlag(theParams.mDebugObjectSizes);\n out.write(conn->getInitialSendSequence());\n conn->writeConnectRequest(&out);\n\n if(innerEncryptPos)\n {\n SymmetricCipher theCipher(theParams.mSharedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, innerEncryptPos, &theCipher);\n }\n SymmetricCipher theCipher(theParams.mArrangedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher);\n\n conn->mConnectSendCount++;\n conn->mConnectLastSendTime = getCurrentTime();\n\n out.sendto(mSocket, conn->getNetAddress());\n}\n\nvoid NetInterface::handleArrangedConnectRequest(const Address &theAddress, BitStream *stream)\n{\n S32 i, j;\n NetConnection *conn;\n Nonce nonce, serverNonce;\n nonce.read(stream);\n\n // see if the connection is in the main connection table.\n // If the connection is in the connection table and it has\n // the same initiatorSequence, we'll just resend the connect\n // acceptance packet, assuming that the last time we sent it\n // it was dropped.\n NetConnection *oldConnection = findConnection(theAddress);\n if(oldConnection)\n {\n ConnectionParameters &cp = oldConnection->getConnectionParameters();\n if(cp.mNonce == nonce)\n {\n sendConnectAccept(oldConnection);\n return;\n }\n }\n\n for(i = 0; i < mPendingConnections.size(); i++)\n {\n conn = mPendingConnections[i];\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n if(conn->getConnectionState() != NetConnection::SendingPunchPackets || theParams.mIsInitiator)\n continue;\n\n if(nonce != theParams.mNonce)\n continue;\n\n for(j = 0; j < theParams.mPossibleAddresses.size(); j++)\n if(theAddress.isEqualAddress(theParams.mPossibleAddresses[j]))\n break;\n if(j != theParams.mPossibleAddresses.size())\n break;\n }\n if(i == mPendingConnections.size())\n return;\n \n ConnectionParameters &theParams = conn->getConnectionParameters();\n SymmetricCipher theCipher(theParams.mArrangedSecret);\n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, stream->getBytePosition(), &theCipher))\n return;\n\n stream->setBytePosition(stream->getBytePosition());\n\n serverNonce.read(stream);\n if(serverNonce != theParams.mServerNonce)\n return;\n\n if(stream->readFlag())\n {\n if(mPrivateKey.isNull())\n return;\n theParams.mUsingCrypto = true;\n theParams.mPublicKey = new AsymmetricKey(stream);\n theParams.mPrivateKey = mPrivateKey;\n\n U32 decryptPos = stream->getBytePosition();\n stream->setBytePosition(decryptPos);\n theParams.mSharedSecret = theParams.mPrivateKey->computeSharedSecretKey(theParams.mPublicKey);\n SymmetricCipher theCipher(theParams.mSharedSecret);\n \n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, decryptPos, &theCipher))\n return;\n\n // now read the first part of the connection's session (symmetric) key\n stream->read(SymmetricCipher::KeySize, theParams.mSymmetricKey);\n Random::read(theParams.mInitVector, SymmetricCipher::KeySize);\n }\n\n U32 connectSequence;\n theParams.mDebugObjectSizes = stream->readFlag();\n stream->read(&connectSequence);\n TNLLogMessageV(LogNetInterface, (\"Received Arranged Connect Request\"));\n\n if(oldConnection)\n disconnect(oldConnection, NetConnection::ReasonSelfDisconnect, \"\");\n\n conn->setNetAddress(theAddress);\n conn->setInitialRecvSequence(connectSequence);\n if(theParams.mUsingCrypto)\n conn->setSymmetricCipher(new SymmetricCipher(theParams.mSymmetricKey, theParams.mInitVector));\n\n const char *errorString = NULL;\n if(!conn->readConnectRequest(stream, &errorString))\n {\n sendConnectReject(&theParams, theAddress, errorString);\n removePendingConnection(conn);\n return;\n }\n addConnection(conn);\n removePendingConnection(conn);\n conn->setConnectionState(NetConnection::Connected);\n conn->onConnectionEstablished();\n sendConnectAccept(conn);\n}\n\n//-----------------------------------------------------------------------------\n// NetInterface disconnection and handling\n//-----------------------------------------------------------------------------\n\nvoid NetInterface::disconnect(NetConnection *conn, NetConnection::TerminationReason reason, const char *reasonString)\n{\n if(conn->getConnectionState() == NetConnection::AwaitingChallengeResponse ||\n conn->getConnectionState() == NetConnection::AwaitingConnectResponse)\n {\n conn->onConnectTerminated(reason, reasonString);\n removePendingConnection(conn);\n }\n else if(conn->getConnectionState() == NetConnection::Connected)\n {\n conn->setConnectionState(NetConnection::Disconnected);\n conn->onConnectionTerminated(reason, reasonString);\n if(conn->isNetworkConnection())\n {\n // send a disconnect packet...\n PacketStream out;\n out.write(U8(Disconnect));\n ConnectionParameters &theParams = conn->getConnectionParameters();\n theParams.mNonce.write(&out);\n theParams.mServerNonce.write(&out);\n U32 encryptPos = out.getBytePosition();\n out.setBytePosition(encryptPos);\n out.writeString(reasonString);\n\n if(theParams.mUsingCrypto)\n {\n SymmetricCipher theCipher(theParams.mSharedSecret);\n out.hashAndEncrypt(NetConnection::MessageSignatureBytes, encryptPos, &theCipher);\n }\n out.sendto(mSocket, conn->getNetAddress());\n }\n removeConnection(conn);\n }\n}\n\nvoid NetInterface::handleDisconnect(const Address &address, BitStream *stream)\n{\n NetConnection *conn = findConnection(address);\n if(!conn)\n return;\n\n ConnectionParameters &theParams = conn->getConnectionParameters();\n\n Nonce nonce, serverNonce;\n char reason[256];\n\n nonce.read(stream);\n serverNonce.read(stream);\n\n if(nonce != theParams.mNonce || serverNonce != theParams.mServerNonce)\n return;\n\n U32 decryptPos = stream->getBytePosition();\n stream->setBytePosition(decryptPos);\n\n if(theParams.mUsingCrypto)\n {\n SymmetricCipher theCipher(theParams.mSharedSecret);\n if(!stream->decryptAndCheckHash(NetConnection::MessageSignatureBytes, decryptPos, &theCipher))\n return;\n }\n stream->readString(reason);\n\n conn->setConnectionState(NetConnection::Disconnected);\n conn->onConnectionTerminated(NetConnection::ReasonRemoteDisconnectPacket, reason);\n removeConnection(conn);\n}\n\nvoid NetInterface::handleConnectionError(NetConnection *theConnection, const char *errorString)\n{\n disconnect(theConnection, NetConnection::ReasonError, errorString);\n}\n\n};\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\nNxCCDSkeleton *pFactory::createCCDSkeleton(CKBeObject *meshReference,int flags)\r\n{\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(meshReference);\r\n\t#endif // _DEBUG\r\n\r\n\r\n\tNxCCDSkeleton *result = NULL;\r\n\tCKMesh *mesh = NULL;\r\n\t\r\n\tif (meshReference->GetClassID()==CKCID_MESH )\r\n\t\tmesh = static_cast(meshReference);\r\n\telse if(\tmeshReference->GetClassID() == CKCID_3DOBJECT && \r\n\t\t\t\t((CK3dEntity*)meshReference)->GetCurrentMesh() )\r\n\t\tmesh = ((CK3dEntity*)meshReference)->GetCurrentMesh();\r\n\r\n\r\n\tif (!mesh)\r\n\t\treturn NULL;\r\n\r\n\r\n\tint numVerts = mesh->GetVertexCount();\r\n\tint numFaces = mesh->GetFaceCount();\r\n\r\n\r\n\tNxReal *vertices = new float[3 * numVerts];\r\n\tNxVec3 *verts = new NxVec3[numVerts];\r\n\r\n\tfor (int i = 0 ; i< numVerts ; i++ )\r\n\t{\r\n\t\tVxVector v;\r\n\t\tmesh->GetVertexPosition(i,&v);\r\n\t\tvertices[i * 3] = v.x;\r\n\t\tvertices[i * 3 + 1] =v.y;\r\n\t\tvertices[i * 3 + 2] = v.z;\r\n\t}\r\n\r\n\tNxU32 *indices2 = new NxU32[numFaces*3];\r\n\r\n\tfor(int j = 0 ; j < numFaces ; j++)\r\n\t{\r\n\r\n\t\tint findicies[3];\r\n\t\tmesh->GetFaceVertexIndex(j,findicies[0],findicies[1],findicies[2]);\r\n\t\tindices2[ j *3 ]\t\t\t= findicies[0];\r\n\t\tindices2[ j *3 + 1 ]\t= findicies[1];\r\n\t\tindices2[ j *3 + 2 ]\t= findicies[2];\r\n\t}\r\n\r\n\tNxSimpleTriangleMesh descr;\r\n\tdescr.numVertices\t\t\t= numVerts;\r\n\tdescr.pointStrideBytes\t= sizeof(NxReal)*3;\r\n\tdescr.points\t\t\t\t= vertices;\r\n\tdescr.numTriangles\t\t= numFaces;\r\n\tdescr.triangles\t\t\t= indices2;\r\n\tdescr.triangleStrideBytes\t= sizeof(NxU32)*3;\r\n\tdescr.flags\t\t\t\t= NX_MF_FLIPNORMALS;\r\n\r\n\tif (GetPMan()->getPhysicsSDK())\r\n\t{\r\n\t\tresult = GetPMan()->getPhysicsSDK()->createCCDSkeleton(descr);\r\n\t}\r\n\r\n\r\n\tdelete [] vertices;\r\n\tdelete [] verts;\r\n\tdelete [] indices2;\r\n\r\n\treturn result;\r\n\r\n\t\r\n}\r\nvoid pFactory::createConvexMesh(NxScene *scene,CKMesh *mesh,NxConvexMeshDesc&descr)\r\n{\r\n\r\n\r\n\t\r\n\tif (!scene || !mesh)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tint numVerts = mesh->GetVertexCount();\r\n\tint numFaces = mesh->GetFaceCount();\r\n\t\r\n\r\n\tNxReal *vertices = new float[3 * numVerts];\r\n\tNxVec3 *verts = new NxVec3[numVerts];\r\n\r\n\tfor (int i = 0 ; i< numVerts ; i++ )\r\n\t{\r\n\t\tVxVector v;\r\n\t\tmesh->GetVertexPosition(i,&v);\r\n\t\tvertices[i * 3] = v.x;\r\n\t\tvertices[i * 3 + 1] =v.y;\r\n\t\tvertices[i * 3 + 2] = v.z;\r\n\t}\r\n\r\n\tNxU32 *indices2 = new NxU32[numFaces*3];\r\n\t\r\n\tfor(int j = 0 ; j < numFaces ; j++)\r\n\t{\r\n\r\n\t\tint findicies[3];\r\n\t\tmesh->GetFaceVertexIndex(j,findicies[0],findicies[1],findicies[2]);\r\n\t\tindices2[ j *3 ]\t\t\t= findicies[0];\r\n\t\tindices2[ j *3 + 1 ]\t= findicies[1];\r\n\t\tindices2[ j *3 + 2 ]\t= findicies[2];\r\n\t}\r\n\tdescr.numVertices\t\t\t= numVerts;\r\n\tdescr.pointStrideBytes\t= sizeof(NxReal)*3;\r\n\tdescr.points\t\t\t\t= vertices;\r\n\tdescr.numTriangles\t\t= numFaces;\r\n\tdescr.triangles\t\t\t= indices2;\r\n\tdescr.triangleStrideBytes\t= sizeof(NxU32)*3;\r\n\tdescr.flags\t\t\t\t= NX_CF_COMPUTE_CONVEX;\r\n\r\n/*\r\n\tdelete [] vertices;\r\n\tdelete [] verts;\r\n\tdelete [] indices2;*/\r\n\r\n}\r\nvoid\r\npFactory::createMesh(NxScene *scene,CKMesh *mesh,NxTriangleMeshDesc&descr)\r\n{\r\n\r\n\tif (!scene || !mesh)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tint numVerts = mesh->GetVertexCount();\r\n\tint numFaces = mesh->GetFaceCount();\r\n\t\r\n\r\n\tNxReal *vertices = new float[3 * numVerts];\r\n\tNxVec3 *verts = new NxVec3[numVerts];\r\n\r\n\tfor (int i = 0 ; i< numVerts ; i++ )\r\n\t{\r\n\t\tVxVector v;\r\n\t\tmesh->GetVertexPosition(i,&v);\r\n\t\tvertices[i * 3] = v.x;\r\n\t\tvertices[i * 3 + 1] =v.y;\r\n\t\tvertices[i * 3 + 2] = v.z;\r\n\t}\r\n\r\n\tNxU32 *indices2 = new NxU32[numFaces*3];\r\n\t\r\n\tfor(int j = 0 ; j < numFaces ; j++)\r\n\t{\r\n\r\n\t\tint findicies[3];\r\n\t\tmesh->GetFaceVertexIndex(j,findicies[0],findicies[1],findicies[2]);\r\n\t\tindices2[ j *3 ]\t\t\t= findicies[0];\r\n\t\tindices2[ j *3 + 1 ]\t= findicies[1];\r\n\t\tindices2[ j *3 + 2 ]\t= findicies[2];\r\n\t}\r\n\tdescr.numVertices\t\t\t= numVerts;\r\n\tdescr.pointStrideBytes\t= sizeof(NxReal)*3;\r\n\tdescr.points\t\t\t\t= vertices;\r\n\tdescr.numTriangles\t\t= numFaces;\r\n\tdescr.triangles\t\t\t= indices2;\r\n\tdescr.triangleStrideBytes\t= sizeof(NxU32)*3;\r\n\tdescr.flags\t\t\t\t= 0;\r\n\r\n\r\n\t/*\r\n\t\r\n\tdelete [] vertices;\r\n\tdelete [] verts;\r\n\tdelete [] indices2;\r\n\r\n\t*/\r\n\r\n}\r\n#ifndef __P_BOX_CONTROLLER_H__\r\n#define __P_BOX_CONTROLLER_H__\r\n\r\n#include \"pTypes.h\"\r\n\r\nclass BoxController;\r\n\r\nclass pBoxController \r\n{\r\npublic:\r\n\t\t\t\t\t\t\t\t\t\r\n\tpBoxController(const NxControllerDesc& desc, NxScene* scene);\r\n\t\r\n\t\t\t\t\t\t\t\t\tvirtual\t\t\t\t\t\t\t~pBoxController();\r\n\r\n\tvoid\t\t\t\t\tmove(const VxVector& disp, int activeGroups, float minDist, int& collisionFlags, float sharpness, const pGroupsMask* groupsMask);\r\n\r\n\t//bool\t\t\t\t\tsetPosition(const VxVector& position)\t{ return setPos(position);\t\t\t\t}\r\n\tpRigidBody*\t\t\t\tgetBody()\t\t\t\t\t\t\tconst;\r\n\r\n\t///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\t// NxpBoxController\r\n\tconst VxVector&\t\t\tgetExtents()\t\t\t\t\t\tconst;\r\n\tbool\t\t\t\t\tsetExtents(const VxVector& extents);\r\n\t\r\n\tvoid\t\t\t\t\tsetStepOffset(const float offset);\r\n\r\n\tVxVector\tgetPosition()const;\r\n\tVxVector&\tgetFilteredPosition();\r\n\tbool\t\t\t\t\tgetWorldBox(VxBbox& box) const;\r\n\tvoid\t\t\t\t\tsetCollision(bool enabled);\r\n\t//virtual\tvoid\t\t\t\t\tsetInteraction(NxCCTInteractionFlag flag)\t{ Controller::setInteraction(flag);\t\t}\r\n\t//virtual\tNxCCTInteractionFlag\tgetInteraction()\t\t\t\t\tconst\t{ return Controller::getInteraction();\t}\r\n\r\n\t//vi//rtual\tvoid\t\t\t\t\treportSceneChanged();\r\n\t//virtual\tvoid*\t\t\t\t\tgetUserData()\t\t\t\t\t\tconst\t{ return userData;\t\t\t\t\t\t}\r\n\t\r\nprivate:\r\n\r\n\tBoxController *mBoxController;\r\n\r\n\r\n};\r\n\r\n#endif\r\n//AGCOPYRIGHTBEGIN\r\n///////////////////////////////////////////////////////////////////////////\r\n// Copyright (c) 2005 AGEIA Technologies.\r\n// All rights reserved. www.ageia.com\r\n///////////////////////////////////////////////////////////////////////////\r\n//AGCOPYRIGHTEND\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLogEntryDecl();\r\nCKERROR CreateLogEntryProto(CKBehaviorPrototype **);\r\nint LogEntry(const CKBehaviorContext& behcontext);\r\nCKERROR LogEntryCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLogEntryDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"pLogEvent\");\t\r\n\tod->SetDescription(\"Displays Internal Log Entries\");\r\n\t\r\n\tod->SetCategory(\"Physics/Manager\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x512542dc,0x1b836fd9));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateLogEntryProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateLogEntryProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"pLogEvent\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareOutput(\"Message\");\r\n\r\n\tproto->DeclareOutput(\"Error\");\r\n\tproto->DeclareOutput(\"Warning\");\r\n\tproto->DeclareOutput(\"Info\");\r\n\tproto->DeclareOutput(\"Trace\");\r\n\tproto->DeclareOutput(\"Debug\");\r\n\r\n\r\n\t\r\n\tproto->DeclareOutParameter(\"Entry\",CKPGUID_STRING);\r\n\t\r\n\tproto->DeclareOutParameter(\"Type\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Component\",CKPGUID_STRING);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(LogEntry);\r\n\tproto->SetBehaviorCallbackFct(LogEntryCB);\r\n\r\n\r\n\t*pproto = proto;\r\n\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint LogEntry(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\r\n\tXString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\r\n\r\n\tif (GetPMan()->GetLastLogEntry().Length())\r\n\t{\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\t\t\tpout->SetStringValue(GetPMan()->GetLastLogEntry().Str());\r\n\t\t\tGetPMan()->SetLastLogEntry(\"\");\r\n\r\n\r\n\t\t\tvtTools::BehaviorTools::SetOutputParameterValue(beh,1,xLogger::GetInstance()->lastTyp);\r\n\t\t\tint descriptionS = xLogger::GetInstance()->getItemDescriptions().size();\r\n\r\n\t\t\tint compo = xLogger::GetInstance()->lastComponent;\r\n\t\t\t\r\n\t\t\tXString compoStr;\r\n\t\t\t/*if(compo<= xLogger::GetInstance()->getItemDescriptions().size() )\r\n\t\t\t\tcompoStr.Format(\"%s\",xLogger::GetInstance()->getItemDescriptions().at(compo));*/\r\n\r\n\r\n\r\n\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\tswitch (xLogger::GetInstance()->lastTyp)\r\n\t\t\t{\r\n\r\n\t\t\tcase ELOGERROR:\r\n\t\t\t\tbeh->ActivateOutput(1,TRUE);\r\n\r\n\t\t\t\tcase ELOGWARNING:\r\n\t\t\t\t\tbeh->ActivateOutput(2,TRUE);\r\n\t\t\t\t\r\n\t\t\t\tcase ELOGINFO:\r\n\t\t\t\t\tbeh->ActivateOutput(3,TRUE);\r\n\t\t\t\t\r\n\t\t\t\tcase ELOGTRACE:\r\n\t\t\t\t\tbeh->ActivateOutput(4,TRUE);\r\n\r\n\t\t\t\tcase ELOGDEBUG:\r\n\t\t\t\t\tbeh->ActivateOutput(5,TRUE);\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\r\n\t\t\t}\r\n\r\n\t\t\r\n\t\t\t\r\n\t}\r\n\r\n\r\n\t//\tSteering\t\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\t\tbeh->ActivateOutput(0,FALSE);\r\n\r\n\t\treturn 1;\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR LogEntryCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\t\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t/*\tCKParameterIn* pin = beh->GetInputParameter(0);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve first input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tif (pin->GetGUID()!=CKPGUID_MESSAGE) {\r\n\t\t\tpin->SetGUID(CKPGUID_MESSAGE,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : first input parameter type must be \\\"Message\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}\r\n\r\n\t\tpin = beh->GetInputParameter(1);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve second input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\r\n\t\tif (!behcontext.ParameterManager->IsDerivedFrom(pin->GetGUID(),CKPGUID_OBJECT)) {\r\n\t\t\tpin->SetGUID(CKPGUID_BEOBJECT,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : second input parameter type must derived from \\\"BeObject\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}*/\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n RenderEngines = RenderEngines\r\n ManagerPath = Managers\r\n BehaviorPath = BuildingBlocks\r\n PluginPath = Plugins\r\n LoadFile1 = gallery_start_noText_012.cmo\r\n LoadFile = serverInit.cmo\r\n InstallDirectory = X:\\sdk\\dev4\r\n\r\n\r\n DisableSwitch = 0\r\n WindowWidth = 400\r\n WindowHeight = 300\r\n FullscreenWidth = 1024\r\n FullscreenHeight = 768\r\n Bpp = 32\r\n Driver = 1\r\n FullScreen = 0\r\n RefreshRate = 60\r\n Mode = 0\r\n AntiAlias = 0\r\n HasResolutionMask = 1\r\n XResolutions = 400,1024,800\r\n YResolutions = 300,768,600\r\n OpenGLVersions = 2.0\r\n\r\n\r\n MouseDragsWindow = 1\r\n OwnerDrawed = 0\r\n Render = 1\r\n AlwayOnTop = 0\r\n ScreenSaverMode = 0\r\n MouseMovesTerminatePlayer = 0\r\n Resizeable = 1\r\n CaptionBar = 1\r\n ShowDialog = 0\r\n ShowAboutTab = 0\r\n ShowConfigTab = 1\r\n MinDirectXVersion = 9\r\n MinRAM = 256\r\n SizeBox = 1\r\n Title = Network Test\r\n UseSplash = 0\r\n ShowLoadingProcess = 1\r\n\r\n\r\n entry0=Resource\\3DChatResourceDB\\Textures\r\n entry1=Resource\\3DChatResourceDB\\Textures\\Dialogs\r\n#ifndef __VT_MODULE_ERROR_STRINGS_H__\r\n#define __VT_MODULE_ERROR_STRINGS_H__\r\n\r\n/*!\r\n * \\brief\r\n * String to describe the error's source\r\n */\r\nstatic char* sLogItems[]=\r\n{\r\n\t\"AGEIA\",\r\n\t\"MANAGER\",\r\n\t\"VSL\",\r\n};\r\n\r\n/*!\r\n * \\brief\r\n * String to describe generic return codes\r\n */\r\nstatic char* sErrorStrings[]=\r\n{\r\n\t\"OK\",\r\n\t\"Ageia error\",\r\n\t\"Invalid parameter\",\r\n\t\"Invalid operation\",\r\n};\r\n\r\n/*!\r\n * \\brief\r\n * String to describe component specific return codes\r\n * \r\n */\r\nstatic char* sBBErrorStrings[]=\r\n{\r\n\t\"OK\",\r\n\t\"\\t Intern :\",\r\n\t\"\\t Parameter invalid :\",\r\n\t\"\\t Reference object invalid:\",\r\n\t\"\\t XML error:\",\r\n\t\"\\t Invalid File:\",\r\n\t\"\\t Reference object is not physicalized:\",\r\n\t\"\\t Reference object doesn't contains a vehicle controller:\",\r\n\t\"\\t Reference object is not a wheel:\",\r\n\t\"\\t Reference object is not a joint:\",\r\n\t\"\\t Reference object is not a cloth:\",\r\n\t\"\\t Couldn't initialize PhysX :\",\r\n\r\n};\r\n\r\n\r\n#endif // __VTMODULEERRORSTRINGS_H__#ifndef __UX_STRING_H__\r\n#define __UX_STRING_H__\r\n\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\ntypedef char\t\tTAnsiChar;\r\n\r\n#ifdef _WIN32\r\n\ttypedef wchar_t TUnicodeChar;\r\n#else\r\n\ttypedef unsigned short TUnicodeChar;\r\n#endif\r\n\r\n//\r\n// Define an alias for the native character data type\r\n//\r\n#ifdef _UNICODE\r\n\ttypedef TUnicodeChar\t\tTChar;\r\n#else\r\n\ttypedef TAnsiChar\t\tTChar;\r\n#endif\r\n\r\n//\r\n// This macro creates an ASCII string (actually a no-op)\r\n//\r\n#define __A(x) (x)\r\n\r\n//\r\n// This macro creates a Unicode string by adding the magic L before the string\r\n//\r\n#define __U(x) (L##x)\r\n\r\n//\r\n// Define an alias for building a string in the native format\r\n//\r\n#ifdef _UNICODE\r\n#define T __U\r\n#else\r\n#define T __A\r\n#endif\r\n\r\n\r\n//===============================================================================\r\n//\r\n// uxString\r\n//\r\nclass uxString\r\n{\r\npublic:\r\n\t//=======================================================\r\n\t//\r\n\t// Construction and destruction\r\n\t//\r\n\tuxString()\t\t\t\t\t\t\t\t// Default constructor, just creates an empty string.\r\n\t{\r\n\t\tText = NULL;\r\n\t\tLen = Size = 0;\r\n\t}\r\n\tuxString(const uxString& String)\t// Copy constructor, makes an instance an exact copy of\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// another string.\r\n\t\tAssignFrom(String);\r\n\t}\r\n\tuxString(const TChar *String)\t\t// Constructor building a string from a regular C string\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// of characters in native format.\r\n\t\tAssignFrom(String);\r\n\t}\r\n#ifdef _UNICODE\r\n\tuxString(const TAnsiChar *String)\t// Constructor building a Unicode string from a regular C\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// string in ANSI format (used for doing conversions).\r\n\t\tif (String == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = strlen(String) + 1;\t\t\t\t// Use ANSI strlen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iUnicode char-by-char\r\n\t\t\tText[i] = (TUnicodeChar)String[i];\r\n\t\tText[Len] = __A('\\0');\r\n\t}\r\n#else\r\n\tuxString(const TUnicodeChar *String)\t\t// Constructor building an ANSI string from a regular C\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t// string in Unicode format (used for doing conversions).\r\n\t\tif (String == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = wcslen(String) + 1;\t\t\t\t// Use Unicode wcslen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iANSI char-by-char\r\n\t\t\tText[i] = (TAnsiChar)String[i];\r\n\t\tText[Len] = __A('\\0');\r\n\t}\r\n#endif\r\n\tvirtual ~uxString()\t\t\t\t\t\t// Destructor. The use of virtual is recommended in C++\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t// for all destructors that can potentially be overloaded.\r\n\t\tif (Size && Text != NULL)\t\t\t// Free the memory used by the string\r\n\t\t\tFreeStr(Text);\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Accessors\r\n\t//\r\n\tTChar *GetString() const\t\t// Returns a pointer to the actual string data.\r\n\t{\r\n\t\treturn Text;\r\n\t}\r\n\tconst int GetLength() const\t// Returns the length of the string currently\r\n\t{\t\t\t\t\t\t\t\t\t\t// held by an instance of the string class.\r\n\t\treturn Len;\r\n\t}\r\n\tconst bool IsNull() const\t\t// Returns true if a NULL string is held by an instance.\r\n\t{\r\n\t\treturn (Text == NULL || !_tcslen(Text));\r\n\t}\r\n\tconst bool IsValidIndex(const int Index) const\t// Returns true if the character index\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// specified is within the bounds of the string.\r\n\t\treturn (Index >= 0 && Index < Len);\r\n\t}\r\n\tconst TAnsiChar *CStr() const\r\n\t{\r\n\t\treturn Text ? Text : NULL;\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Regular transformation functions\r\n\t//\t\r\n\tint Compare(const uxString& String, bool IgnoreCase=false) const\t// Compares another string\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// with this instance. Return\r\n\t\tif (IsNull() && !String.IsNull())\t\t\t\t\t\t\t\t\t\t// values equals those of strcmp(),\r\n\t\t\treturn 1;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// ie -1, 0 or 1 (Less, Equal, Greater)\r\n\t\telse if (!IsNull() && String.IsNull())\t\t\t\t\t\t\t// ... Trivial cases\r\n\t\t\treturn -1;\r\n\t\telse if (IsNull() && String.IsNull())\r\n\t\t\treturn 0;\r\n\t\t\r\n\t\tif (IgnoreCase)\r\n\t\t\treturn _tcsicmp(Text, String.Text);\r\n\t\telse\r\n\t\t\treturn _tcscmp(Text, String.Text);\r\n\t}\r\n\tbool Find(uxString& Str, int& Pos, bool IgnoreCase=false)\tconst\t// Finds a substring within this string.\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Returns true if found (position in Pos).\r\n\t\tif (IsNull() || Str.IsNull())\r\n\t\t\treturn false;\r\n\r\n\t\t// Define a function pointer that will be used to call the appropriate\r\n\t\t// compare function based on the value of IgnoreCase.\r\n\t\tint (* cmpfn)(const TCHAR*, const TCHAR*, size_t) = (IgnoreCase) ? _tcsnicmp : _tcsncmp;\r\n\t\t\r\n\t\tfor (Pos=0 ; Pos<=(Len-Str.Len) ; Pos++)\r\n\t\t{\r\n\t\t\tif (cmpfn(&Text[Pos], Str.Text, Str.Len) == 0)\r\n\t\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\tvoid Delete(int Pos, int Count)\t\t\t\t\t\t// Deletes the specified number of characters,\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// starting at the specified position.\r\n\t\tif (Pos > Len || Count==0)\t\t\t\t\t\t\t// Start is outside string or nothing to delete?\r\n\t\t\treturn;\r\n\t\tif (Pos + Count > Len)\t\t\t\t\t\t\t\t// Clamp Count to string length\r\n\t\t\tCount = (Len - Pos);\r\n\r\n\t\t// Characters are deleted by moving up the data following the region to delete.\r\n\t\tfor (int i=Pos ; iLen)\r\n\t\t\treturn;\r\n\r\n\t\tGrow(1);\t\t\t\t\t\t\t\t\t// Grow the string by one byte to be able to hold character\r\n\r\n\t\t// Move down rest of the string.\r\n\t\t// Copying overlapping memory blocks requires the use of memmove() instead of memcpy().\r\n\t\tmemmove((void *)&Text[Pos+1], (const void *)&Text[Pos], Len-Pos);\r\n\t\tText[Pos] = c;\r\n\t\tText[++Len] = T('\\0');\r\n\t}\r\n\tvoid Insert(int Pos, const uxString& String)\t\t// Inserts a complete string at the given\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// location.\r\n\t if (Pos<0 || Pos>Len || String.IsNull())\r\n\t\t\treturn;\r\n\r\n\t\tTChar *New = AllocStr(String.Len + Len + 1);\r\n\t\tif (Pos > 0)\t\t\t\t\t\t\t\t\t// Set the string portion before the inserted string\r\n\t\t\t_tcsncpy(New, Text, Pos);\r\n\t\t_tcsncpy(&New[Pos], String.Text, String.Len);\t\t\t// Insert the string\r\n\t\tif (Len-Pos > 0)\t\t\t\t\t\t\t\t\t\t\t\t\t// Insert rest of orignal string\r\n\t\t\t_tcsncpy(&New[Pos+String.Len], &Text[Pos], Len-Pos);\r\n\r\n\t\tAssignFrom(New);\t\t\t\t\t\t\t// Copy new string back into stringobject\r\n\t}\r\n\tuxString GetSubString(int Start, int Count, uxString& Dest)\t\t// Crops out a substring.\r\n\t{\r\n\t\tif (!IsValidIndex(Start) || Count <= 0)\t\t// Valid operation?\r\n\t\t{\r\n\t\t\tDest = T(\"\");\r\n\t\t\treturn Dest;\r\n\t\t}\r\n\r\n\t\tTChar *Temp = AllocStr(Count + 1);\r\n\t\t_tcsncpy(Temp, &Text[Start], Count);\r\n\t\tTemp[Count] = T('\\0');\r\n\r\n\t\tDest = Temp;\r\n\t\tFreeStr(Temp);\r\n\t\treturn Dest;\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Special transformation functions\r\n\t//\r\n\tvoid VarArg(TChar *Format, ...)\t\t// Allows you to fill a string object with data in the\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t// same way you use sprintf()\r\n\t\t/*TChar Buf[0x1000]; // Need lots of space\r\n\t\tva_list argptr;\r\n\r\n\t\tva_start(argptr, Format);\r\n#ifdef _UNICODE\r\n\t\tvswprintf(Buf, Format, argptr);\r\n#else\r\n\t\tvsprintf(Buf, Format, argptr);\r\n#endif\r\n\t\tva_end(argptr);\r\n\r\n\t\tSize = _tcslen(Buf) + 1;\r\n\t\tLen = _tcslen(Buf);\r\n\t\tFreeStr(Text);\r\n\t\tText = AllocStr(Size);\r\n\t if (Len > 0)\r\n\t\t\t_tcscpy(Text, Buf);\r\n\t\telse\r\n\t\t\tText[0] = T('\\0');*/\r\n\t}\r\n\tvoid EatLeadingWhitespace()\t\t// Convenient function that removes all whitespace\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// (tabs and spaces) at the beginning of a string.\r\n\t\tif (IsNull())\r\n\t\t\treturn;\r\n\r\n\t int i=0;\r\n\t for (i=0 ; i=0 ; i--)\r\n\t\t{\r\n\t\t\tif (Text[i] != 0x20 && Text[i] != 0x09)\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\tDelete(i+1, Len-i-1);\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Conversion functions\r\n\t//\r\n\tTAnsiChar *ToAnsi(TAnsiChar *Buffer, int BufferLen) const\t// Converts the string to an ANSI string.\r\n\t{\r\n\t\tint i, ConvertLen;\r\n\r\n\t\tif (BufferLen <= 0)\r\n\t\t{\r\n\t\t\tBuffer = NULL;\r\n\t\t\treturn Buffer;\r\n\t\t}\r\n\r\n\t\tif (BufferLen >= Len)\r\n\t\t\tConvertLen = Len;\r\n\t\telse\r\n\t\t\tConvertLen = BufferLen-1;\r\n\r\n\t\tfor (i=0 ; i 255)\t\t// If character is a non-ANSI Unicode character, fill with\r\n\t\t\t\tBuffer[i] = 0x20;\t\t// space instead.\r\n\t\t\telse\r\n#endif\r\n\t\t\t\tBuffer[i] = (TAnsiChar)Text[i];\r\n\t\t}\r\n\t\tBuffer[i] = __A('\\0');\r\n\t\treturn Buffer;\r\n\t}\r\n\tTUnicodeChar *ToUnicode(TUnicodeChar *Buffer, int BufferLen) const\t\t// Converts the string\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// to a Unicode string.\r\n\t\tint i, ConvertLen;\r\n\r\n\t\tif (BufferLen <= 0)\r\n\t\t{\r\n\t\t\tBuffer = NULL;\r\n\t\t\treturn Buffer;\r\n\t\t}\r\n\r\n\t\tif (BufferLen >= Len)\r\n\t\t\tConvertLen = Len;\r\n\t\telse\r\n\t\t\tConvertLen = BufferLen-1;\r\n\r\n\t\tfor (i=0 ; iUnicode char-by-char\r\n\t\t\tText[i] = (TUnicodeChar)String[i];\r\n\t\tText[Len] = A('\\0');\r\n\t}\r\n#else\r\n\tvoid operator =(const TUnicodeChar *String)\t// Sets this string to the contents of a character array\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// in Unicode format (only included in ANSI builds)\r\n\t\tif (String == NULL)\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = wcslen(String) + 1;\t\t// Use Unicode wcslen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iANSI char-by-char\r\n\t\t\tText[i] = (TAnsiChar)String[i];\r\n\t\tText[Len] = __A('\\0');\r\n\t}\r\n#endif\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Concatenation operators\r\n\t//\r\n\tinline friend uxString operator +(const uxString& Str1, const uxString& Str2);\t// Concatenates two strings (see text)\r\n\r\n\tvoid operator +=(const uxString& String)\t\t// Adds another string to the end of the\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// current one.\r\n\t\tif (String.Len > 0)\r\n\t\t{\r\n\t\t\tGrow(String.Len);\r\n\t\t\t_tcsncpy(&Text[Len], String.Text, String.Len);\r\n\t\t\tLen += String.Len;\r\n\t\t}\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Access operators\r\n\t//\r\n\toperator TChar *() const\t\t\t\t\t// Returns the address of the contained string.\r\n\t{\r\n\t\treturn Text;\r\n\t}\r\n\tTChar& uxString::operator [](int Pos)\t// Returns a character reference at a\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t// specific location.\r\n\t\tif (Pos < 0)\t\t\t\t\t\t\t\t// If underrun, just return first character\r\n\t\t\treturn Text[0];\r\n\t\telse if (Pos >= Len)\t\t\t\t\t\t// If overrun, expand string in accordance\r\n\t\t{\r\n\t\t\tGrow(Pos+2);\r\n\t\t\treturn Text[Pos];\r\n\t\t}\r\n\t\telse\t\t\t\t\t\t\t\t\t\t\t// Otherwise, just return character\r\n\t\t\treturn Text[Pos];\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Comparison operators (operates through Compare()).\r\n\t// Functions exist for comparing both string objects and character arrays.\r\n\t//\r\n\tbool operator < (const uxString& Str) const\t{ return (bool)(Compare(Str) == -1);\t\t\t\t}\r\n\tbool operator > (const uxString& Str) const\t{ return (bool)(Compare(Str) == 1);\t\t\t\t\t}\r\n\tbool operator <=(const uxString& Str) const\t{ return (bool)(Compare(Str) != 1);\t\t\t\t\t}\r\n\tbool operator >=(const uxString& Str) const\t{ return (bool)(Compare(Str) != -1);\t\t\t\t}\r\n\tbool operator ==(const uxString& Str) const\t{ return (bool)(Compare(Str) == 0);\t\t\t\t\t}\r\n\tbool operator !=(const uxString& Str) const\t{ return (bool)(Compare(Str) != 0);\t\t\t\t\t}\r\n\tbool operator < (const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) == -1);\t}\r\n\tbool operator > (const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) == 1);\t\t}\r\n\tbool operator <=(const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) != 1);\t\t}\r\n\tbool operator >=(const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) != -1);\t}\r\n\tbool operator ==(const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) == 0);\t\t}\r\n\tbool operator !=(const TChar *Chr) const\t\t{ return (bool)(Compare(uxString(Chr)) != 0);\t\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Protected low-level functions\r\n\t//\r\nprotected:\r\n\tvoid Optimize()\t\t\t// Discards any unused space allocated for the string\r\n\t{\r\n\t\tSize = Len + 1;\r\n\t\tTChar *Temp = AllocStr(Size);\r\n\t\t_tcscpy(Temp, Text);\r\n\t\tFreeStr(Text);\r\n\t\tText = Temp;\r\n\t}\r\n\tvoid Grow(int Num)\t\t// Allocates some more memory so the string can hold an additional Num characters\r\n\t{\r\n\t\tSize += Num;\r\n\t\tTChar *Temp = AllocStr(Size);\r\n\t\t_tcscpy(Temp, Text);\r\n\t\tFreeStr(Text);\r\n\t\tText = Temp;\r\n\t}\r\n\tvoid AssignFrom(uxString& Str)\t\t\t// Does the hard work for all non-converting assignments\r\n\t{\r\n\t\tSize = Str.Size;\r\n\t\tLen = Str.Len;\r\n\t\tif (Size && Len)\t\t\t\t\t\t// No point copying an empty string\r\n\t\t{\r\n\t\t\tText = AllocStr(Size);\r\n\t\t\t_tcscpy(Text, Str.Text);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t}\r\n\t}\r\n\tvoid AssignFrom(const TChar *Str)\t// Does the hard work for all non-converting assignments\r\n\t{\r\n\t\tif (Str == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tSize = _tcslen(Str) + 1;\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\t_tcscpy(Text, Str);\r\n\t}\r\n\r\n\tstatic TChar *AllocStr(int Size)\t\t// Allocates a new character array. You can modify this\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t// function if you for instance use a custom memory manager.\r\n\t\t//return new TChar[Size];\r\n\t\treturn (TChar *)calloc(Size, sizeof(TChar));\r\n\t}\r\n\tstatic void FreeStr(TChar *Ptr)\t\t// Ditto\r\n\t{\r\n\t\tif (Ptr == NULL)\r\n\t\t\treturn;\r\n\t\t//delete [] Ptr;\r\n\t\tfree(Ptr);\r\n\t}\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Protected data members\r\n\t//\r\nprotected:\r\n\tTChar\t\t\t\t\t\t*Text;\t\t\t// The actual character array\r\n\tint\t\t\t\t\t\tSize;\t\t\t\t// Number of bytes allocated for string\r\n\tint\t\t\t\t\t\tLen;\t\t\t\t// Number of characters in string\r\n\r\n\tpublic:\r\n\t// Concatenation operator\r\n\tuxString& operator << (const TChar* rValue)\r\n\t{\r\n\t\tInsert(Len,rValue);\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tuxString& operator<<(const int iValue)\r\n\t{\r\n\t\t\r\n\t\t/*uxString buffer = uxString::AllocStr(15);\r\n\r\n#ifdef _UNICODE\r\n\t\t_itow(iValue,buffer.GetString(),10); \r\n#else\r\n\t\t_itot(iValue,buffer.GetString(),10); \r\n#endif\r\n\t\t*/\r\n\t\t\r\n\t\tchar * szReal = new char[ 512 ];\r\n\t\tsprintf( szReal, \"%d\",iValue);\r\n\t\tuxString buffer(szReal);\r\n\t\tdelete [ ] szReal;\r\n\t\t\r\n\t\tint i = strlen(buffer.GetString());\r\n\t\tint s=buffer.GetLength(); \r\n\r\n\t\t//buffer.EatTrailingWhitespace();\r\n\t\t//buffer.Insert(buffer.Len+2,\"\\0\");\r\n\t\t\r\n\t\tInsert(Len,buffer);\r\n\t\treturn *this; \t\t\r\n\t}\r\n};\r\n\r\n\r\n//=======================================================\r\n//\r\n// Concatenation function (must be global for reasons stated in the text)\r\n//\r\ninline uxString operator +(const uxString& Str1, const uxString& Str2)\r\n{\r\n\tTChar *Temp = uxString::AllocStr(Str1.Size + Str2.Size);\t\t// Allocate memory for new string\r\n\tif (Str1.Len)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Copy first string into dest\r\n\t\t_tcscpy(Temp, Str1.Text);\r\n\tif (Str2.Len)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Copy second string into dest\r\n\t\t_tcscpy(&Temp[Str1.Len], Str2.Text);\r\n\r\n uxString Result = Temp;\r\n\treturn Result;\r\n}\r\n#endif //__UX_STRING_H__#ifndef __P_LINEAR_INTERPOLATION_H__\r\n#define __P_LINEAR_INTERPOLATION_H__\r\n\r\n#include \"NxMath.h\"\r\n#include \"NxSimpleTypes.h\"\r\n\r\n#include \r\n#include \r\n\r\n\r\n\r\nclass pLinearInterpolation {\r\n\ttypedef std::map MapType;\r\n\ttypedef MapType::iterator MapIterator;\r\n\ttypedef MapType::const_iterator ConstMapIterator;\r\n\tMapType _map;\r\n\r\n\tNxF32 _min, _max;\r\npublic:\r\n\tpLinearInterpolation (): _min(0), _max(0), _map() { }\r\n\r\n\tvoid clear() { _map.clear(); }\r\n\tvoid insert(float index, float value) {\r\n\t\tif (_map.empty())\r\n\t\t\t_min = _max = index;\r\n\t\telse {\r\n\t\t\t_min = NxMath::min(_min, index);\r\n\t\t\t_max = NxMath::max(_max, index);\r\n\t\t}\r\n\t\t_map[index] = value;\r\n\t}\r\n\r\n\tvoid print() const {\r\n\t\tConstMapIterator it = _map.begin();\r\n\t\tfor (; it != _map.end(); ++it) {\r\n\t\t\tprintf(\"%2.3f -> %2.3f\\n\", it->first, it->second);\r\n\t\t}\r\n\t}\r\n\r\n\tbool isValid(float number) const { return number>=_min && number<=_max; }\r\n\r\n\tfloat getValue(float number) const {\r\n\t\tConstMapIterator lower = _map.begin();\r\n\t\tif (number < _min)\r\n\t\t\treturn lower->second;\r\n\t\tConstMapIterator upper = _map.end();\r\n\t\tupper--;\r\n\t\tif (number > _max)\r\n\t\t\treturn upper->second;\r\n\r\n\t\tupper = _map.lower_bound(number);\r\n\t\tif (upper == lower)\r\n\t\t\treturn (upper->second);\r\n\t\tlower = upper;\r\n\t\tlower--;\r\n\r\n\t\t//printf(\"- %2.3f %2.3f\\n\", lower->first, upper->first);\r\n\t\tfloat w1 = number - lower->first;\r\n\t\tfloat w2 = upper->first - number;\r\n\t\treturn ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2);\r\n\t}\r\n\r\n\tNxF32 getValueAtIndex(NxI32 index) const {\r\n\t\tConstMapIterator it = _map.begin();\r\n\t\tfor (int i = 0; i < index; i++)\r\n\t\t\t++it;\r\n\t\treturn it->second;\r\n\t}\r\n\r\n\tvoid operator=(const pLinearInterpolation& other) \r\n\t{\r\n\t_map.insert(other._map.begin(), other._map.end());\r\n\t_max = other._max;\r\n\t_min = other._min;\r\n\t}\r\n\r\n\tint getSize() const { return _map.size(); }\r\n};\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJRevoluteDecl();\r\nCKERROR CreatePJRevoluteProto(CKBehaviorPrototype **pproto);\r\nint PJRevolute(const CKBehaviorContext& behcontext);\r\nCKERROR PJRevoluteCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Anchor,\r\n\tbI_AnchorRef,\r\n\tbI_Axis,\r\n\tbI_AxisRef,\r\n\tbbI_Collision,\r\n\tbbI_PMode,\r\n\tbbI_PDistance,\r\n\tbbI_PAngle,\r\n\tbbI_Spring,\r\n\tbbI_HighLimit,\r\n\tbbI_LowLimit,\r\n\tbbI_Motor\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJRevoluteDecl\r\n// FullName: FillBehaviorPJRevoluteDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJRevoluteDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJRevolute\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets/modifies a revolute joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x77cb361c,0x670112a9));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJRevoluteProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJRevoluteProto\r\n// FullName: CreatePJRevoluteProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJRevoluteProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJRevolute\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJRevolute \r\n\r\n\t
\r\n\tPJRevolute is categorized in \\ref Joints\r\n\t
\r\n\t
See PJRevolute.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a revolute joint.\r\n\t
\r\n\t
\r\n\tDOFs removed: 5
\r\n\tDOFs remaining: 1
\r\n\t
\r\n\t\\image html revoluteJoint.png\r\n\r\n\tA revolute joint removes all but a single rotational degree of freedom from two objects. \r\n\tThe axis along which the two bodies may rotate is specified with a point and a direction \r\n\tvector. In theory, the point along the direction vector does not matter, but in practice, \r\n\tit should be near the area where the bodies are closest to improve simulation stability.\r\n\r\n\tAn example for a revolute joint is a door hinge. \r\n\tAnother example would be using a revolute joint to attach rotating fan blades to a \r\n\tceiling. \tThe revolute joint could be motorized, causing the fan to rotate.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJRevolute.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\t\r\n\tAnchor:A point in world space coordinates. See pJointRevolute::setGlobalAnchor().\r\n\t
\r\n\tAnchor Reference: A helper entity to transform a local anchor into the world space.\r\n\t
\r\n\t\r\n\tAxis: An in world space. See pJointRevolute::setGlobalAxis().\r\n\t
\r\n\tAxis Up Reference: A helper entity to transform a local axis into the world space.\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\tCollision: Enable Collision. See pJointRevolute::enableCollision().\r\n\t
\r\n\r\n\t
\r\n\tProjection Mode: Joint projection mode. See pJointRevolute::setProjectionMode() and #ProjectionMode.\r\n\t
\r\n\r\n\tProjection Distance: If any joint projection is used, it is also necessary to set \r\n\tprojectionDistance to a small value greater than zero. When the joint error is larger than projectionDistance the SDK will change it so that the joint error is equal to projectionDistance. Setting projectionDistance too \r\n\tsmall will introduce unwanted oscillations into the simulation.See pJointRevolute::setProjectionDistance().\r\n\t
\r\n\r\n\tProjection Angle: Angle must be greater than 0.02f .If its smaller then current algo gets too close to a singularity. See pJointRevolute::setProjectionAngle().\r\n\t
\r\n\r\n\r\n\t
\r\n\tSpring: Make it springy.See pJointRevolute::setSpring().\r\n\t
\r\n\r\n\t
\r\n\tHigh Limit: Higher rotation limit around the rotation axis. See pJointRevolute::setHighLimit().\r\n\t
\r\n\t\r\n\tLow Limit: Lower rotation limit around rotation axis. See pJointRevolute::setLowLimit().\r\n\t
\r\n\t\r\n\t
\r\n\tMotor: Motor parameters. See pJointRevolute::setMotor().\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\r\n\tSpring: Enables parameter input for spring settings.\r\n\t
\r\n\r\n\tHigh Limit: Enables parameter inputs for angular limits.\r\n\t
\r\n\t\r\n\t\r\n\tMotor: Enables parameter input for motor settings.\r\n\t
\r\n\t\r\n\r\n\r\n\t

Revolute Joint Limits

\r\n\r\n\tA revolute joint allows limits to be placed on how far it rotates around the joint axis. For example, a hinge on a door cannot rotate through 360 degrees; rather, it can rotate between 20 degrees and 180 degrees.\r\n\tThe angle of rotation is measured using the joints normal (axis orthogonal to the joints axis). This is the angle reported by NxRevoluteJoint::getAngle(). The limits are specified as a high and low limit, which must satisfy the condition -Pi < low < high \r\n\r\n\tNote : The white region represents the allowable rotation for the joint.\r\n\r\n\t

Limitations of Revolute Joint Limits

\r\n\tAs shown below, it is not possible to specify certain limit configurations without rotating the joint axes, due to the restrictions on the values of low and high: \r\n\t\\image html revoluteLimitLimitation.png\r\n\r\n\tTo achieve this configuration, it is necessary to rotate the joint counter-clockwise so that low is below the 180 degree line. \r\n\r\n\tNOTE: If the angular region that is prohibited by the twist limit (as in the above figures) is very small, only a few degrees or so, then the joint may \"push through\" the limit and out on the other side if the relative angular velocity is large enough in relation to the time step. Care must be taken to make sure the limit is \"thick\" enough for the typical angular velocities it will be subjected to.\r\n\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include PJRevolute.vsl\r\n\t\r\n\t
\r\n\r\n\t

VSL : Limit Modification


\r\n\t\r\n\t\\include PJRevoluteSetLimits.vsl\r\n\t\r\n\t
\r\n\r\n\t

VSL : Motor Modification


\r\n\t\r\n\t\\include PJRevoluteSetMotor.vsl\r\n\t\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createJointRevolute().
\r\n\r\n\t*/\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetBehaviorCallbackFct( PJRevoluteCB );\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Anchor\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Anchor Reference\",CKPGUID_3DENTITY,\"0.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Axis\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Axis Up Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL);\r\n\tproto->DeclareInParameter(\"Projection Mode\",VTE_JOINT_PROJECTION_MODE,\"0\");\r\n\tproto->DeclareInParameter(\"Projection Distance\",CKPGUID_FLOAT,\"0\");\r\n\tproto->DeclareInParameter(\"Projection Angle\",CKPGUID_FLOAT,\"0.025\");\r\n\t\r\n\tproto->DeclareInParameter(\"Spring\",VTS_JOINT_SPRING);\r\n\tproto->DeclareInParameter(\"High Limit\",VTS_JLIMIT);\r\n\tproto->DeclareInParameter(\"Low Limit\",VTS_JLIMIT);\r\n\tproto->DeclareInParameter(\"Motor\",VTS_JOINT_MOTOR);\r\n\r\n\r\n\tproto->DeclareSetting(\"Spring\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Limit\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Motor\",CKPGUID_BOOL,\"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJRevolute);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJRevolute\r\n// FullName: PJRevolute\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJRevolute(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\r\n\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Revolute))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA && ! worldB )\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor = GetInputParameterValue(beh,bI_Anchor);\r\n\t\tVxVector anchorOut = anchor;\r\n\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);\r\n\t\tif (anchorReference)\r\n\t\t{\r\n\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t}\r\n\r\n\t\t//swing axis\r\n\t\tVxVector Axis = GetInputParameterValue(beh,bI_Axis);\r\n\t\tVxVector axisOut = Axis;\r\n\t\tCK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);\r\n\r\n\t\tif (axisReference)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\taxisReference->GetOrientation(&dir,&up,&right);\r\n\t\t\taxisReference->TransformVector(&axisOut,&up);\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//limit high : \r\n\t\tpJointLimit limitH;\r\n\t\tpJointLimit limitL;\r\n\t\tDWORD limit;\r\n\t\tbeh->GetLocalParameterValue(1,&limit);\r\n\t\tif (limit)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_HighLimit);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tlimitH = pFactory::Instance()->createLimitFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (limit)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_LowLimit);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tlimitL = pFactory::Instance()->createLimitFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tDWORD spring;\r\n\t\tpSpring sSpring; \r\n\t\tbeh->GetLocalParameterValue(0,&spring);\r\n\t\tif (spring)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_Spring);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tsSpring = pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpMotor motor;\r\n\r\n\t\tDWORD hasMotor;beh->GetLocalParameterValue(2,&hasMotor);\r\n\t\tif (hasMotor)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_Motor);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tmotor = pFactory::Instance()->createMotorFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t\r\n\t\tint col = GetInputParameterValue(beh,bbI_Collision);\r\n\t\tProjectionMode mode =GetInputParameterValue(beh,bbI_PMode); \r\n\t\tfloat distance = GetInputParameterValue(beh,bbI_PDistance); \r\n\t\tfloat angle= GetInputParameterValue(beh,bbI_PAngle); \r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\tpJointRevolute *joint = static_cast(worldA->getJoint(target,targetB,JT_Revolute));\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joint create ? \r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createRevoluteJoint(target,targetB,anchorOut,axisOut));\r\n\t\t\t}\r\n\t\t\t////////////////////////////////////////////////////////////////////////// Modification : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tjoint->setGlobalAxis(axisOut);\r\n\t\t\t\tjoint->setGlobalAnchor(anchorOut);\r\n\t\t\t\t\r\n\t\t\t\tif (mode!=0)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setProjectionMode(mode);\r\n\t\t\t\t\tjoint->setProjectionDistance(distance);\r\n\t\t\t\t\tjoint->setProjectionAngle(angle);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif(limit)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setHighLimit(limitH);\t\t\t\t\t\r\n\t\t\t\t\tjoint->setLowLimit(limitL);\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif (spring)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setSpring(sSpring);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (hasMotor)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setMotor(motor);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tjoint->enableCollision(col);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJRevoluteCB\r\n// FullName: PJRevoluteCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJRevoluteCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\r\n\t\t\r\n\t\t\tDWORD twistLimit;\r\n\t\t\tbeh->GetLocalParameterValue(1,&twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_HighLimit,twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_LowLimit,twistLimit);\r\n\r\n\t\t\tDWORD springSwing;\r\n\t\t\tbeh->GetLocalParameterValue(0,&springSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_Spring,springSwing);\r\n\r\n\t\t\tDWORD motor;\r\n\t\t\tbeh->GetLocalParameterValue(2,&motor);\r\n\t\t\tbeh->EnableInputParameter(bbI_Motor,motor);\r\n\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#include \r\n//#include \"stdafx.h\"\r\n#include \r\n#include \r\n#include \r\n\r\n#include \"ConStream.h\"\r\nusing namespace std;\r\n//\r\n// The ConStream constructor initializes the object to point to the\r\n// NUL device. It does this by calling two consecutive constructors.\r\n// First, the member variable m_Nul is initialized with a FILE object\r\n// created by opening device \"nul\", the bit bucket. Second, the base\r\n// class constructor is called with a reference to m_Nul, which is\r\n// an ofstream object. This sets up ConStream so that it will direct\r\n// its output to the given file.\r\n//\r\n\r\nConStream::ConStream() : m_Nul( m_fNul = fopen( \"nul\", \"w\" ) ),\r\n#ifdef _UNICODE\r\n basic_ostream( &m_Nul )\r\n#else\r\n basic_ostream( &m_Nul )\r\n#endif\r\n{\r\n\tlastLine = 0 ;\r\n\tfp;\r\n\tbuf = new char[MAX_PATH];\r\n m_FileBuf = 0;\r\n m_hConsole = INVALID_HANDLE_VALUE;\r\n}\r\n\r\n//\r\n// The ConStream destructor always has to close the m_fNul FILE object\r\n// which was created in the constructor. Even if the Open() method has\r\n// been called and the bit bucket isn't being used, the FILE object is\r\n// still using memory and a system file handle.\r\n//\r\n// If the ConStream object has been opened with a call to member function\r\n// Open(), we have to call the Win32 API function FreeConsole() to close\r\n// the console window. If the console window was open, we also call the\r\n// C fclose() function on the m_fConsole member.\r\n//\r\nConStream::~ConStream()\r\n{\r\n delete m_FileBuf;\r\n if ( m_hConsole != INVALID_HANDLE_VALUE ) {\r\n FreeConsole();\r\n fclose( fp );\r\n }\r\n fclose( fp );\r\n}\r\n\r\n//\r\n// Opening the stream means doing these things:\r\n// 1) Opening a Win32 console using the Win32 API\r\n// 2) Getting an O/S handle to the console\r\n// 3) Converting the O/S handle to a C stdio file handle\r\n// 4) Converting the C stdio file handler to a C FILE object\r\n// 5) Attaching the C FILE object to a C++ filebuf\r\n// 6) Attaching the filebuf object to this\r\n// 7) Disabling buffering so we see our output in real time.\r\n//\r\nvoid ConStream::Open()\r\n{\r\n\r\n\t// allocate a console for this app\r\n\r\n\tAllocConsole();\r\n\r\n\t// set the screen buffer to be big enough to let us scroll text\r\n\r\n\t// redirect unbuffered STDOUT to the console\r\n\r\n\tlStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\thConHandle = _open_osfhandle(lStdHandle, _O_TEXT);\r\n\r\n\tfp = _fdopen( hConHandle, \"w+\" );\r\n\r\n\t*stdout = *fp;\r\n\r\n\t//setvbuf( stdout, buf, _IOFBF , MAX_PATH );\r\n\tsetvbuf( stdout, NULL, _IONBF , 0);\r\n\r\n\t// redirect unbuffered STDIN to the console\r\n\r\n\tlStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);\r\n\r\n\thConHandle = _open_osfhandle(lStdHandle, _O_TEXT);\r\n\r\n\tfp = _fdopen( hConHandle, \"r+\" );\r\n\r\n\t*stdin = *fp;\r\n\r\n//\tsetvbuf( stdin, buf, _IOFBF, MAX_PATH );\r\n\tsetvbuf( stdin, NULL, _IONBF , 0);\r\n\r\n\r\n\t// redirect unbuffered STDERR to the console\r\n\r\n\tlStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);\r\n\r\n\thConHandle = _open_osfhandle(lStdHandle, _O_TEXT);\r\n\r\n\tfp = _fdopen( hConHandle, \"w+\" );\r\n\r\n\t*stderr = *fp;\r\n\r\n\t//setvbuf( stderr, buf, _IOFBF, MAX_PATH );\r\n\tsetvbuf( stderr, NULL, _IONBF, 0);\r\n\t/*SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN);*/\r\n\t// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog\r\n\t// point to console as well\r\n\tios::sync_with_stdio();\r\n\r\n};\r\n\r\n//\r\n// Closing the ConStream is considerably simpler. We just use the\r\n// init() call to attach this to the NUL file stream, then close\r\n// the console descriptors.\r\n//\r\nvoid ConStream::Close()\r\n{\r\n if ( fp != INVALID_HANDLE_VALUE ) {\r\n init( &m_Nul );\r\n FreeConsole();\r\n fclose( fp );\r\n// fp = INVALID_HANDLE_VALUE;\r\n }\r\n};\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\nvoid PhysicManager::_checkObjectsByAttribute()\r\n{\r\n\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tint sizeJFuncMap = ATT_FUNC_TABLE_SIZE;//(sizeof(*getRegistrationTable()) / sizeof((getRegistrationTable())[0]));\r\n\tfor (int fIndex = 0 ; fIndex < sizeJFuncMap ; fIndex ++)\r\n\t{\r\n\r\n\t\tstd::vectorattributeIdList;\r\n\t\tpFactory::Instance()->findAttributeIdentifiersByGuid(getRegistrationTable()[fIndex].guid,attributeIdList);\r\n\t\tint attCount = attributeIdList.size();\r\n\r\n\t\tfor (int i = 0 ; i < attCount ; i++ )\r\n\t\t{\r\n\t\t\tint currentAttType = attributeIdList.at(i);\r\n\t\t\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr( attributeIdList.at(i) );\r\n\t\t\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t\t\t{\t\r\n\t\t\t\tCK3dEntity *target = static_cast(*it);\r\n\t\t\t\tif (target)\r\n\t\t\t\t{\r\n\t\t\t\t\tXString error;\r\n\t\t\t\t\terror.Format(\"Registering :%s with %s\",target->GetName(),attman->GetAttributeNameByType(currentAttType));\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.CStr() );\r\n\t\t\t\t\t(*getRegistrationTable()[fIndex].rFunc)(target,currentAttType,true,false);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::_RegisterAttributeCallbacks()\r\n{\r\n\tif (!getAttributeFunctions().Size())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tAttributeFunctionArrayIteratorType it = getAttributeFunctions().Begin();\r\n\r\n\twhile(it != getAttributeFunctions().End())\r\n\t{\r\n\t\tObjectRegisterFunction myFn = (ObjectRegisterFunction)*it;\r\n\t\tif (myFn)\r\n\t\t{\r\n\t\t\tattman->SetAttributeCallbackFunction(it.GetKey(),PObjectAttributeCallbackFunc,myFn);\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::cleanAttributePostObjects()\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tif (!getAttributePostObjects().Size())\r\n\t\treturn;\r\n\t\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tPostRegistrationArrayIteratorType it = getAttributePostObjects().Begin();\r\n\twhile(it != getAttributePostObjects().End())\r\n\t{\r\n\t\tpAttributePostObject& post = *it;\r\n\t\tCK3dEntity *refObject = static_cast(GetPMan()->m_Context->GetObject(post.objectId));\r\n\t\tif (refObject)\r\n\t\t{\r\n\r\n\t\t\tObjectRegisterFunction regFn = (ObjectRegisterFunction)post.func;\r\n\t\t\tif (regFn)\r\n\t\t\t{\r\n\t\t\t\t(*regFn)(refObject,post.attributeID,true,false);\r\n\t\t\t}\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n\tint s = getAttributePostObjects().Size();\r\n\r\n\tgetAttributePostObjects().Clear();\r\n}\r\n\r\nvoid PhysicManager::populateAttributeFunctions()\r\n{\r\n\r\n\tgetAttributeFunctions().Clear();\r\n\r\n\tint sizeJFuncMap = ATT_FUNC_TABLE_SIZE;// (sizeof(*getRegistrationTable()) / sizeof(ObjectRegistration));\r\n\tfor (int fIndex = 0 ; fIndex < sizeJFuncMap ; fIndex ++)\r\n\t{\r\n\t\t#ifdef _DEBUG \r\n\r\n\t\t//XString _errorStr;\r\n\t\t//getRegistrationTable()[fIndex].rFunc.\r\n\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errString.Str());\r\n\r\n\t\t#endif\r\n\r\n\t\tstd::vectorattributeIdList;\r\n\t\tpFactory::Instance()->findAttributeIdentifiersByGuid(getRegistrationTable()[fIndex].guid,attributeIdList);\r\n\t\tint attCount = attributeIdList.size();\r\n\t\tfor (int i = 0 ; i < attCount ; i++ )\r\n\t\t{\r\n\t\t\tint currentAttType = attributeIdList.at(i);\r\n\t\t\tgetAttributeFunctions().Insert(currentAttType,getRegistrationTable()[fIndex].rFunc);\r\n\t\t}\r\n\t}\r\n}\r\nObjectRegistration*PhysicManager::getRegistrationTable()\r\n{\r\n\treturn attributeFunctionMap;\r\n}\r\n// racer/driveline.h\n\n#ifndef __P_DRIVELINE_H__\n#define __P_DRIVELINE_H__\n\n#include \"vtPhysXBase.h\"\n#include \"XString.h\"\n\n/*\n#ifdef RR_FIXED_TIMESTEP\n#define RR_TIMESTEP 0.01f\n#else\n#define RR_TIMESTEP 0.01f\n#endif\n*/\n\n#define D3_EPSILON (0.00001f)\n\n// Generic constants\n#ifndef PI\n#define PI 3.14159265358979\n#endif\n\n\n// Clutch must be smoothed out a lot when applying starts\n#define DEFAULT_CLUTCH_LINEARITY 0.3f\n\n// Threshold at which force an unlock of engine and gearbox.\n// This can happen if the driver just throws in a gear,\n// without clutching (and if autoclutch is off).\n// We should penalize this with a gear scratch sound and\n// damage.\n#define DELTA_VEL_THRESHOLD 1.0f\n\nclass pDriveLine;\n\nclass MODULE_API pDriveLineComp\n// Driveline component base class\n{\n protected:\n // Administration\n XString name; // For easier debugging\n pDriveLineComp *parent, // Bi-directional tree\n *child[2];\n pDriveLine *driveLine; // Part of which driveline\n\n\n private:\n // Static data\n float inertia; // Inertia of this component\n float ratio; // Gearing ratio (gearbox/differential)\n float invRatio; // 1/ratio (optimized multiplication)\n\n // Semi-static data (recalculated when gear is changed)\n float effectiveInertiaDownStream; // Inertia of component + children\n float cumulativeRatio; // Ratio at this point of the driveline\n\n // Dynamic data\n protected:\n float tReaction, // Reaction torque\n tBraking, // Braking torque (also a reaction torque)\n tEngine; // Torque from the engine side\n // State\n float rotV, // Rotational velocity\n rotA; // Rotational acceleration\n\n public:\n pDriveLineComp();\n virtual ~pDriveLineComp();\n\n // Attribs\n XString GetName(){ return name.CStr(); }\n void SetName(XString s){ name=s; }\n float GetInertia(){ return inertia; }\n void SetInertia(float i){ inertia=i; }\n float GetRatio(){ return ratio; }\n void SetRatio(float r);\n float GetInverseRatio(){ return invRatio; }\n float GetEffectiveInertia(){ return effectiveInertiaDownStream; }\n float GetCumulativeRatio(){ return cumulativeRatio; }\n pDriveLine *GetDriveLine();\n void SetDriveLine(pDriveLine *dl){ driveLine=dl; }\n pDriveLineComp *GetParent(){ return parent; }\n pDriveLineComp *GetChild(int n);\n float GetReactionTorque(){ return tReaction; }\n float GetBrakingTorque(){ return tBraking; }\n float GetEngineTorque(){ return tEngine; }\n\n float GetRotationVel(){ return rotV; }\n void SetRotationVel(float v){ rotV=v; }\n float GetRotationAcc(){ return rotA; }\n void SetRotationAcc(float a){ rotA=a; }\n\n // Attaching to other components\n void AddChild(pDriveLineComp *comp);\n void SetParent(pDriveLineComp *comp);\n\n // Reset for new use\n virtual void Reset();\n\n\n // Precalculation\n void CalcEffectiveInertia();\n void CalcCumulativeRatio();\n\n // Physics\n void CalcReactionForces();\n void CalcEngineForces();\n virtual void CalcForces();\n virtual void CalcAccelerations();\n virtual void Integrate();\n\n\n // Debugging\n void DbgPrint(int depth,XString s);\n};\n\nclass MODULE_API pDriveLine\n// A complete driveline\n// Includes the clutch and the handbrakes\n{\n public:\n pDriveLineComp *root; // Root of driveline tree; the engine\n pDriveLineComp *gearbox; // The gearbox is always there\n pVehicle *car;\n\n // Static driveline data\n int diffs; // Number of differentials\n\n // Semi-static driveline data (changes when gear is changed)\n float preClutchInertia, // Total inertia before clutch (engine)\n postClutchInertia, // After clutch (gearbox, diffs)\n totalInertia; // Pre and post clutch inertia\n\n // Clutch\n float clutchApplication, // 0..1 (how much clutch is applied)\r\n clutchLinearity, // A linear clutch was too easy to stall\n clutchMaxTorque, // Clutch maximum generated torque (Nm)\n clutchCurrentTorque; // Clutch current torque (app*max)\n bool autoClutch; // Assist takes over clutch?\n\n // Handbrakes\n float handbrakeApplication; // 0..1 (control)\n\n // Dynamic\n bool prepostLocked; // Engine is locked to rest of drivetrain?\n float tClutch; // Directed clutch torque (+/-clutchCurT)\n\n public:\n pDriveLine(pVehicle *car);\n ~pDriveLine();\n\n // Attribs\n void SetRoot(pDriveLineComp *comp);\n pDriveLineComp *GetRoot(){ return root; }\n pDriveLineComp *GetGearBox(){ return gearbox; }\n void SetGearBox(pDriveLineComp *c){ gearbox=c; }\n bool IsSingleDiff(){ return diffs==1; }\n int GetDifferentials(){ return diffs; }\n void SetDifferentials(int n){ diffs=n; }\n bool IsPrePostLocked(){ return prepostLocked; }\n void LockPrePost(){ prepostLocked=true; }\n void UnlockPrePost(){ prepostLocked=false; }\n float GetClutchTorque(){ return tClutch; }\n\n // Precalculation\n void CalcCumulativeRatios();\n void CalcEffectiveInertiae();\n void CalcPreClutchInertia();\n void CalcPostClutchInertia();\n\n // Clutch\n float GetClutchApplication(){ return clutchApplication; }\n float GetClutchMaxTorque(){ return clutchMaxTorque; }\n float GetClutchCurrentTorque(){ return clutchCurrentTorque; }\n void SetClutchApplication(float app);\n bool IsAutoClutchActive(){ return autoClutch; }\n void EnableAutoClutch(){ autoClutch=true; }\n void DisableAutoClutch(){ autoClutch=false; }\n\n // Handbrakes\n float GetHandBrakeApplication(){ return handbrakeApplication; }\n\n // Definition\n\n // Input\n void SetInput(int ctlClutch,int ctlHandbrake);\n\n // Physics\n void Reset();\n void CalcForces();\n void CalcAccelerations();\n void Integrate();\n\n // Debugging\n void DbgPrint(XString& s);\n};\n\n#endif\n\n#include \"StdAfx2.h\"\r\n#include \"PCommonDialog.h\"\r\n#include \"PBodySetup.h\"\r\n#include \"PBodyTabCtrl.h\"\r\n#include \"PBXMLSetup.h\"\r\n#include \"resource.h\"\r\n#include \"VITabCtrl.h\"\r\n\r\n\r\n#include \"resource.h\"\r\n#include \"VITabCtrl.h\"\r\n#include \"VIControl.h\"\r\n#include \"..\\..\\include\\interface\\pcommondialog.h\"\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* Global vars */\r\n/************************************************************************/\r\n\r\nstatic CPSharedBase *gXML=NULL;\r\nstatic CPSharedBase *gCOMMON=NULL;\r\nstatic CPSharedBase *gCOLLISION=NULL;\r\nstatic CPSharedBase *gOPTIMIZATION=NULL;\r\n\r\n\r\nstatic CPSharedBase* gSharedBase=NULL;\r\n\r\nstatic CPSharedBase *gDialogs[DLGCOUNT] = \r\n{\r\n\tgXML,\r\n\tgCOMMON,\r\n};\r\n\r\nCPBParentDialog::CPBParentDialog(CKParameter* Parameter,CWnd*parent,CK_CLASSID Cid)\t: \r\n\tCParameterDialog(Parameter,Cid) , CPSharedBase(Parameter,this,Cid) , m_TabControl(parent)\r\n{\t\r\n\r\n\r\n\tif (_cleanUpIfNew(Parameter))\r\n\t{\r\n\t\t_emptyTabs();\r\n\t}\r\n\r\n\tif (gSharedBase)\r\n\t\tgSharedBase=NULL;\r\n\r\n\tgSharedBase =this;\r\n\tsetRootDialog(this);\r\n\tsetRootParameter(Parameter);\r\n\tgetInstance();\r\n\t//loadTabPane();\r\n}\r\nCPBParentDialog::CPBParentDialog(CKParameter* Parameter,CK_CLASSID Cid)\t: \r\n\tCParameterDialog(Parameter,Cid) , CPSharedBase(Parameter,this,Cid) , m_TabControl(NULL)\r\n{\t\r\n\r\n\t\tif (_cleanUpIfNew(Parameter))\r\n\t\t{\r\n\t\t\t_emptyTabs();\r\n\t\t}\r\n\r\n\t\tgSharedBase = this;\t\t\r\n\t\tsetRootDialog(this);\r\n\t\tsetRootParameter(Parameter);\r\n\t\t//loadTabPane();\r\n\r\n\r\n}\r\n\r\n\r\nvoid CPBParentDialog::_destroy()\r\n{\r\n\tif (getTabs().GetTabCount())\r\n\t{\r\n\t\t_emptyTabs();\r\n\t}\r\n\r\n\tgSharedBase=NULL;\r\n}\r\n\r\n/*\r\n\r\nCPBParentDialog::CPBParentDialog(CWnd* pParent = NULL)\t: \r\nCParameterDialog(Parameter,Cid) , CPSharedBase(Parameter,this,Cid)\r\n{\t\r\n\r\n\tif (_cleanUpIfNew(Parameter))\r\n\t{\r\n\t\t_emptyTabs();\r\n\t}\r\n\r\n\tgSharedBase = this;\t\t\r\n\tsetRootDialog(this);\r\n\tsetRootParameter(Parameter);\r\n\r\n}*/\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\nBOOL CPSharedBase::initChildWin(CDialog* pDlg, UINT dialogID,UINT dialogPlaceHolderID)\r\n{\r\n\r\n\tASSERT( pDlg );\r\n\r\n\tif (!pDlg)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\r\n\t// wind handle of the target bed :\r\n\tHWND dstWindow = NULL;\r\n\tCPBParentDialog* parent = (CPBParentDialog*)getInstance()->getRootDlg();\r\n\tif (parent)\r\n\t{\r\n\t\tdstWindow = parent->getDlgWindowHandle(dialogPlaceHolderID);\r\n\t\r\n\t}else\r\n\t\treturn false;\r\n\r\n\r\n\r\n\tCWnd *cDstWindow = CWnd::FromHandle(dstWindow);\r\n\tif (cDstWindow)\r\n\t{\r\n\t\tint p = getNbDialogs();\r\n\t}else\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\r\n\r\n\t//CWnd* pWnd = pDlg->GetDlgItem( dialogPlaceHolderID );\r\n\tCRect rcValue;\r\n\r\n\tif (pDlg) \r\n\t{\r\n\t\tcDstWindow->GetWindowRect( &rcValue ); // Use picture box position.\r\n\t\tparent->ScreenToClient( &rcValue );\r\n\r\n\t\tif (pDlg->Create( dialogID, cDstWindow ))\r\n\t\t{\r\n\t\t\tpDlg->SetWindowPos( cDstWindow, rcValue.left, rcValue.top,rcValue.Width(), rcValue.Height(), SWP_HIDEWINDOW);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//pWnd->ShowWindow(SWP_SHOWWINDOW);\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n\r\n\r\nvoid CPSharedBase::_dtrBodyCommonDlg(){}\r\n\r\n\r\n\r\nCPSharedBase* CPSharedBase::getDialog(int identifier)\r\n{\r\n\tASSERT( identifier >= 0 && identifier < DLGCOUNT );\r\n\tif (gDialogs[identifier])\r\n\t\treturn gDialogs[identifier];\r\n\r\n\treturn NULL;\r\n}\r\n\r\nvoid CPSharedBase::setDialog(int identifier,CPSharedBase*src)\r\n{\r\n\tASSERT( identifier >= 0 && identifier < DLGCOUNT );\r\n\t//if (gDialogs[identifier] != src )\r\n\tgDialogs[identifier] = src;\r\n}\r\nvoid CPSharedBase::destroyDialog(int identifier,CPSharedBase*src)\r\n{\r\n\tASSERT( identifier >= 0 && identifier < DLGCOUNT );\r\n\tif (src)\r\n\t{\r\n\t\t\r\n\t}\r\n\tsrc = gDialogs[identifier] = NULL;\r\n\r\n}\r\nCParameterDialog\t*CPSharedBase::getRootDlg()\r\n{\t\r\n\treturn getInstance() ? getInstance()->dlgRoot : NULL;\t\r\n}\r\nCKParameter\t\t\t*CPSharedBase::getRootParameter()\r\n{\r\n\treturn getInstance() ? getInstance()->parameter : NULL;\t\r\n}\r\nvoid\tCPSharedBase::setRootParameter(CKParameter * val) \r\n{\r\n\tif (getInstance())\r\n\t\tgetInstance()->parameter = val;\t\r\n}\r\nvoid\tCPSharedBase::setRootDialog(CParameterDialog * val)\r\n{\t\t\r\n\tif (getInstance())\t\t\r\n\t\tgetInstance()->dlgRoot = val;\t\r\n}\r\nParDialogArrayType&\tCPSharedBase::getDialogs()\r\n{\r\n\treturn getInstance() ? getInstance()->mDialogs : ParDialogArrayType() ; \r\n}\r\n\r\n\r\nCPSharedBase::~CPSharedBase()\r\n{\r\n\t_reset();\r\n}\r\nvoid CPSharedBase::_destroy()\r\n{\t\r\n\r\n}\r\nvoid CPSharedBase::_reset()\r\n{\r\n\tparameter = NULL;\r\n\tdlgRoot = NULL;\r\n\tmDialogs.Clear();\r\n\tmTab = NULL;\r\n\t\r\n}\r\n\r\nvoid CPSharedBase::_construct()\r\n{\r\n\r\n}\r\n\r\nCPSharedBase::CPSharedBase(\r\n\t\t\t\t\t\t CKParameter* Parameter,\r\n\t\t\t\t\t\t CParameterDialog *rootDialog,\r\n\t\t\t\t\t\t CK_CLASSID Cid)\t:\r\n\t\t\t\t\t\t\t\tdlgRoot(rootDialog) , parameter(Parameter)\r\n{\t\t\r\n\tmDialogs.Clear();\r\n\tmTab = NULL;\r\n}\r\n\r\nCPSharedBase::CPSharedBase(CKParameter* Parameter,CK_CLASSID Cid)\r\n{\t\r\n\tdlgRoot=NULL;\r\n\tmDialogs.Clear();\r\n\tmTab = NULL;\r\n\t\r\n\r\n}\r\nCPSharedBase*CPSharedBase::getInstance()\r\n{\t\r\n\treturn gSharedBase;\r\n}\r\nCPSharedBase::CPSharedBase(CParameterDialog *consumer,CKParameter* parameter)\r\n{\t\t\r\n\taddDialog(consumer,parameter);\t\r\n}\r\nvoid CPSharedBase::addDialog(CParameterDialog *dlg,CKParameter*parameter)\r\n{\t\t\r\n\t/*if(getInstance() && (*getDialogs().FindPtr(parameter)))\t\t\r\n\t\tgetDialogs().InsertUnique(parameter,dlg);\t*/\r\n}\r\nCPSharedBase**\tCPSharedBase::getStaticDialogs()\r\n{\r\n\treturn gDialogs;\t\r\n}\r\nint CPSharedBase::getNbDialogs()\r\n{\t\r\n\tint result = 0;\r\n\tfor ( int i = 0 ; i < DLGCOUNT ; i++ )\r\n\t{\r\n\t\tif (getStaticDialogs()[i] != NULL )\r\n\t\t{\r\n\t\t\tresult++;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n\r\n}\r\n\r\n/*\r\nLRESULT CPBParentDialog::OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam)\r\n{\r\n\r\n\tWORD keyState = 0;\r\n\tkeyState |= (::GetKeyState(VK_CONTROL) < 0) ? MK_CONTROL : 0;\r\n\tkeyState |= (::GetKeyState(VK_SHIFT) < 0) ? MK_SHIFT : 0;\r\n\r\n\tLRESULT lResult;\r\n\tHWND hwFocus = ::GetFocus();\r\n\tconst HWND hwDesktop = ::GetDesktopWindow();\r\n\r\n\tif (hwFocus == NULL)\r\n\t\tlResult = SendMessage(WM_MOUSEWHEEL, (wParam << 16) | keyState, lParam);\r\n\telse\r\n\t{\r\n\t\tdo {\r\n\t\t\tlResult = ::SendMessage(hwFocus, WM_MOUSEWHEEL,(wParam << 16) | keyState, lParam);\r\n\t\t\thwFocus = ::GetParent(hwFocus);\r\n\t\t}\r\n\t\twhile (lResult == 0 && hwFocus != NULL && hwFocus != hwDesktop);\r\n\t}\r\n\treturn lResult;\r\n\r\n}\r\n*/\r\n/*\r\nvoid CPBParentDialog::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)\r\n{\r\n\r\n\t//int cStates = GET_KEYSTATE_WPARAM(wParam);\r\n\tint wheelDirection = zDelta;\r\n\r\n\tif (wheelDirection>0)\r\n\t{\r\n\t\tif ( mTestViControl.GetActiveTabIndex() +1 < mTestViControl.GetTabCount() )\r\n\t\t{\r\n\t\t\tmTestViControl.SetActiveTab(mTestViControl.GetActiveTabIndex() +1 );\r\n\t\t}else{\r\n\t\t\tmTestViControl.SetActiveTab( 0 );\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\tif ( mTestViControl.GetActiveTabIndex() -1 >=0 )\r\n\t\t{\r\n\t\t\tmTestViControl.SetActiveTab(mTestViControl.GetActiveTabIndex() - 1 );\r\n\t\t}else{\r\n\t\t\tmTestViControl.SetActiveTab(mTestViControl.GetTabCount());\r\n\t\t}\r\n\t}\r\n}\r\n*/\r\n\r\n\r\nvoid CPBParentDialog::InitAllControls()\r\n{\r\n\tCRect rect;\r\n\tEnableWindow(true);\r\n\r\n\r\n\tPBodyTabContrl* viCtrl = getTabControl();\r\n\tif (!viCtrl)return;\r\n\r\n\r\n\r\n\tGetClientRect(&rect);\r\n\tHRESULT res = ((VITabCtrl*)getTabControl())->Create(\"NoName\",VITabCtrl::VITAB_UP|VITabCtrl::VITAB_DOWN,rect,((CWnd*)(getTabControl())),IDC_PBODY_TAB_PANE);\r\n\tgetTabControl()->GetClientRect(&rect);\r\n\r\n\tgetTabControl()->_construct();\r\n\r\n\tgetTabControl()->GetClientRect(&rect);\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\t// wind handle of the target bed :\r\n\tHWND dstWindow = NULL;\r\n\tCWnd *cDstWindow = NULL;\r\n\tCPBParentDialog* parent = (CPBParentDialog*)getInstance()->getRootDlg();\r\n\r\n\r\n\r\n\r\n\tif (parent)\r\n\t{\r\n\t\tdstWindow = parent->getDlgWindowHandle(IDC_SPACER);\r\n\t\tif (dstWindow)\r\n\t\t{\r\n\t\t\tcDstWindow= CWnd::FromHandle(dstWindow);\r\n\t\t\r\n\t\t\tCRect rcValue;\r\n\t\t\tcDstWindow->GetWindowRect( &rcValue ); // Use picture box position.\r\n\t\t\tparent->ScreenToClient( &rcValue );\r\n\r\n\t\t\tCWnd * target = parent->GetDlgItem(IDC_PBODY_TAB_PANE);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\r\n\t\t\t\t//target->SetWindowPos( cDstWindow, rcValue.left, rcValue.top,rcValue.Width(), rcValue.Height(), SWP_SHOWWINDOW);\r\n\t\t\t\t//pWnd->ShowWindow(SWP_SHOWWINDOW);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\r\n\r\n\r\n\t//CPBParentDialog* parent = (CPBParentDialog*)getInstance()->getRootDlg();\r\n\t\t\t\r\n\r\n\t\t\t\r\n\t\t\tint err = getTabControl()->InsertTab(-1,\"XML\",parent,true);\r\n\t\t\terr = getTabControl()->InsertTab(-1,\"XMLasas\",parent,true );\r\n\t\t\t\r\n\t\t\r\n\t\t\tVITabCtrl::VITab *bTab= new VITabCtrl::VITab();\r\n\t\t\tbTab->m_Flags=VITabCtrl::VITAB_BORDER;\r\n\t\t\tbTab->m_Name = \"XML\";\r\n\t\t\tbTab->m_Width = 30;\r\n\t\t\tbTab->m_Wnd = NULL;\r\n\r\n\r\n\t\t\terr = getTabControl()->GetTabCount();\r\n\t\t\terr = getTabControl()->InsertTab(-1,bTab,true);\r\n\r\n\t\t\t\r\n\r\n\t\t\r\n\t\t\t\r\n\t//\t\tparent->ScreenToClient( &rect );\r\n\t//\t\tgetTabControl()->ScreenToClient(&rect);\r\n\t\t\t//*/\r\n\r\n\r\n}\r\n\r\nint CPBParentDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)\r\n{\r\n\tif (__super::OnCreate(lpCreateStruct) == -1)\r\n\t\treturn -1;\r\n\r\n\treturn 1;\r\n}\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t Keyboard Camera Orbit\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"GeneralCameraOrbit.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorKeyboardCameraOrbitDecl();\r\nCKERROR CreateKeyboardCameraOrbitProto(CKBehaviorPrototype **pproto);\r\nint KeyboardCameraOrbit(const CKBehaviorContext& behcontext);\r\nvoid ProcessKeyboardInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping);\r\n\r\nCKObjectDeclaration\t*FillBehaviorKeyboardCameraOrbitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Keyboard Camera Orbit\");\r\n\tod->SetDescription(\"Makes a Camera orbit round a 3D Entity using keyboard with limited angles.\");\r\n\t/* rem:\r\n\tOn: Starts the behavior.
\r\n\tOff: Stops the behavior.
\r\n\tExit On: is activated when the behavior has been started.
\r\n\tExit Off: is activated when the behavior has been stop. If in \"return\" mode, is activated only once the camera is back in place.
\r\n\t
\r\n\tTarget Position: Position we are turning around.
\r\n\tTarget Referential: Referential where the position is defined.
\r\n\tMove Speed: Speed in angle per second used when the user moves the camera.
\r\n\tReturn Speed: Speed in angle per second used when the camera returns.
\r\n\tMin Horizontal: Minimal angle allowed on the horizontal rotation. Must have a negative value.
\r\n\tMax Horizontal:Maximal angle allowed on the horizontal rotation. Must have a positive value.
\r\n\tMin Vertical: Minimal angle allowed on the vertical rotation. Must have a negative value.
\r\n\tMax Vertical: Maximal angle allowed on the vertical rotation. Must have a positive value.
\r\n\tZoom Speed: Speed of the zoom in distance per second.
\r\n\tZoom Min: Minimum zoom value allowed. Must have a negative value.
\r\n\tZoom Max: Maximum zoom value allowed. Must have a positive value.
\r\n\t
\r\n\tThe following keys are used by default to move the Camera around its target:
\r\n\t
\r\n\tPage Up: Zoom in.
\r\n\tPage Down: Zoom out.
\r\n\tUp and Down Arrows: Rotate vertically.
\r\n\tLeft and Right Arrows: Rotate horizontally.
\r\n\tThe arrow keys are the inverted T arrow keys and not the ones of the numeric keypad.
\r\n
\r\n\tReturns: Does the camera systematically returns to its original position.
\r\n\tKey Rotate Left: Key used to rotate left.
\r\n\tKey Rotate Right: Key used to rotate right.
\r\n\tKey Rotate Up: Key used to rotate up.
\r\n\tKey Rotate Down: Key used to rotate down.
\r\n\tKey Zoom in: Key used to zoom in.
\r\n\tKey Zoom out: Key used to zoom in.
\r\n
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Movement\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7610f4d,0x69747b9d));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateKeyboardCameraOrbitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tPrototype creation\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR CreateKeyboardCameraOrbitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Keyboard Camera Orbit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t// General Description\r\n\tCKERROR error = FillGeneralCameraOrbitProto(proto);\r\n\tif (error != CK_OK)\r\n\t\treturn (error);\r\n\r\n\t// Additionnal Settings for the Keyboard\r\n\tproto->DeclareSetting(\"Key Rotate Left\", CKPGUID_KEY,\"Left Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Right\", CKPGUID_KEY,\"Right Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Up\", CKPGUID_KEY,\"Up Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Down\", CKPGUID_KEY,\"Down Arrow\");\r\n\tproto->DeclareSetting(\"Key Zoom In\", CKPGUID_KEY,\"PREVIOUS\");\r\n\tproto->DeclareSetting(\"Key Zoom Out\", CKPGUID_KEY,\"NEXT\");\r\n\r\n\t// Set the execution functions\r\n\tproto->SetFunction(KeyboardCameraOrbit);\r\n\tproto->SetBehaviorCallbackFct(GeneralCameraOrbitCallback,CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORCREATE);\r\n\r\n\t// return OK\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tMain Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nint KeyboardCameraOrbit(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn ( GeneralCameraOrbit(behcontext,ProcessKeyboardInputs) );\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFunction that process the inputs\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid ProcessKeyboardInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping)\r\n{\r\n\t// Is the move limited ?\r\n\tCKBOOL Limited = TRUE;\r\n\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\r\n\t// Gets the keys settings\r\n\tint key_left=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_LEFT,&key_left);\r\n\tif(!key_left) key_left=CKKEY_LEFT;\r\n\r\n\tint key_right=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_RIGHT,&key_right);\r\n\tif(!key_right) key_right=CKKEY_RIGHT;\r\n\r\n\tint key_up=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_UP,&key_up);\r\n\tif(!key_up) key_up=CKKEY_UP;\r\n\r\n\tint key_down=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_DOWN,&key_down);\r\n\tif(!key_down) key_down=CKKEY_DOWN;\r\n\r\n\tint key_Zin=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_ZIN,&key_Zin);\r\n\tif(!key_Zin) key_Zin=CKKEY_PRIOR;\r\n\r\n\tint key_Zout=0;\r\n\tbeh->GetLocalParameterValue(LOCAL_KEY_ZOUT,&key_Zout);\r\n\tif(!key_Zout) key_Zout=CKKEY_NEXT;\r\n\r\n\r\n\t////////////////////\r\n\t// Position Update\r\n\t////////////////////\r\n\r\n\t// If the users is moving the camera\r\n\tif (((input->IsKeyDown(key_left)) || (input->IsKeyDown(key_right)) || (input->IsKeyDown(key_up))\r\n\t\t|| (input->IsKeyDown(key_down)))\r\n\t\t&& !stopping)\r\n\t{\r\n\t\tfloat SpeedAngle = 0.87f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_MOVE,&SpeedAngle);\r\n\t\tSpeedAngle *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\r\n\t\t\tfloat MinH = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_H, &MinH);\r\n\r\n\t\t\tfloat MaxH = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_H, &MaxH);\r\n\r\n\t\t\tfloat MinV = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_V, &MinV);\r\n\r\n\t\t\tfloat MaxV = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_V, &MaxV);\r\n\r\n\t\t\tif( input->IsKeyDown(key_right)\t) RotationAngles->x += XMin(SpeedAngle, MaxH - RotationAngles->x);\r\n\t\t\tif( input->IsKeyDown(key_left)\t) RotationAngles->x -= XMin(SpeedAngle, RotationAngles->x - MinH);\r\n\t\t\tif( input->IsKeyDown(key_down)\t) RotationAngles->y += XMin(SpeedAngle, MaxV - RotationAngles->y);\r\n\t\t\tif( input->IsKeyDown(key_up)\t) RotationAngles->y -= XMin(SpeedAngle, RotationAngles->y - MinV);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif( input->IsKeyDown(key_right)\t) RotationAngles->x += SpeedAngle;\r\n\t\t\tif( input->IsKeyDown(key_left)\t) RotationAngles->x -= SpeedAngle;\r\n\t\t\tif( input->IsKeyDown(key_down)\t) RotationAngles->y += SpeedAngle;\r\n\t\t\tif( input->IsKeyDown(key_up)\t) RotationAngles->y -= SpeedAngle;\r\n\t\t}\r\n\t}\r\n\telse if ((Returns) && ((RotationAngles->x != 0) || (RotationAngles->y != 0)))\r\n\t{\r\n\t\tfloat ReturnSpeedAngle = 1.75f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_RETURN, &ReturnSpeedAngle);\r\n\t\tReturnSpeedAngle *= delta / 1000;\r\n\r\n\t\tif( RotationAngles->x < 0 ) RotationAngles->x += XMin(ReturnSpeedAngle, -RotationAngles->x);\r\n\t\tif( RotationAngles->x > 0 ) RotationAngles->x -= XMin(ReturnSpeedAngle, RotationAngles->x);\r\n\t\tif( RotationAngles->y < 0 ) RotationAngles->y += XMin(ReturnSpeedAngle, -RotationAngles->y);\r\n\t\tif( RotationAngles->y > 0 ) RotationAngles->y -= XMin(ReturnSpeedAngle, RotationAngles->y);\r\n\t}\r\n\r\n\r\n\t////////////////\r\n\t// Zoom Update\r\n\t////////////////\r\n\r\n\tif ( (input->IsKeyDown(key_Zin)) || (input->IsKeyDown(key_Zout)) && !stopping ) \r\n\t{\r\n\t\tfloat ZoomSpeed = 40.0f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_ZOOM, &ZoomSpeed);\r\n\t\tZoomSpeed *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinZoom = -40.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_ZOOM, &MinZoom);\r\n\r\n\t\t\tfloat MaxZoom = 10.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_ZOOM, &MaxZoom);\r\n\r\n\t\t\tif( input->IsKeyDown(key_Zin)\t) RotationAngles->z -= XMin(ZoomSpeed, RotationAngles->z + MaxZoom );\r\n\t\t\tif( input->IsKeyDown(key_Zout)\t) RotationAngles->z += XMin(ZoomSpeed, - MinZoom - RotationAngles->z);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif( input->IsKeyDown(key_Zin)\t) RotationAngles->z -= ZoomSpeed;\r\n\t\t\tif( input->IsKeyDown(key_Zout)\t) RotationAngles->z += ZoomSpeed;\r\n\t\t}\r\n\t}\r\n}\r\n#ifndef _XDISTRIBUTED_3D_OBJECT_CLASS_H_\r\n#define _XDISTRIBUTED_3D_OBJECT_CLASS_H_\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n\r\nclass xDistributed3DObjectClass : public xDistributedClass\r\n{\r\n\r\n\r\n\t public : \r\n\t\t xDistributed3DObjectClass();\r\n\t\t int getFirstUserField();\r\n\t\t int getUserFieldBitValue(int walkIndex);\r\n\t\t int getInternalUserFieldIndex(int inputIndex);\r\n\t\t int getUserFieldCount();\r\n\t\t \r\n\t\t void addProperty(const char*name,int type,int predictionType);\r\n\t\t void addProperty(int nativeType,int predictionType);\r\n\r\n\r\n\tprotected : \r\n\r\n};\r\n\r\n#endif\r\n/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 11:07\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\vtPhysXBase.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common \r\n\tfile base:\tvtPhysXBase\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tMinimal includes for the whole component. \r\n\t\t\t\t\r\n\t\t\t\t+ Generic macros and constants, functions\r\n\t\t\t\t+ Virtools specific forward decalarations\r\n\t\t\t\t+ Generic base types such as std::vector\r\n\t\t\t\t+ Component specific forward decalarations\r\n\t\t\t\t+ Disabling Module specific Visual Studio compiler Warnings\r\n\t\t\t\t+ Prerequisites\r\n\t\t\t\t+ Virtools Base Types ( XString, CKGUID, HashTable )\r\n\t\t\t\t+ Constants\r\n\t\r\n\twarning:\tThe order of the includes must stay !\t\t\r\n\r\n\tremarks:\t- This module is using the concept of forward declaration \r\n\t\t\t\t- This header is the base for all other headers.\r\n\t\t\t\t- Do not introduce any platform specific dependencies( ie: windows.h )\r\n\r\n*********************************************************************/\r\n\r\n\r\n\r\n#ifndef __VT_PHYSX_BASE_H__\r\n#define __VT_PHYSX_BASE_H__\r\n\r\n//################################################################\r\n//\r\n// Generic \r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tInclude of base types, not involving external dependencies to std,etc..\r\n//\t\r\n#include \r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tClass to encapsulate a set of flags in a word, using shift operators\r\n//\r\n#include \r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tMacros for generic DLL exports \r\n//\r\n#include \r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tInclude of Virtools related macros\r\n//\r\n#include \r\n\r\n\r\n//################################################################\r\n//\r\n// Component specific constants,strings, error codes\r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\t\t\t+\tAPI Prefix \r\n//\t\t\t+\tError Codes \r\n//\t\t\t+\tError Strings\r\n//\r\n#include \"vtModuleConstants.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tVirtools Guids of the plug-in ( manager + building block only !!! )\r\n//\t\r\n//\tGUIDS for custom enumerations, structures are included by the managers \r\n//\tparameter_x.cpp explicitly ! \r\n//\r\n#include \"vtModuleGuids.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tEnumerations to identifier a custom structure's sub item\r\n//\r\n#include \"vtParameterSubItemIdentifiers_All.h\"\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tEnumerations used by the SDK and the Virtools Interface ( Schematics, VSL)\r\n//\r\n#include \"vtInterfaceEnumeration.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Compiler specific warnings \r\n//\r\n#include \"vcWarnings.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Prerequisites \r\n//\r\n#include \"Prerequisites_All.h\"\r\n\r\n\r\n\r\n\r\n\r\n#endif\r\n ProfileEnabled = FALSE\r\n ProfilingBar = FALSE\r\n ProfilingHistogram = FALSE\r\n ProfilingHistogramRate = 2000.000000\r\n\r\n\r\n Textures,Sprites = Global Format\r\n Sounds = Includes Original Files\r\n Compression = Compressed\r\n Compression Level = 4\r\n\r\n\r\n StartingFlags = NA\r\n\r\n\r\n MaxIteration = 90000\r\n\r\n\r\n Mixing Method = Software\r\n\r\n\r\n Particles Count = 0\r\n\r\n\r\n Stack Size = 1024\r\n Data Size = 262144\r\n Debug Check = FALSE\r\n Show Warnings = FALSE\r\n\r\n\r\n ForceLinearFog = FALSE\r\n EnableScreenDump = FALSE\r\n EnableDebugMode = FALSE\r\n VertexCache = 16\r\n ForceVBLRate = 0\r\n BatchingMaxVertexCountToBeBatched = 32\r\n BatchingDisable = FALSE\r\n EnableRefRasterizer = FALSE\r\n DebugModeLineCount = 10\r\n SortTransparentObjects = TRUE\r\n TextureCacheManagement = TRUE\r\n ForceSoftware = FALSE\r\n DisableFilter = FALSE\r\n DisableDithering = FALSE\r\n DisableMipmap = FALSE\r\n DisableSpecular = FALSE\r\n DisablePerspectiveCorrection = FALSE\r\n UsePixelFog = TRUE\r\n DisableAnimationSorting = FALSE\r\n Antialias = 0\r\n TextureVideoFormat = 32 bits ARGB 8888\r\n SpriteVideoFormat = 32 bits ARGB 8888\r\n BitmapSystemCaching = Procedural\r\n DisplayObjectInformation = NA\r\n DX5LightingModel = TRUE\r\n LinkLightMapTransparency = FALSE\r\n\r\n\r\n VerticesPerVB = 16384\r\n DefaultPrecision = 0.000008\r\n\r\n\r\n/* ----------------------------------- */\r\n/* 16 bits declarations */\r\n/* ----------------------------------- */\r\n#ifndef _WIN32\r\n# include \r\n# define PostMessage(hWnd,wMsg,wParam,lParam) while (!PostMessage (hWnd,wMsg,wParam,lParam)) Yield ();\r\n# define GetCurrentThreadId GetCurrentTask\r\n# define Calloc(n,s) (void far *)GlobalAllocPtr(GMEM_SHARE | GMEM_ZEROINIT,n*s)\r\n# define Free(p) GlobalFreePtr (p)\r\n# define THREADID HTASK\r\n/*\r\n# define OF_WRITE WRITE\r\n# define OF_READ READ \r\n */\r\n#endif\r\n\r\n/* ----------------------------------- */\r\n/* 32 bits redeclarations */\r\n/* ----------------------------------- */\r\n#ifdef _WIN32\r\n# define IsTask(x) ( GetThreadPriority(x)!= THREAD_PRIORITY_ERROR_RETURN \\\r\n || GetLastError() != ERROR_INVALID_HANDLE)\r\n \r\n# define _export\r\n# define unlink _unlink\r\n# define Calloc(n,s) calloc (n,s)\r\n# define Free(p) free (p) \r\n# define THREADID\t\t DWORD\r\nLPSTR GetTempDrive(int nDrive);\r\n#endif\r\n\r\n\r\n/* ----------------------------------- */\r\n/* functions defined for compatibility */\r\n/* ----------------------------------- */\r\n\r\nHINSTANCE GetTaskInstance (HWND hParentWindow);\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#define PARAMETER_OP_TYPE_IS_CONNECTED CKGUID(0x2fe947dd,0x783224e9)\r\n\r\n#define PARAM_OP_TYPE_JGET_LIMIT1 CKGUID(0x3678447e,0x30362a74)\r\n#define PARAM_OP_TYPE_JGET_LIMIT2 CKGUID(0xc21ab2,0x465f7f69)\r\n#define PARAM_OP_TYPE_JGET_LIMIT3 CKGUID(0x3ed57b83,0x47ad145f)\r\n\r\n//pMotor : \r\n#define PARAM_OP_TYPE_JMOTOR_SET_TVEL CKGUID(0xa872a4,0x4e8921a4)\r\n#define PARAM_OP_TYPE_JMOTOR_SET_MAXF CKGUID(0x2026057d,0x372684a)\r\n#define PARAM_OP_TYPE_JMOTOR_SET_SPIN_FREE CKGUID(0x4aa2636b,0x734a6d4c)\r\n\r\n#define PARAM_OP_TYPE_JMOTOR_GET_TVEL CKGUID(0x6f91728a,0x29d13cda)\r\n#define PARAM_OP_TYPE_JMOTOR_GET_MAXF CKGUID(0x1e583ea9,0x4305055)\r\n#define PARAM_OP_TYPE_JMOTOR_GET_SPIN_FREE CKGUID(0x50f145b,0x45df2205)\r\n\r\n/************************************************************************/\r\n/* joint structures : */\r\n/************************************************************************/\r\n\r\nvoid ParamOpJMotorSetTVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpJMotorSetFMAX(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpJMotorSetSpinFree(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpJMotorGetTVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpJMotorGetFMAX(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpJMotorGetSpinFree(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\n\r\nvoid ParamOpJMotorSetTVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,0,value,false);\r\n}\r\n\r\nvoid ParamOpJMotorGetTVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJMotorSetFMAX(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,1,value,false);\r\n}\r\n\r\n\r\nvoid ParamOpJMotorGetFMAX(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJMotorSetSpinFree(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tint value = 0;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,2,value,false);\r\n}\r\n\r\nvoid ParamOpJMotorGetSpinFree(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint value = 0;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n#define PARAM_OP_TYPE_JLIMIT_SET_VALUE CKGUID(0x38a829f0,0x47851486)\r\n#define PARAM_OP_TYPE_JLIMIT_SET_RES CKGUID(0x3ce77eb1,0x2e921a87)\r\n#define PARAM_OP_TYPE_JLIMIT_SET_HARD CKGUID(0x111a4a9f,0x54094430)\r\n\r\n#define PARAM_OP_TYPE_JLIMIT_GET_VALUE CKGUID(0xc203321,0x4ca77bd)\r\n#define PARAM_OP_TYPE_JLIMIT_GET_RES CKGUID(0x19f812e7,0x5fb3cfc)\r\n#define PARAM_OP_TYPE_JLIMIT_GET_HARD CKGUID(0x6b1b44cd,0x5efc7f51)\r\n\r\nvoid ParamOpJLimitSetValue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,0,value,false);\r\n}\r\n\r\nvoid ParamOpJLimitGetValue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJLimitSetRes(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,1,value,false);\r\n}\r\n\r\n\r\nvoid ParamOpJLimitGetRes(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJLimitSetHard(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,2,value,false);\r\n}\r\n\r\nvoid ParamOpJLimitGetHard(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n/************************************************************************/\r\n/* spring : */\r\n/************************************************************************/\r\n#define PARAM_OP_TYPE_JSPRING_SET_SPRING CKGUID(0x2e0f1602,0x7f9d30fe)\r\n#define PARAM_OP_TYPE_JSPRING_SET_DAMPER CKGUID(0x7392369,0x168f33a1)\r\n#define PARAM_OP_TYPE_JSPRING_SET_VALUE CKGUID(0x70026320,0x35b41a38)\r\n\r\n#define PARAM_OP_TYPE_JSPRING_GET_SPRING CKGUID(0x3dde73ff,0x550c16ff)\r\n#define PARAM_OP_TYPE_JSPRING_GET_DAMPER CKGUID(0x1f793582,0x11f96df9)\r\n#define PARAM_OP_TYPE_JSPRING_GET_VALUE CKGUID(0x76226303,0x67ba262f)\r\n\r\nvoid ParamOpJSpringSetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,0,value,false);\r\n}\r\n\r\nvoid ParamOpJSpringGetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJSpringSetDamper(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,1,value,false);\r\n}\r\n\r\n\r\nvoid ParamOpJSpringGetDamper(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJSpringSetValue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,2,value,false);\r\n}\r\n\r\nvoid ParamOpJSpringGetVAlue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* spring : */\r\n/************************************************************************/\r\n#define PARAM_OP_TYPE_JSLIMIT_SET_DAMPING CKGUID(0x24e53be6,0x43bf6178)\r\n#define PARAM_OP_TYPE_JSLIMIT_SET_SPRING CKGUID(0x19ea18da,0x4a8f7902)\r\n#define PARAM_OP_TYPE_JSLIMIT_SET_VALUE CKGUID(0x7abb085e,0x464b16b4)\r\n#define PARAM_OP_TYPE_JSLIMIT_SET_RES CKGUID(0x8eb56f2,0x44a40a2)\r\n\r\n#define PARAM_OP_TYPE_JSLIMIT_GET_DAMPING CKGUID(0x74b33ddd,0x6faa11f1)\r\n#define PARAM_OP_TYPE_JSLIMIT_GET_SPRING CKGUID(0x4440614,0x134514de)\r\n#define PARAM_OP_TYPE_JSLIMIT_GET_VALUE CKGUID(0x455a525d,0x77e17e01)\r\n#define PARAM_OP_TYPE_JSLIMIT_GET_RES CKGUID(0x7d1554b4,0x32a72cd3)\r\n\r\n\r\nvoid ParamOpJSLimitSetDamping(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,0,value,false);\r\n}\r\n\r\nvoid ParamOpJSLimitGetDamping(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJSLimitSetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,1,value,false);\r\n}\r\n\r\n\r\nvoid ParamOpJSLimitGetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJSLimitSetValue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,2,value,false);\r\n}\r\n\r\nvoid ParamOpJSLimitGetValue(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid ParamOpJSLimitSetRes(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,3,value,false);\r\n}\r\nvoid ParamOpJSLimitGetRes(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),3,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* spring : */\r\n/************************************************************************/\r\n#define PARAM_OP_TYPE_JDRIVE_SET_DAMPING CKGUID(0x2ef2554b,0x50681945)\r\n#define PARAM_OP_TYPE_JDRIVE_SET_SPRING CKGUID(0x657274d7,0x5c23079c)\r\n#define PARAM_OP_TYPE_JDRIVE_SET_FORCE CKGUID(0x54d75463,0x2e343c56)\r\n#define PARAM_OP_TYPE_JDRIVE_SET_TYPE CKGUID(0x37ff7a9d,0x1f1c3013)\r\n\r\n#define PARAM_OP_TYPE_JDRIVE_GET_DAMPING CKGUID(0x3d4b76b7,0xf059e8)\r\n#define PARAM_OP_TYPE_JDRIVE_GET_SPRING CKGUID(0x4abe6b69,0x56615834)\r\n#define PARAM_OP_TYPE_JDRIVE_GET_FORCE CKGUID(0x4ff912df,0x40d1429)\r\n#define PARAM_OP_TYPE_JDRIVE_GET_TYPE CKGUID(0x54a63237,0x1f8a3347)\r\n\r\nvoid ParamOpJDriveSetDamping(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,0,value,false);\r\n}\r\n\r\nvoid ParamOpJDriveGetDamping(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJDriveSetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,1,value,false);\r\n}\r\n\r\n\r\nvoid ParamOpJDriveGetSpring(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpJDriveSetForce(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat value = 0.0f;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,2,value,false);\r\n}\r\n\r\nvoid ParamOpJDriveGetForce(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tfloat value = 0.0f;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\nvoid ParamOpJDriveSetType(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tif (!GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tint value = 0;\r\n\tp2->GetValue(&value);\r\n\tres->CopyValue(p1->GetRealSource(),false);\r\n\tvtTools::ParameterTools::SetParameterStructureValue(res,3,value,false);\r\n}\r\nvoid ParamOpJDriveGetType(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint value = 0;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),3,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid ParamOpJIsConnected(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\tCK_ID targetID2;\r\n\tp2->GetValue(&targetID2);\r\n\tCK3dEntity *ent2 = static_cast(context->GetObject(targetID2));\r\n\r\n\r\n\tif (!pFactory::Instance()->jointCheckPreRequisites(ent,ent2,JT_Distance))\r\n\t{\r\n\t\tint result = 0;\r\n\t\tres->SetValue(&result);\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\t// the world : \r\n\tpWorld *worldA=GetPMan()->getWorldByBody(ent); \r\n\tpWorld *worldB=GetPMan()->getWorldByBody(ent2); \r\n\tif (!worldA)\r\n\t{\r\n\t\tworldA = worldB;\r\n\t}\r\n\tif (!worldA)\r\n\t{\r\n\t\tint result = 0;\r\n\r\n\t\tres->SetValue(&result);\r\n\t\treturn;\r\n\r\n\t}\r\n\r\n\tpJoint*joint = static_cast(worldA->getJoint(ent,ent2,JT_Any));\r\n\tint result = joint ? 1 : 0;\r\n\tres->SetValue(&result);\r\n\treturn;\r\n\r\n}\r\n\r\n\r\nvoid PhysicManager::_RegisterParameterOperationsJoint()\r\n{\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\r\n\tpm->RegisterOperationType(PARAMETER_OP_TYPE_IS_CONNECTED, \"connected\");\r\n\tpm->RegisterOperationFunction(PARAMETER_OP_TYPE_IS_CONNECTED,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpJIsConnected);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Drive */\r\n\t/************************************************************************/\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_SET_DAMPING, \"jDsDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_SET_DAMPING,VTS_JOINT_DRIVE,VTS_JOINT_DRIVE,CKPGUID_FLOAT,ParamOpJDriveSetDamping);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_GET_DAMPING, \"jDgDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_GET_DAMPING,CKPGUID_FLOAT,VTS_JOINT_DRIVE,CKPGUID_NONE,ParamOpJDriveGetDamping);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_SET_SPRING, \"jDsSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_SET_SPRING,VTS_JOINT_DRIVE,VTS_JOINT_DRIVE,CKPGUID_FLOAT,ParamOpJDriveSetSpring);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_GET_SPRING, \"jDgSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_GET_SPRING,CKPGUID_FLOAT,VTS_JOINT_DRIVE,CKPGUID_NONE,ParamOpJDriveGetSpring);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_SET_FORCE, \"jDsForce\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_SET_FORCE,VTS_JOINT_DRIVE,VTS_JOINT_DRIVE,CKPGUID_FLOAT,ParamOpJDriveSetForce);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_GET_FORCE, \"jDgForce\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_GET_FORCE,CKPGUID_FLOAT,VTS_JOINT_DRIVE,CKPGUID_NONE,ParamOpJDriveGetForce);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_SET_TYPE, \"jDsType\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_SET_TYPE,VTS_JOINT_DRIVE,VTS_JOINT_DRIVE,VTE_PHYSIC_JDRIVE_TYPE,ParamOpJDriveSetType);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JDRIVE_GET_TYPE, \"jDgType\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JDRIVE_GET_TYPE,VTE_PHYSIC_JDRIVE_TYPE,VTS_JOINT_DRIVE,CKPGUID_NONE,ParamOpJDriveGetType);\r\n\r\n\t/************************************************************************/\r\n\t/* Soft Limit */\r\n\t/************************************************************************/\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_SET_DAMPING, \"jSLsDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_SET_DAMPING,VTS_JOINT_SLIMIT,VTS_JOINT_SLIMIT,CKPGUID_FLOAT,ParamOpJSLimitSetDamping);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_GET_DAMPING, \"jSLgDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_GET_DAMPING,CKPGUID_FLOAT,VTS_JOINT_SLIMIT,CKPGUID_NONE,ParamOpJSLimitGetDamping);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_SET_SPRING, \"jSLsSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_SET_SPRING,VTS_JOINT_SLIMIT,VTS_JOINT_SLIMIT,CKPGUID_FLOAT,ParamOpJSLimitSetSpring);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_GET_SPRING, \"jSLgSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_GET_SPRING,CKPGUID_FLOAT,VTS_JOINT_SLIMIT,CKPGUID_NONE,ParamOpJSLimitGetSpring);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_SET_VALUE, \"jSLsValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_SET_VALUE,VTS_JOINT_SLIMIT,VTS_JOINT_SLIMIT,CKPGUID_FLOAT,ParamOpJSLimitSetValue);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_GET_VALUE, \"jSLgValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_GET_VALUE,CKPGUID_FLOAT,VTS_JOINT_SLIMIT,CKPGUID_NONE,ParamOpJSLimitGetValue);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_SET_RES, \"jSLsRes\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_SET_RES,VTS_JOINT_SLIMIT,VTS_JOINT_SLIMIT,CKPGUID_FLOAT,ParamOpJSLimitSetRes);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSLIMIT_GET_RES, \"jSLgRes\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSLIMIT_GET_RES,CKPGUID_FLOAT,VTS_JOINT_SLIMIT,CKPGUID_NONE,ParamOpJSLimitGetRes);\r\n\r\n\t/************************************************************************/\r\n\t/* spring : */\r\n\t/************************************************************************/\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_SET_SPRING, \"jSsSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_SET_SPRING,VTS_JOINT_SPRING,VTS_JOINT_SPRING,CKPGUID_FLOAT,ParamOpJSpringSetSpring);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_GET_SPRING, \"jSgSpring\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_GET_SPRING,CKPGUID_FLOAT,VTS_JOINT_SPRING,CKPGUID_NONE,ParamOpJSpringGetSpring);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_SET_DAMPER, \"jSsDamper\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_SET_DAMPER,VTS_JOINT_SPRING,VTS_JOINT_SPRING,CKPGUID_FLOAT,ParamOpJSpringSetDamper);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_GET_DAMPER, \"jSgDamper\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_GET_DAMPER,CKPGUID_FLOAT,VTS_JOINT_SPRING,CKPGUID_NONE,ParamOpJSpringGetDamper);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_SET_VALUE, \"jSsValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_SET_VALUE,VTS_JOINT_SPRING,VTS_JOINT_SPRING,CKPGUID_FLOAT,ParamOpJSpringSetValue);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JSPRING_GET_VALUE, \"jSgValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JSPRING_GET_VALUE,CKPGUID_FLOAT,VTS_JOINT_SPRING,CKPGUID_NONE,ParamOpJSpringGetVAlue);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* pJLimit Structure Access : */\r\n\t/************************************************************************/\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_SET_VALUE, \"jLsValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_SET_VALUE,VTS_JLIMIT,VTS_JLIMIT,CKPGUID_FLOAT,ParamOpJLimitSetValue);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_GET_VALUE, \"jLgValue\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_GET_VALUE,CKPGUID_FLOAT,VTS_JLIMIT,CKPGUID_NONE,ParamOpJLimitGetValue);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_SET_RES, \"jLsRestitution\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_SET_RES,VTS_JLIMIT,VTS_JLIMIT,CKPGUID_FLOAT,ParamOpJLimitSetRes);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_GET_RES, \"jLgRestitution\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_GET_RES,CKPGUID_FLOAT,VTS_JLIMIT,CKPGUID_NONE,ParamOpJLimitGetRes);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_SET_HARD, \"jLsHardness\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_SET_HARD,VTS_JLIMIT,VTS_JLIMIT,CKPGUID_FLOAT,ParamOpJLimitSetHard);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JLIMIT_GET_RES, \"jLgHardness\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JLIMIT_GET_HARD,CKPGUID_FLOAT,VTS_JLIMIT,CKPGUID_NONE,ParamOpJLimitGetHard);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* pMotor Structure Acess : */\r\n\t/************************************************************************/\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_SET_TVEL, \"jMsVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_SET_TVEL,VTS_JOINT_MOTOR,VTS_JOINT_MOTOR,CKPGUID_FLOAT,ParamOpJMotorSetTVel);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_GET_TVEL, \"jMgVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_GET_TVEL,CKPGUID_FLOAT,VTS_JOINT_MOTOR,CKPGUID_NONE,ParamOpJMotorGetTVel);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_SET_MAXF, \"jMsFMax\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_SET_MAXF,VTS_JOINT_MOTOR,VTS_JOINT_MOTOR,CKPGUID_FLOAT,ParamOpJMotorSetFMAX);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_GET_MAXF, \"jMgFMax\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_GET_MAXF,CKPGUID_FLOAT,VTS_JOINT_MOTOR,CKPGUID_NONE,ParamOpJMotorGetFMAX);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_SET_SPIN_FREE, \"jMsSpinFree\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_SET_SPIN_FREE,VTS_JOINT_MOTOR,VTS_JOINT_MOTOR,CKPGUID_BOOL,ParamOpJMotorSetSpinFree);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_JMOTOR_GET_SPIN_FREE, \"jMgSpingFree\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_JMOTOR_GET_SPIN_FREE,CKPGUID_BOOL,VTS_JOINT_MOTOR,CKPGUID_NONE,ParamOpJMotorGetSpinFree);\r\n\r\n\r\n\r\n\r\n\r\n\r\n}\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARToolKitPlusDetect\r\n// -------------------\r\n//\r\n// Description:\r\n// Buildingblock that detects pattern (single marker) in the given video\r\n// image. If you want to use more than one pattern, that it is wise to use\r\n// the ARToolKitPlusDetect-BB once and for each pattern the\r\n// ARTPlusPatternTransformation-BB instead of using the\r\n// ARTPlusDetectionAndTransformation-BB for each pattern. The cause is, that\r\n// the ARTPlusDetectionAndTransformation-BB will run a complete detection\r\n// on the video image eache time you call it.\r\n//\r\n// Input Parameter:\r\n// IN_VIDEO_TEXTURE\t\t: The image, in with ARToolKitPlus\r\n//\t\t\t\t\t\t perform the detection\r\n// IN_USE_BCH\t\t\t: Flag which indicates to use BCH-pattern\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_THIN_BORDER\t\t: Flag which indicates to use pattern with\r\n//\t\t\t\t\t\t a thin boarder)\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_AUTO_THRESHOLD\t: Flag which indicates to use the auto-threshold\r\n//\t\t\t\t\t\t function from the ARToolKitPlus\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_THRESHOLD\t\t\t: The threshold value used, if IN_AUTO_THRESHOLD\r\n//\t\t\t\t\t\t is set to false\r\n//\r\n// Output Parameter:\r\n// OUT_ERROR_STRING\t\t: String which describe the error, if one occurs. If\r\n//\t\t\t\t\t\t there was no error the string will contain the word\r\n//\t\t\t\t\t\t \"Success\" (without the marks)\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n// Input Parameter\r\n#define IN_VIDEO_TEXTURE\t0\r\n#define IN_USE_BCH\t\t\t1\r\n#define IN_THIN_BORDER\t\t2\r\n#define IN_AUTO_THRESHOLD\t3\r\n#define IN_THRESHOLD\t\t4\r\n\r\n// Output Parameter\r\n#define OUT_ERROR_STRING 0\r\n\r\n// Output Signals\r\n#define OUTPUT_OK 0\r\n#define OUTPUT_ERROR 1\r\n\r\n#include \"CKAll.h\"\r\n#include \r\n#include \r\n\r\nCKObjectDeclaration\t*FillBehaviorARToolKitPlusDetectDecl();\r\nCKERROR CreateARToolKitPlusDetectProto(CKBehaviorPrototype **);\r\n\r\nint ARToolKitPlusDetect(const CKBehaviorContext& BehContext);\r\nint ARToolKitPlusDetectCallBack(const CKBehaviorContext& BehContext);\r\n\r\nextern bool ARTPlusInitialized;\r\n\r\nARToolKitPlus::ARMarkerInfo* markerInfo = NULL;\r\nint numMarkers = 0;\r\n\r\nextern ARToolKitPlus::TrackerSingleMarker *tracker;\r\n\r\nCKObjectDeclaration\t*FillBehaviorARToolKitPlusDetectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Single Marker Detection\");\t\r\n\t\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateARToolKitPlusDetectProto);\r\n\tod->SetDescription(\"Single Marker Detection\");\r\n\tod->SetCategory(\"ARToolKitPlus\");\r\n\tod->SetGuid(CKGUID(0x1ff46552,0x6c31e58));\r\n\tod->SetAuthorGuid(CKGUID(0x56495254,0x4f4f4c53));\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateARToolKitPlusDetectProto(CKBehaviorPrototype** pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Single Marker Detection\");\r\n\tif (!proto) {\r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\t}\r\n\r\n//--- Inputs declaration\n\tproto->DeclareInput(\"In\");\n\r\n//--- Outputs declaration\n\tproto->DeclareOutput(\"Out\");\n\tproto->DeclareOutput(\"Error\");\n\r\n//--- Input Parameters declaration\n\tproto->DeclareInParameter(\"VideoImage\", CKPGUID_TEXTURE);\n\tproto->DeclareInParameter(\"Use BCH Pattern\", CKPGUID_BOOL, \"TRUE\");\n\tproto->DeclareInParameter(\"Use Thin Border\", CKPGUID_BOOL, \"TRUE\");\n\tproto->DeclareInParameter(\"Enable Auto Threshold\", CKPGUID_BOOL, \"FALSE\");\n\tproto->DeclareInParameter(\"Threshold\", CKPGUID_INT, \"150\");\n\r\n//--- Output Parameters declaration\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_STRING, \"Success\");\n\r\n//----\tLocal Parameters Declaration\r\n\r\n//----\tSettings Declaration\r\n\r\n\tproto->SetBehaviorCallbackFct(ARToolKitPlusDetectCallBack, CKCB_BEHAVIORATTACH|CKCB_BEHAVIORDETACH|CKCB_BEHAVIORDELETE|CKCB_BEHAVIOREDITED|CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORPRESAVE|CKCB_BEHAVIORPOSTSAVE|CKCB_BEHAVIORRESUME|CKCB_BEHAVIORPAUSE|CKCB_BEHAVIORRESET|CKCB_BEHAVIORRESET|CKCB_BEHAVIORDEACTIVATESCRIPT|CKCB_BEHAVIORACTIVATESCRIPT|CKCB_BEHAVIORREADSTATE, NULL);\r\n\tproto->SetFunction(ARToolKitPlusDetect);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint ARToolKitPlusDetect(const CKBehaviorContext& BehContext)\r\n{\r\n\tCKBehavior* beh = BehContext.Behavior;\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tif(ARTPlusInitialized == true)\r\n\t{\r\n\t\tCKTexture* texture = NULL;\r\n\t\tCKBYTE *pixel = NULL;\r\n\t\tCKBOOL autoThreshold = FALSE;\r\n\t\tint threshold = 150;\r\n\t\tCKBOOL useBCH = TRUE;\r\n\t\tCKBOOL thinBorder = TRUE;\r\n\r\n\t\t// Texture (Wichtig, Object holen, nicht Value oder Ptr!!!)\r\n\t\ttexture = CKTexture::Cast(beh->GetInputParameterObject(IN_VIDEO_TEXTURE));\r\n\r\n\t\tif(texture == NULL)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: No Texture Present\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\tpixel = texture->LockSurfacePtr();\r\n\t\tif(pixel == NULL)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: Can't lock texture surface\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t}\r\n\r\n\t\t// Auto Threshold holen\r\n\t\tbeh->GetInputParameterValue(IN_AUTO_THRESHOLD, &autoThreshold);\r\n\t\t// set Auto Thresholding\r\n\t\ttracker->activateAutoThreshold(autoThreshold?true:false);\r\n\r\n\t\t// Threshold holen\r\n\t\tbeh->GetInputParameterValue(IN_THRESHOLD, &threshold);\r\n\t\t// set a threshold. alternatively we could also activate automatic thresholding\r\n\t\ttracker->setThreshold(threshold);\r\n\r\n\t\t// Pattern Typ holen\r\n\t\tbeh->GetInputParameterValue(IN_USE_BCH, &useBCH);\r\n\r\n\t\t// Thin Border holen\r\n\t\tbeh->GetInputParameterValue(IN_THIN_BORDER, &thinBorder);\r\n\r\n\t\tif(useBCH)\r\n\t\t{\r\n\t\t\t// the marker in the BCH test image has a thin border...\r\n\t\t\ttracker->setBorderWidth(0.125f);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttracker->setBorderWidth(thinBorder ? 0.125f : 0.250f);\r\n\t\t}\r\n\r\n\t\t// switch to simple ID based markers\r\n\t\t// use the tool in tools/IdPatGen to generate markers\r\n\t\ttracker->setMarkerMode(useBCH ? ARToolKitPlus::MARKER_ID_BCH : ARToolKitPlus::MARKER_ID_SIMPLE);\r\n\r\n\t\t// here we go, just one call to find the camera pose\r\n\t\tnumMarkers = 0;\r\n\t\tmarkerInfo = NULL;\r\n\t\ttracker->calc(pixel, -1, true, &markerInfo, &numMarkers);\r\n\r\n\t\tif(texture->Restore() != TRUE)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: Can't restore texture surface\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t}\r\n\t}\r\n\tbeh->ActivateOutput(OUTPUT_OK);\r\n\r\n\tchar string[] = \"Success\";\n\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nint ARToolKitPlusDetectCallBack(const CKBehaviorContext& BehContext)\n{\n\tswitch (BehContext.CallbackMessage)\n\t{\n\t\tcase CKM_BEHAVIORATTACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDETACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDELETE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIOREDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORLOAD:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPRESAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPOSTSAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESUME:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPAUSE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESET:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORNEWSCENE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORREADSTATE:\n\t\t\tbreak;\n\t}\n\treturn CKBR_OK;\n}\r\n#pragma once\r\n\r\n#include \"stdafx.h\"\r\n\r\nclass ExeInThread\r\n{\r\n public:\r\n static CKObjectDeclaration * FillBehaviour( void );\t\r\n static int CallBack( const CKBehaviorContext& behaviorContext );\r\n static int BehaviourFunction( const CKBehaviorContext& behaviorContext );\r\n static CKERROR CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr );\r\n\r\n\tenum ThreadStatus {\r\n\t\tIdle = 0, Requested = 2, Active = 3};\r\n\r\n\r\n\tfriend unsigned int BlockingThreadFunction(void *arg);\r\n\r\n\ttypedef struct ThreadInfo\r\n\t{\r\n\t\tCKBehavior*\t\t\ttargetBeh;\r\n\t\tint\t\t\t\t\ttargetInputToActivate;\r\n\t} AsyncThreadInfo;\r\n};\r\n/*************************************************************************/\r\n/*\tFile : XLoader.h\t\t\t\t \t\t\t\t \t\t\t\t\t */\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\t\r\n/*\tDirectX .X files loader\t\t\t\t\t\t\t\t\t\t\t\t */\t\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\t\r\n/*\tVirtools SDK \t\t\t\t\t\t\t\t\t\t\t\t\t\t */\t \r\n/*\tCopyright (c) Virtools 2000, All Rights Reserved.\t\t\t\t\t */\t\r\n/*************************************************************************/\r\n\r\n#ifndef _XLOADER_H\r\n#define _XLOADER_H\r\n\r\n//#include \"Windows.h\"\r\n#include \"stdio.h\"\r\n#include \"DxFile.h\"\r\n#include \"rmxfguid.h\"\r\n#include \"rmxftmpl.h\"\r\n#include \"Ge2Virtools.h\"\r\n#include \"ptypes.h\"\r\n\r\n\r\nXString GetFileObjectName(LPDIRECTXFILEOBJECT obj);\r\n\r\n\r\n#define SAFERELEASE(x) { if (x) x->Release(); x = NULL; }\r\n\r\n/**************************************************\r\n+ Overload of a model reade\r\n+ \r\n***************************************************/\t\r\nclass CKXReader: public CKModelReader {\r\npublic:\t\r\n\tvoid Release() {delete this; };\r\n\t\r\n// Reader Info\r\n\tvirtual CKPluginInfo* GetReaderInfo();\r\n\r\n// No specific Options\r\n\tvirtual int GetOptionsCount() { return 0; }\r\n\tvirtual CKSTRING GetOptionDescription(int i) { return NULL; }\r\n\t\r\n// This reader can only load .X files\r\n\tvirtual CK_DATAREADER_FLAGS GetFlags() {return (CK_DATAREADER_FLAGS)CK_DATAREADER_FILELOAD;}\r\n\r\n// Load Method\r\n\tvirtual CKERROR Load(CKContext* context,CKSTRING FileName,CKObjectArray *liste,CKDWORD LoadFlags,CKCharacter *carac=NULL);\r\n\tBOOL LoadFromFileC(CKContext *ctx, XString filename, CKBOOL hidden, CKDWORD loadflags, CKObjectArray* targetArray, XString password);\r\n\r\n\r\n\tCKXReader() {\r\n\r\n\t\tm_Context = NULL;\r\n\t\tm_VirtoolsExport = NULL;\r\n\t\t\r\n\t\tm_Unnamed\t\t = 0;\r\n\t}\r\n\t~CKXReader() {\r\n\t\tCleanUp();\r\n\t}\r\n\r\nprotected:\r\n\tvoid CleanUp() {\r\n\t\r\n\t\tdelete m_VirtoolsExport;\r\n\t\tm_VirtoolsExport = NULL;\r\n\t}\r\n//-- High level \r\n\t\r\n\r\n\t//-- For unnamed objects return a generic string \"Unnamed_XX\" \r\n\tXString GetUnnamed() { XString Temp = \"Unnamed_\"; Temp << m_Unnamed++; return Temp; }\r\n\r\npublic: \r\n\tCKContext*\t\t\t\t\tm_Context;\r\n\tCK_OBJECTCREATION_OPTIONS\tm_CreationOptions;\r\n\tCKCharacter*\t\t\t\tm_Character;\r\n\tDWORD\t\t\t\t\t\tm_LoadFlags;\r\n\tCK_CLASSID\t\t\t\t\tm_3dObjectsClass;\r\n\tXString\t\t\t\t\t\tm_FileName;\r\n\r\n\tExport2Virtools*\t\t\tm_VirtoolsExport;\t\r\n\t\r\n\tint\t\t\t\t\t\t\tm_Unnamed;\r\n\tfloat\t\t\t\t\t\tm_AnimationLength;\r\n\r\n\r\n};\r\n\r\n\r\n#endif\r\n/********************************************************************\r\n\tcreated:\t2007/11/28\r\n\tcreated:\t28:11:2007 16:25\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\\CustomPlayerConfigurationDialog.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\r\n\tfile base:\tCustomPlayerConfigurationDialog\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"xSplash.h\"\r\n#include \"SplashScreenEx.h\"\r\n\r\n\r\n//************************************\r\n// Method: HideSplash\r\n// FullName: CCustomPlayer::HideSplash\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nvoid CCustomPlayer::HideSplash()\r\n{\r\n\tif (xSplash::GetSplash())\r\n\t{\r\n\t\txSplash::HideSplash();\r\n\t}\r\n}\r\n//************************************\r\n// Method: SetSplashText\r\n// FullName: CCustomPlayer::SetSplashText\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: const char* text\r\n//************************************\r\nvoid CCustomPlayer::SetSplashText(const char* text)\r\n{\r\n\tif (xSplash::GetSplash())\r\n\t{\r\n\t\txSplash::SetText(text);\r\n\t}\r\n\t\r\n}\r\n\r\n//************************************\r\n// Method: ShowSplash\r\n// FullName: CCustomPlayer::ShowSplash\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nvoid CCustomPlayer::ShowSplash()\r\n{\r\n\tCWnd *main = CWnd::FromHandle(m_MainWindow);\r\n\r\n\txSplash::CreateSplashEx(main,40,10);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we modify our splash : \r\n\tCSplashScreenEx *splash = xSplash::GetSplash();\r\n\t/*\r\n\t// we set the loading perc to the right bottom corner : \r\n\tsplash->SetTextFormat(DT_SINGLELINE | DT_RIGHT | DT_BOTTOM);\r\n\t\r\n\t//we set the splash file and the transparency key : \r\n\tsplash->SetBitmap(\"splash.bmp\",255,0,255);\r\n\r\n\t//font : \r\n\tsplash->SetTextFont(\"MicrogrammaDBolExt\",100,CSS_TEXT_NORMAL);*/\r\n\r\n\tif (xSplash::GetSplash())\r\n\t{\r\n\t\txSplash::ShowSplash();\r\n\t}\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\npJointRevolute::pJointRevolute(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Revolute)\r\n{\r\n\r\n}\r\nbool pJointRevolute::setHighLimit(pJointLimit limit)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitDesc sLimit;\tsLimit.value = limit.value;sLimit.restitution = limit.restitution;sLimit.hardness = limit.hardness;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.limit.high= sLimit;\r\n\r\n\tif (sLimit.hardness!=0.0f || sLimit.restitution!=0.0f || sLimit.value !=0.0f )\r\n\t{\r\n\t\tdescr.flags |= NX_RJF_LIMIT_ENABLED;\r\n\t}else\r\n\t\tdescr.flags &=~NX_RJF_LIMIT_ENABLED;\r\n\r\n\tint v = descr.isValid();\r\n\r\n\r\n\tjoint->loadFromDesc(descr);\r\n\treturn true;\r\n}\r\nbool pJointRevolute::setLowLimit(pJointLimit limit)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitDesc sLimit;\tsLimit.value = limit.value;sLimit.restitution = limit.restitution;sLimit.hardness = limit.hardness;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.limit.low= sLimit;\r\n\tif (sLimit.hardness!=0.0f || sLimit.restitution!=0.0f || sLimit.value !=0.0f )\r\n\t{\r\n\t\tdescr.flags |= NX_RJF_LIMIT_ENABLED;\r\n\t}else\r\n\t\tdescr.flags &=~NX_RJF_LIMIT_ENABLED;\r\n\r\n\tbool ret = descr.isValid();\r\n\tjoint->loadFromDesc(descr);\r\n\treturn ret;\r\n}\r\n\r\npSpring pJointRevolute::getSpring()\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\r\n\tjoint->saveToDesc(descr);\r\n\treturn pSpring (descr.spring.damper,descr.spring.spring,descr.spring.targetValue);\r\n\r\n}\r\n\r\nbool pJointRevolute::setSpring(pSpring spring)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\tjoint->saveToDesc(descr);\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.spring= sLimit;\r\n\r\n\tif (spring.damper!=0.0f || !spring.spring!=0.0f || !spring.targetValue !=0.0f )\r\n\t{\r\n\t\tdescr.flags |= NX_RJF_SPRING_ENABLED;\r\n\t}else\r\n\t\tdescr.flags &=~NX_RJF_SPRING_ENABLED;\r\n\r\n\r\n\tjoint->loadFromDesc(descr);\r\n\treturn false;\r\n}\r\n\r\n\r\n\r\npMotor pJointRevolute::getMotor()\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\tjoint->saveToDesc(descr);\r\n\t\r\n\tNxMotorDesc mDescr = descr.motor;\r\n\tpMotor result;\r\n\tresult.freeSpin = mDescr.freeSpin;\r\n\tresult.targetVelocity= mDescr.velTarget;\r\n\tresult.maximumForce = mDescr.maxForce;\r\n\treturn result;\r\n}\r\n\r\nbool pJointRevolute::setMotor(pMotor motor)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxMotorDesc mDescr = descr.motor;\r\n\r\n\tif (motor.maximumForce!=0.0f && motor.targetVelocity !=0.0f )\r\n\t{\r\n\t\tmDescr.freeSpin = motor.freeSpin;\r\n\t\tmDescr.velTarget= motor.targetVelocity;\r\n\t\tmDescr.maxForce= motor.maximumForce;\r\n\t\tdescr.flags |= NX_RJF_MOTOR_ENABLED;\r\n\t\tjoint->setMotor(mDescr);\r\n\t\tdescr.motor = mDescr;\r\n\t}else{\r\n\t\tdescr.flags &=~NX_RJF_MOTOR_ENABLED;\r\n\t}\r\n\tjoint->loadFromDesc(descr);\r\n\r\n\treturn descr.isValid();\r\n}\r\nvoid pJointRevolute::enableCollision(bool collision)\r\n{\r\n\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}\r\n\r\n\r\nvoid pJointRevolute::setGlobalAnchor(const VxVector& anchor)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\tjoint->saveToDesc(descr);\r\n\t//descr.setGlobalAnchor(pMath::getFrom(anchor));\r\n\t//descr.localAnchor[0] = NxVec3(0,-40,0);\r\n\t//\tjoint->loadFromDesc(descr);\r\n\r\n\t\r\n\tjoint->setGlobalAnchor(pMath::getFrom(anchor));\r\n\r\n}\r\n\r\nvoid pJointRevolute::setGlobalAxis(const VxVector& axis)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\t//joint->saveToDesc(descr);\r\n\t//descr.setGlobalAxis(pMath::getFrom(axis));\r\n\t//joint->loadFromDesc(descr);\r\n\r\n\tjoint->setGlobalAxis(pMath::getFrom(axis));\r\n}\r\n\r\n\r\npJointLimit pJointRevolute::getHighLimit()\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\r\n\tjoint->saveToDesc(descr);\r\n\treturn pJointLimit (descr.limit.high.hardness,descr.limit.high.restitution,descr.limit.high.value);\r\n\r\n}\r\n\r\npJointLimit pJointRevolute::getLowLimit()\r\n{\r\n\tNxRevoluteJointDesc descr;\t\r\n\tNxRevoluteJoint*joint = static_cast(getJoint());\r\n\r\n\tjoint->saveToDesc(descr);\r\n\treturn pJointLimit (descr.limit.low.hardness,descr.limit.low.restitution,descr.limit.low.value);\r\n\r\n}\r\nvoid pJointRevolute::setProjectionMode(ProjectionMode mode)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\tNxRevoluteJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionMode = (NxJointProjectionMode)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointRevolute::setProjectionDistance(float distance)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\tNxRevoluteJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionDistance= distance;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointRevolute::setProjectionAngle(float angle)\r\n{\r\n\tNxRevoluteJointDesc descr;\t\tNxRevoluteJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionAngle= angle;\r\n\tint s = descr.isValid();\r\n\tjoint->loadFromDesc(descr);\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBAddLocalForceAtLocalPosDecl();\r\nCKERROR CreatePBAddLocalForceAtLocalPosProto(CKBehaviorPrototype **pproto);\r\nint PBAddLocalForceAtLocalPos(const CKBehaviorContext& behcontext);\r\nCKERROR PBAddLocalForceAtLocalPosCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbbI_Force,\r\n\tbbI_Pos,\r\n\tbbI_Mode\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPBAddLocalForceAtLocalPosDecl\r\n// FullName: FillBehaviorPBAddLocalForceAtLocalPosDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBAddLocalForceAtLocalPosDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBAddLocalForceAtLocalPos\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Applies a force (or impulse) defined in the bodies local coordinate frame, acting at a particular point in local coordinates, to the actor.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x27b72bda,0x4db179ce));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBAddLocalForceAtLocalPosProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBAddLocalForceAtLocalPosProto\r\n// FullName: CreatePBAddLocalForceAtLocalPosProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBAddLocalForceAtLocalPosProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBAddLocalForceAtLocalPos\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PBAddLocalForceAtLocalPos \r\n\r\n\tPBAddLocalForceAtLocalPos is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tApplies a force (or impulse) defined in the actor local coordinate frame, acting at a \r\n\tparticular point in local coordinates, to the actor.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBAddLocalForceAtLocalPos.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tLocal Force:Force/impulse to add, defined in the local frame.\r\n\t
\r\n\tLocal Position:Position in the local frame to add the force at.\r\n\t
\r\n\tForce Mode: The way how the force is applied.See #ForceMode\r\n\t
\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t\r\n\t

Note


\r\n\tNote that if the force does not act along the center of mass of the actor, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\t
\r\n\t
\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pRigidBody::addLocalForceAtLocalPos().
\r\n\t*/\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Local Force\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Local Position\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Force Mode\",VTE_BODY_FORCE_MODE,0);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBAddLocalForceAtLocalPos);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddLocalForceAtLocalPos\r\n// FullName: PBAddLocalForceAtLocalPos\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBAddLocalForceAtLocalPos(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\t\r\n\t\t//the vector : \r\n\t\tVxVector force = GetInputParameterValue(beh,bbI_Force);\r\n\t\tVxVector pos = GetInputParameterValue(beh,bbI_Pos);\r\n\t\tint fMode = GetInputParameterValue(beh,bbI_Mode);\r\n\r\n\t\t// body exists already ? clean and delete it : \r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(result)\r\n\t\t{\r\n\t\t\tresult->addLocalForceAtLocalPos(force,pos,(ForceMode)fMode);\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddLocalForceAtLocalPosCB\r\n// FullName: PBAddLocalForceAtLocalPosCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBAddLocalForceAtLocalPosCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#ifndef __P_CALLBACK_OBJECT_H__\r\n#define __P_CALLBACK_OBJECT_H__\r\n\r\n#include \r\n#include \"vtInterfaceEnumeration.h\"\r\n\r\nclass pWheelContactModify;\r\nclass pCollisionsEntry;\r\nclass pTriggerEntry;\r\nclass pContactModifyData;\r\nclass pWheelContactModifyData;\r\n\r\nclass MODULE_API pCallbackObject\r\n{\r\n\tpublic:\r\n\r\n\t\tpCallbackObject() \r\n\t\t{\r\n\t\t\tpreScript = -1;\r\n\t\t\tpostScript = -1;\r\n\t\t\tcallMask = 0;\r\n\t\t\toverrideMask = -1;\r\n\t\t\tcontactScript = -1;\r\n\t\t\trayCastScript = -1;\r\n\t\t\twheelContactScript = -1;\r\n\t\t\ttriggerScript = -1;\r\n\r\n\t\t\ttriggerEventMask = 0 ; \r\n\t\t\tcollisionEventMask = 0 ; \r\n\t\t}\r\n\r\n\t\tint contactScript;\r\n\t\tint rayCastScript;\r\n\t\tint wheelContactScript;\r\n\t\tint triggerScript;\r\n\t\tint jointBreakScript;\r\n\r\n\t\tint collisionEventMask;\r\n\t\tint contactModificationScript;\r\n\t\t\r\n\t\tint& getCollisionEventMask() { return collisionEventMask; }\r\n\t\tvoid setCollisionEventMask(int val) { collisionEventMask = val; }\r\n\r\n\t\tint triggerEventMask;\r\n\t\t\r\n\t\tint& getTriggerEventMask() { return triggerEventMask; }\r\n\t\tvoid setTriggerEventMask(int val) { triggerEventMask = val; }\r\n\r\n\r\n//\t\tvirtual void advanceTime(float lastDeltaMS);\r\n\r\n\t\t\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// generics \r\n\t\t//\r\n\t\tint overrideMask;\r\n\t\tint& getOverrideMask() { return overrideMask; }\r\n\t\tvoid setOverrideMask(int val) { overrideMask = val; }\r\n\r\n\t\txBitSet callMask;\r\n\t\txBitSet& getCallMask() { return callMask; }\r\n\t\tvoid setCallMask(int val) { callMask = val; }\r\n\r\n\t\tint preScript;\r\n\t\tint& getPreScript() { return preScript; }\r\n\t\tvoid setPreScript(int val) { preScript = val; }\r\n\r\n\t\t\r\n\t\tint postScript;\r\n\t\tint& getPostScript() { return postScript; }\r\n\t\tvoid setPostScript(int val) { postScript = val; }\r\n\r\n\t\tvirtual void processPostScript(){};\r\n\t\tvirtual void processPreScript(){};\r\n\t\t\r\n\t\tvirtual int onPreProcess(){ return -1;};\r\n\t\tvirtual int onPostProcess(){return -1;};\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// generic contact call\r\n\t\t//\r\n\t\tint getContactScript() const { return contactScript; }\r\n\t\tvirtual void setContactScript(int behaviorID,int eventMask)\r\n\t\t{ \r\n\t\t\tcontactScript = behaviorID; \r\n\t\t\tcollisionEventMask = eventMask;\r\n\t\t\tsetFlag(getCallMask(),CB_OnContactNotify,behaviorID);\r\n\t\t}\r\n\t\tvirtual int onContact(pCollisionsEntry *report){ return -1;};\r\n\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// raycast, unused ! \r\n\t\t//\r\n\t\tint getRayCastScript() const { return rayCastScript; }\r\n\t\tvirtual void setRayCastScript(int val) \r\n\t\t{ \r\n\t\t\trayCastScript = val; \r\n\t\t\tsetFlag(getCallMask(),CB_OnRayCastHit,val);\r\n\t\t}\r\n\t\tvirtual bool onRayCastHit(NxRaycastHit *report){ return false;};\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// trigger\r\n\t\t//\r\n\t\tint getTriggerScript() const { return triggerScript; }\r\n\t\tvirtual void setTriggerScript(int behaviorID,int eventMask,CK3dEntity *shapeReference = NULL) \r\n\t\t{ \r\n\t\t\ttriggerScript = behaviorID; \r\n\t\t\ttriggerEventMask = eventMask;\r\n\t\t\tsetFlag(getCallMask(),CB_OnTrigger,behaviorID);\r\n\r\n\t\t}\r\n\t\tvirtual int onTrigger(pTriggerEntry *report){ return -1;};\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// trigger\r\n\t\t//\r\n\t\tint getJointBreakScript() const { return jointBreakScript; }\r\n\t\tvirtual void setJointBreakScript(int behaviorID,CK3dEntity *shapeReference = NULL) \r\n\t\t{ \r\n\t\t\tjointBreakScript = behaviorID; \r\n\t\t\tsetFlag(getCallMask(),CB_OnJointBreak,behaviorID);\r\n\t\t}\r\n\t\tvirtual int onJointBreak(pBrokenJointEntry *entry){ return -1;};\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// wheel related\r\n\t\t//\r\n\t\tint getWheelContactScript() const { return wheelContactScript; }\r\n\t\tvirtual void setWheelContactScript(int val) { wheelContactScript = val; }\r\n\r\n\t\tvirtual bool onWheelContact(CK3dEntity* wheelShapeReference, VxVector& contactPoint, VxVector& contactNormal, float& contactPosition, float& normalForce, CK3dEntity* otherShapeReference, int& otherShapeMaterialIndex){return true;}\r\n\t\tvirtual bool onWheelContactModify(int& changeFlags,pWheelContactModifyData* contact){ return -1;}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// contact modification\r\n\t\t//\r\n\t\tint getContactModificationScript() const { return contactModificationScript; }\r\n\t\tvirtual void setContactModificationScript(int val) \r\n\t\t{ \r\n\t\t\tcontactModificationScript = val; \r\n\t\t\tsetFlag(getCallMask(),CB_OnContactModify,val);\r\n\t\t}\r\n\t\t\r\n\t\tvirtual bool onContactConstraint(int& changeFlags,CK3dEntity *sourceObject,CK3dEntity *otherObject,pContactModifyData *data){ changeFlags = CMM_None; return true;\t\t};\r\n\r\n\r\n\t\tint processOptions;\r\n\t\tvirtual int& getProcessOptions() { return processOptions; }\r\n\t\tvirtual void setProcessOptions(int val) { processOptions = val; }\r\n\r\n\r\n\tprotected:\r\n\tprivate:\r\n\r\n\r\n};\r\n#endif#ifndef _XNET_TYPES_H_\r\n#define _XNET_TYPES_H_\r\n\r\n#include \"vcWarnings.h\"\r\n\r\n\r\n#ifndef _TNL_TYPES_H_\r\n\t#include \"tnlTypes.h\"\r\n#endif\r\n\r\n\r\n#ifndef _XNET_ENUMERATIONS_H_\r\n\t#include \"xNetEnumerations.h\"\r\n#endif\r\n\r\n#ifndef __UX_STRING_H__\r\n\t#include \r\n#endif\r\n\r\n\r\nusing namespace TNL;\r\n\r\n\r\n#ifndef xTimeType\r\n\ttypedef unsigned int xTimeType;\r\n#endif\r\n\r\n#ifndef StringPtr\r\n\t#include \"tnlNetBase.h\"\r\n\t#include \"tnlString.h\"\r\n#endif\r\n\r\n\r\n\r\n#ifndef xNStream\r\n\t#ifndef _TNL_BITSTREAM_H_\r\n\t\t#include \"tnlBitStream.h\"\r\n\t#endif\r\n\ttypedef TNL::BitStream xNStream;\r\n#endif\r\n\r\n__inline bool isFlagOn(TNL::BitSet32 value,int flag)\r\n{\r\n\treturn value.test(1 << flag );\r\n}\r\n__inline bool isFlagOff(TNL::BitSet32 value,int flag)\r\n{\r\n\treturn value.test(1 << flag ) ? false : true;\r\n}\r\n\r\n__inline void enableFlag(TNL::BitSet32 &value,int flag)\r\n{\r\n\tvalue.set(1 << flag,true );\r\n}\r\n__inline void disableFlag(TNL::BitSet32 &value,int flag)\r\n{\r\n\tvalue.set(1 << flag,false);\r\n}\r\n\r\n#ifndef xNString\r\n\ttypedef TNL::StringPtr xNString;\r\n#endif\r\n\r\n\r\n\r\n#include \r\n\r\n#include \r\n#include \r\n\r\n//#include \r\n\r\n\tclass xDistributedClass;\r\nclass xDistributed3DObjectClass;\r\nclass xDistributedObject;\r\nclass xDistributedProperty;\r\nclass xDistributedPropertyInfo;\r\nclass xDistributedSession;\r\nclass xDistributedClient;\r\n\r\n\r\nclass xNetMessage;\r\nclass xNetworkMessage;\r\nclass xMessageType;\r\nclass xMessage;\r\n\r\n\r\ntypedef std::vectorxDistributedPropertyArrayType;\r\ntypedef std::vector::iterator xDistributedPropertyArrayIterator;\r\ntypedef std::vectorxDistributedPropertiesListType;\r\n\r\ntypedef std::vectorxDistributedObjectsArrayType;\r\ntypedef std::vector::iterator xDistributedObjectsArrayIterator;\r\ntypedef std::vector::iterator xDistObjectIt;\r\n\r\ntypedef std::mapxDistributedClassesArrayType;\r\ntypedef std::map::iterator xDistributedClassesArrayIterator;\r\ntypedef xDistributedClassesArrayIterator xDistClassIt;\r\n\r\ntypedef std::vectorNetworkMessagesType;\r\ntypedef std::vector::iterator NetworkMessagesTypeIterator;\r\n\r\ntypedef std::vectorxNetworkMessageArrayType;\r\ntypedef std::vector::iterator xNetworkMessageArrayTypeIterator;\r\n\r\ntypedef std::vectorxSessionArrayType;\r\ntypedef std::vectorxClientArrayType;\r\n\r\ntypedef std::vectorxMessageArrayType;\r\ntypedef std::vector::iterator xMessageArrayIterator;\r\n\r\ntypedef std::vectorxMessageTypeArrayType;\r\ntypedef std::vector::iterator xMessageTypeArrayIterator;\r\n\r\n\r\n\r\n\r\nclass xNetworkMessage\r\n{\r\npublic :\r\n\r\n\ttypedef std::map MessageParameterArrayType;\r\n\ttypedef std::map::iterator MessageParameterArrayTypeIterator;\r\n\r\n\r\n\txNetworkMessage()\r\n\t{\r\n\r\n\t\tm_RecievedParameters = new MessageParameterArrayType();\r\n\r\n\t}\r\n\tfloat lifeTime;\r\n\tbool complete;\r\n\tint targetUserID;\r\n\tint srcUserID;\r\n\tint numParameters;\r\n\tint messageID;\r\n\r\n\r\n\tvirtual ~xNetworkMessage()\r\n\t{\r\n\r\n\t}\r\n\txNString name;\r\n\r\n\r\n\tMessageParameterArrayType *m_RecievedParameters;\r\n};\r\n\r\n\r\nstruct xClientInfo\r\n{\r\n\tint userFlag;\r\n\t//USERNAME_FLAG userNameFlag;\r\n\tint userID;\r\n\txNString userName;\r\n};\r\n\r\nstruct xDistDeleteInfo\r\n{\r\n\tint serverID;\r\n\tint entityID;\r\n\tint deleteState;\r\n\r\n};\r\n#endif\r\n#ifndef __VT_C_BB_ERROR_HELPER_H__\r\n\t#define __VT_C_BB_ERROR_HELPER_H__\r\n\r\n#ifndef __X_LOGGER_H__\r\n\t#include \r\n#endif\r\n\r\n\r\n#define CERROR_STRING(F) sBBErrorStrings[F]\r\n\r\n\r\n#define bbSErrorME(A)\t{\txLogger::xLog(XL_START,ELOGERROR,E_BB,CERROR_STRING(A));\\\r\n\tXLOG_BB_INFO;\\\r\n\tbeh->ActivateOutput(0);\\\r\n\treturn CKBR_PARAMETERERROR ; }\r\n\r\n#define bbErrorME(A)\t{ xLogger::xLog(XL_START,ELOGERROR,E_BB,A);\\\r\n\tXLOG_BB_INFO;\\\r\n\tbeh->ActivateOutput(0);\\\r\n\treturn CKBR_PARAMETERERROR ; }\r\n\r\n#define bbWarning(A){ xLogger::xLog(XL_START,ELOGWARNING,E_BB,A);\\\r\n\tXLOG_BB_INFO;\\\r\n}\r\n\r\n\r\n\r\n/*#define XL_BB_NAME beh->GetPrototype()->GetName()\r\n#define XL_BB_OWNER_SCRIPT beh->GetOwnerScript()->GetName()\r\n#define XL_BB_OWNER_OBJECT beh->GetOwner() ? beh->GetOwner()->GetName() : \"none\"\r\n#define XL_BB_SIGNATURE (\"\\n\\tScript : %s\\n\\tBuildingBlock : %s \\n\\tObject :%s Error :\") \r\n\r\n\r\n#define XLOG_FMT(msg,extro) msg##extro\r\n#define XLOG_MERGE(var, fmt) (#var##fmt )\r\n#define XLOG_MERGE2(var,fmt) (var##fmt)\r\n\r\n#define XLOG_BB_INFO xLogger::xLogExtro(0,XL_BB_SIGNATURE,XL_BB_OWNER_SCRIPT,XL_BB_NAME,XL_BB_OWNER_OBJECT)\r\n\r\n#define VTERROR_STRING(F) sErrorStrings[F]\r\n#define bbError(F) \tXLOG_BB_INFO; \\\r\n\tError(beh,F,BB_OP_ERROR,VTERROR_STRING(F),TRUE,BB_O_ERROR,TRUE)\r\n#define bbNoError(F) Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),FALSE,BB_O_ERROR,FALSE)\r\n*/\r\n\r\n\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n#include \"pVehicleAll.h\"\r\n\r\n\r\nvoid __newpVehicleDescr(BYTE *iAdd)\r\n{\r\n\r\n\tnew (iAdd)pVehicleDesc();\r\n}\r\n\r\nvoid __newpVehicleMotorDesc(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pVehicleMotorDesc();\r\n}\r\n\r\nvoid __newpVehicleGearDesc(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pVehicleGearDesc();\r\n}\r\nvoid PhysicManager::_RegisterVSLVehicle()\r\n{\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// vehicle base types\r\n\t//\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleMotorDesc)\r\n\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpmToGearUp)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpmToGearDown)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpm)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotorDesc,void,setToCorvette)\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleGearDesc)\r\n\tDECLAREMEMBER(pVehicleGearDesc,int,nbForwardGears)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToDefault)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToCorvette)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,bool,isValid)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pVehicleDesc)\r\n\tDECLARECTOR_0(__newpVehicleDescr)\r\n\tDECLAREMEMBER(pVehicleDesc,float,digitalSteeringDelta)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringSteerPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringTurnPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,float,steeringMaxAngle)\r\n\tDECLAREMEMBER(pVehicleDesc,float,transmissionEfficiency)\r\n\tDECLAREMEMBER(pVehicleDesc,float,differentialRatio)\r\n\tDECLAREMEMBER(pVehicleDesc,float,maxVelocity)\r\n\tDECLAREMEMBER(pVehicleDesc,float,motorForce)\r\n\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleGearDesc*,getGearDescription)\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleMotorDesc*,getMotorDescr)\r\n\tDECLAREMETHOD_0(pVehicleDesc,void,setToDefault)\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// vehicle specific \r\n\t//\r\n\r\n\tDECLAREMETHOD_1(pVehicle,void,setPreScript,int)\r\n\tDECLAREMETHOD_1(pVehicle,void,setPostScript,int)\r\n\tDECLAREMETHOD_1(pVehicle,void,setOverrideMask,int)\r\n\r\n\r\n\r\n\tDECLAREMETHOD_1(pVehicle,int,initEngine,int)\r\n\t\r\n\tDECLAREMETHOD_0(pVehicle,BOOL,isValidEngine)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,pEngine*,getEngine)\r\n\tDECLAREMETHOD_0(pVehicle,pGearBox*,getGearBox)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,int,getStateFlags)\r\n\t\r\n\tDECLAREMETHOD_1(pVehicle,void,setClutch,float)\r\n\tDECLAREMETHOD_0(pVehicle,float,getClutch)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// egine\r\n\t//\r\n\tDECLAREMETHOD_1(pEngine,void,SetInertia,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setIdleRPM,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setStallRPM,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setStartRPM,float)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setTimeScale,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setEndRotationalFactor,float)\r\n\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setForceFeedbackScale,float)\r\n\tDECLAREMETHOD_0(pEngine,float,getForceFeedbackScale)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// engine\r\n\t//\r\n\tDECLAREMETHOD_0(pVehicle,pEngine*,getEngine)\r\n\r\n\tDECLAREMETHOD_0(pEngine,pLinearInterpolation,getTorqueCurve)\r\n\tDECLAREMETHOD_1(pEngine,void,setTorqueCurve,pLinearInterpolation)\r\n\r\n\tDECLAREMETHOD_0(pEngine,float,getRPM)\r\n\tDECLAREMETHOD_0(pEngine,float,getTorque)\r\n\tDECLAREMETHOD_0(pEngine,void,setToDefault)\r\n\tDECLAREMETHOD_1(pEngine,void,updateUserControl,int)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setMaxTorque,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setMaxRPM,float)\r\n\tDECLAREMETHOD_1(pEngine,void,setIdleRPM,float)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setBrakingCoeff,float)\r\n\tDECLAREMETHOD_0(pEngine,float,getBrakingCoeff)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setFriction,float)\r\n\tDECLAREMETHOD_0(pEngine,float,getFriction)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,SetInertia,float)\r\n\r\n\tDECLAREMETHOD_1(pEngine,void,setStartRPM,float)\r\n\tDECLAREMETHOD_0(pEngine,float,getStartRPM)\r\n\r\n\tDECLAREMETHOD_0(pEngine,int,GetGears)\r\n\tDECLAREMETHOD_0(pVehicle,void,PreCalcDriveLine)\r\n\r\n\t//DECLAREMETHOD_1(pEngine,float,GetGearRatio,int)\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// interpolation curve, used for for torque and gears\r\n\t//\r\n\tDECLAREMETHOD_0(pLinearInterpolation,int,getSize)\r\n\tDECLAREMETHOD_1(pLinearInterpolation,int,isValid,float)\r\n\tDECLAREMETHOD_1(pLinearInterpolation,float,getValue,float)\r\n\tDECLAREMETHOD_1(pLinearInterpolation,int,getValueAtIndex,int)\r\n\tDECLAREMETHOD_2(pLinearInterpolation,void,insert,float,float)\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// gearbox \r\n\t//\r\n\r\n\tDECLAREMETHOD_1(pGearBox,float,GetTorqueForWheel,pWheel2*)\r\n\r\n\tDECLAREMETHOD_0(pGearBox,pLinearInterpolation,getGearRatios)\r\n\tDECLAREMETHOD_1(pGearBox,void,setGearRatios,pLinearInterpolation)\r\n\r\n\tDECLAREMETHOD_0(pGearBox,pLinearInterpolation,getGearTensors)\r\n\tDECLAREMETHOD_1(pGearBox,void,setGearTensors,pLinearInterpolation)\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// wheel2\r\n\t//\r\n\tDECLAREMETHOD_1(pWheel2,void,setPreScript,int)\r\n\tDECLAREMETHOD_1(pWheel2,void,setPostScript,int)\r\n\tDECLAREMETHOD_1(pWheel2,void,setOverrideMask,int)\r\n\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndBrakingTorqueForWheel)\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndTorqueForWheel)\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndAccForWheel)\r\n\t\r\n\tDECLAREMETHOD_0(pWheel2,float,getWheelTorque)\r\n\tDECLAREMETHOD_0(pWheel2,float,getWheelBreakTorque)\r\n\tDECLAREMETHOD_0(pWheel2,float,getAxleSpeed)\r\n\t\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetForceRoadTC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetForceBodyCC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetTorqueTC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetTorqueFeedbackTC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetTorqueBrakingTC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetTorqueRollingTC)\r\n\r\n\tDECLAREMETHOD_0(pWheel2,float,GetSlipAngle)\r\n\tDECLAREMETHOD_0(pWheel2,float,GetSlipRatio)\r\n\tDECLAREMETHOD_0(pWheel2,float,GetHeading)\r\n\tDECLAREMETHOD_0(pWheel2,float,GetRotation)\r\n\tDECLAREMETHOD_0(pWheel2,float,GetRotationV)\r\n\tDECLAREMETHOD_0(pWheel2,float,GetAcceleration)\r\n\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetVelocity)\r\n\t//DECLAREMETHOD_0(pWheel2,VxVector,GetAcceleration)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetSlipVectorCC)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,GetPosContactWC)\r\n\r\n\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndBrakingTorqueForWheel)\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndTorqueForWheel)\r\n\tDECLAREMETHOD_0(pWheel2,float,getEndAccForWheel)\r\n\tDECLAREMETHOD_0(pWheel2,float,getWheelTorque)\r\n\tDECLAREMETHOD_0(pWheel2,float,getWheelBreakTorque)\r\n\tDECLAREMETHOD_0(pWheel2,bool,isAxleSpeedFromVehicle)\r\n\tDECLAREMETHOD_0(pWheel2,bool,isTorqueFromVehicle)\r\n\r\n\r\n\r\n\r\n\tDECLAREMEMBER(pWheel2,float,radius)\r\n\t\r\n\t\r\n\tDECLAREMEMBER(pWheel2,VxVector,forceGravityCC)\r\n\tDECLAREMEMBER(pWheel2,VxVector,forceBrakingTC)\r\n\r\n\r\n\r\n\tDECLAREMEMBER(pWheel2,VxVector,torqueTC)\r\n\tDECLAREMEMBER(pWheel2,VxVector,forceRoadTC)\r\n\r\n\tDECLAREMEMBER(pWheel2,VxVector,rotation)\r\n\tDECLAREMEMBER(pWheel2,VxVector,rotationA)\r\n\tDECLAREMEMBER(pWheel2,VxVector,rotationV)\r\n\tDECLAREMEMBER(pWheel2,VxVector,velWheelTC)\r\n\tDECLAREMEMBER(pWheel2,VxVector,velWheelCC)\r\n\r\n\tDECLAREMETHOD_1(pWheel2,void,setMass,float)\r\n\tDECLAREMETHOD_1(pWheel2,void,setTireRate,float)\r\n\t\r\n\tDECLAREMETHOD_0(pWheel2,float,getCsSlipLen)\r\n\tDECLAREMETHOD_1(pWheel2,void,setRollingCoeff,float)\r\n\r\n\t\r\n\r\n\r\n\t\r\n\r\n\tDECLAREMETHOD_0(pWheel2,float,getSuspensionTravel)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// pwheel contactdata\r\n\t//\r\n\tDECLAREMETHOD_0(pWheel2,pWheelContactData*,getContact)\r\n\t\r\n\tDECLAREMETHOD_1(pWheel2,bool,getContact,pWheelContactData&dst)\r\n\r\n\tDECLAREMEMBER(pWheel2,bool,hadContact)\r\n\r\n\tDECLAREMEMBER(pWheelContactData,VxVector,contactPoint)\r\n\tDECLAREMEMBER(pWheelContactData,VxVector,contactNormal)\r\n\tDECLAREMEMBER(pWheelContactData,VxVector,longitudalDirection)\r\n\tDECLAREMEMBER(pWheelContactData,VxVector,lateralDirection)\r\n\tDECLAREMEMBER(pWheelContactData,CK3dEntity*,contactEntity)\r\n\tDECLAREMEMBER(pWheelContactData,float,contactForce,)\r\n\tDECLAREMEMBER(pWheelContactData,float,longitudalSlip,)\r\n\tDECLAREMEMBER(pWheelContactData,float,lateralSlip)\r\n\tDECLAREMEMBER(pWheelContactData,float,longitudalImpulse)\r\n\tDECLAREMEMBER(pWheelContactData,float,lateralImpulse)\r\n\tDECLAREMEMBER(pWheelContactData,float,contactPosition)\r\n\tDECLAREMEMBER(pWheelContactData,int,otherShapeMaterialIndex)\r\n\r\n\r\n\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\tDECLAREMETHOD_0(pWheel2,pPacejka*,getPacejka)\r\n\t\r\n\tDECLAREMETHOD_1(pPacejka,void,SetFx,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetFy,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetMz,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetCamber,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetSlipAngle,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetSlipRatio,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetNormalForce,float)\r\n\tDECLAREMETHOD_0(pPacejka,void,setToDefault)\r\n\tDECLAREMETHOD_0(pPacejka,void,Calculate)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetMaxLongForce)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetMaxLatForce)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetMaxLongForce,float)\r\n\tDECLAREMETHOD_1(pPacejka,void,SetMaxLatForce,float)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetLongitudinalStiffness)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetCorneringStiffness)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetFx)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetFy)\r\n\tDECLAREMETHOD_0(pPacejka,float,GetMz)\r\n\r\n\r\n\tDECLAREMETHOD_1(pRigidBody,pWheel2*,getWheel2,CK3dEntity*)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,void,PreCalcDriveLine)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\t\r\n\t/*\r\n\tDECLAREMETHOD_1(pVehicle,void,updateVehicle,float)\r\n\tDECLAREMETHOD_5(pVehicle,void,setControlState,float,bool,float,bool,bool)\r\n\r\n\r\n\tDECLAREMETHOD_1(pVehicle,pWheel*,getWheel,CK3dEntity*)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleMotor*,getMotor)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleGears*,getGears)\r\n\r\n\tDECLAREMETHOD_1(pVehicle,void,setPreProcessingScript,int)\r\n\tDECLAREMETHOD_1(pVehicle,void,setPostProcessingScript,int)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,void,gearUp)\r\n\tDECLAREMETHOD_0(pVehicle,void,gearDown)\r\n\tDECLAREMETHOD_0(pVehicleGears,int,getGear)\r\n\t*/\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//motor : \r\n\t\r\n\t/*DECLAREMETHOD_0(pVehicleMotor,float,getRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotor,float,getTorque)\r\n\r\n\r\n\tDECLAREMETHOD_0(pWheel,pWheel1*,castWheel1)\r\n\tDECLAREMETHOD_0(pWheel,pWheel2*,castWheel2)\r\n\r\n\tDECLAREMETHOD_0(pWheel,float,getWheelRollAngle)\r\n\tDECLAREMETHOD_0(pWheel2,float,getRpm)\r\n\tDECLAREMETHOD_0(pWheel2,float,getAxleSpeed)\r\n\tDECLAREMETHOD_0(pWheel2,float,getSuspensionTravel)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,getGroundContactPos)\r\n*/\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}#ifndef __VTMODULES_GUIDS_H__\r\n #define __VTMODULES_GUIDS_H__\r\n\r\n#include \"vtBaseMacros.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief The guid of the modules manager. Used \r\n//\r\n//\r\n//! \\brief Manager Guid, used in plug-in registration, building blocks and many core components \r\n//\r\n#define GUID_MODULE_MANAGER\t\tCKGUID(0x1c0f04e8,0x442e20e5)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief ::\tThe guid of the modules building blocks\r\n//\t\t\t\tIf defined \"WebPack\", its using the guid of the built-in camera plug in. \r\n#ifdef WebPack\r\n\t#define GUID_MODULE_BUILDING_BLOCKS\tCKGUID(0x12d94eba,0x47057415)\r\n#else\r\n\t#define GUID_MODULE_BUILDING_BLOCKS\tCKGUID(0x36834d9e,0x63664944)\r\n#endif\r\n\r\n#endif#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLogEntryDecl();\r\nCKERROR CreateLogEntryProto(CKBehaviorPrototype **);\r\nint LogEntry(const CKBehaviorContext& behcontext);\r\nCKERROR LogEntryCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLogEntryDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Log Event\");\t\r\n\tod->SetDescription(\"Displays Internal Log Entries\");\r\n\t\r\n\tod->SetCategory(\"TNL\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x512542dc,0x1b836fd9));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateLogEntryProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateLogEntryProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Log Event\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareOutParameter(\"Entry\",CKPGUID_STRING);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(LogEntry);\r\n\tproto->SetBehaviorCallbackFct(LogEntryCB);\r\n\r\n\r\n\t*pproto = proto;\r\n\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint LogEntry(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\r\n\tXString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\r\n\tif (GetNM()->GetLastLogEntry().Length())\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\t\tpout->SetStringValue(GetNM()->GetLastLogEntry().Str());\r\n\t\tGetNM()->SetLastLogEntry(\"\");\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\r\n\t\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR LogEntryCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t/*\tCKParameterIn* pin = beh->GetInputParameter(0);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve first input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tif (pin->GetGUID()!=CKPGUID_MESSAGE) {\r\n\t\t\tpin->SetGUID(CKPGUID_MESSAGE,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : first input parameter type must be \\\"Message\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}\r\n\r\n\t\tpin = beh->GetInputParameter(1);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve second input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\r\n\t\tif (!behcontext.ParameterManager->IsDerivedFrom(pin->GetGUID(),CKPGUID_OBJECT)) {\r\n\t\t\tpin->SetGUID(CKPGUID_BEOBJECT,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : second input parameter type must derived from \\\"BeObject\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}*/\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"Prereqs.h\"\n#include \n#include \"tnl.h\"\n#include \"tnlNetBase.h\"\n#include \"xNetInterface.h\"\n#include \"xNetworkFactory.h\"\n\n#include \"tnlLog.h\"\n\nusing namespace TNL;\nstatic RefPtr myInterFace=NULL;\nstatic const char *localBroadcastAddress = \"IP:broadcast:28999\";\nstatic const char *localHostAddress = \"IP:127.0.0.1:28999\";\n\nclass DedicatedServerLogConsumer : public TNL::LogConsumer\n{\npublic:\n\tvoid logString(const char *string)\n\t{\n\t\tprintf(\"%s\\n\", string);\n\t}\n} gDedicatedServerLogConsumer;\n\n\nint main(int argc, const char **argv)\n{\n\tTNLLogEnable(LogNetInterface, true);\n\n\tmyInterFace = xNetworkFactory::CreateNetworkInterface(true,28999,localHostAddress);\n\n\n\tmyInterFace->setAllowsConnections(true);\n\tmyInterFace->setRequiresKeyExchange(false);\n\n\t//serverInterface->setPrivateKey(new AsymmetricKey(32));\n\t//NetInterfaceTestConnection *clientConnection = new NetInterfaceTestConnection;\n\n\t//Address addr(\"IP:127.0.0.1:25001\");\n\t//clientConnection->connect(clientInterface, &addr, true, false);\n\n\tfor(;;)\n\t{\n\t\tmyInterFace->checkIncomingPackets();\n\t\tmyInterFace->processConnections();\n\t\t//clientInterface->checkIncomingPackets();\n\t\t//clientInterface->processConnections();\n\t}\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n#include \"pWorldCallbacks.h\"\r\n#include \"pCallbackSignature.h\"\r\n\r\n\r\n\r\n\r\n#include \"virtools/vtTools.h\"\r\n#include \"pVehicleAll.h\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\nusing namespace vtTools::BehaviorTools;\r\n\r\nbool pWheel2::isTorqueFromVehicle()\r\n{\r\n\treturn\tgetWheelFlag(WF_Accelerated) && \r\n\t\t\tgetVehicle() && getVehicle()->isValidEngine() && \r\n\t\t\tgetDifferential() ;\r\n}\r\nbool pWheel2::isAxleSpeedFromVehicle()\r\n{\r\n\treturn\t(\tgetWheelFlag(WF_Accelerated) ) && \r\n\t\t\t(\tgetWheelShape()->getWheelFlags() & WSF_AxleSpeedOverride ) &&\r\n\t\t\t\tgetVehicle() && getVehicle()->isValidEngine() && getDifferential() ;\r\n}\r\nvoid pWheel2::applyTorqueToPhysics()\r\n{\r\n\tif (getDifferential())\r\n\t{\r\n\r\n\t\tpDifferential *diff = getDifferential();\r\n\r\n\t\tfloat finalTorqueOut = diff->GetTorqueOut(differentialSide);\r\n\r\n\t\tmWheelShape->setMotorTorque(finalTorqueOut);\r\n\t\t\r\n\r\n\r\n\r\n\r\n\r\n\t\t// Add torque to body because of the accelerating drivetrain\n\t\t// This gives a bit of the GPL effect where your car rolls when\n\t\t// you throttle with the clutch disengaged.\n\t\t\n\t\tfloat tr=getVehicle()->getEngine()->GetTorqueReaction();\n\t\tif(tr>0)\n\t\t{\n//\t\t\tVxVector torque(0,0,diff->GetAccIn()*diff->inertiaIn*tr);\n//\t\t\tgetBody()->addTorque(torque);\n\t\t}\n\r\n\t/*\tif(\t(wheel->getWheelShape()->getWheelFlags() & WSF_AxleSpeedOverride ) )\r\n\t\t{\r\n\t\t\tfloat v = wheel->rotationV.x;\r\n\t\t\tv = v * getEngine()->getEndRotationalFactor() * getEngine()->getTimeScale();\t\r\n\t\t}\r\n\t\t*/\r\n\t}\r\n}\r\n\r\nvoid pWheel2::_createInternalContactModifyCallback()\r\n{\r\n\r\n\tif (mWheelShape)\r\n\t{\r\n\t\tif (!wheelContactModifyCallback)\r\n\t\t{\r\n\t\t\twheelContactModifyCallback = new pWheelContactModify();\r\n\t\t\twheelContactModifyCallback->setWheel(this);\r\n\t\t\tmWheelShape->setUserWheelContactModify((NxUserWheelContactModify*)wheelContactModifyCallback);\r\n\r\n\t\t}\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//track information about callback\t\r\n\t\tif (getBody())\r\n\t\t\tgetBody()->getCallMask().set(CB_OnWheelContactModify,true);\r\n\t}\r\n\r\n\r\n}\r\n\r\nbool pWheelContactModify::onWheelContact(NxWheelShape* wheelShape, \r\n\t\t\t\t\t\t\t\t\t\t NxVec3& contactPoint, \r\n\t\t\t\t\t\t\t\t\t\t NxVec3& contactNormal, \r\n\t\t\t\t\t\t\t\t\t\t NxReal& contactPosition,\r\n\t\t\t\t\t\t\t\t\t\t NxReal& normalForce, \r\n\t\t\t\t\t\t\t\t\t\t NxShape* otherShape, \r\n\t\t\t\t\t\t\t\t\t\t NxMaterialIndex& otherShapeMaterialIndex, \r\n\t\t\t\t\t\t\t\t\t\t NxU32 otherShapeFeatureIndex)\r\n{\r\n\tpWheel2 *wheel = static_cast(getWheel());\r\n\tif (!getWheel())\r\n\t\treturn true;\r\n\r\n\t\r\n\tint contactModifyFlags = 0 ;\r\n\tbool createContact=true;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// store compact : \r\n\t//\r\n\tif (wheel->getBody()->getCallMask().test(CB_OnWheelContactModify))\r\n\t{\r\n\t\tpWheelContactModifyData &contactData = lastData;\r\n\t\tcontactData.object = getEntityFromShape(wheelShape);\r\n\t\tcontactData.contactNormal = getFrom(contactNormal);\r\n\t\tcontactData.contactPoint = getFrom(contactPoint);\r\n\t\tcontactData.contactPosition = contactPosition;\r\n\t\tcontactData.normalForce = normalForce;\r\n\t\tcontactData.otherMaterialIndex = otherShapeMaterialIndex;\r\n\t\t\r\n\t\tcreateContact = wheel->onWheelContactModify(contactModifyFlags,&contactData);\r\n\r\n\r\n\t\tif (!createContact)\r\n\t\t\treturn false;\r\n\r\n\t\tif (contactModifyFlags==0)\r\n\t\t\treturn true;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// copy result back to sdk\r\n\t\t//\r\n\t\tcontactNormal = getFrom(contactData.contactNormal);\r\n\t\tcontactPoint = getFrom(contactData.contactPoint);\r\n\t\tcontactPosition = contactData.contactPosition;\r\n\t\tnormalForce = contactData.normalForce;\r\n\r\n\r\n\t}\r\n\r\n\t//xWarning(\"whatever\");\r\n\treturn true;\r\n}\r\nbool pWheel2::onWheelContactModify(int& changeFlags,pWheelContactModifyData* contact)\r\n{\r\n\r\n\r\n\r\n\tbool result = true;\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\tif (!contact)\r\n\t\treturn true;\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// keep some informationens for our self\r\n\t//\r\n\tif( getProcessOptions() & pVPO_Wheel_UsePHYSX_Load &&\r\n\t\tgetProcessOptions() & pVPO_Wheel_UsePHYSX_CONTACT_DATA && getVehicle() \r\n\t\t)\r\n\t{\r\n\t\tload = contact->contactNormal.y;\r\n\r\n\t\tif (load > 1500)\r\n\t\t\tload = 1500;\r\n\r\n\t\tif (load <= 0)\r\n\t\t\tload = 1000;\r\n\r\n\r\n\t}\r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getWheelContactScript());\r\n\tif (beh && CKGetObject(ctx(),getEntID()))\r\n\t{\r\n\t\t\r\n\t\tSetInputParameterValue(beh,bbIWC_SrcObject,getEntID());\r\n\r\n\t\tSetInputParameterValue(beh,bbIWC_Point,contact->contactPoint);\r\n\t\tSetInputParameterValue(beh,bbIWC_Normal,contact->contactNormal);\r\n\t\tSetInputParameterValue(beh,bbIWC_Position,contact->contactPosition);\r\n\t\tSetInputParameterValue(beh,bbIWC_NormalForce,contact->normalForce);\r\n\t\tSetInputParameterValue(beh,bbIWC_OtherMaterialIndex,contact->otherMaterialIndex);\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// execute:\r\n\t\t//\r\n\t\tbeh->Execute(lastStepTimeSec);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// refuse contact \r\n\t\t//\r\n\t\tresult = GetOutputParameterValue(beh,bbOWC_CreateContact);\r\n\t\tif (!result)\r\n\t\t\treturn false;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// nothing changed, return true\r\n\t\t//\r\n\t\tchangeFlags = GetOutputParameterValue(beh,bbOWC_ModificationFlags);\r\n\t\tif (changeFlags == 0 )\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// pickup data, according to change flags\r\n\t\t//\r\n\t\tif (changeFlags & CWCM_ContactPoint )\r\n\t\t\tcontact->contactPoint = GetOutputParameterValue(beh,bbOWC_Point);\r\n\r\n\t\tif (changeFlags & CWCM_ContactNormal)\r\n\t\t\tcontact->contactNormal= GetOutputParameterValue(beh,bbOWC_Normal);\r\n\t\t\r\n\t\tif (changeFlags & CWCM_ContactPosition )\r\n\t\t\tcontact->contactPosition= GetOutputParameterValue(beh,bbOWC_Position);\r\n\r\n\t\tif (changeFlags & CWCM_NormalForce )\r\n\t\t\tcontact->normalForce = GetOutputParameterValue(beh,bbOWC_NormalForce);\r\n\t}\r\n\r\n\t\t\r\n\r\n\treturn true;\r\n\r\n}\r\n\r\nbool pWheel2::onWheelContact(CK3dEntity* wheelShapeReference, VxVector& contactPoint, VxVector& contactNormal, float& contactPosition, float& normalForce, CK3dEntity* otherShapeReference, int& otherShapeMaterialIndex)\r\n{\r\n\t//NxUserAllocator\r\n\treturn true;\r\n}\r\n\r\nvoid pWheel2::setWheelContactScript(int val)\r\n{\r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(val);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnWheelContactModify,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tpCallbackObject::setWheelContactScript(val);\r\n\r\n\twheelContactModifyCallback = new pWheelContactModify();\r\n\twheelContactModifyCallback->setWheel(this);\r\n\r\n\tgetWheelShape()->setUserWheelContactModify((NxUserWheelContactModify*)wheelContactModifyCallback);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//track information about callback\t\r\n\tgetBody()->getCallMask().set(CB_OnWheelContactModify,true);\r\n\r\n\r\n}\r\nvoid pWheel2::processPreScript()\r\n{\r\n\r\n}\r\nvoid pWheel2::processPostScript()\r\n{\r\n\r\n}\r\nint pWheel2::onPostProcess()\r\n{\r\n\r\n\treturn 1;\r\n}\r\nint pWheel2::onPreProcess()\r\n{\r\n\r\n\treturn 1;\r\n}\r\n\r\nvoid pWheel2::_tick(float dt)\r\n{\r\n\r\n\r\n\t\r\n\tfloat dt2 = dt;\r\n\r\n\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape) return;\r\n\r\n\r\n\tNxVec3 _localVelocity;\r\n\tbool _breaking=false;\r\n\r\n\tNxWheelContactData wcd; \r\n\t\r\n\tNxShape* contactShape = wShape->getContact(wcd);\r\n\r\n\tif (contactShape)\r\n\t{\r\n\r\n\t\tNxVec3 relativeVelocity;\r\n\t\tif ( !contactShape->getActor().isDynamic())\r\n\t\t{\r\n\t\t\trelativeVelocity = getActor()->getLinearVelocity();\r\n\t\t} else {\r\n\t\t\trelativeVelocity = getActor()->getLinearVelocity() - contactShape->getActor().getLinearVelocity();\r\n\t\t}\r\n\t\tNxQuat rotation = getActor()->getGlobalOrientationQuat();\r\n\r\n\t\t_localVelocity = relativeVelocity;\r\n\t\trotation.inverseRotate(_localVelocity);\r\n\t\t_breaking = false; //NxMath::abs(_localVelocity.z) < ( 0.1 );\r\n\t\t//\t\t\t\t\twShape->setAxleSpeed()\r\n\t}\r\n\r\n\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\t\r\n\trollAngle+=wShape->getAxleSpeed() * (dt);\r\n\t//rollAngle+=wShape->getAxleSpeed() * (1.0f/60.0f /*dt* 0.01f*/);\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( contactShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\r\n\tfloat rAngle = getWheelRollAngle();\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxVec3 p0;\r\n\tNxVec3 dir;\r\n\t/*\r\n\tgetWorldSegmentFast(seg);\r\n\tseg.computeDirection(dir);\r\n\tdir.normalize();\r\n\t*/\r\n\tNxReal r = wShape->getRadius();\r\n\tNxReal st = wShape->getSuspensionTravel();\r\n\tNxReal steerAngle = wShape->getSteerAngle();\r\n\tp0 = wheelPose.t; //cast from shape origin\r\n\twheelPose.M.getColumn(1, dir);\r\n\tdir = -dir;\t//cast along -Y.\r\n\tNxReal castLength = r + st;\t//cast ray this long\r\n\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n}\r\n/*--------------------------------------------------------------------- NVMH5 -|----------------------\r\nPath: Sdk\\Demos\\Direct3D9\\src\\GetGPUAndSystemInfo\\\r\nFile: GetGPUAndSystemInfo.cpp\r\n\r\nCopyright NVIDIA Corporation 2003\r\nTO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND\r\nAND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA\r\nOR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER\r\nINCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF\r\nBUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS\r\nSOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r\n\r\n\r\nComments:\r\nSee GetGPUAndSystemInfo.h for additional comments.\r\n\r\n\r\n-------------------------------------------------------------------------------|--------------------*/\r\n\r\n\r\n#include \r\n#include \r\n\r\n#include \"GetGPUAndSystemInfo.h\"\r\n\r\n#include \"shared\\NV_Common.h\"\r\n#include \"shared\\NV_Error.h\"\r\n\r\n\r\n/*------------------------------------------------------------------\r\nRetrieve various data through the IDxDiagContainer interface.\r\n\r\nThe DXDiagNVUtil class provides a few convenient wrapper functions,\r\nand direct querries using the IDxDiagContainer COM object names are\r\nalso supported. For a list of all the container and property COM\r\nobject names, call ListAllDXDiagPropertyNames(..)\r\n------------------------------------------------------------------*/\r\nHRESULT\tGetGPUAndSystemInfo::GetData()\r\n{\r\n\tHRESULT hr = S_OK;\r\n\t//----------------------------------------------------------------------------\r\n\thr = m_DXDiagNVUtil.InitIDxDiagContainer();\r\n\tMSG_AND_RET_VAL_IF( FAILED(hr), \"Couldn't initialize DXDiagNVUtil!\\n\", hr );\r\n\twstring wstr;\r\n\t// Get the computer's machine name:\r\n\tm_DXDiagNVUtil.GetProperty( L\"DxDiag_SystemInfo\", L\"szMachineNameEnglish\", &wstr );\r\n\tm_strMachineName = m_DXDiagNVUtil.WStringToString( &wstr );\r\n\r\n\tFMsg(\"\\n\\n\");\r\n\tFMsg(\"------------------------------------------------------------------------\\n\");\r\n\tFMsgW(L\"machine name: %s\\n\", wstr.c_str() );\r\n\r\n\t// Get info about physcial memory:\r\n\tm_DXDiagNVUtil.GetPhysicalMemoryInMB( & m_fSystemPhysicalMemoryMB );\r\n\tFMsg(\"physical memory: %g MB\\n\", m_fSystemPhysicalMemoryMB );\r\n\t\r\n\t// Get info about logical disks\r\n\tIDxDiagContainer * pContainer, *pChild;\r\n\tDWORD dwNumDisks;\r\n\thr = m_DXDiagNVUtil.GetChildContainer( L\"DxDiag_LogicalDisks\", & pContainer );\r\n\tif( SUCCEEDED(hr))\r\n\t{\r\n\t\tpContainer->GetNumberOfChildContainers( & dwNumDisks );\r\n\r\n\t\twstring drive, space;\r\n\t\tFMsgW(L\"logical disks: %d\\n\", dwNumDisks );\r\n\t\tfor( DWORD n=0; n < dwNumDisks; n++ )\r\n\t\t{\r\n\t\t\thr = m_DXDiagNVUtil.GetChildByIndex( pContainer, n, &pChild );\r\n\t\t\tif( SUCCEEDED(hr) )\r\n\t\t\t{\r\n\t\t\t\tm_DXDiagNVUtil.GetProperty( pChild, L\"szDriveLetter\", &drive );\r\n\t\t\t\tm_DXDiagNVUtil.GetProperty( pChild, L\"szFreeSpace\", &space );\r\n\t\t\t\tFMsgW(L\" %s Free space = %s\\n\", drive.c_str(), space.c_str() );\t\t\t\r\n\t\t\t\tSAFE_RELEASE( pChild );\r\n\t\t\t}\r\n\t\t}\r\n\t\tSAFE_RELEASE( pContainer );\r\n\t}\r\n\r\n\tFMsg(\"------------------------------------------------------------------------\\n\");\r\n\r\n\tm_DXDiagNVUtil.GetDirectXVersion( &m_dwDXVersionMajor, &m_dwDXVersionMinor, &m_cDXVersionLetter );\r\n\tFMsg(\"DirectX Version: %d.%d%c\\n\", m_dwDXVersionMajor, m_dwDXVersionMinor, m_cDXVersionLetter );\r\n\r\n\thr = m_DXDiagNVUtil.GetNumDisplayDevices( & m_dwNumDisplayDevices );\r\n\tMSG_AND_RET_VAL_IF( FAILED(hr), \"Couldn't GetNumDisplayDevices()\\n\", hr );\r\n\tFMsg(\"Num Display Devices: %d\\n\", m_dwNumDisplayDevices );\r\n\r\n\tstring str;\r\n\r\n//\tfor( DWORD dev=0; dev < m_dwNumDisplayDevices; dev ++ )\r\n\tif( m_dwNumDisplayDevices > 0 )\r\n\t{\r\n\t\tDWORD dev = 0;\r\n\r\n\t\t// get info from display devices\r\n\t\tm_DXDiagNVUtil.GetDisplayDeviceDescription(\t\tdev, & m_wstrDeviceDesc );\r\n\t\tm_DXDiagNVUtil.GetDisplayDeviceNVDriverVersion( dev, & m_fDriverVersion );\r\n\t\tm_DXDiagNVUtil.GetDisplayDeviceMemoryInMB(\t\tdev, & m_nDeviceMemoryMB );\r\n\r\n\t\t// report the info via OutputDebugString\r\n\t\tFMsgW(L\"Device %d Description: %s\\n\", dev, m_wstrDeviceDesc.c_str() );\r\n\t\tFMsg( \"Device %d Driver version: %g\\n\", dev, m_fDriverVersion );\r\n\t\tFMsg( \"Device %d Physical mem: %d MB\\n\", dev, m_nDeviceMemoryMB );\r\n\r\n\t\t// Get info about AGP memory:\r\n\t\twstring wstrAGPEnabled, wstrAGPExists, wstrAGPStatus;\r\n\t\thr = m_DXDiagNVUtil.GetDisplayDeviceAGPMemoryStatus( dev, &wstrAGPEnabled, &wstrAGPExists, &wstrAGPStatus );\r\n\t\tif( SUCCEEDED(hr))\r\n\t\t{\r\n\t\t\t// create a string from the AGP status strings\r\n\t\t\tm_strAGPStatus = \"\";\r\n\t\t\tstr = m_DXDiagNVUtil.WStringToString( &wstrAGPEnabled );\r\n\t\t\tm_strAGPStatus += \"AGP Enabled = \"; m_strAGPStatus += str; m_strAGPStatus += \", \";\r\n\t\t\tstr = m_DXDiagNVUtil.WStringToString( &wstrAGPExists );\r\n\t\t\tm_strAGPStatus += \"AGP Exists = \"; m_strAGPStatus += str; m_strAGPStatus += \", \";\r\n\t\t\tstr = m_DXDiagNVUtil.WStringToString( &wstrAGPStatus );\r\n\t\t\tm_strAGPStatus += \"AGP Status = \"; m_strAGPStatus += str;\r\n\t\t}\r\n\t\tFMsg(\"%s\\n\", m_strAGPStatus.c_str() );\r\n\r\n\t\twstring wstrNotes, wstrTestD3D9;\r\n\t\tm_DXDiagNVUtil.GetProperty( L\"DxDiag_DisplayDevices\", L\"0\", L\"szTestResultD3D9English\", &wstrTestD3D9 );\r\n\t\tm_DXDiagNVUtil.GetProperty( L\"DxDiag_DisplayDevices\", L\"0\", L\"szNotesEnglish\",\t\t\t&wstrNotes );\r\n\t\r\n\t\tstr = m_DXDiagNVUtil.WStringToString( &wstrTestD3D9 );\r\n\t\tFMsg(\"Device 0 szTestResultD3D9English = \\\"%s\\\"\\n\", str.c_str() );\r\n\t\tstr = m_DXDiagNVUtil.WStringToString( &wstrNotes );\r\n\t\tFMsg(\"Device 0 szNotesEnglish = \\\"%s\\\"\\n\", str.c_str() );\r\n\t}\r\n\r\n\tm_DXDiagNVUtil.GetDebugLevels( & m_wstrDxDebugLevels );\r\n\tFMsg(\"DirectX Debug Levels:\\n\");\r\n\tFMsgW(L\"%s\\n\", m_wstrDxDebugLevels.c_str() );\r\n\r\n\r\n\t// ListAllDXDiagPropertyNames() is slow\r\n\t// It prints out all nodes, child nodes, properties and their values\r\n//\tm_DXDiagNVUtil.ListAllDXDiagPropertyNames();\r\n\r\n\t// Use a call like that below to print out a specific node and it's children.\r\n\t// For example, to list all the display device property names.\r\n/*\r\n\tm_DXDiagNVUtil.GetChildContainer( L\"DxDiag_DisplayDevices\", &pContainer );\r\n\tm_DXDiagNVUtil.ListAllDXDiagPropertyNames( pContainer, L\"DxDiag_DisplayDevices\" );\r\n\tSAFE_RELEASE( pContainer );\r\n// */\t\r\n\r\n\tm_DXDiagNVUtil.FreeIDxDiagContainer();\r\n\treturn( hr );\r\n}\r\n\r\n\r\nHRESULT GetGPUAndSystemInfo::IsFPBlendingSupported( IDirect3D9 * pD3D9, FloatingPointBlendModes * pOutResult )\r\n{\r\n\tFMsg(\"There is a bug with this code in that is does not report that blending works for ordinary backbuffer formats\\n\");\r\n\tassert( false );\r\n\r\n\tHRESULT hr = S_OK;\r\n\tFAIL_IF_NULL( pD3D9 );\r\n\tFAIL_IF_NULL( pOutResult );\r\n\r\n\tbool * pResult;\r\n\r\n\thr = pD3D9->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_A8R8G8B8,\r\n\t\t\t\t\t\t\t\t\tD3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,\r\n\t\t\t\t\t\t\t\t\tD3DRTYPE_SURFACE,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_R16F );\r\n\tpResult = &pOutResult->m_bR16f;\r\n\tif( hr == D3D_OK )\r\n\t\t*pResult = true;\r\n\telse if( hr == D3DERR_NOTAVAILABLE )\r\n\t\t*pResult = false;\r\n\telse\r\n\t\tFMsg(\"Unknown return result for D3DFMT_R16F : %u\\n\", hr );\r\n\r\n\r\n\thr = pD3D9->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_A8R8G8B8,\r\n\t\t\t\t\t\t\t\t\tD3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,\r\n\t\t\t\t\t\t\t\t\tD3DRTYPE_SURFACE,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_A16B16G16R16F );\r\n\tpResult = &pOutResult->m_bA16B16G16R16f;\r\n\tif( hr == D3D_OK )\r\n\t\t*pResult = true;\r\n\telse if( hr == D3DERR_NOTAVAILABLE )\r\n\t\t*pResult = false;\r\n\telse\r\n\t\tFMsg(\"Unknown return result for D3DFMT_A16B16G16R16F : %u\\n\", hr );\r\n\r\n\thr = pD3D9->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_A8R8G8B8,\r\n//\t\t\t\t\t\t\t\t\tD3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,\r\n\t\t\t\t\t\t\t\t\t0 | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,\t\t// per the DX90SDK docs\r\n\t\t\t\t\t\t\t\t\tD3DRTYPE_SURFACE,\r\n\t\t\t\t\t\t\t\t\tD3DFMT_A8R8G8B8 );\r\n\tpResult = &pOutResult->m_bA8R8G8B8;\r\n\tif( hr == D3D_OK )\r\n\t\t*pResult = true;\r\n\telse if( hr == D3DERR_NOTAVAILABLE )\r\n\t\t*pResult = false;\r\n\telse\r\n\t\tFMsg(\"Unknown return result for D3DFMT_A8R8G8B8 : %u\\n\", hr );\r\n\r\n\r\n\tif( pOutResult->m_bA16B16G16R16f == true )\r\n\t\tFMsg(\"D3DFMT_A16B16G16R16F POSTPIXELSHADER_BLENDING is supported\\n\");\r\n\telse\r\n\t\tFMsg(\"D3DFMT_A16B16G16R16F POSTPIXELSHADER_BLENDING is not supported\\n\");\r\n\r\n\tif( pOutResult->m_bR16f == true )\r\n\t\tFMsg(\"D3DFMT_R16F POSTPIXELSHADER_BLENDING is supported\\n\");\r\n\telse\r\n\t\tFMsg(\"D3DFMT_R16F POSTPIXELSHADER_BLENDING is not supported\\n\");\r\n\r\n\tif( pOutResult->m_bA8R8G8B8 == true )\r\n\t\tFMsg(\"D3DFMT_A8R8G8B8 POSTPIXELSHADER_BLENDING is supported\\n\");\r\n\telse\r\n\t\tFMsg(\"D3DFMT_A8R8G8B8 POSTPIXELSHADER_BLENDING is not supported\\n\");\r\n\r\n/*\r\nUse IDirect3D9::CheckDeviceFormat, with usage (D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADERBLENDING).\r\nHRESULT CheckDeviceFormat( UINT Adapter,\r\n D3DDEVTYPE DeviceType,\r\n D3DFORMAT AdapterFormat,\r\n DWORD Usage,\r\n D3DRESOURCETYPE RType,\r\n D3DFORMAT CheckFormat\r\n);\r\n\r\nD3DFMT_R16F 111 16-bit float format using 16 bits for the red channel. \r\nD3DFMT_G16R16F 112 32-bit float format using 16 bits for the red channel and 16 bits for the green channel. \r\nD3DFMT_A16B16G16R16F \r\n\r\nD3DFMT_R32F 114 32-bit float format using 32 bits for the red channel. \r\nD3DFMT_G32R32F 115 64-bit float format using 32 bits for the red channel and 32 bits for the green channel. \r\nD3DFMT_A32B32G32R32F \r\n\r\nD3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING\r\n\r\nD3DUSAGE_QUERY_FILTER (more than just point sampling)\r\n\r\nQuery the resource to verify support for post pixel shader blending support. \r\nIf IDirect3D9::CheckDeviceFormat fails with D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, \r\npost pixel blending operations are not supported. These include alpha test, pixel fog, \r\nrender-target blending, color write enable, and dithering.\r\n\r\nMSFT examples from SDK\r\n if( pCaps->PixelShaderVersion < D3DPS_VERSION(1,1) )\r\n {\r\n if( FAILED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, \r\n pCaps->DeviceType, adapterFormat, D3DUSAGE_RENDERTARGET,\r\n D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8 ) ) )\r\n {\r\n return E_FAIL;\r\n }\r\n }\r\n\r\n // Need to support post-pixel processing (for alpha blending)\r\n if( FAILED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType,\r\n adapterFormat, D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, \r\n D3DRTYPE_SURFACE, backBufferFormat ) ) )\r\n {\r\n return E_FAIL;\r\n }\r\n\r\nHRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS9* pCaps, DWORD dwBehavior,\r\n D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat )\r\n{\r\n // Need to support post-pixel processing (for alpha blending)\r\n if( FAILED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType,\r\n adapterFormat, D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, \r\n D3DRTYPE_SURFACE, backBufferFormat ) ) )\r\n {\r\n return E_FAIL;\r\n }\r\n\r\n*/\r\n\r\n\r\n\t\r\n\treturn( hr );\r\n}\r\n\r\n#ifndef __P_WORLD_H__\r\n#define __P_WORLD_H__\r\n\r\n#include \"pTypes.h\"\r\n\r\n/**\r\n\\brief Class to maintain physical objects.\r\n*/\r\n\tclass MODULE_API pWorld\r\n\t{\r\n\r\n\tpublic:\r\n\t\tpWorld();\r\n\t\t\r\n\t\tbool m_bCompletedLastFrame; // in class definition\r\n\t\tfloat m_fTimeSinceLastCallToSimulate; // in class def\r\n\r\n\t\tpWorld(CK3dEntity* _o);\r\n\t\tvirtual ~pWorld();\r\n\r\n\t\tvoid _construct();\r\n\r\n\t\tint hadBrokenJoint();\r\n\t\tvoid cleanBrokenJoints();\r\n\r\n\r\n\t\tCK3dEntity* getReference() const { return m_vtReference; }\r\n\t\tvoid setReference(CK3dEntity* val) { m_vtReference = val; }\r\n\r\n\t\tpWorldSettings * getWorldSettings() const { return m_worldSettings; }\r\n\t\tvoid setWorldSettings(pWorldSettings * val) { m_worldSettings = val; }\r\n\r\n\t\tpSleepingSettings * getSleepingSettings() const { return m_SleepingSettings; }\r\n\t\tvoid setSleepingSettings(pSleepingSettings * val) { m_SleepingSettings = val; }\r\n\r\n\t\tNxScene* getScene() const { return mScene; }\r\n\t\tvoid setScene(NxScene* val) { mScene = val; }\r\n\t\tNxMaterial* getDefaultMaterial() const { return mDefaultMaterial; }\r\n\t\tvoid setDefaultMaterial(NxMaterial* val) { mDefaultMaterial = val; }\r\n\r\n\r\n\t\tint UpdateProperties(DWORD mode,DWORD flags);\r\n\r\n\t\tint& getDataFlags() { return m_DataFlags; }\r\n\t\tvoid setDataFlags(int val) { m_DataFlags = val; }\r\n\t\tvoid destroy();\r\n\r\n\r\n\t\tpRigidBody *getBody(CK3dEntity*ent);\r\n\t\tpRigidBody *getBodyFromSubEntity(CK3dEntity *sub);\r\n\r\n\t\t//pJoint*getJoint(CK3dEntity*,CK3dEntity*);\r\n\t\tpJoint*getJoint(CK3dEntity*_a,CK3dEntity*_b,JType type);\r\n\t\tvoid deleteJoint(pJoint*joint);\r\n\r\n\t\tvoid _checkForDominanceConstraints();\r\n\t\tNxCompartment * compartment;\r\n\t\tNxCompartment * getCompartment() const { return compartment; }\r\n\t\tvoid setCompartment(NxCompartment * val) { compartment = val; }\r\n\r\n \r\n\t\t/** @name Collision Filtering \r\n\t\t*/\r\n\t\t//@{\r\n\r\n\t\t/**\r\n\t\t\\brief Setups filtering operations. See comments for ::pGroupsMask\r\n\r\n\t\tSleeping: Does NOT wake the actors up automatically.\r\n\r\n\t\t\\param[in] op0 Filter op 0.\r\n\t\t\\param[in] op1 Filter op 1.\r\n\t\t\\param[in] op2 Filter op 2.\r\n\r\n\t\t@see setFilterBool() setFilterConstant0() setFilterConstant1()\r\n\t\t*/\r\n\t\tvoid setFilterOps(pFilterOp op0,pFilterOp op1, pFilterOp op2);\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Setups filtering's boolean value. See comments for ::pGroupsMask\r\n\r\n\t\tSleeping: Does NOT wake the actors up automatically.\r\n\r\n\t\t\\param[in] flag Boolean value for filter.\r\n\r\n\t\t@see setFilterOps() setFilterConstant0() setFilterConstant1()\r\n\t\t*/\r\n\t\tvoid\tsetFilterBool(bool flag);\t\t\r\n\r\n\t\t/**\r\n\t\t\\brief Setups filtering's K0 value. See comments for ::pGroupsMask\r\n\r\n\t\tSleeping: Does NOT wake the actors up automatically.\r\n\r\n\t\t\\param[in] mask The new group mask. See #pGroupsMask.\r\n\r\n\t\t@see setFilterOps() setFilterBool() setFilterConstant1()\r\n\t\t*/\r\n\t\tvoid\tsetFilterConstant0(const pGroupsMask& mask);\r\n\r\n\t\t/**\r\n\t\t\\brief Setups filtering's K1 value. See comments for ::pGroupsMask\r\n\r\n\t\tSleeping: Does NOT wake the actors up automatically.\r\n\r\n\t\t\\param[in] mask The new group mask. See #pGroupsMask.\r\n\r\n\r\n\t\t@see setFilterOps() setFilterBool() setFilterConstant0()\r\n\t\t*/\r\n\t\tvoid\tsetFilterConstant1(const pGroupsMask& mask);\r\n\r\n\t\t/**\r\n\t\t\\brief Retrieves filtering operation. See comments for ::pGroupsMask\r\n\r\n\t\t\\param[out] op0 First filter operator.\r\n\t\t\\param[out] op1 Second filter operator.\r\n\t\t\\param[out] op2 Third filter operator.\r\n\r\n\t\tSee the user guide page \"Contact Filtering\" for more details.\t\r\n\r\n\t\t\\return the filter operation requested\r\n\r\n\t\t@see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1()\r\n\t\t*/\r\n\t\tvoid\tgetFilterOps(pFilterOp& op0, pFilterOp& op1, pFilterOp& op2)const;\r\n\r\n\t\t/**\r\n\t\t\\brief Retrieves filtering's boolean value. See comments for ::pGroupsMask\r\n\r\n\t\t\\return flag Boolean value for filter.\r\n\r\n\t\t@see setFilterBool() setFilterConstant0() setFilterConstant1()\r\n\t\t*/\r\n\t\tbool \t\t\t\t\t\tgetFilterBool() const;\r\n\r\n\t\t/**\r\n\t\t\\brief Gets filtering constant K0. See comments for ::pGroupsMask\r\n\r\n\t\t\\return the filtering constant, as a mask. See #pGroupsMask.\r\n\r\n\t\t@see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1() getFilterConstant1()\r\n\t\t*/\r\n\t\tpGroupsMask\t\t\t\tgetFilterConstant0() const;\r\n\r\n\t\t/**\r\n\t\t\\brief Gets filtering constant K1. See comments for ::NxGroupsMask\r\n\r\n\t\t\\return the filtering constant, as a mask. See #pGroupsMask.\r\n\r\n\t\t@see setFilterOps() setFilterBool() setFilterConstant0() setFilterConstant1() getFilterConstant0()\r\n\t\t*/\r\n\t\tpGroupsMask\t\t\t\tgetFilterConstant1() const;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t//@}\r\n\r\n\r\n\r\n\t\t/** @name Raycasting\r\n\t\t*/\r\n\t\t//@{\r\n\r\n\t\t/**\r\n\t\t\\brief Returns true if any axis aligned bounding box enclosing a shape of type shapeType is intersected by the ray.\r\n\r\n\t\t\\note Make certain that the direction vector of NxRay is normalized.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediately visible.\r\n\r\n\t\t\\param[in] worldRay The ray to cast in the global frame. Range: See #NxRay\r\n\t\t\\param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #pShapesType.\r\n\t\t\\param[in] groups Mask used to filter shape objects. See #pRigidBody::setGroup\r\n\t\t\\param[in] maxDist Max distance to check along the ray for intersecting bounds. Range: (0,inf)\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\r\n\t\t\\return true if any axis aligned bounding box enclosing a shape of type shapeType is intersected by the ray\r\n\r\n\t\t@see pShapesType VxRay pRigidBody.setGroup() raycastAnyShape()\r\n\t\t*/\r\n\t\tbool\t\t\t\t\t\traycastAnyBounds\t\t(const VxRay& worldRay, pShapesType shapesType, pGroupsMask *groupsMask=NULL,int groups=0xffffffff, float maxDist=pFLOAT_MAX);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns true if any shape of type ShapeType is intersected by the ray.\r\n\r\n\t\t\\note Make certain that the direction vector of NxRay is normalized.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediately visible.\r\n\r\n\t\t\\param[in] worldRay The ray to cast in the global frame. Range: See #VxRay\r\n\t\t\\param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #pShapesType.\r\n\t\t\\param[in] groups Mask used to filter shape objects. See #pRigidBody::setGroup\r\n\t\t\\param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) \r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t\t\\param[in] cache Possible cache for persistent raycasts, filled out by the SDK.\r\n\r\n\t\t\\return Returns true if any shape of type ShapeType is intersected by the ray.\r\n\r\n\t\t@see pShapesType VxRay pRigidBody.setGroup() raycastAnyBounds()\r\n\t\t*/\r\n\t\tbool\t\t\t\t\t\traycastAnyShape\t\t\t(const VxRay& worldRay, pShapesType shapesType, pGroupsMask groupsMask,CKDataArray* cache, int groups=0xffffffff, float maxDist=pFLOAT_MAX);\r\n\r\n\t\t/**\r\n\t\t\\brief Calls the report's hitCallback() method for all the shapes of type ShapeType intersected by the ray.\r\n\r\n\t\thintFlags is a combination of ::NxRaycastBit flags.\r\n\t\tReturns the number of shapes hit. The point of impact is provided as a parameter to hitCallback().\r\n\r\n\t\t\\note Make certain that the direction vector of NxRay is normalized.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediatly visible.\r\n\r\n\t\t

Example

\r\n\r\n\t\t\\include NxUserRaycastReport_Usage.cpp\r\n\r\n\r\n\t\t\\param[in] worldRay The ray to cast in the global frame. Range: See #NxRay\r\n\t\t\\param[in] report User callback, to be called when an intersection is encountered.\r\n\t\t\\param[in] shapesType Choose if to raycast against static, dynamic or both types of shape. See #NxShapesType.\r\n\t\t\\param[in] groups Mask used to filter shape objects. See #NxShape::setGroup\r\n\t\t\\param[in] maxDist Max distance to check along the ray for intersecting objects. Range: (0,inf) \r\n\t\t\\param[in] hintFlags Allows the user to specify which field of #NxRaycastHit they are interested in. See #NxRaycastBit\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask\r\n\r\n\t\t\\return the number of shapes hit\r\n\r\n\t\tPlatform:\r\n\t\t\\li PC SW: Yes\r\n\t\t\\li PPU : Yes\r\n\t\t\\li PS3 : Yes\r\n\t\t\\li XB360: Yes\r\n\r\n\t\t@see raycastAnyShape() raycastAllBounds() NxRay NxUserRaycastReport NxShapesType NxShape.setGroup() NxRaycastHit\r\n\t\t*/\r\n\t\tint raycastAllShapes\t\t(const VxRay& worldRay, pShapesType shapesType, int groups=0xffffffff, float maxDist=pFLOAT_MAX, pRaycastBit hintFlags=(pRaycastBit)0xffffffff, const pGroupsMask* groupsMask=NULL);\r\n\r\n\r\n\t\t//@}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t/** @name Overlap Testing\r\n\t\t*/\r\n\t\t//@{\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the set of shapes overlapped by the world-space sphere.\r\n\r\n\t\tYou can test against static and/or dynamic objects by adjusting 'shapeType'. \r\n\t\tShapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'.\r\n\r\n\t\tThe function returns the total number of collided shapes.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediatly visible.\r\n\r\n\t\t\\param[in] worldSphere Sphere description in world space. Range: See #VxSphere\r\n\t\t\\param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #pShapesType.\r\n\t\t\\param[out] shapes Buffer to store intersecting shapes. \r\n\t\t\\param[in] activeGroups Mask used to filter shape objects. See #pRigidBody::setGroup\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t\t\\param[in] accurateCollision True to test the sphere against the actual shapes, false to test against the AABBs only.\r\n\r\n\t\t\\return the total number of collided shapes.\r\n\r\n\r\n\t\t@see pShapesType overlapAABBShapes\r\n\t\t*/\r\n\t\tint\toverlapSphereShapes\t\t(const VxSphere& worldSphere,CK3dEntity*shapeReference,pShapesType shapeType,CKGroup *shapes,int activeGroups=0xffffffff, const pGroupsMask* groupsMask=NULL, bool accurateCollision=false);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the set of shapes overlapped by the world-space AABB.\r\n\r\n\t\tYou can test against static and/or dynamic objects by adjusting 'shapeType'. \r\n\t\tShapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'.\r\n\r\n\t\tThe function returns the total number of collided shapes.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediatly visible.\r\n\r\n\t\t\\param[in] worldBounds Axis Aligned Bounding Box in world space. Range: \r\n\t\t\\param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See pShapesType.\r\n\t\t\\param[out] shapes Buffer to store intersecting shapes. \r\n\t\t\\param[in] activeGroups Mask used to filter shape objects. See #pRigidBody::setGroup\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t\t\\param[in] accurateCollision True to test the AABB against the actual shapes, false to test against the AABBs only.\r\n\r\n\t\t\\return the total number of collided shapes.\r\n\r\n\t\t@see pxShapesType overlapAABBShapes\r\n\t\t*/\r\n\t\tint overlapAABBShapes\t\t(const VxBbox& worldBounds, CK3dEntity*shapeReference, pShapesType shapeType,CKGroup *shapes,int activeGroups=0xffffffff, const pGroupsMask* groupsMask=NULL, bool accurateCollision=false);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the set of shapes overlapped by the world-space OBB.\r\n\r\n\t\tYou can test against static and/or dynamic objects by adjusting 'shapeType'. \r\n\r\n\t\tThe function returns the total number of collided shapes.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediatly visible.\r\n\r\n\t\t\\param[in] worldBox Oriented Bounding Box in world space. Range: See #NxBox\r\n\t\t\\param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType.\r\n\t\t\\param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes.\r\n\t\t\\param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask\r\n\t\t\\param[in] accurateCollision True to test the OBB against the actual shapes, false to test against the AABBs only.\r\n\r\n\t\t\\return the total number of collided shapes.\r\n\r\n\t\t@see pShapesType overlapOBBShapes \r\n\t\t*/\r\n\t\tint\t\t\t\t\t\toverlapOBBShapes\t\t(const VxBbox& worldBox,CK3dEntity*shapeReference, pShapesType shapeType,CKGroup *shapes, int activeGroups=0xffffffff, const pGroupsMask* groupsMask=NULL, bool accurateCollision=false);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the set of shapes overlapped by the world-space capsule.\r\n\r\n\t\tYou can test against static and/or dynamic objects by adjusting 'shapeType'. \r\n\t\tShapes are written to the static array 'shapes', which should be big enough to hold 'nbShapes'.\r\n\t\tAn alternative is to use the ::NxUserEntityReport callback mechanism.\r\n\r\n\t\tThe function returns the total number of collided shapes.\r\n\r\n\t\t\\note Because the SDK double buffers shape state, a shape will not be updated until a simulation step is \r\n\t\ttaken. For example the result of setting the global pose is not immediatly visible.\r\n\r\n\t\t\\param[in] worldCapsule capsule in world space. Range: See #NxCapsule\r\n\t\t\\param[in] shapeType Choose if to intersect with static, dynamic or both types of shape. See #NxShapesType.\r\n\t\t\\param[out] shapes Buffer to store intersecting shapes. Should be at least sizeof(NxShape *) * nbShapes.\r\n\t\t\\param[in] activeGroups Mask used to filter shape objects. See #NxShape::setGroup\r\n\t\t\\param[in] groupsMask Alternative mask used to filter shapes. See #NxShape::setGroupsMask\r\n\t\t\\param[in] accurateCollision True to test the capsule against the actual shapes, false to test against the AABBs only.\r\n\r\n\t\t\\return the total number of collided shapes.\r\n\r\n\t\tPlatform:\r\n\t\t\\li PC SW: Yes\r\n\t\t\\li PPU : Yes\r\n\t\t\\li PS3 : Yes\r\n\t\t\\li XB360: Yes\r\n\r\n\t\t@see pShapesType overlapCapsuleShapes \r\n\t\t*/\r\n\t\t//virtual\tNxU32\t\t\t\t\t\toverlapCapsuleShapes\t\t(const NxCapsule& worldCapsule, NxShapesType shapeType, NxU32 nbShapes, NxShape** shapes, NxUserEntityReport* callback, NxU32 activeGroups=0xffffffff, const NxGroupsMask* groupsMask=NULL, bool accurateCollision=false) = 0;\r\n\r\n\t\t//@}\r\n\r\n\r\n\r\n\r\n\r\n\t\tvoid step(float stepsize);\r\n\t\tbool isValid();\r\n\r\n\t\tJointFeedbackListType m_JointFeedbackList;\r\n\r\n\t\tJointFeedbackListType& getJointFeedbackList() { return m_JointFeedbackList; }\r\n\t\tvoid setJointFeedbackList(JointFeedbackListType val) { m_JointFeedbackList = val; }\r\n\t\tvoid inspectJoints();\r\n\r\n\t\tvoid deleteBody(pRigidBody*body);\r\n\t\tint getNbBodies();\r\n\t\tint getNbJoints();\r\n\t\tvoid checkList();\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\t\tvoid cSetGroupCollisionFlag(int g1 , int g2,int enabled);\r\n\t\tvoid cIgnorePair(CK3dEntity* _a,CK3dEntity *_b,int ignore);\r\n\r\n\r\n\t\tvoid initUserReports();\r\n\t\tpContactReport *contactReport;\r\n\t\tpContactReport*getContactReportPtr(){ return contactReport;}\r\n\r\n\t\tpContactModify *contactModify;\r\n\t\tpContactModify*getContactModifyPtr(){ return contactModify;}\r\n\r\n\t\tpTriggerReport *triggerReport;\r\n\t\tpTriggerReport *getTriggerReportPtr(){ return triggerReport;}\r\n\r\n\t\tpRayCastReport *raycastReport;\r\n\t\tpRayCastReport * getRaycastReport(){ return raycastReport; }\r\n\t\tvoid setRaycastReport(pRayCastReport * val) { raycastReport = val; }\r\n\t\t\r\n\t\tUserAllocator*\tmAllocator;\r\n\t\t\r\n\t\tUserAllocator* setAllocator() const { return mAllocator; }\r\n\t\tvoid setAllocator(UserAllocator* val) { mAllocator= val; }\r\n\r\n\t\tint getNbOfVehicles();\r\n\t\tint getNbOfWhees();\r\n\r\n\r\n\tpublic :\r\n\r\n\t\tCK3dEntity* m_vtReference;\r\n\r\n\t\tpSleepingSettings *m_SleepingSettings;\r\n\t\tpWorldSettings *m_worldSettings;\r\n\r\n\t\tNxScene*\t\t\tmScene;\r\n\t\tNxMaterial* mDefaultMaterial;\r\n\t\tNxControllerManager *mCManager;\r\n\t\t\r\n\t\t\r\n\r\n\t\tvoid updateVehicles(float dt);\r\n\t\tvoid updateVehicle(pVehicle *vehicle,float dt);\r\n\t\tpVehicle *getVehicle(CK3dEntity* body);\r\n\t\tvoid deleteVehicle(CK3dEntity*body,int flags = 0);\r\n\t\tbool isVehicle(NxActor* actor);\r\n\t\tpWheel1 *getWheel1(CK3dEntity *reference);\r\n\t\tpWheel2 *getWheel2(CK3dEntity *reference);\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\t\tvoid updateClothes();\r\n\t\tvoid updateFluids();\r\n\r\n\r\n\r\n\t\tpCloth *getCloth(CK3dEntity*reference);\r\n\t\tpCloth *getCloth(CK_ID id);\r\n\t\tvoid destroyCloth(CK_ID id);\r\n\r\n\r\n\t\tpFluid *getFluid(CK_ID id);\r\n\t\tpFluid *getFluid(CK3dEntity* entity);\r\n\r\n\r\n\t\tNxShape *getShapeByEntityID(CK_ID id);\r\n\t\tNxShape *getShapeByMeshID(CK_ID id);\r\n\r\n\t\tNxControllerManager * getCManager() const { return mCManager; }\r\n\t\tvoid setCManager(NxControllerManager * val) { mCManager = val; }\r\n\r\n\r\n\t\tvoid advanceTime(float lastDeltaMS);\r\n\t\tint onPreProcess();\r\n\t\tint onPostProcess();\r\n\r\n\t\tint callMask;\r\n\t\tint& getCallMask() { return callMask; }\r\n\t\tvoid setCallMask(int val) { callMask = val; }\r\n\r\n\t\tint overrideMask;\r\n\t\tint& getOverrideMask() { return overrideMask; }\r\n\t\tvoid setOverrideMask(int val) { overrideMask = val; }\r\n\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// material \r\n\t\t//\r\n\t\tbool getMaterialByIndex(int index,pMaterial&dst);\r\n\t\tbool updateMaterialByIndex(int index,pMaterial src);\r\n\r\n\r\n\t\t//---common settings \r\n\r\n\t\tvoid setGravity(VxVector gravity);\r\n\t\tVxVector getGravity();\r\n\r\n\t\tint m_DataFlags;\r\n\t};\r\n\r\n/** @} */\r\n\r\n#endif // !defined(EA_0976AF4F_8E4B_4e7b_B4CD_B7588D3D4FF8__INCLUDED_)\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSGetListObjectDecl();\r\nCKERROR CreateNSGetListObjectProto(CKBehaviorPrototype **);\r\nint NSGetListObject(const CKBehaviorContext& behcontext);\r\nCKERROR NSGetListObjectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 5\r\n#define BEH_OUT_MIN_COUNT 10\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_NEXT\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_SESSION_TYPE,\r\n\tBB_IP_LIST_FULL,\r\n\tBB_IP_LIST_PRIVATE,\r\n\tBB_IP_LIST_LOCKED,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_WAITING,\r\n\tBB_O_ERROR,\r\n\tBB_O_SESSION\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_SESSIONS,\r\n\tBB_OP_SESSION_ID,\r\n BB_OP_SESSION_NAME,\r\n\tBB_OP_SESSION_MASTER,\r\n\tBB_OP_SESSION_USERS,\r\n\tBB_OP_SESSION_MAX_PLAYERS,\r\n\tBB_OP_SESSION_FULL,\r\n\tBB_OP_SESSION_PRIVATE,\r\n\tBB_OP_SESSION_LOCKED,\r\n\tBB_OP_ERROR\r\n\r\n};\r\n\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSGetListObjectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSGetList\");\t\r\n\tod->SetDescription(\"Iterates through all server sessions\");\r\n\r\n\tod->SetCategory(\"TNL/Sessions\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x16760924,0x29200470));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNSGetListObjectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNSGetListObjectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSGetList\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Waiting For Answer\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\tproto->DeclareOutput(\"Session\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Session Type\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareInParameter(\"List Full Sessions\", CKPGUID_BOOL, \"TRUE\");\r\n\tproto->DeclareInParameter(\"List Private Sessions\", CKPGUID_BOOL, \"TRUE\");\r\n\tproto->DeclareInParameter(\"List Locked Sessions\", CKPGUID_BOOL, \"TRUE\");\r\n\t\r\n\r\n\r\n\r\n\tproto->DeclareOutParameter(\"Sessions\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Session ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Session Name\", CKPGUID_STRING, \"\");\r\n\tproto->DeclareOutParameter(\"Session Master\", CKPGUID_STRING, \"\");\r\n\tproto->DeclareOutParameter(\"Users\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Max Players\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Full\", CKPGUID_BOOL, \"FALSE\");\r\n\tproto->DeclareOutParameter(\"Private\", CKPGUID_BOOL, \"FALSE\");\r\n\tproto->DeclareOutParameter(\"Locked\", CKPGUID_BOOL, \"FALSE\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\t\r\n\tproto->DeclareLocalParameter(\"current result\", CKPGUID_POINTER, \"0\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS));\r\n\tproto->SetFunction(NSGetListObject);\r\n\tproto->SetBehaviorCallbackFct(NSGetListObjectCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\ntypedef std::vectorxSessions;\r\n#include \"vtLogTools.h\"\r\n\r\n\r\n\r\nint NSGetListObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id + session name : \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tint connectionID = GetInputParameterValue(beh,0);\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbbNoError(E_NWE_OK);\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we reset our session counter\r\n\t\tint sessionIndex=-1;\r\n\t\tbeh->SetOutputParameterValue(BB_OP_SESSIONS,&sessionIndex);\r\n\r\n\r\n\t\txSessions *sResults = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\r\n\t\t{\r\n\t\t\tsResults = new xSessions();\r\n\t\t}else\r\n\t\t\tsResults->clear();\r\n\r\n\t\tbeh->SetLocalParameterValue(0,&sResults);\r\n\r\n\r\n\t\tint sessionType = GetInputParameterValue(beh,BB_IP_SESSION_TYPE);\r\n\t\tint listFull = GetInputParameterValue(beh,BB_IP_LIST_FULL);\r\n\t\tint listPrivate = GetInputParameterValue(beh,BB_IP_LIST_PRIVATE);\r\n\t\tint listLocked = GetInputParameterValue(beh,BB_IP_LIST_LOCKED);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we iterate though all session objects and add it in a filtered temporary array : \r\n\t\tISession *sInterface = cin->getSessionInterface();\r\n\t\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\t\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\t\txDistObjectIt begin = distObjects->begin();\r\n\t\txDistObjectIt end = distObjects->end();\r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\txDistributedObject* dobj = *begin;\r\n\t\t\tif (dobj)\r\n\t\t\t{\r\n\t\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\r\n\t\t\t\tif (_class)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedSession *session = static_cast(dobj);\r\n\t\t\t\t\t\tif (session && session->getSessionFlags().test(1<< E_SF_COMPLETE ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ( session->isPrivate() && !listPrivate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tbegin++;\r\n\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif ( session->isLocked() && !listLocked)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tbegin++;\r\n\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif ( session->isFull() && !listFull)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tbegin++;\r\n\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tsResults->push_back(session);\r\n \r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbegin++;\r\n\t\t}\r\n\t\tif (sResults->size())\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(1);\r\n\t\t}else\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(BB_O_OUT);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\r\n\t\t\r\n\t\tint currentIndex=0;\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_SESSIONS);\t\tpout->GetValue(&currentIndex);\r\n\t\tcurrentIndex++;\r\n\t\t\r\n\r\n\t\t\r\n\t\txSessions *sResults = NULL;\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\t\t{\t\t\tbeh->ActivateOutput(BB_O_OUT);\t\t\treturn 0;\t\t}\r\n\r\n\t\tif (currentIndex>=sResults->size())\r\n\t\t{\r\n\t\t\tsResults->clear();\r\n\t\t\tbeh->ActivateOutput(BB_O_OUT);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\txDistributedSession * session = sResults->at(currentIndex);\r\n\t\tif (session!=NULL)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tint sIndex = currentIndex+1;\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSIONS,&sIndex);\r\n\r\n\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* output bas data : */\r\n\t\t\t/************************************************************************/\r\n\t\t\tint sessionID = session->getSessionID();beh->SetOutputParameterValue(BB_OP_SESSION_ID,&sessionID);\r\n\t\t\t\r\n\t\t\tCKSTRING sesssionName = const_cast(session->GetName().getString());\r\n\t\t\tCKParameterOut *poutName = beh->GetOutputParameter(BB_OP_SESSION_NAME);\r\n\t\t\tpoutName->SetStringValue(sesssionName);\r\n\r\n\t\t\tint maxPlayers = session->getMaxUsers();\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_MAX_PLAYERS,&maxPlayers);\r\n\r\n\t\t\tint isFull = session->isFull();\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_FULL,&isFull);\r\n\r\n\t\t\tint isPrivate = session->isPrivate();\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_PRIVATE,&isPrivate);\r\n\r\n\t\t\tint isLocked = session->isLocked();\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_LOCKED,&isLocked);\r\n\r\n\t\t\tint numUsers = session->getNumUsers();\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_USERS,&numUsers);\r\n\r\n\t\t\tbeh->SetOutputParameterValue(BB_OP_SESSIONS,&currentIndex);\r\n\t\t\tbeh->ActivateOutput(BB_O_SESSION);\r\n\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/*output additional properties */\r\n\t\t\t/************************************************************************/\r\n\r\n\t\t\tif ( beh->GetOutputParameterCount() > BEH_OUT_MIN_COUNT )\r\n\t\t\t{\r\n\t\t\t\txDistributedSessionClass *_class = (xDistributedSessionClass*)session->getDistributedClass();\r\n\r\n\t\t\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\t\t\tfor (int i = BEH_OUT_MIN_COUNT ; i < beh->GetOutputParameterCount() ; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameterOut *ciIn = beh->GetOutputParameter(i);\r\n\t\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\t\txDistributedPropertyArrayType &props = *session->getDistributedPorperties();\r\n\r\n\t\t\t\t\tint propID = _class->getInternalUserFieldIndex(i - BEH_OUT_MIN_COUNT);\r\n\t\t\t\t\tint startIndex = _class->getFirstUserField();\r\n\t\t\t\t\tint pSize = props.size();\r\n\t\t\t\t\tif (propID==-1 || propID > props.size() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(BB_O_ERROR);\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\txDistributedProperty *prop = props[propID];\r\n\t\t\t\t\tif (prop)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t//we set the update flag in the prop by hand : \r\n\t\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\t\tif (propInfo)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\r\n\t\t\t\t\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tVxVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tfloat vvalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\txDistributedPoint2F * dpoint3F = (xDistributedPoint2F*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tVx2DVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tVxQuaternion vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\txDistributedString * propValue = (xDistributedString*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tTNL::StringPtr ovalue = propValue->mCurrentValue;\r\n\t\t\t\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(i);\r\n\t\t\t\t\t\t\t\t\t\t\tXString errorMesg(ovalue.getString());\r\n\t\t\t\t\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\txDistributedInteger * dpoint3F = (xDistributedInteger*)prop;\r\n\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tint ovalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&ovalue);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_UNKNOWN:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nCKERROR NSGetListObjectCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARToolKitPlusLogger\r\n// --------------------------------------\r\n//\r\n// Description:\r\n// Little helper class which encapsulate the error logging\r\n// (look into ARToolKitPlus for description)\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: Not really integrated into Virtools, just a dummy call\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n#ifndef ARToolKitPlusLogger_H\r\n#define ARToolKitPlusLogger_H \"$Id:$\"\r\n\r\n#include \r\n\r\nclass ARToolKitLogger : public ARToolKitPlus::Logger\r\n{\r\n void artLog(const char* nStr)\r\n\t{\r\n\t\tprintf(nStr);\r\n\t}\r\n};\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n#include \r\n\r\nvoid pRigidBody::updateMaterialSettings(pMaterial& material,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\tif (shapeReference==NULL)\r\n\t\tassert (getMainShape());\r\n\r\n\tNxShape *shape = getSubShape(shapeReference);\r\n\tif (shape)\r\n\t{\r\n\r\n\t\tpMaterial &bMaterial = material;\r\n\t\tif (bMaterial.xmlLinkID !=0)\r\n\t\t{\r\n\t\t\tint bIndex = bMaterial.xmlLinkID;\r\n\t\t\tXString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,bMaterial.xmlLinkID);\r\n\t\t\tbool err = pFactory::Instance()->loadFrom(bMaterial,nodeName.Str(), pFactory::Instance()->getDefaultDocument() );\r\n\t\t}\r\n\t\tiAssertW( bMaterial.isValid(),pFactory::Instance()->findSettings(bMaterial,shapeReference),\r\n\t\t\t\t\"Material settings invalid, try to find material attributes\");\r\n\r\n\t\tiAssertW( bMaterial.isValid(),bMaterial.setToDefault(),\r\n\t\t\t\t\"Material settings were still invalid : \");\r\n\r\n\t\tNxMaterialDesc nxMatDescr;\r\n\t\tpFactory::Instance()->copyTo(nxMatDescr,bMaterial);\r\n\t\tNxMaterial *nxMaterial = getWorld()->getScene()->createMaterial(nxMatDescr);\r\n\t\tif (nxMaterial)\r\n\t\t{\r\n\t\t\tshape->setMaterial(nxMaterial->getMaterialIndex());\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::updatePivotSettings(pPivotSettings pivot,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\tif (shapeReference==NULL)\r\n\t\tassert (getMainShape());\r\n\r\n\tNxShape *shape = getSubShape(shapeReference);\r\n\tif (shape)\r\n\t{\r\n \r\n\t\t// Referential\r\n\t\tCK3dEntity* pivotRef = (CK3dEntity*)GetPMan()->GetContext()->GetObject(pivot.pivotReference);\r\n\r\n\t\tVxVector pivotLocalOut = pivot.localPosition;\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// position\r\n\t\t//\r\n\t\tif (pivotRef)\r\n\t\t{\r\n\t\t\tpivotRef->Transform(&pivotLocalOut,&pivotLocalOut);\r\n\t\t\tshape->setGlobalPosition(getFrom(pivotLocalOut));\r\n\t\t}else\r\n\t\t{\r\n\t\t\tshape->setLocalPosition(getFrom(pivotLocalOut));\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// rotational offset : todo\r\n\t\t//\r\n\t\tVxMatrix mat;\r\n\t\tVx3DMatrixFromEulerAngles(mat,pivot.localOrientation.x,pivot.localOrientation.y,pivot.localOrientation.z);\r\n\r\n\t\tVxQuaternion outQuat;\r\n\t\toutQuat.FromMatrix(mat);\r\n\t\tVxQuaternion referenceQuat=outQuat;\r\n\t\tif (pivotRef)\r\n\t\t{\r\n\t\t\tpivotRef->GetQuaternion(&referenceQuat,NULL);\r\n\t\t\tshape->setLocalOrientation(getFrom(referenceQuat));\r\n\t\t}else{\r\n\r\n\t\t\tshape->setLocalOrientation(getFrom(outQuat));\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::saveToAttributes(pObjectDescr* oDescr)\r\n{\r\n\tif (!oDescr)\r\n\t\treturn;\r\n\t\t\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\tint attTypeActor = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\tint attTypeMaterial = GetPMan()->getAttributeTypeByGuid(VTS_MATERIAL);\r\n\tint attTypeOptimization = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR_OPTIMIZATION);\r\n\tint attTypeCCD = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CCD_SETTINGS);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// disable attribute callback \r\n\t//\r\n\tCKAttributeManager *aMan = GetPMan()->GetContext()->GetAttributeManager();\r\n\tif (aMan)\r\n\t{\r\n\t\t//aMan->SetAttributeCallbackFunction(attTypeActor)\r\n\t}\r\n\r\n\tCK3dEntity *referenceObject = GetVT3DObject();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we remove the old physic attribute : \r\n\tif (referenceObject->HasAttribute(attTypeActor))\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(attTypeActor);\r\n\t}\r\n\treferenceObject->SetAttribute(attTypeActor);\r\n\r\n\tCKParameterOut* actorAttribute = referenceObject->GetAttributeParameter(attTypeActor);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Common Settings\r\n\t//\r\n\tCKParameterOut *parBCommon = GetParameterFromStruct(actorAttribute,PS_COMMON_SETTINGS);\r\n\tif (parBCommon)\r\n\t{\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_HULL_TYPE,oDescr->hullType);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_FLAGS,oDescr->flags);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_DENSITY,oDescr->density);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_WORLD,oDescr->worlReference);\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision Setting\r\n\t//\r\n\tCKParameterOut *parBCollision = GetParameterFromStruct(actorAttribute,PS_COLLISION_SETTINGS);\r\n\tCKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK);\r\n\tif (parBCollision)\r\n\t{\r\n\t\tSetParameterStructureValue(parBCollision,PS_BC_GROUP,oDescr->collisionGroup);\r\n\t\tSetParameterStructureValue(parBCollision,PS_BC_SKINWITDH,oDescr->skinWidth);\r\n\r\n\t\tif (parGroupsMask)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parGroupsMask,0,oDescr->groupsMask.bits0);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,1,oDescr->groupsMask.bits1);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,2,oDescr->groupsMask.bits2);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,3,oDescr->groupsMask.bits3);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Optimization\r\n\t//\r\n\tif (oDescr->mask & OD_Optimization)\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeOptimization))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeOptimization);\r\n\t\t}\r\n\r\n\t\treferenceObject->SetAttribute(attTypeOptimization);\r\n\r\n\t\t\r\n\t\tCKParameterOut *parBOptimization = referenceObject->GetAttributeParameter(attTypeOptimization);\r\n\t\tif (parBOptimization)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_LOCKS,oDescr->optimization.transformationFlags);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_SOLVER_ITERATIONS,oDescr->optimization.solverIterations);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_DOMINANCE_GROUP,oDescr->optimization.dominanceGroup);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_COMPARTMENT_ID,oDescr->optimization.compartmentGroup);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// sleeping\r\n\t\t//\r\n\t\tCKParameterOut *parBSleeping = GetParameterFromStruct(parBOptimization,PS_BO_SLEEPING);\r\n\t\tif (parBSleeping)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_ANGULAR_SLEEP,oDescr->optimization.angSleepVelocity);\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_LINEAR_SLEEP,oDescr->optimization.linSleepVelocity);\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_THRESHOLD,oDescr->optimization.sleepEnergyThreshold);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// damping\r\n\t\t//\r\n\t\tCKParameterOut *parBDamping = GetParameterFromStruct(parBOptimization,PS_BO_DAMPING);\r\n\t\tif (parBDamping)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBDamping,PS_BD_ANGULAR,oDescr->optimization.angDamping);\r\n\t\t\tSetParameterStructureValue(parBDamping,PS_BD_LINEAR,oDescr->optimization.linDamping);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// CCD\r\n\t//\r\n\tif (oDescr->mask & OD_CCD )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeCCD))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeCCD);\r\n\t\t}\r\n\t\t\r\n\t\treferenceObject->SetAttribute(attTypeCCD);\r\n\r\n\t\tCKParameterOut *parBCCD = referenceObject->GetAttributeParameter(attTypeCCD);\r\n\t\tif (parBCCD)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_MOTION_THRESHOLD,oDescr->ccd.motionThresold);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_FLAGS,oDescr->ccd.flags);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_SCALE,oDescr->ccd.scale);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_MESH_REFERENCE,oDescr->ccd.meshReference);\r\n\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Material\r\n\t//\r\n\tif (oDescr->mask & OD_Material )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeMaterial))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeMaterial);\r\n\t\t}\r\n\r\n\t\treferenceObject->SetAttribute(attTypeMaterial);\r\n\r\n\t\tCKParameterOut *parBMaterial = referenceObject->GetAttributeParameter(attTypeMaterial);\r\n\t\tif (parBMaterial)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(parBMaterial,oDescr->material);\r\n\t\t}\r\n\t}\r\n\r\n\r\n }\r\n\r\n\r\n\r\n void pRigidBody::updateOptimizationSettings(pOptimization optimization)\r\n{\r\n\t\r\n\tlockTransformation(optimization.transformationFlags);\r\n\tsetSolverIterationCount(optimization.solverIterations);\r\n\tgetActor()->setDominanceGroup(optimization.dominanceGroup);\r\n\tsetAngularDamping(optimization.angDamping);\r\n\tsetLinearDamping(optimization.linDamping);\r\n\tsetSleepAngularVelocity(optimization.angSleepVelocity);\r\n\tsetSleepLinearVelocity(optimization.linSleepVelocity);\r\n\tsetSleepEnergyThreshold(optimization.sleepEnergyThreshold);\r\n}\r\nvoid pRigidBody::setSleepAngularVelocity(float threshold)\r\n{\r\n\tgetActor()->setSleepAngularVelocity(threshold);\r\n\r\n}\r\nvoid pRigidBody::setSleepLinearVelocity(float threshold)\r\n{\r\n\tgetActor()->setSleepLinearVelocity(threshold);\r\n}\r\nvoid pRigidBody::setSleepEnergyThreshold(float threshold)\r\n{\r\n\tgetActor()->setSleepEnergyThreshold(threshold);\r\n}\r\n\r\nvoid pRigidBody::setDominanceGroup(int dominanceGroup)\r\n{\r\n\tgetActor()->setDominanceGroup(dominanceGroup);\r\n}\r\n\r\nvoid pRigidBody::setSolverIterationCount(int count)\r\n{\r\n\r\n\t\r\n\r\n\tif (getActor())\r\n\t{\r\n\t\tif (count > 0)\r\n\t\t{\r\n\t\t\tgetActor()->setSolverIterationCount(count);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::checkForOptimization()\r\n{\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR_OPTIMIZATION);\r\n\tCK3dEntity *ent = (CK3dEntity*)ctx()->GetObject(mEntID);\r\n\tif ( !ent )\r\n\t\treturn;\r\n\r\n\tif (!ent->HasAttribute(att)) \r\n\t\treturn;\r\n\r\n\r\n\r\n\tCKParameterOut *optPar = ent->GetAttributeParameter(att);\r\n\tif(!optPar)\r\n\t\treturn;\r\n\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tLock transformation degrees :\r\n\t//\r\n\tint transformationlockFlags = GetValueFromAttribute(ent,att,PS_BO_LOCKS);\r\n\tlockTransformation(transformationlockFlags);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tDamping\r\n\t//\r\n\tCKParameterOut * dampPar= GetParameterFromStruct(optPar,PS_BO_DAMPING);\r\n\r\n\tfloat linDamp = GetValueFromParameterStruct(dampPar,PS_BD_LINEAR);\r\n\tfloat angDamp = GetValueFromParameterStruct(dampPar,PS_BD_ANGULAR);\r\n\tif ( linDamp !=0.0f)\r\n\t\tsetLinearDamping(linDamp);\r\n\r\n\tif ( angDamp!=0.0f)\r\n\t\tsetAngularDamping(angDamp);\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tSleeping Settings\r\n\t//\r\n\r\n\tCKParameterOut * sleepPar= GetParameterFromStruct(optPar,PS_BO_SLEEPING);\r\n\tfloat linSleep = GetValueFromParameterStruct(dampPar,PS_BS_LINEAR_SLEEP);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tSolver Iterations \r\n\t//\r\n\t//CKParameterOut * sleepPar= GetParameterFromStruct(optPar,);\r\n\tint solverIterations = GetValueFromParameterStruct(optPar,PS_BO_SOLVER_ITERATIONS);\r\n\tif (solverIterations !=0)\r\n\t{\r\n\t\tsetSolverIterationCount(solverIterations);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// Dominance \r\n\t//\r\n\tint dGroup = GetValueFromParameterStruct(optPar,PS_BO_DOMINANCE_GROUP);\r\n\tif (dGroup!=0)\r\n\t{\r\n\t\tgetActor()->setDominanceGroup(dGroup);\r\n\t}\r\n\r\n\r\n\r\n}\r\nvoid pRigidBody::checkDataFlags()\r\n{\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tint att = GetPMan()->GetPAttribute();\r\n\tint att_damping = GetPMan()->att_damping;\r\n\tint att_ss = GetPMan()->att_sleep_settings;\r\n\tint att_surface =GetPMan()->att_surface_props;\r\n\tint att_deformable =GetPMan()->att_deformable;\r\n\r\n\txBitSet& dFlags = getDataFlags();\r\n\tCK3dEntity *ent = GetVT3DObject();\r\n\r\n\tif (!ent)\t{\t\treturn;\t}\r\n\r\n\tif (ent->HasAttribute(att_surface))\r\n\t\tenableFlag(dFlags,EDF_MATERIAL_PARAMETER);\r\n\telse\t\tdisableFlag(dFlags,EDF_MATERIAL_PARAMETER);\r\n\r\n\tif (ent->HasAttribute(att_damping))\r\n\t\tenableFlag(dFlags,EDF_DAMPING_PARAMETER);\r\n\telse\tdisableFlag(dFlags,EDF_DAMPING_PARAMETER);\r\n\r\n\tif (ent->HasAttribute(att_ss))\r\n\t\tenableFlag(dFlags,EDF_SLEEPING_PARAMETER);\r\n\telse disableFlag(dFlags,EDF_SLEEPING_PARAMETER);\r\n\r\n\tif (ent->HasAttribute(att_deformable))\r\n\t\tenableFlag(dFlags,EDF_DEFORMABLE_PARAMETER);\r\n\telse disableFlag(dFlags,EDF_DEFORMABLE_PARAMETER);\r\n\r\n\r\n\tif (ent->HasAttribute( GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR_OPTIMIZATION) ))\r\n\t\tenableFlag(dFlags,EDF_OPTIMIZATION_PARAMETER);\r\n\telse disableFlag(dFlags,EDF_OPTIMIZATION_PARAMETER);\r\n\r\n}\r\nvoid pRigidBody::destroy()\r\n{\r\n\tif(!getActor())\r\n\t\treturn;\r\n\r\n\tNxU32 nbShapes = getActor()->getNbShapes();\r\n\r\n\r\n\t/*\r\n\tCKSTRING name = GetVT3DObject()->GetName();\r\n\twhile(nbShapes )\r\n\t{\r\n\r\n\tNxShape *s = ((NxShape **)getActor()->getShapes())[0];\r\n\tpSubMeshInfo *sinfo = static_cast(s->userData);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\t\tWheel attached !\r\n\tif (sinfo && s->isWheel() && sinfo->wheel )\r\n\t{\r\n\tpWheel2 *wheel = (pWheel2*)sinfo->wheel;\r\n\tdelete wheel;\r\n\twheel = NULL;\r\n\tsinfo->wheel =NULL;\r\n\t}\r\n\r\n\tif (sinfo)\r\n\t{\r\n\tdelete sinfo;\r\n\tsinfo = NULL;\r\n\t}\r\n\r\n\ts->userData = NULL;\r\n\r\n\tif (getActor()->isDynamic() || (\t!getActor()->isDynamic() && nbShapes >1 )\t)\r\n\t{\r\n\tgetActor()->releaseShape(*s);\r\n\ts=NULL;\r\n\tdestroy();\r\n\t}break;\r\n\t}\r\n\r\n\t*/\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tpVehicle *v = getVehicle();\r\n\tif ( v )\r\n\t{\r\n\t\tgetVehicle()->getWheels().clear();\r\n\t\tgetVehicle()->setActor(NULL);\r\n\t\tgetVehicle()->setBody(NULL);\r\n\r\n\t\tdelete v;\r\n\t\tsetVehicle(NULL);\r\n\t}\r\n\r\n\tpCloth *cloth = getCloth();\r\n\tif (cloth)\r\n\t{\r\n\t\tcloth->releaseReceiveBuffers();\r\n\t\tgetActor()->getScene().releaseCloth(*cloth->getCloth());\r\n\t}\r\n\tgetActor()->getScene().releaseActor(*getActor());\r\n\tsetActor(NULL);\r\n}\r\n\r\nint pRigidBody::getTransformationsLockFlags()\r\n{\r\n\r\n\tint result = 0 ; \r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_POS_X))result|=NX_BF_FROZEN_POS_X;\r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_POS_Y))result|=NX_BF_FROZEN_POS_Y;\r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_POS_Z))result|=NX_BF_FROZEN_POS_Z;\r\n\r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_ROT_X))result|=NX_BF_FROZEN_ROT_X;\r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_ROT_Y))result|=NX_BF_FROZEN_ROT_Y;\r\n\tif (getActor()->readBodyFlag(NX_BF_FROZEN_ROT_Z))result|=NX_BF_FROZEN_ROT_Z;\r\n\r\n\treturn result;\r\n\r\n}\r\nvoid pRigidBody::lockTransformation(int flags)\r\n{\r\n\r\n\t\r\n\tif (getActor() && getActor()->isDynamic())\r\n\t{\r\n\t\tif (flags & NX_BF_FROZEN_POS_X)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_POS_X);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_POS_X);\r\n\r\n\r\n\t\tif (flags & NX_BF_FROZEN_POS_Y)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_POS_Y);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_POS_Y);\r\n\r\n\t\tif (flags & NX_BF_FROZEN_POS_Z)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_POS_Z);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_POS_Z);\r\n\r\n\r\n\t\tif (flags & NX_BF_FROZEN_ROT_X)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_ROT_X);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_ROT_X);\r\n\r\n\t\tif (flags & NX_BF_FROZEN_ROT_Y)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_ROT_Y);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_ROT_Y);\r\n\r\n\t\tif (flags & NX_BF_FROZEN_ROT_Z)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_FROZEN_ROT_Z);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_FROZEN_ROT_Z);\r\n\t}\r\n}\r\nbool pRigidBody::isSleeping()const\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\treturn getActor()->isSleeping();\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nvoid pRigidBody::setSleeping(bool sleeping)\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\tif (sleeping)\r\n\t\t{\r\n\t\t\tgetActor()->putToSleep();\r\n\t\t}else{\r\n\t\t\tgetActor()->wakeUp();\r\n\t\t}\r\n\t}\r\n}\r\nvoid pRigidBody::enableGravity(bool enable)\r\n{\r\n\r\n\tif (getActor())\r\n\t{\r\n\t\tif (!enable)\r\n\t\t{\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t\t}else{\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nbool pRigidBody::isAffectedByGravity()const\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\treturn !getActor()->readBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t}\r\n\treturn false;\r\n}\r\nvoid pRigidBody::setKinematic(bool enabled)\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\tif (enabled)\r\n\t\t\tgetActor()->raiseBodyFlag(NX_BF_KINEMATIC);\r\n\t\telse\r\n\t\t\tgetActor()->clearBodyFlag(NX_BF_KINEMATIC);\r\n\t}\r\n}\r\nbool pRigidBody::isKinematic()const\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\treturn getActor()->readBodyFlag(NX_BF_KINEMATIC);\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nbool pRigidBody::isValid()const { \t\r\n\t\r\n\treturn GetPMan()->GetContext()->GetObject(getEntID()) ? true : false && getActor() ? true : false;\r\n}\r\nint pRigidBody::getHullType(){\t\treturn m_HullType;}\r\nvoid pRigidBody::setHullType(int _type){ \tm_HullType= _type;}\r\nvoid pRigidBody::recalculateFlags(int _flags)\r\n{\r\n\tif (!isValid())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tint current = m_sFlags;\r\n\r\n\tif (getActor()->isDynamic() && !getActor()->readBodyFlag(NX_BF_DISABLE_GRAVITY))\r\n\t{\r\n\t\tcurrent |=BF_Gravity;\r\n\t}\r\n\r\n\r\n\tif (!getActor()->readActorFlag(NX_AF_DISABLE_COLLISION))\r\n\t{\r\n\t\tcurrent |=BF_Collision;\r\n\t}\r\n\r\n\tif (getActor()->isSleeping())\r\n\t{\r\n\t\tcurrent |=BF_Sleep;\r\n\t}\r\n\r\n\tif (getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH )\r\n\t{\r\n\t\tcurrent |=BF_CollisionNotify;\r\n\t}\r\n\r\n\tif (isKinematic())\r\n\t{\r\n\t\tcurrent |=BF_Kinematic;\r\n\t}\r\n\t\r\n\tm_sFlags = current;\r\n}\r\n\r\nvoid pRigidBody::updateFlags( int _flags,CK3dEntity*shapeReference/*=NULL*/ )\r\n{\r\n\r\n\tif (!isValid())return;\r\n\r\n\tsetKinematic(_flags & BF_Kinematic);\r\n\tenableCollision(_flags & BF_Collision,shapeReference);\r\n\tenableCollisionsNotify(_flags & BF_CollisionNotify);\r\n\tenableGravity(_flags & BF_Gravity);\r\n\tsetSleeping(_flags & BF_Sleep);\r\n\tenableTriggerShape(_flags & BF_TriggerShape,shapeReference);\r\n\tm_sFlags |=_flags;\r\n\r\n}\r\n\r\nint pRigidBody::getFlags(){\t\r\n\t\r\n\treturn m_sFlags;;\r\n}\r\nvoid pRigidBody::setFlags(int _flags){\tm_sFlags = _flags;}\r\nvoid pRigidBody::retrieveSettingsFromAttribute()\r\n{\r\n\r\n\tassert(getWorld());\r\n\tassert(getWorld()->getScene());\r\n\tassert(getWorld()->getReference());\r\n\tassert(GetVT3DObject());\r\n\t\r\n\tusing namespace vtTools::AttributeTools;\r\n\tsetDataFlags(0x000);\r\n\r\n\tint att = GetPMan()->GetPAttribute();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//\tOld version \r\n\t//\r\n\r\n\tCK_ID id = getWorld()->getReference()->GetID();\r\n\tSetAttributeValue(GetVT3DObject(),att,E_PPS_WORLD,&id);\r\n\tsetHullType(GetValueFromAttribute(GetVT3DObject(),att,E_PPS_HULLTYPE));\r\n\r\n\t\r\n\t//Sets some flags like movable , etc...\r\n\tsetFlags(GetValueFromAttribute(GetVT3DObject(),att,E_PPS_BODY_FLAGS));\r\n\tsetDensity(GetValueFromAttribute(GetVT3DObject(),att, E_PPS_DENSITY));\r\n\tsetMassOffset(GetValueFromAttribute(GetVT3DObject(),att, E_PPS_MASS_OFFSET));\r\n\tsetPivotOffset(GetValueFromAttribute(GetVT3DObject(),att, E_PPS_SHAPE_OFFSET));\r\n\tsetSkinWidth(GetValueFromAttribute(GetVT3DObject(),att, E_PPS_SKIN_WIDTH));\r\n\r\n\r\n\r\n}\r\nint pRigidBody::isBodyFlagOn(int flags)\r\n{\r\n\tif (getActor() && getActor()->isDynamic())\r\n\t{\r\n\t\treturn getActor()->readBodyFlag((NxBodyFlag)flags);\r\n\t}\r\n\treturn -1;\r\n}\r\nvoid pRigidBody::wakeUp(float wakeCounterValue/* =NX_SLEEP_INTERVAL */)\r\n{\r\n\tgetActor()->wakeUp(wakeCounterValue);\r\n\r\n}\r\n\r\n\r\n\r\ncopy X:\\ProjectRoot\\svn\\local\\vtPhysX\\Doc\\examples\\*.cmo X:\\ProjectRoot\\svn\\local\\vtPhysX\\Doc\\doxyOutput\\html /y\r\ncopy .\\doxyOutput\\vtPhysX.CHM x:\\ProjectRoot\\vdev\\Documentation\\\r\ncopy .\\doxyOutput\\vtPhysX.chi x:\\ProjectRoot\\vdev\\Documentation\\\r\ndoxygen DoxyfileGraphs.dox\r\ncd doxyOutput\r\nvtPhysX.chm\r\n\r\n\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmod_vtAgeia\\Doc /y\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmodsvn\\Plugins\\vtAgeia\\Documentation /y\r\n\r\n\r\n\r\n\r\n\r\n/*\r\n*****************************************************************\r\n* Copyright © ITI Scotland 2006 \r\n*----------------------------------------------------------------\r\n* Module : $File: //depot/ITITM005/Code/GBLCommon/Managers/Include/GBLTools.h $ \r\n*\r\n* Programmer : $Author: sylvain.le.breton $\r\n* Date : $DateTime: 2006/06/12 18:38:19 $ \r\n*\r\n*----------------------------------------------------------------\r\n*\r\n* Module Summary : Generic Tools for GBL.\r\n*\t\t\tParts :\t+ structures \r\n\t\t\t\t\t\t+ typedefs\r\n\t\t\t\t\t\t+ Enums\r\n\t\t\t\t\t\t+ tools for CKParameter\r\n\t\t\t\t\t\t+ tools for CKBehavior\r\n\r\n*----------------------------------------------------------------\r\n* $Revision: #7 $ \r\n* $Change: 23589 $\r\n*****************************************************************\r\n*/\r\n#ifndef __VT_TOOLS_H\r\n\t#define __VT_TOOLS_H\r\n\r\n#include \"CKAll.h\"\r\n\r\nnamespace vtTools\r\n{\r\n\t/*************************************************************************/\r\n\t/* common enumerations\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/* \t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\tnamespace Enums\r\n\t{\r\n\t\t/*\r\n\t\t\tRepresents a virtools super type.\r\n\t\t\tSee GetVirtoolsSuperType.\r\n\t\t*/\r\n\t\tenum SuperType\r\n\t\t{\r\n\t\t\tvtSTRING = 1,\r\n\t\t\tvtFLOAT = 2,\r\n\t\t\tvtINTEGER = 3,\r\n\t\t\tvtVECTOR = 4,\r\n\t\t\tvtVECTOR2D = 5,\r\n\t\t\tvtCOLOUR = 6,\r\n\t\t\tvtMATRIX = 7,\r\n\t\t\tvtQUATERNION = 8,\r\n\t\t\tvtRECTANGLE\t\t= 9,\r\n\t\t\tvtBOX\t\t= 10,\r\n\t\t\tvtBOOL\t\t= 11,\r\n\t\t\tvtENUMERATION = 12,\r\n\t\t\tvtFLAGS = 13,\r\n\t\t\tvtFile = 14,\r\n\t\t\tvtOBJECT = 16,\r\n\t\t\tvtUNKNOWN = 17\r\n\t\t};\r\n \r\n\t\t/*\tAuthor: gunther.baumgart\r\n\t\t\tRepresents the c++ equivalent for TGBLWidgetType\r\n\t\t\tpm->RegisterNewEnum(EVTWIDGETTYPE,\"EVTWidgetType\",\r\n\t\t\t\"StaticText=1,\r\n\t\t\tTextEdit=2,\r\n\t\t\tCheckButton=4,\r\n\t\t\tPushButton=8,\r\n\t\t\tListBox=16,\r\n\t\t\tComboBox=32,\r\n\t\t\tFileSelector=64,\r\n\t\t\tColorSelector=128\" );\r\n\t\t*/\r\n\r\n\t\tenum EVTWidgetType\r\n\t\t{\r\n\t\t\tEVT_WIDGET_STATIC_TEXT\t\t= 1,\r\n\t\t\tEVT_WIDGET_EDIT_TEXT\t\t\t=2,\r\n\t\t\tEVT_WIDGET_CHECK_BUTTON =3,\r\n\t\t\tEVT_WIDGET_LIST_BOX\t\t\t=5,\r\n\t\t\tEVT_WIDGET_COMBO_BOX\t\t=6,\r\n\t\t\tEVT_WIDGET_FILE_SELECTION\t\t=7,\r\n\t\t\tEVT_WIDGET_COLOR_SELECTION\t=8\r\n\t\t};\r\n\r\n\t\t/*\r\n\r\n\t\t*/\r\n\r\n\t}/* end namespace typedefs */\r\n\r\n\t/*************************************************************************/\r\n\t/* common Structs\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace Structs\r\n\t{\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t/*\r\n\t\t\tParameterInfo is used to describe a virtools parameter type. \r\n\t\t\tExample : Matrix\t = horizontalItems = 4,\r\n\t\t\t\t\t\t\t\t\t\t\t verticalItems = 4\r\n\t\t\t\t\t\t\t\t\t\t\t memberType =vtFLOAT,\r\n\t\t\t\t\t\t\t\t\t\t\t superType= vtMATRIX\r\n\t\t*/\r\n\t\tstruct ParameterInfo\r\n\t\t{\r\n\t\t\tint horizontalItems;\r\n\t\t\tint verticalItems;\r\n\r\n\t\t\tEnums::SuperType superType;\r\n\t\t\tEnums::SuperType memberType;\r\n\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t/*\r\n\t\t\tSGBL_WidgetInfo describes an parameter for using GBLWidgets\r\n\t\t\tGBL-Widgets. \r\n\t\t*/\r\n\t\tstruct WidgetInfo\r\n\t\t{\r\n\t\t\tstruct WidgetInfoItem\r\n\t\t\t{\t\r\n\t\t\t\tEnums::SuperType baseType;\r\n\t\t\t\tEnums::EVTWidgetType widgetType;\t\t//with which widget \r\n\t\t\t\tXString value;\r\n\t\t\t\tXString label;\r\n\r\n\t\t\t};\r\n\t\t\tXArrayitems;\r\n\t\t\tStructs::ParameterInfo parameterInfo;\r\n\t\t};\r\n\t}/* end namespace Structs */\r\n\r\n\t/************************************************************************/\r\n\t/* parameter tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace ParameterTools\t\r\n\t{\r\n\r\n\t\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: IsNumeric()\r\n\t\t*\r\n\t\t* Description :\t\tCheck each character of the string\r\n\t\t\t\t\t\t\t\t\tIf a character at a certain position is not a digit,\r\n\t\t\t\t\t\t\t\t\tthen the string is not a valid natural number\r\n\t\t\r\n\t\t* Parameters :\tchar*Str,r : the string to test\r\n\t\t* Returns : int\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tint IsNumeric(const char* Str,Enums::SuperType superType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterMemberInfo()\r\n\t\t*\r\n\t\t* Description :\tGetParameterMemberInfo returns the type super type of the used structure members.\r\n\t\t\t\t\t\t\t\tExample : vtVECTOR returns vtFLOAT \t\t\t\t\r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t* Returns : CO_EVT_VirtoolsSuperType\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tEnums::SuperType GetParameterMemberInfo(CKContext* context,CKParameterType parameterType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterInfo()\r\n\t\t*\r\n\t\t* Description :\tGetParameterInfo returns an info about a virtools type. \r\n\t\t\t\t\t\t\t\tExample : Vector4D returns :\r\n\t\t\t\t\t\t\t\tresult.horizontalItems = 4 ;\r\n\t\t\t\t\t\t\t\tresult.verticalItems = 1 ;\r\n\t\t\t\t\t\t\t\tresult.memberType = vtFLOAT\r\n\t\t\t\t\t\t\t\tresult.superType = vtQUATERNION; \r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t* Returns : ParameterInfo\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tStructs::ParameterInfo GetParameterInfo(CKContext* context,CKParameterType parameterType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: CreateWidgetInfo()\r\n\t\t*\r\n\t\t* Description :\tCreateWidgetInfo returns an handy info about an parameter type and a\r\n\t\t\t\t\t\t\t\tgiven string value of this parameter.\r\n\r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t\t\t\t\t\t\tXString stringValue,r : the string value of the given type.\r\n\r\n\t\t* Returns : WidgetInfo\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tStructs::WidgetInfo* CreateWidgetInfo(CKContext* context,CKParameterType parameterType,XString stringValue);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetWidgetType()\r\n\t\t*\r\n\t\t* Description :\tGetWidgetType returns the type of the GBLWidget which should used for a \r\n\t\t\t\t\t\t\t\tspecific virtools super type. \r\n\t\t\t\t\t\t\t\tExample : vtBOOL = CheckBox\r\n\t\t\t\t\t\t\t\t\t\t\t\tvtENUMERATION = ComboBox\r\n\t\t*\r\n\t\t* Parameters :\tCO_EVT_VirtoolsSuperType superType, r : the given virtools super type\r\n\t\t* Returns : EWidgetType\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tEnums::EVTWidgetType GetWidgetType(Enums::SuperType superType);\r\n\t\t/*\r\n\t\t *******************************************************************\r\n\t\t * Function: TypeCheckedParameterCopy()\r\n\t\t *\r\n\t\t * Description : Copies the source parameter to a destination parameter. On a type mismatch \r\n\t\t *\t\t\t\t\t\tit tries to copy as string. This also works for nested virtools structures. See \r\n\t\t\t\t\t\t\t\tCO_EVT_VirtoolsSuperType for supported types.\r\n\t\t *\r\n\t\t * Parameters :\tCKParameter*dest,rw : the destination parameter\r\n\t\t\t\t\t\t\t\t\tCKParameter*src,r : the source parameter\r\n\t\t * Returns : bool = true if succesful.\r\n\t\t * todo:: return copied diff\r\n\t\t *\r\n\t\t *******************************************************************\r\n\t\t*/\r\n\t\tint TypeCheckedParameterCopy( CKParameter*dest, CKParameter*src);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterAsString()\r\n\t\t *\r\n\t\t * Description : Returns the string value a CKParameter.\r\n\t\t *\r\n\t\t * Parameters :\tCKParameter*src ,r the given parameter\r\n\t\t \r\n\t\t * Returns : CKSTRING \r\n\t\t *\r\n\t\t *******************************************************************\r\n\t\t */\r\n\t\t CKSTRING GetParameterAsString( CKParameter*src);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: CompareStringRep()\r\n\t\t*\r\n\t\t* Description : This function compares the string representation of the two CKParameters.\r\n\t\t*\r\n\t\t* Parameters :\tCKParameter* valueA,r : the first parameter \r\n\t\t\t\t\t\t\t\tCKParameter* valueB,r : the second parameter \r\n\t\t* Returns : int (like strcmp)\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tint CompareStringRep(CKParameter*valueA, CKParameter*valueB);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetVirtoolsSuperType()\r\n\t\t*\r\n\t\t* Description : GetVirtoolsSuperType returns the base type of a virtools parameter. \r\n\t\t\t\t\t\t\t\tThis is very useful to determine whether a parameter can be used for \r\n\t\t\t\t\t\t\t\tnetwork or a database.\r\n\t\t*\r\n\t\t* Parameters : CKContext *ctx, r : the virtools context\r\n\t\t\t\t\t\t\t\t CKGUID guid, r : the guid of the parameter\r\n\t\t*\r\n\t\t* Returns : CO_EVT_VirtoolsSuperType, \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tEnums::SuperType GetVirtoolsSuperType(CKContext *ctx,const CKGUID guid);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: TypeIsSerializable()\r\n\t\t* Description : Returns true if the given type can be stored as string. \r\n\t\t+ It also checks custom virtools structures recursive.\r\n\t\t+ it checks only\r\n\t\t*\r\n\t\t* Parameters :\t\tCKContext *ctx,\tr : the virtools context\r\n\t\tCKParameterType type,\tr : the type\r\n\t\t* Returns : bool \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tbool TypeIsSerializable(CKContext *ctx,CKParameterType type);\r\n\t\t/*\r\n\t\t\t*******************************************************************\r\n\t\t\t* Function: IsValidStruct()\r\n\t\t\t*\r\n\t\t\t* Description : Like TypeIsSerializable, even checks a custom virtools structure, recursive.\r\n\t\t\t*\r\n\t\t\t* Parameters :\t\tCKContext *ctx,r : the virtools context\r\n\t\t\t\t\t\t\t\t\t\tCKGUID type,r : the type to check\r\n\r\n\t\t\t* Returns : bool\r\n\t\t\t*\r\n\t\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tbool IsValidStruct(CKContext *ctx,CKGUID type);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:SetParameterStructureValue()\r\n\t\t*\r\n\t\t* Description : \tSets a specific value in a custom structure.\r\n\t\t*\r\n\t\t* Parameters : CKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structure\r\n\t\t\t\t\t\t\t\tT value, r : the value.\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : is a void \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplatevoid SetParameterStructureValue(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\r\n\t\t\tT value,\r\n\t\t\tbool update = TRUE\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tassert(par && StructurIndex>=0 );\r\n\t\t\tCK_ID* paramids = (CK_ID*)par->GetReadDataPtr(update);\r\n\t\t\tCKParameterOut *pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\tpout->SetValue(&value);\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:SetParameterStructureValue() \r\n\t\t*\r\n\t\t* Description : This is a template function specialization for CKSTRING.\r\n\t\t*\t\t\t\t\t\tSets a specific value in a custom structure.\r\n\t\t*\t\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structure\r\n\t\t\t\t\t\t\t\tT value, r : the value.\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : is a void \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline void SetParameterStructureValue\r\n\t\t\t(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\r\n\t\t\tCKSTRING value,\r\n\t\t\tbool update\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tassert(par && StructurIndex>=0 );\r\n\t\t\tstatic_cast(par->GetCKContext()->GetObject( static_cast(par->GetReadDataPtr(update))[StructurIndex]))->SetStringValue(value);\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetValueFromParameterStruct()\r\n\t\t*\r\n\t\t* Description : returns a object from a custom structure. \r\n\t\t*\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structures\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : T. \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromParameterStruct(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\t\r\n\t\t\tbool update)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tassert(par && value);\r\n\t\t\tCK_ID* paramids = static_cast(par->GetReadDataPtr(update));\t\r\n\t\t\tCKParameterOut* pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\t\tpout->GetValue(&value); \r\n\t\t\treturn value;\r\n\t\t}\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetValueFromParameterStruct()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKSTRING\r\n\t\t*\t\t\t\t\t\tGets a specific value from custom structure.\r\n\t\t*\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structures\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\r\n\t\t* Returns : CKSTRING. \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKSTRING GetValueFromParameterStruct(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\t\r\n\t\t\tbool update)\r\n\t\t{\r\n\t\t\tassert( par && StructurIndex >=0 );\r\n\t\t\tCK_ID* paramids = static_cast(par->GetReadDataPtr(update));\t\r\n\t\t\tCKParameterOut* pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\tCKSTRING stringValue = static_cast(pout->GetReadDataPtr(update));\r\n\t\t\treturn stringValue;\r\n\r\n\t\t}\r\n\t} /*end namespace virtools parameter tools */\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* building block tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace BehaviorTools\t\r\n\t{\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\tT value ;\r\n\t\t\tbeh->GetInputParameterValue(pos,&value);\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : This is a template function specialization for CKSTRING.\r\n\t\t\t\t\t\t\t Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKSTRING\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKSTRING GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\treturn static_cast(beh->GetInputParameterReadDataPtr(pos));\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKObject* GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\treturn beh->GetInputParameterObject(pos);\r\n\t\t}\r\n\r\n\t\t//todo : parametric log / debug forwarding!!! - > g.baumgart !\r\n\t\t\r\n\t\t\r\n\r\n\t}/* end namespace behavior tools*/\r\n\r\n\r\n\t/**************************************************************************/\r\n\t/* attribute tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace AttributeTools\r\n\t{\r\n\t\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T* GetObjectFromAttribute(CKContext *ctx,CKObject *_e,const int attributeID,const int StructurIndex)\r\n\t\t{\r\n\t\t\tT *value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tCK_ID* paramids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(paramids[StructurIndex]);\r\n\t\t\tvalue = (T*)ctx->GetObject(*(CK_ID*)pout->GetReadDataPtr());\r\n\t\t\treturn value ? value : NULL;\r\n\t\t}\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline void SetAttributeValue(CKObject *_e,const int attributeID,const int StructurIndex,T* value)\r\n\t\t{\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif(pout)\r\n\t\t\t{\r\n\t\t\t\tCK_ID* paramids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\t\tpout = (CKParameterOut*)_e->GetCKContext()->GetObject(paramids[StructurIndex]);\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpout->SetValue(&value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromAttribute(CKBeObject *_e,int attributeID,int StructurIndex)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif (pout)\r\n\t\t\t{\r\n\t\t\t\tCK_ID* paramids = static_cast(pout->GetReadDataPtr());\r\n\t\t\t\tpout = static_cast(_e->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpout->GetValue(&value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromAttribute(CKBeObject *_e,int attributeID)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif (pout)\r\n\t\t\t{\r\n\t\t\t\tpout->GetValue(&value);\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t}\r\n\t\t\r\n\t}/* end namespace attribute tools*/\r\n}\r\n\r\n#endif\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOControlDecl();\r\nCKERROR CreateDOControlProto(CKBehaviorPrototype **);\r\nint DOControl(const CKBehaviorContext& behcontext);\r\nCKERROR DOControlCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOControlDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOControl\");\t\r\n\tod->SetDescription(\"Creates an distributed object\");\r\n\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x59f62787,0x78a73262));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOControlProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDOControlProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOControl\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\r\n\r\n\tproto->DeclareOutput(\"Exit In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"test\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\t\r\n\tproto->DeclareSetting(\"Timeout\", CKPGUID_TIME, \"0\");\r\n\tproto->DeclareLocalParameter(\"elapsed time\", CKPGUID_FLOAT, \"0.0f\");\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DOControl);\r\n\tproto->SetBehaviorCallbackFct(DOControlCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOControl(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object :\r\n\tCK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tif (!obj)\r\n\t{\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\t\tXString errorMesg(\"distributed object creation failed,no network connection !\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tIDistributedObjects*doInterface = cin->getDistObjectInterface();\r\n\r\n\txDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());\r\n\tif (!dobj)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\t\tXString errorMesg(\"There is no such an object\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//reset elapsed time :\r\n\t\tfloat elapsedTime = 0.0f;\r\n\t\tbeh->SetLocalParameterValue(1,&elapsedTime);\r\n\r\n\t\tif (!dobj->isOwner() /*&& !dobj->getOwnershipState().test(E_DO_OS_REQUEST) */)\r\n\t\t{\r\n\t\t\tdobj->getOwnershipState().set( 1<< E_DO_OS_REQUEST,true );\r\n\t\t\tif (cin->isValid())\r\n\t\t\t{\r\n\t\t\t\tcin->getConnection()->c2sDORequestOwnerShip(cin->getConnection()->getUserID(),dobj->getServerID());\r\n\t\t\t}\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t}\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by loop : \r\n\r\n\tif ( dobj->getOwnershipState().test(E_DO_OS_REQUEST) )\r\n\t{\r\n\t\t//we requested a dist object already, check the its timeout :\r\n\t\tfloat elapsedTime = 0.0f;\r\n\t\tbeh->GetLocalParameterValue(1,&elapsedTime);\r\n\t\t\r\n\t\t//pickup creations timeout settings : \r\n\t\tfloat timeOut=0.0f;\r\n\t\tbeh->GetLocalParameterValue(0,&timeOut);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//timeout reached : reset everything back \r\n\t\tif (elapsedTime > timeOut)\r\n\t\t{\r\n\t\t\t//reset output server id : \r\n\t\t\tint ids = -1;\r\n\t\t\tbeh->SetOutputParameterValue(0,&ids);\r\n\r\n\t\t\t//output an error string :\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\tXString errorMesg(\"Ownership request failed,timeout\");\r\n\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\r\n\t\t\t//finish, activate error output trigger: \r\n\t\t\tbeh->ActivateOutput(2);\r\n\t\t\treturn 0; \r\n\r\n\t\t}\r\n\r\n\t\tfloat dt = ctx->GetTimeManager()->GetLastDeltaTime();\r\n\t\telapsedTime+=dt;\r\n\t\tbeh->SetLocalParameterValue(1,&elapsedTime);\r\n\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we are within the timeout range, check we have a successfully created object by the server : \r\n\t\t//we are owner now ? \r\n\t\tif ( dobj->getOwnershipState().test(1<getOwnershipState().test(1<isOwner() )\r\n\t\t{\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"Got ownership\");\r\n\t\t\t//clear the change bit : \r\n\t\t\t//dobj->getOwnershipState().set( 1<getOwnershipState().set( 1<< E_DO_OS_REQUEST,false);\r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t\treturn 0; \r\n\t\t}\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR DOControlCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}// --------------------------------------------------------------------------\r\n//\t\t\t\t\twww.UnitedBusinessTechnologies.com\r\n//\t\t\t Copyright (c) 1998 - 2002 All Rights Reserved.\r\n//\r\n// Source in this file is released to the public under the following license:\r\n// --------------------------------------------------------------------------\r\n// This toolkit may be used free of charge for any purpose including corporate\r\n// and academic use. For profit, and Non-Profit uses are permitted.\r\n//\r\n// This source code and any work derived from this source code must retain \r\n// this copyright at the top of each source file.\r\n// \r\n// UBT welcomes any suggestions, improvements or new platform ports.\r\n// email to: \r\n// --------------------------------------------------------------------------\r\n\r\n#include \"pch.h\"\r\n#include \"GStringList.h\"\r\n#include \"GString.h\"\r\n#include \r\n#include // for: strlen(), strstr()\r\n#include \"GProfile.h\"\r\nconst char *GStringList::PeekLast()\r\n{\r\n\tm_strSerializeDest = \"\";\r\n\tGString *pG = (GString *)GList::Last();\r\n\tif (pG)\r\n\t\tm_strSerializeDest = (const char *)*pG;\r\n\treturn m_strSerializeDest;\r\n}\r\n\r\n\r\nconst char *GStringList::PeekFirst()\r\n{\r\n\tm_strSerializeDest = \"\";\r\n\tGString *pG = (GString *)GList::First();\r\n\tif (pG)\r\n\t\tm_strSerializeDest = (const char *)*pG;\r\n\treturn m_strSerializeDest;\r\n}\r\n\r\nconst char *GStringList::RemoveFirst()\r\n{\r\n\tm_strSerializeDest = \"\";\r\n\tGString *pG = (GString *)GList::First();\r\n\tif (pG)\r\n\t{\r\n\t\tGList::RemoveFirst();\r\n\t\tm_strSerializeDest = (const char *)*pG;\r\n\t\tdelete pG;\r\n\t}\r\n\treturn m_strSerializeDest;\r\n}\r\n\r\nconst char *GStringList::RemoveLast()\r\n{\r\n\tm_strSerializeDest = \"\";\r\n\tGString *pG = (GString *)GList::RemoveLast();\r\n\tif (pG)\r\n\t{\r\n\t\tm_strSerializeDest = (const char *)*pG;\r\n\t\tdelete pG;\r\n\t}\r\n\treturn m_strSerializeDest;\r\n}\r\n\r\nGString *GStringList::AddFirst(const char *szString)\r\n{\r\n\tGString *pstrString = new GString(szString);\r\n\tGList::AddHead(pstrString);\r\n\treturn pstrString;\r\n}\r\n\r\n\r\nGString *GStringList::AddLast(const char *szString)\r\n{\r\n\tGString *pstrString = new GString(szString);\r\n\tGList::AddLast(pstrString);\r\n\treturn pstrString;\r\n}\r\n\r\nGStringList::GStringList(const GStringList &src)\r\n{\r\n\tGStringIterator it(&src);\r\n\twhile (it())\r\n\t\tAddLast(it++);\r\n}\r\n\r\nGStringList::GStringList()\r\n{\r\n}\r\n\r\nvoid GStringList::operator+=(const GStringList &src)\r\n{\r\n\tGStringIterator it(&src);\r\n\twhile (it())\r\n\t\tAddLast(it++);\r\n}\r\n\r\nvoid GStringList::operator+=(const char *szSrc)\r\n{\r\n\tAddLast(szSrc);\r\n}\r\n\r\nvoid GStringList::RemoveAll()\r\n{\r\n\tint n = Size();\r\n\tfor(int i=0; iNextNode;\r\n\t\tif (LastNode == FirstNode) \r\n\t\t\tLastNode = 0;\r\n\t\tNode *Save = FirstNode->NextNode;\r\n\t\tdelete (GString *)FirstNode->Data;\r\n\t\tdelete FirstNode;\r\n\t\tFirstNode = Save;\r\n\t\tiSize--;\r\n\t}\r\n}\r\n\r\nvoid GStringIterator::reset()\r\n{\r\n\tpDataNode = (GStringList::Node *)((GStringList *)pTList)->FirstNode;\r\n}\r\n\r\nGStringIterator::GStringIterator(const GStringList *pList)\r\n{\r\n\tpTList = (GStringList *)pList;\r\n\tpDataNode = (GStringList::Node *)((GStringList *)pList)->FirstNode;\r\n}\r\n\r\nconst char *GStringIterator::operator ++ (int)\r\n{\r\n\tGString *pRet = (GString *)pDataNode->Data;\r\n\tpCurrentNode = pDataNode;\r\n\tpDataNode = pDataNode->NextNode;\r\n\treturn pRet->StrVal();\r\n}\r\n\r\nint GStringIterator::operator () (void) const\r\n{\r\n\treturn pDataNode != 0;\r\n}\r\n\r\n\r\nconst char *GStringList::Serialize(const char *pzDelimiter)\r\n{\r\n\tm_strSerializeDest = \"\";\r\n\tGStringIterator it(this);\r\n\tint nCount = 0;\r\n\r\n\twhile (it())\r\n\t{\r\n\t\tif (nCount)\r\n\t\t\tm_strSerializeDest += pzDelimiter;\r\n\t\tnCount++;\r\n\t\tm_strSerializeDest += it++;\r\n\t}\r\n\treturn m_strSerializeDest;\r\n}\r\n\r\nGStringList::GStringList(const char *pzDelimiter, const char *pzSource)\r\n{\r\n\tDeSerialize(pzDelimiter, pzSource);\r\n}\r\n\r\nvoid GStringList::DeSerialize(const char *pzDelimiter, const char *pzSource)\r\n{\r\n\tif (!pzDelimiter || !pzSource || !pzDelimiter[0] || !pzSource[0])\r\n\t\treturn;\r\n\r\n\t\r\n\tint nSourceLen = strlen(pzSource);\r\n\r\n\tint nDelimiterLen = strlen(pzDelimiter);\r\n\t\r\n\tif (!nSourceLen)\r\n\t\treturn;\t\r\n\r\n\tchar *beg = (char *)pzSource; \r\n\tchar *del = strstr(beg,pzDelimiter);\r\n\twhile(1)\r\n\t{\r\n\t\tif ( !del )\r\n\t\t{\r\n\t\t\t// there is only one entry in the list\r\n\t\t\tAddLast(beg);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t// temporarily null on the delimiter\r\n\t\tchar chOld = *del;\r\n\t\t*del = 0;\r\n\r\n\t\t// add this (now null terminated) entry\r\n\t\tAddLast(beg);\r\n\r\n\t\t// advance to the next string\r\n\t\tbeg = del + nDelimiterLen;\r\n\t\t\r\n\t\t// unnull the previous\r\n\t\t*del = chOld;\r\n\r\n\t\t// advance to the next delimiter, break if none\r\n\t\tdel = strstr(beg,pzDelimiter);\r\n\t\tif ( !del )\r\n\t\t{\r\n\t\t\tAddLast(beg);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n}\r\n\r\n#include \"StdAfx2.h\"\r\n\r\n#include \"PCommonDialog.h\"\r\n#include \"PBodySetup.h\"\r\n#include \"..\\..\\include\\interface\\pbodysetup.h\"\r\n\r\n\r\n#define LAYOUT_STYLE\t\t\t(WS_CHILD|WS_VISIBLE)\r\n#define LAYOUT_ShaderREE\t\t130\r\n\r\n\r\n\r\nint CPBodyCfg::OnSelect(int before/* =-1 */)\r\n{\r\n\r\n\treturn -1;\r\n}\r\n\r\nCParameterDialog* CPBodyCfg::refresh(CKParameter*src)\r\n{\treturn this;\t}\r\n\r\nvoid CPBodyCfg::fillFlags()\r\n{\r\n\r\n\tBF_Move.SetCheck(true);\r\n}\r\n\r\n\r\nvoid CPBodyCfg::fillHullType()\r\n{\r\n\r\n\r\n\r\n\tHType.AddString(\"Sphere\");\r\n\tHType.AddString(\"Box\");\r\n\tHType.AddString(\"Capsule\");\r\n\tHType.AddString(\"Plane\");\r\n\tHType.AddString(\"Convex Mesh\");\r\n\tHType.AddString(\"Height Field\");\r\n\tHType.AddString(\"Wheel\");\r\n\tHType.AddString(\"Cloth\");\r\n\tHType.SetCurSel(0);\r\n\r\n}\r\n\r\n\r\nvoid CPBodyCfg::initSplitter()\r\n{\r\n\t\r\n\r\n\r\n\r\n\t//[...] //optional pre initialization steps\r\n\t//int opt = mTestViControl.Create(WS_CHILD|WS_VISIBLE,r,pWnd,IDC_TRACKTEST);\r\n\t/*if (opt)\r\n\t{*/\r\n\r\n\t//\t\tmTestViControl.SetColors(CZC_176,CZC_BLACK,CZC_176,CZC_WHITE,CZC_128,CZC_200);\r\n\t/*\r\n\tmTestViControl.SetFont(GetVIFont(VIFONT_NORMAL),FALSE);\r\n\tmTestViControl.SetItemHeight(18);*/\r\n\t//mTestViControl.SetWindowText(\"Shader Tree\");\r\n\t//\t\tmTestViControl.SetStyle(NTVS_DRAWHSEPARATOR);\r\n\t//\t\tmTestViControl.SetPreAllocSize(2);\r\n\r\n\t// Create columns\r\n\t//\t\tmTestViControl.SetColumnCount(1);\r\n\t//mTestViControl.SetColumn(0, \"Shader\", 0, 10);\r\n\r\n\t//HTREEITEM newItem = mTestViControl.InsertItem(\"asddad\", 0,0, mTestViControl.GetFirstVisibleItem() );\r\n\r\n\r\n\r\n\r\n\t//\t\tnewItem->Flags = NTVI_EDITABLE;\r\n\t//\t\tnewItem->Data = NULL;\r\n\r\n\t/*HNTVITEM newItem;\r\n\tnewItem = mTestViControl.InsertItem(\"asddad\", (HNTVITEM)NULL, TRUE);\r\n\tnewItem->Flags = NTVI_EDITABLE;\r\n\tnewItem->Data = NULL;*/\r\n\r\n\t//}\r\n\r\n}\r\nvoid CPBodyCfg::Init(CParameterDialog *parent)\r\n{\r\n\tmParent = parent;\r\n\r\n}\r\n\r\n\r\nCPBodyCfg::~CPBodyCfg()\r\n{\r\n\t_destroy();\r\n}\r\n\r\nvoid CPBodyCfg::_destroy()\r\n{\r\n\t//::CPSharedBase::_destroy();\r\n\r\n}\r\n//CPSharedBase(this,Parameter)\r\nCPBodyCfg::CPBodyCfg(CKParameter* Parameter,CK_CLASSID Cid)\t:CParameterDialog(Parameter,Cid) \r\n{\r\n\tsetEditedParameter(Parameter);\r\n\t//int snow = getNbDialogs();\r\n\r\n\r\n}\r\n\r\n\r\nLRESULT CPBodyCfg::OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam)\r\n{\r\n\r\n\tWORD keyState = 0;\r\n\tkeyState |= (::GetKeyState(VK_CONTROL) < 0) ? MK_CONTROL : 0;\r\n\tkeyState |= (::GetKeyState(VK_SHIFT) < 0) ? MK_SHIFT : 0;\r\n\r\n\tLRESULT lResult;\r\n\tHWND hwFocus = ::GetFocus();\r\n\tconst HWND hwDesktop = ::GetDesktopWindow();\r\n\r\n\tif (hwFocus == NULL)\r\n\t\tlResult = SendMessage(WM_MOUSEWHEEL, (wParam << 16) | keyState, lParam);\r\n\telse\r\n\t{\r\n\t\tdo {\r\n\t\t\tlResult = ::SendMessage(hwFocus, WM_MOUSEWHEEL,(wParam << 16) | keyState, lParam);\r\n\t\t\thwFocus = ::GetParent(hwFocus);\r\n\t\t}\r\n\t\twhile (lResult == 0 && hwFocus != NULL && hwFocus != hwDesktop);\r\n\t}\r\n\treturn lResult;\r\n\r\n}\r\n\r\nLRESULT CPBodyCfg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\r\n\t\t/*\r\n\t\tcase WM_MOUSEWHEEL:\r\n\t\t{\r\n\t\tint cStates = GET_KEYSTATE_WPARAM(wParam);\r\n\t\tint wheelDirection = GET_WHEEL_DELTA_WPARAM(wParam);\r\n\r\n\t\tif (wheelDirection>0)\r\n\t\t{\r\n\t\tif ( mTestViControl.GetActiveTabIndex() +1 < mTestViControl.GetTabCount() )\r\n\t\t{\r\n\t\tmTestViControl.SetActiveTab(mTestViControl.GetActiveTabIndex() +1 );\r\n\t\t}else{\r\n\t\tmTestViControl.SetActiveTab( 0 );\r\n\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\tif ( mTestViControl.GetActiveTabIndex() -1 >=0 )\r\n\t\t{\r\n\t\tmTestViControl.SetActiveTab(mTestViControl.GetActiveTabIndex() - 1 );\r\n\t\t}else{\r\n\t\tmTestViControl.SetActiveTab(mTestViControl.GetTabCount());\r\n\t\t}\r\n\t\t}\r\n\r\n\t\tbreak;\r\n\t\treturn NULL;\r\n\t\t}\r\n\t\t*/\r\n\tcase WM_LBUTTONDOWN:\r\n\tcase WM_LBUTTONDBLCLK:\r\n\t\t{\r\n\r\n\r\n\t\t\tint indexTabUnderMouse = 0;\r\n\t\t\tindexTabUnderMouse = mTestViControl.GetTabUnderMouse();\r\n\t\t\tif (indexTabUnderMouse >=0 )\r\n\t\t\t{\r\n\t\t\t\tmTestViControl.SetActiveTab(indexTabUnderMouse);\r\n\t\t\t}\r\n\t\t\t//HTREEITEM newItem = mTestViControl.InsertItem(\"asddad2323\",mTestViControl.GetFirstVisibleItem(), mTestViControl.GetFirstVisibleItem() );\r\n\r\n\t\t\t/*HTREEITEM newItem;\r\n\t\t\tnewItem = mTestViControl.InsertItem(\"asddad\", (HTREEITEM)NULL, NULL);\r\n\t\t\t*/\r\n\t\t\t/*\r\n\t\t\tHNTVITEM newItem;\r\n\t\t\tnewItem = mTestViControl.InsertItem(\"asddad\", (HNTVITEM)NULL, TRUE);\r\n\t\t\tnewItem->Flags = NTVI_EDITABLE;\r\n\t\t\tnewItem->Data = NULL;\r\n\r\n\t\t\t*/\r\n\t\t\t/*\r\n\t\t\tmTestViControl.UpdateWindow();\r\n\t\t\tmTestViControl.ShowWindow(1);\r\n\t\t\t*/\r\n\r\n\t\t\t/*\r\n\t\t\tmTestViControl.AddItem(\"asdasd\",NULL);\r\n\t\t\tint a = mTestViControl.GetSubItemCount(0);*/\r\n\r\n\t\t\t/*\r\n\t\t\tRECT r;\r\n\t\t\tGetClientRect(&r);\r\n\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);\r\n\t\t\tpDC->FillSolidRect(&r,RGB(100,200,200));*/\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\tcase WM_ERASEBKGND:\r\n\t\t{\r\n\t\t\t/*RECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);\r\n\t\t\tpDC->FillSolidRect(&r,RGB(200,200,200));\r\n\t\t\treturn 1;*/\r\n\t\t}break;\r\n\tcase CKWM_OK:\r\n\t\t{\r\n\t\t\t//CEdit *valueText = (CEdit*)GetDlgItem(IDC_EDIT);\r\n\t\t\t/*CString l_strValue;\r\n\t\t\tvalueText->GetWindowText(l_strValue);\r\n\r\n\t\t\tdouble d;\r\n\t\t\tif (sscanf(l_strValue,\"%Lf\",&d)) {\r\n\t\t\tparameter->SetValue(&d);\r\n\t\t\t}*/\r\n\t\t} break;\r\n\r\n\tcase CKWM_INIT:\r\n\t\t{\r\n\r\n\t\t\tRECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\t/*\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);*/\r\n\t\t\t//initSplitter();\r\n\t\t\t\t\t\t\r\n\t\t\tfillHullType();\r\n\t\t\tchar temp[64];\r\n\t\t\tdouble d;\r\n\t\t} break;\r\n\t}\r\n\treturn CDialog::WindowProc(message, wParam, lParam);\r\n}\r\n\r\nvoid CPBodyCfg::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\t\r\n\t//CDialog::DoDataExchange(pDX);\r\n\tCParameterDialog::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CPBodyCfg)\r\n\r\n\tDDX_Control(pDX, IDC_HULLTYPE, HType);\r\n\tDDX_Control(pDX, IDC_LBL_HTYPE, LBL_HType);\r\n\r\n\tDDX_Control(pDX, IDC_BFLAGS_MOVING,BF_Move);\r\n\tDDX_Control(pDX, IDC_BFLAGS_GRAV,BF_Grav);\r\n\tDDX_Control(pDX, IDC_BFLAGS_COLL,BF_Collision);\r\n\tDDX_Control(pDX, IDC_BFLAGS_COLL_NOTIFY,BF_CollisionNotify);\r\n\r\n\tDDX_Control(pDX, IDC_BFLAGS_KINEMATIC,BF_Kinematic);\r\n\tDDX_Control(pDX, IDC_BFLAGS_TRIGGER,BF_TriggerShape);\r\n\tDDX_Control(pDX, IDC_BFLAGS_SLEEP,BF_Sleep);\r\n\tDDX_Control(pDX, IDC_BFLAGS_SSHAPE,BF_SubShape);\r\n\tDDX_Control(pDX, IDC_BFLAGS_HIERARCHY,BF_Hierarchy);\r\n\tDDX_Control(pDX, IDC_BFLAGS_DEFORMABLE,BF_Deformable);\r\n\tDDX_Control(pDX, IDC_FLAGS_BG,BF_BG_Rect);\r\n\tDDX_Control(pDX, IDC_LBL_FLAGS,LBL_Flags);\r\n\t//}}AFX_DATA_MAP\r\n\r\n}\r\n\r\nBEGIN_MESSAGE_MAP(CPBodyCfg, CParameterDialog)\r\n\tON_WM_MOUSEMOVE()\r\n\tON_STN_CLICKED(IDC_LBL_FLAGS, OnStnClickedLblFlags)\r\n\tON_STN_CLICKED(IDC_DYNA_FLAGS_RECT, OnStnClickedDynaFlagsRect)\r\nEND_MESSAGE_MAP()\r\n\r\n\r\nvoid CPBodyCfg::OnStnClickedLblFlags()\r\n{\r\n\t// TODO: Add your control notification handler code here\r\n}\r\n\r\nvoid CPBodyCfg::OnStnClickedDynaFlagsRect()\r\n{\r\n\t// TODO: Add your control notification handler code here\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBAddShapeExDecl();\r\nCKERROR CreatePBAddShapeExProto(CKBehaviorPrototype **pproto);\r\nint PBAddShapeEx(const CKBehaviorContext& behcontext);\r\nCKERROR PBAddShapeExCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyRef,\r\n\tbbI_HullType,\r\n\tbbI_Flags,\r\n\tbbI_Pivot,\r\n\tbbI_Mass,\r\n\tbbI_Collision,\r\n\tbbI_CCD,\r\n\tbbI_Material,\r\n\tbbI_Capsule,\r\n\tbbI_CCylinder,\r\n\tbbI_Wheel,\r\n};\r\n\r\n\r\n#define BB_SSTART 3\r\n#define gPIMAP pInMap2322\r\nBBParameter pInMap2322[] =\r\n{\r\n\tBB_PIN(bbI_BodyRef,CKPGUID_3DENTITY,\"Body Reference\",\"\"),\r\n\tBB_PIN(bbI_HullType,VTE_COLLIDER_TYPE,\"Hull Type\",\"Sphere\"),\r\n\tBB_PIN(bbI_Flags,VTF_BODY_FLAGS,\"Flags\",\"Collision,Sub Shape\"),\r\n\tBB_SPIN(bbI_Pivot,VTS_PHYSIC_PIVOT_OFFSET,\"Pivot\",\"\"),\r\n\tBB_SPIN(bbI_Mass,VTS_PHYSIC_MASS_SETUP,\"Mass\",\"\"),\r\n\tBB_SPIN(bbI_Collision,VTS_PHYSIC_COLLISIONS_SETTINGS,\"Collision\",\"All,0,0.025f\"),\r\n\tBB_SPIN(bbI_CCD,VTS_PHYSIC_CCD_SETTINGS,\"CCD\",\"\"),\r\n\tBB_SPIN(bbI_Material,VTS_MATERIAL,\"Material\",\"\"),\r\n\tBB_SPIN(bbI_Capsule,VTS_CAPSULE_SETTINGS_EX,\"Capsule Settings\",\"\"),\r\n\tBB_SPIN(bbI_CCylinder,VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR,\"Convex Cylinder Settings\",\"\"),\r\n\tBB_SPIN(bbI_Wheel,VTS_PHYSIC_WHEEL_DESCR,\"Wheel Settings\",\"\"),\r\n};\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBAddShapeExDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBAddShapeEx\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Adds an entity to the physic engine.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xd8e2970,0x1efe7f65));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBAddShapeExProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBAddShapeExProto\r\n// FullName: CreatePBAddShapeExProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBAddShapeExProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBAddShapeEx\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PBAddShapeEx \r\n\r\n\tPBAddShapeEx is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAdds a sub shape to a registered rigid body.
\r\n\tSee PBPhysicalizeExSamples.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBAddShapeEx.png\r\n\r\n\tIn: triggers the process
\r\n\r\n\tOut: is activated when the process is completed
\r\n\r\n\t
\r\n\r\n\tTarget:The 3D Entity associated to the rigid body
\r\n\r\n\tFlags: Flags to determine common properties for the desired body.It is possible to alter certain flags after creation. See #BodyFlags for more information
\r\n\r\n\t-\tRange: [BodyFlags] \r\n\t-\tDefault:Moving,Collision,World Gravity
\r\n\r\n\t-\tWays to alter flags :\r\n\t\t-\tUsing \\ref PBSetPar\r\n\t\t-\tUsing VSL : #pRigidBody::updateFlags()\r\n\r\n\tHull Type: The desired shape type. The intial shape can NOT be changed after creation. See #HullType for more information
\r\n\r\n\t-\tRange: [HullType]
\r\n\t-\tDefault:Sphere
\r\n\r\n\r\n\t
\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createRigidBody().
\r\n\r\n\r\n\r\n\r\n\t

Optional Parameters

\r\n\r\n\tAll more specific parameters such as material or pivot offset must be enabled by the building block settings
\r\n\r\n\tPivot: Specifies the rigid bodies local shape offset (#pPivotSettings)

\r\n\t\\image html pBPivotParameter.jpg\r\n\r\n\t-\tOffset Linear: \\copydoc pPivotSettings::localPosition\r\n\t-\tOffset Angular: \\copydoc pPivotSettings::localOrientation\r\n\t-\tOffset Reference: \\copydoc pPivotSettings::pivotReference\r\n\r\n\t

Notes


\r\n\r\n\t-\tAlter or set the shape offset : \r\n\t-\tUsing the built-in building blocks with \"Physics\" settings enabled : \r\n\t\t-\t\"Set Position\" \r\n\t\t-\t\"Translate\"\r\n\t\t-\t\"Set Orientation\"\r\n\t\t-\t#pRigidBody::setPosition() or #pRigidBody::setRotation()\r\n\t\t-\tAttach attribute \"Physics\\pBPivotSettings\" to :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material
\r\n\r\n\t
\r\n\r\n\tMass: Overrides mass setup (#pMassSettings)

\r\n\t\\image html pBMassParameter.jpg\r\n\r\n\t-\tNew Density:\t\\copydoc pMassSettings::newDensity\r\n\r\n\t-\tTotal Mass:\t\\copydoc pMassSettings::totalDensity\r\n\r\n\t-\tOffset Linear:\t\\copydoc pMassSettings::localPosition\r\n\r\n\t-\tOffset Angular:\t\\copydoc pMassSettings::localOrientation\r\n\r\n\t-\tOffset Reference:\t\\copydoc pMassSettings::massReference\r\n\r\n\t

Notes


\r\n\t-\tAlter or set mass settings : \r\n\t-\tAttach attribute \"Physics\\pBOptimization\" to the :\t\r\n\t-\t3D-Entity\r\n\t-\tits mesh\r\n\t-\tor to the meshes material
\r\n\t-\t#pRigidBody::updateMassFromShapes()\r\n\r\n\t
\r\n\r\n\tCollision: Overrides collsion settings (#pCollisionSettings)

\r\n\t\\image html pBCollisionParameter.jpg\r\n\r\n\t-\tCollision Group: \t\\copydoc pCollisionSettings::collisionGroup\r\n\r\n\t-\tGroup Mask:\t\\copydoc pCollisionSettings::groupsMask\r\n\r\n\t-\tSkin Width:\\copydoc pCollisionSettings::skinWidth\r\n\r\n\t

Notes


\r\n\t-\tAlter or set collisions settings : \r\n\t\t-\t\\ref PBSetPar. Collisions group can be set per sub shape.\r\n\t\t-\tpRigidBody::setCollisionsGroup()\r\n\t\t-\tpRigidBody::setGroupsMask()\r\n\t\t-\tAttach attribute \"Physics\\pBCollisionSettings\" to :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material
\r\n\t-\tPlease create custom groups in the Virtools \"Flags and Enum manager\" : \"pBCollisionsGroup\". This enumeration is stored in the cmo
\r\n\r\n\t
\r\n\r\n\tCCD: Specifies a CCD mesh. This parameter is NOT being used in this release.

\r\n\t\\image html pBCCSettingsParameter.jpg\r\n\r\n\t
\r\n\r\n\r\n\tMaterial: Specifies a physic material(#pMaterial)

\r\n\t\\image html pBMaterial.jpg\r\n\r\n\t-\tXML Link : \\copydoc pMaterial::xmlLinkID\r\n\t-\tDynamic Friction : \\copydoc pMaterial::dynamicFriction\r\n\t-\tStatic Friction: \\copydoc pMaterial::staticFriction\r\n\t-\tRestitution: \\copydoc pMaterial::restitution\r\n\t-\tDynamic Friction V: \\copydoc pMaterial::dynamicFrictionV\r\n\t-\tStatic Friction V : \\copydoc pMaterial::staticFrictionV\r\n\t-\tDirection Of Anisotropy: \\copydoc pMaterial::dirOfAnisotropy\r\n\t-\tFriction Combine Mode: \\copydoc pMaterial::frictionCombineMode\r\n\t-\tRestitution Combine Mode: \\copydoc pMaterial::restitutionCombineMode\r\n\t-\tFlags: \\copydoc pMaterial::flags\r\n\r\n\t

Notes


\r\n\r\n\t-\tAlter or set a physic material is also possible by :\r\n\t-\t\\ref PBSetMaterial\r\n\t-\t#pRigidBody::updateMaterialSettings()\r\n\t-\tAttach attribute \"Physics\\pBMaterial\" to :\t\r\n\t-\t3D-Entity\r\n\t-\tits mesh\r\n\t-\tor to the meshes material\r\n\t-\tUsing VSL : \r\n\r\n\t\r\n\t\\include pBMaterialSetup.vsl\r\n\t\r\n\r\n\t-\tThe enumeration \"XML Link\" is being populated by the file \"PhysicDefaults.xml\" and gets updated on every reset. \r\n\t-\tIf using settings from XML, the parameter gets updated too
\r\n\r\n\t
\r\n\r\n\r\n\r\n\tCapsule Settings: Overrides capsule default dimensions(#pCapsuleSettingsEx)

\r\n\t\\image html pBCapsuleSettings.jpg\r\n\r\n\t-\tRadius : \\copydoc pCapsuleSettingsEx::radius\r\n\t-\tHeight : \\copydoc pCapsuleSettingsEx::height\r\n\r\n\r\n\t

Notes


\r\n\r\n\t-\tSetting a rigid bodies capsule dimension is also possible by :\r\n\t-\tAttach the attribute \"Physics\\pCapsule\" to :\t\r\n\t-\t3D-Entity\r\n\t-\tits mesh\r\n\t-\tor to the meshes material\r\n\r\n\t-\tVSL :\r\n\r\n\t\r\n\t\\include pBCapsuleEx.vsl\r\n\t\r\n\r\n\t
\r\n\r\n\r\n\tConvex Cylinder Settings: Overrides default convex cylinder settings(#pConvexCylinderSettings)

\r\n\t\\image html pBConvexCylinder.jpg\r\n\r\n\t-\tApproximation : \\copydoc pConvexCylinderSettings::approximation\r\n\r\n\t-\tRadius : \\copydoc pConvexCylinderSettings::radius\r\n\t-\tHeight : \\copydoc pConvexCylinderSettings::height\r\n\r\n\t-\tForward Axis : \\copydoc pConvexCylinderSettings::forwardAxis\r\n\t-\tForward Axis Reference: \\copydoc pConvexCylinderSettings::forwardAxisRef\r\n\r\n\t-\tDown Axis : \\copydoc pConvexCylinderSettings::downAxis\r\n\t-\tDown Axis Reference: \\copydoc pConvexCylinderSettings::downAxisRef\r\n\r\n\t-\tRight : \\copydoc pConvexCylinderSettings::rightAxis\r\n\t-\tRight Axis Reference: \\copydoc pConvexCylinderSettings::rightAxisRef\r\n\r\n\t-\tBuild Lower Half Only : \\copydoc pConvexCylinderSettings::buildLowerHalfOnly\r\n\r\n\t-\tConvex Flags : \\copydoc pConvexCylinderSettings::convexFlags\r\n\r\n\r\n\t

Notes


\r\n\r\n\t-\tSet a rigid bodies convex cylinder parameters by :\r\n\t\t-\tAttach the attribute \"Physics\\pConvexCylinder\" to :\t\r\n\t\t-\t3D-Entity\r\n\t\t-\tits mesh\r\n\t\t-\tor to the meshes material\r\n\t\t-\tVSL :\r\n\t\t\r\n\t\t\t\\include pBConvexCylinder.vsl\r\n\t\t\r\n\r\n\t
\r\n\r\n\r\n\tWheel: Overrides wheel settings(#pWheelDescr)

\r\n\t\\image html pBWheelSettings.jpg\r\n\r\n\t\t-\t@todo Documentation !\r\n\r\n\t*/\r\n\r\n\t\r\n\tBB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(gPIMAP)\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct( PBAddShapeExCB );\r\n\tproto->SetFunction(PBAddShapeEx);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddShapeEx\r\n// FullName: PBAddShapeEx\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBAddShapeEx(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tobjects\t\t\r\n\t//\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\t\r\n\t//the object :\r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t//the world reference, optional used\r\n\tCK3dEntity*worldRef = NULL;\r\n\r\n\t//the world object, only used when reference has been specified\r\n\tpWorld *world = NULL;\r\n\r\n\t//final object description \r\n\tpObjectDescr oDesc;\r\n\t\r\n\tpRigidBody *body = NULL;\r\n\tNxShape *shape = NULL;\r\n\tXString errMesg;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks \r\n\t//\r\n\r\n\r\n\tCK3dEntity *bodyReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_BodyRef);\r\n\tif( !bodyReference) \t\r\n\t\tbbErrorME(\"No body reference specified\");\r\n\tbody = GetPMan()->getBody(bodyReference);\r\n\tif( !body){\r\n\t\terrMesg.Format(\"Object %s is not physicalized\",bodyReference->GetName());\r\n\t\tbbErrorME(errMesg.Str());\r\n\t}\r\n\r\n\tif( !target->GetCurrentMesh() ){\r\n\t\terrMesg.Format(\"Object %s has no mesh\",target->GetName());\r\n\t\tbbErrorME(errMesg.Str());\r\n\t}\r\n\r\n\tshape= GetPMan()->getSubShape(target);\r\n\tif (shape && !body->isSubShape(bodyReference) )\r\n\t{\r\n\t\terrMesg.Format(\"Object %s is not a sub shape of %s\",target,bodyReference->GetName());\r\n\t\tbbErrorME(errMesg.Str());\r\n\t}\r\n\r\n\t//get the parameter array\r\n\tBB_DECLARE_PIMAP;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// general settings\r\n\t//\r\n\toDesc.hullType = (HullType)GetInputParameterValue(beh,bbI_HullType);\r\n\toDesc.flags = (BodyFlags)GetInputParameterValue(beh,bbI_Flags);\r\n\r\n\toDesc.version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\tVxQuaternion refQuad;target->GetQuaternion(&refQuad,body->GetVT3DObject());\r\n\tVxVector relPos;target->GetPosition(&relPos,body->GetVT3DObject());\r\n\r\n\r\n\t//\toptional\r\n\t//\t\tPivot\r\n\t//\r\n\tBBSParameterM(bbI_Pivot,BB_SSTART);\r\n\tif (sbbI_Pivot)\r\n\t{\r\n\t\tCKParameter*pivotParameter = beh->GetInputParameter(BB_IP_INDEX(bbI_Pivot))->GetRealSource();\r\n\t\tif (pivotParameter)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc.pivot,pivotParameter);\r\n\t\t\toDesc.mask |= OD_Pivot;\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tmass\r\n\t//\r\n\tBBSParameterM(bbI_Mass,BB_SSTART);\r\n\tif (sbbI_Mass)\r\n\t{\r\n\r\n\t\tCKParameter*massParameter = beh->GetInputParameter(BB_IP_INDEX(bbI_Mass))->GetRealSource();\r\n\t\tif (massParameter)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc.mass,massParameter);\r\n\t\t\toDesc.mask |= OD_Mass;\r\n\t\t}\r\n\t\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcollision\r\n\t//\r\n\tBBSParameterM(bbI_Collision , BB_SSTART);\r\n\tif (sbbI_Collision)\r\n\t{\r\n\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Collision))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc.collision,par);\r\n\t\t\toDesc.mask |= OD_Collision;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcollision : CCD \r\n\t//\r\n\tBBSParameterM(bbI_CCD, BB_SSTART);\r\n\tif (sbbI_CCD)\r\n\t{\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_CCD))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc.ccd,par);\r\n\t\t\toDesc.mask |= OD_CCD;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tMaterial\r\n\t//\r\n\tBBSParameterM(bbI_Material, BB_SSTART);\r\n\tif (sbbI_Material)\r\n\t{\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Material))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(oDesc.material,par);\r\n\t\t\toDesc.mask |= OD_Material;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcapsule\r\n\t//\r\n\tBBSParameterM(bbI_Capsule, BB_SSTART);\r\n\tif (sbbI_Capsule)\r\n\t{\r\n\t\tif (oDesc.hullType == HT_Capsule)\r\n\t\t{\r\n\t\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Capsule))->GetRealSource();\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tIParameter::Instance()->copyTo(oDesc.capsule,par);\r\n\t\t\t\toDesc.mask |= OD_Capsule;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\terrMesg.Format(\"You attached a capsule parameter but the hull type is not capsule\");\r\n\t\t\tbbWarning(errMesg.Str());\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tconvex cylinder\r\n\t//\r\n\tBBSParameterM(bbI_CCylinder, BB_SSTART);\r\n\tif (sbbI_CCylinder)\r\n\t{\r\n\t\tif (oDesc.hullType == HT_ConvexCylinder)\r\n\t\t{\r\n\t\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_CCylinder))->GetRealSource();\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(oDesc.convexCylinder,par,true);\r\n\t\t\t\toDesc.mask |= OD_ConvexCylinder;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\terrMesg.Format(\"You attached a convex cylinder parameter but the hull type is not a convex cylinder\");\r\n\t\t\tbbWarning(errMesg.Str());\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tconvex cylinder\r\n\t//\r\n\tBBSParameterM(bbI_Wheel, BB_SSTART);\r\n\tif (sbbI_Wheel)\r\n\t{\r\n\t\tif (oDesc.hullType == HT_Wheel)\r\n\t\t{\r\n\t\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Wheel))->GetRealSource();\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tIParameter::Instance()->copyTo(oDesc.wheel,(CKParameterOut*)par);\r\n\t\t\t\toDesc.mask |= OD_Wheel;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\terrMesg.Format(\"You attached a wheel parameter but the hull type is not a wheel\");\r\n\t\t\tbbWarning(errMesg.Str());\r\n\t\t}\r\n\t}\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// create sub shape : \r\n\t//\r\n\tshape = pFactory::Instance()->createShape(bodyReference,oDesc,target,target->GetCurrentMesh(),relPos,refQuad);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// update input parameters\r\n\t//\r\n\tif (sbbI_Material)\r\n\t{\r\n\t\tCKParameterOut *par = (CKParameterOut*)beh->GetInputParameter(BB_IP_INDEX(bbI_Material))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(par,oDesc.material);\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// error out\r\n\t//\r\n\terrorFound:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_GENERICERROR;\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// All ok\r\n\t//\r\n\tallOk:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBAddShapeExCB\r\n// FullName: PBAddShapeExCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBAddShapeExCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"xDistTools.h\"\r\n\r\n\r\n\r\n/*xDistributed3DObjectClass::~xDistributed3DObjectClass()\r\n{\r\n\r\n}*/\r\n\r\nxDistributed3DObjectClass::xDistributed3DObjectClass() : xDistributedClass()\r\n{\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\n int xDistributed3DObjectClass::getFirstUserField(){ return 8; }\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\n int\r\nxDistributed3DObjectClass::getUserFieldBitValue(int walkIndex)\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\tif (dInfo->mNativeType==E_DC_3D_NP_USER)\r\n\t\t{\r\n\t\t\tif (i ==walkIndex)\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tuserTypeCounter++;\r\n\t\t}\r\n\t}\r\n\tint result = getFirstUserField();\r\n result +=userTypeCounter;\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nint\r\nxDistributed3DObjectClass::getInternalUserFieldIndex(int inputIndex)\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\tif (dInfo->mNativeType==E_DC_3D_NP_USER)\r\n\t\t{\r\n\t\t\tif (userTypeCounter == inputIndex)\r\n\t\t\t{\r\n\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t\tuserTypeCounter++;\r\n\t\t}\r\n\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nint xDistributed3DObjectClass::getUserFieldCount()\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\tif (props[i]->mNativeType==E_DC_3D_NP_USER)\r\n\t\t\tuserTypeCounter++;\r\n\t}\r\n\treturn userTypeCounter;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributed3DObjectClass::addProperty(int nativeType,int predictionType)\r\n{\r\n\txDistributedPropertyInfo *result = exists(nativeType);\r\n\tif (!result)\r\n\t{\r\n\t\tTNL::StringPtr name = xDistTools::NativeTypeToString(nativeType);\r\n\t\tint valueType = xDistTools::NativeTypeToValueType(nativeType);\r\n\t\tresult = new xDistributedPropertyInfo( name ,valueType , nativeType ,predictionType );\r\n\t\tgetDistributedProperties()->push_back( result );\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributed3DObjectClass::addProperty(const char*name,int type,int predictionType)\r\n{\r\n\txDistributedPropertyInfo *result = exists(name);\r\n\tif (!result)\r\n\t{\r\n\t\tresult = new xDistributedPropertyInfo( name ,type,E_DC_3D_NP_USER ,predictionType );\r\n\t\tgetDistributedProperties()->push_back( result );\r\n\t}\r\n}\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSaveObjectsDecl();\r\nCKERROR CreateSaveObjectsProto(CKBehaviorPrototype **pproto);\r\nint SaveObjects(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKERROR ZipCallBack(const CKBehaviorContext& behcontext);\r\nCKObjectDeclaration\t*FillBehaviorSaveObjectsDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Save Objects\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetCategory(\"Narratives/Files\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6f12495d,0x1aff17f4));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSaveObjectsProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\n\r\nCKERROR CreateSaveObjectsProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Save Objects\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Save\");\r\n\t\r\n\tproto->DeclareOutput(\"Saved\");\r\n\tproto->DeclareInParameter(\"Filename\", CKPGUID_STRING);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\tproto->SetFunction(SaveObjects);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nint SaveObjects(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\t\r\n\t\r\n\tXString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\r\n\tCKBeObject *beo;\r\n\tCKObjectArray* oa = CreateCKObjectArray();\r\n\tfor (int i = 1 ;iGetInputParameterCount();i++)\r\n\t{\r\n\t\tbeo = (CKBeObject *)beh->GetInputParameterObject(i);\r\n\t\toa->InsertAt(beo->GetID());\r\n\t}\r\n\t\r\n\tctx->Save(filename.Str(),oa,0xFFFFFFFF,NULL);\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\treturn CKBR_OK;\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCGroupTriggerEventDecl();\r\nCKERROR CreatePCGroupTriggerEventProto(CKBehaviorPrototype **pproto);\r\nint PCGroupTriggerEvent(const CKBehaviorContext& behcontext);\r\nCKERROR PCGroupTriggerEventCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCGroupTriggerEventDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCGroupTriggerEvent\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Triggers output if elements of a group stays within, enters or leaves a body .\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xd8c142a,0x4ce04f7b));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePCGroupTriggerEventProto);\r\n\tod->SetCompatibleClassId(CKCID_GROUP);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePCGroupTriggerEventProto\r\n// FullName: CreatePCGroupTriggerEventProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePCGroupTriggerEventProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCGroupTriggerEvent\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PCGroupTriggerEvent \r\n\r\n\tPCGroupTriggerEvent is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tTriggers outputs if the body enters,stays or leaves another body .
\r\n\tSee pBTriggerEvent.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PCGroupTriggerEvent.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\t\r\n\tNo Event: Nothing touched.\r\n\t
\r\n\tEntering: Body entered.\r\n\t
\r\n\tLeaving: Body leaved.\r\n\t
\r\n\tStay: Inside body .\r\n\t
\r\n\r\n\tTarget Group: The group which the bb outputs triggers for.\r\n\t
\r\n\tTouched Object: The touched body.\r\n\t
\r\n\t\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note


\r\n\t\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pRigidBody::addForce().
\r\n\t\r\n\t*/\r\n\r\n\t//proto->DeclareInParameter(\"Extra Filter\",VTF_TRIGGER,\"0\");\r\n\t//proto->DeclareInParameter(\"Remove Event\",CKPGUID_BOOL,\"0\");\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\t\r\n\tproto->DeclareOutput(\"No Event\");\r\n\tproto->DeclareOutput(\"Entering\");\r\n\tproto->DeclareOutput(\"Stay\");\r\n\tproto->DeclareOutput(\"Leaving\");\r\n\tproto->DeclareOutput(\"Has More\");\r\n\r\n\t\r\n\tproto->DeclareOutParameter(\"Trigger Object\",CKPGUID_3DENTITY,0);\r\n\tproto->DeclareOutParameter(\"Touched Object\",CKPGUID_3DENTITY,0);\r\n\tproto->DeclareOutParameter(\"Trigger Event\",VTF_TRIGGER,0);\r\n\r\n\tproto->DeclareLocalParameter(\"currentIndex\", CKPGUID_INT);\r\n\r\n\r\n\t//proto->DeclareSetting(\"Trigger on Enter\",CKPGUID_BOOL,\"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PCGroupTriggerEvent);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Enter,\r\n\tbbO_Stay,\r\n\tbbO_Leave,\r\n\tbbO_HasMore,\r\n};\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Init,\r\n\tbbI_Next,\r\n};\r\n\r\nbool isInGroup(CKGroup *src, CK3dEntity* testObject)\r\n{\r\n\r\n\tif (src && testObject)\r\n\t{\r\n\t\tfor (int i = 0 ; i < src->GetObjectCount() ; i++ )\r\n\t\t{\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)src->GetObject(i);\r\n\t\t\tif(ent)\r\n\t\t\t{\r\n\t\t\t\tif (ent==testObject)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\nint getEventCount()\r\n{\r\n\r\n\tint result= 0;\r\n\tint nbEntries = GetPMan()->getTriggers().Size() ; \r\n\t\r\n\tfor (int i = 0 ; i < GetPMan()->getTriggers().Size(); i++ )\r\n\t{\r\n\t\tpTriggerEntry &entry = *GetPMan()->getTriggers().At(i);\r\n\t\tif(!entry.triggered)\r\n\t\t\tresult++;\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PCGroupTriggerEvent\r\n// FullName: PCGroupTriggerEvent\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PCGroupTriggerEvent(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCKGroup *target = (CKGroup *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t//int extraFilter = GetInputParameterValue(beh,0);\r\n\t//int remove = GetInputParameterValue(beh,1);\r\n\r\n\tint nbOfEvents = getEventCount();\r\n\tif (!nbOfEvents)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbO_None);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* handle init */\r\n\t/************************************************************************/\r\n\tif( beh->IsInputActive(bbI_Init) )\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_Init,FALSE);\r\n\r\n\t\tint index = 0;beh->SetLocalParameterValue(0,&index);\r\n\t\t\r\n\t\t//we have some, forward to in 1:next\r\n\t\tif (nbOfEvents)\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(bbI_Next,TRUE);\r\n\t\t\tbeh->ActivateOutput(bbO_HasMore);\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* handle trigger 'next' */\r\n\t/************************************************************************/\r\n\tif( beh->IsInputActive(bbI_Next) )\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_Next,FALSE);\r\n\r\n\t\tint index = 0;beh->GetLocalParameterValue(0,&index);\r\n\t\tfor (int i = index ; i < GetPMan()->getTriggers().Size(); i++ )\r\n\t\t{\r\n\t\t\tpTriggerEntry &entry = *GetPMan()->getTriggers().At(i);\r\n\t\t\tif (!entry.triggered)\r\n\t\t\t{\r\n\t\t\t\tif (isInGroup(target,entry.triggerShapeEnt))\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->SetOutputParameterObject(0,entry.triggerShapeEnt);\r\n\t\t\t\t\tbeh->SetOutputParameterObject(1,entry.otherObject);\r\n\r\n\t\t\t\t\tSetOutputParameterValue(beh,2,entry.triggerEvent);\r\n\t\t\t\t\tentry.triggered = true;\r\n\r\n\t\t\t\t\t//trigger out \r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_ENTER)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Enter);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_STAY)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Stay);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_LEAVE)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Leave);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t//store index\r\n\t\t\t\t\tbeh->SetLocalParameterValue(1,&index);\r\n\t\t\t\t\tint nbOfLeftEvents = getEventCount();\r\n\t\t\t\t\tif (nbOfLeftEvents)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_HasMore);\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_None);\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PCGroupTriggerEventCB\r\n// FullName: PCGroupTriggerEventCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PCGroupTriggerEventCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Dolly Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDollyDecl();\r\nCKERROR CreateDollyProto(CKBehaviorPrototype **pproto);\r\nint Dolly(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDollyDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Dolly\");\t\r\n\tod->SetDescription(\"Keeps the projection plane at the same position while translating the camera on its Z local axis.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tTranslation Value: translation value on the Camera Z local axis.
\r\n\tHierarchy: if TRUE, then this building block will also apply to the 3D Entity's children.
\r\n
\r\n\tKeeps the projection plane at the same position while translating the camera on its Z local axis.
\r\n */\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xb98b83bb, 0x87787878));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDollyProto);\r\n\tod->SetCompatibleClassId(CKCID_TARGETCAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDollyProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Dolly\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Translation Value\", CKPGUID_FLOAT, \"1.0\");\r\n\tproto->DeclareInParameter(\"Hierarchy\", CKPGUID_BOOL, \"TRUE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Dolly);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint Dolly(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKTargetCamera *tcam = (CKTargetCamera *) beh->GetTarget();\r\n if( !tcam ) return CKBR_OWNERERROR;\r\n\t\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\t// Get Translation value\r\n\tfloat value=1.0f;\r\n\tbeh->GetInputParameterValue(0,&value);\r\n\t\r\n\t// Hierarchy\r\n\tCKBOOL k=TRUE;\r\n\tbeh->GetInputParameterValue(1,&k);\r\n\tk=!k;\r\n\r\n tcam->Translate(0.0f, 0.0f, value, tcam, k);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nrmdir .\\CMakeFiles /s /q\r\ndel .\\*.vcproj /q /f\r\ndel *.sln /q /f\r\ndel CMakeCache.txt /q /f\r\ndel cmake_install.cmake /q /f\r\ndel VTPaths.lua\r\n\r\n\r\ncmake -Wno-dev -p CMakeLists.txt\r\n\r\ncopy VTPaths.lua .\\..\\\r\n\r\n\r\nrmdir .\\CMakeFiles /s /q\r\ndel .\\*.vcproj /q /f\r\ndel *.sln /q /f\r\ndel CMakeCache.txt /q /f\r\ndel cmake_install.cmake /q /f\r\n\r\n\r\n\r\n\r\n#include \r\n\r\n#include \"ToolManager.h\"\r\n\r\n#include \"vtCModuleDefines.h\"\r\n#include \"vtBaseMacros.h\"\r\n\r\n\r\nToolManager *manager = NULL;\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nToolManager::ToolManager(CKContext* ctx)\t:\tvtBaseManager(ctx,VTM_TOOL_MANAGER_GUID,\"ToolManager\")\r\n{\r\n\tm_Context->RegisterNewManager(this);\r\n\tmanager = this;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nCKERROR ToolManager::OnCKPause()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::OnCKPlay()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::PostClearAll()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::OnCKInit()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::PreSave()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKContext* ToolManager::GetContext()\r\n{\r\n\treturn GetInstance()->m_Context;\r\n}\r\nToolManager* ToolManager::GetInstance()\r\n{\r\n\tif (manager)\r\n\t{\r\n\t\treturn manager;\r\n\t}\r\n\t\r\n\treturn NULL;\r\n}\r\nToolManager::~ToolManager(){}\r\n\r\nCKERROR ToolManager::SequenceDeleted(CK_ID *objids,int count)\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ToolManager::SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count)\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::SequenceToBeDeleted(CK_ID *objids,int count)\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ToolManager::SequenceRemovedFromScene(CKScene *scn,CK_ID *objids,int count)\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nCKERROR ToolManager::OnCKReset()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::OnCKEnd()\r\n{\r\n\treturn 0;\r\n}\r\n\r\nCKStateChunk*\r\nToolManager::SaveData(CKFile* SavedFile)\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::PostProcess()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::PreProcess()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::LoadData(CKStateChunk *chunk,CKFile* LoadedFile)\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR ToolManager::PostSave()\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\n\r\n/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\t// include file used for the static configuration\r\n\t#include \"CustomPlayerStaticLibs.h\"\r\n\t#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\nextern CCustomPlayerApp theApp;\r\nCCustomPlayer*\tthePlayer=0;\r\n\r\nint& CCustomPlayer::RasterizerFamily()\r\n{\r\n\treturn m_RasterizerFamily;\r\n}\r\n\r\nint& CCustomPlayer::RasterizerFlags()\r\n{\r\n\treturn m_RasterizerFlags;\r\n}\r\n\r\nint& CCustomPlayer::WindowedWidth()\r\n{\r\n\treturn m_WindowedWidth;\r\n}\r\n\r\nint& CCustomPlayer::WindowedHeight()\r\n{\r\n\treturn m_WindowedHeight;\r\n}\r\n\r\nint& CCustomPlayer::MininumWindowedWidth()\r\n{\r\n\treturn m_MinWindowedWidth;\r\n}\r\n\r\nint& CCustomPlayer::MininumWindowedHeight()\r\n{\r\n\treturn m_MinWindowedHeight;\r\n}\r\n\r\nint& CCustomPlayer::FullscreenWidth()\r\n{\r\n\treturn m_FullscreenWidth;\r\n}\r\n\r\nint& CCustomPlayer::FullscreenHeight()\r\n{\r\n\treturn m_FullscreenHeight;\r\n}\r\n\r\nint CCustomPlayer::Driver()\r\n{\r\n\treturn m_Driver;\r\n}\r\n\r\nint& CCustomPlayer::FullscreenBpp()\r\n{\r\n\treturn m_FullscreenBpp;\r\n}\r\n\r\nCKRenderContext* CCustomPlayer::GetRenderContext()\r\n{\r\n\treturn m_RenderContext;\r\n}\r\n\r\nextern CKERROR LoadCallBack(CKUICallbackStruct& loaddata,void*);\r\n\r\n//************************************\r\n// Method: GetEnginePointers\r\n// FullName: CCustomPlayer::GetEnginePointers\r\n// Access: public \r\n// Returns: vtPlayer::Structs::xSEnginePointers*\r\n// Qualifier:\r\n//************************************\r\nvtPlayer::Structs::xSEnginePointers*\r\nCCustomPlayer::GetEnginePointers()\r\n{\r\n\treturn &m_EnginePointers;\r\n}\r\n\r\n//************************************\r\n// Method: GetEngineWindowInfo\r\n// FullName: CCustomPlayer::GetEngineWindowInfo\r\n// Access: public \r\n// Returns: vtPlayer::Structs::xSEngineWindowInfo*\r\n// Qualifier:\r\n//************************************\r\n\r\nvtPlayer::Structs::xSEngineWindowInfo*\r\nCCustomPlayer::GetEngineWindowInfo()\r\n{\r\n\treturn m_EngineWindowInfo;\r\n}\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// CCustomPlayer: PUBLIC STATIC METHODS\r\n//\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\nCCustomPlayer&\r\nCCustomPlayer::Instance()\r\n{\r\n\tif (thePlayer==0) {\r\n\t\tthePlayer = new CCustomPlayer();\r\n\t}\r\n\treturn *thePlayer;\r\n}\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// CCustomPlayer: PUBLIC METHODS\r\n//\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\nCCustomPlayer::~CCustomPlayer()\r\n{\r\n\t// here we stop/release/clear the Virtools Engine\r\n\r\n\ttry {\r\n\t\tif (!m_CKContext) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// clear the CK context\r\n\t\tm_CKContext->Reset();\r\n\t\tm_CKContext->ClearAll();\r\n\r\n\t\t// destroy the render engine\r\n\t\tif (m_RenderManager && m_RenderContext) {\r\n\t\t\tm_RenderManager->DestroyRenderContext(m_RenderContext);\r\n\t\t}\r\n\t\tm_RenderContext = NULL;\r\n\r\n\t\t// close the ck context\r\n\t\tCKCloseContext(m_CKContext);\r\n\r\n\t\tm_CKContext = NULL;\r\n\r\n\t\t// shutdown all\r\n\t\tCKShutdown();\r\n\r\n\t\tm_CKContext = NULL;\r\n\t\t\r\n\t\r\n\r\n\t\tif (m_AWStyle)\r\n\t\t{\r\n\t\t\tdelete m_AWStyle;\r\n\t\t\tm_AWStyle =NULL;\r\n\t\t}\r\n\t\t\t\t\r\n\r\n\t} catch(...) \r\n\t{\r\n\t}\r\n\t\r\n}\r\n\r\n\r\n\r\nCCustomPlayer::CCustomPlayer()\r\n\t: m_State(eInitial), m_MainWindow(0),m_RenderWindow(0),\r\n\tm_CKContext(0),m_RenderContext(0),\r\n\tm_MessageManager(0),m_RenderManager(0),m_TimeManager(0),\r\n\tm_AttributeManager(0),m_InputManager(0),\r\n\tm_Level(0),m_QuitAttType(-1),m_SwitchResolutionAttType(-1),m_SwitchMouseClippingAttType(-1),\r\n\tm_WindowedResolutionAttType(-1),m_FullscreenResolutionAttType(-1),m_FullscreenBppAttType(-1),\r\n\tm_MsgClick(0),m_MsgDoubleClick(0),\r\n\tm_RasterizerFamily(CKRST_DIRECTX),m_RasterizerFlags(CKRST_SPECIFICCAPS_HARDWARE|CKRST_SPECIFICCAPS_DX9),\r\n\tm_WindowedWidth(640),m_WindowedHeight(480),\r\n\tm_MinWindowedWidth(400),m_MinWindowedHeight(300),\r\n\tm_FullscreenWidth(640),m_FullscreenHeight(480),m_FullscreenBpp(32),\r\n\tm_Driver(-1),m_FullscreenEnabled(FALSE),\r\n\tm_EatDisplayChange(FALSE),m_MouseClipped(FALSE),m_LastError(0),\r\n\tm_PlayerClass(MAINWINDOW_CLASSNAME),m_RenderClass(RENDERWINDOW_CLASSNAME)\r\n{\r\n\tm_EngineWindowInfo = new xSEngineWindowInfo();\r\n\tm_EPaths\t = new xSEnginePaths();\r\n//\tm_AWStyle = NULL;\r\n\tm_AWStyle = new xSApplicationWindowStyle();\r\n\tm_AppMode = normal;\r\n\tm_hThread = NULL;\r\n\r\n}\r\n\r\nBOOL CCustomPlayer::_CheckDriver(VxDriverDesc* iDesc, int iFlags)\r\n{\r\n\t// check the rasterizer family\r\n\tif (iFlags & eFamily) { \r\n\t\tif (iDesc->Caps2D.Family!=m_RasterizerFamily) {\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\t// test directx version\r\n\tif ( (iDesc->Caps2D.Family==CKRST_DIRECTX) && (iFlags & eDirectXVersion) ) {\r\n\t\tif ((iDesc->Caps3D.CKRasterizerSpecificCaps&0x00000f00UL)!=(m_RasterizerFlags&0x00000f00UL)) {\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\t// test hardware/software\r\n\tif (iFlags & eSoftware) {\r\n\t\tif (((int)iDesc->Caps3D.CKRasterizerSpecificCaps&CKRST_SPECIFICCAPS_SOFTWARE)!=(m_RasterizerFlags&CKRST_SPECIFICCAPS_SOFTWARE)) {\r\n\t\t\treturn FALSE;\r\n\t\t}\t\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nvoid CCustomPlayer::_MissingGuids(CKFile* iFile, const char* iResolvedFile)\r\n{\r\n\t// here we manage the error CKERR_PLUGINSMISSING when loading a composition failed\r\n\r\n\t// create missing guids log filename\r\n\tchar fp[_MAX_PATH];\r\n\t{\r\n\t\tGetTempPath(_MAX_PATH,fp);\r\n\t\tchar drive[_MAX_DRIVE];\r\n\t\tchar dir[_MAX_DIR];\r\n\t\tchar fname[_MAX_FNAME];\r\n\t\tchar ext[_MAX_EXT];\r\n\t\t\t\t\r\n\t\t_splitpath(fp,drive,dir,fname,ext);\r\n\t\t_makepath(fp,drive,dir,MISSINGUIDS_LOG,NULL);\r\n\t}\r\n\r\n\t// retrieve the list of missing plugins/guids\r\n\tXClassArray *p = iFile->GetMissingPlugins();\r\n\tCKFilePluginDependencies*it = p->Begin();\t\r\n\r\n\tFILE *logf = NULL;\t\r\n\tchar str[64];\r\n\tfor(CKFilePluginDependencies* it=p->Begin();it!=p->End();it++) {\r\n\t\tint count = (*it).m_Guids.Size();\r\n\t\tfor(int i=0;idoxygen doxyConfigInternal.dox\r\nX:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM\r\n\r\ncopy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmod_vtAgeia\\Doc /y\r\ncopy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmodsvn\\Plugins\\vtAgeia\\Documentation /y\r\n\r\n\r\n\r\n\r\nexit\r\n/********************************************************************\r\n\tcreated:\t2006/22/06\r\n\tcreated:\t22:06:2006 12:26\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\Behaviors\\Generic\\BGInstancer.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\Behaviors\\Generic\r\n\tfile base:\tBGInstancer\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\tinstancing of b-graphs per file\r\n*********************************************************************/\r\n\r\n#define\tBGWRAPPER_GUID\t\t\t\t\tCKGUID(0x35fb3204,0x6b59721c)\r\n\r\n// Parameters for BGWrapper\r\nenum EBGWRAPPERPARAM\r\n\t{\r\n\t// local\r\n\tEBGWRAPPERPARAM_PARAMETER_SCRIPT = 0,\r\n\tEBGWRAPPERPARAM_PARAMETER_NAME = 1,\r\n\tEBGWRAPPERPARAM_LOCAL_PARAMETER_COUNT,\r\n\t};\r\n\r\nclass BGWrapper\r\n{\r\n\r\n\tpublic:\r\n\t\tstatic CKObjectDeclaration*\t FillBehaviour( void );\t\r\n\t\tstatic CKERROR\t\t\t\t CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr );\r\n\t\tstatic int\t\t\t\t\t BehaviourFunction( const CKBehaviorContext& behaviorContext );\r\n\r\n\tprivate:\r\n\t\tstatic CKERROR\t\tBGWrapperCB(const CKBehaviorContext& behContext);\r\n\t\t\r\n\t\tstatic BOOL\t\t\tHasIO(CKBehavior* pBeh);\r\n\t\tstatic BOOL\t\t\tDeleteIO(CKBehavior* pBeh);\r\n\t\tstatic BOOL\t\t\tCreateIO(CKBehavior* pBeh, CKBehavior* pScript);\r\n\t\tstatic BOOL\t\t\tCheckIO(CKBehavior* pBeh, CKBehavior* pScript);\r\n\r\n\t\tstatic CKBehavior*\tBGLoader(CKSTRING fileName,const CKBehaviorContext& behContext);\r\n\r\n\t\tstatic void ActivateNextFrameSubBB(CKBehavior* scriptObject,BOOL &bActivateNextFrame);\r\n\t\tstatic void DesactivateSubBB(CKBehavior* scriptObject);\r\n\t\tstatic void OwnerSubBB(CKBehavior* scriptObject,CKBeObject*owner);\r\n\t\tstatic void\tSetNewBG(CKBehavior *behaviour,CKBehavior *newBehavior);\r\n\t\tstatic void\tDestroyCurrentBG(CKLevel* level,CKBehavior *behaviour,CKBehavior *scriptObject);\r\n\r\n\r\n\r\n};\r\n\r\n\r\n/*\n * Tcp4u v 3.31 Last Revision 27/02/1998 3.30\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: build.h\n * Purpose: Common header file. Group all includes needed \n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#if defined (UNIX)\n# define API4U\n#elif defined (_WINDOWS)\n# ifdef _WIN32\n# define API4U PASCAL\n# else\n# define API4U _export PASCAL FAR\n# endif\n#endif\n\n\n/* --------------------------------------------------- */\n/* The exported include files should compile properly */\n/* --------------------------------------------------- */\n#include \"tcp4u.h\"\n#include \"udp4u.h\"\n#include \"http4u.h\"\n#include \"smtp4u.h\"\n\n\n\n/* --------------------------------------------------- */\n/* The rest of them will have more troubles.......... */\n/* --------------------------------------------------- */\n#define HPUX_SOURCE\n\n#include \n#include \n#include \n#include \n#include \n\n#ifdef _WINDOWS\n# include \n# include \n# include \n#endif\n\n#ifdef UNIX\n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n#ifndef HPUX\n# include \n#endif\n# include \n# include \n/* systemes un peu speciaux --------------------------------------- */\n#ifdef AIX\n# include \n#endif\n#if defined (SOLARIS) || defined (SunOS)\n# include \n#endif\n# include \n\n/* ---------------------------------------------------------------- */\n/* Et si ca ne marche toujours pas, on essaie les definitions :---- */\n#ifndef INADDR_NONE\n# define INADDR_NONE -1\n#endif\n#ifndef FIONREAD\n# define FIONREAD _IOR('f', 127, int) /* get number of bytes to read */\n#endif\n#ifndef SIOCATMARK\n# define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */\n#endif\n/* ---------------------------------------------------------------- */\n#endif /* UNIX */\n\n\n#include \"port.h\" /* fonctions de portage */\n#include \"skt4u.h\" /* define internes */\n#include \"dimens.h\" /* size of communly used data */\n\n\n#ifndef SizeOfTab\n# define SizeOfTab(x) (sizeof x / sizeof (*x))\n#endif\n#ifndef min\n# define min(a,b) ( (a)<(b) ? (a) : (b) )\n#endif\n\n#ifndef __X_BIT_SET_H__\r\n#define __X_BIT_SET_H__\r\n\r\n#ifndef u32\r\n\ttypedef unsigned int u32;\r\n#endif\r\n\r\nclass xBitSet\r\n{\r\nprivate:\r\n u32 mBits;\r\n\r\npublic:\r\n /// Default constructor initializes this bit set to all zeros.\r\n xBitSet() { mBits = 0; }\r\n\r\n /// Copy constructor.\r\n xBitSet(const xBitSet& in_rCopy) { mBits = in_rCopy.mBits; }\r\n\r\n /// Construct from an input u32.\r\n xBitSet(const u32 in_mask) { mBits = in_mask; }\r\n\r\n /// @name Accessors\r\n /// @{\r\n\r\n /// Returns the u32 representation of the bit set.\r\n operator u32() const { return mBits; }\r\n\r\n /// Returns the u32 representation of the bit set.\r\n u32 getMask() const { return mBits; }\r\n\r\n /// @}\r\n\r\n /// @name Mutators\r\n ///\r\n /// Most of these methods take a word (ie, a BitSet32) of bits\r\n /// to operate with.\r\n /// @{\r\n\r\n /// Sets all the bits in the bit set to 1\r\n void set() { mBits = 0xFFFFFFFFUL; }\r\n\r\n /// Sets all the bits in the bit set that are set in m.\r\n void set(const u32 m) { mBits |= m; }\r\n\r\n /// For each bit set in s, sets or clears that bit in this, depending on whether b is true or false.\r\n void set(xBitSet s, bool b) { mBits = (mBits&~(s.mBits))|(b?s.mBits:0); }\r\n\r\n /// Clears all the bits in the bit set to 0.\r\n void clear() { mBits = 0; }\r\n\r\n /// Clears all the bits in the bit set that are set in m.\r\n void clear(const u32 m) { mBits &= ~m; }\r\n\r\n /// Flips all the bits in the bit set that are set in m.\r\n void toggle(const u32 m) { mBits ^= m; }\r\n\r\n /// Test if the passed bits are set.\r\n bool test(const u32 m) const { return (mBits & m) != 0; }\r\n\r\n /// Test if the passed bits and only the passed bits are set.\r\n bool testStrict(const u32 m) const { return (mBits & m) == m; }\r\n\r\n xBitSet& operator =(const u32 m) { mBits = m; return *this; }\r\n xBitSet& operator|=(const u32 m) { mBits |= m; return *this; }\r\n xBitSet& operator&=(const u32 m) { mBits &= m; return *this; }\r\n xBitSet& operator^=(const u32 m) { mBits ^= m; return *this; }\r\n\r\n xBitSet operator|(const u32 m) const { return xBitSet(mBits | m); }\r\n xBitSet operator&(const u32 m) const { return xBitSet(mBits & m); }\r\n xBitSet operator^(const u32 m) const { return xBitSet(mBits ^ m); }\r\n\r\n /// @}\r\n};\r\n\r\n#ifndef xBit\r\n\t#define xBit(f) (1 << f)\r\n#endif\r\n\r\n__inline bool isFlagOn(xBitSet value,int flag)\r\n{\r\n\treturn value.test(1 << flag );\r\n}\r\n__inline bool isFlagOff(xBitSet value,int flag)\r\n{\r\n\treturn value.test(1 << flag ) ? false : true;\r\n}\r\n\r\n__inline void setFlag(xBitSet& value,int flag,bool condition)\r\n{\r\n\tvalue.set(flag,condition);\r\n}\r\n__inline void enableFlag(xBitSet& value,int flag)\r\n{\r\n\tvalue.set(1 << flag,true );\r\n}\r\n__inline void disableFlag(xBitSet& value,int flag)\r\n{\r\n\tvalue.set(1 << flag,false);\r\n}\r\n\r\n#endif//{{NO_DEPENDENCIES}}\r\n// Microsoft Visual C++ generated include file.\r\n// Used by vtAgeiaInterface.rc\r\n//\r\n#define IDD_MYTABEXAMPLE_DIALOG 102\r\n#define IDR_MAINFRAME 128\r\n#define IDD_TAB_ONE 129\r\n#define IDD_TAB_TWO 130\r\n#define IDD_TAB_THREE 131\r\n#define IDC_PBODY_TAB_PANE 145\r\n#define IDC_TREE1 147\r\n#define IDC_MAIN_VIEW_XML 998\r\n#define IDC_PB_XML_TABS 9995\r\n#define IDD_PB_XML_PARENT 9999\r\n#define IDC_BFLAGS_MOVING 10001\r\n#define IDC_LBL_FLAGS 10002\r\n#define IDC_BFLAGS_DEFORMABLE 10003\r\n#define IDC_BFLAGS_GRAV 10004\r\n#define IDC_BFLAGS_KINEMATIC 10005\r\n#define IDC_LBL_DYNAFLAGS 10006\r\n#define IDC_BFLAGS_COLL_NOTIFY 10007\r\n#define IDD_BODYSHORTPANE 10007\r\n#define IDC_BFLAGS_TRIGGER 10008\r\n#define IDC_BFLAGS_SSHAPE 10009\r\n#define IDC_BFLAGS_HIERARCHY 10010\r\n#define IDD_EDITOR 10011\r\n#define IDC_LBL_LFLAGS 10011\r\n#define IDC_FLAGS_BG 10012\r\n#define IDI_EDITORICON 10013\r\n#define IDC_TLFLAGS_POS 10013\r\n#define IDC_TLFLAGS_ROT 10014\r\n#define IDC_HULLTYPE 10015\r\n#define IDC_HULLTYPE2 10016\r\n#define IDC_TLFLAGS_POS_X 10016\r\n#define IDC_TLFLAGS_POS_Y 10017\r\n#define IDC_TLFLAGS_POS_Z 10018\r\n#define IDC_TLFLAGS_ROT_Y 10019\r\n#define IDC_TLFLAGS_ROT_Z 10020\r\n#define IDC_BFLAGS_SLEEP 10021\r\n#define IDD_PBCOMMON 10022\r\n#define IDC_TLFLAGS_ROT_Y2 10022\r\n#define IDC_TLFLAGS_ROT_X 10022\r\n#define IDD_TOOLBAR 10023\r\n#define IDC_XML_MAIN_VIEW 10027\r\n#define IDC_EDIT1 10028\r\n#define IDC_DYNA_FLAGS_RECT 10029\r\n#define IDC_SPACER 10031\r\n#define IDC_BFLAGS_COLL 10306\r\n#define IDC_LBL_HTYPE 10890\r\n#define IDC_LBL_HTYPE2 10891\r\n#define IDD_PB_PARENT_DIALOG 30000\r\n#define IDC_PB_MAINTAB 30001\r\n#define IDD_PB_MAINTAB_DST 30002\r\n#define IDC_MAIN_VIEW 30004\r\n#define IDD_PB_COLLISION_PARENT 30008\r\n#define IDC_XEXTERN_LINK 30022\r\n#define IDC_XEXTERN_LINK_LBL 30030\r\n#define IDC_XINTERN_LINK2 30031\r\n#define IDC_XINTERN_LINK_LBL2 30032\r\n#define IDD_PBODY_TAB_PANE 30033\r\n\r\n// Next default values for new objects\r\n// \r\n#ifdef APSTUDIO_INVOKED\r\n#ifndef APSTUDIO_READONLY_SYMBOLS\r\n#define _APS_NEXT_RESOURCE_VALUE 10008\r\n#define _APS_NEXT_COMMAND_VALUE 32771\r\n#define _APS_NEXT_CONTROL_VALUE 10030\r\n#define _APS_NEXT_SYMED_VALUE 10000\r\n#endif\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pWorldCallbacks.h\"\r\n\r\nvoid pContactReport::onContactNotify(NxContactPair& pair, NxU32 events)\r\n{\r\n\r\n\tpRigidBody *bodyA = NULL;\r\n\tpRigidBody *bodyB = NULL;\r\n\r\n\tif (pair.actors[0])\r\n\t{\r\n\t\tbodyA = static_cast(pair.actors[0]->userData);\r\n\t}\r\n\tif (pair.actors[1])\r\n\t{\r\n\t\tbodyB = static_cast(pair.actors[1]->userData);\r\n\t}\r\n\r\n\tif (bodyA) \r\n\t{\r\n\t\tif (bodyA->hasWheels())\r\n\t\t{\r\n\t\t\tbodyA->handleContactPair(&pair,0);\r\n\t\t\treturn ;\r\n\t\t}\r\n\r\n\t\tif (bodyA->getVehicle())\r\n\t\t{\r\n\t\t\tpVehicle* v = bodyA->getVehicle();\r\n\t\t\tv->handleContactPair(&pair, 0);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t}\r\n\tif ( bodyB ) \r\n\t{\r\n\t\tif (bodyB->hasWheels())\r\n\t\t{\r\n\t\t\tbodyB->handleContactPair(&pair,1);\r\n\t\t\treturn ;\r\n\t\t}\r\n\r\n\t\tif (bodyB->getVehicle())\r\n\t\t{\r\n\t\t\tpVehicle* v = bodyB->getVehicle();\r\n\t\t\tv->handleContactPair(&pair, 1);\r\n\t\t\treturn ;\r\n\t\t}\r\n\r\n\t\t\r\n\t}\r\n\r\n\t// Iterate through contact points\r\n\tNxContactStreamIterator i(pair.stream);\r\n\t//user can call getNumPairs() here\r\n\twhile(i.goNextPair())\r\n\t{\r\n\t\t//user can also call getShape() and getNumPatches() here\r\n\t\twhile(i.goNextPatch())\r\n\t\t{\r\n\t\t\t//user can also call getPatchNormal() and getNumPoints() here\r\n\t\t\tconst NxVec3& contactNormal = i.getPatchNormal();\r\n\t\t\twhile(i.goNextPoint())\r\n\t\t\t{\r\n\t\t\t\t//user can also call getPoint() and getSeparation() here\r\n\t\t\t\tconst NxVec3& contactPoint = i.getPoint();\r\n\t\t\t\tpCollisionsEntry entry;\r\n\t\t\t\tentry.point = pMath::getFrom(contactPoint);\r\n\t\t\t\tNxU32 faceIndex = i.getFeatureIndex0();\r\n\t\t\t\tif(faceIndex==0xffffffff)\t\r\n\t\t\t\t\tfaceIndex = i.getFeatureIndex1();\r\n\t\t\t\tif(faceIndex!=0xffffffff)\r\n\t\t\t\t{\r\n\t\t\t\t\tentry.faceIndex = faceIndex;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tentry.actors[0] = pair.actors[0];\r\n\t\t\t\tentry.actors[1] = pair.actors[1];\r\n\t\t\t\tentry.faceIndex = faceIndex;\r\n\t\t\t\tentry.sumNormalForce = pMath::getFrom(pair.sumNormalForce);\r\n\t\t\t\tentry.sumFrictionForce = pMath::getFrom(pair.sumFrictionForce);\r\n\t\t\t\tentry.faceNormal = pMath::getFrom(contactNormal);\r\n\t\t\t\tpRigidBody *bodyA = NULL;\r\n\t\t\t\tpRigidBody *bodyB = NULL;\r\n\t\t\t\tif (pair.actors[0])\r\n\t\t\t\t{\r\n\t\t\t\t\tbodyA = static_cast(pair.actors[0]->userData);\r\n\t\t\t\t}\r\n\t\t\t\tif (pair.actors[1])\r\n\t\t\t\t{\r\n\t\t\t\t\tbodyB = static_cast(pair.actors[1]->userData);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (bodyA && bodyA->getActor() && (bodyA->getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tentry.bodyA = bodyA;\r\n\t\t\t\t\tentry.bodyB = bodyB;\r\n\t\t\t\t\tbodyA->getCollisions().Clear();\r\n\t\t\t\t\tbodyA->getCollisions().PushBack(entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (bodyB && bodyB->getActor() && (bodyB->getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tentry.bodyA = bodyA;\r\n\t\t\t\t\tentry.bodyB = bodyB;\r\n\t\t\t\t\tbodyB->getCollisions().Clear();\r\n\t\t\t\t\tbodyB->getCollisions().PushBack(entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//\t\t\t\tresult->getActor()->setContactReportFlags(NX_NOTIFY_ON_TOUCH);\r\n\t\t\t\t/*\r\n\t\t\t\t{\r\n\t\t\t\tentry.bodyA = body;\r\n\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\tbody->getCollisions().PushBack(entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pair.actors[1])\r\n\t\t\t\t{\r\n\t\t\t\tpRigidBody *body = static_cast(pair.actors[1]->userData);\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\tentry.bodyB = body;\r\n\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\tbody->getCollisions().PushBack(entry);\r\n\r\n\t\t\t\t}\r\n\t\t\t\t}*/\r\n\t\t\t\t/*getWorld()->getCollisions().PushBack(entry);*/\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nint pWorld::overlapOBBShapes(const VxBbox& worldBounds, CK3dEntity*shapeReference, pShapesType shapeType,CKGroup *shapes,int activeGroups/* =0xffffffff */, const pGroupsMask* groupsMask/* =NULL */, bool accurateCollision/* =false */)\r\n{\r\n\r\n\tint result=0;\r\n\r\n\tNxBox box;\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\r\n\t\tNxShape *shape = getShapeByEntityID(shapeReference->GetID());\r\n\t\tif (shape)\r\n\t\t{\r\n\t\t\t//shape->checkOverlapAABB()\r\n\r\n\t\t\tNxBoxShape*boxShape = static_cast(shape->isBox());\r\n\t\t\tif (boxShape)\r\n\t\t\t{\r\n\t\t\t\tboxShape->getWorldOBB(box);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}else{\r\n\r\n\t\tbox.center = getFrom(worldBounds.GetCenter());\r\n\t\tbox.extents = getFrom(worldBounds.GetSize());\r\n\t}\r\n\r\n\tint total = 0;\r\n\tif (shapeType & ST_Dynamic )\r\n\t{\r\n\t\ttotal+=getScene()->getNbDynamicShapes();\r\n\t}\r\n\r\n\tif (shapeType & ST_Static)\r\n\t{\r\n\t\ttotal+=getScene()->getNbStaticShapes();\r\n\t}\r\n\r\n\tNxShape** _shapes = (NxShape**)NxAlloca(total*sizeof(NxShape*));\r\n\tfor (NxU32 i = 0; i < total; i++) _shapes[i] = NULL;\r\n\r\n\r\n\r\n\tNxGroupsMask mask;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask.bits0 = groupsMask->bits0;\r\n\t\tmask.bits1 = groupsMask->bits1;\r\n\t\tmask.bits2 = groupsMask->bits2;\r\n\t\tmask.bits3 = groupsMask->bits3;\r\n\t}else{\r\n\r\n\t\tmask.bits0 = 0;\r\n\t\tmask.bits1 = 0;\r\n\t\tmask.bits2 = 0;\r\n\t\tmask.bits3 = 0;\r\n\r\n\t}\r\n\r\n\r\n\r\n\r\n\tresult = getScene()->overlapOBBShapes(box,(NxShapesType)shapeType,total,_shapes,NULL,activeGroups,&mask,accurateCollision);\r\n\r\n\tif (_shapes && shapes )\r\n\t{\r\n\t\tfor (int i = 0 ; i < result ; i++)\r\n\t\t{\r\n\t\t\tNxShape *s = _shapes[i];\r\n\t\t\tif (s)\r\n\t\t\t{\r\n\t\t\t\tconst char* name =s->getName();\r\n\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\tif (obj)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tshapes->AddObject((CKBeObject*)obj);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tint op=2;\r\n\r\n\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pWorld::overlapSphereShapes(const VxSphere& worldSphere,CK3dEntity*shapeReference,pShapesType shapeType,CKGroup*shapes,int activeGroups/* =0xffffffff */, const pGroupsMask* groupsMask/* =NULL */, bool accurateCollision/* =false */)\r\n{\r\n\r\n\tint result=0;\r\n\r\n\tNxSphere sphere;\r\n\t\r\n\tif (shapeReference)\r\n\t{\r\n\t\t\r\n\t\t\tNxShape *shape = getShapeByEntityID(shapeReference->GetID());\r\n\t\t\tif (shape)\r\n\t\t\t{\r\n\t\t\t\t//shape->checkOverlapAABB()\r\n\r\n\t\t\t\tNxSphereShape *sphereShape = static_cast(shape->isSphere());\r\n\t\t\t\tif (sphereShape)\r\n\t\t\t\t{\r\n\t\t\t\t\tsphere.radius = sphereShape->getRadius() + worldSphere.Radius();\r\n\r\n\t\t\t\t\t//ori : \r\n\t\t\t\t\tVxVector ori = worldSphere.Center();\r\n\t\t\t\t\tVxVector oriOut = ori;\r\n\t\t\t\t\tif (shapeReference)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tshapeReference->Transform(&oriOut,&ori);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tsphere.center = getFrom(oriOut);\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t}else{\r\n\r\n\t\tsphere.center = getFrom(worldSphere.Center());\r\n\t\tsphere.radius = worldSphere.Radius();\r\n\r\n\t}\r\n\r\n\tint total = 0;\r\n\tif (shapeType & ST_Dynamic )\r\n\t{\r\n\t\ttotal+=getScene()->getNbDynamicShapes();\r\n\t}\r\n\t\r\n\tif (shapeType & ST_Static)\r\n\t{\r\n\t\ttotal+=getScene()->getNbStaticShapes();\r\n\t}\r\n\r\n\tNxShape** _shapes = (NxShape**)NxAlloca(total*sizeof(NxShape*));\r\n\tfor (NxU32 i = 0; i < total; i++) _shapes[i] = NULL;\r\n\r\n\r\n\r\n\tNxGroupsMask mask;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask.bits0 = groupsMask->bits0;\r\n\t\tmask.bits1 = groupsMask->bits1;\r\n\t\tmask.bits2 = groupsMask->bits2;\r\n\t\tmask.bits3 = groupsMask->bits3;\r\n\t}else{\r\n\r\n\t\tmask.bits0 = 0;\r\n\t\tmask.bits1 = 0;\r\n\t\tmask.bits2 = 0;\r\n\t\tmask.bits3 = 0;\r\n\r\n\t}\r\n\t\r\n\r\n\r\n\r\n\tresult = getScene()->overlapSphereShapes(sphere,(NxShapesType)shapeType,total,_shapes,NULL,activeGroups,&mask,accurateCollision);\r\n\r\n\tif (_shapes && shapes )\r\n\t{\r\n\t\tfor (int i = 0 ; i < result ; i++)\r\n\t\t{\r\n\t\t\tNxShape *s = _shapes[i];\r\n\t\t\tif (s)\r\n\t\t\t{\r\n\t\t\t\tconst char* name =s->getName();\r\n\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\tif (obj)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tshapes->AddObject((CKBeObject*)obj);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tint op=2;\r\n\r\n\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pWorld::raycastAllShapes(const VxRay& worldRay, pShapesType shapesType, int groups, float maxDist, pRaycastBit hintFlags, const pGroupsMask* groupsMask)\r\n{\r\n\r\n\tint result = 0;\r\n\r\n\tNxRay rayx;\r\n\trayx.dir = getFrom(worldRay.m_Direction);\r\n\trayx.orig = getFrom(worldRay.m_Origin);\r\n\r\n\tpRayCastReport &report = *getRaycastReport();\r\n\r\n\tNxGroupsMask *mask = NULL;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask = new NxGroupsMask();\r\n\t\tmask->bits0 = groupsMask->bits0;\r\n\t\tmask->bits1 = groupsMask->bits1;\r\n\t\tmask->bits2 = groupsMask->bits2;\r\n\t\tmask->bits3 = groupsMask->bits3;\r\n\r\n\t}\r\n\t\r\n\tresult = getScene()->raycastAllShapes(rayx,report,(NxShapesType)shapesType,groups,maxDist,hintFlags,mask);\r\n\treturn result;\r\n\r\n\r\n}\r\nbool pWorld::raycastAnyBounds(const VxRay& worldRay, pShapesType shapesType, pGroupsMask *groupsMask/* =NULL */,int groups/* =0xffffffff */, float maxDist/* =NX_MAX_F32 */)\r\n{\r\n\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tNxRay _worldRay;\r\n\t_worldRay.dir = getFrom(worldRay.m_Direction);\r\n\t_worldRay.orig = getFrom(worldRay.m_Origin);\r\n\t\r\n\tNxShapesType _shapesType = (NxShapesType)shapesType;\r\n\t\r\n\tNxReal _maxDist=maxDist;\r\n\t\r\n\tNxGroupsMask *mask = NULL;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask = new NxGroupsMask();\r\n\t\tmask->bits0 = groupsMask->bits0;\r\n\t\tmask->bits1 = groupsMask->bits1;\r\n\t\tmask->bits2 = groupsMask->bits2;\r\n\t\tmask->bits3 = groupsMask->bits3;\r\n\r\n\t}\r\n\tbool result = getScene()->raycastAnyBounds(_worldRay,_shapesType,groups,_maxDist,mask);\r\n\treturn result;\r\n\r\n}\r\n\r\nvoid pWorld::cIgnorePair(CK3dEntity *_a, CK3dEntity *_b, int ignore)\r\n{\r\n\r\n\tpRigidBody *a = GetPMan()->getBody(_a);\r\n\tpRigidBody *b = GetPMan()->getBody(_b);\r\n\tif (a&&b && a->getActor() && b->getActor() )\r\n\t{\r\n\t\tif (getScene())\r\n\t\t{\r\n\t\t\tgetScene()->setActorPairFlags(*a->getActor(),*b->getActor(),ignore ? NX_IGNORE_PAIR : NX_NOTIFY_ALL );\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pWorld::cSetGroupCollisionFlag(int g1 , int g2,int enabled)\r\n{\r\n\r\n\tif (getScene())\r\n\t{\r\n\r\n\t\tif (g1 >=0 && g1 <= 31 && g2 >=0 && g2 <= 31)\r\n\t\t{\r\n\t\t\tif (enabled==0 || enabled ==1)\r\n\t\t\t{\r\n\t\t\t\tgetScene()->setGroupCollisionFlag(g1,g2,enabled);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pTriggerReport::onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status)\r\n{\r\n\r\n\tNxActor *triggerActor = &triggerShape.getActor();\r\n\tNxActor *otherActor = &otherShape.getActor();\r\n\r\n\r\n\r\n\r\n\tpRigidBody *triggerBody = NULL;\r\n\tpRigidBody *otherBody = NULL;\r\n\r\n\tif (triggerActor)\r\n\t{\r\n\t\ttriggerBody = static_cast(triggerActor->userData);\r\n\t\ttriggerBody->getTriggers().Clear();\r\n\t}\r\n\r\n\tif (otherActor)\r\n\t{\r\n\t\totherBody = static_cast(otherActor->userData);\r\n\t\totherBody->getTriggers().Clear();\r\n\t}\r\n\t\r\n\r\n\tpTriggerEntry entry;\r\n\tentry.shapeA = &triggerShape;\r\n\tentry.shapeB = &otherShape;\r\n\tentry.triggerEvent = status;\r\n\r\n\tif (triggerBody)\r\n\t{\r\n\t\ttriggerBody->getTriggers().PushBack(entry);\r\n\r\n\t}\r\n\t/*if(status & NX_TRIGGER_ON_ENTER)\r\n\t{\r\n\r\n\r\n\t}\r\n\tif(status & NX_TRIGGER_ON_LEAVE)\r\n\t{\r\n\t\t\t\t\r\n\t}\r\n\tif(status & NX_TRIGGER_ON_STAY)\r\n\t{\r\n\t\t// A body entered the trigger area for the first time\r\n\r\n\t}*/\r\n\r\n\t\r\n\t\r\n\r\n}\r\n\r\n\r\nvoid pWorld::initUserReports()\r\n{\r\n\t\r\n\tcontactReport = new pContactReport();\r\n\tcontactReport->setWorld(this);\r\n\r\n\ttriggerReport = new pTriggerReport();\r\n\ttriggerReport->setWorld(this);\r\n\r\n\traycastReport = new pRayCastReport();\r\n\traycastReport->setWorld(this);\r\n\r\n\t//getScene()->raycastAllShapes()\r\n\r\n\r\n}\r\nbool pRayCastReport::onHit(const NxRaycastHit& hit)\r\n{\r\n\r\n\tCKBehavior *beh =(CKBehavior*)GetPMan()->m_Context->GetObject(mCurrentBehavior);\r\n\tif ( beh )\r\n\t{\r\n\t\tpRayCastHits *carray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&carray);\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\t//carray->clear();\r\n\t\t}else\r\n\t\t{\r\n\t\t\tcarray = new pRayCastHits();\r\n\t\t}\r\n\r\n\t\t//carray->push_back(const_cast(&hit));\r\n\r\n\t\tNxRaycastHit *_hit = new NxRaycastHit();\r\n\r\n\t\t_hit->distance = hit.distance;\r\n\t\t_hit->faceID = hit.faceID;\r\n\t\t_hit->flags = hit.flags;\r\n\t\t_hit->internalFaceID = hit.internalFaceID;\r\n\t\t_hit->materialIndex = hit.materialIndex;\r\n\t\t_hit->shape = hit.shape;\r\n\t\t_hit->u = hit.u;\r\n\t\t_hit->v = hit.v;\r\n\t\t_hit->worldImpact = hit.worldImpact;\r\n\t\t_hit->worldNormal = hit.worldNormal;\r\n\t\t\r\n\t\tconst char *name = hit.shape->getName();\r\n\t\t\r\n\t\tcarray->push_back(_hit);\r\n\r\n\r\n\r\n\r\n\t\tbeh->SetLocalParameterValue(0,&carray);\r\n\r\n\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nvoid pWorld::setFilterOps(pFilterOp op0,pFilterOp op1, pFilterOp op2)\r\n{\r\n\tgetScene()->setFilterOps((NxFilterOp)op0,(NxFilterOp)op1,(NxFilterOp)op2);\r\n}\r\n\r\nvoid pWorld::setFilterBool(bool flag)\r\n{\r\n\tgetScene()->setFilterBool(flag);\r\n}\r\nvoid pWorld::setFilterConstant0(const pGroupsMask& mask)\r\n{\r\n\tNxGroupsMask _mask;\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\t\r\n\tgetScene()->setFilterConstant0(_mask);\r\n}\r\n\r\nvoid pWorld::setFilterConstant1(const pGroupsMask& mask)\r\n{\r\n\tNxGroupsMask _mask;\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\r\n\tgetScene()->setFilterConstant1(_mask);\r\n}\r\n\r\nbool pWorld::getFilterBool()const\r\n{\r\n\treturn getScene()->getFilterBool();\r\n}\r\n\r\npGroupsMask pWorld::getFilterConstant0()const\r\n{\r\n\tNxGroupsMask mask = getScene()->getFilterConstant0();\r\n\tpGroupsMask _mask;\r\n\t\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\r\n\treturn _mask;\r\n\r\n}\r\n\r\npGroupsMask pWorld::getFilterConstant1()const\r\n{\r\n\tNxGroupsMask mask = getScene()->getFilterConstant1();\r\n\tpGroupsMask _mask;\r\n\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\r\n\treturn _mask;\r\n\r\n}\r\n\r\n\r\n\r\n/*\r\nint\r\npWorld::CIsInCollision(CK3dEntity*_a,CK3dEntity*_b)\r\n{\r\n\r\n\tpWorld *world=GetPMan()->getWorldByBody(_a); \r\n\tpWorld *world2=GetPMan()->getWorldByBody(_b); \r\n\r\n\r\n\tif (!world || !world2 || world!=world2 )\r\n\t\treturn false;\r\n\r\n\tpRigidBody*bodyA= world->getBody(_a);\r\n\tpRigidBody*bodyB= world->getBody(_b);\r\n\r\n\tdSurfaceParameters *surface = NULL;\r\n\tbool worldHasSurface = ( world->GetDataFlags() & WDF_HAS_SURFACE_PARAMETER ) ;\r\n\r\n\r\n\tbool useSurface = false;\r\n\r\n\tif (worldHasSurface)\r\n\t{\r\n\t\tsurface = &GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif ( bodyA->GetDataFlags() & BDF_HAS_SURFACE_PARAMETER )\r\n\t{\r\n\t\tsurface = &bodyA->GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif ( bodyB->GetDataFlags() & BDF_HAS_SURFACE_PARAMETER )\r\n\t{\r\n\t\tsurface = &bodyB->GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\r\n\tpRigidBody *surfaceMaterialBody=NULL;\r\n\r\n\tif (bodyA->GetDataFlags() & BDF_HAS_MATERIAL_SURFACE_PARAMETER)\r\n\t{\r\n\r\n\t\tsurfaceMaterialBody = bodyA;\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif (bodyB->GetDataFlags() & BDF_HAS_MATERIAL_SURFACE_PARAMETER)\r\n\t{\r\n\r\n\t\tsurfaceMaterialBody = bodyB;\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif (bodyA && bodyB && bodyA !=bodyB)\r\n\t{\r\n\t\tdGeomID gid1 = bodyA->GetOdeGeom();\r\n\t\tdGeomID gid2 = bodyB->GetOdeGeom();\r\n\t\tif (gid1 && gid2 && gid1!=gid2)\r\n\t\t{\r\n\t\t\tdContact *contact = new dContact[1];\r\n\t\t\tint nbContacts = dCollide (gid1,gid2,1,&contact[0].geom,sizeof(dContactGeom));\r\n\t\t\tif (nbContacts)\r\n\t\t\t{\r\n\t\t\t\tfor (int i=0; i < nbContacts; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (surfaceMaterialBody)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tCK3dEntity *colliderB = NULL;\r\n\t\t\t\t\t\tif (surfaceMaterialBody->GetVT3DObject() == _a )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcolliderB = _b;\r\n\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\tcolliderB = _a;\r\n\r\n\t\t\t\t\t\tif (surfaceMaterialBody->GetVT3DObject() == colliderB )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tint op = 3;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tVxVector cPos(contact[i].geom.pos[0],contact[i].geom.pos[1],contact[i].geom.pos[2] );\r\n\r\n\t\t\t\t\t\tint faceIndex = vtAgeia::math::GetNearestFace(surfaceMaterialBody->GetVT3DObject(),cPos);\r\n\t\t\t\t\r\n\r\n\t\t\t\t\t\tCKMesh * mesh = surfaceMaterialBody->GetVT3DObject()->GetCurrentMesh();\r\n\t\t\t\t\t\tif (mesh)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\r\n\t\t\t\t\t\t\tVxVector pos1,pos2;\r\n\t\t\t\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->GetBaryCenter(&pos2);\r\n\t\t\t\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->Transform(&pos2,&pos2);\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tVxIntersectionDesc desc;\r\n\t\t\t\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->RayIntersection(&cPos,&pos2,&desc,NULL);\r\n CKMaterial *material = mesh->GetFaceMaterial(desc.FaceIndex);\r\n\t\t\t\t\t\t\tif (material)\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\tPhysicMaterialList& mList = surfaceMaterialBody->GetPhysicMaterials();\r\n\t\t\t\t\t\t\t\tint mSize = mList.Size();\r\n\t\t\t\t\t\t\t\tPhysicMaterialList::Iterator it = mList.Find(material->GetID() );\r\n\t\t\t\t\t\t\t\tif( it != mList.End() )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tdSurfaceParameters *sPar = *it;\r\n\t\t\t\t\t\t\t\t\tif (sPar)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tsurface = sPar;\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\nvoid collisionCallback(void *data,dGeomID o1,dGeomID o2)\r\n{\r\n\r\n\tpWorld *world = static_cast(data);\r\n\tif(!world)\r\n\t\treturn;\r\n\r\n\r\n\tif( !o1 || !o2)\r\n\t\treturn;\r\n\tif (!o1->body && !o2->body) return;\r\n\r\n\tif( o1 == o2 )\r\n\t\treturn;\r\n\r\n\tif (dGeomIsSpace(o1) || dGeomIsSpace(o2))\r\n\t{\r\n\t\t// colliding a space with something\r\n\t\tdSpaceCollide2(o1,o2,data,&collisionCallback);\r\n\t\t// Note we do not want to test intersections within a space,\r\n\t\t// only between spaces.\r\n\t\treturn;\r\n\t}\r\n\r\n\tdBodyID b1,b2;\r\n\r\n\tb1 = dGeomgetBody(o1);\r\n\tb2 = dGeomgetBody(o2);\r\n\r\n\tCK_ID e1 = (CK_ID)(dGeomGetData(o1));\r\n\tCK_ID e2 = (CK_ID)(dGeomGetData(o2));\r\n\r\n\r\n\tCK3dEntity *_e1 = static_cast(GetPMan()->m_Context->GetObject(e1));\r\n\tCK3dEntity* _e2 = static_cast(GetPMan()->m_Context->GetObject(e2));\r\n\r\n\t// exit without doing anything if the two bodies are connected by a joint\r\n\tif (b1 && b2 && dAreConnected (b1,b2)) return;\r\n\r\n\tpRigidBody *solid1 = world->getBody(_e1);\r\n\tpRigidBody *solid2 = world->getBody(_e2);\r\n\r\n\tif (!solid1 || !solid2)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tfloat friction=solid1->GetFriction();\r\n\tfloat restitution = solid1->GetRestitution();\r\n\t//for friction, take minimum\r\n\r\n\tfriction=(friction < solid2->GetFriction() ? \tfriction :solid2->GetFriction());\r\n\r\n\t//restitution:take minimum\r\n\trestitution = restitution < solid2->GetRestitution()\t?\trestitution : solid2->GetRestitution();\r\n\r\n\t\r\n\r\n\tdSurfaceParameters *surface = NULL;\r\n\tbool worldHasSurface = ( world->GetDataFlags() & WDF_HAS_SURFACE_PARAMETER ) ;\r\n\t\r\n\r\n\tbool useSurface = false;\r\n\r\n\tif (worldHasSurface)\r\n\t{\r\n\t\tsurface = &world->GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif ( solid1->GetDataFlags() & BDF_HAS_SURFACE_PARAMETER )\r\n\t{\r\n\t\tsurface = &solid1->GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif ( solid2->GetDataFlags() & BDF_HAS_SURFACE_PARAMETER )\r\n\t{\r\n\t\tsurface = &solid2->GetDefaultSurface();\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\r\n\tpRigidBody *surfaceMaterialBody=NULL;\r\n\t\r\n\tif (solid1->GetDataFlags() & BDF_HAS_MATERIAL_SURFACE_PARAMETER)\r\n\t{\r\n \r\n\t\tsurfaceMaterialBody = solid1;\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\tif (solid2->GetDataFlags() & BDF_HAS_MATERIAL_SURFACE_PARAMETER)\r\n\t{\r\n\r\n\t\tsurfaceMaterialBody = solid2;\r\n\t\tuseSurface = true;\r\n\t}\r\n\r\n\r\n\tdContact contact[10];\r\n\t\r\n\tif (int numc = dCollide (o1, o2, 10,&contact[0].geom, sizeof(dContact)))\r\n\t{\r\n\t\tfor (int i=0; i < numc; i++)\r\n\t\t{\r\n\r\n\t\t\tif (contact[i].geom.depth > 0.0f && contact[i].geom.depth <= 0.0001f)\r\n\t\t\t{\r\n\t\t\t\tcontact[i].geom.depth = 0.001f;\r\n\t\t\t}\r\n\t\t\tif (contact[i].geom.depth == 0.0f)\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (surfaceMaterialBody)\r\n\t\t\t{\r\n\r\n\t\t\t\t\r\n\t\t\t\tCK3dEntity *colliderB = NULL;\r\n\t\t\t\tif (surfaceMaterialBody->GetVT3DObject() == _e1 )\r\n\t\t\t\t{\r\n\t\t\t\t\tcolliderB = _e2;\r\n\t\t\t\t}else\r\n\t\t\t\t\tcolliderB = _e1;\r\n\t\t\t\t\r\n\t\t\t\tVxVector cPos(contact[i].geom.pos[0],contact[i].geom.pos[1],contact[i].geom.pos[2] );\r\n\t\t\t\t//int faceIndex = vtODE::math::GetNearestFace(surfaceMaterialBody->GetVT3DObject(),cPos);\r\n\t\t\t\tVxVector pos1,pos2;\r\n\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->GetBaryCenter(&pos2);\r\n\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->Transform(&pos2,&pos2);\r\n\r\n\t\t\t\tVxIntersectionDesc desc;\r\n\t\t\t\tsurfaceMaterialBody->GetVT3DObject()->RayIntersection(&cPos,&pos2,&desc,NULL);\r\n\t\t\t\tint faceIndex = desc.FaceIndex;\r\n\t\t\t\tCKMesh * mesh = surfaceMaterialBody->GetVT3DObject()->GetCurrentMesh();\r\n\t\t\t\tif (mesh)\r\n\t\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t\tCKMaterial *material = mesh->GetFaceMaterial(faceIndex);\r\n\t\t\t\t\tif (material)\r\n\t\t\t\t\t{\r\n \r\n\t\t\t\t\t\tPhysicMaterialList& mList = surfaceMaterialBody->GetPhysicMaterials();\r\n\t\t\t\t\t\tint mSize = mList.Size();\r\n\t\t\t\t\t\tPhysicMaterialList::Iterator it = mList.Find(material->GetID() );\r\n\t\t\t\t\t\tif( it != mList.End() )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdSurfaceParameters *sPar = *it;\r\n\t\t\t\t\t\t\tif (sPar)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsurface = sPar;\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif ( useSurface)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\tcontact[i].surface.mode = surface->mode; \r\n\t\t\t\tcontact[i].surface.mu = surface->mu;\r\n\t\t\t\tcontact[i].surface.mu2 = friction;\r\n\t\t\t\tcontact[i].surface.slip1 = surface->slip1;\r\n\t\t\t\tcontact[i].surface.slip2 = surface->slip2;\r\n\t\t\t\tcontact[i].surface.motion1 = surface->motion1;\r\n\t\t\t\tcontact[i].surface.motion2 = surface->motion2;\r\n\t\t\t\tcontact[i].surface.motionN = surface->motionN;\r\n\t\t\t\tcontact[i].surface.soft_erp = surface->soft_erp;\r\n\t\t\t\tcontact[i].surface.soft_cfm = surface->soft_cfm;\r\n\t\t\t\tcontact[i].surface.bounce = restitution;//0.5;\r\n\t\t\t\tcontact[i].surface.bounce_vel = surface->bounce_vel;\r\n\t\t\t}else\r\n\t\t\t{\r\n\r\n\t\t\t\t//contact[i].surface.mode = dContactSlip1 | dContactSlip2 |dContactBounce|dContactSoftERP | dContactSoftCFM | dContactApprox1;\r\n\t\t\t\t//contact[i].surface.mode = dContactSoftERP | dContactApprox1| dContactApprox0 | dContactSoftCFM|dContactBounce ;\r\n\t\t\t\t//contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactApprox1 |dContactBounce;\r\n\t\t\t\tcontact[i].surface.mode = dContactSoftERP | dContactSoftCFM | dContactSlip1 | dContactSlip2;\r\n\t\t\t\t//contact[i].surface.mode = dContactSoftERP | dContactSoftCFM | dContactBounce| dContactApprox0| dContactSlip1 | dContactSlip2;\r\n\t\t\t\t//contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactApprox1 ;\r\n\t\t\t\tcontact[i].surface.mu = dInfinity;\r\n\t\t\t\tcontact[i].surface.mu2 = friction;\r\n\t\t\t\tcontact[i].surface.slip1 = 0.000001;\r\n\t\t\t\tcontact[i].surface.slip2 = 0.000001;\r\n\t\t\t\tcontact[i].surface.soft_erp = 0.4;\r\n\t\t\t\tcontact[i].surface.soft_cfm = 0.000000005;\r\n\t\t\t\tcontact[i].surface.bounce = restitution;//0.5;\r\n\t\t\t\tcontact[i].surface.bounce_vel = 0.0000001f;\r\n\t\t\t}\r\n\r\n\t\t\tdJointID c = dJointCreateContact (world->World(),world->ContactGroup(),contact+i);\r\n\t\t\tdJointAttach (c,dGeomgetBody(o1),dGeomgetBody(o2));\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nbool pWorld::collide()\r\n{\r\n\r\n\tSpaceID()->collide(this,&collisionCallback);\r\n\r\n\treturn true;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvt3DObjectType pWorld::CIsInCollision(vt3DObjectType a, CKGroup *group,VxVector& pos, VxVector& normal,float &length)\r\n{\r\n\r\n\tpRigidBody *bodyA = getBody(a);\r\n\r\n\tdGeomID gid1 = NULL;\r\n\tif (bodyA)\r\n\t{\r\n\t\tgid1 = bodyA->GetOdeGeom();\r\n\t}\r\n\r\n\tif (!a || !group || !bodyA || !gid1)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tfor (int i = 0 ; i < group->GetObjectCount() ; i ++)\r\n\t{\r\n\r\n\t\tpRigidBody*bodyB= getBody((CK3dEntity*)group->GetObject(i));\r\n\t\tif (bodyB)\r\n\t\t{\r\n\r\n\t\t\tif (bodyB==bodyA)\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB)\r\n\t\t\t{\r\n\t\t\t\tdGeomID gid2 = bodyB->GetOdeGeom();\r\n\t\t\t\tif (gid1==gid2)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (gid2)\r\n\t\t\t\t{\r\n\t\t\t\t\tdContact *contact = new dContact[1];\r\n\r\n\t\t\t\t\tint nbContacts = dCollide (gid1,gid2,1,&contact[0].geom,sizeof(dContactGeom));\r\n\t\t\t\t\tif (nbContacts)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (int i = 0 ; i < nbContacts ; i++ )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpos.x = contact[0].geom.pos[0];\r\n\t\t\t\t\t\t\tpos.y = contact[0].geom.pos[1];\r\n\t\t\t\t\t\t\tpos.z = contact[0].geom.pos[2];\r\n\r\n\t\t\t\t\t\t\tnormal.x =contact[0].geom.normal[0];\r\n\t\t\t\t\t\t\tnormal.y =contact[0].geom.normal[1];\r\n\t\t\t\t\t\t\tnormal.z = contact[0].geom.normal[2];\r\n\r\n\t\t\t\t\t\t\treturn bodyB->GetVT3DObject();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvt3DObjectType pWorld::CRayCollision(VxVector point,CK3dEntity*pointRef,VxVector dir,CK3dEntity*dirRef,float depth,bool skipPosRef,VxVector& pos, VxVector& normal)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//origin of the ray : \r\n\tVxVector origin = point;\r\n\tVxVector originOut = origin;\r\n\tif (pointRef)\r\n\t{\r\n\t\tpointRef->Transform(&originOut,&origin);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//direction of the ray : \r\n\tVxVector dirIn = dir;\r\n\tVxVector dirOut = dirIn;\r\n\tif (dirRef)\r\n\t{\r\n\t\tVxVector dirl,up,right;\r\n\t\tdirRef->GetOrientation(&dirl,&up,&right);\r\n\t\tdirRef->TransformVector(&dirOut,&dirIn);\r\n\t}\r\n\r\n\t//dirOut*=dirIn;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpRigidBody *bodyA = NULL;\r\n\tdGeomID gid1 = NULL;\r\n\t//if position reference is given : \r\n\tif (pointRef)\r\n\t{\r\n\t\tbodyA = getBody(pointRef);\r\n\t\tif (bodyA)\r\n\t\t{\r\n\t\t\tgid1 = bodyA->GetOdeGeom();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//our ray : \r\n\tdGeomID raygeom = dCreateRay(SpaceID(),depth);\r\n\tif (raygeom)\r\n\t{\r\n\t\tdGeomRaySet(raygeom,originOut.x,originOut.y,originOut.z,dirOut.x,dirOut.y,dirOut.z);\r\n\t}\r\n\r\n\tif (!raygeom)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we check through the world :\r\n\r\n\tdxBody *bb;\r\n\tfor (bb=World()->firstbody; bb; bb=(dxBody*)bb->next) \r\n\t{\r\n\t\tpRigidBody *bodyB = static_cast(dBodyGetData(bb));\r\n\t\tif (bodyB)\r\n\t\t{\r\n\t\t\tdGeomID gid2 = bodyB->GetOdeGeom();\r\n\t\t\tCK3dEntity *ent2 = bodyB->GetVT3DObject();\r\n\r\n\t\t\tif (gid2)\r\n\t\t\t{\r\n\t\t\t\tdContact *contact = new dContact[1];\r\n\r\n\t\t\t\tint nbContacts = dCollide (raygeom,gid2,1,&contact[0].geom,sizeof(dContactGeom));\r\n\t\t\t\tif (nbContacts)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (gid1 && gid2 == gid1 && skipPosRef )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tpos.x = contact[0].geom.pos[0];\r\n\t\t\t\t\tpos.y = contact[0].geom.pos[1];\r\n\t\t\t\t\tpos.z = contact[0].geom.pos[2];\r\n\r\n\t\t\t\t\tnormal.x =contact[0].geom.normal[0];\r\n\t\t\t\t\tnormal.y =contact[0].geom.normal[1];\r\n\t\t\t\t\tnormal.z = contact[0].geom.normal[2];\r\n\r\n\t\t\t\t\treturn bodyB->GetVT3DObject();\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvt3DObjectType pWorld::CIsInCollision(vt3DObjectType a, VxVector& pos, VxVector& normal,float &length)\r\n{\r\n\tpWorld *world=GetPMan()->getWorldByBody(a); \r\n\tif (world)\r\n\t{\r\n\r\n\t\tpRigidBody*bodyA= world->getBody(a);\r\n\t\tif (bodyA)\r\n\t\t{\r\n\t\t\tdGeomID gid1 = bodyA->GetOdeGeom();\r\n\t\t\tif (gid1)\r\n\t\t\t{\r\n\t\t\t\tdxBody *bb;\r\n\t\t\t\tfor (bb=world->World()->firstbody; bb; bb=(dxBody*)bb->next) \r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *bodyB = static_cast(dBodyGetData(bb));\r\n\t\t\t\t\tif (bodyB==bodyA)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (bodyB)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tdGeomID gid2 = bodyB->GetOdeGeom();\r\n\t\t\t\t\t\tif (gid1==gid2)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (gid2)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdContact *contact = new dContact[1];\r\n\r\n\t\t\t\t\t\t\tint nbContacts = dCollide (gid1,gid2,1,&contact[0].geom,sizeof(dContactGeom));\r\n\t\t\t\t\t\t\tif (nbContacts)\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\tpos.x = contact[0].geom.pos[0];\r\n\t\t\t\t\t\t\t\tpos.y = contact[0].geom.pos[1];\r\n\t\t\t\t\t\t\t\tpos.z = contact[0].geom.pos[2];\r\n\r\n\t\t\t\t\t\t\t\tnormal.x =contact[0].geom.normal[0];\r\n\t\t\t\t\t\t\t\tnormal.y =contact[0].geom.normal[1];\r\n\t\t\t\t\t\t\t\tnormal.z = contact[0].geom.normal[2];\r\n\r\n\t\t\t\t\t\t\t\tlength = contact[0].geom.depth;\r\n\t\t\t\t\t\t\t\treturn bodyB->GetVT3DObject(); \r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nbool pWorld::CIsInCollision(vt3DObjectType a, vt3DObjectType b,VxVector& pos, VxVector& normal,float &length)\r\n{\r\n\r\n\tbool result = false;\r\n\r\n\tpWorld *world=GetPMan()->getWorldByBody(a); \r\n\tpWorld *world2=GetPMan()->getWorldByBody(b); \r\n\r\n\r\n\tif (!world || !world2 || world!=world2 )\r\n\t\treturn false;\r\n\r\n\tpRigidBody*bodyA= world->getBody(a);\r\n\tpRigidBody*bodyB= world->getBody(b);\r\n\r\n\tif (bodyA && bodyB && bodyA !=bodyB)\r\n\t{\r\n\t\tdGeomID gid1 = bodyA->GetOdeGeom();\r\n\t\tdGeomID gid2 = bodyB->GetOdeGeom();\r\n\t\tif (gid1 && gid2 && gid1!=gid2)\r\n\t\t{\r\n\t\t\tdContact *contact = new dContact[1];\r\n\t\t\tint nbContacts = dCollide (gid1,gid2,1,&contact[0].geom,sizeof(dContactGeom));\r\n\t\t\tif (nbContacts)\r\n\t\t\t{\r\n\t\t\t\tpos.x = contact[0].geom.pos[0];\r\n\t\t\t\tpos.y = contact[0].geom.pos[1];\r\n\t\t\t\tpos.z = contact[0].geom.pos[2];\r\n\r\n\t\t\t\tnormal.x =contact[0].geom.normal[0];\r\n\t\t\t\tnormal.y =contact[0].geom.normal[1];\r\n\t\t\t\tnormal.z = contact[0].geom.normal[2];\r\n\t\t\t\tlength = contact[0].geom.depth;\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n*/#ifndef __PREREQUISITES_PHYS_X_H__\r\n#define __PREREQUISITES_PHYS_X_H__\r\n\r\nclass NxCompartment;\r\nclass NxActor;\r\nclass NxActorDesc;\r\nclass NxScene;\r\nclass NxSceneDescr;\r\nclass NxUserNotify;\r\nclass NxFluidUserNotify;\r\nclass NxCloth;\r\nclass NxClothDesc;\r\nclass NxClothUserNotify;\r\nclass NxClothMeshDesc;\r\n\r\nclass NxSoftBodyUserNotify;\r\nclass NxUserContactModify;\r\nclass NxUserTriggerReport;\r\nclass NxUserContactReport;\r\nclass NxUserActorPairFiltering;\r\nclass NxBounds3;\r\nclass NxUserScheduler;\r\nclass NxSceneDesc;\r\nclass NxBodyDesc;\r\nclass NxShapeDesc;\r\nclass NxMaterial;\r\nclass NxMaterialDesc;\r\nclass NxUserDebugRenderer;\r\nclass NxTriangleMesh;\r\nclass NxTriangleMeshDesc;\r\nclass NxConvexMesh;\r\nclass NxConvexMeshDesc;\r\nclass NxUserOutputStream;\r\nclass NxUserAllocator;\r\nclass NxJoint;\r\nclass NxD6Joint;\r\n\r\nclass NxStream;\r\nclass NxFoundationSDK;\r\nclass NxCCDSkeleton;\t\t\t//this class doesn't actually exist.\r\nclass NxSimpleTriangleMesh;\r\nclass NxHeightField;\r\nclass NxHeightFieldDesc;\r\n\r\nclass NxPhysicsSDKDesc;\r\nclass NxPhysicsSDK;\r\nclass NxMeshData;\r\nclass NxClothMesh;\r\nclass NxControllerManager;\r\nclass NxBoxController;\r\nclass NxBoxControllerDesc;\r\nclass NxCapsuleController;\r\nclass NxCapsuleControllerDesc;\r\nclass UserAllocator;\r\nclass NxRemoteDebugger;\r\nclass NxShape;\r\nclass NxContactPair;\r\nclass NxConvexShapeDesc;\r\nclass NxWheelShape;\r\nclass NxConvexShape;\r\nclass NxCapsuleShape;\r\nclass NxRaycastHit;\r\nclass NxWheelContactData;\r\n\r\n\r\n#if NX_USE_CLOTH_API\r\n\tclass NxClothMesh;\r\n#endif\r\n#if NX_USE_SOFTBODY_API\r\n\tclass NxSoftBodyMesh;\r\n#endif\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief NxU Stream\r\n//\r\nnamespace NXU\r\n{\r\n\r\n\tclass NxActorDesc;\r\n\tclass NxuPhysicsCollection;\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n#endifdofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\nif _ACTION == \"clean\" then\r\n\tos.rmdir(\"./vs*\")\r\n\tos.rmdir(\"../Temp\")\r\n\treturn\r\nend\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\nsolution \"vtTools\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\n\r\npackageConfig_Behaviours =\r\n{\r\n\tName \t\t= \t\"vtToolkit\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" ; \"_AFXDLL\" },\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tFiles\t\t= { D_INCLUDE_ROOT..\"*.h\" ; D_INCLUDE_ROOT..\"Core/**.h\" ; D_CORE_SRC..\"**.c*\";\tD_BB_SRC..\"**.c*\" ; D_BB_SRC..\"*.def\" },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDE_DIRS ; D_DIRECTX9..\"Include\"\t},\r\n\tLibs\t= {\t\"user32\" ; \"kernel32\" ; \"dxerr\"; \"dinput8\" ; \"dxguid\"\t},\r\n\tLibDirectories = { \tD_DIRECTX9..\"lib\" },\r\n\tStaticOptions = { \"convert\" },\r\n\tOptions = { \"/W0 /wd4430\"},\r\n\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n}\r\n\r\npackageConfig_RemoteConsole =\r\n{\r\n\tName \t\t= \t\"vtRemoteConsole\",\r\n\tType\t\t=\t\"ConsoleApp\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; \"VIRTOOLS_USER_SDK\" },\r\n\tTargetSuffix = \"\",\r\n\tFiles\t\t= { D_INCLUDE_ROOT..\"*.h\" ; D_INCLUDE_ROOT..\"Core/**.h\" ; DROOT..\"Test/RemoteConsole/*.**\"},\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDE_DIRS ; \t},\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ;\t},\r\n\tLibDirectories = { \t },\r\n\tOptions = { \"/W1\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n}\r\n\r\ncreateStaticPackage(packageConfig_Behaviours)\r\n--createStaticPackage(packageConfig_RemoteConsole)\r\n\r\n\r\nfunction onclean()\r\n\tprint(\"cleaning\")\r\n\tos.rmdir(\"vs*\")\r\nend\r\n#ifndef _XDISTRIBUTED_3F_H_\r\n#define _XDISTRIBUTED_3F_H_\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xPoint.h\"\r\nclass xDistributedPoint3F : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n//\t\ttypedef xDistributedPropertyBaseDataBase;\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedPoint3F ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\tmLastValue = Point3F(0,0,0);\r\n\t\t\tmCurrentValue= Point3F(0,0,0);\r\n\t\t\tmDifference = Point3F(0,0,0);\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\r\n\t\tvirtual ~xDistributedPoint3F(){}\r\n\r\n\t\tPoint3F mLastValue;\r\n\t\tPoint3F mCurrentValue;\r\n\t\tPoint3F mDifference;\r\n\r\n\t\tPoint3F mLastServerValue;\r\n\t\tPoint3F mLastServerDifference;\r\n \r\n\t\tbool updateValue(Point3F value,xTimeType currentTime);\r\n\t\tPoint3F getDiff(Point3F value);\r\n void pack(xNStream *bstream);\r\n\t\tvoid unpack(xNStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(xNStream *stream);\r\n\t\tvoid updateFromServer(xNStream *stream);\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n \r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n#ifndef __PWORLDTYPES_H__\r\n#define __PWORLDTYPES_H__\r\n\r\n\r\n//################################################################\r\n//\r\n// Help structures and types\r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Meta info to track a broken joint from a NX-SDK callback to the next frame.\r\n//\r\nstruct pBrokenJointEntry\r\n{\r\n\tpJoint*joint;\r\n\tfloat impulse;\r\n\tCK_ID mAEnt;\r\n\tCK_ID mBEnt;\r\n\tbool isTriggered;\r\n\tint jType;\r\n\r\n\tpBrokenJointEntry()\r\n\t{\r\n\t\timpulse = 0 ;\r\n\t\tmAEnt = NULL;\r\n\t\tmBEnt = NULL;\r\n\t\tjType -1;\r\n\t\tisTriggered = false;\r\n\t}\r\n};\r\n\r\ntypedef XArrayJointFeedbackListType;\r\n\r\n\r\n/** \\addtogroup World\r\n@{\r\n*/\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Dominance setup for the scene\r\n//\r\nstruct pDominanceSetupItem\r\n{\r\n\tstruct pDominanceConstraint\r\n\t{\r\n\t\tfloat dominanceA;\r\n\t\tfloat dominanceB;\r\n\r\n\t\tpDominanceConstraint() : \r\n\t\tdominanceA(1.0f), \r\n\t\t\tdominanceB(0.0f)\r\n\t\t{\r\n\r\n\t\t}\r\n\t};\r\n\r\n\tpDominanceConstraint constraint;\r\n\r\n\tint dominanceGroup0;\r\n\tint dominanceGroup1;\r\n\r\n\tpDominanceSetupItem() : \r\n\tdominanceGroup0(0),\r\n\t\tdominanceGroup1(0)\r\n\t{\r\n\t}\r\n};\r\n\r\n/** @} */\r\n\r\n//################################################################\r\n//\r\n// User callbacks\r\n//\r\n#endif \r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetMidiINDevicesDecl();\r\nCKERROR CreateGetMidiINDevicesProto(CKBehaviorPrototype **pproto);\r\nint GetMidiINDevices(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetMidiINDevicesDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Get MidiIN Devices\");\t\r\n\tod->SetDescription(\"Returns all Midi IN Devices\");\r\n\tod->SetCategory(\"Controllers/Midi\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5f521403,0x3bef5561));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetMidiINDevicesProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGetMidiINDevicesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Get MidiIN Devices\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"Get Next\");\r\n\tproto->DeclareInput(\"Get Prev\");\r\n\t\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"LoopOut\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Name\",CKPGUID_STRING);\r\n\tproto->DeclareOutParameter(\"Index\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Count\",CKPGUID_INT);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tproto->SetFunction(GetMidiINDevices);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint indexD = 0;\r\nint countD = 0;\r\n\r\n\r\nint GetMidiINDevices(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tCKRenderManager *rm = (CKRenderManager *)ctx->GetRenderManager();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif( beh->IsInputActive(0) ){\r\n\r\n\t\tMidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n\t\tcountD=midiInGetNumDevs();\r\n\t\tif( !countD){\r\n\t\t\tmm->m_Context->OutputToConsole(\"No Midi IN Devices !\");\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\tbeh->ActivateInput(0, FALSE);\r\n\t\tindexD = 0;\r\n\t\tbeh->ActivateInput(1, TRUE);\r\n\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif( beh->IsInputActive(1) ){\r\n\t\t\tbeh->ActivateInput(1, FALSE);\r\n\t\t\r\n\t\t\tif (indexD > (countD-1)){\r\n\t\t\t\tindexD = 0;\r\n\t\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\t\treturn CKBR_OK;\r\n\t\t\t}\r\n\t\t\tbeh->SetOutputParameterValue(1,&indexD);\r\n\t\t\t\r\n\t\t\tMIDIINCAPS tmp;\r\n\t\t\tmidiInGetDevCaps(indexD, &tmp,sizeof(tmp) );\r\n\t\t\tindexD++;\r\n\t\t\tCKParameterOut *pout2 = beh->GetOutputParameter(0);\r\n\t\t\tpout2->SetStringValue( tmp.szPname );\r\n\t\t\tbeh->ActivateOutput(1);\r\n\r\n\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n\r\nclass NxActor;\r\nclass NxScene;\r\n#include \r\n#include \r\n\r\nNxActor* CookASE(const std::string& filename, NxScene* scene, NxVec3 offset = NxVec3(0,0,0), NxVec3 scale = NxVec3(1,1,1));\r\n#ifndef __IMessages_h\r\n#define __IMessages_h\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nclass Point3F;\r\nclass Point4F;\r\nclass xNetInterface;\r\nclass xNetworkMessage;\r\n\r\n\r\nclass IMessages\r\n{\r\n\tpublic:\r\n\r\n\t\tIMessages(xNetInterface *ninterface);\r\n\r\n\t\t\r\n\r\n\t\txMessageArrayType *getMessages();\r\n\r\n\t\txNetInterface * getNetInterface() const { return mNetInterface; }\r\n\t\tvoid setNetInterface(xNetInterface * val) { mNetInterface = val; }\r\n\r\n\t\tvoid addMessage(xMessage*msg);\r\n\t\txMessage*getNextOutMessage();\r\n\t\txMessage*getNextInMessage();\r\n\t\txMessage*getNextInMessage(xNString mName);\r\n\t\tvoid removeMessage(xMessage*msg);\r\n\t\tvoid deleteMessage(xMessage*msg);\r\n\t\tvoid deleteAllOldMessages();\r\n\t\tint getNumMessagesOfType(int type);\r\n\t\tint getNumOutMessages();\r\n\r\n\r\n\r\n\r\n\t\txMessage*readFromStream(TNL::BitStream *bstream,TNL::BitSet32 flags);\r\n\t\tvoid writeToStream(xMessage *msg,TNL::BitStream *bstream,TNL::BitSet32 flags);\r\n\t\t\r\n\t\tvoid advanceTime(float deltaTime);\r\n\t\tfloat getMessageTimeout() const { return mMessageTimeout; }\r\n\t\tvoid setMessageTimeout(float val) { mMessageTimeout = val; }\r\n\r\n\t\tvoid checkMessages();\r\n\r\n\t\txMessageType *getMessageType(xMessage*message);\r\n\t\txMessageType *createMessageType(xMessage*message);\r\n\t\tvoid registerMessageType(xNString name,int type,int numParameters);\r\n\t\t\r\n\t\tfloat getThresoldTicker() const { return mThresoldTicker; }\r\n\t\tvoid setThresoldTicker(float val) { mThresoldTicker = val; }\r\n\t\tfloat getMinSendTime() const { return mMinSendTime; }\r\n\t\tvoid setMinSendTime(float val) { mMinSendTime = val; }\r\n\r\n\tprotected:\r\n\tprivate:\r\n\r\n\t\txNetInterface *mNetInterface;\r\n\t\tfloat mMessageTimeout;\r\n\t\tfloat mThresoldTicker;\r\n\t\tfloat mMinSendTime;\r\n\t\t\r\n};\r\n\r\n#endif\r\n#include \"StdAfx.h\"\r\n#include \"vt_python_ext.h\"\r\n#include \"initman.h\"\r\nextern vt_python_man* pym;\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nPyObject* log_CaptureStdout(PyObject* self, PyObject* pArgs)\r\n{\r\n\tchar* LogStr = NULL;\r\n\tif (!PyArg_ParseTuple(pArgs, \"s\", &LogStr)) return NULL;\r\n\tif (pym)\r\n\t{\r\n\t\tpym->m_stdOut << LogStr;\r\n\t}\r\n\r\n\t\r\n\tPy_INCREF(Py_None);\r\n\treturn Py_None;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nPyObject* log_CaptureStderr(PyObject* self, PyObject* pArgs)\r\n{\r\n\t\tchar* LogStr = NULL;\r\n\t\tif (!PyArg_ParseTuple(pArgs, \"s\", &LogStr)) return NULL;\r\n\t\tif (pym)\r\n\t\t{\r\n\t\t\tpym->m_stdOut << LogStr;\r\n\t\t}\r\n\t\tPy_INCREF(Py_None);\r\n\t\treturn Py_None;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n#include \"PCommonDialog.h\"\r\n#include \"resource.h\"\r\n#include \"VITabCtrl.h\"\r\n\r\n#include \"VIControl.h\"\r\n\r\n\r\n#define LAYOUT_STYLE\t\t\t(WS_CHILD|WS_VISIBLE)\r\n#define LAYOUT_ShaderREE\t\t130\r\n\r\nRECT\t_GetNullRect() {\r\n\treturn RECT(); \r\n}\r\n\r\n\r\nLRESULT CPBCommonDialog::OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam)\r\n{\r\n\tLRESULT lResult;\r\n\treturn lResult;\r\n\r\n}\r\n\r\nvoid CPBCommonDialog::fillFlags()\r\n{\r\n\r\n\tBF_Move.SetCheck(true);\r\n}\r\n\r\n\r\nvoid CPBCommonDialog::fillHullType()\r\n{\r\n\t\t\r\n\t\tHType.AddString(\"Sphere\");\r\n\t\tHType.AddString(\"Box\");\r\n\t\tHType.AddString(\"Capsule\");\r\n\t\tHType.AddString(\"Plane\");\r\n\t\tHType.AddString(\"Convex Mesh\");\r\n\t\tHType.AddString(\"Height Field\");\r\n\t\tHType.AddString(\"Wheel\");\r\n\t\tHType.AddString(\"Cloth\");\r\n\t\tHType.SetCurSel(0);\r\n}\r\n\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n}\r\n\r\n\r\nCKBOOL CPBCommonDialog::On_Init()\r\n{\t\r\n\r\n\tfillHullType();\r\n\r\n\r\n\treturn true;\r\n\r\n\r\n}\r\n\r\nLRESULT CPBCommonDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r\n{\r\n\tswitch (message)\r\n\t{\r\n\r\n\r\n\tcase WM_MOUSEWHEEL:\r\n\t\t{\r\n\r\n\t\t\t\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\tcase WM_ERASEBKGND:\r\n\t\t{\r\n\t\t\t/*RECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);\r\n\t\t\tpDC->FillSolidRect(&r,RGB(100,8,100));\r\n\t\t\t*/\r\n\r\n\t\t}break;\r\n\tcase CKWM_OK:\r\n\t\t{\r\n\r\n\t\t} break;\r\n\r\n\tcase CKWM_INIT:\r\n\t\t{\r\n\t\t\tfillHullType();\r\n\t\t} break;\r\n\t}\r\n\treturn CDialog::WindowProc(message, wParam, lParam);\r\n}\r\n\r\n\r\nvoid CPBCommonDialog::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\r\n\t//CDialog::DoDataExchange(pDX);\r\n\r\n\tCParameterDialog::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CPBCommonDialog)\r\n\t//DDX_Control(pDX, IDC_DYNA_FLAGS_RECT,mDynaFlagsRect);\r\n\tDDX_Control(pDX, IDC_HULLTYPE, HType);\r\n\tDDX_Control(pDX, IDC_LBL_HTYPE, LBL_HType);\r\n\r\n\r\n\tDDX_Control(pDX, IDC_BFLAGS_MOVING,BF_Move);\r\n\tDDX_Control(pDX, IDC_BFLAGS_GRAV,BF_Grav);\r\n\tDDX_Control(pDX, IDC_BFLAGS_HIERARCHY,BF_Hierarchy);\r\n\t\r\n\tDDX_Control(pDX, IDC_BFLAGS_COLL,BF_Collision);\r\n\tDDX_Control(pDX, IDC_BFLAGS_COLL_NOTIFY,BF_CollisionNotify);\r\n\r\n\tDDX_Control(pDX, IDC_BFLAGS_KINEMATIC,BF_Kinematic);\r\n\tDDX_Control(pDX, IDC_BFLAGS_TRIGGER,BF_TriggerShape);\r\n\tDDX_Control(pDX, IDC_BFLAGS_SLEEP,BF_Sleep);\r\n\tDDX_Control(pDX, IDC_BFLAGS_SSHAPE,BF_SubShape);\r\n\t\r\n\tDDX_Control(pDX, IDC_BFLAGS_DEFORMABLE,BF_Deformable);\r\n\tDDX_Control(pDX, IDC_LBL_LFLAGS,LBL_Flags);\r\n\tDDX_Control(pDX, IDC_LBL_FLAGS,LBL_Flags);\r\n\tDDX_Control(pDX, IDC_LBL_DYNAFLAGS,LBL_DFlags);\r\n\r\n\r\n\tDDX_Control(pDX, IDC_TLFLAGS_POS,TF_POS);\r\n\tDDX_Control(pDX, IDC_TLFLAGS_ROT,TF_ROT);\r\n\t\r\n\tDDX_Control(pDX, IDC_TLFLAGS_POS_X,TF_PX);\r\n\tDDX_Control(pDX, IDC_TLFLAGS_POS_Y,TF_PY);\r\n\tDDX_Control(pDX, IDC_TLFLAGS_POS_Z,TF_PZ);\r\n\r\n\r\n\tDDX_Control(pDX, IDC_TLFLAGS_ROT_X,TF_RX);\r\n\tDDX_Control(pDX, IDC_TLFLAGS_ROT_Y,TF_RY);\r\n\tDDX_Control(pDX, IDC_TLFLAGS_ROT_Z,TF_RZ);\r\n\r\n\t//}}AFX_DATA_MAP\r\n\r\n}\r\n// DoubleParamDialog dialog\r\n\r\nBEGIN_MESSAGE_MAP(CPBCommonDialog, CParameterDialog)\r\n\tON_STN_CLICKED(IDC_DYNA_FLAGS_RECT, OnStnClickedDynaFlagsRect)\r\nEND_MESSAGE_MAP()\r\n\r\n\r\n#include \"xEnumerations.h\" \r\n#include \"..\\..\\include\\interface\\pcommondialog.h\"\r\n\r\n\r\n/*IMPLEMENT_DYNAMIC(CPBCommonDialog, CDialog)\r\nCPBCommonDialog::CPBCommonDialog(CKParameter *param, CWnd* pParent)\r\n: CDialog(CPBCommonDialog::IDD, pParent)\r\n{\r\n\tparameter = param;\r\n}*/\r\n\r\n\r\n\r\n\r\nBOOL CPBCommonDialog::OnInitDialog()\r\n{\r\n\tCParameterDialog::OnInitDialog();\r\n\tm_tt = new CToolTipCtrl();\r\n\tm_tt->Create(this);\r\n\t// Add tool tips to the controls, either by hard coded string \r\n\t// or using the string table resource\r\n\tm_tt->AddTool( &BF_Move, _T(\"This is a tool tip!\"));\r\n\t/*m_tt->AddTool( &mDynaFlagsRect, _T(\"This is a tool tip!\"));\r\n\t//m_ToolTip.AddTool( &m_myEdit, IDS_MY_EDIT);\r\n\tm_tt->Activate(TRUE);\r\n*/\r\n\t// TODO: Add extra initialization here\r\n\r\n\treturn TRUE; // return TRUE unless you set the focus to a control\r\n\t// EXCEPTION: OCX Property Pages should return FALSE\r\n}\r\n\r\nBOOL CPBCommonDialog::PreTranslateMessage(MSG* pMsg)\r\n{\r\n\tif(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST) \r\n\t\tm_tt->RelayEvent(pMsg); \r\n\r\n\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\treturn CParameterDialog::PreTranslateMessage(pMsg);\r\n}\r\n\r\nvoid CPBCommonDialog::OnStnClickedDynaFlagsRect()\r\n{\r\n\t\r\n\tm_tt->Activate(TRUE);\r\n\r\n\tLPRECT rect;\r\n\tm_tt->GetWindowRect(rect);\r\n\tm_tt->GetWindowRect(rect);\r\n\r\n\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJPulleyDecl();\r\nCKERROR CreatePJPulleyProto(CKBehaviorPrototype **pproto);\r\nint PJPulley(const CKBehaviorContext& behcontext);\r\nCKERROR PJPulleyCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\tbI_ObjectB,\r\n\tbI_Anchor0,\r\n\tbI_Anchor1,\r\n\tbI_Pulley0,\r\n\tbI_Pulley0Ref,\r\n\tbI_Pulley1,\r\n\tbI_Pulley1Ref,\r\n\tbI_Stifness,\r\n\tbI_Distance,\r\n\tbI_Ratio,\r\n\tbI_Rigid,\r\n\tbi_Collision,\r\n\tbI_Motor,\r\n\r\n};\r\n//************************************\r\n// Method: FillBehaviorPJPulleyDecl\r\n// FullName: FillBehaviorPJPulleyDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJPulleyDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJPulley\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets a pulley joint between two bodies.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x43d5361f,0x683f2741));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJPulleyProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\treturn od;\r\n}\r\n//************************************\r\n// Method: CreatePJPulleyProto\r\n// FullName: CreatePJPulleyProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJPulleyProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJPulley\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJPulley\r\n\r\n\t
\r\n\tPJPulley is categorized in \\ref Joints\r\n\t
\r\n\t
See pJPulley.cmo.\r\n\r\n\t\r\n\r\n\t\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a pulley (rope) joint.\r\n\t
\r\n\r\n\t\\image html pulleyJoint.png\r\n\r\n\r\n\tThe pulley joint simulates a rope that can be thrown across a pair of pulleys. In this way, it is similar to the distance joint (the length of the rope is the distance) but the rope doesn't connect the two bodies along the shortest path, rather it leads from the connection point on one actor to the pulley point (fixed in world space), then to the second pulley point, and finally to the other actor.\r\n\r\n\tThe pulley joint can also be used to simulate a rope around a single point by making the pulley points coincide.\r\n\r\n\tNote that a setup where either object attachment point coincides with its corresponding pulley suspension point in world space is invalid. In this case, the simulation would be unable to determine the appropriate direction in which to pull the object and a random direction would result. The simulation will be unstable. Note that it is also invalid to allow the simulation to end up in such a state. \r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJPulley.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\r\n\t\r\n\tLocal Anchor A:Sets the attachment point of joint in bodie[0]'s space.See pJointPulley::setLocalAnchorA().\r\n\t
\r\n\r\n\tLocal Anchor B:Sets the attachment point of joint in bodie[1]'s space.See pJointPulley::setLocalAnchorB().\r\n\t
\r\n\r\n\r\n\r\n\tPulley A: Sets the suspension point of joint in world space. See pJointPulley::setPulleyA().\r\n\t
\r\n\r\n\tPulley A Reference: Sets the suspension point of joint in local space by using an reference entity. The above vector gets transformed.\r\n\t
\r\n\r\n\tPulley B: Sets the suspension point of joint in world space.See pJointPulley::setPulleyA().\r\n\t
\r\n\r\n\tPulley B Reference: Sets the suspension point of joint in local space by using an reference entity. The above vector gets transformed.\r\n\t
\r\n\r\n\tStiffness: Sets how stiff the constraint is, between 0 and 1 (stiffest). See pJointPulley::setStiffness().\r\n\t
\r\n\r\n\tDistance: Sets the rest length of the rope connecting the two objects.See pJointPulley::setDistance().\r\n\t
\r\n\r\n\t\\Note The distance is computed as ||(pulley0 - anchor0)|| + ||(pulley1 - anchor1)|| * ratio.\r\n\r\n\tRatio: .Sets transmission ratio. See pJointPulley::setRatio().\r\n\t
\r\n\r\n\tIs Rigid: .Set true if the joint also has to maintain a minimum distance, not just a maximum. See pJointPulley::setRigid().\r\n\t
\r\n\r\n\r\n\tCollision: Enables Collision. See pJointPulley::enableCollision().\r\n\t
\r\n\r\n\tMotor: Motor parameters. See pJointPulley::setMotor().\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\t

Warning

\r\n\tAt least one body must be dynamic.\r\n\t
\r\n\t\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include pJPulley.vsl\r\n\t\r\n\t
\r\n\r\n\t

VSL : Motor Modification


\r\n\t\r\n\t\\include PJRevoluteSetMotor.vsl\r\n\t\r\n\t
\r\n\t
\r\n\t\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createJointPulley(). #pJointPulley
\r\n\r\n\t*/\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetBehaviorCallbackFct( PJPulleyCB );\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Local Anchor A\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Local Anchor B\",CKPGUID_VECTOR,\"0.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Pulley A\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Pulley A Reference\",CKPGUID_3DENTITY);\r\n\r\n\tproto->DeclareInParameter(\"Pulley B\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Pulley B Reference\",CKPGUID_3DENTITY);\r\n\r\n\tproto->DeclareInParameter(\"Stiffness\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Distance\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Ratio\",CKPGUID_FLOAT);\r\n\r\n\tproto->DeclareInParameter(\"Is Rigid\",CKPGUID_BOOL);\r\n\t\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL);\r\n\r\n\tproto->DeclareInParameter(\"Motor\",VTS_JOINT_MOTOR);\r\n\r\n\t\r\n\tproto->DeclareSetting(\"Motor\",CKPGUID_BOOL,\"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJPulley);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJPulley\r\n// FullName: PJPulley\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJPulley(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Pulley))\r\n\t\t{\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\r\n\t\tif (!worldA && !worldB)\r\n\t\t\tbbErrorME(\"Couldnt find any world object\");\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif (!bodyA && !bodyB)\r\n\t\t\tbbErrorME(\"Couldnt find any physic object\");\r\n\r\n\r\n\r\n\t\tif(bodyA && bodyB)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tVxVector anchor0 = GetInputParameterValue(beh,bI_Anchor0);\r\n\t\t\tVxVector anchor1 = GetInputParameterValue(beh,bI_Anchor1);\r\n\r\n\t\t\tVxVector pulley0 = GetInputParameterValue(beh,bI_Pulley0);\r\n\t\t\tCK3dEntity*pulley0Ref= (CK3dEntity *) beh->GetInputParameterObject(bI_Pulley0Ref);\r\n\t\t\tVxVector pulley1 = GetInputParameterValue(beh,bI_Pulley1);\r\n\t\t\tCK3dEntity*pulley1Ref= (CK3dEntity *) beh->GetInputParameterObject(bI_Pulley1Ref);\r\n\r\n\r\n\t\t\tint coll = GetInputParameterValue(beh,bi_Collision);\r\n\r\n\r\n\r\n\t\t\tVxVector pulley0Out = pulley0;\r\n\t\t\tif (pulley0Ref)\r\n\t\t\t\tpulley0Ref->Transform(&pulley0Out,&pulley0);\r\n\r\n\t\t\tVxVector pulley1Out = pulley1;\r\n\t\t\tif (pulley1Ref)\r\n\t\t\t\tpulley1Ref->Transform(&pulley1Out,&pulley1);\r\n\r\n\r\n\t\t\tfloat ratio = GetInputParameterValue(beh,bI_Ratio);\r\n\t\t\tfloat stiff = GetInputParameterValue(beh,bI_Stifness);\r\n\t\t\tfloat distance = GetInputParameterValue(beh,bI_Distance);\r\n\t\t\tint rigid = GetInputParameterValue(beh,bI_Rigid);\r\n\t\t\t\r\n\t\t\tpMotor motor;\r\n\t\t\t\r\n\t\t\tDWORD hasMotor;beh->GetLocalParameterValue(0,&hasMotor);\r\n\t\t\tif (hasMotor)\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *par = beh->GetInputParameter(bI_Motor);\r\n\t\t\t\tif (par)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\t\tif (rPar)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tmotor = pFactory::Instance()->createMotorFromParameter(rPar);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\tpJointPulley*joint = static_cast(worldA->getJoint(target,targetB,JT_Pulley));\r\n\r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createPulleyJoint(target,targetB,pulley0Out,pulley1Out,anchor0,anchor1));\r\n\t\t\t\tif (!joint)\r\n\t\t\t\t{\r\n\t\t\t\t\tbbErrorMesg(\"Couldn't create Pulley joint!\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joint exists : update : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->setStiffness(stiff);\r\n\t\t\t\tjoint->setRatio(ratio);\r\n\t\t\t\tjoint->setRigid(rigid);\r\n\t\t\t\tjoint->setDistance(distance);\r\n\t\t\t\tjoint->setPulleyA(pulley0Out);\r\n\t\t\t\tjoint->setPulleyB(pulley1Out);\r\n\t\t\t\tjoint->setLocalAnchorA(anchor0);\r\n\t\t\t\tjoint->setLocalAnchorB(anchor1);\r\n\t\t\t\tjoint->enableCollision(coll);\r\n\r\n\t\t\t\tif (hasMotor)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setMotor(motor);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJPulleyCB\r\n// FullName: PJPulleyCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJPulleyCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\r\n\t\t\tDWORD hasMotor;\r\n\t\t\tbeh->GetLocalParameterValue(0,&hasMotor);\r\n\t\t\tbeh->EnableInputParameter(bI_Motor,hasMotor);\r\n\r\n\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}// vDevTestUnit.cpp : Defines the entry point for the DLL application.\r\n//\r\n\r\n//#include \"stdafx.h\"\r\n\r\n//\r\n#include \"CKAll.h\"\r\n#include \"Dll_Tools.h\"\r\n\r\n#include \r\n\r\n#include \"VSLManagerSDK.h\"\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\n\r\n#define DECLAREFUN_6d(ret,func,callconv,dllName,arg1,arg2,arg3,arg4,arg5,arg6){\\\r\n\tDllFunc< ret (*)(arg1,arg2,arg3,arg4,arg5,arg6) > Dllf(dllName,func);\\\r\n\tVSLM->RegisterFunction(func, Dllf ,callconv,6,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6);\\\r\n}\r\n#define DECLAREFUN_C_6d(ret,func,dllName,arg1,arg2,arg3,arg4,arg5,arg6) DECLAREFUN_6d(ret,func,VCALLTYPE_CDECL,dllName,arg1,arg2,arg3,arg4,arg5,arg6)\r\n\r\n\r\n/*\r\n\r\n#define DECLAREFUN_0(ret,func,callconv) {\\\r\ntypedef ret (*fptr)(); \\\r\nfptr rawPtr = (fptr) func; \\\r\nTPtrToRoutine ptr; \\\r\nptr.CreateFunctionPtr((void**) &rawPtr); \\\r\nVSLM->RegisterFunction(#func,ptr,callconv,0,#ret);\\\r\n}\r\n#define DECLAREFUN_C_0(ret,func) DECLAREFUN_0(ret,func,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_0(ret,func) DECLAREFUN_0(ret,func,VCALLTYPE_STDCALL)\r\n*/\r\n\r\nbool is=false;\r\n\r\ntemplateclass Real{\r\n \r\n};\r\n\r\ntemplateclass tSocket{\r\n\r\npublic : \r\n\r\n\ttSocket(const char*in){\r\n resultT = new Real(); \r\n\t}\r\n\r\n\tT resultT;\r\n\toperator T(){\r\n\t\treturn resultT;\r\n\t}\r\n};\r\n\r\n\r\n#define DECLAREFUNS_0(ret,func,callconv,dllName) {\\\r\n\ttypedef ret (*fptr)(); \\\r\n\tDllFuncDllf(_T(dllName),func);\\\r\n\tfptr rawPtr = (fptr)Dllf; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tis=VSLM->RegisterFunction(func,ptr,callconv,0,#ret);\\\r\n}\r\n#define DECLAREFUNSS_0(ret,func,dllName) DECLAREFUNS_0(ret,func,VCALLTYPE_CDECL,dllName)\r\n\r\n\r\n\r\nCKERROR InitInstanc1e(CKContext* context)\r\n{\r\n\r\n\tusing namespace VSL; \r\n\r\n\tVSLManager *VSLM = (VSLManager *)context->GetManagerByGuid(VSLMANAGER_GUID);\r\n\r\n\tDECLAREFUNSS_0(void,\"testS\",\"base.dll\")\r\n\r\n\r\n\r\n\ttypedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);\r\n\r\n\tDllFunc<_ShellExec_proto>_ShellExec(_T(\"shell32.dll\"),\"ShellExecuteA\");\r\n\r\n\r\n\tHINSTANCE a = (*_ShellExec)(NULL,\"open\",\"www.gmx.net\",NULL,NULL, SW_MAXIMIZE);\r\n\r\n\r\n\t//MessageBox(NULL,\"\",\"\",0);\r\n\r\n\t//typedef void (*ptrF)();\r\n\t//tSocket(\"void\");\r\n\r\n\t//DllFuncasd( _T(\"Base.dll\"),\"testS\");\r\n\t//VSLM->RegisterFunction( \"testS\", asd ,VCALLTYPE_CDECL,0,\"void\");\r\n\r\n\r\n \r\n\t//(*asd)();\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t//if (is)\r\n\t\t//MessageBox(NULL,\"succed\",\"\",0);\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t//(*_ShellExec)(NULL,\"open\",\"www.gmx.net\",NULL,NULL, SW_MAXIMIZE); //-) simple and handy, or not ?\r\n\r\n\r\n\r\n\t//DECLAREFUN_C_6d(void,\"ShellExecuteA\",\"shell32.dll\",int,const char*,const char*,const char*,const char*,int)\r\n\r\n\r\n\r\n\t\t//base::win32::shell::testS();\r\n\r\n\r\n\t\t//VSLM->RegisterSpace();\r\n\r\n\t\t//DECLAREFUN_C_0d(void,_ShellExec,\"base.dll\")\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//\t\ttypedef void(*_ShellExec_proto)();\r\n\r\n\t\t//DllFuncxas((\"Base.dll\"),\"testS\");\r\n\r\n\r\n\t\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARTPlusDetectionAndTransformation\r\n// ---------------------------------\r\n//\r\n// Description:\r\n// Buildingblock that detects a pattern (single marker) and transforms\r\n// the related Object. If the pattern is not detected, the Object will\r\n// be hidden.\r\n//\r\n// Input Parameter:\r\n// IN_OBJECT\t\t\t: The related virtools object\r\n// IN_VIDEO_TEXTURE\t\t: The image, in with ARToolKitPlus\r\n//\t\t\t\t\t\t perform the detection\r\n// IN_PATTERN_NUMBER\t: The pattern number, which will\r\n//\t\t\t\t\t\t be detected by the BB\r\n// IN_PATTERN_WIDTH\t\t: The width of the real pattern in mm\r\n// IN_USE_BCH\t\t\t: Flag which indicates to use BCH-pattern\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_THIN_BORDER\t\t: Flag which indicates to use pattern with\r\n//\t\t\t\t\t\t a thin boarder)\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_AUTO_THRESHOLD\t: Flag which indicates to use the auto-threshold\r\n//\t\t\t\t\t\t function from the ARToolKitPlus\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_THRESHOLD\t\t\t: The threshold value used, if IN_AUTO_THRESHOLD\r\n//\t\t\t\t\t\t is set to false\r\n//\r\n// Output Parameter:\r\n// OUT_POSITION\t\t\t: Position vector of the detected pattern\r\n// OUT_QUATERNION\t\t: Rotation, given in quaternions, of the detected\r\n//\t\t\t\t\t\t pattern\r\n// OUT_MARKERID\t\t\t: The ID of the Pattern, which has been detected.\r\n//\t\t\t\t\t\t Should be the same number as IN_PATTERN_NUMBER\r\n// OUT_DETECTED\t\t\t: Flag which indicates that the pattern has been\r\n//\t\t\t\t\t\t detected in the image or not\r\n// OUT_TRANSFORM_MATRIX\t: The complete transformation matrix.\r\n//\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \r\n\r\nextern bool ARTPlusInitialized;\r\nextern ARToolKitPlus::TrackerSingleMarker *tracker;\r\n\r\n#define IN_OBJECT\t\t\t0\r\n#define IN_VIDEO_TEXTURE\t1\r\n#define IN_PATTERN_NUMBER\t2\r\n#define IN_PATTERN_WIDTH\t3\r\n#define IN_USE_BCH\t\t\t4\r\n#define IN_THIN_BORDER\t\t5\r\n#define IN_AUTO_THRESHOLD\t6\r\n#define IN_THRESHOLD\t\t7\r\n\r\n#define OUT_POSITION\t\t\t0\r\n#define OUT_QUATERNION\t\t\t1\r\n#define OUT_MARKERID\t\t\t2\r\n#define OUT_DETECTED\t\t\t3\r\n#define OUT_TRANSFORM_MATRIX\t4\r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusDetectionAndTransformationDecl();\r\nCKERROR CreateARTPlusDetectionAndTransformationProto(CKBehaviorPrototype **);\r\nint ARTPlusDetectionAndTransformation(const CKBehaviorContext& BehContext);\r\n\r\nCKERROR ARTPlusDetectionAndTransformationCB(const CKBehaviorContext& BehContext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusDetectionAndTransformationDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Single Marker Detection and Transformation\");\r\n\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateARTPlusDetectionAndTransformationProto);\r\n\tod->SetDescription(\"Detects Single Marker and Calculates Transformation for given Videoframe\");\r\n\tod->SetCategory(\"ARToolKitPlus\");\r\n\tod->SetGuid(CKGUID(0x2f9e2472,0x639e208c));\r\n\tod->SetAuthorGuid(CKGUID(0x653d3e01,0x631c3314));\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateARTPlusDetectionAndTransformationProto(CKBehaviorPrototype** pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Single Marker Detection and Transformation\");\r\n\tif(!proto) \treturn CKERR_OUTOFMEMORY;\r\n\r\n//---\tInputs declaration\r\n\tproto->DeclareInput(\"In\");\r\n\r\n//---\tOutputs declaration\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n//----- Input Parameters Declaration\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Video Texture\",CKPGUID_TEXTURE);\r\n\tproto->DeclareInParameter(\"Pattern Number\",CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Pattern Width (cm)\", CKPGUID_FLOAT, \"8.0\");\n\tproto->DeclareInParameter(\"Use BCH Pattern\", CKPGUID_BOOL, \"TRUE\");\n\tproto->DeclareInParameter(\"Use Thin Border\", CKPGUID_BOOL, \"TRUE\");\n\tproto->DeclareInParameter(\"Enable Auto Threshold\", CKPGUID_BOOL, \"FALSE\");\n\tproto->DeclareInParameter(\"Threshold\", CKPGUID_INT, \"150\");\n\r\n//---\tOutput Parameters Declaration\r\n\tproto->DeclareOutParameter(\"Position\",CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Quaternion\",CKPGUID_QUATERNION);\r\n\tproto->DeclareOutParameter(\"Marker ID\",CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Detected\",CKPGUID_BOOL, FALSE);\r\n\tproto->DeclareOutParameter(\"Transformation Matrix\",CKPGUID_MATRIX);\r\n\r\n//----\tLocal Parameters Declaration\r\n\r\n//----\tSettings Declaration\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorCallbackFct(ARTPlusDetectionAndTransformationCB,CKCB_BEHAVIORBASE|CKCB_BEHAVIOREDITIONS|CKCB_BEHAVIORPAUSE|CKCB_BEHAVIORREADSTATE|CKCB_BEHAVIORRESET|CKCB_BEHAVIORACTIVATESCRIPT|CKCB_BEHAVIORDEACTIVATESCRIPT|CKCB_BEHAVIORRESUME|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORNEWSCENE,NULL);\r\n\tproto->SetFunction(ARTPlusDetectionAndTransformation);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint ARTPlusDetectionAndTransformation(const CKBehaviorContext& BehContext)\r\n{\r\n\tCKBehavior* beh = BehContext.Behavior;\r\n\tCKTexture* texture = NULL;\r\n\tCKBYTE *pixel = NULL;\r\n\tCKBOOL detected = FALSE;\r\n\tint patternID = -1;\r\n\tint markerId = -1;\r\n\tfloat* buffer = NULL;\r\n\tfloat patternWidth = 8.0f; \r\n\tCKBOOL useBCH = TRUE;\r\n\tCKBOOL thinBorder = TRUE;\r\n\tCKBOOL autoThreshold = FALSE;\r\n\tint threshold = 150;\r\n\tCK3dEntity* Object = NULL;\r\n\tVxQuaternion quat = VxQuaternion();\r\n\tVxVector pos = VxVector();\r\n\tVxVector scale = VxVector();\r\n\n\tfloat gl_para[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 1.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 0.0f, 1.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 0.0f, 0.0f, 1.0f} };\n\n\tfloat gl_tmp[4][4] = { {0.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t{0.0f, 0.0f, 0.0f, 0.0f} };\n\r\n\tfloat koordSys[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, 0.0f, 1.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, 1.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, 0.0f, 0.0f, 1.0f} };\n \r\n\tfloat koordSys2[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, -1.0f, 0.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, 0.0f, 1.0f, 0.0f},\n\t\t\t\t\t\t\t {0.0f, 0.0f, 0.0f, 1.0f} };\n\r\n\tbeh->ActivateInput(0, FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tif(ARTPlusInitialized == true)\r\n\t{\r\n\t\t// PatterID\r\n\t\tbeh->GetInputParameterValue(IN_PATTERN_NUMBER, &patternID);\r\n\r\n\t\t// Get object\r\n\t\tObject = CK3dEntity::Cast(beh->GetInputParameterObject(IN_OBJECT));\r\n\t\tif(Object==NULL) return CKBR_BEHAVIORERROR;\r\n\r\n\t\t// Get texture\r\n\t\ttexture = CKTexture::Cast(beh->GetInputParameterObject(IN_VIDEO_TEXTURE));\r\n\t\tif(texture == NULL)\r\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\r\n\t\t// Get pattern width\r\n\t\tbeh->GetInputParameterValue(IN_PATTERN_WIDTH, &patternWidth);\r\n\r\n\t\t// define size of the marker\r\n\t\ttracker->setPatternWidth(patternWidth);\r\n\r\n\t\t// Get the type of pattern\r\n\t\tbeh->GetInputParameterValue(IN_USE_BCH, &useBCH);\r\n\r\n\t\t// Get value for thin border\r\n\t\tbeh->GetInputParameterValue(IN_THIN_BORDER, &thinBorder);\r\n\r\n\t\tif(useBCH)\r\n\t\t{\r\n\t\t\t// the marker in the BCH test image has a thin border...\r\n\t\t\ttracker->setBorderWidth(0.125f);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttracker->setBorderWidth(thinBorder ? 0.125f : 0.250f);\r\n\t\t}\r\n\r\n\t\t// switch to simple ID based markers\r\n\t\t// use the tool in tools/IdPatGen to generate markers\r\n\t\ttracker->setMarkerMode(useBCH ? ARToolKitPlus::MARKER_ID_BCH : ARToolKitPlus::MARKER_ID_SIMPLE);\r\n\r\n\t\t// Get auto threshold\r\n\t\tbeh->GetInputParameterValue(IN_AUTO_THRESHOLD, &autoThreshold);\r\n\t\t// Set auto thresholding in ARToolKitPlus\r\n\t\ttracker->activateAutoThreshold(autoThreshold?true:false);\r\n\r\n\t\tpixel = texture->LockSurfacePtr();\r\n\t\tif(pixel == NULL)\r\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\r\n\t\t// here we go, just one call to find the camera pose\r\n\t\tmarkerId = tracker->calc(pixel, patternID);\r\n\t\t//markerId = tracker->calc(pixel);\r\n\t\t//float conf = (float)tracker->getConfidence();\r\n\r\n\t\tif(texture->Restore() != TRUE)\r\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\r\n\t\tif(markerId==patternID)\r\n\t\t{\r\n\t\t\t// use the result of calc() to setup the OpenGL transformation\r\n\t\t\tbuffer = (float *)tracker->getModelViewMatrix();\r\n\t\t\tdetected = TRUE;\r\n\n\t\t\tfor( int j = 0; j < 4; j++ )\n\t\t\t{\n\t\t\t\tfor( int i = 0; i < 4; i++ )\n\t\t\t\t{\n\t\t\t\t\tgl_para[j][i] = buffer[j*4+i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor( int j = 0; j < 4; j++ )\n\t\t\t{\n\t\t\t\tfor( int i = 0; i < 4; i++ )\n\t\t\t\t{\n\t\t\t\t\tgl_tmp[j][i] = 0.0;\n\t\t\t\t\tfor(int k=0 ; k<4 ; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tgl_tmp[j][i] += koordSys[j][k]*gl_para[k][i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor( int j = 0; j < 4; j++ )\n\t\t\t{\n\t\t\t\tfor( int i = 0; i < 4; i++ )\n\t\t\t\t{\n\t\t\t\t\tgl_para[j][i] = 0.0;\n\t\t\t\t\tfor(int k=0 ; k<4 ; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tgl_para[j][i] += gl_tmp[j][k]*koordSys2[k][i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\r\n\t\t// Set boolean\r\n\t\tbeh->SetOutputParameterValue(OUT_DETECTED, &detected, 0);\r\n\n\t\t// Set marker id\r\n\t\tbeh->SetOutputParameterValue(OUT_MARKERID, &markerId, 0);\r\n\r\n\t\tVxMatrix mat = VxMatrix(gl_para);\r\n\t\tVx3DDecomposeMatrix(mat, quat, pos, scale);\r\n\r\n\t\t// Set position\r\n\t\tbeh->SetOutputParameterValue(OUT_POSITION, &pos, 0);\r\n\n\t\t// Set quaternion\r\n\t\tbeh->SetOutputParameterValue(OUT_QUATERNION, &quat, 0);\r\n\r\n\t\t// Set matrix\r\n\t\tbeh->SetOutputParameterValue(OUT_TRANSFORM_MATRIX, &mat, 0);\r\n\n\t\t//Set visibility if the Object\n\t\tif(detected==TRUE)\n\t\t{\n\t\t\t// transform object if marker is detected\n\t\t\tObject->SetPosition(&pos, NULL, FALSE);\n\t\t\tObject->SetQuaternion(&quat, NULL, FALSE, FALSE);\n\t\t\tObject->Show(CKSHOW);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tObject->Show(CKHIERARCHICALHIDE);\n\t\t}\n\t}\n\treturn CKBR_OK;\n}\r\n\r\nCKERROR ARTPlusDetectionAndTransformationCB(const CKBehaviorContext& BehContext)\r\n{\r\n\tswitch (BehContext.CallbackMessage)\r\n\t{\r\n\t\tcase CKM_BEHAVIORATTACH:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORDELETE:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORDETACH:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORRESUME:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORPAUSE:\t\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORRESET:\t\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\tbreak;\r\n\t\tcase CKM_BEHAVIOREDITED:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORLOAD:\t\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORACTIVATESCRIPT:\tbreak;\r\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\tbreak;\r\n\t\tcase CKM_BEHAVIORNEWSCENE:\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORREADSTATE:\t\t\tbreak;\r\n\r\n\t\tdefault: return CKBR_OK;\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\nimport string\r\n\r\n\r\nimport vt\r\n\r\ncurrentIndex = 0;\r\n\r\ndef loop():\r\n global currentIndex\r\n print (currentIndex)\r\n maxcount = vt.GetInVal(bid,3)\r\n startindex = vt.GetInVal(bid,4)\r\n step = vt.GetInVal(bid,5)\r\n currentIndex +=step\r\n vt.SetOutVal(bid,0,currentIndex)\r\n count = (currentIndex-startindex)/step\r\n if count >= maxcount:\r\n currentIndex = 0\r\n vt.ActivateOut(bid,0,1)\r\n else:\r\n vt.ActivateOut(bid,2,1)\r\n print(count)\r\n\r\n\r\ndef counter():\r\n if vt.IsInputActive(bid,0) :\r\n global currentIndex\r\n currentIndex = 0\r\n loop()\r\n if vt.IsInputActive(bid,1) :\r\n loop()\r\n \r\n \r\n \r\n \r\n #include \"virtools/vtcxglobal.h\"\r\n#include \"windows.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \r\n#include \"pyembed.h\"\r\n#include \"initman.h\"\r\n#include \"vtTools.h\"\r\n#include \"vt_python_ext.h\"\r\nextern vt_python_man* pym;\r\n\r\n\r\n//************************************\r\n// Method: syspath_append\r\n// FullName: syspath_append\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: char *dirname\r\n//************************************\r\nint syspath_append( char *dirname )\n{\n\tPyObject *mod_sys, *dict, *path, *dir;\n\n\tPyErr_Clear( );\n\n\tdir = Py_BuildValue( \"s\", dirname );\n\n\tmod_sys = PyImport_ImportModule( \"sys\" );\t/* new ref */\n\tdict = PyModule_GetDict( mod_sys );\t/* borrowed ref */\n\tpath = PyDict_GetItemString( dict, \"path\" );\t/* borrowed ref */\n\n\tif( !PyList_Check( path ) )\n\t\treturn 0;\n\n\tPyList_Append( path, dir );\n\n\tif( PyErr_Occurred( ) )\n\t\tPy_FatalError( \"could not build sys.path\" );\n\n\tPy_DECREF( mod_sys );\n\n\n\treturn 1;\n}\r\n\r\n//************************************\r\n// Method: vt_ActivateOut\r\n// FullName: vt_ActivateOut\r\n// Access: public static \r\n// Returns: PyObject *\r\n// Qualifier:\r\n// Parameter: PyObject * self\r\n// Parameter: PyObject * args\r\n//************************************\r\nstatic PyObject *vt_ActivateOut( PyObject * self, PyObject * args )\n{\n\tint size = PyTuple_Size(args);\n\tint bid, index, value;\r\n\tPyArg_ParseTuple(args, \"iii\", &bid, &index, &value); \r\n\r\n CK_ID cid = bid; \r\n\tCKBehavior *beh = static_cast(pym->m_Context->GetObject(cid)); \r\n\tif (size!=3)\r\n\t{\r\n\t\t\r\n\t\tpym->m_Context->OutputToConsoleEx(\"PyError:%s : This function only accepts 3 arguments : \\n\\t bid,index,value \",beh->GetName());\r\n\t\tPy_RETURN_NONE;\r\n\t}\r\n\r\n\tif(beh && index < beh->GetOutputCount())\r\n\t{\r\n\t\tbeh->ActivateOutput(index,value);\r\n\t}\r\n \t\t\n\n\tPy_RETURN_NONE;\n\r\n}\r\n//************************************\r\n// Method: vt_SetOutVal\r\n// FullName: vt_SetOutVal\r\n// Access: public static \r\n// Returns: PyObject *\r\n// Qualifier:\r\n// Parameter: PyObject * self\r\n// Parameter: PyObject * args\r\n//************************************\r\nstatic PyObject *vt_SetOutVal( PyObject * self, PyObject * args )\n{\n\t\n\tint size = PyTuple_Size(args);\n\tPyObject *val;\n\tint bid, index;\r\n\tPyArg_ParseTuple(args, \"iiO\", &bid, &index,&val); \r\n\r\n\tCK_ID cid = bid; \r\n\tCKBehavior *beh = static_cast(pym->m_Context->GetObject(cid)); \r\n\tif (size!=3)\r\n\t{\r\n\r\n\t\tpym->m_Context->OutputToConsole(\"PyError : This function only accepts 3 arguments : \\n\\t bid,index,value \");\r\n\t\tPy_RETURN_NONE;\r\n\t}\r\n\t\r\n\tusing namespace vtTools;\n\t\n\tif (beh && val && index < beh->GetOutputParameterCount() )\r\n\t{\r\n\t\tif (PyInt_Check(val))\n\t\t{\n\t\t\tlong ret = PyInt_AsLong(val);\n\t\t\tint retx = static_cast(ret);\n\t\t\tbeh->SetOutputParameterValue(index,&retx);\n\t\t\tPy_RETURN_NONE;\n\t\t}\n\t\tif (PyFloat_Check(val))\n\t\t{\n\t\t\tdouble ret = PyFloat_AsDouble(val);\n\t\t\tfloat retx = static_cast(ret);\n\t\t\tbeh->SetOutputParameterValue(index,&retx);\n\t\t\tPy_RETURN_NONE;\n\t\t}\n\t\tif (PyString_Check(val))\n\t\t{\n\t\t\tstd::string ret;\n\t\t\tCKParameterOut * pout = beh->GetOutputParameter(index);\r\n\t\t\tXString retx(ret.c_str());\r\n\t\t\tpout->SetStringValue(retx.Str());\n\t\t\tPy_RETURN_NONE;\n\t\t}\n\t\tif (PyTuple_Check(val))\n\t\t{\n\t\t\tstd::string outList = to_string(val);\n\t\t\tCKParameterOut * pout = beh->GetOutputParameter(index);\r\n\t\t\tXString retx(outList.c_str());\r\n\t\t\tpout->SetStringValue(retx.Str());\n\t\t\tPy_RETURN_NONE;\n\t\t}\n\n\t\t\n\t}\r\n\tPy_RETURN_NONE;\r\n}\n\r\n\n\r\n\r\n//************************************\r\n// Method: vt_GetInVal\r\n// FullName: vt_GetInVal\r\n// Access: public static \r\n// Returns: PyObject *\r\n// Qualifier:\r\n// Parameter: PyObject * self\r\n// Parameter: PyObject * args\r\n//************************************\r\nstatic PyObject *vt_GetInVal( PyObject * self, PyObject * args )\n{\n\n\tint size = PyTuple_Size(args);\n\tint bid, index;\r\n\tPyArg_ParseTuple(args, \"ii\", &bid, &index); \r\n\r\n\tCK_ID cid = bid; \r\n\tCKBehavior *beh = static_cast(pym->m_Context->GetObject(cid)); \r\n\tif (size!=2)\r\n\t{\r\n\t\tpym->m_Context->OutputToConsole(\"PyError : This function needs 2 arguments : \\n\\t bid,index\");\r\n\t\tPy_RETURN_NONE;\r\n\t}\r\n\r\n\tusing namespace vtTools;\n\tusing namespace vtTools::Enums;\n\n\tCKParameterManager *pam = static_cast(pym->m_Context->GetParameterManager());\r\n\n\tif (index < beh->GetInputParameterCount() )\r\n\t{\n\t\tCKParameterIn *ciIn = beh->GetInputParameter(index);\r\n\r\n\t\tCKParameterType pType = ciIn->GetType();\r\n\t\tvtTools::Enums::SuperType sType = ParameterTools::GetVirtoolsSuperType(pym->m_Context,pam->ParameterTypeToGuid(pType));\t\r\n\t\r\n\t\tPyObject *val;\r\n\r\n\t\tswitch (sType)\r\n\t\t{\r\n\t\tcase vtSTRING:\r\n\t\t\t{\r\n\t\t\t\tval = PyString_FromString( vtTools::BehaviorTools::GetInputParameterValue(beh,index ));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtFLOAT:\r\n\t\t\t{\r\n\t\t\t\tval = PyFloat_FromDouble(static_cast(vtTools::BehaviorTools::GetInputParameterValue(beh,index )));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtINTEGER:\r\n\t\t\t{\r\n\t\t\t\tval = PyInt_FromLong( static_cast(vtTools::BehaviorTools::GetInputParameterValue(beh,index )));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tdefault :\r\n\t\t\tXString err(\"wrong input parameter type: \");\r\n\t\t\terr << ciIn->GetName() << \"Only Types derivated from Interger,Float or String are acceptable\";\r\n\t\t\tpym->m_Context->OutputToConsole(err.Str(),FALSE );\r\n\t\t\tPy_RETURN_NONE;\r\n\t\t}\n\n\t\tif (!val)\n\t\t{\n\t\t\tPy_DECREF(val);\t \n\t\t}\n\t\treturn val;\n\t}\n\tPy_RETURN_NONE;\n}\r\n\r\n\r\nPyObject *vt_IsInputActive( PyObject * self, PyObject * args )\n{\n\t\t\n\tPyObject *arg;\n\n\tint size = PyTuple_Size(args);\n\n\tint bid, index, value;\r\n\tPyArg_ParseTuple(args, \"ii\", &bid, &index); \r\n\r\n\tCK_ID cid = bid; \r\n\r\n\tif (size!=2)\r\n\t{\r\n\t\tpym->m_Context->OutputToConsole(\"PyError : This function only accepts 2 arguments : \\n\\t bid,index \");\r\n\t\tPy_RETURN_NONE;\r\n\t}\r\n\r\n\tCKBehavior *beh = static_cast(pym->m_Context->GetObject(cid)); \r\n\tif(beh && index < beh->GetInputCount())\r\n\t{\r\n\t\treturn Py_BuildValue( \"i\", beh->IsInputActive(index) ? 1:0 );\r\n\t}\r\n\tPy_RETURN_NONE;\n}\r\n\r\nstatic struct PyMethodDef vt_methods[] = \n{\n\t{\"ActivateOut\", vt_ActivateOut, METH_VARARGS, NULL},\n\t{\"SetOutVal\", vt_SetOutVal, METH_VARARGS, NULL},\n\t{\"GetInVal\", vt_GetInVal, METH_VARARGS, NULL},\n\t{\"IsInputActive\", vt_IsInputActive, METH_VARARGS, NULL},\n\t{NULL, NULL, 0, NULL}\n};\r\n\r\nvoid VTPy_Init(void);\r\n\nstatic struct _inittab VTy_Inittab_Modules[] = \n{\n\t{\"vt\", VTPy_Init},\n\t{NULL, NULL}\n};\r\n\r\nvoid VTPy_Init(void)\r\n{\r\n\r\n\tPyObject *module;\n\tPyObject *dict, *smode, *SpaceHandlers, *UnpackModes;\n\tmodule = Py_InitModule3(\"vt\", vt_methods,\"The main vt module\");\n\r\n}\r\n\r\n\r\n\r\nint\r\nvt_python_man::InitPythonModules()\r\n{\r\n\r\n\treturn vpInitModules();\r\n}\r\n\r\nint vpInitModules()\r\n{\r\n\t\n\treturn PyImport_ExtendInittab(VTy_Inittab_Modules);\r\n\r\n}\r\n\r\n//************************************\r\n// Method: PythonLoad\r\n// FullName: PythonLoad\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nbool PythonLoad()\r\n{\r\n\tbool result = false; \r\n\tif (!pym->pLoaded)\r\n\t{\r\n\t\tint argc = 1;\r\n\t\tchar *cmd =GetCommandLineA();\r\n\t\tchar *c1[1];\r\n\t\tc1[0]=new char[256];\r\n\t\tstrcpy(c1[0],cmd);\r\n\t\tresult = !pym->InitPythonModules();\r\n\t\tpym->py = new Python(argc,c1);\r\n\t\tpym->pLoaded = true;\r\n\t\tPySetupStdRedirect();\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nstatic PyMethodDef logMethods[] = {\r\n\t{\r\n\t\t\"CaptureStdout\", log_CaptureStdout, METH_VARARGS, \"Logs stdout\"\t},\r\n\t\t{\t\"CaptureStderr\", log_CaptureStderr, METH_VARARGS, \"Logs stderr\"\t},\r\n\t\t{\tNULL, NULL, 0, NULL\t}\r\n};\r\n\r\n\r\nvoid PySetupStdRedirect()\r\n{\r\n\tPy_InitModule(\"log\", logMethods);\r\n\tPyRun_SimpleString(\"import log\\n\"\r\n\t\t\"import sys\\n\"\r\n\t\t\"class StdoutCatcher:\\n\"\r\n\t\t\"\\tdef write(self, str):\\n\"\r\n\t\t\"\\t\\tlog.CaptureStdout(str)\\n\"\r\n\t\t\"class StderrCatcher:\\n\"\r\n\t\t\"\\tdef write(self, str):\\n\"\r\n\t\t\"\\t\\tlog.CaptureStderr(str)\\n\"\r\n\t\t\"sys.stdout = StdoutCatcher()\\n\"\r\n\t\t\"sys.stderr = StderrCatcher()\\n\"\r\n\t\t);\r\n}\r\n//************************************\r\n// Method: vpCInit\r\n// FullName: vpCInit\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nint vpCInit()\r\n{\r\n\t Py_Initialize();\r\n\t return true;\r\n}\r\n//************************************\r\n// Method: vpCPyRun_SimpleString\r\n// FullName: vpCPyRun_SimpleString\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: const char*cmd\r\n//************************************\r\nvoid vpCPyRun_SimpleString(const char*cmd)\r\n{\r\n\tPyRun_SimpleString(cmd);\r\n}\r\n\r\n//************************************\r\n// Method: vpCPy_Finalize\r\n// FullName: vpCPy_Finalize\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nvoid DestroyPython()\r\n{\r\n\tif (pym->pLoaded)\r\n\t{\r\n\t\tif (pym->py)\r\n\t\t{\r\n\r\n\t\t}\r\n\t}\r\n\tif ( pym->py && pym->py->GetModule())\r\n\t{\r\n\t\tPy_XDECREF(pym->py->module); \r\n\t\tpym->py->module = NULL;\r\n\t}\r\n\t\r\n\tpym->pLoaded = false;\r\n\tPy_Finalize();\r\n}\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n/* ---------------------- */\r\n/* Transferts de Fichiers */\r\n/* ---------------------- */\r\n\r\n#define FTP4W_INCLUDES_AND_GENERAL +\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n\r\n#include /* external header file */ \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\" /* external header file */ \r\n#include \"ftp4w_in.h\" /* internal header file */\r\n#include \"rfc959.h\" /* only for error codes */ \r\n\r\n\r\n\r\nextern LPProcData pFirstProcData;\r\n\r\n\r\n/* ----------------------------------------------------------- */\r\n/* FtpCloseFileTransfer: Ferme les ressources Winsockets */\r\n/* ouvertes pour un transfert de fichier */\r\n/* le fichier est également fermé */\r\n/* Si bFlush est a TRUE, la socket de */\r\n/* données est vidée. */\r\n/* ----------------------------------------------------------- */\r\nint FtpCloseFileTransfer (LPProcData pProcData, BOOL bFlush)\r\n{\r\nint Rc;\r\n \r\n _lclose (pProcData->File.hf); /* close file */\r\n pProcData->File.hf = HFILE_ERROR; \r\n /* close listen socket */\r\n /* flush received buffer */ \r\n if (bFlush)\r\n {\r\n do\r\n Rc = TcpRecv ( pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf, \r\n min (5, pProcData->ftp.nTimeOut), \r\n HFILE_ERROR );\r\n while (Rc > 0);\r\n } /* bFlush */\r\n /* close opened sockets */\r\nreturn TcpClose(&pProcData->ftp.data_socket)==0 ? FTPERR_OK : FTPERR_CANTCLOSE;\r\n} /* FtpCloseFileTransfer */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Utilitaire GetFTPListenSocket */\r\n/* ouvre une socket en réception */\r\n/* based on WINTEL (ftp.c) and BSD (ftp.c) */\r\n/* Retourne un numéro de socket \t\t\t\t\t\t*/\r\n/* Si erreur de la pile TCP : INVALID_SOCKET \t*/\r\n/* Si erreur de communication: INVALID_ANSWER \t*/\r\n/* ------------------------------------------------------------ */\r\nSOCKET GetFTPListenSocket(LPFtpData pFtpData)\r\n{\r\nSOCKET listen_skt;\r\nint iLength, Rc;\r\nLPSTR a, p;\r\nchar szTmp2 [sizeof \"PORT 255,255,255,255,255,255\"]; \r\nunsigned short NonPrivPort; /* a non priviliged port chosen by system */\r\nstruct sockaddr_in saTmpAddr;\r\n\r\n NonPrivPort = 0;\r\n Rc = TcpGetListenSocket (& listen_skt, NULL, & NonPrivPort, 1);\r\n if (Rc != TCP4U_SUCCESS) return INVALID_SOCKET;\r\n p = (LPSTR) & NonPrivPort;\r\n /* inform remote end about our port that we created. */\r\n iLength = sizeof (saTmpAddr);\r\n getsockname(pFtpData->ctrl_socket, (LPSOCKADDR) &saTmpAddr, &iLength);\r\n a = (LPSTR) & saTmpAddr.sin_addr;\r\n\r\n#define UC(b) (((int)b)&0xff)\r\n wsprintf (szTmp2, \"PORT %d,%d,%d,%d,%d,%d\", \r\n UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[1]), UC(p[0]) );\r\n /* on envoie la requete et on attend la réponse */\r\n if ( TnSend (pFtpData->ctrl_socket, szTmp2, FALSE, pFtpData->hLogFile) !=TN_SUCCESS\r\n || IntFtpGetAnswerCode (pFtpData) != 200 )\r\n {\r\n closesocket (listen_skt);\r\n return (SOCKET) INVALID_ANSWER;\r\n }\r\nreturn listen_skt;\r\n} /* GetFTPListenSocket */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Utilitaire GetFTPConnectSocket */\r\n/* Prépare une socket pour le connect */\r\n/* Retourne un numéro de socket \t\t\t\t\t\t*/\r\n/* Si erreur de la pile TCP : INVALID_SOCKET \t*/\r\n/* Si erreur de communication: INVALID_ANSWER \t*/\r\n/* Si erreur dans passive mode:INVALID_MODE \t*/\r\n/* ------------------------------------------------------------ */\r\n\r\nSOCKET GetFTPConnectSocket(LPFtpData pFtpData)\r\n{\r\nint nCount;\r\nint Rc;\r\nSOCKET connect_skt;\r\nLPSTR a, p1, p2; /* a comme adress IP, p comme port */\r\nunsigned short nPort;\r\n\r\n if ( TnSend (pFtpData->ctrl_socket, \"PASV\", FALSE, pFtpData->hLogFile) !=TN_SUCCESS)\r\n return (SOCKET) INVALID_ANSWER;\r\n Rc = IntFtpGetAnswerCode (pFtpData);\r\n if (Rc != 227 ) /* 227 seul retour acceptable */\r\n {\r\n switch (Rc)\r\n {\r\n case 500 : \r\n case 502 : return (SOCKET) INVALID_MODE;\r\n default : return (SOCKET) INVALID_ANSWER;\r\n }\r\n } /* Retour command PASV incorrect */\r\n\r\n /* Réponse du type : 227 Entering Passive Mode (0,0,0,0,12,56) */\r\n a = strchr (& pFtpData->szInBuf [4], '(');\r\n if (a==NULL) return (SOCKET) INVALID_ANSWER;\r\n\r\n /* transforme les 3 premiers ',' en '.' */\r\n for ( p1=strchr(++a,','), nCount=0; \r\n p1!=NULL && nCount<3; \r\n nCount++) \r\n { \r\n *p1++='.';\r\n p1 = strchr(p1, ',');\r\n } \r\n \r\n if (p1==NULL) return (SOCKET) INVALID_ANSWER; /* mauvaise chaine */\r\n *p1++=0; /* fin de chaine et p pointe sur la chaine Port*/\r\n if ( (p2=strchr(p1, ','))==NULL ) return (SOCKET) INVALID_ANSWER; \r\n *p2++=0; \r\n \r\n nPort = atoi (p1) * 256 + atoi(p2);\r\n Rc = TcpConnect (& connect_skt, a, NULL, & nPort);\r\nreturn Rc==TCP4U_SUCCESS ? connect_skt : INVALID_SOCKET;\r\n} /* GetFTPConnectSocket */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Tools Fonction ToolsSetDataConnection () */\r\n/* etablit une connexion sur le port 20 */\r\n/* A l'aide de GetFTPlistenScket */\r\n/* Modifie les éléments suivants : */\r\n/* - pProcData->File.hf */\r\n/* - pProcData->ftp.saAcceptAddr */\r\n/* - pProcData->ftp.cType */\r\n/* - pProcData->ftp.data_socket */\r\n/* ------------------------------------------------------------ */\r\nint ToolsSetDataConnection (LPProcData pProcData, \r\n LPCSTR szLocalFile,\r\n int nMode, \r\n char cBinAscMode,\r\n long lByteCount,\r\n LPSTR szCmdString)\r\n{\r\nSOCKET tmp_socket; /* socket d'aide à la création de la connexion data */\r\nHFILE hFile = HFILE_ERROR;\r\nint Rc, wErrMsg;\r\n\r\n\r\n /* ferme le fichier de la précédent connexion si besoin */\r\n if (pProcData->File.hf!=HFILE_ERROR) _lclose (pProcData->File.hf);\r\n pProcData->File.hf = HFILE_ERROR;\r\n pProcData->File.bAborted = FALSE;\r\n\r\n /* changement de type (ASCII / binaire) */\r\n if (cBinAscMode==TYPE_I || cBinAscMode==TYPE_A || cBinAscMode==TYPE_L8)\r\n {\r\n Rc=FtpSetType (cBinAscMode);\r\n if (Rc!=FTPERR_OK) return Rc;\r\n }\r\n\r\n /* Ouverture du fichier local */\r\n if (szLocalFile!=NULL)\r\n {\r\n switch (nMode)\r\n {\r\n case FTPMODE_WRITE : hFile = _lcreat (szLocalFile, 0); break;\r\n case FTPMODE_APPEND : hFile = _lopen (szLocalFile, OF_WRITE); \r\n if (hFile==HFILE_ERROR) \r\n hFile = _lcreat (szLocalFile, 0); \r\n else _llseek (hFile, 0, SEEK_END); \r\n break;\r\n case FTPMODE_READ : hFile = _lopen (szLocalFile, OF_READ); break;\r\n default : hFile = HFILE_ERROR; break;\r\n } \r\n if (hFile == HFILE_ERROR) return FTPERR_CANTOPENLOCALFILE;\r\n } /* szLocalFile non Nul */\r\n\r\n\r\n /* demande de la socket de connexion : distinction mode passif/mode classique */\r\n if (pProcData->ftp.bPassif)\r\n tmp_socket = GetFTPConnectSocket (& pProcData->ftp);\r\n else tmp_socket = GetFTPListenSocket (& pProcData->ftp);\r\n\r\n /* discussion sur les cas d'erreur */\r\n switch (tmp_socket)\r\n {\r\n case INVALID_SOCKET :\t/* error in socket calls */\r\n \t _lclose (hFile); \r\n \t return pProcData->ftp.bPassif ? \r\n \t\t\t\tFTPERR_CANTCREATESOCKET : \r\n \t\t\t\tFTPERR_DATACONNECTION ;\r\n\t case INVALID_MODE : /* Server does not support passive mode */\r\n _lclose (hFile); \r\n return FTPERR_PASVCMDNOTIMPL ;\r\n case INVALID_ANSWER : /* error in answer */\r\n _lclose (hFile); \r\n \t return FTPERR_UNEXPECTEDANSWER;\r\n } /* tmp_socket en erreur */\r\n\r\n if (lByteCount>0)\r\n {\r\n Rc = FtpRestart (lByteCount);\r\n if (Rc != FTPERR_RESTARTOK)\r\n { _lclose (hFile); return Rc; }\r\n } /* Commande Restart */\r\n\r\n /* envoi de la requete Get/Put/Dir */\r\n Rc = TnSend ( pProcData->ftp.ctrl_socket, szCmdString, FALSE, pProcData->ftp.hLogFile );\r\n if (Rc!=TN_SUCCESS) \r\n { _lclose (hFile); TcpClose (& tmp_socket); return FTPERR_SENDREFUSED; }\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n if (Rc!=150 && Rc!=125) /* 150 et 125 seules réponses autorisées */\r\n { \r\n switch (Rc)\r\n { \r\n case -1 : wErrMsg = FTPERR_NOREPLY; break;\r\n case 550 : wErrMsg = FTPERR_NOREMOTEFILE; break;\r\n case 553 : wErrMsg = FTPERR_TRANSFERREFUSED; break;\r\n default : wErrMsg = FTPERR_UNEXPECTEDANSWER;break;\r\n }\r\n _lclose (hFile);\r\n if (pProcData->ftp.bPassif) WSACancelBlockingCall ();\r\n TcpClose (& tmp_socket);\r\n return wErrMsg;\r\n } /* discussion des cas d'erreur */\r\n\r\n /* mode classique, il reste à attendre la connexion */\r\n if (! pProcData->ftp.bPassif)\r\n {\r\n Rc = TcpAccept (& pProcData->ftp.data_socket,\r\n tmp_socket,\r\n pProcData->ftp.nTimeOut);\r\n /* fermeture de la socket d'attente de connexion */\r\n TcpClose (& tmp_socket);\r\n if (Rc != TCP4U_SUCCESS)\r\n {\r\n _lclose (hFile); /* fermeture fichier */\r\n return HAS_ABORTED() ? FTPERR_CANCELBYUSER : FTPERR_DATACONNECTION;\r\n }\r\n } /* mode classique */\r\n else pProcData->ftp.data_socket = tmp_socket;\r\n pProcData->File.hf = hFile;\r\n\r\nreturn FTPERR_OK;\r\n} /* ToolsSetDataConnection */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Tools Fonction AbortAction () */\r\n/* Traitement Asynchrone de l'abort ou de */\r\n/* certains accidents comme plus d'espace */\r\n/* disque */\r\n/* ------------------------------------------------------------ */\r\nint AbortAction (LPProcData pProcData, BOOL bFlush, BOOL bMsg, UINT nDbg)\r\n{\r\nint Rc;\r\n /* =====> Premier cas : FtpRelease a été appelé -> */\r\n#ifdef TRACE_ABORT\r\n char szTmp[50];\r\n wsprintf (szTmp, \"Abort n° %d -> %d/%d\", nDbg, pProcData->File.bAborted, IsBadWritePtr(pProcData, sizeof *pProcData) );\r\n MessageBox (pProcData->hParentWnd, szTmp, \"DLL\", MB_OK);\r\n#endif\r\n\r\n if (pProcData->ftp.bVerbose) Ftp4w_Trace (NULL, \"entering AbortAction, Debug pos %d\", nDbg); \r\n\r\n if (IsBadWritePtr (pProcData, sizeof *pProcData)) return 0;\r\n /* reset flag */\r\n pProcData->File.bAborted = FALSE;\r\n /* =====> Soit un réél Abort, warning to server */\r\n do\r\n { /* emission prioritaire de Abort */\r\n Rc = TnSend ( pProcData->ftp.ctrl_socket, \"ABOR\", TRUE, pProcData->ftp.hLogFile ); \r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n }\r\n while (Rc==500);\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n /* close sockets and files */\r\n FtpCloseFileTransfer (pProcData, bFlush);\r\n /* send Message if AsynchronousMode */\r\n if (bMsg && pProcData->File.bAsyncMode)\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n TRUE, (LPARAM) FTPERR_CANCELBYUSER);\r\n TcpFlush (pProcData->ftp.ctrl_socket);\r\nreturn Rc;\r\n} /* AbortAction */\r\n\r\n\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie VI : Utilisation de la fenêtre FTP */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n\r\n/* ------------------------------------------------------------- */\r\n/* CALBACK */\r\n/* The Data transfer are not logged */\r\n/* ------------------------------------------------------------- */\r\n\r\nLRESULT _export PASCAL FAR DLLWndProc (HWND hWnd, UINT Msg, \r\n WPARAM wParam, LPARAM lParam) \r\n{\r\nLPProcData pProcData;\r\nint Rc, iRetCode=0;\r\nint nRead=0, nWritten=0;\r\nLPSTR p;\r\n\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData==NULL) return (LRESULT) DefWindowProc (hWnd,Msg,wParam,lParam);\r\n \r\n /* ------- */\r\n /* ABORT ? */\r\n /* ------- */\r\n if ( HAS_ABORTED() && (Msg==WMFTP_RECV || Msg==WMFTP_SEND ||Msg==WMFTP_DIR) )\r\n {\r\n AbortAction (pProcData, Msg!=WMFTP_SEND, TRUE, 1);\r\n return 0l;\r\n } /* Abort */\r\n\r\n\r\n switch (Msg)\r\n {\r\n /* Essentiel pour windows 3.1 */\r\n case WM_TIMER :\r\n KillTimer (hWnd, wParam);\r\n PostMessage (hWnd, wParam, 0, 0l);\r\n break;\r\n \r\n /* ---------------- */\r\n /* Suite du fichier */\r\n /* ---------------- */\r\n case WMFTP_SEND :\r\n nRead = _lread (pProcData->File.hf, pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf );\r\n /* lecture OK */\r\n if (nRead > 0)\r\n {\r\n pProcData->File.lPos += (LONG) nRead;\r\n Rc = TcpSend (pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, nRead, 0, HFILE_ERROR);\r\n if (Rc == TCP4U_SUCCESS) /* envoi OK */\r\n { \r\n /* on envoie un message à la fenêtre FTP */\r\n if ( ++pProcData->File.nCount % FTP_RATE(pProcData) != 0 \r\n || ! SetTimer (pProcData->hFtpWnd, WMFTP_SEND, \r\n pProcData->File.nDelay, NULL) )\r\n PostMessage (pProcData->hFtpWnd, WMFTP_SEND, 0, (LPARAM) pProcData);\r\n /* on envoie un message à l'utilisateur */\r\n if (pProcData->File.bNotify)\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n FALSE, pProcData->File.lPos );\r\n } /* TcpSend OK */\r\n /* Fin du fichier */ \r\n else /* problem */\r\n {\r\n /* Abort can happen during send */\r\n if HAS_ABORTED() AbortAction (pProcData, FALSE, TRUE, 2);\r\n else \r\n {\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n TRUE, (LPARAM) FTPERR_SENDREFUSED);\r\n break;\r\n }\r\n }\r\n } /* lecture du fichier possible */ \r\n else /* fin de fichier */\r\n {\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n switch (Rc)\r\n {\r\n case 250 : \r\n case 226 : iRetCode = FTPERR_OK ; break;\r\n case 452 :\r\n case 552 : iRetCode = FTPERR_CANTWRITE ; break;\r\n default : iRetCode = FTPERR_UNEXPECTEDANSWER; break;\r\n }\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n TRUE, \r\n (LPARAM) iRetCode);\r\n }\r\n break;\r\n\r\n\r\n\r\n case WMFTP_RECV :\r\n nRead = TcpRecv (pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf, \r\n pProcData->ftp.nTimeOut,\r\n HFILE_ERROR); \r\n /* Abort during receive */\r\n if HAS_ABORTED()\r\n {\r\n AbortAction (pProcData, TRUE, TRUE, 3);\r\n break; \r\n } /* Abort */\r\n\r\n /* ---------------- */\r\n /* Suite du fichier */\r\n /* ---------------- */\r\n if ( nRead > 0 \r\n &&\r\n (nWritten = _lwrite (pProcData->File.hf, \r\n pProcData->File.szBuf, \r\n nRead) ) == nRead )\r\n {\r\n pProcData->File.lPos += (LONG) nWritten;\r\n if ( ++pProcData->File.nCount % FTP_RATE(pProcData) != 0 \r\n || ! SetTimer (pProcData->hFtpWnd, WMFTP_RECV, \r\n pProcData->File.nDelay, NULL) )\r\n PostMessage (pProcData->hFtpWnd, WMFTP_RECV, 0, (LPARAM) pProcData);\r\n /* on envoie un message à l'utilisateur */\r\n if (pProcData->File.bNotify)\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n FALSE, pProcData->File.lPos );\r\n } /* TcpRecv and write OK */\r\n else /* fin de données */\r\n {\r\n if (nRead>0 && nWritten!=nRead) /* erreur d'ecriture */\r\n {\r\n AbortAction (pProcData, TRUE, FALSE, 4);\r\n iRetCode=FTPERR_CANTWRITE;\r\n }\r\n else\r\n { \r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n if (nRead == 0) /* fin de transfert */\r\n switch (Rc)\r\n {\r\n case 226 :\r\n case 250 : iRetCode = FTPERR_OK ; break;\r\n default : iRetCode = FTPERR_UNEXPECTEDANSWER;\r\n }\r\n else \r\n iRetCode = FTPERR_DATACONNECTION;\r\n }\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n TRUE, \r\n (LPARAM) iRetCode);\r\n } /* end of data transfer or error */\r\n break;\r\n\r\n\r\n\r\n /* Dir : Mode trame (sinon receive classique) */\r\n case WMFTP_DIR :\r\n nRead = TnReadLine (pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf,\r\n pProcData->ftp.nTimeOut, \r\n HFILE_ERROR );\r\n\r\n if HAS_ABORTED()\r\n {\r\n AbortAction (pProcData, TRUE, TRUE, 5);\r\n break; \r\n } /* Abort */\r\n\r\n /* --------------------------------- */\r\n /* Suite de la lecture du répertoire */\r\n /* --------------------------------- */\r\n p = strchr (pProcData->File.szBuf, '\\r');\r\n if (p!=NULL) *p = 0;\r\n if (nRead > 0)\r\n {\r\n /* on envoie un message à l'utilisateur */\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n FALSE, (LPARAM) pProcData->File.szBuf);\r\n if ( ++pProcData->File.nCount % FTP_DIRRATE(pProcData) != 0 \r\n || ! SetTimer (pProcData->hFtpWnd, WMFTP_DIR, \r\n pProcData->File.nDelay, NULL) )\r\n PostMessage (pProcData->hFtpWnd, WMFTP_DIR, 0, (LPARAM) pProcData);\r\n } /* Receive OK */\r\n else /* fin de données */\r\n {\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n if (nRead == 0) /* fin de transfert */\r\n {\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n switch (Rc)\r\n {\r\n case 226 :\r\n case 250 : iRetCode = FTPERR_OK ; break;\r\n default : iRetCode = FTPERR_UNEXPECTEDANSWER;\r\n }\r\n }\r\n else\r\n iRetCode = FTPERR_DATACONNECTION;\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n TRUE, \r\n (LPARAM) iRetCode);\r\n }\r\n break;\r\n\r\n\r\n } /* switch Msg */\r\nreturn (LRESULT) DefWindowProc (hWnd, Msg, wParam, lParam);\r\n} /* DLLWndProc */\r\n\r\n\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie VII : Transfert de fichier synchrone */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* FtpSyncSend */\r\n/* ------------------------------------------------------------ */\r\nint FtpSyncSend (LPProcData pProcData)\r\n{\r\nint nRead, Rc;\r\nstruct timeval TO;\r\n\r\n for ( ; ; ) \r\n {\r\n if HAS_ABORTED()\r\n {\r\n AbortAction (pProcData, FALSE, TRUE, 6);\r\n return FTPERR_CANCELBYUSER;\r\n }\r\n \r\n nRead = _lread (pProcData->File.hf, \r\n pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf);\r\n if (nRead > 0)\r\n {\r\n pProcData->File.lPos += nRead;\r\n Rc = TcpSend (pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, nRead, 0, HFILE_ERROR);\r\n if (Rc == TCP4U_SUCCESS)\r\n { \r\n if (pProcData->File.bNotify)\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n FALSE,\r\n pProcData->File.lPos );\r\n if (++pProcData->File.nCount % FTP_RATE(pProcData) == 0) \r\n {\r\n TO.tv_sec = pProcData->File.nDelay / 1000;\r\n TO.tv_usec = (long) (pProcData->File.nDelay % 1000) * 1000l;\r\n Rc = select (0, NULL, NULL, NULL, & TO);\r\n if (Rc==-1 && HAS_ABORTED())\r\n {\r\n AbortAction (pProcData, FALSE, TRUE, 7);\r\n return FTPERR_CANCELBYUSER;\r\n }\r\n } /* pause */\r\n } /* nWritten <> nRead */ \r\n else\r\n {\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n return FTPERR_SENDREFUSED;\r\n } /* probleme reseau */ \r\n } /* nRead > 0 */\r\n else /* fin de données */\r\n { \r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n return FtpAutomate (_S_ENDFILETRANSFER, NULL);\r\n } /* can not read file */\r\n } /* do forever */\r\n} /* FtpSyncSend */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSyncRecv */\r\n/* ------------------------------------------------------------ */\r\nint FtpSyncRecv (LPProcData pProcData)\r\n{\r\nint nRead=0, nWritten, iRetCode, Rc;\r\nstruct timeval TO;\r\n\r\n for ( ; ; ) \r\n {\r\n if ( ! HAS_ABORTED() )\r\n nRead = TcpRecv (pProcData->ftp.data_socket, \r\n pProcData->File.szBuf, \r\n sizeof pProcData->File.szBuf, \r\n pProcData->ftp.nTimeOut,\r\n HFILE_ERROR);\r\n \r\n /* repeter le test car bAborted peut etre positionne entre temps */ \r\n if HAS_ABORTED()\r\n {\r\n AbortAction (pProcData, TRUE, TRUE, 8);\r\n return FTPERR_CANCELBYUSER;\r\n }\r\n\r\n if (nRead > 0)\r\n {\r\n nWritten = _lwrite (pProcData->File.hf, \r\n pProcData->File.szBuf, \r\n nRead);\r\n if (nWritten!=nRead)\r\n {\r\n /* envoi d'un ABORT au distant */ \r\n AbortAction (pProcData, TRUE, FALSE, 9); /* receive data */\r\n return FTPERR_CANTWRITE;\r\n } /* lecture TCP Non OK */ \r\n pProcData->File.lPos += (unsigned) nWritten;\r\n if (pProcData->File.bNotify)\r\n PostMessage (pProcData->Msg.hParentWnd, \r\n pProcData->Msg.nCompletedMessage, \r\n FALSE,\r\n pProcData->File.lPos );\r\n if (++pProcData->File.nCount % FTP_RATE(pProcData) == 0) \r\n {\r\n TO.tv_sec = pProcData->File.nDelay / 1000;\r\n TO.tv_usec = (long) (pProcData->File.nDelay % 1000) * 1000l;\r\n Rc = select (0, NULL, NULL, NULL, & TO);\r\n } /* pause to be done */\r\n } /* nRead > 0 */\r\n else /* fin de données */\r\n {\r\n if (nRead == TCP4U_SOCKETCLOSED) /* fin de transfert normal */\r\n {\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n iRetCode = FtpAutomate (_S_ENDFILETRANSFER, NULL);\r\n }\r\n else /* erreur dans la connexion */\r\n { \r\n AbortAction (pProcData, TRUE, FALSE, 10); \r\n iRetCode = FTPERR_DATACONNECTION;\r\n }\r\n return iRetCode;\r\n } /* nRead <=0 */\r\n } /* do forever */\r\n} /* FtpSyncRecv */\r\n\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie VIII : Fonctions FTP exportées */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpAbort */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpAbort (void)\r\n{\r\nLPProcData pProcData;\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FALSE;\r\n if (pProcData->ftp.data_socket != INVALID_SOCKET) \r\n {\r\n WSACancelBlockingCall ();\r\n pProcData->File.bAborted = TRUE;\r\n }\r\n else if (pProcData->ftp.ctrl_socket!=INVALID_SOCKET) WSACancelBlockingCall ();\r\nreturn TRUE;\r\n} \r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpGetFileSize */\r\n/* ------------------------------------------------------------ */\r\nDWORD _export PASCAL FAR FtpGetFileSize (void)\r\n{\r\nLPProcData pProcData;\r\nLPSTR lp;\r\nlong lFileSize=0;\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return 0;\r\n \r\n /* code de retour serveur : 150, 125 -> opening data connection */\r\n if ( _fmemcmp (pProcData->ftp.szInBuf, \"150\", 3)!=0\r\n && _fmemcmp (pProcData->ftp.szInBuf, \"125\", 3)!=0) return 0;\r\n AnsiLower (pProcData->ftp.szInBuf) ;\r\n lp=_fstrstr (pProcData->ftp.szInBuf, \" bytes\");\r\n if (lp==NULL) return 0;\r\n while (isdigit (*--lp));\r\n for (lp++ ; isdigit (*lp) ; lp++ )\r\n { \r\n lFileSize *= 10;\r\n lFileSize += (*lp-'0');\r\n }\r\nreturn lFileSize; \r\n} /* FtpGetFileSize */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpOpenDataConnection */\r\n/* Open the data connection on port 20 */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpOpenDataConnection (LPCSTR szRemote, int nAction,\r\n char cType)\r\n{\r\nchar szTmp [FTP_REPSTRLENGTH];\r\nLPProcData pProcData;\r\n\r\n pProcData = FtpDataPtr ();\r\n wsprintf (szTmp, \"%s %s\", \r\n nAction==FTP4W_STORE_ON_SERVER ? (LPSTR) \"STOR\" :\r\n nAction==FTP4W_APPEND_ON_SERVER ? (LPSTR) \"APPE\" : \r\n (LPSTR) \"RETR\",\r\n szRemote);\r\nreturn ToolsSetDataConnection (pProcData, NULL, FTPMODE_NOTHING,\r\n cType, 0, szTmp);\r\n} /* FtpOpenDataConnection */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRecvThroughDataConnection */\r\n/* recv on port port 20 */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRecvThroughDataConnection (LPSTR szBuf, \r\n unsigned int far *lpBufSize)\r\n{\r\nint Rc= FTPERR_CANCELBYUSER;\r\nLPProcData pProcData;\r\n\r\n pProcData = FtpDataPtr ();\r\n if ( ! HAS_ABORTED() )\r\n Rc = TcpRecv (pProcData->ftp.data_socket, szBuf, *lpBufSize, \r\n pProcData->ftp.nTimeOut, HFILE_ERROR);\r\n /* repeter le test car bAborted peut etre positionne entre temps */ \r\n if HAS_ABORTED()\r\n {\r\n AbortAction (pProcData, TRUE, TRUE, 20);\r\n return FTPERR_CANCELBYUSER;\r\n }\r\n if (Rc>=TCP4U_SUCCESS) \r\n { *lpBufSize = Rc; return FTPERR_OK; }\r\n if (Rc==TCP4U_SOCKETCLOSED) return FTPERR_ENDOFDATA ;\r\n else return FTPERR_DATACONNECTION;\r\n} /* FtpRecvTroughDataConnection */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSendThroughDataConnection */\r\n/* send on port port 20 */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSendThroughDataConnection (LPCSTR szBuf, \r\n unsigned int uBufSize)\r\n{\r\nint Rc;\r\nLPProcData pProcData;\r\n pProcData = FtpDataPtr ();\r\n Rc=TcpSend (pProcData->ftp.data_socket, szBuf, uBufSize, FALSE,HFILE_ERROR);\r\n if (Rc>=TCP4U_SUCCESS) return FTPERR_OK; \r\n else return FTPERR_DATACONNECTION;\r\n} /* FtpSendTroughDataConnection */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpCloseDataConnection */\r\n/* Closes the data connection on port 20 */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpCloseDataConnection (void)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\n pProcData = FtpDataPtr ();\r\n Rc = TcpClose(&pProcData->ftp.data_socket)==TCP4U_SUCCESS ? \r\n FTPERR_OK : FTPERR_CANTCLOSE;\r\n if (Rc==FTPERR_OK) \r\n {\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n switch (Rc)\r\n {\r\n case 250 : \r\n case 226 : return FTPERR_OK ;\r\n case 452 :\r\n case 552 : return FTPERR_CANTWRITE ;\r\n default : return FTPERR_UNEXPECTEDANSWER; \r\n }\r\n } /* transfert OK */\r\nreturn FTPERR_CANTCLOSE;\r\n} /* FtpCloseDataConnection */\r\n\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRecvFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRecvFile (LPCSTR szRemote, LPCSTR szLocal, \r\n char cType, BOOL bNotify,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf (szTmp, \"RETR %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData, \r\n szLocal, \r\n FTPMODE_WRITE,\r\n cType,\r\n 0, /* Skip restart command */\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN(pProcData,Rc); \r\n \r\n pProcData->File.bNotify = bNotify;\r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = FtpGetFileSize ();\r\n \r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_RECV, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncRecv (pProcData);\r\n} /* FtpRecvFile */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSendFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSendFile (LPCSTR szLocal, LPCSTR szRemote, \r\n char cType, BOOL bNotify,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf ( szTmp, \"STOR %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData, \r\n szLocal, \r\n FTPMODE_READ,\r\n cType, \r\n 0, /* Skip restart command */\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN(pProcData, Rc);\r\n\r\n pProcData->File.bNotify = bNotify;\r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = _llseek (pProcData->File.hf, 0, SEEK_END);\r\n _llseek (pProcData->File.hf, 0, SEEK_SET);\r\n\r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_SEND, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncSend (pProcData);\r\n} /* FtpSendFile */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpAppendToLocalFile */\r\n/* The same function than FtpRecvFile */\r\n/* Only a parameter has been changed : */\r\n/* ToolsSetDataConnection is called with */\r\n/* FTPMODE_APPEND instead of FTPMODE_READ */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpAppendToLocalFile (LPCSTR szRemote, LPCSTR szLocal, \r\n char cType, BOOL bNotify,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf (szTmp, \"RETR %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData, \r\n szLocal, \r\n FTPMODE_APPEND,\r\n cType,\r\n 0, /* Skip restart command */\r\n szTmp); \r\n if (Rc!=FTPERR_OK) RETURN(pProcData,Rc); \r\n \r\n pProcData->File.bNotify = bNotify;\r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = FtpGetFileSize ();\r\n \r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_RECV, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncRecv (pProcData);\r\n} /* FtpAppendToLocalFile */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpAppendToRemoteFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpAppendToRemoteFile (LPCSTR szLocal, LPCSTR szRemote,\r\n char cType, BOOL bNotify,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf ( szTmp, \"APPE %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData, \r\n szLocal, \r\n FTPMODE_READ,\r\n cType, \r\n 0, /* Skip restart command */\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN(pProcData, Rc);\r\n\r\n pProcData->File.bNotify = bNotify;\r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = _llseek (pProcData->File.hf, 0, SEEK_END);\r\n _llseek (pProcData->File.hf, 0, SEEK_SET);\r\n\r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_SEND, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncSend (pProcData);\r\n} /* FtpAppendToRemoteFile */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRestartRecvFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRestartRecvFile (LPCSTR szRemote, HFILE hLocal, \r\n char cType, BOOL bNotify,\r\n long lByteCount,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf (szTmp, \"RETR %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData,\r\n NULL, /* no file to be opened */\r\n FTPMODE_WRITE, /* unused */\r\n cType,\r\n lByteCount, /* Restart command */\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN(pProcData,Rc); \r\n \r\n pProcData->File.hf = hLocal;\r\n pProcData->File.bNotify = bNotify;\r\n \r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = FtpGetFileSize () - lByteCount;\r\n \r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_RECV, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncRecv (pProcData);\r\n} /* FtpRestartRecvFile */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRestartSendFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRestartSendFile (HFILE hLocal, LPCSTR szRemote, \r\n char cType, BOOL bNotify,\r\n long lByteCount,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\nlong lFilePos;\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n\r\n wsprintf ( szTmp, \"STOR %s\", szRemote);\r\n Rc = ToolsSetDataConnection (pProcData, \r\n NULL, /* no file to be opened */ \r\n FTPMODE_READ, /* unused */\r\n cType, \r\n lByteCount, /* Restart command */\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN(pProcData, Rc);\r\n\r\n pProcData->File.hf = hLocal;\r\n pProcData->File.bNotify = bNotify;\r\n \r\n /* le nombre d'octets transférés doit partir de 0. En revanche, le nombre */\r\n /* d'octets à transférer doit tenir compte de l'avancement dans le fichier */\r\n lFilePos = _llseek (pProcData->File.hf, 0, SEEK_CUR);\r\n pProcData->File.lTotal =_llseek (pProcData->File.hf, 0, SEEK_END) - lFilePos;\r\n _llseek (pProcData->File.hf, lFilePos, SEEK_SET);\r\n pProcData->File.lPos = 0;\r\n\r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, WMFTP_SEND, 0,(LPARAM)pProcData);\r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncSend (pProcData);\r\n} /* FtpRestartSendFile */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpDir */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpDir (LPCSTR szDef, LPCSTR szLocalFile,\r\n BOOL bLongDir, \r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szTmp [FTP_REPSTRLENGTH];\r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n pProcData->File.bNotify = FALSE;\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n /* synchronous mode -> data must be sent into a file */\r\n if (! pProcData->File.bAsyncMode && szLocalFile==NULL)\r\n return FTPERR_INVALIDPARAMETER;\r\n\r\n if (szDef!=NULL && szDef[0]!=0)\r\n wsprintf ( szTmp, \"%s %s\", (LPSTR) (bLongDir ? \"LIST\" : \"NLST\"), szDef);\r\n else lstrcpy (szTmp, bLongDir ? \"LIST\" : \"NLST\");\r\n Rc = ToolsSetDataConnection (pProcData, \r\n szLocalFile, \r\n FTPMODE_WRITE,\r\n TYPE_A, \r\n 0,\r\n szTmp);\r\n if (Rc!=FTPERR_OK) RETURN (pProcData, Rc);\r\n /* On complete la structure */\r\n pProcData->File.lPos = 0;\r\n pProcData->File.lTotal = 0;\r\n if (pProcData->File.bAsyncMode)\r\n {\r\n PostMessage (pProcData->hFtpWnd, \r\n szLocalFile==NULL ? WMFTP_DIR : WMFTP_RECV,\r\n 0, (LPARAM) pProcData); \r\n return FTPERR_OK;\r\n }\r\n else return FtpSyncRecv (pProcData);\r\n} /* FtpDir */\r\n\r\n\r\n\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* FtpMGet */\r\n/* Receptionne tous les fichiers du repertoire courant */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\nint _export PASCAL FAR FtpMGet (LPCSTR szFilter, char cType, BOOL bNotify,\r\n BOOL (CALLBACK *f) (LPCSTR szRemFile, LPCSTR szLocalFile, int Rc) ) \r\n{\r\nchar szDir [FTP_REPSTRLENGTH];\r\nchar szDirTo [FTP_REPSTRLENGTH];\r\nint Ark;\r\nint Rc;\r\nchar szTempDirFile [144]; /* nom du fichier temporaire */\r\nHFILE hTmpFile; /* handler fichier temporaire */\r\nLPProcData pProcData;\r\nLPSTR p;\r\n\r\n if (FtpIsAsynchronousMode ()) return FTPERR_ASYNCMODE; \r\n\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOACTIVESESSION;\r\n\r\n /* on conserve l'ancien mode */\r\n GetTempFileName (GetTempDrive(0), \"4w\", 0, szTempDirFile); \r\n /* NLST sur le filtre propose */\r\n Rc = FtpDir (szFilter, szTempDirFile, FALSE, 0, 0);\r\n if (Rc != FTPERR_OK)\r\n {\r\n unlink (szTempDirFile);\r\n return FTPERR_CANTOPENLOCALFILE;\r\n } /* error in Dir command */\r\n \r\n /* dir command is OK: list of files to be received is in szTmpFile */ \r\n hTmpFile = _lopen (szTempDirFile, OF_READ);\r\n if (hTmpFile==HFILE_ERROR) \r\n {\r\n unlink (szTempDirFile);\r\n return FTPERR_CANTOPENLOCALFILE;\r\n } /* can not open temporary file (?) */\r\n do\r\n {\r\n memset (szDir, 0, sizeof szDir);\r\n Ark = _lread (hTmpFile, szDir, sizeof szDir - 1);\r\n if (Ark<=0) break;\r\n p = strchr (szDir, '\\n');\r\n if (p == NULL) break;\r\n *p=0; /* fin de chaine */\r\n if (*(p-1)=='\\r') *(p-1)=0; /* precaution */ \r\n /* revenir sur le debut de la ligne suivante */\r\n _llseek (hTmpFile, 1 + (int) (p - szDir) - Ark, 1);\r\n lstrcpy (szDirTo, szDir);\r\n Rc = FTPERR_OK; \r\n if (f == NULL || (*f) (szDir, szDirTo, FTPERR_ENDOFDATA))\r\n Rc = FtpRecvFile (szDir, szDirTo, cType, bNotify, 0, 0);\r\n } /* reste des donnees a lire */\r\n while ( (Rc==FTPERR_OK && f == NULL) || (*f) (szDir, szDirTo, Rc) );\r\n _lclose (hTmpFile);\r\n unlink (szTempDirFile);\r\nreturn Rc;\r\n} /* FtpMGFet */ \r\n#include \t\r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVWSetDecl();\r\nCKERROR CreatePVWSetProto(CKBehaviorPrototype **pproto);\r\nint PVWSet(const CKBehaviorContext& behcontext);\r\nCKERROR PVWSetCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nenum bInputs\r\n{\r\n\tbbI_XML,\r\n\tbbI_AxleSpeed,\r\n\tbbI_Steer,\r\n\tbbI_MotorTorque,\r\n\tbbI_BrakeTorque,\r\n\tbbI_SuspensionSpring,\r\n\tbbI_SuspensionTravel,\r\n\tbbI_Radius,\r\n\tbbI_WFlags,\r\n\tbbI_WSFlags,\r\n\tbbI_LatFunc,\r\n\tbbI_LongFunc,\r\n};\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap2[] =\r\n{\r\n\r\n\tBB_SPIN(bbI_XML,VTE_XML_VEHICLE_SETTINGS,\"XML Link\",\"None\"),\r\n\tBB_SPIN(bbI_AxleSpeed,CKPGUID_FLOAT,\"Axle Speed\",\"2000.0\"),\r\n\tBB_SPIN(bbI_Steer,CKPGUID_ANGLE,\"Steer Angle\",\"1.0\"),\r\n\tBB_SPIN(bbI_MotorTorque,CKPGUID_FLOAT,\"Motor Torque\",\"0.0\"),\r\n\tBB_SPIN(bbI_BrakeTorque,CKPGUID_FLOAT,\"Break Torque\",\"0.0\"),\r\n\tBB_SPIN(bbI_SuspensionSpring,VTS_JOINT_SPRING,\"Suspension Spring\",\"\"),\r\n\tBB_SPIN(bbI_SuspensionTravel,CKPGUID_FLOAT,\"Suspension Travel\",\"0.0\"),\r\n\tBB_SPIN(bbI_Radius,CKPGUID_FLOAT,\"Radius\",\"1.0\"),\r\n\tBB_SPIN(bbI_WFlags,VTS_PHYSIC_WHEEL_FLAGS,\"Wheel Flags\",\"\"),\r\n\tBB_SPIN(bbI_WSFlags,VTF_VWSHAPE_FLAGS,\"Wheel ShapeFlags\",\"\"),\r\n\tBB_SPIN(bbI_LatFunc,VTF_VWTIRE_SETTINGS,\"Latitude Force Settings\",\"\"),\r\n\tBB_SPIN(bbI_LongFunc,VTF_VWTIRE_SETTINGS,\"Longitudinal Force Settings\",\"0.0\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMap2\r\n\r\n//************************************\r\n// Method: FillBehaviorPVWSetDecl\r\n// FullName: FillBehaviorPVWSetDecl\r\n// Access: public\r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPVWSetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVWSet\");\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Sets physical quantities.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7805147,0x322e17e7));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVWSetProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVWSetProto\r\n// FullName: CreatePVWSetProto\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVWSetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVWSet\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*! \\page PVWSet\r\n\r\n\tPVWSet is categorized in \\ref Vehicle\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVWSet.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\t*/\r\n\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PVWSetCB );\r\n\r\n\tBB_EVALUATE_SETTINGS(pInMap2);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// We just want create the building block pictures\r\n\t//\r\n\t#ifdef _DOC_ONLY_\r\n\t\tBB_EVALUATE_INPUTS(pInMap2);\r\n\t#endif // _DOC_ONLY_\r\n\t\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PVWSet);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PVWSet\r\n// FullName: PVWSet\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PVWSet(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object :\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"No Reference Object specified\");\r\n\r\n\r\n\t\tpWheel *wheel = body->getWheel(target);\r\n\t\tif (!wheel)bbErrorME(\"pWheel object doesnt exist!\");\r\n\r\n\t\tpWheel2 *wheel2 = wheel->castWheel2();\r\n\t\tif (!wheel2)bbErrorME(\"Couldnt cast a pWheel2 object\");\r\n\r\n\r\n\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* engel \r\n\t\tkuehne un partner \r\n\t\t*/\r\n\t\t/************************************************************************/\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/************************************************************************/\r\n\t\tBBSParameter(bbI_XML);\r\n\t\tBBSParameter(bbI_AxleSpeed);\r\n\t\tBBSParameter(bbI_Steer);\r\n\t\tBBSParameter(bbI_MotorTorque);\r\n\t\tBBSParameter(bbI_BrakeTorque);\r\n\t\tBBSParameter(bbI_SuspensionSpring);\r\n\t\tBBSParameter(bbI_SuspensionTravel);\r\n\t\tBBSParameter(bbI_Radius);\r\n\r\n\t\tBBSParameter(bbI_WFlags);\r\n\t\tBBSParameter(bbI_WSFlags);\r\n\r\n\t\tBBSParameter(bbI_LatFunc);\r\n\t\tBBSParameter(bbI_LongFunc);\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve values */\r\n\t\t/************************************************************************/\r\n\r\n\t\tint xmlValue = GetInputParameterValue(beh,BB_IP_INDEX(bbI_XML));\r\n\t\tfloat axleVel = GetInputParameterValue(beh,BB_IP_INDEX(bbI_AxleSpeed));\r\n\t\tfloat steer = GetInputParameterValue(beh,BB_IP_INDEX(bbI_Steer));\r\n\t\tfloat mTorque = GetInputParameterValue(beh,BB_IP_INDEX(bbI_MotorTorque));\r\n\t\tfloat bTorque = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BrakeTorque));\r\n\t\tfloat suspensionTravel = GetInputParameterValue(beh,BB_IP_INDEX(bbI_SuspensionTravel));\r\n\r\n\t\tint wFlags = GetInputParameterValue(beh,BB_IP_INDEX(bbI_WFlags));\r\n\t\tint wSFlags = GetInputParameterValue(beh,BB_IP_INDEX(bbI_WSFlags));\r\n\r\n\t\tpSpring sSpring;\r\n\t\tif (sbbI_SuspensionSpring)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_SuspensionSpring);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tsSpring = pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t\tNxSpringDesc xsp;\r\n\t\t\t\t\txsp.damper = sSpring.damper;\r\n\t\t\t\t\txsp.spring = sSpring.spring;\r\n\t\t\t\t\txsp.targetValue = sSpring.targetValue;\r\n\t\t\t\t\tif (xsp.isValid())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\twheel2->setSuspensionSpring(sSpring);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t\tbbErrorME(\"Invalid Spring Setings!\");\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Update Object ! */\r\n\t\t/************************************************************************/\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\tload some settings from XML\r\n\t\tif(sbbI_XML)\r\n\t\t{\r\n\t\t}\r\n\r\n\t\tif (sbbI_Steer)wheel2->setAngle(steer);\r\n\t\tif (sbbI_AxleSpeed)wheel2->setAxleSpeed(axleVel);\r\n\t\tif (sbbI_MotorTorque)wheel2->setMotorTorque(mTorque);\r\n\t\tif (sbbI_BrakeTorque)wheel2->setBreakTorque(bTorque);\r\n\t\tif (sbbI_SuspensionSpring)wheel2->setSuspensionSpring(sSpring);\r\n\t\tif (sbbI_SuspensionTravel)wheel2->setSuspensionTravel(suspensionTravel);\r\n\t\tif (sbbI_WFlags)\r\n\t\t{\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\r\n\t\t\twheel2->setFlags(wFlags);\r\n\r\n\t\t}\r\n\r\n\r\n\t\tif (sbbI_WSFlags)\r\n\t\t{\r\n\t\t\twheel2->getWheelShape()->setWheelFlags(wSFlags);\r\n\t\t}\r\n\r\n\r\n\t\tif (sbbI_LatFunc)\r\n\t\t{\r\n\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(BB_IP_INDEX(bbI_LatFunc));\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tpTireFunction func = pFactory::Instance()->createTireFuncFromParameter(rPar);\r\n\t\t\t\t\tif (func.isValid())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tNxTireFunctionDesc xFn;\r\n\t\t\t\t\t\txFn.asymptoteSlip = func.asymptoteSlip;\r\n\t\t\t\t\t\txFn.asymptoteValue = func.asymptoteValue;\r\n\t\t\t\t\t\txFn.extremumSlip= func.extremumSlip;\r\n\t\t\t\t\t\txFn.extremumValue= func.extremumValue;\r\n\t\t\t\t\t\txFn.stiffnessFactor= func.stiffnessFactor;\r\n\t\t\t\t\t\twheel2->getWheelShape()->setLongitudalTireForceFunction(xFn);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t\tbbErrorME(\"Invalid Tire Function Settings!\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (sbbI_LongFunc)\r\n\t\t{\r\n\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(BB_IP_INDEX(bbI_LongFunc));\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tpTireFunction func = pFactory::Instance()->createTireFuncFromParameter(rPar);\r\n\t\t\t\t\tif (func.isValid())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tNxTireFunctionDesc xFn;\r\n\t\t\t\t\t\txFn.asymptoteSlip = func.asymptoteSlip;\r\n\t\t\t\t\t\txFn.asymptoteValue = func.asymptoteValue;\r\n\t\t\t\t\t\txFn.extremumSlip= func.extremumSlip;\r\n\t\t\t\t\t\txFn.extremumValue= func.extremumValue;\r\n\t\t\t\t\t\txFn.stiffnessFactor= func.stiffnessFactor;\r\n\t\t\t\t\t\twheel2->getWheelShape()->setLongitudalTireForceFunction(xFn);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t\tbbErrorME(\"Invalid Tire Function Settings!\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVWSetCB\r\n// FullName: PVWSetCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PVWSetCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n\r\n\r\n/********************************************************************\r\n\tcreated:\t2007/10/29\r\n\tcreated:\t29:10:2007 15:19\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\\xSystem3D.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\r\n\tfile base:\txSystem3D\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n/*#ifndef USEDIRECTX9\r\n\t#define USEDIRECTX9\r\n#endif*/\r\n\r\n#include \"pch.h\"\r\n#include \"xSystem3D.h\"\r\n#include \"d3d9.h\"\r\n#include \"CKAll.h\"\r\n#include \"3d/DXDiagNVUtil.h\"\r\n#include \"../Manager/InitMan.h\"\r\n\r\n\r\nextern InitMan *_im2;\r\n//////////////////////////////////////////////////////////////////////\r\n//\r\n// DirectX-Helpers\r\n//\r\n//\r\n\r\nnamespace xSystem3DHelper\r\n{\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tvoid xSSaveAllDxPropsToFile(char*file)\r\n\t{\r\n\t\t\r\n\t\tDXDiagNVUtil nvutil;\r\n\t\tnvutil.InitIDxDiagContainer();\r\n\t\t\r\n\t\tFILE *fp = fopen(\"x:\\\\dx.out\",\"a\");\r\n\t\t//nvutil.ListAllDXDiagPropertyNames();\r\n\t\tnvutil.ListAllDXDiagPropertyNamesToTxtFile(fp,true,NULL,NULL);\r\n\r\n\r\n\r\n\t}\r\n\t//int xSGetAvailableTextureMem();\r\n\r\n\tint xSGetAvailableTextureMem(CKContext *ctx)\r\n\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tif (GetIManager() && GetIManager()->m_Context)\r\n\t\t{\r\n\t\t\r\n\t\t\tCKContext * ctx1 = GetIManager()->m_Context;\r\n\t\t\tCKRenderManager* rm = ctx1->GetRenderManager();\r\n\t\t\tCKRenderContext* rc = rm->GetRenderContext(0);\r\n\t\t\tVxDirectXData*\t dx = rc->GetDirectXInfo();\r\n\r\n\t\t\tint z_ = 0;\r\n\t\t\tIDirect3DDevice9 *d_ptr = ((IDirect3DDevice9*)dx->D3DDevice);\r\n\t\t\t\r\n\t\t\tif(dx)\t\t{\t\t\treturn d_ptr->GetAvailableTextureMem();\t\t}\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\treturn -1;\r\n\t\t\r\n\t}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\n\r\n\tfloat xSGetPhysicalMemoryInMB()\r\n\t{\r\n\t\tDXDiagNVUtil nvutil;\r\n\t\tnvutil.InitIDxDiagContainer();\r\n\t\t\r\n\r\n\t\tfloat ret = -1;\r\n\t\tnvutil.GetPhysicalMemoryInMB(&ret);\r\n\t\tnvutil.FreeIDxDiagContainer();\r\n\r\n\t\treturn ret;\r\n\t}\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////\r\n\tint xSGetPhysicalGPUMemoryInMB(int device)\r\n\t{\r\n\r\n\tDXDiagNVUtil nvutil;\r\n\tnvutil.InitIDxDiagContainer();\r\n\r\n\tint ret = -1;\r\n\tnvutil.GetDisplayDeviceMemoryInMB(device, &ret);\r\n\tnvutil.FreeIDxDiagContainer();\r\n\treturn ret;\r\n\t}\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\n\r\nvoid pWorld::_construct()\r\n{\r\n\t//mAllocator = new UserAllocator;\r\n\t//mCManager = NxCreateControllerManager(mAllocator);\r\n}\r\n\r\nvoid pWorld::destroyCloth(CK_ID id)\r\n{\r\n\r\n\tpCloth*cloth = getCloth(id);\r\n\tif (cloth)\r\n\t{\r\n\t\tdelete cloth;\r\n\t}\r\n}\r\n\r\npCloth *pWorld::getCloth(CK_ID id)\r\n{\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tif (id == vCloth->getEntityID() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn vCloth;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\npCloth *pWorld::getCloth(CK3dEntity*reference)\r\n{\r\n\tif (!reference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tif (reference->GetID() == vCloth->getEntityID() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn vCloth;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nvoid pWorld::updateClothes()\r\n{\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tvCloth->updateVirtoolsMesh();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\nint pWorld::getNbBodies()\r\n{\r\n\tint result = 0;\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tresult+= getScene()->getNbActors();\r\n\treturn result;\r\n}\r\nint pWorld::getNbJoints()\r\n{\r\n\tint result = 0;\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tresult+= getScene()->getNbJoints();\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\nNxShape *pWorld::getShapeByEntityID(CK_ID id)\r\n{\r\n\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCK3dEntity *entA = static_cast(GetPMan()->GetContext()->GetObject(id));\r\n\tif (!entA)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body =static_cast(actor->userData);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = body->getActor()->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)body->getActor()->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\t\tif (info)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\t\t\t\tif (ent == entA )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn s;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npRigidBody* pWorld::getBodyFromSubEntity(CK3dEntity *sub)\r\n{\r\n\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body =static_cast(actor->userData);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = body->getActor()->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)body->getActor()->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\t\tif (info)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\t\t\t\tif (ent)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (sub == ent)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\treturn body;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\nvoid pWorld::checkList()\r\n{\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity * ent = static_cast(GetPMan()->GetContext()->GetObject(body->getEntID()));\r\n\t\t\t\tif (!ent)\r\n\t\t\t\t{\r\n\t\t\t\t\tdeleteBody(body);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\r\n\t\t\t\tCK3dEntity * ent = static_cast(GetPMan()->GetContext()->GetObject(vCloth->getEntityID()));\r\n\t\t\t\tif (!ent)\r\n\t\t\t\t{\r\n\t\t\t\t\tdestroyCloth(vCloth->getEntityID());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid pWorld::deleteBody(pRigidBody*body)\r\n{\r\n\r\n\tif (body)\r\n\t{\r\n\t\tbody->destroy();\r\n\t\tif (body->getWorld() && body->getWorld()->getScene() )\r\n\t\t{\r\n\r\n\t\t\tfor (int i = 0 ; i < body->getWorld()->getJointFeedbackList().Size(); i++ )\r\n\t\t\t{\r\n\t\t\t\tpBrokenJointEntry *entry = *body->getWorld()->getJointFeedbackList().At(i);\r\n\t\t\t\tif (entry && entry->joint)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t/*if (entry->joint->GetVTEntA() == body->GetVT3DObject() || entry->joint->GetVTEntB() == body->GetVT3DObject() )\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\ti = 0;\r\n\r\n\t\t\t\t\t}*/\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tdelete body;\r\n\t\tbody =NULL;\r\n\t}\r\n\r\n\tcheckList();\r\n\r\n\r\n}\r\n\r\nvoid pWorld::deleteJoint(pJoint*joint)\r\n{\r\n\r\n\tif (!joint)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tpWorld *world = joint->getWorld();\r\n\tif (world && world->getScene() )\r\n\t{\r\n\r\n\t\t\t\r\n\t\tfor (int i = 0 ; i < world->getJointFeedbackList().Size(); i++ )\r\n\t\t{\r\n\t\t\tpBrokenJointEntry *entry = *world->getJointFeedbackList().At(i);\r\n\t\t\tif (entry && entry->joint == joint)\r\n\t\t\t{\r\n\t\t\t\tworld->getJointFeedbackList().EraseAt(i);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tjoint->getJoint()->userData = NULL;\r\n\t\tworld->getScene()->releaseJoint(*joint->getJoint());\r\n\t\tdelete joint;\r\n\r\n\t}\r\n}\r\n\r\npJoint* pWorld::getJoint(CK3dEntity *_a, CK3dEntity *_b, JType type)\r\n{\r\n\t\r\n\t\tif (!getScene())\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tpRigidBody *a = GetPMan()->getBody(_a);\r\n\t\tpRigidBody *b = GetPMan()->getBody(_b);\r\n\r\n\t\t//bodies have already a joint together ? \r\n\t\tif ( !a && !b)\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif ( a == b)\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (a && !a->isValid() )\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (a && !GetPMan()->getWorldByBody(_a))\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (b && !GetPMan()->getWorldByBody(_b) )\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (b && !b->isValid())\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif ( a && b )\r\n\t\t{\r\n\t\t\tpWorld*worldA = GetPMan()->getWorldByBody(_a);\r\n\t\t\tpWorld*worldB = GetPMan()->getWorldByBody(_b);\r\n\t\t\tif (!worldA || !worldB || (worldA!=worldB) || !worldA->isValid() || !worldB->isValid() )\r\n\t\t\t{\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tNxU32\tjointCount = getScene()->getNbJoints();\r\n\t\tif (jointCount)\r\n\t\t{\r\n\t\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\t\tgetScene()->resetJointIterator();\r\n\t\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t\t{\r\n\t\t\t\tNxJoint\t*j = getScene()->getNextJoint();\r\n\r\n\t\t\t\tif (type == JT_Any)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\t\t\tif ( mJoint )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == _a && mJoint->GetVTEntB() == _b )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tCK3dEntity *inA = _b;\r\n\t\t\t\t\t\tCK3dEntity *inB = _a;\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == inA && mJoint->GetVTEntB() == inB )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\r\n\t\t\t\tif ( j->getType() == type)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\t\t\tif ( mJoint )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == _a && mJoint->GetVTEntB() == _b )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tCK3dEntity *inA = _b;\r\n\t\t\t\t\t\tCK3dEntity *inB = _a;\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == inA && mJoint->GetVTEntB() == inB )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn NULL;\r\n}\r\n\r\nbool pWorld::isValid()\r\n{\r\n\r\n\treturn getScene() ? true : false;\r\n}\r\n\r\nvoid pWorld::step(float stepsize)\r\n{\r\n\r\n\tif (getScene())\r\n\t{\r\n\t\tNxU32 nbTransforms = 0; \r\n\t\tNxActiveTransform *activeTransforms = getScene()->getActiveTransforms(nbTransforms); \r\n\r\n\t\t//getScene()->fetchResults(NX_ALL_FINISHED,true);\r\n\r\n\t\t//stepsize *=0.001f;\r\n\t\t\r\n\t\tupdateVehicles(stepsize);\r\n\t\t\r\n\t\tupdateClothes();\r\n\r\n\t\t#ifdef HAS_FLUIDS\r\n\t\t\tupdateFluids();\r\n\t\t#endif\r\n\r\n\t\tgetScene()->simulate(stepsize);\r\n\r\n\t\t if(nbTransforms && activeTransforms) \r\n\t\t { \r\n\t\t\t for(NxU32 i = 0; i < nbTransforms; ++i) \r\n\t\t\t { \r\n\t\t\t\t // the user data of the actor holds the game object pointer \r\n\t\t\t\t NxActor *actor = activeTransforms[i].actor;\r\n\t\t\t\t if (actor)\r\n\t\t\t\t {\r\n\r\n\t\t\t\t\t pRigidBody *body = (pRigidBody*)actor->userData;\r\n\t\t\t\t\t // update the game object's transform to match the NxActor\r\n\t\t\t\t\t if(body)\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t //gameObject->setTransform(activeTransforms[i].actor2World); \r\n\t\t\t\t\t\t NxMat34 transformation = activeTransforms[i].actor2World;\r\n\t\t\t\t\t\t VxQuaternion rot = pMath::getFrom(transformation.M);\r\n\t\t\t\t\t\t VxVector pos = pMath::getFrom(transformation.t);\r\n\t\t\t\t\t\t VxVector pos2 = pMath::getFrom(transformation.t);\r\n\t\t\t\t\t\t CK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(body->getEntID()));\r\n\r\n\t\t\t\t\t\t NxShape *mainShape=body->getMainShape();\r\n\t\t\t\t\t\t if (mainShape)\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t VxVector diff = getFrom(mainShape->getLocalPosition());\r\n\t\t\t\t\t\t\t if (XAbs(diff.SquareMagnitude()) > 0.01f)\r\n\t\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t\t //pos+=diff;\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t }\r\n\r\n\t\t\t\t\t\t if (ent)\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\tent->SetPosition(&pos);\r\n\t\t\t\t\t\t\tent->SetQuaternion(&rot);\r\n\t\t\t\t\t\t\tbody->updateSubShapes();\r\n\t\t\t\t\t\t }else{\r\n\t\t\t\t\t\t\t xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Invalid Body due simulation.\");\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t }\r\n\t\t\t\t }\r\n\t\t\t} \r\n\t\t }\r\n\r\n\t\t NxU32 error;\r\n\t\t getScene()->flushStream();\r\n\t\t getScene()->fetchResults(NX_RIGID_BODY_FINISHED,true,&error);\r\n\r\n\t\t \r\n\t\t int err = error;\r\n\r\n\r\n\t}\r\n}\r\n\r\n\r\n\r\npRigidBody*pWorld::getBody(CK3dEntity*ent)\r\n{\r\n\tpRigidBody *result = NULL;\r\n\t\r\n\tif (!ent || !getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body && body->getEntID() == ent->GetID() )\r\n\t\t\t{\r\n\t\t\t\treturn body;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (body && body->isSubShape(ent) )\r\n\t\t\t{\r\n\t\t\t\treturn body;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\npWorld::pWorld(CK3dEntity* _o)\r\n{\r\n\r\n\tm_SleepingSettings = NULL;\r\n\tm_worldSettings =NULL;\r\n\tm_vtReference = _o;\r\n\tmScene = NULL;\r\n\tcontactReport = NULL;\r\n\ttriggerReport = NULL;\r\n\r\n}\r\npWorld::~pWorld()\r\n{\r\n\r\n\t//m_worldSettings = NULL;\r\n\t//m_SleepingSettings =NULL;\r\n\tmScene = NULL;\r\n\t//m_vtReference =NULL;\r\n}\r\nvoid pWorld::destroy()\r\n{\r\n\r\n\r\n\tif (getScene())\r\n\t{\r\n\t\tint nbActors = getScene()->getNbActors();\r\n\t\tif (!nbActors)return;\r\n\r\n\r\n\t\tNxActor** actors = getScene()->getActors();\r\n\t\twhile(nbActors--)\r\n\t\t{\r\n\t\t\tNxActor* actor = *actors++;\r\n\t\t\tif(actor->userData != NULL)\r\n\t\t\t{\r\n\t\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\t\tbody->destroy();\r\n\t\t\t\t\tif (body->GetVT3DObject())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Body destroyed :\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdelete body;\r\n\t\t\t\t\tbody =NULL;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (GetPMan()->getPhysicsSDK())\r\n\t{\r\n\t\tGetPMan()->getPhysicsSDK()->releaseScene(*mScene);\r\n\t\tmScene = NULL;\r\n\t}\r\n\r\n\tif (m_SleepingSettings)\r\n\t{\r\n\t\tdelete m_SleepingSettings;\r\n\t\tm_SleepingSettings = NULL;\r\n\t}\r\n\r\n\tif (m_worldSettings)\r\n\t{\r\n\t\tdelete m_worldSettings;\r\n\t\tm_worldSettings = NULL;\r\n\t}\r\n\t\r\n}\r\nint pWorld::UpdateProperties(DWORD mode,DWORD flags)\r\n{\r\n\r\n\treturn 0;\r\n\r\n}// racer/time.h\n\n#ifndef __X_TIME_H__\n#define __X_TIME_H__\n#include \n#include \n\n\nclass MODULE_API xTime\n// A notion of simulation time\n{\n protected:\n float span;\t\t// Time of integration (in seconds)\n int spanMS; // Time of integration in milliseconds\n QTimer *tmr;\t\t// Actual real timer\n int curRealTime;\t// Last recorded REAL time in msecs\n int curSimTime;\t// Time calculated in the sim\n int lastSimTime; // Last point of simulation\n\n public:\n xTime();\n ~xTime();\n\n // Attribs\n int GetRealTime(){ return curRealTime; }\n int GetSimTime(){ return curSimTime; }\n int GetLastSimTime(){ return lastSimTime; }\n int GetSpanMS(){ return spanMS; }\n inline float GetSpan(){ return span; }\n\n void AddSimTime(int msecs);\n void SetLastSimTime(){ lastSimTime=curSimTime; }\n void SetSpan(int ms);\n\n // Methods\n void Start();\n void Stop();\n void Reset();\n void Update();\n};\n\n#endif\n#include \r\n#include \"vtPhysXAll.h\"\r\n//#include \"tinyxml.h\"\r\n#include \r\n\r\n\r\nstatic pFactory* pFact = NULL;\r\n\r\nvoid pFactory::findAttributeIdentifiersByGuid(CKGUID guid,std::vector&targetList)\r\n{\r\n\r\n\tCKContext *ctx = GetPMan()->GetContext();\r\n\r\n\tCKAttributeManager *attMan = ctx->GetAttributeManager();\r\n\tCKParameterManager *parMan = ctx->GetParameterManager();\r\n\r\n\tint cCount = attMan->GetAttributeCount();\r\n\tfor(int i = 0 ; i < cCount ; i++)\r\n\t{\r\n\t\tCKSTRING name = attMan->GetAttributeNameByType(i);\r\n\t\tif ( parMan->ParameterTypeToGuid(attMan->GetAttributeParameterType(i)) == guid )\r\n\t\t{\r\n\t\t\ttargetList.push_back(i);\r\n\t\t}\r\n\t\t\r\n\t}\r\n}\r\n\r\n//************************************\r\n// Method: Instance\r\n// FullName: vtODE::pFactory::Instance\r\n// Access: public \r\n// Returns: pFactory*\r\n// Qualifier:\r\n//************************************\r\npFactory* pFactory::Instance()\r\n{\r\n\r\n\tif (!pFact)\r\n\t{\r\n\t\tpFact = new pFactory(GetPMan(),GetPMan()->getDefaultConfig());\r\n\t}\r\n\treturn pFact;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: ~pFactory\r\n// FullName: vtODE::pFactory::~pFactory\r\n// Access: public \r\n// Returns: \r\n// Qualifier:\r\n//************************************\r\npFactory::~pFactory()\r\n{\r\n\r\n\t//Clean();\r\n\tdelete pFact;\r\n\tpFact = NULL;\r\n}\r\n\r\npFactory::pFactory()\r\n{\r\n\r\n}\r\n//************************************\r\n// Method: pFactory\r\n// FullName: vtODE::pFactory::pFactory\r\n// Access: public \r\n// Returns: // Qualifier: : m_PManager(prm1), m_DefaultDocument(prm2)\r\n// Parameter: PhysicManager* prm1\r\n// Parameter: TiXmlDocument*prm2\r\n//************************************\r\npFactory::pFactory(PhysicManager* prm1,TiXmlDocument*prm2) : \r\n\tmManager(prm1), m_DefaultDocument(prm2)\r\n{\r\n\tpFact = this;\r\n\tmPhysicSDK = NULL;\r\n}\r\n//************************************\r\n// Method: ResolveFileName\r\n// FullName: vtODE::pFactory::ResolveFileName\r\n// Access: public \r\n// Returns: XString\r\n// Qualifier:\r\n// Parameter: const char *input\r\n//************************************\r\nXString pFactory::ResolveFileName(const char *input)\r\n{\r\n\tCKPathManager *pm = GetPMan()->m_Context->GetPathManager();\r\n\t\r\n\tFILE *file = fopen(input,\"r\");\r\n\tXString result;\r\n\tif (file)\r\n\t{\r\n\t\tchar Ini[MAX_PATH];\r\n\t\tchar drive[MAX_PATH];\r\n\t\tchar dir[MAX_PATH];\r\n\t\tchar szPath[MAX_PATH];\r\n\r\n\t\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\t\tsprintf(Ini,\"%s%s%s\",drive,dir,input);\t\r\n\t\t\r\n\t\tfclose(file);\r\n\r\n\t\treturn XString(Ini);\r\n\t}\r\n\r\n\tif (!file)\r\n\t{\r\n\t\tCKSTRING lastCmo = GetPMan()->m_Context->GetLastCmoLoaded();\r\n\t\tCKPathSplitter splitter(const_cast(lastCmo));\r\n\t\tCKPathSplitter splitter2(const_cast(input));\r\n\t\tCKPathMaker maker(splitter.GetDrive(),splitter.GetDir(),const_cast(input),\"\");\r\n\t\tchar* NewFilename = maker.GetFileName();\r\n\t\tfile = fopen(NewFilename,\"r\");\r\n\t\tif (!file)\r\n\t\t{\r\n\t\t\tchar Ini[MAX_PATH];\r\n\t\t\tchar drive[MAX_PATH];\r\n\t\t\tchar dir[MAX_PATH];\r\n\t\t\tchar szPath[MAX_PATH];\r\n\r\n\t\t\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t\t\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\t\t\tsprintf(Ini,\"%s%s%s\",drive,dir,input);\t\r\n\t\t\tfile = fopen(Ini,\"r\");\r\n\t\t\tif(file)\r\n\t\t\t{\r\n\t\t\t\tfclose(file);\r\n\t\t\t\treturn XString(Ini);\r\n\t\t\t}\r\n\r\n\t\t\tif(pm)\r\n\t\t\t{\r\n\t\t\t\tXString fname(const_cast(input));\r\n\t\t\t\tCKERROR error = GetPMan()->m_Context->GetPathManager()->ResolveFileName( fname , DATA_PATH_IDX);\r\n\t\t\t\tif (error ==CK_OK)\r\n\t\t\t\t{\r\n\t\t\t\t\tfile = fopen(fname.CStr(),\"r\");\r\n\t\t\t\t\tif (file)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfclose(file);\r\n\t\t\t\t\t\tresult = fname;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n//************************************\r\n// Method: CreateFrame\r\n// FullName: vtODE::pFactory::CreateFrame\r\n// Access: public \r\n// Returns: CK3dEntity*\r\n// Qualifier:\r\n// Parameter: XString name\r\n//************************************\r\nCK3dEntity*\r\npFactory::createFrame(const char* name)\r\n{\r\n\tif (!strlen(name))\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint count = ctx()->GetObjectsCountByClassID(CKCID_3DENTITY);\r\n\tCK_ID* ol = ctx()->GetObjectsListByClassID(CKCID_3DENTITY);\r\n\r\n\tfor(int j=0;j(ctx()->GetObject(ol[j]));\r\n\t\tif (!strcmp(o->GetName(),name ) )\r\n\t\t{\r\n\t\t\treturn static_cast(o);\r\n\t\t}\r\n\t}\r\n\r\n\tCK_OBJECTCREATION_OPTIONS creaoptions = CK_OBJECTCREATION_NONAMECHECK;\r\n\t//if (dynamic) creaoptions = CK_OBJECTCREATION_DYNAMIC;\r\n\r\n\t// The Creation\r\n\t\r\n\tCKObject* object = ctx()->CreateObject(CKCID_3DENTITY,const_cast(name),creaoptions);\r\n\tCK3dEntity* ent=(CK3dEntity*)object;\r\n\tent->SetFlags(ent->GetFlags()|CK_3DENTITY_FRAME);\r\n\r\n\t// we add it to the level\r\n\r\n\tCKLevel *level = ctx()->GetCurrentLevel();\r\n\tif (level)\r\n\t{\r\n\t\tlevel->AddObject(object);\r\n\t}\r\n\r\n\treturn ent;\r\n\r\n}\r\n\r\n\r\n\r\n//************************************\r\n// Method: _str2Vec\r\n// FullName: vtODE::pFactory::_str2Vec\r\n// Access: public \r\n// Returns: VxVector\r\n// Qualifier:\r\n// Parameter: XString _in\r\n//************************************\r\nVxVector \r\npFactory::_str2Vec(XString _in)\r\n{\r\n\tshort nb = 0 ; \r\n\tVxVector out;\r\n\tXStringTokenizer\ttokizer(_in.CStr(), \",\");\r\n\tconst char*tok = NULL;\r\n\twhile ((tok=tokizer.NextToken(tok)) && nb < 3)\r\n\t{\r\n\t\tXString tokx(tok);\r\n\t\tout.v[nb] = tokx.ToFloat();\r\n\t\tnb++;\r\n\t}\r\n\treturn out;\r\n}\r\n\r\nint pFactory::_str2MaterialFlag(XString _in)\r\n{\r\n\t\r\n\tshort nb = 0 ; \r\n\tint result = 0;\r\n\tXStringTokenizer\ttokizer(_in.CStr(), \"|\");\r\n\tconst char*tok = NULL;\r\n\twhile ((tok=tokizer.NextToken(tok)) && nb < 3)\r\n\t{\r\n\t\tXString tokx(tok);\r\n\t\t\r\n\t\tif ( _stricmp(tokx.CStr(),\"Anisotropic\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= MF_Anisotropic;\r\n\t\t}\r\n\t\tif ( _stricmp(tokx.CStr(),\"DisableFriction\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= MF_DisableFriction;\r\n\t\t}\r\n\t\tif ( _stricmp(tokx.CStr(),\"DisableStrongFriction\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= MF_DisableStrongFriction;\r\n\t\t}\r\n \t\tnb++;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n\r\nint pFactory::_getEnumIndex(XString enumerationFull,XString enumValue)\r\n{\r\n\r\n\tint result = 0;\r\n\tXStringTokenizer\ttokizer(enumerationFull.CStr(), \",\");\r\n\tconst char*tok = NULL;\r\n\twhile ((tok=tokizer.NextToken(tok)))\r\n\t{\r\n\t\tXString tokx(tok);\r\n\t\tif (\t!strcmp(tokx.CStr(),enumValue.CStr())\t)\r\n\t\t{\r\n\t\t\treturn result;\r\n\t\t}\r\n\t//\tout.v[nb] = tokx.ToFloat();\r\n\t\tresult++;\r\n\t}\r\n\treturn 0;\r\n}// PBDodyTab.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx.h\"\r\n#include \"PBDodyTab.h\"\r\n\r\n\r\n// PBDodyTab\r\n\r\nIMPLEMENT_DYNAMIC(PBDodyTab, CTabCtrl)\r\n\r\nPBDodyTab::PBDodyTab()\r\n{\r\n\r\n\tEnableAutomation();\r\n}\r\n\r\nPBDodyTab::~PBDodyTab()\r\n{\r\n}\r\n\r\nvoid PBDodyTab::OnFinalRelease()\r\n{\r\n\t// When the last reference for an automation object is released\r\n\t// OnFinalRelease is called. The base class will automatically\r\n\t// deletes the object. Add additional cleanup required for your\r\n\t// object before calling the base class.\r\n\r\n\tCTabCtrl::OnFinalRelease();\r\n}\r\n\r\n\r\nBEGIN_MESSAGE_MAP(PBDodyTab, CTabCtrl)\r\nEND_MESSAGE_MAP()\r\n\r\n\r\nBEGIN_DISPATCH_MAP(PBDodyTab, CTabCtrl)\r\nEND_DISPATCH_MAP()\r\n\r\n// Note: we add support for IID_IPBDodyTab to support typesafe binding\r\n// from VBA. This IID must match the GUID that is attached to the \r\n// dispinterface in the .IDL file.\r\n\r\n// {35C830F1-59A2-40B2-971F-2BEEC5930188}\r\nstatic const IID IID_IPBDodyTab =\r\n{ 0x35C830F1, 0x59A2, 0x40B2, { 0x97, 0x1F, 0x2B, 0xEE, 0xC5, 0x93, 0x1, 0x88 } };\r\n\r\nBEGIN_INTERFACE_MAP(PBDodyTab, CTabCtrl)\r\n\tINTERFACE_PART(PBDodyTab, IID_IPBDodyTab, Dispatch)\r\nEND_INTERFACE_MAP()\r\n\r\n\r\n// PBDodyTab message handlers\r\n\r\n\r\n#ifndef __xDistributedClient_h\r\n#define __xDistributedClient_h\r\n\r\n#include \"xDistributedObject.h\"\r\n\r\n\r\nclass xDistributedClient : public xDistributedObject\r\n{\r\n\ttypedef xDistributedObject Parent;\r\n\tpublic:\r\n\t\txDistributedClient();\r\n\t\tvirtual ~xDistributedClient();\r\n\r\n\t\t\n\t\tenum MaskBits {\n\t\t\tInitialMask = (1 << 0), ///< This mask bit is never set explicitly, so it can be used for initialization data.\n\t\t\tNameMask = (1 << 1), ///< This mask bit is set when the position information changes on the server.\n\t\t\tMessageMask = (1 << 2), ///< This mask bit is set when the position information changes on the server.\n\t\t};\r\n\r\n\t\t\r\n\t\t\r\n\t\tvoid onGhostRemove();\r\n\t\tbool onGhostAdd(TNL::GhostConnection *theConnection);\n\t\tvoid onGhostAvailable(TNL::GhostConnection *theConnection);\n\t\tTNL::U32 packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream);\n\t\tvoid unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream);\r\n\t\tvoid performScopeQuery(TNL::GhostConnection *connection);\r\n\r\n\t\tTNL::StringPtr getLocalAddress() const { return m_localAddress; }\r\n\t\tvoid setLocalAddress(TNL::StringPtr val) { m_localAddress = val; }\r\n\t\tvirtual void destroy();\r\n\t\tvoid writeControlState(TNL::BitStream *stream);\r\n\t\tvoid readControlState(TNL::BitStream * bstream);\r\n\r\n\t\tvoid pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\t\r\n\t\tint mUserFlags;\r\n\t\tint getUserFlags() const { return mUserFlags; }\r\n\t\tvoid setUserFlags(int val) { mUserFlags = val; }\r\n\t\tTNL::StringPtr mUserName;\r\n\t\tTNL::StringPtr getUserName() const { return mUserName; }\r\n\t\tvoid setUserName(TNL::StringPtr val) { mUserName = val; }\r\n\t\tTNL_DECLARE_RPC(rpcSetName, (TNL::StringPtr name));\r\n\r\n\t\tTNL::BitSet32 mClientFlags;\r\n\t\t\r\n\t\tTNL::BitSet32& getClientFlags() { return mClientFlags; }\r\n\t\tvoid setClientFlags(TNL::BitSet32 val) { mClientFlags = val; }\r\n\t\t\r\n\r\n\t\tvoid setCurrentOutMessage(xMessage* msg);\r\n\t\txMessage*getCurrentMessage(){ return mCurrentMessage ; }\r\n\t\txMessage *mCurrentMessage;\r\n\r\n\r\n\t\tvoid calculateUpdateBits();\r\n\t\t\r\n\t\tuxString print(TNL::BitSet32 flags);\r\n\r\n\tprotected:\r\n\r\n\t\t\r\n\t\tint m_UserID;\r\n\t\tTNL::StringPtr m_localAddress;\r\n\r\n\tpublic:\r\n\t\tTNL_DECLARE_CLASS(xDistributedClient);\r\n};\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#define PARAMETER_OP_TYPE_WHEEL_GETCONTACT CKGUID(0x74654a40,0x74ba3b5b)\r\n#define PARAMETER_OP_TYPE_WDATA_GET_COLLIDER CKGUID(0x4dae6732,0x37740a24)\r\n#define PARAMETER_OP_TYPE_WDATA_GET_MATERIAL CKGUID(0xa45301e,0x73e41d8f)\r\n#define PARAMETER_OP_TYPE_WDATA_GET_CPOINT CKGUID(0x2f731ff8,0xa792311)\r\n\r\n\r\nvoid ParamOpWheelContactGetCollider(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tCK_ID value = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_WCD_CONTACT_ENTITY,false);\r\n\t\t\tres->SetValue(&value);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpWheelContactGetMaterial(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tCKParameterOut *materialParameter = vtTools::ParameterTools::GetParameterFromStruct(p1->GetRealSource(),E_WCD_OTHER_MATERIAL_INDEX,false);\r\n\t\t\tif (materialParameter)\r\n\t\t\t{\r\n\t\t\t\tres->CopyValue(materialParameter);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpWheelGetContact(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tpRigidBody *body = NULL;\r\n\r\n\t//user comes usually with entity which is associated with the wheel and not with the body reference : \r\n\tbody = GetPMan()->getBody(pFactory::Instance()->getMostTopParent(ent));\r\n\tif (!body)\r\n\t\treturn;\r\n\r\n\tpWheel2 *wheel =(pWheel2*)body->getWheel(ent);\r\n\tif (!wheel)return;\r\n\r\n\tpWheelContactData cData = *wheel->getContact();\r\n\r\n\t//copy result in the parameter operations result parameter : \r\n\tpFactory::Instance()->copyTo(res,cData);\r\n\r\n}\r\n\r\n\r\n\r\nvoid PhysicManager::_RegisterParameterOperationsVehicle()\r\n{\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\t\r\n\r\n\tpm->RegisterOperationType(PARAMETER_OP_TYPE_WHEEL_GETCONTACT, \"pwGContact\");\r\n\tpm->RegisterOperationFunction(PARAMETER_OP_TYPE_WHEEL_GETCONTACT,VTS_WHEEL_CONTACT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpWheelGetContact);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// member retrieve of the type pWheelContactData : \r\n\r\n\t//other entity : \r\n\tpm->RegisterOperationType(PARAMETER_OP_TYPE_WDATA_GET_COLLIDER, \"wcdGEntity\");\r\n\tpm->RegisterOperationFunction(PARAMETER_OP_TYPE_WDATA_GET_COLLIDER,CKPGUID_3DENTITY,VTS_WHEEL_CONTACT,CKPGUID_NONE,ParamOpWheelContactGetCollider);\r\n\r\n\t//material\r\n\tpm->RegisterOperationType(PARAMETER_OP_TYPE_WDATA_GET_MATERIAL, \"wcdGMaterial\");\r\n\tpm->RegisterOperationFunction(PARAMETER_OP_TYPE_WDATA_GET_MATERIAL,VTS_MATERIAL,VTS_WHEEL_CONTACT,CKPGUID_NONE,ParamOpWheelContactGetMaterial);\r\n\r\n\r\n\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nint pVehicleMotor::loadNewTorqueCurve(pLinearInterpolation newTCurve)\r\n{\r\n\r\n\t_torqueCurve.clear();\r\n\t_torqueCurve = newTCurve;\r\n\t\r\n\tNxReal maxTorque = 0;\r\n\tNxI32 maxTorquePos = -1;\r\n\tfor (NxU32 i = 0; i < _torqueCurve.getSize(); i++) \r\n\t{\r\n\t\tNxReal v = _torqueCurve.getValueAtIndex(i);\r\n\t\tif (v > maxTorque) {\r\n\t\t\tmaxTorque = v;\r\n\t\t\tmaxTorquePos = i;\r\n\t\t}\r\n\t}\r\n\r\n\t_maxTorque\t\t\t= maxTorque;\r\n\t_maxTorquePos\t\t= (float)maxTorquePos;\r\n\t\r\n\r\n\treturn 1;\r\n}\r\n\r\nvoid pVehicleMotorDesc::setToDefault() \r\n{\r\n\ttorqueCurve.clear();\r\n\tminRpmToGearDown\t= 1000.0f;\r\n\tmaxRpmToGearUp\t\t= 4000.f;\r\n\tmaxRpm\t\t\t\t= 5000.f;\r\n\tminRpm\t\t\t\t= 1000.f;\r\n\t\r\n\r\n\r\n\tsetToCorvette();\r\n\r\n}\r\n\r\nvoid pVehicleMotorDesc::setToCorvette() {\r\n\t\r\n\t// Default should be values for a corvette!\r\n\t// These are corresponding numbers for rotations and torque (in rpm and Nm)\r\n\r\n\t/*\ttorqueCurve.insert(1000.f, 193.f);\r\n\ttorqueCurve.insert(2000.f, 234.f);\r\n\ttorqueCurve.insert(4000.f, 275.f);\r\n\ttorqueCurve.insert(5000.f, 275.f);\r\n\ttorqueCurve.insert(6000.f, 166.f);*/\r\n\ttorqueCurve.insert(1000, 400);\r\n\ttorqueCurve.insert(3000, 500);\r\n\ttorqueCurve.insert(5000, 300);\r\n\tminRpmToGearDown\t= 1500.f;\r\n\tmaxRpmToGearUp\t\t= 4000.f;\r\n\tminRpm\t\t\t\t= 1000.f;\r\n\tmaxRpm\t\t\t\t= 5000.f;\r\n}\r\n\r\nbool pVehicleMotorDesc::isValid() const\r\n{\r\n\r\n\tif (torqueCurve.getSize() == 0) {\r\n\t\tfprintf(stderr, \"pVehicleMotorDesc::isValid(): Empty TorqueCurve\\n\");\r\n\t\treturn false;\r\n\t}\r\n\tif (maxRpmToGearUp < minRpmToGearDown) {\r\n\t\tfprintf(stderr, \"pVehicleMotorDesc::isValid(): maxRpmToGearUp (%2.3f) is smaller than minRpmToGearDown (%2.3f)\\n\",\r\n\t\t\tmaxRpmToGearUp, minRpmToGearDown);\r\n\t\treturn false;\r\n\t}\r\n\treturn true;\r\n\r\n}\r\n\r\n\r\nint pVehicleMotor::changeGears(const pVehicleGears* gears, float threshold) const \r\n{\r\n\tNxI32 gear = gears->getGear();\r\n\tif (_rpm > _maxRpmToGearUp && gear < gears->getMaxGear())\r\n\t\treturn 1;\r\n\telse if (_rpm < _minRpmToGearDown && gear > 1)\r\n\t\treturn -1;\r\n\t/*\r\n\tNxReal normalTorque = _torqueCurve.getValue(_rpm);\r\n\r\n\tNxReal lowerGearRatio = gears->getRatio(gear-1);\r\n\tNxReal normalGearRatio = gears->getCurrentRatio();\r\n\tNxReal upperGearRatio = gears->getRatio(gear+1);\r\n\tNxReal lowerGearRpm = _rpm / normalGearRatio * lowerGearRatio;\r\n\tNxReal upperGearRpm = _rpm / normalGearRatio * upperGearRatio;\r\n\tNxReal lowerTorque = _torqueCurve.getValue(lowerGearRpm);\r\n\tNxReal upperTorque = _torqueCurve.getValue(upperGearRpm);\r\n\tNxReal lowerWheelTorque = lowerTorque * lowerGearRatio;\r\n\tNxReal normalWheelTorque = normalTorque * normalGearRatio;\r\n\tNxReal upperWheelTorque = upperTorque * upperGearRatio;\r\n\t//printf(\"%2.3f %2.3f %2.3f\\n\", lowerWheelTorque, normalWheelTorque, upperWheelTorque);\r\n\t*/\r\n\r\n\treturn 0;\r\n}\r\n\r\n\r\n/********************************************************************\r\n\tcreated:\t2006/11/17\r\n\tcreated:\t17:11:2006 7:11\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_plugins\\vt_PyCaller\\behaviors\\CallPython.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_plugins\\vt_PyCaller\\behaviors\r\n\tfile base:\tCallPython\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#include \"vt_python_funcs.h\"\r\n//#include \"vt_python_funcs.h\"\r\n#include \r\n#include \"pyembed.h\"\r\n#include \"InitMan.h\"\r\nusing std::cout;\r\n#include \r\n\r\n#include \"vtTools.h\"\r\n\r\nusing namespace vtTools;\r\n\r\nCKObjectDeclaration\t*FillBehaviorCallPythonFuncDecl();\r\nCKERROR CreateCallPythonProto(CKBehaviorPrototype **);\r\nint CallPythonFunc(const CKBehaviorContext& behcontext);\r\nCKERROR CallPythonFuncCB(const CKBehaviorContext& behcontext);\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 3\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorCallPythonFuncDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"CallPythonFunc\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x75251b1b,0x382129b8));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateCallPythonProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Python\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateCallPythonProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"CallPythonFunc\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"File\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Func\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Reload\",CKPGUID_BOOL);\r\n\t//proto->DeclareOutParameter(\"return\",CKPGUID_STRING);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS|CKBEHAVIOR_VARIABLEPARAMETERINPUTS|CKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS|CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS|CKBEHAVIOR_VARIABLEOUTPUTS|CKBEHAVIOR_VARIABLEINPUTS));\r\n\t//proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS|CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\tproto->SetFunction( CallPythonFunc );\r\n\tproto->SetBehaviorCallbackFct(CallPythonFuncCB);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint CallPythonFunc(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t//beh->ActivateInput(0,FALSE);\r\n\r\n\tXString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\tXString Func((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\tint reload=false; //= BehaviorTools::GetInputParameterValue(beh,2);\r\n\t\r\n\tbeh->GetInputParameterValue(2,&reload);\r\n\r\n\tvt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//python env test : \r\n\tif (!pm->pLoaded)\r\n\t{\r\n\t\tpm->m_Context->OutputToConsoleEx(\"You must load Python before !\");\r\n\t\tbeh->ActivateOutput(1,false);\r\n\t\treturn CKBR_BEHAVIORERROR;\r\n\r\n\t}\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//creating args : \r\n\tArg_mmap argsout; \r\n\tusing namespace vtTools::Enums;\r\n\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t{\r\n\t\r\n\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\tCKParameterType pType = ciIn->GetType();\r\n\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\r\n\r\n\t\tswitch (sType)\r\n\t\t{\r\n\t\t\tcase vtSTRING:\r\n\t\t\t\t{\r\n\t\t\t\t\targsout.insert(argsout.end(),std::make_pair(ParameterTools::GetParameterAsString(ciIn->GetRealSource()),Py_string));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase vtFLOAT:\r\n\t\t\t\t{\r\n\t\t\t\t\targsout.insert(argsout.end(),std::make_pair(ParameterTools::GetParameterAsString(ciIn->GetRealSource()),Py_real));\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase vtINTEGER:\r\n\t\t\t\t{\r\n\t\t\t\t\targsout.insert(argsout.end(),std::make_pair(ParameterTools::GetParameterAsString(ciIn->GetRealSource()),Py_long));\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\r\n\t\t\tdefault :\r\n\t\t\t\tXString err(\"wrong input parameter type: \");\r\n\t\t\t\terr << ciIn->GetName() << \"Only Types derivated from Interger,Float or String are acceptable\";\r\n\t\t\t\tctx->OutputToConsole(err.Str(),FALSE );\r\n\t\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\ttry // always check for Python_exceptions\r\n\t\t{\r\n\r\n\t\t\tPython *py = pm->py;\r\n\t\t\tif (Func.Length()==0)\r\n\t\t\t{\r\n\t\t\t\tpy->run_file(File.CStr());\r\n\t\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\t\treturn CKBR_OK;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tPyObject *module = pm->InsertPModule(beh->GetID(),File,reload);\r\n\t\t\tPyObject* val = PyInt_FromLong(beh->GetID());\r\n\t\t\t//pm->CurrentId(beh->GetID());\r\n\t\t\tPyObject_SetAttrString( module , \"bid\", val);\r\n\r\n\t\t\tint bOutCount = beh->GetOutputParameterCount();\r\n\t\t\tif (bOutCount)\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t\tCKParameterOut *ciIn = beh->GetOutputParameter(0);\r\n\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\r\n\t\t\t\tswitch (sType)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase vtSTRING:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstd::string ret;\r\n pm->CallPyModule(beh->GetID(),Func,argsout,ret);\r\n\t\t\t\t\t\tCKParameterOut * pout = beh->GetOutputParameter(0);\r\n\t\t\t\t\t\tXString retx(ret.c_str());\r\n\t\t\t\t\t\tpout->SetStringValue(retx.Str());\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase vtFLOAT:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdouble ret=0.0f;\r\n\t\t\t\t\t\tpm->CallPyModule(beh->GetID(),Func,argsout,ret);\r\n\t\t\t\t\t\tfloat retx = (float)ret;\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(0,&retx);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase vtINTEGER:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlong ret=0;\r\n\t\t\t\t\t\tpm->CallPyModule(beh->GetID(),Func,argsout,ret);\r\n\t\t\t\t\t\tint retx = (int)ret;\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(0,&retx);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdefault :\r\n\t\t\t\t\t\tXString err(\"wrong output parameter type: \");\r\n\t\t\t\t\t\terr << ciIn->GetName() << \"Only Types derivated from Interger,Float or String are acceptable\";\r\n\t\t\t\t\t\tctx->OutputToConsole(err.Str(),FALSE );\r\n\t\t\t\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tpm->py->call(Func.Str(),argsout);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\t}\r\n\t\t\tcatch (Python_exception ex)\r\n\t\t\t{\r\n\t\t\t\tpm->m_Context->OutputToConsoleEx(\"PyErr : \\t %s\",(CKSTRING)ex.what());\r\n\t\t\t\tstd::cout << ex.what() << \"pyexeption in beh : \" << beh->GetName();\r\n\t\t\t\tPyErr_Clear();\r\n\t\t\t\tbeh->ActivateOutput(1,TRUE);\r\n\t\t\t}\r\n\t\tbeh->ActivateInput(0,false);\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nCKERROR CallPythonFuncCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t/************************************************************************/\r\n\t/* collecting data :\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\tCKContext* ctx = beh->GetCKContext();\r\n\tCKParameterManager *pm = static_cast(ctx->GetParameterManager());\r\n\t/************************************************************************/\r\n\t/*\tprocess virtools callbacks\t\t:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\r\n\tswitch(behcontext.CallbackMessage)\r\n\t\t{\r\n\r\n\r\n\t\tcase CKM_BEHAVIOREDITED:\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t\tassert(beh && ctx);\r\n\t\t\t\r\n\t\t\tint p_count = beh->GetOutputParameterCount();\r\n\r\n\t\t\t/*while( (BEH_OUT_MIN_COUNT ) < p_count )\r\n\t\t\t{ \r\n\t\t\t\tCKDestroyObject( beh->RemoveOutputParameter( --p_count) );\r\n\t\t\t}*/\r\n\t\t\t\r\n\t\t\tXString name(\"PyFunc: \");\r\n\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\tif ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0)\r\n\t\t\t{\r\n\t\t\t\tXString name(\"PyFile: \");\r\n\t\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\t\tbeh->SetName(name.Str());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tbeh->SetName(name.Str());\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORLOAD : \r\n\t\t{\r\n\t\t\tXString name(\"PyFunc: \");\r\n\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\tbeh->SetName(name.Str());\r\n\t\t\tif ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0)\r\n\t\t\t{\r\n\t\t\t\tXString name(\"PyFile: \");\r\n\t\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\t\tbeh->SetName(name.Str());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\t{\r\n\t\t\t\t/*CKObject *bobj = (CKObject *)beh;\r\n\t\t\t\tCK_ID idb = bobj->GetID();\r\n\t\t\t\tctx->OutputToConsoleEx(\"beh id1 : %d\",idb);*/\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\r\n\t}\r\n\treturn CKBR_OK;\r\n}#ifndef __VEHICLE_AND_WHEEL_STRUCTS_H__\r\n#define __VEHICLE_AND_WHEEL_STRUCTS_H__\r\n/*\r\ntypedef enum PS_WHEELSHAPE\r\n{\r\n\tE_WD_XML,\r\n\tE_WD_SUSPENSION,\r\n\tE_WD_SPRING_RES,\r\n\tE_WD_DAMP,\r\n\tE_WD_SPRING_BIAS,\r\n\tE_WD_MAX_BFORCE,\r\n\tE_WD_FSIDE,\r\n\tE_WD_FFRONT,\r\n\tE_WD_APPROX,\r\n\tE_WD_FLAGS,\r\n\tE_WD_SFLAGS,\r\n\tE_WD_LAT_FUNC,\r\n\tE_WD_LONG_FUNC,\r\n};\r\n*/\r\n\r\n#endif#ifndef ACTORPICKING_H\r\n#define ACTORPICKING_H\r\n\r\n#include \"Actors.h\"\r\n#include \"Joints.h\"\r\n\r\n#ifdef USE_NX_DOUBLE_BUFFERED\r\n#include \"NxdActor.h\"\r\n#endif\r\n\r\nvoid LetGoActor();\r\nbool PickActor(int x, int y);\r\nvoid MoveActor(int x, int y);\r\nvoid ViewProject(NxVec3 &v, int &xi, int &yi, float &depth);\r\nvoid ViewUnProject(int xi, int yi, float depth, NxVec3 &v);\r\n\r\n#endif //ACTORPICKING_H\r\n#ifndef __P_WHEEL_H__\r\n#define __P_WHEEL_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"pDriveline.h\"\r\n#include \"pReferencedObject.h\"\r\n#include \"pCallbackObject.h\"\r\n#include \"pPacejka.h\"\r\n\r\n\r\n\r\nclass pDifferential;\r\nclass pWheelContactModifyData;\r\n\r\n\r\n//#include \"pWheelTypes.h\"\r\n\r\n\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Base class to handle a vehicle wheel.\r\n*/\r\nclass MODULE_API pWheel : public pDriveLineComp\r\n{\r\npublic:\r\n\r\n\r\n\tvirtual\t\t\t\t\t~pWheel() {}\r\n\t\r\n\tpWheel(pRigidBody *body,pWheelDescr *descr);\r\n\tpRigidBody * getBody() const { return mBody; }\r\n\tvoid setBody(pRigidBody * val) { mBody= val; }\r\n\r\n\tvirtual void\t\t\ttick(bool handbrake, float motorTorque, float brakeTorque, NxReal dt) = 0;\r\n\tvirtual NxActor *\t\tgetTouchedActor() const;\r\n\tvirtual VxVector\t\t\tgetWheelPos() const = 0;\r\n\tvirtual void\t\t\tsetAngle(NxReal angle) = 0;\r\n\tvirtual float\t\t\tgetRpm() const = 0;\r\n\tvirtual VxVector\t\t\tgetGroundContactPos() const = 0;\r\n\tvirtual float\t\t\tgetRadius() const = 0;\r\n\r\n\tvirtual bool\t\t\thasGroundContact() const { return getTouchedActor() != NULL; }\r\n\tbool\t\t\tgetWheelFlag(WheelFlags flag) const { return (mWheelFlags & flag) != 0; }\r\n\r\n\tNxActor *getActor() const { return mActor; }\r\n\tvoid setActor(NxActor* val) { mActor = val; }\r\n\r\n\tpRigidBody *mBody;\r\n\tNxActor *mActor;\r\n\t\r\n\t\r\n\r\n\tint\t\t\t\t\tmWheelFlags;\r\n\tint& getWheelFlags(){ return mWheelFlags; }\r\n\tfloat _wheelRollAngle;\r\n\t\r\n\tfloat& getWheelRollAngle() { return _wheelRollAngle; }\r\n\tvoid setWheelRollAngle(float val) { _wheelRollAngle = val; }\r\n\r\n\tpWheel1 *castWheel1();\r\n\tpWheel2 *castWheel2();\r\n\r\n\tvirtual void _updateVirtoolsEntity(bool position,bool rotation)=0;\r\n\tvirtual void _updateAgeiaShape(bool position,bool rotation)=0;\r\n\r\n\tint mEntID;\r\n\tint getEntID() const { return mEntID; }\r\n\tvoid setEntID(int val) { mEntID = val; }\r\n\r\n\tvoid setFlags(int flags);\r\n\r\n\tvirtual void _tick(float dt){};\r\n\r\n\tvirtual int _constructWheel(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\r\n\tvirtual pWheelContactData* getContact()=0;\r\n\r\n\r\n\tNxMat34 mWheelPose;\r\n\tvirtual NxMat34& getWheelPose(){ return mWheelPose; }\r\n\tvoid setWheelPose(NxMat34 val) { mWheelPose = val; }\r\n\r\n};\r\n\r\nclass MODULE_API pWheel1 : public pWheel\r\n{\r\npublic:\r\n\r\n\r\n\tpWheel1(pRigidBody *body,pWheelDescr *descr);\r\n\tpWheel1();\r\n\r\n\tvirtual void\t\t\ttick(bool handbrake, float motorTorque, float brakeTorque, float dt);\r\n\tvirtual NxActor *\t\tgetTouchedActor();\r\n\tvirtual VxVector\t\t\tgetWheelPos() const;\r\n\tvirtual void\t\t\tsetAngle(float angle);\r\n\tvirtual float\t\t\tgetRpm() const; \r\n\tvirtual VxVector\t\t\tgetGroundContactPos() const { return getWheelPos(); }\r\n\tvirtual float\t\t\tgetRadius() const { return _radius; }\r\n\r\n\tContactInfo\t\t\t\t*contactInfo;\r\n\r\n\tvoid _updateVirtoolsEntity(bool position,bool rotation);\r\n\tvoid _updateAgeiaShape(bool position,bool rotation);\r\n\r\n\tNxConvexShape* getWheelConvex() const { return wheelConvex; }\r\n\tvoid setWheelConvex(NxConvexShape* val) { wheelConvex = val; }\r\n\r\n\tNxCapsuleShape* getWheelCapsule() const { return wheelCapsule; }\r\n\tvoid setWheelCapsule(NxCapsuleShape* val) { wheelCapsule = val; }\r\n\r\n\r\n\tint _constructWheel(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\r\n\tvoid\t\t\t\t\tgetSteeringDirection(NxVec3& dir);\r\n\tvoid\t\t\t\t\tupdateContactPosition();\r\n\tvoid\t\t\t\t\tupdateAngularVelocity(float lastTimeStepSize, bool handbrake);\r\n\tvoid\t\t\t\t\tsetWheelOrientation(const NxMat33& m);\r\n\r\n\tvirtual void _tick(float dt);\r\n\r\n\tNxCapsuleShape*\t\t\twheelCapsule;\r\n\t\r\n\tNxConvexShape*\t\t\twheelConvex;\r\n\t\r\n\t\r\n\tNxMaterial*\t\t\t\tmaterial;\r\n\tfloat\t\t\t\t\t_frictionToSide;\r\n\tfloat\t\t\t\t\t_frictionToFront;\r\n\r\n\tfloat\t\t\t\t\t_turnAngle;\r\n\tfloat\t\t\t\t\t_turnVelocity;\r\n\tfloat\t\t\t\t\t_radius;\r\n\tfloat\t\t\t\t\t_perimeter;\r\n\r\n\tfloat\t\t\t\t\t_angle;\r\n\tfloat\t\t\t\t\t_wheelWidth;\r\n\tfloat\t\t\t\t\t_maxSuspension;\r\n\t//NxReal\t\t\t\t\t_rpm;\r\n\tVxVector\t\t\t\t\t_maxPosition;\r\n\tpWheelContactData *getContact();\r\n\r\n};\r\nclass MODULE_API pWheel2 : \r\n\tpublic pWheel , \r\n\tpublic xEngineObjectAssociation,\r\n\tpublic pCallbackObject\r\n{\r\n\tpublic:\r\n\t\r\n\t\tpWheel2();\r\n\t\tpWheel2(pRigidBody *body,pWheelDescr *descr,CK3dEntity *wheelShapeReference);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// vehicle \r\n\t\t//\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// new vehicle code : differential\r\n\t\t//\r\n\t\tpDifferential *differential;\r\n\t\tint differentialSide; // Which output from the diff\r\n\t\tvoid setDifferential(pDifferential *diff,int side);\r\n\t\tpDifferential *getDifferential(){ return differential; }\r\n\t\tint getDifferentialSide(){ return differentialSide; }\r\n\t\t\r\n\t\tpPacejka pacejka; \r\n\t\t\r\n\t\tpPacejka *getPacejka() { return &pacejka; }\r\n\t\tvoid setPacejka(pPacejka val) { pacejka = val; }\r\n\r\n\r\n\t\t// Translation\r\n\t\tVxVector position; // Position in CC wrt the body (!)\r\n\t\tVxVector velocity; // Velocity in wheel coords acceleration; \r\n\t\tVxVector acceleration; // For the suspension\r\n\t\t\t\r\n\t\tVxVector GetVelocity(){ return velocity; }\r\n\t\tVxVector GetAcceleration(){ return acceleration; }\r\n\t\tVxVector GetSlipVectorCC(){ return slipVectorCC; }\r\n\t\tVxVector GetPosContactWC(){ return posContactWC; }\r\n\t\t\r\n\t\t// Rotation\r\n\t\tVxVector rotation; // Current rotation\r\n\t\tVxVector rotationV;\r\n\t\tVxVector rotationA; // Rotation speed and acceleration\r\n\r\n\t\t// Braking\r\n\t\tfloat maxBrakingTorque;\t\t// Max. force when braking 100%\r\n\t\tfloat brakingFactor;\t\t// For example .58 for fronts, .42 back\r\n\t\tfloat lock; // Max angle of heading (radians)\r\n\r\n\t\tint stateFlags;\r\n\t\tfloat lowSpeedFactor; // How slow it is spinning\r\n\t\tfloat slipAngle; // Vel. vs. wheel dir in radians\r\n\t\tfloat slipRatio; // Ratio of wheel speed vs. velocity\r\n\r\n\t\t// Pre-calculated\r\n\t\tfloat distCGM; // Distance to center of geometry\r\n\t\tfloat angleCGM; // Angle (around car Y) of wheel\r\n\t\tfloat distCM; // Distance to center of mass\r\n\r\n\t\tfloat GetSlipAngle(){ return slipAngle; }\r\n\t\tfloat GetSlipRatio(){ return slipRatio; }\r\n\t\tfloat GetHeading(){ return rotation.y; }\r\n\t\tfloat GetRotation(){ return rotation.x; }\r\n\t\tfloat GetRotationV(){ return rotationV.x; }\r\n\r\n\r\n\r\n\t\t\r\n\t\tfloat GetLock(){ return lock; }\r\n\r\n\t\t// End forces\r\n\t\tVxVector forceVerticalCC; // Result of suspension+gravity\r\n\r\n\t\tfloat differentialSlipRatio; // SR calculated by differential eq.\r\n\t\tfloat tanSlipAngle; // From this, 'slipAngle' is derived\r\n\t\tfloat relaxationLengthLat; // 'b' in SAE 950311\r\n\t\tfloat lastU; // To detect switching of long. speed\r\n\t\tfloat signU; // Sign of longitudinal speed\r\n\t\tfloat relaxationLengthLong; // 'B' in SAE 950311\r\n\t\tfloat dampingFactorLong; // Damping at low speed\r\n\t\tfloat dampingFactorLat; // Damping laterally\r\n\t\t// Combined slip\r\n\t\tfloat csSlipLen; // Combined slip vector length\r\n\t\tfloat load; // Load on the wheel (N)\r\n\t\t\r\n\t\tfloat mass; // Mass of wheel+tyre\r\n\t\t\r\n\t\tfloat radius,\r\n\t\t\twidth;\r\n\t\tfloat rollingCoeff; // Rolling resistance coefficient\r\n\t\t\r\n\t\tfloat toe; // Pre-rotating the wheel\r\n\t\tfloat ackermanFactor; // Scaling the steering angle\r\n\r\n\t\tfloat optimalSR,optimalSA; // Optimal slip ratio/angle (in rad)\r\n\t\tfloat tanOptimalSA; \r\n\r\n\t\t// Spring values\r\n\t\tfloat tireRate;\t\t\t// Spring vertical rate of tire\r\n\t\t\r\n\t\t// SAE 950311\r\n\t\tfloat dampingCoefficientLat, // Amount of damping at low speed\r\n\t\t\tdampingCoefficientLong;\r\n\t\tfloat dampingSpeed; // Speed at which to start damping\r\n\r\n\r\n\t\tfloat getTireRate() const { return tireRate; }\r\n\t\tvoid setTireRate(float val) { tireRate = val; }\r\n\r\n\r\n\t\tvoid preCalculate();\r\n\t\tvoid preAnimate();\r\n\t\tvoid postAnimate();\r\n\t\tvoid calcForces();\r\n\r\n\t\t\tvoid calcVerticalForces();\r\n\t\t\tvoid calcLongForces();\r\n\t\t\tvoid calcLatForces();\r\n\t\t\tvoid calcBreakForces();\r\n\t\t\t\r\n\t\tvoid Integrate();\r\n\t\tvoid postStep();\r\n\t\tvoid cleanup();\r\n\r\n\r\n\t\t// Physics\r\n\t\tvoid CalcSlipRatio(VxVector *velWheelCC);\r\n\t\tvoid CalcSlipAngle();\r\n\t\tvoid CalcSlipVelocity();\r\n\t\tvoid CalcLoad();\r\n\t\tvoid CalcPacejka();\r\n\t\tvoid CalcDamping();\r\n\t\tvoid CalcWheelPosWC();\r\n\t\t\r\n\t\tvoid CalcWheelAngAcc();\r\n\t\tvoid CalcBodyForce();\r\n\t\tvoid CalcAccelerations();\r\n\r\n\t\tvoid updateSteeringPose(float rollangle,float steerAngle,float dt);\r\n\t\tvoid updatePosition();\r\n\r\n\r\n\t\tvoid setSteering(float angle);\r\n\t\tfloat pWheel2::getSteerAngle();\r\n\r\n\r\n\r\n\t\tvoid calculatePose(float dt);\r\n\r\n\t\t\r\n\t\t\r\n\r\n\r\n\t\t// Other state vars\r\n\t\t//rfloat load; // Load on the wheel (N)\r\n\t\tfloat radiusLoaded; // Rl = radius of loaded wheel to gnd\r\n\t\tfloat aligningTorque; // Mz in the SAE system\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// \r\n\t\t//\r\n\t\tVxVector torqueTC; // 3-dimensions of torque\r\n\t\tVxVector torqueBrakingTC; // Total braking torque (incl. rr)\r\n\t\tVxVector torqueRollingTC; // Rolling resistance\r\n\t\tVxVector torqueFeedbackTC; // Feedback (road reaction)\r\n\t\tVxVector forceRoadTC; // Because of slip ratio/angle\r\n\t\tVxVector forceDampingTC; // Damping if low-speed (SAE950311)\r\n\t\tVxVector forceBrakingTC;\t\t// Brakes\r\n\t\tVxVector forceBodyCC; // Force on body (for acc.)\r\n\t\tVxVector forceGravityCC;\t\t// Gravity that pulls wheel down\r\n\t\tfloat velMagnitude; // Length of slip velocity vector (obs)\r\n\t\tVxVector velWheelCC, // Real velocity of wheel\r\n\t\tvelWheelTC; // Velocity in tire coords\r\n\t\t// End forces\r\n\r\n\t\tVxVector posContactWC;\t\t// Position of contact patch in WC\r\n\t\tVxVector slipVectorCC, // Diff of tire vs wheel velocity\r\n\t\t\tslipVectorTC; // In tire coords\r\n\t\tfloat slipVectorLength; // Magnitude of slipVector?C\r\n\r\n\t\tpLinearInterpolation crvSlipTraction; // Traction curve for slip ratio\r\n\t\tpLinearInterpolation crvSlipBraking; // Braking curve\r\n\t\tpLinearInterpolation crvLatForce; // Slip angle -> normalized lat. force\r\n\t\tpLinearInterpolation crvSlip2FC; // Effect of slip vel on frict. circle\r\n\r\n\r\n\t\t// Status\r\n\t\tVxVector slipVector; // Diff. of theorial v vs ACTUAL v\r\n\t\tfloat frictionCoeff; // Current friction coefficient\r\n\t\tfloat skidFactor; // How much skidding? 0..1\r\n\t\tfloat slip2FCVelFactor; // Scaling of 'crvSlip2FC' X axis\r\n\r\n\r\n\r\n\t\t\r\n\t\t// Forces\r\n\t\tVxVector GetForceRoadTC(){ return forceRoadTC; }\r\n\t\tVxVector GetForceBodyCC(){ return forceBodyCC; }\r\n\t\tVxVector GetTorqueTC(){ return torqueTC; }\r\n\t\t// Feedback torque is the road reaction torque\r\n\t\tVxVector GetTorqueFeedbackTC(){ return torqueFeedbackTC; }\r\n\t\tVxVector GetTorqueBrakingTC(){ return torqueBrakingTC; }\r\n\t\tVxVector GetTorqueRollingTC(){ return torqueRollingTC; }\r\n\r\n\t\tfloat getCsSlipLen() const { return csSlipLen; }\r\n\t\tvoid setCsSlipLen(float val) { csSlipLen = val; }\r\n\t\tVxVector getVelWheelCC() const { return velWheelCC; }\r\n\t\tvoid setVelWheelCC(VxVector val) { velWheelCC = val; }\r\n\t\tVxVector getVelWheelTC() const { return velWheelTC; }\r\n\t\tvoid setVelWheelTC(VxVector val) { velWheelTC = val; }\r\n\t\tfloat getRollingCoeff() { return rollingCoeff; }\r\n\t\tvoid setRollingCoeff(float val) { rollingCoeff = val; }\r\n\t\t\r\n\t\tfloat getMass();\r\n\t\tvoid setMass(float val) { mass = val; }\r\n\r\n\r\n\t\tbool hadContact;\r\n\t\t\r\n\t\t//NxWheelContactData *lastContactData;\r\n\t\tpWheelContactData *lastContactData;// = *wheel2->getContact();\r\n\r\n\r\n\r\n\t\t virtual void\t\t\ttick(bool handbrake, float motorTorque, float brakeTorque, float dt);\r\n\t\t virtual NxActor *\t\tgetTouchedActor() const;\r\n\t\t virtual VxVector\t\t\tgetWheelPos() const;\r\n\t\t virtual void\t\t\tsetAngle(float angle);\r\n\t\t virtual float\t\t\tgetRpm() const;\r\n\t\t \r\n\t\t VxVector\tgetGroundContactPos() const;\r\n\t\t bool hasGroundContact() const ;\r\n\t\t float\t\t\tgetRadius()const;\r\n\t\t \r\n\t\t NxWheelShape * getWheelShape() const { return mWheelShape; }\r\n\t\t void setWheelShape(NxWheelShape * val) { mWheelShape = val; }\r\n\r\n\t\t void setAxleSpeed(float speed);\r\n\t\t void setMotorTorque(float torque);\r\n\t\t void setBreakTorque(float torque);\r\n\t\t \r\n\t\t float getSuspensionTravel() const;\r\n\t\t float getAxleSpeed()const;\r\n\t\t \r\n\t\t void _updateVirtoolsEntity(bool position,bool rotation);\r\n\t\t void _updateAgeiaShape(bool position,bool rotation);\r\n\r\n\t\t bool setSuspensionSpring(const pSpring& spring);\r\n\t\t pSpring getSuspensionSpring();\r\n\r\n\t\t void setSuspensionTravel(float travel);\r\n\t\t int _constructWheel(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation){ return 1;}\r\n\r\n\t\t pWheelContactData *getContact();\r\n\t\t bool getContact(pWheelContactData&dst);\r\n\t\t virtual void _tick(float dt);\r\n\t\t pVehicle * getVehicle() const { return mVehicle; }\r\n\t\t void setVehicle(pVehicle * val) { mVehicle = val; }\r\n\r\n\t\t //----------------------------------------------------------------\r\n\t\t //\r\n\t\t // manager calls \r\n\t\t //\r\n\t\t int onPreProcess();\r\n\t\t int onPostProcess();\r\n\t\t \r\n\t\t void processPostScript();\r\n\t\t void processPreScript();\r\n\r\n\t\t virtual bool onWheelContact(CK3dEntity* wheelShapeReference, VxVector& contactPoint, VxVector& contactNormal, float& contactPosition, float& normalForce, CK3dEntity* otherShapeReference, int& otherShapeMaterialIndex);\r\n\t\t virtual void setWheelContactScript(int val);\r\n\t\t virtual bool onWheelContactModify(int& changeFlags,pWheelContactModifyData *contact);\r\n\r\n\t\t pWheelContactModify *wheelContactModifyCallback;\r\n\r\n\t\t void _createInternalContactModifyCallback();\r\n\r\n\t\t //----------------------------------------------------------------\r\n\t\t //\r\n\t\t // physics\r\n\t\t //\r\n\t\t float getEndBrakingTorqueForWheel();\r\n\t\t float getEndTorqueForWheel();\r\n\t\t float getEndAccForWheel();\r\n\r\n\t\t float getWheelTorque();\r\n\t\t float getWheelBreakTorque();\r\n\r\n\t\t bool isAxleSpeedFromVehicle();\r\n\t\t bool isTorqueFromVehicle();\r\n\t\t \r\n\t\t void applyTorqueToPhysics();\r\n\t\t void applyAxleSpeedToPhysics();\r\n\r\n\r\n\r\n\t\t \r\n\t\t CK3dEntity * getEntity() const { return entity; }\r\n\t\t void setEntity(CK3dEntity * val) { entity = val; }\r\n\tprivate:\r\n\r\n\t\tNxWheelShape * mWheelShape;\r\n\t\tpVehicle *mVehicle;\r\n\t\tCK3dEntity *entity;\r\n\t\t\r\n};\r\n\r\n/** @} */\r\n\r\n#endif#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"vtNetConfig.h\"\r\n\r\n#ifdef CK_LIB\r\n#define RegisterBehaviorDeclarations Register_TOOLS_BehaviorDeclarations\t\t\r\n#define InitInstance\t\t\t\t\t_TOOLS_InitInstance\r\n#define ExitInstance\t\t\t\t\t_TOOLS_ExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGet_TOOLS_PluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGet_TOOLS_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_TOOLS_PluginInfo\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n#define InitInstance\t\t\t\t\tInitInstance\r\n#define ExitInstance\t\t\t\t\tExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\nCKPluginInfo g_PluginInfo;\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount(){return 2;}\r\n\r\n\r\nCKERROR InitInstanc1e(CKContext* context);\r\n\r\nvtNetworkManager *nm = NULL;\r\n\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tvtNetworkManager* initman =new vtNetworkManager(context);\r\n\tnm = initman;\r\n\t\r\n\tinitman->RegisterVSL();\r\n\tinitman->RegisterParameters();\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\tvtNetworkManager* initman =(vtNetworkManager*)context->GetManagerByGuid(NET_MAN_GUID);\r\n\tdelete initman;\r\n\treturn CK_OK;\r\n}\r\n#define INIT_BEH_GUID\t\tCKGUID(0x8ac02ae,0x224341f4)\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tswitch (Index) \r\n\t{\r\n\tcase 0:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"Network Building Blocks\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_BEH_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"Network Building Blocks\";\r\n\t\tbreak;\r\n\r\n\tcase 1:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"Network Manager\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= InitInstance;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= ExitInstance;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= NET_MAN_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"Network Manager\";\r\n\t\tbreak;\r\n\r\n\r\n\t}\r\n\treturn &g_PluginInfo;\r\n}\r\n\r\n#undef HAS_DISTOBJECTS\r\n\r\n\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\tRegisterBehavior(reg,FillBehaviorConnectToServerDecl);\r\n\t\r\n\t\r\n\r\n\tRegisterBehavior(reg,FillBehaviorLogEntryDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorGetIncomingUserDecl);\r\n\tRegisterBehavior(reg,FillBehaviorGetOutgoingUserUserDecl);\r\n\tRegisterBehavior(reg,FillBehaviorSetUserNameDecl);\r\n\tRegisterBehavior(reg,FillBehaviorUserNameModifiedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNDisconnectDecl);\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorDOCreateDistributedObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDODistributedObjectCreatedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOUserValueModifiedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOBindDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDODestroyDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDODestroyedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOSetUserValueDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOControlDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOOwnerChangedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOGetCurrentOwnerDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDOReleaseDecl);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t\r\n\r\n\tRegisterBehavior(reg,FillBehaviorNSCreateObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSGetListObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSJoinObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSLeaveObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSLockObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSUnlockObjectDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSRemoveUserDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorNMSendDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNMWaiterDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorNCheckForLanServerDecl);\r\n\r\n\r\n\tRegisterBehavior(reg,FillBehaviorDebugTextDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorNServerStartDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNServerStopDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNServerIsRunningDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNGetInterfacesDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNSetParametersDecl);\r\n\r\n\r\n\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pConfig.h\"\r\n\r\n#ifdef DONGLE_VERSION\r\n\r\n\t#include \"matrix32.h\"\r\n\r\n#endif\r\n\r\n\r\nlong DataIn[256]; /* Buffer to read the Dongle data */\r\nlong DataOut[256]; /* Buffer for data to be stored */\r\nlong DataBlock[2]; /* Data buffer for Encrypt/Decrypt */\r\nshort RetCode; /* Return value */\r\nlong API_Version; /* Version number of the Matrix-API */\r\nlong DNG_Version; /* Dongle version number */\r\nshort DNG_LPTADR; /* Adress of LPT port */\r\nshort DNG_Count; /* Number of Dongles connected */\r\nshort DNG_Mem; /* Memory size of Dongle */\r\nshort DNG_MaxVar; /* Maximum number of data fields */\r\nshort AppSlot; /* Application-Slot for Network access */\r\nshort i;\r\n\r\n\r\n\r\nint netMode = 0;\r\nshort DNG_Port = 1;\r\nlong UserCode = 4002529;\r\n\r\nint DONGLE_BASIC_VERSION_KEY_1 = 28071977;\r\nint DONGLE_BASIC_VERSION_KEY_2 = 77917082;\r\n\r\nint DONGLE_BASIC_VERSION_KEY_1_ENC = 364898188;\r\nint DONGLE_BASIC_VERSION_KEY_2_ENC = 930141357;\r\n\r\n\r\n\r\nint DONGLE_ADVANCED_VERSION_KEY1 = 56143954;\r\nint DONGLE_ADVANCED_VERSION_KEY2 = 45934165;\r\n\r\n\r\nextern PhysicManager*manager;\r\n\r\n\r\n#ifdef DONGLE_VERSION\r\n\r\n\r\n#pragma comment(lib,\"matrix32.lib\")\r\n\r\n\r\n\r\nvoid PhysicManager::_initResources(int flags){\r\n\r\n\t\r\n\r\n\t// Init Matrix-API \r\n\tRetCode = Init_MatrixAPI();\r\n\tif(RetCode < 0)\r\n\t{\r\n\t\tprintf(\"Init_MatrixAPI failed %d \\n\", RetCode);\r\n\t\texit;\r\n\t}\r\n\r\n\tAPI_Version = GetVersionAPI();\r\n\tif(API_Version == 0)\r\n\t{\r\n\t\tprintf(\"Cannot read API-Version! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\t\r\n\t// Search for number of Dongles at DNG_Port \r\n\tDNG_Port = Dongle_Find();\r\n\tDNG_Count = Dongle_Count(DNG_Port);\r\n\r\n\tlong test = 0 ;\r\n\tif(DNG_Count > 0)\r\n\t{\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Matrix-Modules at Port %d: %d \\n\", DNG_Port, DNG_Count);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tXString donglePath = _getConfigPath();\r\n\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Cannot find Matrix-Modules at Port %d ! \\n\", DNG_Port);\r\n\t\t\r\n\t\t//return;\r\n\t\t//goto NETWORK_CHECK;\r\n\r\n\t\tint ret = SetConfig_MatrixNet(1,donglePath.Str());\r\n\t\tint DNG_NR = 1;\r\n\t\tAppSlot = 1;\r\n\t\tret = LogIn_MatrixNet(UserCode, AppSlot, DNG_NR);\r\n\t\tif (ret<=0)\r\n\t\t{\r\n\t\t\tMessageBox(NULL,\"Couldn't find Dongle!\",0,MB_OK|MB_ICONERROR);\r\n\t\t\tthis->DongleHasBasicVersion=0;\r\n\t\t\tthis->DongleHasAdvancedVersion=0;\r\n\t\t\t//Release_MatrixAPI();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\r\n\t\tnetMode = 1;\r\n\t\tDNG_Port = Dongle_Find();\r\n\t\tDNG_Count = Dongle_Count(DNG_Port);\r\n\r\n\t\tif(DNG_Count == 0)\r\n\t\t{\r\n\t\t\tmanager->m_Context->OutputToConsoleEx(\"Couldn't find Dongle\");\r\n\t\t}\r\n\r\n\t}\r\n\r\n\t\r\n\tDNG_Mem = Dongle_MemSize(DNG_Count, DNG_Port);\r\n\tif(DNG_Mem > 0)\r\n\t{\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"MemSize of Matrix-Module %d at Port %d: %d Bytes \\n\", DNG_Count, DNG_Port, DNG_Mem);\r\n\r\n\t}\r\n\telse\r\n\t{\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Cannot read MemSize! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\r\n\tRetCode = Dongle_ReadData(UserCode, DataIn,6, DNG_Count, DNG_Port);\r\n\tif(RetCode < 0)\r\n\t{\r\n\t\tm_Context->OutputToConsoleEx(\"Data Read-Error! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\r\n\t\r\n\tDataBlock[0] = 28071977; /* Clear Data */\r\n\tDataBlock[1] = 77917082; /* Clear Data */\r\n\r\n\r\n\tlong DataBlockKeyBasic[2];\r\n\tDataBlockKeyBasic[0] = DataIn[2];\r\n\tDataBlockKeyBasic[1] = DataIn[3];\r\n\r\n\tlong DataBlockKeyAdvanced[2];\r\n\tDataBlockKeyAdvanced[0] = DataIn[4];\r\n\tDataBlockKeyAdvanced[1] = DataIn[5];\r\n\r\n\tRetCode = Dongle_DecryptData(UserCode, DataBlockKeyBasic, DNG_Count, DNG_Port);\r\n\tRetCode = Dongle_DecryptData(UserCode, DataBlockKeyAdvanced, DNG_Count, DNG_Port);\r\n\r\n\t\r\n\r\n\r\n\tif (netMode)\r\n\t{\r\n\t\r\n\t\tif (DataBlockKeyBasic[0]==DONGLE_BASIC_VERSION_KEY_1_ENC && DataBlockKeyBasic[1]==DONGLE_BASIC_VERSION_KEY_2_ENC )\r\n\t\t{\r\n\t\t\tDongleHasBasicVersion= 1;\r\n\t\t}\r\n\r\n\t}else\r\n\t{\r\n\t\tif (DataBlockKeyBasic[0]==DONGLE_BASIC_VERSION_KEY_1 && DataBlockKeyBasic[1]==DONGLE_BASIC_VERSION_KEY_2 )\r\n\t\t{\r\n\t\t\tDongleHasBasicVersion= 1;\r\n\t\t}\r\n\r\n\t\tif (DataBlockKeyAdvanced[0]==DONGLE_ADVANCED_VERSION_KEY1 && DataBlockKeyAdvanced[1]==DONGLE_ADVANCED_VERSION_KEY2)\r\n\t\t{\r\n\t\t\tDongleHasAdvancedVersion=1;\r\n\t\t}\r\n\t}\r\n\r\n\tRelease_MatrixAPI();\r\n\r\n\r\n}\r\n\r\n#endif\r\n\r\n\r\n\r\n/*\r\n#ifdef REDIST\r\n#endif\r\n*/\r\n\r\n/*\r\n#ifdef DEMO_ONLY\r\n\r\n\tvoid FindResourceX()\r\n\t{\r\n\r\n\t}\r\n\r\n#endif\r\n*/\r\n\t\r\n\t\r\n\r\n/*\r\n#if defined (DONGLE_VERSION)\r\n\r\n\r\nvoid PhysicManager::makeDongleTest()\r\n{\r\n\t//FindResourceX();\r\n\r\n}\r\n*/\r\n\r\n\r\n\r\n/*\r\n\r\nvoid MODULE_API FindResourceX()\r\n{\r\n\t\r\n\r\n\tRetCode = Init_MatrixAPI();\r\n\tif(RetCode < 0)\r\n\t{\r\n\t\tprintf(\"Init_MatrixAPI failed %d \\n\", RetCode);\r\n\t\texit;\r\n\t}\r\n\r\n\t\r\n\tAPI_Version = GetVersionAPI();\r\n\tif(API_Version == 0)\r\n\t{\r\n\t\tprintf(\"Cannot read API-Version! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\telse\r\n\t{\r\n\t//\t\tprintf(\"Version of Matrix-API: %d.%d \\n\", HIWORD(API_Version), LOWORD(API_Version));\r\n\t//\t\tmanager->m_Context->OutputToConsoleEx(\"Version of Matrix-API: %d.%d \\n\", HIWORD(API_Version), LOWORD(API_Version));\r\n\t}\r\n\r\n\t\r\n\tint port = Dongle_Find();\r\n\tDNG_Count = Dongle_Count(port);\r\n\tDNG_Port = port;\r\n\r\n\tif(DNG_Count > 0)\r\n\t{\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Matrix-Modules at Port %d: %d \\n\", DNG_Port, DNG_Count);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t//goto NETWORK\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Cannot find Matrix-Modules at Port %d ! \\n\", DNG_Port);\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\r\n\tDNG_Mem = Dongle_MemSize(DNG_Count, DNG_Port);\r\n\tif(DNG_Mem > 0)\r\n\t{\r\n\t\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"MemSize of Matrix-Module %d at Port %d: %d Bytes \\n\", DNG_Count, DNG_Port, DNG_Mem);\r\n\r\n\t}\r\n\telse\r\n\t{\r\n\t\t//manager->m_Context->OutputToConsoleEx(\"Cannot read MemSize! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\r\n\tRetCode = Dongle_ReadData(UserCode, DataIn,6, DNG_Count, DNG_Port);\r\n\tif(RetCode < 0)\r\n\t{\r\n\t\tmanager->m_Context->OutputToConsoleEx(\"Data Read-Error! \\n\");\r\n\t\tRelease_MatrixAPI();\r\n\t\treturn;\r\n\t}\r\n\r\n\t\r\n\t\r\n\tDataBlock[0] = 28071977; \r\n\tDataBlock[1] = 77917082; \r\n\r\n\r\n\r\n\tlong DataBlockKeyBasic[2];\r\n\tDataBlockKeyBasic[0] = DataIn[2];\r\n\tDataBlockKeyBasic[1] = DataIn[3];\r\n\r\n\tlong DataBlockKeyAdvanced[2];\r\n\tDataBlockKeyAdvanced[0] = DataIn[4];\r\n\tDataBlockKeyAdvanced[1] = DataIn[5];\r\n\r\n\tRetCode = Dongle_DecryptData(UserCode, DataBlockKeyBasic, DNG_Count, DNG_Port);\r\n\tRetCode = Dongle_DecryptData(UserCode, DataBlockKeyAdvanced, DNG_Count, DNG_Port);\r\n\r\n\t//manager->m_Context->OutputToConsoleEx(\"Decrypted Data: %lu %lu \\n\", DataBlockKeyBasic[0], DataBlockKeyBasic[1]);\r\n\t//manager->m_Context->OutputToConsoleEx(\"Decrypted Data: %lu %lu \\n\", DataBlockKeyAdvanced[0], DataBlockKeyAdvanced[1]);\r\n\r\n\r\n\tif (DataBlockKeyBasic[0]==DONGLE_BASIC_VERSION_KEY_1 && DataBlockKeyBasic[1]==DONGLE_BASIC_VERSION_KEY_2 )\r\n\t{\r\n//\t\tDongleHasBasicVersion= 1;\r\n\t}\r\n\r\n\tif (DataBlockKeyAdvanced[0]==DONGLE_ADVANCED_VERSION_KEY1 && DataBlockKeyAdvanced[1]==DONGLE_ADVANCED_VERSION_KEY2)\r\n\t{\r\n//\t\tDongleHasAdvancedVersion= 1;\r\n\t}\r\n\r\n\t//manager->m_Context->OutputToConsoleEx(\"Clear Data: %lu %lu \\n\", DataBlock[0], DataBlock[1]);\r\n\t//manager->m_Context->OutputToConsoleEx(\"Encrypted Data: %lu %lu \\n\", DataBlock[0], DataBlock[1]);\r\n\r\n\t\r\n\tRelease_MatrixAPI();\r\n}\r\n\r\n\r\n\r\n#endif\r\n\r\n*/#ifndef __PRIGIDBODYTYPES_H__\r\n#define __PRIGIDBODYTYPES_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"pVTireFunction.h\"\r\n//#include \"pWheelTypes.h\"\r\n\r\n\r\n\r\n/** \\addtogroup RigidBody\r\n@{\r\n*/\r\n\r\nstruct pRigidBodyRestoreInfo \r\n{\r\n\tbool hierarchy;\r\n\tbool removeJoints;\r\n\tpRigidBodyRestoreInfo() : hierarchy(false) , removeJoints(false){}\r\n\r\n};\r\n\r\n/**\r\n\\brief Class describing a rigid bodies mass offset.\r\n*/\r\nclass MODULE_API pMassSettings\r\n{\r\n\r\n\tpublic:\r\n\t\t/**\r\n\t\t\\brief Density scale factor of the shapes belonging to the body \r\n\t\t\t-\tRange: [0,inf)\r\n\t\t\t-\tDefault: [0)\r\n\t\t**/\r\n\t\tfloat newDensity;\r\n\t\t \r\n\t\t/**\r\n\t\t\\brief Total mass of the actor(or zero).\r\n\t\t\t-\tRange: [0,inf)\r\n\t\t\t-\tDefault: 0.0f\r\n\t\t**/\r\n\t\tfloat totalMass;\r\n\t\t/**\r\n\t\t\\brief Local position offset\r\n\t\t\t-\tRange: [vector)\r\n\t\t\t-\tDefault: (0,0,0)\r\n\t\t**/\r\n\t\tVxVector localPosition;\r\n\t\t/**\r\n\t\t\\brief Local orientation offset\r\n\t\t-\tRange: [0,inf)\r\n\t\t-\tDefault: (0,0,0)\r\n\t\t**/\r\n\t\tVxVector localOrientation;\r\n\t\t/**\r\n\t\t\\brief Reference object to determine the mass local position. The members \"Linear\" and \"Angular\" are being used to transform the final matrix.\r\n\t\t-\tRange: [object)\r\n\t\t-\tDefault: 0\r\n\t\t**/\r\n\t\tCK_ID massReference;\r\n\r\n\tpMassSettings()\r\n\t{\r\n\t\tnewDensity = totalMass = 0.0f;\r\n\t\tmassReference = 0 ;\r\n\t}\r\n};\r\n\r\n/**\r\n\r\n\\brief Class to describe a pivot offset\r\n*/\r\nclass MODULE_API pPivotSettings\r\n{\r\n\r\n\r\n\tpublic:\r\n\r\n\t\tbool isValid();\r\n\t\tbool setToDefault();\r\n\t\tbool evaluate(CKBeObject*referenceObject);\r\n\t\t\r\n\r\n\t\t/**\r\n\t\t\\brief Local position offset. The local position of can be changed by #pRigidBody::setPosition\r\n\t\t-\tRange: [vector)\r\n\t\t-\tDefault: (0,0,0)\r\n\t\t**/\r\n\t\tVxVector localPosition;\r\n\t\t/**\r\n\t\t\\brief Local orientation offset. The local orientation of can be changed by #pRigidBody::setRotation\r\n\t\t-\tRange: [0,inf)\r\n\t\t-\tDefault: (0,0,0)\r\n\t\t**/\r\n\t\tVxVector localOrientation;\r\n\t\t/**\r\n\t\t\\brief Reference object to determine the shape local matrix. The members \"Linear\" and \"Angular\" are being used to transform the final matrix.\r\n\t\t-\tRange: [object)\r\n\t\t-\tDefault: 0\r\n\t\t**/\r\n\t\tCK_ID pivotReference;\r\n\r\n\tpPivotSettings()\r\n\t{\r\n\t\tpivotReference=0;\r\n\t}\r\n\r\n};\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Help info to specify a length by an entity reference\r\n//\r\nclass MODULE_API pAxisReferencedLength\r\n{\r\npublic:\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\tbool evaluate(CKBeObject *referenceObject);\r\n\r\n\tfloat value;\r\n\tCKBeObject *reference;\r\n\tint referenceAxis;\r\n\r\n\tpAxisReferencedLength() : \r\n\tvalue(0.0f) , \r\n\t\treference(NULL) , \r\n\t\treferenceAxis(0) \r\n\t{\r\n\t}\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Additional information for deformable objects\r\n//\r\nstruct MODULE_API pDeformableSettings\r\n{\r\n\r\npublic : \r\n\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\tbool evaluate(CKBeObject*referenceObject);\r\n\r\n\tfloat ImpulsThresold;\r\n\tfloat PenetrationDepth;\r\n\tfloat MaxDeform;\r\n\r\n\tpDeformableSettings()\r\n\t{\r\n\t\tImpulsThresold = 50.0f;\r\n\t\tPenetrationDepth = 0.1f ;\r\n\t\tMaxDeform= 0.1f;\r\n\t}\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Additional settings to override a default capsule\r\n//\r\nstruct pCapsuleSettings\r\n{\r\n\r\npublic :\r\n\r\n\tint localLengthAxis;\r\n\tint localRadiusAxis;\r\n\r\n\tfloat height;\r\n\tfloat radius;\r\n\tpCapsuleSettings()\r\n\t{\r\n\t\tlocalRadiusAxis=0;\r\n\t\tlocalLengthAxis=0;\r\n\t\theight = 0.0f;\r\n\t\tradius = 0.0f;\r\n\t}\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Additional settings to override a default capsule\r\n//\r\nstruct MODULE_API pCapsuleSettingsEx\r\n{\r\npublic :\r\n\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\tbool evaluate(CKBeObject*referenceObject);\r\n\r\n\t/**\r\n\t\\brief Radius specified by value or an objects local box size and an axis\r\n\t**/\r\n\tpAxisReferencedLength radius;\r\n\t\r\n\t/**\r\n\t\\brief Height specified by value or an objects local box size and an axis\r\n\t**/\r\n\tpAxisReferencedLength height;\r\n\r\n\tpCapsuleSettingsEx()\r\n\t{\r\n\t\t\r\n\t}\r\n};\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Optional override to describe a convex cylinder.\r\n//\r\nclass MODULE_API pConvexCylinderSettings\r\n{\r\n\r\npublic:\r\n\r\n\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\tbool evaluate(CKBeObject*referenceObject);\r\n\r\n\t\r\n\t/**\r\n\t\\brief Radius specified by value or an objects local box size and an axis\r\n\t**/\r\n\tpAxisReferencedLength radius;\r\n\t/**\r\n\t\\brief Height specified by value or an objects local box size and an axis\r\n\t**/\r\n\tpAxisReferencedLength height;\r\n\r\n\t/**\r\n\t\\brief Amount of cap segments\r\n\t**/\r\n\tint approximation;\r\n\r\n\t/**\r\n\t\\brief Rotation part 1. If a forward axis reference has been specified, the vector gets transformed\r\n\t**/\r\n\tVxVector forwardAxis;\r\n\t/**\r\n\t\\brief Reference to specify the \"Dir\" axis\r\n\t**/\r\n\tCK_ID forwardAxisRef;\r\n\r\n\t/**\r\n\t\\brief Rotation part 2. If a down axis reference has been specified, the vector gets transformed\r\n\t**/\r\n\tVxVector downAxis;\r\n\t/**\r\n\t\\brief Reference to specify the \"Up\" axis\r\n\t**/\r\n\tCK_ID downAxisRef;\r\n\r\n\t/**\r\n\t\\brief Rotation part 3. If a right axis reference has been specified, the vector gets transformed\r\n\t**/\r\n\tVxVector rightAxis;\r\n\t/**\r\n\t\\brief Reference to specify the \"Right\" axis\r\n\t**/\r\n\tCK_ID rightAxisRef;\r\n\r\n\t/**\r\n\t\\brief Create only a half cylinder\r\n\t*/\r\n\tbool buildLowerHalfOnly;\r\n\r\n\t/**\r\n\t\\brief Flags which describe the format and behavior of a convex mesh. See #pConvexFlags\r\n\t*/\r\n\tpConvexFlags convexFlags;\r\n\r\n\tpConvexCylinderSettings() : \r\n\tapproximation(0),\r\n\t\tforwardAxisRef(0),\r\n\t\trightAxisRef(0),\r\n\t\tdownAxisRef(0),\r\n\t\tbuildLowerHalfOnly(false)\r\n\t{\r\n\t\tsetToDefault();\r\n\t\tconvexFlags=((pConvexFlags)(CF_ComputeConvex));\r\n\t\t\r\n\r\n\t\t\r\n\t}\r\n};\r\n\r\nclass MODULE_API pWheelDescr \r\n{\r\n\r\npublic :\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Wheel Capsule Specific \r\n\t//\r\n\tint\t\t\t\t\twheelApproximation;\r\n\r\n\tpAxisReferencedLength radius;\r\n\tfloat width;\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Wheel Common Attributes \r\n\t//\r\n\tfloat\t\t\t\t\twheelSuspension;\r\n\tfloat\t\t\t\t\tspringRestitution;\r\n\tfloat\t\t\t\t\tspringDamping;\r\n\tfloat\t\t\t\t\tspringBias;\r\n\r\n\tfloat\t\t\t\t\tmaxBrakeForce;\r\n\r\n\tfloat\t\t\t\t\tfrictionToSide;\r\n\tfloat\t\t\t\t\tfrictionToFront;\r\n\r\n\tWheelFlags\t\t\t\t\twheelFlags;\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Wheel Shape Specific \r\n\t//\r\n\r\n\tWheelShapeFlags\t\t\t\t\twheelShapeFlags;\r\n\tfloat\t\t\t\tinverseWheelMass;\r\n\tpConvexCylinderSettings convexCylinder;\r\n\t\r\n\tpConvexCylinderSettings getConvexCylinderSettings() { return convexCylinder; }\r\n\tvoid setConvexCylinderSettings(pConvexCylinderSettings val) { convexCylinder = val; }\r\n\tpTireFunction latFunc;int latFuncXML_Id;\r\n\tpTireFunction longFunc;int longFuncXML_Id;\r\n\r\n\tpWheelDescr(){ setToDefault(); }\r\n\t~pWheelDescr(){}\r\n\r\n\tvoid*\t\t\t\t\tuserData;\r\n\tvoid setToDefault();\r\n\tbool isValid() const;\r\n\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Container to store joints\r\n//\r\ntypedef XArrayJointListType;\r\n\r\n\r\nclass pClothDescr\r\n{\r\n\r\n};\r\n\r\n/**\r\n!\t\\brief Describes a rigid body. \r\n\r\nThis is used by #pFactory::createBody() and #pRigidBody::addSubShape() only.\r\n\r\n*/\r\nclass MODULE_API pObjectDescr\r\n{\r\n\r\n\r\npublic : \r\n\r\n\t int mask;\r\n\r\n\r\n\ttypedef enum E_OD_VERSION\r\n\t{\r\n\t\tOD_DECR_V0,\r\n\t\tOD_DECR_V1,\r\n\t};\r\n\r\n\r\n\tCK_ID worlReference;\r\n\r\n\tint version;\r\n\t/**\r\n\t\\brief The shape type of the body. Default = HT_Sphere.\r\n\t*/\r\n\tHullType hullType;\r\n\t/**\r\n\t\\brief The shape type of the body. Default = 1.0f. \r\n\t*/\r\n\tfloat density;\r\n\r\n\t/**\r\n\t\\brief Translates the mass center after the body is created in local space.\r\n\t*/\r\n\tVxVector massOffset;\r\n\t/**\r\n\t\\brief Translates the pivot after the body is created in local space.\r\n\t*/\r\n\tVxVector shapeOffset;\r\n\r\n\t/**\r\n\t\\brief Translates the pivot after the body is created in local space.\r\n\t*/\r\n\tVxVector pivotOffsetLinear;\r\n\t/**\r\n\t\\brief Translates the pivot after the body is created in local space.\r\n\t*/\r\n\tCK_ID pivotOffsetReference;\r\n\r\n\t/**\r\n\t\\brief Translates the pivot after the body is created in local space.\r\n\t*/\r\n\tVxVector pivotOffsetAngular;\r\n\t/**\r\n\t\\brief Describes several properties. See #BodyFlags. Default = 0. \r\n\t*/\r\n\tBodyFlags flags;\r\n\t\r\n\t/**\r\n\t\\brief Will parse the entities hierarchy for additional sub shapes. Child objects needs to have the physic object attribute attached. Default = false. \r\n\t*/\r\n\tbool hirarchy;\r\n\t/**\r\n\t\\brief If there are sub shape attached, #pRigidBodie::addSubShape will call #pRigidBody::updateMassFromShapes(). Default = 0.0f. \r\n\t*/\r\n\tfloat newDensity;\r\n\t/**\r\n\t\\brief If there are sub shape attached, #pRigidBodie::addSubShape will call #pRigidBody::updateMassFromShapes(). Default = 0.0f. \r\n\t*/\r\n\tfloat totalMass; \r\n\t\r\n\tint subEntID;\r\n\tint transformationFlags;\r\n\r\n\tint internalXmlID;\r\n\tint externalXmlID;\r\n\tint xmlImportFlags;\r\n\tVxVector pivotAngularOffset;\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Collision\r\n\t*/\r\n\t//@{\r\n\r\n\t\t/**\r\n\t\t\t\\brief Sets 128-bit mask used for collision filtering. See comments for ::pGroupsMask\r\n\t\t*/\r\n\t\tpGroupsMask groupsMask;\r\n\r\n\t\t/**\r\n\t\t\\brief Adds an additional offset for collision response.\r\n\t\t*/\r\n\t\tfloat skinWidth;\r\n\r\n\t\t/**\r\n\t\t\\brief The collision group the body belongs to. Default = 0. \r\n\t\t*/\r\n\t\tint collisionGroup;\r\n\r\n\t\r\n\t//@}\r\n\t\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name CCD Settings\r\n\t*/\r\n\t//@{\r\n\r\n\t\tfloat ccdMotionThresold;\r\n\t\tint ccdFlags;\r\n\t\tCK_ID ccdMeshReference;\r\n\t\tfloat ccdScale;\r\n\r\n\t\r\n\t//@}\r\n\r\n\t\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Damping\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief the linear damping.\r\n\t*/\r\n\tfloat linearDamping;\r\n\r\n\t/**\r\n\t\\brief the angular damping.\r\n\t*/\r\n\tfloat angularDamping;\r\n\r\n\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Sleeping Settings\r\n\t*/\r\n\t//@{\r\n\r\n\t\tfloat linearSleepVelocity;\r\n\t\tfloat angularSleepVelocity;\r\n\t\tfloat sleepingEnergyThresold;\r\n\r\n\t\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Optimization\r\n\t*/\r\n\t//@{\r\n\r\n\t\tint solverIterations;\r\n\t\tint dominanceGroups;\r\n\t\tint compartmentID;\r\n\r\n\t\t\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Mass\r\n\t*/\r\n\t//@{\r\n\r\n\t\tVxVector massOffsetLinear;\r\n\t\tVxVector massOffsetAngular;\r\n\t\tCK_ID massOffsetReference;\r\n\t\r\n\t//@}\r\n\r\n\r\n\tpOptimization optimization;\r\n\t\tpOptimization& getOptimization() { return optimization; }\r\n\t\tvoid setOptimization(pOptimization val) { optimization = val; }\r\n\t\r\n\tpMaterial material;\r\n\t\tpMaterial& getMaterial() { return material; }\r\n\t\tvoid setMaterial(pMaterial val) { material = val; }\r\n\t\r\n\tpCCDSettings ccd;\r\n\t\tpCCDSettings& getCCD() { return ccd; }\r\n\t\tvoid setCCD(pCCDSettings val) { ccd = val; }\r\n\t\r\n\tpCapsuleSettingsEx capsule;\r\n\t\tpCapsuleSettingsEx& getCapsule() { return capsule; }\r\n\t\tvoid setCapsule(pCapsuleSettingsEx val) { capsule = val; }\r\n\t\r\n\tpConvexCylinderSettings convexCylinder;\r\n\t\tpConvexCylinderSettings& getConvexCylinder() { return convexCylinder; }\r\n\t\tvoid setConvexCylinder(pConvexCylinderSettings val) { convexCylinder = val; }\r\n\t\r\n\tpMassSettings mass;\r\n\t\tpMassSettings& getMass() { return mass; }\r\n\t\tvoid setMass(pMassSettings val) { mass = val; }\r\n\t\r\n\tpPivotSettings pivot;\r\n\t\tpPivotSettings& getPivot() { return pivot; }\r\n\t\tvoid setPivot(pPivotSettings val) { pivot = val; }\r\n\r\n\tpCollisionSettings collision;\r\n\t\tpCollisionSettings& getCollision() { return collision; }\r\n\t\tvoid setCollision(pCollisionSettings val) { collision = val; }\r\n\r\n\tpWheelDescr wheel;\r\n\t\tpWheelDescr& getWheel() { return wheel; }\r\n\t\tvoid setWheel(pWheelDescr val) { wheel = val; }\r\n\r\n\tpObjectDescr()\r\n\t{\r\n\t\tsetToDefault();\r\n\t}\r\n\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief\tMeta data to track the relation between a NxShape and an CK3dEntity.\r\n//!\t\t\tAlso used to track a wheel object in the NxShapes user data.\r\n//\r\nstruct pSubMeshInfo\r\n{\r\n\tpObjectDescr initDescription;\r\n\tNxCCDSkeleton *ccdSkeleton;\r\n\tint meshID;\r\n\tCKBeObject *mesh;\r\n\r\n\tint entID;\r\n\tCKBeObject *refObject;\r\n\tCK_ID ccdReference;\r\n\r\n\tpWheel *wheel;\r\n\r\n\tpSubMeshInfo()\r\n\t{\r\n\t\twheel = NULL;\r\n\t\tmeshID = -1;\r\n\t\tentID = -1 ;\r\n\t\tmesh = NULL;\r\n\t\trefObject = NULL;\r\n\t\tccdSkeleton = NULL;\r\n\t\tccdReference = 0;\r\n\t}\r\n};\r\n\r\n\r\n/** @} */\r\n\r\n\r\n\r\n#endif // __PRIGIDBODYTYPES_H__/********************************************************************\r\n\tcreated:\t2009/02/17\r\n\tcreated:\t17:2:2009 10:21\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\vtPhysXAll.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core \r\n\tfile base:\tvtPhysXAll\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tCommon header for all definitions. Includes ALL !\r\n*********************************************************************/\r\n#ifndef __VTPHYSXALL_H__\r\n#define __VTPHYSXALL_H__\r\n\r\n#include \"pTypes.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Help types\r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Include of necessary meta and extra structures. \r\n//\r\n\r\n#include \"pTypes.h\"\r\n\r\n#include \"pWorldTypes.h\"\r\n#include \"pManagerTypes.h\"\r\n#include \"pJointTypes.h\"\r\n#include \"pRigidBodyTypes.h\"\r\n\r\n\r\n#include \"pVehicleTypes.h\"\r\n#include \"pWheelTypes.h\"\r\n\r\n#include \"pVehicleMotor.h\"\r\n#include \"pVehicleGears.h\"\r\n\r\n#include \"pClothTypes.h\"\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Logger \r\n//\r\n#include \r\n\r\n\r\n//################################################################\r\n//\r\n// Implementation Objects\r\n//\r\n#include \"PhysicManager.h\"\r\n#include \"pRigidBody.h\"\r\n#include \"pFactory.h\"\r\n#include \"pWorld.h\"\r\n#include \"pJoint.h\"\r\n#include \"pSerializer.h\"\r\n\r\n#include \"pWheel.h\"\r\n#include \"pCloth.h\"\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Vehicle Based Types \r\n//\r\n#include \"pVehicle.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Implementation Helper\r\n//\r\n#include \"pMisc.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Parameter Guids\r\n//\r\n#include \"vtParameterGuids.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// NVDIA PhysX Objects\r\n//\r\n#include \"NxPhysics.h\"\r\n#include \"NxUserOutputStream.h\"\r\n#include \"NxSceneDesc.h\"\r\n#include \"NxClothDesc.h\"\r\n#include \"NxFluidDesc.h\"\r\n#include \"NxFluidEmitterDesc.h\"\r\n#include \"NxConvexShapeDesc.h\"\r\n#include \"NxScene.h\"\r\n#ifdef VTPX_HAS_CHARACTER_CONTROLLER\r\n\t#include \"NxControllerManager.h\"\r\n\t#include \"NxCharacter.h\"\r\n\t#include \"NxBoxController.h\"\r\n\t#include \"NxCapsuleController.h\"\r\n\t#include \"pBoxController.h\"\r\n#endif\r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// Generic Virtools Helpers\r\n//\r\n#include \r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// Math conversions\r\n//\r\n#include \"pMathTools.h\"\r\nusing namespace pMath;\r\n\r\n\r\n\r\n#endif // __VTPHYSXALL_H__#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothAddDirectedForceAtPosDecl();\r\nCKERROR CreatePClothAddDirectedForceAtPosProto(CKBehaviorPrototype **pproto);\r\nint PClothAddDirectedForceAtPos(const CKBehaviorContext& behcontext);\r\nCKERROR PClothAddDirectedForceAtPosCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Pos,\r\n\tbbI_Force,\r\n\tbbI_Radius,\r\n\tbbI_ForceMode,\r\n};\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothAddDirectedForceAtPosDecl\r\n// FullName: FillBehaviorPClothAddDirectedForceAtPosDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothAddDirectedForceAtPosDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothAddDirectedForceAtPos\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Applies a directed force (or impulse) at a particular position. All vertices within radius will be affected with a quadratic drop-off. \");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x439b04ff,0x252950fc));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothAddDirectedForceAtPosProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothAddDirectedForceAtPosProto\r\n// FullName: CreatePClothAddDirectedForceAtPosProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothAddDirectedForceAtPosProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothAddDirectedForceAtPos\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothAddDirectedForceAtPos \r\n\r\n\tPClothAddDirectedForceAtPos is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tApplies a directed force (or impulse) at a particular position. All vertices\r\n\twithin radius will be affected with a quadratic drop-off.
\r\n\r\n\tBecause forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\r\n\t@see pCloth::addDirectedForceAtPos()\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothAddDirectedForceAtPos.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\tPosition: Position to apply force at.\r\n\t
\r\n\tForce: Force to apply.\r\n\t
\r\n\tMagnitude: Magnitude of the force/impulse to apply.\r\n\t
\r\n\tRadius: The sphere radius in which particles will be affected.\r\n\t
\r\n\tForce Mode: The mode to use when applying the force/impulse.\r\n\t(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange).\r\n\t
\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothAddDirectedForceAtPosCB );\r\n\tproto->DeclareInParameter(\"Position\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Magnitude\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Radius\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Force Mode\",VTE_BODY_FORCE_MODE);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothAddDirectedForceAtPos);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAddDirectedForceAtPos\r\n// FullName: PClothAddDirectedForceAtPos\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothAddDirectedForceAtPos(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tpCloth *cloth = GetPMan()->getCloth(target->GetID());\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tVxVector position= GetInputParameterValue(beh,bbI_Pos);\r\n\t\tVxVector force = GetInputParameterValue(beh,bbI_Force);\r\n\t\tfloat radius= GetInputParameterValue(beh,bbI_Radius);\r\n\t\tint forceMode = GetInputParameterValue(beh,bbI_ForceMode);\r\n\r\n\t\tcloth->addDirectedForceAtPos(position,force,radius,(ForceMode)forceMode);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAddDirectedForceAtPosCB\r\n// FullName: PClothAddDirectedForceAtPosCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothAddDirectedForceAtPosCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n} PhysicManager pm = GetPhysicManager();\r\n pRigidBody b = pm.getBody(body);\r\n if(b)\r\n {\r\n\tint collGroupMainShape = b.getCollisionsGroup();\r\n\tbool isKinematic = b.isKinematic();\r\n\tbool isGravityOn = b.isAffectedByGravity();\r\n\tbool is collisionOn = b.isCollisionEnabled();\r\n }\r\n#ifndef __PCROSS_TYPES_H__\r\n#define __PCROSS_TYPES_H__\r\n\r\n#include \"pTypes.h\"\r\n//#include \"NxWheelDesc.h\"\r\n#include \"VxMath.h\"\r\n#include \"XString.h\"\r\n#include \"CK3DEntity.h\"\r\n#include \"pVTireFunction.h\"\r\n\r\n\r\n\r\n#endif#include \"pch.h\"\r\n#include \"CKAll.h\"\r\n\r\n#include \"FTP4W.H\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorFTPLoginDecl();\r\nCKERROR CreateFTPLoginProto(CKBehaviorPrototype **pproto);\r\nint FTPLogin(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorFTPLoginDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"FTP Login\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetCategory(\"Narratives/Files\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x3d100c46,0x206c6bc2));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateFTPLoginProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateFTPLoginProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"FTP Login\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Login\");\r\n\tproto->DeclareInput(\"Logout\");\r\n\r\n\tproto->DeclareOutput(\"Login Exit\");\r\n\tproto->DeclareOutput(\"Logout Exit\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"Host\", CKPGUID_STRING,\"127.0.0.1\");\r\n\tproto->DeclareInParameter(\"User\", CKPGUID_STRING,\"ich\");\r\n\tproto->DeclareInParameter(\"Password\", CKPGUID_STRING,\"ich\");\r\n\tproto->DeclareInParameter(\"Port\", CKPGUID_INT,\"21\");\r\n\t\r\n\r\n\tproto->DeclareOutParameter(\"Error Code 0=ok\", CKPGUID_INT,\"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(FTPLogin);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n#define LOG_FILE \"c:\\\\ftp4w.log\"\r\n\r\nint FTPLogin(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\t\tif( beh->IsInputActive(0)){\r\n\t\t\tbeh->ActivateInput(0,FALSE);\r\n\t\r\n\t\t\tHWND win = (HWND)ctx->GetMainWindow();\r\n\t\t\tFtpInit(win);\r\n\t\t\t//HFILE hLogFile = _lcreat (LOG_FILE, 0);\r\n\t\t\t//FtpLogTo (hLogFile);\r\n\t\t\t\r\n\t\t\t\r\n\t\r\n\t\t\tFtpSetDefaultTimeOut (30);\r\n\t\t\tFtpSetPassiveMode(TRUE);\r\n\t\t\tFtpSetAsynchronousMode();\r\n\t\r\n\t\t\tint Port;\r\n\t\t\tbeh->GetInputParameterValue(3,&Port);\r\n\t\t\t\r\n\r\n\r\n\t\t\tXString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\tXString User((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\tXString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2));\r\n\t\t\t\r\n\t\t\tint Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0);\r\n\t\t\tbeh->SetOutputParameterValue(0,&Login);\r\n\t\t\t\r\n\r\n\t\t\tif (Login == 0)beh->ActivateOutput(0);\r\n\t\t\t\telse{\r\n\t\t\t\t\tbeh->ActivateOutput(2);\r\n\t\t\t\t\treturn CKBR_OK;\r\n\t\t\t\t}\r\n\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t}\r\n\r\n\t\tif( beh->IsInputActive(1)){\r\n\t\t\tbeh->ActivateInput(1,FALSE);\r\n\r\n\t\t\tFtpCloseConnection();\r\n\t\t\tFtpRelease ();\r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n#ifndef __PJOINT_H_\r\n#define __PJOINT_H_\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n/** \\addtogroup Joints\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Abstract base class for the different types of joints.\r\n\r\nAll joints are used to connect two dynamic bodies, or an body and the environment.\r\n\r\nA NULL body represents the environment. Whenever the below comments mention two bodies,\r\none of them may always be the environment (NULL).\r\n\r\n*/\r\nclass MODULE_API pJoint {\r\n\r\n\t\r\n\tpublic:\r\n\t\t\r\n\r\n\t\tpJoint(){}\r\n\t\tpJoint(CK3dEntity* _e);\r\n\t\tpJoint(pRigidBody* _a,pRigidBody* _b,int _type);\r\n \r\n\t\tNxJoint *getJoint() { return mJoint;}\r\n\t\tvoid setJoint(NxJoint*j) { mJoint = j ;}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tprotected : \r\n\r\n\t\t\tpRigidBody* m_SolidA;\r\n\t\t\tpRigidBody* m_SolidB;\r\n\t\t\tCK3dEntity* m_vtObjectA;\r\n\t\t\t\r\n\r\n\t\t\tCK3dEntity* m_vtObjectB;\r\n\t\t\t\r\n\t\t\tint m_type;\r\n\t\t\t\r\n\t\t\tpWorld *m_pWorld;\r\n\t\t\tNxJoint *mJoint;\r\n\t\t\t\r\n\r\n\t\t\t\r\n\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tpublic :\r\n\t\t\r\n\t\t/**\r\n\t\t\\brief Retrieve the type of this joint.\r\n\t\t\\return The type of joint.\r\n\r\n\t\t\\see NxJointType\r\n\t\t*/\r\n\t\tJType getType() const { return (JType)m_type; }\r\n\t\t\r\n\t\tCK3dEntity* GetVTEntA(){ return m_vtObjectA;}\r\n\t\tCK3dEntity* GetVTEntB(){ return m_vtObjectB;}\r\n\t\tpRigidBody *GetSolidA();\r\n\t\tpRigidBody *GetSolidB();\r\n\r\n\t\tCK_ID mAID;\r\n\t\tCK_ID mBID;\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tpWorld * getWorld() const { return m_pWorld; }\r\n\t\tvoid setWorld(pWorld * val) { m_pWorld = val; }\r\n\t\t\r\n\t\t\t\r\n\t\t/**\r\n\t\t\\brief Sets the maximum force magnitude that the joint is able to withstand without breaking.\r\n\r\n\t\tThere are two values, one for linear forces, and one for angular forces. Both values are used directly\r\n\t\tas a value for the maximum impulse tolerated by the joint constraints. \r\n\r\n\t\tBoth force values are MaxFloat by default. This setting makes the joint unbreakable. \r\n\t\tThe values should always be nonnegative.\r\n\r\n\t\tThe distinction between maxForce and maxTorque is dependent on how the joint is implemented internally, \r\n\t\twhich may not be obvious. For example what appears to be an angular degree of freedom may be constrained \r\n\t\tindirectly by a linear constraint.\r\n\r\n\t\tSo in most practical applications the user should set both maxTorque and maxForce to low values.\r\n\r\n\t\tSleeping: This call wakes the body(s) if they are sleeping.\r\n\r\n\t\t\\param[in] maxForce Maximum force the joint can withstand without breaking. Range: (0,inf]\r\n\t\t\\param[in] maxTorque Maximum torque the joint can withstand without breaking. Range: (0,inf]\r\n\r\n\t\t*/\r\n\t\tvoid setBreakForces(float maxForce,float maxTorque);\r\n\r\n\t\t/**\r\n\t\t\\brief Retrieves the max forces of a breakable joint. See #setBreakable().\r\n\r\n\t\t\\param[out] maxForce Retrieves the maximum force the joint can withstand without breaking.\r\n\t\t\\param[out] maxTorque Retrieves the maximum torque the joint can withstand without breaking.\r\n\t\t*/\r\n\t\tvoid getBreakForces(float& maxForce,float& maxTorque);\r\n\r\n\t\t/**\r\n\t\t\\brief Adds a limit plane.\r\n\r\n\t\tBoth of the parameters are given in global coordinates. see setLimitPoint() for the meaning of limit planes.\r\n\r\n\t\tThe plane is affixed to the\tbody that does not have the limit point.\r\n\r\n\t\tThe normal of the plane points toward the positive side of the plane, and thus toward the\r\n\t\tlimit point. If the normal points away from the limit point at the time of this call, the\r\n\t\tmethod returns false and the limit plane is ignored.\r\n\r\n\t\t\\note This function always returns true and adds the limit plane unlike earlier versions. This behavior\r\n\t\twas changed to allow the joint to be serialized easily.\r\n\r\n\t\tSleeping: This call wakes the body(s) if they are sleeping.\r\n\r\n\t\t\\param[in] normal Normal for the limit plane in global coordinates. Range: direction vector\r\n\t\t\\param[in] pointInPlane Point in the limit plane in global coordinates. Range: position vector\r\n\t\t\\param[in] restitution Restitution of the limit plane.\r\n\t\tRange: [0.0, 1.0]\r\n\t\tDefault: 0.0\r\n\t\t\\return Always true.\r\n\r\n\t\t\\see setLimitPoint() purgeLimitPlanes() getNextLimitPlane()\r\n\t\t*/\r\n\t\tint addLimitPlane(const VxVector normal, VxVector pointInPlane, float restitution=0.0f);\r\n\r\n\t\t/**\r\n\t\t\\brief deletes all limit planes added to the joint.\r\n\r\n\t\tInvalidates limit plane iterator.\r\n\r\n\t\tSleeping: Does NOT wake the associated body up automatically.\r\n\r\n\t\t\\see addLimitPlane() getNextLimitPlane()\r\n\t\t*/\r\n\t\tvoid purgeLimitPlanes();\r\n\t\t/**\r\n\t\t\\brief Restarts the limit plane iteration.\r\n\r\n\t\tCall before starting to iterate. This method may be used together with\r\n\t\tthe below two methods to enumerate the limit planes.\r\n\t\tThis iterator becomes invalid when planes\r\n\t\tare added or removed, or the plane iterator mechanism is\r\n\t\tinvoked on another joint.\r\n\r\n\t\t\\see hasMoreLimitPlanes() getNextLimitPlane()\r\n\t\t*/\r\n\t\tvoid resetLimitPlaneIterator();\r\n\t\t/**\r\n\t\t\\brief Returns true until the iterator reaches the end of the set of limit planes.\r\n\r\n\t\tAdding or removing elements does not reset the iterator.\r\n\r\n\t\t\\return True if the iterator has not reached the end of the sequence of limit planes.\r\n\r\n\t\r\n\t\t\\see resetLimitPlaneIterator() getNextLimitPlane()\r\n\t\t*/\r\n\t\tint hasMoreLimitPlanes ();\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the next element pointed to by the limit plane iterator, and increments the iterator.\r\n\r\n\t\tPlaces the global frame plane equation (consisting of normal and d, the 4th\r\n\t\telement) coefficients in the argument references. The plane equation is of the form:\r\n\r\n\t\tdot(n,p) + d == 0 (n = normal, p = a point on the plane)\r\n\r\n\t\t\\param[out] planeNormal Used to store the plane normal.\r\n\t\t\\param[out] planeD Used to store the plane 'D'.\r\n\t\t\\param[out] restitution Optional, used to store restitution of the limit plane.\r\n\t\t\\return Returns true if the limit plane is satisfied.\r\n\r\n\t\t\\see resetLimitPlaneIterator() hasMoreLimitPlanes()\r\n\t\t*/\r\n\t\tint getNextLimitPlane (VxVector &planeNormal, float &planeD,float *restitution=NULL);\r\n\t\t/**\r\n\t\t\\brief Sets the limit point.\r\n\r\n\t\tThe point is specified in the global coordinate frame.\r\n\r\n\t\tAll types of joints may be limited with the same system:\r\n\t\tYou may elect a point attached to one of the two bodies to act as the limit point.\r\n\t\tYou may also specify several planes attached to the other body.\r\n\r\n\t\tThe points and planes move together with the body they are attached to.\r\n\r\n\t\tThe simulation then makes certain that the pair of bodies only move relative to each other \r\n\t\tso that the limit point stays on the positive side of all limit planes.\r\n\r\n\t\tthe default limit point is (0,0,0) in the local frame of actor2.\r\n\t\tCalling this deletes all existing limit planes.\r\n\r\n\t\tSleeping: This call wakes the body(s) if they are sleeping.\r\n\r\n\t\t\\param[in] point The limit reference point defined in the global frame. Range: position vector\r\n\t\t\\param[in] pointIsOnActor2 if true the point is attached to the second body. Otherwise it is attached to the first.\r\n\r\n\t\t\\sa getLimitPoint() addLimitPlane()\r\n\t\t*/\r\n\t\tvoid setLimitPoint(VxVector point,bool pointIsOnActor2=true);\r\n\t\t\r\n\t\t/**\r\n\t\t\\brief Retrieves the global space limit point.\r\n\r\n\t\tReturns true if the point is fixed on actor2.\r\n\r\n\t\t\\param[out] worldLimitPoint Used to store the global frame limit point. \r\n\t\t\\return True if the point is fixed to body 2 otherwise the point is fixed to body 1.\r\n\r\n\t\t\\see setLimitPoint() addLimitPlane()\r\n\t\t*/\r\n\t\tbool getLimitPoint(VxVector & worldLimitPoint);\r\n\r\n\r\n\t\tbool IsValid();\r\n\t\tCKContext *context;\r\n\r\n\t\tpJointD6 *castD6Joint();\r\n\t\tpJointFixed*castFixed();\r\n\t\tpJointDistance*castDistanceJoint();\r\n\t\tpJointBall *castBall();\r\n\t\tpJointPulley *castPulley();\r\n\t\tpJointRevolute *castRevolute();\r\n\t\tpJointPrismatic *castPrismatic();\r\n\t\tpJointCylindrical *castCylindrical();\r\n\t\tpJointPointInPlane *castPointInPlane();\r\n\t\tpJointPointOnLine *castPointOnLine();\r\n\r\n\t\tvoid setLocalAnchor0(VxVector anchor0);\r\n\t\tvoid setLocalAnchor1(VxVector anchor1);\r\n\r\n\t\tVxVector getGlobalAxis();\r\n\t\tvoid setGlobalAxis(VxVector axis);\r\n\r\n\t\tVxVector getGlobalAnchor();\r\n\t\tvoid setGlobalAnchor(VxVector anchor);\r\n\r\n\r\n\t\tint getNbLimitPlanes();\r\n\r\n\r\n\t\tvirtual void enableCollision(int collision){}\r\n\r\n\t\tvirtual ~pJoint(){}\r\n\r\n};\r\n/**\r\n\\brief A prismatic joint permits relative translational movement between two bodies along\r\nan axis, but no relative rotational movement.\r\n\r\n\\image html prismJoint.png\r\n\r\n

Creation

\r\n\r\n\\include NxPrismaticJoint_Create.cpp\r\n\r\n\\sa pFactory::createPrismaticJoint()\r\n*/\r\nclass MODULE_API pJointPrismatic : public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointPrismatic(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\r\n\tvoid setGlobalAxis(VxVector axis);\r\n\tvoid setGlobalAnchor(VxVector anchor);\r\n\tvoid enableCollision(int collision);\r\n\r\n\r\n};\r\n/**\r\n\\brief Cylindrical Joints permit relative translational movement between two bodies along\r\nan axis, and also relative rotation along the axis.\r\n\r\n\\image html cylinderJoint.png\r\n\r\n\r\n\\sa pFactory::createCylindricalJoint()\r\n*/\r\nclass MODULE_API pJointCylindrical: public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointCylindrical(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\tvoid setGlobalAxis(VxVector axis);\r\n\tvoid setGlobalAnchor(VxVector anchor);\r\n\tvoid enableCollision(int collision);\r\n\r\n\r\n};\r\n\r\n/**\r\n\\brief A point in plane joint constrains a point on one actor to only move inside a plane attached to another actor. The point attached to the plane is defined by the anchor point. The joint's axis specifies the plane normal.\r\n\r\n\tDOFs removed: 1
\r\n\tDOFs remaining: 5
\r\n\r\n\\image html pointInPlaneJoint.png\r\n\r\n\r\n\\sa pFactory::createPointInPlaneJoint()\r\n*/\r\nclass MODULE_API pJointPointInPlane: public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointPointInPlane(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\t/**\r\n\t\\brief Sets the global axis. \r\n\t\\param[in] axis The new axis.\r\n\t*/\r\n\tvoid setGlobalAxis(VxVector axis);\r\n\t/**\r\n\t\\brief Sets the global anchor. \r\n\t\\param[in] anchor The new anchor.\r\n\t*/\r\n\tvoid setGlobalAnchor(VxVector anchor);\r\n\t/**\r\n\t\\brief Enables collision between both bodies.\r\n\t\\param[in] collision Collision is enabled.\t\r\n\t*/\r\n\tvoid enableCollision(int collision);\r\n\r\n\r\n};\r\n/**\r\n\\brief A point on line joint constrains a point on one actor to only move along a line attached to another actor. The point attached to the line is the anchor point for the joint. The line through this point is specified by its direction (axis) vector.\r\n\r\nDOFs removed: 2
\r\nDOFs remaining: 4
\r\n\r\n\\image html pointOnLineJoint.png\r\n\r\n\r\n\\sa pFactory::createPointInPlaneJoint()\r\n*/\r\nclass MODULE_API pJointPointOnLine: public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointPointOnLine(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\t/**\r\n\t\\brief Sets the global axis. \r\n\t\\param[in] axis The new axis.\r\n\t*/\r\n\tvoid setGlobalAxis(VxVector axis);\r\n\t/**\r\n\t\\brief Sets the global anchor. \r\n\t\\param[in] anchor The new anchor.\r\n\t*/\r\n\tvoid setGlobalAnchor(VxVector anchor);\r\n\t/**\r\n\t\\brief Enables collision between both bodies.\r\n\t\\param[in] collision Collision is enabled.\t\r\n\t*/\r\n\tvoid enableCollision(int collision);\r\n\r\n};\r\n\r\n/**\r\n\\brief A joint which behaves in a similar way to a hinge or axle.\r\n\r\n\\image html revoluteJoint.png\r\n\r\nA hinge joint removes all but a single rotational degree of freedom from two objects.\r\nThe axis along which the two bodies may rotate is specified with a point and a direction\r\nvector.\r\n\r\nAn example for a revolute joint is a door hinge. Another example would be using a revolute \r\njoint to attach rotating fan blades to a ceiling. The revolute joint could be motorized, \r\ncausing the fan to rotate.\r\n\r\n

Revolute Joint Limits

\r\n\r\nA revolute joint allows limits to be placed on how far it rotates around the joint axis. For example, a hinge on a door cannot rotate through 360 degrees; rather, it can rotate between 20 degrees and 180 degrees.\r\nThe angle of rotation is measured using the joints normal (axis orthogonal to the joints axis). This is the angle reported by NxRevoluteJoint::getAngle(). The limits are specified as a high and low limit, which must satisfy the condition -Pi < low < high \r\n\r\nNote : The white region represents the allowable rotation for the joint.\r\n\r\n

Limitations of Revolute Joint Limits

\r\nAs shown below, it is not possible to specify certain limit configurations without rotating the joint axes, due to the restrictions on the values of low and high: \r\n\\image html revoluteLimitLimitation.png\r\n\r\nTo achieve this configuration, it is necessary to rotate the joint counter-clockwise so that low is below the 180 degree line. \r\n\r\nNOTE: If the angular region that is prohibited by the twist limit (as in the above figures) is very small, only a few degrees or so, then the joint may \"push through\" the limit and out on the other side if the relative angular velocity is large enough in relation to the time step. Care must be taken to make sure the limit is \"thick\" enough for the typical angular velocities it will be subjected to.\r\n\r\n\\sa pFactory::createRevoluteJoint()\r\n*/\r\nclass MODULE_API pJointRevolute : public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointRevolute(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\r\n\r\n\t/**\r\n\t\\brief Sets the global axis. \r\n\t\\param[in] axis The new axis.\r\n\t*/\r\n\tvoid setGlobalAxis(const VxVector& axis);\r\n\t/**\r\n\t\\brief Sets the global anchor. \r\n\t\\param[in] anchor The new anchor.\r\n\t*/\r\n\tvoid setGlobalAnchor(const VxVector& anchor);\r\n\r\n\t/**\r\n\t\\brief Retrieves the optional spring.\r\n\t\\return The spring.\r\n\t\\sa setSpring()\r\n\t*/\r\n\tpSpring getSpring();\r\n\t/**\r\n\t\\brief Sets an optional spring.\r\n\t\\param[in] spring The spring.\r\n\t\\return TRUE if spring was valid.\r\n\t\\sa getSpring()\r\n\t*/\r\n\tbool setSpring(pSpring spring);\r\n\r\n\r\n\t/**\r\n\t\\brief Retrieves an optional high limit for angular motion of the joint.\r\n\t\\sa setHighLimit() \r\n\t*/\r\n\tpJointLimit getHighLimit();\r\n\t/**\r\n\t\\brief Sets an optional high limit for angular motion of the joint.\r\n\t\\param[in] limit The new high limit.\r\n\t\\return True if the limit was valid.\r\n\t\\sa getLowLimit() \r\n\t*/\r\n\tbool setHighLimit(pJointLimit limit);\r\n\t/**\r\n\t\\brief Retrieves an optional low limit for angular motion of the joint.\r\n\t\\sa setLowLimit() \r\n\t*/\r\n\tpJointLimit getLowLimit();\r\n\t/**\r\n\t\\brief Sets an optional high limit for angular motion of the joint.\r\n\t\\param[in] limit The new low limit.\r\n\t\\return True if the limit was valid.\r\n\t\\sa setLowLimit() \r\n\t*/\r\n\tbool setLowLimit(pJointLimit limit);\r\n\r\n\t/**\r\n\t\\brief Sets a motor.\r\n\t\\param[in] motor The new motor settings.\r\n\t\\return True if the motor was valid.\r\n\t\\sa getMotor() \r\n\t*/\r\n\tbool setMotor(pMotor motor);\r\n\t/**\r\n\t\\brief Retrieves a motor.\r\n\t\\return The motor settings\r\n\t\\sa setMotor() \r\n\t*/\r\n\tpMotor getMotor();\r\n\t/**\r\n\t\\brief Enables collision between both bodies.\r\n\t\\param[in] collision Collision is enabled.\t\r\n\t*/\r\n\tvoid enableCollision(bool collision);\r\n\tvoid setProjectionMode(ProjectionMode mode);\r\n\tvoid setProjectionDistance(float distance);\r\n\tvoid setProjectionAngle(float angle);\r\n\r\n\r\n\r\n\r\nprotected:\r\nprivate:\r\n\r\n};\r\n\r\n\r\n/*!\r\n * \\brief A pulley joint simulates a rope between two objects passing over 2 pulleys. \r\n * \r\n *\t\\image html pulleyJoint.png \r\n *\r\n * \r\n The pulley joint simulates a rope that can be thrown across a pair of pulleys. In this way, it is similar to the \r\n distance joint (the length of the rope is the distance) but the rope doesn't connect the two bodies along the \r\n shortest path, rather it leads from the connection point on one actor to the pulley point (fixed in world space), \r\n then to the second pulley point, and finally to the other actor.\r\n \r\n The pulley joint can also be used to simulate a rope around a single point by making the pulley points coincide.\r\n\r\n\r\n Note that a setup where either object attachment point coincides with its corresponding pulley suspension point in \r\n\tworld space is invalid. In this case, the simulation would be unable to determine the appropriate direction in which to pull the \r\n\tobject and a random direction would result. The simulation will be unstable. Note that it is also invalid to allow the simulation \r\n\tto end up in such a state. \r\n\r\n*/\r\nclass MODULE_API pJointPulley : public pJoint\r\n{\r\n\r\npublic:\r\n\tpJointPulley(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\t/**\r\n\t\\brief Sets the attachment point of joint in bodie[0]'s space.\r\n\t\r\n\t\\param[in] VxVector anchor\r\n\t\r\n\t\\return void\r\n\t\r\n\t@see pJointPulley::setLocalAnchorB\r\n\t*/\r\n\tvoid setLocalAnchorA(VxVector anchor);\r\n\t/**\r\n\t\\brief Sets the attachment point of joint in bodie[1]'s space.\r\n\t\\param[in] VxVector anchor\r\n\r\n\t\\return void\r\n\r\n\t@see pJointPulley::setLocalAnchorB\r\n\t*/\r\n\tvoid setLocalAnchorB(VxVector anchor);\r\n\r\n\t/**\r\n\t\\brief Returns the attachment point of joint in bodie[0]'s space.\r\n\r\n\t\\return VxVector\r\n\r\n\t@see pJointPulley::setLocalAnchorB\r\n\t*/\r\n\tVxVector getLocalAnchorA();\r\n\t/**\r\n\t\\brief Returns the attachment point of joint in bodie[0]'s space.\r\n\r\n\t\\param[in] VxVector anchor\r\n\r\n\t\\return VxVector\r\n\r\n\t@see pJointPulley::setLocalAnchorA\r\n\t*/\r\n\tVxVector getLocalAnchorB();\r\n\r\n\t/**\r\n\t\\brief Sets the suspension point of joint in world space.\r\n\r\n\t\\param[in] VxVector pulley\r\n\r\n\t\\return void\r\n\r\n\t@see pJointPulley::setPulleyB\r\n\t*/\r\n\tvoid setPulleyA(VxVector pulley);\r\n\t/**\r\n\t\\brief Sets the suspension point of joint in world space.\r\n\r\n\t\\param[in] VxVector pulley\r\n\r\n\t\\return void\r\n\r\n\t@see pJointPulley::setPulleyA\r\n\t*/\r\n\tvoid setPulleyB(VxVector pulley);\r\n\r\n\t/**\r\n\t\\brief Returns the suspension point of joint in world space.\r\n\r\n\t\\return VxVector\r\n\r\n\t@see pJointPulley::getPulleyB\r\n\t*/\r\n\tVxVector getPulleyA();\r\n\t/**\r\n\t\\brief Returns the suspension point of joint in world space.\r\n\r\n\t\\return VxVector\r\n\r\n\t@see pJointPulley::getPulleyA\r\n\t*/\r\n\tVxVector getPulleyB();\r\n\r\n\t/**\r\n\t\\brief Sets how stiff the constraint is, between 0 and 1 (stiffest).\r\n\t\r\n\t\\param[in] float stiffness\r\n\t\t-\tRange: [0,1.0f)
\r\n\t\t-\tDefault: 1.0f\r\n\t\r\n\t\\return void\r\n\t\r\n\t@see getStiffness()\r\n\t*/\r\n\tvoid setStiffness(float stiffness);\r\n\r\n\t/**\r\n\t\\brief Returns how stiff the constraint is, between 0 and 1 (stiffest).\r\n\t\r\n\t\\return float\r\n\t\r\n\t@see setStiffness()\r\n\t*/\r\n\tfloat getStiffness();\r\n\t\r\n\r\n\t/**\r\n\t\\brief Sets transmission ratio.\r\n\t\r\n\t\\param[in] float ratio\r\n\t\t-\tRange: [0,1.0f)
\r\n\t\t-\tDefault: 1.0f\r\n\r\n\t\\return void\r\n\t\r\n\t@see ::getRatio()\r\n\t*/\r\n\tvoid setRatio(float ratio);\r\n\r\n\t/**\r\n\t\\brief Gets transmission ratio.\r\n\t\r\n\t\\return float\r\n\t\r\n\t@see setRatio\r\n\t*/\r\n\tfloat getRatio();\r\n\r\n\r\n\t/**\r\n\t\\brief Set true if the joint also has to maintain a minimum distance, not just a maximum.\r\n\t \r\n\t\\param[in] bool rigid\r\n\t-\tRange: [true,false)
\r\n\t-\tDefault:false\t\r\n\t\\return void\r\n\t\r\n\t@see ::isRigid()\r\n\t*/\r\n\tvoid setRigid(bool rigid);\r\n\r\n\r\n\t/**\r\n\t\\brief Returns true if the joint also has to maintain a minimum distance, not just a maximum.\r\n\t\r\n\t\\return bool\r\n\t\r\n\t@see \r\n\t*/\r\n\tbool isRigid();\r\n\r\n\t/**\r\n\t\\brief \r\n\t\r\n\tSets the rest length of the rope connecting the two objects.\r\n\r\n\tThe distance is computed as ||(pulley0 - anchor0)|| + ||(pulley1 - anchor1)|| * ratio.\r\n\r\n\t\\param[in] float distance\r\n\t-\tRange: [0,inf)
\r\n\t-\tDefault: 0.0f\r\n\t\r\n\t\\return void\r\n\t\r\n\t@see getDistance()\r\n\t*/\r\n\tvoid setDistance(float distance);\r\n\r\n\t/**\r\n\t\\brief Returns the rest length of the rope connecting the two objects.\r\n\r\n\t\\return float\r\n\t\r\n\t@see setDistance()\r\n\t*/\r\n\tfloat getDistance();\r\n\t\r\n\r\n\t/**\r\n\t\\brief Sets motor parameters for the joint. \r\n\t\r\n\t\\param[in] pMotor motor\r\n\t-\tRange: [#pMotor)
\r\n\t-\tDefault: no motor\r\n\r\n\t\\return void\r\n\t\r\n\t@see getMotor()\r\n\t*/\r\n\tvoid setMotor(pMotor motor);\r\n\t\r\n\t/**\r\n\t\\brief Returns motor parameter for the joint.\r\n\r\n\t\\return pMotor\r\n\t\r\n\t@see setMotor()\r\n\t*/\r\n\tpMotor getMotor();\r\n\r\n\r\n\t/**\r\n\t\\brief For convenience only. For the case the pulley hooks are moving, the SDK corrects the these points according to\treference entities.\r\n\t\r\n\t\\return void\r\n\t\r\n\t@see \r\n\t*/\r\n\tvoid setFollowPulleyReferences(bool follow);\r\n\r\n\t/**\r\n\t\\brief Sets the first pulley.\r\n\t\t\r\n\t\\return void\r\n\t\r\n\t@see setPulleyBReference()\r\n\t*/\r\n\tvoid setPulleyAReference(CK3dEntity*ent);\r\n\r\n\t/**\r\n\t\\brief Sets the second pulley.\r\n\r\n\t\\return void\r\n\r\n\t@see setPulleyAReference()\r\n\t*/\r\n\tvoid setPulleyBReference(CK3dEntity*ent);\r\n\r\n\r\n\t/**\r\n\t\\brief Returns the first pulley reference.\r\n\r\n\t\\return void\r\n\r\n\t@see setPulley1Ref()\r\n\t*/\r\n\tCK3dEntity *getPulleyAReference();\r\n\r\n\t/**\r\n\t\\brief Sets the second pulley reference\r\n\r\n\t\\return void\r\n\r\n\t@see setPulley1Ref()\r\n\t*/\r\n\tCK3dEntity *getPulleyBReference();\r\n\r\n\t/**\r\n\t\\brief Enables collision between both bodies.\r\n\r\n\t\\return void\r\n\r\n\t@see setPulley1Ref()\r\n\t*/\r\n\tvoid enableCollision(bool collision);\r\n\r\n\r\nprivate :\r\n\tCK_ID m_Pulley0Reference0;\r\n\tCK_ID m_Pulley0Reference1;\r\n\tbool mFollowPulleyReferences;\r\n\r\n\r\n\r\n\r\n\t\r\n\tpublic :\r\n};\r\n\r\n/**\r\n\\brief A D6 joint is a general constraint between two actors. \r\n\r\n\tIt allows the user to individually define the linear and rotational degrees of freedom. \r\n\tIt also allows the user to configure the joint with limits and driven degrees of freedom as they wish.\r\n\r\n*/\r\nclass MODULE_API pJointD6 : public pJoint\r\n{\r\n\r\npublic:\r\n\t\tpJointD6(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the twist axis.\r\n\t\t\\param[in] mode The new mode.\r\n\t\t\\sa getTwistMotionMode() \r\n\t\t*/\r\n\t\tvoid setTwistMotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getTwist();\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the swing1 axis.\r\n\t\t\\param[in] mode The new mode.\r\n\t\t\\sa getSwing1MotionMode() \r\n\t\t*/\r\n\t\tvoid setSwing1MotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getSwing1();\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the swing2 axis.\r\n\t\t\\param[in] mode The new mode.\r\n\t\t\\sa getSwing2MotionMode() \r\n\t\t*/\r\n\t\tvoid setSwing2MotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getSwing2();\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the linear x axis.\r\n\t\t\\param[in] mode The new mode\r\n\t\t\\sa getXMotionMode() \r\n\t\t*/\r\n\t\tvoid setXMotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getXMotion();\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the linear y axis.\r\n\t\t\\param[in] mode The new mode\r\n\t\t\\sa getZMotionMode() \r\n\t\t*/\r\n\t\tvoid setYMotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getYMotion();\r\n\t\t/**\r\n\t\t\\brief Sets the motion mode for the linear z axis.\r\n\t\t\\param[in] mode The new mode\r\n\t\t\\sa getZMotionMode() \r\n\t\t*/\r\n\t\tvoid setZMotionMode(D6MotionMode mode);\t\r\n\t\tD6MotionMode getZMotion();\r\n\r\n\t\t\r\n\t\tint setLinearLimit(pJD6SoftLimit limit);\t\t\t\tpJD6SoftLimit getLinearLimit();\r\n\t\tint setSwing1Limit(pJD6SoftLimit limit);\t\t\t\tpJD6SoftLimit getSwing1Limit( );\r\n\t\tint setSwing2Limit(pJD6SoftLimit limit);\t\t\t\tpJD6SoftLimit getSwing2Limit();\r\n\t\tint setTwistLowLimit(pJD6SoftLimit value);\t\tpJD6SoftLimit getTwistLowLimit();\r\n\t\tint setTwistHighLimit(pJD6SoftLimit value);\t\tpJD6SoftLimit getTwistHighLimit();\r\n\r\n\t\tpJD6Drive getXDrive();\t\t\t\t\t\t\t\t\t\tint setXDrive(pJD6Drive drive);\r\n\t\tpJD6Drive getYDrive();\t\t\t\t\t\t\t\t\t\tint setYDrive(pJD6Drive drive);\r\n\t\tpJD6Drive getZDrive();\t\t\t\t\t\t\t\t\t\tint setZDrive(pJD6Drive drive);\r\n\r\n\t\tpJD6Drive getSwingDrive();\t\t\t\t\t\t\t\tint setSwingDrive(pJD6Drive drive);\r\n\t\tpJD6Drive getTwistDrive();int setTwistDrive(pJD6Drive drive);\r\n\t\tpJD6Drive getSlerpDrive();int setSlerpDrive(pJD6Drive drive);\r\n\r\n\t\t/**\\brief If the type of xDrive (yDrive,zDrive) is #D6DT_Position, drivePosition defines the goal position.\r\n\r\n\t\t\tRange: position vector
\r\n\t\t\tDefault: Zero\r\n\t\t*/\r\n\t\tvoid setDrivePosition(VxVector pos);\r\n\t\r\n\t\t/**\\brief If the type of swingDrive or twistDrive is #D6DT_Position, driveOrientation defines the goal orientation.\r\n\r\n\t\t\tRange: position vector
\r\n\t\t\tDefault: Zero\r\n\t\t*/\r\n\t\tvoid setDriveRotation(VxQuaternion rot);\r\n\t\r\n\t\t/**\\brief If the type of xDrive (yDrive,zDrive) is D6DT_Velocity, driveLinearVelocity defines the goal linear velocity.\r\n\r\n\t\tRange: unit quaternion
\r\n\t\tDefault: Identity Quaternion\r\n\r\n\t\t*/\r\n\t\tvoid setDriveLinearVelocity(VxVector linVel); \r\n\t\r\n\t\t/**\\brief If the type of swingDrive or twistDrive is D6DT_Velocity, driveAngularVelocity defines the goal angular velocity.\r\n\t\t\r\n\t\t- driveAngularVelocity.x - goal angular velocity about the twist axis\r\n\t\t- driveAngularVelocity.y - goal angular velocity about the swing1 axis\r\n\t\t- driveAngularVelocity.z - goal angular velocity about the swing2 axis\r\n\r\n\r\n\t\tRange: angular velocity vector
\r\n\t\tDefault: Zero\r\n\t\t\r\n\t\t*/\r\n\t\tvoid setDriveAngularVelocity(VxVector angVel);\r\n\r\n\t\t/**\r\n\t\t\\brief Enables collision between the two bodies.\r\n\t\t\\param[in] Collide or not. \r\n\t\t*/\r\n\t\tvoid enableCollision(bool value);\r\n\t\t/**\r\n\t\t\\brief Sets the global anchor. \r\n\t\t\\param[in] anchor The new anchor.\r\n\t\t*/\r\n\t\tvoid setGlobalAnchor(VxVector anchor);\r\n\t\t/**\r\n\t\t\\brief Sets the global axis. \r\n\t\t\\param[in] axis The new axis.\r\n\t\t*/\r\n\t\tvoid setGlobalAxis(VxVector axis);\r\n\t\tvoid setRatio(float ratio);\r\n\t\tvoid setProjectionMode(ProjectionMode mode);\r\n\t\tvoid setProjectionDistance(float distance);\r\n\t\tvoid setProjectionAngle(float angle);\r\n\r\n\t\tprotected:\r\n\t\tprivate:\r\n\r\n};\r\n\r\n\r\n\r\n/**\r\n\\brief A distance joint maintains a certain distance between two points on two bodies.\r\n\r\n\\image html distanceJoint.png\r\n\r\n\\sa pFactory::createDistanceJoint()\r\n*/\r\nclass MODULE_API pJointDistance : public pJoint\r\n{\r\n\r\n\tpublic:\r\n\t\tpJointDistance(pRigidBody* _a,pRigidBody* _b);\r\n\r\n\t\t/**\r\n\t\t\\brief Sets the minimum rest length of the rope or rod between the two anchor points.\r\n\t\t\\param[in] distance The new rest length. The value must be non-zero!\r\n\t\t\\sa getMinDistance()\r\n\t\t*/\r\n\t\tvoid setMinDistance(float distance);\r\n\t\t/**\r\n\t\t\\brief Sets the maximum rest length of the rope or rod between the two anchor points.\r\n\t\t\\param[in] distance The new rest length.The value must be non-zero!\r\n\t\t\\sa getMaxDistance()\r\n\t\t*/\r\n\t\tvoid setMaxDistance(float distance);\r\n\t\t/**\r\n\t\t\\brief Sets the attachment point of the joint in bodies[0] space.\r\n\t\t\\param[in] anchor The new anchor.\r\n\t\t\\sa getLocalAnchor0()\r\n\t\t*/\r\n\t\tvoid setLocalAnchor0(VxVector anchor);\r\n\t\t/**\r\n\t\t\\brief Sets the attachment point of the joint in bodies[1] space.\r\n\t\t\\param[in] anchor The new anchor.\r\n\t\t\\sa getLocalAnchor1()\r\n\t\t*/\r\n\t\tvoid setLocalAnchor1(VxVector anchor);\r\n\t\t/**\r\n\t\t\\brief Retrieves the attachment point of the joint in bodies[1] space.\r\n\t\t\\return anchor The local anchor 0 .\r\n\t\t\\sa setLocalAnchor0()\r\n\t\t*/\r\n\t\tVxVector getLocalAnchor0();\r\n\t\t/**\r\n\t\t\\brief Retrieves the attachment point of the joint in bodies[1] space.\r\n\t\t\\return The local anchor 1.\r\n\t\t\\sa setLocalAnchor1()\r\n\t\t*/\r\n\t\tVxVector getLocalAnchor1();\r\n\t\t/**\r\n\t\t\\brief Retrieves the minimum rest length of the rope or rod between the two anchor points.\r\n\t\t\\return The minimum distance amongst both bodies. \r\n\t\t\\sa setMinDist()\r\n\t\t*/\r\n\t\tfloat getMinDistance();\r\n\t\t/**\r\n\t\t\\brief Retrieves the maximum rest length of the rope or rod between the two anchor points.\r\n\t\t\\return The maximum distance amongst both bodies. \r\n\t\t\\sa setMaxDist()\r\n\t\t*/\r\n\t\tfloat getMaxDistance();\r\n\t\t/**\r\n\t\t\\brief Retrieves the spring which keeps both bodies springy.\r\n\t\t\\return The spring.\r\n\t\t\\sa setSpring()\r\n\t\t*/\r\n\t\tpSpring getSpring();\r\n\t\t/**\r\n\t\t\\brief Makes the joint springy. \r\n\t\t\\param[in] spring The new rest length. The spring.targetValue field is not used.\r\n\t\t\\sa getSpring()\r\n\t\t*/\r\n\t\tbool setSpring(pSpring spring);\r\n\r\n\t\t/**\r\n\t\t\\brief Enables collision between the two bodies.\r\n\t\t\\param[in] Collide or not. \r\n\t\t*/\r\n\t\tvoid enableCollision(int collision);\r\n\r\n\r\n\tprotected:\r\n\tprivate:\r\n\r\n};\r\nclass MODULE_API pJointFixed : public pJoint\r\n{\r\npublic:\r\n\r\n\tpJointFixed(pRigidBody* _a,pRigidBody* _b);\r\n\tprotected:\r\n\tprivate:\r\n};\r\n\r\n/**\r\n\\brief A sphere joint constrains two points on two bodies to coincide.\r\n\r\nThis point, specified in world space (this guarantees that the points coincide \r\nto start with) is the only parameter that has to be specified.\r\n\r\n\\image html sphericalJoint.png\r\n\r\n\r\n*/\r\nclass MODULE_API pJointBall : public pJoint\r\n{\r\n\tpublic:\r\n\r\n\t\tpJointBall(pRigidBody* _a,pRigidBody* _b);\r\n\t\tpJointBall(pRigidBody* _a,pRigidBody* _b,VxVector anchor);\r\n\t\t\r\n\t\t/**\r\n\t\t\\brief Retrieves the global space anchor.\r\n\t\t\\return The joints anchor.\r\n\t\t\\sa getAnchor() \r\n\t\t*/\r\n\t\tVxVector getAnchor();\r\n\t\t/**\r\n\t\t\\brief Sets the global space anchor.\r\n\t\t\\param[in] worldLimitPoint Used to store the global frame limit point. \r\n\t\t\\sa getAnchor() \r\n\t\t*/\r\n\t\tvoid setAnchor(const VxVector& anchor);\r\n\t\t/**\r\n\t\t\\brief Sets the limit axis defined in the joint space of body a.\r\n\t\t\\param[in] swingLimitAxis The new limit axis.\r\n\t\t\\sa getAnchor() \r\n\t\t*/\r\n\t\tvoid setSwingLimitAxis(const VxVector& swingLimitAxis);\r\n\t\t/**\r\n\t\t\\brief Sets the swing limit of the twist axis.\r\n\t\t\\param[in] limit The new swing limit axis.\r\n\t\t\\return True if the limit was valid.\r\n\t\t\\sa getSwingLimit() \r\n\t\t*/\r\n\t\tbool setSwingLimit(pJointLimit limit);\r\n\t\t/**\r\n\t\t\\brief Sets the high rotation limit around the twist axis.\r\n\t\t\\param[in] limit The new twist high limit.\r\n\t\t\\return True if the limit was valid.\r\n\t\t\\sa getTwistLowLimit() \r\n\t\t*/\r\n\t\tbool setTwistHighLimit(pJointLimit limit);\r\n\t\t/**\r\n\t\t\\brief Sets the high rotation limit around the twist axis.\r\n\t\t\\param[in] limit The new twist low limit.\r\n\t\t\\return True if the limit was valid.\r\n\t\t\\sa getTwistLowLimit() \r\n\t\t*/\r\n\t\tbool setTwistLowLimit(pJointLimit limit);\r\n\t\t\r\n\t\t/**\r\n\t\t\\brief Sets a spring that works against swinging.\r\n\t\t\\param[in] spring The new spring.\r\n\t\t\\return True if the spring was valid.\r\n\t\t\\sa getSwingSpring() \r\n\t\t*/\r\n\t\tbool setSwingSpring(pSpring spring);\r\n\t\t/**\r\n\t\t\\brief Sets a spring that works against twisting.\r\n\t\t\\param[in] spring The new spring.\r\n\t\t\\return True if the spring was valid.\r\n\t\t\\sa getTwistSpring() \r\n\t\t*/\r\n\t\tbool setTwistSpring(pSpring spring);\r\n\t\t/**\r\n\t\t\\brief Sets a spring that lets the joint get pulled apart.\r\n\t\t\\param[in] spring The new spring.\r\n\t\t\\return True if the spring was valid.\r\n\t\t\\sa getJointSpring() \r\n\t\t*/\r\n\t\tbool setJointSpring(pSpring spring);\r\n\r\n\t\tpJointLimit getSwingLimit();\r\n\t\tpJointLimit getTwistHighLimit();\r\n\t\tpJointLimit getTwistLowLimit();\r\n\r\n\t\tpSpring getSwingSpring();\r\n\t\tpSpring getTwistSpring();\r\n\t\tpSpring getJointSpring();\r\n\t\tvoid enableFlag(int flag,bool enable);\r\n\r\n\t\t/**\r\n\t\t\\brief Enables collision between the two bodies.\r\n\t\t\\param[in] collision Collide or not. \r\n\t\t*/\r\n\t\tvoid enableCollision(bool collision);\r\n\r\n\t\tvoid setProjectionMode(ProjectionMode mode);\r\n\t\tvoid setProjectionDistance(float distance);\r\n\t\tvoid setProjectionAngle(float angle);\r\n\r\n\r\n\r\n\r\n\tprotected:\r\n\tprivate:\r\n};\r\n\r\n/** @} */\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2009/02/14\r\n\tcreated:\t14:2:2009 15:50\r\n\tfilename: \tSDK\\Include\\Core\\vtParameterGuids.h\r\n\tfile path:\tSDK\\Include\\Core\r\n\tfile base:\tvtParameterGuids\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tUnique identifiers for the entire component \r\n*********************************************************************/\r\n#ifndef __VT_PARAMETER_GUIDS_H__\r\n\t#define __VT_PARAMETER_GUIDS_H__\r\n\r\n\r\n//################################################################\r\n//\r\n// Common Parameter, used by joints, bodies, -or world objects\r\n//\r\n#define VTS_AXIS_REFERENCED_LENGTH\tCKGUID(0x19d6054d,0x4c2a2c99)\r\n#define VTE_PHYSIC_DOMINANCE_GROUP\t\tCKGUID(0x2ae53cee,0x57ca74d0)\r\n\r\n#define VTS_SLEEPING_SETTINGS\t\tCKGUID(0x28d13431,0x24186938)\r\n\r\n#define VTF_TRIGGER CKGUID(0xe9c412e,0x68025071)\r\n#define VTE_FILTER_OPS CKGUID(0x58340fe5,0x67892b1f)\r\n#define VTE_FILTER_MASK CKGUID(0x30ff289e,0x7e57707c)\r\n#define VTS_FILTER_GROUPS CKGUID(0x14443c3a,0x7c886162)\r\n#define VTF_SHAPES_TYPE CKGUID(0x2ff80c77,0x7ab71a8)\r\n#define VTF_RAY_HINTS CKGUID(0x7f5552d,0x70632e9a)\r\n#define VTS_RAYCAST CKGUID(0x3842035f,0x1bc81c7f)\r\n#define VTF_COLLISIONS_EVENT_MASK CKGUID(0x1beb409d,0x5028494f)\r\n\r\n#define VTF_WHEEL_CONTACT_MODIFY_FLAGS CKGUID(0x40495482,0x4ab3283e)\r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// Shape overrides \r\n//\r\n#define VTS_CAPSULE_SETTINGS\t\tCKGUID(0x9a441c3,0x1e1d25ce)\r\n#define VTS_CAPSULE_SETTINGS_EX\t\tCKGUID(0x16f102dc,0x7cb97e54)\r\n//\tWheel type using a convex cylinder, a capsule and a joint spring\r\n#define VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR CKGUID(0x65e30713,0x55ca1048)\r\n\r\n\r\n//################################################################\r\n//\r\n// World Related \r\n//\r\n#define VTS_PHYSIC_DOMINANCE_SCENE_SETTINGS\t\tCKGUID(0x636c3e44,0x658213ea)\r\n\t#define VTS_PHYSIC_DOMINANCE_ITEM\tCKGUID(0x7bee51cc,0xb676809)\r\n\t\t#define VTS_PHYSIC_DOMINANCE_CONSTRAINT\t\tCKGUID(0x6f44420b,0x14b7435d)\r\n\r\n#define VTS_WORLD_SETTINGS\t\tCKGUID(0x5a0b56eb,0x50fc04d2)\r\n#define VTS_PHYSIC_WORLD_PARAMETER\t\tCKGUID(0x27f223a1,0x365777f0)\r\n\r\n//################################################################\r\n//\r\n// Rigid Body Related\r\n//\r\n#define VTS_PHYSIC_PARAMETER\t\tCKGUID(0x90e519f,0x7ec5345d)\r\n#define VTS_PHYSIC_ACTOR\t\tCKGUID(0x381d7e69,0x456458fb)\r\n\r\n#define VTF_PHYSIC_SUBSHAPE_INHERITANCE_FLAGS\t\tCKGUID(0x55c60b24,0x4ddc754e)\r\n\r\n#define VTS_PHYSIC_TRANSFORMATIONS_LIMIT_PARAMETER\t\tCKGUID(0x413f3fb4,0x4f545c24)\r\n\r\n#define VTF_PHYSIC_BODY_COMMON_SETTINGS CKGUID(0x44bc4e8d,0x16cb3288)\r\n#define VTE_BODY_FORCE_MODE\tCKGUID(0x28c8214c,0x1ab04db8)\r\n#define VTF_PHYSIC_BODY_UPDATE_FLAGS\t\tCKGUID(0x7f824fb3,0x5496b62)\r\n#define VTF_PHYSIC_WORLD_UPDATE_FLAGS\t\tCKGUID(0x7f824fb3,0x5496b62)\r\n#define VTF_BODY_FLAGS CKGUID(0x2c173381,0x10f66ab3)\r\n#define VTF_BODY_TRANS_FLAGS CKGUID(0x41242761,0x72e70c27)\r\n#define VTE_COLLIDER_TYPE\t\tCKGUID(0x1c415d41,0x5c534d7a)\r\n#define VTF_CONVEX_FLAGS\t\tCKGUID(0x2d9d5c3e,0x468c0266)\r\n#define VTF_CONTACT_MODIFY_FLAGS\t\tCKGUID(0x7d5c0e7c,0x144d2596)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// XML Setup \r\n//\r\n\r\n#define VTS_PHYSIC_ACTOR_XML_SETTINGS_INTERN\t\tCKGUID(0x35977af4,0x5b430c0c)\r\n#define VTS_PHYSIC_ACTOR_XML_SETTINGS_EXTERN\t\tCKGUID(0x57aa4cab,0x7e173b06)\r\n#define VTS_PHYSIC_ACTOR_XML_IMPORT_FLAGS\t\t\tCKGUID(0x2a2c3ee5,0x33cc3c2f)\r\n#define VTS_PHYSIC_ACTOR_XML_SETUP\t\t\t\t\tCKGUID(0x5e916f6,0x6e7a44ed)\r\n#define VTF_PHYSIC_ACTOR_COPY_FLAGS\t\t\t\t\tCKGUID(0x7013615f,0x9aa642e)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Geometry \r\n//\r\n#define VTS_PHYSIC_PIVOT_OFFSET\t\t\t\t\tCKGUID(0x19e432af,0x571f5bf7)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Collision \r\n//\r\n#define VTF_PHYSIC_COLLISION_MASK\t\tCKGUID(0x7bf86391,0x1ac73b1)\r\n\r\n#define VTS_PHYSIC_CCD_SETTINGS\t\tCKGUID(0x37537e0c,0x55b668d6)\r\n\t#define VTF_PHYSIC_CCD_FLAGS\t\tCKGUID(0x25ee18c2,0x3419342d)\r\n\r\n#define VTS_PHYSIC_COLLISIONS_SETTINGS\t\tCKGUID(0x8027e35,0x7c940e70)\r\n\t#define VTE_PHYSIC_BODY_COLL_GROUP\t\tCKGUID(0xc1e1e0a,0x36fd0de4)\r\n\r\n#define VTS_PHYSIC_COLLISIONS_SETUP\tCKGUID(0x64043794,0x4d9f454b)\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Mass Configuration\r\n//\r\n#define VTS_PHYSIC_MASS_SETUP\t\tCKGUID(0x36855c80,0x81a0a4e)\r\n\t#define VTE_PHYSIC_MASS_TYPE\t\tCKGUID(0x71921e8a,0x8e22f63)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Optimization\r\n//\r\n#define VTS_PHYSIC_SLEEP_SETTINGS\t\tCKGUID(0x41450454,0x3b4a65c2)\r\n#define VTS_PHYSIC_DAMPING_PARAMETER\t\tCKGUID(0x17ad0411,0x3ccd0dd7)\r\n#define VTS_PHYSIC_ACTOR_OPTIMIZATION\t\tCKGUID(0x2fca03db,0x25644fd4)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Material \r\n//\r\n#define VTS_MATERIAL CKGUID(0x4785249d,0x57af4457)\r\n#define VTF_MATERIAL_FLAGS\tCKGUID(0x14ce161f,0x27cc5b83)\r\n#define VTE_MATERIAL_COMBINE_MODE\t\tCKGUID(0x6dbf7c19,0x3dfb0e12)\r\n#define VTE_XML_MATERIAL_TYPE\t\tCKGUID(0x57430496,0x29193343)\r\n\r\n\r\n\r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// Joints : \r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Common shared types \r\n//\r\n\r\n\r\n#define VTE_JOINT_TYPE CKGUID(0x5d9c0413,0xcb96c02)\r\n#define VTS_PHYSIC_JAMOTOR_AXIS_TYPE\t\tCKGUID(0x21352808,0x1e932c41)\r\n\r\n#define VTE_JOINT_MOTION_MODE\t\tCKGUID(0x6ec04e81,0xfd537e)\r\n#define VTS_JOINT_DRIVE\t\tCKGUID(0x563c20ca,0x581e0e4b)\r\n#define VTS_JOINT_SPRING\t\tCKGUID(0x495d0920,0x189674ba)\r\n#define VTS_JLIMIT\t\tCKGUID(0x8d61654,0x1fd01503)\r\n#define VTS_JOINT_SLIMIT\tCKGUID(0xd997313,0x28523dc0)\r\n#define VTS_JOINT_MOTOR CKGUID(0x50ab7cc2,0x37ce0071)\r\n\r\n#define VTS_JOINT_D6 CKGUID(0x215a2fa1,0x7cc02701)\r\n#define VTF_JOINT_D6_AXIS_MASK\tCKGUID(0x461c1af3,0x4b194a84)\r\n#define VTS_JOINT_D6_AXIS_ITEM\tCKGUID(0x37d01b38,0x10a03ef)\r\n#define VTE_JOINT_MOTION_MODE_AXIS\tCKGUID(0x5adb450c,0x5798057d)\r\n#define VTE_JOINT_LIMIT_AXIS CKGUID(0x16d654a4,0x276a048f)\r\n#define VTE_JOINT_DRIVE_AXIS CKGUID(0x1c73456a,0x7d846d2a)\r\n#define VTE_JOINT_PROJECTION_MODE CKGUID(0x2cce3d0b,0x60603c02)\r\n#define VTE_JOINT_TYPE CKGUID(0x16f21041,0x7a6479f3)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Complete Joint Setups \r\n//\r\n\r\n#define VTS_JOINT_FIXED CKGUID(0x3a5163bf,0x3c315528)\r\n#define VTS_JOINT_DISTANCE CKGUID(0x1edf6510,0xdea68b2)\r\n#define VTS_JOINT_BALL CKGUID(0x20271cdc,0x645c4212)\r\n#define VTS_JOINT_REVOLUTE CKGUID(0x7d45030c,0x4f6216ef)\r\n#define VTS_JOINT_PRISMATIC CKGUID(0x37fd735c,0x6b83447d)\r\n#define VTS_JOINT_CYLINDRICAL CKGUID(0x45e07719,0xba2297)\r\n\r\n#define VTS_JOINT_POINT_IN_PLANE CKGUID(0xed23f6,0x2ba449a3)\r\n#define VTS_JOINT_POINT_ON_LINE CKGUID(0x4429006a,0x34345b66)\r\n\r\n#define VTS_JOINT_D6 CKGUID(0x52467f8a,0x3adc012b)\r\n#define VTS_JOINT_D6_DRIVES CKGUID(0x46067fc4,0x56cf693e)\r\n\r\n#define VTS_JOINT_BREAKABLE CKGUID(0xe3d7a63,0x2cc61e4a)\r\n#define VTS_JOINT_D6 CKGUID(0x11bd2119,0x3843102b)\r\n\r\n#define VTS_PHYSIC_JBALL_PARAMETER\t\tCKGUID(0x2c47770d,0x1b7173ad)\r\n#define VTS_PHYSIC_JFIXED_PARAMETER\t\tCKGUID(0x780650ae,0x7e6406c5)\r\n#define VTS_PHYSIC_JHINGE_PARAMETER\t\tCKGUID(0x5a805563,0x292021ce)\r\n#define VTS_PHYSIC_JHINGE2_PARAMETER\t\tCKGUID(0x281717e5,0x353b61f2)\r\n#define VTS_PHYSIC_JUNIVERSAL_PARAMETER\t\tCKGUID(0x7a283845,0x53144e6a)\r\n#define VTS_PHYSIC_JSLIDER_PARAMETER\t\tCKGUID(0x67837673,0x20c04330)\r\n#define VTS_PHYSIC_JMOTOR_PARAMETER\t\tCKGUID(0x677e7eba,0x6505310c)\r\n#define VTS_PHYSIC_JLIMIT_PARAMETER\t\tCKGUID(0x17e57c53,0x43585c91)\r\n#define VTE_PHYSIC_JDRIVE_TYPE CKGUID(0x75a51b10,0xe00025c)\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Joint Misc Structures\r\n//\r\n\r\n#define VTS_PHYSIC_JLIMIT_PLANE CKGUID(0x5abe5f0b,0x7ca6657e)\r\n\r\n//################################################################\r\n//\r\n// Wheel Parameters\r\n//\r\n#define VTF_VSTATE_FLAGS\tCKGUID(0x49ce782d,0x7566828)\r\n#define VTF_VFLAGS\t\t\tCKGUID(0x5cf964cf,0xd382f37)\r\n\r\n\r\n#define VTF_VWSHAPE_FLAGS CKGUID(0x7da158eb,0x16e921a1)\r\n#define VTF_VWTIRE_SETTINGS CKGUID(0x2690c24,0xde55e2b)\r\n\r\n#define VTE_BRAKE_XML_LINK CKGUID(0x77806807,0x4eac2b27)\r\n#define VTE_BRAKE_LEVEL CKGUID(0x161f2b7d,0x2f657a2a)\r\n#define VTF_BRAKE_FLAGS CKGUID(0x46535a8f,0x11815172)\r\n#define VTS_BRAKE_TABLE CKGUID(0x59052709,0xa555846)\r\n#define VTF_WHEEL_CONEX_SHAPE CKGUID(0x3f913a00,0x372f4a50)\r\n#define VTS_WHEEL_CONTACT CKGUID(0x33f24aa8,0x34a57460)\r\n\r\n#define VTS_PHYSIC_WHEEL_DESCR CKGUID(0x5dcd09ae,0x73f72b97)\r\n#define VTS_PHYSIC_WHEEL_FLAGS CKGUID(0x72b70c7d,0x3b60239d)\r\n\r\n//################################################################\r\n//\r\n// Vehicle\r\n//\r\n#define VTS_PHYSIC_VEHICLE_DESCR CKGUID(0x54562468,0xd1a6de6)\r\n#define VTS_PHYSIC_VEHICLE_MOTOR_DESCR CKGUID(0x19317402,0x2f4b65a1)\r\n#define VTS_PHYSIC_GEAR_DESCR CKGUID(0x308e5c88,0x433871f9)\r\n#define VTE_XML_VEHICLE_SETTINGS\t\tCKGUID(0x67ca76e9,0x452f7ceb)\r\n#define VTE_XML_VMOTOR_SETTINGS\t\tCKGUID(0x6af977a6,0x11084c45)\r\n#define VTF_VEHICLE_ENGINE_FLAGS\t\tCKGUID(0x23823b40,0x694f152c)\r\n#define VTE_XML_VGEAR_SETTINGS\t\tCKGUID(0x9bc7981,0x4a6f7245)\r\n#define VTE_XML_WHEEL_SETTINGS\t\tCKGUID(0x1ed80439,0x1f9825c4)\r\n#define VTE_XML_TIRE_SETTINGS\t\tCKGUID(0x4cb47505,0x7b022333)\r\n#define VTS_VMOTOR_ENTRY CKGUID(0x12dd3a77,0x5db358f8)\r\n#define VTS_VMOTOR_TVALUES CKGUID(0x34af3aa2,0x23aa6422)\r\n#define VTS_VGEAR_GRAPH_SETTINGS\tCKGUID(0x25016106,0x3a0024a0)\r\n#define VTS_VGEARBOX_FLAGS\tCKGUID(0x47d632a5,0x50057698)\r\n#define VTS_VGEAR_RATIO_ENTRY\t\tCKGUID(0x36b93b1c,0x79f804c2)\r\n#define VTS_VGEAR_RATIOS\t\tCKGUID(0x5a0230db,0x441f5c18)\r\n#define VTS_VGEAR_CURVE\t\t\tCKGUID(0x6352317b,0x41fe3769)\r\n#define VTS_VGEAR_SETTINGS\tCKGUID(0x7dde30fb,0x701915ea)\r\n#define VTE_VEHICLE_XML_LINK CKGUID(0x4c43611,0x736078b9)\r\n\r\n#define VTF_VEHICLE_PROCESS_OPTIONS CKGUID(0x24fa465f,0x1c2f5b88)\r\n\r\n\r\n//################################################################\r\n//\r\n// Cloth\r\n//\r\n#define VTE_CLOTH_FLAGS CKGUID(0x2c7d5bb6,0x6a9d7c41)\r\n#define VTS_CLOTH_DESCR CKGUID(0x722a5c01,0x5c8d413d)\r\n#define VTS_CLOTH_METAL_DESCR CKGUID(0x1ecb0821,0x709e7bdf)\r\n#define VTE_CLOTH_ATTACH_FLAGS CKGUID(0x428b755b,0x36d60122)\r\n\r\n//################################################################\r\n//\r\n// UNknow :\r\n//\r\n#define VTS_PHYSIC_HEIGHTFIELD_PARAMETERS\t\tCKGUID(0x37430de4,0x54d06445)\r\n\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2006/05/07\r\n\tcreated:\t05:07:2006 8:14\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\Behaviors\\Generic\\BGInstancer.cpp\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\Behaviors\\Generic\r\n\tfile base:\tBGInstancer\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include //for pch only,can be removed!\r\n\r\n#include \"BGInstancer.h\"\r\n\r\n\r\n\r\n/*\r\n *******************************************************************\r\n * Function: CKObjectDeclaration *FillBehaviour( void )\r\n *\r\n * Description : As its name infers, this function describes each Building Block\r\n * on a functional level : what it can be applied to, its GUID, its \r\n * creation function, etc.. \r\n *\t\t\r\n *\r\n * Parameters :\r\n * None\r\n *\r\n * Returns : CKObjectDeclaration *, containing:\r\n * - The type of object declaration ( Must Be CKDLL_BEHAVIORPROTOTYPE )\r\n * - The function that will create the CKBehaviorPrototype for this behavior.\r\n * - A short description of what the behavior is supposed to do.\r\n * - The category in which this behavior will appear in the Virtools interface.\r\n * - A unique CKGUID\r\n * - Author and Version info\r\n * - The class identifier of objects to which the behavior can be applied to.\r\n *\r\n *******************************************************************\r\n */\r\nCKObjectDeclaration * BGWrapper::FillBehaviour( void )\r\n{\r\n CKObjectDeclaration *objectDeclaration = CreateCKObjectDeclaration( \"BgInstancer\" );\t\r\n \r\n objectDeclaration->SetType( CKDLL_BEHAVIORPROTOTYPE );\r\n objectDeclaration->SetCreationFunction( BGWrapper::CreatePrototype );\r\n objectDeclaration->SetDescription( \"Encapsulates the functionality provided by a Behaviour Graph and allows reuse while minimising maintenance overhead.\" );\r\n objectDeclaration->SetCategory( \"Narratives/Script Management\" );\r\n objectDeclaration->SetGuid( BGWRAPPER_GUID );\r\n objectDeclaration->SetVersion( 0x00000001 );\r\n objectDeclaration->SetAuthorGuid( VTCX_AUTHOR_GUID );\r\n objectDeclaration->SetAuthorName( VTCX_AUTHOR );\r\n objectDeclaration->SetCompatibleClassId( CKCID_BEOBJECT );\r\n \r\n return objectDeclaration;\r\n}\r\n\r\n/*\r\n *******************************************************************\r\n * Function: CKERROR CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr )\r\n *\r\n * Description : The prototype creation function will be called the first time \r\n * a behavior must be created to create the CKBehaviorPrototype \r\n * that contains the description of the behavior.\r\n *\r\n * Parameters :\r\n * behaviorPrototypePtr Pointer to a CKBehaviorPrototype object that \r\n * describes the behavior's internal structure \r\n * and relationships with other objects.\r\n *\r\n * Returns : CKERROR\r\n *\r\n *******************************************************************\r\n */\r\nCKERROR BGWrapper::CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr )\r\n\t{\r\n\r\n#if RUNTIME\t\r\n\t// Not editable from Virtools Dev\r\n\tCKBehaviorPrototype *behaviorPrototype = CreateCKBehaviorPrototypeRunTime( \"BGWrapper\" );\r\n#elif GAMEDEVELOPER \r\n\t// Edition depend on the BB.\r\n\tCKBehaviorPrototype *behaviorPrototype = CreateCKBehaviorPrototype( \"BGWrapper\" );\r\n#else\t\t\t\t\t\r\n\t// Editable from Virtools Dev\r\n\tCKBehaviorPrototype *behaviorPrototype = CreateCKBehaviorPrototype( \"BGWrapper\" );\r\n#endif \r\n\r\n\t\r\n\tif ( !behaviorPrototype ) \r\n return CKERR_OUTOFMEMORY;\r\n\r\n //----\tLocal Parameters Declaration\r\n\tbehaviorPrototype->DeclareLocalParameter(\"BG Script\", CKPGUID_BEHAVIOR );\r\n\r\n //----\tSettings Declaration\r\n\tbehaviorPrototype->DeclareSetting(\"BG filename\", CKPGUID_STRING ,\"path undefined.(BGWrapper Settings)\");\r\n\r\n\tbehaviorPrototype->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tbehaviorPrototype->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTS |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKBEHAVIOR_INTERNALLYCREATEDOUTPUTS |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS));\r\n\r\n\tbehaviorPrototype->SetBehaviorCallbackFct(BGWrapperCB,\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKCB_BEHAVIORLOAD |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKCB_BEHAVIORRESET |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKCB_BEHAVIORSETTINGSEDITED |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKCB_BEHAVIORDETACH |\r\n\t\t\t\t\t\t\t\t\t\t\t\tCKCB_BEHAVIORDEACTIVATESCRIPT\r\n\t\t\t\t\t\t\t\t\t\t\t\t, NULL);\r\n\r\n behaviorPrototype->SetFunction( BGWrapper::BehaviourFunction );\r\n \r\n *behaviorPrototypePtr = behaviorPrototype;\r\n return CK_OK;\r\n}\r\n\r\n/*\r\n *******************************************************************\r\n * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )\r\n *\r\n * Description : The execution function is the function that will be called \r\n * during the process loop of the behavior engine, if the behavior \r\n * is defined as using an execution function. This function is not \r\n * called if the behavior is defined as a graph. This function is the \r\n * heart of the behavior: it should compute the essence of the behavior, \r\n * in an incremental way. The minimum amount of computing should be \r\n * done at each call, to leave time for the other behaviors to run. \r\n * The function receives the delay in milliseconds that has elapsed \r\n * since the last behavioral process, and should rely on this value to \r\n * manage the amount of effect it has on its computation, if the effect \r\n * of this computation relies on time.\r\n *\r\n * Parameters :\r\n * behaviourContext\t Behavior context reference, which gives access to \r\n * frequently used global objects ( context, level, manager, etc... )\r\n *\r\n * Returns : int, If it is done, it should return CKBR_OK. If it returns \r\n * CKBR_ACTIVATENEXTFRAME, the behavior will again be called \r\n * during the next process loop.\r\n *\r\n *******************************************************************\r\n */\r\n\r\nint BGWrapper::BehaviourFunction( const CKBehaviorContext& behContext )\r\n{\r\n\tCKBehavior\t*behaviour = behContext.Behavior;\r\n\tCKContext\t*context = behContext.Context;\r\n\tint\t\t\tiPin, nbPin;\r\n\r\n\tCKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EBGWRAPPERPARAM_PARAMETER_SCRIPT);\r\n\r\n\tif (script == NULL)\r\n\t\treturn CKBR_GENERICERROR;\r\n\r\n\t// Activate the right inputs\r\n\tnbPin = behaviour->GetInputCount();\r\n\tfor (iPin = 0; iPin < nbPin; iPin++)\r\n\t\t{\r\n\t\tif (behaviour->IsInputActive(iPin))\r\n\t\t\t{\r\n\t\t\tscript->ActivateInput(iPin, TRUE);\r\n\t\t\tbehaviour->ActivateInput(iPin, FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\t// Deactivate all the outputs\r\n\tnbPin = script->GetOutputCount();\r\n\tfor (iPin = 0; iPin < nbPin; iPin++)\r\n\t\t{\r\n\t\tbehaviour->ActivateOutput(iPin, FALSE);\r\n\t\t}\r\n\r\n\t// Parameter In: Set Source\r\n\tint nbPinBB = behaviour->GetInputParameterCount();\r\n\tint nbPinBG = script->GetInputParameterCount();\r\n\r\n\tif (nbPinBB != nbPinBG)\r\n\t\treturn CKBR_GENERICERROR;\r\n\r\n\tfor (iPin = 0; iPin < nbPinBB; iPin++)\r\n\t{\r\n\t\tCKParameterIn *pBin = behaviour->GetInputParameter(iPin);\r\n\t\tCKParameter* pSource = pBin->GetDirectSource();\r\n\r\n\t\tCKParameterIn *pSin = script->GetInputParameter(iPin);\r\n\t\tpSin->SetDirectSource(pSource);\r\n\t}\r\n\r\n\t// Execute the contained script\r\n\tCKERROR result = script->Execute(behContext.DeltaTime);\r\n\r\n\t// The script loop on itself too much times\r\n\tif (result == CKBR_INFINITELOOP) \r\n\t\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"Execute Script : Script %s Executed too much times\",script->GetName());\r\n\t\tscript->Activate(FALSE,FALSE);\r\n\t\treturn CKBR_OK;\r\n\t\t}\r\n\r\n\t// Activate the right outputs \r\n\tnbPin = script->GetOutputCount();\r\n\tfor (iPin = 0; iPin < nbPin; iPin++)\r\n\t\t{\r\n\t\tif (script->IsOutputActive(iPin))\r\n\t\t\t{\r\n\t\t\tbehaviour->ActivateOutput(iPin);\r\n\t\t\tscript->ActivateOutput(iPin, FALSE);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t// Update Parameters Out\r\n\tnbPin = behaviour->GetOutputParameterCount();\r\n\tfor (iPin = 0; iPin < nbPin; iPin++) \r\n\t\t{\r\n\t\tCKParameterOut *pBout = behaviour->GetOutputParameter(iPin);\r\n\t\tCKParameterOut *pSout = script->GetOutputParameter(iPin);\r\n\t\tpBout->CopyValue(pSout, TRUE);\r\n\t\t}\r\n\r\n\t\r\n\t// Test if there are any active sub-behaviors, restart the next frame if any\r\n\tBOOL bActivateNextFrame = FALSE;\r\n\tActivateNextFrameSubBB(script,bActivateNextFrame);\r\n\tif (bActivateNextFrame)\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n\t// return the execute value\r\n\treturn result;\t\r\n}\r\n\r\n/*\r\n *******************************************************************\r\n * Function: CKERROR BGWrapperCB(const CKBehaviorContext& behContext)\r\n *\r\n * Description : The Behavior Callback function is called by Virtools \r\n * when various events happen in the life of a BuildingBlock.\r\n *\r\n * Parameters :\r\n * behaviourContext\t Behavior context reference, which gives access to \r\n * frequently used global objects ( context, level, manager, etc... )\r\n *\r\n * Returns : CKERROR\r\n *\r\n *******************************************************************\r\n */\r\nCKERROR BGWrapper::BGWrapperCB(const CKBehaviorContext& behContext)\r\n{\r\n\tCKERROR\tresult = CKBR_GENERICERROR; \r\n\r\n\t// Initialize common pointers.\t\r\n\tCKBehavior *behaviour = behContext.Behavior;\r\n\tCKContext *context = behContext.Context;\r\n\tCKLevel *level = behContext.CurrentLevel;\r\n\tCKBeObject *owner = behContext.Behavior->GetOwner();\r\n\t\r\n\tchar*name = behaviour->GetName();\r\n\t\r\n\tif ( behaviour == NULL || context == NULL || level == NULL /*|| owner == NULL*/ )\r\n\t\treturn CKBR_OK;\r\n\t\r\n\t//Get The BG Script Object if exists\r\n\tCKBehavior* newBG = NULL;\r\n\tCKBehavior* curBG = (CKBehavior*)behaviour->GetLocalParameterObject(EBGWRAPPERPARAM_PARAMETER_SCRIPT);\r\n\r\n\t// Get the BG nms file path. GetStringValue doesn't work with setting...\r\n\tchar fileName[_MAX_PATH+1];\r\n\tmemset(fileName,0,_MAX_PATH+1);\r\n\tCKParameter* scriptPath = behaviour->GetLocalParameter(EBGWRAPPERPARAM_PARAMETER_NAME);\r\n\tif ( scriptPath == NULL )\r\n\t\treturn CKBR_OK;\r\n\t\r\n\tint lenPath = scriptPath->GetDataSize();\r\n\tif ( lenPath >= _MAX_PATH )\r\n\t\treturn CKBR_OK;\r\n\t\r\n\tvoid*ptrPath = scriptPath->GetReadDataPtr(TRUE);\r\n\tif ( ptrPath == NULL )\r\n\t\treturn CKBR_OK;\r\n\t\r\n\tmemcpy(fileName,ptrPath,lenPath);\r\n\r\n\tCKDWORD message = behContext.CallbackMessage;\r\n\r\n\tswitch (message)\r\n\t\t{\r\n\t\tcase CKM_BEHAVIORLOAD :\t\t\t\t// when the behavior is loaded\r\n\t\tcase CKM_BEHAVIORRESET:\t\t\t\t// when the behavior is reseted\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED :\t// when the settings are edited\r\n\t\t\t{\r\n\t\t\t\tif ( curBG != NULL )\r\n\t\t\t\t{\r\n\t\t\t\t\tDestroyCurrentBG(level,behaviour,curBG);\r\n\t\t\t\t\tcurBG = NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tnewBG = BGLoader( fileName, behContext );\r\n\t\t\t\tif ( newBG == NULL )\r\n\t\t\t\t\treturn CKBR_OK;\r\n\t\t\t\t\r\n\t\t\t\tif ( message == CKM_BEHAVIORLOAD || message == CKM_BEHAVIORRESET )\r\n\t\t\t\t{\r\n\t\t\t\t\t//context->OutputToConsoleExBeep(\"%s : LOADED %s\",behaviour->GetName(), fileName);\r\n\t\t\t\t\tif ( CheckIO(behaviour, newBG) == TRUE )\r\n\t\t\t\t\t\tresult = CKBR_OK;\r\n\t\t\t\t\telse\t\r\n\t\t\t\t\t\tcontext->OutputToConsoleExBeep(\"%s : Too many inputs/outputs changes in %s\\r\\nPlease reconstruct the wrapper.\",behaviour->GetName(), fileName);\r\n\t\t\t\t}\r\n\t\t\t\telse if ( message == CKM_BEHAVIORSETTINGSEDITED )\r\n\t\t\t\t{\r\n\t\t\t\t\tif ( CheckIO(behaviour, newBG) == TRUE )\r\n\t\t\t\t\t{\t\t\t\t\t\r\n\t\t\t\t\t\tresult = CKBR_OK;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if (DeleteIO(behaviour) == TRUE)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( CreateIO(behaviour, newBG ) == TRUE )\r\n\t\t\t\t\t\t\tresult = CKBR_OK;\r\n\t\t\t\t\t\telse\t\r\n\t\t\t\t\t\t\tcontext->OutputToConsoleExBeep(\"%s : Cannot Create Inputs/Outputs %s\",behaviour->GetName(), fileName);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tcontext->OutputToConsoleExBeep(\"%s : Cannot Delete Inputs/Outputs %s\",behaviour->GetName(), fileName);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif ( result == CKBR_OK && newBG != NULL )\r\n\t\t\t\t\tSetNewBG(behaviour,newBG);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\r\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\r\n\t\t\t{\r\n\t\t\t\tif ( curBG != NULL )\r\n\t\t\t\t\tDesactivateSubBB(curBG);\r\n\t\t\t\tresult = CKBR_OK;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\r\n\t\tcase CKM_BEHAVIORDETACH : // when the behavior is deleted\r\n\t\t\t{\r\n\t\t\t\tif (curBG != NULL)\r\n\t\t\t\t{\r\n\t\t\t\t\tDestroyCurrentBG(level,behaviour,curBG);\r\n\t\t\t\t\tcurBG = NULL;\r\n\t\t\t\t}\r\n\t\t\t\tresult = CKBR_OK;\r\n\t\t\t}\r\n\t\t\tbreak;\t\t\t\t\r\n\t\t\r\n\t\tdefault: \r\n\t\t\t{\r\n\t\t\t\tresult = CKBR_OK;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\t\t\r\n\tif (result != CKBR_OK)\r\n\t\tcontext->OutputToConsoleExBeep(\"%s : Problem while manipulating\",behaviour->GetName());\r\n\r\n\r\n\r\n\treturn result;\r\n\t}\r\n\r\n\r\n /*\r\n *******************************************************************\r\n * Function: CKBehavior* BGLoader(CKSTRING fileName,const CKBehaviorContext& behContext)\r\n *\r\n * Description : Load a virtools script.and add it to the current level.\r\n *\r\n * Parameters :\r\n * fileName\t\t\t\t string containing\tthe script filename to be loaded.\r\n * behaviourContext\t Behavior context reference, which gives access to \r\n * frequently used global objects ( context, level, manager, etc... )\r\n *\r\n * Returns : CKBehavior* the loaded behaviour, NULL if failed.\r\n *\r\n *******************************************************************\r\n */\r\nCKBehavior* BGWrapper::BGLoader(CKSTRING fileName,const CKBehaviorContext& behContext)\r\n{\r\n\tCKERROR\tresult = CKBR_GENERICERROR;\r\n\r\n\t// Initialize common pointers.\t\r\n\tCKBehavior *behaviour = behContext.Behavior;\r\n\tCKContext *context = behContext.Context;\r\n\tCKLevel *level = behContext.CurrentLevel;\r\n\tCKBeObject *owner = behContext.Behavior->GetOwner();\r\n\r\n\tif ( behaviour == NULL || context == NULL || level == NULL )\r\n\t\treturn NULL;\r\n\t\r\n\tchar fileToLoad[_MAX_PATH],nakedFileName[_MAX_PATH];\r\n\tchar drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];\r\n\t_splitpath(fileName, drive, dir, fname, ext);\r\n\r\n\tif ( ext[0] == 0 )\r\n\t\tstrcpy(ext,\".nms\");\r\n\r\n\tstrcpy(fileToLoad,drive);\r\n\tstrcat(fileToLoad,dir);\r\n\tstrcat(fileToLoad,fname);\r\n\tstrcat(fileToLoad,ext);\r\n\r\n\tif ( strcmp(_strlwr(ext),\".nms\") != 0 ) \r\n\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : Can only load .nms files %s\",fileToLoad);\r\n\t\treturn NULL;\r\n\t}\r\n\t\r\n\tCKObjectArray* array = CreateCKObjectArray();\r\n\r\n\tcontext->SetAutomaticLoadMode(CKLOAD_OK, CKLOAD_OK, CKLOAD_USECURRENT, CKLOAD_USECURRENT);\r\n\r\n\t// Virtools Load the BGs nms file.first try the absolute path, then the lastCmoloaded path, and then the PathManager manager data paths\r\n\tif (context->Load(fileToLoad, array, (CK_LOAD_FLAGS)(CK_LOAD_AUTOMATICMODE | CK_LOAD_AS_DYNAMIC_OBJECT )) != CK_OK)\r\n\t{\r\n\t\tstrcpy(nakedFileName,fname);\r\n\t\tstrcat(nakedFileName,ext);\r\n\r\n\t\tCKSTRING lastCmo = context->GetLastCmoLoaded();\r\n\t\tchar driveCmo[_MAX_DRIVE], dirCmo[_MAX_DIR], fnameCmo[_MAX_FNAME], extCmo[_MAX_EXT];\r\n\t\t_splitpath(lastCmo, driveCmo, dirCmo, fnameCmo, extCmo);\r\n\r\n\t\tstrcpy(fileToLoad,driveCmo);strcat(fileToLoad,dirCmo);strcat(fileToLoad,nakedFileName);\r\n\r\n\t\tif (context->Load(fileToLoad, array, (CK_LOAD_FLAGS)(CK_LOAD_AUTOMATICMODE | CK_LOAD_AS_DYNAMIC_OBJECT )) != CK_OK)\r\n\t\t{\r\n\t\t\t// failed then try to go thru the data path.\r\n\t\t\tCKPathManager* pathmanager = behContext.Context->GetPathManager();\r\n\t\t\tif (!pathmanager) \r\n\t\t\t{\r\n\t\t\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : Cannot find the Path Manager\");\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\r\n\t\t\tXString resolved(nakedFileName);\r\n\t\t\tarray->Clear();\r\n\t\t\tpathmanager->ResolveFileName(resolved,DATA_PATH_IDX,-1);\r\n\t\t\tif (context->Load(resolved.Str(), array, (CK_LOAD_FLAGS)(CK_LOAD_AUTOMATICMODE | CK_LOAD_AS_DYNAMIC_OBJECT )) != CK_OK)\r\n\t\t\t{\r\n\t\t\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : Cannot Load %s\", nakedFileName);\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t}\r\n\r\n\t// Check if only one Object is loaded (we should have only one BG here)\r\n\tif ( array->GetCount() != 1 )\r\n\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : To many objects inside the nms %s.It should contain one BG only.\",fileToLoad);\r\n\r\n\t\tlevel->BeginRemoveSequence(TRUE);\r\n\t\tfor (array->Reset(); !array->EndOfList(); array->Next()) \r\n\t\t{\r\n\t\t\tCKObject* curObject = array->GetData(context);\r\n\t\t\tlevel->RemoveObject(curObject);\r\n\t\t\tCKDestroyObject(curObject);\r\n\t\t}\r\n\t\tlevel->BeginRemoveSequence(FALSE);\t\t\r\n\t\tDeleteCKObjectArray(array);\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tarray->Reset();\r\n\tCKObject* curObject = array->GetData(context);\r\n\t\r\n\tif ( curObject == NULL )\r\n\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : Object NULL in loaded array.\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t// Make it not to be saved even if it is loaded as dynamic... (not needed ?)\r\n\tcurObject->ModifyObjectFlags( CK_OBJECT_NOTTOBESAVED,0 );\r\n\t\r\n\t// Check if the object we've loaded is derivated from the BEHAVIOR\r\n\tif ( !CKIsChildClassOf(curObject, CKCID_BEHAVIOR) )\r\n\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : no behavior in the nms : %s\",fileToLoad);\r\n\r\n\t\tlevel->BeginRemoveSequence(TRUE);\r\n\t\tlevel->RemoveObject(curObject);\r\n\t\tlevel->BeginRemoveSequence(FALSE);\t\t\r\n\t\tCKDestroyObject(curObject);\r\n\t\tDeleteCKObjectArray(array);\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCKBehavior*pBG = (CKBehavior*)curObject;\r\n\r\n\t// Check if the behavior we've loaded is a BG and not a BB.\r\n\tif ( pBG->IsUsingFunction() )\r\n\t{\r\n\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : BGWrapper accepts only a BG not a BB : %s\",fileToLoad);\r\n\r\n\t\tlevel->BeginRemoveSequence(TRUE);\r\n\t\tlevel->RemoveObject(curObject);\r\n\t\tlevel->BeginRemoveSequence(FALSE);\t\t\r\n\t\tCKDestroyObject(curObject);\r\n\t\tDeleteCKObjectArray(array);\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t// Check if the BG can be applied to the 's BeObject owner.\r\n\tchar*nameee = pBG->GetName();\r\n\tCK_CLASSID cid = pBG->GetCompatibleClassID();\r\n\t\r\n\t\r\n\tif (owner!=NULL)\r\n\t\tif ( !CKIsChildClassOf(owner, pBG->GetCompatibleClassID()) )\r\n\t\t{\r\n\t\t\tcontext->OutputToConsoleExBeep(\"BGWrapper : Incompatible Class, cannot add BG to script %s\",fileToLoad);\r\n\r\n\t\t\tlevel->BeginRemoveSequence(TRUE);\r\n\t\t\tlevel->RemoveObject(curObject);\r\n\t\t\tlevel->BeginRemoveSequence(FALSE);\t\t\r\n\t\t\tCKDestroyObject(curObject);\r\n\t\t\tDeleteCKObjectArray(array);\r\n\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t// Add the BG to the 's level.\r\n\tlevel->BeginAddSequence(TRUE);\r\n\tlevel->AddObject(curObject);\r\n\tlevel->BeginAddSequence(FALSE);\r\n\tDeleteCKObjectArray(array);\r\n\r\n\tif (owner!=NULL)\r\n\t\tOwnerSubBB(pBG,owner);\r\n\r\n\treturn pBG;\r\n}\r\n\r\n\r\n /*\r\n *******************************************************************\r\n * Function: BOOL CheckIO(CKBehavior* behaviour, CKBehavior* script)\r\n *\r\n * Description : Check if all the Inputs,Outputs, pIns and pOuts of both behavior are matching\r\n *\r\n * Parameters :\r\n * behaviour\t\t Behavior 1, usually the BG wrapper BB.\r\n * script\t Behavior 2, usually the wrapped BG.\r\n *\r\n * Returns : BOOL\r\n *\r\n *******************************************************************\r\n */\r\nBOOL BGWrapper::CheckIO(CKBehavior* behaviour, CKBehavior* script)\r\n\t{\r\n\tint\t\tiParam;\r\n\tint\t\tnbPin0, nbPin1;\r\n\tint\t\tflag = 0;\r\n\t\r\n\t// Input\r\n\tnbPin0 = behaviour->GetInputCount();\r\n\tnbPin1 = script->GetInputCount();\r\n\tif (nbPin0 != nbPin1)\r\n\t\treturn FALSE;\r\n\r\n\t// Ouput\r\n\tnbPin0 = behaviour->GetOutputCount();\r\n\tnbPin1 = script->GetOutputCount();\r\n\tif (nbPin0 != nbPin1)\r\n\t\treturn FALSE;\r\n\r\n\t// Parameter In\r\n\tnbPin0 = behaviour->GetInputParameterCount();\r\n\tnbPin1 = script->GetInputParameterCount();\r\n\tif (nbPin0 != nbPin1)\r\n\t\treturn FALSE;\r\n\tfor (iParam = 0; iParam < nbPin0; iParam++)\r\n\t\t{\r\n\t\tCKParameterIn* pSin = script->GetInputParameter(iParam);\r\n\t\tCKParameterIn* pBin = behaviour->GetInputParameter(iParam);\r\n\t\tif (pSin == NULL || pBin == NULL)\r\n\t\t\treturn FALSE;\r\n\t\tif (pSin->GetType() != pBin->GetType())\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Parameter Out\r\n\tnbPin0 = behaviour->GetOutputParameterCount();\r\n\tnbPin1 = script->GetOutputParameterCount();\r\n\tif (nbPin0 != nbPin1)\r\n\t\treturn FALSE;\r\n\tfor (iParam = 0; iParam < nbPin0; iParam++)\r\n\t\t{\r\n\t\tCKParameterOut* pSout = script->GetOutputParameter(iParam);\r\n\t\tCKParameterOut* pBout = behaviour->GetOutputParameter(iParam);\r\n\t\tif (pSout == NULL || pBout == NULL)\r\n\t\t\treturn FALSE;\r\n\t\tif (pSout->GetType() != pBout->GetType())\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\treturn TRUE;\r\n\t}\r\n\r\n\r\n /*\r\n *******************************************************************\r\n * Function: BOOL\t:CreateIO(CKBehavior* behaviour, CKBehavior* script)\r\n *\r\n * Description : Check if all the Inputs,Outputs, pIns and pOuts of both behavior are matching\r\n *\r\n * Parameters :\r\n * behaviour\t\t Behavior 1, usually the BG wrapper BB.\r\n * script\t Behavior 2, usually the wrapped BG.\r\n *\r\n * Returns : BOOL\r\n *\r\n *******************************************************************\r\n */\r\nBOOL\tBGWrapper::CreateIO(CKBehavior* behaviour, CKBehavior* script)\r\n\t{\r\n\tint\t\tiIO;\r\n\tint\t\tnbPin;\r\n\t\r\n\t// Input\r\n\tnbPin = script->GetInputCount();\r\n\tfor (iIO = 0; iIO < nbPin; iIO++)\r\n\t\t{\r\n\t\tCKBehaviorIO* pPin = script->GetInput(iIO);\r\n\t\tif (pPin == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t\r\n\t\tif (behaviour->AddInput(pPin->GetName()) != iIO)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Output\r\n\tnbPin = script->GetOutputCount();\r\n\tfor (iIO = 0; iIO < nbPin; iIO++)\r\n\t\t{\r\n\t\tCKBehaviorIO* pPin = script->GetOutput(iIO);\r\n\t\tif (pPin == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t\r\n\t\tif (behaviour->AddOutput(pPin->GetName()) != iIO)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Parameter In\r\n\tnbPin = script->GetInputParameterCount();\r\n\tfor (iIO = 0; iIO < nbPin; iIO++)\r\n\t\t{\r\n\t\tCKParameterIn* pPin = script->GetInputParameter(iIO);\r\n\t\tif (pPin == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t\r\n\t\tCKParameterIn* pPin2;\r\n\t\tif ((pPin2 = behaviour->CreateInputParameter(pPin->GetName(), (CKParameterType)pPin->GetType())) == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Parameter Out\r\n\tnbPin = script->GetOutputParameterCount();\r\n\tfor (iIO = 0; iIO < nbPin; iIO++)\r\n\t\t{\r\n\t\tCKParameterOut* pPin = script->GetOutputParameter(iIO);\r\n\t\tif (pPin == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t\r\n\t\tif (behaviour->CreateOutputParameter(pPin->GetName(), (CKParameterType)pPin->GetType()) == NULL)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\treturn TRUE;\r\n\t}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: BOOL\tDeleteIO(CKBehavior* behaviour)\r\n *\r\n * Description : Delete all kind of inputs/outputs on the given behavior\r\n *\r\n * Parameters :\r\n * behaviour\t\t The behavior to be naked on.\r\n *\r\n * Returns : BOOL\r\n *\r\n *******************************************************************\r\n */\r\nBOOL\tBGWrapper::DeleteIO(CKBehavior* behaviour)\r\n\t{\r\n\tint\t\tiIO;\r\n\tint\t\tnbPin0;\r\n\t\r\n\t// Input\r\n\tnbPin0 = behaviour->GetInputCount();\r\n\tfor (iIO = nbPin0-1; iIO >= 0; iIO--)\r\n\t\t{\r\n\t\tif (behaviour->DeleteInput(iIO) != CK_OK)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Ouput\r\n\tnbPin0 = behaviour->GetOutputCount();\r\n\tfor (iIO = nbPin0-1; iIO >= 0; iIO--)\r\n\t\t{\r\n\t\tif (behaviour->DeleteOutput(iIO) != CK_OK)\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t// Parameter In\r\n\tnbPin0 = behaviour->GetInputParameterCount();\r\n\tfor (iIO = nbPin0-1; iIO >= 0; iIO--)\r\n\t\t{\r\n\t\tCKParameterIn* pParam;\r\n\r\n\t\tif ((pParam = behaviour->RemoveInputParameter(iIO)) == NULL)\r\n\t\t\treturn FALSE;\r\n\t\tCKDestroyObject(pParam);\r\n\t\t}\r\n\r\n\t// Parameter Out\r\n\tnbPin0 = behaviour->GetOutputParameterCount();\r\n\tfor (iIO = nbPin0-1; iIO >= 0; iIO--)\r\n\t\t{\r\n\t\tCKParameterOut* pParam;\r\n\t\tif ((pParam = behaviour->RemoveOutputParameter(iIO)) == NULL)\r\n\t\t\treturn FALSE;\r\n\t\tCKDestroyObject(pParam);\r\n\t\t}\r\n\r\n\treturn TRUE;\r\n\t}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: BOOL\tHasIO(CKBehavior* behaviour)\r\n *\r\n * Description : return TRUE if the behavior has almost one IN/OU/PIN/POUT\r\n *\r\n * Parameters :\r\n * behaviour\t\t The behavior to be checked.\r\n *\r\n * Returns : BOOL\r\n *\r\n *******************************************************************\r\n */\r\n\r\nBOOL\tBGWrapper::HasIO(CKBehavior* behaviour)\r\n\t{\r\n\t// Input\r\n\tif (behaviour->GetInputCount())\r\n\t\treturn TRUE;\r\n\r\n\t// Ouput\r\n\tif (behaviour->GetOutputCount())\r\n\t\treturn TRUE;\r\n\r\n\t// Parameter In\r\n\tif (behaviour->GetInputParameterCount())\r\n\t\treturn TRUE;\r\n\r\n\t// Parameter Out\r\n\tif (behaviour->GetOutputParameterCount())\r\n\t\treturn TRUE;\r\n\r\n\treturn FALSE;\r\n\t}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: void ActivateNextFrameSubBB(CKBehavior* scriptObject,BOOL &bActivateNextFrame)\r\n *\r\n * Description : set the bActivateNextFrame to TRUE if one sub behavior is still active.\r\n *\r\n * Parameters :\r\n * scriptObject\t The behavior to be checked.\r\n *\r\n * Returns : void\r\n *\r\n *******************************************************************\r\n */\r\nvoid BGWrapper::ActivateNextFrameSubBB(CKBehavior* scriptObject,BOOL &bActivateNextFrame)\r\n{\r\n\tif ( scriptObject == NULL ) \r\n\t\treturn;\r\n\t\r\n\tif ( scriptObject->IsActive() )\r\n\t{\r\n\t\tbActivateNextFrame = TRUE;\r\n\t\treturn;\r\n\t}\r\n\r\n\tfor ( int i = 0; i < scriptObject->GetSubBehaviorCount(); i++)\r\n\t{\r\n\t\tCKBehavior*scriptSub = scriptObject->GetSubBehavior(i);\r\n\t\tActivateNextFrameSubBB(scriptSub,bActivateNextFrame);\r\n\t}\r\n}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: void DesactivateSubBB(CKBehavior* scriptObject)\r\n *\r\n * Description : Desactivate all sub-Behavior\r\n *\r\n * Parameters :\r\n * scriptObject\t The behavior to be totally desactivated.\r\n *\r\n * Returns : void\r\n *\r\n *******************************************************************\r\n */\r\nvoid BGWrapper::DesactivateSubBB(CKBehavior* scriptObject)\r\n{\r\n\tif ( scriptObject == NULL ) \r\n\t\treturn;\r\n\t\r\n\tscriptObject->Activate(FALSE,TRUE);\r\n\r\n\tfor ( int i = 0; i < scriptObject->GetSubBehaviorCount(); i++)\r\n\t{\r\n\t\tCKBehavior*scriptSub = scriptObject->GetSubBehavior(i);\r\n\t\tDesactivateSubBB(scriptSub);\r\n\t}\r\n}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: void OwnerSubBB(CKBehavior* scriptObject,CKBeObject*owner)\r\n *\r\n * Description : Set Owner ptr to all sub-Behavior.\r\n *\r\n * Parameters :\r\n * scriptObject\t behavior to be parsed.\r\n * owner owner to be assigned.\r\n *\r\n * Returns : void\r\n *\r\n *******************************************************************\r\n */\r\nvoid BGWrapper::OwnerSubBB(CKBehavior* scriptObject,CKBeObject*owner)\r\n{\r\n\tif ( scriptObject == NULL ) \r\n\t\treturn;\r\n\t\r\n\tscriptObject->SetSubBehaviorOwner(owner);\r\n\tscriptObject->SetOwner(owner);\r\n\r\n\tfor ( int i = 0; i < scriptObject->GetSubBehaviorCount(); i++)\r\n\t{\r\n\t\tCKBehavior*scriptSub = scriptObject->GetSubBehavior(i);\r\n\t\tOwnerSubBB(scriptSub,owner);\r\n\t}\r\n}\r\n\r\n /*\r\n *******************************************************************\r\n * Function: void\tSetNewBG(CKBehavior *behaviour,CKBehavior *newBehavior)\r\n *\r\n * Description : Set new BB name and store the BG locally.\r\n *\r\n * Parameters :\r\n * behaviour\t\t\tBG wrapper BB\r\n * newBehavior BG assigned to the wrapper\r\n *\r\n * Returns : void\r\n *\r\n *******************************************************************\r\n */\r\nvoid\tBGWrapper::SetNewBG(CKBehavior *behaviour,CKBehavior *newBehavior)\r\n{\r\n\tif ( behaviour == NULL || newBehavior == NULL )\r\n\t\treturn;\r\n\r\n\tCKSTRING nameBG = newBehavior->GetName();\r\n\tsize_t len = strlen(nameBG);\r\n\tchar*buf = (char*)malloc(len+128);\r\n\tif ( buf != NULL )\r\n\t{\r\n\t\tsprintf(buf, \"BI(%s)\", newBehavior->GetName());\r\n\t\tbehaviour->SetName(buf);\r\n\t\tfree(buf);\r\n\t}\r\n\telse\r\n\t\tbehaviour->SetName(\"BI(###ERROR###)\");\r\n\r\n\tbehaviour->SetLocalParameterObject(EBGWRAPPERPARAM_PARAMETER_SCRIPT,newBehavior);\r\n}\r\n\r\n/*\r\n *******************************************************************\r\n * Function: void\tDestroyCurrentBG(CKLevel* level,CKBehavior *behaviour,CKBehavior *scriptObject)\r\n *\r\n * Description : Destroy the currently wrapped BG\r\n *\r\n * Parameters :\r\n * level level from witch the BG will be removed\r\n * behaviour\t\t BG wrapper BB.\r\n * scriptObject BG assigned to the wrapper.\r\n *\r\n * Returns : void\r\n *\r\n *******************************************************************\r\n */\r\nvoid\tBGWrapper::DestroyCurrentBG(CKLevel* level,CKBehavior *behaviour,CKBehavior *scriptObject)\r\n{\r\n\tif ( level == NULL || behaviour == NULL || scriptObject == NULL )\r\n\t\treturn;\r\n\r\n\tbehaviour->SetName(\"BI(###Failed###)\");\r\n\r\n\tlevel->BeginRemoveSequence(TRUE);\r\n\tlevel->RemoveObject(scriptObject);\r\n\tlevel->BeginRemoveSequence(FALSE);\t\t\r\n\tCKDestroyObject(scriptObject);\r\n\t\r\n\tbehaviour->SetLocalParameterObject(EBGWRAPPERPARAM_PARAMETER_SCRIPT,NULL);\r\n\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n#include \"Bind.h\"\r\n\r\nPhysicManager *ourMan = NULL;\r\n\r\ntypedef ForceMode PForceMode;\r\ntypedef D6MotionMode PJMotion;\r\ntypedef D6DriveType PDriveType;\r\n\r\n//\ta\t{d1=35549095 d2=1877427728 d=0x0012fc9c }\tCKGUID\r\n\r\n#define BEH_GUID_VSL CKGUID(35549095,1877427728)\r\n\r\n\r\nCKGUID getGuidByID(int op)\r\n{\r\n\r\n\tCKBeObject *obj = (CKBeObject*)GetPMan()->GetContext()->GetObject(op);\r\n\r\n\tCKGUID a;\r\n\tif (obj)\r\n\t{\r\n\t\tCKBehavior *beh = (CKBehavior*)(obj);\r\n\t\tif (beh)\r\n\t\t{\r\n\t\t\ta = beh->GetPrototypeGuid();\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\r\nreturn CKGUID();\r\n\r\n}\r\n\r\n\r\nint doVSLScript(int vslBehID)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// our script, simple addition of two inputs\r\n\t//\r\n\tXString vslScript;\r\n\tvslScript << \"void main(){ c = a + b; }\" ;\r\n\t\r\n\t\r\n\tint result = 0;\r\n\r\n\r\n\r\n\tCKBehaviorIO *scriptIn;\r\n\t//sprintf(tmpName,\"%s-beh\",NameChar);\r\n\r\n\t/*\r\n\tCKBehavior *MyScript = (CKBehavior *) ctx()->CreateObject(CKCID_BEHAVIOR,\"MyScript\");\r\n\r\n\tMyScript->SetType(CKBEHAVIORTYPE_SCRIPT);\r\n\tscriptIn=MyScript->CreateInput(\"Start\");\r\n\tMyScript->UseGraph();\r\n\tMyScript->SetCompatibleClassID(CKCID_BEOBJECT);\r\n\t*/\r\n\r\n\t\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// create script\r\n\t//\r\n\t//CK_OBJECTCREATION_OPTIONS crOptions = CK_OBJECTCREATION_DYNAMIC;\r\n\t//CKBehavior *script = (CKBehavior *)ctx()->CreateObject(CKCID_BEHAVIOR,NULL,CK_OBJECTCREATION_DYNAMIC);\r\n\tCKBehavior *script = (CKBehavior *)ctx()->GetObject(vslBehID);\r\n\t//CKERROR error\t=\tscript->InitFromGuid(BEH_GUID_VSL);\r\n\t\r\n\t// create ins/outs\r\n\t//\r\n\tscript->CreateInputParameter(\"a\",CKPGUID_INT);\r\n\tscript->CreateInputParameter(\"b\",CKPGUID_INT);\r\n\r\n\tscript->CreateOutputParameter(\"c\",CKPGUID_INT);\r\n\t\r\n\tscript->SetName(\"Created_Rotate\");\r\n\r\n\t//script->SetAsTargetable();\r\n\t//script->UseTarget();\r\n\r\n\t//error= MyScript->AddSubBehavior(script);\r\n\t//ctx()->GetCurrentLevel()->AddObject(MyScript);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// activate RunVSL Settings \"Run-Time Script Change\"\r\n\t//\r\n\tbool dynaFlag=true;\r\n\t\r\n\t//script->SetLocalParameterValue(0,&dynaFlag);\r\n\t//script->SetLocalParameterValue(1,&dynaFlag);\r\n\r\n\tint count = script->GetInputParameterCount();\r\n\tint lcount = script->GetLocalParameterCount();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Pass the script content\r\n\t//\r\n\tvtTools::BehaviorTools::SetInputParameterValue(script,0,vslScript.Str());\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Pass arguments\r\n\t//\r\n\tvtTools::BehaviorTools::SetInputParameterValue(script,1,10);\r\n\tvtTools::BehaviorTools::SetInputParameterValue(script,2,11);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// execute\r\n\t//\r\n\tscript->Execute(0.5f);\r\n\tresult = vtTools::BehaviorTools::GetOutputParameterValue(script,0);\r\n\r\n\t/*\r\n\tCKFile* file = ctx()->CreateCKFile();\r\n\t\r\n\tfile->StartSave(\"c:\\\\1.nms\");\r\n\tfile->SaveObject((CKObject *) MyScript);\r\n\tfile->EndSave();\r\n\tctx()->DeleteCKFile(file);\r\n\t*/\r\n\r\n\r\n\treturn result;\r\n \r\n}\r\n\r\n\r\n\r\npRigidBody *getBody(CK3dEntity*ent){\r\n\tpRigidBody *body = GetPMan()->getBody(ent);\r\n\tif (body)\r\n\t{\r\n\t\treturn body;\r\n\t}else{\r\n\t\treturn NULL;\r\n\t}\r\n}\r\n\r\nvoid __newpSpring(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pSpring();\r\n}\r\nvoid __newpSoftLimit(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJD6SoftLimit();\r\n}\r\n\r\nvoid __newpDrive(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJD6Drive();\r\n}\r\nvoid __newpJointLimit(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJointLimit();\r\n}\r\n\r\nvoid __newpMotor(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pMotor();\r\n}\r\n\r\n\r\npSerializer *GetSerializer()\r\n{\r\n\treturn pSerializer::Instance();\r\n}\r\n\r\n\r\n\r\nvoid __newpClothDescr(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pClothDesc();\r\n}\r\n\r\n#define TESTGUID CKGUID(0x2c5c47f6,0x1d0755d9)\r\n\r\n\r\nvoid PhysicManager::_RegisterVSL()\r\n{\r\n\tourMan = GetPMan();\r\n\r\n\t\r\n\t_RegisterVSLCommon();\r\n\t_RegisterVSLVehicle();\r\n\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\t\tDECLAREFUN_C_1(CKGUID,getGuidByID,int)\r\n\r\n\t\tDECLAREFUN_C_1(int,doVSLScript,int)\r\n\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\r\n\t\tDECLAREENUM(\"pClothAttachmentFlag\")\r\n\t\tDECLAREENUMVALUE(\"pClothAttachmentFlag\", \"PCAF_ClothAttachmentTwoway\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"pClothAttachmentFlag\", \"PCAF_ClothAttachmentTearable\" ,2 )\r\n\r\n\t\tDECLAREENUM(\"pClothFlag\")\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Pressure\" ,1 )\r\n\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Static\",2)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_DisableCollision\",4)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_SelfCollision\",8)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Gravity\",32)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Bending\",64)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_BendingOrtho\",128)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Damping\",256)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_CollisionTwoway\",512)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_TriangleCollision\",2048)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Tearable\",4096)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Hardware\",8192)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_ComDamping\",16384)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_ValidBounds\",32768)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_FluidCollision\",65536)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_DisableDynamicCCD\",131072)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AddHere\",262144)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToParentMainShape\",524288)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToCollidingShapes\",1048576)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToCore\",2097152)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachAttributes\",4194304)\r\n\r\n\r\n\t\r\n\t\t\t\t\r\n\r\n\r\n\t\tDECLAREOBJECTTYPE(pClothDesc)\r\n\t\t\r\n\t\tDECLAREMEMBER(pClothDesc,float,thickness)\r\n\t\tDECLAREMEMBER(pClothDesc,float,density)\r\n\t\tDECLAREMEMBER(pClothDesc,float,bendingStiffness)\r\n\r\n\t\tDECLAREMEMBER(pClothDesc,float,stretchingStiffness)\r\n\t\tDECLAREMEMBER(pClothDesc,float,dampingCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,friction)\r\n\t\tDECLAREMEMBER(pClothDesc,float,pressure)\r\n\t\tDECLAREMEMBER(pClothDesc,float,tearFactor)\r\n\t\tDECLAREMEMBER(pClothDesc,float,collisionResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,attachmentResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,attachmentTearFactor)\r\n\t\tDECLAREMEMBER(pClothDesc,float,toFluidResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,fromFluidResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,minAdhereVelocity)\r\n\t\tDECLAREMEMBER(pClothDesc,int,solverIterations)\r\n\t\tDECLAREMEMBER(pClothDesc,VxVector,externalAcceleration)\r\n\t\tDECLAREMEMBER(pClothDesc,VxVector,windAcceleration)\r\n\t\tDECLAREMEMBER(pClothDesc,float,wakeUpCounter)\r\n\t\tDECLAREMEMBER(pClothDesc,float,sleepLinearVelocity)\r\n\t\tDECLAREMEMBER(pClothDesc,int,collisionGroup)\r\n\t\tDECLAREMEMBER(pClothDesc,VxBbox,validBounds)\r\n\t\tDECLAREMEMBER(pClothDesc,float,relativeGridSpacing)\r\n\t\tDECLAREMEMBER(pClothDesc,pClothFlag,flags)\r\n\t\tDECLAREMEMBER(pClothDesc,pClothAttachmentFlag,attachmentFlags)\r\n\t\tDECLAREMEMBER(pClothDesc,VxColor,tearVertexColor)\r\n\t\tDECLAREMEMBER(pClothDesc,CK_ID,worldReference)\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pClothDesc,void,setToDefault)\r\n\t\tDECLARECTOR_0(__newpClothDescr)\r\n\r\n\r\n\r\n\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\t\t\t\tVehicle : \r\n\t//\r\n\r\n\tDECLAREMETHOD_1(PhysicManager,pVehicle*,getVehicle,CK3dEntity*)\r\n\tDECLAREMETHOD_1(PhysicManager,pWheel2*,getWheel,CK3dEntity*)\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tBindings for pVehicle related classes : \r\n\t//\r\n\t//\r\n\r\n\r\n\t\r\n\t\r\n\t\r\n\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREOBJECTTYPE(pJointLimit)\r\n\t\tDECLARECTOR_0(__newpJointLimit)\r\n\t\tDECLAREMEMBER(pJointLimit,float,hardness)\r\n\t\tDECLAREMEMBER(pJointLimit,float,restitution)\r\n\t\tDECLAREMEMBER(pJointLimit,float,value)\r\n\r\n\t\tDECLAREOBJECTTYPE(pJD6Drive)\r\n\t\tDECLARECTOR_0(__newpDrive)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,damping)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,spring)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,forceLimit)\r\n\t\tDECLAREMEMBER(pJD6Drive,int,driveType)\r\n\r\n\t\tDECLAREOBJECTTYPE(pJD6SoftLimit)\r\n\t\tDECLARECTOR_0(__newpSoftLimit)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,damping)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,spring)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,value)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,restitution)\r\n\r\n\r\n\t\tDECLAREOBJECTTYPE(pSpring)\r\n\t\tDECLARECTOR_0(__newpSpring)\r\n\t\t//DECLARECTOR_3(__newpSpringSettings3,float,float,float)\r\n\t\tDECLAREMEMBER(pSpring,float,damper)\r\n\t\tDECLAREMEMBER(pSpring,float,spring)\r\n\t\tDECLAREMEMBER(pSpring,float,targetValue)\r\n\r\n\t\tDECLAREOBJECTTYPE(pMotor)\r\n\t\tDECLARECTOR_0(__newpMotor)\r\n\t\tDECLAREMEMBER(pMotor,float,maximumForce)\r\n\t\tDECLAREMEMBER(pMotor,float,targetVelocity)\r\n\t\tDECLAREMEMBER(pMotor,float,freeSpin)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tSerializer : \r\n\t\t//\r\n\t\tDECLAREPOINTERTYPE(pSerializer)\r\n\t\tDECLAREFUN_C_0(pSerializer*, GetSerializer)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,overrideBody,pRigidBody*,int)\r\n\t\tDECLAREMETHOD_2(pSerializer,int,loadCollection,const char*,int)\r\n\t\tDECLAREMETHOD_1(pSerializer,int,saveCollection,const char*)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,parseFile,const char*,int)\r\n\r\n\r\n\t\t\r\n\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tFactory\r\n\t\t//\r\n\r\n\t\t\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tENUMERATION \r\n\t\t//\r\n\r\n\t\tDECLAREENUM(\"D6DriveType\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Position\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Velocity\" ,2 )\r\n\r\n\r\n\t\tDECLAREENUM(\"PForceMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Force\" , 0)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Impulse\" , 1)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_VelocityChange\" , 2)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothImpulse\" , 3)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothVelocityChange\" , 4)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Acceleration\" , 5)\r\n\t\t\r\n\t\tDECLAREENUM(\"D6MotionMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Locked\" , 0)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Limited\" , 1)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Free\" , 2)\r\n\r\n\t\tDECLAREENUM(\"JType\")\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Any\" , -1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Prismatic\" , 0)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Revolute\" , 1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Cylindrical\" , 2)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Spherical\" , 3)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointOnLine\" , 4)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointInPlane\" , 5)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Distance\" , 6)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Pulley\" , 7)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Fixed\" ,8 )\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_D6\" ,9 )\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_2(pFactory,pVehicle*,createVehicle,CK3dEntity*,pVehicleDesc)\r\n\t\t\r\n\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getWheelRollAngle)\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getRpm)\r\n\r\n\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT CREATION\r\n\t\t//\r\n\t\tDECLAREMETHOD_11_WITH_DEF_VALS(pFactory,pJointDistance*,createDistanceJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,VxVector(),VxVector,VxVector(),float,0.0f,float,0.0f,pSpring,pSpring(),BOOL,\"TRUE\",float,\"0.0\",float,\"0.0\",const char *,\"pJDistance\")\r\n\t\tDECLAREMETHOD_5(pFactory,pJointD6*,createD6Joint,CK3dEntity*,CK3dEntity*,VxVector,VxVector,bool)\r\n\t\t\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pFactory,pJointFixed*,createFixedJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,float,\"0.0\",float,\"0,0\",const char*,\"PJFixed\")\r\n\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pFactory,pRigidBody*,createBody,CK3dEntity*,NODEFAULT,pObjectDescr,NODEFAULT,CK3dEntity*,NULL)\r\n\t\t\r\n\t\tDECLAREMETHOD_2(pFactory,pRigidBody*,createRigidBody,CK3dEntity*,pObjectDescr&)\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,bool,loadMaterial,pMaterial&,const char*)\r\n\t\tDECLAREMETHOD_2(pFactory,pMaterial,loadMaterial,const char*,int&)\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,bool,loadFrom,pWheelDescr&,const char*)\r\n\t\tDECLAREMETHOD_5(pFactory,pWheel*,createWheel,CK3dEntity *,CK3dEntity*,pWheelDescr,pConvexCylinderSettings,VxVector)\r\n\r\n\t\tDECLAREMETHOD_9_WITH_DEF_VALS(pFactory,pJointPulley*,createPulleyJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,BOOL,\"TRUE\",float,\"0.0\",float,\"0.0\")\r\n\t\tDECLAREMETHOD_9_WITH_DEF_VALS(pFactory,pJointBall*,createBallJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,VxVector,\"0,0,1\",bool,\"TRUE\",float,\"0.0\",float,\"0.0\",const char*,\"pJBall\")\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointRevolute*,createRevoluteJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,bool,\"TRUE\",float,\"0.0\",float,\"0.0\",const char*,\"pJRevolute\")\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointPrismatic*,createPrismaticJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,bool,TRUE,float,\"0.0\",float,\"0.0\",const char*,\"pJPrismatic\")\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointCylindrical*,createCylindricalJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,bool,TRUE,float,\"0.0\",float,\"0.0\",,const char*,\"pJCylindrical\")\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointPointInPlane*,createPointInPlaneJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,bool,TRUE,float,\"0.0\",float,\"0.0\",const char*,\"pJPointInPlane\")\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointPointOnLine*,createPointOnLineJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,NODEFAULT,VxVector,NODEFAULT,bool,TRUE,float,\"0.0\",float,\"0.0\",const char*,\"pJPointOnLine\")\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,pCloth*,createCloth,CK3dEntity*,pClothDesc)\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tCloth\r\n\t\t//\r\n\t\tDECLAREMETHOD_4(pCloth,void,attachToCore,CK3dEntity*,float,float,float)\r\n\t\tDECLAREMETHOD_2(pCloth,void,attachToShape,CK3dEntity*,pClothAttachmentFlag)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tMANAGER\r\n\t\t//\r\n\t\t\r\n\t\t\r\n\t\tDECLAREMETHOD_0(PhysicManager,pWorld*,getDefaultWorld)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(PhysicManager,pRigidBody*,getBody,CK3dEntity*,NODEFAULT,bool,FALSE)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorldByBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorld,CK_ID)\r\n\t\tDECLAREMETHOD_1(PhysicManager,int,getAttributeTypeByGuid,CKGUID)\r\n\t\tDECLAREMETHOD_2(PhysicManager,void,copyToAttributes,pObjectDescr,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(CK3dEntity,CKBOOL,HasAttribute,int)\r\n\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(PhysicManager,pJoint*,getJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NULL,JType,JT_Any)\r\n\r\n//\t\tDECLAREMETHOD_0(PhysicManager,void,makeDongleTest)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tWorld\r\n\t\t//\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pWorld,pRigidBody*,getBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(pWorld,pVehicle*,getVehicle,CK3dEntity*)\r\n\t\tDECLAREMETHOD_3(pWorld,pJoint*,getJoint,CK3dEntity*,CK3dEntity*,JType)\r\n\r\n\t\tDECLAREMETHOD_3(pWorld,void,setFilterOps,pFilterOp,pFilterOp,pFilterOp)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterBool,bool)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant0,const pGroupsMask&)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant1,const pGroupsMask&)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pWorld,void,setGravity,VxVector)\r\n\t\tDECLAREMETHOD_0(pWorld,VxVector,getGravity)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t//\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pWorld,bool,raycastAnyBounds,const VxRay&,NODEFAULT,pShapesType,NODEFAULT,pGroupsMask,NODEFAULT,int,0xffffffff,float,NX_MAX_F32)\r\n\t\tDECLAREMETHOD_8(pWorld,bool,overlapSphereShapes,CK3dEntity*,const VxSphere&,CK3dEntity*,pShapesType,CKGroup*,int,const pGroupsMask*,BOOL)\r\n\r\n\t\t//(const VxRay& worldRay, pShapesType shapesType, pGroupsMask groupsMask,unsigned int groups=0xffffffff, float maxDist=NX_MAX_F32);\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pJoint,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJoint,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_0(pJoint,VxVector,getGlobalAxis)\r\n\t\tDECLAREMETHOD_0(pJoint,VxVector,getGlobalAnchor)\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT :: Revolute\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointRevolute*,castRevolute)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAnchor,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAxis,const VxVector&)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setLowLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setMotor,pMotor)\r\n\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getLowLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pMotor,getMotor)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: Ball\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointBall*,castBall)\r\n\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setAnchor,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setSwingLimitAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistLowLimit,pJointLimit)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getSwingLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistLowLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setJointSpring,pSpring)\r\n\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getSwingSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getTwistSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getJointSpring)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Prismatic\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPrismatic*,castPrismatic)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Cylindrical\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointCylindrical*,castCylindrical)\r\n\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,enableCollision,int)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointInPlane*,castPointInPlane)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointOnLine*,castPointOnLine)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT BASE \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_1(pJoint,void,setLocalAnchor0,VxVector)\r\n\r\n\t\tDECLAREMETHOD_2(pJoint,void,setBreakForces,float,float)\r\n\t\tDECLAREMETHOD_2(pJoint,void,getBreakForces,float&,float&)\r\n\t\tDECLAREMETHOD_3(pJoint,int,addLimitPlane,VxVector,VxVector,float)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pJoint,void,setLimitPoint,VxVector,NODEFAULT,bool,true)\r\n\t\tDECLAREMETHOD_0(pJoint,void,purgeLimitPlanes)\r\n\t\tDECLAREMETHOD_0(pJoint,void,resetLimitPlaneIterator)\r\n\t\tDECLAREMETHOD_0(pJoint,int,hasMoreLimitPlanes)\r\n\t\tDECLAREMETHOD_3(pJoint,int,getNextLimitPlane,VxVector&,float&,float&)\r\n\t\tDECLAREMETHOD_0(pJoint,int,getType)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: DISTANCE\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointDistance*,castDistanceJoint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMinDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMaxDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor0,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor1,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMinDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMaxDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor0)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor1)\r\n\t\tDECLAREMETHOD_0(pJointDistance,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT PULLEY\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPulley*,castPulley)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setStiffness,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRatio,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRigid,int)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setMotor,pMotor)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getStiffness)\r\n\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getRatio)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getDistance)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,enableCollision,bool)\r\n\t\tDECLAREMETHOD_0(pJointPulley,pMotor,getMotor)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\tJOINT D6\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointD6*,castD6Joint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setTwistMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing1MotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing2MotionMode,D6MotionMode)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setXMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setYMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setZMotionMode,D6MotionMode)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//softwLimits\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getLinearLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setLinearLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing1Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing1Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing2Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing2Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistHighLimit,pJD6SoftLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistLowLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistLowLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getXDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setXDrive,pJD6Drive)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getYDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setYDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getZDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setZDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSwingDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwingDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getTwistDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSlerpDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSlerpDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDrivePosition,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveRotation,VxQuaternion)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveLinearVelocity,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveAngularVelocity,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,enableCollision,bool)\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tRigid Body Exports \r\n\t\t//\r\n\t\t//\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Forces */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addForce,const VxVector&,NODEFAULT, PForceMode, 0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addTorque,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalForce,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalTorque,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtPos, const VxVector&,NODEFAULT,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtLocalPos,const VxVector,NODEFAULT, const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtPos, const VxVector&, NODEFAULT,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtLocalPos, const VxVector&, NODEFAULT,const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Momentum */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularMomentum)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearMomentum)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* collision + callbacks\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setContactReportThreshold,float)\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,setContactReportThreshold)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setContactReportFlags,pContactPairFlags)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getContactReportFlags)\r\n\r\n\r\n\t\tDECLAREMETHOD_2(pRigidBody,void,setContactScript,int,int)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setTriggerScript,int,NODEFAULT,int,NODEFAULT,CK3dEntity*,NULL)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setContactModificationScript,int)\r\n\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setSkinWidth,const float,NODEFAULT,CK3dEntity*,NULL)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Pose : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setPosition,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setRotation,const VxQuaternion&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,translateLocalShapePosition,VxVector)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Velocity : */\r\n\t\t/************************************************************************/\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,getMaxAngularSpeed)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearVelocity)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularVelocity)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Mass */\r\n\t\t/************************************************************************/\r\n\t\t\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setCMassOffsetGlobalPosition,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setCMassGlobalPosition,VxVector)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getCMassLocalPosition)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getCMassGlobalPosition)\r\n\t\t//DECLAREMETHOD_1(pRigidBody,void,setMass,float)\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,getMass)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMassSpaceInertiaTensor,VxVector)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getMassSpaceInertiaTensor)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setCMassOffsetLocalPosition,VxVector)\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMassOffset,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMaxAngularSpeed,float)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Hull */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,pWorld*,getWorld)\r\n\t\tDECLAREMETHOD_1(pRigidBody,pJoint*,isConnected,CK3dEntity*)\r\n\t\tDECLAREMETHOD_2(pRigidBody,pJoint*,isConnected,CK3dEntity*,int)\r\n\t\t//DECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\t\t//DECLAREMETHOD_1_WITH_DEF_VALS(pRigidBody,float,getMass,CK3dEntity*,NULL)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getHullType)\r\n\r\n\t\tDECLAREMETHOD_2(pRigidBody,void,setGroupsMask,CK3dEntity*,const pGroupsMask&)\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getPointVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getLocalPointVelocity,const VxVector&)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isCollisionEnabled)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setKinematic,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isKinematic)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,enableGravity,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isAffectedByGravity)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSleeping,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isSleeping)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,lockTransformation,BodyLockFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,int,isBodyFlagOn,int)\r\n\t\t\r\n\t\tDECLAREMETHOD_1_WITH_DEF_VALS(pRigidBody,void,wakeUp,float,NX_SLEEP_INTERVAL)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSleepEnergyThreshold,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSolverIterationCount,int)\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pRigidBody,bool,onSubShapeTransformation,bool,TRUE,bool,TRUE,bool,TRUE,CK3dEntity*,NULL,bool,true)\r\n\r\n\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setCollisionsGroup,int,NODEFAULT,CK3dEntity*,)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,enableCollision,bool,NODEFAULT,CK3dEntity*,NULL)\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,hasWheels);\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getNbWheels);\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getNbSubShapes);\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getNbSubBodies);\r\n\r\n\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getCollisionsGroup)\r\n\t\tDECLAREMETHOD_2(pRigidBody,int,updateMassFromShapes,float,float)\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pRigidBody,int,addSubShape,CKMesh*,NULL,pObjectDescr,NODEFAULT,CK3dEntity*,NULL,VxVector,VxVector(),VxQuaternion,VxQuaternion())\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,int,removeSubShape,CKMesh*,NODEFAULT,float,0.0,float,0.0)\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Joint\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getNbJoints);\r\n\t\t//DECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,pJoint*,getJointAtIndex,int,NODEFAULT,int&,NODEFAULT,CK3dEntity**,NULL)\r\n\t\tDECLAREMETHOD_1(pRigidBody,pJoint*,getJointAtIndex,int)\r\n\t\tDECLAREMETHOD_2(pRigidBody,pJoint*,getJoint,CK3dEntity*,JType)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,deleteJoint,pJoint*)\r\n\t\tDECLAREMETHOD_2(pRigidBody,void,deleteJoint,CK3dEntity*,JType)\r\n\r\n\tSTOPVSLBIND\r\n}\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnlLog.h\"\n#include \"tnlDataChunker.h\"\n#include \n\nnamespace TNL\n{\n\nLogConsumer *LogConsumer::mLinkedList = NULL;\n\nLogConsumer::LogConsumer()\n{\n mNextConsumer = mLinkedList;\n if(mNextConsumer)\n mNextConsumer->mPrevConsumer = this;\n mPrevConsumer = NULL;\n mLinkedList = this;\n}\n\nLogConsumer::~LogConsumer()\n{\n if(mNextConsumer)\n mNextConsumer->mPrevConsumer = mPrevConsumer;\n if(mPrevConsumer)\n mPrevConsumer->mNextConsumer = mNextConsumer;\n else\n mLinkedList = mNextConsumer;\n}\n\nLogType *LogType::linkedList = NULL;\nLogType *LogType::current = NULL;\n\n#ifdef TNL_ENABLE_LOGGING\n\nLogType *LogType::find(const char *name)\n{\n static ClassChunker logTypeChunker(4096);\n\n for(LogType *walk = linkedList; walk; walk = walk->next)\n if(!strcmp(walk->typeName, name))\n return walk;\n LogType *ret = logTypeChunker.alloc();\n ret->next = linkedList;\n linkedList = ret;\n ret->isEnabled = false;\n ret->typeName = name;\n return ret;\n}\n#endif\n\nvoid LogConsumer::logString(const char *string)\n{\n // by default the LogConsumer will output to the platform debug \n // string printer, but only if we're in debug mode\n#ifdef TNL_DEBUG\n Platform::outputDebugString(string);\n Platform::outputDebugString(\"\\n\");\n#endif\n\t//printf(string);\n}\n\nvoid logprintf(const char *format, ...)\n{\n char buffer[4096];\n U32 bufferStart = 0;\n if(LogType::current)\n {\n strcpy(buffer, LogType::current->typeName);\n bufferStart = strlen(buffer);\n\n buffer[bufferStart] = ':';\n buffer[bufferStart+1] = ' ';\n bufferStart += 2;\n }\n va_list s;\n va_start( s, format );\n dVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, format, s);\n for(LogConsumer *walk = LogConsumer::getLinkedList(); walk; walk = walk->getNext())\n walk->logString(buffer);\n va_end(s);\n Platform::outputDebugString(buffer);\n Platform::outputDebugString(\"\\n\");\n}\n\n};\n\n============================================\r\nReadme for Virtools 4.1\r\nJanuary 2007\r\n(C) Virtools SA, 2007. All rights reserved\r\n============================================\r\n\r\nThis file contains last-minute information for Virtools.\r\nFor information on how to use Virtools and how to get further information, \r\nrefer to the Online Reference (documentation.chm) and the printed User Guide.\r\n\r\n\r\n--------\r\nCONTENTS\r\n--------\r\n\r\n1. System Requirements\r\n\t1.1 Hardware\r\n\t1.2 Software\r\n2. Registration and Support\r\n\t2.1 Registration\r\n\t2.2 Support\r\n3. Installing Additional Components\r\n4. Addons Folder\r\n5. Logos \r\n6. Last Minute Addenda\r\n\r\n\r\n----------------------\r\n1. SYSTEM REQUIREMENTS \r\n----------------------\r\n\r\nTo use Virtools, please ensure you respect the minimum requirements:\r\n\r\n1.1 Hardware\r\n------------\r\n - Pentium III or equivalent \r\n - 1 GB of RAM \r\n - DVD ROM drive \r\n - Monitor capable of displaying 1024 by 768 in 16 bit color (65536 color/Hi-color) \r\n - Pointing device (mouse, trackball, etc.)\r\n - Direct3D or OpenGL compatible 3D graphic accelerator card with 128 MB of RAM\r\n - DirectSound compatible sound card (not a requirement but recommended) \r\n\r\nYou should ensure you have the latest official drivers for your graphics card. \r\n\r\n1.2 Software\r\n------------\r\n - Microsoft Windows (2000, XP or Vista)\r\n - Microsoft DirectX 9.0C (August 2007) for DirectX compatible 3D graphic accelerator cards\r\n - For OpenGL, an OpenGL 2.0 compatible graphics card and driver\r\n - Microsoft Internet Explorer 6.0 (for the Online Reference)\r\n\r\n\r\n---------------------------\r\n2. REGISTRATION AND SUPPORT\r\n---------------------------\r\n\r\nYou will need your Virtools serial number to activate your Virtools Software (with a FlexLM License),\r\nas well as to register for technical support at the virtools website: www.virtools.com.\r\n\r\n2.1 License Registration under FlexLM\r\n-------------------------------------\r\nYou will need obtain a FlexLM license to be able to use your Virtools Software.\r\nProcedures and options are explained here: http://www.virtools.com/downloads/Doc/\r\n\r\n2.2 Support\r\n-----------\r\nTo qualify for support, you must first register online via the Virtools Website. To do this:\r\n\r\n - from the Start menu, choose Program Files > Virtools > Virtools 4.1 > then \"Virtools Support Center\".\r\n\r\nTo obtain technical support, make sure you have a valid maintenance contract and use the link \r\ndescribed above to go to the tech support page where you can send your question.\r\n\r\n\r\n-----------------------------------\r\n3. INSTALLING ADDITIONAL COMPONENTS\r\n-----------------------------------\r\n\r\nBy default, all components are selected when you first launch the Virtools installation \r\nprogram. However, the full install takes up a fair amount of space (c. 1 GB), and may include \r\ncomponents that you do not at the moment need, such as export plugins and sample files, so you \r\nmay have decided to install only some components.\r\n\r\nTo add or re-install any components, simply insert the Virtools DVD, select \"Virtools\" \r\nin the installation program once more, and only select the components you want to install.\r\n\r\n\r\n----------------\r\n4. ADDONS FOLDER\r\n----------------\r\n\r\nIn addition to the Virtools installation folder on the Virtools Installation DVD-ROM, \r\nyou will find a folder 'Addons', containing several applications helpful or necessary for \r\nVirtools. Of note are:\r\n\r\n - Microsoft DirectX 9.0c August 2007 (recommended for DirectX compatible graphics card)\r\n - Adobe Acrobat Reader 6.0.1\r\n - Virtools Thumbnail Viewer (already installed by default)\r\n\t\r\n\r\n---------------\r\n5. LOGOS \r\n---------------\r\nThe various Virtools logos that you may need for contractual or licensing reasons are available at:\r\nhttp://www.virtools.com/partners/partner_zone_library.asp \r\n\r\n\t\r\n---------------\r\n6. Last Minute Addenda\r\n---------------\r\n- IMPORTANT: If you are using the FlexLM Server to manage your Virtools Licenses, please reinstall the new \r\nFlexLM Server available on the DVD or at http://www.virtools.com/downloads/Doc/.//#include \"StdAfx2.h\"\r\n\r\n/*\r\n#include \r\n\r\n#include \"PCommonDialog.h\"\r\n#include \"PBodySetup.h\"\r\n#include \"PBXMLSetup.h\"\r\n*/\r\n/*\r\n\r\n\r\n\r\nvoid CPBParentDialog::OnTabChange(int last,int current)\r\n{\r\n\t\r\n\t\t//mTestViControl.SetActiveTab(current);\r\n\t\treturn;\r\n\t\tCPSharedBase* lastDlg = (CPSharedBase*)getDialog(last);\r\n\t\tif (lastDlg)\r\n\t\t{\r\n\r\n\t\t\tswitch(last)\r\n\t\t\t{\r\n\t\t\t\tcase BTAB_XML:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCPBXMLSetup*xmlDlg=(CPBXMLSetup*)CPSharedBase::getInstance()->getDialog(BTAB_XML);\r\n\t\t\t\t\t\tif (xmlDlg)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//xmlDlg->ShowWindow(SW_HIDE);\r\n\t\t\t\t\t\t\t//xmlDlg->UpdateWindow();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}break;\r\n\r\n\t\t\t\tcase BTAB_COMMON:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCPBodyCfg*cfg=(CPBodyCfg*)CPSharedBase::getInstance()->getDialog(BTAB_COMMON);\r\n\t\t\t\t\t\tif (cfg)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//cfg->ShowWindow(SW_HIDE);\r\n\t\t\t\t\t\t\t//cfg->UpdateWindow();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}break;\r\n\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCPSharedBase* selectedDlg = (CPSharedBase*)getDialog(current);\r\n\t\tif (selectedDlg)\r\n\t\t{\r\n\r\n\t\t\tswitch(current)\r\n\t\t\t{\r\n\t\t\t\tcase BTAB_XML:\r\n\t\t\t\t{\r\n\t\t\t\t\tCPBXMLSetup*xmlDlg=(CPBXMLSetup*)CPSharedBase::getInstance()->getDialog(BTAB_XML);\r\n\t\t\t\t\tif (xmlDlg)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//xmlDlg->ShowWindow(SW_SHOW);\r\n\t\t\t\t\t\t//xmlDlg->UpdateWindow();\r\n\t\t\t\t\t\t//xmlDlg->OnSelect(last);\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}break;\r\n\r\n\t\t\t\tcase BTAB_COMMON:\r\n\t\t\t\t{\r\n\t\t\t\t\tCPBodyCfg*cfg=(CPBodyCfg*)CPSharedBase::getInstance()->getDialog(BTAB_COMMON);\r\n\t\t\t\t\tif (cfg)\r\n\t\t\t\t\t{\r\n//\t\t\t\t\t\tcfg->ShowWindow(SW_NORMAL);\r\n\t\t\t\t\t\t//cfg->UpdateWindow();\r\n\t\t\t\t\t\tcfg->OnSelect(last);\r\n\t\t\t\t\t}\r\n\t\t\t\t}break;\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t}\r\n}\r\n*/\r\n-no need for any virtools dlls here\r\n-includes the physic pack, toolkit , interface widgets\r\n\r\nplease have directx and physx - system software installed.\r\n\r\n\r\nif you run these exe files, please take care your are not using the standard\r\nplugin paths from the player.ini\r\n\r\n\r\nvtPlayerConsole.bat starts the player but just without rendering\r\n\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\nint sessionIDCounter = 20;\r\n\r\n#include \"xLogger.h\"\r\n\r\n\r\nuxString\r\nxDistributedSession::print(TNL::BitSet32 flags)\r\n{\r\n\treturn Parent::print(flags);\r\n}\r\n\r\n\r\n\r\nTNL_IMPLEMENT_NETOBJECT(xDistributedSession); \r\n\r\n\r\n\r\n\r\n\r\nxDistributedSession::xDistributedSession()\r\n{\r\n\r\n\tmSessionFlags = 0;\r\n\tmSessionID =sessionIDCounter;\r\n\tsessionIDCounter ++;\r\n\tmClientTable = new xClientArrayType();\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedSession::~xDistributedSession()\r\n{\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::pack(TNL::BitStream *bstream)\r\n{\r\n\r\n\t//writes update bits : !\r\n\tParent::pack(bstream);\r\n\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\tif (prop->getFlags() & E_DP_NEEDS_SEND)\r\n\t\t\t{\r\n\t\t\t\tprop->pack(bstream);\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"sending session parameter to server : %s\",prop->getPropertyInfo()->mName.getString());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::unpack( TNL::BitStream *bstream,float sendersOneWayTime )\r\n{\r\n\tParent::unpack(bstream,sendersOneWayTime);\r\n\r\n\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tint blockIndex = prop->getBlockIndex();\r\n\r\n\t\tif (propInfo)\r\n\t\t{\r\n\r\n\t\t\tif (getUpdateBits().testStrict(1<unpack(bstream,sendersOneWayTime);\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t unpacking session prop on server :%s\",propInfo->mName.getString());\r\n\t\t\t\tsetMaskBits(1<getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\t//the first time ? : we write out all necessary attributes for the client : \r\n\t\tif(stream->writeFlag(updateMask & InitialMask))\n\t\t{\r\n\r\n\t\t\tif(stream->writeFlag(true))\r\n\t\t\t{\r\n\t\t\t\t//write out name :\r\n\t\t\t\tstream->writeString(GetName().getString(),strlen(GetName().getString()));\r\n\r\n\t\t\t\t//retrieve its class : \r\n\t\t\t\txDistributedClass *distClass = getDistributedClass();\r\n\t\t\t\tif (distClass)\r\n\t\t\t\t{\r\n\t\t\t\t\t//write out the class name : \r\n\t\t\t\t\tstream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString()));\r\n\r\n\t\t\t\t\t//write out the class base type : \r\n\t\t\t\t\tstream->writeInt(distClass->getEnitityType(),32);\r\n\r\n\t\t\t\t\t//write out users id :\r\n\t\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\tint uid = getUserID();\r\n\t\t\t\t\tstream->writeInt(getUserID(),32);\r\n\r\n\t\t\t\t\t//write out server side id : \r\n\t\t\t\t\tint serverID = connection->getGhostIndex(this);\r\n\t\t\t\t\tstream->writeInt(connection->getGhostIndex(this),32);\r\n\t\t\t\t\tsetServerID(connection->getGhostIndex(this));\r\n\r\n\t\t\t\t\tfloat time = getCreationTime();\r\n\t\t\t\t\t//write out creation time\r\n\t\t\t\t\tstream->write(getCreationTime());\r\n\t\t\t\t//\txLogger::xLog(ELOGINFO,XL_START,\"server:init pack update of %s: %f , %d , \",GetName().getString(),time,uid);\r\n\t\t\t\t\tstream->writeInt(getSessionID(),32);\r\n\t\t\t\t\tstream->writeInt(getMaxUsers(),32);\r\n\t\t\t\t\tstream->writeString(getPassword().getString(),strlen(getPassword().getString()));\r\n\r\n\t\t\t\t\t//netInterface->deploySessionClasses(connection);\r\n\r\n\t\t\t\t}\r\n\t\t\t\tsetNetInterface(netInterface);\r\n\t\t\t}\r\n\t\t}\r\n\t\t/************************************************************************/\r\n\t\t/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\tstream->writeSignedInt(getUpdateBits().getMask(),32);\r\n\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server is updating ghosts %d\", getUpdateBits().getMask() );\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\tif (propInfo)\r\n\t\t\t{\r\n\t\t\t\tif (getUpdateBits().testStrict(1<updateGhostValue(stream);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server is updating ghosts %d\",blockIndex);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//getUpdateBits().clear();\r\n\t}\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)\n{\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//initial update ? \r\n\t\tif(stream->readFlag())\n\t\t{\r\n\t\t\tif(stream->readFlag())\n\t\t\t{\r\n\t\t\t\tchar oName[256];stream->readString(oName);\t// retrieve objects name : \r\n\t\t\t\tchar cName[256];stream->readString(cName);\t// retrieve objects dist class name : \r\n\t\t\t\tint type = stream->readInt(32);\t\t\t\t\t\t\t//read the dist class base type : \r\n\t\t\t\tint userID = stream->readInt(32);\t\r\n\t\t\t\tint serverID2 = stream->readInt(32);\t\r\n\t\t\t\tfloat creationTime = 0.0f;\r\n\t\t\t\tstream->read(&creationTime);\r\n\t\t\t\tint sessionID = stream->readInt(32);\t\r\n\t\t\t\tint MaxUsers = stream->readInt(32);\t\r\n\t\t\t\tchar pass[256];stream->readString(pass);\r\n\r\n\r\n\r\n\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//now we store all in the dist object :\r\n\r\n\t\t\t\t//find and store the dist class : \r\n\t\t\t\txDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\t\t\t\txDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName,type);\r\n\t\t\t\tif (!classTemplate)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Warning initial unpack of session %s failed : no related class found : %s\",oName,cName);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"Warning Initial Unpack Update, no related class found : %s\",cName);\r\n\t\t\t\t\t//xLogger::xLog(ELOGERROR,XL_SESSION,\"Warning Initial Unpack Update, no related class found : %s\",cName);\r\n\t\t\t\t\tclassTemplate = netInterface->getDistributedClassInterface()->createClass(cName,type);\r\n\r\n\t\t\t\t}\r\n\t\t\t\tsetDistributedClass(classTemplate);\r\n\t\t\t\tSetName(oName);\r\n\t\t\t\tsetServerID(connection->getGhostIndex(this));\r\n\t\t\t\tsetObjectFlags(E_DO_CREATION_CREATED);\r\n\t\t\t\tsetUserID(userID);\r\n\t\t\t\tsetNetInterface(netInterface);\r\n\t\t\t\tsetCreationTime(creationTime);\r\n\t\t\t\tsetSessionID(sessionID);\r\n \t\t\t\r\n\t\t\t\t\r\n\t\t\t\tgetOwnershipState().set( 1<getUserID() );\r\n\r\n\t\t\t\tsetInterfaceFlags(E_DO_CREATED);\r\n\t\t\t\tgetSessionFlags().set( 1 << E_SF_INCOMPLETE );\r\n\r\n\r\n\t\t\t\txLogger::xLog(ELOGTRACE,E_LI_SESSION,\"Retrieved initial state of session %s\",oName);\r\n\t\t\t\tinitProperties();\r\n\t\t\t\tsetMaxUsers(MaxUsers);\r\n\t\t\t\tsetPassword(xNString(pass));\r\n\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\tsetOwnerConnection(con);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\r\n\t\tint updateBits = stream->readSignedInt(32);\r\n\t\tTNL::BitSet32 updateBitsMask(updateBits);\r\n\t\tsetGhostUpdateBits(updateBits);\r\n\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tint propCounter = 0;\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\tif (updateBitsMask.testStrict(1<updateFromServer(stream);\r\n\t\t\t\txLogger::xLog(ELOGTRACE,E_LI_SESSION,\"Client : retrieving session property : %s |pred :%d\",prop->getPropertyInfo()->mName.getString(),prop->getPropertyInfo()->mPredictionType);\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"client : retrieving session property : %s\",prop->getPropertyInfo()->mName.getString());\r\n\t\t\t\tgetSessionFlags().set( 1 << E_SF_COMPLETE );\r\n\t\t\t\tpropCounter++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (propCounter == props.size())\r\n\t\t{\r\n\t\t\tgetSessionFlags().set( 1 << E_SF_COMPLETE );\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::initProperties()\r\n{\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we iterate through the dist classes properties and create a real \r\n\t//data holding dist prop in the object !\r\n\r\n\txLogger::xLog(ELOGTRACE,E_LI_SESSION,\"Initiate properties of session : %s\",this->GetName().getString());\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertiesListType &props = *_class->getDistributedProperties();\r\n\t\tint userTypeCounter = 0;\r\n\r\n\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = NULL;\r\n\t\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\r\n\r\n\t\t\txLogger::xLog(ELOGTRACE,E_LI_SESSION,\"\\t attaching prop : %s | native type : %d | valueType : %d | prediction type : %d \",dInfo->mName.getString(),dInfo->mNativeType,dInfo->mValueType,dInfo->mPredictionType);\r\n\t\t\t//xLogger::xLogExtro(0,\"\\t attaching prop : %s | native type : %d | valueType : %d | prediction type : %d \",dInfo->mName.getString(),dInfo->mNativeType,dInfo->mValueType,dInfo->mPredictionType);\r\n\t\t\tswitch(dInfo->mValueType)\r\n\t\t\t{\r\n\t\t\tcase E_DC_PTYPE_3DVECTOR :\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint3F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint1F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint2F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedQuatF(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedString(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedInteger(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (dInfo->mNativeType == E_DC_S_NP_USER )\r\n\t\t\t{\r\n\t\t\t\tint blockID = _class->getFirstUserField() + userTypeCounter;\r\n\t\t\t\tuserTypeCounter++;\r\n\t\t\t\tprop->setBlockIndex(blockID);\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tprop->setBlockIndex(dInfo->mNativeType);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::prepare()\r\n{\r\n\tParent::prepare();\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::onGhostRemove()\r\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\r\n\tif (getNetInterface())\r\n\t{\r\n\r\n\t\tif(!getNetInterface()->IsServer())\r\n\t\t{\r\n\t\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\t\twhile (begin!=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\t\tif (distObject)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\t\tif (_class)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\t\tif (distClient && distClient->getSessionID() == getSessionID() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tdistClient->setSessionID(-1);\r\n\t\t\t\t\t\t\t\tdisableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_DELETING);\r\n\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_SESSION_DESTROYED);\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif(getNetInterface()->IsServer())\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,\"Server : Session is going to be deleted : %s\",this->GetName().getString());\r\n\t\t}\r\n\t\t\r\n\t\tgetNetInterface()->getDistObjectInterface()->removeObject(this);\r\n\t\t\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool xDistributedSession::onGhostAdd(TNL::GhostConnection *theConnection)\r\n{\r\n\treturn Parent::onGhostAdd(theConnection);\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nvoid xDistributedSession::onGhostAvailable(TNL::GhostConnection *theConnection)\r\n{\r\n\tParent::onGhostAvailable(theConnection);\r\n\tint conID = ((vtConnection*)theConnection)->getUserID();\r\n\t\r\n\t//xLogger::xLog(ELOGINFO,XL_START, \"session ghost available %d\",conID);\r\n\t\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tint blockIndex = prop->getBlockIndex();\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\tif (getUpdateBits().set(1<getInterface();\r\n\tif (netInterface->IsServer())\r\n\t{\r\n\t\tsetServerID(theConnection->getGhostIndex((TNL::NetObject*)this));\r\n\t\t//xLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION, \"ServerID %d | Name : %s\",getServerID(),GetName().getString());\r\n\t}\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::performScopeQuery(TNL::GhostConnection *connection)\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (!netInterface)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\tif (!distObjects)\r\n\t{ \r\n\t\treturn;\r\n\t}\r\n\t\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\txDistributedObject*dobject = *begin;\r\n\t\tif (dobject)\r\n\t\t{\t\r\n\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty*xDistributedSession::getProperty(int nativeType)\r\n{\r\n\t//return Parent::getProperty(nativeType);\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (prop->getPropertyInfo()->mNativeType == nativeType)\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty*xDistributedSession::getUserProperty(const char*name)\r\n{\r\n\t//return Parent::getUserProperty(name);\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (!strcmp(prop->getPropertyInfo()->mName.getString(),name))\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool xDistributedSession::isClientJoined(int userID)\r\n{\r\n\tbool result = false;\r\n\tfor (int i = 0 ; i < getClientTable().size() ; i ++)\r\n\t{\r\n\t\txDistributedClient *client = getClientTable().at(i);\r\n\t\tif (client->getUserID() == userID)\r\n\t\t\treturn true;\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::addUser(xDistributedClient *client)\r\n{\r\n\tif (client)\r\n\t{\r\n\t\tif (!isClientJoined(client->getUserID()))\r\n\t\t{\r\n\t\t\tgetClientTable().push_back(client);\r\n\t\t\txDistributedInteger *numUser= (xDistributedInteger *)getProperty(E_DC_S_NP_NUM_USERS);\r\n\t\t\tnumUser->updateValue(getClientTable().size(),0);\r\n\t\t\tsetNumUsers(getClientTable().size());\r\n\t\t\tint blockIndex = numUser->getBlockIndex();\r\n\t\t\tgetUpdateBits().set(1<getMyClient();\r\n\tif (client && myClient && client->getUserID() == myClient->getUserID())\r\n\t{\r\n\t\tmyClient->setSessionID(-1);\r\n\t}\r\n\r\n\tif (client)\r\n\t{\r\n\t\tif (isClientJoined(client->getUserID()))\r\n\t\t{\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif (client->getUserID() == getUserID())\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,\"Session master %d left session %d\",client->getUserID(),getSessionID());\r\n\t\t\t\t\r\n\t\t\t\tif (nInterface)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//we tag all existing users as new : \r\n\t\t\t\t\t\r\n\t\t\t\t\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\t\t\t\t\txDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();\r\n\t\t\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\t\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\t\t\t\twhile (begin!=end)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\t\t\t\tif (distObject)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\t\t\t\tif (_class)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\t\t\t\tif (distClient && isClientJoined(distClient->getUserID()))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (isFlagOn(distClient->getClientFlags(),E_CF_SESSION_JOINED))\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t//distClient->setSessionID(-1);\r\n\t\t\t\t\t\t\t\t\t\t\tdisableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\t\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_DELETING);\r\n\t\t\t\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_SESSION_DESTROYED);\r\n\t\t\t\t\t\t\t\t\t\t\txLogger::xLogExtro(0,\"\\tRemoving user %d from session\",distClient->getUserID(),getSessionID());\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbegin++;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tgetClientTable().clear();\r\n\t\t\t\t\tgoto ENDUPDATE;\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (client->getUserID() != getUserID())\r\n\t\t{\r\n\t\t\tenableFlag(client->getClientFlags(),E_CF_REMOVED);\r\n\t\t\tclient->setSessionID(-1);\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tfor(int i = 0 ; i < getClientTable().size() ; i++)\r\n\t\t{\r\n\r\n\t\t\tstd::vector::iterator begin = getClientTable().begin();\r\n\t\t\tstd::vector::iterator end = getClientTable().end();\r\n\t\t\twhile (begin !=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedClient *current = *begin;\r\n\t\t\t\tif (current && current->getUserID() == client->getUserID() )\r\n\t\t\t\t{\r\n getClientTable().erase(begin);\t\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tgoto ENDUPDATE;\r\n\r\n\t\tENDUPDATE :\r\n\t\txDistributedInteger *numUser= (xDistributedInteger *)getProperty(E_DC_S_NP_NUM_USERS);\r\n\t\tnumUser->updateValue(getClientTable().size(),0);\r\n\t\tsetNumUsers(getClientTable().size());\r\n\t\tint blockIndex = numUser->getBlockIndex();\r\n\t\tgetUpdateBits().set(1<mCurrentValue;\r\n\t\t}\r\n\t}\r\n\treturn xNString(\"\");\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedSession::setPassword(xNString val)\r\n{\r\n\r\n\r\n\r\n\tif (getProperty(E_DC_S_NP_PASSWORD))\r\n\t{\r\n\t\txDistributedString* passwordP= static_cast(getProperty(E_DC_S_NP_PASSWORD));\r\n\t\tif (passwordP!=NULL)\r\n\t\t{\r\n\t\t\tpasswordP->mCurrentValue = val;\r\n\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid xDistributedSession::setNumUsers(int val)\r\n{\r\n\r\n\tif (getProperty(E_DC_S_NP_NUM_USERS))\r\n\t{\r\n\t\txDistributedInteger* value = (xDistributedInteger*)getProperty(E_DC_S_NP_NUM_USERS);\r\n\t\tif (value)\r\n\t\t{\r\n\t\t\tvalue->mLastServerValue = val;\r\n\t\t\tvalue->mCurrentValue = val;\r\n\r\n\t\t}\r\n\t}\r\n}\r\nvoid xDistributedSession::setMaxUsers(int val)\r\n{\r\n\r\n\tif (getProperty(E_DC_S_NP_MAX_USERS))\r\n\t{\r\n\t\txDistributedInteger* maxUsers = (xDistributedInteger*)getProperty(E_DC_S_NP_MAX_USERS);\r\n\t\tif (maxUsers)\r\n\t\t{\r\n\t\t\tmaxUsers->mLastServerValue = val;\r\n\t\t\tmaxUsers->mCurrentValue = val;\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool\r\nxDistributedSession::isPrivate()\r\n{\r\n\tif (getProperty(E_DC_S_NP_PASSWORD))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool \r\nxDistributedSession::isLocked()\r\n{\r\n\tint locked = -1;\r\n\tif (getProperty(E_DC_S_NP_LOCKED))\r\n\t{\r\n\t\txDistributedInteger* isLocked = (xDistributedInteger*)getProperty(E_DC_S_NP_LOCKED);\r\n\t\tif (isLocked)\r\n\t\t{\r\n\t\t\tlocked = isLocked->mLastServerValue;\r\n\t\t\treturn locked;\r\n\t\t}\r\n\t}\r\n\treturn locked;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint xDistributedSession::getNumUsers()\r\n{\r\n\tint numUsers = -1;\r\n\tif (getProperty(E_DC_S_NP_LOCKED))\r\n\t{\r\n\t\txDistributedInteger* num = (xDistributedInteger*)getProperty(E_DC_S_NP_NUM_USERS);\r\n\t\tif (num)\r\n\t\t{\r\n\t\t\tnumUsers = num->mLastServerValue;\r\n\t\t\t//TNL::logprintf(\"numPS:%d | numPC:%d\",num->mLastServerValue,num->mCurrentTime);\r\n\t\t\treturn numUsers;\r\n\t\t}\r\n\t}\r\n\treturn numUsers;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool\r\nxDistributedSession::isFull()\r\n{\r\n\treturn getNumUsers() >= getMaxUsers();\r\n\r\n\r\n\tint maxplayers = -1;\r\n\tif (getProperty(E_DC_S_NP_MAX_USERS))\r\n\t{\r\n\t\txDistributedInteger* maxPlayersP = (xDistributedInteger*)getProperty(E_DC_S_NP_MAX_USERS);\r\n\t\tif (maxPlayersP)\r\n\t\t{\r\n\t\t\tmaxplayers = maxPlayersP->mLastServerValue;\r\n\t\t\treturn getNumUsers() < getMaxUsers();\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint xDistributedSession::getMaxUsers()\r\n{\r\n\tint maxplayers = -1;\r\n\tif (getProperty(E_DC_S_NP_MAX_USERS))\r\n\t{\r\n\t\txDistributedInteger* maxPlayersP = (xDistributedInteger*)getProperty(E_DC_S_NP_MAX_USERS);\r\n\t\tif (maxPlayersP)\r\n\t\t{\r\n\t\t\tmaxplayers = maxPlayersP->mCurrentValue;\r\n//\t\t\tTNL::logprintf(\"maxPS:%d | maxPC:%d\",maxPlayersP->mLastServerValue,maxPlayersP->mCurrentTime);\r\n\t\t\treturn maxplayers;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nvoid PhysicManager::_RegisterParameterOperationsMisc()\r\n{\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\t//pm->RegisterOperationType(PARAM_OP_TYPE_BGET_MATERIAL, \"bMat\");\r\n\t//pm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_MATERIAL,VTS_MATERIAL,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpBGetMaterial);\r\n}/********************************************************************\r\n\tcreated:\t2009/06/01\r\n\tcreated:\t1:6:2009 14:12\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick\\hasFFe.cpp\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick \r\n\tfile base:\thasFFe\r\n\tfile ext:\tcpp\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#define STRICT\r\n#define DIRECTINPUT_VERSION 0x0800\r\n\r\n#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }\r\n#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }\r\n#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }\r\n\r\n//#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \"dinput.h\"\r\n#include \"CKAll.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// globals\r\n//\r\nLPDIRECTINPUT8 g_pDI2 = NULL; \r\nLPDIRECTINPUTDEVICE8 g_pFFDevice2 = NULL;\r\n\r\n\r\n#define HAS_CONFIG\r\n\r\n#ifdef HAS_CONFIG\r\n\t#include \"gConfig.h\"\r\n#endif // BB_TOOLS\r\n\r\n#ifdef BB_TOOLS\r\n\r\n\t\t\r\n\t#include \r\n\t#include \"vtLogTools.h\"\r\n\t#include \"vtCBBErrorHelper.h\"\r\n\t#include \r\n\t#include \r\n\tusing namespace vtTools::BehaviorTools;\r\n#endif\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorHasFFEffectsDecl();\r\nCKERROR CreateHasFFEffectsProto(CKBehaviorPrototype **);\r\nint HasFFEffects(const CKBehaviorContext& behcontext);\r\nCKERROR PlayFFECallBackObject2(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorHasFFEffectsDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"JHasForceFeedback\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x12641a78,0x7ca70c45));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateHasFFEffectsProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Joystick\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateHasFFEffectsProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"JHasForceFeedback\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"yes\");\r\n\tproto->DeclareOutput(\"no\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( HasFFEffects );\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nBOOL CALLBACK EnumFFDevicesCallback0( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef )\r\n{\r\n if( FAILED( g_pDI2->CreateDevice( pDDI->guidInstance, &g_pFFDevice2, NULL ) ) )\r\n return DIENUM_CONTINUE; // If failed, try again\r\n return DIENUM_STOP;\r\n}\r\n\r\nHRESULT FreeDirectInput0()\r\n{\r\n // Release any DirectInputEffect objects.\r\n if( g_pFFDevice2 ) \r\n {\r\n\r\n g_pFFDevice2->Unacquire();\r\n SAFE_RELEASE( g_pFFDevice2 );\r\n }\r\n\r\n // Release any DirectInput objects.\r\n SAFE_RELEASE( g_pDI2 );\r\n\r\n return S_OK;\r\n}\r\n\r\nint HasFFEffects(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tHWND mWin = (HWND )ctx->GetMainWindow();\r\n\r\n\tDirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI2, NULL ) ;\r\n\r\n // Get the first enumerated force feedback device\r\n g_pDI2->EnumDevices( 0, EnumFFDevicesCallback0, 0, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK );\r\n\r\n\tif( g_pFFDevice2 == NULL )\r\n beh->ActivateOutput(1);\r\n\telse\r\n\t\tbeh->ActivateOutput(0);\r\n\t\r\n\tFreeDirectInput0();\r\n\treturn CKBR_OK;\r\n}\r\n\r\n/*\n * Tcp4u v 3.31\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: skt4u.h\n * Purpose: Internal header file. Lowest layer of the library\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n\n#ifndef _SKT4U_LOADDED\n#define _SKT4U_LOADDED\n\n \n/* ****************************************************************** */\n/* */\n/* Etage 0 : Gestion des donnees internes */\n/* */\n/* ****************************************************************** */\n\n\n#define STATE_LISTEN 12\n#define STATE_CLIENT 13\n#define STATE_SERVER 14\n \nstruct S_HistoSocket\n{\n SOCKET skt;\n int nState;\n long nRcv;\n long nSnd;\n HTASK hTask;\n} ; /* struct S_HistoSocket */\n\n#define TCP4U_SUCCESS 1 /* >=1 function OK */\n#define TCP4U_ERROR -1 /* error */\n#define TCP4U_TIMEOUT -2 /* timeout has occured */\n#define TCP4U_BUFFERFREED -3 /* the buffer has been freed */\n#define TCP4U_HOSTUNKNOWN -4 /* connect to unknown host */\n#define TCP4U_NOMORESOCKET -5 /* all socket has been used */\n#define TCP4U_NOMORERESOURCE -5 /* or no more free resource */\n#define TCP4U_CONNECTFAILED -6 /* connect function has failed*/\n#define TCP4U_UNMATCHEDLENGTH -7 /* TcpPPRecv : Error in length*/\n#define TCP4U_BINDERROR -8 /* bind failed (Task already started?) */\n#define TCP4U_OVERFLOW -9 /* Overflow during TcpPPRecv */\n#define TCP4U_EMPTYBUFFER -10 /* TcpPPRecv receives 0 byte */\n#define TCP4U_CANCELLED -11 /* Call cancelled by signal */\n#define TCP4U_INSMEMORY -12 /* Not enough memory */\n#define TCP4U_SOCKETCLOSED 0 /* Host has closed connection */\n\n/* ----------- Functions ---------- */\nvoid Skt4uRcd (SOCKET sNewSkt, int nState); /* new socket created */\nvoid Skt4uUnRcd (SOCKET sNewSkt); /* socket destroyed */\nint Skt4uCleanup (void); /* clean internal tables */\nint Skt4uInit (void); /* inits internal tables */\nstruct S_HistoSocket *Skt4uGetStats (SOCKET s); /* Get Histo data */\n\n#endif /* _SKT4U_LOADDED */\n\n//{{NO_DEPENDENCIES}}\r\n// Microsoft Visual C++ generated include file.\r\n// Used by DistributedNetworkClassDialog.rc\r\n//\r\n\r\n#define IDC_SPLIT_MAIN 2012\r\n#define IDD_EDITOR 10009\r\n#define IDC_LIST1 10003\r\n#define IDD_TOOLBAR 10001\r\n#define IDI_EDITORICON 10002\r\n\r\n// Next default values for new objects\r\n// \r\n#ifdef APSTUDIO_INVOKED\r\n#ifndef APSTUDIO_READONLY_SYMBOLS\r\n#define _APS_NEXT_RESOURCE_VALUE 10008\r\n#define _APS_NEXT_COMMAND_VALUE 32771\r\n#define _APS_NEXT_CONTROL_VALUE 10007\r\n#define _APS_NEXT_SYMED_VALUE 10006\r\n#endif\r\n#endif\r\n#pragma once\r\n\r\n#include \"PhysicManager.h\"\r\n\r\n\r\n// vtAgeiaInterfaceEditorDlg.h : header file\r\n//\r\n\r\n//editor dialog creation function, to be called by Virtools Dev\r\nDllEditorDlg*\tfCreateEditorDlg(HWND parent);\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// EditorDlg dialog\r\n\r\nclass vtAgeiaInterfaceEditorDlg : public DllEditorDlg\r\n{\r\npublic:\r\n\t//called on creation of the dialog by Virtools Dev interface\r\n\t//the PluginInterface will be avalaible only when the OnInterfaceInit() has been called\r\n\tvirtual void\tOnInterfaceInit();\r\n\t//called on destruction of the dialog by Virtools Dev interface\r\n\tvirtual void\tOnInterfaceEnd();\r\n\t//callback for receiving notification\r\n\tvirtual HRESULT ReceiveNotification(UINT MsgID,DWORD Param1=0,DWORD Param2=0,CKScene* Context=NULL);\r\n\r\n\tint\t\t\t\tOnGlobalKeyboardShortcut(int commandID);\r\n\tint\t\t\t\tOnLocalKeyboardShortcut(int commandID);\r\n\tvirtual void\tOnCustomMenu(CMenu* menu,int startingCommandID,int endingCommandID);\t//fill custom menu, use commandID= baseID+startingCommandID\r\n\tvirtual void\tOnCustomMenu(int commandID);\t//callback when custom menu used, commandID==baseID (without the startingCommandID)\r\n\t//Create a CTooltipCtrl for tooltip management\r\n\tvoid CreateTooltip();\r\n\r\n\tCKContext *mContext;\r\n\tPhysicManager *pMan;\r\n\tPhysicManager *getPMan(){return pMan;}\r\n\tCKContext *getContext(){return mContext;}\r\n\r\n\tvoid init(CKContext *ctx,PhysicManager *pm);\r\n\tvoid objectPosChanged(CK_ID objID);\r\n\tvoid objectSelChanged(DWORD par1,DWORD par2);\r\n\r\n\tvirtual BOOL LoadData(CKInterfaceObjectManager* iom);\r\n\tvirtual BOOL SaveData(CKInterfaceObjectManager* iom);\r\n\r\n\r\nprotected:\r\n\t//tooltip\r\n\tCToolTipCtrl\tm_wndToolTip;\r\n\r\n// Construction\r\npublic:\r\n\tvtAgeiaInterfaceEditorDlg(CWnd* pParent = NULL); // standard constructor\r\n\r\n// Dialog Data\r\n\t//{{AFX_DATA(vtAgeiaInterfaceEditorDlg)\r\n\tenum { IDD = IDD_EDITOR };\r\n\t\t// NOTE: the ClassWizard will add data members here\r\n\t//}}AFX_DATA\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(vtAgeiaInterfaceEditorDlg)\r\n\tpublic:\r\n\tvirtual BOOL PreTranslateMessage(MSG* pMsg);\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\tvirtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r\n\t//}}AFX_VIRTUAL\r\n\r\n// Implementation\r\nprotected:\r\n\r\n\t// Generated message map functions\r\n\t//{{AFX_MSG(vtAgeiaInterfaceEditorDlg)\r\n\tvirtual BOOL OnInitDialog();\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n//{{AFX_INSERT_LOCATION}}\r\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r\n\r\n#ifndef __PCLOTHTYPES_H__\r\n#define __PCLOTHTYPES_H__\r\n\r\n\r\n#include \"pClothFlags.h\"\r\n\r\n\r\n/** \\addtogroup Cloth\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Descriptor class for pCloth.\r\n*/\r\nclass MODULE_API pClothDesc\r\n{\r\npublic:\r\n\r\n\t/**\r\n\t\\brief Thickness of the cloth.\r\n\r\n\tThe thickness is usually a fraction of the overall extent of the cloth and\r\n\tshould not be set to a value greater than that.\tA good value is the maximal\r\n\tdistance between two adjacent cloth particles in their rest pose. Visual\r\n\tartifacts or collision problems may appear if the thickness is too small.\r\n\r\n\tDefault: 0.01
\r\n\tRange: [0,inf)\r\n\r\n\t@see pCloth.setThickness()\r\n\t*/\r\n\tfloat thickness;\r\n\r\n\t/**\r\n\t\\brief Density of the cloth (mass per area).\r\n\r\n\tDefault: 1.0
\r\n\tRange: (0,inf)\r\n\t*/\r\n\tfloat density;\r\n\r\n\t/**\r\n\t\\brief Bending stiffness of the cloth in the range 0 to 1.\r\n\r\n\tOnly has an effect if the flag PCF_Bending is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,1]\r\n\r\n\t@see PCF_Bending pCloth.setBendingStiffness()\r\n\t*/\r\n\tfloat bendingStiffness;\r\n\r\n\t/**\r\n\t\\brief Stretching stiffness of the cloth in the range 0 to 1.\r\n\r\n\tNote: stretching stiffness must be larger than 0.\r\n\r\n\tDefault: 1.0
\r\n\tRange: (0,1]\r\n\r\n\t@see pCloth.setStretchingStiffness()\r\n\t*/\r\n\tfloat stretchingStiffness;\r\n\r\n\t/**\r\n\t\\brief Spring damping of the cloth in the range 0 to 1.\r\n\r\n\tOnly has an effect if the flag PCF_Damping is set.\r\n\r\n\tDefault: 0.5
\r\n\tRange: [0,1]\r\n\r\n\t@see PCF_Damping pCloth.setDampingCoefficient()\r\n\t*/\r\n\tfloat dampingCoefficient;\r\n\r\n\t/**\r\n\t\\brief Friction coefficient in the range 0 to 1. \r\n\r\n\tDefines the damping of the velocities of cloth particles that are in contact.\r\n\r\n\tDefault: 0.5
\r\n\tRange: [0,1]\r\n\r\n\t@see pCloth.setFriction()\r\n\t*/\r\n\tfloat friction;\r\n\r\n\t/**\r\n\t\\brief If the flag PCF_Pressure is set, this variable defines the volume\r\n\tof air inside the mesh as volume = pressure * restVolume. \r\n\r\n\tFor pressure < 1 the mesh contracts w.r.t. the rest shape\r\n\tFor pressure > 1 the mesh expands w.r.t. the rest shape\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_pressure pCloth.setPressure()\r\n\t*/\r\n\tfloat pressure;\r\n\r\n\t/**\r\n\t\\brief If the flag PCF_Tearable is set, this variable defines the \r\n\telongation factor that causes the cloth to tear. \r\n\r\n\tMust be larger than 1.\r\n\tMake sure meshData.maxVertices and the corresponding buffers\r\n\tin meshData are substantially larger (e.g. 2x) than the number \r\n\tof original vertices since tearing will generate new vertices.\r\n\r\n\tWhen the buffer cannot hold the new vertices anymore, tearing stops.\r\n\r\n\tDefault: 1.5
\r\n\tRange: (1,inf)\r\n\r\n\t@see pCloth.setTearFactor()\r\n\t*/\r\n\tfloat tearFactor;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from cloth to colliding rigid bodies.\r\n\r\n\tOnly has an effect if PCF_CollisionTwoWay is set.\r\n\r\n\tDefault: 0.2
\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_CollisionTwoWay pCloth.setCollisionResponseCoefficient()\r\n\t*/\r\n\tfloat collisionResponseCoefficient;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from cloth to attached rigid bodies.\r\n\r\n\tOnly has an effect if the mode of the attachment is set to nx_cloth_attachment_twoway.\r\n\r\n\tDefault: 0.2
\r\n\tRange: [0,1]\r\n\r\n\t@see pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape pCloth.setAttachmentResponseCoefficient()\r\n\t*/\r\n\tfloat attachmentResponseCoefficient;\r\n\r\n\t/**\r\n\t\\brief If the flag nx_cloth_attachment_tearable is set in the attachment method of pCloth, \r\n\tthis variable defines the elongation factor that causes the attachment to tear. \r\n\r\n\tMust be larger than 1.\r\n\r\n\tDefault: 1.5
\r\n\tRange: (1,inf)\r\n\r\n\t@see pCloth.setAttachmentTearFactor() pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape\r\n\r\n\t*/\r\n\tfloat attachmentTearFactor;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from this cloth to colliding fluids.\r\n\r\n\tOnly has an effect if the PCF_FluidCollision flag is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\tNote: Large values can cause instabilities\r\n\r\n\t@see pClothDesc.flags pClothDesc.fromFluidResponseCoefficient\r\n\t*/\r\n\tfloat toFluidResponseCoefficient;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from colliding fluids to this cloth.\r\n\r\n\tOnly has an effect if the PCF_FluidCollision flag is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\tNote: Large values can cause instabilities\r\n\r\n\t@see pClothDesc.flags pClothDesc.ToFluidResponseCoefficient\r\n\t*/\r\n\tfloat fromFluidResponseCoefficient;\r\n\r\n\t/**\r\n\t\\brief If the PCF_Adhere flag is set the cloth moves partially in the frame \r\n\tof the attached actor. \r\n\r\n\tThis feature is useful when the cloth is attached to a fast moving character.\r\n\tIn that case the cloth adheres to the shape it is attached to while only \r\n\tvelocities below the parameter minAdhereVelocity are used for secondary effects.\r\n\r\n\tDefault: 1.0\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_ADHERE\r\n\t*/ \r\n\r\n\tfloat minAdhereVelocity;\r\n\r\n\t/**\r\n\t\\brief Number of solver iterations. \r\n\r\n\tNote: Small numbers make the simulation faster while the cloth gets less stiff.\r\n\r\n\tDefault: 5\r\n\tRange: [1,inf)\r\n\r\n\t@see pCloth.setSolverIterations()\r\n\t*/ \r\n\r\n\tunsigned int solverIterations;\r\n\r\n\t/**\r\n\t\\brief External acceleration which affects all non attached particles of the cloth. \r\n\r\n\tDefault: (0,0,0)\r\n\r\n\t@see pCloth.setExternalAcceleration()\r\n\t*/ \r\n\tVxVector externalAcceleration;\r\n\r\n\t/**\r\n\t\\brief Acceleration which acts normal to the cloth surface at each vertex.\r\n\r\n\tDefault: (0,0,0)\r\n\r\n\t@see pCloth.setWindAcceleration()\r\n\t*/ \r\n\tVxVector windAcceleration;\r\n\r\n\t/**\r\n\t\\brief The cloth wake up counter.\r\n\r\n\tRange: [0,inf)
\r\n\tDefault: 20.0f*0.02f\r\n\r\n\t@see pCloth.wakeUp() pCloth.putToSleep()\r\n\t*/\r\n\tfloat wakeUpCounter;\r\n\r\n\t/**\r\n\t\\brief Maximum linear velocity at which cloth can go to sleep.\r\n\r\n\tIf negative, the global default will be used.\r\n\r\n\tRange: [0,inf)
\r\n\tDefault: -1.0\r\n\r\n\t@see pCloth.setSleepLinearVelocity() pCloth.getSleepLinearVelocity()\r\n\t*/\r\n\tfloat sleepLinearVelocity;\r\n\r\n\t/**\r\n\t\\brief Sets which collision group this cloth is part of.\r\n\r\n\tRange: [0, 31]\r\n\tDefault: 0\r\n\r\n\tpCloth.setCollisionGroup()\r\n\t*/\r\n\txU16 collisionGroup;\r\n\r\n\t/**\r\n\t\\brief Sets the 128-bit mask used for collision filtering.\r\n\r\n\tDefault: 0\r\n\r\n\t@see NxGroupsMask pCloth.setGroupsMask() pCloth.getGroupsMask()\r\n\t*/\r\n\tpGroupsMask groupsMask;\r\n\r\n\t/**\r\n\t\\brief Force Field Material Index, index != 0 has to be created.\r\n\r\n\tDefault: 0\r\n\t*/\r\n\txU16 forceFieldMaterial;\r\n\r\n\t/**\r\n\t\\brief If the flag PCF_ValidBounds is set, this variable defines the volume\r\n\toutside of which cloth particle are automatically removed from the simulation. \r\n\r\n\t@see PCF_ValidBounds pCloth.setValidBounds()\r\n\t*/\r\n\tVxBbox validBounds;\r\n\r\n\t/**\r\n\t\\brief This parameter defines the size of grid cells for collision detection.\r\n\r\n\tThe cloth is represented by a set of world aligned cubical cells in broad phase.\r\n\tThe size of these cells is determined by multiplying the length of the diagonal\r\n\tof the AABB of the initial cloth size with this constant.\r\n\r\n\tRange: [0.01,inf)
\r\n\tDefault: 0.25\r\n\t*/\r\n\tfloat relativeGridSpacing;\r\n\r\n\t/**\r\n\t\\brief Flag bits.\r\n\r\n\tDefault: PCF_GRAVITY\r\n\r\n\t@see NxClothFlag pCloth.setFlags()\r\n\t*/ \r\n\tunsigned int flags;\r\n\r\n\t/**\r\n\t\\brief Possible debug name. The string is not copied by the SDK, only the pointer is stored.\r\n\r\n\tDefault: NULL\r\n\r\n\t@see pCloth.setName() pCloth.getName()\r\n\t*/\r\n\tconst char* name;\r\n\r\n\r\n\t/**\r\n\t\\brief Vertex color to identify vertieces as tearable.\r\n\r\n\tDefault: 255,255,254\r\n\t*/\r\n\tVxColor tearVertexColor;\r\n\r\n\t/**\r\n\t\\brief Reference object to identify the world.\r\n\r\n\tDefault: pDefaultWorld\r\n\t*/\r\n\tCK_ID worldReference;\r\n\r\n\t/**\r\n\t\\brief Attachment flags.\r\n\r\n\tDefault: PCAF_ClothAttachmentTwoway\r\n\t\r\n\t@see #pClothAttachmentFlag\r\n\t*/\r\n\tpClothAttachmentFlag attachmentFlags;\r\n\r\n\t/**\r\n\t\\brief Constructor sets to default.\r\n\t*/\r\n\tpClothDesc();\r\n\r\n\r\n\t/**\r\n\t\\brief (Re)sets the structure to the default.\t\r\n\t*/\r\n\tvoid setToDefault();\r\n\r\n\t/**\r\n\t\\brief Returns true if the current settings are valid\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n\r\n\r\n};\r\n\r\n/** @} */\r\n#endif \r\n// __PCLOTHTYPES_H__#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOUserValueModifiedDecl();\r\nCKERROR CreateDOUserValueModifiedProto(CKBehaviorPrototype **);\r\nint DOUserValueModified(const CKBehaviorContext& behcontext);\r\nCKERROR DOUserValueModifiedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOUserValueModifiedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOUserValueModified\");\t\r\n\tod->SetDescription(\"Gets a user value on a distributed object\");\r\n\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x349c10e0,0x7982264c));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOUserValueModifiedProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDOUserValueModifiedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOUserValueModified\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareInput(\"Next Value\");\r\n\r\n\r\n\r\n\tproto->DeclareOutput(\"Exit In\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"New Value\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"test\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Time\", CKPGUID_TIME, \"0\");\r\n\tproto->DeclareOutParameter(\"Value\", CKPGUID_STRING, \"No Error\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\tproto->DeclareSetting(\"Class\", CKPGUID_STRING, \"My3DClass\");\r\n\tproto->DeclareSetting(\"Parameter Name\", CKPGUID_STRING, \"test\");\r\n\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DOUserValueModified);\r\n\tproto->SetBehaviorCallbackFct(DOUserValueModifiedCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOUserValueModified(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\r\n\r\n\r\n\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object :\r\n\tCK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tif (!obj)\r\n\t{\r\n\t\tbeh->ActivateOutput(3);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(2);\r\n\t\tXString errorMesg(\"distributed object creation failed,no network connection !\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(3);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t//use objects name, if not specified : \r\n\tCKSTRING name= obj->GetName();\r\n\t\r\n\tIDistributedObjects*doInterface = cin->getDistObjectInterface();\r\n\tIDistributedClasses*cInterface = cin->getDistributedClassInterface();\r\n \r\n\tXString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));\r\n\tXString parameterName((CKSTRING) beh->GetLocalParameterReadDataPtr(1));\r\n\r\n\txDistributedClass *_class = cInterface->get(className.CStr());\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class ok ? \r\n\tif (_class==NULL)\r\n\t{\r\n\t\tbeh->ActivateOutput(3);\r\n\t\tctx->OutputToConsoleEx(\"Distributed Class doesn't exists : %s\",className.CStr());\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\tconst char * cNAme = _class->getClassName().getString();\r\n\r\n\tint classType = _class->getEnitityType();\r\n\tint bcount = beh->GetInputParameterCount();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\r\n\t\r\n\r\n\txDistributedObject *dobjDummy = NULL;\r\n\txDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());\r\n\tif (!dobj)\r\n\t{\r\n\t\tbeh->ActivateOutput(3);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\tif (dobj)\r\n\t{\r\n\t\txDistributedProperty * prop = dobj->getUserProperty(parameterName.CStr());\r\n\t\tif (prop)\r\n\t\t{\r\n\t\t\tif ( dobj->getGhostUpdateBits().testStrict(1 << prop->getBlockIndex()))\r\n\t\t\t{\r\n\t\t\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\t\t\t\tCKParameterOut *ciIn = beh->GetOutputParameter(1);\r\n\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\r\n\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\tint userType = xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType);\r\n\t\t\t\tif ( userType ==sType )\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->ActivateOutput(2);\r\n\t\t\t\t\tdobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);\r\n\t\t\t\t\tswitch(xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase vtFLOAT:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedPoint1F *propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfloat ovalue = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(1,&ovalue);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tcase vtVECTOR2D:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedPoint2F *propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tPoint2F ovalue = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\tVx2DVector ovaluex(ovalue.x,ovalue.y);\r\n\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(1,&ovaluex);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase vtVECTOR:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedPoint3F *propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tPoint3F ovalue = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\tVxVector ovaluex(ovalue.x,ovalue.y,ovalue.z);\r\n\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(1,&ovaluex);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase vtQUATERNION:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedQuatF*propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tQuatF ovalue = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\tVxQuaternion ovaluex(ovalue.x,ovalue.y,ovalue.z,ovalue.w);\r\n\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(1,&ovaluex);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase vtSTRING:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedString*propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tTNL::StringPtr ovalue = propValue->mCurrentValue;\r\n\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\t\t\t\t\t\tXString errorMesg(ovalue.getString());\r\n\t\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase vtINTEGER:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedInteger*propValue = static_cast(prop);\r\n\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tint ovalue = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(1,&ovalue);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\r\n\r\n\r\n\t/*\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\t\r\n\t\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t\txDistributedObject *dobj = doInterface->get(name);\r\n\t\t\tif (!dobj)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\r\n\t\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\txDistributedPropertyArrayType &props = *dobj->getDistributedPorperties();\r\n\t\t\t\r\n\t\t\tint propID = _class->getInternalUserFieldIndex(i - BEH_IN_INDEX_MIN_COUNT);\r\n\t\t\tif (propID==-1 || propID > props.size() )\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\txDistributedProperty *prop = props[propID];\r\n\t\t\tif (prop)\r\n\t\t\t{\r\n\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\tif (propInfo)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\r\n\t\t\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVxVector vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n break;\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tfloat vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(vvalue,currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\r\n\t\r\n\t*/\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by loop : \r\n\treturn 0;\r\n}\r\n\r\nCKERROR DOUserValueModifiedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}/********************************************************************\r\n\tcreated:\t2007/12/12\r\n\tcreated:\t12:12:2007 11:54\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\\vtCXPrecomp.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\r\n\tfile base:\tvtCXPrecomp\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __VTX_PRECOMP_H\r\n#define __VTX_PRECOMP_H\r\n\r\n#include \"VxMath.h\"\r\n#include \"CKAll.h\"\r\n\r\n\r\n#undef min\r\n#undef max\r\n\r\n#endif\r\n#ifndef __vtNetAll_h_\r\n#define __vtNetAll_h_\r\n\r\n#include \"xNetworkTypes.h\"\r\n//#include \"vtNetEnums.h\"\r\n#include \"xNetObject.h\"\r\n\r\n\r\n//#include \"vtNetworkManager.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"xDistributedObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"IDistributedClasses.h\"\r\n#include \"IMessages.h\"\r\n#include \"xPredictionSetting.h\"\r\n\r\n//#include \r\n\r\n#endif\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xLogger.h\"\r\n\r\n\r\nTNL_IMPLEMENT_NETOBJECT(xDistributed3DObject); \r\n\r\nuxString\r\nxDistributed3DObject::print(TNL::BitSet32 flags)\r\n{\r\n\r\n\treturn Parent::print(flags);\r\n\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributed3DObject::pack(TNL::BitStream *bstream)\r\n{\r\n\r\n\t//writes update bits : !\r\n\tParent::pack(bstream);\r\n\r\n\tint updateBites = getUpdateBits().getMask();\r\n\r\n\tint packCounter = 0 ;\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\tint blockIndexF = BIT(blockIndex);\r\n\t\t\tint blockIndexF2 = 1 << blockIndex;\r\n\r\n\t\t\tif (prop->getFlags() & E_DP_NEEDS_SEND)\r\n\t\t\t{\r\n\t\t\t\tprop->pack(bstream);\r\n\t\t\t\tpackCounter++;\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"packing byflag\");\r\n\t\t\t}\r\n\r\n\t\t\tif (getUpdateBits().test( 1 << (prop->getBlockIndex())))\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t//xLogger::xLog(ELOGINFO,XL_START,\"packing %d props with mask \",packCounter,getUpdateBits().getMask() );\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributed3DObject::unpack( TNL::BitStream *bstream,float sendersOneWayTime )\r\n{\r\n\tParent::unpack(bstream,sendersOneWayTime);\r\n\t\t\r\n\tint updateBites = getUpdateBits().getMask();\r\n\t\r\n\tint unpackCounter = 0 ;\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (getUpdateBits().testStrict(1<unpack(bstream,sendersOneWayTime);\r\n\t\t\t\tunpackCounter++;\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t unpacking prop:%s\",propInfo->mName.getString());\r\n\t\t\t\tsetMaskBits(1<getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\t//the first time ? : we write out all necessary attributes for the client : \r\n\t\tif(stream->writeFlag(updateMask & InitialMask))\n\t\t{\r\n\r\n\t\t\tif(stream->writeFlag(true))\r\n\t\t\t{\r\n\t\t\t\t//write out name :\r\n\t\t\t\tstream->writeString(GetName().getString(),strlen(GetName().getString()));\r\n\r\n\t\t\t\t//retrieve its class : \r\n\t\t\t\txDistributedClass *distClass = getDistributedClass();\r\n\t\t\t\tif (distClass)\r\n\t\t\t\t{\r\n\t\t\t\t\t//write out the class name : \r\n\t\t\t\t\tstream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString()));\r\n\r\n\t\t\t\t\t//write out the class base type : \r\n\t\t\t\t\tstream->writeInt(distClass->getEnitityType(),32);\r\n\r\n\t\t\t\t\t//write out users id :\r\n\t\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\tint uid = getUserID();\r\n\t\t\t\t\tstream->writeInt(getUserID(),32);\r\n\r\n\t\t\t\t\t//write out server side id : \r\n\t\t\t\t\tint serverID = connection->getGhostIndex(this);\r\n\t\t\t\t\tstream->writeInt(connection->getGhostIndex(this),32);\r\n\t\t\t\t\tsetServerID(connection->getGhostIndex(this));\r\n\r\n\t\t\t\t\tfloat time = getCreationTime();\r\n\t\t\t\t\t//write out creation time\r\n\t\t\t\t\tstream->write(getCreationTime());\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server:init pack update : %f , %d , \",time,uid);\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"initial pack!\");\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\tsetNetInterface(netInterface);\r\n\t\t\t}\r\n\t\t}\r\n\t\t/************************************************************************/\r\n\t\t/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\tstream->writeSignedInt(getUpdateBits().getMask(),32);\r\n\t\tint unpackCounter = 0 ;\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\tif (propInfo)\r\n\t\t\t{\r\n\t\t\t\tif (getUpdateBits().testStrict(1<updateGhostValue(stream);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server is updating ghosts %d\",blockIndex);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \nxDistributed3DObject::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)\n{\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//initial update ? \r\n\t\tif(stream->readFlag())\n\t\t{\r\n\t\t\tif(stream->readFlag())\n\t\t\t{\r\n\t\t\t\tchar oName[256];stream->readString(oName);\t// retrieve objects name : \r\n\t\t\t\tchar cName[256];stream->readString(cName);\t// retrieve objects dist class name : \r\n\t\t\t\tint type = stream->readInt(32);\t\t\t\t\t\t\t//read the dist class base type : \r\n\t\t\t\tint userID = stream->readInt(32);\t\r\n\t\t\t\tint serverID2 = stream->readInt(32);\t\r\n\t\t\t\tfloat creationTime = 0.0f;\r\n\t\t\t\tstream->read(&creationTime);\r\n\r\n\t \r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//now we store all in the dist object :\r\n\t\t\t\t\r\n\t\t\t\t//find and store the dist class : \r\n\t\t\t\txDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\t\t\t\txDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName);\r\n\t\t\t\tif (!classTemplate)\r\n\t\t\t\t{\r\n\t\t\t\t\tclassTemplate = netInterface->getDistributedClassInterface()->createClass(cName,type);\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_3DOBJECT,\"No class found %s\",oName);\r\n\t\t\t\t}\r\n\t\t\t\tsetDistributedClass(classTemplate);\r\n\t\t\t\tSetName(oName);\r\n\t\t\t\tsetServerID(connection->getGhostIndex(this));\r\n\t\t\t\tsetObjectFlags(E_DO_CREATION_CREATED);\r\n\t\t\t\tsetUserID(userID);\r\n\t\t\t\tgetOwnershipState().set( 1<getUserID() );\r\n\t\t\t\tsetNetInterface(netInterface);\r\n\t\t\t\tsetCreationTime(creationTime);\r\n\t\t\t\tsetInterfaceFlags(E_DO_CREATED);\r\n\t\t\t\tinitProperties();\r\n\t\t\t\tsetSessionID((netInterface->getMyClient()->getSessionID()));\r\n\r\n\t\t\t\tenableFlag(getObjectStateFlags(),E_DOSF_UNPACKED);\r\n\r\n\t\t\t\t\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"Retrieved initial state %s | sessionID:%d\",oName,netInterface->getMyClient()->getSessionID());\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\r\n\t\t\r\n\t\tint updateBits = stream->readSignedInt(32);\r\n\t\tTNL::BitSet32 updateBitsMask(updateBits);\r\n\t\tsetGhostUpdateBits(updateBits);\r\n\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\tif (updateBitsMask.testStrict(1<updateFromServer(stream);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributed3DObject::destroy()\r\n{\r\n\tParent::destroy();\r\n\tm_DistributedClass=NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributed3DObject::xDistributed3DObject() : xDistributedObject()\r\n{\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributed3DObject::~xDistributed3DObject()\r\n{\r\n\r\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid xDistributed3DObject::performScopeQuery(TNL::GhostConnection *connection)\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (!netInterface)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\tif (!distObjects)\r\n\t{ \r\n\t\treturn;\r\n\t}\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\txDistributedObject*dobject = *begin;\r\n\t\tif (dobject)\r\n\t\t{\t\r\n\t\t\t//if (getSessionID() == dobject->getSessionID())\r\n\t\t\t{\r\n\t\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid\nxDistributed3DObject::doInitUpdate()\n{\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tint blockIndex = prop->getBlockIndex();\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\tprop->setFlags(E_DP_NEEDS_SEND );\r\n\t\t}\r\n\t}\n\tsetUpdateState(E_DO_US_PENDING);\n\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributed3DObject::updateAll()\r\n{\r\n\r\n\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props[i];\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\tint blockIndex = prop->getBlockIndex();\r\n\t\tif (propInfo)\r\n\t\t{\r\n\t\t\tsetMaskBits(1<getInterface();\r\n\tvtConnection *con = (vtConnection*)theConnection;\r\n\txDistributedClient *client = (xDistributedClient*)netInterface->getDistObjectInterface()->getByUserID(con->getUserID(),E_DC_BTYPE_CLIENT);\r\n\t\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\tIDistributedObjects *distInterface = netInterface->getDistObjectInterface();\r\n\t\t\tif (distInterface)\r\n\t\t\t{\r\n\t\t\t\tsetServerID(theConnection->getGhostIndex(this));\r\n\t\t\t\tsetSessionID(client->getSessionID());\r\n\t\t\t\t//doInitUpdate();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nbool xDistributed3DObject::onGhostAdd(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\tdistObjects->push_back(this);\r\n\t\t\tsetNetInterface(netInterface);\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributed3DObject::initProperties()\r\n{\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we iterate through the dist classes properties and create a real \r\n\t//data holding dist prop in the object !\r\n\r\n\t//xLogger::xLog(ELOGINFO,XL_START,\"init props of dist object : %s\",this->GetName().getString());\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertiesListType &props = *_class->getDistributedProperties();\r\n\t\tint userTypeCounter = 0;\r\n\r\n\t\t\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = NULL;\r\n\t\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\r\n\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\tswitch(dInfo->mValueType)\r\n\t\t\t{\r\n\t\t\t\tcase E_DC_PTYPE_3DVECTOR :\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint3F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint1F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedPoint2F(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedQuatF(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedString(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t{\r\n\t\t\t\t\tprop = new xDistributedInteger(dInfo,30,3000);\r\n\t\t\t\t\tgetDistributedPorperties()->push_back(prop);\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t attaching prop : %s | native type : %d\",dInfo->mName.getString(),dInfo->mNativeType);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\r\n\t\t\tif (dInfo->mNativeType == E_DC_3D_NP_USER )\r\n\t\t\t{\r\n\t\t\t\tint blockID = _class->getFirstUserField() + userTypeCounter;\r\n\t\t\t\tuserTypeCounter++;\r\n\t\t\t\tprop->setBlockIndex(blockID);\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tprop->setBlockIndex(dInfo->mNativeType);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty*\r\nxDistributed3DObject::getProperty(int nativeType)\r\n{\r\n\t//return Parent::getProperty(nativeType);\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (prop->getPropertyInfo()->mNativeType == nativeType)\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty*\r\nxDistributed3DObject::getUserProperty(const char*name)\r\n{\r\n\t//return Parent::getUserProperty(name);\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (!strcmp(prop->getPropertyInfo()->mName.getString(),name))\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributed3DObject::update(float time)\r\n{\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributed3DObject::prepare()\r\n{\r\n\tParent::prepare();\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_NETOBJECT_RPC(xDistributed3DObject,c2sGetOwnerShip,\r\n\t\t\t\t\t\t\t(TNL::U32 userSrcID),(userSrcID),\r\n\t\t\t\t\t\t\tTNL::NetClassGroupGameMask, TNL::RPCGuaranteedOrdered,TNL::RPCToGhostParent, 0)\r\n{\r\n\r\n\t//setMaskBits(PositionMask);\r\n}\r\n\r\nvoid\r\nxDistributed3DObject::onGhostRemove()\r\n{\r\n\tif (getNetInterface())\r\n\t{\r\n\r\n\t\tif(!getNetInterface()->IsServer())\r\n\t\t{\r\n\t\t\tgetNetInterface()->addDeleteObject(this);\r\n\t\t}\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"removing...\");\r\n\t\tgetNetInterface()->getDistObjectInterface()->removeObject(this);\r\n\t}\r\n}\r\n#include \"pch.h\"\r\n#include \"GProfile.h\"\r\n#include \"GException.h\"\r\n#include \"DirectoryListing.h\"\r\n#include //for: memcpy()\r\n\r\n#ifndef _WIN32\r\n\t#include \r\n#endif\r\n\r\n\r\n#ifdef _WIN32\r\n\t#include \r\n#endif\r\n\r\nstatic GProfile *g_AlternateProfile = 0;\r\nGProfile *SetProfile(GProfile *pApplicationProfile)\r\n{\r\n\tGProfile *pReturn = g_AlternateProfile;\r\n\tg_AlternateProfile = pApplicationProfile;\r\n\treturn pReturn;\r\n}\r\n\r\nGProfile &GetProfile()\r\n{\r\n\tstatic GProfile *s_pDefaultProfile = 0;\r\n\tif (g_AlternateProfile)\r\n\t\treturn *g_AlternateProfile;\r\n\tif (!s_pDefaultProfile)\r\n\t\ts_pDefaultProfile = new GProfile (\"txml.txt\",\"XML_CONFIG_FILE\");\r\n\treturn *s_pDefaultProfile;\r\n}\r\n\r\n\r\nGProfile::GProfile(const char *pzFileName, const char *pzEnvOverride )\r\n\t: m_bCached(0)\r\n{\r\n\tm_strEnvOverride = pzEnvOverride;\r\n\tm_strBaseFileName = pzFileName; // no path\r\n\r\n\tGString strConfigFileDefault;\r\n#ifdef _WIN32\t\t\t\t\t// like \"txml.txt\"\r\n\tstrConfigFileDefault.Format(\"c:\\\\%s\",pzFileName);\r\n#else\r\n\tstrConfigFileDefault.Format(\"/%s\",pzFileName);\r\n#endif\r\n\t// env var like \"XML_CONFIG_FILE\"\r\n\tif (getenv(pzEnvOverride))\r\n\t\t// Use the system environment setting\r\n\t\tm_strFile = getenv(pzEnvOverride);\r\n\telse\r\n\t\t// Use the default\r\n\t\tm_strFile = strConfigFileDefault;\r\n}\r\n\r\n\r\n//\r\n// load the profile configuration file yourself, \r\n// and create this object \"with no disk config file\"\r\nGProfile::GProfile(const char *szBuffer, long dwSize)\r\n{\r\n\tProfileParse(szBuffer, dwSize);\r\n}\r\n\r\n\r\n// create a profile from the supplied file name\r\nGProfile::GProfile(const char *pzFilePathAndName )\r\n\t: m_bCached(0)\r\n{\r\n\tm_strEnvOverride = \"NONE\";\r\n\tm_strBaseFileName = CDirectoryListing::LastLeaf(pzFilePathAndName); //\"txml.txt\";\r\n\r\n\tif (pzFilePathAndName && pzFilePathAndName[0])\r\n\t\t// use the supplied pzFilePathAndName\r\n\t\tm_strFile = pzFilePathAndName;\r\n\r\n}\r\n\r\n\r\nGProfile::~GProfile()\r\n{\r\n\tDestroy();\r\n}\r\n\r\nvoid GProfile::Destroy()\r\n{\r\n\tGListIterator itSections(&m_lstSections);\r\n\twhile (itSections())\r\n\t{\r\n\t\tSection *pSection = (Section *)itSections++;\r\n\r\n\t\tGListIterator itNVP(&pSection->m_lstNVP);\r\n\t\twhile (itNVP())\r\n\t\t{\r\n\t\t\tNameValuePair *pNVP = (NameValuePair *)itNVP++;\r\n\t\t\tdelete pNVP;\r\n\t\t}\r\n\r\n\t\tdelete pSection;\r\n\t}\r\n\r\n\tm_lstSections.RemoveAll();\r\n}\r\n\r\n#ifdef _WIN32\r\nvoid GProfile::ThrowLastError(const char *pzFile)\r\n{\r\n\tLPVOID lpMsgBuf;\r\n\r\n\tDWORD dwExp = GetLastError();\r\n\tFormatMessage( \r\n\t\t\t\t\tFORMAT_MESSAGE_ALLOCATE_BUFFER | \r\n\t\t\t\t\tFORMAT_MESSAGE_FROM_SYSTEM | \r\n\t\t\t\t\tFORMAT_MESSAGE_IGNORE_INSERTS,\r\n\t\t\t\t\tNULL,\r\n\t\t\t\t\tdwExp,\r\n\t\t\t\t\tMAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language\r\n\t\t\t\t\t(LPTSTR) &lpMsgBuf,\r\n\t\t\t\t\t0,\r\n\t\t\t\t\tNULL \r\n\t\t\t\t);\r\n\r\n\tGString strTemp = (char *)lpMsgBuf;\r\n\tstrTemp.TrimRightWS();\r\n\r\n\tGString strFile;\r\n\tstrFile.Format(\"%s - %s\", (const char *)strTemp,pzFile);\r\n\tGenericException exp(dwExp,(const char *)strFile);\r\n\tLocalFree( lpMsgBuf );\r\n\tthrow exp;\r\n}\r\n#endif\r\n\r\nvoid GProfile::GetLine(GString &strLine, \r\n\t\t\t\t\t const char *szBuffer, \r\n\t\t\t\t\t int *nIdx, \r\n\t\t\t\t\t int dwSize)\r\n{\r\n\tstrLine.Empty();\r\n\r\n\twhile (*nIdx < dwSize)\r\n\t{\r\n\t\tif (szBuffer[*nIdx] == '\\n')\r\n\t\t\tbreak;\r\n\r\n\t\tstrLine += szBuffer[*nIdx];\r\n\t\t(*nIdx)++;\r\n\t}\r\n\r\n\t(*nIdx)++;\r\n}\r\n\r\nvoid GProfile::ProfileParse(const char *szBuffer, long dwSize)\r\n{\r\n\tSection *pSection = 0;\r\n\r\n\t// parse the file\r\n\tint nIdx = 0;\r\n\twhile (nIdx < dwSize)\r\n\t{\r\n\t\tGString strLine;\r\n\t\tGetLine(strLine, szBuffer, &nIdx, dwSize);\r\n\r\n\r\n\t\tstrLine.TrimRightWS();\r\n\t\tstrLine.TrimLeftWS();\r\n\t\tif ((strLine.IsEmpty()) || (strLine[0] == ';'))\r\n\t\t\tcontinue;\r\n\r\n\r\n\t\tstrLine.Replace(\"\\\\n\", '\\n');\r\n\r\n\t\tif (strLine[0] == '[')\r\n\t\t{\r\n\t\t\tint nIdx = strLine.Find(']');\r\n\t\t\tif (nIdx == -1)\r\n\t\t\t\tnIdx = strLine.Length();\r\n\r\n\t\t\t// new section\r\n\t\t\tpSection = new Section;\r\n\t\t\tpSection->m_strName = strLine.Mid(1, nIdx - 1);\r\n\t\t\tpSection->m_strName.TrimLeftWS();\r\n\t\t\tpSection->m_strName.TrimRightWS();\r\n\r\n\t\t\tm_lstSections.AddLast(pSection);\r\n\t\t}\r\n\t\telse if (pSection)\r\n\t\t{\r\n\t\t\tint nIdx = strLine.Find('=');\r\n\t\t\tif (nIdx == -1)\r\n\t\t\t\tcontinue;\r\n\t\t\tNameValuePair *pNVP = new NameValuePair;\r\n\t\t\tpSection->m_lstNVP.AddLast(pNVP);\r\n\t\t\tpNVP->m_strName = strLine.Left(nIdx);\r\n\t\t\tpNVP->m_strName.TrimLeftWS();\r\n\t\t\tpNVP->m_strName.TrimRightWS();\r\n\t\t\t\r\n\t\t\tpNVP->m_strValue = strLine.Mid(nIdx + 1);\r\n\t\t\tpNVP->m_strValue.TrimLeftWS();\r\n\t\t\tpNVP->m_strValue.TrimRightWS();\r\n\t\t}\r\n\t}\r\n\tm_bCached = true;\r\n}\r\n\r\nvoid GProfile::Load()\r\n{\r\n\tif (m_bCached)\r\n\t\treturn;\r\n\r\n\t// destroy the cached objects\r\n\tDestroy();\r\n\r\n\tchar *szBuffer = 0;\r\n\tlong dwSize = 0;\r\n\r\n\r\n\r\n#ifdef _WIN32\r\n\t\r\n\t\t// open the file\r\n\t\tHANDLE hFile = CreateFile((const char *)m_strFile, \r\n\t\t\t\t\t\t\t\t GENERIC_READ, 0, 0, OPEN_EXISTING,\r\n\t\t\t\t\t\t\t\t FILE_ATTRIBUTE_NORMAL, 0);\r\n\r\n\t\tdwSize = GetFileSize(hFile, NULL); \r\n \r\n\t\tszBuffer = new char[dwSize + 1];\r\n\r\n\t\t// read the file\r\n\t\tlong dwRead;\r\n\t\tif (!ReadFile(hFile, szBuffer, dwSize, (DWORD *)&dwRead, 0))\r\n\t\t{\r\n\t\t\tdelete [] szBuffer;\r\n\t\t\tCloseHandle(hFile);\r\n\t\t}\r\n\r\n\t\t// close the file\r\n\t\tCloseHandle(hFile);\r\n\r\n\r\n#else\r\n\t// open the file\r\n\tGString strTemp;\r\n\tint nResult = strTemp.FromFile((const char *)m_strFile, 0);\r\n\r\n\tszBuffer = new char[strTemp.Length() + 1];\r\n\tmemcpy(szBuffer,(const char *)strTemp, strTemp.Length());\r\n\tdwSize = strTemp.Length();\r\n\r\n#endif\r\n\r\n\r\n\t// terminate the buffer\r\n\t//szBuffer[dwSize] = 0;\r\n\r\n\tProfileParse(szBuffer, dwSize);\r\n\r\n\tdelete [] szBuffer;\r\n\r\n}\r\n\r\nGProfile::Section *GProfile::FindSection(const char *szSection)\r\n{\r\n\tLoad();\r\n\r\n\tSection *pRet = 0;\r\n\r\n\tGListIterator itSections(&m_lstSections);\r\n\twhile ( itSections() && (!pRet))\r\n\t{\r\n\t\tSection *pSection = (Section *)itSections++;\r\n\r\n\t\tif (pSection->m_strName.CompareNoCase(szSection) == 0)\r\n\t\t\tpRet = pSection;\r\n\t}\r\n\r\n\treturn pRet;\r\n}\r\n\r\nGProfile::NameValuePair *GProfile::FindKey(const char *szKey, GProfile::Section *pSection)\r\n{\r\n\tNameValuePair *pRet = 0;\r\n\t\r\n\tif (pSection)\r\n\t{\r\n\t\tGListIterator itNVP(&pSection->m_lstNVP);\r\n\t\twhile ((itNVP()) && (!pRet))\r\n\t\t{\r\n\t\t\tNameValuePair *pNVP = (NameValuePair *)itNVP++;\r\n\t\t\tif (pNVP->m_strName.CompareNoCase(szKey) == 0)\r\n\t\t\t\tpRet = pNVP;\r\n\t\t}\r\n\t}\r\n\r\n\treturn pRet;\r\n}\r\n\r\n// function retrieves the names of all sections\r\nvoid GProfile::GetSectionNames(GStringList *lpList)\r\n{\r\n\tLoad();\r\n\r\n\tif (lpList)\r\n\t{\r\n\t\tGListIterator itSections(&m_lstSections);\r\n\t\twhile (itSections())\r\n\t\t{\r\n\t\t\tSection *pSection = (Section *)itSections++;\r\n\t\t\tlpList->AddLast(pSection->m_strName);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst GList *GProfile::GetSection(const char *szSectionName)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\r\n\tif (pSection)\r\n\t\treturn &pSection->m_lstNVP;\r\n\t\r\n\treturn 0;\r\n}\r\n\r\n\r\n// written by sean, not sure what this is about...\r\nstatic bool IsTrue(char chValue)\r\n{\r\n\tbool bRet; \r\n\t\r\n\tif (chValue > '1')\r\n\t\tbRet = ((chValue & 0x10) != 0);\r\n\telse\r\n\t\tbRet = ((chValue & 0x01) != 0);\r\n\t\t\r\n\treturn bRet;\r\n}\r\n\r\n// function retrieves a boolean from the specified section\r\nshort GProfile::GetBool(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\tchar chTest = '0';\r\n\t\t\tif (!pNVP->m_strValue.IsEmpty())\r\n\t\t\t\tchTest = pNVP->m_strValue[0];\r\n\t\t\treturn IsTrue(chTest);\r\n\t\t}\r\n\t\telse if (bThrowNotFound)\r\n\t\t{\r\n\t\t\t// throw key not found\r\n\r\n\t\t}\r\n\t}\r\n\telse if (bThrowNotFound)\r\n\t{\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n// function retrieves a boolean from the specified section\r\nshort GProfile::GetBoolean(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\tif (pNVP->m_strValue.CompareNoCase(\"true\") == 0 ||\r\n\t\t\t\tpNVP->m_strValue.CompareNoCase(\"on\") == 0 ||\r\n\t\t\t\tpNVP->m_strValue.CompareNoCase(\"yes\") == 0 ||\r\n\t\t\t\tpNVP->m_strValue.CompareNoCase(\"1\") == 0)\r\n\t\t\t{\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse if (bThrowNotFound)\r\n\t\t{\r\n\r\n\t\t}\r\n\t}\r\n\telse if (bThrowNotFound)\r\n\t{\r\n\t\t// throw key not found\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n\r\n// function retrieves a long from the specified section\r\nlong GProfile::GetLong(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\tif (!pNVP->m_strValue.IsEmpty())\r\n\t\t\t\treturn atol((const char *)pNVP->m_strValue);\r\n\t\t}\r\n\t\telse if (bThrowNotFound)\r\n\t\t{\r\n\t\t\t// throw key not found\r\n\r\n\t\t}\r\n\t}\r\n\telse if (bThrowNotFound)\r\n\t{\r\n\t\t// throw key not found\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nconst char *GProfile::GetPath(const char *szSectionName, const char *szKey, short bThrowNotFound)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\tif ( !( pNVP->m_strValue.Right(1) == \"/\" || pNVP->m_strValue.Right(1) == \"\\\\\") )\r\n\t\t\t{\r\n\t\t#ifdef _WIN32\r\n\t\t\t\tpNVP->m_strValue += \"\\\\\";\r\n\t\t#else\r\n\t\t\t\tpNVP->m_strValue += \"/\";\r\n\t\t#endif\r\n\t\t\t}\r\n\t\t\treturn pNVP->m_strValue;\r\n\t\t}\r\n\t\telse if (bThrowNotFound)\r\n\t\t{\r\n\t\t\t// throw key not found\r\n\r\n\t\t}\r\n\t}\r\n\telse if (bThrowNotFound)\r\n\t{\r\n\t\t// throw key not found\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n// function retrieves a string from the specified section\r\nconst char *GProfile::GetString(const char *szSectionName, const char *szKey, short bThrowNotFound /* = true */)\r\n{\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\treturn (const char *)pNVP->m_strValue;\r\n\t\t}\r\n\t\telse if (bThrowNotFound)\r\n\t\t{\r\n\t\t\t// throw key not found\r\n\r\n\t\t}\r\n\t}\r\n\telse if (bThrowNotFound)\r\n\t{\r\n\t\t// throw key not found\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nvoid GProfile::SetString(const char *szSectionName, const char *szKey, const char *szValue)\r\n{\r\n\tm_bCached = true;\r\n\r\n\tSection *pSection = FindSection(szSectionName);\r\n\tif (!pSection)\r\n\t{\r\n\t\tpSection = new Section;\r\n\t\tpSection->m_strName = szSectionName;\r\n\t\tpSection->m_strName.TrimLeftWS();\r\n\t\tpSection->m_strName.TrimRightWS();\r\n\r\n\t\tm_lstSections.AddLast(pSection);\r\n\t}\r\n\r\n\tif (pSection)\r\n\t{\r\n\t\tNameValuePair *pNVP = FindKey(szKey, pSection);\r\n\t\tif (!pNVP)\r\n\t\t{\r\n\t\t\tpNVP = new NameValuePair;\r\n\t\t\tpSection->m_lstNVP.AddLast(pNVP);\r\n\t\t\tpNVP->m_strName = szKey;\r\n\t\t\tpNVP->m_strName.TrimLeftWS();\r\n\t\t\tpNVP->m_strName.TrimRightWS();\r\n\t\t}\r\n\t\t\t\r\n\t\tif (pNVP)\r\n\t\t{\r\n\t\t\tpNVP->m_strValue = szValue;\r\n\t\t\tpNVP->m_strValue.TrimLeftWS();\r\n\t\t\tpNVP->m_strValue.TrimRightWS();\r\n\t\t}\r\n\t}\r\n}\r\n#include \"pGearbox.h\"\n#include \"vtPhysXAll.h\"\n\n#include \n\n#define DEF_SIZE .25\n#define DEF_MAXRPM 5000\n#define DEF_MAXPOWER 100\n#define DEF_FRICTION 0\n#define DEF_MAXTORQUE 340 // ~ F1 Jos Verstappen\n\n#define DEF_TORQUE 100 // In case no curve is present\n\n// If USE_HARD_REVLIMIT is used, any rpm above the max. RPM\n// returns a 0 engine torque. Although this works, it gives quite\n// hard rev limits (esp. when in 1st gear). Better is to supply\n// a curve which moves down to 0 torque when rpm gets above maxRPM,\n// so a more natural (smooth) balance is obtained (and turn\n// this define off)\n//#define USE_HARD_REVLIMIT\n\n\nvoid pGearBox::SetGear(int gear)\n{\n\n/*#ifdef LTRACE\nqdbg(\"pGearBox:SetGear(%d)\\n\",gear);\n#endif\n*/\n //QASSERT_V(gear>=0&&gearPreCalcDriveLine();\n}\n\n\n\nvoid pGearBox::CalcForces()\n{\n\n/*#ifdef LTRACE\n//qdbg(\"pGearBox::CalcForces()\\n\");\n#endif\n\t*/\n}\n\n/************\n* Integrate *\n************/\nvoid pGearBox::Integrate()\n// Based on current input values, adjust the engine\n{\n int t;\n bool ac=true;// RMGR->IsEnabled(RManager::ASSIST_AUTOCLUTCH);\n\n pDriveLineComp::Integrate();\n\n // The shifting process\n if(autoShiftStart)\n {\n\n\t\n //t=RMGR->time->GetSimTime()-autoShiftStart;\n\tt=car->_lastDT;\n if(ac)car->GetDriveLine()->EnableAutoClutch();\n\t\n // We are in a shifting operation\n if(curGear!=futureGear)\n {\n\t\n // We are in the pre-shift phase\n if(t>=timeToDeclutch)\n {\n\t\t \n\t\t//qdbg(\"Shift: declutch ready, change gear\\n\");\n // Declutch is ready, change gear\n SetGear(futureGear);\n // Trigger gear shift sample\n //car->GetRAPGear()->GetSample()->Play();\n if(ac)\n\t\t\tcar->GetDriveLine()->SetClutchApplication(1.0f);\n } else\n {\n // Change clutch\n if(ac)\n car->GetDriveLine()->SetClutchApplication((t*1000/timeToDeclutch)/1000.0f);\n }\n\t \n } else\n {\n // We are in the post-shift phase\n if(t>=timeToClutch+timeToDeclutch)\n {\n//qdbg(\"Shift: clutch ready, end shift\\n\");\n // Clutch is ready, end shifting process\n#ifdef OBS_MANUAL_CLUTCH\n clutch=1.0f;\n#endif\n // Conclude the shifting process\n autoShiftStart=0;\n if(ac)\n {\n\t\t\n car->GetDriveLine()->SetClutchApplication(0.0f);\n car->GetDriveLine()->DisableAutoClutch();\n }\n } else\n {\n // Change clutch\n \n\t\t if(ac)car->GetDriveLine()->SetClutchApplication(\n ((t-timeToClutch)*1000/timeToDeclutch)/1000.0f);\n\t\t\n }\n }\n }\n}\nvoid pGearBox::OnGfxFrame()\n{\n\t/*\n//qdbg(\"pGearBox:OnGfxFrame()\\n\");\n\n if(autoShiftStart==0)\n {\n // No shift in progress; check shift commands from the controllers\n if(RMGR->controls->control[RControls::T_SHIFTUP]->value)\n {\n//qdbg(\"Shift Up!\\n\");\n if(curGeartime->GetSimTime();\n switch(curGear)\n {\n case 0: futureGear=2; break; // From neutral to 1st\n case 1: futureGear=0; break; // From reverse to neutral\n default: futureGear=curGear+1; break;\n }\n }\n } else if(RMGR->controls->control[RControls::T_SHIFTDOWN]->value)\n {\n autoShiftStart=RMGR->time->GetSimTime();\n if(curGear!=1) // Not in reverse?\n {\n switch(curGear)\n {\n case 0: futureGear=1; break; // From neutral to reverse\n case 2: futureGear=0; break; // From 1st to neutral\n default: futureGear=curGear-1; break;\n }\n }\nqdbg(\"Switch back to futureGear=%d\\n\",futureGear);\n }\n }\n */\n}\n/*\nbool pGearBox::LoadState(QFile *f)\n{\nRDriveLineComp::LoadState(f);\nf->Read(&curGear,sizeof(curGear));\nf->Read(&autoShiftStart,sizeof(autoShiftStart));\nf->Read(&futureGear,sizeof(futureGear));\nreturn TRUE;\n}\nbool pGearBox::SaveState(QFile *f)\n{\nRDriveLineComp::SaveState(f);\nf->Write(&curGear,sizeof(curGear));\nf->Write(&autoShiftStart,sizeof(autoShiftStart));\nf->Write(&futureGear,sizeof(futureGear));\nreturn TRUE;\n}\n\n*/\n/*\nbool pGearBox::Load(QInfo *info,cstring path)\n// 'path' may be 0, in which case the default \"engine\" is used\n{\nchar buf[128];\nint i;\n\nif(!path)path=\"engine\";\n\n// Shifting (still in the 'engine' section for historical reasons)\nsprintf(buf,\"%s.shifting.automatic\",path);\nif(info->GetInt(buf))\nflags|=AUTOMATIC;\n//qdbg(\"Autoshift: flags=%d, buf='%s'\\n\",flags,buf);\nsprintf(buf,\"%s.shifting.shift_up_rpm\",path);\nshiftUpRPM=info->GetFloat(buf,3500);\nsprintf(buf,\"%s.shifting.shift_down_rpm\",path);\nshiftDownRPM=info->GetFloat(buf,2000);\nsprintf(buf,\"%s.shifting.time_to_declutch\",path);\ntimeToDeclutch=info->GetInt(buf,500);\nsprintf(buf,\"%s.shifting.time_to_clutch\",path);\ntimeToClutch=info->GetInt(buf,500);\n\n//qdbg(\"declutch=%d, clutch=%d (buf=%s)\\n\",timeToDeclutch,timeToClutch,buf);\n\n// Gearbox\npath=\"gearbox\"; // !\nsprintf(buf,\"%s.gears\",path);\ngears=info->GetInt(buf,4);\nif(gears>=MAX_GEAR-1)\n{ qwarn(\"Too many gears defined (%d, max=%d)\",gears,MAX_GEAR-1);\ngears=MAX_GEAR-1;\n}\nfor(i=0;iGetFloat(buf,1.0);\nsprintf(buf,\"%s.gear%d.inertia\",path,i);\ngearInertia[i+1]=info->GetFloat(buf);\n}\n\nreturn TRUE;\n}\n*/\n\n\n\n#ifdef OBS\n\nfloat pGearBox::GetInertiaAtDifferential()\n// Returns effective inertia as seen at the input of the differential.\n// This may be used as the input for the differential.\n// Notice the gearing from differential to engine.\n{\n\tfloat totalInertia;\n\tfloat ratio,ratioSquared;\n\n\t// From differential towards engine\n\t// First, the driveshaft\n\tratio=endRatio;\n\tratioSquared=ratio*ratio;\n\ttotalInertia=inertiaDriveShaft*ratioSquared;\n\n\t// Gearing and engine\n\t// Both engine and the faster rotating part of the gearbox are at\n\t// the engine side of the clutch. Therefore, both interia's from those\n\t// 2 objects must be scaled to get the effective inertia.\n\t// Note this scaling factor is squared, for reasons\n\t// I explain on the Racer website.\n\tratio=gearRatio[curGear]*endRatio;\n\tratioSquared=ratio*ratio;\n\ttotalInertia+=clutch*(gearInertia[curGear]+inertiaEngine)*ratioSquared;\n\treturn totalInertia;\n}\n\nfloat pGearBox::GetInertiaForWheel(RWheel *w)\n// Return effective inertia as seen in the perspective of wheel 'w'\n// Takes into account any clutch effects\n{\n\tfloat totalInertia;\n\tfloat inertiaBehindClutch;\n\tfloat NtfSquared,NfSquared;\n\t//float rotationA;\n\tRWheel *wheel;\n\tint i;\n\n\t// Calculate total ratio multiplier; note the multipliers are squared,\n\t// and not just a multiplier for the inertia. See Gillespie's book,\n\t// 'Fundamentals of Vehicle Dynamics', page 33.\n\tNtfSquared=gearRatio[curGear]*endRatio;\n\tNtfSquared*=NtfSquared;\n\n\t// Calculate total inertia that is BEHIND the clutch\n\tNfSquared=endRatio*endRatio;\n\tinertiaBehindClutch=gearInertia[curGear]*NtfSquared+\n\t\tinertiaDriveShaft*NfSquared;\n\t// Add inertia of attached and powered wheels\n\t// This is a constant, so it should be cached actually (except\n\t// when a wheel breaks off)\n\n\t/* for(i=0;iGetWheels();i++)\n\t{\n\twheel=car->GetWheel(i);\n\tif(wheel->IsPowered()&&wheel->IsAttached())\n\tinertiaBehindClutch+=wheel->GetRotationalInertia()->x;\n\t}\n\t*/ \n\t// Add the engine's inertia based on how far the clutch is engaged\n\t/*\n\ttotalInertia=inertiaBehindClutch+clutch*inertiaEngine*NtfSquared;\n\t*/\n\treturn totalInertia;\n}\n// Return effective torque for wheel 'w'\n// Takes into account any clutch effects\nfloat pGearBox::GetTorqueForWheel(pWheel *w)\n\n{\n\t//qdbg(\"clutch=%f, T=%f, ratio=%f\\n\",clutch,torque,gearRatio[curGear]*endRatio);\n\n\t//return clutch*torque*gearRatio[curGear]*endRatio;\n}\n\n\n#endif\n\n\n\nvoid pGearBox::setToDefault()\n{\n\n\tgears = 7;\n\tgearRatio[0]=-2.59f;\n\tgearInertia[0]=0.1f;\n\n\tgearRatio[1]=2.94f;\n\tgearInertia[1]=0.06f;\n\n\tgearRatio[2]=2.056f;\n\tgearInertia[2]=0.05f;\n\n\tgearRatio[3]=1.520f;\n\tgearInertia[3]=0.04f;\n\n\tgearRatio[4]=1.179f;\n\tgearInertia[4]=0.03f;\n\n\tgearRatio[5]=1.030f;\n\tgearInertia[5]=0.02f;\n\n\tgearRatio[6]=0.914f;\n\tgearInertia[6]=0.01f;\n\n\tautoShiftStart = 1;\n\ttimeToClutch=25.0f;\n\ttimeToDeclutch=352.0f;\n\tshiftDownRPM= 3000.0f;\n\tshiftUpRPM=7000.0f;\n\n\n\n}\n\npGearBox::pGearBox(pVehicle *_car)\n: pDriveLineComp()\n{\n\t//SetName(\"gearbox\");\n\n\tcar=_car;\n\tReset();\n}\npGearBox::~pGearBox()\n{\n}\n\nvoid pGearBox::Reset()\n// Reset all variables\n{\n\tint i;\n\n\tflags=0;\n\ttimeToDeclutch=timeToClutch=0;\n\tautoShiftStart=1;\n\tfutureGear=0;\n\tfor(i=0;i#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nusing namespace xUtils;\r\nusing namespace vtAgeia;\r\n\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\n\r\n// [3/31/2009 master] Temp ! \r\n#include \"IParameter.h\"\r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// Declaration of rigid body related attribute callback function\r\n//\r\nint registerRigidBody(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tint error = 0 ;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks :\r\n\t//\r\n\tassert(target);\r\n\t\r\n\tCKAttributeManager* attman = GetPMan()->GetContext()->GetAttributeManager();\r\n\t\r\n\tCKParameterOut *bodyParameter = target->GetAttributeParameter(attributeType);\r\n\t\r\n\tassert(bodyParameter);\r\n\tCKStructHelper sHelper(bodyParameter);\r\n\tif (sHelper.GetMemberCount() ==0 )\r\n\t{\t//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\t}\r\n\r\n\t\r\n\r\n\tif (set)\r\n\t{\r\n\r\n\t\tpRigidBody* body = GetPMan()->getBody(target);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// attribute has been added at run-time, post pone the registration to the next frame.\r\n\t\t//\r\n\t\tif ( isPostJob && GetPMan()->GetContext()->IsPlaying() )\r\n\t\t{\r\n\t\t\tpAttributePostObject postAttObject(target->GetID(),registerRigidBody,attributeType);\r\n\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tif(!GetPMan()->GetContext()->IsPlaying())\r\n\t\t\treturn true;\r\n\r\n\r\n\t\tpObjectDescr *objDecr = new pObjectDescr();\r\n\t\tIParameter::Instance()->copyTo(objDecr,bodyParameter);\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Pivot override ? \r\n\t\t//\r\n\t\tint attPivot = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_PIVOT_OFFSET);\r\n\t\tif (target->HasAttribute(attPivot)){\r\n\t\t\tIParameter::Instance()->copyTo(objDecr->pivot,target->GetAttributeParameter(attPivot));\r\n\t\t\tobjDecr->mask << OD_Pivot;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Pivot override ? \r\n\t\t//\r\n\t\tint attMass = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_MASS_SETUP);\r\n\t\tif (target->HasAttribute(attMass)){\r\n\t\t\tIParameter::Instance()->copyTo(objDecr->mass,target->GetAttributeParameter(attMass));\r\n\t\t\tobjDecr->mask << OD_Mass;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// register the body\r\n\t\t//\r\n\t\tif(!body && !(objDecr->flags & BF_SubShape) )\r\n\t\t{\r\n\t\t\tbody = pFactory::Instance()->createRigidBody(target,*objDecr);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tbody->setInitialDescription(objDecr);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t//SAFE_DELETE(objDecr);\r\n\r\n\r\n\t}\r\n\r\n\r\n\t//xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"register object\");\r\n\r\n\r\n\terror++;\r\n\r\n\treturn error;\r\n}\r\n\r\n\r\n/*\r\n//################################################################\r\n//\r\n// Not being used\r\n//\r\nint registerRigidBody(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\r\nif (!GetPMan()->GetContext()->IsPlaying() && set)\r\n{\r\n\r\nusing namespace vtTools::ParameterTools;\r\nCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\r\nXString errString;\r\nerrString.Format(\"attr added\");\r\nxLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errString.Str());\r\n\r\nXString value = getDefaultValue(distanceParameter);\r\n}\r\n\r\nreturn 0;\r\n}\r\n\r\n*/\r\n#include \"ckall.h\"\r\n\r\nCKERROR CreateMeshAddProto(CKBehaviorPrototype **pproto);\r\nint MeshAdd(const CKBehaviorContext& context);\r\n\r\nextern void CleanUp(CKBehavior *beh);\r\nextern void Load(CKBehavior *beh,CKScene *scn);\r\n\r\nCKObjectDeclaration *FillMeshAddDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Mesh Addition\");\t\r\n\tod->SetDescription(\"Duplicates objects\");\r\n\tod->SetCategory(\"Mesh Modifications/Multi Mesh\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xc73102f,0x4f8c574b));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateMeshAddProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateMeshAddProto(CKBehaviorPrototype **pproto)\r\n{\r\n\t\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Mesh Addition\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Original\", CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Additional\", CKPGUID_3DENTITY);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(MeshAdd);\r\n\t\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\nint MeshAdd(const CKBehaviorContext& behcontext)\r\n{\r\n\t \r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tCK3dEntity *oe = (CK3dEntity *)beh->GetInputParameterObject(0);\r\n\tCKMesh *om=oe->GetCurrentMesh();\r\n\r\n\tCK3dEntity *ae = (CK3dEntity *)beh->GetInputParameterObject(1);\r\n\tCKMesh *am=ae->GetCurrentMesh();\r\n\r\n\tVxVector oePos;\r\n\toe->GetPosition(&oePos,NULL);\r\n\t\r\n\tint oVCount = om->GetVertexCount();\r\n\tint aVCount = am->GetVertexCount();\r\n\r\n\tint oFCount = om->GetFaceCount();\r\n\tint aFCount = am->GetFaceCount();\r\n\r\n\r\n\tom->SetVertexCount(oVCount+aVCount);\r\n\tom->SetFaceCount(oFCount+aFCount);\r\n\r\n\r\n\tVxVector oVPos,oVNormals;\r\n\tfloat u,v;\r\n\t\r\n\r\n\tVxVector aePos,Delta;\r\n\tae->GetPosition(&aePos,NULL);\r\n\t\r\n\tDelta = aePos-oePos;\r\n\r\n\tfor (int j = 0; j< aVCount; j++){\r\n\r\n\t\tam->GetVertexPosition(j,&oVPos);\r\n\t\toVPos += Delta;\r\n\t\tom->SetVertexPosition(j+oVCount,&oVPos);\r\n\r\n\t\tam->GetVertexNormal(j,&oVNormals);\r\n\t\tom->SetVertexNormal(j+oVCount,&oVNormals);\r\n\t\r\n\t\tam->GetVertexTextureCoordinates(j,&u,&v,-1);\r\n\t\tom->SetVertexTextureCoordinates(j+oVCount,u,v,-1);\r\n\t}\r\n\r\n\tfor ( int l=0;l< aFCount;l++){\r\n\t\r\n\t\tint a,b,c;\r\n\t\tVxVector FN;\r\n\t\tam->GetFaceVertexIndex(l,a,b,c);\r\n\t\tom->SetFaceVertexIndex(l+oFCount,a+oVCount,b+oVCount,c+oVCount);\r\n\t\tCKMaterial *OMAT = am->GetFaceMaterial(l);\r\n\t\tom->SetFaceMaterial(l+oFCount,OMAT);\r\n\t}\r\n\r\n\r\n\tom->BuildFaceNormals();\r\n\tbeh->ActivateOutput(0);\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\n#include \r\n\r\n#include \"vtPhysXAll.h\"\r\n#include \"pVehicleAll.h\"\r\n#include \"pWorldSettings.h\"\r\n\r\n\r\n#include \r\n#include \r\n\r\n\r\nusing namespace vtTools::AttributeTools;\r\n\r\n\r\n\r\nint pWorld::hadBrokenJoint()\r\n{\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor && actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body && body->hasBrokenJoint)\r\n\t\t\t{\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nvoid pWorld::cleanBrokenJoints()\r\n{\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor && actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body )\r\n\t\t\t{\r\n\t\t\t\tbody->hasBrokenJoint = false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pWorld::step(float stepsize)\r\n{\r\n\tif (getScene())\r\n\t{\r\n\r\n\t\tCKVariableManager* vm = GetPMan()->GetContext()->GetVariableManager();\r\n\t\tif( !vm )\r\n\t\t\treturn;\r\n\r\n\t\tint disable = 0 ;\r\n\t\tvm->GetValue(\"Physic/Disable Physics\",&disable);\r\n\t\tif (disable)\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\r\n\t\t//int hasBroken = hadBrokenJoint();\r\n\r\n\r\n\r\n\t\tNxU32 nbTransforms = 0; \r\n\t\tNxActiveTransform *activeTransforms = getScene()->getActiveTransforms(nbTransforms); \r\n\r\n\t\tupdateVehicles(stepsize);\r\n\r\n\t\tupdateClothes();\r\n\r\n#ifdef HAS_FLUIDS\r\n\t\tupdateFluids();\r\n#endif\r\n\r\n\r\n\t\tvtAgeia::pWorldSettings *wSettings = GetPMan()->getDefaultWorldSettings();\r\n\r\n\t\tif (wSettings->isFixedTime())\r\n\t\t\tgetScene()->setTiming(wSettings->getFixedTimeStep() * 10.0f, wSettings->getNumIterations() , NX_TIMESTEP_FIXED);\r\n\t\t/*else\t\t\tgetScene()->setTiming( (stepsize * 100 ) / wSettings->getNumIterations() , wSettings->getNumIterations() , NX_TIMESTEP_VARIABLE);\t\t*/\r\n\t\t/*\r\n\t\tNxU32 nbIter = 0 ;\r\n\t\tint op =2;\r\n\t\tNxTimeStepMethod mode = NX_TIMESTEP_FIXED;*/\r\n\t\t/*float stepSz;getScene()->getTiming(stepSz,nbIter,op);*/\r\n\t\r\n\t\tint nbDeleted = GetPMan()->_checkRemovalList();\r\n\t\tif (nbDeleted)\r\n\t\t{\r\n\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"objects to delete\");\r\n\t\t\t//return;\r\n\t\t}\r\n\r\n\r\n\t\tint nbReset = GetPMan()->_getRestoreMap()->Size();\r\n\t\tif(nbReset)\r\n\t\t{\r\n\t\t\tGetPMan()->_checkResetList();\r\n\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"objects to reset\");\r\n\t\t\tGetPMan()->_getResetList().Clear();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tint nbCheck = GetPMan()->getCheckList().Size();\r\n\t\tif(nbCheck)\r\n\t\t{\r\n\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"objects to check\");\r\n\t\t\tGetPMan()->_checkObjectsByAttribute(GetPMan()->GetContext()->GetCurrentLevel()->GetCurrentScene());\r\n\t\t\tGetPMan()->_checkListCheck();\r\n\t\t\tif(nbCheck)\r\n\t\t\t{\r\n\t\t\t\tif(nbCheck && GetPMan()->sceneWasChanged )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"objects to check & and scene change, aborting\");\r\n\t\t\t\t}\r\n\t\t\t\t//GetPMan()->checkWorlds();drdrdr\r\n\t\t\t\t//return;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\r\n\r\n\r\n\t\t\tif(!getScene()->checkResults(NX_RIGID_BODY_FINISHED,false))\r\n\t\t\t{\r\n\t\t\t\tgetScene()->simulate(stepsize * GetPMan()->GetContext()->GetTimeManager()->GetTimeScaleFactor() );\r\n\t\t\t}\r\n\t\t\t\r\n\r\n\t\t\tif(getScene()->checkResults(NX_RIGID_BODY_FINISHED,false) /*&& hasBroken==0*/)\r\n\t\t\t{\r\n\t\t\t\t//if(nbDeleted)\t\t\t\t\treturn;\r\n\t\t\t\tint nbNewPostObjects = GetPMan()->getAttributePostObjects().Size();\r\n\t\t\t\t/*\r\n\t\t\t\tif(m_bCompletedLastFrame)\r\n\t\t\t\t{\r\n\t\t\t\t//getScene()->simulate(stepsize * GetPMan()->GetContext()->GetTimeManager()->GetTimeScaleFactor() );\r\n\t\t\t\tgetScene()->simulate( m_fTimeSinceLastCallToSimulate );\r\n\t\t\t\tm_bCompletedLastFrame = false;\r\n\t\t\t\tm_fTimeSinceLastCallToSimulate = 0.0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tm_fTimeSinceLastCallToSimulate +=(stepsize * GetPMan()->GetContext()->GetTimeManager()->GetTimeScaleFactor());\r\n\r\n\t\t\t\tif(getScene()->checkResults(NX_ALL_FINISHED,false))\r\n\t\t\t\t{*/\r\n\t\t\t\tm_bCompletedLastFrame = true;\r\n\t\t\t\tif(nbTransforms && activeTransforms && !nbDeleted && !nbReset && !nbCheck && !nbNewPostObjects /*&& hasBroken== 0*/) \r\n\t\t\t\t{ \r\n\t\t\t\t\tfor(NxU32 i = 0; i < nbTransforms; ++i) \r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\t// the user data of the actor holds the game object pointer \r\n\t\t\t\t\t\tNxActor *actor = activeTransforms[i].actor;\r\n\t\t\t\t\t\t//XString name = actor->getName();\r\n\t\t\t\t\t\tif (actor !=NULL)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpRigidBody *body = static_cast(actor->userData);\r\n\r\n\t\t\t\t\t\t\t// update the game object's transform to match the NxActor\r\n\t\t\t\t\t\t\tif(body !=NULL)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tassert(body && body->getEntID());\r\n\t\t\t\t\t\t\t\tNxMat34 transformation = activeTransforms[i].actor2World;\r\n\t\t\t\t\t\t\t\tVxQuaternion rot = pMath::getFrom(transformation.M);\r\n\t\t\t\t\t\t\t\tVxVector pos = pMath::getFrom(transformation.t);\r\n\t\t\t\t\t\t\t\tVxVector pos2 = pMath::getFrom(transformation.t);\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(body->getEntID()));\r\n\t\t\t\t\t\t\t\tif (ent !=NULL && ent->GetClassID() != CKCID_3DOBJECT)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t//assert(ent && ent->GetID());\r\n\r\n\t\t\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t\t\tXString errMessage= \"update body\";\r\n\t\t\t\t\t\t\t\terrMessage+=ent->GetName();\r\n\t\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errMessage.Str());\r\n\t\t\t\t\t\t\t\t*/\r\n\r\n\t\t\t\t\t\t\t\t//NxShape *mainShape=body->getMainShape();\r\n\t\t\t\t\t\t\t\tif (ent !=NULL)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tint hier = (body->getFlags() & BF_Hierarchy );\r\n\t\t\t\t\t\t\t\t\tent->SetPosition(&pos,NULL);\r\n\t\t\t\t\t\t\t\t\tent->SetQuaternion(&rot,NULL);\t\r\n\t\t\t\t\t\t\t\t\tbody->updateSubShapes();\r\n\t\t\t\t\t\t\t\t\tbody->onMove(true,true,pos,rot);\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tif (body->hasWheels())\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tbody->wakeUp();\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\t\t//xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Invalid entity due simulation.\");\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t//xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Invalid Body due simulation.\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n\t\t\t\t}\r\n\r\n\t\t\t\tNxU32 error=0;\r\n\t\t\t\tgetScene()->flushStream();\r\n\t\t\t\tgetScene()->fetchResults(NX_ALL_FINISHED,true,&error);\r\n\t\t\t\tif(error !=0)\r\n\t\t\t\t{\r\n\t\t\t\t\tXString err=\"error fetching results : \";\r\n\t\t\t\t\terr << error;\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,err.Str());\r\n\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\t//cleanBrokenJoints();\r\n\t\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"world has broken joints !\");\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\r\n\t//\tupdate Virtools from hardware objects\r\n\r\n\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tNxActor** actors = getScene()->getActors();\r\n\tif(getCompartment())\r\n\t{\r\n\t\twhile(nbActors--)\r\n\t\t{\r\n\t\t\tNxActor* actor = *actors++;\r\n\t\t\tif(actor && actor->userData != NULL)\r\n\t\t\t{\r\n\t\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\t\tif (body && body->getActor()->getCompartment())\r\n\t\t\t\t{\r\n\t\t\t\t\tNxMat34 transformation = actor->getGlobalPose();\r\n\t\t\t\t\tVxQuaternion rot = pMath::getFrom(transformation.M);\r\n\t\t\t\t\tVxVector pos = pMath::getFrom(transformation.t);\r\n\t\t\t\t\tVxVector pos2 = pMath::getFrom(transformation.t);\r\n\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(body->getEntID()));\r\n\t\t\t\t\t//NxShape *mainShape=body->getMainShape();\r\n\t\t\t\t\tif (ent)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t//int hier = (body->getFlags() & BF_Hierarchy );\r\n\t\t\t\t\t\tent->SetPosition(&pos,NULL);\r\n\t\t\t\t\t\tent->SetQuaternion(&rot,NULL);\t\r\n\t\t\t\t\t\tbody->updateSubShapes();\r\n\t\t\t\t\t\tbody->onMove(true,true,pos,rot);\r\n\t\t\t\t\t\tif (body->hasWheels())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//\t\tbody->wakeUp();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\t//xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Invalid Body due simulation.\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/*\r\n\tif(getScene()->checkResults(NX_RIGID_BODY_FINISHED))\r\n\t{\r\n\tNxU32 error;\r\n\tgetScene()->flushStream();\r\n\tgetScene()->fetchResults(NX_RIGID_BODY_FINISHED,true,&error);\r\n\t}\r\n\t*/\r\n\r\n\t/*\r\n\r\n\tint err = error;\r\n\r\n\tNxReal maxTimestep;\r\n\tNxTimeStepMethod method;\r\n\tNxU32 maxIter;\r\n\tNxU32 numSubSteps;\r\n\t//getScene()->getTiming(maxTimestep, maxIter, method, &numSubSteps);\r\n\r\n\r\n\tint op2 = 3;\r\n\top2++;\r\n\t*/\r\n\r\n}\r\n\r\n\r\nint pWorld::onPreProcess()\r\n{\r\n\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tpRigidBody *body = static_cast(actor->userData);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tpVehicle *v = body->getVehicle();\r\n\t\t\tif (!v && body->hasWheels())\r\n\t\t\t{\r\n\t\t\t\tint nbShapes = actor->getNbShapes();\r\n\t\t\t\tNxShape ** slist = (NxShape **)actor->getShapes();\r\n\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpWheel *wheel = sinfo->wheel;\r\n\t\t\t\t\t\t\tpWheel2* wheel2 = dynamic_cast(wheel);\r\n\r\n\t\t\t\t\t\t\tif ( wheel2 && (wheel2->getCallMask().test(CB_OnPreProcess)) )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\twheel2->onPreProcess();\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//if (v && (v->getCallMask().test(CB_OnPreProcess)))\r\n\t\t\t//\tv->onPreProcess();\r\n\t\t}\r\n\t}\r\n\r\n\treturn 1;\r\n}\r\nint pWorld::onPostProcess()\r\n{\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tpRigidBody *body = static_cast(actor->userData);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tpVehicle *v = body->getVehicle();\r\n\t\t\tif (!v && body->hasWheels())\r\n\t\t\t{\r\n\t\t\t\tint nbShapes = actor->getNbShapes();\r\n\t\t\t\tNxShape ** slist = (NxShape **)actor->getShapes();\r\n\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpWheel *wheel = sinfo->wheel;\r\n\t\t\t\t\t\t\tpWheel2* wheel2 = dynamic_cast(wheel);\r\n\r\n\t\t\t\t\t\t\tif ( wheel2 && (wheel2->getCallMask().test(CB_OnPostProcess)))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\twheel2->onPostProcess();\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//if (v && (v->getCallMask().test(CB_OnPostProcess)))\r\n\t\t\t//v->onPostProcess();\r\n\t\t}\r\n\t}\r\n\r\n\treturn 1;\r\n}\r\n#ifndef __P_SERIALIZER_H__\r\n#define __P_SERIALIZER_H__\r\n\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n/** \\addtogroup Serialization\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Class to import and export NxStream files. Those files can be created by 3D related content editors\r\nsuch as Maya and 3D-SMax. Also, you can dump the entire Virtools scene and load it in the\r\nsupplied PhysX Viewer.\r\n*/\r\nclass MODULE_API pSerializer\r\n{\r\npublic:\r\n\tpSerializer();\r\n\t~pSerializer();\r\n\r\n\tstatic pSerializer*Instance();\r\n\tNXU::NxuPhysicsCollection *getCollection(const char *pFilename,int type);\r\n\tbool overrideBody(pRigidBody *body,int flags);\r\n\tint loadCollection(const char*fileName,int flags);\r\n\tint saveCollection(const char*filename);\r\n\tvoid parseFile(const char*filename,int flags);\r\n\r\nprotected:\r\n\tNXU::NxuPhysicsCollection *mCollection;\r\n\r\nprivate:\r\n};\r\n\r\n/** @} */\r\n\r\n#endif#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDirToArrayDecl();\r\nCKERROR CreateDirToArrayProto(CKBehaviorPrototype **pproto);\r\nint DirToArray(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDirToArrayDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Dir to Array\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetCategory(\"Narratives/Files\");\r\n\t\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x4be0703f,0x208b5a7f));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDirToArrayProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDirToArrayProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Dir to Array\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Fill\");\r\n\tproto->DeclareInput(\"Loop In\");\r\n\r\n\tproto->DeclareOutput(\"Reseted\");\r\n\tproto->DeclareOutput(\"Loop Out\");\r\n\r\n\tproto->DeclareInParameter(\"Directory\", CKPGUID_STRING,\"0\");\r\n\tproto->DeclareInParameter(\"Mask\", CKPGUID_STRING,\"0\");\r\n\tproto->DeclareInParameter(\"Recursive\", CKPGUID_BOOL,\"0\");\r\n\r\n\r\n\t\r\n\tproto->DeclareOutParameter(\"entry\", CKPGUID_STRING);\r\n\tproto->DeclareOutParameter(\"counter\", CKPGUID_INT);\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(DirToArray);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\n\r\n#include \r\nstd::vectorflist;\r\n\r\n\r\nint counter = 0 ;\r\n\r\nint DirToArray(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\tXString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\tXString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\r\n\tint rec;\r\n\r\n\tbeh->GetInputParameterValue(2,&rec);\r\n\r\n\t\r\n\r\n\tif( beh->IsInputActive(0) ){\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tflist.erase(flist.begin(),flist.end());\r\n\r\n\t\tCKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec);\r\n\t\tchar* str = NULL;\r\n\t\twhile(str = MyParser.GetNextFile())\r\n\t\t\tflist.push_back(XString(str));\r\n\r\n\t\tcounter = 0;\r\n\t\tbeh->ActivateInput(1,TRUE);\r\n\r\n\t\t\r\n\t}\r\n\r\n\r\n\tif( beh->IsInputActive(1) ){\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\r\n\t\tif ( counter < flist.size() ){\r\n\t\t\tXString entry = flist.at(counter);\r\n\t\t\tCKParameterOut * pout = beh->GetOutputParameter(0);\r\n\t\t\tpout->SetStringValue(entry.Str() );\r\n\t\t\t\t\r\n\t\t\tcounter++;\r\n\t\t\tbeh->SetOutputParameterValue(1,&counter);\r\n\t\t\tbeh->ActivateOutput(1);\r\n\r\n\t\t}else{\r\n\r\n\t\t\tbeh->SetOutputParameterValue(1,&counter);\r\n\t\t\tcounter = 0 ; \r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVControl2Decl();\r\nCKERROR CreatePVControl2Proto(CKBehaviorPrototype **pproto);\r\nint PVControl2(const CKBehaviorContext& behcontext);\r\nCKERROR PVControl2CB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\r\nenum bInTrigger\r\n{\r\n\tTI_DO,\r\n};\r\n\r\nenum bOutputs\r\n{\r\n\r\n\tO_Gear,\r\n\tO_MPH,\r\n\tO_GearRatio,\r\n\tO_MotorRPM,\r\n\t/*O_RPM,\r\n\tO_RPM_WHEELS,\r\n\tO_RATIO,*/\r\n};\r\n\r\n\r\nenum bTInputs\r\n{\r\n\r\n\tIT_On,\r\n\tIT_Off,\r\n\tIT_Forward,\r\n\tIT_Backwards,\r\n\tIT_Left,\r\n\tIT_Right,\r\n\tIT_HandBrake,\r\n\tIT_GUP,\r\n\tIT_GDOWN\r\n\t\r\n};\r\n\r\nenum bTOutputs\r\n{\r\n\tOT_On,\r\n\tOT_Off,\r\n\tOT_GearUp,\r\n\tOT_GearDown,\r\n};\r\n\r\n\r\nenum bSettings\r\n{\r\n\tbs_Manual,\r\n};\r\n\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPVControl2Decl\r\n// FullName: FillBehaviorPVControl2Decl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPVControl2Decl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVCarControl\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Physics Car\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x26371b1c,0x4e3924));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVControl2Proto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVControl2Proto\r\n// FullName: CreatePVControl2Proto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVControl2Proto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVCarControl\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareInput(\"Forward\");\r\n\tproto->DeclareInput(\"Backward\");\r\n\tproto->DeclareInput(\"Turn Left\");\r\n\tproto->DeclareInput(\"Turn Right\");\r\n\tproto->DeclareInput(\"Handbrake\");\r\n\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"GearUp\");\r\n\tproto->DeclareOutput(\"GearDown\");\r\n\t\r\n\t\r\n\r\n\tproto->DeclareOutParameter(\"Current Gear\",CKPGUID_INT,\"-1\");\r\n\tproto->DeclareOutParameter(\"MPH\",CKPGUID_FLOAT,\"-1\");\r\n\tproto->DeclareOutParameter(\"Gear Ratio\",CKPGUID_FLOAT,\"-1\");\r\n\tproto->DeclareOutParameter(\"Motor RPM\",CKPGUID_FLOAT,\"-1\");\r\n\r\n\r\n\tproto->DeclareSetting(\"Automatic\",CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareSetting(\"Semi Analog\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\r\n\t/* PVControl2 \r\n\r\n\tPVControl2 is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVControl2.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::setCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::setKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::enableGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::enableCollision(). \r\n\t
\r\n\tMass Offset: The new mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: The initial shape position in the bodies local space.\r\n\t
\r\n\tNotify Collision: Enables collision notification.This is necessary to use collisions related building blocks. \r\n\t
\r\n\tTransformation Locks: Specifies in which dimension a a transformation lock should occour.\r\n\t
\r\n\tLinear Damping: The new linear damping scale.\r\n\t
\r\n\tAngular Damping: The new linear damping scale.\r\n\t
\r\n\r\n\tFilter Groups: Sets the filter mask of the initial or sub shape.\r\n\t
\r\n\r\n\r\n\tCollisions Group: Enables input for collisions group.\r\n\t
\r\n\tKinematic Object: Enables input for kinematic object.\r\n\t
\r\n\tGravity: Enables input for gravity.\r\n\t
\r\n\tCollision: Enables input for collision. \r\n\t
\r\n\tMas Offset: Enables input for mass offset. \r\n\t
\r\n\tPivot Offset: Enables input for pivot offset.\r\n\t
\r\n\tNotify Collision: Enables input for collision. \r\n\t
\r\n\tLinear Damping: Enables input for linear damping.\r\n\t
\r\n\tAngular Damping: Enables input for angular damping.\r\n\t
\r\n\tFilter Groups: Enables input for filter groups.\r\n\t
\r\n\t\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t\r\n*/\r\n\tproto->SetBehaviorCallbackFct( PVControl2CB );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVControl2);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PVControl2\r\n// FullName: PVControl2\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n#define BBSParameter(A) DWORD s##A;\\\r\n\tbeh->GetLocalParameterValue(A,&s##A)\r\n\r\nint PVControl2(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) bbSErrorME(E_PE_REF);\r\n\r\n\r\n\tpRigidBody *body = NULL;\r\n\r\n\tbody = GetPMan()->getBody(target);\r\n\tif (!body)\r\n\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\r\n\tpVehicle *v = body->getVehicle();\r\n\tif (!v)\r\n\t{\r\n\t\tbbSErrorME(E_PE_NoVeh);\r\n\t}\r\n\r\n\r\n\r\n\tif( beh->IsInputActive(IT_On) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_On,FALSE);\r\n\t\tbeh->ActivateOutput(OT_On);\r\n\r\n\r\n\t}\r\n\r\n\tif( beh->IsInputActive(IT_Off) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_Off,FALSE);\r\n\t\tbeh->ActivateOutput(OT_Off);\r\n\t\treturn 0;\r\n\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\r\n\t//\t\tAcceleration \r\n\t//\r\n\r\n\r\n\tfloat acceleration = 0.0f;\r\n\tfloat steering = 0.0;\r\n\r\n\tint gearUP= 0;\r\n\tint gearDown= 0;\r\n\tint handbrake = 0;\r\n\r\n\r\n\t/*\r\n\tv->setControlState(E_VCS_ACCELERATION,acceleration);\r\n\tv->setControlState(E_VCS_HANDBRAKE,handbrake);\r\n\tv->setControlState(E_VCS_STEERING,steering);\r\n\tv->setControlMode(E_VCS_ACCELERATION,E_VCSM_DIGITAL);\r\n\tv->setControlMode(E_VCS_STEERING,E_VCSM_DIGITAL);\r\n\t*/\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tAcceleration + Handbrake\r\n\t//\r\n\r\n\tif( beh->IsInputActive(IT_Forward) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_Forward,FALSE);\r\n\t\tacceleration = 1.0f;\r\n\t\tv->setControlState(E_VCS_ACCELERATION,acceleration);\r\n\t}\r\n\r\n\tif( beh->IsInputActive(IT_Backwards) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_Backwards,FALSE);\r\n\t\tacceleration = -1.0f;\r\n\t\tv->setControlState(E_VCS_ACCELERATION,acceleration);\r\n\t}\r\n\r\n\t\r\n\tif( beh->IsInputActive(IT_HandBrake) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_HandBrake,FALSE);\r\n\t\thandbrake = 1;\r\n\t\tv->setControlState(E_VCS_HANDBRAKE,handbrake);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tSteering\t\r\n\tif( beh->IsInputActive(IT_Left) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_Left,FALSE);\r\n\t\tsteering = 1.0f;\r\n\t\tv->setControlState(E_VCS_STEERING,steering);\r\n\t}\r\n\r\n\tif( beh->IsInputActive(IT_Right) )\r\n\t{\r\n\t\tbeh->ActivateInput(IT_Right,FALSE);\r\n\t\tsteering = -1.0f;\r\n\t\tv->setControlState(E_VCS_STEERING,steering);\r\n\t}\r\n\r\n\t//if(acceleration !=0.0f || steering !=0.0f || handbrake)\r\n\t//v->control(steering,false,acceleration,false,handbrake);\r\n\r\n\r\n\tint semiAnalog = 0;\r\n\tbeh->GetLocalParameterValue(1,&semiAnalog);\r\n\t\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tGears\t\r\n\t//\r\n\tint automatic=0;\r\n\tbeh->GetLocalParameterValue(bs_Manual,&automatic);\r\n\tv->setAutomaticMode(automatic);\r\n\r\n\r\n\tint lastGear=0;\r\n\tbeh->GetOutputParameterValue(O_Gear,&lastGear);\r\n\r\n\tint currentGear = 0;\r\n\r\n\tif (v->getGears())\r\n\t{\r\n\t\tcurrentGear = v->getGears()->getGear();\r\n\t}\r\n\r\n\tif (!automatic)\r\n\t{\r\n\r\n\t\tif( beh->IsInputActive(IT_GUP) )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(IT_GUP,FALSE);\r\n\t\t\tgearUP =1;\r\n\t\t}\r\n\t\tif( beh->IsInputActive(IT_GDOWN) )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(IT_GDOWN,FALSE);\r\n\t\t\tgearDown=1;\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tif ( gearUP && !gearDown)\r\n\t{\r\n\t\tv->setControlState(E_VCS_GUP,1);\r\n\t\tv->setControlState(E_VCS_GDOWN,0);\r\n\t}else{\r\n\t\tv->setControlState(E_VCS_GUP,0);\r\n\t}\r\n\r\n\tif ( !gearUP && gearDown)\r\n\t{\r\n\t\tv->setControlState(E_VCS_GUP,0);\r\n\t\tv->setControlState(E_VCS_GDOWN,1);\r\n\t}\r\n\tif ( !gearUP)\r\n\t{\r\n\t\tv->setControlState(E_VCS_GUP,0);\r\n\t}\r\n\tif ( !gearDown)\r\n\t{\r\n\t\tv->setControlState(E_VCS_GDOWN,0);\r\n\t}\r\n\r\n/*\r\n\r\n\tif (!automatic)\r\n\t{\r\n\t\t\r\n\t\tif( beh->IsInputActive(IT_GUP) )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(IT_GUP,FALSE);\r\n\t\t\tgearUP =1;\r\n\t\t}\r\n\r\n\t\tif( beh->IsInputActive(IT_GDOWN) )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(IT_GDOWN,FALSE);\r\n\t\t\tgearDown=1;\r\n\t\t}\r\n\r\n\t\tif (gearUP && !gearDown)\r\n\t\t{\r\n\t\t\tv->gearUp();\r\n\t\t}\r\n\t\tif (!gearUP && gearDown)\r\n\t\t{\r\n\t\t\tv->gearDown();\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\tif (v->getGears())\r\n\t\t{\r\n\t\t\tif (currentGear!=lastGear)\r\n\t\t\t{\r\n\t\t\t\tif (currentGear > lastGear)\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->ActivateOutput(OT_GearUp);\r\n\t\t\t\t}else\r\n\t\t\t\t\tbeh->ActivateOutput(OT_GearDown);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n*/\r\n\r\n\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tVehicle Data : \r\n\t//\r\n\r\n\r\n\tfloat mph = v->getMPH();\r\n\tbeh->SetOutputParameterValue(O_MPH,&mph);\r\n\r\n\tfloat gRatio = v->_getGearRatio();\r\n\tbeh->SetOutputParameterValue(O_GearRatio,&gRatio);\r\n\tbeh->SetOutputParameterValue(O_Gear,&currentGear);\r\n\tif (v->getMotor())\r\n\t{\r\n\t\tfloat rpm = v->getMotor()->getRpm();\r\n\t\tbeh->SetOutputParameterValue(O_MotorRPM,&rpm);\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR PVControl2CB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tint automatic=0;\r\n\t\t\tbeh->GetLocalParameterValue(bs_Manual,&automatic);\r\n\r\n\t\t\tint nbI = beh->GetInputCount();\r\n\t\t\t\r\n\t\t\tif (automatic)\r\n\t\t\t{\r\n\t\t\t\tif (nbI > IT_GUP )\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->DeleteInput( IT_GUP);\r\n\t\t\t\t\tbeh->DeleteInput( IT_GUP);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (!automatic)\r\n\t\t\t{\r\n\t\t\t\tif (nbI < IT_GDOWN )\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->AddInput(\"Gear Up\");\r\n\t\t\t\t\tbeh->AddInput(\"Gear Down\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\nFIND_PATH(VTDEV41DIR\r\n NAMES dev.exe devr.exe\r\n PATHS\r\n [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Virtools\\\\Dev\\\\4.1;InstallPath]\r\n )\r\nMARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)\r\nSET(VTDEV41 1)\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npWheelContactData*\r\npWheel1::getContact(){\r\n\r\n\treturn new pWheelContactData();\r\n}\r\n\r\nfloat pWheel1::getRpm()const{\treturn NxMath::abs(_turnVelocity * 60.f);}\r\n\r\nNxActor *pWheel1::getTouchedActor(){ \treturn contactInfo->otherActor; }\r\n\r\nvoid pWheel1::_tick(float dt)\r\n{\r\n\r\n\tif(!hasGroundContact())\r\n\t\tupdateContactPosition();\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// Calculate the wheel rotation around the roll axis\r\n\t//\r\n\tupdateAngularVelocity(dt*0.001f, false);\r\n\r\n\tfloat motorTorque=0.0;\r\n\r\n\tif(getWheelFlag(WF_Accelerated)) \r\n\t{\r\n\t\t/*if (handBrake && getWheelFlag(NX_WF_AFFECTED_BY_HANDBRAKE)) \r\n\t\t{\r\n\t\t\t// Handbrake, blocking!\r\n\t\t}*/\r\n\t\t\r\n\t\tif (hasGroundContact()) \r\n\t\t{\r\n\t\t\t// Touching, force applies\r\n\t\t\tNxVec3 steeringDirection;\r\n\t\t\tgetSteeringDirection(steeringDirection);\r\n\t\t\tsteeringDirection.normalize();\r\n\t\t\tNxReal localTorque = motorTorque;\r\n\t\t\tNxReal wheelForce = localTorque / _radius;\r\n\t\t\tsteeringDirection *= wheelForce;\r\n\t\t\twheelCapsule->getActor().addForceAtPos(steeringDirection, contactInfo->contactPosition);\r\n\t\t\tif(contactInfo->otherActor->isDynamic())\r\n\t\t\t\tcontactInfo->otherActor->addForceAtPos(-steeringDirection, contactInfo->contactPosition);\r\n\t\t} \r\n\t}\r\n\t\r\n\tNxMat34& wheelPose = getWheelCapsule()->getGlobalPose();\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( _angle );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(_turnAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\r\n\tfloat a = _angle;\r\n\tfloat b = getWheelRollAngle();\r\n\r\n\t\r\n\tsetWheelPose(wheelPose);\r\n\t//setWheelOrientation(wheelPose.M);\r\n\r\n\r\n\tcontactInfo->reset();\r\n}\r\n\r\n\r\nvoid pWheel1::_updateVirtoolsEntity(bool position,bool rotation)\r\n{\r\n\r\n\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(getEntID()));\r\n\tif (ent && position)\r\n\t{\r\n\r\n\t\t/*\r\n\t\tNxWheelShape *wShape = getWheelShape();\r\n\t\tNxMat34 pose = wShape->getGlobalPose();\r\n\t\tNxWheelContactData wcd; \r\n\t\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\tNxVec3 suspensionOffsetDirection;\r\n\t\tpose.M.getColumn(1, suspensionOffsetDirection);\r\n\t\tsuspensionOffsetDirection =-suspensionOffsetDirection;\r\n\r\n\t\tif (contactShape && wcd.contactForce > -1000)\r\n\t\t{\r\n\t\t\tNxVec3 toContact = wcd.contactPoint - pose.t;\r\n\t\t\tdouble alongLength = suspensionOffsetDirection.dot(toContact);\r\n\t\t\tNxVec3 across = toContact - alongLength * suspensionOffsetDirection;\r\n\t\t\tdouble r = wShape->getRadius();\r\n\t\t\tdouble pullBack = sqrt(r*r - across.dot(across));\r\n\t\t\tpose.t += (alongLength - pullBack) * suspensionOffsetDirection;\r\n\t\t} else {\r\n\t\t\tpose.t += wShape->getSuspensionTravel() * suspensionOffsetDirection;\r\n\t\t}\r\n\r\n\t\tVxVector oPos = getFrom(pose.t);\r\n\t\tent->SetPosition(&oPos);\r\n\r\n\t\tif (hasGroundContact())\r\n\t\t{\r\n\r\n\t\t\r\n\t\t}else\r\n\t\t{\r\n\t\t\t//\t\t\tVxVector gPos = getWheelPos();\r\n\t\t\t//\t\t\tent->SetPosition(&gPos,getBody()->GetVT3DObject());\r\n\t\t}\r\n\r\n\t\t*/\r\n\t}\r\n\tif (ent && rotation)\r\n\t{\r\n\t\t//float rollAngle = getWheelRollAngle();\r\n\t\t//rollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n\r\n\t\tVxQuaternion rot = pMath::getFrom( getWheelPose().M );\r\n\t\tent->SetQuaternion(&rot,NULL);\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\n\r\nvoid pWheel1::updateContactPosition() \r\n{\r\n\tcontactInfo->contactPositionLocal = getFrom(_maxPosition) - NxVec3(0, _maxSuspension+_radius, 0);\r\n}\r\nvoid pWheel1::setAngle(float angle) \r\n{\r\n\t_angle = angle;\r\n\r\n\tNxReal Cos, Sin;\r\n\tNxMath::sinCos(_angle, Sin, Cos);\r\n\tNxMat33 wheelOrientation = wheelCapsule->getLocalOrientation();\r\n\twheelOrientation.setColumn(0, NxVec3( Cos, 0, Sin ));\r\n\twheelOrientation.setColumn(2, NxVec3( Sin, 0,-Cos ));\r\n\tsetWheelOrientation(wheelOrientation);\r\n\r\n}\r\n\r\nvoid pWheel1::updateAngularVelocity(float lastTimeStepSize, bool handbrake) \r\n{\r\n\tif((mWheelFlags & WF_AffectedByHandbrake) && handbrake) \r\n\t{\r\n\t\t_turnVelocity = 0;\r\n\t} \r\n\telse if (contactInfo->isTouching()) \r\n\t{\r\n\t\tNxReal wheelPerimeter = NxTwoPi * _radius;\r\n\t\tNxReal newTurnVelocity = contactInfo->relativeVelocity / wheelPerimeter;\r\n\t\t_turnVelocity = newTurnVelocity;\r\n\t\t_turnAngle += _turnVelocity * lastTimeStepSize * NxTwoPi;\r\n\t} \r\n\telse \r\n\t{\r\n\t\t_turnVelocity *= 0.99f;\r\n\t\t_turnAngle += _turnVelocity;\r\n\t}\r\n\t\r\n\twhile(_turnAngle >= NxTwoPi)\r\n\t\t_turnAngle -= NxTwoPi;\r\n\twhile (_turnAngle < 0)\r\n\t\t_turnAngle += NxTwoPi;\r\n\r\n\tsetWheelRollAngle(_turnAngle);\r\n\r\n}\r\n\r\nvoid pWheel1::getSteeringDirection(NxVec3& dir) \r\n{\r\n\tif(mWheelFlags & (WF_SteerableInput | WF_SteerableAuto)) \r\n\t{\r\n\t\twheelCapsule->getGlobalOrientation().getColumn(0, dir);\r\n\t} \r\n\telse \r\n\t{\r\n\t\twheelCapsule->getActor().getGlobalOrientation().getColumn(0, dir);\r\n\t}\r\n}\r\n\r\nvoid pWheel1::tick(bool handbrake, float motorTorque, float brakeTorque, float dt)\r\n{\r\n\r\n\tif(getWheelFlag(WF_Accelerated)) \r\n\t{\r\n\t\tif (handbrake && getWheelFlag(WF_AffectedByHandbrake)) \r\n\t\t{\r\n\t\t\t// Handbrake, blocking!\r\n\t\t}\r\n\t\telse if (hasGroundContact()) \r\n\t\t{\r\n\t\t\t// Touching, force applies\r\n\t\t\tNxVec3 steeringDirection;\r\n\t\t\tgetSteeringDirection(steeringDirection);\r\n\t\t\tsteeringDirection.normalize();\r\n\t\t\tNxReal localTorque = motorTorque;\r\n\t\t\tNxReal wheelForce = localTorque / _radius;\r\n\t\t\tsteeringDirection *= wheelForce;\r\n\t\t\twheelCapsule->getActor().addForceAtPos(steeringDirection, contactInfo->contactPosition);\r\n\t\t\tif(contactInfo->otherActor->isDynamic())\r\n\t\t\t\tcontactInfo->otherActor->addForceAtPos(-steeringDirection, contactInfo->contactPosition);\r\n\t\t} \r\n\t}\r\n\r\n\tNxReal OneMinusBreakPedal = 1-brakeTorque;\r\n\r\n\t/*\r\n\tif(handBrake && getWheelFlag(WF_AffectedByHandbrake)) \r\n\t{\r\n\tmaterial->setDynamicFrictionV(1);\r\n\tmaterial->setStaticFrictionV(4);\r\n\tmaterial->setDynamicFriction(0.4f);\r\n\tmaterial->setStaticFriction(1.0f);\r\n\t} \r\n\telse \r\n\t{\r\n\tNxReal newv = OneMinusBreakPedal * _frictionToFront + brakeTorque;\r\n\tNxReal newv4= OneMinusBreakPedal * _frictionToFront + brakeTorque*4;\r\n\tmaterial->setDynamicFrictionV(newv);\r\n\tmaterial->setDynamicFriction(_frictionToSide);\r\n\r\n\tmaterial->setStaticFrictionV(newv*4);\r\n\tmaterial->setStaticFriction(2);\r\n\t}*/\r\n\r\n\tif(!hasGroundContact())\r\n\t\tupdateContactPosition();\r\n\tupdateAngularVelocity(dt, handbrake);\r\n\r\n\tcontactInfo->reset();\r\n}\r\nVxVector pWheel1::getWheelPos()const{ \treturn getFrom(wheelCapsule->getLocalPosition()); }\r\nvoid pWheel1::setWheelOrientation(const NxMat33& m)\r\n{ \r\n\twheelCapsule->setLocalOrientation(m); \r\n\tif (wheelConvex != NULL) \r\n\t\twheelConvex->setLocalOrientation(m); \r\n}\r\n\r\nvoid pWheel1::_updateAgeiaShape(bool position,bool rotation)\r\n{\r\n\r\n}\r\n\r\nint pWheel1::_constructWheel(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation)\r\n{\r\n\treturn 1;\r\n}\r\npWheel1::pWheel1(pRigidBody *body, pWheelDescr *descr) : pWheel(body,descr)\r\n{\r\n\twheelCapsule = NULL;\r\n\twheelConvex = NULL;\r\n\r\n\tcontactInfo = new ContactInfo();\r\n\r\n\r\n}\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n#include \"IParameter.h\"\r\n\r\n\r\nbool pFactory::_createConvexCylinder(NxConvexShapeDesc* shape,\r\n\t\t\t\t\t\t\t\t\t CK3dEntity*dstBodyReference,\r\n\t\t\t\t\t\t\t\t\t pObjectDescr *oDescr)\r\n{\r\n\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(dstBodyReference);\t// <- should never happen !\r\n\t#endif // _DEBUG\r\n\r\n\tbool result = false;\r\n\r\n\tpConvexCylinderSettings cSettingsZero;\r\n\t\r\n\tpConvexCylinderSettings &cSettings = cSettingsZero;\r\n\r\n\tif (oDescr )\r\n\t{\r\n\t\tif( (oDescr->mask & OD_ConvexCylinder)\t)\r\n\t\t\tcSettings = oDescr->convexCylinder;\r\n\t}else\r\n\t{\r\n\t\tfindSettings(cSettings,dstBodyReference);\r\n\t}\r\n\t\r\n\r\n\tcSettings.radius.value *=0.5f;\r\n\tcSettings.height.value *=0.5f;\r\n\r\n\tNxArray points;\r\n\tNxVec3 center(0,0,0);\r\n\r\n\tNxVec3 frontAxis = getFrom(cSettings.forwardAxis);\t\t\t\t// = wheelDesc->downAxis.cross(wheelDesc->wheelAxis);\r\n\tNxVec3 downAxis = getFrom(cSettings.downAxis);//downAxis *=-1.0;\t// = wheelDesc->downAxis;\r\n\tNxVec3 wheelAxis = getFrom(cSettings.rightAxis);\t\t\t\t// = wheelDesc->wheelAxis;\r\n\t\r\n\t\r\n\t//frontAxis.normalize();\r\n\tfrontAxis *= cSettings.radius.value;\r\n\t//downAxis.normalize();\r\n\tdownAxis *= cSettings.radius.value;\r\n\t//wheelAxis.normalize();\r\n\twheelAxis *= cSettings.height.value;\r\n\r\n\tNxReal step;\r\n\r\n\tif(cSettings.buildLowerHalfOnly) \r\n\t{\r\n\t\tif((cSettings.approximation& 0x1) == 0)\r\n\t\t\tcSettings.approximation++;\r\n\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(cSettings.approximation*2);\r\n\t}\r\n\telse \r\n\t{\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(cSettings.approximation);\r\n\t}\r\n\tfor(NxU32 i = 0; i < cSettings.approximation; i++) \r\n\t{\r\n\t\tNxReal iReal;\r\n\t\tif(cSettings.buildLowerHalfOnly) \r\n\t\t{\r\n\t\t\tiReal = (i > (cSettings.approximation >> 1))?(NxReal)(i+cSettings.approximation):(NxReal)i;\r\n\t\t} \r\n\t\telse \r\n\t\t{\r\n\t\t\tiReal = (NxReal)i;\r\n\t\t}\r\n\t\tNxReal Sin, Cos;\r\n\t\tNxMath::sinCos(step * iReal, Sin, Cos);\r\n\t\tNxVec3 insPoint = (downAxis * -Cos) + (frontAxis * Sin);\r\n\t\tpoints.pushBack(insPoint + wheelAxis);\r\n\t\tpoints.pushBack(insPoint - wheelAxis);\r\n\t}\r\n\r\n\tNxConvexMeshDesc convexDesc;\r\n\tconvexDesc.numVertices\t\t\t= points.size();\r\n\tconvexDesc.pointStrideBytes\t\t= sizeof(NxVec3);\r\n\tconvexDesc.points\t\t\t\t= &points[0].x;\r\n\r\n\tint cf = CF_ComputeConvex;\r\n\tcf |= cSettings.convexFlags;\r\n\tconvexDesc.flags\t\t\t\t|= cf;\r\n\r\n\t// Cooking from memory\r\n\tbool status = InitCooking();\r\n\tif (!status) {\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't initiate cooking lib!\");\r\n\t\treturn NULL;\r\n\t}\r\n\tMemoryWriteBuffer buf;\r\n\tint s = convexDesc.isValid();\r\n\tif(CookConvexMesh(convexDesc, buf)) \r\n\t{\r\n\t\t//NxConvexShapeDesc convexShapeDesc;\r\n\t\t\r\n\t\tshape->meshData = getPhysicSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\tshape->localPose.t = center;\r\n\t\tshape->localPose.M.setColumn(0, NxVec3( 1, 0, 0));\r\n\t\tshape->localPose.M.setColumn(1, NxVec3( 0,-1, 0));\r\n\t\tshape->localPose.M.setColumn(2, NxVec3( 0, 0, -1));\r\n\t\tif(shape->meshData != NULL) \r\n\t\t{\r\n\t\t\tresult = true;\r\n\t\t//\tNxU32 shapeNumber = actor->getNbShapes();\r\n\t\t//\tresult = actor->createShape(convexShapeDesc)->isConvexMesh();\r\n\t\t//\tif (!result) {\r\n\t\t//\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\t\t//\t}\r\n\t\t\t//wheel->wheelConvex->userData = wheel;\r\n\t\t}\r\n\t}\r\n\tCloseCooking();\r\n\treturn result;\r\n}\r\n\r\nvoid pRigidBody::updateCollisionSettings(pCollisionSettings collision,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\tif (shapeReference==NULL)\r\n\t\tassert (getMainShape());\r\n\r\n\tNxShape *shape = getSubShape(shapeReference);\r\n\tif (shape)\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Update groups mask \r\n\t\t//\r\n\t\tNxGroupsMask mask1;\r\n\r\n\t\tmask1.bits0 = collision.groupsMask.bits0;\r\n\t\tmask1.bits1 = collision.groupsMask.bits1;\r\n\t\tmask1.bits2 = collision.groupsMask.bits2;\r\n\t\tmask1.bits3 = collision.groupsMask.bits3;\r\n\r\n\t\tshape->setGroupsMask(mask1);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions group\r\n\t\t//\r\n\t\tshape->setGroup(collision.collisionGroup);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Skin Width\r\n\t\t//\r\n\t\tshape->setSkinWidth(collision.skinWidth);\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::updateCollisionSettings(const pObjectDescr oDescr,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\tint v = oDescr.version;\r\n\tassert(oDescr.version == pObjectDescr::E_OD_VERSION::OD_DECR_V1);\r\n\r\n\tif (shapeReference==NULL)\r\n\t\tassert (getMainShape());\r\n\r\n\tNxShape *shape = getSubShape(shapeReference);\r\n\tif (shape)\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Update groups mask \r\n\t\t//\r\n\t\tNxGroupsMask mask1;\r\n\r\n\t\tmask1.bits0 = oDescr.groupsMask.bits0;\r\n\t\tmask1.bits1 = oDescr.groupsMask.bits1;\r\n\t\tmask1.bits2 = oDescr.groupsMask.bits2;\r\n\t\tmask1.bits3 = oDescr.groupsMask.bits3;\r\n\r\n\t\tshape->setGroupsMask(mask1);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions group\r\n\t\t//\r\n\t\tshape->setGroup(oDescr.collisionGroup);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Skin Width\r\n\t\t//\r\n\t\tshape->setSkinWidth(oDescr.skinWidth);\r\n\r\n\r\n\t\t\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// CCD Setup :\r\n\t\t//\r\n\t\tif (oDescr.ccdMeshReference)\r\n\t\t{\r\n\r\n\t\t\tNxCCDSkeleton *skeleton = NULL;\r\n\t\t\tif (oDescr.ccdFlags && CCD_Shared && GetPMan()->GetContext()->GetObject(oDescr.ccdMeshReference) )\r\n\t\t\t\tskeleton = GetPMan()->getCCDSkeleton(((CKBeObject*)(GetPMan()->GetContext()->GetObject(oDescr.ccdMeshReference))));\r\n\r\n\t\t\tif (skeleton == NULL )\r\n\t\t\t\tskeleton = pFactory::Instance()->createCCDSkeleton(shapeReference,oDescr.ccdFlags);\r\n\r\n\t\t\tXString errorString;\r\n\r\n\t\t\tif (!skeleton){\r\n\t\t\t\terrorString.Format(\"Creation of CCD skeleton for %s failed!\",GetVT3DObject()->GetName());\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tshape->setCCDSkeleton(skeleton);\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// update sub mesh info : \r\n\t\t\t//\r\n\r\n\t\t\tpSubMeshInfo *sInfo = static_cast(shape->userData);\r\n\t\t\tif (sInfo){\r\n\t\t\t\tsInfo->ccdReference = oDescr.ccdMeshReference;\r\n\t\t\t\tsInfo->ccdSkeleton = skeleton;\r\n\t\t\t}\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// update actors ccd motion threshold\r\n\t\t\t//\r\n\t\t\tif(getActor())\r\n\t\t\t\tgetActor()->setCCDMotionThreshold(oDescr.ccdMotionThresold);\r\n\r\n\r\n\t\t\t//NX_SF_DYNAMIC_DYNAMIC_CCD\r\n\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// Check we have CCD enabled at all, if not then produce warning\r\n\t\t\t//\r\n\r\n\t\t\tNxPhysicsSDK *sdk = GetPMan()->getPhysicsSDK();\r\n\t\t\tif (sdk)\r\n\t\t\t{\r\n\t\t\t\tfloat ccdParameter = sdk->getParameter(NX_CONTINUOUS_CD);\r\n\t\t\t\tif (ccdParameter < 0.5f)\r\n\t\t\t\t{\r\n\t\t\t\t\terrorString.Format(\"CCD Skeleton for %s created successfully but CCD is not enabled.\\n Please goto Variable Manager and set ´Continues Collision Detection´ to 1.0f\",GetVT3DObject());\r\n\t\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_MANAGER,errorString.Str());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n}\r\n\r\nint pRigidBody::handleContactPair(NxContactPair* pair,int shapeIndex) \r\n{\r\n\r\n\thandleContactPairWheel(pair,shapeIndex);\r\n\r\n\treturn 0;\r\n}\r\n\r\n\r\nint pRigidBody::handleContactPairWheel(NxContactPair* pair,int shapeIndex) \r\n{\r\n\tif (!hasWheels())\r\n\t\treturn 0;\r\n\t\r\n\tNxContactStreamIterator i(pair->stream);\r\n\r\n\twhile(i.goNextPair())\r\n\t{\r\n\t\tNxShape * s = i.getShape(shapeIndex);\r\n\r\n\t\twhile(i.goNextPatch())\r\n\t\t{\r\n\t\t\tconst NxVec3& contactNormal = i.getPatchNormal();\r\n\r\n\t\t\twhile(i.goNextPoint())\r\n\t\t\t{\r\n\r\n\t\t\t\tconst NxVec3& contactPoint = i.getPoint();\r\n\r\n\t\t\t\t//assuming front wheel drive we need to apply a force at the wheels.\r\n\t\t\t\tif (s->is(NX_SHAPE_CAPSULE) && s->userData != NULL) \r\n\t\t\t\t{\r\n\t\t\t\t\t//assuming only the wheels of the car are capsules, otherwise we need more checks.\r\n\t\t\t\t\t//this branch can't be pulled out of loops because we have to do a full iteration through the stream\r\n\r\n\t\t\t\t\tNxQuat local2global = s->getActor().getGlobalOrientationQuat();\r\n\t\t\t\t\t\r\n\t\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\t\tif (!sInfo)return 0;\r\n\t\t\t\t\t\r\n\t\t\t\t\tpWheel1* wheel = dynamic_cast(sInfo->wheel);\r\n\t\t\t\t\tif (!wheel)return 0;\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tif (!wheel->getWheelFlag(WF_UseWheelShape))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\twheel->contactInfo->otherActor = pair->actors[1-shapeIndex];\r\n\t\t\t\t\t\twheel->contactInfo->contactPosition = contactPoint;\r\n\r\n\t\t\t\t\t\twheel->contactInfo->contactPositionLocal = contactPoint;\r\n\t\t\t\t\t\twheel->contactInfo->contactPositionLocal -= wheel->getActor()->getGlobalPosition();\r\n\t\t\t\t\t\tlocal2global.inverseRotate(wheel->contactInfo->contactPositionLocal);\r\n\r\n\t\t\t\t\t\twheel->contactInfo->contactNormal = contactNormal;\r\n\r\n\t\t\t\t\t\tif (wheel->contactInfo->otherActor->isDynamic()) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNxVec3 globalV = s->getActor().getLocalPointVelocity( getFrom(wheel->getWheelPos()) );\r\n\t\t\t\t\t\t\tglobalV -= wheel->contactInfo->otherActor->getLinearVelocity();\r\n\t\t\t\t\t\t\tlocal2global.inverseRotate(globalV);\r\n\t\t\t\t\t\t\twheel->contactInfo->relativeVelocity = globalV.x;\r\n\t\t\t\t\t\t//printf(\"%2.3f (%2.3f %2.3f %2.3f)\\n\", wheel->contactInfo.relativeVelocity,\r\n\t\t\t\t\t\t//\tglobalV.x, globalV.y, globalV.z);\r\n\t\t\t\t\t\t} \r\n\t\t\t\t\t\telse \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNxVec3 vel = s->getActor().getLocalPointVelocity( getFrom(wheel->getWheelPos()));\r\n\t\t\t\t\t\t\tlocal2global.inverseRotate(vel);\r\n\t\t\t\t\t\t\twheel->contactInfo->relativeVelocity = vel.x;\r\n\t\t\t\t\t\t\twheel->contactInfo->relativeVelocitySide = vel.z;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t//NX_ASSERT(wheel->hasGroundContact());\r\n\t\t\t\t\t\t//printf(\" Wheel %x is touching\\n\", wheel);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t*/\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\t\t\r\n\t}\r\n\t//printf(\"----\\n\");\r\n\r\n\treturn 0;\r\n}dofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\n\r\n\r\nsolution \"vtPython\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" ; \"ReleaseRedist\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\n\r\n--\tThe building blocks for vtPythonCaller\r\npackageConfig_vtPythonCaller =\r\n{\r\n\tName \t\t= \t\"vtPythonCaller\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/Behaviors/**.cpp\"\t; DROOT..\"SDK/src/core/*.cpp\" ; DROOT..\"SDK/src/Behaviors/*.def\" ; F_SHARED_SRC ; DROOT..\"build4/**.lua\" ; F_BASE_VT_SRC ; F_VT_STD_INC },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDES ; D_PY..\"include\" },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ;},\r\n\tLibDirectories = { D_PY..\"lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n}\r\n\r\n--\tIf the command line contains --ExtraDefines=\"WebPack\" , we add \"WebPack\" to the\r\n--\tpre-processor directives and also create a package to include the camera building blocks\r\n--\tas defined in packageConfig_CameraRepack\r\nif _OPTIONS[\"ExtraDefines\"] then\r\n\r\n\tif _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\tcreateStaticPackage(packageConfig_CameraRepack)\r\n\tend\r\nend\r\n\r\ncreateStaticPackage(packageConfig_vtPythonCaller)\r\n\r\n\r\nfunction onclean()\r\n\tos.rmdir(\"vs**\")\r\nend\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNDisconnectDecl();\r\nCKERROR CreateNDisconnectProto(CKBehaviorPrototype **);\r\nint NDisconnect(const CKBehaviorContext& behcontext);\r\nCKERROR NDisconnectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNDisconnectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NDisconnect\");\t\r\n\tod->SetDescription(\"Disconnects from the server\");\r\n\t\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x76531dd9,0x4a317862));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNDisconnectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\n\r\ntypedef enum BB_OT\r\n{\r\n\r\n\tBB_O_OUT,\r\n\tBB_O_ERROR\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_ERROR\r\n};\r\n\r\nCKERROR CreateNDisconnectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NDisconnect\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\t\r\n\tproto->SetFunction(NDisconnect);\r\n\t\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NDisconnect(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\tXString errorMesg(\"No network connection !\");\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\terrorMesg = \"No network connection !\";\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n//\t\tError(beh,\"No connection at the moment\",BB_OP_ERROR,TRUE,BB_O_ERROR);\r\n\t\t//xLogger::xLog(ELOGERROR,\"No Connection available. See Script :%s --> Building Block : %s\",beh->GetOwnerScript()->GetName(),\"NSCreate\" );\r\n\t\txLogger::xLog(ELOGERROR,E_LI_CONNECTION,\"No connection at the moment\");\r\n\t\tXLOG_BB_INFO;\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->IsServer())\r\n\t{\r\n\t\tcin->disconnect(connectionID);\r\n\t}\r\n\r\n\r\n\treturn 0;\r\n\t\r\n}#if !defined(EA_C2D3E6DE_B1A5_4f07_B3FA_73F108249451__INCLUDED_)\r\n#define EA_C2D3E6DE_B1A5_4f07_B3FA_73F108249451__INCLUDED_\r\n\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"pReferencedObject.h\"\r\n#include \"pCallbackObject.h\"\r\n\r\n\r\n/** \\addtogroup RigidBody\r\n@{\r\n*/\r\n\r\nstruct pContactModifyData\r\n{\r\n\r\n\t\tfloat minImpulse;\t\t\t//!< Minimum impulse value that the solver can apply. Normally this should be 0, negative amount gives sticky contacts.\r\n\t\tfloat maxImpulse;\t\t\t//!< Maximum impulse value that the solver can apply. Normally this is FLT_MAX. If you set this to 0 (and the min impulse value is 0) then you will void contact effects of the constraint.\r\n\t\tVxVector error;\t\t\t\t//!< Error vector. This is the current error that the solver should try to relax.\r\n\t\tVxVector target;\t\t\t\t//!< Target velocity. This is the relative target velocity of the two bodies.\r\n\r\n\t\t/**\r\n\t\t\\brief Constraint attachment point for shape 0. \r\n\r\n\t\tIf the shape belongs to a dynamic actor, then localpos0 is relative to the body frame of the actor. \r\n\t\tAlternatively it is relative to the world frame for a static actor. \r\n\t\t*/\r\n\t\tVxVector localpos0;\r\n\r\n\t\t/**\r\n\t\t\\brief Constraint attachment point for shape 1. \r\n\r\n\t\tIf the shape belongs to a dynamic actor, then localpos1 is relative to the body frame of the actor. \r\n\t\tAlternatively it is relative to the world frame for a static actor. \r\n\t\t*/\r\n\t\tVxVector localpos1;\r\n\r\n\t\t/**\r\n\t\t\\brief Constraint orientation quaternion for shape 0 relative to shape 0s body frame for dynamic \r\n\t\tactors and relative to the world frame for static actors. \r\n\r\n\t\tThe constraint axis (normal) is along the x-axis of the quaternion. \r\n\t\tThe Y axis is the primary friction axis and the Z axis the secondary friction axis. \r\n\t\t*/\r\n\t\tVxQuaternion localorientation0;\r\n\t\t\r\n\r\n\t\t/**\r\n\t\t\\brief Constraint orientation quaternion for shape 1 relative to shape 1s body frame for dynamic \r\n\t\tactors and relative to the world frame for static actors. \r\n\r\n\t\tThe constraint axis (normal) is along the x-axis of the quaternion. \r\n\t\tThe Y axis is the primary friction axis and the Z axis the secondary friction axis. \r\n\t\t*/\r\n\t\tVxQuaternion localorientation1;\r\n\r\n\t\t/**\r\n\t\t\\brief Static friction parameter 0.\r\n\r\n\t\t\\note 0 does not have anything to do with shape 0/1, but is related to anisotropic friction, \r\n\t\t0 is the primary friction axis.\r\n\t\t*/\r\n\t\tfloat staticFriction0;\r\n\r\n\t\t/**\r\n\t\t\\brief Static friction parameter 1.\r\n\r\n\t\t\\note 1 does not have anything to do with shape 0/1, but is related to anisotropic friction, \r\n\t\t0 is the primary friction axis.\r\n\t\t*/\r\n\t\tfloat staticFriction1;\r\n\r\n\t\t/**\r\n\t\t\\brief Dynamic friction parameter 0.\r\n\r\n\t\t\\note 0 does not have anything to do with shape 0/1, but is related to anisotropic friction, \r\n\t\t0 is the primary friction axis.\r\n\t\t*/\t\t\r\n\t\tfloat dynamicFriction0;\r\n\r\n\t\t/**\r\n\t\t\\brief Dynamic friction parameter 1.\r\n\r\n\t\t\\note 1 does not have anything to do with shape 0/1, but is related to anisotropic friction, \r\n\t\t0 is the primary friction axis.\r\n\t\t*/\r\n\t\tfloat dynamicFriction1;\r\n\t\tfloat restitution;\t\t\t//!< Restitution value.\r\n\r\n};\r\n\r\nstruct pCollisionsEntry\r\n{\r\n\tVxVector sumNormalForce;\r\n\tVxVector sumFrictionForce;\r\n\tVxVector faceNormal;\r\n\tVxVector point;\r\n\txU32 faceIndex;\r\n\tfloat pointNormalForce;\r\n\t/*float patchNormalForce;*/\r\n\tNxActor *actors[2];\r\n\tpRigidBody *bodyA;\r\n\tpRigidBody *bodyB;\r\n\tint eventType;\r\n\tfloat distance;\r\n\tCK_ID shapeEntityA;\r\n\tCK_ID shapeEntityB;\r\n\r\n\r\n\tpCollisionsEntry(){\r\n\r\n\t\tbodyB = bodyA = NULL;\r\n\t\tactors[0]=NULL;\r\n\t\tactors[1]=NULL;\r\n\t\teventType;\r\n\t\tdistance = pointNormalForce = 0.0f;\r\n\t\tshapeEntityA = shapeEntityB = 0 ;\r\n\r\n\r\n\t}\r\n};\r\ntypedef XArrayCollisionsArray;\r\n\r\n\r\n\r\n\r\n/**\r\n\\brief pRigidBody is the main simulation object in the physics SDK.\r\n\r\nThe body is owned by and contained in a pWorld.\r\n\r\n\r\n

Creation

\r\nInstances of this class are created by calling #pFbodyy::createBody() and deleted with #NxScene::deleteBody().\r\n\r\nSee #pObjectDescr for a more detailed description of the parameters which can be set when creating a body.\r\n\r\n//class MODULE_API pRigidBody : public xEngineObjectAssociation\r\n\r\nclass MODULE_API pRigidBody : public pStoredObjectAssociation\r\n\r\n*/\r\nclass MODULE_API pRigidBody : \r\n\tpublic xEngineObjectAssociation,\r\n\tpublic pCallbackObject\r\n{\r\n\r\npublic:\r\n\tpRigidBody(CK3dEntity* _e);\r\n\tpRigidBody(CK3dEntity* _e,pWorld *world);\r\n\tvirtual ~pRigidBody(){}\r\n\r\n\tvoid test();\r\n\r\n\tpObjectDescr *mInitialDescription;\r\n\t\r\n\tpObjectDescr * getInitialDescription() const { return mInitialDescription; }\r\n\tvoid setInitialDescription(pObjectDescr * val) { mInitialDescription = val; }\r\n\tvoid onICRestore(CK3dEntity* parent,pRigidBodyRestoreInfo *restoreInfo);\r\n\r\n\tbool hasBrokenJoint;\r\n\r\n\r\n\tint onJointBreak(pBrokenJointEntry *entry);\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Callback handler\r\n\t*/\r\n\t//@{\r\n \r\n\r\n\tbool onSubShapeTransformation(bool fromPhysicToVirtools=true,bool position=true,bool rotation=true,CK3dEntity*parent=NULL,bool children=true);\r\n\tbool onMove(bool position,bool rotation,VxVector pos,VxQuaternion quad);\r\n\r\n\tvoid processScriptCallbacks();\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// collision notification\r\n\t//\r\n\tvoid onContactNotify(pCollisionsEntry *collisionData);\r\n\tvoid setContactScript(int behaviorID,int eventMask);\r\n\r\n\t/**\r\n\t\\brief Sets the force threshold for contact reports.\r\n\r\n\tSee #getContactReportThreshold().\r\n\r\n\tThe actor must be dynamic.\r\n\r\n\t\\param[in] threshold Force threshold for contact reports. \r\n\t\t-\tRange: (0,inf)\r\n\r\n\t@see getContactReportThreshold getContactReportFlags pContactPairFlag \r\n\t*/\r\n\tvoid setContactReportThreshold(float threshold);\r\n\t/**\r\n\t\\brief Retrieves the force threshold for contact reports.\r\n\r\n\tThe contact report threshold is a force threshold. If the force between \r\n\ttwo actors exceeds this threshold for either of the two actors, a contact report \r\n\twill be generated according to the union of both body' contact report threshold flags.\r\n\tSee #getContactReportFlags().\r\n\r\n\tThe body must be dynamic. The threshold used for a collision between a dynamic actor\r\n\tand the static environment is the threshold of the dynamic actor, and all contacts with\r\n\tstatic actors are summed to find the total normal force.\r\n\r\n\t\\return Force threshold for contact reports.\r\n\r\n\t@see setContactReportThreshold getContactReportFlags pContactPairFlag \r\n\t*/\r\n\tfloat getContactReportThreshold();\r\n\r\n\r\n\tvoid setContactReportFlags(pContactPairFlags flags);\r\n\tint getContactReportFlags();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tjoint break events\r\n\t//\t\r\n\tvoid setJointBreakScript(int behaviorID,CK3dEntity *shapeReference = NULL);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// trigger notification\r\n\t//\r\n\tvoid setTriggerScript(int behaviorID,int eventMask,CK3dEntity *shapeReference = NULL);\r\n\r\n\tint onTrigger(pTriggerEntry *report);\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// contact modification\r\n\t//\r\n\tvoid setContactModificationScript(int behaviorID);\r\n\r\n\tbool onContactConstraint(int& changeFlags,CK3dEntity *sourceObject,CK3dEntity *otherObject,pContactModifyData *data);\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// raycast hit\r\n\t//\r\n\tvirtual void setRayCastScript(int val);\r\n\tvirtual bool onRayCastHit(NxRaycastHit *report);\r\n\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Collision\r\n\t*/\r\n\t//@{\r\n\r\n\tvoid setTriggerFlags(pTriggerFlags flags,CKBeObject *shapeReference=NULL);\r\n\tpTriggerFlags getTriggerFlags(CKBeObject *shapeReference=NULL);\r\n\r\n\tint handleContactPair(NxContactPair* pair,int shapeIndex);\r\n\tint handleContactPairWheel(NxContactPair* pair,int shapeIndex);\r\n\r\n\t/**\r\n\t\\brief Sets 128-bit mask used for collision filtering. See comments for ::pGroupsMask\r\n\r\n\tSleeping: Does NOT wake the associated body up automatically.\r\n\r\n\t\\param[in] shape Reference The sub shape reference object. Leave blank to set the bodies initial shapes groups mask. \r\n\t\\param[in] mask The group mask to set for the shape.\r\n\r\n\t@see getGroupsMask()\r\n\t*/\r\n\tvoid\t\t\t\t\tsetGroupsMask(CK3dEntity *shapeReference,const pGroupsMask& mask);\r\n\r\n\tpGroupsMask getGroupsMask(CK3dEntity *shapeReference);\r\n\r\n\r\n\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Velocity\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief Retrieves the angular velocity of a rigid body. \r\n\t\r\n\t\\return Vector\r\n\t\r\n\t@see setAngularVelocity() getLinearVelocity()\r\n\t\r\n\t\\warning The body must be dynamic.\r\n\t\r\n\t*/\r\n\tVxVector getAngularVelocity()const;\r\n\t/**\r\n\t\t\\brief Retrieves the linear velocity of a rigid body. \r\n\t\t\\return Vector\r\n\t\t\\sa setLinearVelocity() getAngularVelocity()\r\n\t\t\\warning The body must be dynamic.\r\n\t*/\r\n\tVxVector getLinearVelocity()const;\r\n\t/**\r\n\t\\brief Retrieves the maximum angular velocity permitted for this body.\r\n\t\\return float\r\n\t\\sa setMaxAngularVelocity\r\n\t\\warning The body must be dynamic.\r\n\t*/\r\n\tfloat getMaxAngularSpeed()const;\r\n\t/**\r\n\t\\brief Lets you set the maximum angular velocity permitted for this body.\r\n\t\r\n\tBecause for various internal computations, very quickly rotating bodies introduce error \r\n\tinto the simulation, which leads to undesired results.\r\n\r\n\tWith PhysicManager::setParameter(EX_MAX_ANGULAR_VELOCITY) you can set the default maximum velocity for bodies created\r\n\tafter the call. Bodies' high angular velocities are clamped to this value. \r\n\r\n\tHowever, because some bodies, such as car wheels, should be able to rotate quickly, you can override the default setting\r\n\ton a per-body basis with the below call. Note that objects such as wheels which are approximated with spherical or \r\n\tother smooth collision primitives can be simulated with stability at a much higher angular velocity than, say, a box that\r\n\thas corners.\r\n\r\n\tNote: The angular velocity is clamped to the set value before the solver, which means that\r\n\tthe limit may still be momentarily exceeded.\r\n\t\r\n\t\\param[in] val Max allowable angular velocity for body. Range: (0,inf)\r\n\t\r\n\t\\sa getMaxAngularVelocity()\r\n\t\r\n\t\\warning The body must be dynamic.\r\n\t*/\r\n\tvoid setMaxAngularSpeed(float val);\r\n\t/**\r\n\t\\brief Computes the velocity of a point given in body local coordinates as if it were attached to the \r\n\tbody and moving with it.\r\n\t\r\n\t\\param[in] point Point we wish to determine the velocity of, defined in the body local frame. Range: position vector\r\n\t\r\n\t\\return The velocity, in the global frame, of the point.\r\n\r\n\t\\sa getLocalPointVelocity()\r\n\t\r\n\t\\warning The body must be dynamic.\r\n\t*/\r\n\tVxVector getPointVelocity(const VxVector& point)const;\r\n\t/**\r\n\t\\brief Computes the velocity of a point given in body local coordinates as if it were attached to the \r\n\tbody and moving with it.\r\n\r\n\t\\param[in] point Point we wish to determine the velocity of, defined in the body local frame. Range: position vector\r\n\r\n\t\\return The velocity, in the global frame, of the point.\r\n\r\n\t\\sa getPointVelocity()\r\n\r\n\t\\warning The body must be dynamic.\r\n\t*/\r\n\tVxVector getLocalPointVelocity(const VxVector& point)const;\r\n\t/**\r\n\t\\brief Sets the angular velocity of the body.\r\n\r\n\t\\note Note that if you continuously set the angular velocity of an body yourself, \r\n\tforces such as friction will not be able to rotate the body, because forces directly influence only the velocity/momentum.\r\n\r\n\t\\param[in] angVel New angular velocity of body. Range: angular velocity vector\r\n\r\n\t\\sa getAngularVelocity() setLinearVelocity() \r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tSleeping: This call wakes the body if it is sleeping.\r\n\t*/\r\n\tvoid setAngularVelocity(const VxVector& angVel);\r\n\t/**\r\n\t\\brief Sets the linear velocity of the body.\r\n\r\n\t\\note Note that if you continuously set the velocity of an body yourself, \r\n\tforces such as gravity or friction will not be able to manifest themselves, because forces directly\r\n\tinfluence only the velocity/momentum of an body.\r\n\r\n\t\\param[in] linVel New linear velocity of body. Range: velocity vector\r\n\t\\sa getLinearVelocity() setAngularVelocity()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tSleeping: This call wakes the body if it is sleeping.\r\n\t*/\r\n\tvoid setLinearVelocity(const VxVector& linVel);\r\n\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\r\n\t/** @name Mass Manipulation\r\n\t*/\r\n\t//@{\r\n\r\n\r\n\t/**\r\n\t\\brief The setCMassOffsetLocal*() methods set the pose of the center of mass relative to the actor.\r\n\r\n\tSee ::setCMassOffsetLocalPose() for more information.\r\n\r\n\t\\note Setting an unrealistic center of mass which is a long way from the body can make it difficult for\r\n\tthe SDK to solve constraints. Perhaps leading to instability and jittering bodies.\r\n\r\n\tThe actor must be dynamic.\r\n\r\n\tSleeping: This call wakes the actor if it is sleeping.\r\n\r\n\t\\param[in] vec Mass frame offset relative to the actor frame. Range: position vector\r\n\t@see setCMassOffsetLocalPose() setCMassOffsetLocalOrientation() setCMassOffsetGlobalPose()\r\n\t*/\r\n\t//void\t\t\tsetCMassOffsetLocalPosition(VxVector vec);\r\n\r\n\r\n\t/**\r\n\t\\brief The setCMassOffsetGlobal*() methods set the pose of the center of mass relative to world space.\r\n\r\n\tSee ::setCMassOffsetGlobalPose() for more information.\r\n\r\n\t\\note Setting an unrealistic center of mass which is a long way from the body can make it difficult for\r\n\tthe SDK to solve constraints. Perhaps leading to instability and jittering bodies.\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\tSleeping: This call wakes the rigid body if it is sleeping.\r\n\r\n\t\\param[in] vec Mass frame offset relative to the global frame. Range: position vector\r\n\r\n\t@see setCMassOffsetGlobalPose() setCMassOffsetGlobalOrientation()\r\n\r\n\t*/\r\n\tvoid\t\t\tsetCMassOffsetGlobalPosition(VxVector vec);\r\n\r\n\t/**\r\n\t\\brief The setCMassGlobal*() methods move the rigid body by setting the pose of the center of mass.\r\n\r\n\tSee ::setCMassGlobalPose() for more information.\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\tSleeping: This call wakes the rigid body if it is sleeping.\r\n\r\n\t\\param[in] vec rigid bodys new position, from the transformation of the mass frame to the global frame. Range: position vector\r\n\t@see setCMassGlobalPose() setCMassGlobalOrientation() getCMassLocalPose()\r\n\t*/\r\n\tvoid\t\t\tsetCMassGlobalPosition(VxVector vec);\r\n\r\n\t/**\r\n\t\\brief The getCMassLocal*() methods retrieve the center of mass pose relative to the rigid body.\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\t\\return The center of mass position relative to the rigid body.\r\n\r\n\t@see getCMassLocalPose() getCMassLocalOrientation() getCMassGlobalPose()\r\n\t*/\r\n\tVxVector \t\t\tgetCMassLocalPosition(); \r\n\r\n\r\n\t/**\r\n\t\\brief The getCMassGlobal*() methods retrieve the center of mass pose in world space.\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\t\\return The position of the center of mass relative to the global frame.\r\n\t@see getCMassGlobalPose() getCMassGlobalOrientation() getCMassLocalPose()\r\n\t\r\n\t*/\r\n\tVxVector \t\t\tgetCMassGlobalPosition();\r\n\r\n\r\n\t/**\r\n\t\\brief Sets the inertia tensor, using a parameter specified in mass space coordinates.\r\n\r\n\tNote that such matrices are diagonal -- the passed vector is the diagonal.\r\n\r\n\tIf you have a non diagonal world/rigid body space inertia tensor(3x3 matrix). Then you need to\r\n\tdiagonalize it and set an appropriate mass space transform. See #setCMassOffsetLocalPose().\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\tSleeping: Does NOT wake the rigid body up automatically.\r\n\r\n\t\\param[in] m New mass space inertia tensor for the rigid body. Range: inertia vector\r\n\t@see NxBodyDesc.massSpaceInertia getMassSpaceInertia() setMass() setCMassOffsetLocalPose()\r\n\t*/\r\n\tvoid\t\t\tsetMassSpaceInertiaTensor(VxVector m);\r\n\r\n\t/**\r\n\t\\brief Retrieves the diagonal inertia tensor of the rigid body relative to the mass coordinate frame.\r\n\r\n\tThis method retrieves a mass frame inertia vector. If you want a global frame inertia tensor(3x3 matrix),\r\n\tthen see #getGlobalInertiaTensor().\r\n\r\n\tThe rigid body must be dynamic.\r\n\r\n\t\\return The mass space inertia tensor of this rigid body.\r\n\r\n\t@see NxBodyDesc.massSpaceInertia setMassSpaceInertiaTensor() setMass() CMassOffsetLocalPose()\r\n\t*/\r\n\tVxVector\t\t\tgetMassSpaceInertiaTensor();\r\n\r\n\t/**\r\n\t\\brief Retrieves the mass of the body.\r\n\r\n\tZero represents no damping. The damping coefficient must be nonnegative.\r\n\r\n\t\\param[in] angDamp Angular damping coefficient. Range: [0,inf)\r\n\r\n\t\\sa setMass()\r\n\r\n\t\\warning Static bodies will always return 0.\r\n\t*/\r\n\tfloat getMass();\r\n\t/**\r\n\t\\brief Sets the mass of a dynamic body.\r\n\r\n\tThe mass must be positive and the body must be dynamic.\r\n\r\n\tsetMass() does not update the inertial properties of the body, to change the inertia tensor\r\n\tuse setMassSpaceInertiaTensor() or updateMassFromShapes().\r\n\r\n\tSleeping: Does NOT wake the body up automatically.\r\n\r\n\t\\param[in] mass New mass value for the body. Range: (0,inf)\r\n\r\n\t\\sa setMass()\r\n\r\n\t\\warning The mass must be positive and the body must be dynamic.\r\n\t*/\r\n\tvoid setMass(float mass,CKBeObject *shapeReference=NULL);\r\n\t/**\r\n\t\\brief The setCMassOffsetLocal*() methods set the pose of the center of mass relative to the body.\r\n\r\n\tMethods that automatically compute the center of mass such as updateMassFromShapes() as well as computing\r\n\tthe mass and inertia using the bodies shapes, will set this pose automatically.\r\n\r\n\t\\note Setting an unrealistic center of mass which is a long way from the body can make it difficult for\r\n\tthe SDK to solve constraints. Perhaps leading to instability and jittering bodies.\r\n\r\n\tSleeping: This call wakes the body if it is sleeping.\r\n\r\n\t\\param[in] vec Mass frame offset relative to the body frame. Range: position vector\r\n\r\n\t\\warning The body must be dynamic.\r\n\t*/\r\n\tvoid setCMassOffsetLocalPosition(VxVector offset);\r\n\t/**\r\n\t\\brief Recomputes a dynamic body's mass properties from its shapes\r\n\r\n\tGiven a constant density or total mass, the bodies mass properties can be recomputed\r\n\tusing the shapes attached to the body. If the body has no shapes, then only the totalMass\r\n\tparameter can be used. If all shapes in the body are trigger shapes (non-physical), the call\r\n\twill fail.\r\n\r\n\tThe mass of each shape is either the shape's local density (as specified in the #NxShapeDesc; default 1.0) \r\n\tmultiplied by the shape's volume or a directly specified shape mass. \r\n\r\n\tThe inertia tensor, mass frame and center of mass will always be recomputed. If there are no\r\n\tshapes in the body, the mass will be totalMass, and the mass frame will be set to the center\r\n\tof the body.\r\n\r\n\tIf you supply a non-zero total mass, the body's mass and inertia will first be computed as\r\n\tabove and then scaled to fit this total mass.\r\n\r\n\tIf you supply a non-zero density, the body's mass and inertia will first be computed as above\r\n\tand then scaled by this fbody.\r\n\r\n\tEither totalMass or density must be non-zero.\r\n\r\n\t\\param[in] density Density scale fbody of the shapes belonging to the body. Range: [0,inf)\r\n\t\\param[in] totalMass Total mass of the body(or zero). Range: [0,inf)\r\n\r\n\t\\sa setMass()\r\n\r\n\t\\warning \r\n\t\tThe body must be dynamic.
\r\n\t\tSleeping: Does NOT wake the body up automatically.\r\n\r\n\t*/\r\n\tint updateMassFromShapes( float density, float totalMass );\r\n//@}\r\n\t\r\n\r\n\r\n\t/************************************************************************************************/\r\n\r\n\r\n/** @name Forces\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the global coordinate frame to the body.\r\n\r\n\tMethods that automatically compute the center of mass such as updateMassFromShapes() as well as computing\r\n\tthe mass and inertia using the bodies shapes, will set this pose automatically.\r\n\r\n\t\r\n\t\\param[in] force Force/Impulse to apply defined in the global frame. Range: force vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode).Default = #FM_Force.\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.Default = true.\r\n\r\n\t\\sa addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addForce(const VxVector& force,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular \r\n\tpoint in global coordinates, to the body. \r\n\r\n\r\n\tNote that if the force does not act along the center of mass of the body, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\t\\param[in] force Force/impulse to add, defined in the global frame. Range: force vector\r\n\t\\param[in] point Position in the global frame to add the force at. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode)\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\t\r\n\t\\sa ForceMode\r\n\t\\sa addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce() addLocalForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addForceAtPos(const VxVector& force,const VxVector& point,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the global coordinate frame, acting at a particular \r\n\tpoint in local coordinates, to the body. \r\n\r\n\r\n\t\\note Note that if the force does not act along the center of mass of the body, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a\r\n\ttotal external force on an object by calling this once every frame.\r\n\t\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\t\r\n\t\\param[in] force Force/impulse to add, defined in the global frame. Range: force vector\r\n\t\\param[in] point Position in the local frame to add the force at. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode)\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\r\n\t\\sa ForceMode\r\n\t\\sa addForceAtPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce() addLocalForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addForceAtLocalPos(const VxVector& force,const VxVector& point,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the body local coordinate frame to the body.\r\n\t\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] force Force/Impulse to apply defined in the local frame. Range: force vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode)\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\r\n\t\\sa ForceMode\r\n\t\\sa addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addLocalForce(const VxVector& force,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the body local coordinate frame, acting at a \r\n\tparticular point in global coordinates, to the body. \r\n\r\n\t\\note Note that if the force does not act along the center of mass of the body, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a\r\n\ttotal external force on an object by calling this once every frame.\r\n\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] force Force/impulse to add, defined in the local frame. Range: force vector\r\n\t\\param[in] point Position in the global frame to add the force at. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode)\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\r\n\t\\sa ForceMode\r\n\t\\sa addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addLocalForceAtPos(const VxVector& force,const VxVector& point,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the body local coordinate frame, acting at a \r\n\tparticular point in local coordinates, to the body. \r\n\r\n\t\\note Note that if the force does not act along the center of mass of the body, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, you can maintain a\r\n\ttotal external force on an object by calling this once every frame.\r\n\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] force Force/impulse to add, defined in the local frame. Range: force vector\r\n\t\\param[in] point Position in the local frame to add the force at. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode)\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\r\n\t\\sa ForceMode\r\n\t\\sa addForceAtPos() addForceAtLocalPos() addLocalForceAtPos() addLocalForceAtLocalPos() addForce()\r\n\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addLocalForceAtLocalPos(const VxVector& force,const VxVector& point,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies an impulsive torque defined in the global coordinate frame to the body.\r\n\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\r\n\t\\param[in] torque Torque to apply defined in the global frame.\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode).\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\r\n\t\\sa addLocalTorque() addForce()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addTorque(const VxVector& torque,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\t/**\r\n\t\\brief Applies an impulsive torque defined in the body local coordinate frame to the body.\r\n\r\n\t::ForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] torque Torque to apply defined in the local frame.\r\n\t\\param[in] mode The mode to use when applying the force/impulse(see #ForceMode).\r\n\t\\param[in] wakeUp Specify if the call should wake up the body.\r\n\t\\sa addLocalTorque() addForce()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tThis will not induce a torque.
\r\n\tSleeping: This call wakes the body if it is sleeping and the wakeup parameter is true (default).\r\n\t*/\r\n\tvoid addLocalTorque(const VxVector& torque,ForceMode mode=FM_Force,bool wakeUp=true);\r\n\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\r\n\t/** @name Momentum\r\n\t*/\r\n\t//@{\r\n\t\r\n\t/**\r\n\t\\brief Sets the angular momentum of the body. \r\n\r\n\t\\note Note that if you continuously set the linear momentum of an body yourself, \r\n\tforces such as gravity or friction will not be able to manifest themselves, because forces directly\r\n\tinfluence only the velocity/momentum of a body.\r\n\r\n\t\\param[in] angMoment New angular momentum. Range: angular momentum vector\r\n\t\t\r\n\t\\sa getAngularMomentum()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\t*/\r\n\tvoid setAngularMomentum(const VxVector& angMoment);\r\n\t/**\r\n\t\\brief Sets the linear momentum of the body. \r\n\r\n\t\\note Note that if you continuously set the linear momentum of an body yourself, \r\n\tforces such as gravity or friction will not be able to manifest themselves, because forces directly\r\n\tinfluence only the velocity/momentum of a body.\r\n\t\r\n\t\\param[in] linMoment New linear momentum. Range: momentum vector\r\n\r\n\t\\sa getLinearMomentum() \r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\t*/\r\n\tvoid setLinearMomentum(const VxVector& linMoment);\r\n\t/**\r\n\t\\brief Retrieves the angular momentum of an body.\r\n\r\n\tThe angular momentum is equal to the angular velocity times the global space inertia tensor.\r\n\r\n\t\\return The angular momentum for the body.\r\n\r\n\t\\sa setLinearMomentum() getAngularMomentum()\r\n\t\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\t*/\r\n\tVxVector getAngularMomentum()const;\r\n\t/**\r\n\t\\brief Retrieves the linear momentum of an body.\r\n\r\n\tThe momentum is equal to the velocity times the mass.\r\n\r\n\t\\return The linear momentum for the body.\r\n\r\n\t\\sa setLinearMomentum() getAngularMomentum()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\t*/\r\n\tVxVector getLinearMomentum()const;\r\n\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\r\n\t/** @name Pose\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief Sets a dynamic body's position in the world.\r\n\r\n\t\\param[in] pos New position for the bodies frame relative to the global frame. Range: position vector\r\n\t\\param[in] subShapeReference Reference object specifing a subshape for the case the body is a compound object. Must be a mesh or an 3D-entity. Default = Null \r\n\r\n\t\\sa getPosition()\r\n\r\n\t*/\r\n\tvoid setPosition(const VxVector& pos,CK3dEntity *subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Sets a dynamic body's orientation in the world.\r\n\t\r\n\t\\param[in] rot New orientation for the bodies frame.\r\n\t\\param[in] subShapeReference Reference object specifying a sub shape for the case the body is a compound object. Must be a mesh or an 3D-entity. Default = Null \r\n\r\n\t\\sa getLinearMomentum() setAngularMomentum()\r\n\t*/\r\n\tvoid setRotation(const VxQuaternion& rot,CK3dEntity *subShapeReference=NULL);\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Collision\r\n\t*/\r\n\t//@{\r\n\r\n\t\r\n\t/**\r\n\t\\brief Enables/disable collision detection. I.e. the body will not collide with other objects. Please note that you might need to wake \r\n\tthe body up if it is sleeping, this depends on the result you wish to get when using this flag. (If a body is asleep it \r\n\twill not start to fall through objects unless you activate it).\r\n\r\n\t\\param[in] enable. Flag to determining collisions response for the body.\r\n\tto collision detect with each other.\r\n\t\\param[in] subShapeReference Reference object specifing a subshape for the case the body is a compound object. Must be a mesh or an 3D-entity. Default = Null \r\n\r\n\t\\Note\t: Also excludes the body from overlap tests!\r\n\r\n\t\\sa isCollisionEnabled()\r\n\t\r\n\tSleeping: Does NOT wake the associated body up automatically.\r\n\t*/\r\n\tvoid enableCollision(bool enable,CK3dEntity* subShapeReference=NULL);\r\n\r\n\tbool isCollisionEnabled(CK3dEntity* subShapeReference=NULL) ;\r\n\r\n\r\n\tvoid enableCollisionsNotify(bool enable);\r\n\tbool isCollisionsNotifyEnabled();\r\n\r\n\tvoid enableContactModification(bool enable);\r\n\tvoid enableCollisionForceCalculation(bool enable,CK3dEntity* subShapeReference=NULL);\r\n\tvoid enableTriggerShape(bool enable,CK3dEntity* subShapeReference=NULL);\r\n\tbool isTriggerShape(CK3dEntity* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Sets the collisions group the body belongs too.\r\n\r\n\t\\param[in] index The new group index. Default group is 0. Maximum possible group is 31.Collision groups are sets of shapes which may or may not be set\r\n\tto collision detect with each other.\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\note If you pass a sub shape reference then its only setting the group on the sub shape and not for all sub shapes.\r\n\r\n\t\\sa getCollisionsGroup()\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\tSleeping: Does NOT wake the associated body up automatically.\r\n\t*/\r\n\tvoid setCollisionsGroup(int index,CK3dEntity* subShapeReference=NULL);\r\n\r\n\t/**\r\n\t\\brief Retrieves the collisions group which this body or a sub shape of it is part of.\r\n\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\return The collision group this body or sub shape belongs to.\r\n\r\n\t\\sa setCollisionsGroup()\r\n\r\n\t\\warning \r\n\tThe body must be dynamic.
\t\r\n\t*/\r\n\tint getCollisionsGroup(CK3dEntity* subShapeReference=NULL);\r\n\r\n\t//@}\r\n\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Shape\r\n\t*/\r\n\t//@{\r\n\r\n\t/**\r\n\t\\brief Updates the box dimension of the initial shape or a sub shape. \r\n\r\n\t\\param[in] dimension New dimension. Range: dimension vector\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa getBoxDimensions()\r\n\r\n\t\\warning \r\n\t\tThe call doesnt updates the bodies mass.Use updateMassFromShapes()
\t\r\n\r\n\t*/\r\n\tvoid setBoxDimensions(const VxVector&dimension,CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Retrieves the box dimension of the initial shape or sub shape. \r\n\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa setBoxDimensions()\r\n\t*/\r\n\tVxVector getBoxDimensions(CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Updates the radius of the initial shape or a sub shape. \r\n\r\n\t\\param[in] radius New radius.\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa getSphereRadius()\r\n\r\n\t\\warning \r\n\tThe call doest updates the bodies mass.Use updateMassFromShapes()
\t\r\n\r\n\t*/\r\n\tvoid setSphereRadius(float radius,CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Retrieves the radius of the initial shape or sub shape. \r\n\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa setSphereRadius() . \r\n\t*/\r\n\tfloat getSphereRadius(CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Updates the capsule parameter of the initial shape or a sub shape. \r\n\r\n\t\\param[in] radius New radius.\r\n\t\\param[in] length New length.\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa getCapsuleDimensions()\r\n\r\n\t\\warning \r\n\tThe call doesnt updates the bodies mass.Use updateMassFromShapes()
\t\r\n\r\n\t*/\r\n\tvoid setCapsuleDimensions(float radius,float length,CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Retrieves the capsule parameters of the initial shape or sub shape. \r\n\r\n\t\\param[out] radius The radius of the capsule.\r\n\t\\param[out] length The length of the capsule.\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\t\\sa setCapsuleDimensions() . \r\n\t*/\r\n\tvoid getCapsuleDimensions(float& radius,float& length,CKBeObject* subShapeReference=NULL);\r\n\t/**\r\n\t\\brief Retrieves the hull type of the initial shape or sub shape. \r\n\t\\return The hull type.\r\n\t\\param[in] subShapeReference Sub shape reference. Default = Null.\r\n\t*/\r\n\tHullType getShapeType(CKBeObject* subShapeReference=NULL);\r\n\r\n\t/**\r\n\t\\brief Retrieves the skin width of the initial shape or a sub shape. \r\n\t\\return The skin with.\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\t\\sa setSkinWidth()\r\n\t*/\r\n\tfloat getSkinWidth(CKBeObject* subShapeReference=NULL);\r\n\r\n\t/**\r\n\t\\brief Updates the skin width of the initial shape or a sub shape. \r\n\t\r\n\t\\param[in] skinWidth The new skin width. Range: (0,inf)\r\n\t\\param[in] subShapeReference Sub shape reference. Must be a mesh or an 3D-entity. Default = Null.\r\n\r\n\t\\sa setSkinWidth()\r\n\t\\warning\r\n\tSleeping: Does NOT wake the associated body up automatically.\r\n\t*/\r\n\tvoid setSkinWidth(const float skinWidth,CKBeObject* subShapeReference=NULL);\r\n\r\n\t//@}\r\n\r\n\t\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Optimization\r\n\t*/\r\n\t//@{\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief The solver iteration count determines how accurately joints and contacts are resolved.
\r\n\t\tIf you are having trouble with jointed bodies oscillating and behaving erratically, then\r\n\t\tsetting a higher solver iteration count may improve their stability.\r\n\r\n\t\t\\param[in] count Number of iterations the solver should perform for this body.
\r\n\t\t\t-\tRange: [1,255]\r\n\r\n\t\t*/\r\n\t\tvoid setSolverIterationCount(int count);\r\n\r\n\t\t/**\r\n\t\t\r\n\t\t\\brief Assigns dynamic bodies a dominance group identifier.
\r\n\t\t\r\n\t\tThe dominance group is a 5 bit group identifier (legal range from 0 to 31).\r\n\r\n\t\tThe #pWorld::setDominanceGroupPair() lets you set certain behaviors for pairs of dominance groups.\r\n\t\tBy default every body is created in group 0. Static bodies must stay in group 0; thus you can only \r\n\t\tcall this on dynamic bodys.\r\n\r\n\t\tSleeping: Changing the dominance group does NOT wake the body up automatically.\r\n\r\n\t\t@see getDominanceGroup() NxScene::setDominanceGroupPair()\r\n\t\t*/\r\n\t\tvoid setDominanceGroup(int dominanceGroup);\r\n\r\n\t\t/**\r\n\t\t\\brief Retrieves the value set with setDominanceGroup().
\r\n\r\n\t\t\\return The dominance group of this body.\r\n\r\n\t\t@see setDominanceGroup() pWorld::setDominanceGroupPair()\r\n\t\t*/\r\n\t\tint\tgetDominanceGroup() const;\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the linear velocity below which an body may go to sleep.
\r\n\r\n\t\tBodies whose linear velocity is above this threshold will not be put to sleep.\r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t@see isSleeping\r\n\r\n\t\t\\return The threshold linear velocity for sleeping.\r\n\r\n\r\n\t\t@see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold()\r\n\t\t*/\r\n\t\tfloat\t\t\tgetSleepLinearVelocity() const ;\r\n\r\n\t\t/**\r\n\t\t\\brief Sets the linear velocity below which an body may go to sleep.
\r\n\r\n\t\tBodies whose linear velocity is above this threshold will not be put to sleep.\r\n\r\n\t\tIf the threshold value is negative,\tthe velocity threshold is set using the NxPhysicsSDK's \r\n\t\tNX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter.\r\n\r\n\t\tSetting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In\r\n\t\tversion 2.5 and later a new method is used by default which uses the kinetic energy of the body to control\r\n\t\tsleeping.\r\n\r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t\\param[in] threshold Linear velocity below which an body may sleep. Range: (0,inf]\r\n\r\n\t\t@see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepEnergyThreshold() getSleepEnergyThreshold()\r\n\t\t*/\r\n\t\tvoid\t\t\tsetSleepLinearVelocity(float threshold);\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the angular velocity below which an body may go to sleep.
\r\n\r\n\t\tBodies whose angular velocity is above this threshold will not be put to sleep. \r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t\\return The threshold angular velocity for sleeping.\r\n\r\n\t\t@see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepAngularVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold()\r\n\t\t*/\r\n\t\tfloat\t\t\tgetSleepAngularVelocity() const;\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Sets the angular velocity below which an body may go to sleep.
\r\n\r\n\t\tBodies whose angular velocity is above this threshold will not be put to sleep.\r\n\r\n\t\tIf the threshold value is negative,\tthe velocity threshold is set using the NxPhysicsSDK's \r\n\t\tNX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter.\r\n\r\n\t\tSetting the sleep angular/linear velocity only makes sense when the NX_BF_ENERGY_SLEEP_TEST is not set. In\r\n\t\tversion 2.5 and later a new method is used by default which uses the kinetic energy of the body to control \tsleeping.\r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t\\param[in] threshold Angular velocity below which an body may go to sleep. \r\n\t\t\t-\tRange: (0,inf]\r\n\r\n\t\t\r\n\t\t@see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepEnergyThreshold() getSleepEnergyThreshold()\r\n\t\t*/\r\n\t\tvoid\t\t\tsetSleepAngularVelocity(float threshold);\r\n\t\t\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Sets the energy threshold below which an body may go to sleep.
\r\n\r\n\t\tBodies whose kinematic energy is above this threshold will not be put to sleep.\r\n\r\n\t\tIf the threshold value is negative,\tthe velocity threshold is set using the NxPhysicsSDK's \r\n\t\tNX_DEFAULT_SLEEP_ENERGY parameter.\r\n\r\n\t\tSetting the sleep energy threshold only makes sense when the NX_BF_ENERGY_SLEEP_TEST is set. There\r\n\t\tare also other types of sleeping that uses the linear and angular velocities directly instead of the \r\n\t\tenergy.\r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t\\param[in] threshold Energy below which an actor may go to sleep.
\r\n\t\t-\tRange: (0,inf]\r\n\r\n\t\t@see isGroupSleeping() isSleeping() getSleepEnergyThreshold() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepLinearVelocity() setSleepAngularVelocity() \r\n\t\t*/\r\n\t\tvoid setSleepEnergyThreshold(float threshold);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the energy below which an body may go to sleep.
\r\n\r\n\t\tBodies whose energy is above this threshold will not be put to sleep. \r\n\r\n\t\tThe body must be dynamic.\r\n\r\n\t\t\\return The energy threshold for sleeping.\r\n\r\n\t\t@see isGroupSleeping() isSleeping() getSleepLinearVelocity() getSleepAngularVelocity() wakeUp() putToSleep() setSleepAngularVelocity()\r\n\t\t*/\r\n\t\tfloat\t\t\t\tgetSleepEnergyThreshold() const;\r\n\r\n\r\n\t\t/**\r\n\t\t\\brief Retrieves the linear damping coefficient.
\r\n\r\n\t\t\\return The linear damping coefficient associated with this body.\r\n\r\n\t\t\\sa getAngularDamping()\r\n\r\n\t\t\\warning The body must be dynamic.\r\n\t\t*/\r\n\t\tfloat getLinearDamping()const;\r\n\t\t/**\r\n\t\t\\brief Retrieves the angular damping coefficient.
\r\n\r\n\r\n\t\t\\return The angular damping coefficient associated with this body.\r\n\r\n\t\t\\sa setAngularDamping() \r\n\r\n\t\t\\warning The body must be dynamic.\r\n\t\t*/\r\n\t\tfloat getAngularDamping()const;\r\n\t\t/**\r\n\t\t\\brief Sets the linear damping coefficient.
\r\n\r\n\t\tZero represents no damping. The damping coefficient must be nonnegative.\r\n\r\n\t\t\\param[in] linDamp Linear damping coefficient. Range: [0,inf)\r\n\r\n\t\t\\sa getLinearDamping()\r\n\r\n\t\t\\warning The body must be dynamic.\r\n\t\t*/\r\n\t\tvoid setLinearDamping(float linDamp);\r\n\t\t/**\r\n\t\t\\brief Sets the angular damping coefficient.
\r\n\r\n\t\tZero represents no damping. The damping coefficient must be nonnegative.\r\n\r\n\t\t\\param[in] angDamp Angular damping coefficient. Range: [0,inf)\r\n\r\n\t\t\\sa getLinearDamping()\r\n\r\n\t\t\\warning The body must be dynamic.\r\n\t\t*/\r\n\t\tvoid setAngularDamping(float angDamp);\r\n\r\n\r\n\t\t\r\n\r\n\r\n\r\n\r\n\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Conditions\r\n\t*/\r\n\t//@{\r\n\r\n\r\n\t\r\n\t\t/**\r\n\t\t\\brief Sets the body to kinematic.\r\n\t\t\\param[in] enabled Enable kinematic mode. Range: (0,inf)\r\n\t\t\\sa isKinematic()\r\n\t\t*/\r\n\t\tvoid setKinematic(bool enabled);\r\n\t\t/**\r\n\t\t\\brief Retrieves the bodies kinematic state.\r\n\t\t\\return the kinematic state.\r\n\t\t*/\r\n\t\tbool isKinematic()const;\r\n\r\n\t\t/**\r\n\t\t\\brief Checks whether the body is affected by the worlds gravity.\r\n\t\t\\return Is affected by gravity.\r\n\t\t\\sa enableGravity()\r\n\t\t*/\r\n\t\tbool isAffectedByGravity()const;\r\n\t\t/**\r\n\t\t\\brief Enables gravity on the body.\r\n\t\t\\param[in] enable The gravity state. \r\n\t\t\\sa isAffectedByGravity()\r\n\t\t*/\r\n\t\tvoid enableGravity(bool enable);\r\n\r\n\t//@}\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Sleeping\r\n\t*/\r\n\t//@{\r\n\r\n\t\t/**\r\n\t\t\\brief Checks whether the body is in a sleeping state.\r\n\t\t\\return True if sleeping.\r\n\t\t\\sa setSleeping()\r\n\t\t*/\r\n\t\tbool isSleeping()const;\r\n\t\t/**\r\n\t\t\\brief Forces the body to sleep. \r\n\r\n\t\tThe body will stay asleep until the next call to simulate, and will not wake up until then even when otherwise \r\n\t\tit would (for example a force is applied to it). It can however wake up during\r\n\t\tthe next simulate call.\r\n\r\n\t\t\\param[in] sleeping The sleeping state. \r\n\t\t\\sa setSleeping()\r\n\t\t\\warning \r\n\t\t\tThe body must be dynamic.
\r\n\t\t*/\r\n\t\tvoid setSleeping(bool sleeping);\r\n\r\n\t\t/**\r\n\t\t\\brief Wakes up the body if it is sleeping. \r\n\r\n\t\tThe wakeCounterValue determines how long until the body is put to sleep, a value of zero means \r\n\t\tthat the body is sleeping. wakeUp(0) is equivalent to NxActor::putToSleep().\r\n\r\n\t\t\\param[in] wakeCounterValue New sleep counter value. Default = (20.0f*0.02f) . Range: [0,inf]\r\n\t\t\\sa setSleeping() isSleeping() \r\n\t\t\\warning \r\n\t\tThe body must be dynamic.
\r\n\t\t*/\r\n\t\tvoid wakeUp(float wakeCounterValue=pSLEEP_INTERVAL);\r\n\r\n\t//@}\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Sub shapes\r\n\t*/\r\n\t//@{\r\n\r\n\t\t/*\r\n\t\t * \\brief Adds an additional shape to the body. \r\n\t\t *\r\n\t\t * \r\n\t\t *\r\n\t\t * \\return int\r\n\t\t * \\param\t\tCKMesh * mesh\r\n\t\t * \\param\t\tpObjectDescr objectDescr\r\n\t\t * \\param\t\tCK3dEntity * srcRefEntity\r\n\t\t * \\param\t\tVxVector localPosition\r\n\t\t * \\param\t\tVxQuaternion localRotation\r\n\t\t * \\note\r\n\t\t * \\sa\r\n\t\t * \\warning\r\n\t\t */\r\n\t\tint addSubShape(CKMesh *mesh,pObjectDescr& objectDescr,CK3dEntity*srcRefEntity=NULL,VxVector localPosition=VxVector(),VxQuaternion localRotation=VxQuaternion());\r\n\t\t\r\n\t\tint addCollider(pObjectDescr objectDescr,CK3dEntity*srcRefEntity);\r\n\r\n\t\tint removeSubShape(CKBeObject *reference,float newensity=0.0f,float totalMass=0.0f);\r\n\t\tNxShape *_getSubShape(CK_ID meshID);\r\n\t\tNxShape *_getSubShapeByEntityID(CK_ID id);\r\n\t\tbool isSubShape(CKBeObject *object);\r\n\t\tint updateSubShapes(bool fromPhysicToVirtools= true,bool position=true,bool rotation=true,CK3dEntity *childObject=NULL);\r\n\t\tint updateSubShape(bool fromPhysicToVirtools=true,bool position=true,bool rotation=true,CK3dEntity *childObject=NULL,bool hierarchy=true);\r\n\r\n\r\n\t\tNxShape * getMainShape() const { return mMainShape; }\r\n\t\tvoid setMainShape(NxShape * val) { mMainShape = val; }\r\n\t\t\r\n\t\tNxShape *getShapeByIndex(int index=0);\r\n\t\tNxShape* getSubShape(CK3dEntity*shapeReference=NULL);\r\n\r\n\r\n\r\n\r\n\t//@}\r\n\t\r\n\t\r\n\tint _initMainShape(const pObjectDescr oDescr,NxActorDesc&bodyDesc);\r\n\tint _initMainShape(const pObjectDescr oDescr,NxActorDesc* bodyDesc);\r\n\r\n\r\n\r\n\t\r\n\tbool isWheel(CKBeObject *object);\r\n\tbool isVehicle(CKBeObject *object);\r\n\tbool isCharacter(CKBeObject *object);\r\n\t\r\n\r\n\tint getNbJoints();\r\n\tpJoint* getJointAtIndex(int index);\r\n\t\r\n\t\r\n\tpJoint* getJoint(CK3dEntity*_b,JType type);\r\n\tvoid deleteJoint(pJoint*joint);\r\n\tvoid deleteJoint(CK3dEntity*_b,JType type);\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name Serialization\r\n\t*/\r\n\t//@{\r\n\r\n\tvoid readFrom(NXU::NxActorDesc *desc,int flags);\r\n\tvoid writeTo(const char *filename,int flags);\r\n\r\n\t//@}\r\n\r\n\tint getFlags();\r\n\tvoid recalculateFlags(int _flags);\r\n\tvoid updateFlags(int _flags,CK3dEntity*shapeReference=NULL);\r\n\tvoid setFlags(int _flags);\r\n\t\r\n\t\r\n\tint getHullType();\r\n\tvoid setHullType(int _type);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//geometry related :\r\n\t\r\n\t\r\n\r\n\tbool isValid()const;\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//maintainence :\r\n\t\r\n\tCK3dEntity* GetVT3DObject();\r\n\tvoid SetVT3DObject(CK3dEntity* _obj);\r\n\t\r\n\tCK_ID getEntID() const { return mEntID; }\r\n\tvoid setEntID(CK_ID val) { mEntID = val; }\r\n\tvoid destroy();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//optimization settings :\r\n\t\r\n\tpSleepingSettings* getSleepingSettings() { return m_SleepingSettings; }\r\n\tvoid setSleepingSettings(pSleepingSettings* val) { m_SleepingSettings = val; }\r\n\t\r\n\r\n\tvoid Init();\r\n\tvoid retrieveSettingsFromAttribute();\r\n\t\r\n\tvoid UpdateGeometry(int flags=0);\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//pivot manipulation,no affects to mass !\r\n\t\r\n\tvoid setLocalShapePosition(VxVector relative,CK3dEntity*shapeReference=NULL);\r\n\t//void SetPivotOrientation(VxQuaternion relative);\r\n\t\r\n\t\r\n\tpWorld * getWorld() const { return m_pWorld; }\r\n\tvoid setWorld(pWorld * val) { m_pWorld = val; }\r\n\r\n\tvoid clean(int flags=0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//joint related \r\n\tpJoint* isConnected(CK3dEntity*);\r\n\tpJoint* isConnected(CK3dEntity*,int type);\r\n\tint JGetNumJoints();\r\n\t\r\n\t\r\n\tJointListType& GetJoints(){ return m_Joints; }\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//composite geometries \r\n\t\r\n\tVxVector getMassOffset() const { return massOffset; }\r\n\tvoid setMassOffset(VxVector val) { massOffset = val; }\r\n\tvoid setPivotOffset(VxVector val) { pivotOffset = val; }\r\n\tVxVector getPivotOffset(CK3dEntity*shapeReference);\r\n\r\n\tvoid translateLocalShapePosition(VxVector vec);\r\n\tfloat getDensity() const { return mDensity; }\r\n\tvoid setDensity(float val) { mDensity = val; }\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//prototype : \r\n\r\n\txBitSet& getDataFlags() { return mDataFlags; }\r\n\tvoid setDataFlags(xBitSet val) { mDataFlags = val; }\r\n\r\n\tvoid checkDataFlags();\r\n\tvoid checkForOptimization();\r\n\t\r\n\tvoid updateOptimizationSettings(pOptimization optimization);\r\n\r\n\t\r\n\tvoid checkForCCDSettings(CK3dEntity *shapeReference=NULL);\r\n\r\n\tvoid updateCCDSettings(pCCDSettings ccd,CK3dEntity*shapeReference=NULL);\r\n\tvoid updateCollisionSettings(const pObjectDescr oDescr,CK3dEntity*shapeReference=NULL);\r\n\tvoid updateCollisionSettings(pCollisionSettings collision,CK3dEntity*shapeReference=NULL);\r\n\tvoid updatePivotSettings(pPivotSettings pivot,CK3dEntity*shapeReference=NULL);\r\n\tvoid updateMaterialSettings(pMaterial& material,CK3dEntity*shapeReference=NULL);\r\n\tvoid updateMassSettings(pMassSettings massSettings);\r\n\tvoid saveToAttributes(pObjectDescr* oDescr);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Surface : \r\n\t\r\n\r\n\tvoid InitSurfaceMaterials();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t\r\n\t/************************************************************************/\r\n\t/* Material */\r\n\t/*********************************\t***************************************/\r\n\r\n\tpMaterial& getShapeMaterial(CK3dEntity *shapeReference=NULL);\r\n\tvoid setShapeMaterial(pMaterial&material,CK3dEntity*shapeReference=NULL);\r\n\tvoid setShapeMaterialFrom(CKBeObject*src,CK3dEntity*shapeReference=NULL);\r\n\r\n\tNxMaterial* getMaterial() const { return mMaterial; }\r\n\tvoid setMaterial(NxMaterial* val) { mMaterial = val; }\r\n\r\n\r\n\tNxActor* getActor() const { return mActor; }\r\n\tvoid setActor(NxActor* val) { mActor = val; }\r\n\t\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\t\r\n\r\n\tpCloth *mCloth;\r\n\tpCloth * getCloth() const { return mCloth; }\r\n\tvoid setCloth(pCloth * val) { mCloth = val; }\r\n\tbool isDeformable();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tvoid lockTransformation(int flags);\r\n\tint getTransformationsLockFlags();\r\n\tint isBodyFlagOn(int flags);\r\n\r\n\t/************************************************************************/\r\n\t/* Sub shapes : */\r\n\t/************************************************************************/\r\n\r\n\tCollisionsArray mCollisions;\r\n\tCollisionsArray&getCollisions(){return mCollisions;}\r\n\t\r\n\tpTriggerArray mTriggers;\r\n\tpTriggerArray& getTriggers() { return mTriggers; }\r\n\r\n\r\n\r\n\txBitSet mCollisionFlags;\r\n\txBitSet&getCollisionFlags();\r\n\t\r\n\r\n\t\r\n\tpVehicle * getVehicle() const { return mVehicle; }\r\n\tvoid setVehicle(pVehicle * val) { mVehicle = val; }\r\n\tpWheel* getWheel(CK3dEntity* subShapeReference);\r\n\tpWheel2* getWheel2(CK3dEntity* subShapeReference);\r\n\r\n\r\n\r\n\tint getTriggerState() const { return mTriggerState; }\r\n\tvoid setTriggerState(int val) { mTriggerState = val; }\r\n\r\n\tint getNbWheels();\r\n\tvoid updateWheels(float step);\r\n\tvoid _transformWheels();\r\n\tbool hasWheels();\r\n\r\n\r\n\tint getNbSubShapes();\r\n\tint getNbSubBodies();\r\n\r\n\r\n\tprotected :\r\n\t\r\n\t\tDWORD m_DataFlags;//deprecated !\r\n\t\txBitSet mDataFlags;\r\n\t\t\r\n\r\n\r\n\t\tCK_ID mEntID;\r\n\t\tCKContext* context;\r\n\t\tint m_sFlags;\r\n\t\tint m_HullType;\r\n\t\tfloat m_friction;\r\n\t\tfloat m_restitution;\r\n\t\tfloat mDensity;\r\n\t\t\r\n\t\tVxVector massOffset;\r\n\t\tVxVector pivotOffset;\r\n\t\t\r\n\t\tCK3dEntity* mVTObject;\r\n\t\tpWorld * m_pWorld;\r\n\t\tpSleepingSettings* m_SleepingSettings;\r\n\t\tJointListType m_Joints;\r\n\r\n\t\tNxActor* mActor;\r\n\t\tNxMaterial*mMaterial;\r\n\t\tfloat mSkinWidth;\r\n\t\tNxShape *mMainShape;\r\n\r\n\t\t\r\n\r\n\t\tpVehicle *mVehicle;\r\n\r\n\t\tint mTriggerState;\r\n\r\n\t\tpublic:\r\n\t\t\tvoid _checkForNewSubShapes();\r\n\t\t\tvoid _checkForRemovedSubShapes();\r\n\r\n\r\n\t\t\r\n};\r\n\r\n/** @} */\r\n\r\n\r\n#endif // !defined(EA_C2D3E6DE_B1A5_4f07_B3FA_73F108249451__INCLUDED_)\r\n#ifndef __vtNetStructs_h\r\n#define __vtNetStructs_h\r\n\r\n#include \"xNetTypes.h\"\r\n\r\n\r\n\r\n\r\n\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWRayCastAnyBoundsDecl();\r\nCKERROR CreatePWRayCastAnyBoundsProto(CKBehaviorPrototype **pproto);\r\nint PWRayCastAnyBounds(const CKBehaviorContext& behcontext);\r\nCKERROR PWRayCastAnyBoundsCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWRayCastAnyBoundsDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PWRayCastAnyBounds\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Performs a ray cast test\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6e155f2f,0x6d634931));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePWRayCastAnyBoundsProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePWRayCastAnyBoundsProto\r\n// FullName: CreatePWRayCastAnyBoundsProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nenum bInput\r\n{\r\n\tbbI_RayOri,\r\n\tbbI_RayOriRef,\r\n\tbbI_RayDir,\r\n\tbbI_RayDirRef,\r\n\tbbI_Length,\r\n\tbbI_ShapesType,\r\n\tbbI_Groups,\r\n\tbbI_Mask,\r\n};\r\n\r\nenum bbS\r\n{\r\n\tbbS_Groups=0,\r\n\tbbS_Mask=1\r\n};\r\n\r\n\r\nenum bbOT\r\n{\r\n\tbbOT_Yes,\r\n\tbbOT_No,\r\n\r\n};\r\nCKERROR CreatePWRayCastAnyBoundsProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PWRayCastAnyBounds\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PWRayCastAnyBounds \r\n\r\n\tPWRayCastAnyBounds is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tPerforms a ray cast test.
\r\n\tSee PWRayCasts.cmo for example.\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PWRayCastAnyBounds.png\r\n\r\n\tIn: Triggers the process.\r\n\t
\r\n\t\r\n\r\n\r\n\tYes: Hit occured.\r\n\t
\r\n\tNo: No hits.\r\n\t
\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\tTarget: World Reference. pDefaultWorld!\r\n\t
\r\n\tRay Origin: Start of the ray.\r\n\t
\r\n\tRay Origin Reference: Reference object to determine the start of the ray. Ray Origin becomes transformed if an object is given.\r\n\t
\r\n\tRay Direction: Direction of the ray.\r\n\t
\r\n\tRay Direction Reference: Reference object to determine the direction of the ray. Ray Direction becomes transformed if an object is given. Up axis will be used then.\r\n\t
\r\n\tLength: Lenght of the ray.\r\n\t
\r\n\tShapes Types: Adds static and/or dynamic shapes to the test.\r\n\t
\r\n\r\n\tGroups: Includes specific groups to the test. \r\n\t
\r\n\tGroups Mask: Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t
\r\n\r\n\t

Note

\r\n\tThis is as parameter opertion avaiable. See \\ref CollisionsOps !\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pWorld::raycastAnyBounds().
\r\n\t\r\n\t*/\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\t\r\n\tproto->DeclareOutput(\"Yes\");\r\n\tproto->DeclareOutput(\"No\");\r\n\t\r\n\r\n\r\n\tproto->DeclareInParameter(\"Ray Origin\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Ray Origin Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Ray Direction\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Ray Direction Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Length\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Shapes Type\",VTF_SHAPES_TYPE);\r\n\r\n\tproto->DeclareInParameter(\"Groups\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Filter Mask\",VTS_FILTER_GROUPS);\r\n\r\n\t\r\n\tproto->DeclareSetting(\"Groups\",CKPGUID_BOOL,\"false\");\r\n\tproto->DeclareSetting(\"Groups Mask\",CKPGUID_BOOL,\"false\");\r\n\r\n\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PWRayCastAnyBoundsCB );\r\n\tproto->SetFunction(PWRayCastAnyBounds);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Enter,\r\n\tbbO_Stay,\r\n\tbbO_Leave,\r\n};\r\n\r\n//************************************\r\n// Method: PWRayCastAnyBounds\r\n// FullName: PWRayCastAnyBounds\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PWRayCastAnyBounds(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// the world : \r\n\tpWorld *world=GetPMan()->getWorld(target->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tNxScene *scene = world->getScene();\r\n\tif (!scene)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tCK3dEntity *rayOriRef= (CK3dEntity *) beh->GetInputParameterObject(bbI_RayOriRef);\r\n\t\tCK3dEntity *rayDirRef= (CK3dEntity *) beh->GetInputParameterObject(bbI_RayDirRef);\r\n\r\n\t\t//ori : \r\n\t\tVxVector ori = GetInputParameterValue(beh,bbI_RayOri);\r\n\t\tVxVector oriOut = ori;\r\n\t\tif (rayOriRef)\r\n\t\t{\r\n\t\t\trayOriRef->Transform(&oriOut,&ori);\r\n\t\t}\r\n\r\n\t\t//dir : \r\n\t\tVxVector dir = GetInputParameterValue(beh,bbI_RayDir);\r\n\t\tVxVector dirOut = dir;\r\n\t\tif (rayDirRef)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\trayDirRef->GetOrientation(&dir,&up,&right);\r\n\t\t\trayDirRef->TransformVector(&dirOut,&up);\r\n\t\t}\r\n\r\n\t\tfloat lenght = GetInputParameterValue(beh,bbI_Length);\r\n\t\tint types = GetInputParameterValue(beh,bbI_ShapesType);\r\n\r\n\r\n\r\n\t\tVxRay ray;\r\n\t\tray.m_Direction = dirOut;\r\n\t\tray.m_Origin = oriOut;\r\n\r\n\t\tpRayCastReport &report = *world->getRaycastReport();\r\n\t\treport.setCurrentBehavior(beh->GetID());\r\n\r\n\t\tint groupsEnabled;\r\n\t\tDWORD groups = 0xffffffff;\r\n\t\tbeh->GetLocalParameterValue(bbS_Groups,&groupsEnabled);\r\n\t\tif (groupsEnabled)\r\n\t\t{\r\n\t\t\tgroups = GetInputParameterValue(beh,bbI_Groups);\r\n\t\t}\r\n\r\n\t\tpGroupsMask *gmask = NULL;\r\n\t\tDWORD mask;\r\n\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\tif (mask)\r\n\t\t{\r\n\t\t\tCKParameter *maskP = beh->GetInputParameter(bbI_Mask)->GetRealSource();\r\n\t\t\tgmask->bits0 = GetValueFromParameterStruct(maskP,0);\r\n\t\t\tgmask->bits1 = GetValueFromParameterStruct(maskP,1);\r\n\t\t\tgmask->bits2 = GetValueFromParameterStruct(maskP,2);\r\n\t\t\tgmask->bits3 = GetValueFromParameterStruct(maskP,3);\r\n\r\n\t\t}\r\n\r\n\t\tint nbShapes = world->raycastAnyBounds(ray,(pShapesType)types,gmask,groups,lenght);\r\n\r\n\t\t\r\n\r\n\t\tif (nbShapes)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbOT_Yes);\r\n\r\n\t\t}else{\r\n\t\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PWRayCastAnyBoundsCB\r\n// FullName: PWRayCastAnyBoundsCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PWRayCastAnyBoundsCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\r\n\r\n\t\t\tDWORD groups;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Groups,&groups);\r\n\t\t\tbeh->EnableInputParameter(bbI_Groups,groups);\r\n\r\n\t\t\tDWORD mask;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\t\tbeh->EnableInputParameter(bbI_Mask,mask);\r\n\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nvoid pWorld::updateVehicle(pVehicle *vehicle, float dt)\r\n{\r\n\tif (vehicle)\r\n\t{ \r\n\t\tvehicle->updateVehicle(dt);\r\n\t}\r\n}\r\n\r\n\r\n\r\nvoid pWorld::updateVehicles(float dt)\r\n{\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tpRigidBody *body = static_cast(actor->userData);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tif (!isVehicle(actor) && body->hasWheels())\r\n\t\t\t{\r\n\t\t\t\tbody->updateWheels(dt);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (body && isVehicle(actor))\r\n\t\t{\r\n\t\t\tupdateVehicle(body->getVehicle(),dt);\r\n\t\t}\r\n\t}\r\n}\r\nbool pWorld::isVehicle(NxActor* actor)\r\n{\r\n\r\n\tpRigidBody *body = static_cast(actor->userData);\r\n\tif (body)\r\n\t{\r\n\t\treturn body->getVehicle() ? true : false;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\npVehicle*pWorld::getVehicle(CK3dEntity* body)\r\n{\r\n\r\n\tpRigidBody *rbody = getBody(body);\r\n\tif (body && rbody->getVehicle() )\r\n\t{\r\n\t\treturn rbody->getVehicle();\r\n\t}\r\n\treturn NULL;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointCylindrical::pJointCylindrical(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Cylindrical)\r\n{\r\n\r\n}\r\n\r\nvoid pJointCylindrical::setGlobalAnchor(VxVector anchor)\r\n{\r\n\r\n\r\n\tNxCylindricalJointDesc descr;\t\t\r\n\tNxCylindricalJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAnchor(getFrom(anchor));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointCylindrical::setGlobalAxis(VxVector axis)\r\n{\r\n\r\n\r\n\tNxCylindricalJointDesc descr;\t\t\r\n\tNxCylindricalJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAxis(getFrom(axis));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointCylindrical::enableCollision(int collision)\r\n{\r\n\tNxCylindricalJointDesc descr;\t\t\r\n\tNxCylindricalJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"NXU_helper.h\" // NxuStream helper functions.\r\n#include \"NXU_PhysicsInstantiator.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n\r\n#include \"IParameter.h\"\r\n\r\nvoid pRigidBody::updateMassSettings(pMassSettings massSettings)\r\n{\r\n\r\n\t// Referential\r\n\tCK3dEntity* massRef = (CK3dEntity*)GetPMan()->GetContext()->GetObject(massSettings.massReference);\r\n\r\n\tVxVector massLocalOut = massSettings.localPosition;\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// position\r\n\t//\r\n\tif (XAbs(massSettings.localPosition.SquareMagnitude()) >0.0f )\r\n\t{\r\n\t\tif (massRef)\r\n\t\t{\r\n\t\t\tVxVector tOut = massLocalOut;\r\n\t\t\tmassRef->Transform(&massLocalOut,&massLocalOut);\r\n\t\t\tmassRef->TransformVector(&tOut,&tOut,GetVT3DObject());\r\n\t\t\tgetActor()->setCMassOffsetLocalPosition(getFrom(tOut));\r\n\t\t}else\r\n\t\t{\r\n\t\t\tgetActor()->setCMassOffsetLocalPosition(getFrom(massLocalOut));\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// rotational offset : todo\r\n\t//\r\n\tVxMatrix mat;\r\n\tVx3DMatrixFromEulerAngles(mat,massSettings.localOrientation.x,massSettings.localOrientation.y,massSettings.localOrientation.z);\r\n\r\n\tVxQuaternion outQuat;\r\n\toutQuat.FromMatrix(mat);\r\n\r\n\tVxQuaternion referenceQuat=outQuat;\r\n\tif (XAbs(massSettings.localOrientation.SquareMagnitude()) >0.0f )\r\n\t{\r\n\t\tif (massRef)\r\n\t\t{\r\n\t\t\tmassRef->GetQuaternion(&referenceQuat,NULL);\r\n\t\t\tgetActor()->setCMassOffsetGlobalOrientation(getFrom(referenceQuat));\r\n\t\t}else{\r\n\t\t\tgetActor()->setCMassOffsetGlobalOrientation(getFrom(outQuat));\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// recompute mass\r\n\t//\r\n\r\n\tfloat newDensity=massSettings.newDensity;\r\n\tfloat totalMass =massSettings.totalMass;\r\n\r\n\tint bMassResult = 0 ; \r\n\tif (newDensity!=0.0f || totalMass!=0.0f )\r\n\t{\r\n\t\tbMassResult = getActor()->updateMassFromShapes(newDensity,totalMass);\r\n\t}\r\n\r\n\tint op = bMassResult;\r\n\r\n\r\n}\r\n\r\nint pRigidBody::_initMainShape(const pObjectDescr oDescr,NxActorDesc *actorDesc)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity Checks \r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(GetVT3DObject());\t// has to been set before\r\n\t#endif // _DEBUG\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collect some data \r\n\t//\r\n\t\r\n\tVxVector box_s= BoxGetZero(GetVT3DObject());\r\n\tfloat density = oDescr.density;\r\n\tfloat radius = GetVT3DObject()->GetRadius();\r\n\r\n\r\n\tswitch(oDescr.hullType)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Box:\r\n\t\t{\r\n\t\t\tNxBoxShapeDesc shape;\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Sphere:\r\n\t\t{\r\n\t\t\tNxSphereShapeDesc shape;\r\n\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.radius = radius;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\t\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Mesh:\r\n\t\t{\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\r\n\t\t\t\t//xLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Can not use a mesh as de\");\r\n\t\t\t\t//return NULL;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tNxTriangleMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\r\n\t\t\tpFactory::Instance()->createMesh(getWorld()->getScene(),GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxTriangleMeshShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookTriangleMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't cook mesh!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createTriangleMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.group = oDescr.collisionGroup;\r\n\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\t\t\t\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tCloseCooking();\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexMesh:\r\n\t\t{\r\n\t\t\tif (GetVT3DObject()->GetCurrentMesh())\r\n\t\t\t{\r\n\t\t\t\tif (GetVT3DObject()->GetCurrentMesh()->GetVertexCount()>=256 )\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Only 256 vertices for convex meshs allowed, by Ageia!\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Object has no mesh!\");\r\n\t\t\t\treturn false;\r\n\r\n\r\n\t\t\t}\r\n\r\n\t\t\tNxConvexMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\t\t\tpFactory::Instance()->createConvexMesh(getWorld()->getScene(),GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookConvexMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't cook convex mesh!\");\r\n\t\t\t\treturn false;\r\n\r\n\t\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\t\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\t\r\n\t\t\tCloseCooking();\r\n\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexCylinder:\r\n\t\t{\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tif (!pFactory::Instance()->_createConvexCylinder(&shape,GetVT3DObject())){\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Capsule:\r\n\t\t{\r\n\r\n\t\t\tNxCapsuleShapeDesc shape;\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\r\n\t\t\t\tpCapsuleSettings cSettings;\r\n\r\n\t\t\t\tpFactory::Instance()->findSettings(cSettings,GetVT3DObject());\r\n\r\n\t\t\t\tshape.radius = cSettings.radius > 0.0f ? cSettings.radius : box_s.v[cSettings.localRadiusAxis] * 0.5f;\r\n\t\t\t\tshape.height = cSettings.height > 0.0f ? cSettings.height : box_s.v[cSettings.localLengthAxis] - ( 2*shape.radius) ;\r\n\t\t\t}\r\n\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\t//\tshape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc->shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase HT_Wheel:\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Wheel shape can be sub shape only!\");\r\n\t\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n\r\n}\r\n\r\n\r\n/*int pRigidBody::_initMainShape(const pObjectDescr oDescr,NxActorDesc&actorDesc)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity Checks \r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(GetVT3DObject());\t// has to been set before\r\n\t#endif // _DEBUG\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collect some data \r\n\t//\r\n\t\r\n\tVxVector box_s= BoxGetZero(GetVT3DObject());\r\n\tfloat density = oDescr.density;\r\n\tfloat radius = GetVT3DObject()->GetRadius();\r\n\r\n\r\n\tswitch(oDescr.hullType)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Box:\r\n\t\t{\r\n\t\t\tNxBoxShapeDesc shape;\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Sphere:\r\n\t\t{\r\n\t\t\tNxSphereShapeDesc shape;\r\n\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\t\t\t\tshape.radius = radius;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\r\n\t\t\tint oG = oDescr.collisionGroup;\r\n\t\t\tshape.group = oDescr.collisionGroup;\r\n\r\n\t\t\tint k = shape.isValid();\r\n\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Mesh:\r\n\t\t{\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\r\n\t\t\t\t//xLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Can not use a mesh as de\");\r\n\t\t\t\t//return NULL;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tNxTriangleMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\r\n\t\t\tpFactory::Instance()->createMesh(getWorld()->getScene(),GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxTriangleMeshShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookTriangleMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't cook mesh!\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createTriangleMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.group = oDescr.collisionGroup;\r\n\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\r\n\t\t\t\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tCloseCooking();\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexMesh:\r\n\t\t{\r\n\t\t\tif (GetVT3DObject()->GetCurrentMesh())\r\n\t\t\t{\r\n\t\t\t\tif (GetVT3DObject()->GetCurrentMesh()->GetVertexCount()>=256 )\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Only 256 vertices for convex meshs allowed, by Ageia!\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Object has no mesh!\");\r\n\t\t\t\treturn false;\r\n\r\n\r\n\t\t\t}\r\n\r\n\t\t\tNxConvexMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\t\t\tpFactory::Instance()->createConvexMesh(getWorld()->getScene(),GetVT3DObject()->GetCurrentMesh(),myMesh);\r\n\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn false;\r\n\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookConvexMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't cook convex mesh!\");\r\n\t\t\t\treturn false;\r\n\r\n\t\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\t//shape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tint h = shape.isValid();\r\n\t\t\tCloseCooking();\r\n\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_ConvexCylinder:\r\n\t\t{\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tif (!pFactory::Instance()->_createConvexCylinder(&shape,GetVT3DObject())){\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\tcase HT_Capsule:\r\n\t\t{\r\n\r\n\t\t\tNxCapsuleShapeDesc shape;\r\n\r\n\t\t\tif (! (oDescr.flags & BF_Deformable) )\r\n\t\t\t{\r\n\r\n\t\t\t\tpCapsuleSettings cSettings;\r\n\r\n\t\t\t\tpFactory::Instance()->findSettings(cSettings,GetVT3DObject());\r\n\r\n\t\t\t\tshape.radius = cSettings.radius > 0.0f ? cSettings.radius : box_s.v[cSettings.localRadiusAxis] * 0.5f;\r\n\t\t\t\tshape.height = cSettings.height > 0.0f ? cSettings.height : box_s.v[cSettings.localLengthAxis] - ( 2*shape.radius) ;\r\n\t\t\t}\r\n\t\t\tshape.density = density;\r\n\t\t\t//\tshape.materialIndex = result->getMaterial()->getMaterialIndex();\r\n\t\t\t//\tshape.localPose.t = pMath::getFrom(shapeOffset);\r\n\t\t\tif (oDescr.skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = oDescr.skinWidth;\r\n\t\t\tactorDesc.shapes.pushBack(&shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase HT_Wheel:\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Wheel shape can be sub shape only!\");\r\n\t\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n\r\n}\r\n*/\r\n\r\nint pRigidBody::getNbJoints()\r\n{\r\n\r\n\tpWorld *wA =getWorld();\r\n\t\r\n\tint result = 0 ;\r\n\r\n\tif (!wA)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\tNxU32\tjointCount = wA->getScene()->getNbJoints();\r\n\tif (jointCount)\r\n\t{\r\n\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\twA->getScene()->resetJointIterator();\r\n\r\n\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t{\r\n\t\t\tNxJoint\t*j = wA->getScene()->getNextJoint();\r\n\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\tif ( mJoint )\r\n\t\t\t{\r\n\t\t\t\tif (mJoint->GetVTEntA() == GetVT3DObject() || mJoint->GetVTEntB() == GetVT3DObject() )\r\n\t\t\t\t{\r\n\t\t\t\t\tresult++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nvoid pRigidBody::test()\r\n{\r\n\r\n\tpRigidBody *body = this;\r\n\tCK3dEntity* test = (CK3dEntity*)body;\r\n\r\n}\r\nvoid pRigidBody::readFrom(NXU::NxActorDesc *desc,int flags)\r\n{\r\n\r\n\tif ( desc->mHasBody ) // only for dynamic actors\r\n\t{\r\n\t\tfor (NxU32 k=0; kmShapes.size(); k++)\r\n\t\t{\r\n\t\t\tNXU::NxShapeDesc *shape = desc->mShapes[k];\r\n\t\t\tNxVec3 locPos = shape->localPose.t;\r\n\t\t\tNxQuat localQuad = shape->localPose.M;\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\nfloat pRigidBody::getMass(CK3dEntity *shapeReference/* =NULL */)\r\n{\r\n\tfloat result = 0 ; \r\n\tif (getActor())\r\n\t{\r\n\t\tresult = getActor()->getMass();\r\n\t}\r\n\treturn result;\r\n}\r\nVxVector pRigidBody::getLocalPointVelocity( const VxVector& point ) const\r\n{\r\n\t\tif(isValid())\r\n\t\t\treturn pMath::getFrom(getActor()->getLocalPointVelocity(getFrom(point)));\r\n\treturn VxVector();\r\n}\r\n\r\nVxVector pRigidBody::getPointVelocity( const VxVector& point ) const\r\n{\r\n\t\tif(isValid())\r\n\t\t\treturn pMath::getFrom(getActor()->getPointVelocity(getFrom(point)));\r\n\treturn VxVector();\r\n}\r\npJoint* pRigidBody::isConnected(CK3dEntity*ent)\r\n{\r\n\t\r\n\t\r\n\tpJoint *result = NULL;\r\n\tpWorld *wA =getWorld();\r\n\tpWorld *wB =NULL;\r\n\tpRigidBody *b = NULL;\r\n\tif (!wA)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tif (ent)\r\n\t{\r\n\t\tb = GetPMan()->getBody(ent);\r\n\t}\r\n\tif (b)\r\n\t{\r\n\t\twB = b->getWorld();\r\n\t}\r\n\r\n\tNxU32\tjointCount = wA->getScene()->getNbJoints();\r\n\tif (jointCount)\r\n\t{\r\n\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\twA->getScene()->resetJointIterator();\r\n\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t{\r\n\t\t\tNxJoint\t*j = wA->getScene()->getNextJoint();\r\n\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\tif ( mJoint )\r\n\t\t\t{\r\n\t\t\t\tif (mJoint->GetVTEntA() == GetVT3DObject() && mJoint->GetVTEntB() == ent )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn mJoint;\r\n\t\t\t\t}\r\n\t\t\t\tif (mJoint->GetVTEntB() == GetVT3DObject() && mJoint->GetVTEntA() == ent )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn mJoint;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nint pRigidBody::JGetNumJoints()\r\n{\r\n\tint result = 0 ; \r\n\t/*\r\n\tOdeBodyType bid = GetOdeBody();\r\n\tif (bid)\r\n\t{\r\n\t\tdxJoint *j = NULL;\r\n\t\tfor (j=World()->World()->firstjoint; j; j=(dxJoint*)j->next) \r\n\t\t{\r\n\t\t\tpJoint *pJ = static_cast(dJointGetData(j));\r\n\t\t\tif (pJ)\r\n\t\t\t{\r\n\t\t\t\tif (pJ->GetOdeBodyA() == bid || pJ->GetOdeBodyA() == bid )\r\n\t\t\t\t{\r\n\t\t\t\t\tresult ++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn 0;\r\n}\r\nvoid pRigidBody::setLocalShapePosition(VxVector relative,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\t\r\n\tif(!getActor())\r\n\t\treturn;\r\n\r\n\tNxShape *subShape = getSubShape(shapeReference);\r\n\tif (subShape )\r\n\t{\r\n\t\tsubShape->setLocalPosition(getFrom(relative));\r\n\t}\r\n\r\n\t/*NxU32 nbShapes = getActor()->getNbShapes();\r\n \tif ( nbShapes )\r\n \t{\r\n \t\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n \t\tfor (NxU32 j=0; jsetLocalPosition(pMath::getFrom(relative));\r\n\t\t\t\tint op=2;\r\n\t\t\t\treturn;\r\n\r\n\t\t\t\t//getActor()->updateMassFromShapes()\r\n\t\t\t}\r\n \t\t\t//addShapeMesh(c,s);\r\n \t}\r\n\t}*/\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\npRigidBody::pRigidBody(CK3dEntity* _e,pWorld *world) : xEngineObjectAssociation(_e,_e->GetID()) , mVTObject(_e) , m_pWorld(world)\r\n{\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tmActor = NULL;\r\n\t\r\n\tcontext = NULL;\r\n\tif (_e)\r\n\t{\r\n\t\tmEntID = _e->GetID();\r\n\t\tmVTObject = _e;\r\n\t}\r\n\tmMaterial = NULL;\r\n\tmDataFlags = 0;\r\n\tmMainShape = NULL;\r\n\tmMaterial = NULL;\r\n\tmVehicle = NULL;\r\n\tmMainShape = NULL;\r\n\tmActor =NULL;\r\n\tmCloth = NULL;\r\n\r\n\t//mClothRecieveBuffer=NULL;\r\n\r\n}\r\n\r\n\r\npRigidBody::pRigidBody(CK3dEntity* _e)\r\n{\r\n\tSetVT3DObject(_e);\r\n\tif (_e){\r\n\t\tmEntID = _e->GetID();\r\n\t\tmVTObject = _e;\r\n\r\n\t}\r\n\tmMaterial = NULL;\r\n\tmDataFlags = 0;\r\n\tmVehicle = NULL;\r\n\tmMainShape = NULL;\r\n\tmActor =NULL;\r\n\tmVTObject = NULL;\r\n\tm_pWorld = NULL;\r\n\tmCloth = NULL;\r\n\tmInitialDescription = NULL;\r\n\r\n\r\n \t\r\n}\r\n\r\n\r\nvoid pRigidBody::addLocalForceAtLocalPos(const VxVector& force, const VxVector& point,ForceMode mode,bool wakeUp)\r\n{\r\n\tif(isValid())\t\t\r\n\t\tgetActor()->addLocalForceAtLocalPos(pMath::getFrom(force),pMath::getFrom(point),(NxForceMode)mode,wakeUp);\r\n}\r\nvoid pRigidBody::addLocalForceAtPos(const VxVector& force, const VxVector& point,ForceMode mode,bool wakeUp)\r\n{\t\t\t\r\n\tif(isValid())\t\t\r\n\t\tgetActor()->addLocalForceAtPos(pMath::getFrom(force),pMath::getFrom(point),(NxForceMode)mode,wakeUp);\r\n}\r\nvoid pRigidBody::addForceAtLocalPos(const VxVector& force, const VxVector& point,ForceMode mode,bool wakeUp)\r\n{\r\n\tif(isValid())\t\t\r\n\t\tgetActor()->addForceAtLocalPos(pMath::getFrom(force),pMath::getFrom(point),(NxForceMode)mode,wakeUp);\r\n}\r\nvoid pRigidBody::addForceAtPos(const VxVector& force, const VxVector& point,ForceMode mode,bool wakeUp)\r\n{\t\t\t\r\n\tif(isValid())\t\t\r\n\t\tgetActor()->addForceAtPos(pMath::getFrom(force),pMath::getFrom(point),(NxForceMode)mode);\r\n}\r\nvoid pRigidBody::addTorque(const VxVector& torque,ForceMode mode,bool wakeUp)\r\n{\t\t\t\t\r\n\tif(isValid())\t\r\n\t\tgetActor()->addTorque(pMath::getFrom(torque),(NxForceMode)mode,wakeUp);\r\n}\r\nvoid pRigidBody::addLocalTorque(const VxVector& torque,ForceMode mode,bool wakeUp)\r\n{\t\t\t\t\t\t\t\t\t\r\n\tif(isValid())\t\r\n\t\tgetActor()->addLocalTorque(pMath::getFrom(torque),(NxForceMode)mode);\r\n}\r\n\r\nvoid pRigidBody::addLocalForce(const VxVector& force,ForceMode mode,bool wakeUp)\r\n{\t\t\t\r\n\tif(isValid())\t\t\r\n\t\tgetActor()->addLocalForce(pMath::getFrom(force),(NxForceMode)mode,wakeUp);\t\r\n}\r\n\r\nvoid pRigidBody::addForce( const VxVector& force,ForceMode mode/*=E_FM_FORCE*/,bool wakeUp/*=true*/ )\r\n{\t\t\t\t\t\t\t\t\t\t\t\r\n\tif(isValid())\t\r\n\t\tgetActor()->addForce(pMath::getFrom(force),(NxForceMode)mode,wakeUp);\t\r\n}\r\n\r\n\r\nvoid pRigidBody::setLinearMomentum( const VxVector& linMoment )\r\n{\tif(isValid())\t\tgetActor()->setLinearMomentum(pMath::getFrom(linMoment));\t}\r\nvoid pRigidBody::setAngularMomentum( const VxVector& angMoment )\r\n{\t\r\n\tif(isValid())\t\r\n\t\tgetActor()->setAngularMomentum(pMath::getFrom(angMoment));\r\n}\r\nVxVector pRigidBody::getAngularMomentum() const\r\n{\t\r\n\tif(isValid())\r\n\t\treturn pMath::getFrom(getActor()->getAngularMomentum());\r\n\treturn VxVector();\r\n}\r\n\r\nfloat pRigidBody::getAngularDamping() const\r\n{\t\r\n\tif(isValid())\r\n\t\treturn getActor()->getAngularDamping();\r\n\treturn 0.0f;\r\n}\r\nfloat pRigidBody::getLinearDamping() const\r\n{\t\r\n\tif(isValid())\r\n\t\treturn getActor()->getLinearDamping();\r\n\treturn 0.0f;\r\n}\r\nVxVector pRigidBody::getLinearMomentum()const{\t\r\n\tif(isValid())\r\n\t\treturn pMath::getFrom(getActor()->getLinearMomentum());\r\n\treturn VxVector();\r\n}\r\nvoid pRigidBody::setPosition(const VxVector& pos,CK3dEntity *subShapeReference)\r\n{\t\t\r\n\tif(isValid()){\r\n\r\n\t\t\r\n\t\tNxShape *subShape = getSubShape(subShapeReference);\r\n\t\tif (subShape == getMainShape() )\r\n\t\t{\r\n\t\t\tif (!isKinematic())\r\n\t\t\t{\r\n\t\t\t\tgetActor()->setGlobalPosition(pMath::getFrom(pos));\r\n\r\n\t\t\t}else{\r\n\t\t\t\tgetActor()->moveGlobalPosition(pMath::getFrom(pos));\r\n\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tif (subShape)\r\n\t\t\t{\r\n\t\t\t\tsubShape->setGlobalPosition(getFrom(pos));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::setRotation(const VxQuaternion& rot,CK3dEntity *subShapeReference)\r\n{\r\n\tif(isValid())\t\t\r\n\t{\r\n\t\tNxShape *subShape = getSubShape(subShapeReference);\r\n\t\tif (subShape == getMainShape() )\r\n\t\t{\r\n\t\t\tgetActor()->setGlobalOrientation(pMath::getFrom(rot));\r\n\t\t}else \r\n\t\t{\r\n if (subShape)\r\n {\r\n\t\t\t\tsubShape->setGlobalOrientation(getFrom(rot));\r\n }\r\n\t\t}\r\n\t}\r\n}\r\nfloat pRigidBody::getMaxAngularSpeed() const\r\n{\t\r\n\tif(isValid())return getActor()->getMaxAngularVelocity();\r\n\treturn 0.0f;\r\n}\r\nvoid pRigidBody::setMaxAngularSpeed(float val) {\tif(isValid())getActor()->setMaxAngularVelocity(val);\t}\r\nVxVector pRigidBody::getLinearVelocity() const{\t\treturn pMath::getFrom(getActor()->getLinearVelocity());}\r\nVxVector pRigidBody::getAngularVelocity() const{\treturn pMath::getFrom(getActor()->getAngularVelocity());}\r\nvoid pRigidBody::setLinearVelocity( const VxVector& linVel )\r\n{\t\tif(isValid())\t\t\t\t\t\t\r\n\t\t\tgetActor()->setLinearVelocity(pMath::getFrom(linVel));\r\n}\r\nvoid pRigidBody::setAngularVelocity( const VxVector& angVel )\r\n{\r\n\tif(isValid())\t\t\t\r\n\t\tgetActor()->setAngularVelocity(pMath::getFrom(angVel));\r\n}\r\n\r\nvoid pRigidBody::setAngularDamping(float scale)\r\n{\r\n\r\n\tif (getActor() && getActor()->isDynamic())\r\n\t{\r\n\t\tgetActor()->setAngularDamping(scale);\r\n\t}\r\n}\r\nvoid pRigidBody::setLinearDamping(float scale)\r\n{\r\n\r\n\tif (getActor() && getActor()->isDynamic())\r\n\t{\r\n\t\tgetActor()->setLinearDamping(scale);\r\n\t}\r\n\r\n}\r\n\r\n\r\nvoid pRigidBody::setCMassOffsetLocalPosition(VxVector offset)\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\tgetActor()->setCMassOffsetLocalPosition( getFrom(offset) );\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::translateLocalShapePosition(VxVector vec)\r\n{\r\n\r\n\tif (getActor())\r\n\t{\r\n\r\n\t\tif (getMainShape())\r\n\t\t{\r\n\t\t\tNxVec3 currentPos = getMainShape()->getLocalPosition();\r\n\t\t\tgetMainShape()->setLocalPosition( currentPos + getFrom(vec));\r\n\t\t}\r\n\t}\r\n}\r\n\r\npJoint* pRigidBody::isConnected(CK3dEntity*ent,int type)\r\n{\r\n\t/*\r\n\tpJoint *result = NULL;\r\n\r\n\tif ( GetVT3DObject()!=ent)\r\n\t{\r\n\tpRigidBody *b = GetPMan()->getBody(ent);\r\n\r\n\tOdeBodyType abid = GetOdeBody();\r\n\tOdeBodyType bbid = NULL;\r\n\r\n\tif (b)\r\n\t{\r\n\tbbid = b->GetOdeBody();\r\n\t}\r\n\r\n\tdxJoint *j = NULL;\r\n\tfor (j=World()->World()->firstjoint; j; j=(dxJoint*)j->next) \r\n\t{\r\n\tpJoint *pJ = static_cast(dJointGetData(j));\r\n\tif (pJ)\r\n\t{\r\n\r\n\tif (!bbid)\r\n\t{\r\n\tif (dJointGetType(j) ==dJointTypeFixed )\r\n\t{\r\n\tif (pJ->GetOdeBodyA()==abid)\r\n\t{\r\n\treturn pJ;\r\n\t}\r\n\t}\r\n\t}\r\n\r\n\tif ( pJ->GetOdeBodyA()==abid && dJointGetType(j) == type)\r\n\t{\r\n\tif (pJ->GetOdeBodyB()==bbid )\r\n\t{\r\n\treturn pJ;\r\n\t}\r\n\t}\r\n\r\n\tif ( pJ->GetOdeBodyA()==bbid && dJointGetType(j) == type)\r\n\t{\r\n\tif (pJ->GetOdeBodyB()==abid )\r\n\t{\r\n\treturn pJ;\r\n\t}\r\n\t}\r\n\t}\r\n\t}\r\n\t}\r\n\treturn result;\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\nvoid pRigidBody::SetVT3DObject(CK3dEntity* _obj)\r\n{ mEntID = _obj->GetID(); mVTObject=_obj;} \r\n\r\nCK3dEntity*pRigidBody::GetVT3DObject()\r\n{\treturn mVTObject;\t}#include \r\n#include \"pCommon.h\"\r\n#include \"pVehicleAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetExDecl();\r\nCKERROR CreatePVSetExProto(CKBehaviorPrototype **pproto);\r\nint PVSetEx(const CKBehaviorContext& behcontext);\r\nCKERROR PVSetExCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\r\nenum bInputs\r\n{\r\n\tI_XML,\r\n\tI_Flags,\r\n\tI_PFlags,\t\r\n\tI_SteerMax,\r\n};\r\n\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMapx[] = \r\n{\r\n\t\r\n\tBB_SPIN(I_XML,VTE_XML_VEHICLE_SETTINGS,\"Vehicle Settings\",\"None\"),\r\n\tBB_SPIN(I_Flags,VTF_VFLAGS,\"Vehicle Flags\",\"\"),\r\n\tBB_SPIN(I_PFlags,VTF_VEHICLE_PROCESS_OPTIONS,\"Vehicle Process Flags\",\"\"),\r\n\tBB_SPIN(I_SteerMax,CKPGUID_ANGLE,\"Maximum Steer\",\"15\"),\r\n\r\n};\r\n\r\n#define gVSMap pInMapx\r\n//#define BB_LOAD_PIMAP(SOURCE_MAP,SETTING_START_INDEX)\tBBHelper::loadPIMap(beh,pIMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX)\r\n\r\n\r\nCKERROR PVSetExCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\t\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\nCKObjectDeclaration\t*FillBehaviorPVSetExDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVSetEx\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Modifies vehicle parameter.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5b527a19,0x1e1600a9));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVSetExProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\nCKERROR CreatePVSetExProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVSetEx\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetBehaviorCallbackFct( PVSetExCB );\r\n\r\n\t\r\n\tBB_EVALUATE_SETTINGS(gVSMap);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// We just want create the building block pictures\r\n\t//\r\n\t#ifdef _DOC_ONLY_\r\n\t\tBB_EVALUATE_INPUTS(pInMap);\r\n\t#endif // _DOC_ONLY_\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVSetEx);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint PVSetEx(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) bbSErrorME(E_PE_REF);\r\n\r\n\t\t\r\n\t\tpRigidBody *body = NULL;\r\n\t\t\r\n\t\t\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\r\n\t\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\t\r\n\t\tfloat steerMax = GetInputParameterValue(beh,BB_IP_INDEX(I_SteerMax));\r\n\t\t\r\n\t\t\r\n\t\tint flags = GetInputParameterValue(beh,BB_IP_INDEX(I_Flags));\r\n\t\tint pflags = GetInputParameterValue(beh,BB_IP_INDEX(I_PFlags));\r\n\r\n\r\n\t\t\r\n\r\n\t\tBBSParameter(I_XML);\r\n\t\tBBSParameter(I_Flags);\r\n\t\tBBSParameter(I_PFlags);\r\n\t\tBBSParameter(I_SteerMax);\r\n\r\n\r\n\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\r\n\t\t{\r\n\t\t\tpVehicleDesc vdesc;\r\n\t\t\tvdesc.setToDefault();\r\n\r\n\t\t\tif (sI_SteerMax)\r\n\t\t\t{\r\n\t\t\t\tvdesc.steeringMaxAngle = steerMax * RR_RAD_DEG_FACTOR ;\r\n\t\t\t}\r\n\t\t\tif (sI_PFlags)\r\n\t\t\t{\r\n\t\t\t\tvdesc.processFlags = pflags;\r\n\t\t\t}\r\n\r\n\t\t\tv = pFactory::Instance()->createVehicle(target,vdesc);\r\n\r\n\t\t}\r\n\r\n\t\tif (!v)\r\n\t\t\tbbErrorME(\"Couldn't create vehicle\");\r\n\r\n\r\n\t\tif (sI_SteerMax)\r\n\t\t\tv->getSteer()->setLock(steerMax * RR_RAD_DEG_FACTOR);\r\n\t\t\r\n\r\n\t\tif (sI_PFlags)v->setProcessOptions(pflags);\r\n\r\n\r\n\r\n\t\t/*\r\n\t\tif (sI_Mass) v->setMass(mass);\r\n\t\tif (sI_Flags) v->flags = flags;\r\n\t\tif (sI_MotorForce)\tv->setMotorForce(mForce);\r\n\t\tif (sI_DiffRatio)v->setDifferentialRatio(dRatio);\r\n\t\tif (sI_SteerMax)v->setMaxSteering(steerMax) ;\r\n\t\tif (sI_DSDelta)v->setDigitalSteeringDelta(dsDelta);\r\n\t\tif (sI_MaxVelocity)v->setMaxVelocity(maxVel);\r\n\t\tif (sI_CMass)v->setCenterOfMass(cMass);\r\n\t\tif (sI_TEff)v->setTransmissionEfficiency(tEff);\r\n\t\tif(sI_SteeringSteerPoint)v->setSteeringSteerPoint(steeringSteerPoint);\r\n\t\tif(sI_SteerTurnPoint)v->setSteeringTurnPoint(steeringTurnPoint );\r\n\t\t*/\r\n\r\n\r\n\r\n\t\t\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVSetExCB\r\n// FullName: PVSetExCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n/*\r\n\r\ndx\t-0.99999821\tfloat\r\nangle\t-0.21089047\tfloat\r\nzPos\t0.99999857\tfloat\r\ndz\t4.6712832\tfloat\r\nxPos\t-0.99999821\tfloat\r\natan3\t-0.21089047\tfloat\r\n\r\n\r\ndx\t1.0000019\tfloat\r\nangle\t0.21089132\tfloat\r\nzPos\t1.0000004\tfloat\r\ndz\t4.6712813\tfloat\r\nxPos\t1.0000019\tfloat\r\natan3\t0.21089132\tfloat\r\n\r\n\r\n\r\n\r\n*/\r\n\r\n/*\r\n//\t\t\t\tint indexA = BBHelper::getIndex(beh,pMap,bbI_AxleSpeed);\r\n//\t\t\t\tint indexB = BBHelper::getIndex(beh,pMap,bbI_Steer);\r\n\r\n/*\r\nEnablePInputBySettings(beh,bbI_AxleSpeed);\r\nEnablePInputBySettings(beh,bbI_Steer);\r\nEnablePInputBySettings(beh,bbI_MotorTorque);\r\nEnablePInputBySettings(beh,bbI_BrakeTorque);\r\nEnablePInputBySettings(beh,bbI_SuspensionSpring);\r\nEnablePInputBySettings(beh,bbI_SuspensionTravel);\r\nEnablePInputBySettings(beh,bbI_Radius);\r\n*/\r\n\r\n\r\n\r\n\r\n/*\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\r\n\t\t\t\t/*\t\t\t\tBB_DECLARE_PIMAP;\r\n\t\t\t\twhile (\tpIMap->getArray().size() )\r\n\t\t\t\t{\r\n\r\n\t\t\t\tBBParameter *p=pIMap->getArray().at(0);\r\n\t\t\t\tpIMap->getArray().erase(pIMap->getArray().begin());\r\n\t\t\t\tdelete p;\r\n\t\t\t\tp = NULL;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t\t*/\r\n\t\t\t//\t\t\t\tBB_DECLARE_PIMAP;\r\n\t\t\t//\t\t\t\tBBHelper::destroyPIMap(beh,pIMap,BB_PMAP_SIZE);\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointPointOnLine::pJointPointOnLine(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_PointOnLine)\r\n{\r\n}\r\n\r\nvoid pJointPointOnLine::setGlobalAnchor(VxVector anchor)\r\n{\r\n\tNxPointOnLineJointDesc descr;\t\t\r\n\tNxPointOnLineJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAnchor(getFrom(anchor));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointPointOnLine::setGlobalAxis(VxVector axis)\r\n{\r\n\tNxPointOnLineJointDesc descr;\t\t\r\n\tNxPointOnLineJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAxis(getFrom(axis));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointPointOnLine::enableCollision(int collision)\r\n{\r\n\tNxPointOnLineJointDesc descr;\t\t\r\n\tNxPointOnLineJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorCollisionsCheckADecl();\r\nCKERROR CreateCollisionsCheckAProto(CKBehaviorPrototype **pproto);\r\nint CollisionsCheckA(const CKBehaviorContext& behcontext);\r\nCKERROR CollisionsCheckACB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorCollisionsCheckADecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCHasContact\");\t\r\n\tod->SetDescription(\"Checks for a collision on a given body\");\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5189255c,0x18134074));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateCollisionsCheckAProto);\r\n\t//od->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateCollisionsCheckAProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCHasContact\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->SetBehaviorCallbackFct( CollisionsCheckACB );\r\n\tproto->DeclareInput(\"Check\");\r\n\t\r\n\tproto->DeclareOutput(\"Collision\");\r\n\tproto->DeclareOutput(\"No Collision\");\r\n\r\n\tproto->DeclareOutParameter(\"Collider\", CKPGUID_3DENTITY);\r\n\tproto->DeclareOutParameter(\"Position\", CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Normal\", CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Face Index\", CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Normal Force\", CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Friction Force\", CKPGUID_VECTOR);\r\n\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(CollisionsCheckA);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint CollisionsCheckA(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0, FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we haven't't seen yet, create a local array : \r\n\t\t\t\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_PARAMETERERROR;\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tVxVector pos;\r\n\t\t\tVxVector normal;\r\n\t\t\tfloat depth;\r\n\t\t\tint size = body->getCollisions().Size();\r\n\r\n\t\t\tCK3dEntity *colliderEntity = NULL;\r\n\r\n\t\t\tif (!size)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\tbeh->SetOutputParameterObject(0,NULL);\r\n\t\t\t\treturn 0;\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\tif (size)\r\n\t\t\t{\r\n\r\n\t\t\t\t\r\n\r\n\t\t\t\tfor (int i = 0; i < body->getCollisions().Size() ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tpCollisionsEntry *entry = body->getCollisions().At(i);\r\n\t\t\t\t\tif (entry)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCK3dEntity *shapeA = (CK3dEntity*)GetPMan()->GetContext()->GetObject(entry->shapeEntityA);\r\n\t\t\t\t\t\tCK3dEntity *shapeB = (CK3dEntity*)GetPMan()->GetContext()->GetObject(entry->shapeEntityB);\r\n\t\t\t\t\t\tpRigidBody *collider = NULL;\r\n\t\t\t\t\t\tbody->getCollisions().RemoveAt(i);\r\n\t\t\t\t\t\tif( target == body->GetVT3DObject())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (entry->bodyA && entry->bodyA == body)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcollider = entry->bodyB;\r\n\t\t\t\t\t\t\t\tcolliderEntity = shapeB;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (entry->bodyB && entry->bodyB == body)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcollider = entry->bodyA;\r\n\t\t\t\t\t\t\t\tcolliderEntity = shapeA;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}else // its a sub shape collision\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (shapeA && shapeA == target )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcolliderEntity = shapeB;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (shapeB && shapeB == target)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcolliderEntity = shapeA;\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (colliderEntity)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterObject(0,colliderEntity);\r\n\t\t\t\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,1,entry->point);\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,2,entry->faceNormal);\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,3,entry->faceIndex);\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,4,entry->sumNormalForce);\r\n\t\t\t\t\t\t\tSetOutputParameterValue(beh,5,entry->sumFrictionForce);\r\n\t\t\t\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n/*\t\t\tint size = world->getCollisions().Size();\r\n\t\t\tfor (int i = 0; i < world->getCollisions().Size() ; i ++)\r\n\t\t\t{\r\n\t\t\t\tpCollisionsEntry *entry = world->getCollisions().At(i);\r\n\t\t\t\tif (entry)\r\n\t\t\t\t{\r\n\t\t\t\t\tprintf(\"asdasd\");\r\n\t\t\t\t\tint o = 2;\r\n\t\t\t\t\to++;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n*/\r\n\t\t\t//CK3dEntity *collider = world->CIsInCollision(target,pos,normal,depth);\r\n\t\t\t/*\r\n\t\t\tif (collider)\r\n\t\t\t{\r\n\t\t\t\tbeh->SetOutputParameterObject(0,collider);\r\n\t\t\t\tbeh->SetOutputParameterValue(1,&pos);\r\n\t\t\t\tbeh->SetOutputParameterValue(2,&normal);\r\n\t\t\t\tbeh->SetOutputParameterValue(3,&depth);\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn 0;\r\n\t\t\t}else\r\n\t\t\t{\r\n\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t}*/\r\n\t\t}\r\n\t}\r\n\tbeh->ActivateOutput(1);\r\n\treturn 0;\r\n}\r\n\r\nCKERROR CollisionsCheckACB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n#ifndef __XMATH_ALL_H__\r\n#define __XMATH_ALL_H__\r\n\r\n\r\n#include \"Prereqs.h\"\r\n#include \"xTNLInternAll.h\"\r\n//#include \"xMathTools.h\"\r\n\r\n\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n\r\n\r\n#endif#include \"IDistributedObjectsInterface.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n\r\n#include \"xDistributedObject.h\"\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n#include \r\n\r\n#include \"xLogger.h\"\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject* IDistributedObjects::getByUserID(int userID,int classType)\r\n{\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj && dobj->getUserID() == userID && dobj->getDistributedClass() && dobj->getDistributedClass()->getEnitityType() == classType )\r\n\t\t{\r\n return dobj;\t\t\t\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIDistributedObjects::cCreateDistObject(int objectID,int ownerID,const char* objectName,const char*className)\r\n{\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IDistributedObjects::create(const char* objectName,const char*className)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!strlen(objectName) || !strlen(className) ) return;\r\n\tif (!getNetInterface()) return;\r\n\tif (getNetInterface()->IsServer()) return;\r\n\tif (!getNetInterface()->getConnection())return;\r\n\tif (!getNetInterface()->getDistributedClassInterface())return;\r\n\t\r\n\tIDistributedClasses *cInterface = getNetInterface()->getDistributedClassInterface();\r\n\txDistributedClass *_class = cInterface->get(className);\r\n\tif (!_class)return;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//check we have it already :\r\n\tif (get(objectName))return;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//call via connection rpc a dist object creation : \r\n\tint userID = getNetInterface()->getConnection()->getUserID();\r\n\tgetNetInterface()->getConnection()->c2sDOCreate(userID,objectName,className,_class->getEnitityType());\r\n \r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IDistributedObjects::Destroy()\r\n{\r\n\r\n\tif (!getNetInterface())\t{\t\treturn;\t}\r\n\tif (!getNetInterface()->getDistributedObjects())return;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n/*\t\r\n\twhile (begin!=end)\r\n\t{\r\n\t\tint size = distObjects->Size();\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\tdobj->Destroy();\r\n\t\t\tdistObjects->Remove(dobj);\r\n\t\t\tdelete dobj;\r\n\t\t\tdobj = NULL;\r\n\t\t\tbegin = distObjects->begin();\r\n\t\t\t\r\n\t\t\t//continue;\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n*/\r\n\tdistObjects->clear();\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject* IDistributedObjects::get(const char*name)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert(strlen(name));\r\n#endif\r\n\tif (!strlen(name))return NULL;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\tif(!strcmp(const_cast(dobj->GetName().getString()),name))\r\n\t\t\t{\r\n\t\t\t\treturn dobj;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject* IDistributedObjects::get(const char*name,int classType)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert(strlen(name));\r\n#endif\r\n\tif (!strlen(name))return NULL;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\t\tif (!_class)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Found distributed object without class template: %s\",name);\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t\tint classType = _class->getEnitityType();\r\n\t\t\tif(!strcmp(const_cast(dobj->GetName().getString()),name) && \r\n\t\t\t\tclassType == classType )\r\n\t\t\t{\r\n\t\t\t\treturn dobj;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject* IDistributedObjects::get(int serverID)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert( getNetInterface() );\r\n#endif\r\n\tif (!serverID)return NULL;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\tint server = getNetInterface()->m_IsServer;\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\tint serverID2 = dobj->getServerID();\r\n\t\t\tif(dobj->getServerID() == serverID)\r\n\t\t\t{\r\n\t\t\t\treturn dobj;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject* IDistributedObjects::getByEntityID(int entityID)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert( getNetInterface() );\r\n#endif\r\n\r\n\tif (!entityID)return NULL;\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\tint server = getNetInterface()->m_IsServer;\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\tif(dobj->getEntityID() == entityID)\r\n\t\t\t{\r\n\t\t\t\treturn dobj;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject * IDistributedObjects::create(int objID,const char *templateClassName,const char* objectName/*=\"\"*/ )\r\n{\r\n\r\n\r\n\t\r\n\tif (!objID)return NULL;\r\n\tif (!getNetInterface())return NULL;\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the dist class : \r\n\txDistributedClassesArrayType *_classes = getNetInterface()->getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\r\n\t//look it exist : \r\n\txDistClassIt it = _classes->find(templateClassName);\r\n\r\n\txDistributedClass *classTemplate = it->second;\r\n\txDistributedObject*distObject = get(objID);\r\n\r\n\t/////////////////////////////////////////////////////////////////////////\r\n\t//the network update :\r\n\txNetInterface *cin = getNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\t//xLogger::xLog(ELOGERROR,XL_SESSION,\"\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tvtConnection *con = cin->getConnection();\r\n\t//if (!con)return NULL;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the dist object : \r\n\r\n\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\tif (!distObjects)return NULL;\r\n\r\n\t\r\n\tif ( !distObject /*&& classTemplate->GetEnitityType() == E_DC_BTYPE_3D_ENTITY */)\r\n\t{\r\n\t\t\r\n\t\tdistObject = new xDistributedObject();\r\n\t\t//distObject->SetDistributedClass(classTemplate);\r\n\t\tdistObject->setObjectFlags(E_DO_CREATION_INCOMPLETE);\r\n\t\tdistObject->setEntityID(objID);\r\n\t\tdistObject->setServerID(-1);\r\n\t\tdistObject->setCreationTime((float)TNL::Platform::getRealMilliseconds());\r\n\t\tdistObject->SetName(objectName);\r\n\t\tdistObjects->push_back(distObject);\r\n\t\txLogger::xLog(ELOGINFO,XL_START,\"dist object created : %s\",objectName);\r\n\t\treturn distObject;\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedObjects::IDistributedObjects()\r\n{\r\n\tm_NetworkInterface = NULL;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedObjects::IDistributedObjects(xNetInterface *netInterface) : m_NetworkInterface(netInterface)\r\n{\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedObjects::~IDistributedObjects()\r\n{\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIDistributedObjects::Clean()\r\n{\r\n\t/*if(GetNetworkInterface())\r\n\t\tGetNetworkInterface()->GetDistributedObjects()->Clear();*/\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIDistributedObjects::deleteObject(int serverID)\r\n{\r\n\r\n\tTNL::logprintf(\"___delete object : %d\",serverID);\r\n\r\n\txDistributedObject *distObject = get(serverID);\r\n\tif (distObject)\r\n\t{\r\n\t\tremoveObject(distObject);\r\n\r\n\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\tif (_class)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_DISTRIBUTED_BASE_OBJECT,\"Distributed object deleted,server id : %d class : %s\",serverID,_class->getClassName().getString());\r\n\t\t\t\r\n\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t{\r\n\t\t\t\tgetNetInterface()->getDistributedClassInterface()->destroyClass(_class);\r\n\t\t\t}\r\n\t\t\tdelete distObject;\r\n\t\t}else\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Object %d has no class!\",serverID);\r\n\t}else{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Couldn't find distributed object with server id : %d\",serverID);\r\n\t}\r\n}\r\nvoid\r\nIDistributedObjects::deleteObject(xDistributedObject*object)\r\n{\r\n\r\n\t//TNL::logprintf(\"___delete object : %d\",serverID);\r\n\tif (!object)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"invalid object\");\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tif (object)\r\n\t{\r\n\t\tremoveObject(object);\r\n\r\n\t\txDistributedClass *_class = object->getDistributedClass();\r\n\t\tif (_class)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_DISTRIBUTED_BASE_OBJECT,\"deleted %s | class : %s\",object->GetName().getString(),_class->getClassName().getString());\r\n\r\n\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t{\r\n\t\t\t\tgetNetInterface()->getDistributedClassInterface()->destroyClass(_class);\r\n\t\t\t}\r\n\t\t\tdelete object;\r\n\t\t}else\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Object %d has no class!\");\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IDistributedObjects::removeObject(xDistributedObject* object)\r\n{\r\n\r\n\tif (!object)return;\r\n\tif (!getNetInterface())\t{\t\treturn;\t}\r\n\tif (!getNetInterface()->getDistributedObjects())return;\r\n\t\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\r\n\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj && dobj==object)\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_DISTRIBUTED_BASE_OBJECT,\"Removed : server id : %d | class : %s \",object->getServerID(),object->getDistributedClass() ? object->getDistributedClass()->getClassName().getString() : \"NOCLASS\");\r\n\t\t\tgetNetInterface()->getDistributedObjects()->erase(begin);\r\n\r\n\t\t\txDistributedClass *_class = object->getDistributedClass();\r\n\t\t\tif (_class && _class->getEnitityType() == E_DC_BTYPE_SESSION)\r\n\t\t\t{\r\n\t\t\t\t\tgetNetInterface()->getDistributedClassInterface()->destroyClass(_class);\r\n\t\t\t}else\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Object %d : %s has no class!\",object->getServerID(),object->GetName().getString());\r\n\r\n\t\t\treturn;\r\n\t\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nIDistributedObjects::removeAll(xDistributedObjectsArrayType *distObjects)\r\n{\r\n\tif (!distObjects)return;\r\n\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\t//distObjects->erase(begin);\r\n\t\t\tdelete dobj;\r\n\t\t}\r\n\t\t//begin = distObjects->begin();\r\n\t\tbegin++;\r\n\t}\r\n\r\n\tdistObjects->clear();\r\n\r\n}\r\n\r\n\r\n#ifndef __P_FLUIDS_FLUID_EMITTER_H__\r\n#define __P_FLUIDS_FLUID_EMITTER_H__\r\n\r\n\r\n/** \\addtogroup fluids\r\n @{\r\n*/\r\n\r\n\r\n#include \"Nxp.h\"\r\n#include \"NxPhysicsSDK.h\"\r\n#include \"pFluidEmitterDesc.h\"\r\n\r\nclass pFluid;\r\nclass pFluidEmitterDesc;\r\nclass NxShape;\r\n\r\n/**\r\n\\brief The fluid emitter class. It represents an emitter (fluid source) which is associated with one fluid.\r\n\r\nThe emitter is an alternative to adding particles to the fluid via the pFluid::addParticles() method.\r\n\r\nEmission always takes place in a plane given by the orientation and position of the emitter. The \r\nshape of the area of emission is either a rectangle or an ellipse. The direction of emission is usually \r\nperpendicular to the emission plane. However, this can be randomly modulated using the setRandomAngle() \r\nmethod. An emitter can have two types of operation:\r\n
    \r\n
  1. \r\n\tConstant pressure.\r\n\t\tIn this case the state of the surrounding fluid is taken into account. The emitter tries \r\n\t\tto match the rest spacing of the particles. Nice rays of water can be generated this way.\r\n
  2. \r\n\tConstant flow rate.\r\n\t\tIn this case the emitter keeps emitting the same number of particles each frame. The rate can \r\n\t\tbe adjusted dynamically.\r\n
\r\nThe emitter's pose can be animated directly or attached to a shape which belongs to a \r\ndynamic actor. This shape is called the frame shape. When attaching an emitter to a shape, one \r\nhas the option of enabling impulse transfer from the emitter to the body of the shape. \r\nThe impulse generated is dependent on the rate, density, \r\nand velocity of the emitted particles.\r\n\r\n*/\r\nclass MODULE_API pFluidEmitter\r\n{\r\n\r\n\tpublic:\r\n\t\tpFluidEmitter();\r\n\t\t~pFluidEmitter()\t{}\r\n\r\n\t/**\r\n\t\\brief Sets the position of the emitter in world space.\r\n\r\n\t\\param[in] vec New position in world space.\r\n\r\n\t*/\r\n\tvoid\t\tsetGlobalPosition(const VxVector& vec);\r\n\r\n\t/**\r\n\t\\brief Sets the orientation of the emitter in world space.\r\n\r\n\t\\param[in] rot New orientation in world space.\r\n\t*/\r\n\tvoid\t\tsetGlobalOrientation(const VxQuaternion& rot);\r\n\r\n\t/**\r\n\t\\brief Returns the position of the emitter in world space.\r\n\r\n\t\\return The world space position.\r\n\t*/\r\n\tVxVector\t\tgetGlobalPosition()const;\r\n\r\n\t/**\r\n\t\\brief Returns the orientation of the emitter in world space.\r\n\r\n\t\\return The world space orientation.\r\n\r\n\t*/\r\n\t\r\n\tVxQuaternion\t\tgetGlobalOrientation()const;\r\n\r\n\t/**\r\n\t\\brief Sets the position of the emitter relative to the frameShape. \r\n\r\n\tThe pose is relative to the shape frame.\r\n\r\n\tIf the frameShape is NULL, world space is used.\r\n\r\n\t\\param[in] vec The new local position of the emitter.\r\n\r\n\t@see pFluidEmitterDesc.relPose\r\n\t*/\r\n\tvoid\t\tsetLocalPosition(const VxVector& vec)\t;\r\n\r\n\t/**\r\n\t\\brief Sets the orientation of the emitter relative to the frameShape. \r\n\r\n\tThe pose is relative to the shape frame.\r\n\r\n\tIf the frameShape is NULL, world space is used.\r\n\r\n\t\\param[in] mat The new local orientation of the emitter.\r\n\r\n\t@see pFluidEmitterDesc.relPose\r\n\t*/\r\n\tvoid\t\tsetLocalOrientation(const VxQuaternion& mat);\r\n\r\n\t\r\n\t/**\r\n\t\\brief Returns the position of the emitter relative to the frameShape. \r\n\r\n\tThe pose is relative to the shape frame.\r\n\r\n\tIf the frameShape is NULL, world space is used.\r\n\r\n\t\\return The local position of the emitter.\r\n\t@see pFluidEmitterDesc.relPose\r\n\t*/\r\n\r\n\tVxVector\t\tgetLocalPosition()const;\r\n\r\n\t/**\r\n\t\\brief Returns the orientation of the emitter relative to the frameShape. \r\n\r\n\tThe pose is relative to the shape frame.\r\n\r\n\tIf the frameShape is NULL, world space is used.\r\n\r\n\t\\return The local orientation of the emitter.\r\n\r\n\t@see pFluidEmitterDesc.relPose\r\n\t*/\r\n\tVxQuaternion\t\tgetLocalOrientation()const;\r\n\r\n\t/**\r\n\t\\brief Sets the frame shape. Can be set to NULL.\r\n\r\n\t\\param[in] shape The frame shape.\r\n\r\n\t@see pFluidEmitterDesc.frameShape\r\n\t*/\r\n\tvoid \t\tsetFrameShape(CK3dEntity* shape);\r\n\r\n\t/**\r\n\t\\brief Returns the frame shape. May be NULL.\r\n\r\n\t\\return The frame shape.\r\n\r\n\t@see pFluidEmitterDesc.frameShape\r\n\t*/\r\n\tCK3dEntity * \tgetFrameShape()\t\t\t\t\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Returns the radius of the emitter along the x axis.\r\n\r\n\t\\return Radius of emitter along the X axis.\r\n\t\r\n\t@see pFluidEmitterDesc.dimensionX\r\n\t*/\r\n\tfloat \t\t\tgetDimensionX()\t\t\t\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Returns the radius of the emitter along the y axis.\r\n\r\n\t\\return Radius of emitter along the Y axis.\r\n\r\n\t@see pFluidEmitterDesc.dimensionY\r\n\t*/\r\n\tfloat \t\t\tgetDimensionY()const;\r\n\r\n\t/**\r\n\t\\brief Sets the maximal random displacement in every dimension.\r\n\r\n\t\\param[in] disp The maximal random displacement of particles.\r\n\t@see pFluidEmitterDesc.randomPos\r\n\t*/\r\n\tvoid \t\t\tsetRandomPos(VxVector disp);\r\n\r\n\t/**\r\n\t\\brief Returns the maximal random displacement in every dimension.\r\n\r\n\t\\return The maximal random displacement of particles.\r\n\r\n\t@see pFluidEmitterDesc.randomPos\r\n\t*/\r\n\tVxVector \t\t\tgetRandomPos()const;\r\n\r\n\t/**\r\n\t\\brief Sets the maximal random angle offset (in radians). \r\n\r\n\tUnit: Radians\r\n\r\n\t\\param[in] angle Maximum random angle for emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.randomAngle\r\n\t*/\r\n\tvoid \t\t\tsetRandomAngle(float angle);\r\n\r\n\t/**\r\n\t\\brief Returns the maximal random angle offset (in radians). \r\n\r\n\tUnit: Radians\r\n\r\n\t\\return Maximum random angle for emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.randomAngle\r\n\t*/\r\n\tfloat \t\t\tgetRandomAngle();\r\n\r\n\t/**\r\n\t\\brief Sets the velocity magnitude of the emitted particles. \r\n\r\n\t\\param[in] vel New velocity magnitude of emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.fluidVelocityMagnitude\r\n\t*/\r\n\tvoid \t\t\tsetFluidVelocityMagnitude(float vel)\t;\r\n\r\n\t/**\r\n\t\\brief Returns the velocity magnitude of the emitted particles.\r\n\r\n\t\\return Velocity magnitude of emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.fluidVelocityMagnitude\r\n\t*/\r\n\tfloat \t\t\tgetFluidVelocityMagnitude()\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Sets the emission rate (particles/second).\r\n\t\r\n\tOnly used if the pEmitterType is PFET_ConstantFlowRate.\r\n\r\n\t\\param[in] rate New emission rate.\r\n\r\n\t@see pFluidEmitterDesc.rate\r\n\t*/\r\n\tvoid \t\t\tsetRate(float rate);\r\n\r\n\t/**\r\n\t\\brief Returns the emission rate.\r\n\r\n\t\\return Emission rate.\r\n\t@see pFluidEmitterDesc.rate\r\n\t*/\r\n\tfloat \t\t\tgetRate()\t\t\t\t\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Sets the particle lifetime.\r\n\r\n\t\\param[in] life Lifetime of emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.particleLifetime\r\n\t*/\r\n\tvoid \t\t\tsetParticleLifetime(float life)\t;\r\n\r\n\t/**\r\n\t\\brief Returns the particle lifetime.\r\n\r\n\t\\return Lifetime of emitted particles.\r\n\r\n\t@see pFluidEmitterDesc.particleLifetime\r\n\t*/\r\n\tfloat \t\t\tgetParticleLifetime()\t\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Sets the repulsion coefficient.\r\n\r\n\t\\param[in] coefficient The repulsion coefficient in the range from 0 to inf.\r\n\r\n\t@see pFluidEmitterDesc.repulsionCoefficient getRepulsionCoefficient()\r\n\t*/\r\n\tvoid\t\t\t\tsetRepulsionCoefficient(float coefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves the repulsion coefficient.\r\n\r\n\t\\return The repulsion coefficient.\r\n\t@see pFluidEmitterDesc.repulsionCoefficient setRepulsionCoefficient()\r\n\t*/\r\n\tfloat\t\t\t\tgetRepulsionCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Resets the particle reservoir. \r\n\r\n\t\\param[in] new maxParticles value.\r\n\t@see pFluidEmitterDesc.maxParticles\r\n\t*/\r\n\tvoid\t\t\t\tresetEmission(int maxParticles);\r\n\r\n\t/**\r\n\t\\brief Returns the maximal particle number to be emitted. \r\n\r\n\t\\return max particles.\r\n\t\r\n\t@see pFluidEmitterDesc.maxParticles\r\n\t*/\r\n\tint \t\t\t\tgetMaxParticles()\t\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Returns the number of particles that have been emitted already. \r\n\r\n\t\\return number of particles already emitted.\r\n\r\n\t*/\r\n\tint\t\t\t\tgetNbParticlesEmitted()\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Sets the emitter flags. \r\n\r\n\t\\param[in] flag Member of #pFluidEmitterFlag.\r\n\t\\param[in] val New flag value.\r\n\r\n\t@see pFluidEmitterFlag\r\n\t*/\r\n\tvoid\t\t\tsetFlag(pFluidEmitterFlag flag, bool val);\r\n\r\n\t/**\r\n\t\\brief Returns the emitter flags.\r\n\r\n\t\\param[in] flag Member of #pFluidEmitterFlag.\r\n\t\\return The current flag value.\r\n\r\n\t@see pFluidEmitterFlag\r\n\t*/\r\n\tbool\t\t\tgetFlag(pFluidEmitterFlag flag)\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Get the emitter shape.\r\n\r\n\t\\param[in] shape Member of #pEmitterShape.\r\n\t\\return True if it is of type shape.\r\n\r\n\t@see pFluidEmitterDesc.shape\r\n\t*/\r\n\tbool\t\t\tgetShape(pEmitterShape shape)\t\t\tconst;\r\n\r\n\t/**\r\n\t\\brief Get the emitter type.\r\n\r\n\t\\param[in] type Member of #pEmitterType\r\n\t\\return True if it is of type type.\r\n\r\n\t@see pEmitterType\r\n\t*/\r\n\tbool\t\t\tgetType(pEmitterType type) const;\r\n\r\n\t\r\n\tNxFluidEmitter* getEmitter() const { return mEmitter; }\r\n\tvoid setEmitter(NxFluidEmitter* val) { mEmitter = val; }\r\n\r\n\r\n\t/**\r\n\t\\brief Returns the owner fluid.\r\n\r\n\t\\return The fluid this emitter is associated with.\r\n\r\n\t*/\r\n\tpFluid * getFluid() const { return mFluid; }\r\n\t\r\n\tvoid setFluid(pFluid * val) { mFluid = val; }\r\n\t\r\n\r\n\tCK_ID getEntityReference() const { return mEntityReference; }\r\n\tvoid setEntityReference(CK_ID val) { mEntityReference = val; }\r\n\t\r\n\tpFluidRenderSettings * getRenderSettings() const { return mRenderSettings; }\r\n\tvoid setRenderSettings(pFluidRenderSettings * val) { mRenderSettings = val; }\r\n\t\r\n\r\nprivate : \r\n\r\n\t\r\n\tNxFluidEmitter* mEmitter;\r\n\r\n\r\n\tpFluid *mFluid;\r\n\r\n\tCK_ID mEntityReference;\r\n\r\n\tpFluidRenderSettings *mRenderSettings;\r\n\t\r\n};\r\n\r\n/** @} */\r\n\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SendMidiSignal\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateSendMidiSignalProto(CKBehaviorPrototype **);\r\nint SendMidiSignal(const CKBehaviorContext& behcontext);\r\n\r\nCKERROR SendMidiSignalCallBack(const CKBehaviorContext& behcontext); // CallBack Functioon\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorSendMidiSignalDecl()\r\n{\r\n CKObjectDeclaration *od = CreateCKObjectDeclaration(\"Send Midi Data\");\t\r\n od->SetDescription(\"Sends a Midi signal.\");\r\n od->SetCategory(\"Controllers/Midi\");\r\n od->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n od->SetGuid(CKGUID(0x19c33646,0x22be5e86));\r\n od->SetAuthorGuid(VIRTOOLS_GUID);\r\n od->SetAuthorName(\"\");\r\n od->SetVersion(0x00020000);\r\n od->SetCreationFunction(CreateSendMidiSignalProto);\r\n od->SetCompatibleClassId(CKCID_BEOBJECT);\r\n return od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateSendMidiSignalProto(CKBehaviorPrototype **pproto)\r\n{\r\n CKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Send Midi Data\");\r\n if(!proto) return CKERR_OUTOFMEMORY;\r\n \r\n proto->DeclareInput(\"On\");\r\n \r\n proto->DeclareOutput(\"Activated\");\r\n proto->DeclareOutput(\"Error\");\r\n \r\n proto->DeclareInParameter(\"cmd\", CKPGUID_INT, \"144\");\r\n proto->DeclareInParameter(\"var0\", CKPGUID_INT, \"10\");\r\n proto->DeclareInParameter(\"var1\", CKPGUID_INT, \"0\");\r\n proto->DeclareOutParameter(\"return code\", CKPGUID_INT, \"0\");\r\n\r\n proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n proto->SetFunction(SendMidiSignal);\r\n\r\n *pproto = proto;\r\n return CK_OK;\r\n}\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint SendMidiSignal(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tMidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\t\r\n\tint return_code;\r\n\t\r\n\tunion { unsigned long word; unsigned char data[4]; } message;\r\n\r\n\tbeh->GetInputParameterValue(0, &message.data[0]);\r\n\tbeh->GetInputParameterValue(1, &message.data[1]);\r\n\tbeh->GetInputParameterValue(2, &message.data[2] );\r\n\tmessage.data[3] = 0; // unused\r\n\r\n\treturn_code = midiOutShortMsg(mm->midiDeviceOutHandle, message.word);\r\n\n\tif (return_code != MMSYSERR_NOERROR) {\n\t\tmm->m_Context->OutputToConsole(\"error sending midi-cmd\");\n\t\tbeh->SetOutputParameterValue(0,&return_code);\n\t\tbeh->ActivateInput(0, FALSE);\r\n\t\treturn CK_OK;\r\n\t}else\r\n\t\tbeh->ActivateInput(1, FALSE);\r\n \r\n return CK_OK;\r\n\r\n}\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* Fichier de portage Applis 16 bits --> Applis 32 bits */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n/* Version 1.0 ------------------------------------------------------- */\r\n/* 25.11.95 Creation du source pour portage 32 bits */\r\n\r\n\r\n#include \r\n#include \r\n#include \"port32.h\"\r\n\r\n/* --------------------------------- */\r\n/* 32 bits code */\r\n/* --------------------------------- */ \r\n\r\n#ifdef _WIN32\r\nHINSTANCE GetTaskInstance (HWND hParentWnd)\r\n{\r\nreturn (HINSTANCE) GetWindowLong (hParentWnd,GWL_HINSTANCE); \r\n} /* GetTaskInstance */\r\n\r\n\r\nLPSTR GetTempDrive(int nDrive)\r\n{\r\nstatic char szTempPath[144];\r\n GetTempPath (sizeof szTempPath, szTempPath);\r\nreturn (LPSTR) szTempPath;\r\n}\r\n#endif\r\n \r\n\r\n/* --------------------------------- */\r\n/* 16 bits code */\r\n/* --------------------------------- */ \r\n#ifndef _WIN32\r\nHINSTANCE GetTaskInstance (HWND hParentWnd)\r\n{\r\nTASKENTRY TaskEntry;\r\n if (hParentWnd==NULL)\r\n {\r\n TaskEntry.dwSize = sizeof TaskEntry;\r\n TaskFindHandle ( & TaskEntry, GetCurrentTask() );\r\n return TaskEntry.hInst;\r\n }\r\n else \r\n return (HINSTANCE) GetWindowWord (hParentWnd,GWW_HINSTANCE);\r\n} /* GetTaskInstance */\r\n#endif /* 16 bits code */\r\n\r\n\r\n \r\n#ifndef __vtDistributedObjectsInterface_h_\r\n#define __vtDistributedObjectsInterface_h_\r\n\r\n#include \"xNetTypes.h\"\r\nclass xDistributedObject;\r\nclass xNetInterface;\r\n\r\n\r\nclass IDistributedObjects\r\n{\r\npublic:\r\n\tIDistributedObjects();\r\n\tIDistributedObjects(xNetInterface *netInterface);\r\n\t~IDistributedObjects();\r\n\r\n\t\r\n\t\r\n\txDistributedObject *create(int objID,const char *templateClassName,const char* objectName=\"\");\r\n\r\n\txDistributedObject *getByUserID(int userID,int classType);\r\n\txDistributedObject *get(int serverID);\r\n\txDistributedObject *getByEntityID(int entityID);\r\n\txDistributedObject *get(const char*name);\r\n\txDistributedObject *get(const char*name,int classType);\r\n\r\n\txNetInterface * getNetInterface(){return m_NetworkInterface;}\r\n\tvoid setNetInterface(xNetInterface * val){ m_NetworkInterface = val; }\r\n\r\n\tvoid create(const char* objectName,const char*className);\r\n\tvoid cCreateDistObject(int objectID,int ownerID,const char* objectName,const char*className);\r\n\tvoid removeObject(xDistributedObject* object);\r\n\tvoid deleteObject(int serverID);\r\n\tvoid deleteObject(xDistributedObject*object);\r\n\tvoid Clean();\r\n\tvirtual void Destroy();\r\n\tvirtual void removeAll(xDistributedObjectsArrayType *distObjects);\r\n\tuxString print(TNL::BitSet32 flags);\r\n\r\n\t\r\n\r\nprotected:\r\n//\tTNL::SafePtr m_NetworkInterface;\r\n\txNetInterface *m_NetworkInterface;\r\n\t\r\nprivate:\r\n\r\n\r\n};\r\n#endif\r\n// OggReaderDll.cpp : Defines the entry point for the DLL application.\r\n//\r\n\r\n#include \"stdafx.h\"\r\n\r\n#define READER_COUNT 1\r\nCKPluginInfo g_piInfo[READER_COUNT];\r\n\r\n#define READER_VERSION 0x00000001\r\n#define OGGREADER_GUID CKGUID(0x28391930,0x225f26df)\r\n\r\n\r\nCKPluginInfo* OGGReader::GetReaderInfo()\r\n{\r\n\treturn &g_piInfo[0];\r\n}\r\n\r\n#ifdef CK_LIB\r\n\tCKDataReader *CKGet_OggReader_Reader(int pos)\r\n#else\r\n\tCKDataReader* CKGetReader(int pos)\r\n#endif\r\n{\r\n\treturn new OGGReader;\r\n}\r\n \r\n\r\n\r\n#ifdef CK_LIB\r\n\tCKPluginInfo* CKGet_OggReader_PluginInfo(int index)\r\n#else\r\n\tCKPluginInfo* CKGetPluginInfo(int index)\r\n#endif\r\n{\r\n\t\tg_piInfo[0].m_GUID\t\t = OGGREADER_GUID;\r\n\t\tg_piInfo[0].m_Version\t\t= READER_VERSION;\r\n\t\tg_piInfo[0].m_Description\t= \"Ogg Sound Files\";\r\n\t\tg_piInfo[0].m_Summary\t\t= \"Ogg reader\";\r\n\t\tg_piInfo[0].m_Extension\t\t= \"ogg\";\r\n\t\tg_piInfo[0].m_Author\t\t= \"Flashbang Studios, LLC\";\r\n\t\t//g_piInfo[0].m_InitInstanceFct = InitInstance;\r\n\t\tg_piInfo[0].m_Type\t\t\t= CKPLUGIN_SOUND_READER;\t// Plugin Type\r\n\r\n\t\treturn &g_piInfo[0];\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJPointPlaneDecl();\r\nCKERROR CreatePJPointPlaneProto(CKBehaviorPrototype **pproto);\r\nint PJPointPlane(const CKBehaviorContext& behcontext);\r\nCKERROR PJPointPlaneCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Anchor,\r\n\tbI_AnchorRef,\r\n\tbI_Axis,\r\n\tbI_AxisRef,\r\n\tbI_Coll\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJPointPlaneDecl\r\n// FullName: FillBehaviorPJPointPlaneDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJPointPlaneDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJPointInPlane\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets/modifies a point in plane joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6b7f6a11,0x4cb565b8));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJPointPlaneProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJPointPlaneProto\r\n// FullName: CreatePJPointPlaneProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJPointPlaneProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJPointInPlane\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\t/*! \\page PJPointInPlane \r\n\r\n\t
\r\n\tPJPointPlane is categorized in \\ref Joints\r\n\t
\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a cylindrical joint between a two bodies or the world.\r\n\t
\r\n\t
See PJPointInPlane.cmo.\r\n\r\n\r\n\t\\image html pointInPlaneJoint.png\r\n\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJPointPlane.png\r\n\r\n\tA point in plane joint constrains a point on one actor to only move inside a plane attached to another actor. The point attached to the plane is defined by the anchor point. The joint's axis specifies the plane normal.\r\n\r\n\tAn example for a point in plane joint is a magnet on a refrigerator.\r\n\r\n\tDOFs removed: 1\r\n\tDOFs remaining: 5\r\n\r\n\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\tAnchor:A point in world space coordinates. See pJointPointInPlane::setGlobalAnchor().\r\n\t
\r\n\tAnchor Reference: A helper entity to transform a local anchor into the world space.\r\n\t
\r\n\tAxis: An in world space. See pJointPointInPlane::setGlobalAxis().\r\n\t
\r\n\tAxis Up Reference: A helper entity to transform a local axis into the world space.\r\n\t
\r\n\tCollision: Enables Collision. See pJointPointInPlane::enableCollision().\r\n\t
\r\n\r\n\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include PJPointInPlane.vsl\r\n\t\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createPointInPlaneJoint().
\r\n\r\n\t*/\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetBehaviorCallbackFct( PJPointPlaneCB );\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Anchor\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Anchor Reference\",CKPGUID_3DENTITY);\r\n\t\r\n\tproto->DeclareInParameter(\"Axis\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Axis Up Reference\",CKPGUID_3DENTITY);\r\n\t\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL);\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJPointPlane);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJPointPlane\r\n// FullName: PJPointPlane\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJPointPlane(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_PointInPlane))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA && ! worldB )\r\n\t\t\tbbErrorME(\"Couldnt find any world object\");\r\n\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor = GetInputParameterValue(beh,bI_Anchor);\r\n\t\tVxVector anchorOut = anchor;\r\n\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);\r\n\t\tif (anchorReference)\r\n\t\t{\r\n\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t}\r\n\r\n\t\t//swing axis\r\n\t\tVxVector Axis = GetInputParameterValue(beh,bI_Axis);\r\n\t\tVxVector axisOut = Axis;\r\n\t\tCK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);\r\n\r\n\t\tif (axisReference)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\taxisReference->GetOrientation(&dir,&up,&right);\r\n\t\t\taxisReference->TransformVector(&axisOut,&up);\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint col = GetInputParameterValue(beh,bI_Coll);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\tpJointPointInPlane *joint = static_cast(GetPMan()->getJoint(target,targetB,JT_PointInPlane));\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joint create ? \r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createPointInPlaneJoint(target,targetB,anchorOut,axisOut));\r\n\t\t\t}\r\n\t\t\t////////////////////////////////////////////////////////////////////////// Modification : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tjoint->setGlobalAxis(axisOut);\r\n\t\t\t\tjoint->setGlobalAnchor(anchorOut);\r\n\t\t\t\tjoint->enableCollision(col);\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJPointPlaneCB\r\n// FullName: PJPointPlaneCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJPointPlaneCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#ifndef __VTODE_ENUMS_H_\r\n#define __VTODE_ENUMS_H_\r\n\r\n\r\n#endif#ifndef SOFT_MESH_OBJ_H\r\n\r\n#define SOFT_MESH_OBJ_H\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nclass SoftMeshInterface;\r\n\r\nbool loadSoftMeshObj(const char *oname,const char *tname,SoftMeshInterface *smi);\r\n\r\n}; // END OF SOFTBODY NAMESPACE\r\n\r\n#endif\r\nrmdir .\\Release /s /q\r\nmkdir Release\r\nxcopy ..\\Release\\Author .\\Release /s /e\r\n\r\nREM #rar a -ep1 -r -s -x@RarExclusionList.txt vtPhysXDemo.zip ..\\Release\\Author\\\r\n\r\nwinrar a -ep1 -r -s -x@RarExclusionList.txt -n@RarInclusionList.txt vtPhysXDemo.zip Release\r\n\r\n\r\nREM rar a -r -s -x@RarExclusionList.txt -agYYYYMMDD-HHMM GBLSourceSnapshot.rar ..\\\\..\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n/* -------------------------- */\r\n/* internal header file */\r\n/* -------------------------- */\r\n\r\n\r\n#ifdef PAS_TCP4W\r\n# define FTP_DEFCTRLPORT (htons (21)) /* port FTP commande */\r\n#else\r\n# define FTP_DEFCTRLPORT 21 /* port FTP commande */\r\n#endif\r\n#define FTP_DEFTIMEOUT 30 /* timeout en secondes */\r\n#define FTP_TMPSTRLENGTH 50 /* taille d'une chaine temporaire */\r\n#define FTP_REPSTRLENGTH 256 /* taille d'une chaine repertoire */\r\n\r\n\r\n/* messages internes */\r\n#define WMFTP_RELEASE (WM_USER+92) /* msg interne demande FtpRelease */\r\n#define WMFTP_RECV (WM_USER+95) /* msg interne de réception fichier */\r\n#define WMFTP_DIR (WM_USER+96) /* msg interne de réception dir */\r\n#define WMFTP_SEND (WM_USER+98) /* msg interne d'envoi de fichier */\r\n\r\n/* Modes d'ouverture de fichier */\r\n#define FTPMODE_WRITE 32\r\n#define FTPMODE_READ 216\r\n#define FTPMODE_APPEND 467\r\n#define FTPMODE_NOTHING 0\r\n\r\n/* pause dans l'envoi/réception */\r\n#define FTP_DEFASYNCALONE 10\r\n#define FTP_DEFASYNCMULTI 3\r\n#define FTP_DEFDELAY 100 /* millisecondes */\r\n#define FTP_DIRRATE(pX) (pX->Next==NULL && pX->Prev==NULL ? 10 : 4)\r\n#define FTP_RATE(pX) (pX->Next==NULL && pX->Prev==NULL ? \\\r\n pX->File.nAsyncAlone : pX->File.nAsyncMulti)\r\n\r\n/* return codes for GetFtpConnectSocket/GetFtpListeSocket */\r\n#define INVALID_MODE ((SOCKET) -2)\r\n#define INVALID_ANSWER ((SOCKET) -3)\r\n\r\n\r\n/* Arret pendant un transfert */\r\n#define HAS_ABORTED() ( IsBadWritePtr (pProcData,sizeof *pProcData) \\\r\n || pProcData->File.bAborted)\r\n\r\n/* Fin de fonction asynchrone/synchrone */ \r\n#define RETURN(pD,x) \\\r\n { if( (! IsBadWritePtr(pD,sizeof *pD)) && pD->File.bAsyncMode ) \\\r\n { PostMessage(pD->Msg.hParentWnd,pD->Msg.nCompletedMessage,TRUE,x); \\\r\n return FTPERR_OK; } \\\r\n else { return x; } }\r\n\r\n\r\n\r\n\r\n/* ------------------------------------------------- */\r\n/* structures imbriquees */\r\n/* ------------------------------------------------- */\r\nstruct S_FtpData\r\n{\r\n SOCKET ctrl_socket; /* control stream init INVALID_SOCKET */\r\n SOCKET data_socket; /* data stream init INVALID_SOCKET */\r\n char cType; /* type (ASCII/binary) init TYPE_A */\r\n BOOL bVerbose; /* verbose mode init FALSE */ \r\n BOOL bPassif; /* VRAI -> mode passif */ \r\n unsigned short nPort; /* connexion Port init FTP_DEFPORT */\r\n unsigned nTimeOut; /* TimeOut in seconds init FTP_DEFTIMEOUT */\r\n HFILE hLogFile; /* Log file */ \r\n char szInBuf [2048]; /* incoming Buffer */\r\n struct sockaddr_in saSockAddr; /* not used anymore */\r\n struct sockaddr_in saAcceptAddr; /* not used anymore */\r\n}; /* struct S_FtpData */\r\n\r\n\r\nstruct S_FileTrf \r\n{\r\n HFILE hf; /* handle of the file which is being transfered */\r\n unsigned nCount; /* number of writes/reads made on a file */\r\n unsigned nAsyncAlone;/* pause each N frame in Async mode (Def 40) */\r\n unsigned nAsyncMulti;/* Idem but more than one FTP sssion (Def 10) */\r\n unsigned nDelay; /* time of the pause in milliseconds */\r\n BOOL bAborted; /* data transfer has been canceled */\r\n char szBuf[FTP_DATABUFFER]; /* Data buffer */\r\n BOOL bNotify; /* application receives a msg each data packet */\r\n BOOL bAsyncMode; /* synchronous or asynchronous Mode */\r\n LONG lPos; /* Bytes transfered */\r\n LONG lTotal; /* bytes to be transfered */\r\n}; /* struct S_FileTrf */\r\n\r\nstruct S_Msg\r\n{\r\n HWND hParentWnd; /* window which the msg is to be passed */\r\n UINT nCompletedMessage; /* msg to be sent at end of the function */\r\n}; /* struct S_Msg */\r\n\r\n\r\nstruct S_Verbose\r\n{\r\n HWND hVerboseWnd; /* window which the message is to be passed */\r\n UINT nVerboseMsg; /* msg to be sent each time a line is received */\r\n};\r\n\r\n/* ------------------------------------------------- */\r\n/* global structure */\r\n/* ------------------------------------------------- */\r\nstruct S_ProcData\r\n{ \r\n /* task data */\r\n THREADID (CALLBACK * fIdentifyThread)(void); /* function d'identification thread */\r\n THREADID nThreadIdent; /* Identifiant du Thread */\r\n /*HTASK hTask; * Task Id */\r\n HWND hFtpWnd; /* Handle of the internal window */\r\n HWND hParentWnd; /* handle given to the FtpInit function */\r\n HINSTANCE hInstance; /* Task Instance */\r\n BOOL bRelease; /* FtpRelease has been called */\r\n\r\n /* Mesasge information */\r\n struct S_Msg Msg; \r\n struct S_Verbose VMsg; \r\n \r\n /* File information */\r\n struct S_FileTrf File; \r\n\r\n /* Ftp information */\r\n struct S_FtpData ftp;\r\n\r\n /* Linked list */\r\n struct S_ProcData far *Next;\r\n struct S_ProcData far *Prev;\r\n}; /* struct S_ProcData */\r\n\r\ntypedef struct S_ProcData far * LPProcData;\r\ntypedef struct S_FtpData far * LPFtpData;\r\n\r\n\r\n/* ------------------------------------------------- */\r\n/* donnees automate */\r\n/* ------------------------------------------------- */\r\n#define _S_END -2\r\n\r\nenum FtpCmds { _S_CONNECT = 0, _S_USER, _S_PASS, _S_ACCOUNT, _S_QUIT, _S_HELP, \r\n _S_HELPCMD, _S_DELE, _S_CWD, _S_CDUP, _S_MKD, _S_RMD, \r\n _S_PWD, _S_TYPE, _S_RNFR, _S_RNTO, _S_SYST, _S_NOOP, _S_REST,\r\n _S_ENDFILETRANSFER };\r\n\r\n\r\n/* ------------------------------------------------- */\r\n/* primitives internes */\r\n/* ------------------------------------------------- */\r\nLPProcData _export PASCAL FAR FtpDataPtr(void);\r\n\r\nint Protection (void);\r\nint PASCAL FAR IntFtpGetAnswerCode (LPFtpData pFtpData); \r\nint PASCAL FAR IntTnSend (SOCKET s, LPSTR szString, \r\n BOOL bHighPriority, HFILE hf);\r\n\r\n\r\n/* etage III : fonctions FTP */ \r\nint FtpCloseFileTransfer (LPProcData pProcData, BOOL bFlush);\r\n\r\n/* utilitaires */\r\nLPProcData ToolsLocateProcData (void);\r\nSOCKET GetFTPListenSocket(LPFtpData pFtpData);\r\nint AbortAction (LPProcData pProcData, BOOL bFlush, BOOL bMsg, UINT nDbg);\r\n\r\n/* Synchrones */\r\nint FtpSyncSend (LPProcData pProcData);\r\nint FtpSyncRecv (LPProcData pProcData);\r\n\r\n/* Asynchrone */\r\nLRESULT _export PASCAL FAR DLLWndProc (HWND hWnd, UINT Msg, \r\n WPARAM wParam, LPARAM lParam);\r\n\r\nvoid _cdecl Ftp4w_Trace (const char *szFile, const char *fmt, ...);\r\n/*\r\n * u2d v 1.10 Last Revision 02/03/1998 1.10\r\n *\r\n *===========================================================================\r\n *\r\n * Project: u2d, Unix To Dos converter\r\n * File: u2d.c\r\n * Purpose: u2d source code. \r\n * Compilation vith microsoft C compiler: \r\n * \t\tcl -O1 u2d.c setargv.obj \r\n *\r\n *===========================================================================\r\n * \r\n * This software is Copyright (c) 1996-1998 by \r\n *\r\n * This program is free software; you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation; either version 2 of the License, or\r\n * (at your option) any later version.\r\n * \r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU General Public License\r\n * along with this program; if not, write to the Free Software\r\n * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r\n * \r\n */ \r\n\r\n#include \r\n\r\n\r\nint Convert (char *szFile)\r\n{\r\n#define XX_RETURN(s,x) \\\r\n{ printf (\"%s\\n\", s) ; if (pFIn!=NULL) fclose(pFIn) ; \\\r\n if (pFOut!=NULL) fclose(pFOut); \\\r\n if (TmpFile!=NULL) remove(TmpFile); \\\r\n return x; }\r\n \r\nchar *TmpFile=NULL;\r\nint c;\r\nFILE *pFIn=NULL, *pFOut=NULL;\r\n\r\n printf (\"%s\", szFile); fflush (stdout);\r\n TmpFile = tmpnam(NULL); \r\n if (TmpFile==NULL) XX_RETURN (\"\\tCan not create temporary file\", -1);\r\n pFOut = fopen (TmpFile, \"w\");\r\n if (pFOut==NULL) XX_RETURN (\"\\tCan not create temporary file\", -2);\r\n pFIn = fopen (szFile, \"r\");\r\n if (pFIn==NULL) XX_RETURN (\"\\tCan not open input file\", -3);\r\n \r\n while ( (c=fgetc (pFIn)) != EOF)\r\n { if (fputc (c, pFOut)==EOF) XX_RETURN (\"\\tCan not write into output file\", -4); }\r\n if (!feof (pFIn)) XX_RETURN (\"\\tCan not read from input file\", -5);\r\n \r\n fclose (pFIn); fclose (pFOut);\r\n if (remove (szFile)) XX_RETURN (\"\\tCan not rename output file\", -6);\r\n if (rename (TmpFile, szFile)==-1)\r\n { printf (\"\\tinput file %s removed, temp file %s can not be removed\\n\", \r\n \t\t szFile, TmpFile);\r\n return -8; }\r\n printf (\"\\n\"); \r\nreturn 0;\r\n \r\n} /* Convert */\r\n\r\n\r\n\r\nint main (int argc, char *argv[])\r\n{\r\n if (argc<2) \r\n { \r\n printf (\"Usage: u2d file [file [...]]\\n\"\r\n \"Translate a unix text file. Existing file is overwritten\\n\");\r\n }\r\n else\r\n {int Ark;\r\n for (Ark=1 ; Ark#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\npJoint*PhysicManager::getJoint(CK3dEntity*referenceA,CK3dEntity*referenceB/* =NULL */,JType type/* =JT_Any */)\r\n{\r\n\r\n\tpJoint *result = NULL;\r\n\r\n\tpRigidBody *a\t= GetPMan()->getBody(referenceA);\r\n\tpRigidBody *b\t= GetPMan()->getBody(referenceB);\r\n\r\n\tpWorld *wA\t\t= a ? a->getWorld() : NULL;\r\n\tpWorld *wB\t\t= b ? b->getWorld()\t: NULL;\r\n\tpWorld *worldFinal = NULL;\r\n\r\n\r\n\tbool oneBodyJoint = false;// body with world frame ? \r\n\tCK3dEntity* oneBodyJointReference =NULL;\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity Checks\r\n\t//\r\n\tXString errorString;\r\n\t\r\n\t//\tReference A physicalized at all ? \r\n\tif ( !referenceA && !referenceB )\r\n\t{\r\n\t\terrorString.Format(\"No reference specified\");\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//\tReference A IS NOT Reference B ?\r\n\tif ( (referenceA!=NULL && referenceB!=NULL) && (a==b) )\r\n\t{\r\n\t\terrorString.Format(\"Reference A (%s) is the same as Reference B (%s)\",referenceA->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//\tReference A physicalized at all ? \r\n\tif (referenceA && !a){\r\n\t\t\r\n\t\terrorString.Format(\"Reference A (%s) valid but not physicalized\",referenceA->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//\tReference B physicalized at all ? \r\n\tif (referenceB && !b){\r\n\r\n\t\terrorString.Format(\"Reference B (%s) valid but not physicalized\",referenceB->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t//\tworld of object a valid ? \r\n\tif (a && !wA){\r\n\t\terrorString.Format(\"Reference A (%s) is physicalized but has no valid world object\",referenceA->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//\tworld of object b valid ? \r\n\tif (b && !wB){\r\n\t\terrorString.Format(\"Reference B (%s) is physicalized but has no valid world object\",referenceB->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\r\n\t// rigid bodies are in the same world\r\n\tif (\t\t(wA!=NULL && wB!=NULL)\t\t&&\t\t(wA!=wB)\t)\r\n\t{\r\n\t\terrorString.Format(\"Reference A (%s) and B(%s) is physicalized but are not in the same world\",referenceA->GetName(),referenceB->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorString.Str());\r\n\t\treturn result;\r\n\t}\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Preparing lookup \r\n\t//\r\n\tif (\t wA )\r\n\t\tworldFinal = wA;\r\n\tif (\t wB )\r\n\t\tworldFinal = wB;\r\n\r\n\r\n\t//\tconstraint is attached to world frame ? \r\n\tif ( (a && !b)\t|| (b && !a) )\r\n\t\toneBodyJoint = true;\r\n\r\n\t//\tworld frame constraint, track the reference \r\n\tif (oneBodyJoint)\r\n\t{\r\n\t\tif ( a )\r\n\t\t\toneBodyJointReference = referenceA;\r\n\t\tif ( b )\r\n\t\t\toneBodyJointReference = referenceB;\r\n\t}\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Parse the scene joints\r\n\t//\r\n\tNxU32\tjointCount = worldFinal->getScene()->getNbJoints();\r\n\tif (jointCount)\r\n\t{\r\n\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\tworldFinal->getScene()->resetJointIterator();\r\n\t\tfor\t(NxU32 i = 0;\ti <\tjointCount;\t++i)\r\n\t\t{\r\n\t\t\tNxJoint\t*j = worldFinal->getScene()->getNextJoint();\r\n\r\n\t\t\tpJoint *_cJoint = static_cast( j->userData );\r\n\t\t\tif (!_cJoint)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// Special case : has a joint at all, only for world frame constraints\r\n\t\t\t//\r\n\t\t\tif (type == JT_Any)\r\n\t\t\t{\r\n\t\t\t\t\tif (\t\toneBodyJoint &&\t\r\n\t\t\t\t\t\t\t_cJoint->GetVTEntA() == oneBodyJointReference ||\r\n\t\t\t\t\t\t\t_cJoint->GetVTEntB() == oneBodyJointReference \r\n\t\t\t\t\t )\r\n\t\t\t\t\treturn _cJoint;\r\n\t\t\t}\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// Specific joint type\r\n\t\t\t//\r\n\t\t\tif ( j->getType() == type)\r\n\t\t\t{\r\n\r\n\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// world constraint joint\r\n\t\t\t\t//\r\n\t\t\t\tif (oneBodyJoint &&\r\n\t\t\t\t\t_cJoint->GetVTEntA() == oneBodyJointReference ||\r\n\t\t\t\t\t_cJoint->GetVTEntB() == oneBodyJointReference\r\n\t\t\t\t)\r\n\t\t\t\treturn _cJoint;\r\n\t\t\t\t\r\n\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Two references given\r\n\t\t\t\t//\r\n\t\t\t\tif (\t_cJoint->GetVTEntA() == referenceA && _cJoint->GetVTEntB() == referenceB )\r\n\t\t\t\t\treturn _cJoint;\r\n\r\n\t\t\t\tif (\t_cJoint->GetVTEntA() == referenceB && _cJoint->GetVTEntB() == referenceA )\r\n\t\t\t\t\treturn _cJoint;\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}#include \"CKAll.h\"\r\n\r\n#ifdef WebPack\r\n\r\n\r\n\r\n\r\n\r\n#define CAMERA_BEHAVIOR\tCKGUID(0x12d94eba,0x47057415)\r\n#define CKPGUID_PROJECTIONTYPE\t\tCKDEFINEGUID(0x1ee22148, 0x602c1ca1)\r\n#define CKPGUID_MOUSEBUTTON CKGUID(0x1ff24d5a,0x122f2c1f)\r\n\r\nCKERROR InitInstanceCamera(CKContext* context)\r\n{\r\n\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tpm->RegisterNewEnum( CKPGUID_PROJECTIONTYPE,\"Projection Mode\",\"Perspective=1,Orthographic=2\" );\r\n\t// Mouse Camera Orbit\r\n\tpm->RegisterNewEnum(CKPGUID_MOUSEBUTTON,\"Mouse Button\",\"Left=0,Middle=2,Right=1\" );\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\nCKERROR ExitInstanceCamera(CKContext* context)\r\n{\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tpm->UnRegisterParameterType(CKPGUID_PROJECTIONTYPE);\r\n\tpm->UnRegisterParameterType(CKPGUID_MOUSEBUTTON);\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n\r\nint RegisterCameraBeh(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\t// Cameras/Basic\r\n\tRegisterBehavior(reg, FillBehaviorDollyDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetOrthographicZoomDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetCameraTargetDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetClippingDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetFOVDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetProjectionDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetZoomDecl);\r\n\r\n\t// Cameras/FX\r\n\tRegisterBehavior(reg, FillBehaviorCameraColorFilterDecl);\r\n\tRegisterBehavior(reg, FillBehaviorVertigoDecl);\r\n\r\n\t// Cameras/Montage\r\n\tRegisterBehavior(reg, FillBehaviorGetCurrentCameraDecl);\r\n\tRegisterBehavior(reg, FillBehaviorSetAsActiveCameraDecl);\r\n\r\n\t// Cameras/Movement\r\n\tRegisterBehavior(reg, FillBehaviorOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorKeyboardCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorMouseCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorJoystickCameraOrbitDecl);\r\n\tRegisterBehavior(reg, FillBehaviorGenericCameraOrbitDecl);\r\n\r\n\r\n\treturn 0;\r\n}\r\n\r\n#endif/* -*- c -*- */\n/* -------------------------------------------------------------------------\n * swig.i\n *\n * Interface file for the SWIG core.\n *\n * Author(s) : ()\n * ()\n *\n * Copyright (C) 1999-2000. The University of Chicago\n * See the file LICENSE for information on usage and redistribution.\n *\n * $Header: /cvsroot/swig/SWIG/Source/Swig/swig.i,v 1.11 2002/11/30 22:10:17 beazley Exp $\n * ------------------------------------------------------------------------- */\n\n/* todo: implement callable stuff -- ternaryfunc? */\n/* todo: new DOH type to wrap Python objects. geesh. */\n/* todo: Delattr -> return errors */\n\n%module swig\n\n%{\n#include \"doh.h\"\n%}\n\n%typemap(python,in) FILE * {\n $target = PyFile_AsFile($source);\n}\n\n%typemap(python,out) FILE * {\n $target = PyFile_FromFile($source, \"unknown\", \"?\", fclose);\n}\n\n%{\n /* -------------------------------------------------------------------------\n * An extension type for DOH objects -- we could use shadow classes,\n * but this will be lots faster, and provide a slightly cleaner interface.\n * ------------------------------------------------------------------------- */\n\n typedef struct PyDOH {\n PyObject_HEAD\n DOH *doh;\n } PyDOH;\n\n staticforward PyTypeObject PyDOHSequenceType, PyDOHMappingType;\n\n /* --------------------------------------------------------------------- */\n /* meta-functions\n */\n\n /* Given a DOH object, return an equivalent PyObject. Note that\n when the PyObject is destroyed, the DOH's reference count will\n decrease; thus this is refcount-safe on both the DOH and Python\n sides. */\n static PyObject * Swig_PyDOH_new(DOH *in) {\n PyDOH *self;\n if (!in)\n {\n\t Incref(Py_None);\n\t return Py_None;\n }\n if (DohIsMapping(in))\n\t self = PyObject_NEW(PyDOH, &PyDOHMappingType);\n else\n\t self = PyObject_NEW(PyDOH, &PyDOHSequenceType);\n if (!self) return (PyObject *)self;\n self->doh = in;\n Incref(in);\t\t/* increase the DOH refcount */\n return (PyObject *)self;\n }\n\n static void Swig_PyDOH_delete(PyDOH *self) {\n Delete(self->doh);\t\t/* decrease the DOH refcount */\n PyMem_DEL(self);\n }\n\n static int Swig_PyDOH_check(void *self) {\n return ((PyObject *)self)->ob_type == &PyDOHMappingType\n\t || ((PyObject *)self)->ob_type == &PyDOHSequenceType;\n }\n\n /* Given a PyObject, return an equivalent DOH object */\n static PyDOH *Swig_PyDOH_as_DOH(PyObject *source)\n {\n\t DOH *target;\n\n\t if (Swig_PyDOH_check(source))\n\t target = ((PyDOH *)source)->doh;\n\t else if (PyString_Check(source))\n\t target = (DOH *)PyString_AsString(source);\n\t else if (PySequence_Check(source))\n\t printf(\"Sequence -> NULL\\n\"), target = NULL;\n\t else if (PyMapping_Check(source))\n\t printf(\"Mapping -> NULL\\n\"), target = NULL;\n\t else if (PyNumber_Check(source))\n\t target = (DOH *)source;\n\t else if (PyFile_Check(source))\n\t target = (DOH *)PyFile_AsFile(source);\n\t else\n\t printf(\"?? -> NULL\\n\"), target = NULL;\n\n\t return target;\n }\n\n\n /* --------------------------------------------------------------------- */\n /* sequence methods\n */\n\n static int Swig_PyDOH_length(PyDOH *self) {\n return Len(self->doh);\t/* also a mapping method */\n }\n\n static PyObject *Swig_PyDOH_item(PyDOH *self, int index) {\n DOH *r = Getitem(self->doh, index);\n\n if (r)\n\t return Swig_PyDOH_new(r);\n\n /* return an exception */\n PyErr_SetObject(PyExc_KeyError, PyInt_FromLong(index));\n return NULL;\n }\n\n static int Swig_PyDOH_ass_item(PyDOH *self, int index,\n\t\t\t\t PyObject *v) {\n int result;\n if (v)\n\t result = Setitem(self->doh, index, Swig_PyDOH_as_DOH(v));\n else\t\t\t/* NULL v => delete item */\n\t result = Delitem(self->doh, index);\n\n /* post an exception if necessary */\n if (result == -1)\n\t PyErr_SetObject(PyExc_KeyError,\n\t\t\t PyInt_FromLong(index));\n\n return result;\n }\n\n static PySequenceMethods Swig_PyDOH_as_sequence = {\n (inquiry)Swig_PyDOH_length,\n (binaryfunc)NULL,\t\t/* sq_concat */\n (intargfunc)NULL,\t\t/* sq_repeat */\n (intargfunc)Swig_PyDOH_item,\n (intintargfunc)NULL,\t/* sq_slice */\n (intobjargproc)Swig_PyDOH_ass_item,\n (intintobjargproc)NULL\t/* sq_ass_slice */\n };\n\n\n /* --------------------------------------------------------------------- */\n /* Mapping methods\n */\n\n static PyObject *Swig_PyDOH_subscript(PyDOH *self, PyObject *k) {\n DOH *r = Getattr(self->doh, Swig_PyDOH_as_DOH(k));\n if (r)\n\t return Swig_PyDOH_new(r);\n\n PyErr_SetObject(PyExc_KeyError, k);\n return NULL;\n }\n\n static int Swig_PyDOH_ass_subscript(PyDOH *self, PyObject *k,\n\t\t\t\t PyObject *v) {\n int result = 0;\n if (v)\n\t result = Setattr(self->doh, Swig_PyDOH_as_DOH(k),\n\t\t\t Swig_PyDOH_as_DOH(v));\n else\n\t Delattr(self->doh, Swig_PyDOH_as_DOH(k));\n\n if (result == -1)\n\t PyErr_SetObject(PyExc_KeyError,\n\t\t\t k);\n\n return result;\n }\n\n static PyMappingMethods Swig_PyDOH_as_mapping = {\n (inquiry)Swig_PyDOH_length,\n (binaryfunc)Swig_PyDOH_subscript,\n (objobjargproc)Swig_PyDOH_ass_subscript\n };\n\n\n /* --------------------------------------------------------------------- */\n /* named methods\n */\n\n static PyObject *Swig_PyDOH_Copy(PyDOH *self, PyObject *args) {\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Copy\"))\n\t return NULL;\n _result = (DOH *)DohCopy(self->doh);\n return Swig_PyDOH_new(_result);\n }\n\n static PyObject *Swig_PyDOH_Clear(PyDOH *self, PyObject *args) {\n if(!PyArg_ParseTuple(args,\":Clear\"))\n\t return NULL;\n DohClear(self->doh);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n static PyObject *Swig_PyDOH_SetScope(PyDOH *self, PyObject *args) {\n int _arg1;\n\n if(!PyArg_ParseTuple(args,\"i:SetScope\",&_arg1))\n\t return NULL;\n DohSetScope(self->doh,_arg1);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n static PyObject *Swig_PyDOH_Dump(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n DOH * _arg1;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"O:Dump\",&_obj1))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n _result = (int )DohDump(self->doh,_arg1);\n return PyInt_FromLong(_result);\n }\n\n static PyObject *Swig_PyDOH_Firstkey(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Firstkey\"))\n\t return NULL;\n _result = (DOH *)DohFirstkey(self->doh);\n _resultobj = Swig_PyDOH_new(_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Nextkey(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Nextkey\"))\n\t return NULL;\n _result = (DOH *)DohNextkey(self->doh);\n _resultobj = Swig_PyDOH_new(_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_GetInt(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n DOH * _arg1;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"O:GetInt\",&_obj1))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n _result = (int )DohGetInt(self->doh,_arg1);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_GetDouble(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n double _result;\n DOH * _arg1;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"O:GetDouble\",&_obj1))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n _result = (double )DohGetDouble(self->doh,_arg1);\n _resultobj = Py_BuildValue(\"d\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_GetChar(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n char * _result;\n DOH * _arg1;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"O:GetChar\",&_obj1))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n _result = (char *)DohGetChar(self->doh,_arg1);\n _resultobj = Py_BuildValue(\"s\", _result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_SetInt(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _arg1;\n int _arg2;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"Oi:SetInt\",&_obj1,&_arg2))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n DohSetInt(self->doh,_arg1,_arg2);\n Py_INCREF(Py_None);\n _resultobj = Py_None;\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_SetDouble(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _arg1;\n double _arg2;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"Od:SetDouble\",&_obj1,&_arg2))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n DohSetDouble(self->doh,_arg1,_arg2);\n Py_INCREF(Py_None);\n _resultobj = Py_None;\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Insertitem(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n int _arg1;\n DOH * _arg2;\n PyObject * _obj2 = 0;\n\n if(!PyArg_ParseTuple(args,\"iO:Insertitem\",&_arg1,&_obj2))\n\t return NULL;\n _arg2 = Swig_PyDOH_as_DOH(_obj2);\n _result = (int )DohInsertitem(self->doh,_arg1,_arg2);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Firstitem(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Firstitem\"))\n\t return NULL;\n _result = (DOH *)DohFirstitem(self->doh);\n _resultobj = Swig_PyDOH_new(_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Nextitem(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Nextitem\"))\n\t return NULL;\n _result = (DOH *)DohNextitem(self->doh);\n _resultobj = Swig_PyDOH_new(_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Write(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n int _arg2;\n char * _arg1 = 0;\n\n if(!PyArg_ParseTuple(args,\"si:Write\",&_arg1,&_arg2))\n\t return NULL;\n _result = (int )DohWrite(self->doh,_arg1,_arg2);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Read(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n int _arg2;\n char *buffer;\n\n if(!PyArg_ParseTuple(args,\"i:Read\",&_arg2))\n\t return NULL;\n buffer = DohMalloc(_arg2);\n if (!buffer) {\n\t PyErr_SetString(PyExc_MemoryError, \"Not enough memory for Read buffer\");\n\t return NULL;\n }\n _result = (int )DohRead(self->doh,buffer,_arg2);\n _resultobj = Py_BuildValue(\"(is)\",_result, buffer);\n DohFree(buffer);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Seek(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n long _arg1;\n int _arg2;\n\n if(!PyArg_ParseTuple(args,\"li:Seek\",&_arg1,&_arg2))\n\t return NULL;\n _result = (int )DohSeek(self->doh,_arg1,_arg2);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Tell(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n long _result;\n\n if(!PyArg_ParseTuple(args,\":Tell\"))\n\t return NULL;\n _result = (long )DohTell(self->doh);\n _resultobj = Py_BuildValue(\"l\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Getc(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n\n if(!PyArg_ParseTuple(args,\":Getc\"))\n\t return NULL;\n _result = (int )DohGetc(self->doh);\n if (_result > 0) {\n\t char c[2] = { (char)_result, 0 };\n\t _resultobj = PyString_FromString(c);\n }\n else\n {\n\t Py_INCREF(Py_None);\n\t _resultobj = Py_None;\n }\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Putc(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n int _arg0;\n\n if(!PyArg_ParseTuple(args,\"i:Putc\",&_arg0))\n\t return NULL;\n _result = (int )DohPutc(_arg0, self->doh);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Ungetc(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n int _arg0;\n\n if(!PyArg_ParseTuple(args,\"iO:Ungetc\",&_arg0))\n\t return NULL;\n _result = (int )DohUngetc(_arg0,self->doh);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Getline(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _result;\n\n if(!PyArg_ParseTuple(args,\":Getline\"))\n\t return NULL;\n _result = (int )DohGetline(self->doh);\n _resultobj = Py_BuildValue(\"i\",_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Setline(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n int _arg1;\n\n if(!PyArg_ParseTuple(args,\"i:Setline\",&_arg1))\n\t return NULL;\n DohSetline(self->doh,_arg1);\n Py_INCREF(Py_None);\n _resultobj = Py_None;\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Getfile(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _result;\n\n if(!PyArg_ParseTuple(args,\":Getfile\"))\n\t return NULL;\n _result = (DOH *)DohGetfile(self->doh);\n _resultobj = Swig_PyDOH_new(_result);\n return _resultobj;\n }\n\n static PyObject *Swig_PyDOH_Setfile(PyDOH *self, PyObject *args) {\n PyObject * _resultobj;\n DOH * _arg1;\n PyObject * _obj1 = 0;\n\n if(!PyArg_ParseTuple(args,\"O:Setfile\",&_obj1))\n\t return NULL;\n _arg1 = Swig_PyDOH_as_DOH(_obj1);\n DohSetfile(self->doh,_arg1);\n Py_INCREF(Py_None);\n _resultobj = Py_None;\n return _resultobj;\n }\n\n static struct PyMethodDef Swig_PyDOH_methods[] = {\n {\"copy\", (PyCFunction)Swig_PyDOH_Copy, METH_VARARGS},\n {\"clear\", (PyCFunction)Swig_PyDOH_Clear, METH_VARARGS},\n {\"setscope\", (PyCFunction)Swig_PyDOH_SetScope, METH_VARARGS},\n {\"dump\", (PyCFunction)Swig_PyDOH_Dump, METH_VARARGS},\n {\"firstkey\", (PyCFunction)Swig_PyDOH_Firstkey, METH_VARARGS},\n {\"nextkey\", (PyCFunction)Swig_PyDOH_Nextkey, METH_VARARGS},\n {\"getint\", (PyCFunction)Swig_PyDOH_GetInt, METH_VARARGS},\n {\"getdouble\", (PyCFunction)Swig_PyDOH_GetDouble, METH_VARARGS},\n {\"getchar\", (PyCFunction)Swig_PyDOH_GetChar, METH_VARARGS},\n {\"setint\", (PyCFunction)Swig_PyDOH_SetInt, METH_VARARGS},\n {\"setdouble\", (PyCFunction)Swig_PyDOH_SetDouble, METH_VARARGS},\n {\"insertitem\", (PyCFunction)Swig_PyDOH_Insertitem, METH_VARARGS},\n {\"insert\", (PyCFunction)Swig_PyDOH_Insertitem, METH_VARARGS},\n {\"firstitem\", (PyCFunction)Swig_PyDOH_Firstitem, METH_VARARGS},\n {\"nextitem\", (PyCFunction)Swig_PyDOH_Nextitem, METH_VARARGS},\n {\"write\", (PyCFunction)Swig_PyDOH_Write, METH_VARARGS},\n {\"read\", (PyCFunction)Swig_PyDOH_Read, METH_VARARGS},\n {\"seek\", (PyCFunction)Swig_PyDOH_Seek, METH_VARARGS},\n {\"tell\", (PyCFunction)Swig_PyDOH_Tell, METH_VARARGS},\n {\"getc\", (PyCFunction)Swig_PyDOH_Getc, METH_VARARGS},\n {\"putc\", (PyCFunction)Swig_PyDOH_Putc, METH_VARARGS},\n {\"ungetc\", (PyCFunction)Swig_PyDOH_Ungetc, METH_VARARGS},\n {\"getline\", (PyCFunction)Swig_PyDOH_Getline, METH_VARARGS},\n {\"setline\", (PyCFunction)Swig_PyDOH_Setline, METH_VARARGS},\n {\"getfile\", (PyCFunction)Swig_PyDOH_Getfile, METH_VARARGS},\n {\"setfile\", (PyCFunction)Swig_PyDOH_Setfile, METH_VARARGS},\n {NULL, NULL}\n };\n\n\n /* --------------------------------------------------------------------- */\n /* general methods\n */\n\n static PyObject *Swig_PyDOH_getattr(PyDOH *self, char *name) {\n return Py_FindMethod(Swig_PyDOH_methods,\n\t\t\t (PyObject *)self, name);\n }\n\n static int Swig_PyDOH_setattr(PyDOH *self, char *name, PyObject *v) {\n return Setattr(self->doh, name, Swig_PyDOH_as_DOH(v));\n }\n\n static int Swig_PyDOH_cmp(PyDOH *self, PyObject *other) {\n return Cmp(self->doh, Swig_PyDOH_as_DOH(other));\n }\n\n static PyObject *Swig_PyDOH_repr(PyDOH *self) {\n char *str = Char(self->doh);\n char buffer[1024] = \"\";\n\n str = Char(self->doh);\n if (!str) {\n\t /* give up! */\n\t sprintf(buffer, \"\", self->doh);\n\t str = buffer;\n }\n\n return PyString_FromString(str);\n }\n\n static long Swig_PyDOH_hash(PyDOH *self) {\n return (long)Hashval(self->doh);\n }\n\n static char PyDOH_docstring[] =\n \"Interface to DOH objects from Python. DOH objects behave largely\\n\\\nlike Python objects, although some functionality may be different.\";\n\n /* Type objects (one for mappings, one for everything else) */\n static PyTypeObject PyDOHSequenceType = {\n PyObject_HEAD_INIT(&PyType_Type)\n 0,\n \"DOH\",\n sizeof(PyDOH),\n 0,\n (destructor)Swig_PyDOH_delete,\n (printfunc)0,\n (getattrfunc)Swig_PyDOH_getattr,\n (setattrfunc)Swig_PyDOH_setattr,\n (cmpfunc)Swig_PyDOH_cmp,\n (reprfunc)Swig_PyDOH_repr,\n\n 0,\t\t\t/* tp_as_number */\n &Swig_PyDOH_as_sequence,\n 0,\t\t\t/* tp_as_mapping */\n (hashfunc)Swig_PyDOH_hash,\n (ternaryfunc)0,\t\t/* tp_call */\n (reprfunc)0,\t\t/* tp_str */\n (getattrofunc)0,\n (setattrofunc)0,\n 0,\t\t\t/* tp_as_buffer */\n 0,\t\t\t/* tp_xxx4 */\n PyDOH_docstring\n };\n\n static PyTypeObject PyDOHMappingType = {\n PyObject_HEAD_INIT(&PyType_Type)\n 0,\n \"DOH_hash\",\n sizeof(PyDOH),\n 0,\n (destructor)Swig_PyDOH_delete,\n (printfunc)0,\n (getattrfunc)Swig_PyDOH_getattr,\n (setattrfunc)Swig_PyDOH_setattr,\n (cmpfunc)Swig_PyDOH_cmp,\n (reprfunc)Swig_PyDOH_repr,\n\n 0,\t\t\t/* tp_as_number */\n 0,\t\t\t/* tp_as_sequence */\n &Swig_PyDOH_as_mapping,\n (hashfunc)Swig_PyDOH_hash,\n (ternaryfunc)0,\t\t/* tp_call */\n (reprfunc)0,\t\t/* tp_str */\n (getattrofunc)0,\n (setattrofunc)0,\n 0,\t\t\t/* tp_as_buffer */\n 0,\t\t\t/* tp_xxx4 */\n PyDOH_docstring\n };\n %}\n\n%typemap(python,in) DOH * {\n $target = Swig_PyDOH_as_DOH($source);\n}\n\n%typemap(python,out) DOH * {\n $target = Swig_PyDOH_new($source);\n}\n\n%typemap(python,in) char * {\n if (Swig_PyDOH_check($source))\n $target = Char(((PyDOH *)$source)->doh);\n else\n $target = PyString_AsString($source);\n}\n\n%title \"SWIG\", after\n\n%section \"DOH Objects\", before\n\n%subsection \"Constants\"\n\n/* The beginning of a sequence */\n#define DOH_BEGIN -1\n/* The end of a sequence */\n#define DOH_END -2\n/* The current point in a sequence */\n#define DOH_CUR -3\n/* Synonymous with DOH_CUR */\n#define DOH_CURRENT -3\n\n/* Replace any matches of the given text */\n#define DOH_REPLACE_ANY 0x00\n/* Replace, but not inside of quotes */\n#define DOH_REPLACE_NOQUOTE 0x01\n/* Replace only full identifiers */\n#define DOH_REPLACE_ID 0x02\n/* Replace only the first match */\n#define DOH_REPLACE_FIRST 0x04\n\n%subsection \"SuperStrings\"\n/* SuperString constructor */\nextern DOH *NewSuperString(char *string, DOH *filename, int firstline);\n/* Is this a SuperString? */\nextern int SuperString_check(DOH *);\n\n%subsection \"Strings\"\n/* String constructor */\nextern DOH *NewString(const DOH *c);\n/* Is this a string? */\nextern int String_check(const DOH *);\n\n%subsection \"Files\"\n/* File constructor */\nextern DOH *NewFile(DOH *file, char *mode);\n/* File constructor from Python file */\nextern DOH *NewFileFromFile(FILE *file);\n/* File constructor from a file descriptor */\nextern DOH *NewFileFromFd(int fd);\n/* Copy from file to file */\n%name(CopyTo) extern int DohCopyto(DOH *input, DOH *output);\n\n%subsection \"Lists\"\n/* List constructor */\nextern DOH *NewList();\n/* Is this a list? */\nextern int List_check(const DOH *);\n/* Sort a list */\nextern void List_sort(DOH *);\n\n%subsection \"Hash tables\"\n/* Hash table constructor */\nextern DOH *NewHash();\n/* Is this a hash table? */\nextern int Hash_check(const DOH *);\n/* Get a List of the keys in a hash table */\nextern DOH *Hash_keys(DOH *);\n\n%section \"Files\"\n\nextern void Swig_add_directory(DOH *dirname);\nextern DOH *Swig_last_file();\nextern DOH *Swig_search_path();\nextern FILE *Swig_open(DOH *name);\nextern DOH *Swig_read_file(FILE *file);\nextern DOH *Swig_include(DOH *name);\n\n#define SWIG_FILE_DELIMETER \"/\"\n\n%section \"Command Line Parsing\"\n\nextern void Swig_init_args(int argc, char **argv);\nextern void Swig_mark_arg(int n);\nextern void Swig_check_options();\nextern void Swig_arg_error();\n\n%section \"Miscelaneous\", after\n\nextern int DohNewScope();\t/* create a new scope */\nextern void DohDelScope(int); /* Delete a scope */\nextern void DohIntern(DOH *); /* Intern an object */\nextern void DohDebug(int d);\t/* set debugging level */\n\n%section \"Scanner Interface\"\n\n/* typedef struct SwigScanner SwigScanner; */\n\n/* extern SwigScanner *NewSwigScanner(); */\n/* extern void DelSwigScanner(SwigScanner *); */\n/* extern void SwigScanner_clear(SwigScanner *); */\n/* extern void SwigScanner_push(SwigScanner *, DOH *); */\n/* extern void SwigScanner_pushtoken(SwigScanner *, int); */\n/* extern int SwigScanner_token(SwigScanner *); */\n/* extern DOH *SwigScanner_text(SwigScanner *); */\n/* extern void SwigScanner_skip_line(SwigScanner *); */\n/* extern int SwigScanner_skip_balanced(SwigScanner *, int startchar, int endchar); */\n/* extern void SwigScanner_set_location(SwigScanner *, DOH *file, int line); */\n/* extern DOH *SwigScanner_get_file(SwigScanner *); */\n/* extern int SwigScanner_get_line(SwigScanner *); */\n/* extern void SwigScanner_idstart(SwigScanner *, char *idchar); */\n\n/* #define SWIG_MAXTOKENS 512 */\n/* #define SWIG_TOKEN_LPAREN 1 */\n/* #define SWIG_TOKEN_RPAREN 2 */\n/* #define SWIG_TOKEN_SEMI 3 */\n/* #define SWIG_TOKEN_COMMA 4 */\n/* #define SWIG_TOKEN_STAR 5 */\n/* #define SWIG_TOKEN_LBRACE 6 */\n/* #define SWIG_TOKEN_RBRACE 7 */\n/* #define SWIG_TOKEN_EQUAL 8 */\n/* #define SWIG_TOKEN_EQUALTO 9 */\n/* #define SWIG_TOKEN_NOTEQUAL 10 */\n/* #define SWIG_TOKEN_PLUS 11 */\n/* #define SWIG_TOKEN_MINUS 12 */\n/* #define SWIG_TOKEN_AND 13 */\n/* #define SWIG_TOKEN_LAND 14 */\n/* #define SWIG_TOKEN_OR 15 */\n/* #define SWIG_TOKEN_LOR 16 */\n/* #define SWIG_TOKEN_XOR 17 */\n/* #define SWIG_TOKEN_LESSTHAN 18 */\n/* #define SWIG_TOKEN_GREATERTHAN 19 */\n/* #define SWIG_TOKEN_LTEQUAL 20 */\n/* #define SWIG_TOKEN_GTEQUAL 21 */\n/* #define SWIG_TOKEN_NOT 22 */\n/* #define SWIG_TOKEN_LNOT 23 */\n/* #define SWIG_TOKEN_LBRACKET 24 */\n/* #define SWIG_TOKEN_RBRACKET 25 */\n/* #define SWIG_TOKEN_SLASH 26 */\n/* #define SWIG_TOKEN_BACKSLASH 27 */\n/* #define SWIG_TOKEN_ENDLINE 28 */\n/* #define SWIG_TOKEN_STRING 29 */\n/* #define SWIG_TOKEN_POUND 30 */\n/* #define SWIG_TOKEN_PERCENT 31 */\n/* #define SWIG_TOKEN_COLON 32 */\n/* #define SWIG_TOKEN_DCOLON 33 */\n/* #define SWIG_TOKEN_LSHIFT 34 */\n/* #define SWIG_TOKEN_RSHIFT 35 */\n/* #define SWIG_TOKEN_ID 36 */\n/* #define SWIG_TOKEN_FLOAT 37 */\n/* #define SWIG_TOKEN_DOUBLE 38 */\n/* #define SWIG_TOKEN_INT 39 */\n/* #define SWIG_TOKEN_UINT 40 */\n/* #define SWIG_TOKEN_LONG 41 */\n/* #define SWIG_TOKEN_ULONG 42 */\n/* #define SWIG_TOKEN_CHAR 43 */\n/* #define SWIG_TOKEN_PERIOD 44 */\n/* #define SWIG_TOKEN_AT 45 */\n/* #define SWIG_TOKEN_DOLLAR 46 */\n/* #define SWIG_TOKEN_CODEBLOCK 47 */\n/* #define SWIG_TOKEN_ILLEGAL 98 */\n/* #define SWIG_TOKEN_LAST 99 */\n\n%section \"SWIG types\"\n\n/* #define SWIG_TYPE_BYTE 1 */\n/* #define SWIG_TYPE_UBYTE 2 */\n/* #define SWIG_TYPE_SHORT 3 */\n/* #define SWIG_TYPE_USHORT 4 */\n/* #define SWIG_TYPE_INT 5 */\n/* #define SWIG_TYPE_UINT 6 */\n/* #define SWIG_TYPE_LONG 7 */\n/* #define SWIG_TYPE_ULONG 8 */\n/* #define SWIG_TYPE_LONGLONG 9 */\n/* #define SWIG_TYPE_ULONGLONG 10 */\n/* #define SWIG_TYPE_FLOAT 11 */\n/* #define SWIG_TYPE_DOUBLE 12 */\n/* #define SWIG_TYPE_QUAD 13 */\n/* #define SWIG_TYPE_CHAR 14 */\n/* #define SWIG_TYPE_WCHAR 15 */\n/* #define SWIG_TYPE_VOID 16 */\n/* #define SWIG_TYPE_ENUM 17 */\n/* #define SWIG_TYPE_VARARGS 18 */\n/* #define SWIG_TYPE_TYPEDEF 19 */\n\n/* #define SWIG_TYPE_POINTER 50 */\n/* #define SWIG_TYPE_REFERENCE 51 */\n/* #define SWIG_TYPE_FUNCTION 52 */\n/* #define SWIG_TYPE_ARRAY 53 */\n/* #define SWIG_TYPE_RECORD 54 */\n/* #define SWIG_TYPE_NAME 55 */\n\n/* DOH *NewSwigType(int tc, DOH *value); */\n\n\n\n\n\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorAddForceAtPosDecl();\r\nCKERROR CreateAddForceAtPosProto(CKBehaviorPrototype **pproto);\r\nint AddForceAtPos(const CKBehaviorContext& behcontext);\r\nCKERROR AddForceAtPosCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorAddForceAtPosDecl\r\n// FullName: FillBehaviorAddForceAtPosDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorAddForceAtPosDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBAddForceAtPos\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in global coordinates, to the body.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5f182eea,0x747f062d));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateAddForceAtPosProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateAddForceAtPosProto\r\n// FullName: CreateAddForceAtPosProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateAddForceAtPosProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBAddForceAtPos\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\t/*! \\page PBAddForceAtPos \r\n\r\n\tPBAddForceAtPos is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tApplies a force (or impulse) defined in the global coordinate frame, acting at a particular \r\n\tpoint in global coordinates, to the actor.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBAddForceAtPos.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tGlobal Force:Force/impulse to add, defined in the global frame.\r\n\t
\r\n\tPoint:Position in the global/local frame to add the force at.\r\n\t
\r\n\tPoint Reference:Reference object to transform a local point into world coords.\r\n\t
\r\n\tForce Mode: The way how the force is applied.See #ForceMode\r\n\t
\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t

Note


\r\n\tNote that if the force does not act along the center of mass of the actor, this\r\n\twill also add the corresponding torque. Because forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\t
\r\n\t
\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pRigidBody::addForceAtPos().
\r\n\t*/\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Global Force\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Point\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Point Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Force Mode\",VTE_BODY_FORCE_MODE,0);\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t//proto->SetBehaviorCallbackFct( AddForceAtPosCB );\r\n\tproto->SetFunction(AddForceAtPos);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: AddForceAtPos\r\n// FullName: AddForceAtPos\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint AddForceAtPos(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//the vector : \r\n\t\tVxVector vec = GetInputParameterValue(beh,0);\r\n\t\tVxVector vec0 = GetInputParameterValue(beh,1);\r\n\r\n\t\tVxVector outPos = vec0;\r\n\r\n\r\n\t\t//the reference object : \r\n\t\tCK3dEntity *referenceObject = (CK3dEntity *) beh->GetInputParameterObject(2);\r\n\t\t\r\n\t\tif (referenceObject)\r\n\t\t{\r\n\t\t\t\r\n\t\t\treferenceObject->Transform(&outPos,&vec0);\r\n\t\t}\r\n\r\n\r\n\t\tint fMode = GetInputParameterValue(beh,3);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\t\r\n\t\t// body exists already ? clean and delete it : \r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(result)\r\n\t\t{\r\n\t\t\tresult->addForceAtPos(vec,outPos,(ForceMode)fMode);\r\n\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: AddForceAtPosCB\r\n// FullName: AddForceAtPosCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR AddForceAtPosCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n#define BB_SET_POSITION_GUID CKGUID(0xe456e78a, 0x456789aa) \r\n#define BB_SET_ORIENTATION_GUID CKGUID(0x625874aa, 0xaa694132)\r\n#define BB_ROTATE_GUID CKGUID(0xffffffee, 0xeeffffff)\r\n#define BB_TRANSLATE_GUID CKGUID(0x000d000d, 0x000d000d)\r\n\r\n#define BB_SET_EORIENTATION_GUID CKGUID(0xc4966d8,0x6c0c6d14)\r\n\r\n\r\nCKBEHAVIORFCT BBSetEOri;\r\n\r\nint BB_SetEOrientationNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetEOri(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(1,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\r\n\t\t\tVxVector pos,scale;\t\r\n\t\t\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tsolid->setRotation(quat);\r\n\r\n\t\t\tVxVector vectorN(0,0,0);\r\n\r\n\t\t\tint pResetF=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(2,&pResetF);\r\n\t\t\tint pResetT=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(3,&pResetT);\r\n\r\n\t\t\tint pResetLV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(4,&pResetLV);\r\n\t\t\tint pResetAV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(5,&pResetAV);\r\n\r\n\t\t\tif (pResetF)\r\n\t\t\t{\r\n\t\t\t\tsolid->setLinearMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetT)\r\n\t\t\t{\r\n\t\t\t\tsolid->setAngularMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetLV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setLinearVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetAV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setAngularVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t}else\r\n\t\t{\r\n\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\tif (solid)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->updateSubShapes(false,false,true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n/************************************************************************/\r\n/* Set Position : */\r\n/************************************************************************/\r\nCKBEHAVIORFCT BBSetPos;\r\nint BB_SetPosNew(const CKBehaviorContext& context)\r\n{\r\n\r\n\t\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetPos(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\r\n\r\n\t\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\t\r\n\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\treturn 0; \r\n\t\t}\r\n\r\n\t\tpRigidBody *solid = world->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\t\tVxVector vector(0,0,0);\r\n\t\t\t\t//behaviour->GetInputParameterValue(0,&vector);\r\n\t\t\t\tent->GetPosition(&vector);\r\n\t\t\t\tsolid->setPosition(vector,ent);\r\n\r\n\t\t\t\tVxVector vectorN(0,0,0);\r\n\r\n\t\t\t\tint pResetF=0;\r\n\t\t\t\tbehaviour->GetLocalParameterValue(1,&pResetF);\r\n\t\t\t\tint pResetT=0;\r\n\t\t\t\tbehaviour->GetLocalParameterValue(2,&pResetT);\r\n\r\n\t\t\t\tint pResetLV=0;\r\n\t\t\t\tbehaviour->GetLocalParameterValue(3,&pResetLV);\r\n\t\t\t\tint pResetAV=0;\r\n\t\t\t\tbehaviour->GetLocalParameterValue(4,&pResetAV);\r\n\r\n\t\t\t\tif (pResetF)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->setLinearMomentum(vectorN);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pResetT)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->setAngularMomentum(vectorN);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pResetLV)\r\n\t\t\t\t{\t\r\n\t\t\t\t\tsolid->setLinearVelocity(vectorN);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pResetAV)\r\n\t\t\t\t{\t\r\n\t\t\t\t\tsolid->setAngularVelocity(vectorN);\r\n\t\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\tif (solid)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->updateSubShapes(false,true,false);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n/************************************************************************/\r\n/* Set Orientation : */\r\n/************************************************************************/\r\nCKBEHAVIORFCT BBSetOri;\r\nint BB_SetOrientationNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetOri(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tVxVector pos,scale;\t\r\n\t\t\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tsolid->setRotation(quat);\r\n\r\n\t\t\tVxVector vectorN(0,0,0);\r\n\r\n\t\t\tint pResetF=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(1,&pResetF);\r\n\t\t\tint pResetT=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(2,&pResetT);\r\n\r\n\t\t\tint pResetLV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(3,&pResetLV);\r\n\t\t\tint pResetAV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(4,&pResetAV);\r\n\r\n\t\t\tif (pResetF)\r\n\t\t\t{\r\n\t\t\t\tsolid->setLinearMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetT)\r\n\t\t\t{\r\n\t\t\t\tsolid->setAngularMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetLV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setLinearVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetAV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setAngularVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t}else\r\n\t\t{\r\n\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\tif (solid)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->updateSubShapes(false,false,true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nCKBEHAVIORFCT BBRotate;\r\nint BB_RotateNew(const CKBehaviorContext& context)\r\n{\r\n\r\n\t\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBRotate(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tVxVector pos,scale;\t\r\n\t\t\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tsolid->setRotation(quat);\r\n\r\n\t\t\tVxVector vectorN(0,0,0);\r\n\r\n\t\t\tint pResetF=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(1,&pResetF);\r\n\t\t\tint pResetT=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(2,&pResetT);\r\n\r\n\t\t\tint pResetLV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(3,&pResetLV);\r\n\t\t\tint pResetAV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(4,&pResetAV);\r\n\r\n\t\t\tif (pResetF)\r\n\t\t\t{\r\n\t\t\t\tsolid->setLinearMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetT)\r\n\t\t\t{\r\n\t\t\t\tsolid->setAngularMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetLV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setLinearVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetAV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setAngularVelocity(vectorN);\r\n\t\t\t}\r\n\r\n\t\t}else\r\n\t\t{\r\n\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\tif (solid)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->updateSubShapes(false,false,true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nCKBEHAVIORFCT BBTranslate;\r\nint BB_TranslateNew(const CKBehaviorContext& context)\r\n{\r\n\r\n\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBTranslate(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tVxVector pos,scale;\t\r\n\t\t\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tsolid->setPosition(pos,ent);\r\n\r\n\t\t\tVxVector vectorN(0,0,0);\r\n\r\n\t\t\tint pResetF=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(1,&pResetF);\r\n\t\t\tint pResetT=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(2,&pResetT);\r\n\r\n\t\t\tint pResetLV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(3,&pResetLV);\r\n\t\t\tint pResetAV=0;\r\n\t\t\tbehaviour->GetLocalParameterValue(4,&pResetAV);\r\n\r\n\t\t\tif (pResetF)\r\n\t\t\t{\r\n\t\t\t\tsolid->setLinearMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetT)\r\n\t\t\t{\r\n\t\t\t\tsolid->setAngularMomentum(vectorN);\r\n\t\t\t}\r\n\r\n\t\t\tif (pResetLV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setLinearVelocity(vectorN);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (pResetAV)\r\n\t\t\t{\t\r\n\t\t\t\tsolid->setAngularVelocity(vectorN);\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\tif (solid)\r\n\t\t\t\t{\r\n\t\t\t\t\tsolid->updateSubShapes(false,true,false);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nCKERROR PhysicManager::_Hook3DBBs()\r\n{\r\n\t\r\n\tCKBehaviorManager *bm = m_Context->GetBehaviorManager();\r\n\t\r\n\tCKBehaviorPrototype *bproto = CKGetPrototypeFromGuid(BB_SET_EORIENTATION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetEOri = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetEOrientationNew);\r\n\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_POSITION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetPos = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetPosNew);\r\n\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_ORIENTATION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetOri = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetOrientationNew);\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_ROTATE_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBRotate = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_RotateNew);\r\n\t}\r\n\tbproto = CKGetPrototypeFromGuid(BB_TRANSLATE_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBTranslate = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_TranslateNew);\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n/********************************************************************\r\n\tcreated:\t2007/11/28\r\n\tcreated:\t28:11:2007 16:25\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\\CustomPlayerConfigurationDialog.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\r\n\tfile base:\tCustomPlayerConfigurationDialog\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"xUtils.h\"\r\n\r\nint\r\nCCustomPlayer::DoSystemCheck(XString&errorText)\r\n{\r\n\r\n\t/************************************************************************/\r\n\t/*\tSystem Check : */\r\n\t/************************************************************************/\r\n\tint foundError = 0;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\t\tCheck DirectX Version :\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\r\n\tbool DirectXVer_OK = true;\r\n\tif (CPR_CHECK_DIRECTX)\r\n\t{\r\n\t\tDWORD dxVerMinor=0;\r\n\t\tchar *strVersion = NULL;\r\n\t\txUtils::system::GetDirectVersion(strVersion,dxVerMinor);\r\n XString dxVer(strVersion);\r\n\t\tXString dxVer3 = dxVer.Crop(0,3);\r\n\t\tint dxVerWeNeedMin = GetPAppStyle()->g_MinimumDirectXVersion;\r\n\t\tint dxVerInt = dxVer3.ToInt();\r\n\t\tif(dxVerInt < dxVerWeNeedMin )\r\n\t\t{\r\n\t\t\terrorText << \"\\n\\n\" << \"Wrong DirectX Version Detected !\";\r\n\t\t\terrorText << \"\\n\\n\" << \"This application needs at least version : \" << GetPAppStyle()->g_MinimumDirectXVersion;\r\n\t\t\terrorText << \"\\n\\n\" << \"You have version : \" << strVersion;\r\n\t\t\terrorText << \"\\n\\n\" << \"You can download it from here :\" << CPR_MINIMUM_DIRECTX_VERSION_FAIL_URL ;\r\n\t\t\terrorText << \"\\n\";\r\n\t\t\tfoundError =1;\r\n\t\t\tDirectXVer_OK =false;\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\t\tCheck System Ram \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\r\n\tif (CPR_CHECK_RAM && DirectXVer_OK )\r\n\t{\r\n\t\tint ram = xUtils::system::GetPhysicalMemoryInMB();\r\n\t\tif( ram < GetPAppStyle()->g_MiniumumRAM)\r\n\t\t{\r\n\t\t\terrorText << \"\\n This application needs at least : \" << GetPAppStyle()->g_MiniumumRAM << \" of System Memory.\";\r\n\t\t\terrorText << \"\\n\\n\\t You have only : \" << ram ; \r\n\t\t\tfoundError = 1;\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\t\tAdd the last line : support eMail\r\n\r\n\tif(foundError)\r\n\t{\r\n\t\terrorText << \"\\n\\n You can contact us via EMail : mailto:\"<#if !defined(CUSTOMPLAYERAPP_H)\r\n#define CUSTOMPLAYERAPP_H\r\n\r\n#ifndef __AFXWIN_H__\r\n\t#error include 'stdafx.h' before including this file for PCH\r\n#endif\r\n\r\n\r\n#include \"CustomPlayerStructs.h\"\r\n#include \"BaseMacros.h\"\r\n\r\n/*************************************************************************\r\nSummary: This class defines the Windows application object.\r\n\r\nDescription: This class provides member functions for initializing the\r\napplication and for running the application.\r\n\r\nSee also: CCustomPlayerApp::InitInstance, CCustomPlayerApp::Run,\r\nCCustomPlayer.\r\n*************************************************************************/\r\nclass CCustomPlayerApp : public CWinApp\r\n{\r\npublic:\r\n\r\n\t/*************************************************************************\r\n\tSummary: Initialize class members.\r\n\t*************************************************************************/\r\n\tCCustomPlayerApp();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Release window handles.\r\n\t*************************************************************************/\r\n\t~CCustomPlayerApp();\r\n\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(CCustomPlayerApp)\r\n\tpublic:\r\n\tvirtual BOOL InitInstance();\r\n\tvirtual int ExitInstance();\r\n\tvirtual int Run();\r\n\t//}}AFX_VIRTUAL\r\n\r\npublic:\r\n\r\n\t//{{AFX_MSG(CCustomPlayerApp)\r\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code !\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n\r\nprotected:\r\n\r\n\tHWND\t\tm_MainWindow;\t// the main window (visible in windowed mode).\r\n\tHWND\t\tm_RenderWindow;\t// the render window (used for windowed and fullscreen mode).\r\n\t\r\n\t//HWND\t\tm_Splash;\t\t// the window used to display the splash screen.\r\n\tXString\t\tm_PlayerClass;\t// the name of the windows class used for the main window.\r\n\tXString\t\tm_RenderClass;\t// the name of the windows class used for the render window.\r\n\tXString\t\tm_PlayerTitle;\t// the string display in the title bar of the main window.\r\n\tint\t\t\tm_Config;\t\t// the configuration of the player (see EConfigPlayer).\r\n\tHACCEL\t\tm_hAccelTable;\r\n\r\n\t\r\n\r\n\t////////////////////////////////////////\r\n\t// initialization function\r\n\r\n\tATOM\t_RegisterClass();\r\n\tint\t_CreateWindows();\r\n\tvoid\t_DisplaySplashWindow();\r\n\tvoid\t_PublishingRights();\r\n\r\n\t////////////////////////////////////////\r\n\t// configurations management\r\n\r\n\tBOOL\t\t_ReadConfig(XString& oFilename, const char*& oBufferFile,XDWORD& oSize);\r\n\tBOOL\t\t_ReadInternalConfig(const char*& oBufferFile, XDWORD& oSize);\r\n\tBOOL\t\t_ReadCommandLine(const char* iArguments, XString& oFilename);\r\n\tBOOL\t\t_LoadInternal(XString& oFilename);\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\npublic:\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n//\tUSHORT PSaveEngineWindowProperties(const char *configFile,const vtPlayer::Structs::xSEngineWindowInfo& input);\r\n\t\r\n\r\n\t// [11/28/2007 mc007]-\tDialog functions to modify the render settings of the application\r\n\t//void DoConfig();\r\n\t//INT_PTR CALLBACK ConfigureDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tthis is just for handy writing : \r\n\tstatic CCustomPlayerApp* GetInstance();\r\n\t\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n\r\n\r\n\t// _NextBlank, _SkipBlank and _ComputeParamValue are tools used\r\n\t// while parsing the command line.\r\n\tconst char*\t_NextBlank(const char* iStr);\r\n\tconst char* _SkipBlank(const char* iPtr);\r\n\tBOOL\t\t_ComputeParamValue(const char* iPtr, XString& oValue);\r\n\r\n\r\n\t////////////////////////////////////////\r\n\t// windocprocs\r\n\r\n\t// main windowproc\r\n\tstatic LRESULT CALLBACK _MainWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r\n\t// splash screen windowproc\r\n\tstatic LRESULT CALLBACK _LoadingDlgWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\n\tvoid StartMove(LPARAM lParam);\r\n\tvoid DoMMove(LPARAM lParam, WPARAM wParam);\r\n\tint nMMoveX, nMMoveY; //initial mouse position from window origin.\r\n\r\n};\r\n\r\n\r\n////////////////////////////////////////\r\n// inlines\r\n\r\n// _NextBlank, _SkipBlank and _ComputeParamValue are tools used\r\n// while parsing the command line.\r\ninline const char* CCustomPlayerApp::_NextBlank(const char* iStr)\r\n{\r\n\tconst char* ptr = iStr;\r\n\twhile(*ptr!='\\0' && *ptr!=' ' && *ptr!='\\t') {\r\n\t\tptr++;\r\n\t}\r\n\treturn ptr;\r\n}\r\n\r\ninline const char* CCustomPlayerApp::_SkipBlank(const char* iPtr)\r\n{\r\n\twhile(*iPtr!='\\0' && (*iPtr==' ' || *iPtr=='\\t')) {\r\n\t\tiPtr++;\r\n\t}\r\n\treturn iPtr;\r\n}\r\n\r\ninline BOOL CCustomPlayerApp::_ComputeParamValue(const char* iPtr, XString& oValue)\r\n{\r\n\tconst char* tmp = 0;\r\n\tif (*iPtr=='\"') {\r\n\t\ttmp = strchr(iPtr+1,'\"');\r\n\t\tif (tmp==0) {\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t\t++iPtr;\r\n\t} else {\r\n\t\ttmp = _NextBlank(iPtr);\r\n\t}\r\n\r\n\toValue.Create(iPtr,tmp-iPtr);\r\n\treturn TRUE;\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#define GetApp() CCustomPlayerApp::GetInstance()\r\n\r\n#endif // CUSTOMPLAYERAPP_H\r\n#ifndef _XDISTRIBUTED_SESSION_CLASS_H_\r\n#define _XDISTRIBUTED_SESSION_CLASS_H_\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n\r\nclass xDistributedSessionClass : public xDistributedClass\r\n{\r\n\r\n\r\n\t public : \r\n\t\t xDistributedSessionClass();\r\n\t\t int getFirstUserField();\r\n\t\t int getUserFieldBitValue(int walkIndex);\r\n\t\t int getInternalUserFieldIndex(int inputIndex);\r\n\t\t int getUserFieldCount();\r\n\t\t \r\n\t\t void addProperty(const char*name,int type,int predictionType);\r\n\t\t void addProperty(int nativeType,int predictionType);\r\n\r\n\t\t xNString NativeTypeToString(int nativeType);\r\n\t\t int NativeTypeToValueType(int nativeType);\r\n\r\n\tprotected : \r\n\r\n};\r\n\r\n#endif\r\n#ifndef __VT_C_BB_ERROR_HELPER_H__\r\n\t#define __VT_C_BB_ERROR_HELPER_H__\r\n\r\n#ifndef __X_LOGGER_H__\r\n\t#include \r\n#endif\r\n\r\n#ifndef __P_CONSTANTS_H__\r\n\t#include \"pConstants.h\"\t\r\n#endif\r\n\r\n\r\n#define CERROR_STRING(F) sBBErrorStrings[F]\r\n\r\n\r\n#define bbSErrorME(A)\t{\txLogger::xLog(XL_START,ELOGERROR,E_BB,CERROR_STRING(A));\\\r\n\tXLOG_BB_INFO;\\\r\n\tbeh->ActivateOutput(0);\\\r\n\treturn CKBR_PARAMETERERROR ; }\r\n\r\n#define bbErrorME(A)\t{ xLogger::xLog(XL_START,ELOGERROR,E_BB,A);\\\r\n\tXLOG_BB_INFO;\\\r\n\tbeh->ActivateOutput(0);\\\r\n\treturn CKBR_PARAMETERERROR ; }\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2009/06/01\r\n\tcreated:\t1:6:2009 14:15\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick\\JSetXYForce.cpp\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick \r\n\tfile base:\tJSetXYForce\r\n\tfile ext:\tcpp\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n\r\n\r\n#include \r\n#include \"CKAll.h\"\r\n#include \"dInputShared.h\"\r\n\r\n\r\nstatic CKContext *ctx = NULL;\r\nstatic bool gInitiated = false;\r\nextern LPDIRECTINPUTEFFECT g_pEffect;\r\nextern LPDIRECTINPUTDEVICE8 g_pFFDevice;\r\n\r\n\r\n#define HAS_CONFIG\r\n\r\n#ifdef HAS_CONFIG\r\n\t#include \"gConfig.h\"\r\n#endif // BB_TOOLS\r\n\r\n#ifdef BB_TOOLS\r\n\t\r\n\t#include \r\n\t#include \"vtLogTools.h\"\r\n\t#include \"vtCBBErrorHelper.h\"\r\n\t#include \r\n\t#include \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n#endif\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJSetXYForceDecl();\r\nCKERROR CreateJSetXYForceProto(CKBehaviorPrototype **);\r\nint JSetXYForce(const CKBehaviorContext& behcontext);\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext);\r\nCKObjectDeclaration\t*FillBehaviorJSetXYForceDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"JSetXYForce\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6890534f,0x31c12074));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJSetXYForceProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Joystick\");\r\n\treturn od;\r\n}\r\n\r\nenum bbIO_Inputs\r\n{\r\n\tBB_I_DO,\r\n\tBB_I_RELEASE,\r\n};\r\n\r\nenum bbIO_Outputs\r\n{\r\n\tBB_O_DONE,\r\n\tBB_O_RELEASED,\r\n\tBB_O_ERROR,\r\n};\r\n\r\nCKERROR CreateJSetXYForceProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"JSetXYForce\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"release device\");\r\n\t\r\n\tproto->DeclareOutput(\"Done\");\r\n\tproto->DeclareOutput(\"Released\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Force Vector\",CKPGUID_2DVECTOR);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( JSetXYForce );\r\n\r\n\tproto->SetBehaviorCallbackFct(PlayFFECallBackObject);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\n\r\n\r\nint JSetXYForce(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx2 = behcontext.Context;\r\n\tif (!ctx)\r\n\t{\r\n\t\tctx = ctx2;\r\n\t}\r\n\t\r\n\tHWND mWin = (HWND )ctx->GetMainWindow();\r\n\tHRESULT hr = S_OK;\r\n\r\n\r\n\t//init and load effect\r\n\tif( beh->IsInputActive(BB_I_DO) )\r\n\t{\r\n\t\tbeh->ActivateInput(BB_I_DO,FALSE);\r\n\t\tif (!gInitiated)\r\n\t\t{\r\n\t\t\tif (!InitDirectInput2(mWin) == S_OK)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(BB_O_ERROR);\r\n\t\t\t\treturn CKBR_OK;\r\n\t\t\t}else{\r\n\r\n\t\t\t\thr = g_pFFDevice->Acquire();\r\n\t\t\t\thr =g_pEffect->Start( 1, 0 ); // Start the effect\r\n\t\t\t\tgInitiated = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tVx2DVector vectorForce;\r\n\t\tbeh->GetInputParameterValue(0,&vectorForce);\r\n\t\t\r\n\t\t\r\n\r\n\t\tSetDeviceForcesXY(vectorForce.x,vectorForce.y);\r\n\t\tbeh->ActivateOutput(BB_O_DONE);\r\n\t}\r\n\r\n\r\n\t//play\r\n\r\n\tif( beh->IsInputActive(BB_I_RELEASE))\r\n\t{\r\n\t\tbeh->ActivateInput(BB_I_RELEASE,FALSE);\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(BB_I_RELEASE);\r\n\t\t\tFreeDirectInput2();\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/*\r\n\t//stop the effect\r\n\tif( beh->IsInputActive(2) ){\r\n\t\tbeh->ActivateInput(2,FALSE);\r\n\r\n\t\t//g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn CKBR_OK;\r\n\t}*/\r\n\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\tcase CKM_BEHAVIORRESET:\r\n\t\t{\r\n\t\t\tgInitiated = false;\r\n\t\t\tif ( g_pFFDevice)\r\n\t\t\t\tg_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\t\tFreeDirectInput2();\r\n\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\treturn CKBR_OK; \r\n}\r\n#include \"xDistributedString.h\"\r\n\r\nuxString \r\nxDistributedString::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedString::updateFromServer(xNStream *stream)\r\n{\r\n\tmLastValue = mCurrentValue;\r\n\tchar value[256];stream->readString(value);\r\n\tmCurrentValue = value;\r\n\tsetValueState(E_DV_UPDATED);\r\n}\r\n\r\nvoid\r\nxDistributedString::updateGhostValue(xNStream *stream)\r\n{\r\n\t\r\n\tstream->writeString(mCurrentValue.getString(),strlen(mCurrentValue.getString()));\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedString::unpack(xNStream *bstream,float sendersOneWayTime)\r\n{\r\n\r\n\tmLastValue = mCurrentValue;\r\n\tchar value[256];bstream->readString(value);\r\n\tmCurrentValue = value;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedString::pack(xNStream *bstream)\r\n{\r\n\tbstream->writeString(mCurrentValue.getString(),strlen(mCurrentValue.getString()));\r\n\tint flags = getFlags();\r\n\tflags &= (~E_DP_NEEDS_SEND);\r\n\tsetFlags(flags);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedString::updateValue(TNL::StringPtr value,xTimeType currentTime)\r\n{\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue=TNL::StringPtr(mCurrentValue.getString());\r\n mCurrentValue = value;\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\t\r\n\r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\tbool result = false;\r\n\r\n\tif ( strcmp(mCurrentValue,mLastValue) )\r\n\t{\r\n\t\tif (mThresoldTicker2 > 50 )\r\n\t\t{\r\n\t\t\r\n\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\tresult = true ;\r\n\t\t}\r\n\t}\r\n\r\n\tif (mThresoldTicker2 > 50 )\r\n\t{\r\n\t\tmThresoldTicker2 = 0 ;\r\n\t\tmThresoldTicker = 0;\r\n\t}\r\n\tsetFlags(flags);\r\n\treturn result;\r\n}#ifndef __XDIST_TOOLS_H_\r\n#define __XDIST_TOOLS_H_\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nnamespace xDistTools\r\n{\r\n\tTNL::StringPtr NativeTypeToString(int nativeType);\r\n\tint NativeTypeToValueType(int nativeType);\r\n\tint ValueTypeToSuperType(int valueType);\r\n\tint SuperTypeToValueType(int superType);\r\n\txNString ValueTypeToString(int valueType);\r\n\r\n};\r\n\r\n\r\n#endif\r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetAdaptersDecl();\r\nCKERROR CreateGetAdaptersProto(CKBehaviorPrototype **pproto);\r\nint GetAdapters(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetAdaptersDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Get Adapters\");\t\r\n\tod->SetDescription(\"Add Objects\");\r\n\tod->SetCategory(\"Narratives/System\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2ab2796a,0x24c15af7));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"mw\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetAdaptersProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGetAdaptersProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Get Adapters\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Get Next\");\r\n\tproto->DeclareInput(\"Get Prev\");\r\n\t\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"LoopOut\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Name\",CKPGUID_STRING);\r\n\tproto->DeclareOutParameter(\"Index\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Count\",CKPGUID_INT);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tproto->SetFunction(GetAdapters);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint indexD = 0;\r\nint countD = 0;\r\n\r\n\r\nint GetAdapters(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tCKRenderManager *rm = (CKRenderManager *)ctx->GetRenderManager();\r\n\r\n\t\r\n\tif( beh->IsInputActive(0) ){\r\n\t\t\tbeh->ActivateInput(0, FALSE);\r\n\r\n\t\t\t\r\n\t\t\tcountD=rm->GetRenderDriverCount();\r\n\t\t\tindexD = 0;\r\n\r\n\t\t\tbeh->ActivateInput(1, TRUE);\r\n\r\n\t}\r\n\r\n\tif( beh->IsInputActive(1) ){\r\n\t\t\tbeh->ActivateInput(1, FALSE);\r\n\t\t\r\n\t\t\tif (indexD > (countD-1)){\r\n\t\t\t\tindexD = 0;\r\n\t\t\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\t\treturn CKBR_OK;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tbeh->SetOutputParameterValue(1,&indexD);\r\n\t\t\tVxDriverDesc *desc=rm->GetRenderDriverDescription(indexD);\r\n\r\n\t\t\tindexD++;\r\n\r\n\t\t\t\r\n\r\n\t\t\tCKParameterOut *pout2 = beh->GetOutputParameter(0);\r\n\t\t\tpout2->SetStringValue(desc->DriverName.Str() );\r\n\t\t\tbeh->ActivateOutput(1);\r\n\r\n\r\n\t}\r\n\r\n\t\r\n\r\n\r\n\t\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n\r\n/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 7:23\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\vtParameterAll.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\r\n\tfile base:\tvtParameterAll\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __VT_PARAMETER_STRUCTS_H__\r\n#define __VT_PARAMETER_STRUCTS_H__\r\n\r\n\r\n//################################################################\r\n//\r\n// Parameter Structures have been divided by type. \r\n//\r\n#include \"vtParameterSubItemIdentifiers_Body.h\"\r\n#include \"vtParameterSubItemIdentifiers_Joints.h\"\r\n#include \"vtParameterSubItemIdentifiers_VehicleAndWheelStructs.h\"\r\n#include \"vtParameterSubItemIdentifiers_World.h\"\r\n\r\n#endif/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t Joysitck Camera Orbit\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"GeneralCameraOrbit.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorJoystickCameraOrbitDecl();\r\nCKERROR CreateJoystickCameraOrbitProto(CKBehaviorPrototype **pproto);\r\nint JoystickCameraOrbit(const CKBehaviorContext& behcontext);\r\nvoid ProcessJoystickInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping);\r\n\r\nCKObjectDeclaration\t*FillBehaviorJoystickCameraOrbitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Joystick Camera Orbit\");\r\n\tod->SetDescription(\"Makes a Camera orbit round a 3D Entity using Joystick.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tStop: stops the process.
\r\n\tEnded: is activated when the process has been stopped and the camera has recovered its original position in case \"returns\" setting is true.
\r\n\t
\r\n\tTarget Position: Position we are turning around.
\r\n\tTarget Referential: Referential where the position is defined.
\r\n\tMove Speed: Speed in angle per second used when the user moves the camera.
\r\n\tReturn Speed: Speed in angle per second used when the camera returns.
\r\n\tMin Horizontal: Minimal angle allowed on the horizontal rotation. Must have a negative value.
\r\n\tMax Horizontal:Maximal angle allowed on the horizontal rotation. Must have a positive value.
\r\n\tMin Vertical: Minimal angle allowed on the vertical rotation. Must have a negative value.
\r\n\tMax Vertical: Maximal angle allowed on the vertical rotation. Must have a positive value.
\r\n\tZoom Speed: Speed of the zoom in distance per second.
\r\n\tZoom Min: Minimum zoom value allowed. Must have a negative value.
\r\n\tZoom Max: Maximum zoom value allowed. Must have a positive value.
\r\n\t
\r\n\tThe following keys are used by default to move the Camera around its target:
\r\n\t
\r\n\tPage Up: Zoom in.
\r\n\tPage Down: Zoom out.
\r\n\tUp and Down Arrows: Rotate vertically.
\r\n\tLeft and Right Arrows: Rotate horizontally.
\r\n\tThe arrow keys are the inverted T arrow keys and not the ones of the numeric keypad.
\r\n
\r\n\tReturns: Does the camera systematically returns to its original position.
\r\n\tKey Rotate Left: Key used to rotate left.
\r\n\tKey Rotate Right: Key used to rotate right.
\r\n\tKey Rotate Up: Key used to rotate up.
\r\n\tKey Rotate Down: Key used to rotate down.
\r\n\tKey Zoom in: Key used to zoom in.
\r\n\tKey Zoom out: Key used to zoom in.
\r\n
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Movement\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x400f0e6f,0x72822162));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJoystickCameraOrbitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tPrototype creation\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR CreateJoystickCameraOrbitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Joystick Camera Orbit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t// General Description\r\n\tCKERROR error = FillGeneralCameraOrbitProto(proto);\r\n\tif (error != CK_OK)\r\n\t\treturn (error);\r\n\r\n\r\n\t// Setting to choose the mouse button\r\n\tproto->DeclareSetting(\"Joystick Number\", CKPGUID_INT,\"0\");\r\n\tproto->DeclareSetting(\"Zoom In Button\", CKPGUID_INT,\"1\");\r\n\tproto->DeclareSetting(\"Zoom Out Button\", CKPGUID_INT,\"2\");\r\n\tproto->DeclareSetting(\"Inverse Up / Down\", CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Threshold\", CKPGUID_FLOAT,\"0.1\");\r\n\r\n\t// Set the execution functions\r\n\tproto->SetFunction(JoystickCameraOrbit);\r\n\tproto->SetBehaviorCallbackFct(GeneralCameraOrbitCallback,CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORCREATE);\r\n\r\n\t// return OK\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tMain Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nint JoystickCameraOrbit(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn ( GeneralCameraOrbit(behcontext,ProcessJoystickInputs) );\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFunction that process the inputs\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid ProcessJoystickInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping)\r\n{\r\n\t// Is the move limited ?\r\n\tCKBOOL Limited = TRUE;\r\n\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\r\n\t// Gets the Joystick informations\r\n\tint JoystickNumber = 0;\r\n\tVxVector JoystickPosition(0,0,0);\r\n\tbeh->GetLocalParameterValue(LOCAL_JOY_NB,&JoystickNumber);\r\n\tinput->GetJoystickPosition(JoystickNumber,&JoystickPosition);\r\n\r\n\t// Is the move vertically inverted ?\r\n\tCKBOOL inverse = FALSE;\r\n\tfloat InverseFactor = 1.0f;\r\n\tbeh->GetLocalParameterValue(LOCAL_JOY_INVERSE,&inverse);\r\n\tif (inverse)\r\n\t\tInverseFactor = -1.0f;\r\n\r\n\t// Gets the joystick threshold\r\n\tfloat epsilon = 0.1f;\r\n\tbeh->GetLocalParameterValue(LOCAL_JOY_THRESHOLD,&epsilon);\r\n\r\n\r\n\t////////////////////\r\n\t// Position Update\r\n\t////////////////////\r\n\r\n\t// If the users is moving the camera\r\n\tif ( ((fabs(JoystickPosition.x) > epsilon) || (fabs(JoystickPosition.y) > epsilon)) && !stopping)\r\n\t{\r\n\t\tfloat SpeedAngle = 0.87f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_MOVE,&SpeedAngle);\r\n\t\tSpeedAngle *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinH = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_H, &MinH);\r\n\r\n\t\t\tfloat MaxH = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_H, &MaxH);\r\n\r\n\t\t\tfloat MinV = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_V, &MinV);\r\n\r\n\t\t\tfloat MaxV = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_V, &MaxV);\r\n\r\n\t\t\tRotationAngles->x += JoystickPosition.x * SpeedAngle;\r\n\t\t\tRotationAngles->x = XMin(RotationAngles->x, MaxH);\r\n\t\t\tRotationAngles->x = XMax(RotationAngles->x, MinH);\r\n\r\n\t\t\tRotationAngles->y += InverseFactor * JoystickPosition.y * SpeedAngle;\r\n\t\t\tRotationAngles->y = XMin(RotationAngles->y, MaxV);\r\n\t\t\tRotationAngles->y = XMax(RotationAngles->y, MinV);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tRotationAngles->x += JoystickPosition.x * SpeedAngle;\r\n\t\t\tRotationAngles->y += InverseFactor * JoystickPosition.y * SpeedAngle;\r\n\t\t}\r\n\t}\r\n\telse if (Returns && ((RotationAngles->x != 0) || (RotationAngles->y != 0)))\r\n\t{\r\n\t\tfloat ReturnSpeedAngle = 1.75f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_RETURN, &ReturnSpeedAngle);\r\n\t\tReturnSpeedAngle *= delta / 1000;\r\n\r\n\t\tif( RotationAngles->x < 0 ) RotationAngles->x += XMin(ReturnSpeedAngle, -RotationAngles->x);\r\n\t\tif( RotationAngles->x > 0 ) RotationAngles->x -= XMin(ReturnSpeedAngle, RotationAngles->x);\r\n\t\tif( RotationAngles->y < 0 ) RotationAngles->y += XMin(ReturnSpeedAngle, -RotationAngles->y);\r\n\t\tif( RotationAngles->y > 0 ) RotationAngles->y -= XMin(ReturnSpeedAngle, RotationAngles->y);\r\n\t}\r\n\r\n\r\n\t////////////////\r\n\t// Zoom Update\r\n\t////////////////\r\n\r\n\tint ZinButton;\r\n\tbeh->GetLocalParameterValue(LOCAL_JOY_ZIN,&ZinButton);\r\n\r\n\tint ZoutButton;\r\n\tbeh->GetLocalParameterValue(LOCAL_JOY_ZOUT,&ZoutButton);\r\n\r\n\tif ((input->IsJoystickButtonDown(JoystickNumber, ZinButton)) || (input->IsJoystickButtonDown(JoystickNumber, ZoutButton)) && !stopping)\r\n\t{\r\n\t\tfloat ZoomSpeed = 40.0f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_ZOOM,&ZoomSpeed);\r\n\t\tZoomSpeed *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinZoom = -40.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_ZOOM, &MinZoom);\r\n\r\n\t\t\tfloat MaxZoom = 10.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_ZOOM, &MaxZoom);\r\n\r\n\t\t\tif(input->IsJoystickButtonDown(JoystickNumber, ZinButton)) RotationAngles->z -= XMin(ZoomSpeed, RotationAngles->z + MaxZoom);\r\n\t\t\tif(input->IsJoystickButtonDown(JoystickNumber, ZoutButton)) RotationAngles->z += XMin(ZoomSpeed, - MinZoom - RotationAngles->z);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif( input->IsJoystickButtonDown(JoystickNumber, ZinButton)\t) RotationAngles->z -= ZoomSpeed;\r\n\t\t\tif( input->IsJoystickButtonDown(JoystickNumber, ZoutButton)\t) RotationAngles->z += ZoomSpeed;\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\nFIND_PATH(WEBPLAYERDIR\r\n NAMES WebPlayerConfig.exe\r\n PATHS\r\n [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Virtools\\\\WebPlayer;InstallPath]\r\n \"C://ProgramFiles/3D Life Player\"\r\n )\r\nMARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)\r\nSET(WEBPLAYER 1)\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n\r\n\r\n#define FTP4W_INCLUDES_AND_GENERAL +\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\n#include /* external header file */ \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\" /* external header file */ \r\n#include \"ftp4w_in.h\" /* internal header file */\r\n#include \"rfc959.h\" /* only for error codes */ \r\n\r\n\r\n\r\n/* -------------------------------------- */\r\n/* Acces a TnSend depuis Ftp4w */\r\n/* -------------------------------------- */\r\nint _export PASCAL FAR IntTnSend (SOCKET s, LPSTR szString, \r\n BOOL bHighPriority, HFILE hf)\r\n{\r\nint Rc;\r\nLPProcData p = FtpDataPtr();\r\n\r\n\tRc = TnSend (s, szString, bHighPriority, hf);\r\n if (p != NULL && p->ftp.bVerbose)\r\n {\r\n \t\tOutputDebugString (szString);\r\n \t\tOutputDebugString (\"\\r\\n\");\r\n \t}\r\nreturn Rc;\r\n}\r\n\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie III : Etage Telnet avec utilisation de la structure FtpData */\r\n/* Traitement du mode Verbose */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n/* ------------------------------------------------------------ */\r\n/* FtpGetAnswerCode : Attend une réponse du serveur et rend le */\r\n/* code numérique (les 3 premiers octets) */\r\n/* renvoyé par le serveur. */\r\n/* - Le mode verbose consiste à envoyer */\r\n/* l'adresse du buffer à l'utilisateur */\r\n/* - Retourne un nombre entre 100 et 999 si la */\r\n/* fonction s'est bien passée, sinon un code */\r\n/* d'erreur TN_ERROR, TN_TIMEOUT... */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR IntFtpGetAnswerCode (LPFtpData pFtpData)\r\n{\r\nint Rc;\r\n\r\n memset (pFtpData->szInBuf, 0, sizeof pFtpData->szInBuf);\r\n Rc = TnGetAnswerCode (pFtpData->ctrl_socket, pFtpData->szInBuf, \r\n sizeof pFtpData->szInBuf, pFtpData->nTimeOut,\r\n pFtpData->hLogFile);\r\n\r\n if (Rc>0 && pFtpData->bVerbose)\r\n { \r\n LPProcData p = FtpDataPtr();\r\n if (p != NULL)\r\n SendMessage (p->VMsg.hVerboseWnd, p->VMsg.nVerboseMsg,\r\n TRUE, (LPARAM) pFtpData->szInBuf);\r\n \t\tOutputDebugString (pFtpData->szInBuf);\r\n \t\tOutputDebugString (\"\\r\\n\");\r\n }\r\nreturn Rc;\r\n} /* IntFtpGetAnswerCode */\r\n\r\n\r\n/********************************************************************\r\ncreated:\t2007/12/12\r\ncreated:\t12:12:2007 11:55\r\nfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\\BaseMacros.hpp\r\n\t\t\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\r\n\t\t\tfile base:\tBaseMacros\r\n\t\t\tfile ext:\thpp\r\nauthor:\t\tmc007\r\n\r\npurpose:\t\r\n\t\t\t*********************************************************************/\r\n#ifndef __BASEMACROS_H\r\n#define __BASEMACROS_H\r\n\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//\r\n\t\t\t\t//\t\t\t\t\t\tPlatform Headers\r\n\t\t\t\t//\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//\r\n\t\t\t\t//\t\t\t\t\t\tPlatform specific header switchs : \r\n\t\t\t\t//\r\n\t\t\t\t/*#ifdef _WIN32\r\n\t\t\t\t#include \"vtCXPlatform32.h\"\r\n\t\t\t\t#endif\r\n\t\t\t\t*/\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//\r\n\t\t\t\t//\t\t\t\t\t\tBuild switchs : \r\n\t\t\t\t//\r\n\r\n\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////// \r\n\t\t\t\t//\tDebugBuild is used to hide private building blocks, types, attributes,...\r\n#ifdef NDEBUG\r\n\t\t\t\tstatic const bool DebugBuild = true;\r\n#else\r\n\t\t\t\tstatic const bool DebugBuild = false;\r\n#endif\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// dll directives :\r\n#ifdef _WIN32\r\n#define API_EXPORT __declspec(dllexport)\r\n#else\r\n\t\t\t// Unix needs no export, but for name mangling, keep the function name\r\n\t\t\t// clean. If you omit the 'extern \"C\"', the .so names will be compiler dependent.\r\n#define API_EXPORT extern \"C\"\r\n#endif\r\n\r\n#ifndef API_INLINE\r\n#define API_INLINE __inline\r\n#endif\r\n\r\n#ifndef API_sCALL\r\n#define API_sCALL __stdcall\r\n#endif\r\n\r\n#ifndef API_cDECL\r\n#define API_cDECL __cdecl\r\n#endif\r\n\r\n\r\n#define DLLEXPORT\t\t\t__declspec( dllexport )\r\n#define DLLIMPORT\t\t\t__declspec( dllimport )\r\n\r\n\r\n\r\n#if defined(MODULE_STATIC)\r\n#\tdefine MODULE_IMPORT_API\r\n#\tdefine MODULE_EXPORT_API\r\n#else\r\n#\tdefine MODULE_IMPORT_API DLLIMPORT\r\n#\tdefine MODULE_EXPORT_API DLLEXPORT\r\n#endif\r\n\r\n\t\t\t// MODULE_BASE_API\r\n\r\n#if defined( MODULE_BASE_EXPORTS )\r\n\t#\tdefine MODULE_API MODULE_EXPORT_API\r\n#else\r\n\t#\tdefine MODULE_API MODULE_IMPORT_API\r\n#endif\r\n\r\n\r\n\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\t\t\t\tAPI Specific Constants :\r\n\t\t\t//\r\n\r\n#define API_PREFIX \"mw\"\r\n#define API_ENTRY(F) API_PREFIX##F\r\n\r\n#define API_CUSTOM_BB_CATEGORY(F) API_PREFIX##F\t\r\n\t\t\t//\t#define MY_BB_CAT API_CUSTOM_BB_CATEGORY(/MySubCategory) leads to : \"mw/MySubCategory\"\r\n\r\n\r\n#ifndef AUTHOR\r\n#define\tAUTHOR\t\t\t\t\"\"\r\n#endif\r\n\r\n#ifndef AUTHOR_GUID\r\n#define\tAUTHOR_GUID\t\t\tCKGUID(0x79ba75dd,0x41d77c63)\r\n#endif\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\t\t\t\tError Identifiers : \r\n\t\t\t//\r\n\r\n\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\t\t\t\tFile System Specific : \t\t\t\t\t\t\r\n\t\t\t//\r\n\r\n#if defined (_LINUX)\r\n#define FS_PATH_SEPERATOR '/'\r\n#define FS_PATH_DRIVE_SEPARATOR ':'\r\n#define FS_EOL \"\\n\"\t\t\t//(0x0D)\r\n#endif\r\n\r\n#ifdef _WIN32\r\n#define FS_PATH_SEPERATOR '\\\\'\r\n#define FS_PATH_DRIVE_SEPARATOR \r\n#define FS_EOL \"\\r\\n\"\t\t//(0x0A 0x0D)\r\n#endif\r\n\r\n#if defined (macintosh)\r\n#define FS_PATH_SEPERATOR '/'\r\n#define FS_PATH_DRIVE_SEPARATOR \r\n#define FS_EOL \"\\r\"\t\t//(0x0A)\r\n#endif\r\n\r\n#define FS_PATH_EXT_SEPARATOR '.'\r\n\r\n\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\t\t\t\t\t\t\r\n\t\t\t//\r\n\r\n#endif/*****************************************************************************\r\n*\r\n* THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF\r\n* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\r\n* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR\r\n* A PARTICULAR PURPOSE.\r\n*\r\n* Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.\r\n*\r\n******************************************************************************\r\n*\r\n* Seq.H\r\n*\r\n* Public include file for sequencer interface.\r\n*\r\n*****************************************************************************/\r\n\r\n#ifndef MidiSound_h\r\n#define MidiSound_h\r\n\r\n#include \"smf.h\"\r\n\r\n#define VERSION_MINOR 0x00\r\n#define VERSION_MAJOR 0x04\r\n#define SEQ_VERSION ((DWORD)(WORD)((BYTE)VERSION_MINOR | (((WORD)(BYTE)VERSION_MAJOR) << 8)))\r\n\r\n#define SEQ_F_EOF 0x00000001L\r\n#define SEQ_F_COLONIZED 0x00000002L\r\n#define SEQ_F_WAITING 0x00000004L \r\n\r\n#define SEQ_S_NOFILE 0\r\n#define SEQ_S_OPENED 1\r\n#define SEQ_S_PREROLLING 2\r\n#define SEQ_S_PREROLLED 3\r\n#define SEQ_S_PLAYING 4\r\n#define SEQ_S_PAUSED 5\r\n#define SEQ_S_STOPPING 6\r\n#define SEQ_S_RESET 7\r\n\r\n#define MMSG_DONE (WM_USER+20)\r\n#define MMRESULT unsigned int\r\n\r\ntypedef struct tag_preroll\r\n{\r\n TICKS tkBase;\r\n TICKS tkEnd;\r\n} PREROLL,\r\n*LPPREROLL;\r\n\r\ntypedef struct tag_seq * PSEQ;\r\ntypedef struct tag_seq\r\n{\r\n\tpublic:\r\n DWORD cBuffer; /* Number of streaming buffers to alloc */\r\n DWORD cbBuffer; /* Size of each streaming buffer */\r\n LPSTR pstrFile; /* Pointer to filename to open */\r\n UINT uDeviceID; /* Requested MIDI device ID for MMSYSTEM */\r\n UINT uMCIDeviceID; /* Our MCI device ID given to us */\r\n UINT uMCITimeFormat; /* Current time format */\r\n UINT uMCITimeDiv; /* MCI_SEQ_DIV_xxx for current file */\r\n\tHWND\t\thWnd;\t\t\t\t/* Where to post MMSG_DONE when done playing\t*/\r\n\t\r\n UINT uState; /* Sequencer state (SEQ_S_xxx) */\r\n TICKS tkLength; /* Length of longest track */\r\n DWORD cTrk; /* Number of tracks */\r\n MMRESULT mmrcLastErr; /* Error return from last sequencer operation */\r\n\t\r\n PSEQ pNext; /* Link to next PSEQ */\r\n HSMF hSmf; /* Handle to open file */\r\n HMIDIOUT hmidi; /* Handle to open MIDI device */\r\n DWORD dwTimeDivision; /* File time division */\r\n\t\r\n LPBYTE lpbAlloc; /* Streaming buffers -- initial allocation */ \r\n LPMIDIHDR lpmhFree; /* Streaming buffers -- free list */\r\n LPMIDIHDR lpmhPreroll; /* Streaming buffers -- preroll buffer */\r\n DWORD cbPreroll; /* Streaming buffers -- size of lpmhPreroll */\r\n UINT uBuffersInMMSYSTEM; /* Streaming buffers -- in use */\r\n \r\n TICKS tkBase; /* Where playback started from in stream */\r\n TICKS tkEnd; /* Where playback should end */\r\n \r\n DWORD fdwSeq; /* Various sequencer flags */\r\n\t\r\n} SEQ,\r\n*PSEQ;\r\n\r\n\r\n\r\nclass MidiSound {\r\nprivate:\r\n\tPSEQ pSeq;\r\n\r\n\r\nprivate:\r\n\t MMRESULT AllocBuffers();\r\n\t\r\n\t VOID FreeBuffers();\r\n\t\r\npublic:\r\n\t MidiSound(void *hwnd);\r\n\r\n\t ~MidiSound();\r\n\r\n\t// Fichier midi associe\r\n\t MMRESULT SetSoundFileName(const char * fname);\r\n\t const char* GetSoundFileName();\r\n\r\n\t BOOL IsPlaying(); \r\n\r\n\t BOOL IsPaused(); \r\n\r\n\t MMRESULT OpenFile();\r\n\t\r\n\t MMRESULT CloseFile( );\r\n\t\r\n\t MMRESULT Preroll();\r\n\t\r\n\t MMRESULT Start();\r\n\t\r\n\t MMRESULT Pause();\r\n\t\r\n\t MMRESULT Restart();\r\n\t\r\n\t MMRESULT Stop();\r\n\t\r\n\t MMRESULT Time(PTICKS pTicks);\r\n\t\r\n\t TICKS MillisecsToTicks(DWORD msOffset);\r\n\t\r\n\t DWORD TicksToMillisecs(TICKS tkOffset);\r\n};\r\n#endif\r\n// DistributedNetworkClassDialogEditor.h : main header file for the EDITOR DLL\r\n//\r\n\r\n#pragma once\r\n\r\n#ifndef __AFXWIN_H__\r\n\t#error include 'stdafx.h' before including this file for PCH\r\n#endif\r\n\r\n#include \"resource.h\"\t\t// main symbols\r\n\r\nclass DistributedNetworkClassDialogEditorDlg;\r\nclass DistributedNetworkClassDialogToolbarDlg;\r\n\r\nextern DistributedNetworkClassDialogEditorDlg*\t\tg_Editor;\r\nextern DistributedNetworkClassDialogToolbarDlg*\t\tg_Toolbar;\r\n\r\n//plugin interface for communication with Virtools Dev\r\nextern PluginInterface*\t\ts_Plugininterface;\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CEditorApp\r\n// See Editor.cpp for the implementation of this class\r\n//\r\n\r\nclass DistributedNetworkClassDialogEditorApp : public CWinApp\r\n{\r\nprotected:\r\n\tvoid\tInitImageList();\r\n\tvoid\tDeleteImageList();\r\n\tCImageList\t\tm_ImageList;\r\n\r\npublic:\r\n\tDistributedNetworkClassDialogEditorApp();\r\n\r\n// Overrides\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(DistributedNetworkClassDialogCEditorApp)\r\n\tpublic:\r\n\tvirtual BOOL InitInstance();\r\n\tvirtual int ExitInstance();\r\n\t//}}AFX_VIRTUAL\r\n\r\n\t//{{AFX_MSG(DistributedNetworkClassDialogCEditorApp)\r\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code !\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n//{{AFX_INSERT_LOCATION}}\r\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r\n\n#ifndef __QLIB_TIMER_H\n#define __QLIB_TIMER_H\n\n#include \n#include \n#ifdef linux\n\t#include \n#endif\n\n// Vertical trace resolution?\n//#define USE_VTRACE\n\n#if defined(__sgi)\n\t// UST nanosecond resolution?\n\t#define USE_UST\n#endif\n\n#if defined(linux)\n// time() usage? Bad resolution and misplaced offsets within the second\n\t#define USE_GETTIMEOFDAY\n#endif\n\n#if defined(WIN32)\n\t#define USE_OS_TICK // Use milliseconds NT timer\n#endif\n\n#ifndef ulong\n\ttypedef unsigned long ulong;\n#endif\n\n\n\nclass MODULE_API QTimer \n{\n private:\n#ifdef USE_TIME\n time_t base_secs;\n int ticks; // Seconds (not very high frequency!)\n#endif\n#ifdef USE_GETTIMEOFDAY\n int ticks;\n struct timeval tv; // Should do microsecs\n int base_usecs; // Base time in usecs\n struct timeval tvBase; // Base time\n#endif\n#ifdef USE_OS_TICK\n int ticks;\n int baseTicks;\n#endif\n\n#if defined(__sgi)\n ulong base_secs,base_micros;\t// Intuition (Amiga) style\n\t#ifdef USE_UST\n\t\tuint64 ticks;\t\t\t// UST ticks go FAST!\n\t\tuint64 baseUST;\t\t// UST timing\n\t#endif\n\t#ifdef USE_VTRACE\n\t\tint baseVCount;\t\t// Vertical retraces base\n\t\tint ticks;\t\t\t// Current #ticks recorded\n\t#endif\n#endif\n\n bool isRunning;\t\t// Recording time?\n //QClassType ID() const { return QOBJ_TIMER; }\n\n protected:\n void ResetBase();\t\t// Base GLX vtrace counter\n void UpdateTicks();\n\n public:\n QTimer();\n ~QTimer();\n\n bool IsRunning(){ return isRunning; }\n void Reset();\n void Start();\n void Stop();\n\n // Get time\n void GetTime(ulong *secs,ulong *micros);\n ulong GetSeconds();\n int GetMilliSeconds();\n int GetMicroSeconds();\n#ifdef WIN32\n int GetTicks();\n#else\n// SGI\n#ifdef USE_UST\n uint64 GetTicks();\n#else\n int GetTicks();\n#endif\n#endif\n\n // Adjust time\n void AdjustMilliSeconds(int delta);\n\n // Higher level\n void WaitForTime(int secs,int msecs=0);\n};\n\n#endif\n#ifndef __P_COMMON_H__\r\n#define __P_COMMON_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtLogTools.h\"\r\n#include \"vtCBBErrorHelper.h\"\r\n#include \r\n#include \r\n\r\n\r\n#define HAS_CONFIG\r\n#ifdef HAS_CONFIG\r\n\t#include \"gConfig.h\"\r\n#endif\r\n\r\nusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\r\n\r\n\r\n\r\n#endif#ifndef _XDISTRIBUTED_POINT4F_H_\r\n#define _XDISTRIBUTED_POINT4F_H_\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xQuat.h\"\r\n\r\nclass xDistributedQuatF : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedQuatF ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tmLastValue = QuatF(0.0f,0.0f,0.0f,0.0f);\r\n\t\t\tmCurrentValue= QuatF(0.0f,0.0f,0.0f,0.0f);\r\n\t\t\tmDifference = QuatF(0.0f,0.0f,0.0f,0.0f);\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\r\n\t\t~xDistributedQuatF(){}\r\n\t\t\r\n\r\n\t\tQuatF mLastValue;\r\n\t\tQuatF mCurrentValue;\r\n\t\tQuatF mDifference;\r\n\r\n\t\tQuatF mLastServerValue;\r\n\t\tQuatF mLastServerDifference;\r\n \r\n\t\tbool updateValue(QuatF value,xTimeType currentTime);\r\n\t\tQuatF getDiff(QuatF value);\r\n void pack(xNStream *bstream);\r\n\t\tvoid unpack(xNStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(xNStream *stream);\r\n\t\tvoid updateFromServer(xNStream *stream);\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n\r\n \r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n#include \r\n\r\n#include \"NxShape.h\"\r\n#include \"Nxp.h\"\r\n#include \"pMisc.h\"\r\n\r\n#include \"PhysicManager.h\"\r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nnamespace vtAgeia\r\n{\r\nCK3dEntity *getEntityFromShape(NxShape* shape)\r\n{\r\n\r\n\tif ( !shape)\r\n\t\treturn NULL;\r\n\t\r\n\tpSubMeshInfo *sInfo = (pSubMeshInfo*)shape->userData;\r\n\tif (sInfo)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity*)CKGetObject(ctx(),sInfo->entID);\r\n\t\treturn ent;\r\n\t}\r\n\treturn NULL;\r\n}\r\nbool isChildOf(CK3dEntity*parent,CK3dEntity*test)\r\n{\r\n\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= parent->HierarchyParser(subEntity) )\r\n\t{\r\n\t\tif (subEntity == test)\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nCK3dEntity* findSimilarInSourceObject(CK3dEntity *parentOriginal,CK3dEntity* partentCopied,CK3dEntity *copiedObject,CK3dEntity*prev)\r\n{\r\n\r\n\r\n\tif (!parentOriginal || !copiedObject )\r\n\t\treturn NULL;\r\n\r\n\tif (parentOriginal->GetChildrenCount() < 1)\r\n\t\treturn NULL;\r\n\r\n\t\r\n\tif ( prev && prev!=copiedObject && isChildOf(parentOriginal,prev) && !isChildOf(partentCopied,prev) )\r\n\t\t\treturn prev;\r\n\t\t\t\r\n\t\r\n\tCK3dEntity *orginalObject= (CK3dEntity*)ctx()->GetObjectByNameAndClass(copiedObject->GetName(),CKCID_3DOBJECT,prev);\r\n\tif (orginalObject)\r\n\t{\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// tests \r\n\t\t//\r\n\t\tif ( orginalObject==copiedObject )\r\n\t\t\tfindSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject);\r\n\t\t\t\r\n\r\n\t\tif ( !isChildOf(parentOriginal,orginalObject)) \r\n\t\t\t\tfindSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject);\r\n\t\r\n\t\tif( isChildOf(partentCopied,orginalObject) )\r\n\t\t\tfindSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject);\r\n\r\n\r\n\r\n\t\treturn orginalObject;\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n\r\nbool calculateOffsets(CK3dEntity*source,CK3dEntity*target,VxQuaternion &quat,VxVector& pos)\r\n{\r\n\tif (!source && !target)\r\n\t\treturn false;\r\n\t\r\n\tCK3dEntity* child = NULL;\r\n\tbool isChild = false;\r\n\twhile (child = source->HierarchyParser(child) )\r\n\t{\r\n\t\tif (child == target )\r\n\t\t{\r\n\t\t\tisChild = true;\r\n\t\t}\r\n\t}\r\n\r\n\tVxQuaternion refQuad2;\r\n\ttarget->GetQuaternion(&refQuad2,source);\r\n\tVxVector relPos;\r\n\ttarget->GetPosition(&relPos,source);\r\n\t\r\n\tpos = relPos;\r\n\tquat = refQuad2;\r\n\r\n\treturn true;\r\n\r\n}\r\nint getNbOfPhysicObjects(CK3dEntity *parentObject,int flags/* =0 */)\r\n{\r\n\t#ifdef _DEBUG\r\n\t\tassert(parentObject);\r\n\t#endif // _DEBUG\r\n\r\n\tint result = 0;\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// parse hierarchy \r\n\t//\r\n\t\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= parentObject->HierarchyParser(subEntity) )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(subEntity);\r\n\t\tif (body)\r\n\t\t\tresult++;\r\n\t}\r\n\treturn result;\r\n}\r\nint getHullTypeFromShape(NxShape *shape)\r\n{\r\n\r\n\tint result = - 1; \r\n\tif (!shape)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tint nxType = shape->getType();\r\n\tswitch (nxType)\r\n\t{\r\n\t\tcase NX_SHAPE_PLANE:\r\n\t\t\treturn HT_Plane;\r\n\t\t\r\n\t\tcase NX_SHAPE_BOX:\r\n\t\t\treturn HT_Box;\r\n\t\t\r\n\t\tcase NX_SHAPE_SPHERE:\r\n\t\t\treturn HT_Sphere;\r\n\t\t\r\n\t\tcase NX_SHAPE_CONVEX: \r\n\t\t\treturn HT_ConvexMesh;\r\n\t\t\r\n\t\tcase NX_SHAPE_CAPSULE:\r\n\t\t\treturn HT_Capsule;\r\n\t\t\r\n\t\tcase NX_SHAPE_MESH:\r\n\t\t\treturn HT_Mesh;\r\n\t}\r\n\r\n\treturn -1;\r\n\r\n}\r\n\r\n\r\nint getEnumIndex(CKParameterManager* pm,CKGUID parGuide,XString enumValue)\r\n{\r\n\r\n\tint pType = pm->ParameterGuidToType(parGuide);\r\n\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\r\n\t\t\tif( !strcmp(enumStruct->GetEnumDescription(i),enumValue.Str()) ) \r\n\t\t\t\treturn i;\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nXString getEnumDescription(CKParameterManager* pm,CKGUID parGuide)\r\n{\r\n\r\n\tXString result;\r\n\tint pType = pm->ParameterGuidToType(parGuide);\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\t\t\t\tresult << enumStruct->GetEnumDescription(i);\r\n\t\t\t\tresult << \"=\";\r\n\t\t\t\tresult << enumStruct->GetEnumValue(i);\r\n\t\t\t\tif (i < enumStruct->GetNumEnums() -1 )\r\n\t\t\t\t{\r\n\t\t\t\t\tresult << \",\";\r\n\t\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nXString getEnumDescription(CKParameterManager* pm,CKGUID parGuide,int parameterSubIndex)\r\n{\r\n\r\n\tXString result=\"None\";\r\n\tint pType = pm->ParameterGuidToType(parGuide);\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\t\t\tif(i == parameterSubIndex)\r\n\t\t\t{\r\n\t\t\t\tresult = enumStruct->GetEnumDescription(i);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n//************************************\r\n// Method: BoxGetZero\r\n// FullName: vtAgeia::BoxGetZero\r\n// Access: public \r\n// Returns: VxVector\r\n// Qualifier:\r\n// Parameter: vt3DObject ent\r\n//************************************\r\nVxVector BoxGetZero(CK3dEntity* ent)\r\n{\r\n\r\n\tVxVector box_s= VxVector(1,1,1);\r\n\tif (ent)\r\n\t{\r\n\r\n\t\tVxMatrix mat = ent->GetWorldMatrix();\r\n\t\tVxVector g;\r\n\t\t//Vx3DMatrixToEulerAngles(mat,&g.x,&g.y,&g.z);\r\n\t\t//SetEulerDirection(ent,VxVector(0,0,0));\r\n\t\tCKMesh *mesh = ent->GetCurrentMesh();\r\n\r\n\r\n\t\tif (mesh!=NULL)\r\n\t\t{\r\n\t\t\tbox_s = mesh->GetLocalBox().GetSize();\r\n\t\t}\r\n\t\t//SetEulerDirection(ent,g); \r\n\t}\r\n\treturn box_s;\r\n}\r\n\r\n//************************************\r\n// Method: SetEulerDirection\r\n// FullName: vtAgeia::SetEulerDirection\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK3dEntity* ent\r\n// Parameter: VxVector direction\r\n//************************************\r\nvoid SetEulerDirection(CK3dEntity* ent,VxVector direction)\r\n{\r\n\r\n\tVxVector dir,up,right;\r\n\tVxMatrix mat;\r\n\tVx3DMatrixFromEulerAngles(mat,direction.x,direction.y,direction.z);\r\n\tdir=(VxVector)mat[2];\r\n\tup=(VxVector)mat[1];\r\n\tright=(VxVector)mat[0];\r\n\tent->SetOrientation(&dir,&up,&right,NULL,FALSE);\r\n\r\n}\r\n\r\n\r\n}\r\n\r\n/*\r\n*****************************************************************\r\n* Copyright © ITI Scotland 2006 \r\n*----------------------------------------------------------------\r\n* Module : $File: //depot/ITITM005/Code/GBLCommon/include/GBLPlatformWIN32.h $ \r\n*\r\n* Programmer : $Author: gunther.baumgart $\r\n* Date : $DateTime: 2006/05/17 15:37:18 $ \r\n*\r\n*----------------------------------------------------------------\r\n*\r\n* Module Summary : Platform specific Types and Functions.\r\n*\r\n*----------------------------------------------------------------\r\n* $Revision: #5 $ \r\n* $Change: 21762 $\r\n*****************************************************************\r\n*/\r\n\r\n#include \r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//Macros :\r\n/*\r\n\tFrom winnt.h : \r\n*/\r\n#ifndef MAKEWORD\r\n\t#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))\r\n#endif\r\n\r\n#ifndef LOWORD\r\n\t#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))\r\n#endif\r\n\r\n#ifndef HIWORD\r\n\t#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))\r\n#endif\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n// DataRelay.cpp : Defines the initialization routines for the plugin DLL.\r\n//\r\n#include \"CKAll.h\"\r\n#include \"DataManager.h\"\r\n\r\n#include \"bginstancer.h\"\r\n#include \"gblasyncblock.h\"\r\n\r\n\r\n\r\n#ifdef CK_LIB\r\n#define RegisterBehaviorDeclarations Register_TOOLS_BehaviorDeclarations\t\t\r\n#define InitInstance\t\t\t\t\t_TOOLS_InitInstance\r\n#define ExitInstance\t\t\t\t\t_TOOLS_ExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGet_TOOLS_PluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGet_TOOLS_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_TOOLS_PluginInfo\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n#define InitInstance\t\t\t\t\tInitInstance\r\n#define ExitInstance\t\t\t\t\tExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\nCKERROR InitInstance(CKContext* context);\r\nCKERROR ExitInstance(CKContext* context);\r\n\r\n#define PLUGIN_COUNT 2\r\n\r\nCKPluginInfo g_PluginInfo[PLUGIN_COUNT];\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount(){return 2;}\r\n\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tint Plugin = 0;\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"Virtools\";\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Generic tools\";\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00010000;\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL;\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0xbd1e1d69, 0x0ee9fdca);\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"Collection of generic tools\";\r\n\tPlugin++;\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"Virtools\";\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Tools manager\";\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00010000;\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= InitInstance;\n\tg_PluginInfo[Plugin].m_ExitInstanceFct\t= ExitInstance;\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= DataManagerGUID;\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"Tool manager\";\r\n\treturn &g_PluginInfo[Index];\r\n}\r\n\r\n// If no manager is used in the plugin \r\n//\tthese functions are optional and can be exported.\r\n// Virtools will call 'InitInstance' when loading the behavior library\r\n// and 'ExitInstance' when unloading it.\r\n//\tIt is a good place to perform Attributes Types declaration, \r\n// registering new enums or new parameter types.\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n new DataManager(context);\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\t// This function will only be called if the dll is unloaded explicitely \r\n\t// by a user in Virtools Dev interface\r\n\t// Otherwise the manager destructor will be called by Virtools runtime directly\r\n delete context->GetManagerByGuid(DataManagerGUID);\r\n\treturn CK_OK;\r\n}\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\n{\n\n\t::CKStoreDeclaration(reg, BGWrapper::FillBehaviour());\r\n\t::CKStoreDeclaration(reg, ExeInThread::FillBehaviour());\n\n\tRegisterBehavior(reg,FillBehaviorGetAdaptersDecl);\r\n\tRegisterBehavior(reg,FillBehaviorGetAdaptersModieDecl);\r\n\tRegisterBehavior(reg,FillBehaviorGoFullScreenDecl);\n\n\n\n\tRegisterBehavior(reg, FillBehaviorHasFFEffectsDecl);\n\tRegisterBehavior(reg, FillBehaviorJSetXYForceDecl);\n\n\n\tRegisterBehavior(reg,FillBehaviorGetCurrentPathDecl);\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorDirToArrayDecl);\r\n\t\r\n\t\n\n}\n\r\n\r\n\r\n\r\n\r\n\r\n/********************************************************************\r\n\tcreated:\t2008/04/10\r\n\tcreated:\t10:4:2008 12:49\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_tnl\\Manager\\xDistributedBaseClass.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\vt_tnl\\Manager\r\n\tfile base:\txDistributedBaseClass\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef _XDISTRIBUTED_BASE_CLASS_H_\r\n#define _XDISTRIBUTED_BASE_CLASS_H_\r\n#include \"xNetTypes.h\"\r\n\r\n//typedef XHashTablexDistributedPropertyInfoArrayType;\r\n//typedef XHashTable::Iterator xDistributedPropertyInfoArrayIterator;\r\n\r\nclass xDistributed3DObjectClass;\r\n\r\n/*\r\n#ifdef GetClassNameA\r\n\t#undef GetClassNameA\r\n#endif\r\n*/\r\nclass xDistributedClass\r\n{\r\n\tpublic:\r\n\r\n\t\txDistributedClass();\r\n\t\tvirtual ~xDistributedClass();\r\n\r\n\t\tint getEnitityType() { return m_EnitityType; }\r\n\t\tvoid setEnitityType(int val) { m_EnitityType = val; }\r\n\r\n\t\txNString getClassName();\r\n\t\tvoid setClassName(xNString name);\r\n\r\n\t\txDistributedPropertiesListType* getDistributedProperties() { return m_DistributedProperties; }\t\t\r\n\t\tint getNativeFlags()\t{ return m_NativeFlags; }\r\n\t\tvoid setNativeFlags( int val ){ m_NativeFlags = val; }\r\n\r\n\t\tvirtual void addProperty(const char*name,int type,int predictionType){}\r\n\t\tvirtual void addProperty(int nativeType,int predictionType){}\r\n\r\n\t\txDistributed3DObjectClass *cast(xDistributedClass *_in);\r\n\r\n\t\tvirtual int getFirstUserField(){ return 0; }\r\n\t\tvirtual int getUserFieldBitValue(int walkIndex){ return 0; }\r\n\t\tvirtual int getInternalUserFieldIndex(int inputIndex){ return 0;} \r\n\t\tvirtual int getUserFieldCount(){return 0;}\r\n\r\n\t\tvirtual xNString NativeTypeToString(int nativeType){ return xNString(\"\");}\r\n\t\tvirtual int NativeTypeToValueType(int nativeType){ return -1;}\r\n \r\n\tpublic : \r\n\t\txDistributedPropertyInfo *exists(const char*name);\r\n\t\tvirtual xDistributedPropertyInfo *exists(int nativeType);\r\n\r\n\tprotected:\r\n\r\n\t\tint m_NativeFlags;\r\n\t\t\r\n\t\tint m_EnitityType;\r\n\t\txNString m_ClassName;\r\n\t\tint m_NativeProperties;\r\n\t\t\r\n\t\txDistributedPropertiesListType *m_DistributedProperties;\r\n\t\t\r\n\tprivate:\r\n};\r\n\r\n#endif\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU\n// General Public License, alternative licensing options are available\n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnl.h\"\n#include \"tnlClientPuzzle.h\"\n#include \"tnlRandom.h\"\n\n#include \n\nnamespace TNL {\n\nvoid ClientPuzzleManager::NonceTable::reset()\n{\n mChunker.freeBlocks();\n mHashTableSize = Random::readI(MinHashTableSize, MaxHashTableSize) * 2 + 1;\n mHashTable = (Entry **) mChunker.alloc(sizeof(Entry *) * mHashTableSize);\n for(U32 i = 0; i < mHashTableSize; i++)\n mHashTable[i] = NULL;\n}\n\nbool ClientPuzzleManager::NonceTable::checkAdd(Nonce &theNonce)\n{\n U32 nonce1 = readU32FromBuffer(theNonce.data);\n U32 nonce2 = readU32FromBuffer(theNonce.data + 4);\n\n U64 fullNonce = (U64(nonce1) << 32) | nonce2;\n\n U32 hashIndex = U32(fullNonce % mHashTableSize);\n for(Entry *walk = mHashTable[hashIndex]; walk; walk = walk->mHashNext)\n if(walk->mNonce == theNonce)\n return false;\n Entry *newEntry = (Entry *) mChunker.alloc(sizeof(Entry));\n newEntry->mNonce = theNonce;\n newEntry->mHashNext = mHashTable[hashIndex];\n mHashTable[hashIndex] = newEntry;\n return true;\n}\n\nClientPuzzleManager::ClientPuzzleManager()\n{\n mCurrentDifficulty = InitialPuzzleDifficulty;\n mLastUpdateTime = 0;\n mLastTickTime = 0;\n Random::read(mCurrentNonce.data, Nonce::NonceSize);\n Random::read(mLastNonce.data, Nonce::NonceSize);\n\n mCurrentNonceTable = new NonceTable;\n mLastNonceTable = new NonceTable;\n}\n\nClientPuzzleManager::~ClientPuzzleManager()\n{\n delete mCurrentNonceTable;\n delete mLastNonceTable;\n}\n\nvoid ClientPuzzleManager::tick(U32 currentTime)\n{\n if(!mLastTickTime)\n mLastTickTime = currentTime;\n\n // use delta of last tick time and current time to manage puzzle\n // difficulty.\n\n // not yet implemented.\n\n\n // see if it's time to refresh the current puzzle:\n U32 timeDelta = currentTime - mLastUpdateTime;\n if(timeDelta > PuzzleRefreshTime)\n {\n mLastUpdateTime = currentTime;\n mLastNonce = mCurrentNonce;\n NonceTable *tempTable = mLastNonceTable;\n mLastNonceTable = mCurrentNonceTable;\n mCurrentNonceTable = tempTable;\n\n mLastNonce = mCurrentNonce;\n mCurrentNonceTable->reset();\n Random::read(mCurrentNonce.data, Nonce::NonceSize);\n }\n}\n\nbool ClientPuzzleManager::checkOneSolution(U32 solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity)\n{\n U8 buffer[8];\n writeU32ToBuffer(solution, buffer);\n writeU32ToBuffer(clientIdentity, buffer + 4);\n\n hash_state hashState;\n U8 hash[32];\n\n sha256_init(&hashState);\n sha256_process(&hashState, buffer, sizeof(buffer));\n sha256_process(&hashState, clientNonce.data, Nonce::NonceSize);\n sha256_process(&hashState, serverNonce.data, Nonce::NonceSize);\n sha256_done(&hashState, hash);\n\n U32 index = 0;\n while(puzzleDifficulty > 8)\n {\n if(hash[index])\n return false;\n index++;\n puzzleDifficulty -= 8;\n }\n U8 mask = 0xFF << (8 - puzzleDifficulty);\n return (mask & hash[index]) == 0;\n}\n\nClientPuzzleManager::ErrorCode ClientPuzzleManager::checkSolution(U32 solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity)\n{\n\n\treturn Success;\n if(puzzleDifficulty != mCurrentDifficulty)\n return InvalidPuzzleDifficulty;\n NonceTable *theTable = NULL;\n if(serverNonce == mCurrentNonce)\n theTable = mCurrentNonceTable;\n else if(serverNonce == mLastNonce)\n theTable = mLastNonceTable;\n if(!theTable)\n return InvalidServerNonce;\n if(!checkOneSolution(solution, clientNonce, serverNonce, puzzleDifficulty, clientIdentity))\n return InvalidSolution;\n if(!theTable->checkAdd(clientNonce))\n return InvalidClientNonce;\n return Success;\n}\n\nbool ClientPuzzleManager::solvePuzzle(U32 *solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity)\n{\n U32 startTime = Platform::getRealMilliseconds();\n U32 startValue = *solution;\n\n // Until we're done...\n for(;;)\n {\n U32 nextValue = startValue + SolutionFragmentIterations;\n for(;startValue < nextValue; startValue++)\n {\n if(checkOneSolution(startValue, clientNonce, serverNonce, puzzleDifficulty, clientIdentity))\n {\n *solution = startValue;\n return true;\n }\n }\n\n // Then we check to see if we're out of time...\n if(Platform::getRealMilliseconds() - startTime > MaxSolutionComputeFragment)\n {\n *solution = startValue;\n return false;\n }\n }\n}\n\n};\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n#include \"IParameter.h\"\r\n#include \"pVehicleAll.h\"\r\n#include \r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetGearsDecl();\r\nCKERROR CreatePVSetGearsProto(CKBehaviorPrototype **pproto);\r\nint PVSetGears(const CKBehaviorContext& behcontext);\r\nCKERROR PVSetGearsCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tI_XML,\r\n\tI_nbFGears,\r\n\tI_Flags,\r\n\tI_Ratios,\r\n\tI_ShiftUpRPM,\r\n\tI_ShiftDownRPM,\r\n\tI_Clutch,\r\n\tI_ClutchRelease,\r\n\t\r\n};\r\n\r\n#define BB_SSTART 4\r\n\r\n\r\nBBParameter pInMap6[] = \r\n{\r\n\r\n\tBB_PIN(I_XML,VTE_XML_VGEAR_SETTINGS,\"XML Link\",\"None\"),\r\n\tBB_PIN(I_nbFGears,CKPGUID_INT,\"Number of Forward Gears\",\"None\"),\r\n\tBB_PIN(I_Flags,VTS_VGEARBOX_FLAGS,\"Flags\",\"None\"),\r\n\tBB_PIN(I_Ratios,VTS_VGEAR_RATIOS,\"Forward Ratios/Inertias\",\"None\"),\r\n\tBB_SPIN(I_ShiftUpRPM,CKPGUID_FLOAT,\"Shift Up RPM\",\"\"),\r\n\tBB_SPIN(I_ShiftDownRPM,CKPGUID_FLOAT,\"Shift Down RPM\",\"\"),\r\n\tBB_SPIN(I_Clutch,CKPGUID_TIME,\"Clutch Time\",\"\"),\r\n\tBB_SPIN(I_ClutchRelease,CKPGUID_TIME,\"Clutch Release Time\",\"\"),\r\n\r\n\r\n\r\n\r\n\r\n\t/*BB_SPIN(I_RatioC,VTS_VGEAR_SETTINGS,\"Gear Graphic Setup\",\"None\"),*/\r\n};\r\n\r\n#define gPIMAP pInMap6\r\n\r\nCKERROR PVSetGearsCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\tCKContext *ctx = beh->GetCKContext();\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDELETE:\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\t\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPVSetGearsDecl\r\n// FullName: FillBehaviorPVSetGearsDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration*FillBehaviorPVSetGearsDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVGears\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Attachs and/or modifies a gearbox of a vehicle controller\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5d701f33,0x17d519eb));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVSetGearsProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVSetGearsProto\r\n// FullName: CreatePVSetGearsProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVSetGearsProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVGears\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\t//proto->DeclareOutParameter(\"Result Ratio Curve\",CKPGUID_2DCURVE,\"FALSE\");\r\n\r\n//\tproto->DeclareOutParameter(\"Result Torque Curve\",CKPGUID_2DCURVE,\"FALSE\");\r\n//\r\n\t/*\r\n\t\r\n\tPVSetGears \r\n\r\n\tPVSetGears is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVSetGears.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::setCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::setKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::enableGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::enableCollision(). \r\n\t
\r\n\tMass Offset: The new mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: The initial shape position in the bodies local space.\r\n\t
\r\n\tNotify Collision: Enables collision notification.This is necessary to use collisions related building blocks. \r\n\t
\r\n\tTransformation Locks: Specifies in which dimension a a transformation lock should occour.\r\n\t
\r\n\tLinear Damping: The new linear damping scale.\r\n\t
\r\n\tAngular Damping: The new linear damping scale.\r\n\t
\r\n\r\n\tFilter Groups: Sets the filter mask of the initial or sub shape.\r\n\t
\r\n\r\n\r\n\tCollisions Group: Enables input for collisions group.\r\n\t
\r\n\tKinematic Object: Enables input for kinematic object.\r\n\t
\r\n\tGravity: Enables input for gravity.\r\n\t
\r\n\tCollision: Enables input for collision. \r\n\t
\r\n\tMas Offset: Enables input for mass offset. \r\n\t
\r\n\tPivot Offset: Enables input for pivot offset.\r\n\t
\r\n\tNotify Collision: Enables input for collision. \r\n\t
\r\n\tLinear Damping: Enables input for linear damping.\r\n\t
\r\n\tAngular Damping: Enables input for angular damping.\r\n\t
\r\n\tFilter Groups: Enables input for filter groups.\r\n\t
\r\n\t\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\r\n\t*/\r\n\r\n\t//proto->DeclareSetting(\"Collisions Group\",CKPGUID_BOOL,\"FALSE\");\r\n\t/*proto->DeclareSetting(\"Kinematic\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Mass Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Pivot Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Notify Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Transformation Locks\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Linear Damping\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Angular Damping\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Filter Groups\",CKPGUID_BOOL,\"FALSE\");\r\n*/\r\n\tproto->SetBehaviorCallbackFct( PVSetGearsCB );\r\n\t\r\n\tBB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(gPIMAP);\r\n\r\n\t//proto->DeclareSetting(\"Output Ratio Curve\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\r\n\tproto->SetFunction(PVSetGears);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PVSetGears\r\n// FullName: PVSetGears\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n\r\nint getNewRatioTable(\tCKBehavior*beh,float dst[],CK2dCurve *resultCurve,int size = 6)\r\n{\r\n\r\n\tint result = 0 ;\r\n\r\n\r\n\tBB_DECLARE_PIMAP;//retrieves the parameter input configuration array\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tWe store safely some temporary data to determine the given \r\n\t//\t\tuser values are valid and can be send to the motor \r\n\t//\r\n\tCKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_Ratios));\r\n\tCKParameter *pout= inP->GetDirectSource();\r\n\tif (pout)\r\n\t{\r\n\t\t\r\n\t\tint gear = 0;\r\n\t\tfloat ratio = 0.0f;\r\n\t\tfor (int i = 0 ; i < 6 ; i++)\r\n\t\t{\r\n\t\t\tCK_ID* paramids = static_cast(pout->GetReadDataPtr());\r\n\t\t\tCKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i]));\r\n\t\t\tif (sub)\r\n\t\t\t{\r\n\r\n\t\t\t\tgear = GetValueFromParameterStruct(sub,0,false);\r\n\t\t\t\tratio = GetValueFromParameterStruct(sub,1,false);\r\n\r\n\t\t\t\tif ( ratio !=0.0 )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tdst[i] = ratio;\r\n\r\n\t\t\t\t\tresult++;\r\n\t\t\t\t\t//dst.insert(gear,ratio);\r\n\r\n\t\t\t\t\tif (resultCurve )\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tfloat dx = 1/ (size) ;\r\n\t\t\t\t\t\tfloat dy = ratio / 10;\r\n\t\t\t\t\t\tresultCurve->AddControlPoint(Vx2DVector(dx,dy) );\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(0,&resultCurve);\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nint PVSetGears(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target )\tbbSErrorME(E_PE_REF);\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)\t\t\tbbSErrorME(E_PE_NoBody);\r\n\t\t\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\t\t\t\tbbSErrorME(E_PE_NoVeh);\r\n\r\n\t\tif (!v->isValidEngine())\r\n\t\t\tbbErrorME(\"Vehicle is not complete\");\r\n\r\n\t\tpGearBox *gBox = v->getGearBox();\r\n\t\tif (!gBox)\t\t\tbbErrorME(\"No valid gearbox\");\r\n\r\n\r\n\r\n\t\tCK2dCurve* pOCurve = NULL;\t//optional \r\n\t\tCK2dCurve* pICurve = NULL;\t//optional \r\n\r\n\r\n\r\n\t\tBB_DECLARE_PIMAP;//retrieves the parameter input configuration array\r\n\r\n\r\n\t\tBBSParameterM(I_XML,BB_SSTART);//our bb settings concated as s##I_XML\r\n\t\tBBSParameterM(I_nbFGears,BB_SSTART);\r\n\t\tBBSParameterM(I_Flags,BB_SSTART);\r\n\t\tBBSParameterM(I_Ratios,BB_SSTART);\r\n\t\tBBSParameterM(I_ShiftUpRPM,BB_SSTART);\r\n\t\tBBSParameterM(I_ShiftDownRPM,BB_SSTART);\r\n\t\tBBSParameterM(I_Clutch,BB_SSTART);\r\n\t\tBBSParameterM(I_ClutchRelease,BB_SSTART);\r\n\r\n\t\tint xmlLink = GetInputParameterValue(beh,BB_IP_INDEX(I_XML));\r\n\t\tint nbGears = GetInputParameterValue(beh,BB_IP_INDEX(I_nbFGears));\r\n\t\tint flags = GetInputParameterValue(beh,BB_IP_INDEX(I_Flags));\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// setup ratios / inertias\r\n\t\t//\r\n\t\tCKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_Ratios));\r\n\r\n\t\tCKParameter *pout= inP->GetDirectSource();\r\n\t\tif (pout)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(gBox,pout);\r\n\t\t\t\r\n\t\t\tv->getDriveLine()->CalcPreClutchInertia();\r\n\t\t\tv->getDriveLine()->CalcCumulativeRatios();\r\n\t\t\tv->getDriveLine()->CalcEffectiveInertiae();\r\n\t\t\tv->getDriveLine()->CalcPostClutchInertia();\r\n\r\n\t\t}\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t//\tSetup nb of gears\r\n\t\t//\r\n\t\tiAssertW1(X_IS_BETWEEN(nbGears,3,10),nbGears=3);\r\n\t\tgBox->setGears(nbGears);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// RPMs\r\n\t\t//\r\n\t\tif (sI_ShiftUpRPM)\r\n\t\t\tgBox->setShiftUpRPM(GetInputParameterValue(beh,BB_IP_INDEX(I_ShiftUpRPM)));\r\n\r\n\t\tif (sI_ShiftDownRPM)\r\n\t\t\tgBox->setShiftDownRPM(GetInputParameterValue(beh,BB_IP_INDEX(I_ShiftDownRPM)));\r\n\r\n\t\tif (sI_Clutch)\r\n\t\t\tgBox->setTimeToClutch(GetInputParameterValue(beh,BB_IP_INDEX(I_Clutch)));\r\n\r\n\t\tif (sI_ClutchRelease)\r\n\t\t\tgBox->setTimeToDeclutch(GetInputParameterValue(beh,BB_IP_INDEX(I_ClutchRelease)));\r\n\r\n\r\n\t\t//float bRatio = GetInputParameterValue(beh,BB_IP_INDEX(I_BRatio));//silent update \r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//a optinal curve to display ratio between horse power and rpm\r\n\t\t/*DWORD outputCurve;\tbeh->GetLocalParameterValue(BB_PMAP_SIZE(gPIMAP),&outputCurve);//special settings !\r\n\t\tif (outputCurve)\r\n\t\t\tbeh->GetOutputParameterValue(0,&pOCurve);\r\n\t\t*/\r\n\r\n\t\t/*if (!gears && !sI_Ratios )\r\n\t\t{\r\n\t\t\tsI_Ratios = true;\r\n\t\t}*/\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\tChecking we have to replace of the entire motor object ! \r\n\t\t//\r\n\t\tif (sI_Ratios)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\tpLinearInterpolation nTable;\r\n\r\n\t\t\t/*nbGears = gDesc->nbForwardGears;\r\n\t\t\tint ratioSize = getNewRatioTable(beh,gDesc->forwardGearRatios,NULL,nbGears);\r\n\t\t\t*/\r\n\r\n\t\t\t/*\r\n\t\t\tif (ratioSize )\r\n\t\t\t{\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (pOCurve)\r\n\t\t\t\t{\r\n\t\t\t\t\twhile (pOCurve->GetControlPointCount())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tpOCurve->DeleteControlPoint(pOCurve->GetControlPoint(0));\r\n\t\t\t\t\t\tpOCurve->Update();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\r\n\r\n//\t\t\t\tgDesc->backwardGearRatio\t=\tsI_BRatio\t?\tbRatio : gears ? gears->_minRpm: mDesc->minRpm;\r\n\r\n\t\t\t\t//getNewRatioTable(beh,gDesc->forwardGearRatios,pOCurve,ratioSize);\r\n\r\n\t\t\t\t//if (!gDesc->isValid())\t\t\t\t\tbbErrorME(\"gear description was invalid, aborting update \");\r\n\t\t\t\t//gDesc->nbForwardGears =ratioSize;\r\n\t\t\t\t\r\n\t\t\t\t//v->setGears(pFactory::Instance()->createVehicleGears(*gDesc));\r\n\r\n\t\t\t\tpVehicleGears *loaded = v->getGears();\r\n\t\t\t\tif (!loaded)\r\n\t\t\t\t\tbbErrorME(\"creating of new gears failed unexpected\");\r\n\r\n\t\t\t}\r\n\t\t\t*/\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\tFlexibility : \r\n\t\t//\r\n\t\t\r\n\t\t/*\r\n\t\tif (sI_nbFGears && gears )gears->_nbForwardGears = nbGears;\r\n\t\tif (sI_BRatio && gears )gears->_backwardGearRatio;\r\n\t\tif (outputCurve && pOCurve\t)\r\n\t\t{\r\n\t\t\tint s = pOCurve->GetControlPointCount();\r\n\t\t\tfor (int i = 0 ; i < pOCurve->GetControlPointCount() ; i++)\r\n\t\t\t{\r\n\t\t\t\tCK2dCurvePoint* point = pOCurve->GetControlPoint(i);\r\n\t\t\t\tpoint->SetLinear(true);\r\n\t\t\t}\r\n\t\t\tpOCurve->Update();\r\n\t\t\tbeh->SetOutputParameterValue(0,&pOCurve);\r\n\t\t}\r\n\t\tdelete gDesc;\r\n\t\tgDesc;\r\n\t\t*/\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n#include \"vtBBHelper.h\"\r\n#include \"xDebugTools.h\"\r\n#include \"pCallbackSignature.h\"\r\n\r\n\r\nint PhysicManager::_checkListCheck()\r\n{\r\n\tint result = 0 ;\r\n\twhile(bodyListCheck.Size())\r\n\t{\t\r\n\t\tresult ++;\r\n\t\tbodyListCheck.PopBack();\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint PhysicManager::_checkRemovalList()\r\n{\r\n\r\n\tint result = 0 ; \r\n\r\n\tif (bodyListRemove.Size() < 1)\r\n\t\treturn 0;\r\n\r\n\tpWorldMapIt wit = getWorlds()->Begin();\r\n\r\n\tbool wasDeleting = false;\r\n\twhile(wit != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *wit;\r\n\t\t\r\n\t\t\tint cCount = bodyListRemove.Size();\r\n\r\n\t\t\t//for (CK3dEntity** it = bodyListRemove.Begin(); it != bodyListRemove.End(); ++it)\r\n\t\t\t//int i = 0 ; i < bodyListRemove.Size() ; i ++ )\r\n\t\t\twhile(bodyListRemove.Size())\r\n\t\t\t{\t\r\n\t\t\t\tCK_ID id = *bodyListRemove.At(0);\r\n\t\t\t\tCK3dEntity * ent = (CK3dEntity*)GetPMan()->GetContext()->GetObject(id);\r\n\t\t\t\tif(ent)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody* body = GetPMan()->getBody(ent);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"deleting body \");\r\n\t\t\t\t\t\tbody->destroy();\r\n\t\t\t\t\t\tSAFE_DELETE(body)\r\n\t\t\t\t\t\tcCount = bodyListRemove.Size();\r\n\t\t\t\t\t\tresult ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbodyListRemove.PopFront();\r\n\t\t\t}\r\n\t\twit++;\r\n\t}\r\n\t//bodyListRemove.Clear();\r\n\t//_cleanOrphanedJoints();\r\n\tif(wasDeleting)\r\n\t{\r\n\t}\r\n\t//getScene()->checkResults(NX_ALL_FINISHED,true)\r\n/*\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tw->getScene()->fetchResults(NX_ALL_FINISHED,false);\r\n\t\tit++;\r\n\t}\r\n\t*/\r\n\treturn result;\r\n}\r\n\r\n\r\nXString printSignature(BBParameter pAarray[],int size)\r\n{\r\n\r\n\tCKParameterManager *pm = GetPMan()->GetContext()->GetParameterManager();\r\n\tXString signature;\r\n\t\r\n\tfor(int i = 0 ; i < size ; i ++ )\r\n\t{\r\n\t\tBBParameter *par = &pAarray[i];\r\n\t\tsignature << \"\\t\\t Parameter :\" << par->name << \": must be type of \" << pm->ParameterGuidToName(par->guid) << \" \\n \";\r\n\t}\r\n\treturn signature;\r\n\r\n}\r\n\r\nbool isCompatible(CKParameterManager *pm,CKGUID a,CKGUID b)\r\n{\r\n\r\n\tif (a == b)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// special case custom flags or enumeration, integer is possible\r\n\t//\r\n\tif\t(\t(\tpm->GetEnumDescByType(pm->ParameterGuidToType(a)) ||\r\n\t\t\t\tpm->GetFlagsDescByType(pm->ParameterGuidToType(a)) \r\n\t\t\t) &&\r\n\t\t\tpm->IsDerivedFrom(b,CKPGUID_INT) \r\n\t\t)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nint checkInputSignature(CKBehavior *beh,BBParameter *pAarray,int size)\r\n{\r\n\r\n\tint result = true;\r\n\tint parameterCount = beh->GetInputParameterCount();\r\n\tif ( parameterCount < size)\r\n\t{\r\n\t\tresult = 0;\r\n\t}\r\n\r\n\tCKParameterManager *pm = GetPMan()->GetContext()->GetParameterManager();\r\n\tfor (int i = 0 ; i < size ; i ++)\r\n\t{\r\n\t\tCKParameterIn *inPar = beh->GetInputParameter(i);\r\n\t\tBBParameter *par = &pAarray[i];\r\n\r\n\t\tif (!isCompatible(pm,par->guid,inPar->GetGUID()))\r\n\t\t{\r\n\t\t\tresult = 0;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint checkOutputSignature(CKBehavior *beh,BBParameter *pAarray,int size)\r\n{\r\n\r\n\tint result = 1;\r\n\tint parameterCount = beh->GetOutputParameterCount();\r\n\tif ( parameterCount < size)\r\n\t{\r\n\t\tresult= 0;\r\n\t}\r\n\r\n\tCKParameterManager *pm = GetPMan()->GetContext()->GetParameterManager();\r\n\tfor (int i = 0 ; i < size ; i ++)\r\n\t{\r\n\t\tCKParameterOut *inPar = beh->GetOutputParameter(i);\r\n\t\tBBParameter *par = &pAarray[i];\r\n\r\n\t\tif (!isCompatible(pm,par->guid,inPar->GetGUID()))\r\n\t\t{\r\n\t\t\tresult= 0;\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\treturn result;\r\n}\r\n\r\nbool PhysicManager::checkCallbackSignature(CKBehavior *beh,int type,XString& errMessage)\r\n{\r\n\r\n\tif (!beh)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\tCKParameterManager *pm = GetPMan()->GetContext()->GetParameterManager();\r\n\r\n\tint parameterCount = beh->GetInputParameterCount();\r\n\tswitch(type)\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions notify\r\n\t\t//\r\n\t\tcase CB_OnContactNotify:\r\n\t\t{\r\n\t\t\terrMessage.Format(\"\\n\\t Input parameters for collisions notify must have this signature : \\n\"); \r\n\t\t\tif ( parameterCount < BB_PMAP_SIZE(pInMapContactCallback))\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pInMapContactCallback,BB_PMAP_SIZE(pInMapContactCallback) );\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tfor (int i = 0 ; i < BB_PMAP_SIZE(pInMapContactCallback) ; i ++)\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *inPar = beh->GetInputParameter(i);\r\n\t\t\t\tBBParameter *par = &pInMapContactCallback[i];\r\n\t\t\t\t\r\n\t\t\t\tif (!isCompatible(pm,par->guid,inPar->GetGUID()))\r\n\t\t\t\t{\r\n\t\t\t\t\terrMessage << printSignature(pInMapContactCallback,BB_PMAP_SIZE(pInMapContactCallback) );\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// wheel contact modify\r\n\t\t//\r\n\t\tcase CB_OnWheelContactModify:\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// check input parameters\r\n\t\t\t\t//\r\n\t\t\t\tbool result = true;\r\n\t\t\t\terrMessage.Format(\"\\n\\t Input parameters for wheel contact modification must have this signature : \\n\"); \r\n\t\t\t\tint ok = checkInputSignature(beh,pInMapWheelContactModifyCallback,BB_PMAP_SIZE(pInMapWheelContactModifyCallback));\r\n\t\t\t\tif ( !ok )\r\n\t\t\t\t{\r\n\t\t\t\t\terrMessage << printSignature(pInMapWheelContactModifyCallback,BB_PMAP_SIZE(pInMapWheelContactModifyCallback) );\r\n\t\t\t\t\tresult =false;\r\n\t\t\t\t}\r\n\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// check output parameters\r\n\t\t\t\t//\r\n\t\t\t\terrMessage.Format(\"\\n\\t Input parameters for wheel contact modification must have this signature : \\n\"); \r\n\t\t\t\tok = checkOutputSignature(beh,pOutMapWheelContactModifyCallback,BB_PMAP_SIZE(pOutMapWheelContactModifyCallback));\r\n\t\t\t\tif (!ok)\r\n\t\t\t\t{\r\n\t\t\t\t\terrMessage << printSignature(pOutMapWheelContactModifyCallback,BB_PMAP_SIZE(pOutMapWheelContactModifyCallback) );\r\n\t\t\t\t\tresult = false;\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions notify\r\n\t\t//\r\n\t\tcase CB_OnRayCastHit:\r\n\t\t{\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// check input parameters\r\n\t\t\t//\r\n\t\t\terrMessage.Format(\"\\n\\t Input parameters for raycast hit report must have this signature : \\n\"); \r\n\t\t\tint ok = checkInputSignature(beh,pInMapRaycastHitCallback,BB_PMAP_SIZE(pInMapRaycastHitCallback));\r\n\t\t\tif ( !ok )\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pInMapRaycastHitCallback,BB_PMAP_SIZE(pInMapRaycastHitCallback));\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions notify\r\n\t\t//\r\n\t\tcase CB_OnContactModify:\r\n\t\t{\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// check input parameters\r\n\t\t\t//\r\n\t\t\tbool result = true;\r\n\t\t\terrMessage.Format(\"\\n\\t Input parameters for contact modification must have this signature : \\n\"); \r\n\t\t\tint ok = checkInputSignature(beh,pInMapContactModifyCallback,BB_PMAP_SIZE(pInMapContactModifyCallback));\r\n\t\t\tif ( !ok )\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pInMapContactModifyCallback,BB_PMAP_SIZE(pInMapContactModifyCallback) );\r\n\t\t\t\tresult =false;\r\n\t\t\t}\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// check output parameters\r\n\t\t\t//\r\n\t\t\terrMessage.Format(\"\\n\\t Output parameters for contact modification must have this signature : \\n\"); \r\n\t\t\tok = checkOutputSignature(beh,pOutMapContactModifyCallback,BB_PMAP_SIZE(pOutMapContactModifyCallback));\r\n\t\t\tif (!ok)\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pOutMapContactModifyCallback,BB_PMAP_SIZE(pOutMapContactModifyCallback) );\r\n\t\t\t\tresult = false;\r\n\t\t\t}\r\n\t\t\treturn result;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// trigger\r\n\t\t//\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Collisions notify\r\n\t\t//\r\n\t\tcase CB_OnTrigger:\r\n\t\t{\r\n\t\t\terrMessage.Format(\"\\n\\t Input parameters for trigger notify must have this signature : \\n\"); \r\n\t\t\tif ( parameterCount < BB_PMAP_SIZE(pInMapTriggerCallback))\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pInMapTriggerCallback,BB_PMAP_SIZE(pInMapTriggerCallback) );\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tfor (int i = 0 ; i < BB_PMAP_SIZE(pInMapTriggerCallback) ; i ++)\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *inPar = beh->GetInputParameter(i);\r\n\t\t\t\tBBParameter *par = &pInMapTriggerCallback[i];\r\n\r\n\t\t\t\tif (!isCompatible(pm,par->guid,inPar->GetGUID()))\r\n\t\t\t\t{\r\n\t\t\t\t\terrMessage << printSignature(pInMapTriggerCallback,BB_PMAP_SIZE(pInMapTriggerCallback) );\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Joint Break Script\r\n\t\t//\r\n\t\tcase CB_OnJointBreak:\r\n\t\t{\r\n\t\t\terrMessage.Format(\"\\n\\t Input parameters for joint breaks must have this signature : \\n\"); \r\n\t\t\tif ( parameterCount < BB_PMAP_SIZE(pInMapJointBreakCallback))\r\n\t\t\t{\r\n\t\t\t\terrMessage << printSignature(pInMapJointBreakCallback,BB_PMAP_SIZE(pInMapJointBreakCallback) );\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\tfor (int i = 0 ; i < BB_PMAP_SIZE(pInMapJointBreakCallback) ; i ++)\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *inPar = beh->GetInputParameter(i);\r\n\t\t\t\tBBParameter *par = &pInMapJointBreakCallback[i];\r\n\r\n\t\t\t\tif (!isCompatible(pm,par->guid,inPar->GetGUID()))\r\n\t\t\t\t{\r\n\t\t\t\t\terrMessage << printSignature(pInMapJointBreakCallback,BB_PMAP_SIZE(pInMapJointBreakCallback) );\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t}\r\n\treturn false;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n\r\n\r\nPhysicManager *ourMan = NULL;\r\n\r\nCKGUID GetPhysicManagerGUID() { \treturn GUID_MODULE_MANAGER;}\r\n\r\ntypedef ForceMode PForceMode;\r\ntypedef D6MotionMode PJMotion;\r\ntypedef D6DriveType PDriveType;\r\ntypedef int BodyLockFlags;\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#define TESTGUID CKGUID(0x2c5c47f6,0x1d0755d9)\r\n\r\n\r\nvoid PhysicManager::_RegisterVSLRigidBody()\r\n{\r\n\r\n\t\t\r\n\t\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\n\r\n\r\nPhysicManager*GetPhysicManager()\r\n{\r\n\treturn GetPMan();\r\n}\r\n\r\n/*\r\nvoid __newvtWorldSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pWorldSettings();\r\n}\r\nvoid __newvtSleepingSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pSleepingSettings();\r\n}\r\nvoid __newvtJointSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pJointSettings();\r\n}\r\n\r\n\r\nint TestWS(pWorldSettings pWS)\r\n{\r\nVxVector grav = pWS.Gravity();\r\nreturn 2;\r\n}\r\n\r\npFactory* GetPFactory();\r\n\r\n\r\npFactory* GetPFactory()\r\n{\r\nreturn pFactory::Instance();\r\n}\r\n\r\n\r\nextern pRigidBody*getBody(CK3dEntity*ent);\r\n*/#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"tinyxml.h\"\r\n\r\n\r\npVehicle *pFactory::createVehicle(CK3dEntity *body,pVehicleDesc descr)\r\n{\r\n\r\n\tpVehicle *result =NULL;\r\n\r\n\tif (!body)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpRigidBody *rBody = GetPMan()->getBody(body);\r\n\r\n\tif (!rBody)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif (rBody->getVehicle())\r\n\t{\r\n\t\treturn rBody->getVehicle();\r\n\t}\r\n\t\r\n\tdescr.body = rBody;\r\n\tresult = new pVehicle(descr,body);\r\n\tresult->_vehicleMotor = NULL;\r\n\tresult->_vehicleGears = NULL;\r\n\tresult->setProcessOptions(descr.processFlags);\r\n\r\n\tresult->setActor(rBody->getActor());\r\n\trBody->setVehicle(result);\r\n\tresult->setMaxSteering(descr.steeringMaxAngle);\r\n\tresult->initWheels(0);\r\n\tresult->initEngine(0);\r\n\r\n\t\r\n\t//result->control(0, true, 0, true, false);\r\n\t//result->control(0, true, 0, true, false);\r\n\treturn result;\r\n \r\n}\r\n\r\n\r\n\r\npVehicleGears* pFactory::createVehicleGears(pVehicleGearDesc descr)\r\n{\r\n\r\n\tif (!descr.isValid())\r\n\t\treturn NULL;\r\n\tpVehicleGears *gears = new pVehicleGears();\r\n\tNxI32 nbForwardGears = gears->_nbForwardGears = descr.nbForwardGears;\r\n\t\r\n\tmemcpy(gears->_forwardGearRatios, descr.forwardGearRatios, sizeof(NxF32) * nbForwardGears);\r\n\tmemcpy(gears->_forwardGears, descr.forwardGears, sizeof(pLinearInterpolation) * nbForwardGears);\r\n\t\r\n\tgears->_curGear = 1;\r\n\r\n\t//gears->_backwardGear = gearDesc.backwardGear;\r\n\tgears->_backwardGearRatio = descr.backwardGearRatio;\r\n\r\n\treturn gears;\r\n\r\n}\r\n\r\npVehicleMotor* pFactory::createVehicleMotor(pVehicleMotorDesc descr)\r\n{\r\n\r\n\tif (!descr.isValid())\r\n\t\treturn NULL;\r\n\tpVehicleMotor* motor = new pVehicleMotor();\r\n\tmotor->_torqueCurve = descr.torqueCurve;\r\n\tNxReal maxTorque = 0;\r\n\tNxI32 maxTorquePos = -1;\r\n\tfor (NxU32 i = 0; i < motor->_torqueCurve.getSize(); i++) {\r\n\t\tNxReal v = motor->_torqueCurve.getValueAtIndex(i);\r\n\t\tif (v > maxTorque) {\r\n\t\t\tmaxTorque = v;\r\n\t\t\tmaxTorquePos = i;\r\n\t\t}\r\n\t}\r\n\tmotor->_maxTorque\t\t\t= maxTorque;\r\n\tmotor->_maxTorquePos\t\t= (float)maxTorquePos;\r\n\tmotor->_maxRpmToGearUp\t\t= descr.maxRpmToGearUp;\r\n\tmotor->_minRpmToGearDown\t= descr.minRpmToGearDown;\r\n\tmotor->_maxRpm\t\t\t\t= descr.maxRpm;\r\n\tmotor->_minRpm\t\t\t\t= descr.minRpm;\r\n\r\n\tmotor->_rpm = 0.0f;\r\n\r\n\treturn motor;\r\n\r\n}\r\n\r\nXString pFactory::_getVehicleWheelAsEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\tif (!doc)\r\n\t{\r\n\t\treturn XString(\"\");\r\n\t}\r\n\r\n\tXString result(\"None=0\");\r\n\tint counter = 1;\r\n\r\n\t\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif ( doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\t\t\t\tif (!strcmp(child->Value(), \"wheel\" ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)child;\r\n\r\n\t\t\t\t\tconst char* vSName = NULL;\r\n\t\t\t\t\tvSName = sube->Attribute(\"name\");\r\n\t\t\t\t\tif (vSName && strlen(vSName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (result.Length())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresult << vSName;\r\n\t\t\t\t\t\tresult << \"=\" << counter;\r\n\t\t\t\t\t\tcounter ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\nXString pFactory::_getVehicleSettingsAsEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\tif (!doc)\r\n\t{\r\n\t\treturn XString(\"\");\r\n\t}\r\n\r\n\tXString result(\"None=0\");\r\n\tint counter = 1;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif ( doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\t\t\t\tif (!strcmp(child->Value(), \"vehicle\" ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)child;\r\n\r\n\t\t\t\t\tconst char* vSName = NULL;\r\n\t\t\t\t\tvSName = sube->Attribute(\"name\");\r\n\t\t\t\t\tif (vSName && strlen(vSName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (result.Length())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresult << vSName;\r\n\t\t\t\t\t\tresult << \"=\" << counter;\r\n\t\t\t\t\t\tcounter ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"ToolManager.h\"\r\n\r\nvoid ToolManager::RegisterVSL()\r\n{\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\npFluidEmitterDesc::pFluidEmitterDesc()\r\n{\r\n\tsetToDefault();\r\n}\r\n\r\npFluidEmitterDesc::~pFluidEmitterDesc()\r\n{\r\n}\r\n\r\nvoid pFluidEmitterDesc::setToDefault()\r\n{\r\n\tframeShape\t\t\t\t\t\t= NULL;\r\n\ttype\t\t\t\t\t\t\t= (pEmitterType)(NX_FE_CONSTANT_PRESSURE);\r\n\tmaxParticles\t\t\t\t\t= 0;\r\n\tshape\t\t\t\t\t\t\t= (pEmitterShape)(NX_FE_RECTANGULAR);\r\n\tdimensionX\t\t\t\t\t\t= 0.25f;\r\n\tdimensionY\t\t\t\t\t\t= 0.25f;\r\n\trandomAngle\t\t\t\t\t\t= 0.0f;\r\n\trandomPos = VxVector(0,0,0);\r\n\tfluidVelocityMagnitude\t\t\t= 1.0f;\r\n\trate\t\t\t\t\t\t\t= 100.0f;\r\n\tparticleLifetime\t\t\t\t= 0.0f;\r\n\trepulsionCoefficient\t\t\t= 1.0f;\r\n\tflags\t\t\t\t\t\t\t= (pFluidEmitterFlag)(NX_FEF_ENABLED|NX_FEF_VISUALIZATION|NX_FEF_ADD_BODY_VELOCITY);\r\n}\r\n\r\nbool pFluidEmitterDesc::isValid() const\r\n{\r\n\r\n\tif (dimensionX < 0.0f) return false;\r\n\tif (dimensionY < 0.0f) return false;\r\n\r\n\tif (randomPos.x < 0.0f) return false;\r\n\tif (randomPos.y < 0.0f) return false;\r\n\tif (randomPos.z < 0.0f) return false;\r\n\tif (randomAngle < 0.0f) return false;\r\n\r\n\tif (!(((shape & NX_FE_ELLIPSE) > 0) ^ ((shape & NX_FE_RECTANGULAR) > 0))) return false;\r\n\tif (!(((type & NX_FE_CONSTANT_FLOW_RATE) > 0) ^ ((type & NX_FE_CONSTANT_PRESSURE) > 0))) return false;\r\n\r\n\tif (rate < 0.0f) return false;\r\n\tif (fluidVelocityMagnitude < 0.0f) return false;\r\n\tif (particleLifetime < 0.0f) return false;\r\n\tif (repulsionCoefficient < 0.0f) return false;\r\n\r\n\treturn true;\r\n}\r\n#endif#define STRICT\r\n#define DIRECTINPUT_VERSION 0x0800\r\n\r\n#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }\r\n#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }\r\n#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\nstatic CKContext *ctx = NULL;\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// \r\n//\r\n#define HAS_CONFIG\r\n\r\n#ifdef HAS_CONFIG\r\n#include \"gConfig.h\"\r\n#endif // BB_TOOLS\r\n\r\n#ifdef BB_TOOLS\r\n\t\r\n\t#include \r\n\t#include \"vtLogTools.h\"\r\n\t#include \"vtCBBErrorHelper.h\"\r\n\t#include \r\n\t#include \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n#endif\r\n\r\n//-----------------------------------------------------------------------------\r\n// Defines, constants, and global variables\r\n//-----------------------------------------------------------------------------\r\nstruct EFFECTS_NODE\r\n{\r\n LPDIRECTINPUTEFFECT pDIEffect;\r\n DWORD dwPlayRepeatCount;\r\n EFFECTS_NODE* pNext;\r\n};\r\n\r\nLPDIRECTINPUT8 g_pDI = NULL; \r\nLPDIRECTINPUTDEVICE8 g_pFFDevice = NULL;\r\nEFFECTS_NODE g_EffectsList;\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Function-prototypes\r\n//-----------------------------------------------------------------------------\r\nINT_PTR CALLBACK MainDialogProc( HWND, UINT, WPARAM, LPARAM );\r\nBOOL CALLBACK EnumFFDevicesCallback( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef );\r\nBOOL CALLBACK EnumAndCreateEffectsCallback( LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef );\r\n\r\nHRESULT InitDirectInput( HWND hDlg );\r\nHRESULT FreeDirectInput2();\r\nVOID EmptyEffectList();\r\nHRESULT OnReadFile( HWND hDlg,const char*file);\r\nHRESULT OnPlayEffects2( HWND hDlg );\r\n\r\nHRESULT InitDirectInput( HWND hDlg )\r\n{\r\n HRESULT hr;\r\n\r\n // Setup the g_EffectsList circular linked list\r\n ZeroMemory( &g_EffectsList, sizeof( EFFECTS_NODE ) );\r\n g_EffectsList.pNext = &g_EffectsList;\r\n\r\n // Create a DInput object\r\n if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )\r\n\t{\r\n\t\tctx->OutputToConsole(\"PlayFFE :: DirectInput8Create\");\r\n\t return hr;\r\n\t}\r\n\r\n // Get the first enumerated force feedback device\r\n if( FAILED( hr = g_pDI->EnumDevices( 0, EnumFFDevicesCallback, 0, \r\n DIEDFL_ATTACHEDONLY | \r\n DIEDFL_FORCEFEEDBACK ) ) )\r\n\t{\r\n\t\tctx->OutputToConsole(\"PlayFFE :: EnumDevices failed\");\t\t\r\n\t\treturn hr;\r\n\t}\r\n\r\n \r\n if( g_pFFDevice == NULL )\r\n {\r\n\r\n\t ctx->OutputToConsole(\"PlayFFE :: No force feedback device found.\");\r\n return -1;\r\n }\r\n\r\n\r\n // Set the data format\r\n if( FAILED( hr = g_pFFDevice->SetDataFormat( &c_dfDIJoystick ) ) )\r\n return hr;\r\n\r\n\r\n // Set the coop level\r\n hr = g_pFFDevice->SetCooperativeLevel( hDlg , DISCL_EXCLUSIVE | DISCL_FOREGROUND) ;\r\n\r\n\r\n\r\n // Disable auto-centering spring\r\n DIPROPDWORD dipdw;\r\n dipdw.diph.dwSize = sizeof(DIPROPDWORD);\r\n dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);\r\n dipdw.diph.dwObj = 0;\r\n dipdw.diph.dwHow = DIPH_DEVICE;\r\n dipdw.dwData = FALSE;\r\n\r\n\r\n\r\n if( FAILED( hr = g_pFFDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph ) ) )\r\n return hr;\r\n\r\n // Acquire the device\r\n if( FAILED( hr = g_pFFDevice->Acquire() ) )\r\n return hr;\r\n\r\n\r\n\tint op = 2;\r\n\t\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EnumFFDevicesCallback()\r\n// Desc: Get the first enumerated force feedback device\r\n//-----------------------------------------------------------------------------\r\nBOOL CALLBACK EnumFFDevicesCallback( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef )\r\n{\r\n if( FAILED( g_pDI->CreateDevice( pDDI->guidInstance, &g_pFFDevice, NULL ) ) )\r\n return DIENUM_CONTINUE; // If failed, try again\r\n\r\n // Stop when a device was successfully found\r\n return DIENUM_STOP;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: FreeDirectInput2()\r\n// Desc: Initialize the DirectInput variables.\r\n//-----------------------------------------------------------------------------\r\nHRESULT FreeDirectInput2()\r\n{\r\n // Release any DirectInputEffect objects.\r\n if( g_pFFDevice ) \r\n {\r\n EmptyEffectList();\r\n g_pFFDevice->Unacquire();\r\n SAFE_RELEASE( g_pFFDevice );\r\n }\r\n\r\n // Release any DirectInput objects.\r\n SAFE_RELEASE( g_pDI );\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EmptyEffectList()\r\n// Desc: Goes through the circular linked list and releases the effects, \r\n// and deletes the nodes\r\n//-----------------------------------------------------------------------------\r\nVOID EmptyEffectList()\r\n{\r\n EFFECTS_NODE* pEffectNode = g_EffectsList.pNext;\r\n EFFECTS_NODE* pEffectDelete;\r\n\r\n while ( pEffectNode != &g_EffectsList )\r\n {\r\n pEffectDelete = pEffectNode; \r\n pEffectNode = pEffectNode->pNext;\r\n\r\n SAFE_RELEASE( pEffectDelete->pDIEffect );\r\n SAFE_DELETE( pEffectDelete );\r\n }\r\n\r\n g_EffectsList.pNext = &g_EffectsList;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: OnReadFile()\r\n// Desc: Reads a file contain a collection of DirectInput force feedback \r\n// effects. It creates each of effect read in and stores it \r\n// in the linked list, g_EffectsList.\r\n//-----------------------------------------------------------------------------\r\nHRESULT OnReadFile( HWND hDlg,const char*file)\r\n{\r\n HRESULT hr;\r\n\r\n EmptyEffectList();\r\n\r\n // Enumerate the effects in the file selected, and create them in the callback\r\n if( FAILED( hr = g_pFFDevice->EnumEffectsInFile( file,EnumAndCreateEffectsCallback, \r\n NULL, DIFEF_MODIFYIFNEEDED ) ) )\r\n return hr;\r\n\r\n // If list of effects is empty, then we haven't been able to create any effects\r\n if( g_EffectsList.pNext == &g_EffectsList )\r\n {\r\n\t\tctx->OutputToConsole(\"Unable to create any effects.\");\r\n\r\n }\r\n else\r\n {\r\n // We have effects so enable the 'play effects' button\r\n\r\n }\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: EnumAndCreateEffectsCallback()\r\n// Desc: Create the effects as they are enumerated and add them to the \r\n// linked list, g_EffectsList\r\n//-----------------------------------------------------------------------------\r\nBOOL CALLBACK EnumAndCreateEffectsCallback(LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef )\r\n{ \r\n HRESULT hr;\r\n LPDIRECTINPUTEFFECT pDIEffect = NULL;\r\n\r\n // Create the file effect\r\n if( FAILED( hr = g_pFFDevice->CreateEffect( pDIFileEffect->GuidEffect, \r\n pDIFileEffect->lpDiEffect, \r\n &pDIEffect, NULL ) ) )\r\n {\r\n ctx->OutputToConsole(\"Could not create force feedback effect on this device\");\r\n return DIENUM_CONTINUE;\r\n }\r\n\r\n // Create a new effect node\r\n EFFECTS_NODE* pEffectNode = new EFFECTS_NODE;\r\n if( NULL == pEffectNode )\r\n return DIENUM_STOP;\r\n\r\n // Fill the pEffectNode up\r\n ZeroMemory( pEffectNode, sizeof( EFFECTS_NODE ) );\r\n pEffectNode->pDIEffect = pDIEffect;\r\n pEffectNode->dwPlayRepeatCount = 1;\r\n\r\n // Add pEffectNode to the circular linked list, g_EffectsList\r\n pEffectNode->pNext = g_EffectsList.pNext;\r\n g_EffectsList.pNext = pEffectNode;\r\n\r\n return DIENUM_CONTINUE;\r\n}\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: OnPlayEffects2()\r\n// Desc: Plays all of the effects enumerated in the file \r\n//-----------------------------------------------------------------------------\r\nHRESULT OnPlayEffects2( HWND hDlg )\r\n{\r\n EFFECTS_NODE* pEffectNode = g_EffectsList.pNext;\r\n LPDIRECTINPUTEFFECT pDIEffect = NULL;\r\n HRESULT hr;\r\n\r\n // Stop all previous forces\r\n if( FAILED( hr = g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL ) ) )\r\n return hr;\r\n\r\n\t\r\n while ( pEffectNode != &g_EffectsList )\r\n {\r\n // Play all of the effects enumerated in the file \r\n pDIEffect = pEffectNode->pDIEffect;\r\n\r\n if( NULL != pDIEffect )\r\n {\r\n if( FAILED( hr = pDIEffect->Start( pEffectNode->dwPlayRepeatCount, 0 ) ) )\r\n return hr;\r\n }\r\n\r\n pEffectNode = pEffectNode->pNext;\r\n }\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPlayFFEffectDecl();\r\nCKERROR CreatePlayFFEffectProto(CKBehaviorPrototype **);\r\nint PlayFFEffect(const CKBehaviorContext& behcontext);\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPlayFFEffectDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PlayFFEffect\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x54397475,0x4ca43e26));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePlayFFEffectProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Joystick\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreatePlayFFEffectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"PlayFFEffect\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"Init\");\r\n\tproto->DeclareInput(\"play\");\r\n\tproto->DeclareInput(\"stop\");\r\n\tproto->DeclareInput(\"release device\");\r\n\t\r\n\r\n\tproto->DeclareOutput(\"initiated\");\r\n\tproto->DeclareOutput(\"play exit\");\r\n\tproto->DeclareOutput(\"stopped\");\r\n\tproto->DeclareOutput(\"released\");\r\n\r\n\tproto->DeclareOutput(\"error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"effect file\",CKPGUID_STRING);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( PlayFFEffect );\r\n\r\n\tproto->SetBehaviorCallbackFct(PlayFFECallBackObject);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint PlayFFEffect(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx2 = behcontext.Context;\r\n\tctx = ctx2;\r\n\r\n\r\n\r\n\tHWND mWin = (HWND )ctx->GetMainWindow();\r\n\r\n\t//init and load effect\r\n\tif( beh->IsInputActive(0) ){\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\tHRESULT result = InitDirectInput(mWin);\r\n\t\tHRESULT sa = S_OK;\r\n\t\tif (InitDirectInput(mWin) == S_OK)\r\n\t\t{\r\n\r\n\t\t\tXString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\tOnReadFile(mWin,filename.Str());\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}else{\r\n\t\t\tbeh->ActivateOutput(4);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\n\r\n\t//play\r\n\r\n\tif( beh->IsInputActive(1) ){\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\t\t\r\n\t\t\r\n\t\tif (OnPlayEffects2(NULL) != S_OK ){\r\n\t\t\tbeh->ActivateOutput(4);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\r\n\t//stop the effect\r\n\tif( beh->IsInputActive(2) ){\r\n\t\tbeh->ActivateInput(2,FALSE);\r\n\r\n\t // Stop all previous forces\r\n\t\tg_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\tbeh->ActivateOutput(2);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\r\n\t// [11/7/2004]\r\n\t//save device release\r\n\r\n\tif( beh->IsInputActive(3) ){\r\n\t\tbeh->ActivateInput(3,FALSE);\r\n\r\n\r\n\r\n\t\tif ( g_pFFDevice)\r\n\t\t\tg_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\t\t\r\n\t\tFreeDirectInput2();\r\n\t\tbeh->ActivateOutput(3);\r\n\t\treturn CKBR_OK;\r\n\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\nCKERROR PlayFFECallBackObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORDETACH:\r\n\tcase CKM_BEHAVIORRESET:\r\n\t{\r\n\t\t\r\n\t\t\r\n\t\t\tif ( g_pFFDevice)\r\n\t\t\t\tg_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );\r\n\t\t\tFreeDirectInput2();\r\n\t\t\t//Sleep(2000);\r\n\t\t\t\r\n\r\n\t}\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn CKBR_OK; \r\n}\r\n#include \"StdAfx.h\"\r\n#include \r\n#include \"InitMan.h\"\r\n\r\nextern vt_python_man *pym;\r\n\r\nint pModId = 0;\r\n\r\n\r\nPythonModule*\r\nPythonModule::GetPythonModule(int id)\r\n{\r\n\r\n\t\tVSLPModulesIt it = pym->GetVSLPModules().find(id);\r\n\t\tif(it != pym->GetVSLPModules().end() )\r\n\t\t{\r\n\t\t\treturn it->second;\r\n\t\t}else\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t\r\n\treturn NULL;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nPythonModule::PythonModule(const char*file,const char*func,int bid) : m_File(file) , m_Func(func) , m_BehaviourID(bid)\r\n{\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nPythonModule*\r\nPythonModule::CreatePythonModule(const char*file,const char*func,int bid)\r\n{\r\n\r\n\t\r\n\tPythonModule *pmod = new PythonModule(file,func,bid);\r\n\tint targetID = -1;\r\n\r\n \r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//its used in schematic ? \r\n\t\r\n\tCKBehavior *script = static_cast(pym->m_Context->GetObject(bid));\r\n\tif (script)\r\n\t{\r\n\t\ttargetID = bid;\r\n\t\t\r\n\t\t//PyObject* val = PyInt_FromLong(bid);\r\n\t\t//PyObject_SetAttrString( module , \"bid\", val);\r\n\t}else\r\n\t{\r\n\r\n\t}\r\n\t\r\n\tpym->InsertPVSLModule(pmod);\r\n\treturn pmod;\r\n\r\n}\r\n\r\n#ifndef __VT_BB_HELPER_H__\r\n\t#define __VT_BB_HELPER_H__\r\n\r\n#include \r\n\r\nnamespace vtTools\r\n{\r\n\r\n\tnamespace BehaviorTools\r\n\t{\r\n\r\n\t\tstruct BBParameter\r\n\t\t{\r\n\t\t\tint ID; \tCKGUID guid;\t\tXString name;\tXString defaultValue;\tint condition;\tint settingsID; int inputIndex;\r\n\t\t\tCKObject *par;\r\n\t\t\tbool fixed;\r\n\t\t\tBBParameter()\r\n\t\t\t{\r\n\t\t\t\tcondition = -1; \t\tID = 0;\t\tguid = CKGUID(0,0);\t\tname = \"\";\t\tdefaultValue = \"\"; settingsID = -1;\t\tpar = NULL;\r\n\t\t\t\tinputIndex= -1;\r\n\t\t\t\tfixed = false;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tBBParameter(int _ID,CKGUID _guid,XString _name,XString _defaultValue) : \r\n\t\t\tID(_ID), guid(_guid) , name(_name) , defaultValue(_defaultValue)\r\n\t\t\t{\r\n\t\t\t\tcondition = -1;\r\n\t\t\t\tsettingsID = 0;\r\n\t\t\t\tpar = NULL;\r\n\t\t\t\tinputIndex= -1;\r\n\t\t\t\tfixed = false;\r\n\t\t\t}\r\n\r\n\t\t\tBBParameter(int _ID,bool _fixed,CKGUID _guid,XString _name,XString _defaultValue,int _condition) : \r\n\t\t\tID(_ID), guid(_guid) , name(_name) , defaultValue(_defaultValue)\r\n\t\t\t{\r\n\t\t\t\tcondition = _condition;\r\n\t\t\t\tsettingsID = 0;\r\n\t\t\t\tpar = NULL;\r\n\t\t\t\tinputIndex= -1;\r\n\t\t\t\tfixed = _fixed;\r\n\t\t\t}\r\n\r\n\t\t\tBBParameter(int _ID,CKGUID _guid,XString _name,XString _defaultValue,int _condition) : \r\n\t\t\tID(_ID), guid(_guid) , name(_name) , defaultValue(_defaultValue), condition(_condition)\r\n\t\t\t{\r\n\t\t\t\tsettingsID = 0;\r\n\t\t\t\tpar = NULL;\r\n\t\t\t\tinputIndex= -1;\r\n\t\t\t\tfixed = false;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\r\n\t\tclass BBParArray\r\n\t\t{\r\n\r\n\t\tpublic : \r\n\t\t\tBBParArray() : isDuplicat(false) , isLoaded(false) , states(0){} \r\n\t\t\tstd::vectorpars;\r\n\r\n\t\t\tstd::vector&getArray()\r\n\t\t\t{\r\n\t\t\t\treturn pars;\r\n\t\t\t}\r\n\t\t\tbool isDuplicat;\r\n\t\t\tbool isLoaded;\r\n\t\t\tint states;\r\n\t\t\tint bbId;\r\n\r\n\r\n\t\t\tenum {\r\n BBArrayIsLoaded=1,\r\n\t\t\t\tBBArrayIsInitiated=2\r\n\t\t\t};\r\n\t\t};\r\n\r\n\t\tclass BBPOHelper\r\n\t\t{\r\n\r\n\t\tpublic :\r\n\r\n\t\t\tstatic int getIndex(CKBehavior *beh,BBParameter *par)\r\n\t\t\t{\r\n\t\t\t\tif (!par)return -1;\r\n\t\t\t\tif (par && !par->par )return -1;\r\n\r\n\t\t\t\tfor (int i = 0 ; i< beh->GetOutputParameterCount() ; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (par->par == beh->GetOutputParameter(i)) return i;\r\n\t\t\t\t}\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\tstatic void remapIndex(CKBehavior *beh,BBParArray *pAarray,int size )\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *p=pAarray->getArray().at(i);\r\n\t\t\t\t\tp->inputIndex = p->par !=NULL ? getIndex(beh,p) : -1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tstatic int getIndex(CKBehavior *beh,BBParArray *pAarray,int indicator )\r\n\t\t\t{\r\n\r\n#ifdef _DEBUG\r\n\t\t\t\tassert(beh);\r\n\t\t\t\tassert(pAarray);\r\n#endif\r\n\t\t\t\treturn pAarray->getArray().at(indicator)->inputIndex;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tstatic int getIndexInv(CKBehavior *beh,BBParameter pInMap[],int indicator )\r\n\t\t\t{\r\n\r\n#ifdef _DEBUG\r\n\t\t\t\tassert(beh);\r\n#endif\r\n\r\n\t\t\t\tfor ( int i = 0 ; i < beh->GetOutputParameterCount() ; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!strcmp(beh->GetOutputParameter(i)->GetName(),pInMap[indicator].name.Str() ))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn i;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\tstatic void loadPOMap(CKBehavior *beh,BBParArray *dst,BBParameter pInMap[],int size,int start)\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *p=new BBParameter(pInMap[i].ID,pInMap[i].guid,pInMap[i].name,pInMap[i].defaultValue,pInMap[i].condition);\r\n\t\t\t\t\tdst->getArray().push_back(p);\r\n\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter(start + i );\t\r\n\t\t\t\t\tint v=0 ; \r\n\t\t\t\t\tlp->GetValue(&p->condition);\r\n\t\t\t\t\tif (p->condition)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint index = getIndexInv(beh,pInMap,i);\r\n\t\t\t\t\t\tp->par = ((CKObject*)beh->GetOutputParameter(index));\r\n\t\t\t\t\t\tp->condition = 1;\r\n\t\t\t\t\t\tp->inputIndex = index;\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tp->par = NULL;\r\n\t\t\t\t\t\tp->condition=-1;\r\n\t\t\t\t\t\tp->inputIndex = -1;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdst->isLoaded=true;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tstatic void printPOMap(CKBehavior *beh,BBParArray *dst,BBParameter pInMap[],int size,int start)\r\n\t\t\t{\r\n\t\t\t\tXString header;\r\n\t\t\t\tif (dst->isLoaded)\r\n\t\t\t\t{\r\n\t\t\t\t\theader << \"IsLoaded:\" << \"TRUE\";\r\n\t\t\t\t}\r\n\r\n\t\t\t\theader << \"|Size:\" << dst->getArray().size();\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,header.Str());\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *par = dst->getArray().at( i );\r\n\r\n\t\t\t\t\tXString o;\r\n\t\t\t\t\to << par->name << \" : iIndex\" << par->inputIndex << \" | cond:\" << par->condition;\r\n\t\t\t\t\tif (par->par !=NULL)\r\n\t\t\t\t\t{\r\n o << \"| Par=1\";\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,o.Str());\r\n\r\n\t\t\t\t}\r\n\t\t\t\r\n\r\n\t\t\t}\r\n\r\n\t\t\tstatic void initPMap(CKBehavior *beh,BBParArray *dst,BBParameter pInMap[],int size,int start)\r\n\t\t\t{\r\n\t\t\t\tif (dst==NULL)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"No Array supplied\");\r\n\r\n\t\t\t\t}\r\n\t\t\t\r\n\t\t\t\tif (dst->isLoaded)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tBBParameter *p=new BBParameter(pInMap[i].ID,pInMap[i].guid,pInMap[i].name,pInMap[i].defaultValue,pInMap[i].condition);\r\n\t\t\t\t\tdst->getArray().push_back(p);\r\n\t\t\t\t\tif (pInMap[i].condition ==1 )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter(start + i );\tlp->SetValue(&pInMap[i].condition);\r\n\t\t\t\t\t\tp->par = (CKObject*)beh->CreateOutputParameter(pInMap[i].name.Str(),pInMap[i].guid);\r\n\t\t\t\t\t\tint index = getIndex(beh,p);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tBBPOHelper::remapIndex(beh,dst,size);\r\n\t\t\t}\r\n\r\n\t\t\tstatic void remapArray(CKBehavior *beh,BBParArray *pArray,int size,int settingStartIndex)\r\n\t\t\t{\r\n\t\t\t\tfor (int sI = settingStartIndex; sI < size + settingStartIndex; sI ++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter(sI ); int val = 0;\t\tlp->GetValue(&val);\r\n\t\t\t\t\tBBParameter *par = pArray->getArray().at( sI - settingStartIndex);\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t// Settings ON : \r\n\t\t\t\t\tif (val)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( par->par == NULL )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpar->condition = 1;\r\n\t\t\t\t\t\t\tpar->par = (CKObject*)beh->CreateOutputParameter(par->name.Str(),par->guid);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t// Settings ON : \r\n\t\t\t\t\tif (!val)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( par->par )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tCKDestroyObject(par->par);\r\n\t\t\t\t\t\t\tpar->par = NULL;\r\n\t\t\t\t\t\t\tpar->condition = -1;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tremapIndex(beh,pArray,size);\r\n\t\t\t}\r\n\r\n\t\t\tstatic void destroyPMap(CKBehavior *beh,BBParArray *pArray)\r\n\t\t\t{\r\n\t\t\t\tBBParArray *pMap = static_cast(beh->GetAppData());\r\n\t\t\t\tif (pMap)\r\n\t\t\t\t{\r\n\t\t\t\t\twhile (\tpMap->getArray().size() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tBBParameter *p=pMap->getArray().at(0);\r\n\t\t\t\t\t\tpMap->getArray().erase(pMap->getArray().begin());\r\n\t\t\t\t\t\tif (p)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tp->par = NULL;\r\n\t\t\t\t\t\t\tdelete p;\r\n\t\t\t\t\t\t\tp = NULL;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbeh->SetAppData(NULL);\r\n\t\t\t\t\tpMap->getArray().clear();\r\n\t\t\t\t\tdelete pMap;\r\n\t\t\t\t\tpMap = NULL;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tclass BBHelper\r\n\t\t{\r\n\r\n\t\tpublic :\r\n\r\n\t\t\t\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic int getIndex(CKBehavior *beh,BBParameter *par)\r\n\t\t\t{\r\n\t\t\t\tif (!par)return -1;\r\n\t\t\t\tif (par && !par->par )return -1;\r\n\r\n\t\t\t\tfor (int i = 0 ; i< beh->GetInputParameterCount() ; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (par->par == beh->GetInputParameter(i)) return i;\r\n\t\t\t\t}\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic void remapIndex(CKBehavior *beh,BBParArray *pAarray,int size )\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *p=pAarray->getArray().at(i);\r\n\t\t\t\t\tp->inputIndex = p->par !=NULL ? getIndex(beh,p) : -1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic int getIndex(CKBehavior *beh,BBParArray *pAarray,int indicator )\r\n\t\t\t{\r\n\r\n\t\t\t\t#ifdef _DEBUG\r\n\t\t\t\t\tassert(beh);\r\n\t\t\t\t\tassert(pAarray);\r\n\t\t\t\t#endif\r\n\t\t\t\treturn pAarray->getArray().at(indicator)->inputIndex;\r\n\r\n\t\t\t}\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic int getIndexInv(CKBehavior *beh,BBParameter pInMap[],int indicator )\r\n\t\t\t{\r\n\r\n\t\t#ifdef _DEBUG\r\n\t\t\t\tassert(beh);\r\n\t\t#endif\r\n\r\n\t\t\t\tfor ( int i = 0 ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!strcmp(beh->GetInputParameter(i)->GetName(),pInMap[indicator].name.Str() ))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn i;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\tstatic void loadPIMap(CKBehavior *beh,BBParArray *dst,BBParameter pInMap[],int size,int start)\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *p=new BBParameter(pInMap[i].ID,pInMap[i].fixed,pInMap[i].guid,pInMap[i].name,pInMap[i].defaultValue,pInMap[i].condition);\r\n\t\t\t\t\tdst->getArray().push_back(p);\r\n\r\n\t\t\t\t\tif (!p->fixed)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint d = i - start ;\r\n\t\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter( i - start);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tlp->GetValue(&p->condition);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (p->condition)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tint index = getIndexInv(beh,pInMap,i);\r\n\t\t\t\t\t\tp->par = ((CKObject*)beh->GetInputParameter(index));\r\n\t\t\t\t\t\tp->condition = 1;\r\n\t\t\t\t\t\tp->inputIndex = index;\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tp->par = NULL;\r\n\t\t\t\t\t\tp->condition=-1;\r\n\t\t\t\t\t\tp->inputIndex = -1;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdst->isLoaded = true;\r\n\t\t\t}\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic void initPIMap(CKBehavior *beh,BBParArray *dst,BBParameter pInMap[],int size,int start)\r\n\t\t\t{\r\n\t\t\t\tif (dst->isLoaded)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tBBParameter *p=new BBParameter(pInMap[i].ID,pInMap[i].guid,pInMap[i].name,pInMap[i].defaultValue,pInMap[i].condition);\r\n\t\t\t\t\tdst->getArray().push_back(p);\r\n\t\t\t\t\tif (pInMap[i].condition ==1 )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter(start + i );\tlp->SetValue(&pInMap[i].condition);\r\n\t\t\t\t\t\tp->par = (CKObject*)beh->CreateInputParameter(pInMap[i].name.Str(),pInMap[i].guid);\r\n\t\t\t\t\t\tint index = getIndex(beh,p);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tBBHelper::remapIndex(beh,dst,size);\r\n\t\t\t}\r\n\r\n\t\t\tstatic void remapArray(CKBehavior *beh,BBParArray *pArray,int size,int settingStartIndex)\r\n\t\t\t{\r\n\t\t\t\tfor (int sI = 0; sI < size ; sI ++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tBBParameter *par = pArray->getArray().at(sI);\r\n\t\t\t\t\tif (par->fixed)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\r\n\t\t\t\t\tCKParameterLocal *lp = beh->GetLocalParameter(sI - settingStartIndex ); int val = 0;\t\tlp->GetValue(&val);\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t// Settings ON : \r\n\t\t\t\t\tif (val)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( par->par == NULL )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpar->condition = 1;\r\n\t\t\t\t\t\t\tpar->par = (CKObject*)beh->CreateInputParameter(par->name.Str(),par->guid);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t// Settings ON : \r\n\t\t\t\t\tif (!val)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( par->par )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tCKDestroyObject(par->par);\r\n\t\t\t\t\t\t\tpar->par = NULL;\r\n\t\t\t\t\t\t\tpar->condition = -1;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tremapIndex(beh,pArray,size);\r\n\t\t\t}\r\n\r\n\t\t\t/************************************************************************/\r\n\t\t\t/* */\r\n\t\t\t/************************************************************************/\r\n\t\t\tstatic void destroyPIMap(CKBehavior *beh,BBParArray *pArray)\r\n\t\t\t{\r\n\t\t\t\tBBParArray *pIMap = static_cast(beh->GetAppData());\r\n\t\t\t\tif (pIMap)\r\n\t\t\t\t{\r\n\t\t\t\t\twhile (\tpIMap->getArray().size() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tBBParameter *p=pIMap->getArray().at(0);\r\n\t\t\t\t\t\tpIMap->getArray().erase(pIMap->getArray().begin());\r\n\t\t\t\t\t\tif (p)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tp->par = NULL;\r\n\t\t\t\t\t\t\tdelete p;\r\n\t\t\t\t\t\t\tp = NULL;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbeh->SetAppData(NULL);\r\n\t\t\t\t\tpIMap->getArray().clear();\r\n\t\t\t\t\tdelete pIMap;\r\n\t\t\t\t\tpIMap = NULL;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n\r\n}\r\n#endifdofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\nsolution \"vtArToolkit\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" ; \"ReleaseRedist\" ; \"ReleaseDemo\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\npackageConfig_ARToolkit =\r\n{\r\n\tName \t\t= \t\"ArtToolkitLib\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES ; D_AT_DEFINES },\r\n\tFiles\t\t= { D_AT_SRC ; D_AT..\"include/**.h\"},\r\n\tIncludes \t= { D_AT_INCLUDES },\r\n\tOptions = { \"/W0\"}\r\n}\r\n\r\n\r\n--\tStatic library of the built-in camera building blocks\r\n--\r\n--\tThis package needs to be compiled for web player distributions.\r\n--\tCall createSolutions40Web2005.bat for instance\r\n--\r\npackageConfig_CameraRepack=\r\n{\r\n\tName \t\t= \t\"Camera\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" },\r\n\tFiles\t\t= { DDEPS..\"camera/behaviors/**.cpp\"\t},\r\n\tIncludes \t= { D_STD_INCLUDES ; },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n}\r\n\r\n--\tThe core vtPhysX SDK, compiled as DLL with exports. This is the entire base library for\r\n--\r\n--\t\t-\tbuilding blocks\r\n--\t\t-\tinterface plug-ins\r\n--\t\t-\tcustom parameter types\r\n--\t\t-\tcustom file readers\r\n--\r\n--\r\n\r\n--\tThe building blocks for vtPhysX, depending on packageConfig_vtAgeiaLib\r\npackageConfig_vtArToolkitBeh =\r\n{\r\n\tName \t\t= \t\"ARToolkitBehaviors\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" },\r\n\tFiles\t\t= { D_CORE_SRC ; DROOT..\"SDK/src/Behaviors/**.cpp\"\t; DROOT..\"SDK/src/Behaviors/*.def\" ; F_SHARED_SRC ; DROOT..\"build4/**.lua\" ; F_EXTRA_BB_SRC ; F_BASE_SRC },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDES ; D_AT_INCLUDES },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"ArtToolkitLib\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n\r\n}\r\n\r\n\r\n--\tIf the command line contains --ExtraDefines=\"WebPack\" , we add \"WebPack\" to the\r\n--\tpre-processor directives and also create a package to include the camera building blocks\r\n--\tas defined in packageConfig_CameraRepack\r\nif _OPTIONS[\"ExtraDefines\"] then\r\n\r\n\tif _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\tcreateStaticPackage(packageConfig_CameraRepack)\r\n\tend\r\nend\r\n\r\ncreateStaticPackage(packageConfig_ARToolkit)\r\ncreateStaticPackage(packageConfig_vtArToolkitBeh)\r\n\r\n\r\n\r\n\r\n--include \"CppConsoleApp\"\r\n\r\nfunction onclean()\r\n\tos.rmdir(\"vs**\")\r\nend\r\n--/************************************************************************/\r\n\r\n\r\n\t--Build/Compiler Setup.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n--/************************************\r\n\r\n\t--Internal Paths Substitution :\r\n\r\n\r\n\tDROOT \t= \"../\"\r\n\tDDEPS = DROOT..\"Dependencies/\"\r\n\r\n\tDDOCS\t= DROOT..\"Docs\"\r\n\r\n\tD_INCLUDE_ROOT\t= DROOT..\"SDK/Include/\"\r\n\tD_LIBS\t= DROOT..\"SDK/Lib/\"\r\n\r\n\r\n\tD_CORE_SRC\t= DROOT..\"SDK/Src/Core/\"\r\n\tD_BB_SRC\t\t= DROOT..\"SDK/Src/Behaviors/\"\r\n\tD_DIRECTX9\t\t= DDEPS..\"dx/\"\r\n\r\n\tD_CORE_INCLUDE_DIRS =\r\n\t{\r\n\t\tD_INCLUDE_ROOT..\"Core/Manager\";\r\n\t\tD_INCLUDE_ROOT..\"Core\";\r\n\t\tD_INCLUDE_ROOT..\"Core/Common\";\r\n\r\n\t}\r\n\r\n\tD_STD_INCLUDES =\r\n\t{\r\n\t\t\"../Shared\";\r\n\t\t\"../../usr/include\";\r\n\t}\r\n\r\n\tDEF_STD_DIRECTIVES \t=\r\n\t{\r\n\t\t\"WIN32\";\"_WINDOWS\"\r\n\t}\r\n\r\n\t--/************************************\r\n\r\n\t--Your Paths settings :\r\n\r\n\r\n\tDEV35DIR=DDEPS..\"vt/Dev35/\"\r\n\tDEV40DIR=DDEPS..\"vt/Dev40/\"\r\n\tDEV41DIR=DDEPS..\"vt/Dev41/\"\r\n\r\n\r\n\tOUTPUT_PATH_OFFSETT_TO_PROJECTFILES\t=\"../../Bin\"\r\n\tOUTPUT_PATH_OFFSETT_TO_PROJECTFILES_MINUS_ONE\t= \"../Bin\"\r\n\r\n\tOUTPUT_PATH_OFFSETT_TO_INTERNAL_LIBS=\"../SDK/Lib/\"\r\n\tOUTPUT_PATH_OFFSETT_TO_TMP=\"../TEMP\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"resourceplayer.h\"\r\n\r\n\r\n#include \"CustomPlayerDialogAboutPage.h\"\r\n#include \"CustomPlayerDialog.h\"\r\n\r\n#include \"commonhelpers.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"mdexceptions.h\"\r\n\r\n\r\n\r\n\r\n#ifdef _DEBUG\r\n#undef THIS_FILE\r\nstatic char BASED_CODE THIS_FILE[] = __FILE__;\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CAboutPage dialog\r\n\r\n\r\nnamespace\r\n{\r\n\tenum\r\n\t{\r\n\t\tRE_CONTROL = 4711\t// Id of the RichEdit Control\r\n\t};\r\n\r\n\t// Retrieve the GPL text from our resources\r\n\tCString GetTextResource(UINT id)\r\n\t{\r\n\t\tCString s;\r\n\r\n\t\tHGLOBAL hresource = NULL;\r\n\t\ttry\r\n\t\t{\r\n\t\t\tHRSRC hrsrc= FindResource(NULL, MAKEINTRESOURCE(id), _T(\"TEXT\"));\r\n\t\t\tif (hrsrc == NULL)\r\n\t\t\t\tMdThrowLastWinerror();\r\n\r\n\t\t\tDWORD dwSize= SizeofResource(AfxGetInstanceHandle(), hrsrc);\r\n\t\t\tif (dwSize == 0)\r\n\t\t\t\tMdThrowLastWinerror();\r\n\r\n\t\t\thresource= LoadResource(NULL, hrsrc);\r\n\t\t\tconst BYTE *pData= (const BYTE *)LockResource(hresource);\r\n\r\n\t\t\tCComBSTR bstr(dwSize, (LPCSTR)pData);\r\n\r\n\t\t\ts= bstr;\r\n\t\t}\r\n\t\tcatch (CException *pe)\r\n\t\t{\r\n\t\t\tpe->ReportError();\r\n\t\t\tpe->Delete();\r\n\t\t}\r\n\r\n\t\tif (hresource != NULL)\r\n\t\t\tFreeResource(hresource);\r\n\r\n\t\treturn s;\r\n\t}\r\n}\r\n\r\nCustomPlayerDialogAboutPage::CustomPlayerDialogAboutPage() : CPropertyPage(CustomPlayerDialogAboutPage::IDD)\r\n{\r\n\t//{{AFX_DATA_INIT(CAboutPage)\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\nvoid CustomPlayerDialogAboutPage::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tCPropertyPage::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CAboutPage)\r\n\t//}}AFX_DATA_MAP\r\n\tDDX_Control(pDX, IDC_ERROR_RICHT_TEXT, m_ErrorRichText);\r\n}\r\n\r\n\r\n\r\nBEGIN_MESSAGE_MAP(CustomPlayerDialogAboutPage, CPropertyPage)\r\n\t//{{AFX_MSG_MAP(CAboutPage)\r\n\t\t// NOTE: the ClassWizard will add message map macros here\r\n\t//}}AFX_MSG_MAP\r\n\tON_EN_SETFOCUS(IDC_ERROR_RICHT_TEXT, OnEnSetfocusErrorRichtText)\r\n\tON_NOTIFY(EN_LINK, IDC_ERROR_RICHT_TEXT, OnEnLinkErrorRichtText)\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CAboutPage message handlers\r\n\r\nvoid CustomPlayerDialogAboutPage::OnEnSetfocusErrorRichtText()\r\n{\r\n\tif (m_ErrorRichText)\r\n\t{\r\n\t\tCRect rc;\r\n\t\tm_ErrorRichText.GetWindowRect(rc);\r\n\t\tScreenToClient(rc);\r\n\t\tDWORD newStyle= ES_CENTER;\r\n\t\tDWORD style= m_ErrorRichText.GetStyle();\r\n\t\tstyle&= ~ES_CENTER;\r\n\t\tstyle|= newStyle;\r\n\t\tstyle|= WS_VSCROLL;\r\n\r\n\t\tDWORD exstyle= m_ErrorRichText.GetExStyle();\r\n\r\n\t\tm_ErrorRichText.SetAutoURLDetect();\r\n\t\tm_ErrorRichText.SetEventMask(ENM_LINK);\r\n\t\tm_ErrorRichText.SetFont(GetFont());\r\n\r\n\r\n\t\tCString text;\r\n\r\n\t\tCFile aboutFile;\r\n\t\tCFileException ex;\r\n\r\n\t\tchar Ini[MAX_PATH];\r\n\t\tchar drive[MAX_PATH];\r\n\t\tchar dir[MAX_PATH];\r\n\t\tchar szPath[MAX_PATH];\r\n \r\n\r\n\t\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\t\tsprintf(Ini,\"%s%s%s\",drive,dir,\"playerinfo.dat\");\r\n\r\n\t\tif(aboutFile.Open(Ini,CFile::modeNoTruncate|CFile::modeReadWrite|CFile::shareExclusive,&ex))\r\n\t\t{\r\n\t\t\tchar pbuf[16000];\r\n\t\t\tDWORD length = aboutFile.Read(pbuf,16000);\r\n\t\t\tXString b(pbuf);\r\n\t\t\tXString bufferOut = b.Create(b.Str(),length);\r\n\r\n\t\t\ttext.SetString(bufferOut.Str());\r\n\t\t\taboutFile.Close();\r\n\r\n\t\t}else\r\n\t\t{\r\n\t\t\ttext = GetTextResource(IDR_ABOUT);\r\n\t\t}\r\n\r\n\t\t \r\n\t\tm_ErrorRichText.SetWindowText(text);\r\n\t\tm_ErrorRichText.UpdateData();\r\n\t\tm_ErrorRichText.UpdateWindow();\r\n\t\tm_ErrorRichText.HideCaret();\r\n\r\n\t}\r\n\t\r\n}\r\n\r\nvoid CustomPlayerDialogAboutPage::OnEnLinkErrorRichtText(NMHDR *pNMHDR, LRESULT *pResult)\r\n{\r\n\t\r\n\tENLINK *el= reinterpret_cast(pNMHDR);\r\n\t*pResult = 0;\r\n\r\n\tif (el->msg == WM_LBUTTONDOWN)\r\n\t{\r\n\t\tCString link;\r\n\t\tm_ErrorRichText.GetTextRange(el->chrg.cpMin, el->chrg.cpMax, link);\r\n\r\n\t\tShellExecute(*this, NULL, link, NULL, _T(\"\"), SW_SHOWNORMAL);\r\n\t}\r\n}\r\n#ifndef _DistTypesAll_h\r\n#define _DistTypesAll_h\r\n\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedString.h\"\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"IParameter.h\"\r\n\r\nbool pFactory::findSettings(pPivotSettings& dst,CKBeObject*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_PIVOT_OFFSET);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_PIVOT_OFFSET);\r\n\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\r\n\treturn false;\r\n}\r\n\r\nCKParameterOut* pFactory::findSettings(pWheelDescr& dst,CKBeObject*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_WHEEL_DESCR);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_WHEEL_DESCR);\r\n\tif (!par)\r\n\t{\r\n att = GetPMan()->GetContext()->GetAttributeManager()->GetAttributeTypeByName(\"Wheel\");\r\n\t\tpar = src->GetAttributeParameter(att);\r\n\t}\r\n\tbool copied = IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\treturn par;\r\n}\r\n\r\nbool pFactory::findSettings(pCollisionSettings& dst,CKBeObject*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_COLLISIONS_SETTINGS);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_COLLISIONS_SETTINGS);\r\n\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\r\n\treturn false;\r\n}\r\n\r\nbool pFactory::findSettings(pOptimization& dst,CKBeObject*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR_OPTIMIZATION);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_ACTOR_OPTIMIZATION);\r\n\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\r\n\treturn false;\r\n}\r\n\r\nbool pFactory::findSettings(pMassSettings& dst,CKBeObject*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_MASS_SETUP);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_MASS_SETUP);\r\n\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\r\n\treturn false;\r\n}\r\n\r\nint pFactory::copyTo(CKParameter *src,pDominanceSetupItem&dst)\r\n{\r\n\r\n\tint result = 0 ; \r\n\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif // _DEBUG\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tCKParameter *contraintParameter = GetParameterFromStruct(src,PS_WD_CONSTRAINT);\r\n\r\n\tdst.constraint.dominanceA = GetValueFromParameterStruct(contraintParameter,PS_WDC_A);\r\n\tdst.constraint.dominanceB = GetValueFromParameterStruct(contraintParameter,PS_WDC_B);\r\n\r\n\tdst.dominanceGroup0 = GetValueFromParameterStruct(src,PS_WD_GROUP_A);\r\n\tdst.dominanceGroup1 = GetValueFromParameterStruct(src,PS_WD_GROUP_B);\r\n\r\n\t\r\n\r\n\treturn 0;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\nbool pFactory::copyTo(pConvexCylinderSettings&dst,CKParameter*src,bool evaluate/* =true */)\r\n{\r\n\r\n\tbool result = false;\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t#endif // _DEBUG\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//int att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_MASS_SETUP);\r\n\t//CKParameterOut *par = findSettingsParameter(src,VTS_PHYSIC_MASS_SETUP);\r\n\r\n\t/*\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)src);\r\n\t*/\r\n\r\n\r\n\r\n\tcopyTo(dst.radius, GetParameterFromStruct(src,PS_CC_RADIUS_REFERENCED_VALUE),true);\r\n\tcopyTo(dst.height, GetParameterFromStruct(src,PS_CC_HEIGHT_REFERENCED_VALUE),true);\r\n\r\n\tdst.approximation = GetValueFromParameterStruct(src,PS_CC_APPROXIMATION);\r\n\t\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate Forward Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.forwardAxis = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS);\r\n\tdst.forwardAxisRef = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS_REF);\r\n\tCK3dEntity *f = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.forwardAxisRef);\r\n\tif (f)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\tf->GetOrientation(&dir,&up,&right);\r\n\t\tf->TransformVector(&dst.forwardAxis,&dir);\r\n\t\tdst.forwardAxis.Normalize();\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate Down Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.downAxis = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS);\r\n\tdst.downAxisRef = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS_REF);\r\n\tCK3dEntity *d = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.downAxisRef);\r\n\r\n\tif (d)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\td->GetOrientation(&dir,&up,&right);\r\n\t\td->TransformVector(&dst.downAxis,&up);\r\n\t\tdst.downAxis.Normalize();\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate Right Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.rightAxis = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS);\r\n\tdst.rightAxisRef = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS_REF);\r\n\t\r\n\tCK3dEntity *r = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.rightAxisRef);\r\n\tif (r)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\tr->GetOrientation(&dir,&up,&right);\r\n\t\tr->TransformVector(&dst.rightAxis,&right);\r\n\t\tdst.rightAxis.Normalize();\r\n\t}\r\n\r\n\tdst.buildLowerHalfOnly = GetValueFromParameterStruct(src,PS_CC_BUILD_LOWER_HALF_ONLY);\r\n\tdst.convexFlags = (pConvexFlags)GetValueFromParameterStruct(src,PS_CC_EXTRA_SHAPE_FLAGS);\r\n\r\n\treturn true;\r\n}\r\n\r\nbool pFactory::findSettings(pConvexCylinderSettings&dst,CKBeObject *src)\r\n{\r\n\r\n\tbool result = false;\r\n\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif // _DEBUG\r\n\t\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint attType = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR);\r\n\tCKParameterOut *pout = src->GetAttributeParameter(attType);\r\n\tif (!pout)\r\n\t{\r\n\t\tCKMesh *currentMesh = ((CK3dEntity*)src)->GetCurrentMesh();\r\n\t\tif (currentMesh)\r\n\t\t{\r\n\t\t\tpout = currentMesh->GetAttributeParameter(attType);\r\n\t\t\tif (!pout)\r\n\t\t\t{\r\n\r\n\t\t\t\tdst.forwardAxis.Set(1.0f,0.0f,0.0f);\r\n\t\t\t\tdst.downAxis.Set(0.0f,-1.0f,0.0f);\r\n\t\t\t\tdst.rightAxis.Set(0.0f,0.0f,-1.0f);\r\n\t\t\t\t\r\n\t\t\t\tdst.buildLowerHalfOnly = false;\r\n\t\t\t\tdst.approximation = 10;\r\n\r\n\t\t\t\tVxVector size(0.0f);\r\n\t\t\t\t\r\n\t\t\t\tif (src->GetClassID() == CKCID_3DOBJECT )\r\n\t\t\t\t{\r\n\t\t\t\t\tCK3dEntity *ent3D = (CK3dEntity*)src;\r\n\t\t\t\t\tif (ent3D)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsize = ent3D->GetBoundingBox(true).GetSize();\r\n\t\t\t\t\t}\r\n\t\t\t\t}else if(src->GetClassID() == CKCID_MESH)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKMesh *mesh = (CKMesh*)src;\r\n\t\t\t\t\tif (mesh)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsize = mesh->GetLocalBox().GetSize();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdst.radius.value = size.x * 0.5f;\r\n\t\t\t\tdst.height.value = size.y; \r\n\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn copyTo(dst,pout);\r\n}\r\n\r\nbool pFactory::findSettings(pCapsuleSettings&dst,CKBeObject *src)\r\n{\r\n\r\n\tbool result = false;\r\n\tif (!src)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tCKParameterOut *pout = src->GetAttributeParameter(GetPMan()->att_capsule);\r\n\tif (!pout)\r\n\t{\r\n\t\tCKMesh *currentMesh = ((CK3dEntity*)src)->GetCurrentMesh();\r\n\t\tif (currentMesh)\r\n\t\t{\r\n\t\t\tpout = currentMesh->GetAttributeParameter(GetPMan()->att_capsule);\r\n\t\t\tif (!pout)\r\n\t\t\t{\r\n\t\t\t\tdst.localLengthAxis = CKAXIS_Y;\r\n\t\t\t\tdst.localRadiusAxis = CKAXIS_X;\r\n\t\t\t\tdst.height = -1.0f;\r\n\t\t\t\tdst.radius = -1.0f;\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn copyTo(dst,pout);\r\n}\r\n\r\n\r\nbool pFactory::findSettings(pCapsuleSettingsEx&dst,CKBeObject *src)\r\n{\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tif (!src)return false;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_CAPSULE_SETTINGS_EX);\r\n\tCKParameterOut *par = findSettingsParameter(src,VTS_CAPSULE_SETTINGS_EX);\r\n\r\n\tif (par)\r\n\t\treturn IParameter::Instance()->copyTo(dst,(CKParameter*)par);\r\n\r\n\t//dst.height.referenceAxis\t= CKAXIS_Y;\r\n\t//dst.radius.referenceAxis\t= CKAXIS_X;\r\n\r\n\treturn false;\r\n\t\t\t\t\r\n}\r\n\r\nvoid pFactory::copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Retrieve the value :\r\n\t//\r\n\tdst.value = GetValueFromParameterStruct(src,PS_ARL_VALUE);\r\n\r\n\tdst.referenceAxis = GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT_AXIS);\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate the value basing on the given objects local box and an axis. \r\n\t//\r\n\tCK_ID idRef= GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT);\r\n\tCKBeObject *object = (CKBeObject*)GetPMan()->GetContext()->GetObject(idRef);\r\n\r\n\tif (!object)\r\n\t\treturn;\r\n\r\n\tdst.reference = object;\r\n\r\n\tif (!evaluate)return;\r\n\t\r\n\r\n VxVector size(0.0f);\r\n\tif (object->GetClassID() == CKCID_3DOBJECT )\r\n\t{\r\n\t\tCK3dEntity *ent3D = (CK3dEntity*)object;\r\n\t\tif (ent3D)\r\n\t\t{\r\n\t\t\tsize = ent3D->GetBoundingBox(true).GetSize();\r\n\t\t}\r\n\t}else if(object->GetClassID() == CKCID_MESH)\r\n\t{\r\n\t\tCKMesh *mesh = (CKMesh*)object;\r\n\t\tif (mesh)\r\n\t\t{\r\n\t\t\tsize = mesh->GetLocalBox().GetSize();\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\tdst.value = size[dst.referenceAxis];\r\n}\r\n\r\n\r\npWorldSettings*pFactory::getWorldSettings(CK3dEntity*ent)\r\n{\r\n\r\n\t/*\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!ent )\r\n\t{\r\n\treturn NULL;\r\n\t}\r\n\tif (!ent->HasAttribute(GetPMan()->att_world_object ))\r\n\t{\r\n\treturn NULL;\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpWorldSettings *result = new pWorldSettings();\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\tresult->m_Gravity= GetValueFromAttribute(ent,GetPMan()->att_world_object,0);\r\n\tresult->m_CFM= GetValueFromAttribute(ent,GetPMan()->att_world_object,1);\r\n\tresult->m_ERP= GetValueFromAttribute(ent,GetPMan()->att_world_object,2);\r\n\tresult->m_MaximumContactCorrectVelocity = GetValueFromAttribute(ent,GetPMan()->att_world_object,3);\r\n\tresult->m_ContactSurfaceLayer = GetValueFromAttribute(ent,GetPMan()->att_world_object,4);\r\n\treturn result;\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\npObjectDescr* pFactory::createPObjectDescrFromParameter(CKParameter *par)\r\n{\r\n\r\n\tif (!par)\r\n\t\treturn NULL;\r\n\r\n\t//################################################################\r\n\t//\r\n\t// ATTENTION : \r\n\t//\r\n\r\n\tpObjectDescr *descr = new pObjectDescr();\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\tint hType,flags,hierarchy,collGroup;\r\n\tVxVector mOffset,sOffset;\r\n\tfloat density,skinWidth,newDensity,totalMass;\r\n\r\n\tcollGroup = GetValueFromParameterStruct(par,E_PPS_COLL_GROUP,false);\r\n\thierarchy = GetValueFromParameterStruct(par,E_PPS_HIRARCHY,false);\r\n\thType = GetValueFromParameterStruct(par,E_PPS_HULLTYPE,false);\r\n\tflags = GetValueFromParameterStruct(par,E_PPS_BODY_FLAGS,false);\r\n\tdensity = GetValueFromParameterStruct(par,E_PPS_DENSITY,false);\r\n\tnewDensity = GetValueFromParameterStruct(par,E_PPS_NEW_DENSITY,false);\r\n\ttotalMass = GetValueFromParameterStruct(par,E_PPS_TOTAL_MASS,false);\r\n\tskinWidth = GetValueFromParameterStruct(par,E_PPS_SKIN_WIDTH,false);\r\n\tmOffset = GetValueFromParameterStruct(par,E_PPS_MASS_OFFSET,false);\r\n\tsOffset = GetValueFromParameterStruct(par,E_PPS_MASS_OFFSET,false);\r\n\r\n\r\n\t\r\n\tdescr->density = density;\r\n\tdescr->skinWidth = skinWidth;\r\n\tdescr->massOffset = mOffset;\r\n\tdescr->shapeOffset = sOffset;\r\n\tdescr->hullType = (HullType)hType;\r\n\tdescr->flags = (BodyFlags)flags;\r\n\tdescr->hirarchy = hierarchy;\r\n\tdescr->newDensity = newDensity;\r\n\tdescr->totalMass = totalMass;\r\n\r\n\treturn descr;\r\n\t\r\n\treturn NULL;\r\n}\r\n\r\npSleepingSettings*pFactory::getSleepingSettings(CK3dEntity*ent)\r\n{\r\n\t/*\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!ent )\r\n\t{\r\n\treturn NULL;\r\n\t}\r\n\tif (!ent->HasAttribute(GetPMan()->att_sleep_settings ))\r\n\t{\r\n\treturn NULL;\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpSleepingSettings *result = new pSleepingSettings();\r\n\tusing namespace vtTools::AttributeTools;\r\n\tresult->m_SleepSteps= GetValueFromAttribute(ent,GetPMan()->att_sleep_settings,0);\r\n\tresult->m_AngularThresold= GetValueFromAttribute(ent,GetPMan()->att_sleep_settings,1);\r\n\tresult->m_LinearThresold = GetValueFromAttribute(ent,GetPMan()->att_sleep_settings,2);\r\n\tresult->m_AutoSleepFlag = GetValueFromAttribute(ent,GetPMan()->att_sleep_settings,3);\r\n\treturn result;\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\nbool pFactory::copyTo(pCapsuleSettings&dst,CKParameter*src)\r\n{\r\n\tif (!src)\treturn false;\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tdst.localLengthAxis = GetValueFromParameterStruct(src,E_CS_LENGTH_AXIS);\r\n\tdst.localRadiusAxis = GetValueFromParameterStruct(src,E_CS_RADIUS_AXIS);\r\n\tdst.radius = GetValueFromParameterStruct(src,E_CS_RADIUS);\r\n\tdst.height = GetValueFromParameterStruct(src,E_CS_LENGTH);\r\n\r\n\treturn true;\r\n}\r\nint pFactory::copyTo(CKParameterOut*dst,pGroupsMask src)\r\n{\r\n\r\n\tif (!dst)\treturn 0;\r\n\r\n\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\tSetParameterStructureValue(dst,0,src.bits0,false);\r\n\tSetParameterStructureValue(dst,1,src.bits1,false);\r\n\tSetParameterStructureValue(dst,2,src.bits2,false);\r\n\tSetParameterStructureValue(dst,3,src.bits3,false);\r\n\r\n\treturn true;\r\n}\r\nint pFactory::copyTo(pGroupsMask &dst,CKParameter*src)\r\n{\r\n\r\n\tif (!src)\treturn 0;\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\tdst.bits0 = GetValueFromParameterStruct(src,0);\r\n\tdst.bits1 = GetValueFromParameterStruct(src,1);\r\n\tdst.bits2 = GetValueFromParameterStruct(src,2);\r\n\tdst.bits3 = GetValueFromParameterStruct(src,3);\r\n\treturn 1;\r\n}\r\n\r\nCKParameterOut *pFactory::findSettingsParameter(CKBeObject *src,CKGUID guid)\r\n{\r\n\r\n\r\n\tif (!src)return NULL;\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(guid);\r\n\tCKParameterOut *par = src->GetAttributeParameter(att);\r\n\tif (par){\r\n\t\treturn par;\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Try sub objects\r\n\t//\r\n\tCK3dEntity *ent3D = static_cast(src);\r\n\tif (ent3D)\r\n\t{\r\n\t\tCKMesh *mesh = ent3D->GetCurrentMesh();\r\n\t\tif (mesh)\r\n\t\t{\r\n\t\t\tpar = mesh->GetAttributeParameter(att);\r\n\t\t\tif (!par)\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < mesh->GetMaterialCount() ; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKMaterial *entMaterial = mesh->GetMaterial(i);\r\n\t\t\t\t\tpar = entMaterial->GetAttributeParameter(att);\r\n\t\t\t\t\tif (par)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn par;\r\n}/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t AddNodalLink\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"StdAfx.h\"\r\n#include \"virtools/vtcxglobal.h\"\r\n#include \"windows.h\"\r\n#include \"Python.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \"pyembed.h\"\r\n#include \"InitMan.h\"\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLoadPythonDecl();\r\nCKERROR CreateLoadPythonProto(CKBehaviorPrototype **);\r\nint LoadPython(const CKBehaviorContext& behcontext);\r\nCKERROR LoadPythonCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorLoadPythonDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"LoadPython\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x422f5f39,0x71d0452b));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateLoadPythonProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Python\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateLoadPythonProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"LoadPython\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"append libpath\",CKPGUID_STRING);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( LoadPython );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint LoadPython(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tXString path((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\tvt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);\r\n\r\n\tif (PythonLoad())\r\n\t{\r\n\t\tsyspath_append(path.Str());\r\n\t\tbeh->ActivateOutput(0);\r\n\t}else\r\n\t{\r\n\t\tbeh->ActivateOutput(1);\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n#ifndef _XNETBASE_H_\r\n#define _XNETBASE_H_\r\n\r\n#ifndef _XNET_ENUMERATIONS_H_\r\n\t#include \"xNetEnumerations.h\"\r\n#endif\r\n\r\n#ifndef _XNET_TYPES_H_\r\n\t#include \"xNetTypes.h\"\r\n#endif\r\n\r\n\r\n\r\n\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVGetDecl();\r\nCKERROR CreatePVGetProto(CKBehaviorPrototype **pproto);\r\nint PVGet(const CKBehaviorContext& behcontext);\r\nCKERROR PVGetCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools;\r\nusing namespace BehaviorTools;\r\n\r\n\r\n\r\nenum bbI_Inputs\r\n{\r\n\tbbI_BodyReference,\r\n\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\nenum bbOutputs\r\n{\r\n\tO_StateFlags,\r\n\tO_Acceleration,\r\n\tO_Steering,\r\n\tO_MTorque,\r\n\tO_MPH,\r\n\tO_RPM,\r\n\tO_MRPM,\r\n\tO_WRPM,\r\n\tO_Gear,\r\n};\r\n\r\nBBParameter pOutMapv[] = \r\n{\r\n\tBB_SPOUT(O_StateFlags,VTF_VSTATE_FLAGS,\"State Flags\",\"0.0\"),\r\n\tBB_SPOUT(O_Acceleration,CKPGUID_FLOAT,\"Acceleration\",\"0.0\"),\r\n\tBB_SPOUT(O_Steering,CKPGUID_ANGLE,\"Steering\",\"0.0\"),\r\n\tBB_SPOUT(O_MTorque,CKPGUID_FLOAT,\"Motor Torque\",\"0.0\"),\r\n\tBB_SPOUT(O_MPH,CKPGUID_FLOAT,\"MPH\",\"0.0\"),\r\n\tBB_SPOUT(O_RPM,CKPGUID_FLOAT,\"RPM\",\"0.0\"),\r\n\tBB_SPOUT(O_MRPM,CKPGUID_FLOAT,\"M - RPM\",\"0.0\"),\r\n\tBB_SPOUT(O_WRPM,CKPGUID_FLOAT,\"Wheel RPM\",\"0.0\"),\r\n\tBB_SPOUT(O_Gear,CKPGUID_INT,\"Gear\",\"0.0\"),\r\n};\r\n\r\n#define gOPMap pOutMapv\r\n\r\n\r\nCKERROR PVGetCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tint cb = behcontext.CallbackMessage;\r\n\tBB_DECLARE_PMAP;\r\n\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t\t{\r\n\t\t\t\tBB_LOAD_POMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\t\t\t\tBB_DESTROY_PMAP;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\t{\r\n\t\t\t\tBB_INIT_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t\t{\r\n\t\t\t\tBB_REMAP_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVGetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVGet\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Retrieves vehicle related parameters.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x70b293c,0x1ef4fa7));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVGetProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVGetProto\r\n// FullName: CreatePVGetProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVGetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVGet\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->SetBehaviorCallbackFct( PVGetCB );\r\n\r\n\r\n\tBB_EVALUATE_SETTINGS(gOPMap);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVGet);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PVGet\r\n// FullName: PVGet\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PVGet(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\t\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\r\n\t\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\r\n\t\t{\r\n\t\t\tbbSErrorME(E_PE_NoVeh);\r\n\t\t}\r\n\r\n\t\tBB_DECLARE_PMAP;\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/*****\r\n\t\t*******************************************************************/\r\n\r\n\t\tBBSParameter(O_StateFlags);\r\n\t\tBBSParameter(O_Acceleration);\r\n\t\tBBSParameter(O_Steering);\r\n\t\tBBSParameter(O_MTorque);\r\n\t\tBBSParameter(O_MPH);\r\n\t\tBBSParameter(O_RPM);\r\n\t\tBBSParameter(O_MRPM);\r\n\t\tBBSParameter(O_WRPM);\r\n\t\tBBSParameter(O_Gear);\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\r\n\t\tBB_O_SET_VALUE_IF(int,O_StateFlags,v->getStateFlags());\r\n\t\tBB_O_SET_VALUE_IF(float,O_Acceleration,v->_cAcceleration);\r\n\t\tBB_O_SET_VALUE_IF(float,O_Steering,v->_cSteering);\r\n\t\tBB_O_SET_VALUE_IF(float,O_MPH,v->getMPH());\r\n\r\n\t\tfloat wRPM = v->_computeRpmFromWheels();\r\n\t\tBB_O_SET_VALUE_IF(float,O_WRPM,wRPM);\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// output new engine values\r\n\t\t//\r\n\t\tif (v->isValidEngine())\r\n\t\t{\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_MTorque,v->getEngine()->GetEngineTorque());\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_RPM,v->getRPM());\r\n\t\t\tBB_O_SET_VALUE_IF(int,O_Gear,v->getGear());\r\n\t\t}\r\n\r\n\r\n\r\n\t\t/*\r\n\t\tif (v->getMotor())\r\n\t\t{\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_MTorque,v->getMotor()->getTorque());\r\n\t\t\tfloat mRPM = v->_computeMotorRpm(wRPM);\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_MRPM,mRPM);\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_RPM,v->getMotor()->getRpm());\r\n\t\t}\r\n\r\n\t\tif (v->getGears())\r\n\t\t{\r\n\r\n\t\t\tBB_O_SET_VALUE_IF(int,O_Gear,v->getGears()->getGear());\r\n\t\t}\r\n\t\t*/\r\n\t}\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVGetCB\r\n// FullName: PVGetCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\ndofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\nif _ACTION == \"clean\" then\r\n\tos.rmdir(\"./vs*\")\r\n\tos.rmdir(\"../Temp\")\r\n\treturn\r\nend\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\nsolution \"vtTools\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\n\r\n\r\npackageConfig_TCP4 =\r\n{\r\n\tName \t\t= \t\"Tcp4u\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t},\r\n\tFiles\t\t= { DDEPS..\"tcp4u/include/*.h\"\t;\tDDEPS..\"tcp4u/src/*.c*\"\t},\r\n\tIncludes \t= { DDEPS..\"tcp4u/include\" },\r\n\tOptions = { \"/W0\"}\r\n\r\n}\r\n\r\npackageConfig_FTP4W32 =\r\n{\r\n\tName \t\t= \t\"FTP4W32\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t},\r\n\tFiles\t\t= { DDEPS..\"ftpw32/*.h\"\t;\tDDEPS..\"ftpw32/*.c*\"\t},\r\n\tIncludes \t= { DDEPS..\"tcp4u/include\"; DDEPS..\"ftpw32\" },\r\n\tOptions = { \"/W0\"}\r\n\r\n}\r\n\r\n\r\nD_NetIncDirs = { DDEPS..\"ftpw32\" ; DDEPS..\"tcp4u/include\" }\r\n\r\npackageConfig_Behaviours =\r\n{\r\n\tName \t\t= \t\"vtToolkit\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" ; \"USEDIRECTX9\" },\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tFiles\t\t= { D_INCLUDE_ROOT..\"*.h\" ; D_INCLUDE_ROOT..\"Core/**.h\" ; D_CORE_SRC..\"**.c*\";\tD_BB_SRC..\"**.c*\" ; D_BB_SRC..\"*.def\" },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDE_DIRS ; D_NetIncDirs\t; DDEPS..\"dx/Include\" },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"FTP4W32\" ; \"Tcp4u\" ; \"Ws2_32\"\t; \"dxerr\"; \"dinput8\";\"dxguid\" ; \"Version\" },\r\n\tLibDirectories = { \tD_DX..\"lib\" },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n}\r\n\r\ncreateStaticPackage(packageConfig_TCP4)\r\ncreateStaticPackage(packageConfig_FTP4W32)\r\ncreateStaticPackage(packageConfig_Behaviours)\r\n\r\n\r\nfunction onclean()\r\n\tprint(\"cleaning\")\r\n\tos.rmdir(\"vs*\")\r\nend\r\n/********************************************************************\r\n\tcreated:\t2009/02/17\r\n\tcreated:\t17:2:2009 8:26\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\include\\core\\Common\\pTypes.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\include\\core\\Common \r\n\tfile base:\tpTypes\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tType definitions, Function pointers \r\n*********************************************************************/\r\n#ifndef __P_TYPES_H__\r\n#define __P_TYPES_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"CKAll.h\"\r\n\r\n\r\n//################################################################\r\n//\r\n// Common used types for rigid bodies and joints\r\n//\r\n\r\n\r\n/**\r\n\\brief Describes a joint spring. The spring is implicitly integrated, so even high spring and damper coefficients should be robust.\r\npSpring is registered as custom structure #pJSpring and can be accessed or modified through parameter operations.
\r\n\r\n*/\r\nclass pSpring\r\n{\r\n\r\npublic:\r\n\t/**\r\n\tDamper coefficient\r\n\t*/\r\n\tfloat damper;\r\n\t/**\r\n\tSpring coefficient\r\n\t*/\r\n\tfloat spring;\r\n\t/**\r\n\tTarget value (angle/position) of spring where the spring force is zero.\r\n\t*/\r\n\tfloat targetValue;\r\n\tpSpring()\r\n\t{\r\n\t\tdamper = 0.0f;\r\n\t\tspring = 0.0f;\r\n\t\ttargetValue = 0.0f;\r\n\t}\r\n\tpSpring(float _damper,float _spring,float _targetValue)\r\n\t{\r\n\r\n\t\tdamper = _damper;\r\n\t\tspring = _spring;\r\n\t\ttargetValue = _targetValue;\r\n\t}\r\n};\r\n\r\n\r\n\r\n\r\n\r\n/** \\addtogroup Collision\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief 128-bit mask used for collision filtering.\r\n\r\nThe collision filtering equation for 2 shapes S0 and S1 is:\r\n\r\n
 (G0 op0 K0) op2 (G1 op1 K1) == b 
\r\n\r\nwith\r\n\r\n
    \r\n
  • G0 = pGroupsMask for shape S0. See ::setGroupsMask
  • \r\n
  • G1 = pGroupsMask for shape S1. See ::setGroupsMask
  • \r\n
  • K0 = filtering constant 0. See ::setFilterConstant0
  • \r\n
  • K1 = filtering constant 1. See ::setFilterConstant1
  • \r\n
  • b = filtering boolean. See ::setFilterBool
  • \r\n
  • op0, op1, op2 = filtering operations. See ::setFilterOps
  • \r\n
\r\n\r\nIf the filtering equation is true, collision detection is enabled.\r\n\r\n@see pWorld::setFilterOps()\r\n*/\r\nclass pGroupsMask\r\n{\r\npublic:\r\n\tAPI_INLINE\tpGroupsMask()\t{}\r\n\tAPI_INLINE\t~pGroupsMask()\t{}\r\n\tint\t\tbits0, bits1, bits2, bits3;\r\n};\r\n\r\n\r\n\r\nclass pRay\r\n{\r\n\r\npublic:\r\n\tVxVector orig;\r\n\tVxVector dir;\r\n\r\n};\r\n\r\nclass pRaycastHit\r\n{\r\npublic:\r\n\tfloat distance;\r\n\tCK3dEntity *shape;\r\n\tVxVector worldImpact;\r\n\tVxVector worldNormal;\r\n\tint faceID;\r\n\tint internalFaceID;\r\n\tfloat u;\r\n\tfloat v;\r\n\tint materialIndex;\r\n\tint flags;\r\n\r\n\tpRaycastHit()\r\n\t{ \r\n\t\tdistance = 0.0;\r\n\t\tshape = NULL;\r\n\t\tu = 0.0f;\r\n\t\tv= 0.0f;\r\n\t\tfaceID = 0 ; \r\n\t\tmaterialIndex = 0 ; \r\n\t\tflags = 0;\r\n\r\n\t}\r\n\r\n};\r\n\r\n/**\r\n\\brief Class for describing rigid bodies ccd settings.\r\n*/\r\nclass pCCDSettings\r\n{\r\npublic : \r\n\t\r\n\tbool isValid();\r\n\tbool setToDefault();\r\n\tbool evaluate(CKBeObject*referenceObject);\r\n\r\n\tfloat motionThresold;\r\n\tint flags;\r\n\tCK_ID meshReference;\r\n\tfloat scale;\r\n\r\n\tpCCDSettings()\r\n\t{\r\n\t\tmotionThresold = 0.0;\r\n\t\tflags = 0 ;\r\n\t\tmeshReference =0;\r\n\t\tscale = 1.0f;\r\n\t}\r\n};\r\n\r\n/**\r\n\r\n\\brief Class for describing rigid bodies or its sub shapes collisions settings.\r\n\r\n\\sa #pRigidBody::updateCollisionSettings()\r\n*/\r\nclass pCollisionSettings\r\n{\r\n\tpublic:\r\n\t\t\r\n\t\tbool isValid();\r\n\t\tbool setToDefault();\r\n\t\t/**\r\n\t\t\\brief\tcollisions group the shape belongs to\r\n\t\t\t-\tRange: [0,32]\r\n\t\t\t-\tDefault: 0\r\n\t\t*/\r\n\t\tint collisionGroup;\r\n\t\t/**\r\n\t\t\\brief 128-bit mask used for collision filtering\r\n\t\t-\tRange: [0,4x4 bits]\r\n\t\t-\tDefault: all off\r\n\t\t*/\r\n\t\tpGroupsMask groupsMask;\r\n\t\t/**\r\n\t\t\\brief Additional collisions offset\r\n\t\t-\tRange: [0,1.0f]\r\n\t\t-\tDefault:0.25f\r\n\t\t-\tCan NOT altered after creation\r\n\t\t*/\r\n\t\tfloat skinWidth;\r\n\r\n\tpCollisionSettings()\r\n\t{\r\n\t\tcollisionGroup = 0;\r\n\t\tskinWidth = 0.025f;\r\n\t}\r\n};\r\n\r\n//@}\r\n\r\n\r\n\r\n\r\n\r\n\r\ntypedef std::vectorpRayCastHits;\r\n\r\n\r\n/**\r\n\\brief Class for describing rigid bodies optimization.\r\n*/\r\nclass MODULE_API pOptimization \r\n{\r\n\tpublic : \r\n\r\n\t\tbool isValid();\r\n\t\tbool setToDefault();\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t/**\r\n\t\t\\brief Flags to lock a rigid body in certain degree of freedom. See also #pRigidBody::lockTransformation\r\n\t\t*/\r\n\t\tBodyLockFlags transformationFlags;\r\n\t\t/**\r\n\t\t\\brief Sets the linear damping coefficient. Zero represents no damping. The damping coefficient must be nonnegative. See pRigidBody::setLinearDamping\r\n\t\t*/\r\n\t\tfloat linDamping;\r\n\t\t/**\r\n\t\t\\brief Sets the angular damping coefficient.Zero represents no damping. The damping coefficient must be nonnegative.See pRigidBody::setAngularDamping\r\n\t\t*/\r\n\t\tfloat angDamping;\r\n\t\t/**\r\n\t\t\\copydoc pRigidBody::setSolverIterationCount\r\n\t\t*/\r\n\t\tint solverIterations;\r\n\t\t/**\r\n\t\t\\copydoc pRigidBody::setDominanceGroup\r\n\t\t*/\r\n\t\tint dominanceGroup;\r\n\t\t/**\r\n\t\t\\brief Not Implemented\r\n\t\t*/\r\n\t\tint compartmentGroup;\r\n\t\t/**\r\n\t\t\\copydoc pRigidBody::setSleepEnergyThreshold\r\n\t\t*/\r\n\t\tfloat sleepEnergyThreshold;\r\n\t\t/**\r\n\t\t\\copydoc pRigidBody::setSleepLinearVelocity\r\n\t\t*/\r\n\t\tfloat linSleepVelocity;\r\n\t\t/**\r\n\t\t\\copydoc pRigidBody::setSleepAngularVelocity\r\n\t\t*/\r\n\t\tfloat angSleepVelocity;\r\n\r\n\t\tpOptimization()\r\n\t\t{\r\n\r\n\t\t\ttransformationFlags = (BodyLockFlags)0;\r\n\r\n\t\t\tlinDamping = angDamping = 0.0f;\r\n\t\t\tsolverIterations = 24 ;\r\n\t\t\tdominanceGroup=0;\r\n\t\t\tcompartmentGroup=0;\r\n\t\t\tsleepEnergyThreshold =0.0f;\r\n\t\t\tlinSleepVelocity = angSleepVelocity = 0.0;\r\n\t\t}\r\n\r\n};\r\n\r\n/**\r\n\\brief Class for describing a shape's surface properties.\r\n*/\r\nclass MODULE_API pMaterial \r\n{\r\npublic : \r\n\r\n\tbool isValid();\r\n\r\n\t/**\r\n\t\\brief\tFlags, a combination of the bits defined by the enum ::pMaterialFlag
\r\n\t\t-\tDefault: 0\r\n\r\n\t@see MaterialFlags\r\n\t*/\r\n\tint flags;\r\n\r\n\t/**\r\n\t\\brief\tCoefficient of dynamic friction. If set to greater than staticFriction,
\r\n\t\t\tthe effective value of staticFriction will be increased to match. if flags & MF_Anisotropic is set, then this value is used for the primary direction of anisotropy (U axis)
\r\n\t\t-\tRange: [0,+inf)\r\n\t\t-\tDefault: [0)\r\n\t*/\r\n\tfloat dynamicFriction;\r\n\t/**\r\n\t\\brief \tCoefficient of static friction. If flags & MF_Anisotropic is set,
\r\n\t\t\tthen this value is used for the primary direction of anisotropy (U axis)\r\n\t*/\r\n\tfloat staticFriction;\r\n\t/**\r\n\t\\brief Coefficient of restitution. Makes the object bounce as little as possible, higher values up to 1.0 result in more bounce. Note that values close to or above 1 may cause stability problems and/or increasing energy.\r\n\t\t-\tRange: [0,1)\r\n\t\t-\tDefault: [0)\r\n\t*/\r\n\tfloat restitution;\r\n\t/**\r\n\t\\brief Anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy. This is only used if flags & MF_Anisotropic is set.\r\n\t\t-\tRange: [0,inf)\r\n\t\t-\tDefault: [0)\r\n\t*/\r\n\tfloat dynamicFrictionV;\r\n\t/**\r\n\t\\brief Anisotropic static friction coefficient for along the secondary (V) axis of anisotropy. This is only used if flags & MF_Anisotropic is set. \r\n\t\t-\tRange: [0,inf)\r\n\t\t-\tDefault: [0)\r\n\t*/\r\n\tfloat staticFrictionV;\r\n\t/**\r\n\t\\brief Friction combine mode. See the enum CombineMode .\r\n\t\t-\tRange: [CombineMode)\r\n\t\t-\tDefault: [CM_Average)\r\n\t*/\r\n\tCombineMode frictionCombineMode;\r\n\t/**\r\n\t\\brief Restitution combine mode. See the enum CombineMode .\r\n\t\t-\tRange: [CombineMode)\r\n\t\t-\tDefault: [CM_Average)\r\n\t*/\r\n\tCombineMode restitutionCombineMode;\r\n\t/**\r\n\t\\brief shape space direction (unit vector) of anisotropy. This is only used if flags & MF_Anisotropic is set. \r\n\t\t-\tRange: [vector)\r\n\t\t-\tDefault: [1.0f,0.0f,0.0f)\r\n\t*/\r\n\tVxVector dirOfAnisotropy;\r\n\r\n\t/**\r\n\t\\brief unique name of the material \r\n\t*/\r\n\tconst char*\t\t\t\t\t\t\t\t\tname;\r\n\r\n\t/**\r\n\t\\brief Enumeration to identify a material setup from PhysicDefaults.xml. Is being populated automatically on reset.\r\n\t\t-\tRange: [0,Number of material setups in xml file)\r\n\t\t-\tDefault: [NONE)\r\n\t*/\r\n\tint\t\t\t\t\t\t\t\t\t\t\t\t\txmlLinkID;\r\n\r\n\tint getNxMaterialID() const { return mNxMaterialID; }\r\n\tvoid setNxMaterialID(int val) { mNxMaterialID = val; }\r\n\r\n\tpMaterial()\r\n\t{\r\n\t\tsetToDefault();\r\n\t}\r\n\t__inline void setToDefault()\r\n\t{\r\n\t\tdynamicFriction\t= 0.0f;\r\n\t\tstaticFriction\t= 0.0f;\r\n\t\trestitution\t\t= 0.0f;\r\n\t\tdynamicFrictionV= 0.0f;\r\n\t\tstaticFrictionV = 0.0f;\r\n\t\tdirOfAnisotropy = VxVector(1,0,0);\r\n\t\tflags = 0;\r\n\t\tfrictionCombineMode = CM_Average;\r\n\t\trestitutionCombineMode = CM_Average;\r\n\t\txmlLinkID =0;\r\n\t\tname = \"\";\r\n\t}\r\n\t\r\n\t\r\n\r\nprivate :\r\n\r\n\tint mNxMaterialID;\r\n};\r\n\r\n\r\n\r\n#endif\r\n#include \"CKAll.h\"\r\n\r\n#include \"N3dGraph.h\"\r\n\r\nchar* Network3dName = \"Nodal Path\";\r\n\r\nN3DGraph::N3DGraph(CKContext *context):m_Size(0),m_AllocatedSize(10) {\r\n\tm_States = new N3DState[m_AllocatedSize];\r\n\tm_Display = NULL;\r\n\tm_EdgeNumber = 0;\r\n\tm_Context=context;\r\n}\r\n\r\nN3DGraph::~N3DGraph() {\r\n\tfor(int i=0;im_Next;\r\n\t\t\tdelete temp;\r\n\t\t}\r\n\t}\r\n\tdelete [] m_States;\r\n\tm_States = NULL;\r\n}\r\n\r\nvoid\r\nN3DGraph::TestAndReallocate(int n) {\r\n\tif(m_Size+n > m_AllocatedSize) {\r\n\t\tm_AllocatedSize *= 2;\r\n\t\tN3DState* old = m_States;\r\n\t\tm_States = new N3DState[m_AllocatedSize];\r\n\t\tmemcpy(m_States,old,m_Size*sizeof(N3DState));\r\n\t\tdelete [] old;\r\n\t}\r\n}\r\n\r\nint \r\nN3DGraph::GetStatesNumber() const\r\n{\r\n\treturn m_Size;\r\n}\r\n\r\nint \r\nN3DGraph::GetEdgesNumber() const\r\n{\r\n\treturn m_EdgeNumber;\r\n}\r\n\r\n\r\nN3DState*\r\nN3DGraph::InsertState(CK3dEntity* e) \r\n{\r\n\tif(!StateSeek(CKOBJID(e))) {\r\n\t\tTestAndReallocate();\r\n\t\tm_States[m_Size].m_Edges = NULL;\r\n\t\tm_States[m_Size].m_Data = CKOBJID(e);\r\n\t\tm_Size++;\r\n\t\treturn m_States+(m_Size-1);\r\n\t}\r\n\treturn NULL;\r\n}\r\n\t\r\n\r\nvoid\r\nN3DGraph::SetDifficult(CK3dEntity *ent,float diff){\r\n\r\n\r\n\tint sp = SeekPosition(CKOBJID(ent));\r\n\tif(sp<0) return;\r\n\r\n\tN3DState* state = GetState(sp);\r\n\tif(state) {\r\n\t\t// first we (de)activate all the leaving edges\r\n\t\tN3DEdge* edge;\r\n\t\tedge = state->m_Edges;\r\n\t\twhile(edge) {\r\n\t\t\tedge->m_Difficulty = diff ; \r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\t}\r\n\r\n\r\n}\r\n\r\nN3DEdge*\r\nN3DGraph::InsertEdge(CK3dEntity* s,CK3dEntity* e,float d) \r\n{\r\n\tif(s == e) return NULL;\r\n\r\n\tint spos = SeekPosition(CKOBJID(s));\r\n\tif(spos == -1) { // the first state isn't yet in graph\r\n\t\tInsertState(s);\r\n\t\tspos = m_Size-1;\r\n\t}\r\n\t// we check if the destination state is in the graph\r\n\tint epos = SeekPosition(CKOBJID(e));\r\n\tif(epos == -1) { \r\n\t\tInsertState(e);\r\n\t\tepos = m_Size-1;\r\n\t}\r\n\r\n\tN3DEdge* edge = m_States[spos].m_Edges;\r\n\tif(edge) {\r\n\t\twhile(edge->m_Next) {\r\n\t\t\t// if successor is already there, we didn't do anything\r\n\t\t\tif(edge->m_Successor == epos) return NULL;\r\n\t\t\tedge=edge->m_Next;\r\n\t\t}\r\n\t\tif(edge->m_Successor == epos) return NULL;\r\n\t\tedge->m_Next = CreateEdge(epos,d,GetDistance(GetState(spos),GetState(epos)));\r\n\t\treturn edge->m_Next;\r\n\t} else {\r\n\t\tm_States[spos].m_Edges = CreateEdge(epos,d,GetDistance(GetState(spos),GetState(epos)));\r\n\t\treturn m_States[spos].m_Edges;\r\n\t}\r\n}\r\n\t\r\nvoid \r\nN3DGraph::ActivateEdge(CK3dEntity* s,CK3dEntity* e,BOOL a,BOOL dyn) \r\n{\r\n\tN3DEdge* edge = EdgeSeek(CKOBJID(s),CKOBJID(e));\r\n\tif(edge) {\r\n\t\tif(dyn) {\r\n\t\t\tif(a) edge->m_Active |= STATEDYNAMICACTIVITY;\r\n\t\t\telse edge->m_Active &= ~STATEDYNAMICACTIVITY;\r\n\t\t} else {\r\n\t\t\tif(a) {\r\n\t\t\t\tedge->m_Active |= STATEBASICACTIVITY;\r\n\t\t\t\tedge->m_Active |= STATEDYNAMICACTIVITY;\r\n\t\t\t} else {\r\n\t\t\t\tedge->m_Active &= ~STATEBASICACTIVITY;\r\n\t\t\t\tedge->m_Active &= ~STATEDYNAMICACTIVITY;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid \r\nN3DGraph::ActivateState(CK3dEntity* s,BOOL a) \r\n{\r\n\tint sp = SeekPosition(CKOBJID(s));\r\n\tif(sp<0) return;\r\n\r\n\tN3DState* state = GetState(sp);\r\n\tif(state) {\r\n\t\t// first we (de)activate all the leaving edges\r\n\t\tN3DEdge* edge;\r\n\t\tedge = state->m_Edges;\r\n\t\twhile(edge) {\r\n\t\t\tif(a) edge->m_Active |= STATEDYNAMICACTIVITY;\r\n\t\t\telse edge->m_Active &= ~STATEDYNAMICACTIVITY;\r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\r\n\t\t// next we iterate all the edges to (de)activate the entering ones\r\n\t\tfor(int i=0;im_Successor == sp) {\r\n\t\t\t\t\tif(a) edge->m_Active |= STATEDYNAMICACTIVITY;\r\n\t\t\t\t\telse edge->m_Active &= ~STATEDYNAMICACTIVITY;\r\n\t\t\t\t}\r\n\t\t\t\tedge = edge->m_Next;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\t\r\n\t}\r\n}\r\n\r\nBOOL\r\nN3DGraph::SetOccupier(CK3dEntity* s,CK3dEntity* o) \r\n{\r\n\tN3DState* state = StateSeek(CKOBJID(s));\r\n\tif(state) {\r\n\t\tCK_ID id = CKOBJID(o);\r\n\t\tif(id) { // we are trying to set an occupier\r\n\t\t\tif(state->m_Occupier && state->m_Occupier!=id ) // there is already an occupier : we can't set it\r\n\t\t\t\treturn FALSE;\r\n\t\t\tstate->m_Occupier = id;\r\n\t\t} else { // we are trying to remove an occupation\r\n\t\t\tstate->m_Occupier = 0;\r\n\t\t}\r\n\t\treturn TRUE;\r\n\t}\r\n\treturn FALSE;\r\n}\r\n\r\nCK3dEntity*\r\nN3DGraph::GetOccupier(CK3dEntity* s) \r\n{\r\n\tN3DState* state = StateSeek(CKOBJID(s));\r\n\tif(state) {\r\n\t\treturn (CK3dEntity*)m_Context->GetObject(state->m_Occupier);\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nBOOL \r\nN3DGraph::IsEdgeActive(CK3dEntity* s,CK3dEntity* e) \r\n{\r\n\tN3DEdge* edge = EdgeSeek(CKOBJID(s),CKOBJID(e));\r\n\tif(edge) {\r\n\t\treturn (edge->m_Active&STATEDYNAMICACTIVITY);\r\n\t} else return false;\r\n}\r\n\r\nvoid \r\nN3DGraph::ResetActivity()\r\n{\r\n\tN3DEdge* edge;\r\n\tfor(int i=0;im_Active&STATEBASICACTIVITY) edge->m_Active |= STATEDYNAMICACTIVITY;\r\n\t\t\telse edge->m_Active &= ~STATEDYNAMICACTIVITY;\r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\t}\r\n\t\r\n}\r\n\r\nvoid \r\nN3DGraph::DeleteState(CK_ID e) \r\n{\r\n\tint ni = SeekPosition(e);\r\n\tif(ni<0) return;\r\n\t// we now destroy all the edges leaving the destroyed node\r\n\tN3DEdge* edge;\r\n\tN3DEdge* backedge;\r\n\tedge = m_States[ni].m_Edges;\r\n\twhile(edge) {\r\n\t\tbackedge = edge;\r\n\t\tedge = edge->m_Next;\r\n\t\tdelete backedge;\r\n\t\tm_EdgeNumber--;\r\n\t}\r\n\r\n\tmemmove(m_States+ni,m_States+ni+1,sizeof(N3DState)*(m_Size-ni-1));\r\n\tint* trans = new int[m_Size];\r\n\tint i;\r\n\tfor (i=0;im_Successor = trans[edge->m_Successor];\r\n\t\t\tif(edge->m_Successor == -1) {\r\n\t\t\t\tif(backedge) {\r\n\t\t\t\t\tN3DEdge* temp = backedge->m_Next;\r\n\t\t\t\t\tbackedge->m_Next = edge->m_Next;\r\n\t\t\t\t\tedge=edge->m_Next;\r\n\t\t\t\t\tdelete temp;\r\n\t\t\t\t\tm_EdgeNumber--;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tN3DEdge* temp = edge;\r\n\t\t\t\t\tm_States[i].m_Edges = edge->m_Next;\r\n\t\t\t\t\tedge = edge->m_Next;\r\n\t\t\t\t\tdelete temp;\r\n\t\t\t\t\tm_EdgeNumber--;\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tbackedge = edge;\r\n\t\t\t\tedge=edge->m_Next;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tdelete [] trans;\r\n}\r\n\r\nvoid \r\nN3DGraph::DeleteEdge(CK3dEntity* s,CK3dEntity* e) \r\n{\r\n\tint si = SeekPosition(CKOBJID(s));\r\n\tint ei = SeekPosition(CKOBJID(e));\r\n\t\r\n\tN3DEdge* edge;\r\n\tN3DEdge* backedge;\r\n\tedge=m_States[si].m_Edges;\r\n\tbackedge = NULL;\r\n\twhile(edge) {\r\n\t\tif(edge->m_Successor == ei) {\r\n\t\t\tif(backedge) {\r\n\t\t\t\tN3DEdge* temp = backedge->m_Next;\r\n\t\t\t\tbackedge->m_Next = edge->m_Next;\r\n\t\t\t\tedge=edge->m_Next;\r\n\t\t\t\tdelete temp;\r\n\t\t\t\tm_EdgeNumber--;\r\n\t\t\t} else {\r\n\t\t\t\tN3DEdge* temp = edge;\r\n\t\t\t\tm_States[si].m_Edges = edge->m_Next;\r\n\t\t\t\tedge = edge->m_Next;\r\n\t\t\t\tdelete temp;\r\n\t\t\t\tm_EdgeNumber--;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tbackedge = edge;\r\n\t\t\tedge=edge->m_Next;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nN3DEdge*\r\nN3DGraph::EdgeSeek(CK_ID s,CK_ID e)\r\n{\r\n\tint si = SeekPosition(s);\r\n\tint ei = SeekPosition(e);\r\n\t\r\n\tif(si < 0 || ei < 0)\r\n\t\treturn NULL;\r\n\r\n\tN3DEdge* edge;\r\n\tedge=m_States[si].m_Edges;\r\n\twhile(edge) {\r\n\t\tif(edge->m_Successor == ei) {\r\n\t\t\treturn edge;\r\n\t\t} else {\r\n\t\t\tedge=edge->m_Next;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nN3DState*\r\nN3DGraph::StateSeek(CK_ID s)\r\n{\r\n\tfor(int i=0;im_Active = STATEBASICACTIVITY|STATEDYNAMICACTIVITY;\r\n\tedge->m_Next = NULL;\r\n\tedge->m_Successor = e;\r\n\tedge->m_Difficulty = d;\r\n\treturn edge;\r\n}\r\n\r\nN3DEdge* \r\nN3DGraph::GetSuccessorsList(int i)\r\n{\r\n\treturn m_States[i].m_Edges;\r\n}\r\n\r\nint \r\nN3DGraph::SeekPosition(CK_ID e) const\r\n{\r\n\tfor(int i=0;i nodelist;\r\ntypedef XListIt nodelistit;\r\n\r\nCK3dEntity*\r\nN3DGraph::FindPath(CK3dEntity* start,CK3dEntity* goal,CKGroup* path,BOOL basic,BOOL occupation)\r\n{\r\n\tDWORD activity;\r\n\tif(basic) activity = STATEBASICACTIVITY;\r\n\telse activity = STATEDYNAMICACTIVITY;\r\n\r\n\tnodelist open;\r\n\tVxVector a,b,c;\r\n\r\n\tN3DState* startnode = StateSeek(CKOBJID(start));\r\n\tif(!startnode) return NULL;\r\n\tN3DState* goalnode = StateSeek(CKOBJID(goal));\r\n\tif(!goalnode) return NULL;\r\n\r\n\tstartnode->m_AStar.g = 0;\r\n\tstartnode->m_AStar.h = GetDistance(startnode,goalnode);\r\n\tstartnode->m_AStar.f = startnode->m_AStar.g + startnode->m_AStar.h;\r\n\tstartnode->m_AStar.parent = NULL;\r\n\r\n\tPushOnOpen(open,startnode);\r\n\twhile (open.Size()) {\r\n\t\tnodelistit first = open.Begin();\r\n\t\tN3DState* n = *first;\r\n\t\topen.Remove(first);\r\n\t\tn->m_Flag &= ~LISTOPEN;\r\n\t\t\r\n\t\tif(n == goalnode) {\r\n\t\t\tCK3dEntity* nodetogo = NULL;\r\n\t\t\tif(path) { // we construct an entire path\r\n\t\t\t\t// parcourir n en remontant les parent et ajouter les m_Data au path\r\n\t\t\t\twhile(n->m_AStar.parent && (n!=n->m_AStar.parent)) {\r\n\t\t\t\t\tpath->AddObjectFront((CKBeObject*)m_Context->GetObject(n->m_Data));\r\n\t\t\t\t\tn = n->m_AStar.parent;\r\n\t\t\t\t}\r\n\t\t\t\tnodetogo = (CK3dEntity*)path->GetObject(0);\r\n\t\t\t\tpath->AddObjectFront((CKBeObject*)m_Context->GetObject(n->m_Data));\r\n\t\t\t} else {\r\n\t\t\t\t// parcourir n en remontant les parent et ajouter les m_Data au path\r\n\t\t\t\tCK_ID idtogo=0;\r\n\t\t\t\twhile(n->m_AStar.parent && (n!=n->m_AStar.parent)) {\r\n\t\t\t\t\tidtogo = n->m_Data;\r\n\t\t\t\t\tn = n->m_AStar.parent;\r\n\t\t\t\t}\r\n\t\t\t\tnodetogo = (CK3dEntity*)m_Context->GetObject(idtogo);\r\n\t\t\t}\r\n\r\n\t\t\t// now we must clear the flags\r\n\t\t\tfor(int i=0;im_Edges;\r\n\t\tN3DState* n_;\r\n\t\tfloat newg;\r\n\t\twhile(edge) {\r\n\t\t\tif(edge->m_Active&activity) {\r\n\t\t\t\tn_ = m_States+edge->m_Successor;\r\n\t\t\t\tif(!occupation || !n_->m_Occupier) {\r\n\t\t\t\t\t// newg = n->m_AStar.g + GetDistance(n,n_);\r\n\t\t\t\t\tnewg = n->m_AStar.g + edge->m_Difficulty*edge->m_Distance;\r\n\t\t\t\t\tif(n_->m_Flag) {\r\n\t\t\t\t\t\tif(n_->m_AStar.g <= newg) {\r\n\t\t\t\t\t\t\tedge = edge->m_Next;\r\n\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tn_->m_AStar.parent = n;\r\n\t\t\t\t\tn_->m_AStar.g = newg;\r\n\t\t\t\t\tn_->m_AStar.h = GetDistance(n_,goalnode);\r\n\t\t\t\t\tn_->m_AStar.f = n_->m_AStar.g + n_->m_AStar.h;\r\n\t\t\t\t\t// remove n' if present in closed\r\n\t\t\t\t\tn_->m_Flag &= ~LISTCLOSE;\r\n\t\t\t\t\t// add n_ in open if it is not yet in it\r\n\t\t\t\t\tif(!(n_->m_Flag&LISTOPEN)) {\r\n\t\t\t\t\t\tPushOnOpen(open,n_);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// get the next successor\r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\t\t// closed->InsertRear(n);\r\n\t\tn->m_Flag |= LISTCLOSE;\r\n\t}\r\n\t\r\n\t// now we must clear the flags\r\n\tfor(int i=0;im_Flag |= LISTOPEN;\r\n\tnodelistit first = open.Begin();\r\n\tnodelistit last = open.End();\r\n\r\n\twhile(first != last) {\r\n\t\tif(n->m_AStar.f < (*first)->m_AStar.f) {\r\n\t\t\topen.Insert(first,n);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tfirst++;\r\n\t}\r\n\r\n\topen.Insert(first,n);\r\n}\r\n\r\nfloat\r\nN3DGraph::GetDistance(N3DState* n1,N3DState* n2)\r\n{\r\n\treturn Magnitude(n1->m_Position-n2->m_Position);\r\n}\r\n\r\nCK3dEntity* \r\nN3DGraph::GetSafeEntity(N3DState* s)\r\n{\r\n\tCK3dEntity *ent = (CK3dEntity*)m_Context->GetObject(s->m_Data);\r\n\tif(!ent) {\r\n\t\tDeleteState(s->m_Data);\r\n\t}\r\n\treturn ent;\r\n}\r\n\r\n\r\nvoid \r\nN3DGraph::CreateFromChunk(CKStateChunk* chunk)\r\n{\r\n\tchunk->StartRead();\r\n\tif(!chunk->SeekIdentifier(N3DGRAPHSTART_IDENTIFIER)) return;\r\n\r\n\tint version = chunk->ReadInt();\r\n\tif((version != N3DGRAPH_VERSION1)&&(version != N3DGRAPH_VERSION2)) return;\r\n\r\n\tm_Size = chunk->ReadInt();\r\n\tdelete[] m_States;\r\n\tif(m_Size) {\r\n\t\tm_States = new N3DState[m_Size];\r\n\t\tm_AllocatedSize = m_Size;\r\n\t} else { // size = 0\r\n\t\tm_States = new N3DState[1];\r\n\t\tm_AllocatedSize = 1;\r\n\t}\r\n\r\n\tfor(int i=0;iReadObjectID();\r\n\r\n\t\tif(version == N3DGRAPH_VERSION2) {\r\n\t\t\tm_States[i].m_Occupier = chunk->ReadObjectID();\r\n\t\t} else m_States[i].m_Occupier = 0;\r\n\r\n\t\t// edges number\r\n\t\tint size = chunk->ReadInt();\r\n\t\t\r\n\t\tN3DEdge* edge;\r\n\t\tN3DEdge* oldedge = NULL;\r\n\t\tN3DEdge* firstedge = NULL;\r\n\t\tfor(int j=0;jm_Next = edge;\r\n\t\t\t\toldedge = edge;\r\n\t\t\t}\r\n\t\t\tedge->m_Active = chunk->ReadInt();\r\n\t\t\tedge->m_Difficulty= chunk->ReadFloat();\r\n\t\t\tedge->m_Successor = chunk->ReadInt();\r\n\t\t}\r\n\t\tm_States[i].m_Edges = firstedge;\r\n\t}\r\n\r\n\t// We clean everything\r\n\tClean();\r\n\t// we calculate the distance\r\n\tUpdateDistance();\r\n}\r\n\r\nvoid N3DGraph::Clean()\r\n{\r\n\t// we check if the nodes have themselves as successors = not permitted\r\n\tint i;\r\n\tfor(i=0;im_Successor == i) { // Self edge : achtung\r\n\t\t\t\tif(backedge) {\r\n\t\t\t\t\tN3DEdge* temp = backedge->m_Next;\r\n\t\t\t\t\tbackedge->m_Next = edge->m_Next;\r\n\t\t\t\t\tedge=edge->m_Next;\r\n\t\t\t\t\tdelete temp;\r\n\t\t\t\t\tm_EdgeNumber--;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tN3DEdge* temp = edge;\r\n\t\t\t\t\tm_States[i].m_Edges = edge->m_Next;\r\n\t\t\t\t\tedge = edge->m_Next;\r\n\t\t\t\t\tdelete temp;\r\n\t\t\t\t\tm_EdgeNumber--;\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tbackedge = edge;\r\n\t\t\t\tedge=edge->m_Next;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid \r\nN3DGraph::SaveToChunk(CKStateChunk* chunk)\r\n{\r\n\tClean();\r\n\r\n\tchunk->StartWrite();\r\n\t// start identifier\r\n\tchunk->WriteIdentifier(N3DGRAPHSTART_IDENTIFIER);\r\n\t// version\r\n\tchunk->WriteInt(N3DGRAPH_VERSION2);\r\n\t// size\r\n\tchunk->WriteInt(m_Size);\r\n\t// state size\r\n\tint i;\r\n\tfor(i=0;iWriteObject(m_Context->GetObject(m_States[i].m_Data));\r\n\t\tchunk->WriteObject(m_Context->GetObject(m_States[i].m_Occupier));\r\n\t\tint count=0;\r\n\t\tN3DEdge* edge = m_States[i].m_Edges;\r\n\t\twhile(edge) { \r\n\t\t\tedge=edge->m_Next; \r\n\t\t\tcount++; \r\n\t\t}\r\n\r\n\t\tchunk->WriteInt(count);\r\n\t\tedge = m_States[i].m_Edges;\r\n\t\twhile(edge) {\r\n\t\t\tchunk->WriteInt(edge->m_Active);\r\n\t\t\tchunk->WriteFloat(edge->m_Difficulty);\r\n\t\t\tchunk->WriteInt(edge->m_Successor);\r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\t}\r\n\t// end identifier\r\n\tchunk->CloseChunk();\r\n}\r\n\r\nvoid \r\nN3DGraph::UpdateDistance()\r\n{\r\n\tint i;\r\n\tfor(i=0;iGetPosition(&a);\r\n\t\tm_States[i].m_Position = a;\r\n\t}\r\n\tfor(i=0;im_Distance = GetDistance(GetState(i),GetState(edge->m_Successor));\r\n\t\t\tedge=edge->m_Next; \r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\nvoid GraphRender(CKRenderContext* rc, void *arg)\r\n{\r\n\tCKContext* m_Context=rc->GetCKContext();\r\n\tVxDrawPrimitiveData* data = rc->GetDrawPrimitiveStructure(CKRST_DP_TR_CL_VC,3);\r\n\tCKWORD* indices = rc->GetDrawPrimitiveIndices(3);\r\n\tVxVector4* positions = (VxVector4*)data->Positions.Ptr;\r\n\tDWORD* colors = (DWORD*)data->Colors.Ptr;\r\n\r\n\tVxVector pos;\r\n\tVxVector nodepos,nodepos2;\r\n\tVxVector4 hompos;\r\n\r\n\tindices[0] = 0;\r\n\tindices[1] = 1;\r\n\tindices[2] = 2;\r\n\t\r\n\tVxVector v0(0,3,0);\r\n\tVxVector v1(3,-3,0);\r\n\tVxVector v2(-3,-3,0);\r\n\r\n\tint width = rc->GetWidth();\r\n\tint height= rc->GetHeight();\r\n\r\n\tcolors[0] = RGBAFTOCOLOR(1.0f,1.0f,1.0f,1.0f); \r\n\r\n\tVxRect ScreenSize;\r\n\trc->GetViewRect(ScreenSize);\r\n\tfloat WidthOn2=ScreenSize.GetWidth()*0.5f;\r\n\tfloat HeightOn2=ScreenSize.GetHeight()*0.5f;\r\n\tfloat DevX=ScreenSize.left+WidthOn2;\r\n\tfloat DevY=ScreenSize.top+HeightOn2;\r\n\r\n\tv0.x *=0.5f / WidthOn2;\r\n\tv1.x *=0.5f / WidthOn2;\r\n\tv2.x *=0.5f / WidthOn2;\r\n\r\n\tv0.y *=0.5f / HeightOn2;\r\n\tv1.y *=0.5f / HeightOn2;\r\n\tv2.y *=0.5f / HeightOn2;\r\n\r\n\r\n\tVxMatrix View = rc->GetViewTransformationMatrix();\r\n\tVxMatrix Projection = rc->GetProjectionTransformationMatrix();\r\n// A custom projection matrix to render homogenous coordinates\r\n\trc->SetWorldTransformationMatrix(VxMatrix::Identity());\r\n\trc->SetViewTransformationMatrix(VxMatrix::Identity());\r\n\t\r\n\r\n\r\n\r\n\tN3DGraph* graph = (N3DGraph*)arg;\r\n\tif(!graph) return;\r\n\tN3DDisplayStructure* display = graph->GetDisplay();\r\n\r\n\tXVoidArray* extents = graph->GetExtentsList();\r\n\tif(extents)\r\n\t{\r\n\t\tfor (void** ptr=extents->Begin();ptr!=extents->End();++ptr)\r\n\t\t\tdelete (N3DExtent*)*ptr;\r\n\t\textents->Clear();\r\n\t}\r\n\r\n\tN3DEdge* edge;\r\n\tN3DEdge* edgeend;\r\n\tN3DState* start;\r\n\tN3DState* end;\r\n\tCK3dEntity* startent;\r\n\tCK3dEntity* endent;\r\n\tint i;\r\n\trc->SetTexture(NULL);\r\n\trc->SetState(VXRENDERSTATE_ALPHATESTENABLE,FALSE);\r\n\trc->SetState(VXRENDERSTATE_ZENABLE,TRUE);\r\n\trc->SetState(VXRENDERSTATE_CULLMODE,VXCULL_NONE);\r\n\trc->SetState(VXRENDERSTATE_ZWRITEENABLE,FALSE);\r\n\trc->SetState(VXRENDERSTATE_ALPHABLENDENABLE,TRUE);\r\n\trc->SetState(VXRENDERSTATE_SRCBLEND,VXBLEND_SRCALPHA);\r\n\trc->SetState(VXRENDERSTATE_DESTBLEND,VXBLEND_INVSRCALPHA);\r\n\r\n\r\n\tfor(i=0;iGetStatesNumber();i++) {\r\n\t\tstart = graph->GetState(i);\r\n\t\tedge = start->m_Edges;\r\n\t\tstartent = graph->GetSafeEntity(start);\r\n\t\tif(!startent) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tstartent->GetPosition(&pos);\r\n\r\n\t\t// Transform Pos to Node_Pos & Hom_pos (ClipFlags is 0 if the vertex is inside the view frustrum)\r\n\t\tVx3DMultiplyMatrixVector(&nodepos,View,&pos);\r\n\t\tVx3DMultiplyMatrixVector4(&hompos,Projection,&nodepos);\r\n\t\tBOOL Clipped = FALSE;\r\n\t\tif ((hompos.x<-hompos.w) || (hompos.x>hompos.w) || \r\n\t\t\t(hompos.y<-hompos.w) || (hompos.y>hompos.w) ||\r\n\t\t\t(hompos.z<0) || (hompos.z>hompos.w)) {\r\n\t\t\tClipped = TRUE;\r\n\t\t}\r\n\r\n\t\t// First we draw the node\r\n\t\tdata->VertexCount=3;\r\n\t\tif( !Clipped) { // is the node in viewport\r\n\t\t\t// we can then add it to the Node Extents list\r\n\t\t\tif(extents) {\r\n\t\t\t\tN3DExtent* ext = new N3DExtent;\r\n\t\t\t\tVxVector4 screenpos = hompos;\r\n\t\t\t\tscreenpos.w = 1.0f/screenpos.w;\r\n\t\t\t\tscreenpos.x = (screenpos.x*screenpos.w*WidthOn2)+DevX;\r\n\t\t\t\tscreenpos.y = -(screenpos.y*screenpos.w*HeightOn2)+DevY;\r\n\r\n\t\t\t\text->m_Node = start->m_Data;\r\n\t\t\t\text->m_Rect.left = (long)screenpos.x - 6;\r\n\t\t\t\text->m_Rect.right= (long)screenpos.x + 6;\r\n\t\t\t\text->m_Rect.top = (long)screenpos.y - 6;\r\n\t\t\t\text->m_Rect.bottom = (long)screenpos.y + 6;\r\n\t\t\t\textents->PushBack((void *)ext);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(display && ((start->m_Data == display->m_Node)||(start->m_Data == display->m_EndNode))) { // this node is the selected one or the ending one\r\n\t\t\t\tpositions[0] = nodepos + 2 * v0 * nodepos.z;\r\n\t\t\t\tpositions[1] = nodepos + 2 * v1 * nodepos.z;\r\n\t\t\t\tpositions[2] = nodepos + 2 * v2 * nodepos.z;\r\n\t\t\t\tcolors[0] = colors[1] = colors[2] = RGBAFTOCOLOR(1.0f ,0,1.0f,0.6f); \r\n\t\t\t} else {\r\n\t\t\t\tpositions[0] = nodepos + v0 * nodepos.z;\r\n\t\t\t\tpositions[1] = nodepos + v1 * nodepos.z;\r\n\t\t\t\tpositions[2] = nodepos + v2 * nodepos.z;\r\n\t\t\t\tif(start->m_Occupier) {\r\n\t\t\t\t\tcolors[0] = colors[1] = colors[2] = RGBAFTOCOLOR(1.0f,0.0f,0.0f,0.6f); \r\n\t\t\t\t} else {\r\n\t\t\t\t\tcolors[0] = colors[1] = colors[2] = RGBAFTOCOLOR(0.3f,0.3f,1.0f,0.6f); \r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// we actually draw it\r\n\t\t\trc->DrawPrimitive(VX_TRIANGLELIST,indices,3,data);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t// Next we draw the edges\r\n\t\tdata->VertexCount=2;\r\n\t\twhile(edge) {\r\n\t\t\tBOOL MustDraw = TRUE;\r\n\t\t\tend = graph->GetState(edge->m_Successor);\r\n\t\t\tedgeend = end->m_Edges;\r\n\r\n\t\t\tif(edge->m_Active&STATEDYNAMICACTIVITY) {\r\n\t\t\t\tcolors[0]=RGBAFTOCOLOR(0,1.0f,0,0.6f);\r\n\t\t\t} else {\r\n\t\t\t\tcolors[0]=RGBAFTOCOLOR(1.0f,0,0,0.6f);\r\n\t\t\t}\r\n\t\t\tcolors[1]=RGBAFTOCOLOR(0,0,1.0f,0.6f);\r\n\t\t\twhile(edgeend) {\r\n\t\t\t\tif(edgeend->m_Successor == i) {\r\n\t\t\t\t\tif(i > edge->m_Successor) MustDraw = FALSE;\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tif(edge->m_Active&STATEDYNAMICACTIVITY) {\r\n\t\t\t\t\t\t\tcolors[0]=RGBAFTOCOLOR(0,1.0f,0.0f,0.6f);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tcolors[0]=RGBAFTOCOLOR(1.0f,0,0,0.6f);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(edgeend->m_Active&STATEDYNAMICACTIVITY) {\r\n\t\t\t\t\t\t\tcolors[1]=RGBAFTOCOLOR(0,1.0f,0,0.6f);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tcolors[1]=RGBAFTOCOLOR(1.0f,0,0,0.6f);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tedgeend = edgeend->m_Next;\r\n\t\t\t}\r\n\t\t\tif(MustDraw) {\r\n\t\t\t\tendent = graph->GetSafeEntity(end);\r\n\t\t\t\tif(!endent) return;\r\n\t\t\t\tendent->GetPosition(&pos);\r\n\t\t\t\tVx3DMultiplyMatrixVector(&nodepos2,View,&pos);\r\n\t\t\t\tpositions[0] = nodepos;\r\n\t\t\t\tpositions[1] = nodepos2;\r\n\t\t\t\trc->DrawPrimitive(VX_LINELIST,indices,2,data);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tedge = edge->m_Next;\r\n\t\t}\r\n\t}\r\n\r\n\t// We now draw the path selected\r\n\tdata->VertexCount=3;\r\n\tCKGroup* group = graph->GetPath();\r\n\tif(group) {\r\n\t\tint count = group->GetObjectCount();\r\n\t\tfor(i=1;iGetObject(i-1);\r\n\t\t\tendent = (CK3dEntity*)group->GetObject(i);\r\n\t\t\t\r\n\t\t\tstartent->GetPosition(&pos);\r\n\t\t\tVx3DMultiplyMatrixVector(&nodepos,View,&pos);\r\n\t\t\tendent->GetPosition(&pos);\r\n\t\t\tVx3DMultiplyMatrixVector(&nodepos2,View,&pos);\r\n\t\t\tpositions[2] = nodepos2;\r\n\r\n\t\t\tVxVector d = Normalize(nodepos2 - nodepos);\r\n\t\t\td.x *= nodepos.z * 0.5f / WidthOn2;\r\n\t\t\td.y *= nodepos.z * 0.5f / HeightOn2;\r\n\t\t\tVxVector n(-d.y*3.0f ,d.x*3.0f,0);\r\n\t\t\tpositions[0] = nodepos + n;\r\n\t\t\tpositions[1] = nodepos - n;\r\n\t\t\t\r\n\t\t\tcolors[0] = colors[1] = colors[2] = RGBAFTOCOLOR(1.0f,0.0f,1.0f,0.6f); \r\n\t\t\t// we actually draw it\r\n\t\t\trc->DrawPrimitive(VX_TRIANGLELIST,indices,3,data);\r\n\t\t}\r\n\t}\r\n\r\n\trc->SetViewTransformationMatrix(View);\r\n\r\n}\r\n\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n\r\n#include \"xNetTypes.h\"\r\n#include \"tnl.h\"\r\n#include \"tnlPlatform.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"tnlGhostConnection.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n\r\n#include \"xPredictionSetting.h\"\r\n#include \"vtGuids.h\"\r\n#include \"xNetConstants.h\"\r\n#include \"vtTools.h\"\r\n\r\n\r\nvoid ParamOpBGetErrorString(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetErrorString(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint error;\r\n\tp1->GetValue(&error);\r\n\tif (error < 15)\r\n\t{\r\n\t\tres->SetStringValue(sErrorStrings[error]);\r\n\t\t\r\n\t}\r\n}\r\n\r\nvoid \r\nvtNetworkManager::RegisterParameters()\r\n{\r\n\r\n\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\r\n\tpm->RegisterNewEnum(VTE_NETWORK_ERROR,\"Network Error\",\"Ok=0,\\\r\n\t\t\tIntern=1,\\\r\n\t\t\tNo connection=2,\\\r\n\t\t\tNot joined to a session=3,\\\r\n\t\t\tSession needs password=4,\\\r\n\t\t\tSession is locked=5,\\\r\n\t\t\tSession already exists=6,\\\r\n\t\t\tSession is full=7,\\\r\n\t\t\tYou must be session master=8,\\\r\n\t\t\tInvalid parameter=9,\\\r\n\t\t\tThere is not such user=10,\\\r\n\t\t\tDistributed class already exists=11,\\\r\n\t\t\tCouldn't connect to any server=12,\\\r\n\t\t\tYou already joined to a session=13,\\\r\n\t\t\tNo such session=14\");\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_GET_ERROR_TEXT, \"GetString\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_GET_ERROR_TEXT,CKPGUID_STRING,VTE_NETWORK_ERROR,CKPGUID_NONE,ParamOpBGetErrorString);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#ifndef CKPhysicManager_H\r\n\t#define CKPhysicManager_H \"$Id:$\"\r\n\r\n\r\n#include \"vtPhysXBase.h\"\r\n#include \"CKBaseManager.h\"\r\n\r\nclass MODULE_API CKPhysicManager :public CKBaseManager {\r\npublic:\r\n \r\n \r\n#ifdef DOCJETDUMMY // Docjet secret macro\r\n#else\r\n\r\n\r\n\tvirtual CKERROR OnCKInit()=0; \r\n\tvirtual CKERROR PostClearAll()=0;\r\n\tvirtual CKERROR PreSave()=0;\r\n\tvirtual CKERROR OnCKReset()=0;\r\n\tvirtual CKERROR PreProcess()=0;\r\n\r\n\tvirtual CKDWORD GetValidFunctionsMask()\t{ return CKMANAGER_FUNC_PostClearAll|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_OnCKInit|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PreSave|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PostLoad|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_OnCKReset|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PreProcess;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\tvirtual void _RegisterParameters()=0;\r\n\tvirtual void _RegisterVSL()=0;\r\n\t \r\n\tCKPhysicManager(CKContext *Context,CKGUID guid,char* name);\r\n\tvirtual ~CKPhysicManager() {}\r\n\r\n\r\n\t\r\n#endif // Docjet secret macro\r\n};\r\n\r\n// CK2 VERSION ...\r\n#endif\r\n#include \"StdAfx.h\"\r\n#include \"virtools/vtcxglobal.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \r\n#include \"pyembed.h\"\r\n#include \"InitMan.h\"\r\nusing std::cout;\r\n#include \r\n\r\n#include \"vtTools.h\"\r\n\r\nusing namespace vtTools;\r\n\r\nCKObjectDeclaration\t*FillBehaviorCallPythonFuncDecl2();\r\nCKERROR CreateCallPythonProto2(CKBehaviorPrototype **);\r\nint CallPythonFunc2(const CKBehaviorContext& behcontext);\r\nCKERROR CallPythonFuncCB2(const CKBehaviorContext& behcontext);\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 3\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorCallPythonFuncDecl2()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"CallPythonFuncEx\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x67251d33,0x402868fb));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateCallPythonProto2);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Python\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateCallPythonProto2(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"CallPythonFuncEx\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"File\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Func\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Reload\",CKPGUID_BOOL);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS|CKBEHAVIOR_VARIABLEPARAMETERINPUTS|CKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS|CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS|CKBEHAVIOR_VARIABLEOUTPUTS|CKBEHAVIOR_VARIABLEINPUTS));\r\n\tproto->SetFunction( CallPythonFunc2 );\r\n\tproto->SetBehaviorCallbackFct(CallPythonFuncCB2);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint CallPythonFunc2(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tXString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\tXString Func((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\tint reload=false; //= BehaviorTools::GetInputParameterValue(beh,2);\r\n\t\r\n\tbeh->GetInputParameterValue(2,&reload);\r\n\r\n\tvt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\tPython *py = pm->py;\r\n \r\n\tif (!pm->pLoaded)\r\n\t{\r\n\t\tpm->m_Context->OutputToConsoleEx(\"You must load Python before !\");\r\n\t\tbeh->ActivateOutput(1,false);\r\n\t\treturn CKBR_BEHAVIORERROR;\r\n\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\ttry \r\n\t\t{\r\n\t\t\tPyObject *module = pm->InsertPModule(beh->GetID(),File,reload);\r\n\t\t\tPyObject* val = PyInt_FromLong(beh->GetID());\r\n\t\t\tPyObject_SetAttrString( module , \"bid\", val);\r\n pm->CallPyModule(beh->GetID(),Func);\r\n\t\t\r\n\t\t}\r\n\t\tcatch (Python_exception ex)\r\n\t\t{\r\n\t\t\tpm->m_Context->OutputToConsoleEx(\"PyErr : \\t %s\",(CKSTRING)ex.what());\r\n\t\t\tstd::cout << ex.what() << \"pyexeption in beh : \" << beh->GetName();\r\n\t\t\tPyErr_Clear();\r\n\t\t\tbeh->ActivateOutput(1,false);\r\n\t\t}\r\n\t\tbeh->ActivateInput(0,false);\r\n\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\telse\r\n\t{\r\n\t\tfor (int i = 1 ; i < beh->GetOutputCount() ; i++ )\r\n\t\t{\r\n\t\t\t\r\n\t\t\ttry \r\n\t\t\t{\r\n\t\t\t\tPyObject *module = pm->GetPModule(beh->GetID());\r\n\t\t\t\tif(module)\r\n\t\t\t\t\tpm->CallPyModule(beh->GetID(),Func);\r\n\t\t\t}\r\n\t\t\tcatch (Python_exception ex)\r\n\t\t\t{\r\n\t\t\t\tpm->m_Context->OutputToConsoleEx(\"PyErr : \\t %s\",(CKSTRING)ex.what());\r\n\t\t\t\tstd::cout << ex.what() << \"pyexeption in beh : \" << beh->GetName();\r\n\t\t\t\tbeh->ActivateOutput(1,TRUE);\r\n\t\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t\t}\r\n\t\t\tbeh->ActivateInput(i,false);\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\treturn CKBR_OK;\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nCKERROR CallPythonFuncCB2(const CKBehaviorContext& behcontext)\r\n{\r\n\t/************************************************************************/\r\n\t/* collecting data :\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\tCKContext* ctx = beh->GetCKContext();\r\n\tCKParameterManager *pm = static_cast(ctx->GetParameterManager());\r\n\t/************************************************************************/\r\n\t/*\tprocess virtools callbacks\t\t:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\r\n\tswitch(behcontext.CallbackMessage)\r\n\t\t{\r\n\r\n\r\n\t\tcase CKM_BEHAVIOREDITED:\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t\tassert(beh && ctx);\r\n\t\t\t\r\n\t\t\tint p_count = beh->GetOutputParameterCount();\r\n\r\n\t\t\t/*while( (BEH_OUT_MIN_COUNT ) < p_count )\r\n\t\t\t{ \r\n\t\t\t\tCKDestroyObject( beh->RemoveOutputParameter( --p_count) );\r\n\t\t\t}*/\r\n\t\t\t\r\n\t\t\tXString name(\"PyFuncX: \");\r\n\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\tif ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0)\r\n\t\t\t{\r\n\t\t\t\tXString name(\"PyFileX: \");\r\n\t\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\t\tbeh->SetName(name.Str());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tbeh->SetName(name.Str());\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\tcase CKM_BEHAVIORLOAD : \r\n\t\t{\r\n\t\t\tXString name(\"PyFuncX: \");\r\n\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\tbeh->SetName(name.Str());\r\n\t\t\tif ( strlen(((CKSTRING) beh->GetInputParameterReadDataPtr(1))) ==0)\r\n\t\t\t{\r\n\t\t\t\tXString name(\"PyFileX: \");\r\n\t\t\t\tname << ((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\t\t\tbeh->SetName(name.Str());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJCreateDistanceJointDecl();\r\nCKERROR CreatePJCreateDistanceJointProto(CKBehaviorPrototype **pproto);\r\nint PJCreateDistanceJoint(const CKBehaviorContext& behcontext);\r\nCKERROR PJCreateDistanceJointCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Anchor0,\r\n\tbI_Anchor1,\r\n\tbI_Collision,\r\n\tbbI_Min,\r\n\tbbI_Max,\r\n\tbbI_Spring,\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJCreateDistanceJointDecl\r\n// FullName: FillBehaviorPJCreateDistanceJointDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJCreateDistanceJointDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJDistance\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets a distance joint between two bodies.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x52ff6b14,0x474e4938));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJCreateDistanceJointProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJCreateDistanceJointProto\r\n// FullName: CreatePJCreateDistanceJointProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJCreateDistanceJointProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJDistance\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJDistance \r\n\r\n\t
\r\n\tPJDistance is categorized in \\ref Joints\r\n\t
\r\n\t
See PJDistance.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a distance joint.\r\n\t
\r\n\t
\r\n\tDOFs removed: 1
\r\n\tDOFs remaining: 5
\r\n\t
\r\n\t\\image html distanceJoint.png\r\n\r\n\r\n\tThe distance joint tries to maintain a certain minimum and/or maximum distance between two points attached to a pair of actors. It can be set to springy in order to behave like a rubber band.\r\n\r\n\tAn example for a distance joint is a pendulum swinging on a string, or in the case of a springy distance joint, a rubber band between two objects.\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJDistance.png\r\n\r\n\tIn :triggers the process\r\n\t
\r\n\tOut :is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B :The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\tLocal Anchor 0 :A point in bodies a local space. See pJointDistance::setLocalAnchor0().\r\n\t
\r\n\t
\r\n\tLocal Anchor 1 :A point in bodies a local space. See pJointDistance::setLocalAnchor1().\r\n\t
\r\n\t
\r\n\tCollision :Enable Collision. See pJointDistance::enableCollision().\r\n\t
\r\n\t
\r\n\r\n\tMinimum Distance :The minimum rest length of the rope or rod between the two anchor points.The value must be non-zero! See pJointDistance::setMinDistance().\r\n\t
\r\n\t
\r\n\r\n\tMaximum Distance :The maximum rest length of the rope or rod between the two anchor points.\tThe value must be non-zero! See pJointDistance::setMaxDistance().\r\n\t
\r\n\t
\r\n\t\r\n\tJoint Spring: The spring to make it springy. The spring.targetValue field is not used. See pJointDistance::setSpring().\r\n\t
\r\n\t
\r\n\t\r\n\r\n\t\r\n\tMinimum Distance : Enables parameter input for minimum distance.\r\n\t
\r\n\tMaximum Distance : Enables parameter input for maximum distance.\r\n\t
\r\n\tSpring : Enables parameter input for the spring.\r\n\t
\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include PJDistance.vsl\r\n\t\r\n\t
\r\n\r\n\t

VSL : Modifiy


\r\n\t\r\n\t\\include PJDistanceModify.vsl\r\n\t\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createDistanceJoint().
\r\n\r\n\t*/\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\tproto->SetBehaviorCallbackFct( PJCreateDistanceJointCB );\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Local Anchor 0\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Local Anchor 1\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL,\"TRUE\");\r\n\t\r\n\tproto->DeclareInParameter(\"Minimum Distance\",CKPGUID_FLOAT,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Maximum Distance\",CKPGUID_FLOAT,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Joint Spring\",VTS_JOINT_SPRING,\"2.1,3.0,4.0\");\r\n\r\n\tproto->DeclareSetting(\"Minimum Distance\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Maximum Distance\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Spring\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJCreateDistanceJoint);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJCreateDistanceJoint\r\n// FullName: PJCreateDistanceJoint\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJCreateDistanceJoint(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Distance))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\r\n\t\tif(bodyA && bodyB)\r\n\t\t{\r\n\r\n\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t//anchor : \r\n\t\t\tVxVector anchor0 = GetInputParameterValue(beh,bI_Anchor0);\r\n\t\t\tVxVector anchor1 = GetInputParameterValue(beh,bI_Anchor1);\r\n\r\n\t\t\tint coll = GetInputParameterValue(beh,bI_Collision);\r\n\r\n\r\n\t\t\tfloat min= 0.0f;\r\n\t\t\tfloat max = 0.0f;\r\n\r\n\t\t\t\r\n\t\t\tDWORD minDistance;\r\n\t\t\tbeh->GetLocalParameterValue(0,&minDistance);\r\n\t\t\tif (minDistance)\r\n\t\t\t{\r\n\t\t\t\tmin = GetInputParameterValue(beh,bbI_Min);\r\n\t\t\t}\r\n\r\n\t\t\tDWORD maxDistance;\r\n\t\t\tbeh->GetLocalParameterValue(1,&maxDistance);\r\n\t\t\tif (maxDistance)\r\n\t\t\t{\r\n\t\t\t\tmax = GetInputParameterValue(beh,bbI_Max);\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\tpSpring spring;\r\n\t\t\tDWORD hasspring;\r\n\t\t\tbeh->GetLocalParameterValue(2,&hasspring);\r\n\t\t\tif (hasspring)\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_Spring);\r\n\t\t\t\tif (par)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\t\tif (rPar)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tspring = pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tspring.spring = 0.0f;\r\n\t\t\t\tspring.damper = 0.0f;\r\n\t\t\t\tspring.targetValue= 0.0f;\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\r\n\t\t\tpJointDistance *joint = static_cast(worldA->getJoint(target,targetB,JT_Distance));\r\n\t\t\r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createDistanceJoint(target,targetB,anchor0,anchor1,min,max,spring));\r\n\t\t\t}\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tjoint->setMinDistance(min);\r\n\t\t\t\tjoint->setMaxDistance(max);\r\n\t\t\t\tjoint->setLocalAnchor0(anchor0);\r\n\t\t\t\tjoint->setLocalAnchor1(anchor1);\r\n\t\t\t\tjoint->setSpring(spring);\r\n\t\t\t\tjoint->enableCollision(coll);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJCreateDistanceJointCB\r\n// FullName: PJCreateDistanceJointCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJCreateDistanceJointCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\tDWORD minDistance;\r\n\t\t\tbeh->GetLocalParameterValue(0,&minDistance);\r\n\t\t\tbeh->EnableInputParameter(bbI_Min,minDistance);\r\n\t\t\t\r\n\t\t\tDWORD maxDistance;\r\n\t\t\tbeh->GetLocalParameterValue(1,&maxDistance);\r\n\t\t\tbeh->EnableInputParameter(bbI_Max,maxDistance);\r\n\r\n\t\t\tDWORD spring;\r\n\t\t\tbeh->GetLocalParameterValue(2,&spring);\r\n\t\t\tbeh->EnableInputParameter(bbI_Spring,spring);\r\n\r\n\t\t\r\n\t\r\n\t\t\t\r\n\r\n\t\r\n\t\t\t\r\n\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\n\r\n#include \"InitMan.h\"\r\n#ifndef _WIN32_WINNT\t\r\n#define _WIN32_WINNT 0x0501\r\n#endif\t\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \"AutoLock.h\"\r\nusing namespace AutoLock;\r\nvtExternalEvent *Msg;\r\nHANDLE hmem = NULL;\r\n\r\nint post = 0;\r\nextern InitMan *_im;\r\n\r\n#pragma comment (lib,\"ATLSD.LIB\")\r\n\r\nHANDLE m_hLogItemSendEvent = ::CreateEvent(NULL,TRUE,FALSE,\"LogItemSendEventName\");\r\nHANDLE m_hShutdownEvent = ::CreateEvent(NULL,FALSE,FALSE,\"SendRcvShutdownEvent\");\r\nHANDLE m_hLogItemReceivedEvent = ::CreateEvent(NULL,FALSE,FALSE,\"LogItemReceivedEventName\");\r\nHANDLE aHandles[] = { m_hShutdownEvent , m_hLogItemSendEvent };\r\n\r\nBOOL vt_UnloadPlugin(CKGUID input);\r\nBOOL vt_ReloadPlugin(CKGUID input);\r\nBOOL recieved = false;\r\nBOOL changed = true;\r\n\r\nvoid\r\nInitMan::InitMessages(int flags,XString name)\r\n{\r\n\r\n\tm_Context->ActivateManager((CKBaseManager*) this,true);\t\r\n\r\n\tif( NULL != ( m_hMMFile = CreateFileMapping( INVALID_HANDLE_VALUE,\r\n\t\tNULL,PAGE_READWRITE,0,\r\n\t\tsizeof( vtExternalEvent ),\"sharedMemFile\" ) ))//_T(\"LogSndRcvMMF\") )))\r\n\t{\r\n\t\tif( NULL != (m_pData = (vtExternalEvent*)::MapViewOfFile(m_hMMFile,\r\n\t\t\tFILE_MAP_READ | FILE_MAP_WRITE, \r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t\tsizeof( vtExternalEvent* )) ) )\r\n\t\t{\r\n\t\t\t//\t\t\t\t\treturn S_OK;\r\n\t\t}\r\n\t}\r\n\t//return HRESULT_FROM_WIN32( ::GetLastError( ) );\r\n}\r\n\r\n\r\n\r\nCKERROR InitMan::PostProcess()\r\n{\t\r\n\tif (!changed){\r\n\r\n\t\tSetEvent( m_hShutdownEvent );\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nvoid\r\nInitMan::PerformMessages()\r\n{\r\n\r\n//\tm_Context->OutputToConsole(\"performe\");\r\n\tHRESULT hr = S_OK;\r\n\r\n\tUSES_CONVERSION;\r\n\r\n\tswitch( ::WaitForMultipleObjects(sizeof(aHandles) /sizeof(HANDLE),&(aHandles[0]),FALSE,1))\r\n\t{\r\n\r\n\tcase WAIT_OBJECT_0:\t\r\n\t\t{\t\r\n\t\t\tSetEvent( m_hShutdownEvent );\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase WAIT_OBJECT_0 + 1:\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tCLockableMutex m_mtxMMFile(\"sharedMem\");\r\n\t\t\t\tCAutoLockT< CLockableMutex > lock(&m_mtxMMFile, 5000 );\r\n\t\t\t\tvtExternalEvent *pLI = reinterpret_cast(m_pData);\r\n\r\n\t\t\t\tif (pLI)\r\n\t\t\t\t{\r\n\t\t\t\t\tm_Context->OutputToConsole(\"vtPluginProxy : msg recieved\",FALSE);\r\n\t\t\t\t\t\r\n\t\t\t\t\tXString command(pLI->command);\r\n\t\t\t\t\tm_Context->OutputToConsoleEx(command.Str());\r\n\t\t\t\t\tXString commandArg(pLI->commandArg);\r\n\t\t\t\t\tif (!command.Compare(\"unload\"))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t/*vtGUID inputGuid;\r\n\t\t\t\t\t\tinputGuid.FromString(commandArg);\r\n\t\t\t\t\t\tm_Context->OutputToConsole(\"vtPluginProxy : Unload Plugin\",FALSE);\r\n\t\t\t\t\t\tvt_UnloadPlugin(inputGuid.GetVirtoolsGUID());*/\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (!command.Compare(\"reload\"))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t/*vtGUID inputGuid;\r\n\t\t\t\t\t\tinputGuid.FromString( commandArg );\r\n\t\t\t\t\t\tm_Context->OutputToConsole(\"vtPluginProxy : Reload Plugin\",FALSE);\r\n\t\t\t\t\t\tvt_ReloadPlugin(inputGuid.GetVirtoolsGUID());*/\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tchanged = true;\r\n\t\t\t\t\tSetEvent( m_hLogItemReceivedEvent );\r\n\t\t\t\t\t::ResetEvent(m_hShutdownEvent);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn ;\r\n\t\t\t}\r\n\t\t\tcatch( CAutoLockTimeoutExc )\r\n\t\t\t{\r\n\t\t\t\thr = HRESULT_FROM_WIN32( WAIT_TIMEOUT );\r\n\t\t\t}\r\n\t\t\tcatch( CAutoLockWaitExc& e )\r\n\t\t\t{\r\n\t\t\t\thr = HRESULT_FROM_WIN32( e.GetLastError() );\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\tdefault:\r\n\t\tint op=0;\r\n//\t\tATLASSERT(0);\r\n\t}\r\n}\r\n\r\n/********************************************************************\r\n\tcreated:\t2009/01/05\r\n\tcreated:\t5:1:2009 18:18\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtTools\\SDK\\Include\\Core\\vtCModuleDefines.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtTools\\SDK\\Include\\Core\r\n\tfile base:\tvtCModuleDefines\r\n\tfile ext:\th\r\n\tauthor:\r\n\r\n\tpurpose:\r\n*********************************************************************/\r\n#ifndef __VTCMODULES_DEFINES_H_\r\n\t#define __VTCMODULES_DEFINES_H_\r\n\r\n#include \r\n\r\n#define VTCMODULE_NAME VTCX_API_PREFIX(\"TOOLS\")\r\n#define VTCMODULE_ATTRIBUTE_CATAEGORY VTCMODULE_NAME\r\n\r\n#define VTM_TOOL_MANAGER_GUID\t\tCKGUID(0x7a9a6475,0x6fb90c74)\r\n\r\n#define VTBB_PLG_GUID\t\tCKGUID(0x3262afb,0x230b4434)\r\n\r\n#endif\r\n#include \"StdAfx.h\"\r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"IParameter.h\"\r\n\r\n#include \"vtStructHelper.h\"\r\n\r\n\r\nstatic IParameter* gIPar = NULL;\r\n\r\n#include \"pMisc.h\"\r\n#include \"pVehicleAll.h\"\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\nint IParameter::copyTo(pLinearInterpolation& dst,CKParameter*src)\r\n{\r\n\tif (!src)\r\n\t\treturn false;\r\n\r\n\tint gear = 0;\r\n\tfloat ratio = 0.0f;\r\n\r\n\r\n\tCKStructHelper sHelper(src);\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tfor (int i = 0 ; i < sHelper.GetMemberCount() ; i++)\r\n\t{\r\n\t\tCK_ID* paramids = static_cast(src->GetReadDataPtr());\r\n\t\tCKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i]));\r\n\t\tif (sub)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tdst.insert(GetValueFromParameterStruct(sub,0,false),\r\n\t\t\t\tGetValueFromParameterStruct(sub,1,false)\r\n\t\t\t\t);\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n\r\nint IParameter::copyTo(pGearBox *dst,CKParameter*src)\r\n{\r\n\tif (!src || !dst)\r\n\t\treturn false;\r\n\t\r\n\tint gear = 0;\r\n\tfloat ratio = 0.0f;\r\n\r\n\tfor (int i = 0 ; i < 7 ; i++)\r\n\t{\r\n\t\tCK_ID* paramids = static_cast(src->GetReadDataPtr());\r\n\t\tCKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i]));\r\n\t\tif (sub)\r\n\t\t{\r\n\t\t\tdst->gearRatio[i] = \tGetValueFromParameterStruct(sub,0,false);\r\n\t\t\tdst->gearInertia[i] =\tGetValueFromParameterStruct(sub,1,false);\r\n\r\n\t\t\tdst->getGearRatios().insert((float)i,dst->gearRatio[i]);\r\n\t\t\tdst->getGearTensors().insert((float)i,dst->gearInertia[i]);\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nint IParameter::copyTo(pVehicleBrakeTable& dst,CKParameter*src)\r\n{\r\n\t\r\n\tint result = 0;\r\n\r\n\tfor (int i = 0 ; i < BREAK_TABLE_ENTRIES ; i ++)\r\n\t\tdst.brakeEntries[i] = GetValueFromParameterStruct(src,i);\r\n\r\n\treturn true;\r\n\r\n\r\n}\r\nint IParameter::copyTo(CKParameter*dst,pWheelDescr src)\r\n{\r\n\tif (!dst)return false;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\tSetParameterStructureValue(dst,E_WD_SPRING_BIAS,src.springBias,false);\r\n\tSetParameterStructureValue(dst,E_WD_SPRING_RES,src.springRestitution,false);\r\n\tSetParameterStructureValue(dst,E_WD_DAMP,src.springDamping,false);\r\n\tSetParameterStructureValue(dst,E_WD_MAX_BFORCE,src.maxBrakeForce,false);\r\n\tSetParameterStructureValue(dst,E_WD_FFRONT,src.frictionToFront,false);\r\n\tSetParameterStructureValue(dst,E_WD_FSIDE,src.frictionToSide,false);\r\n\tSetParameterStructureValue(dst,E_WD_FLAGS,src.wheelFlags,false);\r\n\tSetParameterStructureValue(dst,E_WD_INVERSE_WHEEL_MASS,src.inverseWheelMass,false);\r\n\tSetParameterStructureValue(dst,E_WD_SFLAGS,src.wheelShapeFlags,false);\r\n\tSetParameterStructureValue(dst,E_WD_SUSPENSION,src.wheelSuspension,false);\r\n\r\n\r\n \r\n\r\n}\r\n\r\nint IParameter::copyTo(pWheelDescr& dst,CKParameter*src)\r\n{\r\n\tint result = 1;\r\n\tif (!src)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tusing namespace vtTools::ParameterTools;\r\n\t\r\n\tdst.wheelSuspension = GetValueFromParameterStruct(src,E_WD_SUSPENSION);\r\n\tdst.springRestitution= GetValueFromParameterStruct(src,E_WD_SPRING_RES);\r\n\tdst.springBias = GetValueFromParameterStruct(src,E_WD_SPRING_BIAS);\r\n\tdst.springDamping= GetValueFromParameterStruct(src,E_WD_DAMP);\r\n\r\n\tdst.maxBrakeForce= GetValueFromParameterStruct(src,E_WD_MAX_BFORCE);\r\n\tdst.frictionToSide= GetValueFromParameterStruct(src,E_WD_FSIDE);\r\n\tdst.frictionToFront= GetValueFromParameterStruct(src,E_WD_FFRONT);\r\n\r\n\tCKParameterOut *pOld = GetParameterFromStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\tif (pOld)\r\n\t{\r\n\t\tif (pOld->GetGUID() == CKPGUID_FLOAT)\r\n\t\t{\r\n\t\t\tdst.inverseWheelMass= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\t\t}\r\n\r\n\t\tif (pOld->GetGUID() == CKPGUID_INT)\r\n\t\t{\r\n\t\t\tdst.wheelApproximation= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\t\r\n\tdst.wheelFlags= (WheelFlags)GetValueFromParameterStruct(src,E_WD_FLAGS);\r\n\tdst.wheelShapeFlags=(WheelShapeFlags) GetValueFromParameterStruct(src,E_WD_SFLAGS);\r\n\r\n\r\n\tCKParameterOut *parLatFunc = GetParameterFromStruct(src,E_WD_LAT_FUNC);\r\n\tCKParameterOut *parLongFunc = GetParameterFromStruct(src,E_WD_LONG_FUNC);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* XML Setup ? */\r\n\t/************************************************************************/\r\n\tint xmlLinkId= GetValueFromParameterStruct(src,E_WD_XML);\r\n\tbool wIsXML=false;\r\n\tbool latIsXML= false;\r\n\tbool longIsXML=false;\r\n\r\n\tXString nodeName;\r\n\tif ( xmlLinkId !=0 )\r\n\t{\r\n\t\tnodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_WHEEL_SETTINGS,xmlLinkId);\r\n\t\tpFactory::Instance()->loadWheelDescrFromXML(dst,nodeName.CStr(),pFactory::Instance()->getDefaultDocument());\r\n\t\twIsXML =true;\r\n\t\tif (!dst.isValid())\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Wheel Description was invalid\");\r\n\t\t}\r\n\t\tif (dst.latFunc.xmlLink!=0)\r\n\t\t{\r\n\t\t\tlatIsXML=true;\r\n\t\t}\r\n\r\n\t\tif (dst.longFunc.xmlLink!=0)\r\n\t\t{\r\n\t\t\tlongIsXML=true;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!latIsXML)\r\n\t{\r\n\t\tdst.latFunc = pFactory::Instance()->createTireFuncFromParameter(parLatFunc);\r\n\t}\r\n\r\n\tif (!longIsXML)\r\n\t{\r\n\t\tdst.longFunc= pFactory::Instance()->createTireFuncFromParameter(parLongFunc);\r\n\t}\r\n\r\n\tif (wIsXML)\r\n\t{\r\n\t\tIParameter::Instance()->copyTo((CKParameterOut*)src,dst);\r\n\r\n\t}\r\n\tif (longIsXML)\r\n\t{\r\n\t\tpFactory::Instance()->copyTo(GetParameterFromStruct(src,E_WD_LONG_FUNC),dst.longFunc);\r\n\t}\r\n\r\n\tif (latIsXML)\r\n\t{\r\n\t\tpFactory::Instance()->copyTo(GetParameterFromStruct(src,E_WD_LAT_FUNC),dst.latFunc);\r\n\t}\r\n\r\n\treturn result;\r\n}\r\nint IParameter::copyTo(pConvexCylinderSettings& dst,CKParameter*src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tcopyTo(dst.radius, GetParameterFromStruct(src,PS_CC_RADIUS_REFERENCED_VALUE),true);\r\n\tcopyTo(dst.height, GetParameterFromStruct(src,PS_CC_HEIGHT_REFERENCED_VALUE),true);\r\n\r\n\tdst.approximation = GetValueFromParameterStruct(src,PS_CC_APPROXIMATION);\r\n\tdst.buildLowerHalfOnly = GetValueFromParameterStruct(src,PS_CC_BUILD_LOWER_HALF_ONLY);\r\n\tdst.convexFlags = (pConvexFlags)GetValueFromParameterStruct(src,PS_CC_EXTRA_SHAPE_FLAGS);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Calculate Forward Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.forwardAxis = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS);\r\n\tdst.forwardAxisRef = GetValueFromParameterStruct(src,PS_CC_FORWARD_AXIS_REF);\r\n\r\n\tCK3dEntity *f = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.forwardAxisRef);\r\n\tif (f)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\tf->GetOrientation(&dir,&up,&right);\r\n\t\tf->TransformVector(&dst.forwardAxis,&dir);\r\n\t\tdst.forwardAxis.Normalize();\r\n\t}\r\n\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Calculate Down Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.downAxis = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS);\r\n\tdst.downAxisRef = GetValueFromParameterStruct(src,PS_CC_DOWN_AXIS_REF);\r\n\t\r\n\tCK3dEntity *d = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.downAxisRef);\r\n\tif (d)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\td->GetOrientation(&dir,&up,&right);\r\n\t\td->TransformVector(&dst.downAxis,&up);\r\n\t\tdst.downAxis.Normalize();\r\n\t}\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Calculate Right Axis, optionally referenced by an entity \r\n\t//\r\n\tdst.rightAxis = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS);\r\n\t\r\n\tdst.rightAxisRef = GetValueFromParameterStruct(src,PS_CC_RIGHT_AXIS_REF);\r\n\tCK3dEntity *r = (CK3dEntity*)GetPMan()->m_Context->GetObject(dst.rightAxisRef);\r\n\tif (r)\r\n\t{\r\n\t\tVxVector dir,up,right;\r\n\t\tr->GetOrientation(&dir,&up,&right);\r\n\t\tr->TransformVector(&dst.rightAxis,&right);\r\n\t\tdst.rightAxis.Normalize();\r\n\t}\r\n\r\n\r\n\t\r\n\r\n\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(CKParameter*dst,pConvexCylinderSettings& src)\r\n{\r\n\r\n\tcopyTo(src.radius, GetParameterFromStruct(dst,PS_CC_RADIUS_REFERENCED_VALUE),true);\r\n\tcopyTo(src.height, GetParameterFromStruct(dst,PS_CC_HEIGHT_REFERENCED_VALUE),true);\r\n\r\n\tSetParameterStructureValue(dst,PS_CC_APPROXIMATION,src.approximation,false);\r\n\tSetParameterStructureValue(dst,PS_CC_BUILD_LOWER_HALF_ONLY,src.buildLowerHalfOnly,false);\r\n\tSetParameterStructureValue(dst,PS_CC_EXTRA_SHAPE_FLAGS,src.convexFlags,false);\r\n\t\r\n\tSetParameterStructureValue(dst,PS_CC_FORWARD_AXIS,src.forwardAxis,false);\r\n\tSetParameterStructureValue(dst,PS_CC_DOWN_AXIS,src.downAxis,false);\r\n\tSetParameterStructureValue(dst,PS_CC_RIGHT_AXIS,src.rightAxis,false);\r\n\r\n\tCK3dEntity *f = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.forwardAxisRef);\r\n\tif (f)\r\n\t\tSetParameterStructureValue(dst,PS_CC_FORWARD_AXIS_REF,f->GetID(),false);\r\n\r\n\t\r\n\tCK3dEntity *d = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.downAxisRef);\r\n\tif (d)\r\n\t\tSetParameterStructureValue(dst,PS_CC_DOWN_AXIS_REF,d->GetID(),false);\r\n\r\n\r\n\tCK3dEntity *r = (CK3dEntity*)GetPMan()->m_Context->GetObject(src.rightAxisRef);\r\n\tif (r)\r\n\t\tSetParameterStructureValue(dst,PS_CC_RIGHT_AXIS_REF,r->GetID(),false);\r\n\r\n\treturn 1;\r\n\r\n\r\n}\r\n\r\nint IParameter::copyTo(pMassSettings& dst,CKParameter*src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tdst.newDensity= GetValueFromParameterStruct(src,PS_BM_DENSITY,false);\r\n\tdst.totalMass= GetValueFromParameterStruct(src,PS_BM_TOTAL_MASS,false);\r\n\tdst.localPosition = GetValueFromParameterStruct(src,PS_BM_PIVOT_POS,false);\r\n\tdst.localOrientation = GetValueFromParameterStruct(src,PS_BM_PIVOT_ROTATION,false);\r\n\tdst.massReference= GetValueFromParameterStruct(src,PS_BM_PIVOT_REFERENCE,false);\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(CKParameter*dst,pMassSettings src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(dst);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\tSetParameterStructureValue(dst,PS_BM_DENSITY,src.newDensity,false);\r\n\tSetParameterStructureValue(dst,PS_BM_TOTAL_MASS,src.totalMass,false);\r\n\tSetParameterStructureValue(dst,PS_BM_PIVOT_POS,src.localPosition,false);\r\n\tSetParameterStructureValue(dst,PS_BM_PIVOT_ROTATION,src.localOrientation,false);\r\n\tSetParameterStructureValue(dst,PS_BM_PIVOT_REFERENCE,src.massReference,false);\r\n\r\n\treturn 1;\r\n\r\n}\r\n\r\n\r\nint IParameter::copyTo(CKParameter*dst,pPivotSettings src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(dst);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tSetParameterStructureValue(dst,PS_BP_LINEAR,src.localPosition,false);\r\n\tSetParameterStructureValue(dst,PS_BP_ANGULAR,src.localOrientation,false);\r\n\tSetParameterStructureValue(dst,PS_BP_REFERENCE,src.pivotReference,false);\r\n\r\n\t/*\r\n\tdst.localPosition = GetValueFromParameterStruct(src,PS_BP_LINEAR,false);\r\n\tdst.localOrientation = GetValueFromParameterStruct(src,PS_BP_ANGULAR,false);\r\n\tdst.pivotReference = GetValueFromParameterStruct(src,PS_BP_REFERENCE,false);\r\n\r\n\t*/\r\n\r\n\treturn 1;\r\n\r\n}\r\n\r\nint IParameter::copyTo(pPivotSettings& dst,CKParameter*src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tdst.localPosition = GetValueFromParameterStruct(src,PS_BP_LINEAR,false);\r\n\tdst.localOrientation = GetValueFromParameterStruct(src,PS_BP_ANGULAR,false);\r\n\tdst.pivotReference = GetValueFromParameterStruct(src,PS_BP_REFERENCE,false);\r\n\treturn 1;\r\n\r\n}\r\n\r\nint IParameter::copyTo(pObjectDescr&dst,CK3dEntity*src,int copyFlags)\r\n{\r\n\r\n\tpRigidBody *srcBody = GetPMan()->getBody(src);\r\n\tNxActor *actor = NULL;\r\n\tpObjectDescr*initDescr = NULL;\r\n\tNxShape *mainShape= NULL;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\tif (!src || !srcBody || !srcBody->getMainShape())\r\n\t\treturn 0;\r\n\r\n\r\n\tinitDescr = srcBody->getInitialDescription();\r\n\tactor = srcBody->getActor();\r\n\tmainShape = srcBody->getMainShape();\r\n\r\n\r\n\r\n\tif (!initDescr || !actor )\r\n\t\treturn 0;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// general settings\r\n\t//\r\n\tdst.hullType = (HullType)vtAgeia::getHullTypeFromShape(srcBody->getMainShape());\r\n \r\n\t\r\n\tsrcBody->recalculateFlags(0);\r\n\tdst.flags = (BodyFlags)srcBody->getFlags();\r\n\tdst.worlReference = srcBody->getWorld()->getReference()->GetID();\r\n\tdst.density = initDescr->density;\r\n\tdst.mask = initDescr->mask;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : optimization\r\n\t//\r\n\tif ( (copyFlags & PB_CF_OPTIMIZATION) )\r\n\t{\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// damping + sleeping\r\n\t\t//\r\n\t\tdst.optimization.angDamping = actor->getAngularDamping();\r\n\t\tdst.optimization.linDamping = actor->getLinearDamping();\r\n\t\tdst.optimization.linSleepVelocity = actor->getSleepLinearVelocity();\r\n\t\tdst.optimization.angSleepVelocity = actor->getSleepAngularVelocity();\r\n\t\tdst.optimization.sleepEnergyThreshold = actor->getSleepEnergyThreshold();\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// transformation flags\r\n\t\t//\r\n\r\n\t\tdst.optimization.transformationFlags = (BodyLockFlags)srcBody->getTransformationsLockFlags();\r\n\r\n\r\n\t\tdst.optimization.solverIterations = actor->getSolverIterationCount();\r\n\t\tdst.optimization.dominanceGroup = actor->getDominanceGroup();\r\n\t\tdst.optimization.compartmentGroup = initDescr->optimization.compartmentGroup;\r\n\t}\r\n\t\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : collision\r\n\t//\r\n\t//if ( (dst.mask & OD_Optimization ) )\r\n\tif ( (copyFlags & PB_CF_COLLISION ) )\r\n\t{\r\n\t\tdst.collisionGroup = mainShape->getGroup();\r\n\r\n\t\tNxGroupsMask nxMask = mainShape->getGroupsMask();\r\n\t\tdst.groupsMask.bits0 = nxMask.bits0;\r\n\t\tdst.groupsMask.bits1 = nxMask.bits1;\r\n\t\tdst.groupsMask.bits2 = nxMask.bits2;\r\n\t\tdst.groupsMask.bits3 = nxMask.bits3;\r\n\t\tdst.skinWidth = mainShape->getSkinWidth();\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : ccd\r\n\t//\r\n\t//if ( (dst.mask & OD_CCD) )\r\n\tif ( (copyFlags & OD_CCD ) && (dst.mask & OD_CCD) )\r\n\t{\r\n\r\n\t\tdst.ccd.flags = initDescr->ccd.flags;\r\n\t\tdst.ccd.meshReference = initDescr->ccd.meshReference;\r\n\t\tdst.ccd.motionThresold = initDescr->ccd.motionThresold;\r\n\t\tdst.ccd.scale = initDescr->ccd.scale;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : capsule\r\n\t//\r\n\tif ( (copyFlags && OD_Capsule) && (dst.mask & OD_Capsule) )\r\n\t\tdst.capsule = initDescr->capsule;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : convex cylinder\r\n\t//\r\n\tif ( (copyFlags && OD_ConvexCylinder) && (dst.mask & OD_ConvexCylinder) )\r\n\t\tdst.convexCylinder = initDescr->convexCylinder;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : material\r\n\t//\r\n\tif ( (copyFlags && OD_Material) && (dst.mask & OD_Material) )\r\n\t\tdst.material = initDescr->material;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// specific override : pivot\r\n\t//\r\n\tif ( (copyFlags && OD_Pivot) )\r\n\t{\r\n\t\t//dst.pivotOffsetAngular\t= getFrom(mainShape->getLocalOrientation() );\r\n\t\tdst.pivotOffsetLinear\t= getFrom( mainShape->getLocalPosition() );\r\n\t\t//dst.pivotOffsetReference= initDescr->pivotOffsetReference;\r\n\t}\r\n\r\n\tif ( (copyFlags && PB_CF_MASS_SETTINGS) )\r\n\t{\r\n\t\t//dst.pivotOffsetAngular\t= getFrom(mainShape->getLocalOrientation() );\r\n\t\tdst.massOffsetLinear\t= getFrom(actor->getCMassLocalPosition());\r\n\t\t//dst.pivotOffsetReference= initDescr->pivotOffsetReference;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// correct data mask :\r\n\t//\r\n\r\n\tDWORD mask = (DWORD)(dst.mask);\r\n\tmask &=~((OD_Pivot));\r\n\r\n\r\n\r\n\tif ( !(copyFlags & PB_CF_PIVOT_SETTINGS) )\r\n\t\tmask &=~((OD_Pivot));\r\n\r\n\tif ( !(copyFlags & PB_CF_MASS_SETTINGS) )\r\n\t\tmask &=~(OD_Mass);\r\n\r\n\tif ( !(copyFlags & PB_CF_OPTIMIZATION) )\r\n\t\tmask &=~(OD_Optimization);\r\n\r\n\tif ( !(copyFlags & PB_CF_COLLISION) )\r\n\t\tmask &=~(OD_Collision);\r\n\r\n\tif ( !(copyFlags & PB_CF_CCD) )\r\n\t\tmask &=~(OD_CCD);\r\n\r\n\tif ( !(copyFlags & PB_CF_CAPSULE) )\r\n\t\tmask &=~(OD_Capsule);\r\n\r\n\t\r\n\tif ( !(copyFlags & PB_CF_CONVEX_CYLINDER) )\r\n\t\tmask&=~(OD_ConvexCylinder);\r\n\t\r\n\tif ( !(copyFlags & PB_CF_MATERIAL) )\r\n\t\tmask &=~(OD_Material);\r\n\r\n\treturn 1;\r\n}\r\n\r\n\r\n\r\n\r\nint IParameter::copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Retrieve the value :\r\n\t//\r\n\tdst.value = GetValueFromParameterStruct(src,PS_ARL_VALUE);\r\n\r\n\tdst.referenceAxis = GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT_AXIS);\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate the value basing on the given objects local box and an axis. \r\n\t//\r\n\tCK_ID idRef= GetValueFromParameterStruct(src,PS_ARL_REF_OBJECT);\r\n\tCKBeObject *object = (CKBeObject*)GetPMan()->GetContext()->GetObject(idRef);\r\n\r\n\tif (!object)\r\n\t\treturn -1;\r\n\r\n\tdst.reference = object;\r\n\r\n\tif (!evaluate)return -1;\r\n\r\n\r\n\tVxVector size(0.0f);\r\n\tif (object->GetClassID() == CKCID_3DOBJECT )\r\n\t{\r\n\t\tCK3dEntity *ent3D = (CK3dEntity*)object;\r\n\t\tif (ent3D)\r\n\t\t{\r\n\t\t\tsize = ent3D->GetBoundingBox(true).GetSize();\r\n\t\t}\r\n\t}else if(object->GetClassID() == CKCID_MESH)\r\n\t{\r\n\t\tCKMesh *mesh = (CKMesh*)object;\r\n\t\tif (mesh)\r\n\t\t{\r\n\t\t\tsize = mesh->GetLocalBox().GetSize();\r\n\t\t}\r\n\t}\r\n\tdst.value = size[dst.referenceAxis];\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(CKParameter *dst, pAxisReferencedLength &src, bool evaluate)\r\n{\r\n\tSetParameterStructureValue(dst,PS_ARL_VALUE,src.value,false);\r\n\tSetParameterStructureValue(dst,PS_ARL_REF_OBJECT_AXIS,src.referenceAxis,false);\r\n\tif (src.reference)\r\n\t{\r\n\t\tSetParameterStructureValue(dst,PS_ARL_REF_OBJECT,src.reference->GetID(),false);\r\n\t}\r\n\treturn 1;\r\n}\r\n\r\n\r\n\r\nint IParameter::copyTo(pCapsuleSettingsEx& dst,CKParameter*src)\r\n{\r\n\t//SetParameterStructureValue(dst,PS_BM_DENSITY,src.newDensity,false);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tpFactory::Instance()->copyTo(dst.radius, GetParameterFromStruct(src,PS_BCAPSULE_RADIUS_REFERENCED_VALUE),false);\r\n\tpFactory::Instance()->copyTo(dst.height, GetParameterFromStruct(src,PS_PCAPSULE_HEIGHT_REFERENCED_VALUE),false);\r\n\r\n\treturn 1;\r\n}\r\nint IParameter::copyTo(CKParameter*dst,pCapsuleSettingsEx src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(dst);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tcopyTo(GetParameterFromStruct(dst,PS_BCAPSULE_RADIUS_REFERENCED_VALUE),src.radius,false);\r\n\tcopyTo(GetParameterFromStruct(dst,PS_PCAPSULE_HEIGHT_REFERENCED_VALUE),src.height,false);\r\n\r\n\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(pCCDSettings& dst,CKParameter*src)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n#ifdef _DEBUG\r\n\tassert(src);\r\n#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//----------------------------------------------------------------\r\n\r\n\t//\r\n\t// general\r\n\t//\r\n\r\n\tdst.flags = GetValueFromParameterStruct(src,PS_B_CCD_FLAGS,false);\r\n\tdst.motionThresold = GetValueFromParameterStruct(src,PS_B_CCD_MOTION_THRESHOLD,false);\r\n\tdst.scale= GetValueFromParameterStruct(src,PS_B_CCD_SCALE,false);\r\n\tdst.meshReference= GetValueFromParameterStruct(src,PS_B_CCD_MESH_REFERENCE,false);\r\n\r\n\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(pOptimization& dst,CKParameter*src)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t#endif \r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Retrieve all sub parameters : \r\n\t//\r\n\tCKParameterOut *parSleeping = GetParameterFromStruct(src,PS_BO_SLEEPING);\r\n\tCKParameterOut *parDamping = GetParameterFromStruct(src,PS_BO_DAMPING);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// general\r\n\t//\r\n\t\r\n\tdst.transformationFlags = (BodyLockFlags) GetValueFromParameterStruct(src,PS_BO_LOCKS,false);\r\n\t\r\n\tdst.solverIterations = GetValueFromParameterStruct(src,PS_BO_SOLVER_ITERATIONS,false);\r\n\tdst.compartmentGroup = GetValueFromParameterStruct(src,PS_BO_COMPARTMENT_ID,false);\r\n\tdst.dominanceGroup\t= GetValueFromParameterStruct(src,PS_BO_DOMINANCE_GROUP,false);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sleeping\r\n\t//\r\n\tdst.angSleepVelocity = GetValueFromParameterStruct(parSleeping,PS_BS_ANGULAR_SLEEP,false);\r\n\tdst.linSleepVelocity = GetValueFromParameterStruct(parSleeping,PS_BS_LINEAR_SLEEP,false);\r\n\tdst.sleepEnergyThreshold = GetValueFromParameterStruct(parSleeping,PS_BS_THRESHOLD,false);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Damping\r\n\t//\r\n\tdst.angDamping = GetValueFromParameterStruct(parDamping,PS_BD_ANGULAR,false);\r\n\tdst.linDamping= GetValueFromParameterStruct(parDamping,PS_BD_LINEAR,false);\r\n\r\n\treturn 1;\r\n\r\n}\r\n\r\nint IParameter::copyTo(CKParameter*dst,pObjectDescr*src)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(dst);\r\n\t\tassert(src);\r\n\t#endif \r\n\r\n\t\t\r\n\t\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Retrieve all sub parameters : \r\n\t//\r\n\tCKParameterOut *parBCommon = GetParameterFromStruct(dst,PS_COMMON_SETTINGS);\r\n\tCKParameterOut *parBCollision = GetParameterFromStruct(dst,PS_COLLISION_SETTINGS);\r\n\t\t//CKParameterOut *parBCCD = GetParameterFromStruct(parBCollision,PS_BC_CCD_SETUP);\r\n\t\tCKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK);\r\n\t\r\n\t#ifdef _DEBUG\r\n\t\tassert(parBCommon);\r\n\t\t//assert(parBPivot);\r\n\t\t//assert(parBCCD);\r\n\t\tassert(parBCollision);\r\n\t#endif \r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\ttransfer\t\t\r\n\t//\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// common \r\n\t//\r\n\tSetParameterStructureValue(parBCommon,PS_BC_HULL_TYPE,src->hullType);\r\n\tSetParameterStructureValue(parBCommon,PS_BC_DENSITY,src->density);\r\n\tSetParameterStructureValue(parBCommon,PS_BC_FLAGS,src->flags);\r\n\tSetParameterStructureValue(parBCommon,PS_BC_WORLD,src->worlReference);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// XML\r\n\t//\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision\r\n\t//\r\n\tSetParameterStructureValue(parBCollision,PS_BC_GROUP,src->collisionGroup);\r\n\tSetParameterStructureValue(parBCollision,PS_BC_SKINWITDH,src->skinWidth);\r\n\r\n\r\n\tSetParameterStructureValue(parGroupsMask,0,src->groupsMask.bits0);\r\n\tSetParameterStructureValue(parGroupsMask,1,src->groupsMask.bits1);\r\n\tSetParameterStructureValue(parGroupsMask,2,src->groupsMask.bits2);\r\n\tSetParameterStructureValue(parGroupsMask,3,src->groupsMask.bits3);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// CCD\r\n\t//\r\n\r\n\t/*\r\n\tSetParameterStructureValue(parBCCD,PS_B_CCD_MOTION_THRESHOLD,src->ccdMotionThresold);\r\n\tSetParameterStructureValue(parBCCD,PS_B_CCD_FLAGS,src->ccdFlags);\r\n\tSetParameterStructureValue(parBCCD,PS_B_CCD_MESH_REFERENCE,src->ccdMeshReference);\r\n\tSetParameterStructureValue(parBCCD,PS_B_CCD_SCALE,src->ccdScale);\r\n\r\n\t*/\r\n\treturn 1;\r\n\r\n}\r\n\r\n\r\nint IParameter::copyTo(pCollisionSettings &dst,CKParameter*src)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t#endif \r\n\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tCKParameterOut *parGroupsMask = GetParameterFromStruct(src,PS_BC_GROUPSMASK);\r\n\t\r\n\t// Sanity checks\r\n\t#ifdef _DEBUG\r\n\t\tassert(parGroupsMask);\r\n\t#endif \r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision Setup \r\n\t//\r\n\tdst.collisionGroup = GetValueFromParameterStruct(src,PS_BC_GROUP,false);\r\n\r\n\t//\t\r\n\tdst.groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0);\r\n\tdst.groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1);\r\n\tdst.groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2);\r\n\tdst.groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3);\r\n\r\n\tdst.skinWidth = GetValueFromParameterStruct(src,PS_BC_SKINWITDH,false);\r\n\treturn 1;\r\n}\r\n\r\nint IParameter::copyTo(pObjectDescr*dst,CKParameter*src)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(dst);\r\n\t\tassert(src);\r\n\t#endif \r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Possible this function is invoked due the loading of a cmo file whilst core is not started yet : \r\n\t//\r\n\tCKStructHelper sHelper(src);\r\n\tif(sHelper.GetMemberCount() == 0)\r\n\t\treturn 0;\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Retrieve all sub parameters : \r\n\t//\r\n\tCKParameterOut *parBCommon = GetParameterFromStruct(src,PS_COMMON_SETTINGS);\r\n\t//CKParameterOut *parBPivot = GetParameterFromStruct(src,PS_PIVOT);\r\n\t//CKParameterOut *parBMass = GetParameterFromStruct(src,PS_MASS);\r\n\tCKParameterOut *parBCollision = GetParameterFromStruct(src,PS_COLLISION_SETTINGS);\r\n\t\t//CKParameterOut *parBCCD = GetParameterFromStruct(parBCollision,PS_BC_CCD_SETUP);\r\n\t\tCKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK);\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(parBCommon);\r\n\t\t//assert(parBPivot);\r\n\t\t//assert(parBMass);\r\n\t\tassert(parBCollision);\r\n\t#endif \r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Common settings as hull type, body flags, ...\r\n\t//\r\n\r\n\tdst->hullType =(HullType)GetValueFromParameterStruct(parBCommon,PS_BC_HULL_TYPE,false);\r\n\tdst->flags = (BodyFlags)GetValueFromParameterStruct(parBCommon,PS_BC_FLAGS,false);\r\n\t/*dst->transformationFlags = GetValueFromParameterStruct(parBCommon,PS_BC_TFLAGS,false);*/\r\n\tdst->worlReference = GetValueFromParameterStruct(parBCommon,PS_BC_WORLD,false);\r\n\tdst->density = GetValueFromParameterStruct(parBCommon,PS_BC_DENSITY,false);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Pivot Offset\r\n\t//\r\n\r\n\t/*\r\n\tdst->pivotOffsetLinear = GetValueFromParameterStruct(parBPivot,PS_BP_LINEAR,false);\r\n\tdst->pivotOffsetAngular = GetValueFromParameterStruct(parBPivot,PS_BP_ANGULAR,false);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Mass\tOffset\r\n\t//\r\n\t\r\n\tdst->density = GetValueFromParameterStruct(parBMass,PS_BM_DENSITY,false);\r\n\tdst->totalMass = GetValueFromParameterStruct(parBMass,PS_BM_TOTAL_MASS,false);\r\n\tdst->massOffsetLinear = GetValueFromParameterStruct(parBMass,PS_BM_PIVOT_POS,false);\r\n\t*/\r\n\t//dst->massOffsetAngular = GetValueFromParameterStruct(parBMass,PS_BM_PIVOT_ROTATION,false);\r\n\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision Setup \r\n\t//\r\n\tdst->collisionGroup = GetValueFromParameterStruct(parBCollision,PS_BC_GROUP,false);\r\n\t\r\n\t//\t\r\n\tdst->groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0);\r\n\tdst->groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1);\r\n\tdst->groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2);\r\n\tdst->groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3);\r\n\r\n\tdst->skinWidth = GetValueFromParameterStruct(parBCollision,PS_BC_SKINWITDH,false);\r\n\t\r\n\tdst->collision.groupsMask.bits0 = GetValueFromParameterStruct(parGroupsMask,0);\r\n\tdst->collision.groupsMask.bits1 = GetValueFromParameterStruct(parGroupsMask,1);\r\n\tdst->collision.groupsMask.bits2 = GetValueFromParameterStruct(parGroupsMask,2);\r\n\tdst->collision.groupsMask.bits3 = GetValueFromParameterStruct(parGroupsMask,3);\r\n\t\r\n\tdst->collision.skinWidth = GetValueFromParameterStruct(parBCollision,PS_BC_SKINWITDH,false);\r\n\tdst->collision.collisionGroup = GetValueFromParameterStruct(parBCollision,PS_BC_GROUP,false);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// CCD Settings\r\n\t//\r\n\t/*dst->ccdFlags = GetValueFromParameterStruct(parBCCD,PS_B_CCD_FLAGS,false);\r\n\tdst->ccdMotionThresold= GetValueFromParameterStruct(parBCCD,PS_B_CCD_MOTION_THRESHOLD,false);\r\n\tdst->ccdScale = GetValueFromParameterStruct(parBCCD,PS_B_CCD_SCALE,false);\r\n\tdst->ccdMeshReference = GetValueFromParameterStruct(parBCCD,PS_B_CCD_MESH_REFERENCE,false);\r\n\t*/\r\n\r\n\tdst->mask << OD_Collision;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Misc\r\n\t//\r\n\tdst->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\r\n\treturn 1;\r\n}\r\nIParameter* IParameter::Instance()\r\n{\r\n\tif (!gIPar)\r\n\t{\r\n\t\tgIPar = new IParameter(GetPMan());\r\n\t}\r\n\treturn gIPar;\r\n}\r\n\r\n\r\n\r\nIParameter::IParameter(PhysicManager*_pManager) : mManager(_pManager)\r\n{\r\n\tgIPar = this;\r\n\r\n}#include \"xNetEnumerations.h\"\r\n#include \"xDistTools.h\"\r\n\r\nnamespace xDistTools\r\n{\r\n\r\nxNString ValueTypeToString(int valueType)\r\n{\r\n\r\n\tswitch(valueType)\r\n\t{\r\n\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\treturn xNString(\"3D Vector\");\r\n\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\treturn xNString(\"2D Vector\");\r\n\t\tcase E_DC_PTYPE_INT:\r\n\t\t\treturn xNString(\"Integer\");\r\n\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\treturn xNString(\"Float\");\r\n\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\treturn xNString(\"String\");\r\n\t}\r\n\r\n\treturn xNString(\"Unknown\");\r\n}\r\n\r\nint SuperTypeToValueType(int superType)\r\n{\r\n\r\n\tswitch(superType)\r\n\t{\r\n\tcase vtVECTOR2D:\r\n\t\treturn E_DC_PTYPE_2DVECTOR;\r\n\tcase vtVECTOR:\r\n\t\treturn E_DC_PTYPE_3DVECTOR;\r\n\tcase vtINTEGER:\r\n\t\treturn E_DC_PTYPE_INT;\r\n\tcase vtQUATERNION:\r\n\t\treturn E_DC_PTYPE_QUATERNION;\r\n\tcase vtSTRING:\r\n\t\treturn E_DC_PTYPE_STRING;\r\n\tcase vtBOOL:\r\n\t\treturn E_DC_PTYPE_INT;\r\n\tcase vtFLOAT:\r\n\t\treturn E_DC_PTYPE_FLOAT;\r\n\tdefault :\r\n\t\treturn E_DC_PTYPE_UNKNOWN;\r\n\r\n\t}\r\n\treturn E_DC_PTYPE_UNKNOWN;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint ValueTypeToSuperType(int valueType)\r\n{\r\n\r\n\r\n\r\n\tswitch(valueType)\r\n\t{\r\n\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\treturn vtVECTOR;\r\n\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\treturn vtVECTOR2D;\r\n\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\treturn vtQUATERNION;\r\n\t\tcase E_DC_PTYPE_INT:\r\n\t\t\treturn vtINTEGER;\r\n\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\treturn vtFLOAT;\r\n\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\treturn vtSTRING;\r\n\t}\r\n\treturn vtUNKNOWN;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nint NativeTypeToValueType(int nativeType)\r\n{\r\n\tint result = 0;\r\n\tswitch(nativeType)\r\n\t{\r\n\t\tcase E_DC_3D_NP_LOCAL_POSITION:\r\n\t\tcase E_DC_3D_NP_LOCAL_SCALE:\r\n\t\tcase E_DC_3D_NP_WORLD_POSITION:\r\n\t\tcase E_DC_3D_NP_WORLD_SCALE:\r\n\t\t\treturn E_DC_PTYPE_3DVECTOR;\r\n\t\tcase E_DC_3D_NP_WORLD_ROTATION:\r\n\t\tcase E_DC_3D_NP_LOCAL_ROTATION:\r\n\t\t\treturn E_DC_PTYPE_QUATERNION;\r\n\t\tcase E_DC_3D_NP_VISIBILITY:\r\n\t\t\treturn E_DC_PTYPE_BOOL;\r\n\t break;\r\n\t}\r\n\treturn E_DC_PTYPE_UNKNOWN;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL::StringPtr NativeTypeToString(int nativeType)\r\n{\r\n\r\n\tswitch(nativeType)\r\n\t{\r\n\t\tcase E_DC_3D_NP_LOCAL_POSITION:\r\n\t\t\treturn TNL::StringPtr(\"Local Position\");\r\n\t\t\tbreak;\r\n\t\tcase E_DC_3D_NP_LOCAL_ROTATION:\r\n\t\t\treturn TNL::StringPtr(\"Local Rotation\");\r\n\t\t\tbreak;\r\n\t\tcase E_DC_3D_NP_LOCAL_SCALE:\r\n\t\t\treturn TNL::StringPtr(\"Local Scale\");\r\n\t\tcase E_DC_3D_NP_WORLD_POSITION:\r\n\t\t\treturn TNL::StringPtr(\"World Position\");\r\n\t\t\tbreak;\r\n\t\tcase E_DC_3D_NP_WORLD_ROTATION:\r\n\t\t\treturn TNL::StringPtr(\"World Rotation\");\r\n\t\t\tbreak;\r\n\t\tcase E_DC_3D_NP_WORLD_SCALE:\r\n\t\t\treturn TNL::StringPtr(\"World Scale\");\r\n\t\t\tbreak;\r\n\t\tcase E_DC_3D_NP_VISIBILITY:\r\n\t\t\treturn TNL::StringPtr(\"Visibility\");\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\treturn TNL::StringPtr(\"Unknown\");\r\n\t\t\tbreak;\r\n\t}\r\n\treturn TNL::StringPtr(\"null\");\r\n}\r\n\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBPhysicalizeDecl();\r\nCKERROR CreatePBPhysicalizeProto(CKBehaviorPrototype **pproto);\r\nint PBPhysicalize(const CKBehaviorContext& behcontext);\r\nCKERROR PBPhysicalizeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n/*\tbbI_TargetObject=0,*/\r\n\tbbI_Flags=0,\r\n\tbbI_HullType,\r\n\tbbI_Density,\r\n\tbbI_SkinWidth,\r\n\tbbI_MassShift,\r\n\tbbI_ShapeShift,\r\n\tbbI_TargetWorld,\r\n\tbbI_Hierachy,\r\n\tbbI_NewDensity,\r\n\tbbI_TotalMass,\r\n bbI_Material\r\n\r\n};\r\n\r\nenum bSettings\r\n{\r\n\tbbS_USE_DEFAULT_WORLD,\r\n\t//bbS_USE_WORLD_SLEEP_SETTINGS,\r\n\t//bbS_USE_WORLD_DAMPING_SETTINGS,\r\n\tbbS_USE_WORLD_MATERIAL,\r\n\tbbS_ADD_ATTRIBUTES\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPBPhysicalizeDecl\r\n// FullName: FillBehaviorPBPhysicalizeDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBPhysicalizeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBPhysicalize\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Adds an entity to the physic engine.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x186f7d29,0xe8901dc));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBPhysicalizeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBPhysicalizeProto\r\n// FullName: CreatePBPhysicalizeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBPhysicalizeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBPhysicalize\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/* \\page TestBlock\r\n\tPBPhysicalize \r\n\r\n\tPBPhysicalize is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tApplies an impulsive torque defined in the actor local coordinate frame to the actor.
\r\n\tSee pBPhysicalize.cmo for example.\r\n\t

Technical Information

\r\n\r\n\t\\image html PBPhysicalize.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t\r\n\tFlags: Flags to determine common properties for the desired body. See #BodyFlags.\r\n\t
\r\n\tHulltype: The desired shape type. See #HullType.\r\n\t
\r\n\t\tYou can add or remove sub shapes on the fly by pRigidBody::addSubShape() or #PBAddShape.
\r\n\t\t\tThe intial shape can NOT changed after the bodies registration.
\r\n\t\t
\r\n\tDensity: Density of the initial shape. This will be only used if
\r\n\t\t\"Hierarchy\" =false and
\r\n\t\t\"New Density\" !=0.0f or \"Total Mass\" != 0.0f. #pRigidBody::updateMassFromShapes() can update the mass dynamically.\r\n\t
\r\n\t
\r\n\tSkin Width: Specifies by how much shapes can interpenetrate. See #pRigidBody::setSkinWidth().\r\n\t
\r\n\t
\r\n\tMass Offset: Moves the mass center in the local bodies space.\r\n\t
\r\n\t
\r\n\tPivot Offset: Position of the initial shape in the bodies space.\r\n\t
\r\n\t
\r\n\tTarget World: Multiple worlds are provided. If not specified, it belongs to an automatically created default world(pDefaultWorld).This parameter must be enabled through the settings of this building block.\r\n\t
\r\n\t
\r\n\tHierarchy: If enabled, this function will parse the entities hierarchy and attaches children as additional collisions shapes. Those children must have the physic attribute attached whereby the sub shape flag must be \r\n\t\t\tenabled(#BodyFlags). Sub shapes can be attached by #addSubShape() or #PBAddShape afterwards.\r\n\t
\r\n\t
\r\n\tNew Density: Density scale factor of the shapes belonging to the body.If you supply a non-zero total mass, \r\n\tthe bodies mass and inertia will first be computed as\tabove and then scaled to fit this total mass. See #pRigidBody::updateMassFromShapes().\r\n\t
\r\n\t
\r\n\tTotal Mass: Total mass if it has sub shapes.If you supply a non-zero density, \r\n\tthe bodies mass and inertia will first be computed as above and then scaled by this factor.See #pRigidBody::updateMassFromShapes().\r\n\t
\r\n\t
\r\n\tMaterial: The material of this body. This parameter must be enabled through the settings of this building block.By default it is using the worlds material. The material of a body can be specified explicity by attaching\r\n\ta physic material attribute on the entity or its mesh or the meshs material. This is the lookup order :
\r\n\t- building block input parameter
\r\n\t- entity mesh
\r\n\t- entities mesh material \r\n\t
\r\n\t
\r\n\t
\r\n\tUse Default World: Enables input for the world reference.\r\n\t
\r\n\tUse Worlds Material: Enables input for a physic material.\r\n\t
\r\n\tAdd Attributes: Attaches the physic attribute to the entity.\r\n\t
\r\n\t\r\n\r\n\t
\r\n\t

Warning

\r\n\r\n\t

Note


\r\n\t
\r\n\t
\r\n\t\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createBody().
\r\n\t\r\n\t

VSL


\r\n\t\t\r\n\t\t\\include PBPhysicalize.cpp\r\n\t\t\r\n\r\n\t*/\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Flags\",VTF_BODY_FLAGS,\"Moving Object,Updates in Virtools,Auto Disable,World Gravity,Enabled,Collision\");\r\n\tproto->DeclareInParameter(\"Hull type\",VTE_COLLIDER_TYPE,\"Sphere\");\r\n\tproto->DeclareInParameter(\"Density\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"Skin Width\",CKPGUID_FLOAT,\"-1.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Mass Offset\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Pivot Offset\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Target World Reference\",CKPGUID_3DENTITY,\"pDefaultWorld\");\r\n\tproto->DeclareInParameter(\"Hierarchy\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareInParameter(\"New Density\",CKPGUID_FLOAT,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Total Mass\",CKPGUID_FLOAT,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Material\",VTS_MATERIAL);\r\n\t\t\r\n\tproto->DeclareSetting(\"Use Default World\",CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareSetting(\"Use Worlds Material\",CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareSetting(\"Add Attributes\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct( PBPhysicalizeCB );\r\n\tproto->SetFunction(PBPhysicalize);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBPhysicalize\r\n// FullName: PBPhysicalize\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBPhysicalize(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//basic parameters\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//settings\r\n\tint useDWorld;\tbeh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);\r\n//\tint useWorldSS;\tbeh->GetLocalParameterValue(bbS_USE_WORLD_SLEEP_SETTINGS,&useWorldSS);\r\n//\tint useWorldDS;\tbeh->GetLocalParameterValue(bbS_USE_WORLD_DAMPING_SETTINGS,&useWorldDS);\r\n\tint useWorldM;\tbeh->GetLocalParameterValue(bbS_USE_WORLD_MATERIAL,&useWorldM);\r\n\tint addAttributes;\tbeh->GetLocalParameterValue(bbS_ADD_ATTRIBUTES,&addAttributes);\r\n\r\n\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *referenceObject = (CK3dEntity *) beh->GetTarget();\r\n\tif( !referenceObject ) return CKBR_OWNERERROR;\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the world : \r\n\tCK3dEntity*worldRef = NULL;\r\n\tif (!useDWorld)\r\n\t{\r\n\t\tworldRef = (CK3dEntity *) beh->GetInputParameterObject(bbI_TargetWorld);\r\n\t}\r\n\r\n\t// the world : \r\n\tpWorld *world=GetPMan()->getWorld(worldRef,referenceObject); \r\n\tif (!world)\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\r\n\t}\r\n\r\n\tpRigidBody*result = world->getBody(referenceObject);\r\n\tif (result)\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//pick up some parameters : \r\n\tint flags = GetInputParameterValue(beh,bbI_Flags);\r\n\tint hType = GetInputParameterValue(beh,bbI_HullType);\r\n\tfloat density = GetInputParameterValue(beh,bbI_Density);\r\n\tfloat skinWidth = GetInputParameterValue(beh,bbI_SkinWidth);\r\n\tint hierarchy = GetInputParameterValue(beh,bbI_Hierachy);\r\n\tfloat newDensity = GetInputParameterValue(beh,bbI_NewDensity);\r\n\tfloat totalMass = GetInputParameterValue(beh,bbI_TotalMass);\r\n\r\n\r\n\r\n\r\n\tVxVector massOffset = GetInputParameterValue(beh,bbI_MassShift);\r\n\tVxVector shapeOffset = GetInputParameterValue(beh,bbI_ShapeShift);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we remove the old physic attribute : \r\n\tif (referenceObject->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(GetPMan()->GetPAttribute());\r\n\t}\r\n\treferenceObject->SetAttribute(GetPMan()->GetPAttribute());\r\n\t\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HIRARCHY,&hierarchy);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HULLTYPE,&hType);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_BODY_FLAGS,&flags);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_DENSITY,&density);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_NEW_DENSITY,&newDensity);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_TOTAL_MASS,&totalMass);\r\n\tSetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);\r\n\t//SetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);\r\n\r\n\tCK_ID wID = world->getReference()->GetID();\r\n\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->GetPAttribute(),E_PPS_WORLD,&wID);\r\n\t\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Material : \r\n\tif (!useWorldM)\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(GetPMan()->att_surface_props))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(GetPMan()->att_surface_props);\r\n\t\t}\r\n\t\t\r\n\t\treferenceObject->SetAttribute(GetPMan()->att_surface_props);\r\n\r\n\t\tCKParameterIn *pMatIn = beh->GetInputParameter(bbI_Material);\r\n\t\tCKParameter *pMat = pMatIn->GetRealSource();\r\n\t\tCKParameterOut* pout = referenceObject->GetAttributeParameter(GetPMan()->att_surface_props);\r\n\t\tint error = pout->CopyValue(pMat);\r\n\t\tpout->Update();\r\n\t}\r\n\r\n\tpRigidBody *body = pFactory::Instance()->createRigidBodyFull(referenceObject,worldRef);\r\n\tif (body)\r\n\t{\r\n\t\tbody->translateLocalShapePosition(shapeOffset);\r\n\t}\r\n\t//GetPMan()->checkWorlds();\r\n\r\n\tif (!addAttributes)\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(GetPMan()->GetPAttribute());\r\n\t\treferenceObject->RemoveAttribute(GetPMan()->att_surface_props);\r\n\t}\r\n\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBPhysicalizeCB\r\n// FullName: PBPhysicalizeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBPhysicalizeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\tDWORD useDWorld;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);\r\n \t\t\tbeh->EnableInputParameter(bbI_TargetWorld,!useDWorld);\r\n\r\n/*\r\n\t\t\tDWORD useDWorldSS;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_USE_WORLD_SLEEP_SETTINGS,&useDWorldSS);\r\n\t\t\tbeh->EnableInputParameter(bbI_SleepSettings,!useDWorldSS);\r\n\r\n\t\t\tDWORD useDWorldDS;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_USE_WORLD_DAMPING_SETTINGS,&useDWorldDS);\r\n\t\t\tbeh->EnableInputParameter(bbI_DampingSettings,!useDWorldDS);\r\n*/\r\n\t\t\tDWORD useDWorldM;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_USE_WORLD_MATERIAL,&useDWorldM);\r\n\t\t\tbeh->EnableInputParameter(bbI_Material,!useDWorldM);\r\n\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n#include \"vtBBHelper.h\"\r\n#include \"xDebugTools.h\"\r\n\r\nvoid PhysicManager::_cleanOrphanedJoints()\r\n{\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tNxU32\tjointCount = w->getScene()->getNbJoints();\r\n\t\tif (jointCount)\r\n\t\t{\r\n\t\t\tNxArray< NxJoint * >joints;\r\n\t\t\tw->getScene()->resetJointIterator();\r\n\t\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t\t{\r\n\t\t\t\tNxJoint\t*j = w->getScene()->getNextJoint();\r\n\t\t\t\tNxActor *a= NULL;\r\n\t\t\t\tNxActor *b= NULL;\r\n\t\t\t\tif (a == NULL && b==NULL)\r\n\t\t\t\t{\r\n\t\t\t\t\tw->getScene()->releaseJoint(*j);\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\t\t\t\t\t/*if(mJoint)\r\n\t\t\t\t\t\tmJoint->setJoint(NULL);\r\n\t\t\t\t\tSAFE_DELETE(mJoint);\r\n\t\t\t\t\t*/\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n}\r\n\r\n\r\nvoid PhysicManager::_removeObjectsFromOldScene(CKScene *lastScene)\r\n{\r\n\tif (!lastScene)\r\n\t\treturn;\r\n\r\n\tCKSceneObjectIterator objIt = lastScene->GetObjectIterator();\r\n\tCKObject *tpObj;\r\n\twhile(!objIt.End())\r\n\t{\t\r\n\t\tCK3dEntity *tpObj = (CK3dEntity *)GetContext()->GetObject(objIt.GetObjectID());\r\n\t\tif (tpObj)\r\n\t\t{\r\n\t\t\tpRigidBody *body = getBody(tpObj);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteBody(body);\r\n\t\t\t}\r\n\t\t}\r\n\t\tobjIt++;\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::copyToAttributes( pObjectDescr src,CK3dEntity *dst )\r\n{\r\n\r\n\tif (!dst)\r\n\t\treturn;\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\tint attTypeActor = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\tint attTypeMaterial = GetPMan()->getAttributeTypeByGuid(VTS_MATERIAL);\r\n\tint attTypeOptimization = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR_OPTIMIZATION);\r\n\tint attTypeCCD = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CCD_SETTINGS);\r\n\tint attTypePivot = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_PIVOT_OFFSET);\r\n\tint attTypeMass = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_MASS_SETUP);\r\n\tint attTypeCapsule= GetPMan()->getAttributeTypeByGuid(VTS_CAPSULE_SETTINGS_EX);\r\n\tint attTypeCCyl= GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// disable attribute callback \r\n\t//\r\n\tCKAttributeManager *aMan = GetPMan()->GetContext()->GetAttributeManager();\r\n\tif (aMan)\r\n\t{\r\n\t\t//aMan->SetAttributeCallbackFunction(attTypeActor)\r\n\t}\r\n\r\n\tCK3dEntity *referenceObject = dst;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we remove the old physic attribute : \r\n\tif (referenceObject->HasAttribute(attTypeActor))\r\n\t{\r\n\t\treferenceObject->RemoveAttribute(attTypeActor);\r\n\t}\r\n\treferenceObject->SetAttribute(attTypeActor);\r\n\r\n\r\n\tCKParameterOut* actorAttribute = referenceObject->GetAttributeParameter(attTypeActor);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Common Settings\r\n\t//\r\n\tCKParameterOut *parBCommon = GetParameterFromStruct(actorAttribute,PS_COMMON_SETTINGS);\r\n\tif (parBCommon)\r\n\t{\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_HULL_TYPE,src.hullType);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_FLAGS,src.flags);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_DENSITY,src.density);\r\n\t\tSetParameterStructureValue(parBCommon,PS_BC_WORLD,src.worlReference);\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision Setting\r\n\t//\r\n\tCKParameterOut *parBCollision = GetParameterFromStruct(actorAttribute,PS_COLLISION_SETTINGS);\r\n\tCKParameterOut *parGroupsMask = GetParameterFromStruct(parBCollision,PS_BC_GROUPSMASK);\r\n\tif (parBCollision)\r\n\t{\r\n\t\tSetParameterStructureValue(parBCollision,PS_BC_GROUP,src.collisionGroup);\r\n\t\tSetParameterStructureValue(parBCollision,PS_BC_SKINWITDH,src.skinWidth);\r\n\r\n\t\tif (parGroupsMask)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parGroupsMask,0,src.groupsMask.bits0);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,1,src.groupsMask.bits1);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,2,src.groupsMask.bits2);\r\n\t\t\tSetParameterStructureValue(parGroupsMask,3,src.groupsMask.bits3);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Optimization\r\n\t//\r\n\tif (src.mask & OD_Optimization)\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeOptimization))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeOptimization);\r\n\t\t}\r\n\r\n\t\treferenceObject->SetAttribute(attTypeOptimization);\r\n\r\n\r\n\t\tCKParameterOut *parBOptimization = referenceObject->GetAttributeParameter(attTypeOptimization);\r\n\t\tif (parBOptimization)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_LOCKS,src.optimization.transformationFlags);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_SOLVER_ITERATIONS,src.optimization.solverIterations);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_DOMINANCE_GROUP,src.optimization.dominanceGroup);\r\n\t\t\tSetParameterStructureValue(parBOptimization,PS_BO_COMPARTMENT_ID,src.optimization.compartmentGroup);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// sleeping\r\n\t\t//\r\n\t\tCKParameterOut *parBSleeping = GetParameterFromStruct(parBOptimization,PS_BO_SLEEPING);\r\n\t\tif (parBSleeping)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_ANGULAR_SLEEP,src.optimization.angSleepVelocity);\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_LINEAR_SLEEP,src.optimization.linSleepVelocity);\r\n\t\t\tSetParameterStructureValue(parBSleeping,PS_BS_THRESHOLD,src.optimization.sleepEnergyThreshold);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// damping\r\n\t\t//\r\n\t\tCKParameterOut *parBDamping = GetParameterFromStruct(parBOptimization,PS_BO_DAMPING);\r\n\t\tif (parBDamping)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBDamping,PS_BD_ANGULAR,src.optimization.angDamping);\r\n\t\t\tSetParameterStructureValue(parBDamping,PS_BD_LINEAR,src.optimization.linDamping);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// CCD\r\n\t//\r\n\tif (src.mask & OD_CCD )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeCCD))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeCCD);\r\n\t\t}\r\n\r\n\t\treferenceObject->SetAttribute(attTypeCCD);\r\n\r\n\t\tCKParameterOut *parBCCD = referenceObject->GetAttributeParameter(attTypeCCD);\r\n\t\tif (parBCCD)\r\n\t\t{\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_MOTION_THRESHOLD,src.ccd.motionThresold);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_FLAGS,src.ccd.flags);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_SCALE,src.ccd.scale);\r\n\t\t\tSetParameterStructureValue(parBCCD,PS_B_CCD_MESH_REFERENCE,src.ccd.meshReference);\r\n\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Material\r\n\t//\r\n\tif (src.mask & OD_Material )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeMaterial))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeMaterial);\r\n\t\t}\r\n\r\n\t\treferenceObject->SetAttribute(attTypeMaterial);\r\n\r\n\t\tCKParameterOut *parBMaterial = referenceObject->GetAttributeParameter(attTypeMaterial);\r\n\t\tif (parBMaterial)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(parBMaterial,src.material);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Pivot\r\n\t//\r\n\tif (src.mask & OD_Pivot )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypePivot))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypePivot);\r\n\t\t}\r\n\t\treferenceObject->SetAttribute(attTypePivot);\r\n\t\tCKParameterOut *parBPivot = referenceObject->GetAttributeParameter(attTypePivot);\r\n\t\tif (parBPivot)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(parBPivot,src.pivot);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Mass\r\n\t//\r\n\tif (src.mask & OD_Mass )\r\n\t{\r\n\t\tif (referenceObject->HasAttribute(attTypeMass))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeMass);\r\n\t\t}\r\n\t\treferenceObject->SetAttribute(attTypeMass);\r\n\t\tCKParameterOut *parBMass = referenceObject->GetAttributeParameter(attTypeMass);\r\n\t\tif (parBMass)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(parBMass,src.mass);\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Capsule\r\n\t//\r\n\tif (src.mask & OD_Capsule)\r\n\t{\r\n\r\n\t\tif (referenceObject->HasAttribute(attTypeCapsule))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeCapsule);\r\n\t\t}\r\n\t\treferenceObject->SetAttribute(attTypeCapsule);\r\n\t\tCKParameterOut *parBCapsule = referenceObject->GetAttributeParameter(attTypeCapsule);\r\n\t\tif (parBCapsule)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(parBCapsule,src.capsule);\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// convex Cylinder\r\n\t//\r\n\tif (src.mask & OD_ConvexCylinder)\r\n\t{\r\n\r\n\t\tif (referenceObject->HasAttribute(attTypeCCyl))\r\n\t\t{\r\n\t\t\treferenceObject->RemoveAttribute(attTypeCCyl);\r\n\t\t}\r\n\t\treferenceObject->SetAttribute(attTypeCCyl);\r\n\t\tCKParameterOut *parBCCyl= referenceObject->GetAttributeParameter(attTypeCCyl);\r\n\t\tif (parBCCyl)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(parBCCyl,src.convexCylinder);\r\n\t\t}\r\n\t}\r\n}\r\n\r\npVehicle*PhysicManager::getVehicle(CK3dEntity*bodyReference)\r\n{\r\n\r\n\tpRigidBody *body=getBody(bodyReference);\r\n\tif (bodyReference && body )\r\n\t{\r\n\t\treturn body->getVehicle();\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npWheel2*PhysicManager::getWheel(CK3dEntity*wheelReference)\r\n{\r\n\r\n\tpRigidBody *body=getBody(wheelReference);\r\n\tif (wheelReference && body )\r\n\t{\r\n\t\treturn static_cast(body->getWheel(wheelReference));\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nNxShape *PhysicManager::getSubShape(CK3dEntity*referenceObject)\r\n{\r\n\tif (!referenceObject)\r\n\t\treturn NULL;\r\n\r\n\tpRigidBody *body = getBody(referenceObject);\r\n\tif (!body)\r\n\t\treturn NULL;\r\n\r\n\t\r\n\treturn body->getSubShape(referenceObject);\r\n\r\n\r\n}\r\nNxCCDSkeleton* PhysicManager::getCCDSkeleton(CKBeObject *shapeReference)\r\n{\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\tint s = getWorlds()->Size();\r\n\r\n\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tNxActor** actors = w->getScene()->getActors();\r\n\t\tint nbActors = w->getScene()->getNbActors();\r\n\t\twhile(nbActors--)\r\n\t\t{\r\n\t\t\tNxActor* actor = *actors++;\r\n\t\t\tif(actor->userData != NULL)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = actor->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)actor->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\tif (sInfo)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nvoid PhysicManager::createWorlds(int flags)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\t//assert(m_DefaultSleepingSettings());\r\n//\tassert(getWorlds());\r\n#endif\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_world_object);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\t\tCK3dEntity*target = static_cast(*it);\r\n\t\tpWorld *world = getWorld(target->GetID());\r\n\r\n\t\tconst char*name = target->GetName();\r\n\t\tif (world == getDefaultWorld() )\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//world not registered :\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//at first we check for an attached sleeping settings attribute, when not, we use this->DefaultDefaultSleepingSettings \r\n//\t\t\tpSleepingSettings *sleepSettings = target->HasAttribute(att_sleep_settings) ? \r\n//\t\t\t\tpFactory::Instance()->GetSleepingSettingsFromEntity(target) : &this->DefaultSleepingSettings(); \r\n\r\n\t\t\t//we also retrieve objects world settings\r\n\t\t\t//pWorldSettings * worldSettings = pFactory::Instance()->GetWorldSettingsFromEntity(target);\r\n\r\n\t\t\t//now we can create the final world,the function initiates the world and also it inserts the world \r\n\t\t\t//in our m_pWorlds array !\r\n\t\t\t//world = pFactory::Instance()->createWorld(target,worldSettings,sleepSettings);\r\n\t\t}\r\n\t}\r\n};\r\nint PhysicManager::getNbWorlds(){\treturn getWorlds()->Size();}\r\nvoid PhysicManager::checkClothes()\r\n{\r\n\r\n\tif (!getNbObjects())\r\n\t\treturn;\r\n\r\n\tif (!isValid())\tperformInitialization();\r\n\tif (!isValid())\r\n\t{\r\n\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't make manager valid\");\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we iterate through all entities tagged with the physic attribute \r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_clothDescr);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\r\n\t\tCK3dEntity *target = static_cast(*it);\r\n\t\tif (target)\r\n\t\t{\r\n\t\t\tconst char *bName = target->GetName();\r\n\t\t\t// is the body registered in any world ? \r\n\t\t\r\n\r\n\t\t\tCK_ID wID = vtTools::AttributeTools::GetValueFromAttribute(target,att_clothDescr,E_CS_WORLD_REFERENCE);\r\n\t\t\tCK3dEntity *worldReference = (CK3dEntity*)m_Context->GetObject(wID);\r\n\t\t\tpWorld *world = getWorld(wID);\r\n\r\n\t\t\tif (!worldReference)\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (getBody(target))\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (world->getShapeByEntityID(target->GetID()))\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (world && worldReference)\r\n\t\t\t{\r\n\t\t\t\tpCloth *cloth = world->getCloth(target);\r\n\t\t\t\tif (!cloth)\r\n\t\t\t\t{\r\n\t\t\t\t\tpClothDesc *descr = pFactory::Instance()->createClothDescrFromParameter(target->GetAttributeParameter(att_clothDescr));\r\n\t\t\t\t\tcloth = pFactory::Instance()->createCloth(target,*descr);\r\n\t\t\t\t\tif(cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\tif (descr->flags & PCF_AttachToParentMainShape )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (target->GetParent())\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *bodyReference = pFactory::Instance()->getMostTopParent(target);\r\n\t\t\t\t\t\t\t\tif (bodyReference)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tpRigidBody *body = GetPMan()->getBody(bodyReference);\r\n\t\t\t\t\t\t\t\t\tif (body)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tcloth->attachToShape((CKBeObject*)bodyReference,descr->attachmentFlags);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\tif (descr->flags & PCF_AttachToCollidingShapes)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcloth->attachToCollidingShapes(descr->attachmentFlags);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\nbool isSceneObject(CK3dEntity *object)\r\n{\r\n\r\n\tCKLevel *level = GetPMan()->GetContext()->GetCurrentLevel();\r\n\tif(level)\r\n\t{\r\n\t\tfor(int i = 0 ; i < level->GetSceneCount() ; i++ )\r\n\t\t{\r\n\t\t\tCKScene *scene = level->GetScene(i);\r\n\t\t\tif(scene && scene->IsObjectHere(object))\r\n\t\t\t\treturn true;\t\t\t\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\nvoid PhysicManager::checkWorlds()\r\n{\r\n\r\n\r\n\tCKScene *currentScene = NULL;\r\n\r\n\tCKLevel *level = GetContext()->GetCurrentLevel();\r\n\tif(level)\r\n\t{\r\n\t\tcurrentScene = level->GetCurrentScene();\r\n\t}\r\n\r\n\tif (!getNbObjects())\r\n\t\treturn;\r\n\r\n\tif (!isValid())\tperformInitialization();\r\n\tif (!isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't make manager valid\");\r\n\t\treturn;\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we iterate through all entities tagged with the physic attribute \r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_physic_object);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\r\n\t\tCK3dEntity *target = static_cast(*it);\r\n\t\tif (target && !isSceneObject(target))\r\n\t\t{\r\n\t\t\tconst char *bName = target->GetName();\r\n\t\t\t// is the body registered in any world ? \r\n\t\t\tpRigidBody* body = getBody(target);\r\n\t\t\tif(!body)\r\n\t\t\t{\r\n\t\t\t\t//we retrieve the bodies target world : \r\n\t\t\t\tCK_ID wID = vtTools::AttributeTools::GetValueFromAttribute(target,GetPAttribute(),E_PPS_WORLD);\r\n\t\t\t\tint flags = vtTools::AttributeTools::GetValueFromAttribute(target,GetPAttribute(),E_PPS_BODY_FLAGS);\r\n\t\t\t\tif (flags & BF_SubShape)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tpWorld *world = getWorld(wID) ? getWorld(wID) : getDefaultWorld();\r\n\t\t\t\tif(world)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\t//now create the final rigid body : \r\n\t\t\t\t\tbody = pFactory::Instance()->createRigidBodyFull(target,world->getReference());\r\n\t\t\t\t\tGetPMan()->getCheckList().PushBack(target->GetID());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\tcheckClothes();\r\n\t_checkObjectsByAttribute(currentScene);\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpWorldMapIt itx = getWorlds()->Begin();\r\n\twhile(itx != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *itx;\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->checkList();\r\n\t\t}\r\n\t\titx++;\r\n\t}\r\n}\r\npWorld *PhysicManager::getWorld(CK3dEntity *_o, CK3dEntity *body)\r\n{\r\n\tpWorld *result=NULL;\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// Priorities : \r\n\t//\t\t1. the given world by _o\r\n\t//\t\t2. DefaultWorld\r\n\t//\t\t3. body physic attribute\r\n\t//\t\t4. created default world\r\n\t//\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we try to get it over _o : \r\n\tif (_o)\r\n\t{\r\n\t\tresult = getWorld(_o->GetID());\r\n\t\tif (result && getWorld(_o->GetID())->getReference() )\r\n\t\t{\r\n\t\t\t_o = result->getReference();\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//still nothing, we try to get the default world :\r\n\tresult = getDefaultWorld();\r\n\tif (result && getDefaultWorld()->getReference() )\r\n\t{\r\n\t\tCK_ID id = getDefaultWorld()->getReference()->GetID();\r\n\t\t_o = result->getReference();\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we try to get it over the bodies attribute : \r\n\tif (body)\r\n\t{\r\n\t\tif (body->HasAttribute(GetPAttribute()))\r\n\t\t{\r\n\t\t\tCK_ID id = vtTools::AttributeTools::GetValueFromAttribute(body,GetPMan()->GetPAttribute(),E_PPS_WORLD);\r\n\t\t\t_o = static_cast(ctx()->GetObject(id));\r\n\t\t\tif (_o)\r\n\t\t\t{\r\n\t\t\t\tresult = getWorld(_o->GetID());\r\n\t\t\t\tif (result && getWorld(_o->GetID())->getReference())\r\n\t\t\t\t{\r\n\t\t\t\t\t_o = result->getReference();\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t}\r\n\t\t\t\t_o = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//still nothing \r\n\tif (!getDefaultWorld())\r\n\t{\r\n\t\treturn NULL;\r\n\t\t//result = pFactory::Instance()->createDefaultWorld(\"pDefaultWorld\");\r\n\t\t/*\r\n\t\tif (result)\r\n\t\t{\r\n\t\t\t_o = getDefaultWorld()->getReference();\r\n\t\t}else{\r\n\t\t\t\r\n\t\t\tGetPMan()->performInitialization();\r\n\t\t\tresult = GetPMan()->getDefaultWorld();\r\n\t\t\t_o = result->getReference();\r\n\t\t}\r\n\r\n\t\t*/\r\n\t}\r\n\treturn result;\r\n}\r\nvoid PhysicManager::destroyWorlds()\r\n{\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\tint s = getWorlds()->Size();\r\n\r\n\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->destroy();\r\n\r\n\t\t\tif (w->getReference())\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"World destroyed :%s\",w->getReference()->GetName());\r\n\t\t\t}\r\n\r\n\t\t\tgetWorlds()->Remove(w->getReference());\r\n\t\t\tdelete w;\r\n\t\t\tw = NULL;\r\n\t\t\t\r\n\t\t\tif (getWorlds()->Size())\r\n\t\t\t{\r\n\t\t\t\tdestroyWorlds();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tgetWorlds()->Clear();\r\n}\r\npWorld*PhysicManager::getWorld(CK_ID _o)\r\n{\r\n\t\r\n\tpWorld *result = NULL;\r\n\tCK3dEntity *obj = static_cast(GetContext()->GetObject(_o));\r\n\tif (obj)\r\n\t{\r\n\t\tif (getWorlds()->FindPtr(obj))\r\n\t\t{\r\n\t\t\treturn *getWorlds()->FindPtr(obj);\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\nvoid PhysicManager::deleteWorld(CK_ID _o)\r\n{\r\n\t\r\n\tCK3dEntity *obj = static_cast(GetContext()->GetObject(_o));\r\n\tif (obj)\r\n\t{\r\n\t\tpWorld *w = getWorld(_o);\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->destroy();\r\n\t\t\tgetWorlds()->Remove(obj);\r\n\t\t\tdelete w;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n\r\npWorld*PhysicManager::getWorldByShapeReference(CK3dEntity *shapeReference)\r\n{\r\n\r\n\tif (!shapeReference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\t\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\tpRigidBody *body = w->getBody(pFactory::Instance()->getMostTopParent(shapeReference));\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tif (body->isSubShape((CKBeObject*)shapeReference))\r\n\t\t\t\t{\r\n\t\t\t\t\treturn w;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\npWorld*PhysicManager::getWorldByBody(CK3dEntity*ent)\r\n{\r\n\r\n\tif (!ent)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\t//pRigidBody *body = w->getBody(pFactory::Instance()->getMostTopParent(ent));\r\n\t\t\tpRigidBody *body = w->getBody(ent);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\treturn w;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\npCloth *PhysicManager::getCloth(CK_ID entityID)\r\n{\r\n\r\n\tCK3dEntity *entity = (CK3dEntity*)m_Context->GetObject(entityID);\r\n\tif (!entityID)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\tpCloth *cloth = w->getCloth(entity);\r\n\t\t\tif (cloth)\r\n\t\t\t{\r\n\t\t\t\treturn cloth;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n \r\n\treturn NULL;\r\n}\r\nint PhysicManager::getNbObjects(int flags /* =0 */)\r\n{\r\n\r\n\tCKAttributeManager* attman = ctx()->GetAttributeManager();\r\n\r\n\tint testAtt = -1;\r\n\r\n\tif (flags == 0) testAtt = GetPMan()->GetPAttribute();\r\n\r\n\tint newPhysicObjectAttributeType = getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\r\n\r\n\t// [3/31/2009 master]\r\n\t\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(testAtt);\r\n\tint startSize = 0;\r\n\tstartSize +=Array.Size();\r\n\t\r\n\tstartSize+=attman->GetAttributeListPtr(newPhysicObjectAttributeType).Size();\r\n\r\n\r\n\t/*\r\n\t\tpWorldMapIt it = getWorlds()->Begin();\r\n\t\twhile(it != getWorlds()->End())\r\n\t\t{\r\n\t\t\tpWorld *w = *it;\r\n\t\t\tif (w)\r\n\t\t\t{\r\n\t\t\t\tw->checkList();\r\n\t\t\t}\r\n\t\t\tit++;\r\n\t\t}\r\n\t*/\r\n\treturn startSize;\r\n}Virtools RSC File 1.0\r\n#include \"xMessage.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\n\r\n\r\nxMessage::~xMessage()\r\n{\r\n\txDistributedPropertyArrayIterator begin = getParameters().begin();\r\n\txDistributedPropertyArrayIterator end = getParameters().end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedProperty *prop = *begin;\r\n\t\tif (prop)\r\n\t\t{\r\n\r\n\t\t\txDistributedPropertyInfo *info = prop->m_PropertyInfo;\r\n\t\t\tif (info)\r\n\t\t\t{\r\n\t\t\t\tdelete info;\r\n\t\t\t\tprop->m_PropertyInfo=NULL;\r\n\t\t\t}\r\n\r\n\t\t\tgetParameters().erase(begin);\r\n\t\t\tdelete prop;\r\n\t\t\tbegin = getParameters().begin();\r\n\t\t\tint size = getParameters().size();\r\n\t\t\tif (size)\r\n\t\t\t\tcontinue;\r\n\t\t\telse\r\n\t\t\t\tbreak;\r\n\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n}#include \r\n#include \"vtWindow.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#include \"Manager.h\"\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* tools */\r\n/************************************************************************/\r\nvoid\r\nvtWindow::ParseCommandLine(const char*cmdLine)\r\n{\r\n\tchar Dummy[512]=\"\";\r\n\tchar Dummy2[512]=\"\";\r\n\tchar Dummy3[512]=\"\";\r\n\tchar FileName[512]=\"\";\r\n\tchar Options[8][128]={\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"};\r\n\tchar Engine[128]=\"CK2_3D\";\t// Default render engine\r\n\r\n\tXString lpCmdLine(cmdLine);\r\n\tlpCmdLine.ToLower(); \r\n\r\n\r\n\tsscanf(lpCmdLine.Str(),\"\"\"%s\"\" -%s -%s -%s -%s -%s -%s -%s -%s\",Dummy,Options[0],Options[1],Options[2],Options[3],Options[4],Options[5],Options[6],Options[7]);\r\n\tfor (int i=0;i<7;i++)\r\n\t{\r\n\t\tswitch (Options[i][0])\r\n\t\t{\r\n\t\t\tcase 'd': sscanf(Options[i],\"d=%d\",&m_Player->GetPAppStyle()->g_Render); break;\r\n\t\t\t/*\r\n\t\t\tcase 'w': sscanf(Options[i],\"w=%d\",&m_ep.g_Width); break;\r\n\t\t\tcase 'h': sscanf(Options[i],\"h=%d\",&m_ep.g_Height); break;\r\n\t\t\tcase 'b': sscanf(Options[i],\"bpp=%d\",&m_ep.g_Bpp); break;\r\n\t\t\tcase 'f' : sscanf(Options[i],\"f=%d\",&m_ep.g_GoFullScreen); break;\r\n\t\t\t*/\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/************************************************************************/\r\n/* player control */\r\n/************************************************************************/\r\nvoid vtWindow::Terminate(int flags)\r\n{\r\n\r\n\tm_Player->Pause();\r\n\tm_Player->Terminate(flags);\r\n\tif (m_Player) \r\n\t{\r\n\t\t//PostQuitMessage(0);\r\n\t\tdelete m_Player;\r\n\t\tm_Player =0;\r\n\t}\r\n}\r\n\r\nvoid vtWindow::Pause()\r\n{\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\t\tm_Player->Pause();\r\n\t}\r\n}\r\n\r\nvoid vtWindow::Play()\r\n{\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\t\tm_Player->Play();\r\n\t}\r\n}\r\n\r\nvoid vtWindow::LoadCompostion(char *file)\r\n{\r\n\r\n\tPause();\r\n\tif(m_Player->_Load((const char*)file)!=CK_OK) { // else we load it from a file (iData contains the filename)\r\n\t\tMessageBox(NULL,\"Unable to load composition from file.\",\"Initialisation Error\",MB_OK|MB_ICONERROR);\r\n\t}\r\n\r\n\tif (!m_Player->_FinishLoad()) \r\n\t{\r\n\t\tMessageBox(NULL,\"Unable to start composition from file.\",\"Initialisation Error\",MB_OK|MB_ICONERROR);\r\n\t}\r\n\r\n\r\n\r\n}\r\n\r\n\r\nint vtWindow::WndProc(long *hWnd, int uMsg, long * wParam, long* lParam )\r\n{\r\n\r\n\tif (m_Player && m_Player->m_CKContext->IsPlaying() )\r\n\t{\r\n\t\tm_Player->_MainWindowWndProcStub((HWND)hWnd,(UINT)uMsg,(WPARAM)wParam,(LPARAM)lParam);\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n/************************************************************************/\r\n/*vt to cshap messaging : */\r\n/************************************************************************/\r\nvoid vtWindow::DeleteMessage(int messageID)\r\n{\r\n\tint result = -1;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tcman->DeleteMessage(messageID);\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid vtWindow::CleanMessages()\r\n{\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tcman->CleanMessages();\r\n\t\t\tcman->SetHasMessages(false);\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nchar*vtWindow::GetMessageValueStr(int messageID,int parameterSubID)\r\n{\r\n\tchar* result = NULL;\r\n\t\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetMessageValueStr(messageID,parameterSubID);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nfloat vtWindow::GetMessageValueFloat(int messageID,int parameterSubID)\r\n{\r\n\tfloat result = -1.0f;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetMessageValueFloat(messageID,parameterSubID);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::GetMessageValueInt(int messageID,int parameterSubID)\r\n{\r\n\tint result = -1;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetMessageValueInt(messageID,parameterSubID);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nchar* vtWindow::GetMessageName(int messageID)\r\n{\r\n\tXString result;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\treturn cman->GetMessageName(messageID);\r\n\t\t}\r\n\t}\r\n\treturn result.Str();\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::HasMessages()\r\n{\r\n\tint result = -1;\r\n\t//MessageBox(NULL,\"\",\"\",1);\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->HasMessages();\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint vtWindow::GetMessageParameterType(int messageID, int parameterSubID)\r\n{\r\n\tint result = -1;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetMessageParameterType(messageID,parameterSubID);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::GetNumParameters(int messageID)\r\n{\r\n\tint result = -1;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetNumParameters(messageID);\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::GetNumMessages()\r\n{\r\n\tint result = -1;\r\n\tif (m_Player->m_CKContext)\r\n\t{\r\n\r\n\t\tCSManager* cman =(CSManager*)m_Player->m_CKContext->GetManagerByGuid(INIT_MAN_GUID);\r\n\t\tif (cman)\r\n\t\t{\r\n\t\t\tresult = cman->GetNumMessages();\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n/************************************************************************/\r\n/* window specific functions */\r\n/************************************************************************/\r\nint vtWindow::UpdateRenderSize(int w,int h)\r\n{\r\n\tPause();\r\n\t//m_Player->Stop();\r\n\r\n\tif (m_Player->m_RenderContext)\r\n\t{\r\n\t\tSleep(300);\r\n\t\t::SetWindowPos(m_Player->m_MainWindow,NULL,0,0,w,h,SWP_NOMOVE);\r\n\t\t::SetWindowPos(m_Player->m_RenderWindow,NULL,0,0,w,h,SWP_NOMOVE);\r\n\t\tm_Player->m_WindowedWidth = w;\r\n\t\tm_Player->m_WindowedHeight = h;\r\n\t\tSleep(150);\r\n\t\tm_Player->m_RenderContext->Resize(0,0,w,h);\r\n\t}\r\n\tSleep(50);\r\n\tPlay();\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::GetWidth(){\treturn m_Player->m_WindowedWidth;}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::GetHeight(){\treturn m_Player->m_WindowedHeight;}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::Show(int ShowFlags) { \tShowWindow(m_Player->m_RenderWindow,1);\treturn 1;}\r\n/************************************************************************/\r\n/* sending msg to vt */\r\n/************************************************************************/\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,char* value)\r\n{\r\n\r\n\tif (m_Player)\r\n\t{\r\n\t\treturn m_Player->SendMessage(targetObject,message,id0,id1,id2,value);\r\n\t}\r\n\treturn 0;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,float value)\r\n{\r\n\r\n\t//MessageBox(NULL,\"\",\"\",1);\r\n\tif (m_Player)\r\n\t{\r\n\t\treturn m_Player->SendMessage(targetObject,message,id0,id1,id2,value);\r\n\t}\r\n\treturn 0;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint vtWindow::SendMessage(char *targetObject,char *message,int id0,int id1,int id2,int value)\r\n{\r\n\r\n\tif (m_Player)\r\n\t{\r\n\t\treturn m_Player->SendMessage(targetObject,message,id0,id1,id2,value);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint vtWindow::CreateAsChild(long * parent)\r\n{\r\n\r\n\t\r\n\t\r\n\tHWND win = (HWND)(parent);\r\n\tint ptr = (int)parent;\r\n\t/*XString buffer;\r\n\tbuffer.Format(\"id:%d\",ptr);\r\n\tMessageBox(NULL,buffer.Str(),\"\",1);*/\r\n\r\n\tm_Player = &CCustomPlayer::Instance();\r\n\tHINSTANCE hinst = (HINSTANCE)GetModuleHandle(\"vtWindow.dll\");\r\n\t\r\n\tm_Player->m_hInstance = hinst;\r\n\tm_Player->m_hWndParent = win;\r\n\t\r\n\tm_Player->_RegisterClass();\r\n\tm_Player->PLoadEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE);\r\n\tm_Player->PLoadEnginePathProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\r\n\tm_Player->PLoadAppStyleProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\tm_Player->m_AppMode = preview;\r\n\r\n\t//we only create windows when we want to render something !\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif(!GetPlayer()._CreateWindows()) \r\n\t\t{\r\n\t\t\tMessageBox(NULL,FAILED_TO_CREATE_WINDOWS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\tconst char* fileBuffer = 0;\r\n\tXDWORD fileSize = 0;\r\n\tXString filename(GetPlayer().GetEPathProfile()->CompositionFile);\r\n\t// initialize the player\r\n\tif(!m_Player->InitPlayer(m_Player->m_MainWindow,m_Player->m_RenderWindow,m_Player->m_Config,filename.Length()==0?fileBuffer:filename.CStr(),filename.Length()==0?fileSize:0)) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\t\r\n\t\r\n\r\n\tm_Player->m_Config = 0 ;\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif (m_Player->m_Config&eAutoFullscreen) {\r\n\t\t\t// we are a auto fullscreen mode\r\n\t\t\t// so we hide the main window\r\n\t\t\tShowWindow(m_Player->m_MainWindow,SW_SHOW);\r\n\t\t\tUpdateWindow(m_Player->m_MainWindow);\r\n\t\t\t// we show the render window\r\n\t\t\tShowWindow(m_Player->m_RenderWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_Player->m_RenderWindow);\r\n\t\t} else {\r\n\t\t\t// we are in windowed mode\r\n\t\t\t// so we show the main window\r\n\t\t\t/*ShowWindow(m_Player->m_MainWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_MainWindow);\r\n\t\t\t// the render window too\r\n\t\t\tShowWindow(m_Player->m_RenderWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_Player->m_RenderWindow);*/\r\n\t\t}\r\n\t}\r\n\r\n\t// we reset the player to start it\r\n\tm_Player->Reset();\r\n\r\n\tm_Player->RedirectLog();\r\n\r\n\r\n\r\n\treturn true;\r\n}\r\n\r\nvoid vtWindow::Destroy()\r\n{\r\n\tif (m_Player) \r\n\t{\r\n\t\tPostQuitMessage(0);\r\n\t\tdelete m_Player;\r\n\t\tm_Player =0;\r\n\t}\r\n}\r\n\r\nint vtWindow::Run()\r\n{\r\n\tif (m_Player->m_hThread)\r\n\t{\r\n\t\tm_Player->Stop();\r\n\t}\r\n\r\n\tif (m_Player)\r\n\t{\r\n\t\treturn m_Player->RunInThread();\r\n\t}\r\n\treturn 1;\r\n}\r\nint\r\nvtWindow::DoFrame()\r\n{\r\n\tif (m_Player)\r\n\t{\r\n\t\treturn m_Player->DoFrame();\r\n\t}\r\n\treturn 1;\r\n}\r\nint\r\nvtWindow::Tick()\r\n{\r\n\treturn m_Player->Tick();\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvtWindow::vtWindow()\r\n{\r\n\tm_Player = NULL;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nint\r\nvtWindow::Init()\r\n{\r\n\r\n\tm_Player = &CCustomPlayer::Instance();\r\n\tHINSTANCE hinst = (HINSTANCE)GetModuleHandle(\"vtWindow.dll\");\r\n\tm_Player->m_hInstance = hinst;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n\r\n\tm_Player->_RegisterClass();\r\n\tint LastError = GetLastError();\r\n\tm_Player->PLoadEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE);\r\n\tm_Player->PLoadEnginePathProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\r\n\tm_Player->PLoadAppStyleProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\tm_Player->m_AppMode = m_Player->PGetApplicationMode(GetCommandLine()); // sets player.m_AppMode = full;\r\n\r\n\tParseCommandLine(GetCommandLine());\r\n\r\n\t//we only create windows when we want to render something !\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif(!GetPlayer()._CreateWindows()) \r\n\t\t{\r\n\t\t\tMessageBox(NULL,FAILED_TO_CREATE_WINDOWS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\t\r\n\tconst char* fileBuffer = 0;\r\n\tXDWORD fileSize = 0;\r\n\tXString filename(GetPlayer().GetEPathProfile()->CompositionFile);\r\n\t// initialize the player\r\n\tif(!m_Player->InitPlayer(m_Player->m_MainWindow,m_Player->m_RenderWindow,m_Player->m_Config,filename.Length()==0?fileBuffer:filename.CStr(),filename.Length()==0?fileSize:0)) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tm_Player->m_Config = 0 ;\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif (m_Player->m_Config&eAutoFullscreen) {\r\n\t\t\t// we are a auto fullscreen mode\r\n\t\t\t// so we hide the main window\r\n\t\t\tShowWindow(m_Player->m_MainWindow,SW_SHOW);\r\n\t\t\tUpdateWindow(m_Player->m_MainWindow);\r\n\t\t\t// we show the render window\r\n\t\t\tShowWindow(m_Player->m_RenderWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_Player->m_RenderWindow);\r\n\t\t} else {\r\n\t\t\t// we are in windowed mode\r\n\t\t\t// so we show the main window\r\n\t\t\tShowWindow(m_Player->m_MainWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_MainWindow);\r\n\t\t\t// the render window too\r\n\t\t\tShowWindow(m_Player->m_RenderWindow,1);\r\n\t\t\tUpdateWindow(m_Player->m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_Player->m_RenderWindow);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\t// we reset the player to start it\r\n\tm_Player->Reset();\r\n\r\n\tm_Player->RedirectLog();\r\n\r\n\r\n\r\n\r\n\r\n \r\n\treturn 1;\r\n\r\n}/*\n * Tcp4u v 3.31 Last Revision 27/02/1998 3.30\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: smtp4u.c\n * Purpose: manage SMTP protocol\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\nstatic char szWhat[]=\"@(#)X-Mailer: Smtp4u by Ph. Jounin version 3.30\";\n\n#include \"build.h\"\n\n#define SMTP4U_STDHEADER &szWhat[4]\n/* ------------------------------------ */\n/* DATA */\n/* ------------------------------------ */\n\nstruct S_SmtpProto\n{\n char *szCmd;\n struct S_TnProto tAnswer[16];\n};\n\n\n/* this enum should be in the same order */\n/* than the SmtpProto array */\nenum { _SMTP4U_CONNECT=0, \n _SMTP4U_HELO, \n _SMTP4U_MAILFROM,\n _SMTP4U_MAILFROMSIZE,\n _SMTP4U_RCPTTO, \n _SMTP4U_DATA, \n _SMTP4U_ENDOFDATA, \n _SMTP4U_VERIFY, \n _SMTP4U_QUIT,\n _SMTP4U_REST, \n };\n\n/* The last NULL string is handled by the TnProtoExchange Callback */\nstruct S_SmtpProto SmtpProto[] = \n{\n { NULL, /* CONNECTION */\n { { \"220\", SMTP4U_SUCCESS, },\n { \"421\", SMTP4U_SERVICECLOSED, },\n { NULL, 0 } } },\n { \"HELO %s\",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"500\", SMTP4U_SYNTAXERROR, },\n { \"501\", SMTP4U_SYNTAXERROR, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, },\n { \"550\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"MAIL From:<%s>\",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"451\", SMTP4U_SERVERCANTEXECUTE, },\n { \"452\", SMTP4U_STORAGEEXCEDED, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { \"501\", SMTP4U_SERVERCANTEXECUTE, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, },\n { \"552\", SMTP4U_STORAGEEXCEDED, },\n { NULL, 0 } } },\n { \"MAIL From:<%s> SIZE=%ld\",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"451\", SMTP4U_SERVERCANTEXECUTE, },\n { \"452\", SMTP4U_STORAGEEXCEDED, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { \"501\", SMTP4U_SERVERCANTEXECUTE, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, },\n { \"552\", SMTP4U_STORAGEEXCEDED, },\n { NULL, 0 } } },\n { \"RCPT To: \",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"251\", SMTP4U_SUCCESS, }, /* forwarded */\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"451\", SMTP4U_SERVERCANTEXECUTE, },\n { \"452\", SMTP4U_STORAGEEXCEDED, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { \"501\", SMTP4U_SERVERCANTEXECUTE, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, },\n { \"551\", SMTP4U_UNKNOWNUSER, },\n { \"552\", SMTP4U_STORAGEEXCEDED, },\n { \"553\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"DATA\",\n { { \"354\", SMTP4U_SUCCESS, },\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"451\", SMTP4U_SERVERCANTEXECUTE, },\n { \"452\", SMTP4U_STORAGEEXCEDED, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, }, /* ??? */\n { \"554\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"\\r\\n.\", /* END DATA */\n { { \"250\", SMTP4U_SUCCESS, },\n { \"451\", SMTP4U_SERVERCANTEXECUTE, },\n { \"452\", SMTP4U_STORAGEEXCEDED, },\n { \"552\", SMTP4U_STORAGEEXCEDED, },\n { \"554\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"VRFY %s\",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"251\", SMTP4U_FORWARDED },\n { \"421\", SMTP4U_SERVERCANTEXECUTE, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { \"501\", SMTP4U_SERVERCANTEXECUTE, },\n { \"504\", SMTP4U_NOTIMPLEMENTED, },\n { \"550\", SMTP4U_UNKNOWNUSER, },\n { \"551\", SMTP4U_UNKNOWNUSER, },\n { \"553\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"QUIT\",\n { { \"221\", SMTP4U_SUCCESS, },\n { \"250\", SMTP4U_SUCCESS, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n { \"REST\",\n { { \"250\", SMTP4U_SUCCESS, },\n { \"500\", SMTP4U_SERVERCANTEXECUTE, },\n { \"501\", SMTP4U_SERVERCANTEXECUTE, },\n { \"503\", SMTP4U_SERVERCANTEXECUTE, },\n { \"504\", SMTP4U_SERVERCANTEXECUTE, },\n { NULL, 0 } } },\n}; /* SMTP protocol */\n\n\n\n/* -------------------------------------------------------------- */\n/* Send one RCPT command by user */\n/* returns : SMTP4U_SUCCESS */\n/* SMTP4U_DATAERROR */\n/* SMTP4U_TIMEOUT */\n/* SMTP4U_UNKNOWNUSER */\n/* SMTP4U_SERVERCANTEXECUTE */\n/* SMTP4U_NOTIMPLEMENTED */\n/* SMTP4U_UNEXCEPTEDANSWER */\n/* -------------------------------------------------------------- */\nint API4U SmtpSendRcpt (SOCKET CSock, LPCSTR szTo, \n LPSTR szBuffer, UINT uBufSize)\n{\nLPCSTR pTo = szTo;\nLPSTR qCmd = NULL;\nint Rc = SMTP4U_SUCCESS;\nint Ark;\n\n Tcp4uLog (LOG4U_PROC, \"SmtpSendRcpt\");\n while (*pTo!=0 && Rc==SMTP4U_SUCCESS)\n {\n /* constructs the beginning of the command */\n Strcpy (szBuffer, SmtpProto[_SMTP4U_RCPTTO].szCmd);\n qCmd = szBuffer + Strlen (SmtpProto[_SMTP4U_RCPTTO].szCmd);\n \n /* get the first recipient from the pTo line */\n for (Ark=0 ; pTo[Ark]!=0 && pTo[Ark]!=SMTP4U_SEPARATOR ; Ark++)\n qCmd[Ark] = pTo[Ark];\n qCmd[Ark]=0;\n\n /* skip spaces and affect pTo the next recipient */\n while (pTo[Ark]==SMTP4U_SEPARATOR || pTo[Ark]==' ' || pTo[Ark]=='\\t')\n Ark++;\n pTo += Ark;\n\n /* send the RCPT string */\n Rc = TnProtoExchange (CSock, /* used socket */\n szBuffer,\n szBuffer, uBufSize, \n TnReadMultiLine, /* recv function */\n SmtpProto[_SMTP4U_RCPTTO].tAnswer, \n SizeOfTab(SmtpProto[_SMTP4U_RCPTTO].tAnswer),\n TRUE, /* sensitive compare */\n SMTP4U_DEFTIMEOUT, \n HFILE_ERROR);\n } /* until either error or no more recipient */\n Tcp4uLog (LOG4U_EXIT, \"SmtpSendRcpt\");\nreturn Rc/********************************************************************\r\n\tcreated:\t2007/11/23\r\n\tcreated:\t23:11:2007 12:21\r\n\tfilename: \te:\\ProjectRoot\\current\\vt_plugins\\vtOpenDynamics\\Manager\\vtOdeTypes.h\r\n\tfile path:\te:\\ProjectRoot\\current\\vt_plugins\\vtOpenDynamics\\Manager\r\n\tfile base:\tvtOdeTypes\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __VTODE_TYPES_H_\r\n\t#define __VTODE_TYPES_H_\r\n\r\n\r\n#include \"pSleepingSettings.h\"\r\n#include \"pWorldSettings.h\"\r\n\r\ntypedef CK3dEntity* vt3DObjectType;\r\ntypedef VxVector xVector3;\r\n\r\nstruct vtHeightFieldData\r\n{\r\n\r\n\t/*\r\n\tint wS,dS,warp;\r\n\tfloat w,d,thickness,scale;\r\n\tint ID,tID;\r\n\tfloat rF,gF,bF,aF;\r\n\tfloat maxH;\r\n\tCK_ID maxHReference;\r\n\tdHeightfieldDataID heightFieldData;\r\n\tvtHeightFieldData(float _w,float _d,float _thickness,float _scale,int _wS,int _dS,int _warp,int _ID,int _texID,float _rF,float _gF,float _bF,float _aF) :\r\n\t\tw(_w) , d(_d) , thickness(_thickness) , scale(_scale ) ,warp(_warp) , ID(_ID) , wS(_wS) , dS(_dS) ,tID(_texID) , rF(_rF) , gF(_gF) ,bF(_bF) , aF(_aF)\r\n\t\t{\r\n heightFieldData = NULL;\r\n\t\t}\r\n\t\t\r\n\tfloat lastH;\r\n\tVx2DVector lastHCoord;\r\n\tint lastColor;\r\n*/\r\n\r\n};\r\nstruct vtWorldInfo\r\n{ \r\n\r\n/*\tVxVector Gravity;\r\n\tfloat CFM;\r\n\tfloat ERP;\r\n\tfloat StepResFactor;\r\n\tint MaxIterations;\r\n\tint AutoEnableDepth;\r\n\tfloat MaximumContactCorrectVelocity;\r\n\tfloat ContactSurfaceLayer;\r\n\tfloat rF,gF,bF,aF;\r\n\t\r\n\tvtWorldInfo()\r\n\t{\r\n\t\tGravity.x = 0.0f;\r\n\t\tGravity.y = -10.0f;\r\n\t\tGravity.z = 0.0f;\r\n\t\tCFM = 0.00000001f;\r\n\t\tERP = 0.9f;\r\n\t\tAutoEnableDepth = 1;\r\n\t\tMaxIterations = 100;\r\n\t\tStepResFactor = 0.0085f;\r\n\t}\r\n\t\r\n\tvtWorldInfo(VxVector _g,float _CFM,float _ERP,int _Auto,int _Max,float _StepResFactor,float _rF,float _gF,float _bF,float _aF)\r\n\t : Gravity(_g) , CFM(_CFM) , ERP(_ERP) , AutoEnableDepth(_Auto) , MaxIterations(_Max) , StepResFactor(_StepResFactor) , rF(_rF) , gF(_gF),bF(_bF ),aF(_aF)\r\n\t{\r\n\t}\r\n*/\t\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nstruct vtIntersectionInfo \r\n{\r\n\t/*\r\n\tvt3DObjectType m_ObjectPart;\r\n\tvt3DObjectType m_TouchedObstacle;\r\n\tvt3DObjectType m_TouchedSubObstacle;\r\n\txVector3 m_position;\r\n\txVector3 m_Normal;\r\n\tfloat\tm_Depth;\r\n\tint m_num; \r\n\t*/\r\n};\r\n\r\n#endif\r\n// --------------------------------------------------------------------------\r\n//\t\t\t\t\twww.UnitedBusinessTechnologies.com\r\n//\t\t\t Copyright (c) 1998 - 2002 All Rights Reserved.\r\n//\r\n// Source in this file is released to the public under the following license:\r\n// --------------------------------------------------------------------------\r\n// This toolkit may be used free of charge for any purpose including corporate\r\n// and academic use. For profit, and Non-Profit uses are permitted.\r\n//\r\n// This source code and any work derived from this source code must retain \r\n// this copyright at the top of each source file.\r\n// \r\n// UBT welcomes any suggestions, improvements or new platform ports.\r\n// email to: \r\n// --------------------------------------------------------------------------\r\n#include \"pch.h\"\r\n#include \"GException.h\"\r\n#include \"GString.h\"\r\n#include \"GProfile.h\"\r\n#include //for: va_start(), va_end \r\n#include //for: strlen(), memcpy()\r\n\r\nstatic char *g_pzStaticErrMap = 0;\r\n\r\nvoid SetErrorDescriptions(const char *pzErrData)\r\n{\r\n\tif (g_pzStaticErrMap)\r\n\t\tdelete g_pzStaticErrMap;\r\n\tg_pzStaticErrMap = new char[strlen(pzErrData)+1];\r\n\tmemcpy(g_pzStaticErrMap,pzErrData,strlen(pzErrData)+1);\r\n}\r\n\r\n\r\nGProfile &GetErrorProfile()\r\n{\r\n\tstatic GString strErrorFile;\r\n\tGString *pstrErrorFileContents = 0;\r\n\r\n\tif (strErrorFile.IsEmpty())\r\n\t{\r\n\t\tif (g_pzStaticErrMap)\r\n\t\t{\r\n\t\t\tstrErrorFile = \"Static Load\";\r\n\t\t\tpstrErrorFileContents = new GString(g_pzStaticErrMap,strlen(g_pzStaticErrMap));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tconst char *pzErrFile = GetProfile().GetString(\"System\", \"Errors\", 0);\r\n\t\t\tif (pzErrFile && pzErrFile[0])\r\n\t\t\t{\r\n\t\t\t\tpstrErrorFileContents = new GString();\r\n\t\t\t\tif (!pstrErrorFileContents->FromFile(pzErrFile,0))\r\n\t\t\t\t{\r\n\t\t\t\t\tpzErrFile = 0;\r\n\t\t\t\t}\r\n\t\t\t\tstrErrorFile = pzErrFile;\r\n\t\t\t}\r\n\t\t\t// if the error file could not be found, default to a minimal error file\r\n\t\t\tif (!pzErrFile)\r\n\t\t\t{\r\n\t\t\t\t(*pstrErrorFileContents) = \"[Exception]\\nSubSystem=0\\n[Profile]\\nSubSystem=1\\n0=[%s.%s]Error Description File Not loaded.\\n1=[%s]Error Description File Not loaded.\\n\";\r\n\t\t\t\tstrErrorFile = \"Static\";\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tstatic GProfile ErrorProfile(pstrErrorFileContents->StrVal(), pstrErrorFileContents->Length());\r\n\treturn ErrorProfile;\r\n}\r\n\r\n\r\n#if defined _DEBUGX && _WIN32\r\n\r\n#include \r\n#include \r\n#include \r\n#pragma comment( lib, \"imagehlp\" )\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n/////////////////////// Win32 stack tracing ///////////////////////////////\r\n\r\n#define gle (GetLastError())\r\n#define lenof(a) (sizeof(a) / sizeof((a)[0]))\r\n#define MAXNAMELEN 1024 // max name length for found symbols\r\n#define IMGSYMLEN ( sizeof IMAGEHLP_SYMBOL )\r\n#define TTBUFLEN 65536 // for a temp buffer\r\n\r\nvoid _stack_se_translator(unsigned int e, _EXCEPTION_POINTERS* p)\r\n{\r\n\tHANDLE hThread;\r\n\r\n\tDuplicateHandle( GetCurrentProcess(), GetCurrentThread(),\r\n\t\tGetCurrentProcess(), &hThread, 0, false, DUPLICATE_SAME_ACCESS );\r\n\r\n\tGenericCallStack stk(hThread, *(p->ContextRecord));\r\n\t\r\n\tCloseHandle( hThread );\r\n\r\n\tthrow stk;\r\n}\r\n\r\n\r\nGenericCallStack::GenericCallStack(const GenericCallStack &src)\r\n{\r\n\t_stk = src._stk;\r\n}\r\n\r\nstruct ModuleEntry\r\n{\r\n\tstd::string imageName;\r\n\tstd::string moduleName;\r\n\tDWORD baseAddress;\r\n\tDWORD size;\r\n};\r\ntypedef std::vector< ModuleEntry > ModuleList;\r\ntypedef ModuleList::iterator ModuleListIter;\r\n\r\n// miscellaneous toolhelp32 declarations; we cannot #include the header\r\n// because not all systems may have it\r\n#define MAX_MODULE_NAME32 255\r\n#define TH32CS_SNAPMODULE 0x00000008\r\n#pragma pack( push, 8 )\r\ntypedef struct tagMODULEENTRY32\r\n{\r\n DWORD dwSize;\r\n DWORD th32ModuleID; // This module\r\n DWORD th32ProcessID; // owning process\r\n DWORD GlblcntUsage; // Global usage count on the module\r\n DWORD ProccntUsage; // Module usage count in th32ProcessID's context\r\n BYTE * modBaseAddr; // Base address of module in th32ProcessID's context\r\n DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr\r\n HMODULE hModule; // The hModule of this module in th32ProcessID's context\r\n char szModule[MAX_MODULE_NAME32 + 1];\r\n char szExePath[MAX_PATH];\r\n} MODULEENTRY32;\r\ntypedef MODULEENTRY32 * PMODULEENTRY32;\r\ntypedef MODULEENTRY32 * LPMODULEENTRY32;\r\n#pragma pack( pop )\r\n\r\nbool fillModuleListTH32( ModuleList& modules, DWORD pid )\r\n{\r\n\t// CreateToolhelp32Snapshot()\r\n\ttypedef HANDLE (__stdcall *tCT32S)( DWORD dwFlags, DWORD th32ProcessID );\r\n\t// Module32First()\r\n\ttypedef BOOL (__stdcall *tM32F)( HANDLE hSnapshot, LPMODULEENTRY32 lpme );\r\n\t// Module32Next()\r\n\ttypedef BOOL (__stdcall *tM32N)( HANDLE hSnapshot, LPMODULEENTRY32 lpme );\r\n\r\n\t// I think the DLL is called tlhelp32.dll on Win9X, so we try both\r\n\tconst char *dllname[] = { \"kernel32.dll\", \"tlhelp32.dll\" };\r\n\tHINSTANCE hToolhelp;\r\n\ttCT32S pCT32S;\r\n\ttM32F pM32F;\r\n\ttM32N pM32N;\r\n\r\n\tHANDLE hSnap;\r\n\tMODULEENTRY32 me = { sizeof me };\r\n\tbool keepGoing;\r\n\tModuleEntry e;\r\n\tint i;\r\n\r\n\tfor ( i = 0; i < lenof( dllname ); ++ i )\r\n\t{\r\n\t\thToolhelp = LoadLibrary( dllname[i] );\r\n\t\tif ( hToolhelp == 0 )\r\n\t\t\tcontinue;\r\n\t\tpCT32S = (tCT32S) GetProcAddress( hToolhelp, \"CreateToolhelp32Snapshot\" );\r\n\t\tpM32F = (tM32F) GetProcAddress( hToolhelp, \"Module32First\" );\r\n\t\tpM32N = (tM32N) GetProcAddress( hToolhelp, \"Module32Next\" );\r\n\t\tif ( pCT32S != 0 && pM32F != 0 && pM32N != 0 )\r\n\t\t\tbreak; // found the functions!\r\n\t\tFreeLibrary( hToolhelp );\r\n\t\thToolhelp = 0;\r\n\t}\r\n\r\n\tif ( hToolhelp == 0 ) // nothing found?\r\n\t\treturn false;\r\n\r\n\thSnap = pCT32S( TH32CS_SNAPMODULE, pid );\r\n\tif ( hSnap == (HANDLE) -1 )\r\n\t\treturn false;\r\n\r\n\tkeepGoing = !!pM32F( hSnap, &me );\r\n\twhile ( keepGoing )\r\n\t{\r\n\t\t// here, we have a filled-in MODULEENTRY32\r\n\t\te.imageName = me.szExePath;\r\n\t\te.moduleName = me.szModule;\r\n\t\te.baseAddress = (DWORD) me.modBaseAddr;\r\n\t\te.size = me.modBaseSize;\r\n\t\tmodules.push_back( e );\r\n\t\tkeepGoing = !!pM32N( hSnap, &me );\r\n\t}\r\n\r\n\tCloseHandle( hSnap );\r\n\r\n\tFreeLibrary( hToolhelp );\r\n\r\n\treturn modules.size() != 0;\r\n}\r\n\r\n// miscellaneous psapi declarations; we cannot #include the header\r\n// because not all systems may have it\r\ntypedef struct _MODULEINFO {\r\n LPVOID lpBaseOfDll;\r\n DWORD SizeOfImage;\r\n LPVOID EntryPoint;\r\n} MODULEINFO, *LPMODULEINFO;\r\n\r\nbool fillModuleListPSAPI( ModuleList& modules, DWORD pid, HANDLE hProcess )\r\n{\r\n\t// EnumProcessModules()\r\n\ttypedef BOOL (__stdcall *tEPM)( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded );\r\n\t// GetModuleFileNameEx()\r\n\ttypedef DWORD (__stdcall *tGMFNE)( HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize );\r\n\t// GetModuleBaseName() -- redundant, as GMFNE() has the same prototype, but who cares?\r\n\ttypedef DWORD (__stdcall *tGMBN)( HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize );\r\n\t// GetModuleInformation()\r\n\ttypedef BOOL (__stdcall *tGMI)( HANDLE hProcess, HMODULE hModule, LPMODULEINFO pmi, DWORD nSize );\r\n\r\n\tHINSTANCE hPsapi;\r\n\ttEPM pEPM;\r\n\ttGMFNE pGMFNE;\r\n\ttGMBN pGMBN;\r\n\ttGMI pGMI;\r\n\r\n\tint i;\r\n\tModuleEntry e;\r\n\tDWORD cbNeeded;\r\n\tMODULEINFO mi;\r\n\tHMODULE *hMods = 0;\r\n\tchar *tt = 0;\r\n\r\n\thPsapi = LoadLibrary( \"psapi.dll\" );\r\n\tif ( hPsapi == 0 )\r\n\t\treturn false;\r\n\r\n\tmodules.clear();\r\n\r\n\tpEPM = (tEPM) GetProcAddress( hPsapi, \"EnumProcessModules\" );\r\n\tpGMFNE = (tGMFNE) GetProcAddress( hPsapi, \"GetModuleFileNameExA\" );\r\n\tpGMBN = (tGMFNE) GetProcAddress( hPsapi, \"GetModuleBaseNameA\" );\r\n\tpGMI = (tGMI) GetProcAddress( hPsapi, \"GetModuleInformation\" );\r\n\tif ( pEPM == 0 || pGMFNE == 0 || pGMBN == 0 || pGMI == 0 )\r\n\t{\r\n\t\t// yuck. Some API is missing.\r\n\t\tFreeLibrary( hPsapi );\r\n\t\treturn false;\r\n\t}\r\n\r\n\thMods = new HMODULE[TTBUFLEN / sizeof HMODULE];\r\n\ttt = new char[TTBUFLEN];\r\n\t// not that this is a sample. Which means I can get away with\r\n\t// not checking for errors, but you cannot. :)\r\n\r\n\tif ( ! pEPM( hProcess, hMods, TTBUFLEN, &cbNeeded ) )\r\n\t{\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\tif ( cbNeeded > TTBUFLEN )\r\n\t{\r\n\t\tgoto cleanup;\r\n\t}\r\n\r\n\tfor ( i = 0; i < cbNeeded / sizeof hMods[0]; ++ i )\r\n\t{\r\n\t\t// for each module, get:\r\n\t\t// base address, size\r\n\t\tpGMI( hProcess, hMods[i], &mi, sizeof mi );\r\n\t\te.baseAddress = (DWORD) mi.lpBaseOfDll;\r\n\t\te.size = mi.SizeOfImage;\r\n\t\t// image file name\r\n\t\ttt[0] = '\\0';\r\n\t\tpGMFNE( hProcess, hMods[i], tt, TTBUFLEN );\r\n\t\te.imageName = tt;\r\n\t\t// module name\r\n\t\ttt[0] = '\\0';\r\n\t\tpGMBN( hProcess, hMods[i], tt, TTBUFLEN );\r\n\t\te.moduleName = tt;\r\n\r\n\t\tmodules.push_back( e );\r\n\t}\r\n\r\ncleanup:\r\n\tif ( hPsapi )\r\n\t\tFreeLibrary( hPsapi );\r\n\tdelete [] tt;\r\n\tdelete [] hMods;\r\n\r\n\treturn modules.size() != 0;\r\n}\r\n\r\nbool fillModuleList( ModuleList& modules, DWORD pid, HANDLE hProcess )\r\n{\r\n\t// try toolhelp32 first\r\n\tif ( fillModuleListTH32( modules, pid ) )\r\n\t\treturn true;\r\n\t// nope? try psapi, then\r\n\treturn fillModuleListPSAPI( modules, pid, hProcess );\r\n}\r\n\r\nvoid enumAndLoadModuleSymbols( HANDLE hProcess, DWORD pid )\r\n{\r\n\tModuleList modules;\r\n\tModuleListIter it;\r\n\tchar *img, *mod;\r\n\r\n\t// fill in module list\r\n\tfillModuleList( modules, pid, hProcess );\r\n\r\n\tfor ( it = modules.begin(); it != modules.end(); ++ it )\r\n\t{\r\n\t\t// unfortunately, SymLoadModule() wants writeable strings\r\n\t\timg = new char[(*it).imageName.size() + 1];\r\n\t\tstrcpy( img, (*it).imageName.c_str() );\r\n\t\tmod = new char[(*it).moduleName.size() + 1];\r\n\t\tstrcpy( mod, (*it).moduleName.c_str() );\r\n\r\n\t\tSymLoadModule( hProcess, 0, img, mod, (*it).baseAddress, (*it).size );\r\n\r\n\t\tdelete [] img;\r\n\t\tdelete [] mod;\r\n\t}\r\n}\r\n\r\nGenericCallStack::GenericCallStack(HANDLE hThread, CONTEXT& c)\r\n{\r\n\tDWORD imageType = IMAGE_FILE_MACHINE_I386;\r\n\tHANDLE hProcess = GetCurrentProcess();\r\n\r\n\tint frameNum; // counts walked frames\r\n\tDWORD offsetFromSymbol; // tells us how far from the symbol we were\r\n\tDWORD symOptions; // symbol handler settings\r\n\tIMAGEHLP_SYMBOL *pSym = (IMAGEHLP_SYMBOL *) malloc( IMGSYMLEN + MAXNAMELEN );\r\n\tchar undFullName[MAXNAMELEN]; // undecorated name with all shenanigans\r\n\r\n\tIMAGEHLP_MODULE Module;\r\n\tIMAGEHLP_LINE Line;\r\n\tstd::string symSearchPath;\r\n\tchar *tt = 0, *p;\r\n\r\n\tSTACKFRAME s; // in/out stackframe\r\n\tmemset( &s, '\\0', sizeof s );\r\n\r\n\ttt = new char[TTBUFLEN];\r\n\r\n\t// build symbol search path from:\r\n\tsymSearchPath = \"\";\r\n\t// current directory\r\n\tif ( GetCurrentDirectory( TTBUFLEN, tt ) )\r\n\t\tsymSearchPath += tt + std::string( \";\" );\r\n\t// dir with executable\r\n\tif ( GetModuleFileName( 0, tt, TTBUFLEN ) )\r\n\t{\r\n\t\tfor ( p = tt + strlen( tt ) - 1; p >= tt; -- p )\r\n\t\t{\r\n\t\t\t// locate the rightmost path separator\r\n\t\t\tif ( *p == '\\\\' || *p == '/' || *p == ':' )\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t// if we found one, p is pointing at it; if not, tt only contains\r\n\t\t// an exe name (no path), and p points before its first byte\r\n\t\tif ( p != tt ) // path sep found?\r\n\t\t{\r\n\t\t\tif ( *p == ':' ) // we leave colons in place\r\n\t\t\t\t++ p;\r\n\t\t\t*p = '\\0'; // eliminate the exe name and last path sep\r\n\t\t\tsymSearchPath += tt + std::string( \";\" );\r\n\t\t}\r\n\t}\r\n\t// environment variable _NT_SYMBOL_PATH\r\n\tif ( GetEnvironmentVariable( \"_NT_SYMBOL_PATH\", tt, TTBUFLEN ) )\r\n\t\tsymSearchPath += tt + std::string( \";\" );\r\n\t// environment variable _NT_ALTERNATE_SYMBOL_PATH\r\n\tif ( GetEnvironmentVariable( \"_NT_ALTERNATE_SYMBOL_PATH\", tt, TTBUFLEN ) )\r\n\t\tsymSearchPath += tt + std::string( \";\" );\r\n\t// environment variable SYSTEMROOT\r\n\tif ( GetEnvironmentVariable( \"SYSTEMROOT\", tt, TTBUFLEN ) )\r\n\t\tsymSearchPath += tt + std::string( \";\" );\r\n\r\n\tif ( symSearchPath.size() > 0 ) // if we added anything, we have a trailing semicolon\r\n\t\tsymSearchPath = symSearchPath.substr( 0, symSearchPath.size() - 1 );\r\n\r\n\t// why oh why does SymInitialize() want a writeable string?\r\n\tstrncpy( tt, symSearchPath.c_str(), TTBUFLEN );\r\n\ttt[TTBUFLEN - 1] = '\\0'; // if strncpy() overruns, it doesn't add the null terminator\r\n\r\n\t// init symbol handler stuff (SymInitialize())\r\n\tif ( ! SymInitialize( hProcess, tt, false ) )\r\n\t{\r\n\t\tgoto tagCleanUp;\r\n\t}\r\n\r\n\tsymOptions = SymGetOptions();\r\n\tsymOptions |= SYMOPT_LOAD_LINES;\r\n\tsymOptions &= ~SYMOPT_UNDNAME;\r\n\tSymSetOptions( symOptions ); // SymSetOptions()\r\n\r\n\tenumAndLoadModuleSymbols( hProcess, GetCurrentProcessId() );\r\n\r\n\t// init STACKFRAME for first call\r\n\t// Notes: will have to be #ifdef-ed for Alphas; MIPSes are dead anyway,\r\n\t// and good riddance.\r\n\ts.AddrPC.Offset = c.Eip;\r\n\ts.AddrPC.Mode = AddrModeFlat;\r\n\ts.AddrFrame.Offset = c.Ebp;\r\n\ts.AddrFrame.Mode = AddrModeFlat;\r\n\r\n\tmemset( pSym, '\\0', IMGSYMLEN + MAXNAMELEN );\r\n\tpSym->SizeOfStruct = IMGSYMLEN;\r\n\tpSym->MaxNameLength = MAXNAMELEN;\r\n\r\n\tmemset( &Line, '\\0', sizeof Line );\r\n\tLine.SizeOfStruct = sizeof Line;\r\n\r\n\tmemset( &Module, '\\0', sizeof Module );\r\n\tModule.SizeOfStruct = sizeof Module;\r\n\r\n\toffsetFromSymbol = 0;\r\n\r\n\tfor ( frameNum = 0; ;)\r\n\t{\r\n\t\t// get next stack frame (StackWalk(), SymFunctionTableAccess(), SymGetModuleBase())\r\n\t\t// if this returns ERROR_INVALID_ADDRESS (487) or ERROR_NOACCESS (998), you can\r\n\t\t// assume that either you are done, or that the stack is so hosed that the next\r\n\t\t// deeper frame could not be found.\r\n\t\tif ( ! StackWalk( imageType, hProcess, hThread, &s, &c, NULL,\r\n\t\t\tSymFunctionTableAccess, SymGetModuleBase, NULL ) )\r\n\t\t\tbreak;\r\n\r\n\t\tif ( s.AddrPC.Offset != 0 )\r\n\t\t{ // we seem to have a valid PC\r\n\t\t\t// show procedure info (SymGetSymFromAddr())\r\n\t\t\tif ( ! SymGetSymFromAddr( hProcess, s.AddrPC.Offset, &offsetFromSymbol, pSym ) )\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// UnDecorateSymbolName()\r\n\t\t\t\tUnDecorateSymbolName( pSym->Name, undFullName, MAXNAMELEN, UNDNAME_COMPLETE );\r\n\t\t\t\tif (!frameNum && strstr(undFullName, \"Exception\"))\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t_stk += undFullName;\r\n\t\t\t}\r\n\t\t} // we seem to have a valid PC\r\n\r\n\t\t// no return address means no deeper stackframe\r\n\t\tif ( s.AddrReturn.Offset == 0 )\r\n\t\t{\r\n\t\t\t// avoid misunderstandings in the printf() following the loop\r\n\t\t\tSetLastError( 0 );\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t++frameNum;\r\n\t}\r\n\r\n\t// de-init symbol handler etc. (SymCleanup())\r\n\tSymCleanup( hProcess );\r\n\tfree( pSym );\r\ntagCleanUp:;\t\r\n\tdelete [] tt;\r\n}\r\n\r\nGenericCallStack::~GenericCallStack()\r\n{\r\n}\r\n\r\nconst GStringList *GenericCallStack::GetStack()\r\n{\r\n\treturn &_stk;\r\n}\r\n\r\nconst char *GenericCallStack::GetStackAsString() \r\n{\r\n\t_strStk.Empty();\r\n\tGStringIterator it(&_stk);\r\n\t\r\n\twhile (it())\r\n\t{\r\n\t\tif (!_strStk.IsEmpty())\r\n\t\t\t_strStk += \"\\n\";\r\n\t\t_strStk += it++;\r\n\t}\r\n\r\n\treturn (const char *)_strStk;\r\n}\r\n\r\n#endif\r\n\r\nGenericException::GenericException(int nError, int nSubSystem, const char *pzText, GStringList *pStack)\r\n{\r\n\t_error = nError;\r\n\t_subSystem = nSubSystem;\r\n\t_cause = 0;\r\n\tthis->Format(\"%s\",pzText);\r\n\r\n\tif (pStack)\r\n\t{\r\n\t\tGStringIterator it(pStack);\r\n\t\twhile (it())\r\n\t\t\t_stk.AddLast(it++);\r\n\t}\r\n}\r\n\r\nvoid GenericException::AddErrorDetail(int nError, const char *pzErrorText)\r\n{\r\n\tGString strTemp;\r\n\tstrTemp.Format(\"[Error %ld] %s\\n\",nError,pzErrorText);\r\n\t_ErrorDetail.AddLast(strTemp);\r\n}\r\n\r\n\r\nvoid GenericException::AddErrorDetail(const char* szSystem, int error, ...)\r\n{\r\n\tint nSubSystem = 0;\r\n\tint nError = error;\r\n\ttry\r\n\t{\r\n\t\tGProfile &ErrorProfile = GetErrorProfile();\r\n\t\tnSubSystem = atoi(ErrorProfile.GetString(szSystem, \"SubSystem\"));\r\n\r\n\t\tGString strKey;\r\n\t\tstrKey.Format(\"%ld\", error);\r\n\t\tstrKey = ErrorProfile.GetString(szSystem, (const char *)strKey);\r\n\r\n\t\tGString strTemp;\r\n\t\tva_list argList;\r\n\t\tva_start(argList, error);\r\n\t\tstrTemp.FormatV((const char *)strKey, argList);\r\n\t\tva_end(argList);\r\n\r\n\t\tGString strAddedToUserStack;\r\n\t\tstrAddedToUserStack.Format(\"[Error %ld:%ld] %s\\n\", nSubSystem, nError, (const char *)strTemp);\r\n\t\t_ErrorDetail.AddLast(strAddedToUserStack);\r\n\r\n\t}\r\n\tcatch (GenericException &e)\r\n\t{\r\n\t\t_subSystem = e._subSystem;\r\n\t\t_error = e._error;\r\n\r\n\t\tFormat(\"%s\", (const char *)e);\r\n\t\treturn;\r\n\t}\r\n}\r\n\r\n\r\nGenericException::GenericException(const char* szSystem, int error, ...)\r\n{\r\n\t_subSystem = 0;\r\n\t_error = error;\r\n\r\n\ttry\r\n\t{\r\n\t\tGProfile &ErrorProfile = GetErrorProfile();\r\n\t\t_subSystem = atoi(ErrorProfile.GetString(szSystem, \"SubSystem\"));\r\n\t\tGString strKey;\r\n\t\tstrKey.Format(\"%ld\", error);\r\n\t\tstrKey = ErrorProfile.GetString(szSystem, (const char *)strKey);\r\n\r\n\t\tva_list argList;\r\n\t\tva_start(argList, error);\r\n\t\tFormatV((const char *)strKey, argList);\r\n\t\tva_end(argList);\r\n\t}\r\n\tcatch (GenericException &e)\r\n\t{\r\n\t\t_subSystem = e._subSystem;\r\n\t\t_error = e._error;\r\n\r\n\t\tFormat(\"%s\", (const char *)e);\r\n\t\treturn;\r\n\t}\r\n\r\n}\r\n\r\nGenericException::GenericException(const GenericException &cpy)\r\n{\r\n\t_subSystem = cpy._subSystem;\r\n\t_error = cpy._error;\r\n\t_ErrorDetail = cpy._ErrorDetail;\r\n\tFormat(\"%s\", (const char *)cpy);\r\n}\r\n\r\nGenericException::GenericException(int error, const char *str)\r\n{\r\n\t_subSystem = 0;\r\n\t_error = error;\r\n\tFormat(\"%s\", str);\r\n}\r\n\r\nGenericException::GenericException()\r\n{\r\n\t_subSystem = 0;\r\n}\r\n\r\nGenericException::~GenericException()\r\n{\r\n}\r\n\r\nconst char *GenericException::GetDescription() \r\n{\r\n\t// Get the user stack into strUserStack\r\n\tGString strUserStack;\r\n\tGStringIterator it(&_ErrorDetail);\r\n\twhile (it())\r\n\t{\r\n\t\tstrUserStack += it++;\r\n\t\tif (it())\r\n\t\t\tstrUserStack += \"\\n\";\r\n\t}\r\n\r\n\t_ret.Format(\"[Error %ld:%ld] %s\\n%s\", _subSystem, _error, (const char *)*this, (const char *)strUserStack);\r\n\treturn (const char *)_ret; \r\n}\r\n\r\n\r\nconst char *GenericException::ToXML(const char *pzExceptionParent/* = \"TransactResultSet\"*/) \r\n{\r\n\t_ret.Empty();\r\n\r\n\t// Get the user stack into strUserStack\r\n\tGString strUserStack;\r\n\tGStringIterator it(&_ErrorDetail);\r\n\twhile (it())\r\n\t{\r\n\t\tstrUserStack += \"\\t\\t\";\r\n\t\tstrUserStack.AppendEscapeXMLReserved(it++);\r\n\t\tstrUserStack += \"\";\r\n\t\tif (it())\r\n\t\t\tstrUserStack += \"\\n\";\r\n\t}\r\n\r\n\r\n\tGString strDescription = (const char *)*this;\r\n\tstrDescription.EscapeXMLReserved();\r\n\t\r\n\r\n\t_ret.Format(\"<%s>\\n\\t\\n\\t\\t%s\\n\\t\\t\"\r\n\t\t\t\t\"%ld\\n\\t\\t%d\\n%s\\t\",\r\n\t\t\t\tpzExceptionParent,\r\n\t\t\t\t(const char *)strDescription,\r\n\t\t\t\t_error,\r\n\t\t\t\t_subSystem,\r\n\t\t\t\t(const char *)strUserStack,\r\n\t\t\t\tpzExceptionParent);\r\n\r\n\r\n\treturn (const char *)_ret; \r\n}\r\n\r\nlong GenericException::GetCause()\r\n{ \r\n\t_cause = _subSystem;\r\n\t_cause <<= 4;\r\n\t_cause |= _error;\r\n\r\n\treturn _cause;\r\n}\r\n\r\nconst GStringList *GenericException::GetStack()\r\n{\r\n\treturn &_stk;\r\n}\r\n\r\nconst char *GenericException::GetStackAsString()\r\n{\r\n\t_ret.Empty();\r\n\r\n\tif (_stk.isEmpty())\r\n\t{\r\n\t\t_ret = \"Call stack unavailable.\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tGStringIterator it(&_stk);\r\n\t\t\r\n\t\twhile (it())\r\n\t\t{\r\n\t\t\tif (!_ret.IsEmpty())\r\n\t\t\t\t_ret += \"\\n\";\r\n\t\t\t_ret += it++;\r\n\t\t}\r\n\t}\r\n\r\n\treturn (const char *)_ret;\r\n}\r\n#ifndef __IPARAMETER_H__\r\n#define __IPARAMETER_H__\r\n\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n/*!\r\n\t\\if internal2\r\n\t\t\\brief\tInterface for parameters, implemented as singleton. \r\n\t\tHelps to convert from PhysX to Virtools and vice versa. \r\n\r\n\t\t\\Note This class has been introduced to collect parameter exchange related functionality. In the initial implementation of \r\n\t\t\t\tthis SDK, pFactory was responsible to perform these tasks. \r\n\t\t\t\t\r\n\t\t\\Warning We are migrating all parameter related functions from pFactory to here.\r\n\r\n\t\\endif \r\n\t\t\t\t\r\n */\r\nclass MODULE_API IParameter \r\n{\r\n\r\npublic:\r\n\r\n\t/*!\r\n\t * \\brief\tDefault Constructor. Not been used. This is a singleton class and needs to\r\n\t\t\t\t\tbe instanced only the PhysicManager\r\n\t */\r\n\tIParameter();\r\n\r\n\tIParameter(PhysicManager*_pManager);\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name RigidBody\r\n\t*/\r\n\t//@{\r\n\r\n\r\n\t/**\r\n\t\\brief Conversion for the custom structure #pBSetup. \r\n\t\\param[in] pObjectDescr * dst, w: target object\r\n\t\\param[in] CKParameter * src, r : source parameter. \r\n\r\n\t\\return int\r\n\t\r\n\t@see \r\n\t*/\r\n\tint copyTo(pObjectDescr*dst,CKParameter*src);\r\n\r\n\t/**\r\n\t\\brief Conversion for the custom structure #pBSetup. \r\n\t\\param[in] CKParameter * src, r : source parameter. \r\n\t\\param[in] pObjectDescr * dst, w: target object\r\n\r\n\t\\return int\r\n\r\n\t@see \r\n\t*/\r\n\tint copyTo(CKParameter*dst,pObjectDescr*src);\r\n\r\n\t/**\r\n\t\\brief Conversion for the custom structure #pBPivotSettings. \r\n\t\\param[in] CKParameter * dst, w : target parameter. \r\n\t\\param[in] pObjectDescr * src, w: src object\r\n\r\n\t\\return int\r\n\t@see \r\n\r\n\t*/\r\n\r\n\tint copyTo(pOptimization& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pOptimization src);\r\n\r\n\tint copyTo(pCCDSettings& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pCCDSettings src);\r\n\r\n\r\n\tint copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate=true);\r\n\tint copyTo(CKParameter*dst,pAxisReferencedLength&src,bool evaluate=true);\r\n\r\n\r\n\r\n\tint copyTo(pCapsuleSettingsEx& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pCapsuleSettingsEx src);\r\n\r\n\r\n\r\n\tint copyTo(pConvexCylinderSettings& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pConvexCylinderSettings& src);\r\n\r\n\tint copyTo(pObjectDescr&dst,CK3dEntity*src,int copyFlags);\r\n\tint copyTo(pObjectDescr&dst,const pObjectDescr&src);\r\n\r\n\r\n\tint copyTo(pMassSettings& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pMassSettings src);\r\n\r\n\tint copyTo(pPivotSettings& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pPivotSettings src);\r\n\r\n\tint copyTo(pCollisionSettings& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pCollisionSettings src);\r\n\r\n\tint copyTo(pWheelDescr& dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pWheelDescr src);\r\n\r\n\tint copyTo(pVehicleBrakeTable& dst,CKParameter*src);\r\n\r\n\tint copyTo(pLinearInterpolation&dst,CKParameter*src);\r\n\r\n\tint copyTo(pGearBox *dst,CKParameter*src);\r\n\tint copyTo(CKParameter*dst,pGearBox *src);\r\n\r\n\tint copyTo(pLinearInterpolation&dst,CKParameter*src,int size,float maxValue,float minValue);\r\n\r\n\r\n\r\n\t//@}\r\n\r\n\r\n\r\n\tstatic IParameter* Instance();\r\n\t\r\n\tprivate:\r\n\t\tPhysicManager* mManager;\r\n\r\n};\r\n\r\n\r\n#define GetIPar() IParameter::Instance()\r\n\r\n#endif // __IPARAMETER_H__#include \"ZipDll.h\"\r\n#include \"UnzipDll.h\"\r\n#include \"CKAll.h\"\r\n\r\n//#include \"..\\Manager\\ZipManager.h\"\r\n\r\n#define ZERROR_NONE 0\r\n#define ZERROR_DLL_NOT_FOUND 1\r\n#define ZERROR_DLL_FOUNCTION_NOT_FOUND 2\r\n#define ZERROR_NOT_INITIALIZED 3\r\n\r\nclass CInfoZip {\r\npublic:\r\n\r\n\t\r\n\tCInfoZip();\r\n\tvirtual ~CInfoZip();\r\n\r\n\tBOOL ExtractFiles(const char* pszArchive, const char* pszTargetFolder);\r\n\tvoid SetDefaultValues(CUnzipParams *pParams);\r\n\tvoid ReleaseParams(CUnzipParams *pParams);\r\n\tBOOL Execute(CUnzipParams *pParams);\r\n\tBOOL FinalizeUnzip();\r\n\tBOOL FinalizeZip(char *tempfile);\r\n\tBOOL InitializeUnzip();\r\n\tBOOL InitializeZip(char *tempfile);\r\n\tBOOL GetInitializedUnzip();\r\n\tBOOL GetInitializedZip();\r\n\tvoid ReleaseParams(CZipParams *pParams);\r\n\tBOOL AddFiles(const char *pszArchive, char **paFiles, int iFileCount);\r\n\tBOOL Execute(CZipParams *pParams);\r\n\tvoid SetDefaultValues(CZipParams *pZipParms);\r\n\tBOOL GetInitialized();\r\n\tUINT GetLastError();\r\n\tint GetZipDllVersion();\r\n\tint GetUnzipDllVersion();\r\n\r\n\tCZipDllExec m_ZipDllExec;\r\n\t\r\n\t\r\n\r\n\tvoid SetLastError(UINT uiError);\r\n\tUINT m_uiLastError;\r\n\tHINSTANCE m_ZipDllHandle;\r\n\tHINSTANCE m_UnzipDllHandle;\r\n\t\r\n\tCUnzipDllExec m_UnzipDllExec;\r\n\tCGetZipDllVersion m_GetZipDllVersion;\r\n\t\r\n\t\r\n\r\nprivate:\r\n\t\r\n};\r\n\r\nBOOL __stdcall DefaultZipCallback(CZipCallbackData *pData);\r\n\r\n\r\nusing System;\r\nusing System.Collections;\r\nusing System.ComponentModel;\r\nusing System.Drawing;\r\nusing System.Data;\r\nusing System.Windows.Forms;\r\n\r\nnamespace runme\r\n{\r\n /// \r\n /// Summary description for vtPanel.\r\n /// \r\n public class vtPanel : System.Windows.Forms.Panel\r\n {\r\n /// \r\n /// Required designer variable.\r\n /// \r\n private System.ComponentModel.Container components = null;\r\n public vtWindow vtWin = null;\r\n public WindowsApplication.Form1 parent;\r\n public void Init(WindowsApplication.Form1 _parent, vtWindow vtw)\r\n {\r\n parent = _parent;\r\n vtWin = vtw;\r\n //this.OnSizeChanged()\r\n }\r\n\r\n\r\n protected override void OnSizeChanged(EventArgs e)\r\n {\r\n System.Drawing.Size panelSize = this.Size;\r\n base.OnSizeChanged(e);\r\n\r\n }\r\n\r\n\r\n\r\n public vtPanel()\r\n {\r\n // This call is required by the Windows.Forms Form Designer.\r\n InitializeComponent();\r\n\r\n // TODO: Add any initialization after the InitComponent call\r\n }\r\n\r\n /// \r\n /// Clean up any resources being used.\r\n /// \r\n protected override void Dispose(bool disposing)\r\n {\r\n if (disposing)\r\n {\r\n if (components != null)\r\n components.Dispose();\r\n }\r\n base.Dispose(disposing);\r\n }\r\n\r\n #region Component Designer generated code\r\n /// \r\n /// Required method for Designer support - do not modify \r\n /// the contents of this method with the code editor.\r\n /// \r\n private void InitializeComponent()\r\n {\r\n components = new System.ComponentModel.Container();\r\n }\r\n #endregion\r\n\r\n //protected override void OnPaintBackground(PaintEventArgs pevent) {\r\n /*protected override void OnPaintBackground(PaintEventArgs pevent)\r\n {\r\n\t\t\t\r\n if(vtWin.HasMessages()==1)\n {\n\n String console = parent.richTextBox1.Text;\n\t\t\t\t\n for (int nbMsg = 0 ; nbMsg < vtWin.GetNumMessages() ; nbMsg ++)\r\n {\r\n console +=\"\\n message recieved : \" + nbMsg + \" name : \" + vtWin.GetMessageName(nbMsg);\r\n for (int nbPar = 0 ; nbPar < vtWin.GetNumParameters(nbMsg) ; nbPar ++ )\r\n {\r\n int parType = vtWin.GetMessageParameterType(nbMsg,nbPar);\r\n switch (parType)\r\n {\r\n //string : \r\n case 1:\r\n {\r\n String value = vtWin.GetMessageValueStr(nbMsg,nbPar);\r\n console +=\"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg,nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n //float :\r\n case 2:\r\n {\r\n float value = vtWin.GetMessageValueFloat(nbMsg,nbPar);\r\n console +=\"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg,nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n //integer :\r\n case 3:\r\n {\r\n int value = vtWin.GetMessageValueInt(nbMsg,nbPar);\r\n console +=\"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg,nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n }\r\n //vtWin.DeleteMessage(0);\r\n vtWin.CleanMessages();\r\n parent.richTextBox1.Text = console;\r\n }\r\n\r\n // Calling the base class OnPaint\r\n base.OnPaint(pevent);\r\n }*/\r\n }\r\n}\r\n/*\r\n * FileAndDirUtil.h\r\n * \r\n * Author: \r\n *\r\n * Content: Tools for directory structure handling and file processing.\r\n *\r\n */\r\n\r\n#ifndef _FileAndDirUtil_H_\r\n#define _FileAndDirUtil_H_\r\n\r\n#ifdef WIN32\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\nbool isFile(const char* filename);\r\nbool isDir(const char* dirpath);\r\nbool getDir(char* path, bool cutLastSlash);\r\nHANDLE fileSearchGetNext(HANDLE searchHandle, const char* path, char* file_name);\r\n\r\n#endif // WIN32\r\n\r\n\r\n\r\n#endif // _FileAndDirUtil_H_\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetMidiOutPort\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateSetMidiOutPortProto(CKBehaviorPrototype **);\r\nint SetMidiOutPort(const CKBehaviorContext& behcontext);\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorSetMidiOutPortDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Midi Output Port\");\t\r\n\tod->SetDescription(\"Sets the Midi Out Port (usally 0).\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE );\r\n\tod->SetGuid(CKGUID(0x149d28c7,0x29947940));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetMidiOutPortProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Midi\");\r\n\treturn od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateSetMidiOutPortProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Midi Out Port\");\r\n if(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Midi Output Port\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetMidiOutPort);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint SetMidiOutPort(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n beh->ActivateInput(0, FALSE);\r\n beh->ActivateOutput(0);\r\n \r\n //see @MidiManager::PostProcess();\r\n beh->GetInputParameterValue(0, &mm->DesiredmidiOutDevice);\r\n\r\n return CKBR_OK;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothDecl();\r\nCKERROR CreatePClothProto(CKBehaviorPrototype **pproto);\r\nint PCloth(const CKBehaviorContext& behcontext);\r\nCKERROR PClothCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\r\n\tbbI_AttachmentFlags=E_CS_FLAGS+2,\r\n\tbbI_TargetWorld = E_CS_FLAGS+3,\r\n\r\n\r\n};\r\n\r\n\r\nenum bSettings\r\n{\r\n\tbbS_USE_DEFAULT_WORLD,\r\n\tbbS_ADD_ATTRIBUTES\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothDecl\r\n// FullName: FillBehaviorPClothDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothDecl()\r\n{\r\n\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCloth\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Creates or modifies a cloth.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7901564e,0x7fdb5d76));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothProto\r\n// FullName: CreatePClothProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCloth\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PCloth \r\n\r\n\tPCloth is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a cloth.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PCloth.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target reference. The entity can not be a rigid body or a shub shape!\r\n\t
\r\n\t
\r\n\t\r\n\tThickness: Thickness of the cloth.\r\n\r\n\t\tThe thickness is usually a fraction of the overall extent of the cloth and\r\n\t\tshould not be set to a value greater than that.\tA good value is the maximal\r\n\t\tdistance between two adjacent cloth particles in their rest pose. Visual\r\n\t\tartifacts or collision problems may appear if the thickness is too small.\r\n\r\n\t\tDefault: 0.01
\r\n\t\tRange: [0,inf)\r\n\r\n\t\t@see pCloth.setThickness()\t
\r\n\t\r\n\tDensity : Density of the cloth (mass per area).\r\n\t\r\n\t\tDefault: 1.0
\r\n\t\tRange: (0,inf)\t
\r\n\t\r\n\t
\r\n\r\n\r\n\r\n\tBending Stiffness: Bending stiffness of the cloth in the range 0 to 1.\r\n\t\r\n\tOnly has an effect if the flag PCF_Bending is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,1]\r\n\r\n\t@see PCF_Bending pCloth.setBendingStiffness()\r\n\r\n\r\n\r\n\r\n\r\n\t
\r\n\tStretching Stiffness: Stretching stiffness of the cloth in the range 0 to 1.\r\n\t\r\n\t\\note: stretching stiffness must be larger than 0.\r\n\r\n\tDefault: 1.0
\r\n\tRange: (0,1]\r\n\r\n\t@see pCloth.setStretchingStiffness()\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\tDamping: Spring damping of the cloth in the range 0 to 1.\r\n\r\n\tOnly has an effect if the flag PCF_Damping is set.\r\n\r\n\tDefault: 0.5
\r\n\tRange: [0,1]\r\n\r\n\t@see PCF_Damping pCloth.setDampingCoefficient()\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\tFrictionFriction coefficient in the range 0 to 1. \r\n\r\n\tDefines the damping of the velocities of cloth particles that are in contact.\r\n\r\n\tDefault: 0.5
\r\n\tRange: [0,1]\r\n\r\n\t@see pCloth.setFriction()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tPressure :\r\n\r\n\tIf the flag PCF_Pressure is set, this variable defines the volume\r\n\tof air inside the mesh as volume = pressure * restVolume. \r\n\r\n\tFor pressure < 1 the mesh contracts w.r.t. the rest shape\r\n\tFor pressure > 1 the mesh expands w.r.t. the rest shape\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_pressure pCloth.setPressure()\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tTear Factor: \r\n\t\r\n\t\tIf the flag PCF_Tearable is set, this variable defines the \r\n\t\telongation factor that causes the cloth to tear. \r\n\r\n\t\tMust be larger than 1.\r\n\t\tMake sure meshData.maxVertices and the corresponding buffers\r\n\t\tin meshData are substantially larger (e.g. 2x) than the number \r\n\t\tof original vertices since tearing will generate new vertices.\r\n\r\n\t\tWhen the buffer cannot hold the new vertices anymore, tearing stops.\r\n\t\t\r\n\t\tDefault: 1.5
\r\n\t\tRange: (1,inf)\r\n\r\n\t\t@see pCloth.setTearFactor()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tCollision Response Coefficient: \r\n\r\n\tDefines a factor for the impulse transfer from cloth to colliding rigid bodies.\r\n\r\n\tOnly has an effect if PCF_CollisionTwoWay is set.\r\n\r\n\tDefault: 0.2
\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_CollisionTwoWay pCloth.setCollisionResponseCoefficient()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t\r\n\t
\r\n\t
\r\n\r\n\r\n\r\n\t
\r\n\tAttachment Response Coefficient: Defines a factor for the impulse transfer from cloth to attached rigid bodies.\r\n\r\n\tOnly has an effect if the mode of the attachment is set to nx_cloth_attachment_twoway.\r\n\r\n\tDefault: 0.2
\r\n\tRange: [0,1]\r\n\r\n\t@see pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape pCloth.setAttachmentResponseCoefficient()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tAttachment Tear Factor: \r\n\r\n\tIf the flag PCF_Tearable is set in the attachment method of pCloth, \r\n\tthis variable defines the elongation factor that causes the attachment to tear. \r\n\r\n\tMust be larger than 1.\r\n\r\n\tDefault: 1.5
\r\n\tRange: (1,inf)\r\n\r\n\t@see pCloth.setAttachmentTearFactor() pCloth.attachToShape pCloth.attachToCollidingShapes pCloth.attachVertexToShape\r\n\t\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tTo Fluid Response Coefficient: \r\n\t\r\n\tDefines a factor for the impulse transfer from this cloth to colliding fluids.\r\n\r\n\tOnly has an effect if the PCF_FluidCollision flag is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\tNote: Large values can cause instabilities\r\n\r\n\t@see pClothDesc.flags pClothDesc.fromFluidResponseCoefficient\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tFrom Fluid Response Coefficient: \r\n\r\n\tDefines a factor for the impulse transfer from colliding fluids to this cloth.\r\n\r\n\tOnly has an effect if the PCF_FluidCollision flag is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\tNote: Large values can cause instabilities\r\n\r\n\t@see pClothDesc.flags pClothDesc.ToFluidResponseCoefficient\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tMin Adhere Velocity: \r\n\t\r\n\tIf the PCF_Adhere flag is set the cloth moves partially in the frame \r\n\tof the attached actor. \r\n\r\n\tThis feature is useful when the cloth is attached to a fast moving character.\r\n\tIn that case the cloth adheres to the shape it is attached to while only \r\n\tvelocities below the parameter minAdhereVelocity are used for secondary effects.\r\n\r\n\tDefault: 1.0\r\n\tRange: [0,inf)\r\n\r\n\t@see PCF_AdHere\r\n\r\n\t\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tSolver Iterations: \r\n\t\r\n\tNumber of solver iterations. \r\n\r\n\tNote: Small numbers make the simulation faster while the cloth gets less stiff.\r\n\r\n\tDefault: 5\r\n\tRange: [1,inf)\r\n\r\n\t@see pCloth.setSolverIterations()\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tExternal acceleration : \r\n\t\r\n\t\tExternal acceleration which affects all non attached particles of the cloth. \r\n\r\n\t\tDefault: (0,0,0)\r\n\r\n\t\t@see pCloth.setExternalAcceleration()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tWind Acceleration: \r\n\r\n\t\tAcceleration which acts normal to the cloth surface at each vertex.\r\n\r\n\t\tDefault: (0,0,0)\r\n\r\n\t\t@see pCloth.setWindAcceleration()\r\n\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tWake Up Counter: \r\n\r\n\t\tThe cloth wake up counter.\r\n\r\n\t\tRange: [0,inf)
\r\n\t\tDefault: 20.0f*0.02f\r\n\r\n\t\t@see pCloth.wakeUp() pCloth.putToSleep()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tSleep Linear Velocity:\r\n\r\n\tMaximum linear velocity at which cloth can go to sleep.\r\n\r\n\tIf negative, the global default will be used.\r\n\r\n\tRange: [0,inf)
\r\n\tDefault: -1.0\r\n\r\n\t@see pCloth.setSleepLinearVelocity() pCloth.getSleepLinearVelocity()\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\tCollision Group: \r\n\r\n\tSets which collision group this cloth is part of.\r\n\r\n\tRange: [0, 31]\r\n\tDefault: 0\r\n\r\n\tpCloth.setCollisionGroup()\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tValid Bounds: \r\n\r\n\tIf the flag PCF_ValidBounds is set, this variable defines the volume\r\n\toutside of which cloth particle are automatically removed from the simulation. \r\n\r\n\t@see PCF_ValidBounds pCloth.setValidBounds()\r\n\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\tRelative Grid Spacing: \r\n\r\n\tThis parameter defines the size of grid cells for collision detection.\r\n\r\n\tThe cloth is represented by a set of world aligned cubical cells in broad phase.\r\n\tThe size of these cells is determined by multiplying the length of the diagonal\r\n\tof the AABB of the initial cloth size with this constant.\r\n\r\n\tRange: [0.01,inf)
\r\n\tDefault: 0.25\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\tFlags: \r\n\r\n\tCloth flags.\r\n\r\n\tDefault: Gravity\r\n\r\n\t@see pClothFlag\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t
\r\n\tAttachment Flags: \r\n\r\n\tAttachment flags.\r\n\r\n\tDefault: PCAF_ClothAttachmentTwoway\r\n\r\n\t@see pClothAttachmentFlag\r\n\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pCloth
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PClothCreate.vsl\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothCB );\r\n\r\n\tproto->DeclareInParameter(\"Thickness\",CKPGUID_FLOAT,\"0.01f\");\r\n\tproto->DeclareInParameter(\"Density\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"Bending Stiffness\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"Stretching Stiffness\",CKPGUID_FLOAT,\"1.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Damping Coefficient\",CKPGUID_FLOAT,\"0.50f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Friction\",CKPGUID_FLOAT,\"0.5f\");\r\n\tproto->DeclareInParameter(\"Pressure\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"Tear Factor\",CKPGUID_FLOAT,\"1.5f\");\r\n\tproto->DeclareInParameter(\"Collision Response Coefficient\",CKPGUID_FLOAT,\"0.2f\");\r\n\r\n\tproto->DeclareInParameter(\"Attachment Response Coefficient\",CKPGUID_FLOAT,\"0.2f\");\r\n\tproto->DeclareInParameter(\"AttachmentTearFactor\",CKPGUID_FLOAT,\"1.5f\");\r\n\tproto->DeclareInParameter(\"ToFluidResponseCoefficient\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"FromFluidResponseCoefficient\",CKPGUID_FLOAT,\"1.0f\");\r\n\r\n\tproto->DeclareInParameter(\"MinAdhereVelocity\",CKPGUID_FLOAT,\"1.0f\");\r\n\tproto->DeclareInParameter(\"SolverIterations\",CKPGUID_INT,\"5\");\r\n\tproto->DeclareInParameter(\"ExternalAcceleration\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"WindAcceleration\",CKPGUID_VECTOR);\r\n\r\n\tproto->DeclareInParameter(\"WakeUpCounter\",CKPGUID_FLOAT,\"0.4f\");\r\n\tproto->DeclareInParameter(\"SleepLinearVelocity\",CKPGUID_FLOAT,\"-1.0f\");\r\n\tproto->DeclareInParameter(\"CollisionGroup\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"ValidBounds\",CKPGUID_BOX);\r\n\r\n\tproto->DeclareInParameter(\"RelativeGridSpacing\",CKPGUID_FLOAT,\"0.25f\");\r\n\tproto->DeclareInParameter(\"Flags\",VTE_CLOTH_FLAGS,\"Gravity\");\r\n\tproto->DeclareInParameter(\"Tear Vertex Color\",CKPGUID_COLOR,\"1.0f\");\r\n\tproto->DeclareInParameter(\"Target World Reference\",CKPGUID_3DENTITY,\"pDefaultWorld\");\r\n\tproto->DeclareInParameter(\"Attachment Flags\",VTE_CLOTH_ATTACH_FLAGS);\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Core Body Reference\",CKPGUID_3DENTITY,\"\");\r\n\r\n\tproto->DeclareInParameter(\"Metal Impulse Threshold\",CKPGUID_FLOAT,\"50\");\r\n\tproto->DeclareInParameter(\"Metal Penetration Depth\",CKPGUID_FLOAT,\"0.5\");\r\n\tproto->DeclareInParameter(\"Metal Max Deformation Distance\",CKPGUID_FLOAT,\"0.5\");\r\n\r\n\t//proto->DeclareSetting(\"Use Default World\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PCloth);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PCloth\r\n// FullName: PCloth\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PCloth(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n#ifdef DONLGE\r\n\tif(!PhysicManager::DongleHasAdvancedVersion)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : no license !\");\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\t}\r\n\r\n#endif\r\n\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tCK3dEntity*worldRef = (CK3dEntity *) beh->GetInputParameterObject(E_CS_WORLD_REFERENCE);\r\n\t\tif (!worldRef)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : invalid world reference !\");\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\t\r\n\t\tCK3dEntity*metalCoreRef = (CK3dEntity *) beh->GetInputParameterObject(E_CS_ATTACHMENT_FLAGS +1);\r\n\t\tif (!metalCoreRef)\r\n\t\t{\r\n\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : invalid world reference !\");\r\n\t\t\t//beh->ActivateOutput(0);\r\n\t\t\t//return CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tpWorld *world = GetPMan()->getWorld(worldRef->GetID());\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : couldn't find world !\");\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpRigidBody*body = world->getBody(target);\r\n\t\tif(body)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Cannot create cloth : target can not be a rigid body !\");\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\t}\r\n\r\n\t\tNxShape *shape = world->getShapeByEntityID(target->GetID());\r\n\t\tif(shape)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Cannot create cloth : target can not be a shape !\");\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\t}\r\n\t\t\r\n\r\n\t\tpClothDesc *descr = new pClothDesc();\r\n\r\n\t\tusing namespace vtTools::ParameterTools;\r\n\t\tusing namespace vtTools::BehaviorTools;\r\n\t\tdescr->thickness = GetInputParameterValue(beh,E_CS_THICKNESS);\r\n\t\tdescr->density = GetInputParameterValue(beh,E_CS_DENSITY);\r\n\t\tdescr->bendingStiffness = GetInputParameterValue(beh,E_CS_BENDING_STIFFNESS);\r\n\t\tdescr->stretchingStiffness = GetInputParameterValue(beh,E_CS_STRETCHING_STIFFNESS);\r\n\t\tdescr->dampingCoefficient = GetInputParameterValue(beh,E_CS_DAMPING_COEFFICIENT);\r\n\t\tdescr->friction = GetInputParameterValue(beh,E_CS_FRICTION);\r\n\t\tdescr->pressure = GetInputParameterValue(beh,E_CS_PRESSURE);\r\n\t\tdescr->tearFactor = GetInputParameterValue(beh,E_CS_TEAR_FACTOR);\r\n\t\tdescr->collisionResponseCoefficient = GetInputParameterValue(beh,E_CS_COLLISIONRESPONSE_COEFFICIENT);\r\n\t\tdescr->attachmentResponseCoefficient = GetInputParameterValue(beh,E_CS_ATTACHMENTRESPONSE_COEFFICIENT);\r\n\t\tdescr->attachmentTearFactor = GetInputParameterValue(beh,E_CS_ATTACHMENT_TEAR_FACTOR);\r\n\t\tdescr->toFluidResponseCoefficient = GetInputParameterValue(beh,E_CS_TO_FLUID_RESPONSE_COEFFICIENT);\r\n\r\n\t\tdescr->fromFluidResponseCoefficient = GetInputParameterValue(beh,E_CS_FROM_FLUIDRESPONSE_COEFFICIENT);\r\n\t\tdescr->minAdhereVelocity = GetInputParameterValue(beh,E_CS_MIN_ADHERE_VELOCITY);\r\n\t\tdescr->solverIterations = GetInputParameterValue(beh,E_CS_SOLVER_ITERATIONS);\r\n\r\n\r\n\t\tdescr->externalAcceleration = GetInputParameterValue(beh,E_CS_EXTERN_ALACCELERATION);\r\n\t\tdescr->windAcceleration = GetInputParameterValue(beh,E_CS_WIND_ACCELERATION);\r\n\t\tdescr->wakeUpCounter = GetInputParameterValue(beh,E_CS_WAKE_UP_COUNTER);\r\n\r\n\t\tdescr->sleepLinearVelocity = GetInputParameterValue(beh,E_CS_SLEEP_LINEAR_VELOCITY);\r\n\t\tdescr->collisionGroup = GetInputParameterValue(beh,E_CS_COLLISIONG_ROUP);\r\n\r\n\t\tdescr->validBounds = GetInputParameterValue(beh,E_CS_VALID_BOUNDS);\r\n\t\tdescr->relativeGridSpacing = GetInputParameterValue(beh,E_CS_RELATIVE_GRID_SPACING);\r\n\r\n\t\tdescr->flags = GetInputParameterValue(beh,E_CS_FLAGS);\r\n\t\tdescr->tearVertexColor = GetInputParameterValue(beh,E_CS_TEAR_VERTEX_COLOR);\r\n\t\tdescr->attachmentFlags = (pClothAttachmentFlag)GetInputParameterValue(beh,E_CS_ATTACHMENT_FLAGS);\r\n\r\n\r\n\t\tfloat metalImpulsThresold = GetInputParameterValue(beh,E_CS_ATTACHMENT_FLAGS + 2);\r\n\t\tfloat metalPenetrationDepth = GetInputParameterValue(beh,E_CS_ATTACHMENT_FLAGS + 3);\r\n\t\tfloat metalMaxDeform= GetInputParameterValue(beh,E_CS_ATTACHMENT_FLAGS + 4);\r\n\r\n\r\n\t\tdescr->worldReference = worldRef->GetID();\r\n\t\t\r\n\t\t//descr->setToDefault();\r\n//\t\tdescr->flags = descr->flags | PCF_Bending;\r\n\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tcloth = pFactory::Instance()->createCloth(target,*descr);\r\n\t\t\tif (!cloth)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : factory object failed !\");\r\n\t\t\t}\r\n\t\t}\r\n\r\n//\t\tdescr->flags = descr->flags | PCF_AttachToCore;\r\n\r\n\r\n\t\tif (cloth)\r\n\t\t{\r\n\t\t\tcloth->setThickness(descr->thickness);\r\n\t\t\tcloth->setBendingStiffness(descr->bendingStiffness);\r\n\t\t\tcloth->setStretchingStiffness(descr->stretchingStiffness);\r\n\t\t\tcloth->setDampingCoefficient(descr->dampingCoefficient);\r\n\t\t\tcloth->setFriction(descr->friction);\r\n\t\t\tcloth->setPressure(descr->pressure);\r\n\t\t\tcloth->setTearFactor(descr->tearFactor);\r\n\t\t\tcloth->setCollisionResponseCoefficient(descr->collisionResponseCoefficient);\r\n\t\t\tcloth->setAttachmentResponseCoefficient(descr->attachmentResponseCoefficient);\r\n\t\t\tcloth->setAttachmentTearFactor(descr->attachmentTearFactor);\r\n\t\t\tcloth->setToFluidResponseCoefficient(descr->toFluidResponseCoefficient);\r\n\t\t\tcloth->setFromFluidResponseCoefficient(descr->fromFluidResponseCoefficient);\r\n\t\t\tcloth->setMinAdhereVelocity(descr->minAdhereVelocity);\r\n\t\t\tcloth->setSolverIterations(descr->solverIterations);\r\n\t\t\tcloth->setExternalAcceleration(descr->externalAcceleration);\r\n\t\t\tcloth->setWindAcceleration(descr->windAcceleration);\r\n\t\t\tcloth->setSleepLinearVelocity(descr->sleepLinearVelocity);\r\n\t\t\tcloth->setGroup(descr->collisionGroup);\r\n\t\t\tcloth->setValidBounds(descr->validBounds);\r\n\t\t\tcloth->setFlags(descr->flags);\r\n\r\n\t\t}\r\n\r\n\t\tint flags = GetInputParameterValue(beh,bbI_AttachmentFlags);\r\n\r\n\t\tif (descr->flags & PCF_AttachToParentMainShape )\r\n\t\t{\r\n\t\t\tif (target->GetParent())\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity *bodyReference = pf->getMostTopParent(target);\r\n\t\t\t\tif (bodyReference)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *body = GetPMan()->getBody(bodyReference);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcloth->attachToShape((CKBeObject*)bodyReference,flags);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\r\n\t\tif (descr->flags & PCF_AttachToCollidingShapes)\r\n\t\t{\r\n\t\t\tcloth->attachToCollidingShapes(flags);\r\n\t\t}\r\n\r\n\r\n\t\r\n\t\tif (descr->flags & PCF_AttachToCore)\r\n\t\t{\r\n\t\t\tif (metalCoreRef)\r\n\t\t\t{\r\n\t\t\t\tpRigidBody*metalBody = world->getBody(metalCoreRef);\r\n\t\t\t\tif (!metalBody)\r\n\t\t\t\t{\r\n\r\n\r\n\t\t\t\t\tpObjectDescr objDesc;\r\n\t\t\t\t\tobjDesc.flags =(BodyFlags)(BF_Collision|BF_Gravity|BF_Moving);\r\n\t\t\t\t\tobjDesc.hullType = HT_Capsule;\r\n\t\t\t\t\tobjDesc.density = 0.1f;\r\n\t\t\t\t\tmetalBody = pFactory::Instance()->createCapsule(metalCoreRef,worldRef,&objDesc,0);\r\n\t\t\t\t\tif (metalBody)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcloth->attachToCore(metalCoreRef,metalImpulsThresold,metalPenetrationDepth,metalMaxDeform);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothCB\r\n// FullName: PClothCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n/*\r\n\t\t\tDWORD useDWorld;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);\r\n\t\t\tbeh->EnableInputParameter(bbI_TargetWorld,!useDWorld);\r\n*/\r\n\t\t\t\r\n\r\n\t\t\t/*DWORD ADamp;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_ADamp,&ADamp);\r\n\t\t\tbeh->EnableInputParameter(bbI_ADamp,ADamp);*/\r\n\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothDestroyDecl();\r\nCKERROR CreatePClothDestroyProto(CKBehaviorPrototype **pproto);\r\nint PClothDestroy(const CKBehaviorContext& behcontext);\r\nCKERROR PClothDestroyCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_ShapeReference, \r\n\r\n};\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothDestroyDecl\r\n// FullName: FillBehaviorPClothDestroyDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothDestroyDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothDestroy\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Destroys a physical cloth.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x8d604ec,0x2e926408));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothDestroyProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothDestroyProto\r\n// FullName: CreatePClothDestroyProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothDestroyProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothDestroy\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothDestroy \r\n\r\n\tPClothDestroy is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tDestroys a physical cloth.
\r\n\r\n\t@see pWorld::destroyCloth()\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothDestroy.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothDestroyCB );\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothDestroy);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDestroy\r\n// FullName: PClothDestroy\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothDestroy(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tpCloth *cloth = GetPMan()->getCloth(target->GetID());\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpWorld *world = cloth->getWorld();\r\n\t\tworld->destroyCloth(target->GetID());\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDestroyCB\r\n// FullName: PClothDestroyCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothDestroyCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n#include \r\n\r\nNxActor*pWheel::getTouchedActor()const{\treturn NULL;}\r\n\r\nvoid pWheelDescr::setToDefault()\r\n{\r\n\r\n\tuserData = NULL;\r\n\twheelFlags =(WheelFlags)0;\r\n\r\n\t//radius.setToDefault();\r\n\tspringBias = 0;\r\n\tspringRestitution = 1.f;\r\n\tspringDamping = 0.f;\r\n\r\n\twheelSuspension = 1.f;\r\n\tmaxBrakeForce = 0.0f;\r\n\tfrictionToSide = 1.0f;\r\n\tfrictionToFront = 1.0f;\r\n\tlatFuncXML_Id=0;\r\n\tlongFuncXML_Id=0;\r\n\tinverseWheelMass = 0.1f;\r\n\twheelShapeFlags =(WheelShapeFlags)0;\r\n\r\n\tlatFunc.setToDefault();\r\n\tlongFunc.setToDefault();\r\n\r\n\r\n}\r\nbool pWheelDescr::isValid() const\r\n{\r\n\r\n\t/*if(!NxMath::isFinite(radius))\treturn false;\r\n\tif(radius<=0.0f)\t\t\t\treturn false;*/\r\n\t\r\n\tbool result = true;\r\n\tint a=X_NEGATE(NxMath::isFinite(wheelSuspension));\r\n\t//iAssertWR(X_NEGATE(NxMath::isFinite(wheelSuspension)),\"\",result );\r\n\tiAssertWR(inverseWheelMass > 0.0f,\"\",result );\r\n\tiAssertWR(X_NEGATE(inverseWheelMass<0.0f),\"\",result );\r\n\t//iAssertWR(X_NEGATE(brakeTorque<0.0f),\"\",result );\r\n\t//iAssertWR(X_NEGATE(NxMath::isFinite(steerAngle)),\"\",result );\r\n\t//iAssertWR(X_NEGATE(brakeTorque<0.0f),\"\",result );\r\n\tiAssertWR(longFunc.isValid(),\"\",result );\r\n\tiAssertWR(latFunc.isValid(),\"\",result );\r\n\r\n/*\tif (!suspension.isValid()) return false;\r\n\tif (!longitudalTireForceFunction.isValid()) return false;\r\n\tif (!lateralTireForceFunction.isValid()) return false;\r\n*/\r\n\t//if (NxMath::abs(1-wheelAxis.magnitudeSquared()) > 0.001f)\r\n\t//\treturn false;\r\n\tif (wheelApproximation > 0 && wheelApproximation < 4) {\r\n\r\n\t\treturn false;\r\n\t}\r\n\tif ((wheelFlags & WF_SteerableAuto) && (wheelFlags & WF_SteerableInput)) \r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint pWheel::_constructWheel(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation)\r\n{\r\n\treturn 1;\r\n}\r\n\r\nvoid pWheel::setFlags(int flags)\r\n{\r\n\tmWheelFlags = flags;\r\n}\r\n\r\npWheel::pWheel(pRigidBody *body,pWheelDescr *descr)\r\n{\r\n\r\n\tmBody = body;\r\n\tmWheelFlags = descr->wheelFlags;\r\n\t_wheelRollAngle = 0.0f;\r\n\tmActor= body->getActor();\r\n\r\n}\r\n\r\npWheel1*pWheel::castWheel1()\r\n{\r\n\treturn dynamic_cast(this);\r\n}\r\npWheel2*pWheel::castWheel2()\r\n{\r\n\r\n\treturn dynamic_cast(this);\r\n}\r\n\r\n\r\n\r\n\r\n#ifndef __XMATH_TOOLS_H__\r\n#define __XMATH_TOOLS_H__\r\n\r\n#include \"Prereqs.h\"\r\n#include \"xTNLInternAll.h\"\r\n#include \"xPoint.h\"\r\n#include \"xQuat.h\"\r\nnamespace xMath\r\n{\r\n\r\n__inline void convert(Point3F &target,VxVector source)\r\n{\r\n\ttarget.x = source.x;\r\n\ttarget.y = source.y;\r\n\ttarget.z = source.z;\r\n}\r\n__inline Point3F getFrom(VxVector source)\r\n{\r\n\treturn Point3F(source.x,source.y,source.z);\r\n}\r\n__inline VxVector getFrom(Point3F source){return VxVector(source.x,source.y,source.z);}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n__inline void convert(Point2F &target,Vx2DVector source)\r\n{\r\n\ttarget.x = source.x;\r\n\ttarget.y = source.y;\r\n}\r\n__inline Point2F getFrom(Vx2DVector source)\r\n{\r\n\treturn Point2F(source.x,source.y);\r\n}\r\n__inline Vx2DVector getFrom(Point2F source){return Vx2DVector(source.x,source.y);}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n__inline QuatF getFrom(VxQuaternion source)\r\n{\r\n\treturn QuatF(source.x,source.y,source.z,source.w);\r\n}\r\n__inline VxQuaternion getFrom(QuatF source){return VxQuaternion(source.x,source.y,source.z,source.w);}\r\n__inline void convert(QuatF &target,VxQuaternion source)\r\n{\r\n\ttarget.x = source.x;\r\n\ttarget.y = source.y;\r\n\ttarget.z = source.z;\r\n\ttarget.w = source.w;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n}\r\n\r\n#endif\r\n#ifndef __bCCOError_H\r\n#define __bCCOError_H\r\n\r\n#include \r\n\r\n/**\r\n* Within the Virtools C/C++ SDK, this element a learning application error.\r\n*/\r\nclass bCCOError\r\n{\r\n\r\npublic:\r\n\t/**\r\n\t* Within the Virtools C/C++ SDK, this enumeration represents the type of the\r\n\t* error which will be used to determine how the handling operation reacts to the\r\n\t* error.\r\n\t*/\r\n\tenum bECOErrorType\r\n\t{\r\n\t\t/**\r\n\t\t* Within the Virtools C/C++ SDK, this enumeration denotes a fatal GBL platform\r\n\t\t* error. The GBL platform will take appropriate steps to shutdown the learning\r\n\t\t* application in such circumstances.\r\n\t\t*/\r\n\t\tbERROR_FATAL = 2,\r\n\t\t/**\r\n\t\t* Within the Virtools C/C++ SDK, this enumeration denotes a local GBL platform\r\n\t\t* error. The GBL platform will not take additional steps to handle such an error,\r\n\t\t* instead, it is the responsibility of the operation receiving such an error to\r\n\t\t* take appropriate actions.\r\n\t\t*/\r\n\t\tbERROR_LOCAL = 1,\r\n\t\t/**\r\n\t\t* Within the Virtools C/C++ SDK, this enumeration denotes a successful status,\r\n\t\t* generally used by operations as a successful return value.\r\n\t\t*/\r\n\t\tbERROR_OK = 0\r\n\t};\r\n\r\n\t/**\r\n\t* The destructor of the class.\r\n\t**/\r\n\tbCCOError() {;}\r\n\t\r\n\t/**\r\n\t* This is the copy constructor for the GBL error class, ensuring that \r\n\t* a deep copy of the information is performed, including the internal \r\n\t* error description. \r\n\t**/\r\n\tbCCOError(bCCOError&error)\r\n\t\t{\r\n\t\t\terrorType = error.GetType();\r\n\t\t\terrorDescription = error.GetDescription();\r\n\t\t\terrorCode = error.GetCode();\r\n\t\t}\r\n\r\n inline bCCOError& operator=( const bCCOError &rhs )\r\n {\r\n\t\t\terrorType = rhs.GetType();\r\n\t\t\terrorDescription = rhs.GetDescription();\r\n\t\t\terrorCode = rhs.GetCode();\r\n\r\n return *this;\r\n }\r\n\r\n inline bCCOError& operator=( const bECOErrorType &type )\r\n {\r\n\t\t\terrorType = type;\r\n\r\n return *this;\r\n }\r\n\r\n inline bCCOError& operator=( const int &code )\r\n {\r\n\t\t\terrorCode = code;\r\n\r\n return *this;\r\n }\r\n\r\n inline bCCOError& operator=( const XString &desc )\r\n {\r\n\t\t\terrorDescription = desc;\r\n\r\n return *this;\r\n }\r\n\r\n\t/**\r\n\t* A constructor for the class, which only requires the type to be specified.\r\n\t**/\r\n\tbCCOError(bCCOError::bECOErrorType type) : \r\n\t\terrorType(type) \r\n\t\t{;}\r\n\t\r\n\t/**\r\n\t* A standard constructor for the class, which will accept values being supplied \r\n\t* for all values contained within the error. NOTE: This operation also specifies\r\n\t* default initial values for any of the parameters that are not provided.\r\n\t**/\r\n\tbCCOError(bCCOError::bECOErrorType type , XString description, int code) : \r\n\t\terrorType(type) , errorDescription(description), errorCode(code) \r\n\t\t{;}\r\n\t\r\n\t/**\r\n\t* The destructor of the class.\r\n\t**/\r\n\t~bCCOError() {;}\r\n\r\n\t/**\r\n\t* Implicit conversion to string.\r\n\t**/\r\n\tinline operator const char *( ) const \r\n\t{\r\n\t return errorDescription.CStr(); \t\r\n\t}\r\n inline const char * GetDescription()const\r\n {\r\n return errorDescription.CStr();\r\n }\r\n\t\r\n\t/**\r\n\t* Implicit conversion to int. It will return the error code.\r\n\t**/\r\n\tinline operator int()const{\r\n\t\treturn errorCode;\r\n\t}\r\n inline int GetCode()const\r\n {\r\n return errorCode;\r\n }\r\n\t\r\n\t/**\r\n\t* Implicit conversion to bECOErrorType. It will return the error type.\r\n\t**/\r\n\tinline operator bECOErrorType()const\r\n\t{\r\n\t\treturn errorType;\r\n\t}\r\n inline bECOErrorType GetType()const\r\n {\r\n return errorType;\r\n }\r\n\r\n\t/**\r\n\t* An accessor operation to set the value of the description for the GBL error.\r\n\t**/\r\n\tinline SetDescription(XString desc)\r\n\t{\r\n\t\terrorDescription = desc;\r\n\t}\r\n\t\r\n\t/**\r\n\t* An accessor operation to set the value of the code for the GBL error.\r\n\t**/\r\n\tinline SetCode(int code)\r\n\t{\r\n\t\terrorCode = code;\r\n\t}\r\n\r\n\t/**\r\n\t* An accessor operation to set the value of the type for the GBL error.\r\n\t**/\r\n\tinline SetType(bECOErrorType type)\r\n\t{\r\n\t\terrorType = type;\r\n\t}\r\n\r\nprivate:\r\n\t/**\r\n\t* This element represents the unique code associated with the GBL platform error.\r\n\t*/\r\n\tint errorCode;\r\n\t/**\r\n\t* This element represents the human readable description associated with error,\r\n\t* that is suitable for being displayed in a dialog or log file.\r\n\t*/\r\n\tXString errorDescription;\r\n\t/**\r\n\t* This element is represents the severity associated with the GBL platform error.\r\n\t*/\r\n\tbCCOError::bECOErrorType errorType;\r\n\r\n};\r\n#endif/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t MidiPlayer\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKALL.h\"\r\n#include \"CKMidiSound.h\"\r\n\r\nCKERROR CreateMidiPlayerBehaviorProto(CKBehaviorPrototype **pproto);\r\nint MidiPlayer(const CKBehaviorContext& behcontext);\r\nCKERROR MidiPlayerCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorMidiPlayerDecl()\r\n{\r\n\t\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Midi Player\");\r\n\tod->SetDescription(\"Plays/Stops a MIDI sound.\");\r\n\t/* rem:\r\n\tPlay: Starts playback.
\r\n\tStop: Stops playback.
\r\n\t
\r\n\tOut Play: is activated when the Play input is triggered.
\r\n\tOut Stop: is activated when the Stop input is triggered.
\r\n\t
\r\n\t*/\r\n\tod->SetCategory(\"Sounds/Midi\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x843cb43a, 0xa12dac48));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateMidiPlayerBehaviorProto);\r\n\tod->SetCompatibleClassId(CKCID_MIDISOUND);\r\n\treturn od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateMidiPlayerBehaviorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Midi Player\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"Play\");\r\n\tproto->DeclareInput(\"Stop\");\r\n proto->DeclareInput(\"Pause/Resume\");\r\n\t\r\n\tproto->DeclareOutput(\"Out Play\");\r\n\tproto->DeclareOutput(\"Out Stop\");\r\n\tproto->DeclareOutput(\"Out Pause/Resume\");\r\n\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_NONE);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\t\r\n\tproto->SetFunction(MidiPlayer);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct(MidiPlayerCB);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint MidiPlayer(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n //____________________________/ PLAY\r\n if( beh->IsInputActive(0) ){\r\n\r\n CKMidiSound *midi=NULL; // back-compatibility\r\n midi = (CKMidiSound *)( beh->GetInputParameter(0) ? beh->GetInputParameterObject(0):beh->GetTarget() );\r\n\r\n if(midi){\r\n midi->Play();\r\n beh->ActivateInput(0,FALSE);\r\n beh->ActivateOutput(0);\r\n }\r\n }\r\n \r\n //____________________________/ STOP\r\n if( beh->IsInputActive(1) ){\r\n\r\n CKMidiSound *midi=NULL; // back-compatibility\r\n midi = (CKMidiSound *)( beh->GetInputParameter(0) ? beh->GetInputParameterObject(0):beh->GetTarget() );\r\n\r\n if(midi){\r\n midi->Stop();\r\n beh->ActivateInput(1,FALSE);\r\n beh->ActivateOutput(1);\r\n }\r\n }\r\n \r\n //____________________________/ PAUSE\r\n if( beh->IsInputActive(2) ){\r\n\r\n CKMidiSound *midi=NULL; // back-compatibility\r\n midi = (CKMidiSound *)( beh->GetInputParameter(0) ? beh->GetInputParameterObject(0):beh->GetTarget() );\r\n\r\n if(midi){\r\n midi->Pause( midi->IsPlaying() );\r\n beh->ActivateInput(2,FALSE);\r\n beh->ActivateOutput(2);\r\n }\r\n }\r\n\r\n \r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR MidiPlayerCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n \r\n CKMidiSound *midi=NULL; // back-compatibility\r\n midi = (CKMidiSound *)( beh->GetInputParameter(0) ? beh->GetInputParameterObject(0):beh->GetTarget() );\r\n if( !midi ) return CKBR_OK;\r\n\r\n switch(behcontext.CallbackMessage)\r\n\t{\r\n\t \r\n case CKM_BEHAVIORDETACH:\r\n case CKM_BEHAVIORRESET:\r\n {\r\n midi->Stop();\r\n\r\n } break;\r\n case CKM_BEHAVIORPAUSE:\r\n {\r\n midi->Pause();\r\n\r\n } break;\r\n \r\n case CKM_BEHAVIORRESUME:\r\n {\r\n\t\tif( midi->IsPaused() ){\r\n\t\t\tmidi->Pause(FALSE);\r\n\t\t}\r\n } break;\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2008/01/14\r\n\tcreated:\t14:1:2008 12:06\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\AboutPage.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\n\tfile base:\tAboutPage\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\tShow an about text via a rich text control given from the projects resource file about.txt !\r\n*********************************************************************/\r\n#pragma once\r\n#include \"resourceplayer.h\"\r\n#include \"afxwin.h\"\r\n#include \"afxcmn.h\"\r\nclass CustomPlayerDialogAboutPage : public CPropertyPage\r\n{\r\n// Construction\r\npublic:\r\n\tCustomPlayerDialogAboutPage();\r\n\r\n// Dialog Data\r\n\t//{{AFX_DATA(CAboutPage)\r\n\tenum { IDD = IDD_ABOUTP };\r\n\t//}}AFX_DATA\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generate virtual function overrides\r\n\t//{{AFX_VIRTUAL(CAboutPage)\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n// Implementation\r\nprotected:\r\n\t\r\n\t// Generated message map functions\r\n\t//{{AFX_MSG(CAboutPage)\r\n\t\t// NOTE: the ClassWizard will add member functions here\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\npublic:\r\n\t\r\n\tCRichEditCtrl m_ErrorRichText;\r\n\tafx_msg void OnEnSetfocusErrorRichtText();\r\n\tCString errorText;\r\n\r\n\tafx_msg void OnEnLinkErrorRichtText(NMHDR *pNMHDR, LRESULT *pResult);\r\n};\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \r\n#include \"pCallbackObject.h\"\r\n#include \"pCallbackSignature.h\"\r\n#include \r\n\r\n#include \"virtools/vtTools.h\"\r\n#include \"vtInterfaceEnumeration.h\"\r\n#include \"vtAttributeHelper.h\"\r\n\r\nstatic float incrTimer = 0.0f;\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\nusing namespace vtTools::BehaviorTools;\r\n\r\nint getJointType(int attributeIndex)\r\n{\r\n\tswitch(attributeIndex)\r\n\t{\r\n\t\tcase 1:\r\n\t\t\treturn JT_Distance;\r\n\t\tcase 2:\r\n\t\t\treturn JT_Fixed;\r\n\t\tcase 3:\r\n\t\t\treturn JT_Spherical;\r\n\t\tcase 4:\r\n\t\t\treturn JT_Prismatic;\r\n\t\tcase 5:\r\n\t\t\treturn JT_PointInPlane;\r\n\t\tcase 6:\r\n\t\t\treturn JT_PointOnLine;\r\n\t\tcase 7:\r\n\t\t\treturn JT_Cylindrical;\r\n\t\tcase 8:\r\n\t\t\treturn JT_Revolute;\r\n\t\tcase 9:\r\n\t\t\treturn JT_D6;\r\n\t\tdefault:\r\n\t\t\t\treturn -1;\r\n\t}\r\n\r\n\treturn -1;\r\n\r\n}\r\n\r\nvoid pRigidBody::onICRestore(CK3dEntity* parent,pRigidBodyRestoreInfo *restoreInfo)\r\n{\r\n\r\n\r\n\tif (!parent)\r\n\t\treturn;\r\n\r\n\tCKScene *level_scene = GetPMan()->GetContext()->GetCurrentLevel()->GetLevelScene();\r\n\tif(level_scene)\r\n\t{\r\n\t\tif(level_scene)\r\n\t\t{\r\n\t\t\tCKStateChunk *chunk = level_scene->GetObjectInitialValue(parent);\r\n\t\t\tif (chunk)\r\n\t\t\t{\r\n\t\t\t\tCKReadObjectState(parent,chunk);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\r\n\tVxVector pos(0,0,0);\r\n\tVxVector scale;\t\r\n\tVxQuaternion quat;\r\n\tVx3DDecomposeMatrix(parent->GetWorldMatrix(),quat,pos,scale);\r\n\r\n\r\n\tVxVector vectorN(0,0,0);\r\n\tsetLinearMomentum(vectorN);\r\n\tsetAngularMomentum(vectorN);\r\n\tsetLinearVelocity(vectorN);\r\n\tsetAngularVelocity(vectorN);\r\n\tparent->GetPosition(&pos);\r\n\t\r\n\tsetPosition(pos);\r\n\tsetRotation(quat);\r\n\t\r\n\tif (level_scene && restoreInfo->hierarchy)\r\n\t{\r\n\t\r\n\t\tCK3dEntity* subEntity = NULL;\r\n\t\tXArraySrcObjects;\r\n\t\twhile (subEntity= parent->HierarchyParser(subEntity) )\r\n\t\t{\r\n\t\t\tCKStateChunk *chunk = level_scene->GetObjectInitialValue(subEntity);\r\n\t\t\tif (chunk)\r\n\t\t\t{\r\n\t\t\t\tCKReadObjectState(subEntity,chunk);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tonSubShapeTransformation(false,true,true,parent,restoreInfo->hierarchy);\r\n\r\n\tbool hadJoints = false;\r\n\t\r\n\tif (restoreInfo->removeJoints)\r\n\t{\r\n\t\tCKAttributeManager* attman = GetPMan()->GetContext()->GetAttributeManager();\r\n\t\tint sizeJFuncMap = ATT_FUNC_TABLE_SIZE;//(sizeof(*getRegistrationTable()) / sizeof((getRegistrationTable())[0]));\r\n\t\tfor (int fIndex = 1 ; fIndex < sizeJFuncMap ; fIndex ++)\r\n\t\t{\r\n\t\t\tstd::vectorattributeIdList;\r\n\t\t\tpFactory::Instance()->findAttributeIdentifiersByGuid(GetPMan()->getRegistrationTable()[fIndex].guid,attributeIdList);\r\n\t\t\tint attCount = attributeIdList.size();\r\n\t\t\tfor (int i = 0 ; i < attCount ; i++ )\r\n\t\t\t{\r\n\t\t\t\tint currentAttType = attributeIdList.at(i);\r\n\t\t\t\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr( attributeIdList.at(i) );\r\n\t\t\t\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t\t\t\t{\t\r\n\t\t\t\t\tCK3dEntity *target = static_cast(*it);\r\n\t\t\t\t\tif (target == parent && fIndex != -1 )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tusing namespace vtTools::ParameterTools;\r\n\t\t\t\t\t\tCKParameterOut *attributeParameter = target->GetAttributeParameter(currentAttType);\r\n\t\t\t\t\t\tif (attributeParameter)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tCKStructHelper sHelper(target->GetAttributeParameter(currentAttType));\r\n\t\t\t\t\t\t\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\t\t// get body b :\r\n\t\t\t\t\t\t\tCK_ID bodyBId = GetValueFromParameterStruct(attributeParameter,0);\r\n\t\t\t\t\t\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\r\n\t\t\t\t\t\t\tpJoint *joint = getJoint(bodyBEnt,(JType)getJointType(fIndex));\r\n\t\t\t\t\t\t\tif (joint)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tXString error;\r\n\t\t\t\t\t\t\t\tXString bodyBName;\r\n\t\t\t\t\t\t\t\tif (joint->GetVTEntB())\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tbodyBName.Format(\" %s \",joint->GetVTEntB()->GetName());\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\terror.Format(\"Deleting joint by attribute from : %s with attribute %s connected to :%s\",target->GetName(),attman->GetAttributeNameByType(currentAttType),bodyBName.Str());\r\n\t\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.CStr() );\r\n\t\t\t\t\t\t\t\tdeleteJoint(bodyBEnt, (JType)getJointType(fIndex));\r\n\t\t\t\t\t\t\t\thadJoints = true;\r\n\t\t\t\t\t\t\t\tint b = getNbJoints();\r\n\t\t\t\t\t\t\t\tb++;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t/*\r\n\t\t\t\t\t\tXString error;\r\n\t\t\t\t\t\terror.Format(\"Deleting joint by attribute from : %s with %s\",target->GetName(),attman->GetAttributeNameByType(currentAttType));\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.CStr() );*/\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tif(hadJoints)\r\n\t\tGetPMan()->getCheckList().PushBack(getEntID());\r\n\r\n\t//GetPMan()->checkPhysics = true;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// check for constraint attributes\r\n\t//GetPMan()->_checkObjectsByAttribute();\r\n}\r\n\r\nbool pRigidBody::onMove(bool position/* =true */,bool rotation/* =true */,VxVector pos,VxQuaternion quad)\r\n{\r\n\r\n\t/************************************************************************/\r\n\t/*\r\n\t+\tdetermine whether the specified \"children\" object have sub shapes !\r\n\t- recursive call of updateSubShape\r\n\r\n\t+ exit if any object has been updated\r\n\r\n\t*/\r\n\t/************************************************************************/\r\n\r\n\r\n\t//pSubMeshInfo *info = static_cast(subShape->userData);\r\n\t\r\n\t\r\n\tCK3dEntity* subEntity = NULL;\r\n\tXArraySrcObjects;\r\n\t//SrcObjects.PushBack( subShape );\r\n\r\n\t\r\n\tCK_ID id = getEntID();\r\n\tCK3dEntity * thisEnt = (CK3dEntity*)GetPMan()->GetContext()->GetObject(id);\r\n\tif(thisEnt)\r\n\t\treturn false;\r\n\twhile (subEntity= thisEnt->HierarchyParser(subEntity))\r\n\t{\r\n\r\n\t\tCKSTRING name =subEntity->GetName();\r\n/*\t\tNxShape *childShape = getSubShape(subEntity);\r\n\t\tif (childShape)\r\n\t\t{s\r\n\t\t\tpSubMeshInfo *childInfo = static_cast(childShape->userData);\r\n\t\t\tif (childInfo)\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity *child = (CK3dEntity*)ctx()->GetObject(childInfo->entID);\r\n\t\t\t\tif ( child && isSubShape(child) && childInfo->initDescription.flags & BF_SubShape )\r\n\t\t\t\t{\r\n\t\t\t\t\t//SrcObjects.PushBack(child);//\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n*/\r\n\r\n\t\t// body ? \r\n\t\tpRigidBody *body = GetPMan()->getBody(subEntity);\r\n\t\tif (body && body!=this )\r\n\t\t{\r\n\t\t\tbody->updateSubShapes();\r\n\t\t}\r\n\t}\r\n\r\n\t/*\r\n\tfor(int i = 0;i(*SrcObjects.At(i)));\r\n\t\tif (s)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *childInfo = static_cast(s->userData);\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)ctx()->GetObject(childInfo->entID);\r\n\t\t\tif (!ent)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (position)\r\n\t\t\t{\r\n\r\n\t\t\t\tVxVector relPos;\r\n\t\t\t\tent->GetPosition(&relPos,GetVT3DObject());\r\n\t\t\t\ts->setLocalPosition(getFrom(relPos));\r\n\r\n\t\t\t\t//onSubShapeTransformation(fromPhysicToVirtools,position,false,childObject);\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (rotation)\r\n\t\t\t{\r\n\t\t\t\t/*\r\n\t\t\t\tVxQuaternion refQuad2;\r\n\t\t\t\tent->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\t\t\ts->setLocalOrientation(getFrom(refQuad2));\r\n\t\t\t\t\r\n\t\t\t\t//onSubShapeTransformation(fromPhysicToVirtools,false,rotation,childObject);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t*/\r\n\treturn true;\r\n}\r\nbool pRigidBody::onSubShapeTransformation(bool fromPhysicToVirtools/* =true */,bool position/* =true */,bool rotation/* =true */,CK3dEntity*parent,bool children/* =true */)\r\n{\r\n\r\n\t/************************************************************************/\r\n\t/*\r\n\t\t+\tdetermine whether the specified \"children\" object have sub shapes !\r\n\t\t\t- recursive call of updateSubShape\r\n\r\n\t\t+ exit if any object has been updated\r\n\r\n\t*/\r\n\t/************************************************************************/\r\n\r\n\tif ( !parent )\r\n\t\treturn false;\r\n\r\n\tNxShape *subShape = getSubShape(parent);\r\n\tif (!subShape)\r\n\t\treturn false;\r\n\r\n\tint count = parent->GetChildrenCount();\r\n\r\n\tif (subShape == getMainShape())\r\n\t\treturn false;\r\n\r\n\tpSubMeshInfo *info = static_cast(subShape->userData);\r\n\tCK3dEntity* subEntity = NULL;\r\n\r\n\tXArraySrcObjects;\r\n\tSrcObjects.PushBack( subShape );\r\n\t\r\n\twhile (subEntity= parent->HierarchyParser(subEntity) )\r\n\t{\r\n\r\n\t\tCKSTRING name =subEntity->GetName();\r\n\t\tNxShape *childShape = getSubShape(subEntity);\r\n\t\tif (childShape)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *childInfo = static_cast(childShape->userData);\r\n\t\t\tif (childInfo)\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity *child = (CK3dEntity*)ctx()->GetObject(childInfo->entID);\r\n\t\t\t\tif ( child && isSubShape(child) && childInfo->initDescription.flags & BF_SubShape )\r\n\t\t\t\t{\r\n\t\t\t\t\tSrcObjects.PushBack( childShape );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfor(int i = 0;i(*SrcObjects.At(i)));\r\n\t\tif (s)\r\n\t\t{\r\n\t\t\tpSubMeshInfo *childInfo = static_cast(s->userData);\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)ctx()->GetObject(childInfo->entID);\r\n\t\t\tif (!ent)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tif (position)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tVxVector relPos;\r\n\t\t\t\tent->GetPosition(&relPos,GetVT3DObject());\r\n\t\t\t\ts->setLocalPosition(getFrom(relPos));\r\n\t\t\t\t//onSubShapeTransformation(fromPhysicToVirtools,position,false,childObject);\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (rotation)\r\n\t\t\t{\r\n\t\t\t\tVxQuaternion refQuad2;\r\n\t\t\t\tent->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\t\t\ts->setLocalOrientation(getFrom(refQuad2));\r\n\t\t\t\t//onSubShapeTransformation(fromPhysicToVirtools,false,rotation,childObject);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\nbool pRigidBody::onRayCastHit(NxRaycastHit *report)\r\n{\r\n\r\n\treturn true;\r\n}\r\nvoid pRigidBody::setRayCastScript(int val)\r\n{\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(val);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnRayCastHit,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\tpCallbackObject::setRayCastScript(val);\r\n}\r\nbool pRigidBody::onContactConstraint(int& changeFlags,CK3dEntity *sourceObject,CK3dEntity *otherObject,pContactModifyData *data)\r\n{\r\n\r\n\tbool result = true;\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\tif (sourceObject != GetVT3DObject())\r\n\t\treturn true;\r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getContactModificationScript());\r\n\tif (!beh)\r\n\t\treturn true;\r\n\r\n\tif (!data)\r\n\t\treturn true;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// store data in behaviors inputs\r\n\t//\r\n\r\n\tif (sourceObject)\r\n\t\tSetInputParameterValue(beh,bbICM_SrcObject,sourceObject->GetID());\r\n\tif (otherObject)\r\n\t\tSetInputParameterValue(beh,bbICM_OtherObject,otherObject->GetID());\r\n\r\n\tSetInputParameterValue(beh,bbICM_MinImpulse,data->minImpulse);\r\n\tSetInputParameterValue(beh,bbICM_MaxImpulse,data->maxImpulse);\r\n\t\r\n\tSetInputParameterValue(beh,bbICM_Error,data->error);\r\n\tSetInputParameterValue(beh,bbICM_Target,data->target);\r\n\t\r\n\tSetInputParameterValue(beh,bbICM_LP0,data->localpos0);\r\n\tSetInputParameterValue(beh,bbICM_LP1,data->localpos1);\r\n\t\r\n\tSetInputParameterValue(beh,bbICM_LO0,data->localorientation0);\r\n\tSetInputParameterValue(beh,bbICM_LO1,data->localorientation1);\r\n\r\n\tSetInputParameterValue(beh,bbICM_SF0,data->staticFriction0);\r\n\tSetInputParameterValue(beh,bbICM_SF1,data->staticFriction1);\r\n\r\n\tSetInputParameterValue(beh,bbICM_DF0,data->dynamicFriction0);\r\n\tSetInputParameterValue(beh,bbICM_DF1,data->dynamicFriction1);\r\n\r\n\tSetInputParameterValue(beh,bbICM_Restitution,data->restitution);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// execute:\r\n\t//\r\n\tbeh->Execute(lastStepTimeMS);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// refuse contact \r\n\t//\r\n\tresult = GetOutputParameterValue(beh,bbOCM_CreateContact);\r\n\tif (!result)\r\n\t\treturn false;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// nothing changed, return true\r\n\t//\r\n\tchangeFlags = GetOutputParameterValue(beh,bbOCM_ModifyFlags);\r\n\tif (changeFlags == CMM_None )\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// pickup data, according to change flags\r\n\t//\r\n\tif (changeFlags & CMM_MinImpulse )\r\n\t\tdata->minImpulse = GetOutputParameterValue(beh,bbOCM_MinImpulse);\r\n\r\n\tif (changeFlags & CMM_MaxImpulse)\r\n\t\tdata->maxImpulse = GetOutputParameterValue(beh,bbOCM_MaxImpulse);\r\n\r\n\tif (changeFlags & CMM_Error )\r\n\t\tdata->error = GetOutputParameterValue(beh,bbOCM_Error);\r\n\t\r\n\tif (changeFlags & CMM_Target )\r\n\t\tdata->target = GetOutputParameterValue(beh,bbOCM_Target);\r\n\r\n\r\n\tif (changeFlags & CMM_StaticFriction0)\r\n\t\tdata->staticFriction0 = GetOutputParameterValue(beh,bbOCM_SF0);\r\n\tif (changeFlags & CMM_StaticFriction1)\r\n\t\tdata->staticFriction1 = GetOutputParameterValue(beh,bbOCM_SF1);\r\n\r\n\tif (changeFlags & CMM_DynamicFriction0)\r\n\t\tdata->dynamicFriction0 = GetOutputParameterValue(beh,bbOCM_DF0);\r\n\tif (changeFlags & CMM_DynamicFriction1)\r\n\t\tdata->dynamicFriction1 = GetOutputParameterValue(beh,bbOCM_DF1);\r\n\r\n\tif (changeFlags & CMM_LocalPosition0)\r\n\t\tdata->localpos0 = GetOutputParameterValue(beh,bbOCM_LP0);\r\n\tif (changeFlags & CMM_LocalPosition1)\r\n\t\tdata->localpos1 = GetOutputParameterValue(beh,bbOCM_LP1);\r\n\r\n\tif (changeFlags & CMM_LocalOrientation0)\r\n\t\tdata->localorientation0 = GetOutputParameterValue(beh,bbOCM_LO0);\r\n\tif (changeFlags & CMM_LocalOrientation1)\r\n\t\tdata->localorientation1 = GetOutputParameterValue(beh,bbOCM_LO1);\r\n\r\n\tif (changeFlags & CMM_Restitution)\r\n\t\tdata->restitution = GetOutputParameterValue(beh,bbOCM_Restitution);\r\n\r\n\treturn true;\r\n}\r\n\r\nvoid pRigidBody::setContactModificationScript(int behaviorID)\r\n{\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(behaviorID);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnContactModify,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tpCallbackObject::setContactModificationScript(behaviorID);\r\n\tenableContactModification(true);\r\n\r\n\r\n}\r\n\r\nvoid pRigidBody::setJointBreakScript(int behaviorID,CK3dEntity *shapeReference)\r\n{\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(behaviorID);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnJointBreak,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tpCallbackObject::setJointBreakScript(behaviorID);\r\n\t\r\n}\r\n\r\n\r\nvoid pRigidBody::setTriggerScript(int behaviorID,int eventMask,CK3dEntity *shapeReference)\r\n{\r\n\t/*if (descr.flags & BF_TriggerShape )\r\n\t{\r\n\t\tresult->setFlag(NX_TRIGGER_ENABLE,TRUE);\r\n\t}\r\n\t*/\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(behaviorID);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnTrigger,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tNxShape * shape = getSubShape(shapeReference);\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// check mask \r\n\t//\r\n\tpTriggerFlags tFlags = (pTriggerFlags)eventMask;\r\n\r\n\tif\t(\t(eventMask & TF_OnEnter) ||\r\n\t\t\t(eventMask & TF_OnStay) ||\r\n\t\t\t(eventMask & TF_OnLeave)\r\n\t\t)\r\n\t{\r\n\t\tshape->setFlag(NX_TRIGGER_ON_ENTER,eventMask & TF_OnEnter);\r\n\t\tshape->setFlag(NX_TRIGGER_ON_STAY,eventMask & TF_OnStay);\r\n\t\tshape->setFlag(NX_TRIGGER_ON_LEAVE,eventMask & TF_OnLeave);\r\n\t\tpCallbackObject::setTriggerScript(behaviorID,eventMask);\r\n\t}else\r\n\t{\r\n\t\tshape->setFlag(NX_TRIGGER_ENABLE,false);\r\n\t\tpCallbackObject::setTriggerScript(-1,0);\r\n\t}\r\n}\r\nint pRigidBody::onTrigger(pTriggerEntry *report)\r\n{\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getTriggerScript());\r\n\tif (!beh)\r\n\t\treturn -1;\r\n\r\n\tif (!report)\r\n\t\treturn -1;\r\n\r\n\tif (getTriggerEventMask() & report->triggerEvent )\r\n\t{\r\n\t\tif (report->triggerBody)\r\n\t\t\tSetInputParameterValue(beh,bbIT_SrcObject,report->triggerBody->GetID());\r\n\t\r\n\t\tif (report->otherObject)\r\n\t\t\tSetInputParameterValue(beh,bbIT_OtherObject,report->otherObject->GetID());\r\n\r\n\t\tSetInputParameterValue(beh,bbIT_EventType,report->triggerEvent);\r\n\t\treport->triggered = true;\r\n\t\tbeh->ActivateInput(0,TRUE);\r\n\t\tbeh->Execute(lastStepTimeMS);\r\n\r\n\t\treturn 1;\r\n\r\n\r\n\t}\r\n\r\n\treturn -1;\r\n}\r\n\r\nvoid pRigidBody::setContactScript(int behaviorID,int eventMask)\r\n{ \r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(behaviorID);\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tXString errMessage;\r\n\tif (!GetPMan()->checkCallbackSignature(beh,CB_OnContactNotify,errMessage))\r\n\t{\r\n\t\txError(errMessage.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tpCallbackObject::setContactScript(behaviorID,eventMask);\r\n\t\r\n\tif (getActor())\r\n\t\tgetActor()->setContactReportFlags(eventMask);\r\n\r\n}\r\n\r\nvoid pRigidBody::onContactNotify(pCollisionsEntry *collisionData)\r\n{\r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getContactScript());\r\n\tif (!beh)\r\n\t\treturn;\r\n\r\n\tif (!collisionData)\r\n\t\treturn;\r\n\r\n\tif (getCollisionEventMask() & collisionData->eventType )\r\n\t{\r\n\r\n\t\tif (collisionData->bodyA != this )\r\n\t\t\tXSwap(collisionData->bodyA,collisionData->bodyB);\r\n\r\n\t\tSetInputParameterValue(beh,bbI_SrcObject,collisionData->bodyA->GetVT3DObject()->GetID());\r\n\t\tSetInputParameterValue(beh,bbI_EventType,collisionData->eventType);\r\n\t\tSetInputParameterValue(beh,bbI_NormalForce,collisionData->sumNormalForce);\r\n\t\tSetInputParameterValue(beh,bbI_FForce,collisionData->sumFrictionForce);\r\n\t\tSetInputParameterValue(beh,bbI_Point,collisionData->point);\r\n\t\tSetInputParameterValue(beh,bbI_PointNormalForce,collisionData->pointNormalForce);\r\n\t\tSetInputParameterValue(beh,bbI_FaceNormal,collisionData->faceNormal);\r\n\t\tSetInputParameterValue(beh,bbI_FaceIndex,collisionData->faceIndex);\r\n\t\tSetInputParameterValue(beh,bbI_Distance,collisionData->distance);\r\n\r\n\r\n\t\tif (collisionData->bodyB && collisionData->bodyB->GetVT3DObject() )\r\n\t\t{\r\n\t\t\tSetInputParameterValue(beh,bbI_OtherObject,collisionData->bodyB->GetVT3DObject()->GetID());\r\n\t\t}\r\n\t\tbeh->Execute(lastStepTimeMS);\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\nint pRigidBody::onJointBreak(pBrokenJointEntry *entry)\r\n{\r\n\r\n\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getJointBreakScript());\r\n\tif (!beh)\r\n\t\treturn -1;\r\n\r\n\tif (!entry)\r\n\t\treturn -1;\r\n\r\n\tCK3dEntity *bodyAEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mAEnt));\r\n\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mBEnt));\r\n\r\n\tif (bodyAEnt)\r\n\t{\r\n\t\tSetInputParameterValue(beh,bbJB_SrcObject,entry->mAEnt);\r\n\t}else\r\n\t\tSetInputParameterValue(beh,bbJB_SrcObject,0);\r\n\r\n\tif(bodyBEnt)\r\n\t\tSetInputParameterValue(beh,bbJB_OtherObject,entry->mBEnt);\r\n\telse\r\n\t\tSetInputParameterValue(beh,bbJB_OtherObject,0);\r\n\r\n\tSetInputParameterValue(beh,bbJB_Force,entry->impulse);\r\n\t\r\n\tfloat \telapsedTime = GetPMan()->GetContext()->GetTimeManager()->GetLastDeltaTimeFree();\r\n\tbeh->Execute(elapsedTime);\r\n\r\n/*\tXString log = \"joint break at : \" ;\r\n\tlog+= elapsedTime;\r\n\r\n\r\n\tif (bodyAEnt)\r\n\t{\r\n\t\tlog+=bodyAEnt->GetName();\r\n\t}\r\n\r\n\tif (bodyBEnt)\r\n\t{\r\n\t\tlog= log + \" : with : \" + bodyBEnt->GetName();\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,log.Str());\r\n*/\r\n\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"joint break\");\r\n\tGetPMan()->getJointFeedbackList().RemoveAt( GetPMan()->getJointFeedbackList().GetPosition(entry) );\r\n\treturn 1;\r\n}\r\n\r\nfloat pRigidBody::getContactReportThreshold()\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\treturn getActor()->getContactReportThreshold();\r\n\t}\r\n\treturn -1.0f;\r\n}\r\n\r\n\r\n\r\nvoid pRigidBody::setContactReportThreshold(float threshold)\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\tgetActor()->setContactReportThreshold(threshold);\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::setContactReportFlags(pContactPairFlags flags)\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\tgetActor()->setContactReportFlags((NxU32)flags);\r\n\t}\r\n}\r\nint pRigidBody::getContactReportFlags()\r\n{\r\n\tif (getActor())\r\n\t{\r\n\t\treturn getActor()->getContactReportFlags();\r\n\t}\r\n\treturn -1;\r\n\r\n}\r\n\r\n\r\n\r\nvoid pRigidBody::processScriptCallbacks()\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision Callbacks\r\n\t//\r\n\r\n\t/*if ( !(getCallMask() & CB_OnContactNotify) )\r\n\t\treturn;\r\n*/\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorRegisterAttributeTypeDecl();\r\nCKERROR CreateRegisterAttributeTypeProto(CKBehaviorPrototype **pproto);\r\nint RegisterAttributeType(const CKBehaviorContext& behcontext);\r\nCKERROR RegisterAttributeTypeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Name,\r\n\tbbI_Category,\r\n\tbbI_DefValue,\r\n\tbbI_PType,\r\n\tbbI_Class,\r\n\tbbI_User,\r\n\tbbI_Save,\r\n\r\n\r\n\r\n};\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorRegisterAttributeTypeDecl\r\n// FullName: FillBehaviorRegisterAttributeTypeDecl\r\n// Access: public\r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorRegisterAttributeTypeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"RegisterAttribute\");\r\n\tod->SetCategory(\"Physic/Manager\");\r\n\tod->SetDescription(\"Registers a new attribute type.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x63e567c4,0x65583276));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateRegisterAttributeTypeProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateRegisterAttributeTypeProto\r\n// FullName: CreateRegisterAttributeTypeProto\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateRegisterAttributeTypeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"RegisterAttribute\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"Name\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Category\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Default Value\",CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Parameter Type\",CKPGUID_PARAMETERTYPE);\r\n\tproto->DeclareInParameter(\"Compatible Class\",CKPGUID_CLASSID);\r\n\r\n\tproto->DeclareInParameter(\"User\",CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareInParameter(\"Save\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( RegisterAttributeTypeCB );\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\t\r\n\tproto->SetFunction(RegisterAttributeType);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: RegisterAttributeType\r\n// FullName: RegisterAttributeType\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint RegisterAttributeType(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tCKAttributeManager* attman = ctx->GetAttributeManager();\r\n\tCKParameterManager *pMan = ctx->GetParameterManager();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t\r\n\t\tCKSTRING name = GetInputParameterValue(beh,bbI_Name);\r\n\t\tCKSTRING category = GetInputParameterValue(beh,bbI_Category);\r\n\t\tCKSTRING defValue = GetInputParameterValue(beh,bbI_DefValue);\r\n\t\tint pType = GetInputParameterValue(beh,bbI_PType);\r\n\t\tCK_CLASSID classId = GetInputParameterValue(beh,bbI_Class);\r\n\r\n\t\tint attFlags = 0 ;\r\n\t\tint user = GetInputParameterValue(beh,bbI_User);\r\n\t\tint save = GetInputParameterValue(beh,bbI_Save);\r\n\r\n\t\tif(user)\r\n\t\t\tattFlags|=CK_ATTRIBUT_USER;\r\n\r\n\t\tif(save)\r\n\t\t\tattFlags|=CK_ATTRIBUT_TOSAVE;\r\n\r\n\t\tattFlags|=CK_ATTRIBUT_CAN_DELETE;\r\n\r\n\t\tCKAttributeType aIType = attman->GetAttributeTypeByName(name);\r\n\t\tif (aIType!=-1)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t}\r\n\r\n\t\tint att = attman->RegisterNewAttributeType(name,pMan->ParameterTypeToGuid(pType),classId,(CK_ATTRIBUT_FLAGS)attFlags);\r\n\r\n\t\tif (strlen(category))\r\n\t\t{\r\n\t\t\tattman->AddCategory(category);\r\n\t\t\tattman->SetAttributeCategory(att,category);\r\n\t\t}\r\n\t\tif (strlen(defValue))\r\n\t\t{\r\n\t\t\tattman->SetAttributeDefaultValue(att,defValue);\r\n\t\t}\r\n\r\n\t}\r\n\tpm->populateAttributeFunctions();\r\n\tpm->_RegisterAttributeCallbacks();\r\n\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: RegisterAttributeTypeCB\r\n// FullName: RegisterAttributeTypeCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR RegisterAttributeTypeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\t/*\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\nvtPlayerConsole.exe -d=1 -mode=server\r\n#ifndef __X_DEBUG_TOOLS_H__\r\n #define __X_DEBUG_TOOLS_H__\r\n\r\n\t#include \"xPlatform.h\"\r\n\t#include \"xAssertion.h\"\r\n\t#include \"xLogger.h\"\r\n//\t#include \r\n\t#include \r\n\r\n\t#define X_IS_BETWEEN(VALUE,MIN,MAX) (VALUE < MAX && VALUE > MIN)\r\n\t\r\n\t#define X_NEGATE(A) !(A)\r\n\t#define _FLT_ASSIGMENT(A,B) ((A=B)==0)\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// base types\r\n\t//\r\n\t\r\n\r\n\t\r\n\t#define D_MSG_BUFFER_MAX 4096\r\n\r\n\r\n\r\n\t#ifdef _DEBUG\r\n\r\n\t\t#define D_FILE_INFO 1\r\n\t\t#define D_FILE_LINE_INFO 0\r\n\t#else\n\t\r\n\t\t#define D_FILE_INFO 1\r\n\t\t#define D_FILE_LINE_INFO 0\r\n\t\r\n\t#endif\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// constants\r\n\t//\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t// hide filed details\r\n\t#if D_FILE_INFO==1\r\n\t\t#if !defined(__FILE__)\r\n\t\t\textern const char *const __FILE__;\r\n\t\t#endif \r\n\t#else\r\n\t\t#undef __FILE__\r\n\t\t#define __FILE__ \"\"\r\n\t#endif\r\n\r\n\t\r\n\t#if D_FILE_LINE_INFO==1\r\n\t\t#if !defined(__LINE__)\r\n\t\t\textern const unsigned int __LINE__;\r\n\t\t#endif\r\n\t#else\r\n\t\t#undef __LINE__\r\n\t\t#define __LINE__ 0\r\n\t#endif\r\n\t\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// surround objects : \r\n\t//\r\n\t#if defined(referenceObject)\r\n\t\t#define\t\tDC_OBJECT referenceObject\r\n\t#else\r\n\t\t#define\t\tDC_OBJECT NULL\r\n\t#endif\r\n\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Constants\r\n\t//\r\n\t#define ASSERT_STRING \"Assertion\"\r\n\t\r\n\t#define FATAL_STRING \"Assertion\"\r\n\r\n\t#define\t\tD_SO_NAME_EX(SourceObjectName) SourceObjectName ? SourceObjectName->GetName() : \"none\"\r\n\r\n#ifdef referenceObject\r\n\t#define\t\tD_SO_NAME referenceObject ? referenceObject->GetName() : \"none\"\r\n#else\r\n\t#define D_SO_NAME\t\"???\"\r\n#endif\r\n\r\n\t\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// code fragments\r\n\t//\r\n\t\r\n\r\n\t#define D_DO_POST(PostAction) PostAction;\r\n\r\n\t#define D_ASSERT_P_END(PostAction) xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,buffer);\\\r\n\t\tD_DO_POST(PostAction);\r\n\t\r\n\t\r\n\r\n\t#define xSTR_MERGE(A,B) A##B\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Assertions code fragments\r\n\t//\r\n\r\n\t#define WCASSERT_PREFIX(Assertion,bufferSize) if(!(Assertion)){char buffer[bufferSize];\r\n\t\r\n\r\n\t#define xASSERT_FORMAT_STRING(Assertion) \"%s :\\n\\t Assertion \\\"\" #Assertion \"\\\" failed \\n\\t : %s : \"\r\n\t\t\r\n\t//#define xASSERT_FORMAT_OPERATION(Assertion,postMsg,PostAction) _snprintf(buffer,D_MSG_BUFFER_MAX,xASSERT_FORMAT_STRING_PA(Assertion,PostAction),D_SO_NAME,xSTR_MERGE(postMsg,PostAction));\r\n\t\r\n\t#define xASSERT_FORMAT_OPERATION_EX(Assertion,SourceObjectName,PostMessage,PostAction) _snprintf(buffer,D_MSG_BUFFER_MAX,xASSERT_FORMAT_STRING(Assertion),SourceObjectName, \\\r\n\t\t\txSTR_MERGE(PostMessage,xSTR_MERGE(\" , excecuting : \",#PostAction))); \r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// constants\r\n\t//\r\n\t#if D_FILE_INFO==1\r\n\r\n\t\t#define xASSERT_FORMAT_STRING(A) \"%s :\\n\\t Assertion2 \\\"\" #A \"\\\" failed in \\n\\t : (%s:%d) :\\n\\t %s \" // \\\"\" #B \"\\\" \"\r\n\r\n\t\t#define xASSERT_FORMAT_OPERATION_EX(Assertion,SourceObjectName,PostMessage,PostAction) _snprintf(buffer,D_MSG_BUFFER_MAX,xASSERT_FORMAT_STRING(Assertion),SourceObjectName,__FILE__,__LINE__, \\\r\n\t\t\txSTR_MERGE(PostMessage,xSTR_MERGE(\" , excecuting : \",#PostAction))); \r\n\t#endif\r\n\t\r\n\r\n\t#define WIDEN2(x) L ## x\r\n\t#define WIDEN(x) WIDEN2(x)\r\n\t#define __WFILE__ WIDEN(__FILE__)\r\n\t#define AMACRO( object_name, var_name ) reinterpret_cast((&(((object_name*)0)->var_name))) \r\n\r\n\r\n\r\n\r\n\r\n\t#define xAssertWPO(Assertion) xVerify(Assertion)\r\n\r\n\t#define REFRESH_ASSERT_HANDLER(Type,Assertion,PostMessage,PostAction,Result) updateAssertHandlerData(Type,#Assertion,__FILE__,__LINE__,PostMessage,((void*)(PostAction)),Result);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// macros to make an assert, error warning message, and providing a field to correct data\r\n\t//\r\n\t// prepare meta data : \r\n\t\r\n\r\n\t#define CREATE_ASSERT_INFO_EX(Assertion,Type,FormatString,SourceObjectName,PostMessage,PostAction) WCASSERT_PREFIX(Assertion,D_MSG_BUFFER_MAX) \\\r\n\t\txASSERT_FORMAT_OPERATION_EX(Assertion,SourceObjectName,PostMessage,PostAction); \r\n\t\r\n\t#define xwASSERTEx(Assertion,SourceObjectName,PostMessage,PostAction,Result) CREATE_ASSERT_INFO_EX(Assertion,AFS_ASSERT,xASSERT_FORMAT_STRING(Assertion),SourceObjectName,PostMessage,PostAction,Result);\r\n\t\r\n\t//REFRESH_ASSERT_HANDLER(AFS_ASSERT,Assertion,buffer,PostAction,Result); \r\n\r\n\t#define __xwASSERT(Assertion,SourceObjectName,PostMessage,PostAction,Result) xwASSERTEx(Assertion,SourceObjectName,PostMessage,PostAction,Result)\r\n\r\n\t#define xAssertW(Assertion,PostAction,PostMessage,SourceObjectName,Result) \\\r\n\t\t__xwASSERT(Assertion,SourceObjectName,PostMessage,PostAction,Result) \\\r\n\t\t\t_xAssertHandler(Assertion); \\\r\n\t\t\t D_ASSERT_P_END(PostAction) \\\r\n\t\t\tResult = false; \\\r\n\t}\r\n\t\r\n/*\r\n\t#define xAssertW(Assertion,PostAction,PostMessage,SourceObjectName,Result) \\\r\n\t\t__xwASSERT(Assertion,SourceObjectName,PostMessage,PostAction,Result) \\\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"start assert\");\\\r\n\t\t(false || (Assertion) || (xAssertionEx::getErrorHandler() && (xAssertionEx::getErrorHandler()\\\r\n\t\t( AFS_ASSERT, #Assertion, __FILE__, __LINE__,\"asdasd\",NULL,TRUE), true)));\\\r\n\t\txAssertInfo *info = assertFailed();\\\r\n\t\tif(info ){\\\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"assert failed\");\\\r\n\t\t\tD_ASSERT_P_END(PostAction) \\\r\n\t\t\tResult = false; } \\\r\n\t}*/\r\n\r\n\r\n\t\t/*\t\r\n_xAssertHandler(Assertion); \\\r\n\t\t\txAssertInfo *info = assertFailed();\\\r\n\t\t\tif(info ){\\\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"assert failed\");\\\r\n\t\t\tD_ASSERT_P_END(PostAction) \\\r\n\t\t\tResult = false; } \\\r\n\t}\r\n*/\r\n\t#define iAssertW(Assertion,PostAction,PostMessage)\\\r\n\t{\tbool returnValue = false;\\\r\n\t\txAssertW(Assertion,PostAction,PostMessage,D_SO_NAME,returnValue)\\\r\n\t}\r\n\r\n\t#define iAssertWR(Assertion,PostAction,Result){\\\r\n\t\txAssertW(Assertion,PostAction,\"\",D_SO_NAME,Result)\\\r\n\t}\r\n\r\n\t\r\n\r\n\t#define iAssertW1(Assertion,PostAction)\\\r\n\t{\tbool returnValue = false;\\\r\n\t\tiAssertW(Assertion,PostAction,\"\")\\\r\n\t}\r\n\r\n\t#define iAssertAndAbortMesg(Assertion,Msg)\\\r\n\t{\tbool returnValue = false;\\\r\n\t\tiAssertW(Assertion,NULL,Msg);\\\r\n\t\tif(!returnValue)return;\\\r\n\t}\r\n\t#define iAssertAndAbort1(Assertion,POSTACTION)\\\r\n\t{\tbool returnValue = false;\\\r\n\t\tiAssertW(Assertion,POSTACTION,\"\");\\\r\n\t\tif(!returnValue)return;\\\r\n\t}\r\n\r\n\t#define xError(Message) xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,Message);\r\n\t#define xWarning(Message) xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,Message);\r\n\t#define xTrace(Message) xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,Message);\r\n\t#define xInfo(Message) xLogger::xLog(XL_START,ELOGINFO,E_LI_MANAGER,Message);\r\n\t\r\n\tvoid _inline qdbg(const char *fmt,...)\r\n\t{\n\t\tchar buffer[4096];\r\n\t\tunsigned int bufferStart = 0;\r\n\r\n\t\tva_list s;\r\n\t\tva_start( s, fmt );\r\n\t\t_vsnprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, fmt, s);\r\n\t\tva_end(s);\n\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_MANAGER,buffer);\r\n\t}\r\n\r\n\t#define xTrace1(Message,Object) { char buffer[D_MSG_BUFFER_MAX];\\\r\n\t\t_snprintf(buffer,Message,Object ? Object->GetName() : \"\");\\\r\n\t\txTrace(buffer)\\\r\n\t}\r\n\r\n\r\n\r\n//#define iAssertWR(Assertion,PostAction,Result) xVerify(Assertion) \r\n//#define iAssertW1(Assertion,PostAction) xVerify(Assertion) \r\n\r\n\t\t\r\n\t//(xAssertionEx::getErrorHandler() && (xAssertionEx::getErrorHandler()( AFS_ASSERT, #Assertion, __FILE__, __LINE__,\"\",\"\",FALSE), true)))\r\n//xVerify(Assertion);\r\n\r\n\r\n\t\r\n\t//xVerify(Assertion)\r\n\r\n\t\r\n\r\n\t\t\r\n\t//xASSERT_FORMAT_OPERATION(Condition,postMsg) \\\r\n\t//D_ASSERT_P_END(postStep) }\r\n\t\t\t\t\t\r\n\r\n\r\n\t\t\r\n\t\r\n\r\n\t\r\n\r\n\t//#define D_VERIFY_O(Condition,obj,postMsg) WASSERT_VERIFY_PREFIX(Condition,D_MSG_BUFFER_MAX)\r\n\t//#define D_VERIFY_CORRECT_MOP(Condition) WASSERT_VERIFY_AND_CORRECT_PREFIX(Condition)\r\n\t//xASSERT_FORMAT_OPERATION(Condition,postMsg);\r\n\r\n\r\n\t//,postMsg,postStep,Result\r\n\t//if(!(Condition)){char buffer[bufferSize];\r\n\t\t//char buffer[bufferSize]; \r\n\r\n\r\n\r\n\t//#define WASSERT_CHECK_PREFIX(Condition,bufferSize) xCheck(Condition); \r\n\t\t\r\n\r\n\t//char buffer[bufferSize];\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t//\t!assert(a) ? : print warning, do post step\r\n\t//\t\t\r\n\t//\r\n\r\n\t#define xWASSERT_O_P(Condition,obj,postMsg,postStep) WCASSERT_PREFIX(Condition,D_MSG_BUFFER_MAX)\\\r\n\t\txASSERT_FORMAT_OPERATION(Condition,postMsg) \\\r\n\t\tD_ASSERT_P_END(postStep) }\r\n\t\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// !assert(condition)? print warning and leave\r\n\t//\r\n\t#define D_WASSERTION_O(Condition,obj,postMsg) WASSERT_CHECK_PREFIX(Condition,D_MSG_BUFFER_MAX) \\\r\n\t\txASSERT_FORMAT_OPERATION(Condition,postMsg);\r\n\r\n\t\r\n\t\r\n\t#define D_CHECK_O(Condition,obj,postMsg) WASSERT_CHECK_PREFIX(Condition,D_MSG_BUFFER_MAX)\r\n\r\n\r\n\t\t//xASSERT_FORMAT_OPERATION(Condition,postMsg);\r\n\r\n\r\n/*D_ASSERT_P_END(postStep) }*/\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// !assert(condition)? print warning and leave\r\n\t//\r\n/*\t#define eAssertCheckMO(cond,obj,postMsg) WASSERT_CHECK_PREFIX(cond,D_MSG_BUFFER_MAX)\\\r\n\t\txASSERT_FORMAT_OPERATION(cond,postMsg) \\\r\n\t\tD_ASSERT_P_END(postStep) }\r\n*/\r\n#endif //D_FILE_INFO\r\n\r\n//#endif//file\r\n\r\n\t\r\n\r\n\t\t#ifndef __VSL_GLOBAL_FUNCTIONS_H__\r\n#define __VSL_GLOBAL_FUNCTIONS_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n/************************************************************************************************/\r\n/** @name Joints\r\n*/\r\n//@{\r\n\r\n\r\n/**\r\n\\brief Quick access for #PhysicManager::getJoint\r\n\r\n\\return pJoint*\r\n\r\n@see \r\n*/\r\npJoint*getJoint(CK3dEntity *referenceA,CK3dEntity *referenceB=NULL,JType type= JT_Any);\r\n\r\n\r\n//@}\r\n\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2009/02/17\r\n\tcreated:\t17:2:2009 8:23\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\xBaseTypes.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common \r\n\tfile base:\txBaseTypes\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tType definitions, Arrays, ...\r\n*********************************************************************/\r\n#ifndef __X_BASE_TYPES_H__\r\n#define __X_BASE_TYPES_H__\r\n\r\n\r\n//################################################################\r\n//\r\n// Float, Integers, Boolean\r\n//\r\n\r\n#ifndef u32\r\n\ttypedef unsigned int u32;\r\n#endif\r\n\r\nnamespace xBase\r\n{\r\n\ttypedef float xReal32;\r\n\ttypedef int xS32;\r\n\ttypedef unsigned int xU32;\r\n\ttypedef bool xBool;\r\n\ttypedef unsigned short\t\txU16;\r\n}\r\n\r\nusing xBase::xS32;\r\nusing xBase::xU32;\r\nusing xBase::xReal32;\r\nusing xBase::xBool;\r\nusing xBase::xU16;\r\n\r\n//################################################################\r\n//\r\n//\tContainers \r\n//\r\n\r\n#include\r\n#include \r\n#include \r\n\r\n#endif // __XBASETYPES_H__project( NxuStreamLib )\r\n\r\nadd_subdirectory (./) \r\n\r\ninclude_directories( \r\n ../../include/Physics\r\n ../../include/ageia\r\n ../../src/NXStream\r\n \r\n)\r\n\r\nadd_definitions( \r\n -DMODULE_BASE_EXPORTS\r\n -DNOMINMAX\r\n -DVIRTOOLS_MODULE\r\n -DVIRTOOLS_USER_SDK\r\n -DWIN32\r\n -D_CRT_SECURE_NO_DEPRECATE\r\n -D_DEBUG\r\n -D_USRDLL\r\n)\r\n\r\nadd_library( NxuStreamLib STATIC ${SOURCES} )\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPMaterialIteratorDecl();\r\nCKERROR CreatePMaterialIteratorProto(CKBehaviorPrototype **pproto);\r\nint PMaterialIterator(const CKBehaviorContext& behcontext);\r\nCKERROR PMaterialIteratorCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\nenum bInputs\r\n{\r\n\tI_XML,\r\n\tI_DFRICTION,\r\n\tI_SFRICTION,\r\n\tI_RES,\r\n\tI_DFRICTIONV,\r\n\tI_SFRICTIONV,\r\n\tI_ANIS,\r\n\tI_FCMODE,\r\n\tI_RCMODE,\r\n\tI_FLAGS,\r\n};\r\n\r\nenum bOutputs\r\n{\r\n\tO_INDEX,\r\n\tO_XML,\r\n\tO_NAME,\r\n\tO_DFRICTION,\r\n\tO_SFRICTION,\r\n\tO_RES,\r\n\tO_DFRICTIONV,\r\n\tO_SFRICTIONV,\r\n\tO_ANIS,\r\n\tO_FCMODE,\r\n\tO_RCMODE,\r\n\tO_FLAGS,\r\n\tO_MATERIAL,\r\n};\r\n\r\nCKERROR PMaterialIteratorCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\tCKContext *ctx = beh->GetCKContext();\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\r\n\t\t\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPMaterialIteratorDecl\r\n// FullName: FillBehaviorPMaterialIteratorDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration*FillBehaviorPMaterialIteratorDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PMaterialIterator\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Attaches and/or modifies the physic material of a rigid body or its sub shape\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x121d1c0f,0x65a62e73));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePMaterialIteratorProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePMaterialIteratorProto\r\n// FullName: CreatePMaterialIteratorProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePMaterialIteratorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PMaterialIterator\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\r\n\tproto->DeclareInput(\"Next\");\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"Loop\");\r\n\r\n\tproto->DeclareLocalParameter(\"current result\", CKPGUID_POINTER, \"0\");\r\n\r\n\tproto->DeclareOutParameter(\"Index\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"XML Link\",VTE_XML_MATERIAL_TYPE);\r\n\tproto->DeclareOutParameter(\"Name\",CKPGUID_STRING);\r\n\tproto->DeclareOutParameter(\"Dynamic Friction\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"Static Friction\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"Restitution\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"Dynamic Friction V\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"Static Friction V\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"Direction of Anisotropy \",CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Friction Combine Mode\",VTE_MATERIAL_COMBINE_MODE);\r\n\tproto->DeclareOutParameter(\"Restitution Combine Mode\",VTE_MATERIAL_COMBINE_MODE);\r\n\tproto->DeclareOutParameter(\"Flags\",VTF_MATERIAL_FLAGS);\r\n\tproto->DeclareOutParameter(\"Result\",VTS_MATERIAL);\r\n\r\n\tproto->SetBehaviorCallbackFct( PMaterialIteratorCB );\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PMaterialIterator);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PMaterialIterator\r\n// FullName: PMaterialIterator\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\ntypedef std::vectorLMaterials;\r\n\r\n\r\nint PMaterialIterator(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we reset our session counter\r\n\t\tint sessionIndex=-1;\r\n\t\tbeh->SetOutputParameterValue(0,&sessionIndex);\r\n\r\n\r\n\t\tLMaterials*sResults = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\r\n\t\t{\r\n\t\t\tsResults = new LMaterials();\r\n\t\t}else\r\n\t\t\tsResults->clear();\r\n\r\n\r\n\t\tNxScene * scene = GetPMan()->getDefaultWorld()->getScene();\r\n\t\tfor(int i = 0 ; i < GetPMan()->getDefaultWorld()->getScene()->getNbMaterials() ; i ++)\r\n\t\t{\r\n\t\t\r\n\t\t\tNxMaterial *currentMaterial = scene->getMaterialFromIndex(i);\r\n\r\n\t\t\tsResults->push_back(currentMaterial);\r\n\t\t}\r\n\r\n\t\tbeh->SetLocalParameterValue(0,&sResults);\r\n\r\n\r\n\r\n\t\tif (sResults->size())\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(1);\r\n\t\t}else\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\r\n\t\tint currentIndex=0;\tCKParameterOut *pout = beh->GetOutputParameter(0);\t\tpout->GetValue(&currentIndex);\r\n\t\tcurrentIndex++;\r\n\r\n\r\n\r\n\t\tLMaterials *sResults = NULL;\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\t\t{\t\t\tbeh->ActivateOutput(0);\t\t\treturn 0;\t\t}\r\n\r\n\t\tif (currentIndex>=sResults->size())\r\n\t\t{\r\n\t\t\tsResults->clear();\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tNxMaterial * material = sResults->at(currentIndex);\r\n\t\tif (material!=NULL)\r\n\t\t{\r\n\r\n\t\t\tint sIndex = currentIndex+1;\r\n\t\t\tbeh->SetOutputParameterValue(0,&sIndex);\r\n\r\n\t\t\t\r\n\r\n\t\t\t\t\t\r\n\t\t\t//SetOutputParameterValue(beh,O_XML,material->xmlLinkID);\r\n\t\t\tSetOutputParameterValue(beh,O_DFRICTION,material->getDynamicFriction());\r\n\t\t\tSetOutputParameterValue(beh,O_SFRICTION,material->getStaticFriction());\r\n\r\n\t\t\tSetOutputParameterValue(beh,O_RES,material->getRestitution());\r\n\r\n\t\t\tSetOutputParameterValue(beh,O_DFRICTIONV,material->getDynamicFrictionV());\r\n\t\t\tSetOutputParameterValue(beh,O_SFRICTIONV,material->getStaticFrictionV());\r\n\r\n\t\t\tSetOutputParameterValue(beh,O_ANIS,getFrom(material->getDirOfAnisotropy()));\r\n\t\t\tSetOutputParameterValue(beh,O_FCMODE,material->getFrictionCombineMode());\r\n\t\t\tSetOutputParameterValue(beh,O_RCMODE,material->getFrictionCombineMode());\r\n\t\t\tSetOutputParameterValue(beh,O_FLAGS,material->getFlags());\r\n\t\t}\r\n\r\n\t\tif(material->userData )\r\n\t\t{\r\n\t\t\tpMaterial *bMaterial = static_cast(material->userData);\r\n\r\n\t\t\tif (bMaterial && bMaterial->xmlLinkID )\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t\tint xid = bMaterial->xmlLinkID;\r\n\t\t\t\tXString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,xid);\r\n\t\t\t\tCKParameterOut *nameStr = beh->GetOutputParameter(O_NAME);\r\n\t\t\t\tnameStr->SetStringValue(nodeName.Str());\r\n\t\t\t}\r\n\t\t}\r\n\t\t//pFactory::Instance()->copyTo(beh->GetOutputParameter(O_MATERIAL),material);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"vtStructHelper.h\"\r\n\r\n#define PHYSIC_JOINT_CAT \"Physic Constraints\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\r\n\r\nStructurMember myStructJBall[] =\r\n{\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Limit Swing Axis\",\"0,0,0\"),\r\n\t\t\r\n\t\tSTRUCT_ATTRIBUTE(VTE_JOINT_PROJECTION_MODE,\"Projection Mode\",\"None\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Projection Distance\",\"0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"TRUE\"),\r\n\t\t\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JLIMIT,\"Swing Limit\",\"0.0,0.0,0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JLIMIT,\"Twist High Limit \",\"0.0,0.0,0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JLIMIT,\"Twist Low Limit \",\"0.0,0.0,0.0\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JOINT_SPRING,\"Swing Spring\",\"0.0,0.0,0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JOINT_SPRING,\"Twist Spring\",\"0.0,0.0,0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(VTS_JOINT_SPRING,\"Joint Spring\",\"0.0,0.0,0.0\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n\r\n};\r\n\r\n\r\nStructurMember myStructJDistance[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Local 0 Anchor\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Local 0 Reference\",\"\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Local 1 Anchor\",\"0,0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Local 1 Reference\",\"pDefaultWorld\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"TRUE\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Minimum Distance\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Distance\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_SPRING,\"Spring\",\"0.0f,0.0f,0.0f\"),\r\n\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n\r\n};\r\n\r\n\r\nStructurMember myStructJFixed[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n\r\n};\r\n\r\nStructurMember JPrismaticMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n\t\r\n};\r\n\r\nStructurMember JCylindricalMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n};\r\n\r\nStructurMember JPointInPlaneMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n};\r\n\r\nStructurMember JPointOnLineMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"\"),\r\n\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\t\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n};\r\n\r\nStructurMember JRevoluteMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Collision\",\"TRUE\"),\r\n\t\r\n\tSTRUCT_ATTRIBUTE(VTE_JOINT_PROJECTION_MODE,\"Projection Mode\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Projection Distance\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Projection Angle\",\"0.3\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_SPRING,\"Spring\",\"0.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JLIMIT,\"Limit High\",\"0.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JLIMIT,\"Limit Low\",\"0.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_MOTOR,\"Motor\",\"0.0,0.0,0.0\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Force\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Maximum Torque\",\"0.0\"),\r\n\r\n\r\n};\r\n\r\n\r\n\r\nStructurMember JLimitPlaneMemberTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\tSTRUCT_ATTRIBUTE(VTE_JOINT_TYPE,\"Target Joint Type\",\"JT_Any\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Restitution\",\"0.0f\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Point is on Body\",\"False\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Limit Point\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Limit Point Reference\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Normal\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Normal Up Reference\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Point in Plane\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Point in Plane Reference\",\"\"),\r\n\r\n};\r\n\r\nStructurMember JD6Members[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Body B\",\"BodyB\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Anchor\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Anchor Reference\",\"\"),\r\n\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Axis\",\"0,0,0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Axis Reference\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_JOINT_D6_AXIS_MASK,\"Axis Mask\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"X\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Y\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Z\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Swing 1\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Swing 2\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Twist Low\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_D6_AXIS_ITEM,\"Twist High\",\"\"),\r\n};\r\n\r\nStructurMember JD6AxisItem[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTE_JOINT_MOTION_MODE_AXIS,\"Axis\",\"X\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_JOINT_SLIMIT,\"Limit\",\"\"),\r\n};\r\n\r\n#define gSMapJDistance myStructJDistance\r\n#define gSMapJFixed myStructJFixed\r\n#define gSMapJBall myStructJBall\r\n#define gSMapJPrismatic JPrismaticMemberTable\r\n#define gSMapJRevolute JRevoluteMemberTable\r\n#define gSMapJCylindrical JCylindricalMemberTable\r\n#define gSMapJPointInPlane JPointInPlaneMemberTable\r\n#define gSMapJPointOnLine JPointOnLineMemberTable\r\n#define gSMapJLimitPlane JLimitPlaneMemberTable\r\n\r\nextern void\tPObjectAttributeCallbackFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);\r\nvoid PhysicManager::_RegisterJointParameters()\r\n{\r\n\r\n\t\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// D6 Help Structures\r\n\t//\r\n\r\n\tpm->RegisterNewEnum(VTE_JOINT_MOTION_MODE,\"pJMotionMode\",\"Locked=0,Limited=1,Free=2\");\r\n\tpm->RegisterNewStructure(VTS_JOINT_SLIMIT,\"pJD6SLimit\",\"Damping,Spring,Value,Restitution\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_ANGLE,CKPGUID_FLOAT);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Types for D6 - Joint - Attribute only :\r\n\t//\r\n\r\n\t\r\n\t//SetWindowLong(m_hWnd,GWL_USERDATA,(LONG)this_mod); // set our user data to a \"this\" pointer\r\n\t/*\r\n\tpm->RegisterNewEnum(VTF_JOINT_D6_AXIS_MASK,\"pD6AxisMask\",\"X=1,Y=2,Z=4,Swing1=8,Swing2=16,Twist Low=32,Twist High=64\");\r\n\tREGISTER_CUSTOM_STRUCT(\"pJD6AxisItem\",PS_D6_AXIS_ITEM,VTS_JOINT_D6_AXIS_ITEM,JD6AxisItem,TRUE);\r\n\tREGISTER_CUSTOM_STRUCT(\"pJD6\",PS_D6,VTS_JOINT_D6,JD6Members,TRUE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJD6\",PS_D6,PHYSIC_JOINT_CAT,VTS_JOINT_D6,CKCID_BEOBJECT,JD6Members,true,attRef);\r\n\r\n\t*/\r\n\r\n\tint attRef=0;\r\n\tpm->RegisterNewEnum(VTE_JOINT_TYPE,\"pJointType\",\"None=-1,Prismatic=0,Revolute=1,Cylindrical=2,Spherical=3,Point On Line=4,Point In Plane=5,Distance=6,Pulley=7,Fixed=8,D6=9\");\r\n\t\r\n\tpm->RegisterNewEnum(VTE_PHYSIC_JDRIVE_TYPE,\"pJD6DriveType\",\"Disabled=0,Position=1,Velocity=2\");\r\n\tpm->RegisterNewStructure(VTS_JOINT_DRIVE,\"pJD6Drive\",\"Damping,Spring,Force Limit,Drive Type\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,VTE_PHYSIC_JDRIVE_TYPE);\r\n\r\n\tpm->RegisterNewStructure(VTS_JOINT_SPRING,\"pJSpring\",\"Damper,Spring,Target Value\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT);\r\n\tpm->RegisterNewStructure(VTS_JLIMIT,\"pJLimit\",\"Value,Restitution,Hardness\",CKPGUID_ANGLE,CKPGUID_FLOAT,CKPGUID_FLOAT);\r\n\r\n\r\n\tpm->RegisterNewEnum(VTE_JOINT_MOTION_MODE_AXIS,\"pJD6Axis\",\"Twist=0,Swing1=1,Swing2=2,X=3,Y=4,Z=5\");\r\n\tpm->RegisterNewEnum(VTE_JOINT_DRIVE_AXIS,\"pJD6DriveAxis\",\"Twist=0,Swing=1,Slerp=2,X=3,Y=4,Z=5\");\r\n\tpm->RegisterNewEnum(VTE_JOINT_LIMIT_AXIS,\"pJD6LimitAxis\",\"Linear=0,Swing1=1,Swing2,Twist High,Twist Low\");\r\n\r\n\tpm->RegisterNewEnum(VTE_JOINT_PROJECTION_MODE,\"pJProjectionMode\",\"None=0,Point MinDist=1,Linear MindDist\");\r\n\tpm->RegisterNewStructure(VTS_JOINT_MOTOR,\"pJMotor\",\"Target Velocity,Maximum Force,Free Spin\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_BOOL);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJDistance\",PS_JDISTANCE_MEMBERS,VTS_JOINT_DISTANCE,gSMapJDistance,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJDistance\",PS_JDISTANCE_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_DISTANCE,CKCID_3DOBJECT,gSMapJDistance,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJFixed\",PS_JFIXED_MEMBERS,VTS_JOINT_FIXED,gSMapJFixed,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJFixed\",PS_JFIXED_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_FIXED,CKCID_3DOBJECT,gSMapJFixed,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJBall\",PS_JBALL_MEMBERS,VTS_JOINT_BALL,gSMapJBall,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJBall\",PS_JBALL_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_BALL,CKCID_3DOBJECT,gSMapJBall,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJPrismatic\",PS_JPRISMATIC_MEMBERS,VTS_JOINT_PRISMATIC ,gSMapJPrismatic,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJPrismatic\",PS_JPRISMATIC_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_PRISMATIC ,CKCID_BEOBJECT,gSMapJPrismatic,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJCylindrical\",PS_JCYLINDRICAL_MEMBERS,VTS_JOINT_CYLINDRICAL,gSMapJCylindrical,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJCylindrical\",PS_JCYLINDRICAL_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_CYLINDRICAL,CKCID_BEOBJECT,gSMapJCylindrical,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJRevolute\",PS_JREVOLUTE,VTS_JOINT_REVOLUTE,gSMapJRevolute,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJRevolute\",PS_JREVOLUTE,PHYSIC_JOINT_CAT,VTS_JOINT_REVOLUTE ,CKCID_BEOBJECT,gSMapJRevolute,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJPointInPlane\",PS_JPOINT_IN_PLANE_MEMBERS,VTS_JOINT_POINT_IN_PLANE,gSMapJPointInPlane,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJPointInPlane\",PS_JPOINT_IN_PLANE_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_POINT_IN_PLANE,CKCID_BEOBJECT,gSMapJPointInPlane,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJPointOnLine\",PS_JPOINT_ON_LINE_MEMBERS,VTS_JOINT_POINT_ON_LINE,gSMapJPointOnLine,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJPointOnLine\",PS_JPOINT_ON_LINE_MEMBERS,PHYSIC_JOINT_CAT,VTS_JOINT_POINT_ON_LINE,CKCID_BEOBJECT,gSMapJPointOnLine,true,attRef);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pJLimitPlane\",PS_JLIMIT_PLANE_MEMBERS,VTS_PHYSIC_JLIMIT_PLANE,gSMapJLimitPlane,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pJLimitPlane\",PS_JLIMIT_PLANE_MEMBERS,PHYSIC_JOINT_CAT,VTS_PHYSIC_JLIMIT_PLANE,CKCID_BEOBJECT,gSMapJLimitPlane,true,attRef);\r\n\r\n\r\n\r\n\r\n\r\n\tpopulateAttributeFunctions();\r\n\t_RegisterAttributeCallbacks();\r\n \r\n}\r\n \r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n/* \r\nCette partie décrit les codes de retour du serveur vers le client \r\nIls sont disponibles dans le RFC numéro 959 FILE TRANSFER PROTOCOL\r\nEn voici un extrait \r\n*/\r\n\r\n\r\n/* \r\n \r\nRFC 959 October 1985\r\nFile Transfer Protocol\r\n\r\n\r\n 4.2.2 Numeric Order List of Reply Codes\r\n\r\n 110 Restart marker reply.\r\n In this case, the text is exact and not left to the\r\n particular implementation; it must read:\r\n MARK yyyy = mmmm\r\n Where yyyy is User-process data stream marker, and mmmm\r\n server's equivalent marker (note the spaces between markers\r\n and \"=\").\r\n 120 Service ready in nnn minutes.\r\n 125 Data connection already open; transfer starting.\r\n 150 File status okay; about to open data connection.\r\n\r\n 200 Command okay.\r\n 202 Command not implemented, superfluous at this site.\r\n 211 System status, or system help reply.\r\n 212 Directory status.\r\n 213 File status.\r\n 214 Help message.\r\n On how to use the server or the meaning of a particular\r\n non-standard command. This reply is useful only to the\r\n human user.\r\n 215 NAME system type.\r\n Where NAME is an official system name from the list in the\r\n Assigned Numbers document.\r\n 220 Service ready for new user.\r\n 221 Service closing control connection.\r\n Logged out if appropriate.\r\n 225 Data connection open; no transfer in progress.\r\n 226 Closing data connection.\r\n Requested file action successful (for example, file\r\n transfer or file abort).\r\n 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).\r\n 230 User logged in, proceed.\r\n 250 Requested file action okay, completed.\r\n 257 \"PATHNAME\" created.\r\n \r\n 331 User name okay, need password.\r\n 332 Need account for login.\r\n 350 Requested file action pending further information.\r\n \r\n 421 Servlosing control connection.\r\n This may be a reply to any command if the service knows it\r\n must shut down.\r\n 425 Can't open data connection.\r\n 426 Connection closed; transfer aborted.\r\n 450 Requested file action not taken.\r\n File unavailable (e.g., file busy).\r\n 451 Requested action aborted: local error in processing.\r\n 452 Requested action not taken.\r\n Insufficient storage space in system.\r\n \r\n 500 Syntax error, command unrecognized.\r\n This may include errors such as command line too long.\r\n 501 Syntax error in parameters or arguments.\r\n 502 Command not implemented.\r\n 503 Bad sequence of commands.\r\n 504 Command not implemented for that parameter.\r\n 530 Not logged in.\r\n 532 Need account for storing files.\r\n 550 Requested action not taken.\r\n File unavailable (e.g., file not found, no access).\r\n 551 Requested action aborted: page type unknown.\r\n 552 Requested file action aborted.\r\n Exceeded storage allocation (for current directory or\r\n dataset).\r\n 553 Requested action not taken.\r\n File name not allowed.\r\n \r\n*/\r\n\r\n#define RFC_CMDOK 200\r\n#define RFC_DATACONNECTIONCLOSED 226\r\n#define RFC_USERLOGGEDIN 230\r\n#define RFC_FILEACTIONOK 250\r\n\r\n#define RFC_BADPARAMETERS 501\r\n#define RFC_NOTIMPLEMENTED 502\r\n#define RFC_NOTCONNECTED 530\r\n#define RFC_FILEUNAVAILABLE 550\r\n#define RFC_FILEACTIONABORTED 552\r\n#define RFC_BADFILENAME 553#if !defined(CUSTOMPLAYERSTATICDLLS_H)\r\n#define CUSTOMPLAYERSTATICDLLS_H\r\n\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\r\n\r\n#ifdef WIN32\r\n#define CDECL_CALL __cdecl\r\n#else\r\n#define CDECL_CALL\r\n#endif\r\n\r\n\r\n//----- Registration functions\t\r\ninline void CustomPlayerRegisterRenderEngine(CKPluginManager& iPluginManager);\r\ninline void CustomPlayerRegisterReaders(CKPluginManager& iPluginManager);\r\ninline void CustomPlayerRegisterManagers(CKPluginManager& iPluginManager);\r\ninline void CustomPlayerRegisterBehaviors(CKPluginManager& iPluginManager);\r\n\r\n//----- Behaviors\r\ninline void Register3DTransfoBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterBBAddonsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterBBAddons2Behaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterCamerasBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterCharactersBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterCollisionsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterControllersBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterGridsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterInterfaceBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterLightsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterLogicsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterMaterialsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterMeshesBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterMidiBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterNarrativesBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterParticleSystemsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterShaderBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterSoundsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterVSLBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterVideoBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterVisualsBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterWorldEnvBehaviors(CKPluginManager& iPluginManager);\r\n// network\r\ninline void RegisterNetworkBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterNetworkServerBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterMultiPlayerBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterDownloadBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterDatabaseBehaviors(CKPluginManager& iPluginManager);\r\ninline void RegisterCryptoBehaviors(CKPluginManager& iPluginManager);\r\n// physics\r\ninline void RegisterPhysicsBehaviors(CKPluginManager& iPluginManager);\r\n\r\n//----- Managers \r\ninline void RegisterParamOpManager(CKPluginManager& iPluginManager);\r\ninline void RegisterInputManager(CKPluginManager& iPluginManager);\r\ninline void RegisterSoundManager(CKPluginManager& iPluginManager);\r\ninline void RegisterCKFEMgrManager(CKPluginManager& iPluginManager);\r\ninline void RegisterVideoManager(CKPluginManager& iPluginManager);\r\ninline void RegisterDX8VideoManager(CKPluginManager& iPluginManager);\r\ninline void RegisterDX9VideoManager(CKPluginManager& iPluginManager);\r\n\r\n//----- Readers \r\ninline void RegisterVirtoolsReader(CKPluginManager& iPluginManager);\r\ninline void RegisterImageReader(CKPluginManager& iPluginManager);\r\ninline void RegisterAVIReader(CKPluginManager& iPluginManager);\r\ninline void RegisterPNGReader(CKPluginManager& iPluginManager);\r\ninline void RegisterJPGReader(CKPluginManager& iPluginManager);\r\ninline void RegisterWAVReader(CKPluginManager& iPluginManager);\r\ninline void RegisterTIFFReader(CKPluginManager& iPluginManager);\r\n\r\n\r\n\r\n//-----------------------------------------------------------\r\n// When behaviors and plugins are compiled in a static library : \r\n// List of declaration functions for every possible plugins...\r\n\r\nstruct\tCKRasterizerInfo;\r\nstruct\tCKPluginInfo;\r\nclass\tCKDataReader;\r\n\r\n/*******************************************\r\n+ There is only one function a rasterizer Dll is supposed\r\nto export :\"CKRasterizerGetInfo\", it will be used by the render engine \r\nto retrieve information about the plugin :\r\n- Description \r\n******************************************/\r\ntypedef void (*CKRST_GETINFO)(CKRasterizerInfo*); \r\n\r\n/***************************************************/\r\n/**** RENDER ENGINE ********************************/\r\nCKPluginInfo* CDECL_CALL CK2_3DGetPluginInfo(int Index);\r\n\r\n/***************************************************/\r\n/***** RASTERIZERS *********************************/\r\nvoid CDECL_CALL CKDX7RasterizerGetInfo(CKRasterizerInfo* Info);\r\nvoid CDECL_CALL CKDX8RasterizerGetInfo(CKRasterizerInfo* Info);\r\nvoid CDECL_CALL CKDX9RasterizerGetInfo(CKRasterizerInfo* Info);\r\nvoid CDECL_CALL CKGL15RasterizerGetInfo(CKRasterizerInfo* Info);\r\n\r\n/***************************************************/\r\n/**** READERS **************************************/\r\n//---- Virtools Reader (4)\r\nCKPluginInfo* CDECL_CALL CKGetVirtoolsPluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGetVirtoolsReader(int index);\r\n\r\n//---- Image Reader (3)\r\nCKPluginInfo* CDECL_CALL CKGet_ImageReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_ImageReader_Reader(int pos);\r\n\r\n//---- Avi Reader (1)\r\nCKPluginInfo* CDECL_CALL CKGet_AviReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_AviReader_Reader(int pos);\r\n\r\n//---- PNG Reader (1)\r\nCKPluginInfo* CDECL_CALL CKGet_PngReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_PngReader_Reader(int pos);\r\n\r\n//---- JPG Reader (1)\r\nCKPluginInfo* CDECL_CALL CKGet_JpgReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_JpgReader_Reader(int pos);\r\n\r\n//---- Wav Reader (3)\r\nCKPluginInfo* CDECL_CALL CKGet_WavReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_WavReader_Reader(int pos);\r\n\r\n//---- Tif Reader (1)\r\nCKPluginInfo* CDECL_CALL CKGet_TifReader_PluginInfo(int index);\r\nCKDataReader* CDECL_CALL CKGet_TifReader_Reader(int pos);\r\n\r\n/***************************************************/\r\n/**** EXTENSIONS ***********************************/\r\nCKPluginInfo* CDECL_CALL CKGet_ParamOp_PluginInfo(int Index);\r\n\r\n\r\n/***************************************************/\r\n/**** MANAGERS ***********************************/\r\nCKPluginInfo* CDECL_CALL CKGet_InputManager_PluginInfo(int Index);\r\nCKPluginInfo* CDECL_CALL CKGet_SoundManager_PluginInfo(int Index);\r\nCKPluginInfo* CDECL_CALL CKGet_VideoManager_PluginInfo(int Index);\r\nCKPluginInfo* CDECL_CALL CKGet_CKFEMgr_PluginInfo(int Index);\r\n\r\nCKPluginInfo* CDECL_CALL CKGet_Dx8VideoManager_PluginInfo(int Index);\r\nCKPluginInfo* CDECL_CALL CKGet_Dx9VideoManager_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Dx8VideoManager_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\nvoid CDECL_CALL Register_Dx9VideoManager_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\n/***************************************************/\r\n/**** BEHAVIORS ***********************************/\r\n\r\n\r\n\r\n//--- 3D Transfo (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_3DTransfo_PluginInfo(int index);\r\nvoid CDECL_CALL Register_3DTransfo_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ BuildingBlock Addons (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_BBAddons_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_BBAddons_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ BuildingBlock Addons 2 (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_BBAddons2_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_BBAddons2_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Cameras (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Cameras_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Cameras_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Controllers (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Controllers_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Controllers_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Characters (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Characters_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Characters_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Collisions (1: Coll Manager, 2 : Floor Manager , 3 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Collisions_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Collisions_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Grids (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_Grids_PluginInfo(int index);\r\nvoid CDECL_CALL Register_Grids_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Interface (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_Interface_PluginInfo(int index);\r\nvoid CDECL_CALL Register_Interface_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Lights (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Lights_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Lights_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Logics (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Logics_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Logics_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Materials (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Materials_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Materials_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Meshes (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_MeshModifiers_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_MeshModifiers_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Midi (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_MidiBehaviors_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_MidiBehaviors_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//------ Narratives (1 : Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Narratives_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Narratives_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Particles (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_Particles_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Particles_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Physics (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_Physics_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Physics_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Sounds (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Sounds_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Sounds_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Visuals (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Visuals_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Visuals_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- World Env (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_WorldEnvironment_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_WorldEnvironment_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- VSManager (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_VSManager_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_VSManager_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- VSServerManager (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_VSServerManager_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_VSServerManager_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- MultiPlayer (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_MP_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_MP_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- DownloadMedia (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_DLM_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_DLM_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Database (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_DBC_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_DBC_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- VSLManager (1: Beh, 2 : Manager)\r\nCKPluginInfo* CDECL_CALL CKGet_VSLManager_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_VSLManager_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- ShaderManager ( 1 : Manager, 2 : Beh) \r\n\r\nCKPluginInfo* CDECL_CALL CKGet_Shaders_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Shaders_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- CryptedLoader (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_CryptedLoader_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_CryptedLoader_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n//--- Video (1: Beh)\r\nCKPluginInfo* CDECL_CALL CKGet_Video_PluginInfo(int Index);\r\nvoid CDECL_CALL Register_Video_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\n\r\n//--------------------- Implementation -------------------------------------//\r\n//---------------------\t\t of -------------------------------------//\r\n//--------------------- registration functions -----------------------------//\r\n\r\n\r\n/****************************************************************************\r\nBEHAVIORS\r\n*******************************************************************************/\r\n\r\ninline void Register3DTransfoBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- 3D Tranfo\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_3DTransfo_PluginInfo(0),Register_3DTransfo_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_3DTransfo_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"3DTransfo\",2);\r\n}\r\n\r\ninline void RegisterBBAddonsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- BuildingBlock Addons (1 : Beh)\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_BBAddons_PluginInfo(0),Register_BBAddons_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"BBAddons\",1);\r\n}\r\n\r\ninline void RegisterBBAddons2Behaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- BuildingBlock Addons 2 (1 : Beh)\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_BBAddons2_PluginInfo(0),Register_BBAddons2_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"BBAddons2\",1);\r\n}\r\n\r\ninline void RegisterCamerasBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Cameras\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Cameras_PluginInfo(0),Register_Cameras_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Cameras\",1);\r\n}\r\n\r\ninline void RegisterControllersBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Controllers\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Controllers_PluginInfo(0),Register_Controllers_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Controllers\",1);\r\n}\r\n\r\ninline void RegisterCharactersBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Characters\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Characters_PluginInfo(0),Register_Characters_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Character\",1);\r\n}\r\n\r\ninline void RegisterCollisionsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Collisions\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Collisions_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Collisions_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterPluginInfo(2,CKGet_Collisions_PluginInfo(2),Register_Collisions_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Collision\",3);\r\n}\r\n\r\ninline void RegisterGridsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- Grids\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Grids_PluginInfo(0),Register_Grids_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Grids_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Grids\",2);\r\n}\r\n\r\ninline void RegisterInterfaceBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- Interface\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Interface_PluginInfo(0),Register_Interface_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Interface_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Interface\",2);\r\n}\r\n\r\ninline void RegisterLightsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Lights\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Lights_PluginInfo(0),Register_Lights_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Lights\",1);\r\n}\r\n\r\ninline void RegisterLogicsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Logics\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Logics_PluginInfo(0),Register_Logics_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Logics\",1);\r\n}\r\n\r\ninline void RegisterMaterialsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Materials\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Materials_PluginInfo(0),Register_Materials_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Materials\",1);\r\n}\r\n\r\ninline void RegisterMeshesBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- Meshes\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_MeshModifiers_PluginInfo(0),Register_MeshModifiers_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_MeshModifiers_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Meshes\",2);\r\n}\r\n\r\ninline void RegisterMidiBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- Midi\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_MidiBehaviors_PluginInfo(0),Register_MidiBehaviors_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_MidiBehaviors_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Midi\",2);\r\n}\r\n\r\ninline void RegisterNarrativesBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Narratives\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Narratives_PluginInfo(0),Register_Narratives_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Narratives\",1);\r\n}\r\n\r\ninline void RegisterParticleSystemsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Particle systems \r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Particles_PluginInfo(0),Register_Particles_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Particles_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"ParticleSystems\",2);\r\n}\r\n\r\ninline void RegisterPhysicsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Physics\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Physics_PluginInfo(0),Register_Physics_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Physics_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Physics\",2);\r\n}\r\n\r\ninline void RegisterSoundsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Sounds\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Sounds_PluginInfo(0),Register_Sounds_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Sounds\",1);\r\n}\r\n\r\ninline void RegisterShaderBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Shader Behaviors\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Shaders_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Shaders_PluginInfo(1),Register_Shaders_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Shaders\",2);\r\n}\r\n\r\ninline void RegisterVideoBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Visuals\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Video_PluginInfo(0),Register_Video_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Video\",1);\r\n}\r\n\r\ninline void RegisterVisualsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Visuals\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Visuals_PluginInfo(0),Register_Visuals_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Visuals\",1);\r\n}\r\n\r\ninline void RegisterWorldEnvBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- World Env\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_WorldEnvironment_PluginInfo(0),Register_WorldEnvironment_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"WorldEnv\",1);\r\n}\r\n\r\ninline void RegisterNetworkBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Network Manager\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_VSManager_PluginInfo(0),Register_VSManager_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_VSManager_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Network\",2);\r\n}\r\n\r\ninline void RegisterNetworkServerBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Network Server Manager\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_VSServerManager_PluginInfo(0),Register_VSServerManager_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_VSServerManager_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"NetworkServer\",2);\r\n}\r\n\r\ninline void RegisterMultiPlayerBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- MultiPlayer\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_MP_PluginInfo(0),Register_MP_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_MP_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"MultiPlayer\",2);\r\n}\r\n\r\ninline void RegisterDownloadBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- DownloadMedia\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_DLM_PluginInfo(0),Register_DLM_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"DownloadMedia\",1);\r\n}\r\n\r\ninline void RegisterDatabaseBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- Database\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_DBC_PluginInfo(0),Register_DBC_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Database\",1);\r\n}\r\n\r\ninline void RegisterVSLBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- VSL\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_VSLManager_PluginInfo(0),Register_VSLManager_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_VSLManager_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"VSL\",2);\r\n}\r\n\r\ninline void RegisterCryptoBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//-- CryptedLoader\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_CryptedLoader_PluginInfo(0),Register_CryptedLoader_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"CryptedLoader\",1);\r\n}\r\n\r\n\r\n/****************************************************************************\r\nMANAGERS\r\n*******************************************************************************/\r\n\r\n\r\ninline void RegisterParamOpManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_ParamOp_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"CKParamOp\",1);\r\n}\r\n\r\ninline void RegisterCKFEMgrManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_CKFEMgr_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"CKFEMgr\",1);\r\n}\r\n\r\ninline void RegisterInputManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_InputManager_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"InputManager\",1);\r\n}\r\n\r\ninline void RegisterSoundManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_SoundManager_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"SoundManager\",1);\r\n}\r\n\r\ninline void RegisterVideoManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_VideoManager_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"VideoManager\",1);\r\n}\r\n\r\ninline void RegisterDX8VideoManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Dx8VideoManager_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Dx8VideoManager_PluginInfo(1),Register_Dx8VideoManager_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"DX8VideoManager\",2);\r\n}\r\n\r\ninline void RegisterDX9VideoManager(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_Dx9VideoManager_PluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_Dx9VideoManager_PluginInfo(1),Register_Dx9VideoManager_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"DX9VideoManager\",2);\r\n}\r\n\r\n\r\n/****************************************************************************\r\nREADERS\r\n*******************************************************************************/\r\n\r\n\r\ninline void RegisterVirtoolsReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGetVirtoolsPluginInfo(0),NULL,CKGetVirtoolsReader);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGetVirtoolsPluginInfo(1),NULL,CKGetVirtoolsReader);\r\n\tiPluginManager.RegisterPluginInfo(2,CKGetVirtoolsPluginInfo(2),NULL,CKGetVirtoolsReader);\r\n\tiPluginManager.RegisterPluginInfo(3,CKGetVirtoolsPluginInfo(3),NULL,CKGetVirtoolsReader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Virtools Reader\",4);\r\n}\r\n\r\ninline void RegisterImageReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_ImageReader_PluginInfo(0),NULL,CKGet_ImageReader_Reader);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_ImageReader_PluginInfo(1),NULL,CKGet_ImageReader_Reader);\r\n\tiPluginManager.RegisterPluginInfo(2,CKGet_ImageReader_PluginInfo(2),NULL,CKGet_ImageReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Image Reader\",3);\r\n}\r\n\r\ninline void RegisterAVIReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_AviReader_PluginInfo(0),NULL,CKGet_AviReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"AVI Reader\",1);\r\n}\r\n\r\ninline void RegisterPNGReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_PngReader_PluginInfo(0),NULL,CKGet_PngReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"PNG Reader\",1);\r\n}\r\n\r\ninline void RegisterJPGReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_JpgReader_PluginInfo(0),NULL,CKGet_JpgReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"JPG Reader\",1);\r\n}\r\n\r\ninline void RegisterWAVReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_WavReader_PluginInfo(0),NULL,CKGet_WavReader_Reader);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_WavReader_PluginInfo(1),NULL,CKGet_WavReader_Reader);\r\n\tiPluginManager.RegisterPluginInfo(2,CKGet_WavReader_PluginInfo(2),NULL,CKGet_WavReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Wav Reader\",3);\r\n}\r\n\r\ninline void RegisterTIFFReader(CKPluginManager& iPluginManager)\r\n{\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_TifReader_PluginInfo(0),NULL,CKGet_TifReader_Reader);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Tiff Reader\",1);\r\n}\r\n\r\n\r\n\r\n\r\ninline void CustomPlayerRegisterRenderEngine(CKPluginManager& iPluginManager)\r\n{\r\n#if defined(USE_DX8)\r\n\tiPluginManager.AddRenderEngineRasterizer(CKDX8RasterizerGetInfo);\r\n#else\r\n\tiPluginManager.AddRenderEngineRasterizer(CKDX9RasterizerGetInfo);\r\n#endif\r\n\tiPluginManager.AddRenderEngineRasterizer(CKGL15RasterizerGetInfo);\r\n\tiPluginManager.RegisterPluginInfo(0,CK2_3DGetPluginInfo(0),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"ck2_3d\",1);\r\n}\r\n\r\ninline void CustomPlayerRegisterReaders(CKPluginManager& iPluginManager)\r\n{\r\n\tRegisterVirtoolsReader(iPluginManager);\r\n\tRegisterImageReader(iPluginManager);\r\n\tRegisterAVIReader(iPluginManager);\r\n\tRegisterPNGReader(iPluginManager);\r\n\tRegisterJPGReader(iPluginManager);\r\n\tRegisterWAVReader(iPluginManager);\r\n#if !defined(_DEBUG)\r\n\tRegisterTIFFReader(iPluginManager);\t\r\n#endif\r\n}\r\n\r\ninline void CustomPlayerRegisterManagers(CKPluginManager& iPluginManager)\r\n{\r\n\tRegisterParamOpManager(iPluginManager);\r\n\tRegisterInputManager(iPluginManager);\r\n\tRegisterSoundManager(iPluginManager);\r\n\tRegisterCKFEMgrManager(iPluginManager);\r\n\t//RegisterVideoManager(iPluginManager);\r\n#if defined(USE_DX8)\r\n\tRegisterDX8VideoManager(iPluginManager);\r\n#else\r\n\t//RegisterDX9VideoManager(iPluginManager);\r\n#endif\r\n}\r\n\r\ninline void CustomPlayerRegisterBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\r\n\tRegister3DTransfoBehaviors(iPluginManager);\r\n\tRegisterBBAddonsBehaviors(iPluginManager);\r\n\tRegisterBBAddons2Behaviors(iPluginManager);\r\n\tRegisterCamerasBehaviors(iPluginManager);\r\n\tRegisterCharactersBehaviors(iPluginManager);\r\n\tRegisterCollisionsBehaviors(iPluginManager);\r\n\tRegisterControllersBehaviors(iPluginManager);\r\n\tRegisterGridsBehaviors(iPluginManager);\r\n\tRegisterInterfaceBehaviors(iPluginManager);\r\n\tRegisterLightsBehaviors(iPluginManager);\r\n\tRegisterLogicsBehaviors(iPluginManager);\r\n\tRegisterMaterialsBehaviors(iPluginManager);\r\n\tRegisterMeshesBehaviors(iPluginManager);\r\n\tRegisterMidiBehaviors(iPluginManager);\r\n\tRegisterNarrativesBehaviors(iPluginManager);\r\n\tRegisterParticleSystemsBehaviors(iPluginManager);\r\n\t//RegisterShaderBehaviors(iPluginManager);\r\n\tRegisterSoundsBehaviors(iPluginManager);\r\n\tRegisterVSLBehaviors(iPluginManager);\r\n\t//RegisterVideoBehaviors(iPluginManager);\r\n\tRegisterVisualsBehaviors(iPluginManager);\r\n\tRegisterWorldEnvBehaviors(iPluginManager);\r\n\r\n\r\n\tRegisterPhysicsBehaviors(iPluginManager);\r\n/*\r\n\tRegisterCryptoBehaviors(iPluginManager);\r\n\tRegisterNetworkBehaviors(iPluginManager);\r\n\tRegisterNetworkServerBehaviors(iPluginManager);\r\n\tRegisterMultiPlayerBehaviors(iPluginManager);\r\n\tRegisterDownloadBehaviors(iPluginManager);\r\n\tRegisterDatabaseBehaviors(iPluginManager);\r\n\t*/\r\n\t\r\n\r\n}\r\n\r\n\r\n\r\n#endif // CUSTOM_PLAYER_STATIC\r\n\r\n\r\n#endif // CUSTOMPLAYERSTATICDLLS_H#include \"StdAfx.h\"\n#include \n#include \n#include \n\n#ifdef linux\n\t#include \n#endif\n\n// Screen Hertz; for Quizes, PAL should do the trick\n#define TRACES_PER_SECOND\t50\n\nQTimer::QTimer()\n{\n\tReset();\n}\nQTimer::~QTimer()\n{\n}\n\nvoid QTimer::ResetBase()\n// Reset 0-base for time counting\n{\n#ifdef USE_VTRACE\n baseVCount=app->GetVTraceCount();\n#endif\n\n#ifdef USE_UST\n dmGetUST(&baseUST);\n#endif\n\n#ifdef USE_TIME\n time(&base_secs);\n#endif\n\n#ifdef USE_GETTIMEOFDAY\n struct timezone tz;\n gettimeofday(&tvBase,&tz);\n // Calculate time in usecs\n base_usecs=tvBase.tv_sec*1000000+tvBase.tv_usec;\n#endif\n\n#ifdef USE_OS_TICK\n //baseTicks=(int)GetTickCount();\n baseTicks=(int)timeGetTime();\r\n#endif\n}\n\n/**********************\n* STOPWATCH EMULATION *\n**********************/\nvoid QTimer::UpdateTicks()\n// Updates 'ticks' to the last available time instant (NOW)\n{\n if(!isRunning)\n { \n return;\n }\n\n#ifdef USE_VTRACE\n int vc;\n vc=app->GetVTraceCount();\n ticks+=vc-baseVCount;\n baseVCount=vc;\n#endif\n\n#ifdef USE_UST\n uint64 vc;\n dmGetUST(&vc);\n ticks+=vc-baseUST;\n baseUST=vc;\n#endif\n\n#ifdef USE_OS_TICK\n // Looks a lot like UST\n int t;\n //t=(int)GetTickCount();\r\n t=(int)timeGetTime();\r\n ticks+=t-baseTicks;\n baseTicks=t;\n#endif\n\n#ifdef USE_GETTIMEOFDAY\n int t;\n struct timezone tz;\n gettimeofday(&tv,&tz);\n t=tv.tv_sec*1000000+tv.tv_usec;\n ticks+=t-base_usecs;\n base_usecs=t;\n#endif\n}\nvoid QTimer::Reset()\n{ /** Starts timer at current time **/\n ResetBase();\n ticks=0;\n isRunning=FALSE;\n}\nvoid QTimer::Start()\n// Turn timer on\n{\n if(isRunning)return;\n ResetBase();\n isRunning=TRUE;\n}\nvoid QTimer::Stop()\n// Stop time recording\n{\n if(!isRunning)return;\n UpdateTicks();\n isRunning=FALSE;\n}\n\n/****************\n* RETRIEVE TIME *\n****************/\nvoid QTimer::GetTime(ulong *secs,ulong *micros)\n/** Get passed time since last reset **/\n{\n\n}\nulong QTimer::GetSeconds()\n/** Get passed seconds since last Start() **/\n{ \n#ifdef USE_VTRACE\n long s;\n int vc;\n //vc=app->GetVTraceCount();\n //return (ulong)((vc-baseVCount)/TRACES_PER_SECOND);\n UpdateTicks();\n return ticks/TRACES_PER_SECOND;\n#endif\n#ifdef USE_UST\n UpdateTicks();\n return ticks/1000000000;\t\t// 10^9 = nanoseconds\n#endif\n#ifdef USE_TIME\n time_t t;\n time(&t);\n return (ulong)(t-base_secs);\n#endif\n#ifdef USE_OS_TICK\n UpdateTicks();\n return ticks/1000;\n#endif\n#ifdef USE_GETTIMEOFDAY\n UpdateTicks();\n return ticks/1000000;\n#endif\n}\n#ifdef USE_UST\nuint64 QTimer::GetTicks()\n#else\nint QTimer::GetTicks()\n#endif\n// Get #ticks, 1 tick is 1 vertical blank interval, or nanosecond, or WHATEVER!\n// Don't use this function in application code; too many variant\n{\n UpdateTicks();\n return ticks;\n //int vc;\n //vc=app->GetVTraceCount();\n //return (int)(vc-baseVCount);\n}\nint QTimer::GetMilliSeconds()\n{\n#ifdef USE_UST\n //uint64 div;\n //div=1000000;\n UpdateTicks();\n//qdbg(\"ticks=%lld\\n\",ticks);\n return (int)(ticks/1000000);\n#endif\n#ifdef USE_TIME\n UpdateTicks();\n return (int)(ticks*1000);\n#endif\n#ifdef USE_OS_TICK\n UpdateTicks();\n return (int)ticks;\n#endif\n#ifdef USE_GETTIMEOFDAY\n UpdateTicks();\n return ticks/1000;\n#endif\n}\nint QTimer::GetMicroSeconds()\n// Returns time in microseconds\n{\n#ifdef USE_UST\n UpdateTicks();\n return (int)(ticks/1000);\n#endif\n#ifdef USE_TIME\n UpdateTicks();\n return (int)(ticks*1000000);\n#endif\n#ifdef USE_OS_TICK\n // Not really microseconds!\n UpdateTicks();\n return (int)ticks;\n#endif\n#ifdef USE_GETTIMEOFDAY\n UpdateTicks();\n return ticks;\n#endif\n}\n\n\nvoid QTimer::WaitForTime(int secs,int msecs)\n// Reasonably multitasking-friendly wait for the timer to pass the given\n// time and return.\n// On O2's and most low level SGI's, the accurary is ~10ms (scheduler slice)\n// Starts the timer if it is not running (instead of just returning)\n// On Win32, we might just use Sleep()\n{ int n;\n secs=secs*1000+msecs;\n // Make sure timer is running\n if(!IsRunning())Start();\n while(1)\n { n=GetMilliSeconds();\n if(n>=secs)break;\n Sleep(10);\n }\n}\n\n/*****************\n* TIME ADJUSTING *\n*****************/\nvoid QTimer::AdjustMilliSeconds(int delta)\n// Adjust time in milliseconds\n// 'delta' may be negative or positive. Note that this may underflow the\n// timer, meaning it will be negative.\n{\n#ifdef USE_UST\n uint64 delta64;\n delta64=(uint64)delta;\n // Get time in nanoseconds\n delta64*=1000000;\n ticks+=delta64;\n#endif\n#ifdef USE_OS_TICK\n // Adjust msecs\n ticks+=delta;\n#endif\n#ifdef USE_GETTIMEOFDAY\n ticks+=delta*1000;\n#endif\n}\n\n/** TEST **/\n\n//#define NOTDEF_TEST\n#ifdef NOTDEF_TEST\n\n#include \n\nvoid main(void)\n{ QTimer *qt;\n ulong s,m;\n QAppSetup();\n qt=new QTimer();\n while(!RMB())\n { qt->GetTime(&s,&m);\n printf(\"S=%d, M=%4d\\n\",s,m);\n }\n //delete qt;\n QAppQuit();\n}\n\n#endif\n#ifndef __PWHEELTYPES_H__\r\n#define __PWHEELTYPES_H__\r\n\r\n#include \"NxVec3.h\"\r\n#include \"NxMat34.h\"\r\n#include \"NxUserContactReport.h\"\r\n\r\n//#include \"pRigidBodyTypes.h\"\r\n//#include \"pVTireFunction.h\"\r\n\r\n\r\n\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\nclass pWheelContactModifyData\r\n{\r\npublic :\r\n\tCK3dEntity *object;\r\n\tVxVector contactPoint;\r\n\tVxVector contactNormal;\r\n\tfloat contactPosition;\r\n\tfloat normalForce;\r\n\tint otherMaterialIndex;\r\n\tpWheelContactModify()\r\n\t{\r\n\t\tobject = NULL;\r\n\t\tcontactPosition = 0.0f;\r\n\t\tnormalForce = 0.0f;\r\n\t\totherMaterialIndex = 0;\r\n\t}\r\n};\r\n\r\n\r\n\r\n\r\nstruct ContactInfo \r\n{\r\n\tContactInfo() { reset(); }\r\n\tvoid reset() { otherActor = NULL; relativeVelocity = 0; }\r\n\tbool isTouching() const { return otherActor != NULL; }\r\n\tNxActor*\t\t\t\totherActor;\r\n\tNxVec3\t\t\t\t\tcontactPosition;\r\n\tNxVec3\t\t\t\t\tcontactPositionLocal;\r\n\tNxVec3\t\t\t\t\tcontactNormal;\r\n\tNxReal\t\t\t\t\trelativeVelocity;\r\n\tNxReal\t\t\t\t\trelativeVelocitySide;\r\n};\r\n\r\n\r\n/**\r\n\\brief Contact information used by pWheel\r\n\r\n\r\n@see pWheel pWheel.getContact()\r\n*/\r\nclass pWheelContactData\r\n{\r\npublic:\r\n\t/**\r\n\t\\brief The point of contact between the wheel shape and the ground.\r\n\r\n\t*/\r\n\tVxVector contactPoint;\r\n\r\n\t/**\r\n\t\\brief The normal at the point of contact.\r\n\r\n\t*/\r\n\tVxVector contactNormal;\r\n\r\n\t/**\r\n\t\\brief The direction the wheel is pointing in.\r\n\t*/\r\n\tVxVector longitudalDirection;\r\n\r\n\t/**\r\n\t\\brief The sideways direction for the wheel(at right angles to the longitudinal direction).\r\n\t*/\r\n\tVxVector lateralDirection;\r\n\r\n\t/**\r\n\t\\brief The magnitude of the force being applied for the contact.\r\n\t*/\r\n\tfloat contactForce;\r\n\r\n\t/**\r\n\t\\brief What these exactly are depend on NX_WF_INPUT_LAT_SLIPVELOCITY and NX_WF_INPUT_LNG_SLIPVELOCITY flags for the wheel.\r\n\t*/\r\n\tfloat longitudalSlip, lateralSlip;\r\n\r\n\t/**\r\n\t\\brief the clipped impulses applied at the wheel.\r\n\t*/\r\n\tfloat longitudalImpulse, lateralImpulse;\r\n\r\n\t/**\r\n\t\\brief The material index of the shape in contact with the wheel.\r\n\r\n\t@see pMaterial \r\n\t*/\r\n\tint otherShapeMaterialIndex;\r\n\r\n\t/**\r\n\t\\brief The distance on the spring travel distance where the wheel would end up if it was resting on the contact point.\r\n\t*/\r\n\tfloat contactPosition;\r\n\r\n\t/**\r\n\t\\brief The distance on the spring travel distance where the wheel would end up if it was resting on the contact point.\r\n\t*/\r\n\tCK3dEntity* contactEntity;\r\n\r\n\r\n\t/**\r\n\t\\brief The material of the colliding shape \r\n\t*/\r\n\tpMaterial otherMaterial;\r\n\r\n};\r\n\r\n/**\r\n\\brief An interface class that the user can implement in order to modify the contact point on which the \r\nWheelShape base its simulation constraints.\r\n\r\nThreading: It is necessary to make this class thread safe as it will be called in the context of the\r\nsimulation thread. It might also be necessary to make it reentrant, since some calls can be made by multi-threaded\r\nparts of the physics engine.\r\n\r\nYou enable the use of this callback by specifying a callback function in NxWheelShapeDesc.wheelContactModify \r\nor by setting a callback function through NxWheelShape.setUserWheelContactModify().\r\n\r\nPlease note: \r\n+ There will only be callbacks if the WheelShape finds a contact point. Increasing the suspensionTravel value\r\ngives a longer raycast and increases the chance of finding a contact point (but also gives a potentially slower \r\nsimulation).\r\n\r\n@see NxWheelShapeDesc.wheelContactModify NxWheelShape.setUserWheelContactModify() NxWheelShape.getUserWheelContactModify()\r\n*/\r\nclass MODULE_API pWheelContactModify : NxUserWheelContactModify\r\n{\r\n\tpublic:\r\n\r\n\t\tpWheelContactModify() :\r\n\t\t wheel(NULL) , lastContactModifyData()\r\n\t\t {\r\n\r\n\t\t }\r\n\t\t/**\r\n\t\t\\brief This callback is called once for each wheel and sub step before the wheel constraints are setup\r\n\t\tand fed to the SDK. The values passed in the parameters can be adjusted to affect the vehicle simulation.\r\n\t\tThe most interesting values are contactPosition, contactPoint, and contactNormal. The contactPosition value\r\n\t\tspecifies how far on the travel distance the contactPoint was found. If you want to simulate a bumpy road,\r\n\t\tthen this is the main parameter to change. It is also good to adjust the contactPoint variable, so that the\r\n\t\twheel forces are applied in the correct position. \r\n\r\n\t\t\\param wheelShape The WheelShape that is being processed.\r\n\t\t\\param contactPoint The contact point (in world coordinates) that is being used for the wheel.\r\n\t\t\\param contactNormal The normal of the geometry at the contact point.\r\n\t\t\\param contactPosition The distance on the spring travel distance where the wheel would end up if it was resting on the contact point.\r\n\t\t\\param normalForce The normal force on the wheel from the last simulation step.\r\n\t\t\\param otherShape The shape with which the wheel is in contact.\r\n\t\t\\param otherShapeMaterialIndex The material on the other shape in the position where the wheel is in contact. Currently has no effect on the simulation.\r\n\t\t\\param otherShapeFeatureIndex The feature on the other shape in the position where the wheel is in contact.\r\n\r\n\t\t\\return Return true to keep the contact (with the possibly edited values) or false to drop the contact.\r\n\t\t*/\r\n\t\tvirtual bool onWheelContact(NxWheelShape* wheelShape, NxVec3& contactPoint, NxVec3& contactNormal, NxReal& contactPosition, NxReal& normalForce, NxShape* otherShape, NxMaterialIndex& otherShapeMaterialIndex, NxU32 otherShapeFeatureIndex);\r\n\r\n\t\tpWheelContactModifyData* lastContactModifyData;\r\n\r\n\r\n\t\tpWheelContactModifyData* getLastContactModifyData() const { return lastContactModifyData; }\r\n\t\tvoid setLastContactModifyData(pWheelContactModifyData* val) { lastContactModifyData = val; }\r\n\r\n\r\n\t\tpWheel2* getWheel() const { return wheel; }\r\n\t\tvoid setWheel(pWheel2* val) { wheel = val; }\r\n\t\t\r\n\t\tpWheelContactModifyData& getLastData(){ return lastData; }\r\n\t\tvoid setLastData(pWheelContactModifyData val) { lastData = val; }\r\n\r\n\r\nprivate:\r\n\r\n\tpWheel2* wheel;\r\n\tpWheelContactModifyData lastData;\r\n\t\r\n\r\n};\r\n\r\n\r\n\r\n\r\n/** @} */\r\n\r\n#endif // __PWHEELTYPES_H__#ifndef __P_V_TIRE_FUNCTION_H__\r\n#define __P_V_TIRE_FUNCTION_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\n\r\n/**\r\n\\brief cubic hermit spline coefficients describing the longitudinal tire force curve.\r\n\r\nForce\r\n^\t\textrema\r\n| _*_\r\n| ~ \\ asymptote\r\n| / \\~__*______________\r\n| /\r\n|/\r\n---------------------------> Slip\r\n*/\r\nclass MODULE_API pTireFunction\r\n\t{\r\n\tpublic:\r\n\r\n\tvirtual ~pTireFunction(){};\r\n\t\r\n\t/**\r\n\t\\brief extremal point of curve. Both values must be positive.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 1.0\r\n\t*/\r\n\tfloat extremumSlip;\r\n\r\n\t/**\r\n\t\\brief extremal point of curve. Both values must be positive.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 0.02\r\n\t*/\r\n\tfloat extremumValue;\r\n\r\n\t/**\r\n\t\\brief point on curve at which for all x > minumumX, function equals minimumY. Both values must be positive.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 2.0\r\n\t*/\r\n\tfloat asymptoteSlip;\r\n\t\r\n\t/**\r\n\t\\brief point on curve at which for all x > minumumX, function equals minimumY. Both values must be positive.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 0.01\r\n\t*/\r\n\tfloat asymptoteValue;\r\n\r\n\r\n\t/**\r\n\t\\brief Scaling factor for tire force.\r\n\t\r\n\tThis is an additional overall positive scaling that gets applied to the tire forces before passing \r\n\tthem to the solver. Higher values make for better grip. If you raise the *Values above, you may \r\n\tneed to lower this. A setting of zero will disable all friction in this direction.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 1000000.0 (quite stiff by default)\r\n\t*/\r\n\tfloat stiffnessFactor;\r\n\r\n\r\n\t/**\r\n\t\\brief Scaling factor for tire force.\r\n\t\r\n\tThis is an additional overall positive scaling that gets applied to the tire forces before passing \r\n\tthem to the solver. Higher values make for better grip. If you raise the *Values above, you may \r\n\tneed to lower this. A setting of zero will disable all friction in this direction.\r\n\r\n\tRange: (0,inf)
\r\n\tDefault: 1000000.0 (quite stiff by default)\r\n\t*/\r\n//\tfloat stiffnessFactor;\r\n\r\n\r\n\t/**\r\n\tconstructor sets to default.\r\n\t*/\r\n\tpTireFunction();\t\r\n\t/**\r\n\t(re)sets the structure to the default.\t\r\n\t*/\r\n\tvirtual\tvoid\tsetToDefault();\r\n\t/**\r\n\treturns true if the current settings are valid\r\n\t*/\r\n\tvirtual\tbool\tisValid() const;\r\n\r\n\t/**\r\n\tevaluates the Force(Slip) function\r\n\t*/\r\n\tfloat hermiteEval(float t) const;\r\n\r\n\r\n\tint xmlLink;\r\n\t\r\n};\r\n\r\n/** @} */\r\n\r\n#endif#include \"xDistributedInteger.h\"\r\n#include \"xPredictionSetting.h\"\r\n#include \"xMathFnc2.h\"\r\n\r\nuxString \r\nxDistributedInteger::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedInteger::updateFromServer(TNL::BitStream *stream)\r\n{\r\n\r\n\tmLastServerValue = stream->readSignedInt(32);\r\n\tsetValueState(E_DV_UPDATED);\r\n}\r\n\r\nvoid\r\nxDistributedInteger::updateGhostValue(TNL::BitStream *stream)\r\n{\r\n\t\r\n\tstream->writeSignedInt(mCurrentValue,32);\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedInteger::unpack(TNL::BitStream *bstream,float sendersOneWayTime)\r\n{\r\n\r\n\tmLastValue = mCurrentValue;\r\n\tint value = bstream->readSignedInt(32);\r\n\tmCurrentValue = value;\r\n\tmDifference= mCurrentValue - mLastValue;\r\n \r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedInteger::pack(TNL::BitStream *bstream)\r\n{\r\n\t\t\r\n\tbstream->writeSignedInt(mCurrentValue,32);\r\n\tint flags = getFlags();\r\n\tflags &= (~E_DP_NEEDS_SEND);\r\n\tsetFlags(flags);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedInteger::updateValue(TNL::S32 value,xTimeType currentTime)\r\n{\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue = mCurrentValue;\r\n mCurrentValue = value;\r\n\tmDifference = mCurrentValue - mLastValue;\r\n\t\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\r\n\r\n\tfloat lengthDiff = fabsf((float)mDifference +0.5f);\r\n\r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\tbool result = false;\r\n\r\n\tif ( lengthDiff > getPredictionSettings()->getMinDifference() ) \r\n\t{\r\n\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime() )\r\n\t\t{\r\n\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\tresult = true ;\r\n\t\t}\r\n\t}\r\n\r\n\tfloat serverDiff = (float)(mCurrentValue-mLastServerValue);\r\n\r\n\tif ( fabsf( serverDiff + .5f) > getPredictionSettings()->getMinDifference() )\r\n\t{\r\n\t\tif (mThresoldTicker2 > (getPredictionSettings()->getMinSendTime() * 0.2f) )\r\n\t\t{\r\n\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\tresult = true ;\r\n\t\t}\r\n\t}\r\n\r\n\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime() )\r\n\t{\r\n\t\tmThresoldTicker2 = 0 ;\r\n\t\tmThresoldTicker = 0;\r\n\t}\r\n\tsetFlags(flags);\r\n\treturn result;\r\n}#ifndef __P_REFERENCED_OBJECT_H__\r\n#define __P_REFERENCED_OBJECT_H__\r\n\r\ntemplateclass MODULE_API pStoredObjectAssociation\r\n{\r\n\tpublic:\r\n\r\n\t\t//xEngineObjectAssociation() : mInternalId(-1) , mClassId(-1) {};\r\n\t\t//xEngineObjectAssociation(EngineObject _Object,ImplementationObject _ImplObject,int _EngineObjectId) : mEngineObject(_Object) , mImplementationObject(_ImplObject) , mInternalId(_EngineObjectId) { } \r\n\t\t//xEngineObjectAssociation< (EngineObject _Object,ImplementationObject _ImplObject,int _EngineObjectId){}\r\n\t\tint getInternalId() const { return mInternalId; }\r\n\t\tvoid setInternalId(int val) { mInternalId = val; }\r\n\r\n\t\tint getClassId() const { return mClassId; }\r\n\t\tvoid setClassId(int val) { mClassId = val; }\r\n\r\n\r\n\t\tbool existsInCore();\r\n\r\n\t\tvirtual void onCreate(){};\r\n\t\tvirtual void onCopy(int oldId){};\r\n\t\tvirtual void onRemove(){};\r\n\t\tvirtual void onDelete(){};\r\n\t\tvirtual void onCheck(){};\r\n\r\n\t\t//operator T(){\treturn mObject; }\r\n\r\n\r\n\tprotected:\r\n\r\n\tprivate:\r\n\t\tint mClassId;\r\n\t\tint mInternalId;\r\n\t\tEngineObject mEngineObject;\r\n\t\tImplementationObject mImplementationObject;\r\n\r\n};\r\n\r\n\r\ntemplateclass MODULE_API xImplementationObject\r\n{\r\npublic:\r\n\r\n\t\t//xLinkedObjectStorage() : mInternalId(-1) , mClassId(-1) {};\r\n\t\ttypedef void* xImplementationObject::*StoragePtr;\r\n\t\txImplementationObject(){}\r\n\t\txImplementationObject(StoragePtr storage)\r\n\t\t{ \r\n\r\n\t\t} \r\n\r\n\t\tT getImpl() { return mObject; }\r\n\r\n\r\n\tprotected:\r\n\tprivate:\r\n\t\tT mObject;\r\n\t\tStoragePtr mStorage;\r\n\r\n};\r\n\r\n\r\ntemplateclass MODULE_API xEngineObjectAssociation\r\n{\r\n\tpublic:\r\n\r\n\t\txEngineObjectAssociation() :\r\n\t\t\tmInternalId(-1) , mClassId(-1) {};\r\n\t\txEngineObjectAssociation(T _Object,int _InternalId) : \r\n\t\t\tmObject(_Object) , mInternalId(_InternalId) { } \r\n\t\t\r\n\t\tint getInternalId() const { return mInternalId; }\r\n\t\tvoid setInternalId(int val) { mInternalId = val; }\r\n\r\n\t\tint getClassId() const { return mClassId; }\r\n\t\tvoid setClassId(int val) { mClassId = val; }\r\n\r\n\t\t\r\n\t\tbool existsInCore();\r\n\r\n\t\tvirtual void onCreate(){};\r\n\t\tvirtual void onCopy(int oldId){};\r\n\t\tvirtual void onRemove(){};\r\n\t\tvirtual void onDelete(){};\r\n\t\tvirtual void onCheck(){};\r\n\r\n\t\t//operator T(){\treturn mObject; }\r\n\r\n\tprotected:\r\n\tprivate:\r\n\t\tint mClassId;\r\n\t\tint mInternalId;\r\n\t\tT mObject;\r\n\r\n};\r\n#endif#if !defined(CUSTOMPLAYERSTATICLIBS_H)\r\n#define CUSTOMPLAYERSTATICLIBS_H\r\n\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\r\n#pragma warning( disable : 4099)\r\n\r\n#if defined(_DEBUG)\r\n\t#pragma comment(lib,\"strmbase\")\r\n#else\r\n\t#pragma comment(lib,\"strmbase\")\r\n#endif\r\n\r\n\r\n// virtools base libraries\r\n#pragma comment(lib,\"CKZlibStatic\")\r\n#pragma comment(lib,\"VxMathStatic\") \r\n#pragma comment(lib,\"CK2Static\")\r\n#pragma comment(lib,\"AssemblerStatic\")\r\n#pragma comment(lib,\"VSLStatic\")\r\n#pragma comment(lib,\"VSLManagerStatic\")\r\n#pragma comment(lib,\"CKFEMgrStatic\")\r\n#pragma comment(lib,\"CKRasterizerLibStatic\")\r\n#pragma comment(lib,\"CK2_3DStatic\")\r\n\r\n// opengl rasterizers\r\n// If you need CGFX uncomment\r\n//#pragma comment(lib,\"cg\")\r\n//#pragma comment(lib,\"cgGL\")\r\n#pragma comment(lib,\"opengl32\")\r\n#pragma comment(lib,\"CKGLRasterizerStatic\")\r\n\r\n// DirectX rasterizers\r\n#pragma comment(lib,\"dxguid\")\r\n\r\n#if defined(USE_DX8)\r\n\t#pragma comment(lib,\"d3dx8\")\r\n\t#pragma comment(lib,\"d3d8\")\r\n\t#pragma comment(lib,\"CKDX8RasterizerStatic\")\r\n#else\r\n\t#pragma comment(lib,\"dxerr9\")\r\n\t#pragma comment(lib,\"d3dx9\")\r\n\t#pragma comment(lib,\"d3d9\")\r\n\t#pragma comment(lib,\"CKDX9RasterizerStatic\")\r\n#endif\r\n\r\n\r\n// virtools plugins\r\n#pragma comment(lib,\"VirtoolsLoaderStatic\")\r\n#pragma comment(lib,\"ImageReaderStatic\")\r\n#pragma comment(lib,\"TiffReaderStatic\")\r\n#pragma comment(lib,\"Vfw32\")\r\n#pragma comment(lib,\"Winmm\")\r\n#pragma comment(lib,\"Msacm32\")\r\n#pragma comment(lib,\"AviReaderStatic\")\r\n#pragma comment(lib,\"WavReaderStatic\")\r\n#pragma comment(lib,\"JpgLoaderStatic\")\r\n#pragma comment(lib,\"PngLoaderStatic\")\r\n#pragma comment(lib,\"AscLoaderStatic\")\r\n#if defined(USE_DX8)\r\n\t#pragma comment(lib,\"Dx8VideoManagerStatic\")\r\n#else\r\n\t//#pragma comment(lib,\"Dx9VideoManagerStatic\")\r\n#endif\r\n#pragma comment(lib,\"3dsLoaderStatic\")\r\n#if defined(USE_DX8)\r\n\t#pragma comment(lib,\"DDSReaderStatic\")\r\n#else\r\n\t#pragma comment(lib,\"DDSReaderStatic9\")\r\n#endif\r\n#pragma comment(lib,\"TiffReaderStatic\")\r\n#pragma comment(lib,\"XLoaderStatic\")\r\n\r\n// thir party libraries used for plugins\r\n#if defined(_DEBUG)\r\n\t#pragma comment(lib,\"JpegLibD\")\r\n\t#pragma comment(lib,\"pnglibd\")\r\n#else\r\n\t#pragma comment(lib,\"jpeglib\")\r\n\t#pragma comment(lib,\"pnglib\")\r\n\t#pragma comment(lib,\"LibTiff\")\r\n#endif\r\n\r\n\r\n// virtools managers\r\n#pragma comment(lib,\"dsound\")\r\n#pragma comment(lib,\"DX7SoundManagerStatic\")\r\n#pragma comment(lib,\"dinput8\")\r\n#pragma comment(lib,\"DX5InputManagerStatic\")\r\n#pragma comment(lib,\"ParameterOperationsStatic\")\r\n//#pragma comment(lib,\"VideoManagerStatic\")\r\n\r\n// virtools behaviors\r\n#pragma comment(lib,\"3DTransfoStatic\")\r\n#pragma comment(lib,\"BuildingBlocksAddons1Static\")\r\n#pragma comment(lib,\"BuildingBlocksAddons2Static\")\r\n#pragma comment(lib,\"CamerasStatic\")\r\n#pragma comment(lib,\"CharactersStatic\")\r\n#pragma comment(lib,\"CollisionsStatic\")\r\n#pragma comment(lib,\"ControllersStatic\")\r\n#pragma comment(lib,\"GridsStatic\")\r\n#pragma comment(lib,\"InterfaceStatic\")\r\n#pragma comment(lib,\"LightsStatic\")\r\n#pragma comment(lib,\"LogicsStatic\")\r\n#pragma comment(lib,\"MaterialsStatic\")\r\n#pragma comment(lib,\"MeshModifiersStatic\")\r\n#pragma comment(lib,\"MidiManagerStatic\")\r\n#pragma comment(lib,\"NarrativesStatic\")\r\n#pragma comment(lib,\"ParticleSystemsStatic\")\r\n#pragma comment(lib,\"SoundsStatic\")\t\t\r\n//#pragma comment(lib,\"VideoStatic\")\r\n#pragma comment(lib,\"VisualsStatic\")\r\n#pragma comment(lib,\"WorldEnvironmentsStatic\")\r\n// If you need CGFX uncomment this line and comment the next one\r\n \r\n//#pragma comment(lib,\"ShaderStatic\")\r\n/*#pragma comment(lib,\"ShaderStaticHLSL\")*/\r\n\r\n\r\n#ifdef vtToolkit\r\n\t#pragma comment(lib,\"vtToolkit\")\r\n#endif // vtTools\r\n\r\n#ifdef vtWidgets\r\n\t#pragma comment(lib,\"vtWidgets\")\r\n#endif\r\n\r\n#ifdef vtPhysX\r\n\t#pragma comment(lib,\"vtPhysXLib\")\r\n#endif\r\n\r\n\r\n// physics libraries\r\n#pragma comment(lib,\"PhysicsStatic\")\r\n\r\n\r\n// virtools network\r\n/*#pragma comment(lib,\"VCryptStatic\")\r\n#pragma comment(lib,\"CryptedLoaderStatic\")\r\n#pragma comment(lib,\"nk2static\")\r\n#pragma comment(lib,\"vsutilsstatic\")\r\n#pragma comment(lib,\"vsmanager2static\")\r\n#pragma comment(lib,\"VSServer2static\") // NOTE: this lib is in the Additional Dependencies of the linker (for linking problems)\r\n#pragma comment(lib,\"MultiUserClientStatic\")\r\n#pragma comment(lib,\"MultiUserServerStatic\")// NOTE: this lib is in the Additional Dependencies of the linker (for linking problems)\r\n#pragma comment(lib,\"DatabaseClientModule2Static\")\r\n#pragma comment(lib,\"DownloadMediaClient2Static\")\r\n*/\r\n\r\n\r\n#endif // CUSTOM_PLAYER_STATIC\r\n\r\n\r\n#endif // CUSTOMPLAYERSTATICLIBS_H\r\n\r\n/*\n * Tcp4u v 3.31 Creation 27/02/1998 Last Revision 27/02/1998 3.30\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: smtp4u.h\n * Purpose: main functions for smtp protocol management\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * Permission is hereby granted to copy, distribute or otherwise\n * use any part of this package as long as you do not try to make\n * money from it or pretend that you wrote it. This copyright\n * notice must be maintained in any copy made.\n *\n * Use of this software constitutes acceptance for use in an AS IS\n * condition. There are NO warranties with regard to this software.\n * In no event shall the author be liable for any damages whatsoever\n * arising out of or in connection with the use or performance of this\n * software. Any use of this software is at the user's own risk.\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n * ()\n */\n\n\n#ifndef SMTP4UX_API\n\n#ifdef __cplusplus \nextern \"C\" { /* Assume C declarations for C++ */ \n#endif /* __cplusplus */ \n\n\n#define SMTP4U_DEFPORT 25\n#define SMTP4U_DEFTIMEOUT 60 /* seconds */\n#define SMTP4U_SEPARATOR ';' /* semi colon character */\n\n/**************************\n * definition error code\n **************************/\n\nenum SMTP4_RETURN_CODE {\n SMTP4U_UNEXPECTEDANSWER = -3100, /* answer was not expected */\n SMTP4U_SERVICECLOSED, /* service unavailable */\n SMTP4U_NOTIMPLEMENTED, /* host recognize but can't exec cmd*/\n SMTP4U_MIMENOTSUPPORTED, /* server doesn't support MIME ext. */\n SMTP4U_SERVERCANTEXECUTE, /* refused by server */\n SMTP4U_CANTCONNECT, /* can not connect to the server */\n SMTP4U_DATAERROR, /* Error during communication */\n SMTP4U_SYNTAXERROR, /* Bad parameters */\n SMTP4U_STORAGEEXCEDED, /* server limits exceeded */\n SMTP4U_UNKNOWNUSER, /* unknown destinee */\n SMTP4U_SUCCESS = 1, /* Success !! */\n SMTP4U_FORWARDED /* address OK,unknwon on this server*/\n};\n\n\nint API4U SmtpSendMessage (LPCSTR szFrom, \n LPCSTR szTo, \n LPCSTR szMessage,\n LPCSTR szHost, \n LPCSTR szMyDomain);\n\n\n\n#ifdef __cplusplus \n} /* End of extern \"C\" */ \n#endif /* ifdef __cplusplus */\n\n#define SMTP4UX_API loaded\n#endif /* ifndef SMTP4UX_API */\n#include \"CKAll.h\"\r\nCKObjectDeclaration\t*FillBehaviorGetCurrentPathDecl();\r\nCKERROR CreateGetCurrentPathProto(CKBehaviorPrototype **pproto);\r\nint GetCurrentPath(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetCurrentPathDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Get Current Path\");\t\r\n\tod->SetDescription(\"Add Objects\");\r\n\tod->SetCategory(\"Narratives/Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x41676403,0x5d3d10c4));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetCurrentPathProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGetCurrentPathProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Get Current Path\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Create Zip File\");\r\n\tproto->DeclareOutput(\"Zip File created\");\r\n\tproto->DeclareOutParameter(\"Path\",CKPGUID_STRING);\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(GetCurrentPath);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint GetCurrentPath(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tXString Current;\r\n\tVxGetCurrentDirectory(Current.Str());\r\n\tCKParameterOut *pout = beh->GetOutputParameter(0);\r\n\tpout->SetStringValue(Current.Str());\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n/********************************************************************\r\n\tcreated:\t2007/12/12\r\n\tcreated:\t12:12:2007 11:55\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\\vtcxglobal.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\r\n\tfile base:\tvtcxglobal\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n\r\n\r\n#ifndef __VTCXGLOBAL_H_\r\n\t#define __VTCXGLOBAL_H_\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tPlatform Headers\r\n//\r\n\r\n#include \r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tPlatform specific header switchs : \r\n//\r\n#ifdef _WIN32\r\n\t#include \r\n#endif\r\n\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tBuild switchs : \r\n//\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// \r\n//\tGBLDebugBuild is used to hide GBL - private building blocks, types, attributes,...\r\n#ifdef NDEBUG\r\n\tstatic const bool vtCXDebugBuild = true;\r\n#else\r\n\tstatic const bool vtCXDebugBuild = false;\r\n#endif\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n// dll directives :\r\n#ifndef VTCX_API_EXPORT\r\n\t#define VTCX_API_EXPORT __declspec(dllexport)\r\n#endif\r\n\r\n#ifndef VTCX_API_INLINE\r\n\t#define VTCX_API_INLINE __inline\r\n#endif\r\n\r\n#ifndef VTCX_API_sCALL\r\n\t#define VTCX_API_sCALL __stdcall\r\n#endif\r\n\r\n#ifndef VTCX_API_cDECL\r\n\t#define VTCX_API_cDECL __cdecl\r\n#endif\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tAPI Specific Constants :\r\n//\r\n\r\n#define VTCX_API_PREFIX \"vtCX\"\r\n#define VTCX_API_ENTRY(F) VTCX_API_PREFIX##F\r\n\r\n#define VTCX_API_CUSTOM_BB_CATEGORY(F) VTCX_API_PREFIX##F\t\r\n\t//\t#define MY_BB_CAT VTCX_API_CUSTOM_BB_CATEGORY(/Configurable Information) leads to : \"GBL/Configurable Information\"\r\n\r\n\r\n#ifndef VTCX_AUTHOR\r\n\t#define\tVTCX_AUTHOR\t\t\t\t\"\"\r\n#endif\r\n\r\n#ifndef VTCX_AUTHOR_GUID\r\n\t#define\tVTCX_AUTHOR_GUID\t\t\tCKGUID(0x79ba75dd,0x41d77c63)\r\n#endif\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tError Identifiers : \r\n//\r\n\r\n//Error code to identify the GBL-COMMON Component :\r\n#define VTCX_ERROR_ID_VTCX_COMMON 10\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFile System Specific : \t\t\t\t\t\t\r\n//\r\n\r\n#if defined (_LINUX)\r\n\t#define VTCX_FS_PATH_SEPERATOR '/'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR ':'\r\n\t#define VTCX_FS_EOL \"\\n\"\t\t\t//(0x0D)\r\n#endif\r\n\r\n#ifdef _WIN32\r\n\t#define VTCX_FS_PATH_SEPERATOR '\\\\'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR \r\n\t#define VTCX_FS_EOL \"\\r\\n\"\t\t//(0x0A 0x0D)\r\n#endif\r\n\r\n#if defined (macintosh)\r\n\t#define VTCX_FS_PATH_SEPERATOR '/'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR \r\n\t#define VTCX_FS_EOL \"\\r\"\t\t//(0x0A)\r\n#endif\r\n\r\n#define VTCX_FS_PATH_EXT_SEPARATOR '.'\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n\r\n \t\t\r\n\r\n\r\n#endif///////////////////////////////////////////////////////////\r\n// xLogger.cpp\r\n// Implementation of the Class xLogger\r\n// Created on: 10-Feb-2007 12:40:39\r\n///////////////////////////////////////////////////////////\r\n//#include \r\n//#include \r\n\r\n#include \r\n\r\n\r\n#include \r\n#include \r\n\r\n#include \"xLogger.h\"\r\n#include \"uxString.h\"\r\n#include \"xBitSet.h\"\r\n\r\n#include \r\n#include \"tnlLog.h\"\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nusing xUtils::xLogger;\r\nusing xUtils::xLoggerFlags;\r\n//using xUtils::xLogConsumer;\r\nusing namespace xUtils;\r\n\r\n/*\r\nusing namespace TNL;\r\nusing namespace TNL::Platform;\r\n*/\r\n\r\n\r\n\r\n\r\nxLogConsumer *xLogConsumer::mLinkedList = NULL;\r\nvoid xLogConsumer::logString(const char *string)\r\n{\r\n\t// by default the LogConsumer will output to the platform debug \r\n\t// string printer, but only if we're in debug mode\r\n//#ifdef TNL_DEBUG\r\n\r\n\tTNL::Platform::outputDebugString(string);\r\n\tTNL::Platform::outputDebugString(\"\\n\");\r\n\r\n\t//printf(string);\r\n/*\tOutputDebugString(string);\r\n\tOutputDebugString(\"\\n\");\r\n*/\r\n\r\n}\r\n\r\nxLogConsumer::xLogConsumer()\r\n{\r\n\tmNextConsumer = mLinkedList;\r\n\tif(mNextConsumer)\r\n\t\tmNextConsumer->mPrevConsumer = this;\r\n\tmPrevConsumer = NULL;\r\n\tmLinkedList = this;\r\n}\r\n\r\nxLogConsumer::~xLogConsumer()\r\n{\r\n\tif(mNextConsumer)\r\n\t\tmNextConsumer->mPrevConsumer = mPrevConsumer;\r\n\tif(mPrevConsumer)\r\n\t\tmPrevConsumer->mNextConsumer = mNextConsumer;\r\n\telse\r\n\t\tmLinkedList = mNextConsumer;\r\n}\r\n\r\n\r\n\r\nstatic xLogger *xlog=NULL;\r\n\r\nconst char*formatLine(const char *msg,...);\r\nvoid printMessage(const char*buffer);\r\n\r\n#include \r\n#define ANSI /* Comment out for UNIX version */\r\n#ifdef ANSI /* ANSI compatible version */\r\n\t#include \r\n\tint average( int first, ... );\r\n#else /* UNIX compatible version */\r\n\t#include \r\n\tint average( va_list );\r\n#endif\r\n\r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\t#include \"CKAll.h\"\r\n#endif\r\n\r\nvoid xLogger::finalPrint(const char*string)\r\n{\r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\r\n\tif (getVirtoolsContext())\r\n\t{\r\n\t\tgetVirtoolsContext()->OutputToConsole(const_cast(string),FALSE);\r\n\t}\r\n#endif\r\n\r\n\tif (strlen(string))\r\n\t{\r\n\t\tprintf(string);\r\n\t\tTNL::Platform::outputDebugString(string);\r\n\r\n\t}\r\n\t\r\n\tfor(xLogConsumer *walk = xLogConsumer::getLinkedList(); walk; walk = walk->getNext())\r\n\t\twalk->logString(string);\r\n\r\n}\r\n\r\nvoid xLogger::enableLoggingLevel(int item,int level,int enable)\r\n{\r\n\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n\r\n\t\txBitSet& flags = it->second;\r\n\t\tif (level !=8)\r\n\t\t{\r\n\t\t\tflags.set( 1 << level,enable);\r\n\t\t}else\r\n\t\t\tflags.set();\r\n\t\t\r\n\t}\r\n}\r\n\r\n\r\n//************************************\r\n// Method: getLogLevel\r\n// FullName: xLogger::getLogLevel\r\n// Access: public \r\n// Returns: xBitSet\r\n// Qualifier:\r\n// Parameter: int item\r\n//************************************\r\nxBitSet xLogger::getLogLevel(int item)\r\n{\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n\t\treturn it->second;\r\n\t}\r\n\r\n\txBitSet result;\r\n\tresult.set();\r\n\treturn result;\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: addLogItem\r\n// FullName: xLogger::addLogItem\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: int item\r\n//************************************\r\nvoid xLogger::addLogItem(int item)\r\n{\r\n\r\n\r\n\txBitSet flags;\r\n\tflags.set(1 << ELOGWARNING,true);\r\n\tflags.set(1 << ELOGERROR,true);\r\n\tflags.set(1 << ELOGINFO,true);\r\n\r\n\tgetLogItems().insert(std::make_pair(item,flags));\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: setLoggingLevel\r\n// FullName: xLogger::setLoggingLevel\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: int item\r\n// Parameter: xBitSet flags\r\n//************************************\r\nvoid xLogger::setLoggingLevel(int item,xBitSet flags)\r\n{\r\n\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n xBitSet& lflags = it->second;\r\n\t\tlflags = flags;\r\n \r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: dVsprintf\r\n// FullName: dVsprintf\r\n// Access: public \r\n// Returns: signed int\r\n// Qualifier:\r\n// Parameter: char *buffer\r\n// Parameter: unsigned int bufferSize\r\n// Parameter: const char *format\r\n// Parameter: void *arglist\r\n//************************************\r\nsigned int dVsprintf(char *buffer, unsigned int bufferSize, const char *format, void *arglist)\r\n{\r\n#ifdef TNL_COMPILER_VISUALC\r\n\tsigned int len = _vsnprintf(buffer, bufferSize, format, (va_list) arglist);\r\n#else\r\n\tsigned int len = vsnprintf(buffer, bufferSize, format, (char *) arglist);\r\n#endif\r\n\treturn len;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: xLog\r\n// FullName: xLogger::xLog\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: char *cppText\r\n// Parameter: int type\r\n// Parameter: int component\r\n// Parameter: const char *header\r\n// Parameter: ...\r\n//************************************\r\nvoid xLogger::xLog(char *cppText,int type,int component,const char *header, ...)\r\n{\r\n\r\n\r\n\t\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\r\n\tva_end(s);\r\n\r\n\tchar headerout[2048];\r\n\tif (strlen(cppText))\r\n\t{\t\t\r\n\t\tsprintf(headerout,\"%s :\\t->%s\",cppText,header);\r\n\t\txLog(type,component,headerout,buffer);\r\n\t}else\r\n\t{\r\n\t\txLog(type,component,header,buffer);\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: xLog\r\n// FullName: xLogger::xLog\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: xBitSet styleFlags\r\n// Parameter: int type\r\n// Parameter: int component\r\n// Parameter: const char *header\r\n// Parameter: ...\r\n//************************************\r\nvoid xLogger::xLog(xBitSet styleFlags,int type,int component,const char *header, ...)\r\n{\r\n\r\n\t/*\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\tchar headerBuffer[4096];\r\n\tchar verbosityStr[512];\r\n\tchar componentString[256];\r\n\tsprintf(componentString,\"%s\",sLogItems[component]);\r\n\r\n\r\n\tuxString leadIn(\"\");\r\n\r\n\tif (type > 4)\t{\t\ttype =4;\t} \r\n\tif (type < 0)\t{\t\ttype =0;\t} \r\n\r\n\tif ( styleFlags.test(E_PSF_PRINT_LOG_TYPE) )\r\n\t{\r\n\t\tleadIn << \"\\n<-----------------> \" << sLogTypes[type] << \" : \";\r\n\t}\r\n\t\r\n\tif ( styleFlags.test(E_PSF_PRINT_COMPONENT) )\r\n\t{\r\n\t\tleadIn << \"|---\" << componentString << \"--|\";\r\n\t}\r\n\r\n\tleadIn << \"\\n\";\r\n\t\r\n\r\n\r\n\tswitch(type)\r\n\t{\r\n\t\tcase ELOGINFO:\r\n\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t\tbreak;\r\n\t\tcase ELOGTRACE:\r\n\t\t\tSetConsoleTextAttribute(hConsole, 11);\r\n\t\t\tbreak;\r\n\t\tcase ELOGERROR:\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t\tbreak;\r\n\t\tcase ELOGWARNING:\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif ( styleFlags.test(E_PSF_PRINT_LOG_TYPE) || styleFlags.test(E_PSF_PRINT_COMPONENT) )\r\n\t\tTNL::logprintf(leadIn.CStr());\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\tchar buffer2[4096];\r\n\tsprintf(buffer2,\" : %s \",buffer);\r\n\tTNL::logprintf(buffer2);\r\n\r\n\t\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n*/\r\n\treturn;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: xLog\r\n// FullName: xLogger::xLog\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: int type\r\n// Parameter: int component\r\n// Parameter: const char *header\r\n// Parameter: ...\r\n//************************************\r\nvoid xLogger::xLog(int type,int component,const char *header, ...)\r\n{\r\n\r\n\r\n\t\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\t\r\n\tchar headerBuffer[4096];\r\n\tchar verbosityStr[512];\r\n\tchar componentString[256];\r\n\r\n\tint descriptionS = xLogger::GetInstance()->getItemDescriptions().size();\r\n\tconst char* cString = GetInstance()->getItemDescriptions().at(component);\r\n\tif(component <= xLogger::GetInstance()->getItemDescriptions().size() )\r\n\t\tsprintf(componentString,\"%s\",GetInstance()->getItemDescriptions().at(component));\r\n\telse\r\n\t\tsprintf(componentString,\"UNKNOWN COMPONENT\");\r\n\r\n\r\n\r\n\t\r\n\tswitch(type)\r\n\t{\r\n\tcase ELOGINFO:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"\\n<----------------->\tINFO : |---%s---|\\n\",componentString);\r\n\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGTRACE:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"\\n<----------------->\tTRACE : |---%s---|\\n\",componentString);\r\n\t\t\tSetConsoleTextAttribute(hConsole, 11);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGERROR:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"\\n<----------------->\tERROR : |---%s---|\\n\",componentString);\r\n\t\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGWARNING:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"\\n<----------------->\tWARNING : |---%s---|\\n\",componentString);\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN);\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\tsprintf(headerBuffer,\"%s\",verbosityStr);\r\n\tGetInstance()->finalPrint(headerBuffer);\r\n\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\tchar buffer2[4096];\r\n\tsprintf(buffer2,\" : %s\\n\",buffer);\r\n\tGetInstance()->finalPrint(buffer2);\r\n\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\treturn;\r\n\r\n}\r\n\r\n\r\n//************************************\r\n// Method: xLogExtro\r\n// FullName: xLogger::xLogExtro\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: int style\r\n// Parameter: const char *header\r\n// Parameter: ...\r\n//************************************\r\nvoid xLogger::xLogExtro(int style,const char *header, ...)\r\n{\r\n\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n//\tTNL::Platform::outputDebugString(buffer);\r\n//\tTNL::Platform::outputDebugString(\"\\n\");\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\r\n\tchar headerBuffer[4096];\r\n\r\n\tsprintf(headerBuffer,\"%s\\n\",header);\r\n\tGetInstance()->finalPrint(buffer);\r\n\r\n\r\n\t//printf(headerBuffer);\r\n\r\n\t/*\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN);\r\n\t*/\r\n\r\n//\tprintf(\"\\n%s\",buffer);\r\n\t\r\n//TNL::logprintf(headerBuffer);\r\n//\tTNL::logprintf(buffer);\r\n\t/*\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);*/\r\n\r\n\r\n\treturn;\r\n\r\n\r\n\r\n}\r\n\r\nvoid \r\nxLogger::xLog(int verbosity,const char *header,const char*msg,...)\r\n{\r\n\r\n\t\r\n\t\tchar buffer[4096];\r\n\t\tunsigned int bufferStart = 0;\r\n\r\n\t\tva_list s;\r\n\t\tva_start( s, msg );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, msg, s);\r\n\t\tva_end(s);\r\n\r\n\t\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\t\r\n\t\tchar headerBuffer[4096];\r\n\t\tchar verbosityStr[512];\r\n\t\r\n\t\tswitch(verbosity)\r\n\t\t{\r\n\t\t\tcase ELOGINFO:\r\n\t\t\t\t{\r\n\t\t\t\t\tsprintf(verbosityStr,\"--------------------------------------INFO\t\\n-\\n\");\r\n\t\t\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\tcase ELOGERROR:\r\n\t\t\t\t{\r\n\t\t\t\t\tsprintf(verbosityStr,\"ooo--------------------------------ERROR\t\\n-\\n\");\r\n\t\t\t\t\t/*SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\t\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\t\t\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);*/\r\n\t\t\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\t\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t//sprintf(headerBuffer,\"%s %s\\n\\t%s\\n----\",verbosityStr,header,buffer);\r\n\t\tsprintf(headerBuffer,\"%s %s-\\n--\",verbosityStr,header);\r\n\t\tprintf(headerBuffer);\r\n\t\t\r\n\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN);\r\n\r\n\t\tprintf(\"--->%s\\n\",buffer);\r\n\t\r\n\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\r\n\r\n\t\t//TNL::logprintf(headerBuffer);\r\n\t\treturn;\r\n\r\n\t\tva_list va;\r\n\t\tva_start (va,msg);\r\n\t\tchar bufferN[1024] = { 0 } ; \r\n\t\tvsprintf(bufferN,msg,va );\r\n\t\tva_end (va);\r\n\t\tprintMessage(bufferN);\r\n\t\r\n\r\n}\r\n\r\n//************************************\r\n// Method: getLogFlags\r\n// FullName: xLogger::getLogFlags\r\n// Access: public \r\n// Returns: xBitSet&\r\n// Qualifier:\r\n//************************************\r\nxBitSet& xLogger::getLogFlags()\r\n{\r\n\treturn GetInstance()->mLogFlags ;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: getVerbosityFlags\r\n// FullName: xLogger::getVerbosityFlags\r\n// Access: public \r\n// Returns: xBitSet&\r\n// Qualifier:\r\n//************************************\r\nxBitSet& xLogger::getVerbosityFlags()\r\n{\r\n\treturn GetInstance()->m_VerbosityFlags;\r\n}\r\n\r\n//************************************\r\n// Method: isLogging\r\n// FullName: xLogger::isLogging\r\n// Access: public \r\n// Returns: bool\r\n// Qualifier:\r\n// Parameter: int logItem\r\n//************************************\r\nbool xLogger::isLogging(int logItem)\r\n{ \r\n\treturn GetInstance()->getVerbosityFlags().test(1<getVerbosityFlags().set(1<< logItem,enbabled); \r\n}\r\n\r\n/*\r\nvoid \r\nxLogger::xLog(DWORD verbosity,const char*msg,...)\r\n{\r\n\r\n\t\tchar buffer[4096];\r\n\t\tunsigned int bufferStart = 0;\r\n\r\n\t\tva_list s;\r\n\t\tva_start( s, msg );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, msg, s);\r\n\t\tva_end(s);\r\n\r\n\t\t//printf(buffer);\r\n\t\tTNL::logprintf(buffer);\r\n\t\treturn;\r\n\r\n\t\tva_list va;\r\n\t\tva_start (va,msg);\r\n\t\tchar bufferN[1024] = { 0 } ; \r\n\t\tvsprintf(bufferN,msg,va );\r\n\t\tva_end (va);\r\n\t\tprintMessage(bufferN);\r\n\r\n}\r\n*/\r\n\r\n\r\nvoid \r\nxLogger::Init()\r\n{\r\n\r\n}\r\n\r\nxLogger::xLogger()\r\n{\r\n\r\n\txlog = this;\r\n\tm_LogOutChannels = ELOGGER_NONE;\r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\tmContext = NULL;\r\n#endif\r\n\r\n\r\n\r\n}\r\n\r\n//************************************\r\n// Method: GetInstance\r\n// FullName: xLogger::GetInstance\r\n// Access: public \r\n// Returns: xLogger*\r\n// Qualifier:\r\n//************************************\r\nxLogger*xLogger::GetInstance()\r\n{\r\n\tif (xlog ==NULL)\t{\r\n\t\txlog = new xLogger();\t}\r\n\treturn xlog;\r\n}\r\n\r\nvoid printMessage(const char*buffer)\r\n{\r\n\r\n\tusing namespace xUtils;\r\n\r\n\t/*if ( (xlog->m_LogOutChannels & ELOGGER_CONSOLE) && console )\r\n\t{\r\n\t\t//Consoleln(buffer);\r\n\t\tfflush (stderr);\r\n\t\tfflush (stdout);\r\n\t\tstrcpy(xlog->m_ConsStream->buf,buffer);\r\n\r\n\t}\r\n\r\n\tif ( (xlog->m_LogOutChannels & ELOGGER_CEGUI) && ceGUI && xGuiSystem::GetInstance()->m_RenderingGUI )\r\n\t{\r\n\t\tgetApp->SetDebugPanelText(0,buffer);\r\n\t}*/\r\n}\r\n\r\n\r\nxLogger::~xLogger()\r\n{\r\n\r\n}\r\n/*\n * Tcp4u v 3.31 Last Revision 06/06/1997 3.20\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: skt4u.c\n * Purpose: Stats on socket usage\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n\n\n\n/* ****************************************************************** */\n/* Etage 0 : */\n/* Gestion des donnees internes */\n/* */\n/* ****************************************************************** */\n\nstatic BOOL bInitDone=FALSE; /* Init has been done */\n\n\n/* ------------------------------------------------------------------ */\n/* Historiques des ouvertures / fermetures */\n/* ------------------------------------------------------------------ */\n\nstatic struct S_HistoSocket HistoSocket[512];\n\n#define FindFirstFreeIdx() FindSocketIdx (INVALID_SOCKET)\n#define INVALID_INDEX -1\n#ifndef INVALID_SOCKET\n# define INVALID_SOCKET (SOCKET) (-1)\n#endif /* INVALID_SOCKET */\n\n\n/* ------------------------------------------------------------------ */\n/* recherche d'un index dans le tableau */\n/* ------------------------------------------------------------------ */\nstatic int FindSocketIdx (SOCKET s)\n{\nint Ark;\n for (Ark=0 ; Ark pas besoin de UnrcdSkt */\n for (Ark=0 ; Ark#ifndef __X_MESSAGE_H_\r\n#define __X_MESSAGE_H_\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nclass xMessage\r\n{\r\npublic :\r\n\r\n\r\n\r\n\txMessage()\r\n\t{\r\n\r\n\t\tmessageID = -1;\r\n\t\tmessageType = -1;\r\n\t\tmFlags = 0 ; \r\n\t\tlifeTime = 0.0f;\r\n\t\tmSendCount =0;\r\n\t\tsrcUser = -1;\r\n\t\tdstUser = -1;\r\n\t\tmNumUsers = 0;\r\n\r\n\r\n\t}\r\n\r\n\tfloat getLifeTime() const { return lifeTime; }\r\n\tvoid setLifeTime(float val) { lifeTime = val; }\r\n\r\n\tbool IsComplete() const { return complete; }\r\n\tvoid SetComplete(bool val) { complete = val; }\r\n\r\n\tint getDstUser() const { return dstUser; }\r\n\tvoid setDstUser(int val) { dstUser = val; }\r\n\r\n\r\n\tint getSrcUser() const { return srcUser; }\r\n\tvoid setSrcUser(int val) { srcUser = val; }\r\n\t\r\n\tint getClientSideSrcUser() const { return clientSideSrcUser; }\r\n\tvoid setClientSideSrcUser(int val) { clientSideSrcUser = val; }\r\n\r\n\tint getNumParameters() { return mParameters.size(); }\r\n\r\n\tint getMessageID() const { return messageID; }\r\n\tvoid setMessageID(int val) { messageID = val; }\r\n\tint getMessageType() const { return messageType; }\r\n\tvoid setMessageType(int val) { messageType = val; }\r\n\r\n\r\n\txNString getName() const { return name; }\r\n\tvoid setName(xNString val) { name = val; }\r\n\r\n\tTNL::BitSet32& getFlags() { return mFlags; }\r\n\tvoid setFlags(TNL::BitSet32 val) { mFlags = val; }\r\n\r\n\tint getSendCount() { return mSendCount; }\r\n\tvoid setSendCount(int val) { mSendCount = val; }\r\n\r\n\t~xMessage();\r\n\r\n\txDistributedPropertyArrayType mParameters;\r\n\txDistributedPropertyArrayType& getParameters() { return mParameters; }\r\n\r\n\txDistributedClient * getClientSource() { return mClientSource; }\r\n\tvoid setClientSource(xDistributedClient * val) { mClientSource = val; }\r\n\tbool getIgnoreSessionMaster() const { return ignoreSessionMaster; }\r\n\tvoid setIgnoreSessionMaster(bool val) { ignoreSessionMaster = val; }\r\n\t\r\n\tint& getNumUsers() { return mNumUsers; }\r\n\tvoid setNumUsers(int val) { mNumUsers = val; }\r\n\r\nprotected : \r\n\tfloat lifeTime;\r\n\tbool complete;\r\n\tint dstUser;\r\n\tint srcUser;\r\n\tint clientSideSrcUser;\r\n\t\r\n\t\r\n\tint messageID;\r\n\tint messageType;\r\n\txNString name;\r\n\tTNL::BitSet32 mFlags;\r\n\tint mSendCount;\r\n\tint mNumUsers;\r\n\t\r\n\tbool ignoreSessionMaster;\r\n\t\r\n\txDistributedClient *mClientSource;\r\n\t\r\n\r\n\r\n};\r\n\r\n#endif//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnlTypes.h\"\n#include \"tnl.h\"\n#include \"tnlJournal.h\"\n\n#include \n#if defined (TNL_OS_XBOX)\n#include \n\n#elif defined (TNL_OS_WIN32)\n#include \n\n#include \n\n#else\n\n#include \n#include \n#include \n\n#endif\n\n#include \n#include \n#include \n#include \n#include \"tnlRandom.h\"\n#include \"tnlLog.h\"\n\nnamespace TNL {\n\n#if defined (TNL_OS_XBOX)\n\nvoid Platform::outputDebugString(const char *string)\n{\n OutputDebugString(string);\n}\n\nvoid Platform::debugBreak()\n{\n DebugBreak();\n}\n\nvoid Platform::forceQuit()\n{\n logprintf(\"-Force Quit-\");\n // Reboot!\n LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };\n XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );\n}\n\nU32 Platform::getRealMilliseconds()\n{\n U32 tickCount;\n TNL_JOURNAL_READ_BLOCK ( getRealMilliseconds,\n TNL_JOURNAL_READ( (&tickCount) );\n return tickCount;\n )\n\n tickCount = GetTickCount();\n\n TNL_JOURNAL_WRITE_BLOCK ( getRealMilliseconds,\n TNL_JOURNAL_WRITE( (tickCount) );\n )\n return tickCount;\n}\n\n\n//--------------------------------------\nvoid Platform::AlertOK(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);\n TNLLogMessageV(LogPlatform, (\"AlertOK: %s - %s\", message, windowTitle));\n return;\n}\n\n//--------------------------------------\nbool Platform::AlertOKCancel(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;\n TNLLogMessageV(LogPlatform, (\"AlertOKCancel: %s - %s\", message, windowTitle));\n return false;\n}\n\n//--------------------------------------\nbool Platform::AlertRetry(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);\n TNLLogMessageV(LogPlatform, (\"AlertRetry: %s - %s\", message, windowTitle));\n return false;\n}\n\n\nclass WinTimer\n{\n private:\n F64 mPeriod;\n bool mUsingPerfCounter;\n public:\n WinTimer()\n {\n S64 frequency;\n mUsingPerfCounter = QueryPerformanceFrequency((LARGE_INTEGER *) &frequency);\n mPeriod = 1000.0f / F64(frequency);\n }\n S64 getCurrentTime()\n {\n if(mUsingPerfCounter)\n {\n S64 value;\n QueryPerformanceCounter( (LARGE_INTEGER *) &value);\n return value;\n }\n else\n {\n return GetTickCount();\n }\n }\n F64 convertToMS(S64 delta)\n {\n if(mUsingPerfCounter)\n return mPeriod * F64(delta);\n else\n return F64(delta);\n }\n};\n\nstatic WinTimer gTimer;\n\nS64 Platform::getHighPrecisionTimerValue()\n{\n return gTimer.getCurrentTime();\n}\n\nF64 Platform::getHighPrecisionMilliseconds(S64 timerDelta)\n{\n return gTimer.convertToMS(timerDelta);\n}\n\nvoid Platform::sleep(U32 msCount)\n{\n\t// no need to sleep on the xbox...\n}\n\n#elif defined (TNL_OS_WIN32)\n\nbool Platform::checkHeap()\n{\n#ifdef TNL_COMPILER_VISUALC\n return _heapchk() == _HEAPOK;\n#else\n return true;\n#endif\n}\n\nvoid Platform::outputDebugString(const char *string)\n{\n OutputDebugString(string);\n}\n\nvoid Platform::debugBreak()\n{\n DebugBreak();\n}\n\nvoid Platform::forceQuit()\n{\n ExitProcess(1);\n}\n\nU32 Platform::getRealMilliseconds()\n{\n U32 tickCount;\n TNL_JOURNAL_READ_BLOCK ( getRealMilliseconds,\n TNL_JOURNAL_READ( (&tickCount) );\n return tickCount;\n )\n\n tickCount = GetTickCount();\n\n TNL_JOURNAL_WRITE_BLOCK ( getRealMilliseconds,\n TNL_JOURNAL_WRITE( (tickCount) );\n )\n return tickCount;\n}\n\nclass WinTimer\n{\n private:\n F64 mPeriod;\n bool mUsingPerfCounter;\n public:\n WinTimer()\n {\n S64 frequency;\n mUsingPerfCounter = QueryPerformanceFrequency((LARGE_INTEGER *) &frequency);\n mPeriod = 1000.0f / F64(frequency);\n }\n S64 getCurrentTime()\n {\n if(mUsingPerfCounter)\n {\n S64 value;\n QueryPerformanceCounter( (LARGE_INTEGER *) &value);\n return value;\n }\n else\n {\n return GetTickCount();\n }\n }\n F64 convertToMS(S64 delta)\n {\n if(mUsingPerfCounter)\n return mPeriod * F64(delta);\n else\n return F64(delta);\n }\n};\n\nstatic WinTimer gTimer;\n\nS64 Platform::getHighPrecisionTimerValue()\n{\n S64 currentTime;\n TNL_JOURNAL_READ_BLOCK ( getHighPrecisionTimerValue,\n TNL_JOURNAL_READ( (&currentTime) );\n return currentTime;\n )\n\n currentTime = gTimer.getCurrentTime();\n\n TNL_JOURNAL_WRITE_BLOCK ( getHighPrecisionTimerValue,\n TNL_JOURNAL_WRITE( (currentTime) );\n )\n\n return currentTime;\n}\n\nF64 Platform::getHighPrecisionMilliseconds(S64 timerDelta)\n{\n F64 timerValue;\n TNL_JOURNAL_READ_BLOCK ( getHighPrecisionMilliseconds,\n TNL_JOURNAL_READ( (&timerValue) );\n return timerValue;\n )\n\n timerValue = gTimer.convertToMS(timerDelta);\n\n TNL_JOURNAL_WRITE_BLOCK ( getHighPrecisionMilliseconds,\n TNL_JOURNAL_WRITE( (timerValue) );\n )\n\n return timerValue;\n}\n\nvoid Platform::sleep(U32 msCount)\n{\n Sleep(msCount);\n}\n\n//--------------------------------------\nvoid Platform::AlertOK(const char *windowTitle, const char *message)\n{\n ShowCursor(true);\n MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);\n}\n\n//--------------------------------------\nbool Platform::AlertOKCancel(const char *windowTitle, const char *message)\n{\n ShowCursor(true);\n return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;\n}\n\n//--------------------------------------\nbool Platform::AlertRetry(const char *windowTitle, const char *message)\n{\n ShowCursor(true);\n return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);\n}\n\n#else // osx and linux\n\nvoid Platform::debugBreak()\n{\n kill(getpid(), SIGTRAP);\n}\n\nvoid Platform::outputDebugString(const char *string)\n{\n //printf(\"%s\", string);\n}\n\nvoid Platform::forceQuit()\n{\n debugBreak();\n exit(1);\n}\n\n\nU32 x86UNIXGetTickCount();\n//--------------------------------------\n\nU32 Platform::getRealMilliseconds()\n{\n return x86UNIXGetTickCount();\n}\n\nstatic bool sg_initialized = false;\nstatic U32 sg_secsOffset = 0;\n\nU32 x86UNIXGetTickCount()\n{\n // TODO: What happens when crossing a day boundary?\n //\n timeval t;\n\n if (sg_initialized == false) {\n sg_initialized = true;\n\n ::gettimeofday(&t, NULL);\n sg_secsOffset = t.tv_sec;\n }\n\n ::gettimeofday(&t, NULL);\n\n U32 secs = t.tv_sec - sg_secsOffset;\n U32 uSecs = t.tv_usec;\n\n // Make granularity 1 ms\n return (secs * 1000) + (uSecs / 1000);\n}\n\nclass UnixTimer\n{\n public:\n UnixTimer()\n {\n }\n S64 getCurrentTime()\n {\n return x86UNIXGetTickCount();\n }\n F64 convertToMS(S64 delta)\n {\n return F64(delta);\n }\n};\n\nstatic UnixTimer gTimer;\n\nS64 Platform::getHighPrecisionTimerValue()\n{\n return gTimer.getCurrentTime();\n}\n\nF64 Platform::getHighPrecisionMilliseconds(S64 timerDelta)\n{\n return gTimer.convertToMS(timerDelta);\n}\n\nvoid Platform::sleep(U32 msCount)\n{\n usleep(msCount * 1000);\n}\n\n//--------------------------------------\nvoid Platform::AlertOK(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);\n TNLLogMessageV(LogPlatform, (\"AlertOK: %s - %s\", message, windowTitle));\n return;\n}\n\n//--------------------------------------\nbool Platform::AlertOKCancel(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;\n TNLLogMessageV(LogPlatform, (\"AlertOKCancel: %s - %s\", message, windowTitle));\n return false;\n}\n\n//--------------------------------------\nbool Platform::AlertRetry(const char *windowTitle, const char *message)\n{\n// ShowCursor(true);\n// return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);\n TNLLogMessageV(LogPlatform, (\"AlertRetry: %s - %s\", message, windowTitle));\n return false;\n}\n\n#endif\n\n/*\nchar *strdup(const char *src)\n{\n char *buffer = (char *) malloc(strlen(src) + 1);\n strcpy(buffer, src);\n return buffer;\n}*/\nbool atob(const char *str)\n{\n return !stricmp(str, \"true\") || atof(str);\n}\n\nS32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)\n{\n va_list args;\n va_start(args, format);\n#ifdef TNL_COMPILER_VISUALC\n S32 len = _vsnprintf(buffer, bufferSize, format, args);\n#else\n S32 len = vsnprintf(buffer, bufferSize, format, args);\n#endif\n return (len);\n}\n\n\nS32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist)\n{\n#ifdef TNL_COMPILER_VISUALC\n S32 len = _vsnprintf(buffer, bufferSize, format, (va_list) arglist);\n#else\n S32 len = vsnprintf(buffer, bufferSize, format, (char *) arglist);\n#endif\n return len;\n}\n\n};\n\n\n#if defined (__GNUC__)\n\nint stricmp(const char *str1, const char *str2)\n{\n while(toupper(*str1) == toupper(*str2) && *str1)\n {\n str1++;\n str2++;\n }\n return (toupper(*str1) > toupper(*str2)) ? 1 : ((toupper(*str1) < toupper(*str2)) ? -1 : 0);\n}\n\nint strnicmp(const char *str1, const char *str2, unsigned int len)\n{\n for(unsigned int i = 0; i < len; i++)\n {\n if(toupper(str1[i]) == toupper(str2[i]))\n continue;\n return (toupper(str1[i]) > toupper(str2[i])) ? 1 : ((toupper(str1[i]) < toupper(str2[i])) ? -1 : 0);\n }\n return 0;\n}\n\n#endif\n\n\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nusing namespace vtAgeia;\r\n\r\npJointD6::pJointD6(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_D6)\r\n{\r\n\r\n}\r\n\r\nvoid pJointD6::setDriveAngularVelocity(VxVector angVel)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return;\tjoint->saveToDesc(descr);\r\n\t//joint->setDriveAngularVelocity(pMath::getFrom(angVel));\r\n\tdescr.driveAngularVelocity = (pMath::getFrom(angVel));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointD6::setDriveLinearVelocity(VxVector linVel)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\t//joint->setDriveLinearVelocity(pMath::getFrom(linVel));\r\n\tdescr.driveLinearVelocity = (pMath::getFrom(linVel));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointD6::setDriveRotation(VxQuaternion rot)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tjoint->setDriveOrientation(pMath::getFrom(rot));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointD6::setDrivePosition(VxVector pos)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tjoint->setDrivePosition(pMath::getFrom(pos));\r\n\tdescr.drivePosition = (pMath::getFrom(pos));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getSlerpDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.slerpDrive.damping,descr.slerpDrive.spring,descr.slerpDrive.forceLimit,descr.slerpDrive.driveType.bitField);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setSlerpDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\tsdrive.driveType=drive.driveType;\tdescr.slerpDrive = sdrive;\r\n\tdescr.flags |=NX_D6JOINT_SLERP_DRIVE;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getTwistDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.twistDrive.damping,descr.twistDrive.spring,descr.twistDrive.forceLimit,descr.twistDrive.driveType);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setTwistDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\t\tsdrive.driveType=drive.driveType;\tdescr.twistDrive = sdrive;\r\n\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getSwingDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.swingDrive.damping,descr.swingDrive.spring,descr.swingDrive.forceLimit,descr.swingDrive.driveType);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setSwingDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\t\tsdrive.driveType=drive.driveType;\tdescr.swingDrive = sdrive;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getZDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.zDrive.damping,descr.zDrive.spring,descr.zDrive.forceLimit,descr.zDrive.driveType);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setZDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\t\tsdrive.driveType=drive.driveType;\tdescr.zDrive = sdrive;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getYDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.yDrive.damping,descr.yDrive.spring,descr.yDrive.forceLimit,descr.yDrive.driveType);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setYDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\t\tsdrive.driveType=drive.driveType;\tdescr.yDrive = sdrive;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6Drive pJointD6::getXDrive()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6Drive result(descr.xDrive.damping,descr.xDrive.spring,descr.xDrive.forceLimit,descr.xDrive.driveType);\r\n\treturn result;\r\n}\r\n\r\n\r\nint pJointD6::setXDrive(pJD6Drive drive)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return -1 ;\tjoint->saveToDesc(descr);\r\n\tNxJointDriveDesc sdrive;\t\tsdrive.damping = drive.damping;\t\tsdrive.spring = drive.spring;\t\tsdrive.forceLimit = drive.forceLimit;\t\tsdrive.driveType=drive.driveType;\tdescr.xDrive = sdrive;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\npJD6SoftLimit pJointD6::getTwistLowLimit()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6SoftLimit result(descr.twistLimit.low.damping,descr.twistLimit.low.spring,descr.twistLimit.low.value,descr.twistLimit.low.restitution);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setTwistLowLimit(pJD6SoftLimit limit)\r\n{\r\n\tNxD6JointDesc descr;\t\r\n\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return -1 ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitSoftDesc sLimit;\tsLimit.value = limit.value;\tsLimit.spring = limit.spring;\tsLimit.damping = limit.damping;\tsLimit.restitution = limit.restitution;\r\n\tif (!sLimit.isValid())return -1;\r\n\tdescr.twistLimit.low= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\npJD6SoftLimit pJointD6::getTwistHighLimit()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6SoftLimit result(descr.twistLimit.high.damping,descr.twistLimit.high.spring,descr.twistLimit.high.value,descr.twistLimit.high.restitution);\r\n\treturn result;\r\n}\r\n\r\n\r\nint pJointD6::setTwistHighLimit(pJD6SoftLimit limit)\r\n{\r\n\tNxD6JointDesc descr;\t\r\n\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return -1 ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitSoftDesc sLimit;\tsLimit.value = limit.value;\tsLimit.spring = limit.spring;\tsLimit.damping = limit.damping;\tsLimit.restitution = limit.restitution;\r\n\tif (!sLimit.isValid())return -1;\r\n\tdescr.twistLimit.high= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\npJD6SoftLimit pJointD6::getSwing2Limit()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6SoftLimit result(descr.swing2Limit.damping,descr.swing2Limit.spring,descr.swing2Limit.value,descr.swing2Limit.restitution);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setSwing2Limit(pJD6SoftLimit limit)\r\n{\r\n\tNxD6JointDesc descr;\t\r\n\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return -1 ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitSoftDesc sLimit;\tsLimit.value = limit.value;\tsLimit.spring = limit.spring;\tsLimit.damping = limit.damping;\tsLimit.restitution = limit.restitution;\r\n\tif (!sLimit.isValid())return -1;\r\n\tdescr.swing2Limit= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\npJD6SoftLimit pJointD6::getSwing1Limit()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6SoftLimit result(descr.swing1Limit.damping,descr.swing1Limit.spring,descr.swing1Limit.value,descr.swing1Limit.restitution);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setSwing1Limit(pJD6SoftLimit limit)\r\n{\r\n\tNxD6JointDesc descr;\t\r\n\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return -1 ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitSoftDesc sLimit;\tsLimit.value = limit.value;\tsLimit.spring = limit.spring;\tsLimit.damping = limit.damping;\tsLimit.restitution = limit.restitution;\r\n\tif (!sLimit.isValid())return -1;\r\n\tdescr.swing1Limit= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\npJD6SoftLimit pJointD6::getLinearLimit()\r\n{\r\n\tNxD6JointDesc descr;NxD6Joint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tpJD6SoftLimit result(descr.linearLimit.damping,descr.linearLimit.spring,descr.linearLimit.value,descr.linearLimit.restitution);\r\n\treturn result;\r\n}\r\n\r\nint pJointD6::setLinearLimit(pJD6SoftLimit limit)\r\n{\r\n\tNxD6JointDesc descr;\t\r\n\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return -1 ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxJointLimitSoftDesc sLimit;\tsLimit.value = limit.value;\tsLimit.spring = limit.spring;\tsLimit.damping = limit.damping;\tsLimit.restitution = limit.restitution;\r\n\tif (!sLimit.isValid())return -1;\r\n\tdescr.linearLimit = sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointD6::setTwistMotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.twistMotion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nvoid pJointD6::setSwing1MotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.swing1Motion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nvoid pJointD6::setSwing2MotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.swing2Motion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nvoid pJointD6::setXMotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.xMotion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nvoid pJointD6::setYMotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.yMotion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nvoid pJointD6::setZMotionMode(D6MotionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());if (!joint)return;joint->saveToDesc(descr);\r\n\tdescr.zMotion = (NxD6JointMotion)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nD6MotionMode pJointD6::getTwist()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.twistMotion;\r\n}\r\nD6MotionMode pJointD6::getSwing1()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.swing1Motion;\r\n}\r\nD6MotionMode pJointD6::getSwing2()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.swing2Motion;\r\n}\r\nD6MotionMode pJointD6::getXMotion()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.xMotion;\r\n}\r\nD6MotionMode pJointD6::getYMotion()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.yMotion;\r\n}\r\nD6MotionMode pJointD6::getZMotion()\r\n{\r\n\tNxD6JointDesc descr;\tNxD6Joint *joint = static_cast(getJoint());\r\n\tif (!joint)return D6MM_Locked;\r\n\tjoint->saveToDesc(descr);\r\n\treturn (D6MotionMode)descr.zMotion;\r\n}\r\n\r\n\r\nvoid pJointD6::setGlobalAnchor(VxVector anchor)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tjoint->setGlobalAnchor(pMath::getFrom(anchor));\r\n}\r\nvoid pJointD6::setGlobalAxis(VxVector axis)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tjoint->setGlobalAxis(pMath::getFrom(axis));\r\n\t//joint->setGlobalA(pMath::getFrom(anchor));\r\n}\r\nvoid pJointD6::setRatio(float ratio)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (ratio!=0.0f)\r\n\t{\r\n\t\tdescr.jointFlags|=NX_D6JOINT_GEAR_ENABLED;\r\n\t\tdescr.gearRatio = ratio;\r\n\t}else\r\n\t{\r\n\t\tdescr.jointFlags&=~NX_D6JOINT_GEAR_ENABLED;\r\n\t}\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointD6::enableCollision( bool value )\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (value)\r\n\t{\r\n\t\tdescr.jointFlags|=NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t{\r\n\t\tdescr.jointFlags&=~NX_JF_COLLISION_ENABLED;\r\n\t}\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointD6::setProjectionMode(ProjectionMode mode)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionMode = (NxJointProjectionMode)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointD6::setProjectionDistance(float distance)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionDistance= distance;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointD6::setProjectionAngle(float angle)\r\n{\r\n\tNxD6JointDesc descr;\t\tNxD6Joint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionAngle= angle;\r\n\tjoint->loadFromDesc(descr);\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n\r\n#include \"pDifferential.h\"\r\n\r\n#include \"pVehicleAll.h\"\r\n\r\n//+\t\tvelWheelCC\t{x=66.735077 y=0.097698294 z=-215.35669 ...}\tVxVector\r\n//+\t\tvelWheelTC\t{x=66.735077 y=0.097698294 z=-215.35669 ...}\tVxVector\r\n\r\n\r\nenum StateFlags\r\n{\r\n\tON_SURFACE=1, // Wheel is touching surface?\r\n\tATTACHED=2, // Attached to suspension?\r\n\tLOW_SPEED=4 // Wheel is turning slow\r\n};\r\n\r\n\r\n#define FRICTION_COEFF 100.0f\r\n#define MASS 12\r\n#define TIRE_RATE 50000.0f\r\n#define WHEEL_PENETRATION_DEPTH -0.0258f\r\n#define WHEEL_SUSPENSION_FORCE VxVector(0,-1025.0f,0)\r\n#define RR_EPSILON_VELOCITY\t0.001\t\t// Wheel velocity\r\n#define OPT_SLIPVECTOR_USES_TANSA\r\n\r\n\r\n\r\n// Use full 3D patch for surface detection?\r\n#define USE_3D_PATCH\r\n\r\n#define ENV_INI \"env.ini\"\r\n\r\n// For method #3, slipVector (Gregor Veble), use tan(SA) or SA?\r\n#define OPT_SLIPVECTOR_USES_TANSA\r\n\r\n// Skid methods\r\n//#define SKID_METHOD_SEPARATE_LON_LAT\r\n//#define SKID_METHOD_SLIP_RA_VECTOR\r\n#define SKID_METHOD_Z_GREGOR\r\n\r\n// Point at which skidmarks appear\r\n#define SKIDMARK_SLIPRATIO 0.2\r\n\r\n// Apply damping to slipRatio/slipAngle differential eq's at low speed?\r\n//#define DO_DAMPING_LAT\r\n//#define DO_DAMPING_LONG\r\n\r\n\r\n// Apply low-speed enhancements? (obsolete since 18-5-01)\r\n#define DO_LOW_SPEED\r\n\r\n// Distance (in m) to start with wheel ray-track intersection; this is\r\n// the height at which the ray is started to avoid getting a ray\r\n// that starts BENEATH the track surface and therefore not hitting it.\r\n#define DIST_INTERSECT 1.0\r\n\r\n// Define the next symbol to check for wheel velocity reversal (vertically),\r\n// and if so, the wheel is stopped momentarily. Is used to rule out\r\n// incredibly high damper forces from pushing the wheel to full up or down.\r\n// Should perhaps not be needed anymore combined with the implicit integrator.\r\n// Note that this acts at the outermost positions of the wheel.\r\n//#define DAMP_VERTICAL_VELOCITY_REVERSAL\r\n\r\n// Damp the wheel when crossing the equilibrium position?\r\n// As the wheel passes its center position, the spring force reverses. To\r\n// avoid adding energy into the system, when passing this position, damping\r\n// is used to avoid overaccelerating the tire to the other side.\r\n// Note that this acts when the wheel is near its center (rest) position,\r\n// contrast this with DAMP_VERTICAL_VELOCITY_REVERSAL.\r\n#define DAMP_VERTICAL_EQUILIBRIUM_REVERSAL\r\n\r\n// Use implicit integration? This should be more stable with\r\n// high damper rates.\r\n#define INTEGRATE_IMPLICIT_VERTICAL\r\n\r\n// Gregor Veble combined slip algorithm? (instead of Pacejka)\r\n//#define DO_GREGOR\r\n#ifdef DO_GREGOR\r\n\t#undef DO_DAMPING_LAT\r\n\t#undef DO_DAMPING_LONG\r\n#endif\r\n\r\n// Delayed slip angle?\r\n//#define USE_SAE950311_LAT\r\n\r\n// If not using SAE950311, damp SA at low speed? (to avoid jittering)\r\n#define USE_SA_DAMPING_AT_LOW_SPEED\r\n\r\n// Wheel locking results in force going the direction of -slipVector?\r\n#define USE_WHEEL_LOCK_ADJUST\r\n\r\n#define USE_NXWHEEL_CONTACT_DATA\r\n\r\n#define USE_NXWHEEL_NORMALFORCE_LOAD\r\n\r\n\r\n\r\n\r\nstatic int getFrictionMethod(){ return FC_SLIPVECTOR; }\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid pWheel2::CalcPacejka()\r\n{\r\n\r\n\tfloat normalForce;\r\n\t\r\n\r\n\tif (hadContact)\r\n\t{\r\n\t\tnormalForce=forceRoadTC.y;\r\n\t}else{\r\n\t\tnormalForce = 0.0f;\r\n\t}\r\n\t\r\n/*\r\n\tif (hadContact)\r\n\t{\r\n\tnormalForce=500.0f;\r\n\t}else{\r\n\t\tnormalForce = 0.0f;\r\n\t}\r\n*/\t\r\n\r\n\t\r\n\tpacejka.SetCamber(0);\r\n\r\n\tbool FC_SLIPVECTOR =true;\r\n\t// Note our positive slipAngle is the reverse of SAE's definition\r\n\tif(FC_SLIPVECTOR)\r\n\t{\r\n\t\t// 's and also 's idea of mixing Pacejka\r\n\t\t// Note that Gregor's Veble 'z' is 'csSlipLen' here.\r\n\t\t// The load isn't touched\r\n\t\tpacejka.SetNormalForce(normalForce);\r\n\t\t// Lateral\r\n\t\t//qdbg(\" csSlipLen=%f, oSA=%f,oSR=%f\\n\",csSlipLen,optimalSA,optimalSR);\r\n\t\tif(csSlipLenfrictionFactor!=1.0f)\r\n\t\t{\r\n\t\r\n\t\t\tfloat frictionFactor = 0.1f;\r\n\t\t\tpacejka.SetFx(pacejka.GetFx()*frictionFactor);\r\n\t\t\tpacejka.SetFy(pacejka.GetFy()*frictionFactor);\r\n\t\t\t// Do the same to the aligning moment, although not scientifically\r\n\t\t\t// based (does aligning torque scale linearly with surface friction?)\r\n\t\t\tpacejka.SetMz(pacejka.GetMz()*frictionFactor);\r\n\t\t\tpacejka.SetMaxLongForce(pacejka.GetMaxLongForce()*frictionFactor);\r\n\t\t\tpacejka.SetMaxLatForce(pacejka.GetMaxLatForce()*frictionFactor);\r\n\t\t}\r\n*/\r\n\t\r\n\t//forceRoadTC.z=pacejka.GetFx();\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// old\r\n\t//\r\n\t\r\n\t/*\r\n\tfloat factor = getVehicle()->getEngine()->getForceFeedbackScale();\r\n\tfloat longitudalImpulse = xCheckFloat(lastContactData->longitudalImpulse);\r\n\tif (lastContactData)\r\n\t{\r\n\t\tforceRoadTC.z= longitudalImpulse * factor;\r\n\t}*/\r\n\r\n\t// Put some results in appropriate variables\r\n\t#ifdef LTRACE\r\n\t\tqdbg(\" pacejka.Fx=%f\\n\",pacejka.GetFx());\r\n\t#endif\r\n\t\r\n\tfloat fx = pacejka.GetFx();;\r\n\tforceRoadTC.z=pacejka.GetFx();\r\n\t\r\n}\r\n\r\n\r\n\r\n\r\nvoid ConvertTireToCarOrientation(pWheel2 * wheel , VxVector *from,VxVector *to)\r\n// Convert vector 'from' from tire coordinates\r\n// to car coordinates (into 'to')\r\n// Assumes: from!=to\r\n{\r\n\tif (!wheel)\r\n\t\treturn;\t\r\n\t\r\n\tfloat angle,sinAngle,cosAngle;\r\n\r\n\t// Note that the tire is constrained in 5 dimensions, so only\r\n\t// 1 rotation needs to be done\r\n\r\n\t// Heading\r\n\tangle=wheel->GetHeading();\r\n\tsinAngle=sin(angle);\r\n\tcosAngle=cos(angle);\r\n\r\n\t// Rotate around Y axis to get heading of car right\r\n\tto->x=from->z*sinAngle+from->x*cosAngle;\r\n\tto->y=from->y;\r\n\tto->z=from->z*cosAngle-from->x*sinAngle;\r\n}\r\n\r\nvoid ConvertCarToTireOrientation (pWheel2*wheel, VxVector *from,VxVector*to)\r\n// Convert vector 'from' from car coordinates\r\n// to tire coordinates (into 'to')\r\n// Assumes: from!=to\r\n{\r\n\tif (!wheel)\r\n\t\treturn;\t\r\n\r\n\tfloat angle,sinAngle,cosAngle;\r\n\r\n\t// Heading\r\n\tangle=-wheel->GetHeading();\r\n\r\n\tif(fabs(angle)x=from->z*sinAngle+from->x*cosAngle;\r\n\tto->y=from->y;\r\n\tto->z=from->z*cosAngle-from->x*sinAngle;\r\n\t//to->DbgPrint(\"C2T to\");\r\n}\r\n\r\n\r\nvoid pWheel2::calcVerticalForces()\r\n{\r\n\tVxVector downGravity;\r\n\t//float mass = getVehicle()->getBody()->getMass();\r\n\t\r\n\tNxVec3 grav;\r\n\tgetVehicle()->getBody()->getActor()->getScene().getGravity(grav);\r\n\t\r\n\r\n\tdownGravity.y = -mass * -grav.y ;\r\n\tif (getEntity())\r\n\t{\r\n\t\tgetEntity()->TransformVector(&forceGravityCC,&downGravity);\r\n\t}\r\n\t\r\n\tforceVerticalCC=forceGravityCC+forceRoadTC+WHEEL_SUSPENSION_FORCE;\r\n\t\r\n\tfloat inverseWheelMass = mWheelShape->getInverseWheelMass();\r\n\r\n\r\n}\r\nvoid pWheel2::calcLongForces()\r\n{\r\n\tif (lastContactData)\r\n\t{\r\n\r\n\t\t//\r\n\t\t// LONGITUDINAL FORCES\r\n\t\t//\r\n\r\n\t\t// Differential will do resulting long. torques for the engine\r\n\r\n\t\t// Calculate longitudinal road reaction force using Pacejka's magic formula\r\n\t\tfloat pf;\r\n\r\n\t\t// Pacejka\r\n\t\tfloat factor = getVehicle()->getEngine()->getForceFeedbackScale();\r\n\t\tfloat longitudalImpulse = xCheckFloat(lastContactData->longitudalImpulse);\r\n\r\n\t\t//qdbg(\"Pacejka Fx=%f, signU=%f\\n\",pf,signU);\r\n\t\tforceRoadTC.z= factor * longitudalImpulse * signU ;\r\n\t}\r\n\t\t\r\n\t\r\n\r\n\r\n\t\r\n}\r\n\r\nvoid pWheel2::calcBreakForces()\r\n{\r\n\r\n\r\n}\r\n\r\n\r\nvoid pWheel2::preAnimate()\r\n{\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// store last contact\r\n\t//\r\n\thadContact = getContact(*lastContactData);\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// reset\r\n\t//\r\n\tforceRoadTC.Set(0,0,0);\r\n\ttorqueTC.Set(0,0,0);\r\n\ttorqueFeedbackTC.Set(0,0,0);\r\n\tdampingFactorLong=dampingFactorLat=0;\r\n\tforceVerticalCC.Set(0,0,0);\r\n\tforceDampingTC.Set(0,0,0);\r\n\ttorqueTC.Set(0,0,0);\r\n\ttorqueFeedbackTC.Set(0,0,0);\r\n\tvelWheelTC.Set(0,0,0);\r\n\tvelWheelCC.Set(0,0,0);\r\n\r\n\r\n\r\n\r\n\r\n\t//signU = ( getVehicle()->_currentStatus & VS_IsRollingForward ) ? 1.0f : - 1.0f;\r\n\r\n\tCalcLoad();\r\n\tCalcSlipAngle();\r\n\tCalcSlipRatio(&velWheelTC);\r\n\t\r\n\t\r\n\tfloat tanOptimalSA=tan(0.18296f);\r\n\tfloat optimalSR=0.0965f;\r\n\tbool make =true;\r\n\t\r\n\tif(getFrictionMethod() == FC_SLIPVECTOR)\r\n\t{\r\n\t\t// Calculate SA/SR vector length (>1 = wanting more than tire supports)\r\n\r\n\t\tfloat lat,lon;\r\n\t\tif (getVehicle()->getProcessOptions() & pVPO_SV_Tansa )\r\n\t\t\tlat=tanSlipAngle/tanOptimalSA;\r\n\t\telse\r\n\t\t\tlat=slipAngle/optimalSA;\r\n\r\n\r\n\t\tlon=slipRatio/optimalSR;\r\n\t\tcsSlipLen=sqrtf(lat*lat+lon*lon);\r\n\t\t\r\n\t\t//qdbg(\" latNrm=%f, lonNrm=%f, csSlipLen=%f\\n\",lat,lon,csSlipLen);\r\n\t}\r\n\t\r\n\r\n\r\n\tCalcSlipVelocity();\r\n\r\n\t// Low speed detection\r\n\r\n\r\n\tif (getVehicle()->getProcessOptions() & pVPO_CheckLowSpeed)\r\n\t{\r\n\t\tfloat lowSpeed = 0.03f;\r\n\t\tif(rotationV.x>-lowSpeed&&rotationV.xGetValue(coeff);\r\n\telse*/\r\n\t\tthis->frictionCoeff=1.0f;\r\n\r\n\r\n\t\r\n}\r\nvoid pWheel2::CalcLoad()\r\n{\r\n\tif (hadContact)\r\n\t{\r\n\t\t//forceRoadTC.y=-50*0.057598811f;//\tfloat; lastContactData->contactForce;\r\n\r\n\t\tif (\t(getVehicle()->getProcessOptions() & pVPO_Wheel_UsePHYSX_Load) &&\r\n\t\t\t\t(getVehicle()->getProcessOptions() & pVPO_Wheel_UsePHYSX_CONTACT_DATA)\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tforceRoadTC.y = load;\r\n\t\t}\r\n\t\telse{\r\n\r\n\t\t\tforceRoadTC.y=-tireRate * WHEEL_PENETRATION_DEPTH;//\tfloat; lastContactData->contactForce;\r\n\t\t}\r\n\r\n\t\tstateFlags|=ON_SURFACE;\r\n\t}else\r\n\t{\r\n\t\tstateFlags&=~ON_SURFACE;\r\n\t\tforceRoadTC.y = 0.0f;\r\n\t}\r\n\r\n\t//load=forceRoadTC.y;\r\n\r\n\tradiusLoaded=getWheelShape()->getRadius();\r\n}\r\nvoid pWheel2::calcForces()\r\n{\r\n\r\n\tif (hadContact)\r\n\t{\r\n\r\n\t\t \r\n\t\tfloat len;\r\n\r\n\r\n\t\tfloat pf=0.0f;\r\n\t\tfloat radiusLoaded = getRadius();\r\n\t\t\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// vertical forces\r\n\t\t//\r\n\t\t\r\n\t\tNxVec3 grav;getBody()->getActor()->getScene().getGravity(grav);\r\n\t\t\r\n\t\tVxVector forceGravityWC;\r\n\t\tforceGravityWC.y = getMass() * grav.y;\r\n\r\n\t\tif (getEntity())\r\n\t\t\tgetEntity()->TransformVector(&forceGravityCC,&forceGravityWC);\r\n\r\n\t\tVxVector suspension;\r\n\t\tsuspension.y = -load;\r\n\t\tforceVerticalCC=forceGravityCC+forceRoadTC+suspension;\r\n\r\n\t\t\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// long forces\r\n\t\t//\r\n\t\t\r\n\t\t//\r\n\t\t// LONGITUDINAL FORCES\r\n\t\t//\r\n\r\n\t\t// Differential will do resulting long. torques for the engine\r\n\r\n\t\t// Calculate longitudinal road reaction force using Pacejka's magic formula\r\n\t\t// Pacejka\r\n\t\t//float factor = getVehicle()->getEngine()->getForceFeedbackScale();\r\n\t\t//float longitudalImpulse = xCheckFloat(lastContactData->longitudalImpulse);\r\n\t\t//qdbg(\"Pacejka Fx=%f, signU=%f\\n\",pf,signU);\r\n\t\t//forceRoadTC.z= factor * longitudalImpulse * signU ;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// \r\n\t\t//\r\n\t\t\r\n\r\n\t\t#ifdef DO_GREGOR\r\n\t\t\t\tpf=Fx;\r\n\t\t#else\r\n\t\t\t\t// Pacejka\r\n\t\t\t\tpf=pacejka.GetFx()*this->frictionCoeff;\r\n\t\t#endif\r\n\r\n\t\t//qdbg(\"Pacejka Fx=%f, signU=%f\\n\",pf,signU);\r\n\t\tforceRoadTC.z=signU*pf;\r\n\t\t\r\n\r\n\t\tif ( getVehicle()->getProcessOptions() & pVPO_Lat_Damping )\r\n\t\t{\r\n\t\t\t\t// Add damping force because of slipRatio vibrations\r\n\t\t\t\t// at low speed (SAE950311)\r\n\t\t\t\tforceRoadTC.z+=forceDampingTC.z;\r\n\t\t\t\t//qdbg(\"FroadTC.z=%f, Fdamp=%f\\n\",forceRoadTC.z,forceDampingTC.z);\r\n\t\t}\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t//\tCalculate braking forces & torques (brakes & rolling resistance)\r\n\t\t//\r\n\t\tfloat curBrakingTorque;\r\n\t\t// Calculate braking torque more directly\r\n\r\n\t\tfloat bTorqueV = getVehicle()->calculateBraking( getVehicle()->_lastDT );\r\n\r\n\t\tcurBrakingTorque= bTorqueV * maxBrakingTorque/1000.0f;\r\n\t\tcurBrakingTorque*=brakingFactor;\r\n\t\t// Apply braking torque in the reverse direction of the wheel's rotation\r\n\t\tif(rotationV.x>0)\r\n\t\t{ \r\n\t\t\ttorqueBrakingTC.x=curBrakingTorque;\r\n\t\t} \r\n\t\telse\r\n\t\t{ \r\n\t\t\ttorqueBrakingTC.x=-curBrakingTorque;\r\n\t\t}\r\n\t\tforceBrakingTC.z=torqueBrakingTC.x/radiusLoaded;\r\n\r\n\t\t// Calculate feedback torque (goes back to differential)\r\n\t\t// This doesn't include braking and rolling resistance, which are\r\n\t\t// potential braking forces (which may not be fully used if the\r\n\t\t// wheel is not rotating), but only the forces which are always\r\n\t\t// there, like road reaction.\r\n\t\ttorqueFeedbackTC.x=-forceRoadTC.z*radiusLoaded;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// \r\n\t\t//\r\n\t\t// Calculate rolling resistance (from , Fr=u*Fv\r\n\t\t// where Fv is the normal force, and 'u' the rolling coefficient)\r\n\t\t// Rolling coefficient may need to go up with speed though\r\n\t\t//forceRoadTC.y = pf;\r\n\r\n\r\n\t\tif(rotationV.x>0)\r\n\t\t\ttorqueRollingTC.x=-rollingCoeff*forceRoadTC.y*radiusLoaded;\r\n\t\telse\r\n\t\t\ttorqueRollingTC.x=rollingCoeff*forceRoadTC.y*radiusLoaded;\r\n\r\n\t\t// Calculate total braking torque (this is POTENTIAL, not always acted upon!)\r\n\t\ttorqueBrakingTC.x=-forceBrakingTC.z*radiusLoaded;\r\n\t\ttorqueBrakingTC.x+=torqueRollingTC.x;\r\n\r\n\t\t//\r\n\t\t// lateral forces :\r\n\t\t//\r\n\t\t/*float lateralForce = xCheckFloat(lastContactData->lateralImpulse);\r\n\t\tfactor = getVehicle()->getEngine()->getForceFeedbackScale();\r\n\t\tforceRoadTC.x= signU*lateralForce * factor ;\r\n\t\t*/\r\n\r\n\t\t#ifdef DO_GREGOR\r\n\t\t\t\tpf=Fy;\r\n\t\t#else\r\n\t\t\t\tpf=pacejka.GetFy()*frictionCoeff;\r\n\t\t#endif\r\n\t\t\t\t//pf=forceRoadTC.x;\r\n\t\t\r\n\t\t#ifdef OBS\r\n\t\t\t\tqdbg(\"Pacejka Fy(lat)=%f, SR=%f, SA=%f, load=%f\\n\",pf,slipRatio,slipAngle,load);\r\n\t\t#endif\r\n\t\t\t\t\r\n\t\tforceRoadTC.x=pf;\r\n\r\n\t\t\r\n\t\tif(getProcessOptions() & pVPO_Forces_No_Lateral)\r\n\t\t{\r\n\t\t\t// Cancel lateral forces\r\n\t\t\tpacejka.SetFy(0);\r\n\t\t\tforceRoadTC.x=0;\r\n\t\t}\r\n\r\n\t\tif (getProcessOptions() & pVPO_Lat_Damping )\r\n\t\t{\r\n\t\t\r\n\t\t\t\t// Add damping force because of slipAngle vibrations\r\n\t\t\t\t// at low speed (SAE950311)\r\n\t\t\t\t// Note the mix of 2 coordinate systems here\r\n\t\t\t\tforceRoadTC.x+=forceDampingTC.x;\r\n\t\t\t\t//qdbg(\"Damping fRoad.x=%f, Fdamp=%f\\n\",forceRoadTC.x,forceDampingTC.x);\r\n\t\t}\r\n\t\t\r\n\t\t// WHEEL LOCKING\r\n\r\n\t\tif(getVehicle()->getProcessOptions() & pVPO_Wheel_LockAdjust )\r\n\t\t\tgoto skip_wla;\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tif(slipRatio<0)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tVxVector forceLockedCC,forceLockedTC;\r\n\t\t\tfloat slideFactor,oneMinusSlideFactor,lenSlip,lenNormal,y;\r\n\r\n\t\t\t// As the wheel is braked, more and more sliding kicks in.\r\n\t\t\t// At the moment of 100% slide, the braking force points\r\n\t\t\t// in the reverse direction of the slip velocity. Inbetween\r\n\t\t\t// SR=0 and SR=-1 (and beyond), there is more and more sliding,\r\n\t\t\t// so the force begins to point more and more like the slip vel.\r\n\r\n\t\t\t\r\n\t\t\t// Calculate sliding factor (0..1)\r\n\t\t\tif(slipRatio<-1.0f)\r\n\t\t\t\tslideFactor=1.0f;\r\n\t\t\telse \r\n\t\t\t\tslideFactor=-slipRatio;\r\n\r\n\t\t\t//slideFactor*=.75f;\r\n\t\t\toneMinusSlideFactor=1.0f-slideFactor;\r\n\t\t\t// Calculate 100% wheel lock direction\r\n\t\t\tforceLockedCC.x=slipVectorCC.x;\r\n\t\t\tforceLockedCC.y=0;\r\n\t\t\tforceLockedCC.z=slipVectorCC.z;\r\n\t\t\t// Make it match forceRoadTC's coordinate system\r\n\t\t\t\r\n\t\t\tConvertCarToTireOrientation(this,&forceLockedCC,&forceLockedTC);\r\n\r\n\r\n\t\t\t// Calc magnitude of normal and locked forces\r\n\t\t\tlenSlip=forceLockedTC.Magnitude();\r\n\r\n\t\t\ty=forceRoadTC.y; forceRoadTC.y=0;\r\n\t\t\tlenNormal=forceRoadTC.Magnitude();\r\n\t\t\tforceRoadTC.y=y;\r\n\t\t\tif(lenSlipgetGearBox()->GetTorqueForWheel(this);\r\n\r\n\t//\r\n\t// ROTATIONAL acceleration\r\n\t//\r\n\toldVX=rotationV.x;\r\n\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\t//\r\n\t// ROTATIONAL acceleration\r\n\t//\r\n\t//#define OBS\r\n\t#ifdef OBS\r\n\t\t// Check for locked wheel braking\r\n\t\t//float netForce= getVehicle()->getEngine()->forEngin .z+forceRoadTC.z;\r\n\t\t//qdbg(\"Fe=%f, Fr=%f, Fb=%f\\n\",forceEngineTC.z,forceRoadTC.z,forceBrakingTC.z);\r\n\t\tif(rotationV.x>-RR_EPSILON_VELOCITY&&rotationV.x-netForce)||\r\n\t\t\t\t(netForce>0&&forceBrakingTC.z<-netForce))\r\n\t\t\t\t//if(forceBrakingTC.z<-netForce||forceBrakingTC.z>netForce)\r\n\t\t\t{\r\n\t\t\t\t//qdbg(\"RWh:Int; braking force keeps wheel still\\n\");\r\n\t\t\t\trotationV.x=0;\r\n\t\t\t\tgoto skip_rot;\r\n\t\t\t}\r\n\t\t}\r\n\t#endif\r\n\r\n\t\r\n\t\t\r\n\r\n\tfloat timeStep= lastStepTimeSec;\r\n\r\n\r\n\t\r\n\tfloat a = rotationA.x*timeStep ;\r\n\trotationV.x+=rotationA.x*timeStep;\r\n\t//skip_rot:\r\n\r\n\t// Check for wheel velocity reversal; in this case, damp the\r\n\t// velocity to a minimum to get rid of jittering wheels at low\r\n\t// speed and/or high braking.\r\n\tif(differential)\r\n\t{\r\n\t\tif(oldVX>0&&rotationV.x<0)\r\n\t\t{\r\n\t\t\t// Lock the side\r\n\t\t\t//qdbg(\"RWh%d; vel reversal, lock\\n\",wheelIndex);\r\n\t\t\tdifferential->Lock(differentialSide);\r\n\t\t\trotationV.x=0;\r\n\t\t\tdifferentialSlipRatio=0;\r\n\t\t} else if(oldVX<0&&rotationV.x>0)\r\n\t\t{\r\n\t\t\t//qdbg(\"RWh%d; vel reversal, lock\\n\",wheelIndex);\r\n\t\t\t// Lock the side\r\n\t\t\tdifferential->Lock(differentialSide);\r\n\t\t\trotationV.x=0;\r\n\t\t\tdifferentialSlipRatio=0;\r\n\t\t}\r\n\t} else\r\n\t{\r\n\t\t// No differential, use controlled jittering\r\n\t\tif(oldVX>=0&&rotationV.x<0)\r\n\t\t{\r\n\t\t\t// Just lift the rotation over the 0 barrier; this will induce\r\n\t\t\t// jittering near 0, but it's so small that it's unnoticeable.\r\n\t\t\t// If we keep it at 0, you get larger jitters either way (+/-)\r\n\t\t\t// until the wheel rotates again and starts the reversal again.\r\n\t\t\trotationV.x=-0.0001;\r\n\t\t} else if(oldVX<=0&&rotationV.x>0)\r\n\t\t{\r\n\t\t\trotationV.x=0.0001;\r\n\t\t}\r\n\t}\r\n\t//qdbg(\" rotV after velocity reversal=%f\\n\",rotationV.x);\r\n\r\n\t// Wheel rotation (spinning)\r\n\t//\r\n\r\n\tfloat rotVx =rotation.x;\r\n\trotation.x+=rotationV.x*timeStep;\r\n\t//rotation.x+=(rotationV.x+0.5f*rotationA.x*timeStep)*timeStep;\r\n\t//rotation.x+=rotationV.x*timeStep;\r\n\t// Keep rotation in limits\r\n\twhile(rotation.x>=2*PI)\r\n\t\trotation.x-=2*PI;\r\n\twhile(rotation.x<0)\r\n\t\trotation.x+=2*PI;\r\n\r\n\t// Friction reversal measures\r\n\tif( (oldVX<0&&rotationV.x>0) || (oldVX>0&&rotationV.x<0) )\r\n\t{ \r\n\t\trotationV.x=0;\r\n\t\r\n\t\t//qdbg(\"RWh:Int; friction reversal halt; %f -> %f\\n\",oldVX,rotationV.x);\r\n\t}\r\n}\r\n\r\nvoid pWheel2::CalcWheelAngAcc()\r\n{\r\n\tif(differential)\r\n\t{\r\n\t\t// Use differential to determine acceleration\r\n\t\tif(differential->IsLocked(differentialSide))\r\n\t\t{\r\n\t\t\t// Wheel is held still by braking torques\r\n\t\t\trotationA.x=0;\r\n\t\t} else\r\n\t\t{\r\n\t\t\t// Wheel is allowed to roll\r\n\t\t\trotationA.x=differential->GetAccOut(differentialSide);\r\n\t\t}\r\n\t\t//qdbg(\"diff=%p, diffSide=%d\\n\",differential,differentialSide);\r\n\t} else\r\n\t{\r\n\t\t// Uses torque directly (no engine/differential forces)\r\n\t\trotationA.x=(torqueFeedbackTC.x+torqueBrakingTC.x)/GetInertia();\r\n\t}\r\n}\r\n\r\nvoid pWheel2::CalcAccelerations()\r\n{\r\n\r\n\trotationA.Set(0,0,0);\r\n\r\n\tCalcWheelAngAcc();\r\n\t//CalcBodyForce();\r\n\r\n\t// Vertical forces; suspension, gravity, ground, tire rate\r\n\t//acceleration=forceVerticalCC/GetMass();\r\n\tacceleration.x=acceleration.z=0.0f;\r\n\tacceleration.y=forceVerticalCC.y/mass;\r\n\r\n\r\n\r\n#ifdef OBS\r\n\tqdbg(\"RWh:AF; forceVerticalCC.y=%f, mass=%f\\n\",forceVerticalCC.y,MASS);\r\n#endif\r\n\r\n}\r\n\r\n\r\n\r\nvoid pWheel2::CalcSlipRatio(VxVector *velWheelCC)\r\n{\r\n\r\n\t//rfloat vGround,vFreeRolling;\r\n\r\n\tfloat lastTime =lastStepTimeSec;\r\n\r\n\t/*\r\n\tlastTime*=0.1f;\r\n*/\r\n\r\n\t//velWheelTC->DbgPrint(\"velWheelTC in CalcSR\");\r\n\tif(!hadContact)\r\n\t{\r\n\t\t//qdbg(\"CalcSR; not on surface\\n\");\r\n\t\t// Not touching the surface, no slip ratio\r\n\t\tslipRatio=0;\r\n\t\t// Tire vibrations stop\r\n\t\tdifferentialSlipRatio=0;\r\n\t\treturn;\r\n\t}\r\n\r\n\t// SAE950311 algorithm\r\n\tfloat u,delta,B;\r\n\tu=velWheelTC.z;\r\n\tB=relaxationLengthLong;\r\n\r\n\t// Switch to normal slip ratio calculations when there is\r\n\t// speed (in the case when the velocities catch up on the timestep)\r\n\t// Notice this test can be optimized, because the timestep and B\r\n\t// are constants, so a 'turningPointU' can be defined.\r\n\t//qdbg(\"Threshold: %f\\n\",u*RR_TIMESTEP/B);\r\n\t\r\n\tfloat t0 = u*lastTime;\r\n\tbool tc = B>0.5 ? true : false;\r\n\r\n\r\n\t\r\n\tif(u*lastTime/B>0.5)\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// changed : \r\n\t\t//\r\n\t\t//float wheelSlipRatio \r\n\t\t\r\n\t\tslipRatio=rotationV.x*radiusLoaded/u-1;\r\n\t\t//slipRatio = lastContactData->longitudalSlip;\r\n\t\t\r\n\t\treturn;\r\n\t\t// Use straightforward slip ratio\r\n\t\tslipRatio=rotationV.x*radiusLoaded/u-1;\r\n\t\t//qdbg(\"'u' big enough; straight SR %f\\n\",slipRatio);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif((lastU<0&&u>=0)||(lastU>=0&&u<0))\r\n\t{\r\n\t\t// 'u' changed sign, reverse slip\r\n\t\t//qdbg(\"'u' changed sign from %f to %f; SR=-SR\\n\",u,lastU);\r\n\t\t//differentialSlipRatio=-differentialSlipRatio;\r\n\t\t// Damp while reversing slip; we're close to a standstill.\r\n\t\tfloat dampSRreversal = 0.2f;\r\n\t\tdifferentialSlipRatio=-dampSRreversal*differentialSlipRatio;\r\n\t}\r\n\tlastU=u;\r\n\t// Detect sign of 'u' (real velocity of wheel)\r\n\tif(u<0)signU=-1.0f; else signU=1.0f;\r\n\r\n\t// Eq. 26\r\n\t//delta=(fabs(u)-rotationV.x*radius*signU)/B-(fabs(u)/B)*differentialSlipRatio;\r\n\tif(u<0)\r\n\t{\r\n\t\t// Eq. 25\r\n\t\tdelta=(-u+rotationV.x*radius)/B+(u/B)*differentialSlipRatio;\r\n\t} else\r\n\t{\r\n\t\t// Eq. 20\r\n\t\tdelta=(u-rotationV.x*radius)/B-(u/B)*differentialSlipRatio;\r\n\t}\r\n\r\n\t\r\n\t// Integrate\r\n\tdifferentialSlipRatio+=delta*lastTime;\r\n\tif(differentialSlipRatio>10)differentialSlipRatio=10;\r\n\telse if(differentialSlipRatio<-10)differentialSlipRatio=-10;\r\n\t// Set slip ratio for the rest of the sim. Note that\r\n\t// we use a different slip ratio definition from that of SAE950311\r\n\t//qdbg(\" old SR=%f => new SR=%f\\n\",slipRatio,-differentialSlipRatio);\r\n\tslipRatio=-differentialSlipRatio;\r\n\r\n\r\n}\r\n\r\nvoid pWheel2::updatePosition()\r\n{\r\n\tNxMat34 &wheelPose = getWheelPose();\r\n\tNxWheelContactData wcd; \r\n\tNxShape* contactShape = mWheelShape->getContact(wcd);\r\n\tNxReal stravel = mWheelShape->getSuspensionTravel();\r\n\tNxReal radius = mWheelShape->getRadius();\r\n\t//have ground contact?\r\n\tif( contactShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n}\r\n\r\nvoid pWheel2::updateSteeringPose(float rollangle,float steerAngle,float dt)\r\n{\r\n\t\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\r\n\trollAngle+=getWheelShape()->getAxleSpeed() * (dt * 0.01f);\r\n\r\n\t\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\r\n\tNxMat34& wheelPose = mWheelShape->getGlobalPose();\r\n\r\n\r\n\tNxReal stravel = mWheelShape->getSuspensionTravel();\r\n\tNxReal radius = mWheelShape->getRadius();\r\n\r\n\r\n\r\n\tfloat rAngle = getWheelRollAngle();\r\n\tfloat steer = mWheelShape->getSteerAngle();\r\n\r\n\r\n\tNxVec3 dir;\r\n\r\n\tNxReal r = mWheelShape->getRadius();\r\n\tNxReal st = mWheelShape->getSuspensionTravel();\r\n\r\n\t\r\n\twheelPose.M.getColumn(1, dir);\r\n\tdir = -dir;\t//cast along -Y.\r\n\tNxReal castLength = r + st;\t//cast ray this long\r\n\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( mWheelShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\r\n\tsetWheelPose(wheelPose);\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid pWheel2::CalcSlipAngle()\r\n// Based on the wheel world velocity and heading, calculate\r\n// the angle from the wheel heading to the wheel's actual velocity\r\n// Contrary to SAE, our Y-axis points up, and slipAngle>0 means\r\n// in our case that the you're in a right turn (basically)\r\n// 31-03-01: SAE950311 implementation (using relaxation lengths\r\n// and a differential equation for the slip angle) for low-speed etc.\r\n{\r\n\r\n\r\n\tVxVector velWheelWC;\r\n\r\n\tif(!hadContact)\r\n\t{\r\n\t\t//qdbg(\"CalcSA; not on surface\\n\");\r\n\t\t// Not touching the surface, no need to do slip angle\r\n\t\tslipAngle=0;\r\n\t\t// Tire springs back to 0 instantly (should be slowly actually)\r\n\t\ttanSlipAngle=0;\r\n\t\tvelWheelTC.Set(0,0,0);\r\n\t\tvelWheelCC.Set(0,0,0);\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\tint options = getProcessOptions();\r\n\t\r\n\tif (options & pVPO_Wheel_UsePHYSX_CONTACT_DATA )\r\n\t{\r\n\r\n\t\t/*\r\n\t\tVxVector dir,up,right;\r\n\t\tgetEntity()->GetOrientation(&dir,&up,&right);\r\n\t\t*/\r\n\r\n\t\tVxVector point= lastContactData->contactPoint;\r\n\t\tif( lastContactData->contactPosition <= ( getWheelShape()->getSuspensionTravel() + radius) ) \r\n\t\t\tpoint.y+=getRadius();\r\n\t\telse\r\n\t\t\tpoint.y = getWheelPose().t.y - getSuspensionTravel();\r\n\r\n\t\t//getEntity()->TransformVector(&point,&point);\r\n/*\r\n\t\tgetBody()->GetVT3DObject()->InverseTransformVector(&point,&point);\r\n\r\n\t\t/*\r\n\t\t\r\n\t\tgetEntity()->InverseTransformVector(&contactLocal,&point);\r\n\r\n\t\tVxVector contactLocal2;\r\n\t\tgetEntity()->InverseTransform(&contactLocal,&point);\r\n*/\r\n\r\n\t\tgetBody()->GetVT3DObject()->InverseTransform(&point,&point);\r\n\r\n\t\tvelWheelCC = getBody()->getLocalPointVelocity(point);\r\n\t\t//getEntity()->TransformVector(&velWheelCC,&velWheelCC);\r\n\t\tConvertCarToTireOrientation(this,&velWheelCC,&velWheelTC);\r\n\r\n\r\n\t}\r\n\r\n\tif ( options & pVPO_SA_Delay )\r\n\t{\r\n\t\t// Derive change in tan(slipAngle) using SAE950311\r\n\t\t// u=longitudinal velocity, v=lateral velocity\r\n\t\tfloat u,b,v,delta;\r\n\t\tu=velWheelTC.z;\r\n\t\tv=velWheelTC.x;\r\n\t\tb=relaxationLengthLat;\r\n\r\n\t\tif ( options & pVPO_SA_DownSettle)\r\n\t\t{\r\n\t\t\t\t// Make sure SA settles down at low speeds\r\n\t\t\t\tfloat min=5.0f;\r\n\t\t\t\tif(u=0.0f)u=min;\r\n\t\t\t\telse if(u>-min&&u<=0)u=-min;\r\n\t\t}\r\n\t\t\t\r\n\r\n\t\t// Calculate change in tan(SA)\r\n\t\tdelta=(v/b)-(fabs(u)/b)*tanSlipAngle;\r\n\t\tif( getWheelFlag(WF_Accelerated) && getVehicle() )\r\n\t\t{\r\n\t\t\t//qdbg(\"CSA; u=%f, v=%f, delta=%f, tanSA=%f, SA=%f\\n\",u,v,delta,tanSlipAngle,slipAngle);\r\n\t\t\t//\tqdbg(\"delta=%f, tanSA=%f, SA=%f\\n\",delta,tanSlipAngle,atan(tanSlipAngle));\r\n\t\t\t//\tIntegrate\r\n\t\t\ttanSlipAngle+=delta*lastStepTimeMS;\r\n\t\t\t// Derive new slip angle from state variable 'tanSlipAngle'\r\n\t\t\tslipAngle=atanf(tanSlipAngle);\r\n\r\n\t\t}\r\n\t}else\r\n\t{\r\n\r\n\t\t// Calculate wheel velocity because of rotation around yaw (Y) axis\r\n\t\t\r\n\t\t/*velWheelCC.x+=car->GetBody()->GetRotVel()->y*cos(-angleCGM)*distCGM;\r\n\t\tvelWheelCC.z+=car->GetBody()->GetRotVel()->y*sin(-angleCGM)*distCGM;\r\n\t\tConvertCarToTireOrientation(&velWheelCC,&velWheelTC);\r\n\t\t*/\r\n\r\n\t\t/*\r\n\t\t// Get velocity of contact patch wrt the track (=world)\r\n\t\tDVector3 cpPos,*p;\r\n\t\tp=susp->GetPosition();\r\n\t\t// Taking the tire movement from really the contact patch location\r\n\t\t// seems to overrate the lateral movement the tire goes through.\r\n\t\t// This is due because the body rolls, but normally the suspension\r\n\t\t// won't roll the tire in exactly the same way, but instead,\r\n\t\t// the tire rotates with respect to the body, so the lateral\r\n\t\t// movements are actually quite small.\r\n\t\t// To simulate this, I approximate the movement with respect\r\n\t\t// to the suspension attachment point, which moves far less\r\n\t\t// laterally. This became apparent when dealing with much stiffer\r\n\t\t// tire and suspension spring rates, which made the car wobbly.\r\n\t\t// Taking a less laterally sensitive position solved this.\r\n\t\tcpPos.x=p->x;\r\n\t\t//cpPos.y=p->y+susp->GetLength()+radius;\r\n\t\tcpPos.y=p->y;\r\n\t\tcpPos.z=p->z; // Kingpin effects are ignored\r\n\t\tcar->GetBody()->CalcBodyVelForBodyPos(&cpPos,&velWheelCC);\r\n\t\tcar->ConvertCarToWorldOrientation(&velWheelCC,&velWheelWC);\r\n\t\tConvertCarToTireOrientation(&velWheelCC,&velWheelTC);\r\n\t\t*/\r\n\r\n\t\t//qdbg(\"velWheelTC.z=%f, rotZ=%f\\n\",velWheelTC.z,rotationV.x*radius);\r\n\r\n\t\t// Non-SAE950311 method (no lag in slip angle buildup)\r\n\t\t// Calculate slip angle as the angle between the wheel velocity vector\r\n\t\t// and the wheel direction vector\r\n\t\t\r\n\t\tif(velWheelCC.x>-RR_EPSILON_VELOCITY&&velWheelCC.x-RR_EPSILON_VELOCITY&&velWheelCC.z slipAngle=0\\n\");\r\n\t\t} \r\n\t\telse\r\n\t\t{ \r\n\t\t\t// Enough velocity, calculate real angle\r\n\t\t\tfloat h = GetHeading();\r\n\r\n\t\t\tfloat realSteer = mWheelShape->getSteerAngle();\r\n\r\n\t\t\tslipAngle=atan2(velWheelCC.x,velWheelCC.z)-GetHeading();\r\n\r\n\t\t\tif (getProcessOptions() & pVPO_SA_Damping )\r\n\t\t\t{\r\n\t\t\t\t// Damp down at low velocity\r\n\t\t\t\tif(fabs(velWheelCC.x)<0.3f&&fabs(velWheelCC.z)<0.3f)\r\n\t\t\t\t{\r\n\t\t\t\t\tfloat max=fabs(velWheelCC.x);\r\n\t\t\t\t\tif(fabs(velWheelCC.z) %f\\n\",slipAngle*RR_RAD2DEG,max,slipAngle*max);\r\n\t\t\t\t\tslipAngle*=max*0.5f;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Keep slipAngle between -180..180 degrees\r\n\t\t\tif(slipAngle<-PI)\r\n\t\t\t\tslipAngle+=2*PI;\r\n\t\t\telse if(slipAngle>PI)\r\n\t\t\t\tslipAngle-=2*PI;\r\n\t\t\r\n\t\t}\r\n\t\tif ( options & pVPO_SV_Tansa)\r\n\t\t{\r\n\t\t\tbool make = true ;\r\n\t\t\tif(make)\r\n\t\t\t{\r\n\t\t\t\t// We need tan(SA) when combining Pacejka Fx/Fy later\r\n\t\t\t\ttanSlipAngle=tan(slipAngle);\r\n\t\t\t\t//qdbg(\"FCSV: tanSA=%f\\n\",tanSlipAngle);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}#include \"VxDefines.h\"\r\n#include \"CKAll.h\"\r\n\r\n#undef min\r\n#undef max\r\n// ===============================================================================\r\n//\t\t\t\t\t\t NVIDIA PHYSX SDK TRAINING PROGRAMS\r\n//\t\t\t\t\t LESSON 404: TANK\r\n//\r\n//\t\t\t\t\t\t Written by , 5-1-06\r\n// ===============================================================================\r\n\r\n#ifndef LESSON407_H\r\n#define LESSON407_H\r\n\r\n#include \"CommonCode2.h\"\r\n\r\nvoid PrintControls();\r\nvoid NewLight();\r\nvoid SetMotorOnTread(int i, const NxMotorDesc& mDesc);\r\nvoid ProcessMotorKeys();\r\nvoid InitMotors();\r\nint main(int argc, char** argv);\r\n\r\n#endif // LESSON407_H\r\n/* -----------------------------------------------------------------------------\n * See the LICENSE file for information on copyright, usage and redistribution\n * of SWIG, and the README file for authors - http://www.swig.org/release.html.\n *\n * typemap.c\n *\n * A somewhat generalized implementation of SWIG1.1 typemaps.\n * ----------------------------------------------------------------------------- */\n\nchar cvsroot_typemap_c[] = \"$Id: typemap.c 9889 2007-08-10 02:55:27Z wuzzeb $\";\n\n#include \"swig.h\"\n#include \"cparse.h\"\n#include \n\n#if 0\n#define SWIG_DEBUG\n#endif\n\nstatic void replace_embedded_typemap(String *s);\n\n/* -----------------------------------------------------------------------------\n * Typemaps are stored in a collection of nested hash tables. Something like\n * this:\n *\n * [ type ]\n * +-------- [ name ]\n * +-------- [ name ]\n * \n * Each hash table [ type ] or [ name ] then contains references to the\n * different typemap methods. These are referenced by names such as\n * \"tmap:in\", \"tmap:out\", \"tmap:argout\", and so forth.\n *\n * The object corresponding to a specific method has the following\n * attributes:\n *\n * \"type\" - Typemap type\n * \"pname\" - Parameter name\n * \"code\" - Typemap code\n * \"typemap\" - Descriptive text describing the actual map\n * \"locals\" - Local variables (if any)\n * \n * ----------------------------------------------------------------------------- */\n\n#define MAX_SCOPE 32\n\n\nstatic Hash *typemaps[MAX_SCOPE];\nstatic int tm_scope = 0;\n\nstatic Hash *get_typemap(int tm_scope, SwigType *type) {\n Hash *tm = 0;\n SwigType *dtype = 0;\n if (SwigType_istemplate(type)) {\n String *ty = Swig_symbol_template_deftype(type, 0);\n dtype = Swig_symbol_type_qualify(ty, 0);\n /* Printf(stderr,\"gettm %s %s\\n\", type, dtype); */\n type = dtype;\n Delete(ty);\n }\n tm = Getattr(typemaps[tm_scope], type);\n\n\n if (dtype) {\n if (!tm) {\n String *t_name = SwigType_templateprefix(type);\n if (!Equal(t_name, type)) {\n\ttm = Getattr(typemaps[tm_scope], t_name);\n }\n Delete(t_name);\n }\n Delete(dtype);\n }\n\n return tm;\n}\n\nstatic void set_typemap(int tm_scope, SwigType *type, Hash *tm) {\n SwigType *dtype = 0;\n if (SwigType_istemplate(type)) {\n String *ty = Swig_symbol_template_deftype(type, 0);\n dtype = Swig_symbol_type_qualify(ty, 0);\n /* Printf(stderr,\"settm %s %s\\n\", type, dtype); */\n type = dtype;\n Delete(ty);\n } else {\n dtype = Copy(type);\n type = dtype;\n }\n Setattr(typemaps[tm_scope], type, tm);\n Delete(dtype);\n}\n\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_init()\n *\n * Initialize the typemap system\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_init() {\n int i;\n for (i = 0; i < MAX_SCOPE; i++) {\n typemaps[i] = 0;\n }\n typemaps[0] = NewHash();\n tm_scope = 0;\n}\n\nstatic String *tmop_name(const String_or_char *op) {\n static Hash *names = 0;\n String *s;\n /* Due to \"interesting\" object-identity semantics of DOH,\n we have to make sure that we only intern strings without object\n identity into the hash table.\n\n (Swig_typemap_attach_kwargs calls tmop_name several times with\n the \"same\" String *op (i.e., same object identity) but differing\n string values.)\n\n Most other callers work around this by using char* rather than\n String *.\n -- mkoeppe, Jun 17, 2003\n */\n const char *op_without_object_identity = Char(op);\n if (!names)\n names = NewHash();\n s = Getattr(names, op_without_object_identity);\n if (s)\n return s;\n s = NewStringf(\"tmap:%s\", op);\n Setattr(names, op_without_object_identity, s);\n Delete(s);\n return s;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_new_scope()\n * \n * Create a new typemap scope\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_new_scope() {\n tm_scope++;\n typemaps[tm_scope] = NewHash();\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_pop_scope()\n *\n * Pop the last typemap scope off\n * ----------------------------------------------------------------------------- */\n\nHash *Swig_typemap_pop_scope() {\n if (tm_scope > 0) {\n return typemaps[tm_scope--];\n }\n return 0;\n}\n\n/* ----------------------------------------------------------------------------- \n * Swig_typemap_register()\n *\n * Add a new multi-valued typemap\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_char *code, ParmList *locals, ParmList *kwargs) {\n Hash *tm;\n Hash *tm1;\n Hash *tm2;\n Parm *np;\n String *tmop;\n SwigType *type;\n String *pname;\n\n if (!parms)\n return;\n tmop = tmop_name(op);\n\n /* Register the first type in the parameter list */\n\n type = Getattr(parms, \"type\");\n pname = Getattr(parms, \"name\");\n\n /* See if this type has been seen before */\n tm = get_typemap(tm_scope, type);\n if (!tm) {\n tm = NewHash();\n set_typemap(tm_scope, type, tm);\n Delete(tm);\n }\n if (pname) {\n /* See if parameter has been seen before */\n tm1 = Getattr(tm, pname);\n if (!tm1) {\n tm1 = NewHash();\n Setattr(tm, pname, tm1);\n Delete(tm1);\n }\n tm = tm1;\n }\n\n /* Now see if this typemap op has been seen before */\n tm2 = Getattr(tm, tmop);\n if (!tm2) {\n tm2 = NewHash();\n Setattr(tm, tmop, tm2);\n Delete(tm2);\n }\n\n /* For a multi-valued typemap, the typemap code and information\n is really only stored in the last argument. However, to\n make this work, we perform a really neat trick using\n the typemap operator name.\n\n For example, consider this typemap\n\n %typemap(in) (int foo, int *bar, char *blah[]) {\n ...\n }\n\n To store it, we look at typemaps for the following:\n\n operator type-name\n ----------------------------------------------\n \"in\" int foo\n \"in-int+foo:\" int *bar\n \"in-int+foo:-p.int+bar: char *blah[]\n\n Notice how the operator expands to encode information about\n previous arguments. \n\n */\n\n np = nextSibling(parms);\n if (np) {\n /* Make an entirely new operator key */\n String *newop = NewStringf(\"%s-%s+%s:\", op, type, pname);\n /* Now reregister on the remaining arguments */\n Swig_typemap_register(newop, np, code, locals, kwargs);\n\n /* Setattr(tm2,newop,newop); */\n Delete(newop);\n } else {\n String *str = SwigType_str(type, pname);\n String *typemap = NewStringf(\"typemap(%s) %s\", op, str);\n ParmList *clocals = CopyParmList(locals);\n ParmList *ckwargs = CopyParmList(kwargs);\n\n Setattr(tm2, \"code\", code);\n Setattr(tm2, \"type\", type);\n Setattr(tm2, \"typemap\", typemap);\n if (pname) {\n Setattr(tm2, \"pname\", pname);\n }\n Setattr(tm2, \"locals\", clocals);\n Setattr(tm2, \"kwargs\", ckwargs);\n\n Delete(clocals);\n Delete(ckwargs);\n\n Delete(str);\n Delete(typemap);\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_get()\n *\n * Retrieve typemap information from current scope.\n * ----------------------------------------------------------------------------- */\n\nstatic Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {\n Hash *tm, *tm1;\n /* See if this type has been seen before */\n if ((scope < 0) || (scope > tm_scope))\n return 0;\n tm = get_typemap(scope, type);\n if (!tm) {\n return 0;\n }\n if ((name) && Len(name)) {\n tm1 = Getattr(tm, name);\n return tm1;\n }\n return tm;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_copy()\n *\n * Copy a typemap\n * ----------------------------------------------------------------------------- */\n\nint Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *parms) {\n Hash *tm = 0;\n String *tmop;\n Parm *p;\n String *pname;\n SwigType *ptype;\n int ts = tm_scope;\n String *tmops, *newop;\n if (ParmList_len(parms) != ParmList_len(srcparms))\n return -1;\n\n tmop = tmop_name(op);\n while (ts >= 0) {\n p = srcparms;\n tmops = NewString(tmop);\n while (p) {\n ptype = Getattr(p, \"type\");\n pname = Getattr(p, \"name\");\n\n /* Lookup the type */\n tm = Swig_typemap_get(ptype, pname, ts);\n if (!tm)\n\tbreak;\n\n tm = Getattr(tm, tmops);\n if (!tm)\n\tbreak;\n\n /* Got a match. Look for next typemap */\n newop = NewStringf(\"%s-%s+%s:\", tmops, ptype, pname);\n Delete(tmops);\n tmops = newop;\n p = nextSibling(p);\n }\n Delete(tmops);\n\n if (!p && tm) {\n\n /* Got some kind of match */\n Swig_typemap_register(op, parms, Getattr(tm, \"code\"), Getattr(tm, \"locals\"), Getattr(tm, \"kwargs\"));\n return 0;\n }\n ts--;\n }\n /* Not found */\n return -1;\n\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_clear()\n *\n * Delete a multi-valued typemap\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_clear(const String_or_char *op, ParmList *parms) {\n SwigType *type;\n String *name;\n Parm *p;\n String *newop;\n Hash *tm = 0;\n\n /* This might not work */\n newop = NewString(op);\n p = parms;\n while (p) {\n type = Getattr(p, \"type\");\n name = Getattr(p, \"name\");\n tm = Swig_typemap_get(type, name, tm_scope);\n if (!tm)\n return;\n p = nextSibling(p);\n if (p)\n Printf(newop, \"-%s+%s:\", type, name);\n }\n if (tm) {\n tm = Getattr(tm, tmop_name(newop));\n if (tm) {\n Delattr(tm, \"code\");\n Delattr(tm, \"locals\");\n Delattr(tm, \"kwargs\");\n }\n }\n Delete(newop);\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_apply()\n *\n * Multi-argument %apply directive. This is pretty horrible so I sure hope\n * it works.\n * ----------------------------------------------------------------------------- */\n\nstatic\nint count_args(String *s) {\n /* Count up number of arguments */\n int na = 0;\n char *c = Char(s);\n while (*c) {\n if (*c == '+')\n na++;\n c++;\n }\n return na;\n}\n\nint Swig_typemap_apply(ParmList *src, ParmList *dest) {\n String *ssig, *dsig;\n Parm *p, *np, *lastp, *dp, *lastdp = 0;\n int narg = 0;\n int ts = tm_scope;\n SwigType *type = 0, *name;\n Hash *tm, *sm;\n int match = 0;\n\n /* Printf(stdout,\"apply : %s --> %s\\n\", ParmList_str(src), ParmList_str(dest)); */\n\n /* Create type signature of source */\n ssig = NewStringEmpty();\n dsig = NewStringEmpty();\n p = src;\n dp = dest;\n lastp = 0;\n while (p) {\n lastp = p;\n lastdp = dp;\n np = nextSibling(p);\n if (np) {\n Printf(ssig, \"-%s+%s:\", Getattr(p, \"type\"), Getattr(p, \"name\"));\n Printf(dsig, \"-%s+%s:\", Getattr(dp, \"type\"), Getattr(dp, \"name\"));\n narg++;\n }\n p = np;\n dp = nextSibling(dp);\n }\n\n /* make sure a typemap node exists for the last destination node */\n type = Getattr(lastdp, \"type\");\n tm = get_typemap(tm_scope, type);\n if (!tm) {\n tm = NewHash();\n set_typemap(tm_scope, type, tm);\n Delete(tm);\n }\n name = Getattr(lastdp, \"name\");\n if (name) {\n Hash *tm1 = Getattr(tm, name);\n if (!tm1) {\n tm1 = NewHash();\n Setattr(tm, NewString(name), tm1);\n Delete(tm1);\n }\n tm = tm1;\n }\n\n /* This is a little nasty. We need to go searching for all possible typemaps in the\n source and apply them to the target */\n\n type = Getattr(lastp, \"type\");\n name = Getattr(lastp, \"name\");\n\n while (ts >= 0) {\n\n /* See if there is a matching typemap in this scope */\n sm = Swig_typemap_get(type, name, ts);\n\n /* if there is not matching, look for a typemap in the\n original typedef, if any, like in:\n\n typedef unsigned long size_t;\n ...\n %apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size};\n */\n if (!sm) {\n SwigType *ntype = SwigType_typedef_resolve(type);\n if (ntype && (Cmp(ntype, type) != 0)) {\n\tsm = Swig_typemap_get(ntype, name, ts);\n }\n Delete(ntype);\n }\n\n if (sm) {\n /* Got a typemap. Need to only merge attributes for methods that match our signature */\n Iterator ki;\n match = 1;\n for (ki = First(sm); ki.key; ki = Next(ki)) {\n\t/* Check for a signature match with the source signature */\n\tif ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) {\n\t String *oldm;\n\t /* A typemap we have to copy */\n\t String *nkey = Copy(ki.key);\n\t Replace(nkey, ssig, dsig, DOH_REPLACE_ANY);\n\n\t /* Make sure the typemap doesn't already exist in the target map */\n\n\t oldm = Getattr(tm, nkey);\n\t if (!oldm || (!Getattr(tm, \"code\"))) {\n\t String *code;\n\t ParmList *locals;\n\t ParmList *kwargs;\n\t Hash *sm1 = ki.item;\n\n\t code = Getattr(sm1, \"code\");\n\t locals = Getattr(sm1, \"locals\");\n\t kwargs = Getattr(sm1, \"kwargs\");\n\t if (code) {\n\t Replace(nkey, dsig, \"\", DOH_REPLACE_ANY);\n\t Replace(nkey, \"tmap:\", \"\", DOH_REPLACE_ANY);\n\t Swig_typemap_register(nkey, dest, code, locals, kwargs);\n\t }\n\t }\n\t Delete(nkey);\n\t}\n }\n }\n ts--;\n }\n Delete(ssig);\n Delete(dsig);\n return match;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_clear_apply()\n *\n * %clear directive. Clears all typemaps for a type (in the current scope only). \n * ----------------------------------------------------------------------------- */\n\n/* Multi-argument %clear directive */\nvoid Swig_typemap_clear_apply(Parm *parms) {\n String *tsig;\n Parm *p, *np, *lastp;\n int narg = 0;\n Hash *tm;\n String *name;\n\n /* Create a type signature of the parameters */\n tsig = NewStringEmpty();\n p = parms;\n lastp = 0;\n while (p) {\n lastp = p;\n np = nextSibling(p);\n if (np) {\n Printf(tsig, \"-%s+%s:\", Getattr(p, \"type\"), Getattr(p, \"name\"));\n narg++;\n }\n p = np;\n }\n tm = get_typemap(tm_scope, Getattr(lastp, \"type\"));\n if (!tm) {\n Delete(tsig);\n return;\n }\n name = Getattr(lastp, \"name\");\n if (name) {\n tm = Getattr(tm, name);\n }\n if (tm) {\n /* Clear typemaps that match our signature */\n Iterator ki, ki2;\n char *ctsig = Char(tsig);\n for (ki = First(tm); ki.key; ki = Next(ki)) {\n char *ckey = Char(ki.key);\n if (strncmp(ckey, \"tmap:\", 5) == 0) {\n\tint na = count_args(ki.key);\n\tif ((na == narg) && strstr(ckey, ctsig)) {\n\t Hash *h = ki.item;\n\t for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) {\n\t Delattr(h, ki2.key);\n\t }\n\t}\n }\n }\n }\n Delete(tsig);\n}\n\n/* Internal function to strip array dimensions. */\nstatic SwigType *strip_arrays(SwigType *type) {\n SwigType *t;\n int ndim;\n int i;\n t = Copy(type);\n ndim = SwigType_array_ndim(t);\n for (i = 0; i < ndim; i++) {\n SwigType_array_setdim(t, i, \"ANY\");\n }\n return t;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_search()\n *\n * Search for a typemap match. Tries to find the most specific typemap\n * that includes a 'code' attribute.\n * ----------------------------------------------------------------------------- */\n\nHash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *name, SwigType **matchtype) {\n Hash *result = 0, *tm, *tm1, *tma;\n Hash *backup = 0;\n SwigType *noarrays = 0;\n SwigType *primitive = 0;\n SwigType *ctype = 0;\n int ts;\n int isarray;\n const String *cname = 0;\n SwigType *unstripped = 0;\n String *tmop = tmop_name(op);\n\n if ((name) && Len(name))\n cname = name;\n ts = tm_scope;\n\n while (ts >= 0) {\n ctype = type;\n while (ctype) {\n /* Try to get an exact type-match */\n tm = get_typemap(ts, ctype);\n if (tm && cname) {\n\ttm1 = Getattr(tm, cname);\n\tif (tm1) {\n\t result = Getattr(tm1, tmop);\t/* See if there is a type-name match */\n\t if (result && Getattr(result, \"code\"))\n\t goto ret_result;\n\t if (result)\n\t backup = result;\n\t}\n }\n if (tm) {\n\tresult = Getattr(tm, tmop);\t/* See if there is simply a type match */\n\tif (result && Getattr(result, \"code\"))\n\t goto ret_result;\n\tif (result)\n\t backup = result;\n }\n isarray = SwigType_isarray(ctype);\n if (isarray) {\n\t/* If working with arrays, strip away all of the dimensions and replace with \"ANY\".\n\t See if that generates a match */\n\tif (!noarrays) {\n\t noarrays = strip_arrays(ctype);\n\t}\n\ttma = get_typemap(ts, noarrays);\n\tif (tma && cname) {\n\t tm1 = Getattr(tma, cname);\n\t if (tm1) {\n\t result = Getattr(tm1, tmop);\t/* type-name match */\n\t if (result && Getattr(result, \"code\"))\n\t goto ret_result;\n\t if (result)\n\t backup = result;\n\t }\n\t}\n\tif (tma) {\n\t result = Getattr(tma, tmop);\t/* type match */\n\t if (result && Getattr(result, \"code\"))\n\t goto ret_result;\n\t if (result)\n\t backup = result;\n\t}\n\tDelete(noarrays);\n\tnoarrays = 0;\n }\n\n /* No match so far. If the type is unstripped, we'll strip its\n qualifiers and check. Otherwise, we'll try to resolve a typedef */\n\n if (!unstripped) {\n\tunstripped = ctype;\n\tctype = SwigType_strip_qualifiers(ctype);\n\tif (!Equal(ctype, unstripped))\n\t continue;\t\t/* Types are different */\n\tDelete(ctype);\n\tctype = unstripped;\n\tunstripped = 0;\n }\n {\n\tString *octype;\n\tif (unstripped) {\n\t Delete(ctype);\n\t ctype = unstripped;\n\t unstripped = 0;\n\t}\n\toctype = ctype;\n\tctype = SwigType_typedef_resolve(ctype);\n\tif (octype != type)\n\t Delete(octype);\n }\n }\n\n /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default mapping */\n\n primitive = SwigType_default(type);\n while (primitive) {\n tm = get_typemap(ts, primitive);\n if (tm && cname) {\n\ttm1 = Getattr(tm, cname);\n\tif (tm1) {\n\t result = Getattr(tm1, tmop);\t/* See if there is a type-name match */\n\t if (result)\n\t goto ret_result;\n\t}\n }\n if (tm) {\t\t\t/* See if there is simply a type match */\n\tresult = Getattr(tm, tmop);\n\tif (result)\n\t goto ret_result;\n }\n {\n\tSwigType *nprim = SwigType_default(primitive);\n\tDelete(primitive);\n\tprimitive = nprim;\n }\n }\n if (ctype != type) {\n Delete(ctype);\n ctype = 0;\n }\n ts--;\t\t\t/* Hmmm. Nothing found in this scope. Guess we'll go try another scope */\n }\n result = backup;\n\nret_result:\n if (noarrays)\n Delete(noarrays);\n if (primitive)\n Delete(primitive);\n if ((unstripped) && (unstripped != type))\n Delete(unstripped);\n if (matchtype) {\n *matchtype = Copy(ctype);\n }\n if (type != ctype)\n Delete(ctype);\n return result;\n}\n\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_search_multi()\n *\n * Search for a multi-valued typemap.\n * ----------------------------------------------------------------------------- */\n\nHash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch) {\n SwigType *type;\n SwigType *mtype = 0;\n String *name;\n String *newop;\n Hash *tm, *tm1;\n\n if (!parms) {\n *nmatch = 0;\n return 0;\n }\n type = Getattr(parms, \"type\");\n name = Getattr(parms, \"name\");\n\n /* Try to find a match on the first type */\n tm = Swig_typemap_search(op, type, name, &mtype);\n if (tm) {\n if (mtype && SwigType_isarray(mtype)) {\n Setattr(parms, \"tmap:match\", mtype);\n }\n Delete(mtype);\n newop = NewStringf(\"%s-%s+%s:\", op, type, name);\n tm1 = Swig_typemap_search_multi(newop, nextSibling(parms), nmatch);\n if (tm1)\n tm = tm1;\n if (Getattr(tm, \"code\")) {\n *(nmatch) = *nmatch + 1;\n } else {\n tm = 0;\n }\n Delete(newop);\n }\n return tm;\n}\n\n\n/* -----------------------------------------------------------------------------\n * typemap_replace_vars()\n *\n * Replaces typemap variables on a string. index is the $n variable.\n * type and pname are the type and parameter name.\n * ----------------------------------------------------------------------------- */\n\nstatic\nvoid replace_local_types(ParmList *p, const String *name, const String *rep) {\n SwigType *t;\n while (p) {\n t = Getattr(p, \"type\");\n Replace(t, name, rep, DOH_REPLACE_ANY);\n p = nextSibling(p);\n }\n}\n\nstatic\nint check_locals(ParmList *p, const char *s) {\n while (p) {\n char *c = GetChar(p, \"type\");\n if (strstr(c, s))\n return 1;\n p = nextSibling(p);\n }\n return 0;\n}\n\nstatic\nvoid typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) {\n char var[512];\n char *varname;\n SwigType *ftype;\n\n Replaceall(s, \"$typemap\", \"$TYPEMAP\");\n\n ftype = SwigType_typedef_resolve_all(type);\n\n if (!pname)\n pname = lname;\n {\n Parm *p;\n int rep = 0;\n p = locals;\n while (p) {\n if (Strchr(Getattr(p, \"type\"), '$'))\n\trep = 1;\n p = nextSibling(p);\n }\n if (!rep)\n locals = 0;\n }\n\n sprintf(var, \"$%d_\", index);\n varname = &var[strlen(var)];\n\n /* If the original datatype was an array. We're going to go through and substitute\n its array dimensions */\n\n if (SwigType_isarray(type) || SwigType_isarray(ftype)) {\n String *size;\n int ndim;\n int i;\n if (SwigType_array_ndim(type) != SwigType_array_ndim(ftype))\n type = ftype;\n ndim = SwigType_array_ndim(type);\n size = NewStringEmpty();\n for (i = 0; i < ndim; i++) {\n String *dim = SwigType_array_getdim(type, i);\n if (index == 1) {\n\tchar t[32];\n\tsprintf(t, \"$dim%d\", i);\n\tReplace(s, t, dim, DOH_REPLACE_ANY);\n\treplace_local_types(locals, t, dim);\n }\n sprintf(varname, \"dim%d\", i);\n Replace(s, var, dim, DOH_REPLACE_ANY);\n replace_local_types(locals, var, dim);\n if (Len(size))\n\tPutc('*', size);\n Append(size, dim);\n Delete(dim);\n }\n sprintf(varname, \"size\");\n Replace(s, var, size, DOH_REPLACE_ANY);\n replace_local_types(locals, var, size);\n Delete(size);\n }\n\n /* Parameter name substitution */\n if (index == 1) {\n Replace(s, \"$parmname\", pname, DOH_REPLACE_ANY);\n }\n strcpy(varname, \"name\");\n Replace(s, var, pname, DOH_REPLACE_ANY);\n\n /* Type-related stuff */\n {\n SwigType *star_type, *amp_type, *base_type, *lex_type;\n SwigType *ltype, *star_ltype, *amp_ltype;\n String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;\n String *descriptor, *star_descriptor, *amp_descriptor;\n String *ts;\n char *sc;\n\n sc = Char(s);\n\n if (strstr(sc, \"type\") || check_locals(locals, \"type\")) {\n /* Given type : $type */\n ts = SwigType_str(type, 0);\n if (index == 1) {\n\tReplace(s, \"$type\", ts, DOH_REPLACE_ANY);\n\treplace_local_types(locals, \"$type\", type);\n }\n strcpy(varname, \"type\");\n Replace(s, var, ts, DOH_REPLACE_ANY);\n replace_local_types(locals, var, type);\n Delete(ts);\n sc = Char(s);\n }\n if (strstr(sc, \"ltype\") || check_locals(locals, \"ltype\")) {\n /* Local type: $ltype */\n ltype = SwigType_ltype(type);\n ts = SwigType_str(ltype, 0);\n if (index == 1) {\n\tReplace(s, \"$ltype\", ts, DOH_REPLACE_ANY);\n\treplace_local_types(locals, \"$ltype\", ltype);\n }\n strcpy(varname, \"ltype\");\n Replace(s, var, ts, DOH_REPLACE_ANY);\n replace_local_types(locals, var, ltype);\n Delete(ts);\n Delete(ltype);\n sc = Char(s);\n }\n if (strstr(sc, \"mangle\") || strstr(sc, \"descriptor\")) {\n /* Mangled type */\n\n mangle = SwigType_manglestr(type);\n if (index == 1)\n\tReplace(s, \"$mangle\", mangle, DOH_REPLACE_ANY);\n strcpy(varname, \"mangle\");\n Replace(s, var, mangle, DOH_REPLACE_ANY);\n\n descriptor = NewStringf(\"SWIGTYPE%s\", mangle);\n\n if (index == 1)\n\tif (Replace(s, \"$descriptor\", descriptor, DOH_REPLACE_ANY))\n\t SwigType_remember(type);\n\n strcpy(varname, \"descriptor\");\n if (Replace(s, var, descriptor, DOH_REPLACE_ANY))\n\tSwigType_remember(type);\n\n Delete(descriptor);\n Delete(mangle);\n }\n\n /* One pointer level removed */\n /* This creates variables of the form\n $*n_type\n $*n_ltype\n */\n\n if (SwigType_ispointer(ftype) || (SwigType_isarray(ftype)) || (SwigType_isreference(ftype))) {\n if (!(SwigType_isarray(type) || SwigType_ispointer(type) || SwigType_isreference(type))) {\n\tstar_type = Copy(ftype);\n } else {\n\tstar_type = Copy(type);\n }\n if (!SwigType_isreference(star_type)) {\n\tif (SwigType_isarray(star_type)) {\n\t SwigType_del_element(star_type);\n\t} else {\n\t SwigType_del_pointer(star_type);\n\t}\n\tts = SwigType_str(star_type, 0);\n\tif (index == 1) {\n\t Replace(s, \"$*type\", ts, DOH_REPLACE_ANY);\n\t replace_local_types(locals, \"$*type\", star_type);\n\t}\n\tsprintf(varname, \"$*%d_type\", index);\n\tReplace(s, varname, ts, DOH_REPLACE_ANY);\n\treplace_local_types(locals, varname, star_type);\n\tDelete(ts);\n } else {\n\tSwigType_del_element(star_type);\n }\n star_ltype = SwigType_ltype(star_type);\n ts = SwigType_str(star_ltype, 0);\n if (index == 1) {\n\tReplace(s, \"$*ltype\", ts, DOH_REPLACE_ANY);\n\treplace_local_types(locals, \"$*ltype\", star_ltype);\n }\n sprintf(varname, \"$*%d_ltype\", index);\n Replace(s, varname, ts, DOH_REPLACE_ANY);\n replace_local_types(locals, varname, star_ltype);\n Delete(ts);\n Delete(star_ltype);\n\n star_mangle = SwigType_manglestr(star_type);\n if (index == 1)\n\tReplace(s, \"$*mangle\", star_mangle, DOH_REPLACE_ANY);\n\n sprintf(varname, \"$*%d_mangle\", index);\n Replace(s, varname, star_mangle, DOH_REPLACE_ANY);\n\n star_descriptor = NewStringf(\"SWIGTYPE%s\", star_mangle);\n if (index == 1)\n\tif (Replace(s, \"$*descriptor\", star_descriptor, DOH_REPLACE_ANY))\n\t SwigType_remember(star_type);\n sprintf(varname, \"$*%d_descriptor\", index);\n if (Replace(s, varname, star_descriptor, DOH_REPLACE_ANY))\n\tSwigType_remember(star_type);\n\n Delete(star_descriptor);\n Delete(star_mangle);\n Delete(star_type);\n } else {\n /* TODO: Signal error if one of the $* substitutions is\n requested */\n }\n /* One pointer level added */\n amp_type = Copy(type);\n SwigType_add_pointer(amp_type);\n ts = SwigType_str(amp_type, 0);\n if (index == 1) {\n Replace(s, \"$&type\", ts, DOH_REPLACE_ANY);\n replace_local_types(locals, \"$&type\", amp_type);\n }\n sprintf(varname, \"$&%d_type\", index);\n Replace(s, varname, ts, DOH_REPLACE_ANY);\n replace_local_types(locals, varname, amp_type);\n Delete(ts);\n\n amp_ltype = SwigType_ltype(type);\n SwigType_add_pointer(amp_ltype);\n ts = SwigType_str(amp_ltype, 0);\n\n if (index == 1) {\n Replace(s, \"$&ltype\", ts, DOH_REPLACE_ANY);\n replace_local_types(locals, \"$&ltype\", amp_ltype);\n }\n sprintf(varname, \"$&%d_ltype\", index);\n Replace(s, varname, ts, DOH_REPLACE_ANY);\n replace_local_types(locals, varname, amp_ltype);\n Delete(ts);\n Delete(amp_ltype);\n\n amp_mangle = SwigType_manglestr(amp_type);\n if (index == 1)\n Replace(s, \"$&mangle\", amp_mangle, DOH_REPLACE_ANY);\n sprintf(varname, \"$&%d_mangle\", index);\n Replace(s, varname, amp_mangle, DOH_REPLACE_ANY);\n\n amp_descriptor = NewStringf(\"SWIGTYPE%s\", amp_mangle);\n if (index == 1)\n if (Replace(s, \"$&descriptor\", amp_descriptor, DOH_REPLACE_ANY))\n\tSwigType_remember(amp_type);\n sprintf(varname, \"$&%d_descriptor\", index);\n if (Replace(s, varname, amp_descriptor, DOH_REPLACE_ANY))\n SwigType_remember(amp_type);\n\n Delete(amp_descriptor);\n Delete(amp_mangle);\n Delete(amp_type);\n\n /* Base type */\n if (SwigType_isarray(type)) {\n SwigType *bt = Copy(type);\n Delete(SwigType_pop_arrays(bt));\n base_type = SwigType_str(bt, 0);\n Delete(bt);\n } else {\n base_type = SwigType_base(type);\n }\n\n base_name = SwigType_namestr(base_type);\n if (index == 1) {\n Replace(s, \"$basetype\", base_name, DOH_REPLACE_ANY);\n replace_local_types(locals, \"$basetype\", base_name);\n }\n strcpy(varname, \"basetype\");\n Replace(s, var, base_type, DOH_REPLACE_ANY);\n replace_local_types(locals, var, base_name);\n\n base_mangle = SwigType_manglestr(base_type);\n if (index == 1)\n Replace(s, \"$basemangle\", base_mangle, DOH_REPLACE_ANY);\n strcpy(varname, \"basemangle\");\n Replace(s, var, base_mangle, DOH_REPLACE_ANY);\n Delete(base_mangle);\n Delete(base_type);\n Delete(base_name);\n\n lex_type = SwigType_base(rtype);\n if (index == 1)\n Replace(s, \"$lextype\", lex_type, DOH_REPLACE_ANY);\n strcpy(varname, \"lextype\");\n Replace(s, var, lex_type, DOH_REPLACE_ANY);\n Delete(lex_type);\n }\n\n /* Replace any $n. with (&n)-> */\n {\n char temp[64];\n sprintf(var, \"$%d.\", index);\n sprintf(temp, \"(&$%d)->\", index);\n Replace(s, var, temp, DOH_REPLACE_ANY);\n }\n\n /* Replace the bare $n variable */\n sprintf(var, \"$%d\", index);\n Replace(s, var, lname, DOH_REPLACE_ANY);\n Delete(ftype);\n}\n\n/* ------------------------------------------------------------------------\n * static typemap_locals()\n *\n * Takes a string, a parameter list and a wrapper function argument and\n * creates the local variables.\n * ------------------------------------------------------------------------ */\n\nstatic void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {\n Parm *p;\n char *new_name;\n\n p = l;\n while (p) {\n SwigType *pt = Getattr(p, \"type\");\n SwigType *at = SwigType_alttype(pt, 1);\n String *pn = Getattr(p, \"name\");\n String *value = Getattr(p, \"value\");\n if (at)\n pt = at;\n if (pn) {\n if (Len(pn) > 0) {\n\tString *str;\n\tint isglobal = 0;\n\n\tstr = NewStringEmpty();\n\n\tif (strncmp(Char(pn), \"_global_\", 8) == 0) {\n\t isglobal = 1;\n\t}\n\n\t/* If the user gave us $type as the name of the local variable, we'll use\n\t the passed datatype instead */\n\n\tif ((argnum >= 0) && (!isglobal)) {\n\t Printf(str, \"%s%d\", pn, argnum);\n\t} else {\n\t Append(str, pn);\n\t}\n\tif (isglobal && Wrapper_check_local(f, str)) {\n\t p = nextSibling(p);\n\t Delete(str);\n\t if (at)\n\t Delete(at);\n\t continue;\n\t}\n\tif (value) {\n\t String *pstr = SwigType_str(pt, str);\n\t new_name = Wrapper_new_localv(f, str, pstr, \"=\", value, NIL);\n\t Delete(pstr);\n\t} else {\n\t String *pstr = SwigType_str(pt, str);\n\t new_name = Wrapper_new_localv(f, str, pstr, NIL);\n\t Delete(pstr);\n\t}\n\tif (!isglobal) {\n\t /* Substitute */\n\t Replace(s, pn, new_name, DOH_REPLACE_ID | DOH_REPLACE_NOQUOTE);\n\t}\n\tDelete(str);\n }\n }\n p = nextSibling(p);\n if (at)\n Delete(at);\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_lookup()\n *\n * Perform a typemap lookup (ala SWIG1.1)\n * ----------------------------------------------------------------------------- */\n\nString *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname,\n\t\t\t String_or_char *lname, String_or_char *source, String_or_char *target, Wrapper *f) {\n Hash *tm;\n String *s = 0;\n SwigType *mtype = 0;\n ParmList *locals;\n tm = Swig_typemap_search(op, type, pname, &mtype);\n if (!tm)\n return 0;\n\n s = Getattr(tm, \"code\");\n if (!s) {\n if (mtype)\n Delete(mtype);\n return 0;\n }\n\n\n /* Blocked */\n if (Cmp(s, \"pass\") == 0) {\n Delete(mtype);\n return 0;\n }\n\n s = Copy(s);\t\t\t/* Make a local copy of the typemap code */\n\n locals = Getattr(tm, \"locals\");\n if (locals)\n locals = CopyParmList(locals);\n\n /* This is wrong. It replaces locals in place. Need to fix this */\n if (mtype && SwigType_isarray(mtype)) {\n typemap_replace_vars(s, locals, mtype, type, pname, lname, 1);\n } else {\n typemap_replace_vars(s, locals, type, type, pname, lname, 1);\n }\n\n if (locals && f) {\n typemap_locals(s, locals, f, -1);\n }\n\n replace_embedded_typemap(s);\n\n /* Now perform character replacements */\n Replace(s, \"$source\", source, DOH_REPLACE_ANY);\n Replace(s, \"$target\", target, DOH_REPLACE_ANY);\n\n /* {\n String *tmname = Getattr(tm,\"typemap\");\n if (tmname) Replace(s,\"$typemap\",tmname, DOH_REPLACE_ANY);\n }\n */\n\n Replace(s, \"$parmname\", pname, DOH_REPLACE_ANY);\n /* Replace(s,\"$name\",pname,DOH_REPLACE_ANY); */\n\n Delete(locals);\n Delete(mtype);\n return s;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_lookup_new()\n *\n * Attach one or more typemaps to a node\n * op - typemap name, eg \"out\", \"newfree\"\n * node - the node to attach the typemaps to\n * lname -\n * f -\n * ----------------------------------------------------------------------------- */\n\nString *Swig_typemap_lookup_new(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f) {\n SwigType *type;\n SwigType *mtype = 0;\n String *pname;\n Hash *tm = 0;\n String *s = 0;\n String *sdef = 0;\n ParmList *locals;\n ParmList *kw;\n char temp[256];\n String *symname;\n String *cname = 0;\n String *clname = 0;\n char *cop = Char(op);\n /* special case, we need to check for 'ref' call \n and set the default code 'sdef' */\n if (node && Cmp(op, \"newfree\") == 0) {\n sdef = Swig_ref_call(node, lname);\n }\n\n type = Getattr(node, \"type\");\n if (!type)\n return sdef;\n\n pname = Getattr(node, \"name\");\n\n#if 1\n if (pname && node && checkAttribute(node, \"kind\", \"function\")) {\n /* \n For functions, look qualified names first, such as\n\n struct Foo {\n int *foo(int bar) -> Foo::foo\n };\n */\n Symtab *st = Getattr(node, \"sym:symtab\");\n String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;\n if (qsn) {\n if (Len(qsn) && !Equal(qsn, pname)) {\n\ttm = Swig_typemap_search(op, type, qsn, &mtype);\n\tif (tm && (!Getattr(tm, \"pname\") || strstr(Char(Getattr(tm, \"type\")), \"SWIGTYPE\"))) {\n\t tm = 0;\n\t}\n }\n Delete(qsn);\n }\n }\n if (!tm)\n#endif\n tm = Swig_typemap_search(op, type, pname, &mtype);\n if (!tm)\n return sdef;\n\n s = Getattr(tm, \"code\");\n if (!s)\n return sdef;\n\n /* Empty typemap. No match */\n if (Cmp(s, \"pass\") == 0)\n return sdef;\n\n s = Copy(s);\t\t\t/* Make a local copy of the typemap code */\n\n locals = Getattr(tm, \"locals\");\n if (locals)\n locals = CopyParmList(locals);\n\n if (pname) {\n if (SwigType_istemplate(pname)) {\n cname = SwigType_namestr(pname);\n pname = cname;\n }\n }\n if (SwigType_istemplate((char *) lname)) {\n clname = SwigType_namestr((char *) lname);\n lname = clname;\n }\n\n if (mtype && SwigType_isarray(mtype)) {\n typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1);\n } else {\n typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);\n }\n\n if (locals && f) {\n typemap_locals(s, locals, f, -1);\n }\n replace_embedded_typemap(s);\n /* {\n String *tmname = Getattr(tm,\"typemap\");\n if (tmname) Replace(s,\"$typemap\",tmname, DOH_REPLACE_ANY);\n } */\n\n Replace(s, \"$name\", pname, DOH_REPLACE_ANY);\n\n symname = Getattr(node, \"sym:name\");\n if (symname) {\n Replace(s, \"$symname\", symname, DOH_REPLACE_ANY);\n }\n\n Setattr(node, tmop_name(op), s);\n if (locals) {\n sprintf(temp, \"%s:locals\", cop);\n Setattr(node, tmop_name(temp), locals);\n Delete(locals);\n }\n\n if (Checkattr(tm, \"type\", \"SWIGTYPE\")) {\n sprintf(temp, \"%s:SWIGTYPE\", cop);\n Setattr(node, tmop_name(temp), \"1\");\n }\n\n /* Attach kwargs */\n kw = Getattr(tm, \"kwargs\");\n while (kw) {\n String *value = Copy(Getattr(kw, \"value\"));\n String *type = Getattr(kw, \"type\");\n char *ckwname = Char(Getattr(kw, \"name\"));\n if (type) {\n String *mangle = Swig_string_mangle(type);\n Append(value, mangle);\n Delete(mangle);\n }\n sprintf(temp, \"%s:%s\", cop, ckwname);\n Setattr(node, tmop_name(temp), value);\n Delete(value);\n kw = nextSibling(kw);\n }\n\n /* Look for warnings */\n {\n String *w;\n sprintf(temp, \"%s:warning\", cop);\n w = Getattr(node, tmop_name(temp));\n if (w) {\n Swig_warning(0, Getfile(node), Getline(node), \"%s\\n\", w);\n }\n }\n\n /* Look for code fragments */\n {\n String *f;\n sprintf(temp, \"%s:fragment\", cop);\n f = Getattr(node, tmop_name(temp));\n if (f) {\n String *fname = Copy(f);\n Setfile(fname, Getfile(node));\n Setline(fname, Getline(node));\n Swig_fragment_emit(fname);\n Delete(fname);\n }\n }\n\n if (cname)\n Delete(cname);\n if (clname)\n Delete(clname);\n if (mtype)\n Delete(mtype);\n if (sdef) {\t\t\t/* put 'ref' and 'newfree' codes together */\n String *p = NewStringf(\"%s\\n%s\", sdef, s);\n Delete(s);\n Delete(sdef);\n s = p;\n }\n return s;\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_attach_kwargs()\n *\n * If this hash (tm) contains a linked list of parameters under its \"kwargs\"\n * attribute, add keys for each of those named keyword arguments to this\n * parameter for later use.\n * For example, attach the typemap attributes to p:\n * %typemap(in, foo=\"xyz\") ...\n * A new attribute called \"tmap:in:foo\" with value \"xyz\" is attached to p.\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {\n String *temp = NewStringEmpty();\n Parm *kw = Getattr(tm, \"kwargs\");\n while (kw) {\n String *value = Copy(Getattr(kw, \"value\"));\n String *type = Getattr(kw, \"type\");\n if (type) {\n Hash *v = NewHash();\n Setattr(v, \"type\", type);\n Setattr(v, \"value\", value);\n Delete(value);\n value = v;\n }\n Clear(temp);\n Printf(temp, \"%s:%s\", op, Getattr(kw, \"name\"));\n Setattr(p, tmop_name(temp), value);\n Delete(value);\n kw = nextSibling(kw);\n }\n Clear(temp);\n Printf(temp, \"%s:match_type\", op);\n Setattr(p, tmop_name(temp), Getattr(tm, \"type\"));\n Delete(temp);\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_warn()\n *\n * If any warning message is attached to this parameter's \"tmap:op:warning\"\n * attribute, print that warning message.\n * ----------------------------------------------------------------------------- */\n\nstatic void Swig_typemap_warn(const String_or_char *op, Parm *p) {\n String *temp = NewStringf(\"%s:warning\", op);\n String *w = Getattr(p, tmop_name(temp));\n Delete(temp);\n if (w) {\n Swig_warning(0, Getfile(p), Getline(p), \"%s\\n\", w);\n }\n}\n\nstatic void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p) {\n String *temp = NewStringf(\"%s:fragment\", op);\n String *f = Getattr(p, tmop_name(temp));\n if (f) {\n String *fname = Copy(f);\n Setfile(fname, Getfile(p));\n Setline(fname, Getline(p));\n Swig_fragment_emit(fname);\n Delete(fname);\n }\n Delete(temp);\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_attach_parms()\n *\n * Given a parameter list, this function attaches all of the typemaps for a\n * given typemap type\n * ----------------------------------------------------------------------------- */\n\nString *Swig_typemap_get_option(Hash *tm, String *name) {\n Parm *kw = Getattr(tm, \"kwargs\");\n while (kw) {\n String *kname = Getattr(kw, \"name\");\n if (Equal(kname, name)) {\n return Getattr(kw, \"value\");\n }\n kw = nextSibling(kw);\n }\n return 0;\n}\n\nvoid Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) {\n Parm *p, *firstp;\n Hash *tm;\n int nmatch = 0;\n int i;\n String *s;\n ParmList *locals;\n int argnum = 0;\n char temp[256];\n char *cop = Char(op);\n String *kwmatch = 0;\n p = parms;\n\n#ifdef SWIG_DEBUG\n Printf(stdout, \"Swig_typemap_attach_parms: %s\\n\", op);\n#endif\n\n while (p) {\n argnum++;\n nmatch = 0;\n#ifdef SWIG_DEBUG\n Printf(stdout, \"parms: %s %s %s\\n\", op, Getattr(p, \"name\"), Getattr(p, \"type\"));\n#endif\n tm = Swig_typemap_search_multi(op, p, &nmatch);\n#ifdef SWIG_DEBUG\n if (tm)\n Printf(stdout, \"found: %s\\n\", tm);\n#endif\n if (!tm) {\n p = nextSibling(p);\n continue;\n }\n /*\n Check if the typemap requires to match the type of another\n typemap, for example:\n\n %typemap(in) SWIGTYPE * (int var) {...}\n %typemap(freearg,match=\"in\") SWIGTYPE * {if (var$argnum) ...}\n\n here, the freearg typemap requires the \"in\" typemap to match,\n or the 'var$argnum' variable will not exist.\n */\n kwmatch = Swig_typemap_get_option(tm, \"match\");\n if (kwmatch) {\n String *tmname = NewStringf(\"tmap:%s\", kwmatch);\n String *tmin = Getattr(p, tmname);\n Delete(tmname);\n#ifdef SWIG_DEBUG\n if (tm)\n\tPrintf(stdout, \"matching: %s\\n\", kwmatch);\n#endif\n if (tmin) {\n\tString *tmninp = NewStringf(\"tmap:%s:numinputs\", kwmatch);\n\tString *ninp = Getattr(p, tmninp);\n\tDelete(tmninp);\n\tif (ninp && Equal(ninp, \"0\")) {\n\t p = nextSibling(p);\n\t continue;\n\t} else {\n\t SwigType *typetm = Getattr(tm, \"type\");\n\t String *temp = NewStringf(\"tmap:%s:match_type\", kwmatch);\n\t SwigType *typein = Getattr(p, temp);\n\t Delete(temp);\n\t if (!Equal(typein, typetm)) {\n\t p = nextSibling(p);\n\t continue;\n\t } else {\n\t int nnmatch;\n\t Hash *tmapin = Swig_typemap_search_multi(kwmatch, p, &nnmatch);\n\t String *tmname = Getattr(tm, \"pname\");\n\t String *tnname = Getattr(tmapin, \"pname\");\n\t if (!(tmname && tnname && Equal(tmname, tnname)) && !(!tmname && !tnname)) {\n\t p = nextSibling(p);\n\t continue;\n\t }\n\t }\n\n\t}\n } else {\n\tp = nextSibling(p);\n\tcontinue;\n }\n }\n\n s = Getattr(tm, \"code\");\n if (!s) {\n p = nextSibling(p);\n continue;\n }\n#ifdef SWIG_DEBUG\n if (s)\n Printf(stdout, \"code: %s\\n\", s);\n#endif\n\n /* Empty typemap. No match */\n if (Cmp(s, \"pass\") == 0) {\n p = nextSibling(p);\n continue;\n }\n\n s = Copy(s);\n locals = Getattr(tm, \"locals\");\n if (locals)\n locals = CopyParmList(locals);\n firstp = p;\n#ifdef SWIG_DEBUG\n Printf(stdout, \"nmatch: %d\\n\", nmatch);\n#endif\n for (i = 0; i < nmatch; i++) {\n SwigType *type;\n String *pname;\n String *lname;\n SwigType *mtype;\n\n\n type = Getattr(p, \"type\");\n pname = Getattr(p, \"name\");\n lname = Getattr(p, \"lname\");\n mtype = Getattr(p, \"tmap:match\");\n\n if (mtype) {\n\ttypemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1);\n\tDelattr(p, \"tmap:match\");\n } else {\n\ttypemap_replace_vars(s, locals, type, type, pname, lname, i + 1);\n }\n\n if (Checkattr(tm, \"type\", \"SWIGTYPE\")) {\n\tsprintf(temp, \"%s:SWIGTYPE\", cop);\n\tSetattr(p, tmop_name(temp), \"1\");\n }\n p = nextSibling(p);\n }\n\n if (locals && f) {\n typemap_locals(s, locals, f, argnum);\n }\n\n replace_embedded_typemap(s);\n\n /* Replace the argument number */\n sprintf(temp, \"%d\", argnum);\n Replace(s, \"$argnum\", temp, DOH_REPLACE_ANY);\n\n /* Attach attributes to object */\n#ifdef SWIG_DEBUG\n Printf(stdout, \"attach: %s %s %s\\n\", Getattr(firstp, \"name\"), tmop_name(op), s);\n#endif\n Setattr(firstp, tmop_name(op), s);\t/* Code object */\n\n if (locals) {\n sprintf(temp, \"%s:locals\", cop);\n Setattr(firstp, tmop_name(temp), locals);\n Delete(locals);\n }\n\n /* Attach a link to the next parameter. Needed for multimaps */\n sprintf(temp, \"%s:next\", cop);\n Setattr(firstp, tmop_name(temp), p);\n\n /* Attach kwargs */\n Swig_typemap_attach_kwargs(tm, op, firstp);\n\n /* Print warnings, if any */\n Swig_typemap_warn(op, firstp);\n\n /* Look for code fragments */\n Swig_typemap_emit_code_fragments(op, firstp);\n\n /* increase argnum to consider numinputs */\n argnum += nmatch - 1;\n Delete(s);\n#ifdef SWIG_DEBUG\n Printf(stdout, \"res: %s %s %s\\n\", Getattr(firstp, \"name\"), tmop_name(op), Getattr(firstp, tmop_name(op)));\n#endif\n\n }\n#ifdef SWIG_DEBUG\n Printf(stdout, \"Swig_typemap_attach_parms: end\\n\");\n#endif\n\n}\n\n/* -----------------------------------------------------------------------------\n * split_embedded()\n *\n * This function replaces the special variable $typemap(....) with typemap\n * code. The general form of $typemap is as follows:\n *\n * $TYPEMAP(method, $var1=value, $var2=value, $var3=value,...)\n *\n * For example:\n *\n * $TYPEMAP(in, $1=int x, $input=y, ...)\n *\n * Note: this was added as an experiment and could be removed\n * ----------------------------------------------------------------------------- */\n\n/* Splits the arguments of an embedded typemap */\nstatic List *split_embedded(String *s) {\n List *args = 0;\n char *c, *start;\n int level = 0;\n int leading = 1;\n args = NewList();\n\n c = strchr(Char(s), '(');\n c++;\n\n start = c;\n while (*c) {\n if (*c == '\\\"') {\n c++;\n while (*c) {\n\tif (*c == '\\\\') {\n\t c++;\n\t} else {\n\t if (*c == '\\\"')\n\t break;\n\t}\n\tc++;\n }\n }\n if ((level == 0) && ((*c == ',') || (*c == ')'))) {\n String *tmp = NewStringWithSize(start, c - start);\n Append(args, tmp);\n Delete(tmp);\n start = c + 1;\n leading = 1;\n if (*c == ')')\n\tbreak;\n c++;\n continue;\n }\n if (*c == '(')\n level++;\n if (*c == ')')\n level--;\n if (isspace((int) *c) && leading)\n start++;\n if (!isspace((int) *c))\n leading = 0;\n c++;\n }\n return args;\n}\n\nstatic void split_var(String *s, String **name, String **value) {\n char *eq;\n char *c;\n\n eq = strchr(Char(s), '=');\n if (!eq) {\n *name = 0;\n *value = 0;\n return;\n }\n c = Char(s);\n *name = NewStringWithSize(c, eq - c);\n\n /* Look for $n variables */\n if (isdigit((int) *(c))) {\n /* Parse the value as a type */\n String *v;\n Parm *p;\n v = NewString(eq + 1);\n p = Swig_cparse_parm(v);\n Delete(v);\n *value = p;\n } else {\n *value = NewString(eq + 1);\n }\n}\n\nstatic void replace_embedded_typemap(String *s) {\n char *start = 0;\n while ((start = strstr(Char(s), \"$TYPEMAP(\"))) {\n\n /* Gather the argument */\n char *end = 0, *c;\n int level = 0;\n String *tmp;\n c = start;\n while (*c) {\n if (*c == '(')\n\tlevel++;\n if (*c == ')') {\n\tlevel--;\n\tif (level == 0) {\n\t end = c + 1;\n\t break;\n\t}\n }\n c++;\n }\n if (end) {\n tmp = NewStringWithSize(start, (end - start));\n } else {\n tmp = 0;\n }\n\n /* Got a substitution. Split it apart into pieces */\n if (tmp) {\n List *l;\n Hash *vars;\n String *method;\n int i, ilen;\n\n l = split_embedded(tmp);\n vars = NewHash();\n ilen = Len(l);\n for (i = 1; i < ilen; i++) {\n\tString *n, *v;\n\tsplit_var(Getitem(l, i), &n, &v);\n\tif (n && v) {\n\t Insert(n, 0, \"$\");\n\t Setattr(vars, n, v);\n\t}\n\tDelete(n);\n\tDelete(v);\n }\n\n method = Getitem(l, 0);\n /* Generate the parameter list for matching typemaps */\n\n {\n\tParm *p = 0;\n\tParm *first = 0;\n\tchar temp[32];\n\tint n = 1;\n\twhile (1) {\n\t Hash *v;\n\t sprintf(temp, \"$%d\", n);\n\t v = Getattr(vars, temp);\n\t if (v) {\n\t if (p) {\n\t set_nextSibling(p, v);\n\t set_previousSibling(v, p);\n\t }\n\t p = v;\n\t Setattr(p, \"lname\", Getattr(p, \"name\"));\n\t if (Getattr(p, \"value\")) {\n\t Setattr(p, \"name\", Getattr(p, \"value\"));\n\t }\n\t if (!first)\n\t first = p;\n\t DohIncref(p);\n\t Delattr(vars, temp);\n\t } else {\n\t break;\n\t }\n\t n++;\n\t}\n\t/* Perform a typemap search */\n\tif (first) {\n#ifdef SWIG_DEBUG\n\t Printf(stdout, \"Swig_typemap_attach_parms: embedded\\n\");\n#endif\n\t Swig_typemap_attach_parms(method, first, 0);\n\t {\n\t String *tm;\n\t int match = 0;\n\t char attr[64];\n\t sprintf(attr, \"tmap:%s\", Char(method));\n\n\t /* Look for the typemap code */\n\t tm = Getattr(first, attr);\n\t if (tm) {\n\t sprintf(attr, \"tmap:%s:next\", Char(method));\n\t if (!Getattr(first, attr)) {\n\t\t/* Should be no more matches. Hack??? */\n\t\t/* Replace all of the remaining variables */\n\t\tIterator ki;\n\t\tfor (ki = First(vars); ki.key; ki = Next(ki)) {\n\t\t Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY);\n\t\t}\n\t\t/* Do the replacement */\n\t\tReplace(s, tmp, tm, DOH_REPLACE_ANY);\n\t\tDelete(tm);\n\t\tmatch = 1;\n\t }\n\t }\n\t if (!match) {\n\t Swig_error(Getfile(s), Getline(s), \"No typemap found for %s\\n\", tmp);\n\t }\n\t }\n\t}\n }\n Replace(s, tmp, \"\", DOH_REPLACE_ANY);\n Delete(vars);\n Delete(tmp);\n Delete(l);\n }\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Swig_typemap_debug()\n * ----------------------------------------------------------------------------- */\n\nvoid Swig_typemap_debug() {\n int ts;\n Printf(stdout, \"---[ typemaps ]--------------------------------------------------------------\\n\");\n\n ts = tm_scope;\n while (ts >= 0) {\n Printf(stdout, \"::: scope %d\\n\\n\", ts);\n Printf(stdout, \"%s\\n\", typemaps[ts]);\n ts--;\n }\n Printf(stdout, \"-----------------------------------------------------------------------------\\n\");\n}\n/********************************************************************\r\n\tcreated:\t2007/12/12\r\n\tcreated:\t12:12:2007 11:55\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\\CustomPlayerStructs.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\r\n\tfile base:\tCustomPlayerStructs\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __CUSTOM_PLAYER_STRUCTS_H_\r\n#define __CUSTOM_PLAYER_STRUCTS_H_\r\n\r\nnamespace vtPlayer\r\n{\r\n\r\n\tnamespace Structs\r\n\t{\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//managers,... : \r\n\t\tstruct xSEnginePointers\r\n\t\t{\r\n\r\n\t\t\tCKContext*\t\t TheCKContext;\r\n\t\t\tCKTimeManager*\t TheTimeManager;\r\n\t\t\tCKMessageManager* TheMessageManager;\r\n\t\t\tCKRenderManager* TheRenderManager;\r\n\t\t\tCKRenderContext* TheRenderContext;\r\n\t\t\tCKPluginManager* ThePluginManager;\r\n\t\t\t\r\n\t\t\txSEnginePointers() : TheCKContext(0),TheTimeManager(0),TheMessageManager(0),\r\n\t\t\t\tTheRenderManager(0),TheRenderContext(0),ThePluginManager(0)\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t}\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//player modies : \r\n\t\tenum xEApplicationMode\r\n\t\t{\r\n\t\t\tconfig, // Config dialog box\r\n\t\t\tpreview, // Mini preview window in Display Properties dialog\r\n\t\t\tnormal, // Full-on screensaver mode\r\n\t\t\tpasswordchange,\r\n\t\t\tjava,\r\n\t\t\tdecompress,\r\n\t\t\tstatic_res,\r\n\t\t\tpopup\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//Paths : \r\n\t\tclass xSEnginePaths\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tXString RenderPath;\r\n\t\t\tXString ManagerPath;\r\n\t\t\tXString BehaviorPath;\r\n\t\t\tXString PluginPath;\r\n\t\t\tXString CompositionFile;\r\n\t\t\tXString DecompressFile;\r\n\t\t\tXString ConfigFile;\r\n\t\t\tXString ApplicationProfileFile;\r\n\t\t\tXString InstallDirectory;\r\n\r\n\t\t\tvirtual ~xSEnginePaths(){}\r\n\r\n\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//Engine Parameters:\r\n\t\tstruct xSEngineWindowInfo{\r\n\r\n\t\t\tint\t\t\t\t g_FullScreenDriver;\r\n\t\t\tint\t\t\t\t g_Mode;\r\n\t\t\tBOOL\tg_DisableSwitch;\r\n\t\t\tBOOL\tg_NoContextMenu;\r\n\t\t\tBOOL\tg_GoFullScreen;\r\n\t\t\tint\tg_RefreshRate;\r\n\t\t\tint\tg_WidthW;\r\n\t\t\tint\tg_HeightW;\r\n\t\t\tint\tg_Width;\r\n\t\t\tint\tg_Height;\r\n\t\t\tint\tg_Bpp;\r\n\t\t\tint g_Driver;\r\n\t\t\tint FSSA;\r\n\t\t\tBOOL g_HasResMask;\r\n\r\n\t\t\ttypedef XArray xSResMaskArray;\r\n\t\t\txSResMaskArray g_ResMaskArrayX;\r\n\t\t\txSResMaskArray g_ResMaskArrayY;\r\n\r\n\t\t\ttypedef XArray xSAllowedOpenGLVersions;\r\n\t\t\txSAllowedOpenGLVersions g_OpenGLMask;\r\n\r\n\t\t\txSEngineWindowInfo() : \r\n\t\t\tg_FullScreenDriver(0),\r\n\t\t\t\tg_Mode(0),\r\n\t\t\t\tg_DisableSwitch(false),\r\n\t\t\t\tg_NoContextMenu(false),\r\n\t\t\t\tg_GoFullScreen(false),\r\n\t\t\t\tg_RefreshRate(g_Width),\r\n\t\t\t\tg_Width(1024),\r\n\t\t\t\tg_Height(768),\r\n\t\t\t\tg_Bpp(32),\r\n\t\t\t\tg_Driver(0),\r\n\t\t\t\tFSSA(0){}\r\n\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//Application Style\r\n\t\tclass xSApplicationWindowStyle\r\n\t\t{\r\n\r\n\t\tpublic:\r\n\t\t\tint g_MouseDrag;\r\n\t\t\tint g_OwnerDrawed;\r\n\t\t\tint g_Render;\r\n\t\t\tint IsRenderering() const { return g_Render; }\r\n\t\t\tint g_Sound;\r\n\t\t\tint g_CaptionBar;\r\n\t\t\tint g_IsResizeable;\r\n\t\t\tint g_SizeBox;\r\n\t\t\tint g_AOT;\r\n\t\t\tXString g_AppTitle;\r\n\t\t\tXString AppTitle() const { return g_AppTitle; }\r\n\t\t\tint g_SSMode;\r\n\t\t\tint g_MMT;\r\n\t\t\tBOOL g_UseSplash;\r\n\t\t\tBOOL g_ShowLoadingProcess;\r\n\t\t\tBOOL g_AllowEscExit;\r\n\t\t\tint g_ShowDialog;\r\n\t\t\tint g_ShowAboutTab;\r\n\t\t\tint g_ShowConfigTab;\r\n\t\t\tint g_MinimumDirectXVersion;\r\n\t\t\tint g_MiniumumRAM;\r\n\t\t\tBOOL ShowLoadingProcess() const { return g_ShowLoadingProcess; }\r\n\t\t\tBOOL UseSplash() const { return g_UseSplash; }\r\n\r\n\t\t\txSApplicationWindowStyle() : \r\n\t\t\tg_Render(0),\r\n\t\t\tg_CaptionBar(0),\r\n\t\t\tg_IsResizeable(0),\r\n\t\t\tg_SizeBox(0),\r\n g_AOT(0),\r\n\t\t\tg_SSMode(0),\r\n\t\t\tg_MMT(0),\r\n\t\t\tg_ShowDialog(0),\r\n\t\t\tg_ShowAboutTab(0),\r\n\t\t\tg_ShowConfigTab(0),\r\n\t\t\tg_MinimumDirectXVersion(9),\r\n\t\t\tg_MiniumumRAM(256),\r\n\t\t\tg_UseSplash(false),\r\n\t\t\tg_AllowEscExit(false)\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\r\n\t\t\tvirtual ~xSApplicationWindowStyle()\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\t\t};\r\n\t}\t//end of namespace structs\r\n}\t//end of namespace structs\r\n\r\nusing namespace vtPlayer::Structs;\r\n\r\n#endif/* ----------------------------------------------------------------------------- \n * See the LICENSE file for information on copyright, usage and redistribution\n * of SWIG, and the README file for authors - http://www.swig.org/release.html.\n *\n * utils.cxx\n *\n * Various utility functions.\n * ----------------------------------------------------------------------------- */\n\nchar cvsroot_utils_cxx[] = \"$Id: utils.cxx 10003 2007-10-17 21:42:11Z wsfulton $\";\n\n#include \n\nint is_public(Node *n) {\n String *access = Getattr(n, \"access\");\n return !access || !Cmp(access, \"public\");\n}\n\nint is_private(Node *n) {\n String *access = Getattr(n, \"access\");\n return access && !Cmp(access, \"private\");\n}\n\nint is_protected(Node *n) {\n String *access = Getattr(n, \"access\");\n return access && !Cmp(access, \"protected\");\n}\n\nint is_member_director(Node *parentnode, Node *member) {\n int director_mode = Swig_director_mode();\n\n if (parentnode && checkAttribute(member, \"storage\", \"virtual\")) {\n int parent_nodirector = GetFlag(parentnode, \"feature:nodirector\");\n if (parent_nodirector)\n return 0;\n int parent_director = director_mode && GetFlag(parentnode, \"feature:director\");\n int cdecl_director = parent_director || GetFlag(member, \"feature:director\");\n int cdecl_nodirector = GetFlag(member, \"feature:nodirector\");\n return cdecl_director && !cdecl_nodirector && !GetFlag(member, \"feature:extend\");\n } else {\n return 0;\n }\n}\n\nint is_member_director(Node *member) {\n return is_member_director(Getattr(member, \"parentNode\"), member);\n}\n\n\n/* Clean overloaded list. Removes templates, ignored, and errors */\n\nvoid clean_overloaded(Node *n) {\n Node *nn = Getattr(n, \"sym:overloaded\");\n Node *first = 0;\n int cnt = 0;\n while (nn) {\n String *ntype = nodeType(nn);\n if ((GetFlag(nn, \"feature:ignore\")) ||\n\t(Getattr(nn, \"error\")) ||\n\t(Strcmp(ntype, \"template\") == 0) ||\n\t((Strcmp(ntype, \"cdecl\") == 0) && is_protected(nn) && !is_member_director(nn)) || ((Strcmp(ntype, \"using\") == 0) && !firstChild(nn))) {\n /* Remove from overloaded list */\n Node *ps = Getattr(nn, \"sym:previousSibling\");\n Node *ns = Getattr(nn, \"sym:nextSibling\");\n if (ps) {\n\tSetattr(ps, \"sym:nextSibling\", ns);\n }\n if (ns) {\n\tSetattr(ns, \"sym:previousSibling\", ps);\n }\n Delattr(nn, \"sym:previousSibling\");\n Delattr(nn, \"sym:nextSibling\");\n Delattr(nn, \"sym:overloaded\");\n nn = ns;\n continue;\n } else if ((Strcmp(ntype, \"using\") == 0)) {\n /* A possibly dangerous parse tree hack. We're going to\n cut the parse tree node out and stick in the resolved\n using declarations */\n\n Node *ps = Getattr(nn, \"sym:previousSibling\");\n Node *ns = Getattr(nn, \"sym:nextSibling\");\n Node *un = firstChild(nn);\n Node *pn = un;\n\n if (!first) {\n\tfirst = un;\n }\n while (pn) {\n\tNode *ppn = Getattr(pn, \"sym:nextSibling\");\n\tSetattr(pn, \"sym:overloaded\", first);\n\tSetattr(pn, \"sym:overname\", NewStringf(\"%s_%d\", Getattr(nn, \"sym:overname\"), cnt++));\n\tif (ppn)\n\t pn = ppn;\n\telse\n\t break;\n }\n if (ps) {\n\tSetattr(ps, \"sym:nextSibling\", un);\n\tSetattr(un, \"sym:previousSibling\", ps);\n }\n if (ns) {\n\tSetattr(ns, \"sym:previousSibling\", pn);\n\tSetattr(pn, \"sym:nextSibling\", ns);\n }\n if (!first) {\n\tfirst = un;\n\tSetattr(nn, \"sym:overloaded\", first);\n }\n } else {\n if (!first)\n\tfirst = nn;\n Setattr(nn, \"sym:overloaded\", first);\n }\n nn = Getattr(nn, \"sym:nextSibling\");\n }\n if (!first || (first && !Getattr(first, \"sym:nextSibling\"))) {\n Delattr(n, \"sym:overloaded\");\n }\n}\n#include \"xDistributedObject.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xNetInterface.h\"\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \r\n\r\n#include \r\n\r\n\r\nuxString\r\nxDistributedObject::print(TNL::BitSet32 flags)\r\n{\r\n\r\n\tusing namespace std;\r\n\tuxString result(\" \");\r\n\tchar buffer[4096];\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//name ? \r\n\tif (isFlagOn(flags,E_OPF_NAME))\r\n\t{\r\n\t\tresult << \" Name:\" << GetName().getString();\r\n\t}\r\n\t\r\n\r\n\t\r\n\t//ghostID\r\n\tif (isFlagOn(flags,E_OPF_GHOST_ID))\r\n\t{\r\n\t\tresult << \" GhostID:\";\r\n\t\tint gID = getOwnerConnection() ? getOwnerConnection()->getGhostIndex((TNL::NetObject*)this) :-1 ;\r\n\t\tresult <getClassName().getString() : \"NOCLASS\");\r\n\t\tint EType = getDistributedClass() ? getDistributedClass()->getEnitityType() : -1;\r\n\t\tresult << \" : EType:\" << EType;\r\n\t}\r\n\t\r\n\t//SessionID?\r\n\tif (isFlagOn(flags,E_OPF_SESSION_ID))\r\n\t{\r\n\t\tresult << \" SessionID:\" << getSessionID();\r\n\t}\r\n\r\n\r\n\treturn result;\r\n\t//TNL::logprintf(result.CStr());\r\n//\txLogger::xLogExtro(0,\"UserName : %s \\n\\tSessionID:%d \\n\\tIsJoined:%d \\n\\tGhostIndex:%d\",sobj->getUserName().getString(),sobj->getSessionID(),isFlagOn(sobj->getClientFlags(),E_CF_SESSION_JOINED) ? 1 : 0,gIndex );\r\n\r\n\r\n}\r\n\r\nTNL::U32 \r\nxDistributedObject::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream)\r\n{\r\n\r\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\r\n\t//write out name :\r\n\tconst char* name = GetName().getString();\r\n\tstream->writeString(name,strlen(name));\r\n\t//write class : \r\n\txDistributedClass *distClass = getDistributedClass();\r\n\tif (distClass)\r\n\t{\r\n\t\t//write out the class name : \r\n\t\tstream->writeString(distClass->getClassName().getString());\r\n\t\t//write out the class base type : \r\n\t\tstream->writeInt(distClass->getEnitityType(),32);\r\n\r\n\t}else\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_DISTRIBUTED_BASE_OBJECT,\"initial pack : no class found\");\r\n\t\r\n\t//write user id\r\n\tstream->writeInt(getUserID(),32);\r\n\t//write session id \r\n\tstream->writeInt(getSessionID(),32);\r\n\r\n\tsetNetInterface(netInterface);\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_DISTRIBUTED_BASE_OBJECT,\"initial pack\");\r\n\r\n\treturn 0;\r\n}\r\n\r\n\r\nvoid \r\nxDistributedObject::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)\r\n{\r\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tvtConnection *vconnection = (vtConnection*)connection;\r\n\r\n\tchar oName[256];stream->readString(oName);\t// retrieve objects name : \r\n\tchar cName[256];stream->readString(cName);\t// retrieve objects dist class name : \r\n\tint type = stream->readInt(32);\t\t\r\n\t\r\n\tsetUserID(stream->readInt(32));\r\n\tsetSessionID(stream->readInt(32));\r\n\tSetName(oName);\r\n\t\r\n\t\r\n\t//find and store the dist class : \r\n\txDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\txDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName);\r\n\tif (!classTemplate)\r\n\t{\r\n\t\tclassTemplate = netInterface->getDistributedClassInterface()->createClass(cName,type);\r\n\t}else\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_DISTRIBUTED_BASE_OBJECT,\"initial unpack : no class found\");\r\n\tsetDistributedClass(classTemplate);\r\n\t\r\n\t\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_DISTRIBUTED_BASE_OBJECT,\"initial unpack\");\r\n\t\r\n\tsetNetInterface(netInterface);\r\n\r\n\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty* xDistributedObject::getProperty(int nativeType)\r\n{\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (prop->getPropertyInfo()->mNativeType == nativeType)\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedProperty* xDistributedObject::getUserProperty(const char*name)\r\n{\r\n\txDistributedProperty* result = NULL;\r\n\tif (getDistributedClass())\r\n\t{\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertyArrayType &props = *getDistributedPorperties();\r\n\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = props[i];\r\n\r\n\t\t\tif (!strcmp(prop->getPropertyInfo()->mName.getString(),name))\r\n\t\t\t{\r\n\t\t\t\treturn prop;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedObject::onGhostAvailable(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\tIDistributedObjects *distInterface = netInterface->getDistObjectInterface();\r\n\t\t\tif (distInterface)\r\n\t\t\t{\r\n\t\t\t\tsetServerID(theConnection->getGhostIndex(this));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool xDistributedObject::onGhostAdd(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\tdistObjects->push_back(this);\r\n\t\t\tsetNetInterface(netInterface);\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nvoid\r\nxDistributedObject::writeControlState(xNStream *stream)\r\n{\r\n\t\r\n}\r\n\r\nvoid\r\nxDistributedObject::changeOwnership(int newUserID,int state)\r\n{\r\n\r\n\tsetUserID(newUserID);\r\n\t\r\n\tif (newUserID == getUserID())\r\n\t{\r\n\t\tsetOwnershipState(E_DO_OS_OWNER);\r\n\t}\r\n\r\n\tif (newUserID !=getUserID())\r\n\t{\r\n\t\tsetOwnershipState(E_DO_OS_OTHER);\r\n\t}\r\n\r\n}\r\n\r\nvoid\r\nxDistributedObject::getOwnership()\r\n{\r\n\tgetOwnershipState().set( 1<< E_DO_OS_REQUEST,true );\r\n/*\r\n\t\txNetInterface *nInterface = getNetInterface();\r\n\t\tif (nInterface)\r\n\t\t{\r\n\t\t\tif (nInterface->isValid())\r\n\t\t\t{\r\n\t\t\t\tnInterface->getConnection()->c2sDORequestOwnerShip()\r\n\t\t\t}\r\n\t\t}*/\r\n\t\r\n\r\n\t/*\r\n\tif ( && getOwnershipState() !=E_DO_OS_REQUEST)\r\n\t{\r\n\t\tsetOwnershipState(E_DO_OS_REQUEST);\r\n\t}\r\n\t*/\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributedObject::pack(xNStream *bstream)\r\n{\r\n\tbstream->writeSignedInt(this->getUpdateBits().getMask(),32);\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedObject::unpack( xNStream *bstream,float sendersOneWayTime )\r\n{\r\n\tint uFlags = bstream->readSignedInt(32);\r\n\tsetUpdateBits(uFlags);\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributedObject::prepare()\r\n{\r\n\t//TNL::PacketStream stream;\n\t/*pack(&stream);\n\tstream.setBytePosition(0);\n\tunpack(&stream);*/\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributedObject::initProperties()\r\n{\r\n \r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we iterate through the dist classes properties\r\n\tif (getDistributedClass())\r\n\t{\r\n\r\n\t\txDistributedClass *_class = getDistributedClass();\r\n\t\txDistributedPropertiesListType *props = _class->getDistributedProperties();\r\n\t\tif (props)\r\n\t\t{\r\n\r\n\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributed3DObject* xDistributedObject::cast(xDistributedObject* _in){ return static_cast(_in); }\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributedObject::destroy()\r\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\txDistObjectIt begin = distObjects->begin();\r\n\t\txDistObjectIt end = distObjects->end();\r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\tif (*begin==this)\r\n\t\t\t{\r\n\t\t\t\tdistObjects->erase(begin);\r\n\t\t\t}\r\n\t\t\tbegin++;\r\n\t\t}\r\n\t}\r\n\tParent::Destroy();\r\n\tm_DistributedClass=NULL;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject::xDistributedObject() : xNetObject()\r\n{\r\n\tm_DistributedClass=NULL;\r\n\tm_EntityID = 0;\r\n\tm_InterfaceFlags =0;\r\n\tm_ObjectFlags = 0;\r\n\tm_UpdateFlags = 0;\r\n\tm_UpdateState = 0;\r\n\tm_GhostDebugID = 0;\r\n\tm_GhostUpdateBits = 0;\r\n\tm_DistrtibutedPorperties = new xDistributedPropertyArrayType(); \r\n\tm_OwnershipState.clear();\r\n\tmSessionID = -1;\r\n\tmObjectStateFlags =0;\r\n\r\n\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedObject::~xDistributedObject()\r\n{\r\n\r\n\tParent::Destroy();\r\n\r\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\n/*\nvoid xDistributedObject::performScopeQuery(TNL::GhostConnection *connection)\n{\r\n\t\r\n\r\n\txNetInterface *netInterface = GetNetInterface();\r\n\tif (!netInterface)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tvtDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\tif (!distObjects)\r\n\t{ \r\n\t\treturn;\r\n\t}\r\n\tvtDistObjectIt begin = distObjects->begin();\r\n\tvtDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\txDistributedObject*dobject = *begin;\r\n\t\tif (dobject)\r\n\t\t{\t\r\n\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}*/\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\n/*\nvoid xDistributedObject::onGhostAvailable(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\tIDistributedObjects *distInterface = netInterface->getDistObjectInterface();\r\n\t\t\tif (distInterface)\r\n\t\t\t{\r\n\t\t\t\t//cast a dist object :\r\n//\t\t\t\txDistributedObject *distObject = static_cast(this);\r\n//\t\t\t\tconst char *className =distObject->GetDistributedClass()->ClassName().CStr();\r\n\t\t\t\t//distInterface->cCreateDistObject(distObject->GetServerID(),this->GetUserID(),this->GetName().getString(),className);\r\n\t\t\t\tlogprintf(\"OnGhostAdd\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}*/\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\n/*\r\nbool xDistributedObject::onGhostAdd(TNL::GhostConnection *theConnection)\r\n{\r\n\t\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\tvtDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\tdistObjects->PushBack(this);\r\n\t\t\tSetNetInterface(netInterface);\r\n\t\t\tlogprintf(\"OnGhostAdd\");\r\n\t\t\r\n\t\t}\r\n\t}\r\n\treturn TRUE;\r\n}\n*/\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\n/*\nTNL::U32 \nxDistributedObject::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, xNStream *stream)\n{\r\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\r\n\t\t//server side only : \r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\t//the first time ? : we write out all necessary attributes for the client : \r\n\t\t\tif(stream->writeFlag(updateMask & InitialMask))\n\t\t\t{\r\n\t\t\t\t//write out name :\r\n\t\t\t\tconst char* name = this->GetName().getString();\r\n\t\t\t\tstream->writeString(name,strlen(name));\r\n\t\t\t\t//retrieve its class : \r\n\t\t\t\txDistributedClass *distClass = GetDistributedClass();\r\n\t\t\t\tif (distClass)\r\n\t\t\t\t{\r\n\t\t\t\t\t//write out the class name : \r\n\t\t\t\t\tstream->writeString(distClass->ClassName().CStr());\r\n\t\t\t\t\t//write out the class base type : \r\n\t\t\t\t\tstream->writeSignedInt(distClass->GetEnitityType(),16);\r\n\t\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\tstream->writeSignedInt(con->GetUserID(),16);\r\n\t\t\t\t\t\r\n\t\t\t\t}else\r\n\t\t\t\t{\r\n\t\t\t\t\t//write out the class name : \r\n\t\t\t\t\tstream->writeString(\"NOCLASS\");\r\n\t\t\t\t\t//write out the class base type : \r\n\t\t\t\t\tstream->writeSignedInt(100,16);\r\n\t\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\tstream->writeSignedInt(con->GetUserID(),16);\r\n\t\t\t\t}\r\n\t\t\t\tlogprintf(\"server:init pack update\");\r\n\t\t\t\tSetNetInterface(netInterface);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n*/\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n/*\r\nvoid \nxDistributedObject::unpackUpdate(TNL::GhostConnection *connection, xNStream *stream)\n{\n\r\n\t\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\t//client side only : \r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//initial update ? \r\n\t\t\tif(stream->readFlag())\n\t\t\t{\r\n\r\n\t\t\t\tchar oName[256];stream->readString(oName);\t// retrieve objects name : \r\n\t\t\t\tchar cName[256];stream->readString(cName);\t// retrieve objects dist class name : \r\n\t\t\t\tint type = stream->readInt(16);\t\t\t\t\t\t\t//read the dist class base type : \r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//now we store all in the dist object :\r\n\t\t\t\tSetName(oName);\r\n\r\n\t\t\t\t//find and store the dist class : \r\n\t\t\t\tXDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\t\t\t\txDistributedClass *classTemplate = NULL;\r\n\t\t\t\txDistClassIt it = _classes->Find(cName);\r\n\t\t\t\tif (it != _classes->End())\r\n\t\t\t\t{\r\n\t\t\t\t\tclassTemplate = *it;\r\n\t\t\t\t\t//store the class :\r\n\t\t\t\t\t//distObject->SetDistributedClass(classTemplate);\r\n\t\t\t\t}\r\n\t\t\t\t//store server id : \r\n\t\t\t\tint serverID = connection->getGhostIndex((NetObject*)this);\r\n\t\t\t\tSetServerID(serverID);\r\n\t\t\t\tSetObjectFlags(E_DO_CREATION_CREATED);\r\n\r\n\t\t\t\tthis->SetNetInterface(netInterface);\r\n\r\n\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\tint userID = stream->readInt(16);\t\r\n\t\t\t\tSetUserID(userID);\r\n\r\n\t\t\t\tlogprintf(\"DO initial update received by server : %s | class : %s\",oName,cName );\r\n\t\t\t\t//store it in our array : \r\n\t\t\t\t//vtDistributedObjectsArrayType *distObjects = netInterface->GetDistributedObjects();\r\n\t\t\t\t//distObjects->PushBack(distObject);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n*/\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorJD6SetDriveDecl();\r\nCKERROR CreateJD6SetDriveProto(CKBehaviorPrototype **pproto);\r\nint JD6SetDrive(const CKBehaviorContext& behcontext);\r\nCKERROR JD6SetDriveCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyA=0,\r\n\tbbI_BodyB,\r\n\tbbI_Anchor,\r\n\tbbI_AnchorRef,\r\n\tbbI_Axis,\r\n\tbbI_AxisRef\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJD6SetDriveDecl\r\n// FullName: FillBehaviorJD6SetDriveDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJD6SetDriveDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJD6SetDrive\");\t\r\n\tod->SetCategory(\"Physic/D6\");\r\n\tod->SetDescription(\"Modifies the D6 drive.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2db16c45,0x695938e4));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJD6SetDriveProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJD6SetDriveProto\r\n// FullName: CreateJD6SetDriveProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJD6SetDriveProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJD6SetDrive\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PJD6SetDrive\r\n\r\n\t
\r\n\tPJD6SetDrive is categorized in \\ref D6BB\r\n\t
\r\n\t
See PJD6.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies a linear or an angular drive.\r\n\t
\r\n\t
\r\n\t

Technical Information

\r\n\r\n\t\\image html PJD6SetDrive.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body to identfy the joint.\r\n\t
\r\n\t
\r\n\r\n\tTarget Drive: The target drive. See #D6DriveAxis.\r\n\t
\r\n\tDrive: Holds drive settings. See #pJD6Drive. \r\n\t
\r\n\t\r\n\tSee \\ref D6AngularDrivesGuide \"Angular Drives\"
\r\n\t\r\n\tSee \\ref D6LinearDrivesGuide \"Linear Drives\"
\r\n\r\n\r\n\t\r\n*/\r\n\t\r\n\tproto->SetBehaviorCallbackFct( JD6SetDriveCB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Target Drive\",VTE_JOINT_DRIVE_AXIS,0);\r\n\tproto->DeclareInParameter(\"Drive\",VTS_JOINT_DRIVE);\r\n\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JD6SetDrive);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JD6SetDrive\r\n// FullName: JD6SetDrive\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JD6SetDrive(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointD6 *joint =static_cast(worldA->getJoint(target,targetB,JT_D6));\r\n\t\t\tD6DriveAxis targetDrive = GetInputParameterValue(beh,1); \r\n\t\t\tpJD6Drive drive;\r\n\r\n\r\n\t\t\tCKParameter* pout = beh->GetInputParameter(2)->GetRealSource();\r\n\t\t\tCK_ID* ids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\tfloat damping,spring,forceLimit;\r\n\t\t\tint driveMode;\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[0]);\r\n\t\t\tpout->GetValue(&damping);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[1]);\r\n\t\t\tpout->GetValue(&spring);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[2]);\r\n\t\t\tpout->GetValue(&forceLimit);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[3]);\r\n\t\t\tpout->GetValue(&driveMode);\r\n\r\n\r\n\t\t\tdrive.damping = damping;\r\n\t\t\tdrive.spring = spring;\r\n\t\t\tdrive.driveType = driveMode;\r\n\t\t\tdrive.forceLimit = forceLimit;\r\n\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tswitch(targetDrive)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tcase D6DA_Twist:\r\n\t\t\t\t\t\tjoint->setTwistDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6DA_Swing:\r\n\t\t\t\t\t\tjoint->setSwingDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6DA_Slerp:\r\n\t\t\t\t\t\tjoint->setSlerpDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6DA_X:\r\n\t\t\t\t\t\tjoint->setXDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6DA_Y:\r\n\t\t\t\t\t\tjoint->setYDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6DA_Z:\r\n\t\t\t\t\t\tjoint->setZDrive(drive);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JD6SetDriveCB\r\n// FullName: JD6SetDriveCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JD6SetDriveCB(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pVehicleMotor.h\"\r\n#include \"pVehicleGears.h\"\r\n#include \"pSteer.h\"\r\n#include \"pGearbox.h\"\r\n#include \r\n#include \"NxArray.h\"\r\n\r\n#include \"pVehicleAll.h\"\r\n\r\n\r\n#include \"virtools/vtTools.h\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\nusing namespace vtTools::BehaviorTools;\r\n\r\nvoid pVehicle::step(float dt)\r\n{\r\n\r\n\r\n\tif (isValidEngine())\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// update user controls\r\n\t\t//\r\n\t\tsteer->SetInput(_cSteering);doSteering();\r\n\r\n\t\tengine->updateUserControl(_cAcceleration);\r\n\r\n\t\tif (\t(_currentStatus & VS_IsAcceleratedForward ) ||\r\n\t\t\t(_currentStatus & VS_IsAcceleratedBackward)\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tdriveLine->SetInput(1000.0f,_cHandbrake);\r\n\t\t}\r\n\t\tif (!(_currentStatus & VS_IsAccelerated) )\r\n\t\t{\r\n\t\t\tdriveLine->SetInput(0.0f,_cHandbrake);\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// \r\n\t\t//\r\n\r\n\t\tpreAnimate();\r\n\t\t\r\n\t\t\r\n\t\tengine->CalcForces();\r\n\t\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t\t{\r\n\t\t\tpWheel2 *cW = (pWheel2*)_wheels[i];\r\n\t\t\tif (cW->isAxleSpeedFromVehicle() || cW->isTorqueFromVehicle() )\r\n\t\t\t\tcW->calcForces();\r\n\t\t}\r\n\r\n\t\tdriveLine->CalcForces();\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\n\t\t\t// Now that engine and wheel forces are unknown, check the diffs\n\t\t\tfor(int i=0;iCalcForces();\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tdriveLine->CalcAccelerations();\r\n\r\n\r\n\t\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t\t{\r\n\t\t\tpWheel2 *cW = (pWheel2*)_wheels[i];\r\n\t\t\tif (cW->isAxleSpeedFromVehicle() || cW->isTorqueFromVehicle() )\r\n\t\t\t\tcW->CalcAccelerations();\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t#ifdef OBS_RPM_IS_NEW\n\t\t\t\t// Engine RPM is related to the rotation of the powered wheels,\n\t\t\t\t// since they are physically connected, somewhat\n\t\t\t\t// Take the minimal rotation\n\t\t\t\tfloat minV=99999.0f,maxV=0;\n\t\t\t\tfor(int i=0;i<_wheels.size();i++)\n\t\t\t\t{\n\t\t\t\t\tpWheel2 *cW = (pWheel2*)_wheels[i];\r\n\t\t\t\t\tif (cW && (cW->getWheelFlag(WF_Accelerated) && ( cW->getWheelShape()->getWheelFlags() & WSF_AxleSpeedOverride))\t\t\t\t\t\t)\r\n\t\t\t\t\t{\n\t\t\t\t\t\tif(cW->GetRotationV()>maxV)\n\t\t\t\t\t\t\tmaxV=cW->GetRotationV();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t#ifdef OBS_HMM\n\t\t\t\t\t\t\t\tif(cW[i]->GetRotationV()GetRotationV();\n\t\t\t\t\t\t\t#endif\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/*engine->\n\t\t\t\tengine->ApplyWheelRotation(maxV);*/\n\n\t\t#endif\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tsteer->Integrate();\r\n\r\n\t\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t\t{\r\n\t\t\tpWheel2 *cW = (pWheel2*)_wheels[i];\r\n\t\t\tif (cW->isAxleSpeedFromVehicle() || cW->isTorqueFromVehicle() )\r\n\t\t\t\tcW->Integrate();\r\n\t\t}\r\n\r\n\t\t\r\n\t\tdriveLine->Integrate();\r\n\r\n\t\t\n\t\tfor(int i=0;iIntegrate();\n\t\t}\n\r\n\t\tgearbox->processFutureGear();\r\n\r\n\t}\r\n}\r\nvoid pVehicle::processPreScript()\r\n{\r\n\r\n}\r\nvoid pVehicle::processPostScript()\r\n{\r\n\tCKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(postScript);\r\n\tif (beh)\r\n\t{\r\n\t\tSetInputParameterValue(beh,0,5);\r\n\t\tbeh->Execute(_lastDT);\r\n\t\t GetOutputParameterValue(beh,0);\r\n\t}\r\n}\r\nint pVehicle::onPostProcess()\r\n{\r\n\r\n\t/*\r\n\tif (getBody()->isSleeping())\r\n\t\tgetBody()->wakeUp();\r\n\t*/\r\n\r\n\r\n\r\n\t_lastDT = lastStepTimeMS;\r\n\r\n\r\n\t_currentStatus = _calculateCurrentStatus();\r\n\t\r\n\tVehicleStatus status = (VehicleStatus)_currentStatus;\r\n\tfloat bTorque = calculateBraking(_lastDT);\r\n\t\r\n\tif (_cSteering != 0 || _cAcceleration != 0 || _cHandbrake)\r\n\t\tgetActor()->wakeUp(0.05);\r\n\r\n\tif (isValidEngine())\t\t//new vehicle code\r\n\t\tstep(_lastDT);\r\n\telse\t\t\t\t\t\t//old\r\n\t\t_performSteering(_lastDT );\r\n\r\n\r\n\tif ( !(flags & VF_UseAdvance ))\r\n\t{\r\n\t\t_performAcceleration(_lastDT);\r\n\t\tpostStep();\r\n\t}else\r\n\t{\r\n\t\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t\t{\r\n\r\n\t\t\tpWheel2* wheel = (pWheel2*)_wheels[i];\r\n\t\t\t\r\n\r\n\t\t\tif( wheel->isTorqueFromVehicle())\r\n\t\t\t\twheel->applyTorqueToPhysics();\r\n\r\n\t\t\tif(\twheel->isAxleSpeedFromVehicle() )\r\n\t\t\t{\r\n/*\t\t\t\t\tfloat v = wheel->rotationV.x;\r\n\t\t\t\t\tv = v * getEngine()->getEndRotationalFactor() * getEngine()->getTimeScale();\t\r\n\r\n*/\t\t\t\t\t//wheel->getWheelShape()->setAxleSpeed(v);\r\n\r\n/*\r\n\t\t\t\t\tpDifferential *diff = getDifferential(0);\r\n\t\t\t\t\tfloat tOutOne = diff->GetTorqueOut(wheel[0]->differentialSide);\r\n\t\t\t\t\tfloat tOutSeconf = diff->GetTorqueOut(wheel[1]->differentialSide);\r\n\r\n\r\n*/\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t{\r\n\t\tpWheel2* wheel = (pWheel2*)_wheels[i];\r\n\t\twheel->updateSteeringPose( wheel->getWheelRollAngle(),wheel->getWheelShape()->getSteerAngle(),_lastDT);\r\n\t\twheel->updatePosition();\r\n\t}\r\n\r\n\t\r\n\tsetVSFlags(_currentStatus);\r\n\r\n\tprocessPostScript();\r\n\r\n\tupdateControl(0,false,0,false,false);\r\n\r\n\r\n\treturn 1;\r\n}\r\n\r\nint pVehicle::onPreProcess()\r\n{\r\n\t_lastDT = lastStepTimeMS;\r\n\r\n\t\r\n\treturn 1;\r\n}\r\n\r\n\r\n\r\nvoid pVehicle::updateVehicle( float lastTimeStepSize )\r\n{\r\n\r\n\treturn;\r\n\r\n\t_lastDT = lastTimeStepSize;\r\n\r\n\t_currentStatus = _calculateCurrentStatus();\r\n\r\n\tVehicleStatus status = (VehicleStatus)_currentStatus;\r\n\r\n\r\n\tif (_cSteering != 0 || _cAcceleration != 0 || _cHandbrake)\r\n\t\tgetActor()->wakeUp(0.05);\r\n\r\n\t\r\n\tfloat bTorque = calculateBraking(lastTimeStepSize);\r\n\t\r\n\t\r\n\r\n\t_performSteering(lastTimeStepSize);\r\n\tif (engine && gearbox && driveLine )\r\n\t{\r\n\t\tstep(lastTimeStepSize);\r\n\t}\r\n\r\n\r\n\tif ( !(flags & VF_UseAdvance ))\r\n\t{\r\n\t\t_performAcceleration(lastTimeStepSize);\r\n\t\tpostStep();\r\n\t}else\r\n\t{\r\n\t\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t\t{\r\n\r\n\t\t\t\r\n\t\t\tpWheel2* wheel = (pWheel2*)_wheels[i];\r\n/*\t\t\tif( (wheel->getWheelFlag(WF_Accelerated)) && (wheel->getWheelShape()->getWheelFlags() & WSF_AxleSpeedOverride ))\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tfloat v = wheel->rotationV.x *= 1.0f;\r\n\r\n\t\t\t\twheel->getWheelShape()->setAxleSpeed( v );\r\n\t\t\t}\r\n\t\t\t*/\r\n\t\t}\r\n\t}\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t{\r\n\t\tpWheel2* wheel = (pWheel2*)_wheels[i];\r\n\t\twheel->updateSteeringPose( wheel->getWheelRollAngle(),wheel->getWheelShape()->getSteerAngle(),lastTimeStepSize);\r\n\t\twheel->updatePosition();\r\n\t}\r\n\r\n\tif (getMotor())\r\n\t{\r\n\t\t_currentStatus |= E_VSF_HAS_MOTOR;\r\n\t}\r\n\r\n\tif (getGears())\r\n\t{\r\n\t\t_currentStatus |= E_VSF_HAS_GEARS;\r\n\t}\r\n\r\n\tsetVSFlags(_currentStatus);\r\n\r\n\t\r\n\t\r\n\treturn;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// old code \r\n\t//\r\n\r\n\t//control(_cSteering,_cAnalogSteering,_cAcceleration,_cAnalogAcceleration,_cHandbrake);\r\n\t//printf(\"updating %x\\n\", this);\r\n\r\n\tNxReal distanceSteeringAxisCarTurnAxis = _steeringSteerPoint.x - _steeringTurnPoint.x;\r\n\tNX_ASSERT(_steeringSteerPoint.z == _steeringTurnPoint.z);\r\n\tNxReal distance2 = 0;\r\n\tif (NxMath::abs(_steeringWheelState) > 0.01f)\r\n\t\tdistance2 = distanceSteeringAxisCarTurnAxis / NxMath::tan(_steeringWheelState * _steeringMaxAngleRad);\r\n\t\r\n\tNxU32 nbTouching = 0;\r\n\tNxU32 nbNotTouching = 0; \r\n\tNxU32 nbHandBrake = 0;\r\n\tint wSize = _wheels.size();\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_SteerableInput))\r\n\t\t{\r\n\t\t\tif(distance2 != 0)\r\n\t\t\t{\r\n\t\t\t\tNxReal xPos = wheel->getWheelPos().x;\r\n\t\t\t\tNxReal xPos2 = _steeringSteerPoint.x- wheel->getWheelPos().x;\r\n\t\t\t\tNxReal zPos = wheel->getWheelPos().z;\r\n\t\t\t\tNxReal dz = -zPos + distance2;\r\n\t\t\t\tNxReal dx = xPos - _steeringTurnPoint.x;\r\n\t\t\t\tfloat atan3 = NxMath::atan(dx/dz);\r\n\r\n\t\t\t\tfloat angle =(NxMath::atan(dx/dz));\r\n\t\t\t\tif (dx < 0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tangle*=-1.0f;\r\n\t\t\t\t}\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t\t//errMessage.Format(\"w%d dz:%f dx:%f dx2%f distance:%f atan3:%f\",i,dz,dx,xPos2,distance2,atan3);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\r\n\r\n\t\t\t} else {\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t}\r\n\t\t\t//printf(\"%2.3f\\n\", wheel->getAngle());\r\n\r\n\t\t} else if(wheel->getWheelFlag(WF_SteerableAuto))\r\n\t\t{\r\n\t\t\tNxVec3 localVelocity = getActor()->getLocalPointVelocity(getFrom(wheel->getWheelPos()));\r\n\t\t\tNxQuat local2Global = getActor()->getGlobalOrientationQuat();\r\n\t\t\tlocal2Global.inverseRotate(localVelocity);\r\n\t\t\t//\t\t\tprintf(\"%2.3f %2.3f %2.3f\\n\", wheel->getWheelPos().x,wheel->getWheelPos().y,wheel->getWheelPos().z);\r\n\t\t\tlocalVelocity.y = 0;\r\n\t\t\tif(localVelocity.magnitudeSquared() < 0.1f)\r\n\t\t\t{\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t} else {\r\n\t\t\t\tlocalVelocity.normalize();\r\n\t\t\t\t//\t\t\t\tprintf(\"localVelocity: %2.3f %2.3f\\n\", localVelocity.x, localVelocity.z);\r\n\t\t\t\tif(localVelocity.x < 0)\r\n\t\t\t\t\tlocalVelocity = -localVelocity;\r\n\t\t\t\tNxReal angle = NxMath::clamp((NxReal)atan(localVelocity.z / localVelocity.x), 0.3f, -0.3f);\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// now the acceleration part\r\n\t\tif(!wheel->getWheelFlag(WF_Accelerated))\r\n\t\t\tcontinue;\r\n\r\n\t\tif(_handBrake && wheel->getWheelFlag(WF_AffectedByHandbrake))\r\n\t\t{\r\n\t\t\tnbHandBrake++;\r\n\t\t} \r\n\t\telse\r\n\t\t{\r\n\t\t\tif (!wheel->hasGroundContact())\r\n\t\t\t{\r\n\t\t\t\tnbNotTouching++;\r\n\t\t\t} else {\r\n\t\t\t\tnbTouching++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tNxReal motorTorque = 0.0; \r\n\tfloat _acc = NxMath::abs(_accelerationPedal);\r\n\t\r\n\tXString errMessage;\r\n\tif(nbTouching && NxMath::abs(_accelerationPedal) > 0.1f ) \r\n\t{\r\n\t\tNxReal axisTorque = _computeAxisTorque();\r\n\t\tNxReal wheelTorque = axisTorque / (NxReal)(_wheels.size() - nbHandBrake);\r\n\t\tNxReal wheelTorqueNotTouching = nbNotTouching>0?wheelTorque*(NxMath::pow(0.5f, (NxReal)nbNotTouching)):0;\r\n\t\tNxReal wheelTorqueTouching = wheelTorque - wheelTorqueNotTouching;\r\n\t\tmotorTorque = wheelTorqueTouching / (NxReal)nbTouching; \r\n\t} else {\r\n\t\t_updateRpms();\r\n\t}\r\n\t\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#define BB_SET_POSITION_GUID CKGUID(0xe456e78a, 0x456789aa) \r\n#define BB_SET_ORIENTATION_GUID CKGUID(0x625874aa, 0xaa694132)\r\n#define BB_ROTATE_GUID CKGUID(0xffffffee, 0xeeffffff)\r\n#define BB_TRANSLATE_GUID CKGUID(0x000d000d, 0x000d000d)\r\n\r\n#define BB_SET_EORIENTATION_GUID CKGUID(0xc4966d8,0x6c0c6d14)\r\n#define BB_PLAY_GLOBAL_ANIMATION CKGUID(0x1c9236e1,0x42f40996)\r\n#define BB_SET_LOCAL_MATRIX CKGUID(0x21f5f30d, 0x08d5a1db)\r\n#define BB_SET_WORLD_MATRIX CKGUID(0xaa4aa6f0, 0xddefdef4)\r\n#define BB_RESTORE_IC CKGUID(0x766e4e44,0x4fac6d52)\r\n#define BB_LAUNCH_SCENE CKGUID(0x188d6d43,0x169613dd)\r\n\r\n\r\n\r\nCKBEHAVIORFCT BBSetEOri;\r\nCKBEHAVIORFCT BBSetPos;\r\nCKBEHAVIORFCT BBSetOri;\r\nCKBEHAVIORFCT BBRotate;\r\nCKBEHAVIORFCT BBTranslate;\r\nCKBEHAVIORFCT BBPlayGlobalAnimation;\r\nCKBEHAVIORFCT BBSetLocalMatrix;\r\nCKBEHAVIORFCT BBSetWorldMatrix;\r\nCKBEHAVIORFCT BBRestoreIC;\r\nCKBEHAVIORFCT BBLaunchScene;\r\n\r\n\r\n\r\n#define BRESET VxVector vectorN(0,0,0);\\\r\n\tint pResetF=0;behaviour->GetLocalParameterValue(1,&pResetF);\\\r\n\tint pResetT=0;behaviour->GetLocalParameterValue(2,&pResetT);\\\r\n\tint pResetLV=0;behaviour->GetLocalParameterValue(3,&pResetLV);\\\r\n\tint pResetAV=0;behaviour->GetLocalParameterValue(4,&pResetAV);\\\r\n\tif (pResetF)\tsolid->setLinearMomentum(vectorN);\\\r\n\tif (pResetT)solid->setAngularMomentum(vectorN);\\\r\n\tif (pResetLV)solid->setLinearVelocity(vectorN);\\\r\n\tif (pResetAV)solid->setAngularVelocity(vectorN);\\\r\n\r\n\r\nint BB_SetEOrientationNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetEOri(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(1,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\r\n\r\n\t\t\tBRESET;\r\n\t\t\tVxVector pos,scale;\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,1);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\tVxVector vector(0,0,0);\r\n\t\t\t\tent->GetPosition(&vector);\r\n\t\t\t\tsolid->setPosition(vector,ent);\r\n\t\t\t\t\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setRotation(quat);\r\n\t\t\t}\r\n\t\t\t//solid->updateSubShapes(false,false,true,ent);\r\n\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\nint BB_SetPosNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\tBBSetPos(context);\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\t\r\n\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\treturn 0; \r\n\t\t}\r\n\r\n\t\tpRigidBody *solid = world->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tBRESET;\r\n\t\t\tVxVector pos,scale;\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,1);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,false,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\tVxVector vector(0,0,0);\r\n\t\t\t\tent->GetPosition(&vector);\r\n\t\t\t\tsolid->setPosition(vector,ent);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint BB_SetOrientationNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetOri(context);\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tBRESET\r\n\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,2);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setRotation(quat);\r\n\t\t\t}\r\n\t\t\t//solid->updateSubShapes(false,true,true,ent);\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nint BB_RotateNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\tBBRotate(context);\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent,true);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tBRESET;\r\n\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,3);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setRotation(quat);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nint BB_TranslateNew(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\tBBTranslate(context);\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tBRESET;\r\n\t\t\tVxVector pos,scale;\tVxQuaternion quat;\r\n\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,1);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\tsolid->setPosition(pos,ent);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nint BBPlayGlobalAnimation_New(const CKBehaviorContext& context)\r\n{\r\n\r\n\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tint returnValue= BBPlayGlobalAnimation(context);\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\t\r\n\r\n\t\t\tBRESET\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,true);\r\n\t\t\t}else{\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setPosition(pos,ent);\r\n\t\t\t\r\n\t\t\t}\r\n\t\t}/*\r\n\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tpWorld *world = GetPMan()->getWorldByBody(ent);\r\n\t\t\t\t\tif (world)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsolid = world->getBodyFromSubEntity(ent);\r\n\t\t\t\t\t\tif (solid)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsolid->updateSubShapes(false,true,true);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}*/\r\n\t\t\r\n\t}\r\n\treturn returnValue;\r\n}\r\n\r\nint BBSetLocalMatrix_New(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetLocalMatrix(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\r\n\t\t\tBRESET;\r\n\t\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,1);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setPosition(pos,ent);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nint BBSetWorldMatrix_New(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBSetWorldMatrix(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\r\n\t\t\t//solid->getActor()->\r\n\r\n\t\t\tBRESET\r\n\t\t\t\tint hierarchy = vtTools::BehaviorTools::GetInputParameterValue(behaviour,1);\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,hierarchy);\r\n\t\t\t}else{\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setPosition(pos,ent);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nint BBRestoreIC_New(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\tBBRestoreIC(context);\r\n\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tCK3dEntity *ent = (CK3dEntity *) behaviour->GetTarget();\r\n\tint hierarchy=0;behaviour->GetLocalParameterValue(5,&hierarchy);\r\n\tint restoreJoints=0;behaviour->GetLocalParameterValue(6,&restoreJoints);\r\n\tbool done= false;\r\n\tif (pUpdate)\r\n\t{\r\n\t\tif( !ent ) \r\n\t\t\treturn CKBR_OWNERERROR;\r\n\t\tpRigidBody *solid = GetPMan()->getBody(ent);\r\n\t\tif (solid)\r\n\t\t{\r\n\t\t\tBRESET\r\n\r\n\t\t\tif (ent && ent->GetClassID() != CKCID_3DOBJECT)\r\n\t\t\t{\r\n\t\t\t\treturn CK_OK;\r\n\t\t\t}\r\n\r\n\t\t\t/*\r\n\t\t\tif ( (solid->getFlags() & BF_Hierarchy ) && solid->GetVT3DObject() !=ent )\r\n\t\t\t{\r\n\t\t\t\tsolid->onSubShapeTransformation(false,true,true,ent,(solid->getFlags() & BF_Hierarchy ));\r\n\t\t\t}else{\r\n\t\t\t\tVxVector pos,scale;\t\r\n\t\t\t\tVxQuaternion quat;\r\n\t\t\t\tVx3DDecomposeMatrix(ent->GetWorldMatrix(),quat,pos,scale);\r\n\t\t\t\tsolid->setPosition(pos,ent);\r\n\t\t\t}\r\n\t\t\t*/\r\n\r\n\t\t\tpRigidBodyRestoreInfo *rInfo = new pRigidBodyRestoreInfo();\r\n\t\t\trInfo->hierarchy = hierarchy;\r\n\t\t\trInfo->removeJoints= restoreJoints;\r\n\t\t\tGetPMan()->_getRestoreMap()->Insert(ent->GetID(),rInfo);\r\n\t\t\tdone = true;\r\n\t\t}\r\n\t}\r\n\r\n\tif (hierarchy && !done)\r\n\t{\r\n\t\tCKScene *scene = GetPMan()->GetContext()->GetCurrentLevel()->GetLevelScene();\r\n\t\tif(scene)\r\n\t\t{\t\t\r\n\t\t\tCK3dEntity* subEntity = NULL;\r\n\t\t\tXArraySrcObjects;\r\n\t\t\twhile (subEntity= ent->HierarchyParser(subEntity) )\r\n\t\t\t{\r\n\t\t\t\tCKStateChunk *chunk = scene->GetObjectInitialValue(subEntity);\r\n\t\t\t\tif (chunk)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKReadObjectState(subEntity,chunk);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\nint BBLaunchScene_New(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior\t*behaviour = context.Behavior;\r\n\tCKContext\t*ctx = context.Context;\r\n\r\n\r\n\tCKScene *currentScene= GetPMan()->GetContext()->GetCurrentLevel()->GetCurrentScene();\r\n\tCKScene *nextScene = NULL;\r\n\tBBLaunchScene(context);\r\n/*\r\n\tint pUpdate=0;\r\n\tbehaviour->GetLocalParameterValue(0,&pUpdate);\r\n\tnextScene = (CKScene*)behaviour->GetInputParameterObject(0);\r\n\tif (pUpdate)\r\n\t{\r\n\t\tif(GetPMan()->GetContext()->IsPlaying())\r\n\t\t{\t\t\r\n\t\t\tGetPMan()->_removeObjectsFromOldScene(currentScene);\r\n\t\t\tGetPMan()->_checkObjectsByAttribute(nextScene);\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nCKERROR PhysicManager::_Hook3DBBs()\r\n{\r\n\tCKBehaviorManager *bm = m_Context->GetBehaviorManager();\r\n\t\r\n\tCKBehaviorPrototype *bproto = CKGetPrototypeFromGuid(BB_SET_EORIENTATION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetEOri = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetEOrientationNew);\r\n\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_POSITION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetPos = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetPosNew);\r\n\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_ORIENTATION_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetOri = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_SetOrientationNew);\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_ROTATE_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBRotate = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_RotateNew);\r\n\t}\r\n\tbproto = CKGetPrototypeFromGuid(BB_TRANSLATE_GUID);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBTranslate = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BB_TranslateNew);\r\n\t}\r\n\r\n\r\n\t\r\n\tbproto = CKGetPrototypeFromGuid(BB_PLAY_GLOBAL_ANIMATION);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBPlayGlobalAnimation = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BBPlayGlobalAnimation_New);\r\n\t}\r\n\t\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_LOCAL_MATRIX);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetLocalMatrix = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BBSetLocalMatrix_New);\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_SET_WORLD_MATRIX);\r\n\tif(bproto)\r\n\t{\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"false\");\r\n\t\tBBSetWorldMatrix = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BBSetWorldMatrix_New);\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_RESTORE_IC);\r\n\tif(bproto)\r\n\t{\r\n\t\t\r\n\t\tbproto->DeclareSetting(\"Update Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Force\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Torque\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Linear Velocity\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Reset Angular Velocity\",CKPGUID_BOOL,\"true\");\r\n\r\n\t\tbproto->DeclareSetting(\"Hierarchy\",CKPGUID_BOOL,\"true\");\r\n\t\tbproto->DeclareSetting(\"Restore Joints from Attribute\",CKPGUID_BOOL,\"true\");\r\n\r\n\r\n\t\tBBRestoreIC = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BBRestoreIC_New);\r\n\t}\r\n\r\n\tbproto = CKGetPrototypeFromGuid(BB_LAUNCH_SCENE);\r\n\tif(bproto)\r\n\t{\r\n\r\n\t\t//bproto->DeclareSetting(\"Destroy Old Physics\",CKPGUID_BOOL,\"true\");\r\n\t\tBBLaunchScene = bproto->GetFunction();\r\n\t\tbproto->SetFunction(BBLaunchScene_New);\r\n\t}\r\n\r\n\treturn CK_OK;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n\r\n#include \"pVehicleAll.h\"\r\n\r\n\r\n\r\nPhysicManager*GetPhysicManager();\r\npRigidBody *getBody(CK3dEntity*ent);\r\nCKGUID GetPhysicManagerGUID() { \treturn GUID_MODULE_MANAGER;}\r\n\r\ntypedef ForceMode PForceMode;\r\ntypedef D6MotionMode PJMotion;\r\ntypedef D6DriveType PDriveType;\r\n\r\n\r\npFactory* getPFactory()\r\n{\r\n\treturn pFactory::Instance();\r\n}\r\n\r\n\r\nvoid __newpObjectDescr(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pObjectDescr();\r\n}\r\n\r\n\r\nvoid __newpRaycastHit(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pRaycastHit();\r\n}\r\n\r\nvoid __newpGroupsMask(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pGroupsMask();\r\n}\r\n\r\nvoid __newpOptimization(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pOptimization();\r\n}\r\nvoid __newpMassSettings(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pMassSettings();\r\n}\r\nvoid __newpCCD(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pCCDSettings();\r\n}\r\nvoid __newpCollisionSettings(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pCollisionSettings();\r\n}\r\n\r\nvoid __newpPivotSettings(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pPivotSettings();\r\n}\r\n\r\nvoid __newpMaterial(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pMaterial();\r\n}\r\nvoid __newpAxisReferenceLength(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pAxisReferencedLength();\r\n}\r\n\r\n\r\nvoid __newpCapsuleSettingsEx(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pCapsuleSettingsEx();\r\n}\r\nvoid __newpConvexCylinder(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pConvexCylinderSettings();\r\n}\r\n\r\nvoid __newpWheelDescr(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pWheelDescr();\r\n}\r\n\r\nvoid __newpTireFunction(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pTireFunction();\r\n}\r\n\r\n\r\nvoid __newpInterpolation(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pLinearInterpolation();\r\n}\r\n\r\nCKGUID getRigidBodyParameterType()\r\n{\r\n\treturn VTS_PHYSIC_ACTOR;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#define TESTGUID CKGUID(0x2c5c47f6,0x1d0755d9)\r\n\r\nvoid logWarning(const char*errMessage)\r\n{\r\n\tif (!errMessage || !strlen(errMessage))\r\n\t\treturn;\r\n\r\n\txLogger::xLog(XL_START,ELOGWARNING,E_VSL,errMessage);\r\n\r\n\r\n}\r\n\r\nvoid PhysicManager::_RegisterVSLCommon()\r\n{\r\n\t\t\t\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// manager related\r\n\t//\r\n\r\n\t{\r\n\r\n\t\tDECLAREENUM(\"pSDKParameter\")\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_SkinWidth\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_DefaultSleepLinVelSquared\" ,2 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_DefaultSleepAngVelSquared\" ,3 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_BounceThreshold\" ,4 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_DynFrictScaling\" , 5)\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_StaFrictionScaling\" ,6 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_MaxAngularVelocity\" ,7 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ContinuousCD\" ,8 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_AdaptiveForce\" ,68 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_CollVetoJointed\" ,69 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_TriggerTriggerCallback\" ,70 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_SelectHW_Algo\" ,71 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_CCDEpsilon\" ,73 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_SolverConvergenceThreshold\" ,74 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_BBoxNoiseLevel\" ,75 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ImplicitSweepCacheSize\" , 76)\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_DefaultSleepEnergy\" ,77 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ConstantFluidMaxPackets\" ,78 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ConstantFluidMaxParticlesPerStep\" ,79 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_AsynchronousMeshCreation\" ,96 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ForceFieldCustomKernelEpsilon\" ,97 )\r\n\t\tDECLAREENUMVALUE(\"pSDKParameter\", \"pSDKP_ImprovedSpringSolver\" ,98 )\r\n\t\r\n\t}\r\n\r\n\r\n\tREGISTERCONST(\"FLT_MAX\",BIND_FLOAT,FLT_MAX)\r\n\tREGISTERCONST(\"PTYPE_RIGID_BODY\",BIND_FLOAT,FLT_MAX)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// common types\r\n\t//\r\n\tDECLAREPOINTERTYPE(pFactory)\r\n\tDECLAREFUN_C_0(pFactory,getPFactory)\r\n\t\r\n\t\r\n\t\r\n\tDECLAREFUN_C_0(CKGUID, GetPhysicManagerGUID)\r\n\tDECLAREOBJECTTYPE(PhysicManager)\r\n\tDECLARESTATIC_1(PhysicManager,PhysicManager*,Cast,CKBaseManager* iM)\r\n\tDECLAREFUN_C_0(PhysicManager*, GetPhysicManager)\r\n\r\n\tDECLAREPOINTERTYPE(pRigidBody)\r\n\tDECLAREPOINTERTYPE(pPacejka)\r\n\r\n\tDECLAREPOINTERTYPEALIAS(pRigidBody,\"pBody\")\r\n\t\r\n\tDECLAREFUN_C_0(CKGUID,getRigidBodyParameterType)\r\n\tDECLAREFUN_C_1(void,logWarning,const char*)\r\n\r\n\tDECLAREPOINTERTYPE(pWorld)\r\n\tDECLAREPOINTERTYPE(pCloth)\r\n\tDECLAREPOINTERTYPE(pVehicle)\r\n\tDECLAREPOINTERTYPE(pWheel)\r\n\tDECLAREPOINTERTYPE(pVehicle)\r\n\tDECLAREPOINTERTYPE(pVehicleMotor)\r\n\tDECLAREPOINTERTYPE(pVehicleGears)\r\n\r\n\tDECLAREPOINTERTYPE(pWheel1)\r\n\tDECLAREPOINTERTYPE(pWheel2)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// new vehicle pack\r\n\t//\r\n\tDECLAREPOINTERTYPE(pEngine)\r\n\tDECLAREPOINTERTYPE(pGearBox)\r\n\tDECLAREPOINTERTYPE(pWheelContactData)\r\n\r\n\tDECLAREPOINTERTYPE(pLinearInterpolation)\r\n\t//DECLARECTOR_0(__newpInterpolation)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\tDECLAREINHERITANCESIMPLE(\"pWheel\",\"pWheel1\")\r\n\tDECLAREINHERITANCESIMPLE(\"pWheel\",\"pWheel2\")\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJoints :\r\n\t\t//\r\n\r\n\t\t\r\n\t\tDECLAREPOINTERTYPE(pJoint)\r\n\t\tDECLAREPOINTERTYPE(pJointFixed)\r\n\t\tDECLAREPOINTERTYPE(pJointDistance)\r\n\t\tDECLAREPOINTERTYPE(pJointD6)\r\n\t\tDECLAREPOINTERTYPE(pJointPulley)\r\n\t\tDECLAREPOINTERTYPE(pJointBall)\r\n\t\tDECLAREPOINTERTYPE(pJointRevolute)\r\n\t\tDECLAREPOINTERTYPE(pJointPrismatic)\r\n\t\tDECLAREPOINTERTYPE(pJointCylindrical)\r\n\t\tDECLAREPOINTERTYPE(pJointPointInPlane)\r\n\t\tDECLAREPOINTERTYPE(pJointPointOnLine)\r\n\r\n\t\t\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointDistance\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointD6\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointFixed\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPulley\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointBall\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointRevolute\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPrismatic\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointCylindrical\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPointOnLine\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPointInPlane\")\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// help structures collision\r\n\t//\r\n\t\r\n\tDECLAREOBJECTTYPE(pGroupsMask)\r\n\tDECLARECTOR_0(__newpGroupsMask)\r\n\tDECLAREMEMBER(pGroupsMask,int,bits0)\r\n\tDECLAREMEMBER(pGroupsMask,int,bits1)\r\n\tDECLAREMEMBER(pGroupsMask,int,bits2)\r\n\tDECLAREMEMBER(pGroupsMask,int,bits3)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pCollisionSettings)\r\n\tDECLARECTOR_0(__newpCollisionSettings)\r\n\tDECLAREMEMBER(pCollisionSettings,int,collisionGroup)\r\n\tDECLAREMEMBER(pCollisionSettings,pGroupsMask,groupsMask)\r\n\tDECLAREMEMBER(pCollisionSettings,float,skinWidth)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pRaycastHit)\r\n\tDECLARECTOR_0(__newpRaycastHit)\r\n\tDECLAREMEMBER(pRaycastHit,float,distance)\r\n\tDECLAREMEMBER(pRaycastHit,CK3dEntity*,shape)\r\n\tDECLAREMEMBER(pRaycastHit,VxVector,worldImpact)\r\n\tDECLAREMEMBER(pRaycastHit,VxVector,worldNormal)\r\n\tDECLAREMEMBER(pRaycastHit,int,faceID)\r\n\tDECLAREMEMBER(pRaycastHit,int,internalFaceID)\r\n\tDECLAREMEMBER(pRaycastHit,float,u)\r\n\tDECLAREMEMBER(pRaycastHit,float,v)\r\n\tDECLAREMEMBER(pRaycastHit,int,materialIndex)\r\n\tDECLAREMEMBER(pRaycastHit,int,flags)\r\n\r\n\tDECLAREENUM(\"pFilterOp\")\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_And\" , 0)\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_Or\" , 1)\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_Xor\" ,2)\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_Nand\",3 )\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_Nor\" , 4)\r\n\tDECLAREENUMVALUE(\"pFilterOp\", \"FO_NXor\" ,5 )\r\n\r\n\tDECLAREENUM(\"pShapesType\")\r\n\tDECLAREENUMVALUE(\"pShapesType\", \"ST_Static\" , 1)\r\n\tDECLAREENUMVALUE(\"pShapesType\", \"ST_Dynamic\" , 2)\r\n\tDECLAREENUMVALUE(\"pShapesType\", \"ST_All\" , 3)\r\n\r\n\tDECLAREENUM(\"pTriggerFlags\")\r\n\tDECLAREENUMVALUE(\"pTriggerFlags\", \"TF_Disable\" , 8)\r\n\tDECLAREENUMVALUE(\"pTriggerFlags\", \"TF_OnEnter\" , 1)\r\n\tDECLAREENUMVALUE(\"pTriggerFlags\", \"TF_OnLeave\" , 2)\r\n\tDECLAREENUMVALUE(\"pTriggerFlags\", \"TF_OnStay\" , 4)\r\n\r\n\tDECLAREENUM(\"pContactModifyMask\")\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_None\" , 0)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_MinImpulse\" , 1)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_MaxImpulse\" , 2)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_Error\" , 4)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_Target\" , 8)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_LocalPosition0\" , 16)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_LocalPosition1\" , 32)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_LocalOrientation0\" , 64)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_LocalOrientation1\" , 128)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_StaticFriction0\" , 256)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_StaticFriction1\" , 512)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_DynamicFriction0\" , 1024)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_DynamicFriction1\" , 2048)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_Restitution\" , 8196)\r\n\tDECLAREENUMVALUE(\"pContactModifyMask\", \"CMM_Force32\" ,2147483648 )\r\n\r\n\tDECLAREENUM(\"pCollisionEventMask\")\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_IgnorePair\" , 1)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnStartTouch\" , 2)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnEndTouch\" , 4)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnTouch\" , 8)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnImpact\" , 16)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnRoll\" , 32)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnSlide\" , 64)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_Forces\" , 128)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnStartTouchForceThreshold\" , 256)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnEndTouchForceThreshold\" , 512)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_OnTouchForceThreshold\" , 1024)\r\n\tDECLAREENUMVALUE(\"pCollisionEventMask\", \"CPF_ContactModification\" , 65536)\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// help structures Rigid body\r\n\t//\r\n\t\r\n\tDECLAREENUM(\"BodyFlags\")\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Moving\" , 1)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Gravity\" , 2)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Collision\" , 4)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Kinematic\" , 8)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_SubShape\" , 16)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Hierarchy\" , 32)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Attributes\" , 64)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_TriggerShape\" , 128)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_Sleep\" , 4096)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_CollisionNotify\" , 512)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_CollisionsForce\" , 1024)\r\n\tDECLAREENUMVALUE(\"BodyFlags\", \"BF_ContactModify\" , 2048)\r\n\r\n\tDECLAREENUM(\"BodyLockFlags\")\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LPX\" , 2)\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LPY\" , 4)\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LPZ\" , 8)\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LRX\" , 16)\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LRY\" , 32)\r\n\tDECLAREENUMVALUE(\"BodyLockFlags\", \"BF_LRZ\" , 64)\r\n\r\n\r\n\r\n\tDECLAREENUM(\"HullType\")\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Sphere\" , 0)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Box\" , 1)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Capsule\" , 2)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Plane\" , 3)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Mesh\" , 4)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_ConvexMesh\" , 5)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_HeightField\" , 6)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_Wheel\" , 7)\r\n\tDECLAREENUMVALUE(\"HullType\", \"HT_ConvexCylinder\" , 9)\r\n\r\n\t\r\n\r\n\r\n\tDECLAREENUM(\"CombineMode\")\r\n\tDECLAREENUMVALUE(\"CombineMode\", \"CM_Average\" , 0)\r\n\tDECLAREENUMVALUE(\"CombineMode\", \"CM_Min\" , 1)\r\n\tDECLAREENUMVALUE(\"CombineMode\", \"CM_Multiply\" , 2)\r\n\tDECLAREENUMVALUE(\"CombineMode\", \"CM_Max\" , 3)\r\n\r\n\tDECLAREENUM(\"pObjectDescrMask\")\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_XML\" , 1)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Pivot\" , 2)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Mass\" , 4)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Collision\" , 8)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_CCD\" , 16)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Material\" , 32)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Optimization\" , 64)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Capsule\" , 128)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_ConvexCylinder\" , 256)\r\n\tDECLAREENUMVALUE(\"pObjectDescrMask\", \"OD_Wheel\" , 512)\r\n\r\n\r\n\tDECLAREENUM(\"DIRECTION\")\r\n\tDECLAREENUMVALUE(\"DIRECTION\", \"DIR_X\" , 0)\r\n\tDECLAREENUMVALUE(\"DIRECTION\", \"DIR_Y\" , 1)\r\n\tDECLAREENUMVALUE(\"DIRECTION\", \"DIR_Z\" , 2)\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Wheel related types\r\n\t//\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pTireFunction)\r\n\tDECLARECTOR_0(__newpTireFunction)\r\n\tDECLAREMEMBER(pTireFunction,float,extremumSlip)\r\n\tDECLAREMEMBER(pTireFunction,float,extremumValue)\r\n\tDECLAREMEMBER(pTireFunction,float,asymptoteSlip)\r\n\tDECLAREMEMBER(pTireFunction,float,stiffnessFactor)\r\n\tDECLAREMEMBER(pTireFunction,int,xmlLink)\r\n\tDECLAREMETHOD_0(pTireFunction,void,setToDefault)\r\n\r\n\r\n\r\n\t\r\n\t\r\n\tDECLAREENUM(\"WheelFlags\")\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_SteerableInput\" , 1)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_SteerableAuto\" , 2)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_AffectedByHandbrake\" , 4)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_Accelerated\" , 8)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_BuildLowerHalf\" , 256)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_UseWheelShape\" , 512)\r\n\tDECLAREENUMVALUE(\"WheelFlags\", \"WF_VehicleControlled\" , 1024)\r\n\r\n\r\n\tDECLAREENUM(\"WheelShapeFlags\")\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_WheelAxisContactNormal\" , 1)\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_InputLatSlipVelocity\" , 1)\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_InputLongSlipVelocity\" , 2)\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_UnscaledSpringBehavior\" , 4)\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_EmulateLegacyWheel\" , 8)\r\n\tDECLAREENUMVALUE(\"WheelShapeFlags\", \"WSF_ClampedFriction\" , 16)\r\n\r\n\t\r\n\t\r\n\tDECLAREENUM(\"pConvexFlags\")\r\n\tDECLAREENUMVALUE(\"pConvexFlags\", \"CF_FlipNormals\" , CF_FlipNormals)\r\n\tDECLAREENUMVALUE(\"pConvexFlags\", \"CF_16BitIndices\" , CF_16BitIndices)\r\n\tDECLAREENUMVALUE(\"pConvexFlags\", \"CF_ComputeConvex\" , CF_ComputeConvex)\r\n\tDECLAREENUMVALUE(\"pConvexFlags\", \"CF_InflateConvex\" , CF_InflateConvex)\r\n\tDECLAREENUMVALUE(\"pConvexFlags\", \"CF_UncompressedNormals\" , CF_UncompressedNormals)\r\n\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pAxisReferencedLength)\r\n\tDECLARECTOR_0(__newpAxisReferenceLength)\r\n\tDECLAREMEMBER(pAxisReferencedLength,float,value)\r\n\tDECLAREMEMBER(pAxisReferencedLength,CKBeObject*,reference)\r\n\tDECLAREMEMBER(pAxisReferencedLength,int,referenceAxis)\r\n\tDECLAREMETHOD_0(pAxisReferencedLength,bool,isValid)\r\n\tDECLAREMETHOD_0(pAxisReferencedLength,void,setToDefault)\r\n\r\n\tDECLAREOBJECTTYPE(pWheelDescr)\r\n\tDECLARECTOR_0(__newpWheelDescr)\r\n\tDECLAREMEMBER(pWheelDescr,float,springRestitution)\r\n\tDECLAREMEMBER(pWheelDescr,pAxisReferencedLength,radius)\r\n\tDECLAREMEMBER(pWheelDescr,float,wheelSuspension)\r\n\tDECLAREMEMBER(pWheelDescr,float,springDamping)\r\n\tDECLAREMEMBER(pWheelDescr,float,springDamping)\r\n\tDECLAREMEMBER(pWheelDescr,float,maxBrakeForce)\r\n\tDECLAREMEMBER(pWheelDescr,float,frictionToFront)\r\n\tDECLAREMEMBER(pWheelDescr,float,frictionToSide)\r\n\tDECLAREMEMBER(pWheelDescr,float,inverseWheelMass)\r\n\tDECLAREMEMBER(pWheelDescr,WheelFlags,wheelFlags)\r\n\tDECLAREMEMBER(pWheelDescr,WheelShapeFlags,wheelShapeFlags)\r\n\tDECLAREMEMBER(pWheelDescr,pTireFunction,latFunc)\r\n\tDECLAREMEMBER(pWheelDescr,pTireFunction,longFunc)\r\n\tDECLAREMETHOD_0(pWheelDescr,void,setToDefault)\r\n\tDECLAREMETHOD_0(pWheelDescr,bool,isValid)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pConvexCylinderSettings)\r\n\tDECLARECTOR_0(__newpCollisionSettings)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,pAxisReferencedLength,radius)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,pAxisReferencedLength,height)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,int,approximation)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,VxVector,forwardAxis)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,CK3dEntity*,forwardAxisRef)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,VxVector,downAxis)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,CK3dEntity*,downAxisRef)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,VxVector,rightAxis)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,CK3dEntity*,rightAxisRef)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,bool,buildLowerHalfOnly)\r\n\tDECLAREMEMBER(pConvexCylinderSettings,pConvexFlags,convexFlags)\r\n\tDECLAREMETHOD_0(pConvexCylinderSettings,bool,isValid)\r\n\tDECLAREMETHOD_0(pConvexCylinderSettings,void,setToDefault)\r\n\r\n\tDECLAREOBJECTTYPE(pCapsuleSettingsEx)\r\n\tDECLARECTOR_0(__newpCapsuleSettingsEx)\r\n\tDECLAREMEMBER(pCapsuleSettingsEx,pAxisReferencedLength,radius)\r\n\tDECLAREMEMBER(pCapsuleSettingsEx,pAxisReferencedLength,height)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pMaterial)\r\n\tDECLARECTOR_0(__newpMaterial)\r\n\tDECLAREMEMBER(pMaterial,int,flags)\r\n\tDECLAREMEMBER(pMaterial,float,dynamicFriction)\r\n\tDECLAREMEMBER(pMaterial,float,staticFriction)\r\n\tDECLAREMEMBER(pMaterial,float,restitution)\r\n\tDECLAREMEMBER(pMaterial,float,dynamicFrictionV)\r\n\tDECLAREMEMBER(pMaterial,float,staticFrictionV)\r\n\tDECLAREMEMBER(pMaterial,CombineMode,frictionCombineMode)\r\n\tDECLAREMEMBER(pMaterial,CombineMode,restitutionCombineMode)\r\n\tDECLAREMEMBER(pMaterial,VxVector,dirOfAnisotropy)\r\n\tDECLAREMEMBER(pMaterial,int,xmlLinkID)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pOptimization)\r\n\tDECLARECTOR_0(__newpOptimization)\r\n\tDECLAREMEMBER(pOptimization,BodyLockFlags,transformationFlags)\r\n\tDECLAREMEMBER(pOptimization,float,linDamping)\r\n\tDECLAREMEMBER(pOptimization,float,angDamping)\r\n\tDECLAREMEMBER(pOptimization,float,linSleepVelocity)\r\n\tDECLAREMEMBER(pOptimization,float,angSleepVelocity)\r\n\tDECLAREMEMBER(pOptimization,float,sleepEnergyThreshold)\r\n\tDECLAREMEMBER(pOptimization,int,dominanceGroup)\r\n\tDECLAREMEMBER(pOptimization,int,solverIterations)\r\n\tDECLAREMEMBER(pOptimization,int,compartmentGroup)\r\n\r\n\tDECLAREOBJECTTYPE(pMassSettings)\r\n\tDECLARECTOR_0(__newpMassSettings)\r\n\tDECLAREMEMBER(pMassSettings,float,newDensity)\r\n\tDECLAREMEMBER(pMassSettings,float,totalMass)\r\n\tDECLAREMEMBER(pMassSettings,VxVector,localPosition)\r\n\tDECLAREMEMBER(pMassSettings,VxVector,localOrientation)\r\n\tDECLAREMEMBER(pMassSettings,CK_ID,massReference)\r\n\r\n\tDECLAREOBJECTTYPE(pPivotSettings)\r\n\tDECLARECTOR_0(__newpPivotSettings)\r\n\tDECLAREMEMBER(pPivotSettings,VxVector,localPosition)\r\n\tDECLAREMEMBER(pPivotSettings,VxVector,localOrientation)\r\n\tDECLAREMEMBER(pPivotSettings,CK_ID,pivotReference)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pCCDSettings)\r\n\tDECLARECTOR_0(__newpCCD)\r\n\tDECLAREMEMBER(pCCDSettings,float,motionThresold)\r\n\tDECLAREMEMBER(pCCDSettings,int,flags)\r\n\tDECLAREMEMBER(pCCDSettings,CK_ID,meshReference)\r\n\tDECLAREMEMBER(pCCDSettings,float,scale)\r\n\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pObjectDescr)\r\n\tDECLARECTOR_0(__newpObjectDescr)\r\n\tDECLAREMEMBER(pObjectDescr,HullType,hullType)\r\n\tDECLAREMEMBER(pObjectDescr,float,density)\r\n\tDECLAREMEMBER(pObjectDescr,BodyFlags,flags)\r\n\tDECLAREMEMBER(pObjectDescr,VxVector,massOffset)\r\n\tDECLAREMEMBER(pObjectDescr,VxVector,shapeOffset)\r\n\tDECLAREMEMBER(pObjectDescr,float,skinWidth)\r\n\tDECLAREMEMBER(pObjectDescr,float,newDensity)\r\n\tDECLAREMEMBER(pObjectDescr,float,totalMass)\r\n\tDECLAREMEMBER(pObjectDescr,int,collisionGroup)\r\n\tDECLAREMEMBER(pObjectDescr,int,hirarchy)\r\n\r\n\tDECLAREMEMBER(pObjectDescr,int,mask)\r\n\t\r\n\t\r\n\r\n\tDECLAREMEMBER(pObjectDescr,pCollisionSettings,collision)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pCollisionSettings&,getCollision)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setCollision,pCollisionSettings)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pMaterial,material)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pMaterial&,getMaterial)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setMaterial,pMaterial)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pMassSettings,mass)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pMassSettings&,getMass)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setMass,pMassSettings)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pCCDSettings,ccd)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pCCDSettings&,getCollision)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setCollision,pCCDSettings)\r\n\r\n\tDECLAREMEMBER(pObjectDescr,pOptimization,optimization)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pOptimization&,getOptimization)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setOptimization,pOptimization)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pPivotSettings,pivot)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pPivotSettings&,getPivot)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setPivot,pPivotSettings)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pCapsuleSettingsEx,capsule)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pCapsuleSettingsEx&,getCapsule)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setCapsule,pCapsuleSettingsEx)\r\n\t\r\n\tDECLAREMEMBER(pObjectDescr,pConvexCylinderSettings,convexCylinder)\r\n\t\tDECLAREMETHOD_0(pObjectDescr,pConvexCylinderSettings&,getConvexCylinder)\r\n\t\tDECLAREMETHOD_1(pObjectDescr,void,setConvexCylinder,pConvexCylinderSettings)\r\n\r\n\r\n\tDECLAREMETHOD_1(CK3dEntity,CKParameterOut*,GetAttributeParameter,int)\r\n\r\n\r\n\t\t//#define REGISTERVSLGUID(iGUID, iClassName)\t\tVSLM->RegisterGUID(iGUID, iClassName);\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\n\r\n\r\nPhysicManager*GetPhysicManager()\r\n{\r\n\treturn GetPMan();\r\n}\r\n/******************************************************************************\r\n\r\n Copyright (C) 1999, 2000 NVIDIA Corporation\r\n This file is provided without support, instruction, or implied warranty of any\r\n kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is\r\n not liable under any circumstances for any damages or loss whatsoever arising\r\n from the use or inability to use this file or items derived from it.\r\n \r\n Comments:\r\n \r\n \r\n \r\n******************************************************************************/\r\n#ifndef __NVFILE_H\r\n#define __NVFILE_H\r\n\r\n//#include \"NVDX8Macros.h\"\r\n#include \"nvmesh.h\"\r\n#include \"nvframe.h\"\r\n#include \r\n#include \r\ntypedef std::basic_string tstring; \r\n\r\n\r\nclass NVFile : public NVFrame\r\n{\r\n\tHRESULT LoadMesh( IDirect3DDevice9* pDevice, LPD3DXFILEDATA pFileData, \r\n\t\t\t\t\t NVFrame* pParentFrame );\r\n\tHRESULT LoadFrame( IDirect3DDevice9* pDevice, LPD3DXFILEDATA pFileData, \r\n\t\t NVFrame* pParentFrame );\r\npublic:\r\n\r\n\tvoid GetBoundingInfo(NVBounds* pBounds);\r\n\tHRESULT Create( IDirect3DDevice9* pDevice, const tstring& strFilename );\r\n\tHRESULT Render( IDirect3DDevice9* pDevice );\r\n\r\n\tNVFile() : NVFrame( _T(\"NVFile_Root\") ) {}\r\n\r\n\ttstring m_strFilePath;\r\n};\r\n\r\n#endif\r\n\r\n\r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\n\r\n#define SNDINTERNAL\r\n/*****************************************************************************\r\n*\r\n* pSeq CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF\r\n* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\r\n* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR\r\n* A PARTICULAR PURPOSE.\r\n*\r\n* Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.\r\n*\r\n******************************************************************************\r\n*\r\n*MidiSound::uence.C\r\n*\r\n*MidiSound::uencer engine for MIDI player app\r\n*\r\n*****************************************************************************/\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include \"MidiSound.h\"\r\n\r\nstatic void FAR PASCAL seqMIDICallback(HMIDISTRM hms, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);\r\nstatic MMRESULT XlatSMFErr(SMFRESULT smfrc);\r\n\r\n\r\nextern CRITICAL_SECTION gMidiCS;\r\n\r\n// Fichier de son associe\r\n MMRESULT MidiSound::SetSoundFileName(const char * name) {\r\n\t if (name==NULL) {\r\n\t\t return MCIERR_INVALID_FILE;\r\n\t }\r\n\r\n\tpSeq->pstrFile=CKStrdup((char *)name);\r\n\treturn OpenFile();\r\n}\r\n\r\n const char* MidiSound::GetSoundFileName() {\r\n\treturn pSeq->pstrFile;\r\n}\r\n\t\r\n\r\nBOOL MidiSound::IsPlaying()\r\n{\r\n\treturn (pSeq->uState==SEQ_S_PLAYING);\r\n}\r\n\r\nBOOL MidiSound::IsPaused()\r\n{\r\n\treturn (pSeq->uState==SEQ_S_PAUSED);\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::AllocBuffers\r\n*\r\n* Allocate buffers for pSeq instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance to allocate buffers for.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation was successful.\r\n*\r\n* MCIERR_OUT_OF_MEMORY If there is insufficient memory for\r\n* the requested number and size of buffers.\r\n*\r\n*MidiSound::AllocBuffers allocates playback buffers based on the\r\n* cbBuffer and cBuffer fields of pSeq. cbBuffer specifies the\r\n* number of bytes in each buffer, and cBuffer specifies the\r\n* number of buffers to allocate.\r\n*\r\n*MidiSound::AllocBuffers must be called before any otherMidiSound::uencer call\r\n* on a newly alloctedMidiSound::UENCE structure. It must be paired with\r\n* a call toMidiSound::FreeBuffers, which should be the last call made\r\n* before theMidiSound::UENCE structure is discarded.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::AllocBuffers()\r\n{\r\n DWORD dwEachBufferSize;\r\n DWORD dwAlloc;\r\n UINT i;\r\n LPBYTE lpbWork;\r\n\r\n //assert(pSeq != NULL);\r\n\r\n pSeq->uState =SEQ_S_NOFILE;\r\n pSeq->lpmhFree = NULL;\r\n pSeq->lpbAlloc = NULL;\r\n pSeq->hSmf = (HSMF)NULL;\r\n \r\n /* First make sure we can allocate the buffers they asked for\r\n */\r\n dwEachBufferSize = sizeof(MIDIHDR) + (DWORD)(pSeq->cbBuffer);\r\n dwAlloc = dwEachBufferSize * (DWORD)(pSeq->cBuffer);\r\n \r\n pSeq->lpbAlloc = (unsigned char*) GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE, dwAlloc);\r\n if (NULL == pSeq->lpbAlloc)\r\n return MCIERR_OUT_OF_MEMORY;\r\n\r\n /* Initialize all MIDIHDR's and throw them into a free list\r\n */\r\n pSeq->lpmhFree = NULL;\r\n\r\n lpbWork = pSeq->lpbAlloc;\r\n for (i=0; i < pSeq->cBuffer; i++)\r\n {\r\n ((LPMIDIHDR)lpbWork)->lpNext = pSeq->lpmhFree;\r\n\r\n ((LPMIDIHDR)lpbWork)->lpData = (char*)lpbWork + sizeof(MIDIHDR);\r\n ((LPMIDIHDR)lpbWork)->dwBufferLength = pSeq->cbBuffer;\r\n ((LPMIDIHDR)lpbWork)->dwBytesRecorded = 0;\r\n ((LPMIDIHDR)lpbWork)->dwUser = (DWORD)(UINT)pSeq;\r\n ((LPMIDIHDR)lpbWork)->dwFlags = 0;\r\n\r\n pSeq->lpmhFree = (LPMIDIHDR)lpbWork;\r\n\r\n lpbWork += dwEachBufferSize;\r\n }\r\n\r\n return MMSYSERR_NOERROR;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::FreeBuffers\r\n*\r\n* Free buffers for pSeq instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance to free buffers for.\r\n* \r\n*MidiSound::FreeBuffers frees all allocated memory belonging to the\r\n* givenMidiSound::uencer instance pSeq. It must be the last call\r\n* performed on the instance before it is destroyed.\r\n* \r\n****************************************************************************/\r\n VOID MidiSound::FreeBuffers()\r\n{\r\n LPMIDIHDR lpmh;\r\n \r\n //assert(pSeq != NULL);\r\n\r\n if (NULL != pSeq->lpbAlloc)\r\n {\r\n lpmh = (LPMIDIHDR)pSeq->lpbAlloc;\r\n //assert(!(lpmh->dwFlags & MHDR_PREPARED));\r\n \r\n GlobalFreePtr(pSeq->lpbAlloc);\r\n }\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::OpenFile\r\n*\r\n* Associates a MIDI file with the givenMidiSound::uencer instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If there is already a file open\r\n* on pSeq instance.\r\n* \r\n* MCIERR_OUT_OF_MEMORY If there was insufficient memory to\r\n* allocate internal buffers on the file.\r\n*\r\n* MCIERR_INVALID_FILE If initial attempts to parse the file\r\n* failed (such as the file is not a MIDI or RMI file).\r\n*\r\n*MidiSound::OpenFile may only be called if there is no currently open file\r\n* on the instance. It must be paired with a call toMidiSound::CloseFile\r\n* when operations on pSeq file are complete.\r\n*\r\n* The pstrFile field of pSeq contains the name of the file\r\n* to open. pSeq name will be passed directly to mmioOpen; it may\r\n* contain a specifcation for a custom MMIO file handler. The task\r\n* context used for all I/O will be the task which callsMidiSound::OpenFile.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::OpenFile()\r\n{ \r\n MMRESULT rc = MMSYSERR_NOERROR;\r\n SMFOPENFILESTRUCT sofs;\r\n SMFFILEINFO sfi;\r\n SMFRESULT smfrc;\r\n DWORD cbBuffer;\r\n\r\n //assert(pSeq != NULL);\r\n\r\n if (pSeq->uState !=SEQ_S_NOFILE)\r\n {\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n }\r\n\r\n //assert(pSeq->pstrFile != NULL);\r\n \r\n sofs.pstrName = pSeq->pstrFile;\r\n\r\n smfrc = smfOpenFile(&sofs);\r\n if (SMF_SUCCESS != smfrc)\r\n {\r\n rc = XlatSMFErr(smfrc);\r\n goto Seq_Open_File_Cleanup;\r\n }\r\n\r\n pSeq->hSmf = sofs.hSmf;\r\n smfGetFileInfo(pSeq->hSmf, &sfi);\r\n \r\n pSeq->dwTimeDivision = sfi.dwTimeDivision;\r\n pSeq->tkLength = sfi.tkLength;\r\n pSeq->cTrk = sfi.dwTracks;\r\n \r\n /* Track buffers must be big enough to hold the state data returned\r\n ** by smfSeek()\r\n */\r\n cbBuffer = __min(pSeq->cbBuffer, smfGetStateMaxSize());\r\n \r\nSeq_Open_File_Cleanup: \r\n if (MMSYSERR_NOERROR != rc)\r\n CloseFile();\r\n else\r\n pSeq->uState =SEQ_S_OPENED;\r\n\r\n return rc;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::CloseFile\r\n*\r\n* Deassociates a MIDI file with the givenMidiSound::uencer instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* stopped.\r\n* \r\n* A call toMidiSound::CloseFile must be paired with a prior call to\r\n*MidiSound::OpenFile. All buffers associated with the file will be\r\n* freed and the file will be closed. TheMidiSound::uencer must be\r\n* stopped before pSeq call will be accepted.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::CloseFile()\r\n{\r\n LPMIDIHDR lpmh;\r\n \r\n //assert(pSeq != NULL);\r\n \r\n if (SEQ_S_OPENED != pSeq->uState)\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n \r\n if ((HSMF)NULL != pSeq->hSmf)\r\n {\r\n smfCloseFile(pSeq->hSmf);\r\n pSeq->hSmf = (HSMF)NULL;\r\n }\r\n\r\n /* If we were prerolled, need to clean up -- have an open MIDI handle\r\n ** and buffers in the ready queue\r\n */\r\n\t//EnterCriticalSection(&gMidiCS);\r\n\t\r\n for (lpmh = pSeq->lpmhFree; lpmh; lpmh = lpmh->lpNext)\r\n midiOutUnprepareHeader(pSeq->hmidi, lpmh, sizeof(*lpmh));\r\n\r\n if (pSeq->lpmhPreroll)\r\n\t{\r\n midiOutUnprepareHeader(pSeq->hmidi, pSeq->lpmhPreroll, sizeof(*pSeq->lpmhPreroll));\r\n\t\t(void) GlobalFreePtr(pSeq->lpmhPreroll);\r\n\t}\r\n\r\n if (pSeq->hmidi != NULL)\r\n {\r\n // cast by aymeric\r\n\t\t//EnterCriticalSection(&gMidiCS);\t\t\t\r\n\t\tmidiStreamClose((HMIDISTRM)pSeq->hmidi);\r\n pSeq->hmidi = NULL;\r\n\t\t//LeaveCriticalSection(&gMidiCS);\t\t\r\n\t}\r\n pSeq->uState =SEQ_S_NOFILE;\r\n\t\r\n\t//LeaveCriticalSection(&gMidiCS);\r\n\r\n return MMSYSERR_NOERROR;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Preroll\r\n*\r\n* Prepares the file for playback at the given position.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* lpPreroll - Specifies the starting and ending tick\r\n* positions to play between.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* opened or prerolled.\r\n*\r\n* Open the device so we can initialize channels.\r\n*\r\n* Loop through the tracks. For each track, seek to the given position and\r\n* send the init data SMF gives us to the handle.\r\n*\r\n* Wait for all init buffers to finish.\r\n*\r\n* Unprepare the buffers (they're only ever sent here; theMidiSound::uencer\r\n* engine merges them into a single stream during normal playback) and\r\n* refill them with the first chunk of data from the track. \r\n*\r\n* \r\n****************************************************************************/\r\n MMRESULT MidiSound::Preroll()\r\n{\r\n\tpSeq->tkBase=0;\r\n\tpSeq->tkEnd=pSeq->tkLength;\r\n\tstruct tag_preroll prerroll={0,pSeq->tkLength};\r\n\tLPPREROLL lpPreroll=&prerroll;\r\n SMFRESULT smfrc;\r\n MMRESULT mmrc = MMSYSERR_NOERROR;\r\n MIDIPROPTIMEDIV mptd;\r\n LPMIDIHDR lpmh = NULL;\r\n LPMIDIHDR lpmhPreroll = NULL;\r\n DWORD cbPrerollBuffer;\r\n UINT uDeviceID=MIDI_MAPPER ;\r\n\r\n //assert(pSeq != NULL);\r\n\r\n pSeq->mmrcLastErr = MMSYSERR_NOERROR;\r\n\r\n if (pSeq->uState !=SEQ_S_OPENED &&\r\n pSeq->uState !=SEQ_S_PREROLLED)\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n\r\n\tpSeq->tkBase = lpPreroll->tkBase;\r\n\tpSeq->tkEnd = lpPreroll->tkEnd;\r\n\r\n if (pSeq->hmidi)\r\n {\r\n // Recollect buffers from MMSYSTEM back into free queue\r\n //\r\n\t\t//EnterCriticalSection(&gMidiCS);\r\n pSeq->uState =SEQ_S_RESET;\r\n midiOutReset(pSeq->hmidi);\r\n\t\t//LeaveCriticalSection(&gMidiCS);\r\n\t\twhile (pSeq->uBuffersInMMSYSTEM)\r\n\t\t\tSleep(0);\r\n }\r\n \r\n pSeq->uBuffersInMMSYSTEM = 0;\r\n pSeq->uState =SEQ_S_PREROLLING;\r\n \r\n //\r\n // We've successfully opened the file and all of the tracks; now\r\n // open the MIDI device and set the time division.\r\n //\r\n // NOTE:MidiSound::Preroll is equivalent to seek; device might already be open\r\n //\r\n if (NULL == pSeq->hmidi)\r\n {\r\n uDeviceID = pSeq->uDeviceID;\r\n\t\tuDeviceID = MIDI_MAPPER;\r\n // cast by aymeric\r\n\t\tif ((mmrc = midiStreamOpen((LPHMIDISTRM)&pSeq->hmidi,\r\n &uDeviceID,\r\n 1,\r\n (DWORD)seqMIDICallback,\r\n 0,\r\n CALLBACK_FUNCTION)) != MMSYSERR_NOERROR)\r\n {\r\n pSeq->hmidi = NULL;\r\n goto Preroll_Cleanup;\r\n }\r\n \r\n mptd.cbStruct = sizeof(mptd);\r\n mptd.dwTimeDiv = pSeq->dwTimeDivision;\r\n // cast by aymeric\r\n if ((mmrc = midiStreamProperty(\r\n (HMIDISTRM)pSeq->hmidi,\r\n (LPBYTE)&mptd,\r\n MIDIPROP_SET|MIDIPROP_TIMEDIV)) != MMSYSERR_NOERROR)\r\n {\r\n //DPF(1, \"midiStreamProperty() -> %04X\", (WORD)mmrc);\r\n\t\t\t//EnterCriticalSection(&gMidiCS);\r\n\t\t\t\tmidiStreamClose((HMIDISTRM)pSeq->hmidi); \r\n\t\t\t\tpSeq->hmidi = NULL;\r\n\t\t\t\tmmrc = MCIERR_DEVICE_NOT_READY;\r\n //LeaveCriticalSection(&gMidiCS);\r\n\t\t\tgoto Preroll_Cleanup;\r\n }\r\n }\r\n\r\n mmrc = MMSYSERR_NOERROR;\r\n\r\n //\r\n // Allocate a preroll buffer. Then if we don't have enough room for\r\n // all the preroll info, we make the buffer larger. \r\n //\r\n if (!pSeq->lpmhPreroll)\r\n {\r\n cbPrerollBuffer = 4096;\r\n lpmhPreroll = (LPMIDIHDR)GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE,\r\n cbPrerollBuffer);\r\n }\r\n else\r\n {\r\n cbPrerollBuffer = pSeq->cbPreroll;\r\n lpmhPreroll = pSeq->lpmhPreroll;\r\n }\r\n\r\n lpmhPreroll->lpNext = pSeq->lpmhFree;\r\n lpmhPreroll->lpData = (char*)lpmhPreroll + sizeof(MIDIHDR);\r\n lpmhPreroll->dwBufferLength = cbPrerollBuffer - sizeof(MIDIHDR);\r\n lpmhPreroll->dwBytesRecorded = 0;\r\n lpmhPreroll->dwUser = (DWORD)(UINT)pSeq;\r\n lpmhPreroll->dwFlags = 0;\r\n\r\n do\r\n {\r\n smfrc = smfSeek(pSeq->hSmf, pSeq->tkBase, lpmhPreroll);\r\n if( SMF_SUCCESS != smfrc )\r\n {\r\n if( ( SMF_NO_MEMORY != smfrc ) ||\r\n ( cbPrerollBuffer >= 32768L ) )\r\n {\r\n //DPF(1, \"smfSeek() returned %lu\", (DWORD)smfrc);\r\n\r\n GlobalFreePtr(lpmhPreroll);\r\n pSeq->lpmhPreroll = NULL;\r\n\r\n mmrc = XlatSMFErr(smfrc);\r\n goto Preroll_Cleanup;\r\n }\r\n else // Try to grow buffer.\r\n {\r\n cbPrerollBuffer *= 2;\r\n lpmh = (LPMIDIHDR)GlobalReAllocPtr( lpmhPreroll, cbPrerollBuffer, 0 );\r\n if( NULL == lpmh )\r\n {\r\n //DPF(2,\"seqPreroll - realloc failed, aborting preroll.\");\r\n mmrc = MCIERR_OUT_OF_MEMORY;\r\n goto Preroll_Cleanup;\r\n }\r\n\r\n lpmhPreroll = lpmh;\r\n lpmhPreroll->lpData = (char*)lpmhPreroll + sizeof(MIDIHDR);\r\n lpmhPreroll->dwBufferLength = cbPrerollBuffer - sizeof(MIDIHDR);\r\n\r\n pSeq->lpmhPreroll = lpmhPreroll;\r\n pSeq->cbPreroll = cbPrerollBuffer;\r\n }\r\n }\r\n } while( SMF_SUCCESS != smfrc );\r\n\r\n if (!pSeq->lpmhPreroll)\r\n {\r\n\t\t//to keep access to buffer and free memory before closing\r\n\t\tpSeq->lpmhPreroll = lpmhPreroll;\r\n\t\tpSeq->cbPreroll = cbPrerollBuffer;\r\n\t}\r\n\r\n if (MMSYSERR_NOERROR != (mmrc = midiOutPrepareHeader(pSeq->hmidi, lpmhPreroll, sizeof(MIDIHDR))))\r\n {\r\n //DPF(1, \"midiOutPrepare(preroll) -> %lu!\", (DWORD)mmrc);\r\n\r\n mmrc = MCIERR_DEVICE_NOT_READY;\r\n goto Preroll_Cleanup;\r\n }\r\n\r\n ++pSeq->uBuffersInMMSYSTEM;\r\n\r\n if (MMSYSERR_NOERROR != (mmrc = midiStreamOut((HMIDISTRM)pSeq->hmidi, lpmhPreroll, sizeof(MIDIHDR))))\r\n {\r\n //DPF(1, \"midiStreamOut(preroll) -> %lu!\", (DWORD)mmrc);\r\n\r\n mmrc = MCIERR_DEVICE_NOT_READY;\r\n --pSeq->uBuffersInMMSYSTEM;\r\n goto Preroll_Cleanup;\r\n }\r\n //DPF(3,\"seqPreroll: midiStreamOut(0x%x,0x%lx,%u) returned %u.\",pSeq->hmidi,lpmhPreroll,sizeof(MIDIHDR),mmrc);\r\n\r\n pSeq->fdwSeq &= ~SEQ_F_EOF;\r\n while (pSeq->lpmhFree)\r\n {\r\n lpmh = pSeq->lpmhFree;\r\n pSeq->lpmhFree = lpmh->lpNext;\r\n\r\n smfrc = smfReadEvents(pSeq->hSmf, lpmh, pSeq->tkEnd);\r\n if (SMF_SUCCESS != smfrc && SMF_END_OF_FILE != smfrc)\r\n {\r\n //DPF(1, \"SFP: smfReadEvents() -> %u\", (UINT)smfrc);\r\n mmrc = XlatSMFErr(smfrc);\r\n goto Preroll_Cleanup;\r\n }\r\n\r\n if (MMSYSERR_NOERROR != (mmrc = midiOutPrepareHeader(pSeq->hmidi, lpmh, sizeof(*lpmh))))\r\n {\r\n //DPF(1, \"SFP: midiOutPrepareHeader failed\");\r\n goto Preroll_Cleanup;\r\n }\r\n\r\n if (MMSYSERR_NOERROR != (mmrc = midiStreamOut((HMIDISTRM)pSeq->hmidi, lpmh, sizeof(*lpmh))))\r\n {\r\n //DPF(1, \"SFP: midiStreamOut failed\");\r\n goto Preroll_Cleanup;\r\n }\r\n\r\n ++pSeq->uBuffersInMMSYSTEM; \r\n\r\n if (SMF_END_OF_FILE == smfrc)\r\n {\r\n pSeq->fdwSeq |=SEQ_F_EOF;\r\n break;\r\n }\r\n } \r\n\r\nPreroll_Cleanup:\r\n if (MMSYSERR_NOERROR != mmrc)\r\n {\r\n pSeq->uState =SEQ_S_OPENED;\r\n pSeq->fdwSeq &= ~SEQ_F_WAITING;\r\n }\r\n else\r\n {\r\n pSeq->uState =SEQ_S_PREROLLED;\r\n }\r\n\r\n return mmrc;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Start\r\n*\r\n* Starts playback at the current position.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* stopped.\r\n*\r\n* MCIERR_DEVICE_NOT_READY If the underlying MIDI device could\r\n* not be opened or fails any call.\r\n* \r\n* TheMidiSound::uencer must be prerolled beforeMidiSound::Start may be called.\r\n*\r\n* Just feed everything in the ready queue to the device.\r\n* \r\n***************************************************************************/\r\n MMRESULT MidiSound::Start()\r\n{\r\n if (NULL == pSeq)\r\n\t{\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n }\r\n\r\n if (SEQ_S_PREROLLED != pSeq->uState)\r\n {\r\n\tPreroll();\r\n\t}\r\n\r\n if (SEQ_S_PREROLLED != pSeq->uState)\r\n {\r\n //DPF(1, \"seqStart(): State is wrong! [%u]\", pSeq->uState);\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n }\r\n\r\n pSeq->uState =SEQ_S_PLAYING;\r\n\r\n return midiStreamRestart((HMIDISTRM)pSeq->hmidi);\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Pause\r\n*\r\n* Pauses playback of the instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* playing.\r\n*\r\n* TheMidiSound::uencer must be playing beforeMidiSound::Pause may be called.\r\n* Pausing theMidiSound::uencer will cause all currently on notes to be turned\r\n* off. pSeq may cause playback to be slightly inaccurate on restart\r\n* due to missing notes.\r\n* \r\n***************************************************************************/\r\n MMRESULT MidiSound::Pause()\r\n{\r\n //assert(NULL != pSeq);\r\n \r\n if (SEQ_S_PLAYING != pSeq->uState)\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n\r\n pSeq->uState =SEQ_S_PAUSED;\r\n\r\n\tOutputDebugString(\"MidiSound::Pause\\n\");\r\n\t\r\n\t//EnterCriticalSection(&gMidiCS); \r\n midiStreamPause((HMIDISTRM)pSeq->hmidi);\r\n //LeaveCriticalSection(&gMidiCS);\r\n \r\n return MMSYSERR_NOERROR;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Restart\r\n*\r\n* Restarts playback of an instance after a pause.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* paused.\r\n*\r\n* TheMidiSound::uencer must be paused beforeMidiSound::Restart may be called.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::Restart()\r\n{\r\n //assert(NULL != pSeq);\r\n\r\n\t switch(pSeq->uState){\r\n\t\tcase SEQ_S_PAUSED: \r\n\t\t\tpSeq->uState =SEQ_S_PLAYING;\r\n\t\t\tmidiStreamRestart((HMIDISTRM)pSeq->hmidi);\t \r\n\t\t\tbreak;\r\n\t \r\n\t\tcase SEQ_S_OPENED:\r\n\t\t\tStart();\r\n\t\t\tbreak;\r\n\t }\r\n return MMSYSERR_NOERROR;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Stop\r\n*\r\n* Totally stops playback of an instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* paused or playing.\r\n*\r\n* TheMidiSound::uencer must be paused or playing beforeMidiSound::Stop may be called.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::Stop()\r\n{\r\n //assert(NULL != pSeq);\r\n\r\n /* Automatic success if we're already stopped\r\n */\r\n if (SEQ_S_PLAYING != pSeq->uState &&\r\n SEQ_S_PAUSED != pSeq->uState)\r\n {\r\n pSeq->fdwSeq &= ~SEQ_F_WAITING;\r\n return MMSYSERR_NOERROR;\r\n }\r\n\r\n pSeq->uState =SEQ_S_STOPPING;\r\n pSeq->fdwSeq |=SEQ_F_WAITING;\r\n //EnterCriticalSection(&gMidiCS);\r\n\r\n\tOutputDebugString(\"MidiSound::Stop\\n\");\r\n\r\n\tif(pSeq->hmidi){\r\n\t\t\r\n#if 1 //--- modification by Francisco\r\n\t\tpSeq->mmrcLastErr = midiStreamClose((HMIDISTRM)pSeq->hmidi);\r\n\t\tpSeq->uState = SEQ_S_OPENED;\r\n\t\tpSeq->hmidi = 0;\r\n\t\tpSeq->fdwSeq &= ~SEQ_F_WAITING;\r\n return MMSYSERR_NOERROR;\r\n#else //---\t\t\r\n\t\tif (MMSYSERR_NOERROR != (pSeq->mmrcLastErr = midiStreamStop((HMIDISTRM)pSeq->hmidi)))\r\n\t\t{\r\n\t\t\tpSeq->fdwSeq &= ~SEQ_F_WAITING;\r\n\t\t\t//LeaveCriticalSection(&gMidiCS);\r\n\t\t\treturn MCIERR_DEVICE_NOT_READY;\r\n\t\t}\r\n\r\n\t\twhile (pSeq->uBuffersInMMSYSTEM)\r\n\t\t\tSleep(0);\r\n\r\n\t\tif(pSeq->hmidi)\t\t\t\r\n\t\t\tmidiStreamClose((HMIDISTRM)pSeq->hmidi);\r\n#endif\r\n\t} \r\n //LeaveCriticalSection(&gMidiCS);\r\n\treturn MMSYSERR_NOERROR;\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::Time\r\n*\r\n* Determine the current position in playback of an instance.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* pTicks - A pointer to a DWORD where the current position\r\n* in ticks will be returned.\r\n*\r\n* Returns\r\n* MMSYSERR_NOERROR If the operation is successful.\r\n*\r\n* MCIERR_DEVICE_NOT_READY If the underlying device fails to report\r\n* the position.\r\n* \r\n* MCIERR_UNSUPPORTED_FUNCTION If theMidiSound::uencer instance is not\r\n* paused or playing.\r\n*\r\n* TheMidiSound::uencer must be paused, playing or prerolled beforeMidiSound::Time\r\n* may be called.\r\n*\r\n***************************************************************************/\r\n MMRESULT MidiSound::Time(PTICKS pTicks)\r\n{\r\n MMRESULT mmr;\r\n MMTIME mmt;\r\n \r\n //assert(pSeq != NULL);\r\n\r\n if (SEQ_S_PLAYING != pSeq->uState &&\r\n SEQ_S_PAUSED != pSeq->uState &&\r\n SEQ_S_PREROLLING != pSeq->uState &&\r\n SEQ_S_PREROLLED != pSeq->uState &&\r\n SEQ_S_OPENED != pSeq->uState)\r\n {\r\n //DPF(1, \"seqTime(): State wrong! [is %u]\", pSeq->uState);\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n }\r\n\r\n *pTicks = 0;\r\n if (SEQ_S_OPENED != pSeq->uState)\r\n {\r\n *pTicks = pSeq->tkBase;\r\n if (SEQ_S_PREROLLED != pSeq->uState)\r\n {\r\n mmt.wType = TIME_TICKS;\r\n mmr = midiStreamPosition((HMIDISTRM)pSeq->hmidi, &mmt, sizeof(mmt));\r\n if (MMSYSERR_NOERROR != mmr)\r\n {\r\n //DPF(1, \"midiStreamPosition() returned %lu\", (DWORD)mmr);\r\n return MCIERR_DEVICE_NOT_READY;\r\n }\r\n\r\n *pTicks += mmt.u.ticks;\r\n }\r\n }\r\n\r\n return MMSYSERR_NOERROR;\r\n}\r\n \r\n/***************************************************************************\r\n* \r\n*MidiSound::MillisecsToTicks\r\n*\r\n* Given a millisecond offset in the output stream, returns the associated\r\n* tick position.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* msOffset - The millisecond offset into the stream.\r\n*\r\n* Returns the number of ticks into the stream.\r\n*\r\n***************************************************************************/\r\n TICKS MidiSound::MillisecsToTicks(DWORD msOffset)\r\n{\r\n return smfMillisecsToTicks(pSeq->hSmf, msOffset);\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::TicksToMillisecs\r\n*\r\n* Given a tick offset in the output stream, returns the associated\r\n* millisecond position.\r\n*\r\n* pSeq - TheMidiSound::uencer instance.\r\n*\r\n* tkOffset - The tick offset into the stream.\r\n*\r\n* Returns the number of milliseconds into the stream.\r\n*\r\n***************************************************************************/\r\n DWORD MidiSound::TicksToMillisecs(TICKS tkOffset)\r\n{\r\n return smfTicksToMillisecs(pSeq->hSmf, tkOffset);\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n*MidiSound::MIDICallback\r\n*\r\n* Called by the system when a buffer is done\r\n*\r\n* dw1 - The buffer that has completed playback.\r\n*\r\n***************************************************************************/\r\nstatic void FAR PASCAL seqMIDICallback(HMIDISTRM hms, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)\r\n{\r\n\tLPMIDIHDR\t\t\t\t\tlpmh\t\t= (LPMIDIHDR)dw1;\r\n PSEQ pSeq;\r\n MMRESULT mmrc;\r\n SMFRESULT smfrc;\r\n\r\n\tif (uMsg != MOM_DONE)\r\n\t\treturn;\r\n\r\n\t//assert(NULL != lpmh);\r\n\r\n pSeq = (PSEQ)(lpmh->dwUser);\r\n\r\n //assert(pSeq != NULL);\r\n\r\n --pSeq->uBuffersInMMSYSTEM;\r\n \r\n if (SEQ_S_RESET == pSeq->uState)\r\n {\r\n // We're recollecting buffers from MMSYSTEM\r\n //\r\n\t\tif (lpmh != pSeq->lpmhPreroll)\r\n\t\t{\r\n \tlpmh->lpNext = pSeq->lpmhFree;\r\n \tpSeq->lpmhFree = lpmh;\r\n\t\t}\r\n\r\n return;\r\n }\r\n \r\n\r\n if ((SEQ_S_STOPPING == pSeq->uState) || (pSeq->fdwSeq &SEQ_F_EOF))\r\n {\r\n /*\r\n ** Reached EOF, just put the buffer back on the free\r\n ** list \r\n */\r\n\t\tif (lpmh != pSeq->lpmhPreroll)\r\n\t\t{\r\n \tlpmh->lpNext = pSeq->lpmhFree;\r\n \tpSeq->lpmhFree = lpmh;\r\n\t\t}\r\n\r\n if (MMSYSERR_NOERROR != (mmrc = midiOutUnprepareHeader(pSeq->hmidi, lpmh, sizeof(*lpmh))))\r\n {\r\n //DPF(1, \"midiOutUnprepareHeader failed inMidiSound::BufferDone! (%lu)\", (DWORD)mmrc);\r\n }\r\n\r\n if (0 == pSeq->uBuffersInMMSYSTEM)\r\n {\r\n //DPF(1, \"seqBufferDone: normalMidiSound::uencer shutdown.\");\r\n \r\n /* Totally done! Free device and notify.\r\n */\r\n\t\t\t//EnterCriticalSection(&gMidiCS);\r\n\t\t\tOutputDebugString(\"midiStreamClose\\n\");\r\n/*\r\n\t\t\tif(pSeq->hmidi)\t\t\t\r\n\t\t\t\tmidiStreamClose((HMIDISTRM)pSeq->hmidi);\r\n*/ \t\t\t\r\n pSeq->hmidi = NULL;\r\n pSeq->uState =SEQ_S_OPENED;\r\n pSeq->mmrcLastErr = MMSYSERR_NOERROR;\r\n pSeq->fdwSeq &= ~SEQ_F_WAITING;\r\n\r\n\t\t\t//LeaveCriticalSection(&gMidiCS);\r\n\r\n \t// lParam indicates whether or not to preroll again. Don't if we were explicitly\r\n \t// stopped.\r\n \t// \r\n PostMessage(pSeq->hWnd, MMSG_DONE, (WPARAM)pSeq, (LPARAM)(SEQ_S_STOPPING != pSeq->uState));\r\n }\r\n }\r\n else\r\n {\r\n /*\r\n ** Not EOF yet; attempt to fill another buffer\r\n */\r\n smfrc = smfReadEvents(pSeq->hSmf, lpmh, pSeq->tkEnd);\r\n \r\n switch(smfrc)\r\n {\r\n case SMF_SUCCESS:\r\n break;\r\n\r\n case SMF_END_OF_FILE:\r\n pSeq->fdwSeq |=SEQ_F_EOF;\r\n smfrc = SMF_SUCCESS;\r\n break;\r\n\r\n default:\r\n //DPF(1, \"smfReadEvents returned %lu in callback!\", (DWORD)smfrc);\r\n pSeq->uState =SEQ_S_STOPPING;\r\n break;\r\n }\r\n\r\n if (SMF_SUCCESS == smfrc)\r\n {\r\n ++pSeq->uBuffersInMMSYSTEM;\r\n mmrc = midiStreamOut((HMIDISTRM)pSeq->hmidi, lpmh, sizeof(*lpmh));\r\n if (MMSYSERR_NOERROR != mmrc)\r\n {\r\n //DPF(1, \"seqBufferDone(): midiStreamOut() returned %lu!\", (DWORD)mmrc);\r\n \r\n --pSeq->uBuffersInMMSYSTEM;\r\n pSeq->uState =SEQ_S_STOPPING;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/***************************************************************************\r\n* \r\n* XlatSMFErr\r\n*\r\n* Translates an error from the SMF layer into an appropriate MCI error.\r\n*\r\n* smfrc - The return code from any SMF function.\r\n*\r\n* Returns\r\n* A parallel error from the MCI error codes. \r\n*\r\n***************************************************************************/\r\nstatic MMRESULT XlatSMFErr(SMFRESULT smfrc)\r\n{\r\n switch(smfrc)\r\n {\r\n case SMF_SUCCESS:\r\n return MMSYSERR_NOERROR;\r\n\r\n case SMF_NO_MEMORY:\r\n return MCIERR_OUT_OF_MEMORY;\r\n\r\n case SMF_INVALID_FILE:\r\n case SMF_OPEN_FAILED:\r\n case SMF_INVALID_TRACK:\r\n return MCIERR_INVALID_FILE;\r\n\r\n default:\r\n return MCIERR_UNSUPPORTED_FUNCTION;\r\n }\r\n}\r\n\r\n\r\n MidiSound::MidiSound(void *hwnd) {\r\n if ((pSeq = (PSEQ)LocalAlloc(LPTR, sizeof(SEQ))) == NULL)\r\n return;\r\n\r\n pSeq->cBuffer = 4;\r\n pSeq->cbBuffer = 1024;\r\n\tpSeq->pstrFile = NULL;\r\n\r\n if (AllocBuffers() != MMSYSERR_NOERROR)\r\n return;\r\n pSeq->hWnd = (HWND)hwnd;\r\n}\r\n\r\nMidiSound::~MidiSound() {\r\n\tStop();\r\n\tif (pSeq->pstrFile)\r\n\t\tfree(pSeq->pstrFile);\r\n\tpSeq->pstrFile=NULL;\r\n\tFreeBuffers();\r\n\tLocalFree(pSeq);\r\n}\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n\r\n\r\n#define PARAMETER_OP_TYPE_STRING_TO_ATT CKGUID(0x3678447e,0x30362a74)\r\n\r\n#define PARAM_OP_TYPE_CIS_INI_COLLISION CKGUID(0x4ec2349b,0x5edf7dd8)\r\n#define PARAM_OP_TYPE_CHAS_CONTACT CKGUID(0x3ed57b83,0x47ad145f)\r\n#define PARAM_OP_TYPE_CRAY_COLLISION CKGUID(0x53425880,0x1b540c2b)\r\n\r\n#define PARAM_OP_TYPE_CGROUP_COLLISION CKGUID(0x7b762a1a,0x702e471c)\r\n\r\n#define PARAM_OP_RC_ANY_BOUNDS CKGUID(0x31e415e2,0x61e42210)\r\n#define PARAM_OP_RC_ANY_SHAPE CKGUID(0x62943427,0x31877a8f)\r\n\r\n\r\n\r\nvoid ParamOpRayCastAnyShape(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tCK_ID targetID = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_WORLD,false);\r\n\tCK_ID oriRef = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_ORI_REF,false);\r\n\tCK_ID dirRef = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_DIR_REF,false);\r\n\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorld(targetID);\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tint result = false;\r\n\t\t\tres->SetValue(&result);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tCK3dEntity *rayOriRef= (CK3dEntity *)GetPMan()->m_Context->GetObject(oriRef);\r\n\t\tCK3dEntity *rayDirRef= (CK3dEntity *) GetPMan()->m_Context->GetObject(dirRef);\r\n\r\n\t\tVxVector ori = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_ORI,false);\r\n\t\tVxVector dir = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_DIR,false);\r\n\r\n\t\tVxVector oriOut = ori;\r\n\t\tif (rayOriRef)\r\n\t\t{\r\n\t\t\trayOriRef->Transform(&oriOut,&ori);\r\n\t\t}\r\n\r\n\t\t//dir : \r\n\t\tVxVector dirOut = dir;\r\n\t\tif (rayDirRef)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\trayDirRef->GetOrientation(&dir,&up,&right);\r\n\t\t\trayDirRef->TransformVector(&dirOut,&up);\r\n\t\t}\r\n\r\n\t\tint groups = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_GROUPS,false);\r\n\t\tfloat length = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_LENGTH,false);\r\n\t\tint types = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_SHAPES_TYPES,false);\r\n\r\n\r\n\t\tCK_ID* paramids = static_cast(p1->GetReadDataPtr());\t\r\n\t\tCKParameterOut* maskP = static_cast(p1->GetCKContext()->GetObject(paramids[E_RC_GROUPS_MASK]));\r\n\r\n\t\tNxGroupsMask mask;\r\n\t\tmask.bits0 = GetValueFromParameterStruct(maskP,0);\r\n\t\tmask.bits1 = GetValueFromParameterStruct(maskP,1);\r\n\t\tmask.bits2 = GetValueFromParameterStruct(maskP,2);\r\n\t\tmask.bits3 = GetValueFromParameterStruct(maskP,3);\r\n\r\n\t\tNxRay ray;\r\n\t\tray.orig = getFrom(oriOut);\r\n\t\tray.dir = getFrom(dirOut);\r\n\r\n\r\n\t\t//NxShape **shapes = new NxShape*[2];\r\n\r\n\t\tNxU32 total = world->getScene()->getTotalNbShapes();//world->getScene()->getNbDynamicShapes() + world->getScene()->getNbStaticShapes();\r\n\t\t//NxShape** shapes = NULL ;//(NxShape**)NxAlloca(nbShapes*sizeof(NxShape*));\r\n\r\n\t\tNxShape** shapes = (NxShape**)NxAlloca(total*sizeof(NxShape*));\r\n\t\tfor (NxU32 i = 0; i < total; i++) shapes[i] = NULL;\r\n\r\n\t\t//NxShape **shapes = NULL;\r\n\t\tint result = world->getScene()->raycastAnyShape(ray,(NxShapesType)types,groups,length,&mask,shapes);\r\n\t\t\r\n\t\t\tNxShape *s = shapes[0];\r\n\t\t\tif (s)\r\n\t\t\t{\r\n\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\tif (obj)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCK_ID id = obj->GetID();\r\n\t\t\t\t\t\tres->SetValue(&id);\r\n\t\t\t\t\t\t//beh->SetOutputParameterObject(bbO_Shape,obj);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\r\n\r\n\t\t//res->SetValue(&result);\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n}\r\n\r\n\r\nvoid ParamOpRayCastAnyBounds(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tCK_ID targetID = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_WORLD,false);\r\n\tCK_ID oriRef = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_ORI_REF,false);\r\n\tCK_ID dirRef = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_DIR_REF,false);\r\n\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorld(targetID);\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tint result = false;\r\n\t\t\tres->SetValue(&result);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tCK3dEntity *rayOriRef= (CK3dEntity *)GetPMan()->m_Context->GetObject(oriRef);\r\n\t\tCK3dEntity *rayDirRef= (CK3dEntity *) GetPMan()->m_Context->GetObject(dirRef);\r\n\r\n\t\tVxVector ori = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_ORI,false);\r\n\t\tVxVector dir = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_DIR,false);\r\n\r\n\t\tVxVector oriOut = ori;\r\n\t\tif (rayOriRef)\r\n\t\t{\r\n\t\t\trayOriRef->Transform(&oriOut,&ori);\r\n\t\t}\r\n\r\n\t\t//dir : \r\n\t\tVxVector dirOut = dir;\r\n\t\tif (rayDirRef)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\trayDirRef->GetOrientation(&dir,&up,&right);\r\n\t\t\trayDirRef->TransformVector(&dirOut,&up);\r\n\t\t}\r\n\r\n\t\tint groups = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_GROUPS,false);\r\n\t\tfloat length = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_LENGTH,false);\r\n\t\tint types = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),E_RC_SHAPES_TYPES,false);\r\n\r\n\r\n\t\tCK_ID* paramids = static_cast(p1->GetReadDataPtr());\t\r\n\t\tCKParameterOut* maskP = static_cast(p1->GetCKContext()->GetObject(paramids[E_RC_GROUPS_MASK]));\r\n\r\n\t\tNxGroupsMask mask;\r\n\t\tmask.bits0 = GetValueFromParameterStruct(maskP,0);\r\n\t\tmask.bits1 = GetValueFromParameterStruct(maskP,1);\r\n\t\tmask.bits2 = GetValueFromParameterStruct(maskP,2);\r\n\t\tmask.bits3 = GetValueFromParameterStruct(maskP,3);\r\n\r\n\t\tNxRay ray;\r\n\t\tray.orig = getFrom(oriOut);\r\n\t\tray.dir = getFrom(dirOut);\r\n\r\n\t\tint result = world->getScene()->raycastAnyBounds(ray,(NxShapesType)types,groups,length,&mask);\r\n\r\n\t\tres->SetValue(&result);\r\n\t\treturn;\r\n\r\n\r\n\r\n\r\n\t}\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#define PARAM_OP_TYPE_MGET_SFRICTION CKGUID(0x58566e7b,0x494f208a)\r\n#define PARAM_OP_TYPE_MGET_SFRICTIONV CKGUID(0x7af723af,0x7e222884)\r\n#define PARAM_OP_TYPE_MGET_SDFRICTION CKGUID(0x10733925,0x77c37dba)\r\n#define PARAM_OP_TYPE_MGET_SDFRICTIONV CKGUID(0x29131ba,0x3b2a6f07)\r\n#define PARAM_OP_TYPE_MGET_ANIS CKGUID(0x255256df,0x61fe2f77)\r\n#define PARAM_OP_TYPE_MGET_FMODE CKGUID(0x321f0335,0x589576df)\r\n#define PARAM_OP_TYPE_MGET_RMODE CKGUID(0x1cb07645,0x79ff1329)\r\n#define PARAM_OP_TYPE_MGET_XML_TYPE CKGUID(0x6fea2100,0x6667545b)\r\n#define PARAM_OP_TYPE_MGET_RES CKGUID(0x41702512,0x78c48ca)\r\n\r\n\r\n#define PARAM_OP_TYPE_MSET_SFRICTION CKGUID(0x2f2e1071,0x2d4623ec)\r\n#define PARAM_OP_TYPE_MSET_SFRICTIONV CKGUID(0x31940b2a,0x67f43440)\r\n#define PARAM_OP_TYPE_MSET_SDFRICTION CKGUID(0x205b0164,0x39d626d0)\r\n#define PARAM_OP_TYPE_MSET_SDFRICTIONV CKGUID(0x11f36b7a,0x7877377b)\r\n#define PARAM_OP_TYPE_MSET_ANIS CKGUID(0x36565c47,0x46002830)\r\n#define PARAM_OP_TYPE_MSET_FMODE CKGUID(0x4ddb7828,0x4d111b71)\r\n#define PARAM_OP_TYPE_MSET_RMODE CKGUID(0x5d2315b7,0x2cb834f3)\r\n\r\n\r\nvoid ParamOpMGetF(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tfloat value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->staticFriction;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),2,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetDF(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tfloat value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->dynamicFriction;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),1,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetR(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tfloat value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->restitution;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),3,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetDFV(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tfloat value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->dynamicFrictionV;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),4,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\nvoid ParamOpMGetFV(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tfloat value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->staticFrictionV;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),5,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetA(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tVxVector value(0.0f);\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = getFrom(mDesrc->dirOfAnisotropy);\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),6,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetFMode(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tint value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->frictionCombineMode;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),7,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpMGetRMode(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tint index = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\tint value = 0;\r\n\tif (index !=0 && GetPMan()->getCurrentFactory())\r\n\t{\r\n\t\tif (GetPMan()->getDefaultConfig())\r\n\t\t{\r\n\t\t\tXString mName = vtAgeia::getEnumDescription(pm,VTE_XML_MATERIAL_TYPE,index);\r\n\t\t\tNxMaterialDesc *mDesrc = pFactory::Instance()->createMaterialFromXML(mName.Str(),GetPMan()->getDefaultConfig());\r\n\t\t\tif (mDesrc)\r\n\t\t\t{\r\n\t\t\t\tvalue = mDesrc->restitutionCombineMode;\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t\tdelete mDesrc;\r\n\t\t\t\tmDesrc = NULL;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),8,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\nvoid ParamOpMGetXMat(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tint value = 0;\r\n\tif (p1)\r\n\t{\r\n\t\tif (p1->GetRealSource())\r\n\t\t{\r\n\t\t\tvalue = vtTools::ParameterTools::GetValueFromParameterStruct(p1->GetRealSource(),0,false);\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&value);\r\n}\r\n\r\n\r\n#define PARAM_OP_TYPE_BGET_RESTITUTION CKGUID(0x58566e7b,0x494f208a)\r\n\r\n\r\nvoid ParamOpStringToAdd(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tCKAttributeManager *am = (CKAttributeManager*)context->GetAttributeManager();\r\n\r\n\t//CKSTRING test = \r\n\tCKParameter *p = p1->GetRealSource();\r\n\r\n\tif (!p)\t{ return;\t}\r\n\r\n\tCKSTRING test = vtTools::ParameterTools::GetParameterAsString(p);\r\n\tif (!strlen(test))return;\r\n\r\n\r\n\tXString aName;\r\n\tXString aCat;\r\n\tXString aType;\r\n\r\n\tXStringTokenizer\ttokizer(test, \"|\");\r\n\tconst char*tok = NULL;\r\n\tint nb = 0;\r\n\twhile ((tok=tokizer.NextToken(tok)) && nb < 3)\r\n\t{\r\n\t\tXString tokx(tok);\r\n\r\n\t\tswitch (nb)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t\taName = tokx.Str();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 1:\r\n\t\t\t\taCat= tokx.Str();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 2:\r\n\t\t\t\taType = tokx.Str();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tnb++;\r\n\t}\r\n\r\n\tCKAttributeType aIType = am->GetAttributeTypeByName(aName.Str());\r\n\tif (aIType!=-1)\r\n\t{\r\n\t\tres->SetValue(&aIType);\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\tCKGUID pType = pm->ParameterNameToGuid(aType.Str());\r\n\tCKParameterType pt = pm->ParameterGuidToType(pType);\r\n\tif (pt==-1)\r\n\t{\r\n\t\tpType = CKPGUID_NONE;\r\n\t}\r\n\r\n\taIType = am->RegisterNewAttributeType(aName.Str(),pType,CKCID_OBJECT);\r\n\r\n\tif (aCat.Length())\r\n\t{\r\n\t\tam->AddCategory(aCat.Str());\r\n\t\tam->SetAttributeCategory(aIType,aCat.Str());\r\n\t}\r\n\r\n\r\n\tres->SetValue(&aIType);\r\n\t\r\n}\r\n\r\nvoid PhysicManager::_RegisterParameterOperations()\r\n{\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\r\n\t_RegisterParameterOperationsBody();\r\n\t_RegisterParameterOperationsJoint();\r\n\t_RegisterParameterOperationsVehicle();\r\n\r\n\r\n\tpm->RegisterOperationType(PARAMETER_OP_TYPE_STRING_TO_ATT, \"convert\");\r\n\tpm->RegisterOperationFunction(PARAMETER_OP_TYPE_STRING_TO_ATT,CKPGUID_ATTRIBUTE,CKPGUID_STRING,CKPGUID_NONE,ParamOpStringToAdd);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_RMODE, \"pMgRMode\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_RMODE,VTE_MATERIAL_COMBINE_MODE,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetRMode);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_FMODE, \"pMgFMode\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_FMODE,VTE_MATERIAL_COMBINE_MODE,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetFMode);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_RES, \"pMgRestitution\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_RES,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetR);\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_SFRICTION, \"pMgSFriction\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_SFRICTION,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetF);\r\n\t\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_SFRICTIONV, \"pMgSVFriction\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_SFRICTIONV,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetFV);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_SDFRICTION, \"pMgDFriction\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_SDFRICTION,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetDF);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_SDFRICTIONV, \"pMgDVFriction\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_SDFRICTIONV,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetDFV);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_ANIS, \"pMgAnis\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_ANIS,CKPGUID_VECTOR,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetA);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_MGET_XML_TYPE, \"pMgType\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_MGET_XML_TYPE,VTE_XML_MATERIAL_TYPE,VTS_MATERIAL,CKPGUID_NONE,ParamOpMGetXMat);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\r\n\r\n\r\n\t\r\n/*\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_FRICTION, \"GetFriction\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_FRICTION,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetFriction);\r\n\r\n\t\r\n\r\n\t\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_LDAMP, \"GetLinDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_LDAMP,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetLDamp);\r\n\t\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_LDAMPT, \"GetLinDampingT\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_LDAMPT,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetLDampT);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_ADAMP, \"GetAngDamping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_ADAMP,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetADamp);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_ADAMPT, \"GetAngDampingT\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_ADAMPT,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetADampT);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_CIS_INI_COLLISION, \"IsInCollision\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_CIS_INI_COLLISION,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpCIsInCollision);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_CHAS_CONTACT, \"HasContact\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_CHAS_CONTACT,CKPGUID_3DENTITY,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpCHasContact);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_CRAY_COLLISION, \"RayCollision\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_CRAY_COLLISION,CKPGUID_3DENTITY,CKPGUID_3DENTITY,CKPGUID_VECTOR4,ParamOpCRayCollision);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_CGROUP_COLLISION, \"IsCollision\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_CGROUP_COLLISION,CKPGUID_3DENTITY,CKPGUID_3DENTITY,CKPGUID_GROUP,ParamOpCIsInCollisionWithGroup);\r\n*/\r\n\r\n\r\n\t\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_RC_ANY_BOUNDS, \"raycastAnyBounds\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_RC_ANY_BOUNDS,CKPGUID_BOOL,VTS_RAYCAST,CKPGUID_NONE,ParamOpRayCastAnyBounds);\r\n\t\r\n\tpm->RegisterOperationType(PARAM_OP_RC_ANY_SHAPE, \"raycastAnyShape\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_RC_ANY_SHAPE,CKPGUID_3DENTITY,VTS_RAYCAST,CKPGUID_NONE,ParamOpRayCastAnyShape);\r\n\r\n\r\n\t\r\n\t\r\n\r\n\r\n\r\n\r\n\t\r\n \r\n}\r\n\r\n/*\r\nvoid ParamOpBGetLVelocity(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetAVelocity(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetForce(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetTorque(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetFriction(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBisFixed(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetHType(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpBGetLDamp(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetLDampT(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpBGetADamp(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpBGetADampT(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpCIsInCollision(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpCHasContact(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\nvoid ParamOpCRayCollision(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\nvoid ParamOpCIsInCollisionWithGroup(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2);\r\n\r\n*/\r\n\r\n\r\n/*\r\nvoid ParamOpCIsInCollisionWithGroup(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//retrieve the position ori : \r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//retrieve the group\r\n\tCK_ID targetIDG;\r\n\tp2->GetValue(&targetIDG);\r\n\tCKGroup *group = static_cast(context->GetObject(targetIDG));\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//our result object : \r\n\tCK3dEntity* result = NULL;\r\n\tCK_ID id = 0;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//check our input object : \r\n\tif (!ent)\r\n\t{\r\n\t\tres->SetValue(&id);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (ent )\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tVxVector pos,normal;\r\n\t\t\tfloat depth;\r\n\t\t\tresult = world->CIsInCollision(ent,group,pos,normal,depth);\t\r\n\t\t\tif (result)\r\n\t\t\t{\r\n\t\t\t\tid = result->GetID();\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&id);\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpCRayCollision(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//retrieve the position ori : \r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//our result object : \r\n\tCK3dEntity* result = NULL;\r\n\tCK_ID id = 0;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//check our input object : \r\n\tif (!ent)\r\n\t{\r\n\t\tres->SetValue(&id);\r\n\t\treturn;\r\n\t}\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we retrieve ori of the ray by a box : \r\n\tVxVector4 inVec(0,0,0,0);\r\n\tp2->GetValue(&inVec);\r\n\r\n\tVxVector oriOut(0,0,0);\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//direction of the ray : \r\n\tVxVector dirIn (inVec.x,inVec.y,inVec.z);\r\n\t\t\r\n\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\r\n\tif (world)\r\n\t{\r\n\t\tVxVector pos,normal;\r\n\t\tfloat depth;\r\n\t\tresult = world->CRayCollision(oriOut,ent,dirIn,ent,inVec.w,true,pos,normal);\t\t\r\n\t\tif (result)\r\n\t\t{\r\n\t\t\tid = result->GetID();\r\n\t\t}\r\n\r\n\t}\r\n\tres->SetValue(&id);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpCHasContact(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\tCK3dEntity* result = NULL;\r\n\tCK_ID id = 0;\r\n\r\n\tif (ent )\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\t\r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tVxVector pos,normal;\r\n\t\t\tfloat depth;\r\n\t\t\tresult = world->CIsInCollision(ent,pos,normal,depth);\t\t\r\n\t\t\tif (result)\r\n\t\t\t{\r\n\t\t\t\tid = result->GetID();\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&id);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpCIsInCollision(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\t\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\tCK_ID targetID2;\r\n\tp2->GetValue(&targetID2);\r\n\tCK3dEntity *ent2 = static_cast(context->GetObject(targetID2));\r\n\t\r\n\tint result = 0;\r\n\r\n\tif (ent && ent2)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tpWorld *world2=GetPMan()->getWorldByBody(ent2); \r\n\t\tif (world && world2 && world == world2)\r\n\t\t{\r\n\t\t\tVxVector pos,normal;\r\n\t\t\tfloat depth;\r\n result = world->CIsInCollision(ent,ent2,pos,normal,depth);\t\t\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&result);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetFriction(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->GetFriction();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetLDamp(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->GetLinearDamping();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetLDampT(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->GetLinearDampingThreshold();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetADamp(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->GetLinearDamping();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetADampT(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->GetLinearDampingThreshold();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n*/\r\n//////////////////////////////////////////////////////////////////////////DEV35DIR=\"X:/sdk/dev35\"\t\r\nDEV40DIR=\"X:/sdk/dev4\" \r\nDEV41DIR=\"X:/sdk/dev41R\"\t\r\n/********************************************************************\r\n\tcreated:\t2009/01/05\r\n\tcreated:\t5:1:2009 18:18\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtTools\\SDK\\Include\\Core\\vtCModuleDefines.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtTools\\SDK\\Include\\Core\r\n\tfile base:\tvtCModuleDefines\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __VTMODULES_DEFINES_H_\r\n\t#define __VTMODULES_DEFINES_H_\r\n\r\n#include \r\n\r\n#define VTCMODULE_NAME VTCX_API_PREFIX(\"TOOLS\")\r\n#define VTCMODULE_ATTRIBUTE_CATAEGORY VTCMODULE_NAME\r\n\r\n#define VTM_TOOL_MANAGER_GUID\t\tCKGUID(0x7a9a6475,0x6fb90c74)\r\n\r\n#define VTBB_PLG_GUID\t\tCKGUID(0x3262afb,0x230b4434)\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"VSLManagerSDK.h\"\r\n\r\n\r\n#ifdef HAS_FLUID\r\n\r\nvoid __newpFluidDescr(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pFluidDesc();\r\n}\r\n\r\nvoid __newpFluidEmitterDesc(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pFluidEmitterDesc();\r\n}\r\n\r\nvoid PhysicManager::_RegisterFluid_VSL()\r\n{\r\n\r\n\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* pFluidFlags */\r\n\t/************************************************************************/\r\n\r\n\tDECLAREENUM(\"pFluidFlag\")\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_DisableGravity\" , 2)\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_CollisionTwoway\" , 4)\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_Enabled\" , 8)\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_Hardware\" , 16)\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_PriorityMode\" , 32)\r\n\tDECLAREENUMVALUE(\"pFluidFlag\", \"PFF_ProjectToPlane\" , 64)\r\n\r\n\tDECLAREENUM(\"pFluidSimulationMethod\")\r\n\tDECLAREENUMVALUE(\"pFluidSimulationMethod\", \"PFS_SPH\" , 1)\r\n\tDECLAREENUMVALUE(\"pFluidSimulationMethod\", \"PFS_NoParticleInteraction\" , 2)\r\n\tDECLAREENUMVALUE(\"pFluidSimulationMethod\", \"PFS_MixedMode\" , 4)\r\n\r\n\tDECLAREENUM(\"pFluidCollisionMethod\")\r\n\tDECLAREENUMVALUE(\"pFluidCollisionMethod\", \"PFCM_Static\" , 1)\r\n\tDECLAREENUMVALUE(\"pFluidCollisionMethod\", \"PFCM_Dynamic\" , 2)\r\n\r\n\r\n\t\r\n\tDECLAREOBJECTTYPE(pFluidDesc)\r\n\tDECLARECTOR_0(__newpFluidDescr)\r\n\tDECLAREMEMBER(pFluidDesc,int,maxParticles)\r\n\tDECLAREMEMBER(pFluidDesc,float,attractionForDynamicShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,attractionForStaticShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,collisionDistanceMultiplier)\r\n\tDECLAREMEMBER(pFluidDesc,int,collisionGroup)\r\n\tDECLAREMEMBER(pFluidDesc,pFluidCollisionMethod,collisionMethod)\r\n\tDECLAREMEMBER(pFluidDesc,float,collisionResponseCoefficient)\r\n\tDECLAREMEMBER(pFluidDesc,float,damping)\r\n\tDECLAREMEMBER(pFluidDesc,float,dynamicFrictionForDynamicShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,dynamicFrictionForStaticShapes)\r\n\tDECLAREMEMBER(pFluidDesc,VxVector,externalAcceleration)\r\n\tDECLAREMEMBER(pFluidDesc,float,fadeInTime)\r\n\tDECLAREMEMBER(pFluidDesc,float,kernelRadiusMultiplier)\r\n\tDECLAREMEMBER(pFluidDesc,float,packetSizeMultiplier)\r\n\tDECLAREMEMBER(pFluidDesc,int,maxParticles)\r\n\tDECLAREMEMBER(pFluidDesc,float,motionLimitMultiplier)\r\n\tDECLAREMEMBER(pFluidDesc,int,numReserveParticles)\r\n\tDECLAREMEMBER(pFluidDesc,int,packetSizeMultiplier)\r\n\tDECLAREMEMBER(pFluidDesc,float,restitutionForDynamicShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,restitutionForStaticShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,restParticlesPerMeter)\r\n\tDECLAREMEMBER(pFluidDesc,float,restDensity)\r\n\tDECLAREMEMBER(pFluidDesc,pFluidSimulationMethod,simulationMethod)\r\n\tDECLAREMEMBER(pFluidDesc,float,staticFrictionForDynamicShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,staticFrictionForStaticShapes)\r\n\tDECLAREMEMBER(pFluidDesc,float,stiffness)\r\n\tDECLAREMEMBER(pFluidDesc,float,surfaceTension)\r\n\tDECLAREMEMBER(pFluidDesc,float,viscosity)\r\n\tDECLAREMEMBER(pFluidDesc,pFluidFlag,flags)\r\n\tDECLAREMEMBER(pFluidDesc,CK_ID,worldReference)\r\n\r\n\r\n\tDECLAREMETHOD_0(pFluidDesc,void,setToDefault)\r\n\tDECLAREMETHOD_0(pFluidDesc,bool,isValid)\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* emitter */\r\n\t/************************************************************************/\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\temitter flags : \r\n\t//\r\n\tDECLAREENUM(\"pFluidEmitterFlag\")\r\n\tDECLAREENUMVALUE(\"pFluidEmitterFlag\", \"PFEF_ForceOnBody\" , 4)\r\n\tDECLAREENUMVALUE(\"pFluidEmitterFlag\", \"PFEF_AddBodyVelocity\" , 8)\r\n\tDECLAREENUMVALUE(\"pFluidEmitterFlag\", \"PFEF_Enabled\" , 16)\r\n\r\n\tDECLAREENUM(\"pEmitterShape\")\r\n\tDECLAREENUMVALUE(\"pEmitterShape\", \"PFES_Rectangular\" , 1)\r\n\tDECLAREENUMVALUE(\"pEmitterShape\", \"PFES_Ellipse\" , 2)\r\n\r\n\tDECLAREENUM(\"pEmitterType\")\r\n\tDECLAREENUMVALUE(\"pEmitterType\", \"PFET_ConstantPressure\" , 1)\r\n\tDECLAREENUMVALUE(\"pEmitterType\", \"PFET_ConstantFlowRate\" , 2)\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\temitter descr : \r\n\t//\r\n\r\n\tDECLAREOBJECTTYPE(pFluidEmitterDesc)\r\n\tDECLARECTOR_0(__newpFluidEmitterDesc)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,CK3dEntity*,frameShape)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,pEmitterType,type)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,int,maxParticles)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,pEmitterShape,shape)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,dimensionX)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,dimensionY)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,VxVector,randomPos)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,randomAngle)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,fluidVelocityMagnitude)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,rate)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,randomAngle)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,particleLifetime)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,float,repulsionCoefficient)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,pFluidEmitterFlag,flags)\r\n\tDECLAREMETHOD_0(pFluidEmitterDesc,void,setToDefault)\r\n\tDECLAREMETHOD_0(pFluidEmitterDesc,bool,isValid)\r\n\tDECLAREMEMBER(pFluidEmitterDesc,CK_ID,entityReference)\r\n\r\n\r\n\r\n\tDECLAREPOINTERTYPE(pFluidEmitter)\r\n\t\r\n\t/************************************************************************/\r\n\t/* fluid */\r\n\t/************************************************************************/\r\n\t\r\n\tDECLAREPOINTERTYPE(pFluid)\r\n\tDECLAREMETHOD_0(pFluid,CK3dEntity*,getParticleObject)\r\n\r\n\tDECLAREMETHOD_2(pFactory,pFluid*,createFluid,CK3dEntity*,pFluidDesc)\r\n\r\n\tDECLAREMETHOD_1(pFluid,pFluidEmitter*,createEmitter,const pFluidEmitterDesc&)\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\r\n\r\n\r\n}\r\n\r\n#endif // HAS_FLUID#include \"crypting.h\"\r\n#include \r\n#include \r\n#include \r\n\r\nint EncryptPassword(char* pcPassword)\r\n{\r\n\t\r\n\tint aiKey[50] = {0x02, 0x03, 0x05, 0x07, 0x11, 0x13, 0x17, 0x19, 0x23, 0x29,\r\n\t 0xA2, 0xB3, 0xC5, 0xD7, 0xE1, 0xF3, 0xA7, 0xB9, 0xC3, 0xD9,\r\n\t 0x93, 0xA4, 0xB6, 0xC8, 0xD2, 0xE4, 0x98, 0xA8, 0xB4, 0xC8,\r\n\t 0x46, 0x58, 0x63, 0x67, 0x74, 0x78, 0x57, 0x57, 0x68, 0x67,\r\n\t 0xA9, 0xBC, 0xC9, 0xDF, 0xF6, 0x0C, 0xBF, 0xCF, 0xFC, 0xFF};\r\n\r\n\r\n\tchar acPassword[256];\r\n\tchar acTemp[3];\r\n\r\n\r\n\tif(pcPassword == NULL) return TRUE;\r\n\tZeroMemory(acPassword, 256 * sizeof(char));\r\n\r\n\r\n\tsrand(strlen(pcPassword) * 17);\r\n\tfor(int a = 0; a < (int)(strlen(pcPassword)); a++)\r\n\t{\r\n\t\tsrand(rand() + strlen(pcPassword) * a);\r\n\t\tsrand((rand() % (aiKey[a % 50])) + (rand() % (aiKey[(a * 23) % 50])));\r\n\t\tsrand((rand() % (aiKey[(a + 2305) % 50])) + (rand() % (aiKey[(17 + a * 133) % 50])) * 177);\r\n\r\n\r\n\t\tacPassword[a] = pcPassword[a] + (rand() % 256);\r\n\r\n\t\tsrand(((BYTE)(acPassword[a]) + 1) * (a + 23) + (rand() % 1381));\r\n\t\t//ok, thatīs crazy enough\r\n\t}\r\n\r\n\tZeroMemory(pcPassword, strlen(pcPassword) * sizeof(char));\r\n\r\n\r\n\t\r\n\tfor(int a = 0; a < (int)(strlen(acPassword)); a++)\r\n\t{\r\n\t\tsprintf(acTemp, \"%02x\", (byte)(acPassword[a]));\r\n\t\tstrcat(pcPassword, acTemp);\r\n\t}\r\n\t\r\n\t\r\n\treturn FALSE;\r\n}\r\n// mdexceptions.h\r\n//\r\n// WinDirStat - Directory Statistics\r\n// Copyright (C) 2003-2004 \r\n//\r\n// This program is free software; you can redistribute it and/or modify\r\n// it under the terms of the GNU General Public License as published by\r\n// the Free Software Foundation; either version 2 of the License, or\r\n// (at your option) any later version.\r\n//\r\n// This program is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n// GNU General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with this program; if not, write to the Free Software\r\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n//\r\n// This general purpose header is derived from a file\r\n// created by www.daccord.net und published\r\n// here under GPL with friendly permission of D'accord.\r\n\r\n// Md is just a prefix.\r\n\r\n#ifndef MDEXCEPTIONS_H_INCLUDED\r\n#define MDEXCEPTIONS_H_INCLUDED\r\n\r\n#ifndef _INC_STDARG\r\n#include \r\n#endif\r\n\r\n#pragma warning(disable: 4290) // C++ Exception Specification ignored\r\n\r\nclass CMdStringException: public CException\r\n{\r\npublic:\r\n\tCMdStringException(LPCTSTR pszText)\r\n\t\t: m_sText(pszText) // pszText may be a MAKEINTRESOURCE\r\n\t{}\r\n\tvirtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, PUINT pnHelpContext = NULL)\r\n\t{\r\n\t\tif (pnHelpContext != NULL)\r\n\t\t\t*pnHelpContext= 0;\r\n\t\tif (nMaxError != 0 && lpszError != NULL)\r\n\t\t\tlstrcpyn(lpszError, m_sText, nMaxError);\r\n\t\treturn true;\r\n\t}\r\nprotected:\r\n\tCString m_sText;\r\n};\r\n\r\ninline CString MdGetExceptionMessage(CException *pe)\r\n{\r\n\tCString s;\r\n\tBOOL b= pe->GetErrorMessage(s.GetBuffer(1024), 1024);\r\n\ts.ReleaseBuffer();\r\n\r\n\tif (!b)\r\n\t\ts= _T(\"(no error message available)\");\r\n\r\n\treturn s;\r\n}\r\n\r\ninline CString MdGetWinerrorText(HRESULT hr)\r\n{\r\n\tCString sRet;\t\r\n\tLPVOID lpMsgBuf;\r\n\tDWORD dw= FormatMessage(\r\n\t\tFORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, \r\n\t\tNULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \r\n\t\t(LPTSTR) &lpMsgBuf, 0, NULL\r\n\t);\r\n\tif (dw == NULL)\r\n\t{\r\n\t\tCString s(MAKEINTRESOURCE(AFX_IDP_NO_ERROR_AVAILABLE));\r\n\t\tsRet.Format(_T(\"%s (0x%08lx)\"), s, hr);\r\n\t}\r\n\telse \r\n\t{ \r\n\t\tsRet= (LPCTSTR)lpMsgBuf; \r\n\t\tLocalFree(lpMsgBuf); \r\n\t}\r\n\treturn sRet;\r\n}\r\n\r\ninline void MdThrowStringException(UINT resId) throw (CMdStringException *)\r\n{\r\n\tthrow new CMdStringException(MAKEINTRESOURCE(resId));\r\n}\r\n\r\ninline void MdThrowStringException(LPCTSTR pszText) throw (CMdStringException *)\r\n{\r\n\tthrow new CMdStringException(pszText);\r\n}\r\n\r\ninline void __MdFormatStringExceptionV(CString& rsText, LPCTSTR pszFormat, va_list vlist)\r\n{\r\n\tCString sFormat(pszFormat); // may be a MAKEINTRESOURCE\r\n\trsText.FormatMessageV(sFormat, &vlist);\r\n}\r\n\r\ninline void AFX_CDECL MdThrowStringExceptionF(LPCTSTR pszFormat, ...)\r\n{\r\n\tCString sText;\r\n\r\n\tva_list vlist;\r\n\tva_start(vlist, pszFormat);\r\n\t__MdFormatStringExceptionV(sText, pszFormat, vlist);\r\n\tva_end(vlist);\r\n\r\n\tMdThrowStringException(sText);\r\n}\r\n\r\ninline void MdThrowStringExceptionV(LPCTSTR pszFormat, va_list vlist)\r\n{\r\n\tCString sText;\r\n\t__MdFormatStringExceptionV(sText, pszFormat, vlist);\r\n\tMdThrowStringException(sText);\r\n}\r\n\r\ninline void AFX_CDECL MdThrowStringExceptionF(UINT nResIdFormat, ...)\r\n{\r\n\tCString sText;\r\n\r\n\tva_list vlist;\r\n\tva_start(vlist, nResIdFormat);\r\n\t__MdFormatStringExceptionV(sText, MAKEINTRESOURCE(nResIdFormat), vlist);\r\n\tva_end(vlist);\r\n\r\n\tMdThrowStringException(sText);\r\n}\r\n\r\ninline void MdThrowStringExceptionF(UINT nResIdFormat, va_list vlist)\r\n{\r\n\tCString sText;\r\n\t__MdFormatStringExceptionV(sText, MAKEINTRESOURCE(nResIdFormat), vlist);\r\n\tMdThrowStringException(sText);\r\n}\r\n\r\ninline void MdThrowWinerror(DWORD dw, LPCTSTR pszPrefix =NULL) throw (CMdStringException *)\r\n{\r\n\tCString sMsg= pszPrefix;\r\n\tsMsg+= _T(\": \") + MdGetWinerrorText(dw);\r\n\tMdThrowStringException(sMsg);\r\n}\r\n\r\ninline void MdThrowHresult(HRESULT hr, LPCTSTR pszPrefix =NULL) throw (CMdStringException *)\r\n{\r\n\tCString sMsg= pszPrefix;\r\n\tsMsg+= _T(\": \") + MdGetWinerrorText(hr);\r\n\tMdThrowStringException(sMsg);\r\n}\r\n\r\n\r\ninline void MdThrowLastWinerror(LPCTSTR pszPrefix =NULL) throw (CMdStringException *)\r\n{\r\n\tMdThrowWinerror(GetLastError(), pszPrefix);\r\n}\r\n\r\ninline void MdThrowFailed(HRESULT hr, LPCTSTR pszPrefix =NULL) throw (CMdStringException *)\r\n{\r\n\tif (FAILED(hr))\r\n\t\tMdThrowHresult(hr, pszPrefix);\r\n}\r\n\r\n#endif\r\nimport vt\r\nimport sys\r\nimport socket\r\n\r\n### Common ####\r\nMSGLEN = 10\r\n\r\ndef vt_client():\r\n client = server_connect('localhost', 9090)\r\n vt.ActivateOut(bid,0,1)\r\n if vt.IsInputActive(bid,0):\r\n\tmy_message = vt.GetInVal(bid,3)\r\n\tvt.SetOutVal(bid,0,my_message)\r\n\tif message_send(client, my_message):\r\n\t vt.ActivateOut(bid,2,1)\r\n\t msg = message_get(client)\r\n\t if(msg):\r\n\t\tvt.ActivateOut(bid,3,1)\r\n\t\tvt.SetOutVal(bid,1,len(msg))\r\n\t\tvt.SetOutVal(bid,2, msg)\r\n\r\n\r\ndef server_connect(host, port):\r\n #create an INET, STREAMing socket\r\n client = socket.socket(\r\n socket.AF_INET, socket.SOCK_STREAM)\r\n #now connect to the web server on port 80 \r\n # - the normal http port\r\n client.connect((host, port))\r\n\r\n return client\r\n\r\ndef message_get(sock):\r\n msg = ''\r\n chunk = ''\r\n\r\n while len(msg) < MSGLEN:\r\n\tchunk = sock.recv(MSGLEN-len(msg))\r\n if chunk == '':\r\n\t vt.ActivateOut(bid,1,1)\r\n\t vt.SetOutVal(bid,3, \"socket connection broken\")\r\n\tmsg = msg + chunk\r\n\treturn msg\r\n return 0\r\n\r\ndef message_send(sock, message):\r\n msgfmt = \"%-\" + \"%ds\" % (MSGLEN)\r\n msg = msgfmt % (message)\r\n\r\n totalsent = 0\r\n while totalsent < MSGLEN:\r\n sent = sock.send(msg[totalsent:])\r\n if sent == 0:\r\n\t vt.ActivateOut(bid,1,1)\r\n vt.SetOutVal(bid,3, \"socket connection broken\")\r\n totalsent = totalsent + sent\r\n return 1\r\ndofile(\"ModuleConfig.lua\")\r\ndofile(\"ModuleHelper.lua\")\r\n\r\n\r\n\r\nif _ACTION == \"help\" then\r\n\tpremake.showhelp()\r\n\treturn\r\n\r\nend\r\n\r\n\r\n\r\nsolution \"vtPhysX\"\r\n\r\n\tconfigurations { \"Debug\", \"Release\" , \"ReleaseDebug\" ; \"ReleaseRedist\" ; \"ReleaseDemo\" }\r\n\r\n\tif _ACTION and _OPTIONS[\"Dev\"] then\r\n\t\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tend\r\n\r\n\r\npackageConfig_libtomcrypt =\r\n{\r\n\tName \t\t= \t\"libtomcrypt\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES },\r\n\tFiles\t\t= { DDEPS..\"libtomcrypt/*.c\"\t; DDEPS..\"libtomcrypt/*.h\"},\r\n\tIncludes \t= { DDEPS..\"libtomcrypt\" },\r\n\tExludeFiles\t\t= { DDEPS..\"libtomcrypt/aes_tab.c\" ; DDEPS..\"libtomcrypt/sha384.c\" ; DDEPS..\"libtomcrypt/sha224.c\" ; DDEPS..\"libtomcrypt/rsa_sys.c\" ; DDEPS..\"libtomcrypt/ecc_sys.c\" ; DDEPS..\"libtomcrypt/dh_sys.c\" ; },\r\n\tOptions = { \"/W0\"}\r\n}\r\n\r\npackageConfig_libTNL =\r\n{\r\n\tName \t\t= \t\"libTNL\",\r\n\tType\t\t=\t\"StaticLib\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES; \"TNL_ENABLE_LOGGING\" ; \"TNL_DEBUG\" },\r\n\tFiles\t\t= { DDEPS..\"tnl/*.cpp\"\t;\tDDEPS..\"tnl/*.h\"},\r\n\tIncludes \t= { DDEPS..\"libtomcrypt\" ; },\r\n\tLibs\t= {\t},\r\n\tOptions = { \"/W0\"}\r\n\r\n}\r\n\r\n\r\n\r\n--\tThe building blocks for vtPhysX, depending on packageConfig_vtAgeiaLib\r\npackageConfig_vtTNL =\r\n{\r\n\tName \t\t= \t\"vtTNL\",\r\n\tType\t\t=\t\"SharedLib\",\r\n\tTargetSuffix = \"/BuildingBlocks\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \t\"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\" ; \"TNL_ENABLE_LOGGING\" ; \"TNL_DEBUG\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/Behaviors/**.cpp\"\t; DROOT..\"SDK/src/Behaviors/*.def\" ; D_DOCS_PAGES..\"*.page\" ; F_SHARED_SRC ; DROOT..\"build4/**.lua\" ; F_BASE_SRC ; D_CORE_SRC ; F_BASE_VT_SRC ; F_BASE_STD_INC},\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDES },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"libTNL\" ; \"Ws2_32\" ; \"libtomcrypt\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\" ..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()..\"\\\\BuildingBlocks\"\r\n\r\n}\r\n\r\npackageConfig_xConsoleServer =\r\n{\r\n\tName \t\t= \t\"xConsoleServer\",\r\n\tType\t\t=\t\"ConsoleApp\",\r\n\tTargetSuffix = \"\",\r\n\tDefines \t= { DEF_STD_DIRECTIVES \t; \t\"VIRTOOLS_USER_SDK\" ; \"MODULE_BASE_EXPORTS\"; \"TNL_ENABLE_LOGGING\" ; \"TNL_DEBUG\" },\r\n\tFiles\t\t= { DROOT..\"SDK/src/ConsoleServer/*.cpp\"; F_SHARED_SRC ; F_BASE_SRC ; D_CORE_SRC ; F_BASE_VT_SRC ; F_BASE_STD_INC },\r\n\tIncludes \t= { D_STD_INCLUDES ; D_CORE_INCLUDES },\r\n\tLibs\t= {\t\"ck2\" ; \"vxmath\" ; \"user32\" ; \"kernel32\" ; \"libTNL\" ; \"Ws2_32\" ; \"libtomcrypt\" },\r\n\tLibDirectories = { },\r\n\tOptions = { \"/W0\"},\r\n\tExludeFiles\t\t= { DROOT..\"SDK/src/core/vtNetworkManager*.cpp\" },\r\n\tPostCommand = \"copy $(TargetDir)$(TargetFileName) \"..getVTDirectory():lower()..\"\\n\"..\"copy $(TargetDir)$(InputName).pdb \"..getVTDirectory():lower()\r\n\r\n}\r\n\r\n--\tIf the command line contains --ExtraDefines=\"WebPack\" , we add \"WebPack\" to the\r\n--\tpre-processor directives and also create a package to include the camera building blocks\r\n--\tas defined in packageConfig_CameraRepack\r\nif _OPTIONS[\"ExtraDefines\"] then\r\n\r\n\tif _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\tcreateStaticPackage(packageConfig_CameraRepack)\r\n\tend\r\nend\r\n\r\ncreateStaticPackage(packageConfig_vtTNL)\r\ncreateStaticPackage(packageConfig_libtomcrypt)\r\ncreateStaticPackage(packageConfig_libTNL)\r\ncreateStaticPackage(packageConfig_xConsoleServer)\r\n\r\n\r\n--include \"CppConsoleApp\"\r\n\r\nfunction onclean()\r\n\tos.rmdir(\"vs**\")\r\nend\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetIncomingUserDecl();\r\nCKERROR CreateGetIncomingUserProto(CKBehaviorPrototype **);\r\nint GetIncomingUser(const CKBehaviorContext& behcontext);\r\nCKERROR GetIncomingUserCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetIncomingUserDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NIncomingUser\");\t\r\n\tod->SetDescription(\"User enters a session\");\r\n\t\r\n\tod->SetCategory(\"TNL/User Management\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7a770be7,0x77130778));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetIncomingUserProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_OFF,\r\n\tBB_IT_NEXT,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_INCOMING,\r\n\tBB_O_ERROR,\r\n\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_USER_ID,\r\n\tBB_OP_USER_NAME,\r\n\tBB_OP_ERROR\r\n};\r\n\r\nCKERROR CreateGetIncomingUserProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NIncomingUser\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Stop\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Incoming\");\r\n\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\t\r\n\tproto->DeclareOutParameter(\"User ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"User Name\", CKPGUID_STRING, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"-1\");\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(GetIncomingUser);\r\n\tproto->SetBehaviorCallbackFct(GetIncomingUserCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint GetIncomingUser(const CKBehaviorContext& behcontext)\r\n{\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\r\n\tint connectionID=-1;\r\n\tbeh->GetInputParameterValue(0,&connectionID);\r\n\t\r\n\tXString userName((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbbNoError(E_NWE_OK);\r\n\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t/*\r\n\txDistributedSession *session = cin->getCurrentSession();\r\n\tif (!session)\r\n\t{\r\n\t\tbbError(E_NWE_NO_SUCH_SESSION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED))\r\n\t{\r\n\t\tbbError(E_NWE_NO_SESSION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n*/\r\n\r\n\r\n\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\tvtConnection *con = cin->getConnection();\r\n\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClient *client = static_cast(dobj);\r\n\t\t\t\t\tif (client)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedClient *myClient = cin->getMyClient();\r\n\t\t\t\t\t\txDistributedSession *session = cin->getCurrentSession();\r\n\r\n\t\t\t\t\t\tif ( isFlagOn(client->getClientFlags(),E_CF_ADDING) && client->getUserID() != con->getUserID() )\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tdisableFlag(client->getClientFlags(),E_CF_ADDING);\r\n\t\t\t\t\t\t\tenableFlag(client->getClientFlags(), E_CF_ADDED);\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif (isFlagOn(myClient->getClientFlags(),E_CF_SESSION_JOINED))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_USER_ID,client->getUserID());\r\n\t\t\t\t\t\t\t\tSetOutputParameterValue(beh,BB_OP_USER_NAME,client->getUserName().getString());\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//xLogger::xLog(ELOGINFO,E_LI_CLIENT,\"Incoming user %d\",client->getUserID());\r\n\t\t\t\t\t\t\t\t//XLOG_BB_INFO;\r\n\t\t\t\t\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\t\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\t\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR GetIncomingUserCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"resourceplayer.h\"\r\n\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n// include file used for the static configuration\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\n#include \"vtTools.h\"\r\n\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\nint CCustomPlayer::_CreateWindows()\r\n{\r\n\tRECT mainRect;\r\n\r\n\tint k = WindowedWidth();\r\n\tint k1 = WindowedHeight();\r\n\r\n\t// compute the main window rectangle, so the window is centered\r\n\tmainRect.left = (GetSystemMetrics(SM_CXSCREEN)-WindowedWidth())/2;\r\n\tmainRect.right = WindowedWidth()+mainRect.left;\r\n\tmainRect.top = (GetSystemMetrics(SM_CYSCREEN)-WindowedHeight())/2;\r\n\tmainRect.bottom = WindowedHeight()+mainRect.top;\r\n\tBOOL ret = AdjustWindowRect(&mainRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\r\n\tDWORD dwStyle;\r\n\r\n\t// create the main window\r\n\r\n\tswitch(PGetApplicationMode())\r\n\t{\r\n\tcase normal:\r\n\t\t{\r\n\t\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),GetPAppStyle()->g_AppTitle.Str(),WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t\t\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t\t\t\tNULL,NULL,m_hInstance,NULL);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase preview:\r\n\t\t{\r\n\t\t\tRECT rc;\r\n\t\t\tGetClientRect( m_hWndParent, &rc );\r\n\t\t\tdwStyle = WS_VISIBLE | WS_CHILD;\r\n\t\t\tAdjustWindowRect( &rc, dwStyle, FALSE );\r\n\t\t\tm_MainWindow = m_hWndParent;\r\n\t\t\tm_WindowedWidth = rc.right - rc.left ; \r\n\t\t\tm_WindowedHeight = rc.bottom - rc.top;\r\n\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_VISIBLE)&~WS_CAPTION,rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,m_MainWindow,NULL,m_hInstance,this);\r\n\t\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\tcase popup:\r\n\t\t{\r\n\t\t\tdwStyle = (WS_OVERLAPPEDWINDOW); \r\n\t\t\t//m_MainWindow = CreateWindowEx( dwStyle , m_PlayerClass.CStr(), GetPAppStyle()->g_AppTitle.Str(), WS_POPUP, mainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top , m_MainWindow, NULL,m_hInstance, NULL );\r\n\t\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),\"asd\",WS_POPUP,mainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,NULL,NULL,m_hInstance,NULL);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tdefault:\r\n\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),GetPAppStyle()->g_AppTitle.Str(),WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t\t\tNULL,NULL,m_hInstance,NULL);\r\n\t\tbreak;\r\n\t}\r\n\r\n\r\n\r\n\t//\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),\"asd\",WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t//\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t//\t\tNULL,NULL,m_hInstance,NULL);\r\n\r\n\tint errorL = GetLastError();\r\n\r\n\tif(!m_MainWindow) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif(PGetApplicationMode() != preview)\r\n\t{\r\n\t\t// create the render window\r\n\t\tif (( GetEWindowInfo()->g_GoFullScreen )) \r\n\t\t{\r\n\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_OVERLAPPED|WS_VISIBLE)&~WS_CAPTION,\r\n\t\t\t\t0,0,FullscreenWidth(),FullscreenHeight(),m_MainWindow,NULL,m_hInstance,0);\r\n\t\t} else {\r\n\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_OVERLAPPED|WS_VISIBLE)&~WS_CAPTION,\r\n\t\t\t\t0,0,WindowedWidth(),WindowedHeight(),m_MainWindow,NULL,m_hInstance,0);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tif(!m_RenderWindow) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n\r\n\r\n\r\nATOM CCustomPlayer::_RegisterClass()\r\n{\r\n\t// register window classes\r\n\r\n\tWNDCLASSEX wcex;\r\n\r\n\r\n\twcex.cbSize\t\t\t= sizeof(WNDCLASSEX); \r\n\twcex.style\t\t\t= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;\r\n\twcex.lpfnWndProc\t= (WNDPROC)_MainWindowWndProcStub;\r\n\twcex.cbClsExtra\t\t= 0;\r\n\twcex.cbWndExtra\t\t= 0;\r\n\twcex.hInstance\t\t= m_hInstance;\r\n\t//wcex.hIconSm = (HICON) LoadImage(m_hInstance,TEXT(\"AppIcon\"),IMAGE_ICON,16, 16,LR_LOADFROMFILE);\r\n\tHICON icon = NULL;\r\n\ticon = (HICON) LoadImage(NULL,TEXT(\"app.ico\"),IMAGE_ICON,16, 16,LR_LOADFROMFILE);\r\n\tif (icon)\r\n\t{\r\n\t\twcex.hIcon = icon;\r\n\t}else{\r\n\t\twcex.hIcon\t\t\t= LoadIcon( m_hInstance, MAKEINTRESOURCE(IDI_VIRTOOLS) );\r\n\t}\r\n\r\n\twcex.hCursor\t\t= NULL;\r\n\twcex.hbrBackground\t= NULL;\r\n\twcex.lpszMenuName\t= NULL;\r\n\twcex.lpszClassName\t= m_PlayerClass.CStr();\r\n\twcex.hIconSm\t\t= icon;\r\n \r\n\tWNDCLASS MyRenderClass;\r\n\tZeroMemory(&MyRenderClass,sizeof(MyRenderClass));\r\n\tMyRenderClass.style\t\t\t= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;\r\n\tMyRenderClass.lpfnWndProc\t= (WNDPROC)_MainWindowWndProcStub;\r\n\tMyRenderClass.hInstance\t\t= m_hInstance;\r\n\tMyRenderClass.lpszClassName\t= m_RenderClass.CStr();\r\n\r\n\t::RegisterClass(&MyRenderClass);\r\n\r\n\tint le = GetLastError();\r\n\r\n\tint result = ::RegisterClassEx(&wcex);\r\n\r\n\tle = GetLastError();\r\n\r\n\tint h = 2 ; \r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nvoid CCustomPlayer::_SetResolutions()\r\n{\r\n\t// retrieve the windowed attribute\r\n\tCKParameterOut* pout = m_Level->GetAttributeParameter(m_WindowedResolutionAttType);\r\n\tif (pout) {\r\n\t\tVx2DVector res(m_WindowedWidth,m_WindowedHeight);\r\n\t\t// set it\r\n\t\tpout->SetValue(&res);\r\n\t}\r\n\r\n\t// retrieve the fullscreen attribute\r\n\tpout = m_Level->GetAttributeParameter(m_FullscreenResolutionAttType);\r\n\tif (pout) {\r\n\t\tVx2DVector res(m_FullscreenWidth,m_FullscreenHeight);\r\n\t\t// set it\r\n\t\tpout->SetValue(&res);\r\n\t}\r\n\r\n\t// retrieve the fullscreen bpp attribute\r\n\tpout = m_Level->GetAttributeParameter(m_FullscreenBppAttType);\r\n\tif (pout) {\r\n\t\t// set it\r\n\t\tpout->SetValue(&m_FullscreenBpp);\r\n\t}\r\n}\r\nBOOL CCustomPlayer::ChangeResolution()\r\n{\r\n\tif (!m_RenderContext)\r\n\t\treturn FALSE;\r\n\r\n\tif (m_RenderContext->IsFullScreen()) {\r\n\t\t// we are in fullscreen mode\r\n\t\tif (_GetFullScreenResolution()) {\r\n\t\t\t// the resolution has changed\r\n\r\n\t\t\t// pause the player\r\n\t\t\tm_CKContext->Pause();\r\n\t\t\t// and stop fullscreen\r\n\t\t\tm_RenderContext->StopFullScreen();\r\n\r\n\t\t\t// return to fullscreen with the new resolution\r\n\t\t\tm_RenderContext->GoFullScreen(m_FullscreenWidth,m_FullscreenHeight,m_FullscreenBpp,m_Driver);\r\n\r\n\t\t\tVxDriverDesc* Check_API_Desc = m_RenderManager->GetRenderDriverDescription(m_Driver);\r\n\t\t\t//we have to resize the mainwin to allow correct picking (only in DX)\r\n\t\t\tif (Check_API_Desc->Caps2D.Family==CKRST_DIRECTX && m_RenderContext->IsFullScreen()) {\r\n\t\t\t\t//store current size\r\n\t\t\t\tGetWindowRect(m_MainWindow,&m_MainWindowRect);\r\n\r\n\t\t\t\t//Resize the window\r\n\t\t\t\t::SetWindowPos(m_MainWindow,HWND_TOPMOST,0,0,m_FullscreenWidth,m_FullscreenHeight,NULL);\r\n\r\n\t\t\t\t//Prevent the window from beeing resized\r\n\t\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\t\tst&=~WS_THICKFRAME;\r\n\t\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\t\t\t}\t\r\n\t\t\t// everything is ok to restart the player\r\n\t\t\tm_CKContext->Play();\r\n\t\t}\r\n\t} else {\r\n\t\t// we are in windowed mode\t\r\n\t\tif (_GetWindowedResolution()) {\r\n\t\t\t// the resolution has changed\r\n\r\n\t\t\t//allow the window to be resized\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\r\n\t\t\t//reposition the window\r\n\t\t\tm_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;\r\n\t\t\tm_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;\r\n\t\t\tm_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;\r\n\t\t\tm_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;\r\n\t\t\tBOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t\t::SetWindowPos(m_MainWindow,0,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);\r\n\r\n\t\t\t// and set the position of the render window in the main window\r\n\t\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\t\t\tm_RenderContext->Resize(0,0,m_WindowedWidth,m_WindowedHeight);\r\n\t\t}\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CCustomPlayer::ClipMouse(BOOL iEnable)\r\n{\r\n\t// manage the mouse clipping\r\n\r\n\tif (!GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t\treturn false;\r\n\tif(iEnable==FALSE) {\r\n\t\t// disable the clipping\r\n\t\treturn ClipCursor(NULL);\r\n\t}\r\n\r\n\tif (!m_RenderContext) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// retrieve the render window rectangle\r\n\tVxRect r;\r\n\tm_RenderContext->GetWindowRect(r,TRUE);\r\n\r\n\tRECT rect;\r\n\trect.top = (LONG)r.top;\r\n\trect.left = (LONG)r.left;\r\n\trect.bottom = (LONG)r.bottom;\r\n\trect.right = (LONG)r.right;\r\n\r\n\t// to clip the mouse in it.\r\n\treturn ClipCursor(&rect);\r\n}\r\n\r\nBOOL CCustomPlayer::SwitchFullscreen(BOOL value)\r\n{\r\n\r\n\tif (!m_RenderContext || !m_FullscreenEnabled) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// mark eat display change to true\r\n\t// so we cannot switch the display during this function.\r\n\tm_EatDisplayChange = TRUE;\r\n\r\n\tif ( !value && m_RenderContext->IsFullScreen() ) {\r\n\t\t// siwtch to windowed mode\r\n\r\n\t\t// retrieve the windowed resolution from the attributes\r\n\t\t_GetWindowedResolution();\r\n\t\t// we pause the player\r\n\t\tm_CKContext->Pause();\r\n\t\t// stop the fullscreen\r\n\t\tm_RenderContext->StopFullScreen();\r\n\r\n\t\t//restore the main window size (only in DirectX rasterizer->m_MainWindowRect.bottom not modified)\r\n\t\tif (m_MainWindowRect.bottom!=0 && !m_RenderContext->IsFullScreen()) {\r\n\t\t\t//allow the window to be resized\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\t\t\t\r\n\t\t}\r\n\r\n\t\t//reposition the window\r\n\t\tm_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;\r\n\t\tm_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;\r\n\t\tm_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;\r\n\t\tm_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;\r\n\t\tBOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t::SetWindowPos(m_MainWindow,HWND_NOTOPMOST,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);\r\n\r\n\t\t// now we can show the main widnwos\r\n\t\tShowWindow(m_MainWindow,SW_SHOW);\r\n\t\tSetFocus(m_MainWindow);\r\n\r\n\t\t// and set the position of the render window in the main window\r\n\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\r\n\t\tm_RenderContext->Resize(0,0,m_WindowedWidth,m_WindowedHeight);\r\n\r\n\t\t// and give the focus to the render window\r\n\t\tSetFocus(m_RenderWindow);\r\n\r\n\t\t// everything is ok to restart the player\r\n\t\tm_CKContext->Play();\r\n\t} \r\n\telse if(value && !m_RenderContext->IsFullScreen())\r\n\t{\r\n\t\t// switch to fullscreen mode\r\n\r\n\t\t// retrieve the fullscreen resolution from the attributes\r\n\t\t_GetFullScreenResolution();\r\n\t\t// we pause the player\r\n\t\tm_CKContext->Pause();\r\n\t\t// and go fullscreen\r\n\t\tm_RenderContext->GoFullScreen(m_FullscreenWidth,m_FullscreenHeight,m_FullscreenBpp,m_Driver);\r\n\r\n\t\t// everything is ok to restart the player\r\n\t\tm_CKContext->Play();\r\n\r\n\t\tVxDriverDesc* Check_API_Desc = m_RenderManager->GetRenderDriverDescription(m_Driver);\r\n\t\t//we have to resize the mainwin to allow correct picking (only in DX)\r\n\t\tif (Check_API_Desc->Caps2D.Family==CKRST_DIRECTX && m_RenderContext->IsFullScreen()) {\r\n\t\t\t//store current size\r\n\t\t\tGetWindowRect(m_MainWindow,&m_MainWindowRect);\r\n\r\n\t\t\t//Resize the window\r\n\t\t\t::SetWindowPos(m_MainWindow,HWND_TOPMOST,0,0,m_FullscreenWidth,m_FullscreenHeight,NULL);\r\n\r\n\t\t\t//Prevent the window from beeing resized\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst&=~WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\t\t}\r\n\t} \r\n\r\n\t// mark eat display change to false\r\n\t// as we have finished\r\n\tm_EatDisplayChange = FALSE;\r\n\r\n\tClipMouse(m_MouseClipped);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CCustomPlayer::SwitchFullscreen()\r\n{\r\n\t\tif (!m_RenderContext || !m_FullscreenEnabled) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// mark eat display change to true\r\n\t// so we cannot switch the display during this function.\r\n\tm_EatDisplayChange = TRUE;\r\n\r\n\tif (m_RenderContext->IsFullScreen()) {\r\n\t\t// siwtch to windowed mode\r\n\r\n\t\t// retrieve the windowed resolution from the attributes\r\n\t\t_GetWindowedResolution();\r\n\t\t// we pause the player\r\n\t\tm_CKContext->Pause();\r\n\t\t// stop the fullscreen\r\n\t\tm_RenderContext->StopFullScreen();\r\n\r\n\t\t//restore the main window size (only in DirectX rasterizer->m_MainWindowRect.bottom not modified)\r\n\t\tif (m_MainWindowRect.bottom!=0 && !m_RenderContext->IsFullScreen()) {\r\n\t\t\t//allow the window to be resized\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\t\t\t\r\n\t\t}\r\n\r\n\t\t//reposition the window\r\n\t\tm_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;\r\n\t\tm_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;\r\n\t\tm_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;\r\n\t\tm_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;\r\n\t\tBOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t::SetWindowPos(m_MainWindow,HWND_NOTOPMOST,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);\r\n\r\n\t\t// now we can show the main widnwos\r\n\t\tShowWindow(m_MainWindow,SW_SHOW);\r\n\t\tSetFocus(m_MainWindow);\r\n\r\n\t\t// and set the position of the render window in the main window\r\n\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\r\n\t\t// and give the focus to the render window\r\n\t\tSetFocus(m_RenderWindow);\r\n\r\n\t\t// everything is ok to restart the player\r\n\t\tm_CKContext->Play();\r\n\t} else {\r\n\t\t// switch to fullscreen mode\r\n\r\n\t\t// retrieve the fullscreen resolution from the attributes\r\n\t\t_GetFullScreenResolution();\r\n\t\t// we pause the player\r\n\t\tm_CKContext->Pause();\r\n\t\t// and go fullscreen\r\n\t\tm_RenderContext->GoFullScreen(m_FullscreenWidth,m_FullscreenHeight,m_FullscreenBpp,m_Driver);\r\n\r\n\t\t// everything is ok to restart the player\r\n\t\tm_CKContext->Play();\r\n\r\n\t\tVxDriverDesc* Check_API_Desc = m_RenderManager->GetRenderDriverDescription(m_Driver);\r\n\t\t//we have to resize the mainwin to allow correct picking (only in DX)\r\n\t\tif (Check_API_Desc->Caps2D.Family==CKRST_DIRECTX && m_RenderContext->IsFullScreen()) {\r\n\t\t\t//store current size\r\n\t\t\tGetWindowRect(m_MainWindow,&m_MainWindowRect);\r\n\r\n\t\t\t//Resize the window\r\n\t\t\t::SetWindowPos(m_MainWindow,HWND_TOPMOST,0,0,m_FullscreenWidth,m_FullscreenHeight,NULL);\r\n\r\n\t\t\t//Prevent the window from beeing resized\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst&=~WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\t\t}\r\n\t} \r\n\r\n\t// mark eat display change to false\r\n\t// as we have finished\r\n\tm_EatDisplayChange = FALSE;\r\n\r\n\tClipMouse(m_MouseClipped);\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n\r\nBOOL CCustomPlayer::_CheckFullscreenDisplayMode(BOOL iDoBest)\r\n{\r\n\tVxDriverDesc* desc = m_RenderManager->GetRenderDriverDescription(m_Driver);\r\n\r\n\t// try to find the correct fullscreen display mode\r\n\tVxDisplayMode* displayMode = NULL;\r\n\tfor (displayMode=desc->DisplayModes.Begin();displayMode!=desc->DisplayModes.End();displayMode++) {\r\n\t\tif (displayMode->Width==m_FullscreenWidth\t&&\r\n\t\t\tdisplayMode->Height==m_FullscreenHeight\t&&\r\n\t\t\tdisplayMode->Bpp==m_FullscreenBpp) {\r\n\t\t\t\tm_FullscreenEnabled = TRUE;\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t}\r\n\r\n\tif (!iDoBest) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// we did not find a display mode\r\n\t// try 640x480x32\r\n\tm_FullscreenWidth = 640;\r\n\tm_FullscreenHeight = 480;\r\n\tm_FullscreenBpp = 32;\r\n\r\n\tfor (displayMode=desc->DisplayModes.Begin();displayMode!=desc->DisplayModes.End();displayMode++) {\r\n\t\tif (displayMode->Width==m_FullscreenWidth\t&&\r\n\t\t\tdisplayMode->Height==m_FullscreenHeight\t&&\r\n\t\t\tdisplayMode->Bpp==m_FullscreenBpp) {\r\n\t\t\t\tm_FullscreenEnabled = TRUE;\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t}\r\n\r\n\t// we did not find a display mode\r\n\t// try 640x480x16\r\n\tm_FullscreenBpp = 16;\r\n\r\n\tfor (displayMode=desc->DisplayModes.Begin();displayMode!=desc->DisplayModes.End();displayMode++) {\r\n\t\tif (displayMode->Width==m_FullscreenWidth\t&&\r\n\t\t\tdisplayMode->Height==m_FullscreenHeight\t&&\r\n\t\t\tdisplayMode->Bpp==m_FullscreenBpp) {\r\n\t\t\t\tm_FullscreenEnabled = TRUE;\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t}\r\n\r\n\tm_FullscreenEnabled = FALSE;\r\n\treturn FALSE;\r\n}\r\n\r\n\r\nBOOL CCustomPlayer::_GetFullScreenResolution()\r\n{\r\n\t// retrieve the fullscreen resolution from attribute\r\n\r\n\t// retrieve the attribute (resolution width and height)\r\n\tCKParameterOut* paramRes = m_Level->GetAttributeParameter(m_FullscreenResolutionAttType);\r\n\tif (!paramRes) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// save old values\r\n\tint oldWidth = m_FullscreenWidth;\r\n\tint oldHeight = m_FullscreenHeight;\r\n\tint oldBpp = m_FullscreenBpp;\r\n\r\n\t// retrieve the attribute (bpp)\r\n\tCKParameterOut* paramBpp = m_Level->GetAttributeParameter(m_FullscreenBppAttType);\r\n\tif (paramBpp) {\r\n\t\tparamBpp->GetValue(&m_FullscreenBpp);\r\n\t}\r\n\r\n\tVx2DVector res(m_FullscreenWidth,m_FullscreenHeight);\r\n\tparamRes->GetValue(&res);\r\n\tm_FullscreenWidth = (int)res.x;\r\n\tm_FullscreenHeight = (int)res.y;\r\n\r\n\t// check the resolution is compatible with the fullscreen mode\r\n\tif (!_CheckFullscreenDisplayMode(FALSE)) {\r\n\t\t// else ...\r\n\t\tm_FullscreenWidth = oldWidth;\r\n\t\tm_FullscreenHeight = oldHeight;\r\n\t\tm_FullscreenBpp = oldBpp;\r\n\t\t// ... reset attributes with old values\r\n\t\t_SetResolutions();\r\n\t}\r\n\r\n\t// returns TRUE if at least one value has changed\r\n\treturn (m_FullscreenWidth!=oldWidth || m_FullscreenHeight!=oldHeight || m_FullscreenBpp!=oldBpp);\r\n}\r\n\r\nBOOL CCustomPlayer::_GetWindowedResolution()\r\n{\t\r\n\t// retrieve the windowed resolution from attribute\r\n\r\n\t// retrieve the attribute (resolution width and height)\r\n\tCKParameterOut* pout = m_Level->GetAttributeParameter(m_WindowedResolutionAttType);\r\n\tif (!pout) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// save old values\r\n\tint oldWidth = m_WindowedWidth;\r\n\tint oldHeight = m_WindowedHeight;\r\n\r\n\tVx2DVector res(m_WindowedWidth,m_WindowedHeight);\r\n\tpout->GetValue(&res);\r\n\tm_WindowedWidth = (int)res.x;\r\n\tm_WindowedHeight = (int)res.y;\r\n\r\n\t// returns TRUE if at least one value has changed\r\n\treturn (m_WindowedWidth!=oldWidth || m_WindowedHeight!=oldHeight);\r\n}\r\n\r\n\r\n\r\nLRESULT CCustomPlayer::OnSysKeyDownMainWindow(int iConfig, int iKey)\r\n{\r\n\t// Manage system key (ALT + KEY)\r\n\t// system keys can be disable using eDisableKeys\r\n\r\n\tswitch(iKey)\r\n\t{\r\n\tcase VK_RETURN:\r\n\t\tif (!(iConfig&eDisableKeys)) \r\n\t\t{\r\n\t\t\t// ALT + ENTER -> SwitchFullscreen\r\n\t\t\tSwitchFullscreen( !m_RenderContext->IsFullScreen() );\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\tcase VK_F4:\r\n\t\tif (!(iConfig&eDisableKeys)) {\r\n\t\t\t// ALT + F4 -> Quit the application\r\n\t\t\tPostQuitMessage(0);\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn 0;\r\n}\r\nvoid CCustomPlayer::OnActivateApp(BOOL iActivate)\r\n{\r\n\t// if\r\n\t// - the application is being activated (iActivate == TRUE)\r\n\t// - the render context is in fullscreen\r\n\t// - and the player is not already switching fullscreen (m_EatDisplayChange == FALSE)\r\n\tif (iActivate==FALSE && m_RenderContext && m_RenderContext->IsFullScreen() && !m_EatDisplayChange) {\r\n\t\t// we switch fullscreen because the application is deactivated\r\n\t\t//SwitchFullscreen();\r\n\t\t\r\n\t}\r\n}\r\n\r\nvoid CCustomPlayer::OnFocusChange(BOOL iFocus)\r\n{\r\n\t// here we manage the focus change\r\n\r\n\tif (!m_CKContext) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t///////////////////////\r\n\t// First, check minimize/restore\r\n\t///////////////////////\r\n\r\n\tif ( (m_State==ePlaying) && IsIconic(m_MainWindow) ) { // we must pause process\r\n\t\t// the application is minimized\r\n\t\tm_State = eMinimized;\r\n\t\t// so we pause the player\r\n\t\tm_CKContext->Pause();\r\n\t\treturn;\r\n\t}\r\n\r\n\tif ( (m_State==eMinimized) && !IsIconic(m_MainWindow) ) { // we must restart process\r\n\t\t// the application is no longer minimized\r\n\t\tm_State = ePlaying;\r\n\t\t// so we restart the player\r\n\t\tm_CKContext->Play();\r\n\t\treturn;\r\n\t}\r\n\r\n\t///////////////////////\r\n\t// then check focus lost behavior\r\n\t///////////////////////\r\n\r\n\tCKDWORD pauseMode = m_CKContext->GetFocusLostBehavior();\r\n\r\n\tif(m_State==ePlaying || m_State==eFocusLost) {\r\n\t\tswitch (pauseMode)\r\n\t\t{\r\n\t\t\t// if the composition is configured to pause\r\n\t\t\t// the input manager when the focus is lost\r\n\t\t\t// note: for a stand alone player\r\n\t\t\t// CK_FOCUSLOST_PAUSEINPUT_MAIN and CK_FOCUSLOST_PAUSEINPUT_PLAYER\r\n\t\t\t// is the same thing. there is a difference only for the webplayer\r\n\t\tcase CK_FOCUSLOST_PAUSEINPUT_MAIN:\r\n\t\tcase CK_FOCUSLOST_PAUSEINPUT_PLAYER:\r\n\t\t\t// we pause/unpause it depending on the focus\r\n\t\t\tm_InputManager->Pause(!iFocus);\r\n\t\t\tbreak;\r\n\r\n\t\t\t// if the composition is configured to pause\r\n\t\t\t// the player (pause all) when the focus is lost\r\n\t\tcase CK_FOCUSLOST_PAUSEALL:\r\n\t\t\tif (!iFocus) {\r\n\t\t\t\t// focus lost\r\n\t\t\t\tm_State = eFocusLost;\r\n\t\t\t\t// pause the player\r\n\t\t\t\tm_CKContext->Pause();\t\r\n\t\t\t} else {\r\n\t\t\t\t// else\r\n\t\t\t\tm_State = ePlaying;\r\n\t\t\t\t// play\r\n\t\t\t\tm_CKContext->Play();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid CCustomPlayer::OnMouseClick(int iMessage)\r\n{\r\n\t// here we manage the mouse click\r\n\r\n\tif (!m_RenderContext) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// retrieve the cursor position\r\n\tPOINT pt;\r\n\tGetCursorPos(&pt);\r\n\tScreenToClient(m_RenderWindow,&pt);\r\n\r\n\t// convert the windows message to the virtools message\r\n\tint msg = (iMessage==WM_LBUTTONDOWN)?m_MsgClick:m_MsgDoubleClick;\r\n\r\n\t// retrieve information about object \"under\" the mouse\r\n\tVxIntersectionDesc desc;\r\n\tCKObject* obj = m_RenderContext->Pick(pt.x,pt.y,&desc);\r\n\tif(obj && CKIsChildClassOf(obj,CKCID_BEOBJECT)) {\r\n\t\t// send a message to the beobject\r\n\t\tm_MessageManager->SendMessageSingle(msg,(CKBeObject*)obj);\r\n\t}\r\n\r\n\tif (desc.Sprite) {\r\n\t\t// send a message to the sprite\r\n\t\tm_MessageManager->SendMessageSingle(msg,(CKBeObject *)desc.Sprite);\r\n\t}\r\n}\r\n\r\nvoid CCustomPlayer::OnPaint()\r\n{\r\n\tif (!m_RenderContext || m_RenderContext->IsFullScreen()) {\r\n\t\treturn;\r\n\t}\r\n\t// in windowed mode call render when WM_PAINT\r\n\tm_RenderContext->Render();\r\n}\r\n/********************************************************************\r\n\tcreated:\t2008/01/14\r\n\tcreated:\t14:1:2008 12:02\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\stylepge.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\n\tfile base:\tstylepge\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\tDisplays and stores settings in/from the player.ini \r\n*********************************************************************/\r\n#pragma once\r\n#include \"resourceplayer.h\"\r\n#include \"afxwin.h\"\r\nclass CustomPlayerDialogGraphicPage : public CPropertyPage\r\n{\r\n// Construction\r\npublic:\r\n\tCustomPlayerDialogGraphicPage();\r\n\r\n// Dialog Data\r\n\t//{{AFX_DATA(CStylePage)\r\n\tenum { IDD = IDD_STYLE };\r\n\tint m_nShapeStyle;\r\n\tint m_FSSA;\r\n\t//}}AFX_DATA\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generate virtual function overrides\r\n\t//{{AFX_VIRTUAL(CStylePage)\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n// Implementation\r\nprotected:\r\n\tvirtual void OnOK();\r\n\t\r\n\t// Generated message map functions\r\n\t//{{AFX_MSG(CStylePage)\r\n\t\t// NOTE: the ClassWizard will add member functions here\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\npublic:\r\n\tCComboBox m_windowMode;\r\n\tCListBox m_Driver;\r\n\tCComboBox m_FModes;\r\n\tCComboBox m_Bpps;\r\n\tCComboBox m_RRates;\r\n\t\r\n\tBOOL m_FullScreen;\r\n\tafx_msg void OnLbnSelchangeDriverList();\r\n\tCButton m_FullScreenBtn;\r\n\tCComboBox m_CB_FSSA;\r\n\tafx_msg void OnCbnSelchangeCombo1();\r\n\tafx_msg void OnCbnSelchangeCbFmode();\r\n\tafx_msg void OnCbnSelchangeCbBpps();\r\n\tafx_msg void OnCbnSelchangeCbRrates();\r\n\tafx_msg void OnBnClickedCheckbFullscreen();\r\n\tafx_msg void OnCbnSelchangeCbFssa();\r\n};\r\n#ifndef NX_PHYSICS_NXTARGETS\r\n#define NX_PHYSICS_NXTARGETS\r\n\r\n#include \"NxSwTarget.h\"\r\n#if NX_ENABLE_HW_PARSER\r\n#include \"NxHwTarget.h\"\r\n#endif\r\n\r\n#endif\r\n//AGCOPYRIGHTBEGIN\r\n///////////////////////////////////////////////////////////////////////////\r\n// Copyright (c) 2007 AGEIA Technologies.\r\n// All rights reserved. www.ageia.com\r\n///////////////////////////////////////////////////////////////////////////\r\n//AGCOPYRIGHTEND\r\n/******************************************************************************\r\n\r\n Copyright (C) 1999, 2000 NVIDIA Corporation\r\n This file is provided without support, instruction, or implied warranty of any\r\n kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is\r\n not liable under any circumstances for any damages or loss whatsoever arising\r\n from the use or inability to use this file or items derived from it.\r\n \r\n Comments:\r\n \r\n \r\n \r\n******************************************************************************/\r\n#include \r\n#include \r\n#include \"rmxfguid.h\"\r\n#include \"rmxftmpl.h\"\r\n#include \"shared/nvfile.h\"\r\n\r\nusing namespace std;\r\n\r\n#ifndef SAFE_RELEASE\r\n #define SAFE_RELEASE(x) { if (x) { x->Release(); x = NULL; } }\r\n#endif\r\n\r\nHRESULT NVFile::LoadFrame( IDirect3DDevice9* pDevice,\r\n LPD3DXFILEDATA pFileData,\r\n NVFrame* pParentFrame )\r\n{\r\n LPD3DXFILEDATA pChildData = NULL;\r\n GUID guid;\r\n DWORD cbSize;\r\n NVFrame* pCurrentFrame;\r\n HRESULT hr;\r\n\r\n // Get the type of the object\r\n if( FAILED( hr = pFileData->GetType( &guid ) ) )\r\n return hr;\r\n\r\n if( guid == TID_D3DRMMesh )\r\n {\r\n hr = LoadMesh( pDevice, pFileData, pParentFrame );\r\n if( FAILED(hr) )\r\n return hr;\r\n }\r\n if( guid == TID_D3DRMFrameTransformMatrix )\r\n {\r\n D3DXMATRIX* pmatMatrix;\r\n hr = pFileData->Lock(&cbSize, (LPCVOID*)&pmatMatrix );\r\n if( FAILED(hr) )\r\n return hr;\r\n\r\n // Update the parent's matrix with the new one\r\n pParentFrame->SetMatrix( pmatMatrix );\r\n }\r\n if( guid == TID_D3DRMFrame )\r\n {\r\n // Get the frame name\r\n TCHAR strAnsiName[512] = _T(\"\");\r\n SIZE_T dwNameLength = 512;\r\n SIZE_T cChildren;\r\n\r\n#ifdef UNICODE\r\n\r\n\t\tCHAR tmp[512];\r\n if( FAILED( hr = pFileData->GetName( tmp, &dwNameLength ) ) )\r\n return hr;\r\n\r\n\t\tMultiByteToWideChar(CP_ACP,0,tmp,512,strAnsiName,512);\r\n#else\r\n if( FAILED( hr = pFileData->GetName( strAnsiName, &dwNameLength ) ) )\r\n return hr;\r\n#endif\r\n\r\n\r\n // Create the frame\r\n pCurrentFrame = new NVFrame( strAnsiName );\r\n if( pCurrentFrame == NULL )\r\n return E_OUTOFMEMORY;\r\n\r\n pCurrentFrame->m_pNext = pParentFrame->m_pChild;\r\n pParentFrame->m_pChild = pCurrentFrame;\r\n\r\n // Enumerate child objects\r\n pFileData->GetChildren(&cChildren);\r\n for (UINT iChild = 0; iChild < cChildren; iChild++)\r\n {\r\n // Query the child for its FileData\r\n hr = pFileData->GetChild(iChild, &pChildData );\r\n if( SUCCEEDED(hr) )\r\n {\r\n hr = LoadFrame( pDevice, pChildData, pCurrentFrame );\r\n SAFE_RELEASE( pChildData );\r\n }\r\n\r\n if( FAILED(hr) )\r\n return hr;\r\n }\r\n }\r\n\r\n return S_OK;\r\n}\r\n\r\nHRESULT NVFile::LoadMesh( IDirect3DDevice9* pDevice,\r\n LPD3DXFILEDATA pFileData,\r\n NVFrame* pParentFrame )\r\n{\r\n // Currently only allowing one mesh per frame\r\n if( pParentFrame->m_pMesh )\r\n return E_FAIL;\r\n\r\n // Get the mesh name\r\n TCHAR strAnsiName[512] = {0};\r\n SIZE_T dwNameLength = 512;\r\n\r\n HRESULT hr;\r\n#ifdef UNICODE\r\n\r\n\tCHAR tmp[512];\r\n if( FAILED( hr = pFileData->GetName( tmp, &dwNameLength ) ) )\r\n return hr;\r\n\r\n\tMultiByteToWideChar(CP_ACP,0,tmp,512,strAnsiName,512);\r\n#else\r\n if( FAILED( hr = pFileData->GetName( strAnsiName, &dwNameLength ) ) )\r\n return hr;\r\n#endif\r\n\r\n // Create the mesh\r\n pParentFrame->m_pMesh = new NVMesh( strAnsiName );\r\n if( pParentFrame->m_pMesh == NULL )\r\n return E_OUTOFMEMORY;\r\n pParentFrame->m_pMesh->Create( pDevice, pFileData );\r\n\r\n return S_OK;\r\n}\r\n\r\nHRESULT NVFile::Create( IDirect3DDevice9* pDevice, const tstring& strPathname )\r\n{\r\n LPD3DXFILE pDXFile = NULL;\r\n LPD3DXFILEENUMOBJECT pEnumObj = NULL;\r\n LPD3DXFILEDATA pFileData = NULL;\r\n HRESULT hr;\r\n SIZE_T cChildren;\r\n\r\n\ttstring::size_type Pos = strPathname.find_last_of(_T(\"\\\\\"), strPathname.size());\r\n\tif (Pos != strPathname.npos)\r\n\t{\r\n\t\t// Make sure we are on the right path for loading resources associated with this file\r\n\t\tm_strFilePath = strPathname.substr(0, Pos);\r\n\t\tSetCurrentDirectory(m_strFilePath.c_str());\r\n\t}\r\n\r\n // Create a x file object\r\n if( FAILED( hr = D3DXFileCreate( &pDXFile ) ) )\r\n return E_FAIL;\r\n\r\n // Register templates for d3drm and patch extensions.\r\n if( FAILED( hr = pDXFile->RegisterTemplates( (VOID*)D3DRM_XTEMPLATES,\r\n D3DRM_XTEMPLATE_BYTES ) ) )\r\n {\r\n SAFE_RELEASE( pDXFile );\r\n return E_FAIL;\r\n }\r\n#ifdef UNICODE\r\n \tint len = WideCharToMultiByte(CP_ACP,0,strPathname.c_str(),-1,NULL,NULL,NULL,NULL);\r\n\tchar *tmp = new char[len];\r\n\tWideCharToMultiByte(CP_ACP,0,strPathname.c_str(),-1,tmp,len,NULL,NULL);\r\n\r\n\r\n\thr = pDXFile->CreateEnumObject( (VOID*)tmp,\r\n D3DXF_FILELOAD_FROMFILE, &pEnumObj );\r\n\t\r\n#else\r\n // Create enum object\r\n hr = pDXFile->CreateEnumObject( (VOID*)strPathname.c_str(),\r\n D3DXF_FILELOAD_FROMFILE, &pEnumObj );\r\n#endif\r\n\tif (FAILED(hr))\r\n {\r\n SAFE_RELEASE( pDXFile );\r\n return hr;\r\n }\r\n\r\n // Enumerate top level objects (which are always frames)\r\n pEnumObj->GetChildren(&cChildren);\r\n for (UINT iChild = 0; iChild < cChildren; iChild++)\r\n {\r\n hr = pEnumObj->GetChild(iChild, &pFileData);\r\n if (FAILED(hr))\r\n return hr;\r\n\r\n hr = LoadFrame( pDevice, pFileData, this );\r\n SAFE_RELEASE( pFileData );\r\n if( FAILED(hr) )\r\n {\r\n SAFE_RELEASE( pEnumObj );\r\n SAFE_RELEASE( pDXFile );\r\n return E_FAIL;\r\n }\r\n }\r\n\r\n SAFE_RELEASE( pFileData );\r\n SAFE_RELEASE( pEnumObj );\r\n SAFE_RELEASE( pDXFile );\r\n\r\n return S_OK;\r\n}\r\n\r\nHRESULT NVFile::Render( IDirect3DDevice9* pDevice )\r\n{\r\n // Setup the world transformation\r\n D3DXMATRIX matSavedWorld, matWorld;\r\n pDevice->GetTransform(D3DTS_WORLD, &matSavedWorld);\r\n D3DXMatrixMultiply( &matWorld, &matSavedWorld, &m_mat );\r\n pDevice->SetTransform(D3DTS_WORLD, &matWorld );\r\n\r\n // Render opaque subsets in the meshes\r\n if( m_pChild )\r\n m_pChild->Render( pDevice, TRUE, FALSE );\r\n\r\n // Enable alpha blending\r\n pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );\r\n pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );\r\n pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );\r\n\r\n // Render alpha subsets in the meshes\r\n if( m_pChild )\r\n m_pChild->Render( pDevice, FALSE, TRUE );\r\n\r\n // Restore state\r\n pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );\r\n pDevice->SetTransform(D3DTS_WORLD, &matSavedWorld );\r\n\r\n return S_OK;\r\n}\r\n\r\n\r\nbool CalcFileObjectSizeCB( NVFrame* pFrame, D3DXMATRIX* pMat, VOID* pfSize )\r\n{\r\n\tNVBounds* pBounds = (NVBounds*)pfSize;\r\n\tNVMesh* pMesh = pFrame->m_pMesh;\r\n\tDWORD dwStride = 0;\r\n\r\n\tif (!pMesh)\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\t// Get the bounds for the mesh and transform them by the local\r\n\t// world transform.\r\n\tNVBounds MeshBounds = *pMesh->GetBounds();\r\n\tMeshBounds.Transform(pMat);\r\n\t\r\n\tif (pBounds->m_vecMaxExtents.x < MeshBounds.m_vecMaxExtents.x)\r\n\t\tpBounds->m_vecMaxExtents.x = MeshBounds.m_vecMaxExtents.x;\r\n\r\n\tif (pBounds->m_vecMaxExtents.y < MeshBounds.m_vecMaxExtents.y)\r\n\t\tpBounds->m_vecMaxExtents.y = MeshBounds.m_vecMaxExtents.y;\r\n\r\n\tif (pBounds->m_vecMaxExtents.z < MeshBounds.m_vecMaxExtents.z)\r\n\t\tpBounds->m_vecMaxExtents.z = MeshBounds.m_vecMaxExtents.z;\r\n\r\n\r\n\tif (pBounds->m_vecMinExtents.x > MeshBounds.m_vecMinExtents.x)\r\n\t\tpBounds->m_vecMinExtents.x = MeshBounds.m_vecMinExtents.x;\r\n\r\n\tif (pBounds->m_vecMinExtents.y > MeshBounds.m_vecMinExtents.y)\r\n\t\tpBounds->m_vecMinExtents.y = MeshBounds.m_vecMinExtents.y;\r\n\r\n\tif (pBounds->m_vecMinExtents.z > MeshBounds.m_vecMinExtents.z)\r\n\t\tpBounds->m_vecMinExtents.z = MeshBounds.m_vecMinExtents.z;\r\n\r\n\tif (pBounds->m_fRadius < MeshBounds.m_fRadius)\r\n\t\tpBounds->m_fRadius = MeshBounds.m_fRadius;\r\n\r\n return true;\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: GetBoundingInfo()\r\n// Desc:\r\n//-----------------------------------------------------------------------------\r\nvoid NVFile::GetBoundingInfo(NVBounds* pBounds)\r\n{\r\n\tpBounds->m_vecCenter = D3DXVECTOR3(0.0f, 0.0f, 0.0f);\r\n\tpBounds->m_fRadius = 0.0f;\r\n\tpBounds->m_vecMinExtents = D3DXVECTOR3(FLT_MAX, FLT_MAX, FLT_MAX);\r\n\tpBounds->m_vecMaxExtents = D3DXVECTOR3(-FLT_MAX, -FLT_MAX, -FLT_MAX);\r\n\r\n\tD3DXMATRIX Matrix;\r\n\tD3DXMatrixIdentity(&Matrix);\r\n WalkFrames(CalcFileObjectSizeCB, &Matrix, (VOID*)pBounds);\r\n\r\n\tpBounds->m_vecCenter = (pBounds->m_vecMaxExtents + pBounds->m_vecMinExtents) / 2.0f;\r\n}\r\n\r\n#include \"stdafx2.h\"\r\n#include \"resource.h\"\r\n#include \"PBodyTabCtrl.h\"\r\n#include \"PBodyQuickPage.h\"\r\n\r\n\r\n\r\n\r\n/*#include \"TabOne.h\"\r\n#include \"TabTwo.h\"\r\n#include \"TabThree.h\"\r\n*/\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// PBodyTabContrl\r\n\r\nIMPLEMENT_DYNCREATE(PBodyTabContrl,VITabCtrl)\r\n\r\nPBodyTabContrl::PBodyTabContrl(CWnd*win)\r\n{\r\n\r\n\r\n\t//PBodyTabContrl\r\n\tm_tabPages[0]=new PBodyQuickPage();\r\n\tif (m_tabPages[0])\r\n\t{\r\n\t\tm_nNumberOfPages=1;\r\n\r\n\t}\r\n\t/*m_tabPages[1]=new CTabTwo;\r\n\tm_tabPages[2]=new CTabThree;\r\n\t*/\r\n\r\n\tm_nNumberOfPages=1;\r\n}\r\n\r\nPBodyTabContrl::PBodyTabContrl() : VITabCtrl()\r\n{\r\n\r\n\t//PBodyTabContrl\r\n\tm_tabPages[0]=new PBodyQuickPage();\r\n\tif (m_tabPages[0])\r\n\t{\r\n\t\tm_nNumberOfPages=1;\r\n\r\n\t}\r\n\t/*m_tabPages[1]=new CTabTwo;\r\n\tm_tabPages[2]=new CTabThree;\r\n*/\r\n\r\n\tm_nNumberOfPages=1;\r\n}\r\n\r\nPBodyTabContrl::~PBodyTabContrl()\r\n{\r\n\tfor(int nCount=0; nCount < m_nNumberOfPages; nCount++){\r\n\t\tdelete m_tabPages[nCount];\r\n\t}\r\n}\r\n\r\n\r\n\r\nvoid PBodyTabContrl::_construct()\r\n{\r\n\r\n\tVITabCtrl::EnableWindow(true);\r\n\tVITabCtrl::EnableAutomation();\r\n\tVITabCtrl::ShowWindow(SW_SHOW);\r\n\r\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n\r\n\r\n\r\n\tm_tabCurrent=0;\r\n\t//m_tabPages[0]->Create(IDD_PBCOMMON, this);\r\n\t//m_tabPages[1]->Create(IDD_PBCOMMON, this);\r\n\t\r\n\t//m_tabPages[0]->ShowWindow(SW_SHOW);\r\n\t//m_tabPages[1]->ShowWindow(SW_SHOW);\r\n\t//m_tabPages[1]->ShowWindow(SW_SHOW);\r\n\r\n\t//m_tabPages[2]->ShowWindow(SW_HIDE);\r\n\r\n\tm_nNumberOfPages = 1;\r\n\r\n\tSetRectangle();\r\n}\r\nvoid PBodyTabContrl::Init()\r\n{\t\r\n//VITabCtrl::UpdateWindow();\r\n\r\n}\r\n\r\nvoid PBodyTabContrl::SetRectangle()\r\n{\r\n\t\r\n\tCRect tabRect, itemRect;\r\n\tint nX, nY, nXc, nYc;\r\n\r\n\tGetClientRect(&tabRect);\r\n\tCRect r;\r\n\r\n\r\n\t((CTabCtrl *)(this))->GetItemRect(0, &itemRect);\r\n\r\n\r\n\r\n\t//TabCtrl_GetItemRect(0, &itemRect);\r\n\t//GetItemRect\r\n\r\n\tnX=itemRect.left;\r\n\tnY=itemRect.bottom+1;\r\n\tnXc=tabRect.right-itemRect.left-1;\r\n\tnYc=tabRect.bottom-nY-1;\r\n/*\r\n\tm_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);\r\n\tfor(int nCount=1; nCount < m_nNumberOfPages; nCount++){\r\n\t\tm_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);\r\n\t}*/\r\n\t\r\n}\r\n\r\nBEGIN_MESSAGE_MAP(PBodyTabContrl, VITabCtrl)\r\n\t//{{AFX_MSG_MAP(PBodyTabContrl)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// PBodyTabContrl message handlers\r\n\r\n/*\r\nvoid PBodyTabContrl::OnLButtonDown(UINT nFlags, CPoint point) \r\n{\r\n\r\n\r\n\tCTabCtrl &tabContr = ((CTabCtrl*)(this));\r\n\ttabContr::OnLButtonDown(nFlags, point);\r\n\r\n\tif(m_tabCurrent != (CTabCtrl*)GetCurFocus()){\r\n\t\tm_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);\r\n\t\tm_tabCurrent=GetCurFocus();\r\n\t\tm_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);\r\n\t\tm_tabPages[m_tabCurrent]->SetFocus();\r\n\t}\r\n\t\r\n\t\r\n}\r\n*/int EncryptPassword(char* pcPassword);\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n\r\n\r\n#include \r\n//#include \"windows.h\"\r\n\r\nTNL::RefPtrm_NetInterfaceServer = NULL;\r\nTNL::RefPtrGetServerInterface(){ return m_NetInterfaceServer;}\r\nconst char *localBroadcastAddress = \"IP:broadcast:28999\";\nconst char *localHostAddress = \"IP:127.0.0.1:28999\";\r\nconst char *localServerAddress =\"IP:Any:28999\";\n\n#include \"xLogger.h\"\n#include \"IMessages.h\"\n\nclass DedicatedServerLogConsumer : public TNL::LogConsumer\n{\npublic:\n\tvoid logString(const char *string)\n\t{\n\t\t//ctx()->OutputToConsoleEx(\"%s\\n\",string);\n\t\tprintf(\"%s\\n\\n\", string);\n\t}\n} gDedicatedServerLogConsumer;\n\nusing namespace TNL;\n\n\nfloat mLastTime=0.0;\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \"xNetConstants.h\"\r\nHANDLE m_hPromptThread;\r\nbool m_bQuitThread = false;\r\n\nUINT WINAPI PromptThread( LPVOID pParam );\r\n//-----------------------------------------------------------------------------\r\n// Name: ParseInput\r\n// Desc: Handle user input\r\n//-----------------------------------------------------------------------------\r\nvoid ParseInput( TCHAR* buffer )\r\n{\r\n\t\r\n\t\r\n\tTCHAR* token = _tcstok( buffer, TEXT(\" \\t\") );\r\n\tif( token == NULL )\r\n\t\treturn;\r\n\r\n\t_tcsupr( token );\r\n\r\n\tif( !_tcscmp( token, TEXT(\"LOGLEVEL\") ) ||\r\n\t\t!_tcscmp( token, TEXT(\"SETLOG\") ))\r\n\t{\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tint component = 0; \r\n\t\tint level = 0;\r\n\t\tint value = 0;\r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tcomponent = _ttol( token );\r\n\r\n\t\t}\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tlevel = _ttol( token );\r\n\t\t}\r\n\t\t\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tvalue = _ttol( token );\r\n\t\t}\r\n\t\t\r\n\t\ttoken = NULL;\r\n\r\n\t\tif (GetServerInterface())\r\n\t\t{\r\n\t\t\tGetServerInterface()->enableLogLevel(component,level,value);\r\n\t\t}\r\n\t\t\r\n\t\treturn;\r\n\t}\r\n\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\tif( !_tcscmp( token, TEXT(\"STATS\") ) || \t\t!_tcscmp( token, TEXT(\"PRINT\") ) )\r\n\t{\r\n\t\t\t\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tint component = 0; \r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tcomponent = _ttol( token );\r\n\t\t\tif (GetServerInterface())\r\n\t\t\t{\r\n\t\t\t\tGetServerInterface()->printObjects(component,component);\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tif (GetServerInterface())\r\n\t\t\t{\r\n\t\t\t\tGetServerInterface()->printObjects(0,0);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn;\r\n\t}\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\tif( !_tcscmp( token, TEXT(\"SETMSGMINTIME\") ) || \t\t!_tcscmp( token, TEXT(\"MMTIME\") ) )\r\n\t{\r\n\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tfloat component = 0; \r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tcomponent = (float)_ttol( token );\r\n\t\t\tif (GetServerInterface())\r\n\t\t\t{\r\n\t\t\t\tGetServerInterface()->getMessagesInterface()->setThresoldTicker(component);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\tif( !_tcscmp( token, TEXT(\"SETMSGTIMEOUT\") ) || \t\t!_tcscmp( token, TEXT(\"MTOUT\") ) )\r\n\t{\r\n\r\n\t\ttoken = _tcstok( NULL, TEXT(\" \\t\") );\r\n\t\tfloat component = 0; \r\n\t\tif( token )\r\n\t\t{\r\n\t\t\tcomponent = (float)_ttol( token );\r\n\t\t\tif (GetServerInterface())\r\n\t\t\t{\r\n\t\t\t\tGetServerInterface()->getMessagesInterface()->setMessageTimeout(component);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tif( !_tcscmp( token, TEXT(\"HELP\") ) || \t\t!_tcscmp( token, TEXT(\"?\") ) )\r\n\t{\r\n\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Print component index for command setLog\");\r\n\t\tfor (int i = 0 ; i < 16 ; i++ )\r\n\t\t{\r\n\t\t\txLogger::xLogExtro(0,\"Index : %d : \\t %s\",i,sLogItems[i]);\r\n \r\n\t\t}\r\n\t\t\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Print verbosity levels\");\r\n\t\txLogger::xLogExtro(0,\"0 : DEBUG\");\r\n\t\txLogger::xLogExtro(0,\"1 : TRACE\");\r\n\t\txLogger::xLogExtro(0,\"2 : ERROR\");\r\n\t\txLogger::xLogExtro(0,\"3 : WARNING\");\r\n\t\txLogger::xLogExtro(0,\"4 : INFO\");\r\n\r\n\t\txLogger::xLogExtro(0,\"\\t write 'setLog 1 2 1' to enable all session related errors\" );\r\n\t\txLogger::xLogExtro(0,\"\\t write 'setLog 1 2 0' to disable all session related errors \\n\" );\r\n\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"commands :\");\r\n\t\txLogger::xLogExtro(0,\"\\t print [Index]:0-4 : prints object informations\\n\" );\r\n\t\txLogger::xLogExtro(0,\"\\t setMsgMinTime [value]:5-x ms : sets minimum time between message sending\\n\" );\r\n\t\txLogger::xLogExtro(0,\"\\t setMsgTimeout [value]:5-x ms : sets message lifetime,\\n\" );\r\n\r\n\r\n\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\tif( !_tcscmp( token, TEXT(\"STOP\") ) || \r\n\t\t!_tcscmp( token, TEXT(\"QUIT\") ) || \r\n\t\t!_tcscmp( token, TEXT(\"EXIT\") ) )\r\n\t{\r\n\t\tm_bQuitThread = TRUE;\r\n\r\n\t}\r\n\t\r\n\t\r\n}\nvoid DoPrompt( TCHAR* strPromptString, TCHAR* strBuffer )\r\n{\r\n\t//m_pMazeApp->ConsolePrintf( LINE_PROMPT, strPromptString );\r\n\r\n\tDWORD dwRead;\r\n\tBOOL bSuccess;\r\n\tbSuccess = ReadConsole( GetStdHandle(STD_INPUT_HANDLE), strBuffer, 128, &dwRead, NULL );\r\n\r\n\tif( !bSuccess || dwRead < 2 )\r\n\t{\r\n\t\t_tcscpy( strBuffer, TEXT(\"\") );\r\n\t\treturn;\r\n\t}\r\n\r\n\tstrBuffer[dwRead-2]=0;\r\n\t//m_pMazeApp->ConsolePrintf( LINE_INPUT, strBuffer );\r\n}\nUINT WINAPI StaticPromptThread( LPVOID pParam )\r\n{\r\n\treturn PromptThread( pParam );\r\n}\r\n\r\n\r\n//-----------------------------------------------------------------------------\r\n// Name: PromptThread\r\n// Desc: Thread body for infite command prompts\r\n//-----------------------------------------------------------------------------\r\nUINT WINAPI PromptThread( LPVOID pParam )\r\n{\r\n\t// Loop around getting and dealing with keyboard input\r\n\tTCHAR buffer[512];\r\n\twhile( !m_bQuitThread )\r\n\t{\r\n\r\n\t\tDoPrompt( TEXT(\"Command> \"), buffer );\r\n\t\tParseInput( buffer );\r\n\t};\r\n\r\n\t//_tprintf( TEXT(\"Stopping...\") );\r\n\r\n\treturn 0;\r\n}\r\n\n\n\nint main(int argc, const char **argv)\n{\r\n\r\n\r\n\txLogger::GetInstance()->addLogItem(E_LI_SESSION);\r\n\t//xLogger::GetInstance()->enableLoggingLevel(E_LI_SESSION,ELOGINFO,1);\r\n\t\r\n\txLogger::GetInstance()->addLogItem(E_LI_CLIENT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_3DOBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_2DOBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_DISTRIBUTED_BASE_OBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_DISTRIBUTED_CLASS_DESCRIPTORS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_MESSAGES);\r\n\txLogger::GetInstance()->addLogItem(E_LI_ARRAY_MESSAGES);\r\n\txLogger::GetInstance()->addLogItem(E_LI_CONNECTION);\r\n\txLogger::GetInstance()->addLogItem(E_LI_NET_INTERFACE);\r\n\txLogger::GetInstance()->addLogItem(E_LI_GHOSTING);\r\n\txLogger::GetInstance()->addLogItem(E_LI_STATISTICS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_BUILDINGBLOCKS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_VSL);\r\n\txLogger::GetInstance()->addLogItem(E_LI_CPP);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_CPP,ELOGINFO,1);\r\n\txLogger::GetInstance()->addLogItem(E_LI_ASSERTS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_PREDICTION);\r\n\txLogger::GetInstance()->addLogItem(E_LI_SERVER_MESSAGES);\r\n\r\n\txLogger::GetInstance()->addItemDescription(\"Session\");\r\n\txLogger::GetInstance()->addItemDescription(\"Client\");\r\n\txLogger::GetInstance()->addItemDescription(\"3dObject\");\r\n\txLogger::GetInstance()->addItemDescription(\"2dObject\");\r\n\txLogger::GetInstance()->addItemDescription(\"DistBase Object\");\r\n\txLogger::GetInstance()->addItemDescription(\"DistClassDescr\");\r\n\txLogger::GetInstance()->addItemDescription(\"Messages\");\r\n\txLogger::GetInstance()->addItemDescription(\"ArrayMessages\");\r\n\txLogger::GetInstance()->addItemDescription(\"Connection\");\r\n\txLogger::GetInstance()->addItemDescription(\"NetInterface\");\r\n\txLogger::GetInstance()->addItemDescription(\"Ghosting\");\r\n\txLogger::GetInstance()->addItemDescription(\"Stats\");\r\n\txLogger::GetInstance()->addItemDescription(\"BB\");\r\n\txLogger::GetInstance()->addItemDescription(\"VSL\");\r\n\txLogger::GetInstance()->addItemDescription(\"CPP\");\r\n\txLogger::GetInstance()->addItemDescription(\"Asserts\");\r\n\txLogger::GetInstance()->addItemDescription(\"Prediction\");\r\n\txLogger::GetInstance()->addItemDescription(\"ServerMsg\");\r\n\r\n\r\n\tTNLLogEnable(LogNetInterface,true);\r\n\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//create a server : \r\n\t\r\n\tTNL::Address *add = new TNL::Address(\"IP:Any:28999\");\r\n\tTNL::Address *addBC=new TNL::Address(\"IP:broadcast:28999\");\r\n\tm_NetInterfaceServer = new xNetInterface(true,*add,*addBC);\r\n\tTNL::AsymmetricKey *theKey = new TNL::AsymmetricKey(32);\n\tm_NetInterfaceServer->setPrivateKey(theKey);\r\n\tm_NetInterfaceServer->setRequiresKeyExchange(false);\r\n\r\n\tif (m_NetInterfaceServer)\r\n\t{\r\n\t\tm_NetInterfaceServer->setAllowsConnections(true);\r\n\t\t\r\n\t}\r\n\r\n\t//Sleep(2000);\r\n\tif (GetServerInterface() && GetServerInterface()->getSocket().isValid() )\r\n\t{\r\n\t\t\r\n\t\t//logprintf(\"\\t Server Created\");\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Server created\");\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"enter '?' for available commands !\" );\r\n\r\n\r\n\t}else{\r\n xLogger::xLog(ELOGERROR,E_LI_CPP,\"Couldn't create socket\");\r\n\t}\r\n\r\n\t\r\n\tUINT dwPromptThreadID;\r\n\tm_hPromptThread = (HANDLE)_beginthreadex( NULL, 0, StaticPromptThread, NULL, 0, &dwPromptThreadID );\r\n\tfor (;;)\r\n\t{\r\n\r\n\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\n\n\t\tfloat timeDelta = (currentTime - mLastTime);\r\n\t\tmLastTime = (float)currentTime;\r\n\t\tGetServerInterface()->getMessagesInterface()->advanceTime(timeDelta);\r\n\t\tGetServerInterface()->tick();\r\n\t\tGetServerInterface()->getMessagesInterface()->checkMessages();\n\t\tGetServerInterface()->getMessagesInterface()->deleteAllOldMessages();\r\n\t\tif (m_bQuitThread)\r\n\t\t{\r\n\t\t\tGetServerInterface()->destroy();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t/*char message[400];\r\n\t\tgets(message);\r\n\t\tif (!strcmp(message,\"exit\"))\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t\r\n\r\n\t\twhile (kbhit()){\r\n\t\t\tgetch();\r\n\t\t}*/\r\n\t\tTNL::Platform::sleep(1);\r\n\t}\r\n\r\n\r\n\treturn 0;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2009/04/14\r\n\tcreated:\t14:4:2009 11:29\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Src\\Core\\DataManagerRemote.cpp\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Src\\Core \r\n\tfile base:\tDataManagerRemote\r\n\tfile ext:\tcpp\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\thandles remote messages\r\n*********************************************************************/\r\n#include \"StdAfx.h\"\r\n#include \"DataManager.h\"\r\n\r\n#ifdef G_EXTERNAL_ACCESS\r\n\r\n#include \"MemoryFileMappingTypes.h\"\r\n\r\n#include \r\n#include \"AutoLock.h\"\r\n#include \"vtGUID.h\"\r\n\r\nusing namespace AutoLock;\r\n\r\nvtExternalEvent *Msg;\r\n\r\nHANDLE hmem = NULL;\r\n\r\nint post = 0;\r\n\r\nHANDLE m_hLogItemSendEvent = ::CreateEvent(NULL,TRUE,FALSE,\"LogItemSendEventName\");\r\nHANDLE m_hShutdownEvent = ::CreateEvent(NULL,FALSE,FALSE,\"SendRcvShutdownEvent\");\r\nHANDLE m_hLogItemReceivedEvent = ::CreateEvent(NULL,FALSE,FALSE,\"LogItemReceivedEventName\");\r\nHANDLE aHandles[] = { m_hShutdownEvent , m_hLogItemSendEvent };\r\n\r\nBOOL recieved = false;\r\nBOOL changed = true;\r\n\r\n\r\n\r\n\r\nint DataManager::_SharedMemoryTickPost(int flagsOfWhatever)\r\n{\r\n\r\n\tif (!changed){\r\n\r\n\t\tSetEvent( m_hShutdownEvent );\r\n\t}\r\n\treturn CK_OK;\r\n\r\n\treturn 0;\r\n}\r\n\r\nint DataManager::_SharedMemoryTick(int flagsOfWhatever)\r\n{\r\n\r\n\tHRESULT hr = S_OK;\r\n\r\n\t//USES_CONVERSION;\r\n\r\n\tswitch( ::WaitForMultipleObjects(sizeof(aHandles) /sizeof(HANDLE),&(aHandles[0]),FALSE,1))\r\n\t{\r\n\r\n\tcase WAIT_OBJECT_0:\t\r\n\t\t{\t\r\n\t\t\tSetEvent( m_hShutdownEvent );\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase WAIT_OBJECT_0 + 1:\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\r\n\t\t\t\tCLockableMutex m_mtxMMFile(\"sharedMem\");\r\n\t\t\t\tCAutoLockT< CLockableMutex > lock(&m_mtxMMFile, 5000 );\r\n\t\t\t\tvtExternalEvent *pLI = reinterpret_cast(m_pData);\r\n\t\t\t\t\r\n\t\r\n\t\t\t\t//XString command(pLI->command);\r\n\t\t\t\t//XString commandArg(pLI->commandArg);\r\n\r\n\r\n\t\t\t\tXString msgStr;\r\n\t\t\t\tmsgStr.Format(\"Remote Message:%s\",pLI->command);\r\n\t\t\t\tm_Context->OutputToConsole(msgStr.Str(),FALSE);\r\n\r\n\t\t\t\tchanged = true;\r\n\t\t\t\tSetEvent( m_hLogItemReceivedEvent );\r\n\t\t\t\t::ResetEvent(m_hShutdownEvent);\r\n\t\t\t\treturn CK_OK;\r\n\t\t\t}\r\n\t\t\tcatch( CAutoLockTimeoutExc )\r\n\t\t\t{\r\n\t\t\t\thr = HRESULT_FROM_WIN32( WAIT_TIMEOUT );\r\n\t\t\t}\r\n\t\t\tcatch( CAutoLockWaitExc& e )\r\n\t\t\t{\r\n\t\t\t\thr = HRESULT_FROM_WIN32( e.GetLastError() );\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\t\t//\tdefault:\r\n\t\t//\t\tATLASSERT(0);\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\nint DataManager::_initSharedMemory(int flagsOfWhatever)\r\n{\r\n\r\n\tif( NULL != ( m_hMMFile = CreateFileMapping( INVALID_HANDLE_VALUE,\r\n\t\tNULL,PAGE_READWRITE,0,\r\n\t\tsizeof( vtExternalEvent ),\"sharedMemFile\" ) ))//_T(\"LogSndRcvMMF\") )))\r\n\t{\r\n\t\tif( NULL != (m_pData = (vtExternalEvent*)::MapViewOfFile(m_hMMFile,\r\n\t\t\tFILE_MAP_READ | FILE_MAP_WRITE, \r\n\t\t\t0,\r\n\t\t\t0,\r\n\t\t\tsizeof( vtExternalEvent* )) ) )\r\n\t\t{\r\n\t\t\treturn S_OK;\r\n\t\t}\r\n\t}\r\n\r\n\treturn HRESULT_FROM_WIN32( ::GetLastError( ) );\r\n}\r\n#endif\r\n/********************************************************************\r\n\tcreated:\t2007/11/28\r\n\tcreated:\t28:11:2007 16:25\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\\CustomPlayerConfigurationDialog.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\r\n\tfile base:\tCustomPlayerConfigurationDialog\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"resource.h\"\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\r\n//\r\n//\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nextern CCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\nINT_PTR CALLBACK ConfigureDialogProcHelper( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )\r\n{\r\n return GetApp()->ConfigureDialogProc( hwndDlg, uMsg, wParam, lParam );\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\nvoid CCustomPlayerApp::DoConfig()\r\n{\r\n\tDialogBox( m_hInstance, MAKEINTRESOURCE(IDD_DIALOG1), m_MainWindow , (DLGPROC)ConfigureDialogProcHelper );\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n\r\nstruct _dinfo\r\n{\r\n\tint _w,_h,_bpp,_hz;\r\n\t_dinfo():_w(0), _h(0),_bpp(0),_hz(0){}\r\n\t_dinfo(int w,int h,int bpp,int hz) : _w(w), _h(h),_bpp(bpp),_hz(hz){}\r\n};\r\n\r\n#include \r\n#include \r\nstd::vector<_dinfo>_modes;\r\n\r\n_dinfo _current;\r\n_dinfo *_currentW=NULL;\r\n\r\nint _currentDriver=-1;\r\nint _currentWMode=-1;\r\nint currentRes=-1;\r\nint currentBpp=-1;\r\nint currentRRate = -1;\r\nint currentFSSA = -1;\r\n\r\n\r\nvoid _UpdateLists(HWND hwndDlg,int DriverId)\r\n{\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tint count = GetPlayer().GetEnginePointers()->TheRenderManager->GetRenderDriverCount();\r\n\tint i,index;\r\n\tchar ChaineW[256];\r\n\tbool driverfound = false;\r\n\r\n\tSendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_RESETCONTENT,0,0);\r\n\tSendDlgItemMessage(hwndDlg,IDC_LISTDRIVER,LB_RESETCONTENT,0,0);\r\n\t\r\n\tSendDlgItemMessage(hwndDlg,IDCB_BPP,CB_RESETCONTENT,0,0);\r\n\tSendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_RESETCONTENT,0,0);\r\n\tSendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_RESETCONTENT,0,0);\r\n\tSendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_RESETCONTENT,0,0);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we fill the driver list :\r\n\tfor (i=0;iTheRenderManager->GetRenderDriverDescription(i);\r\n\t\tindex=SendDlgItemMessage(hwndDlg,IDC_LISTDRIVER,LB_ADDSTRING,0,(LPARAM)desc->DriverName.CStr());\r\n\t\tSendDlgItemMessage(hwndDlg,IDC_LISTDRIVER,LB_SETITEMDATA,index,i);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we set the driver in the listbox to driver we found in the player.ini\r\n\t\tif (i==DriverId)\r\n\t\t{\r\n\t\t\tSendDlgItemMessage(hwndDlg,IDC_LISTDRIVER,LB_SETCURSEL,index,0);\r\n\t\t\tdriverfound = true;\r\n\t\t}\r\n\r\n\t}\r\n\t//FullScreen :\r\n\tSendDlgItemMessage(hwndDlg,IDC_CHB_FULLSCREEN,BM_SETCHECK,ewinfo->g_GoFullScreen,0);\r\n\r\n\tVxDriverDesc *MainDesc=ep->TheRenderManager->GetRenderDriverDescription(ewinfo->g_FullScreenDriver);\r\n\t\r\n\tXArray bpps;//temporary storage to avoid doubles in the list\r\n\tXArray rrates;//temporary storage to avoid doubles in the list\r\n\tXArraymodes;//temporary storage to avoid doubles in the list\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we only display window resolutions according to the current display settings:\r\n\tHDC hdc;\r\n\tPAINTSTRUCT ps ;\r\n\thdc = BeginPaint (hwndDlg, &ps) ;\r\n\tint currentDesktopBpp = GetDeviceCaps (hdc, BITSPIXEL) ;\r\n\tint currentDesktopRRate = GetDeviceCaps (hdc, VREFRESH) ;\r\n\tEndPaint(hwndDlg,&ps);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we fill the bpp and the refresh rate combo boxes : \r\n\r\n\tfor (i=0;iDisplayModes.Size();i++)\r\n\t{\r\n\t\tXArray::Iterator it = bpps.Find(MainDesc->DisplayModes[i].Bpp);\r\n\t\tif( it == bpps.End() )\r\n\t\t{\r\n\t\t\tbpps.PushBack(MainDesc->DisplayModes[i].Bpp);\r\n\t\t\tsprintf(ChaineW,\"%d\",MainDesc->DisplayModes[i].Bpp);\r\n\t\t\tindex = SendDlgItemMessage(hwndDlg,IDCB_BPP,CB_ADDSTRING,0,(LPARAM)ChaineW);\r\n\t\t\tSendDlgItemMessage(hwndDlg,IDCB_BPP,CB_SETITEMDATA,index,i);\r\n\r\n\t\t\tif (ewinfo->g_Bpp== MainDesc->DisplayModes[i].Bpp)\r\n\t\t\t{\r\n\t\t\t\tSendDlgItemMessage(hwndDlg,IDCB_BPP,CB_SETCURSEL,index,0);\r\n\t\t\t}\r\n\t\t}\r\n\t\tit = rrates.Find(MainDesc->DisplayModes[i].RefreshRate);\r\n\t\tif( it == rrates.End() )\r\n\t\t{\r\n\t\t\trrates.PushBack(MainDesc->DisplayModes[i].RefreshRate);\r\n\t\t\tsprintf(ChaineW,\"%d\",MainDesc->DisplayModes[i].RefreshRate);\r\n\t\t\tindex = SendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_ADDSTRING,0,(LPARAM)ChaineW);\r\n\t\t\tSendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_SETITEMDATA,index,i);\r\n\t\t\tif (ewinfo->g_RefreshRate == MainDesc->DisplayModes[i].RefreshRate)\r\n\t\t\t{\r\n\t\t\t\tSendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_SETCURSEL,index,0);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tXString mode;mode<DisplayModes[i].Width<DisplayModes[i].Height;\r\n\t\tit = modes.Find(mode.ToInt());\r\n\t\tif( it == modes.End() )\r\n\t\t{\r\n\t\t\tmodes.PushBack(mode.ToInt());\r\n\t\t\tsprintf(ChaineW,\"%d x %d\",MainDesc->DisplayModes[i].Width,MainDesc->DisplayModes[i].Height);\r\n\t\t\t\r\n\t\t\tindex=SendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_ADDSTRING,0,(LPARAM)ChaineW);\r\n\t\t\tSendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_SETITEMDATA,index,i);\r\n\r\n\t\t\tif (ewinfo->g_Height == MainDesc->DisplayModes[i].Height && ewinfo->g_Width == MainDesc->DisplayModes[i].Width )\r\n\t\t\t{\r\n\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_SETCURSEL,index,0);\r\n\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_SETTOPINDEX,index,0);\r\n\t\t\t}\r\n\r\n int iRRate = MainDesc->DisplayModes[i].RefreshRate;\r\n\t\t\tint iBpp = MainDesc->DisplayModes[i].Bpp;\r\n\t\t\tint h= iRRate;\r\n\t\t\tif (MainDesc->DisplayModes[i].Bpp == currentDesktopBpp && MainDesc->DisplayModes[i].RefreshRate == currentDesktopRRate )\r\n\t\t\t{\r\n\t\t\t\tindex=SendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_ADDSTRING,0,(LPARAM)ChaineW);\r\n\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_SETITEMDATA,index,i);\r\n\r\n\t\t\t\tif (ewinfo->g_HeightW == MainDesc->DisplayModes[i].Height && ewinfo->g_WidthW == MainDesc->DisplayModes[i].Width )\r\n\t\t\t\t{\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_SETCURSEL,index,0);\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_SETTOPINDEX,index,0);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nINT_PTR CALLBACK CCustomPlayerApp::ConfigureDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )\r\n{\r\n\r\n\t\r\n\tWORD wNotifyCode = HIWORD(wParam); \r\n\tint wID = LOWORD(wParam); \r\n\t\r\n\r\n\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\r\n\tswitch (uMsg)\r\n\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t{\r\n\t\t\t//bpp,rrate,res,resW,driver:\r\n\t\t\t_UpdateLists(hwndDlg,ewinfo->g_FullScreenDriver);\r\n\t\t\t\r\n\t\t\t//FSSA :\r\n\t\t\tswitch(ewinfo->FSSA)\r\n\t\t\t{\r\n\t\t\t\tcase 0:\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_FSSA_0,BM_SETCHECK,1,0);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 1:\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_FSSA_1,BM_SETCHECK,1,0);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 2:\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_FSSA_2,BM_SETCHECK,1,0);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_FSSA_0,BM_SETCHECK,1,0);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\treturn FALSE;\r\n\t\t\r\n\t\tcase WM_COMMAND:\r\n\t\t\tint prevWidth=0,prevHeight=0,prevBpp=0;\r\n\r\n\t\t\tif (wNotifyCode==LBN_SELCHANGE)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (wID==IDC_LISTDRIVER)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tint index=SendDlgItemMessage(hwndDlg,IDC_LISTDRIVER,LB_GETCURSEL,0,0);\r\n\t\t\t\t\t_UpdateLists(hwndDlg,index);\r\n\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (wID==IDC_LISTMODE)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentRes = SendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_GETCURSEL,0,0);\r\n\t\t\t\t\t//VxDriverDesc *MainDesc=ep->TheRenderManager->GetRenderDriverDescription(ewinfo->g_FullScreenDriver);\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\r\n\t\t\tif(wNotifyCode==BN_CLICKED)\r\n\t\t\t{\r\n\t\t\t\tif (wID==IDC_FSSA_0)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentFSSA = 0; \r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (wID==IDC_FSSA_1)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentFSSA = 1; \r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t\tif (wID==IDC_FSSA_2)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentFSSA = 2; \r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (wNotifyCode==CBN_SELCHANGE )\r\n\t\t\t{\r\n\t\t\t\tif (wID==IDC_WINSIZE)\r\n\t\t\t\t{\r\n\t\t\t\t\t_currentWMode =SendDlgItemMessage(hwndDlg,IDC_WINSIZE,CB_GETCURSEL,0,0);\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t\tif (wID==IDCB_BPP)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentBpp =SendDlgItemMessage(hwndDlg,IDCB_BPP,CB_GETCURSEL,0,0);\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t\tif (wID==IDCB_RRATE)\r\n\t\t\t\t{\r\n\t\t\t\t\tcurrentRRate =SendDlgItemMessage(hwndDlg,IDCB_RRATE,CB_GETCURSEL,0,0);\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif (LOWORD(wParam) == IDC_CANCEL2){\r\n\t\t\t\t\r\n\t\t\t\tEndDialog(hwndDlg, LOWORD(wParam));\r\n\t\t\t\tSendNotifyMessageW(m_MainWindow,WM_CLOSE,0,0);\r\n\r\n\t\t\t\treturn TRUE;\r\n\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif (LOWORD(wParam) == IDOK) \r\n\t\t\t{\r\n\r\n\t\t\t\t\t//fssa : \r\n\t\t\t\t\tif(currentFSSA>=0)\r\n\t\t\t\t\t\tewinfo->FSSA = currentFSSA;\r\n\r\n\t\t\t\t\t//fullscreen : \r\n\t\t\t\t\tewinfo->g_GoFullScreen = IsDlgButtonChecked(hwndDlg, IDC_CHB_FULLSCREEN ) == BST_CHECKED;\r\n\t\t\t\t\t\r\n\t\t\t\t\t//bpp\r\n\t\t\t\t\tif(currentBpp>=0){\r\n\t\t\t\t\t\tTCHAR szText[_MAX_PATH + 1];\r\n\t\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDCB_BPP, CB_GETLBTEXT, (WPARAM)currentBpp, (LPARAM)szText);\r\n\t\t\t\t\t\tXString o(szText);\r\n\t\t\t\t\t\tewinfo->g_Bpp = o.ToInt();\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t//refresh rate\r\n\t\t\t\t\tif (currentRRate>=0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTCHAR szText[_MAX_PATH + 1];\r\n\t\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDCB_RRATE, CB_GETLBTEXT, (WPARAM)currentRRate, (LPARAM)szText);\r\n\t\t\t\t\t\tXString o(szText);\r\n\t\t\t\t\t\tewinfo->g_RefreshRate = o.ToInt();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t//full screen settings\r\n\t\t\t\t\tif (currentRes>=0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint index=SendDlgItemMessage(hwndDlg,IDC_LISTMODE,LB_GETCURSEL,0,0);\r\n\t\t\t\t\t\tTCHAR szText[MAX_PATH];\r\n\t\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_LISTMODE, LB_GETTEXT, index, ((LPARAM)szText));\t\t\t\t\t\t\r\n\t\t\t\t\t\tXStringTokenizer\ttokizer(szText, \" x \");\r\n\t\t\t\t\t\tconst char*tok = NULL;\r\n\t\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\t\tXString width(tok);\r\n\t\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\t\tXString height(tok);\r\n\t\t\t\t\t\tewinfo->g_Width = width.ToInt();\r\n\t\t\t\t\t\tewinfo->g_Height = height.ToInt();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (_currentWMode>=0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tTCHAR szText[_MAX_PATH + 1];\r\n\t\t\t\t\t\tSendDlgItemMessage(hwndDlg,IDC_WINSIZE, CB_GETLBTEXT, (WPARAM)_currentWMode, (LPARAM)szText);\r\n\t\t\t\t\t\tMessageBox(NULL,szText,\"\",1);\r\n\t\t\t\t\t\tXStringTokenizer\ttokizer(szText, \"x\");\r\n\t\t\t\t\t\tconst char*tok = NULL;\r\n\t\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\t\tXString width(tok);\r\n\t\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\t\tXString height(tok);\r\n\t\t\t\t\t\tewinfo->g_WidthW = width.ToInt();\r\n\t\t\t\t\t\tewinfo->g_HeightW = height.ToInt();\r\n\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tEndDialog(hwndDlg, LOWORD(wParam));\r\n\t\t\t\t\tPSaveEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE,*GetPlayer().GetEngineWindowInfo());\r\n\t\t\t\t\tSendNotifyMessageW(m_MainWindow,WM_CLOSE,0,0);\r\n\t\t\t\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t}\r\n return FALSE;\r\n}\r\n\r\n#ifndef _XNET_CONSTANTS_H_\r\n#define _XNET_CONSTANTS_H_\r\n\r\n//#include \"xNetTypes.h\"\r\n\r\nstatic float DO_TIME_THRESHOLD = 150.0f;\r\n\r\nstatic char* sLogItems[]=\r\n{\r\n\t\t\"CLIENT\",\r\n\t\t\"SESSION\",\r\n\t\t\"3DOBJECT\",\r\n\t\t\"2DOBJECT\",\r\n\t\t\"Distributed Base Object\",\r\n\t\t\"Distributed Classes\",\r\n\t\t\"MESSAGES\",\r\n\t\t\"ARRAY_MESSAGES\",\r\n\t\t\"CONNECTION\",\r\n\t\t\"NET_INTERFACE\",\r\n\t\t\"GHOSTING\",\r\n\t\t\"STATISTICS\",\r\n\t\t\"BUILDINGBLOCKS\",\r\n\t\t\"VSL\",\r\n\t\t\"CPP\",\r\n\t\t\"ASSERTS\",\r\n\t\t\"PREDICTION\",\r\n\t\t\"SERVER_MESSAGES\"\r\n};\r\n\r\nstatic char* sErrorStrings[]=\r\n{\r\n\t\"OK\",\r\n\t\"\\t Intern :\",\r\n\t\"\\t No connection :\",\r\n\t\"\\t Not joined to a session:\",\r\n\t\"\\t Session needs right password:\",\r\n\t\"\\t Session is locked:\",\r\n\t\"\\t Session already exists:\",\r\n\t\"\\t Session is full:\",\r\n\t\"\\t You must be session master:\",\r\n\t\"\\t Invalid parameter :\",\r\n\t\"\\t There is not such user :\",\r\n\t\"\\t Distributed class already exists :\",\r\n\t\"\\t Couldn't connect to any server :\",\r\n\t\"\\t You already joined to a session :\",\r\n\t\"\\t No such session :\"\r\n};\r\n\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\nstatic pFactory* pFact = NULL;\r\n\r\nint pFactory::cloneLimitPlanes(pJoint *src,pJoint *dst,CK3dEntity *srcReference,CK3dEntity *dstReference)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t\tassert(dst);\r\n\t\tassert(dstReference);\r\n\t\tassert(srcReference);\r\n\t#endif // _DEBUG\r\n\r\n\tNxJoint *j = src->getJoint();\r\n\tif (!j)\r\n\t\treturn 0;\r\n\t\r\n\t\r\n\tint numLimitPlanes = src->getNbLimitPlanes();\r\n\tif (!numLimitPlanes)\r\n\t\treturn -1;\r\n\r\n\tNxVec3 *planeNormal = new NxVec3[numLimitPlanes];\r\n\tNxReal *planeD = new NxReal[numLimitPlanes];\r\n\tNxReal *restitution = new NxReal[numLimitPlanes];\r\n\r\n\tNxVec3 planeLimitPt;\r\n\tbool onActor2 = j->getLimitPoint( planeLimitPt );\r\n\tNxVec3 *worldLimitPt = new NxVec3[numLimitPlanes];\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy to buffer\r\n\t//\r\n\tj->resetLimitPlaneIterator();\r\n\r\n\tfor(int iter=0 ; iter < numLimitPlanes ; iter++ )\r\n\t{\r\n\t\tj->getNextLimitPlane( planeNormal[iter], planeD[iter], &restitution[iter] );\r\n\t}\r\n\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// create limitPoints\r\n\t//\r\n\r\n\tdst->setLimitPoint(getFrom(planeLimitPt),onActor2);\r\n\r\n\r\n\tfor(int iter=0 ; iter < numLimitPlanes ; iter++ )\r\n\t{\r\n\t\r\n\t\tif ( ( fabs(planeNormal[iter].z) > fabs(planeNormal[iter].x) ) &&\r\n\t\t\t( fabs(planeNormal[iter].z) > fabs(planeNormal[iter].y) ) )\r\n\t\t{\r\n\t\t\tworldLimitPt[iter].x = planeLimitPt.x;\r\n\t\t\tworldLimitPt[iter].y = planeLimitPt.y;\r\n\t\t\tworldLimitPt[iter].z = -planeD[iter] / planeNormal[iter].z;\r\n\t\t}\r\n\t\t// k, that didn't work - try x,z = 0\r\n\t\telse if ( ( fabs(planeNormal[iter].y) > fabs(planeNormal[iter].x) ) &&\r\n\t\t\t( fabs(planeNormal[iter].y) > fabs(planeNormal[iter].z) ) )\r\n\t\t{\r\n\t\t\tworldLimitPt[iter].x = planeLimitPt.x;\r\n\t\t\tworldLimitPt[iter].z = planeLimitPt.z;\r\n\t\t\tworldLimitPt[iter].y = -planeD[iter] / planeNormal[iter].y;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tworldLimitPt[iter].y = planeLimitPt.y;\r\n\t\t\tworldLimitPt[iter].z = planeLimitPt.z;\r\n\t\t\tworldLimitPt[iter].x = -planeD[iter] / planeNormal[iter].x;\r\n\t\t}\r\n\r\n\t\tdst->addLimitPlane(getFrom(planeNormal[iter]),getFrom(worldLimitPt[iter]),restitution[iter]);\r\n\r\n\t}\r\n\r\n\tdelete []worldLimitPt;\r\n\tdelete []planeNormal;\r\n\tdelete []restitution;\r\n\tdelete []planeD;\r\n\r\n\tworldLimitPt = NULL;\r\n\tplaneD = NULL;\r\n\trestitution = NULL;\r\n\tplaneD = NULL;\r\n\r\n\r\n\treturn numLimitPlanes;\r\n\t\r\n}\r\n\r\npJoint *pFactory::cloneJoint(pJoint *src,CK3dEntity *srcReference,CK3dEntity *dstReference,int copyFlags)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t\tassert(dstReference);\r\n\t#endif // _DEBUG\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Prepare pointers\r\n\t//\r\n\tNxActor *actorA = NULL;\r\n\tpRigidBody *actorABody = GetPMan()->getBody(dstReference);\r\n\tif (actorABody){\r\n\t\tactorA = actorABody->getActor();\r\n\t}\r\n\telse{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"You need at least one rigid body\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\r\n\t//actorB can be NULL and can not be the same as actorA : \r\n\tNxActor *actorB = NULL;\r\n\tpRigidBody *actorBBody = NULL;\r\n\tCK3dEntity *referenceB = NULL;\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// determine the first, this will be the clone !\r\n\t//\r\n\tif ( src->GetVTEntA() && src->GetVTEntA() !=srcReference )\r\n\t{\r\n\t\tactorBBody = GetPMan()->getBody(src->GetVTEntA());\r\n\t\tif (actorBBody)\r\n\t\t{\r\n\t\t\tactorB = actorBBody->getActor();\r\n\t\t\treferenceB = actorBBody->GetVT3DObject();\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// determine the second\r\n\t//\r\n\tif ( src->GetVTEntB() && src->GetVTEntB() !=srcReference )\r\n\t{\r\n\t\tactorBBody = GetPMan()->getBody(src->GetVTEntB());\r\n\t\tif (actorBBody)\r\n\t\t{\r\n\t\t\tactorB = actorBBody->getActor();\r\n\t\t\treferenceB = actorBBody->GetVT3DObject();\r\n\t\t}\r\n\t}\r\n\r\n\tif ( (copyFlags & PB_CF_SWAP_JOINTS_REFERENCES) )\r\n\t{\r\n\t\tXSwap(actorA,actorB);\r\n\t\tXSwap(actorABody,actorBBody);\r\n\r\n\t}\r\n\r\n\tCK3dEntity *testA = actorABody->GetVT3DObject();\r\n\tCK3dEntity *testB = NULL;\r\n\tif (actorBBody)\r\n\t\ttestB = actorBBody->GetVT3DObject();\r\n\r\n\r\n\r\n\tswitch (src->getType())\r\n\t{\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Distance Joint : \r\n\t\t//\r\n\t\tcase JT_Distance :\r\n\t\t{\r\n\r\n\t\t\tNxDistanceJoint *nxSrc = src->getJoint()->isDistanceJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxDistanceJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\t\t\t\t\r\n\t\t\t\tNxDistanceJoint *nxJoint = (NxDistanceJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointDistance *joint = new pJointDistance(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\r\n\t\t\t\treturn joint;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Fixed Joint : \r\n\t\t//\r\n\t\tcase JT_Fixed :\r\n\t\t{\r\n\r\n\t\t\tNxFixedJoint *nxSrc = src->getJoint()->isFixedJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxFixedJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxFixedJoint *nxJoint = (NxFixedJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointFixed *joint = new pJointFixed(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Ball Joint : \r\n\t\t//\r\n\t\tcase JT_Spherical:\r\n\t\t{\r\n\r\n\t\t\tNxSphericalJoint *nxSrc = src->getJoint()->isSphericalJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxSphericalJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxSphericalJoint *nxJoint = (NxSphericalJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointBall *joint = new pJointBall(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Revolute Joint : \r\n\t\t//\r\n\t\tcase JT_Revolute:\r\n\t\t{\r\n\r\n\t\t\tNxRevoluteJoint *nxSrc = src->getJoint()->isRevoluteJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxRevoluteJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxRevoluteJoint *nxJoint = (NxRevoluteJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointRevolute *joint = new pJointRevolute(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Cylindrical Joint : \r\n\t\t//\r\n\t\tcase JT_Cylindrical:\r\n\t\t{\r\n\r\n\t\t\tNxCylindricalJoint *nxSrc = src->getJoint()->isCylindricalJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxCylindricalJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxCylindricalJoint *nxJoint = (NxCylindricalJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointCylindrical*joint = new pJointCylindrical(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// Prismatic Joint : \r\n\t\t//\r\n\t\tcase JT_Prismatic:\r\n\t\t{\r\n\r\n\t\t\tNxPrismaticJoint *nxSrc = src->getJoint()->isPrismaticJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxPrismaticJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxPrismaticJoint *nxJoint = (NxPrismaticJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointPrismatic*joint = new pJointPrismatic(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// PointInPlane Joint : \r\n\t\t//\r\n\t\tcase JT_PointInPlane:\r\n\t\t{\r\n\r\n\t\t\tNxPointInPlaneJoint*nxSrc = src->getJoint()->isPointInPlaneJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxPointInPlaneJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxPointInPlaneJoint *nxJoint = (NxPointInPlaneJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointPointInPlane*joint = new pJointPointInPlane(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// PointOnLine Joint : \r\n\t\t//\r\n\t\tcase JT_PointOnLine:\r\n\t\t{\r\n\r\n\t\t\tNxPointOnLineJoint*nxSrc = src->getJoint()->isPointOnLineJoint();\r\n\t\t\tif (nxSrc)\r\n\t\t\t{\r\n\t\t\t\tNxPointOnLineJointDesc descrNew;\r\n\t\t\t\tnxSrc->saveToDesc(descrNew);\r\n\r\n\t\t\t\tdescrNew.actor[0] = actorA;\tdescrNew.actor[1] = actorB;\r\n\r\n\t\t\t\tNxPointOnLineJoint *nxJoint = (NxPointOnLineJoint*)actorA->getScene().createJoint(descrNew);\r\n\t\t\t\tif (!nxJoint)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t}\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t\t\t\t//\t\tvt object :\r\n\t\t\t\tpJointPointOnLine*joint = new pJointPointOnLine(actorABody,actorBBody);\r\n\t\t\t\tnxJoint->userData = joint;\r\n\t\t\t\tjoint->setJoint(nxJoint);\r\n\t\t\t\tjoint->setWorld(actorABody->getWorld());\r\n\t\t\t\treturn joint;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nvoid pFactory::cloneJoints(CK3dEntity *src,CK3dEntity *dst,int copyFlags)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(src);\r\n\t\tassert(dst);\r\n\t#endif // _DEBUG\r\n\r\n\r\n\tpRigidBody *srcBody = GetPMan()->getBody(src);\r\n\tpRigidBody *dstBody = GetPMan()->getBody(dst);\r\n\t\r\n\tXString errMsg;\r\n\r\n\tif ( !srcBody || !dstBody )\r\n\t{\r\n\t\terrMsg.Format(\"You need two rigid objects to clone joints from a rigid body\");\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errMsg.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tpWorld* srcBodyWorld = srcBody->getWorld();\r\n\tpWorld* dstBodyWorld = dstBody->getWorld();\r\n\r\n\tif(\t!srcBodyWorld || !dstBodyWorld )\r\n\t{\r\n\t\terrMsg.Format(\"You need two valid world objects to clone joints from a rigid body\");\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errMsg.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\tif(\tsrcBodyWorld!=dstBodyWorld )\r\n\t{\r\n\t\terrMsg.Format(\"Worlds objects must be same\");\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errMsg.Str());\r\n\t\treturn;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy process\r\n\t//\r\n\t\r\n\tpWorld *testWorld = dstBodyWorld;\r\n\r\n\r\n\tNxU32\tjointCount = testWorld->getScene()->getNbJoints();\r\n\tif (jointCount)\r\n\t{\r\n\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\ttestWorld->getScene()->resetJointIterator();\r\n\r\n\t\tNxJoint *last = NULL;\r\n\t\tpJoint *lastJ = NULL;\r\n\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t{\r\n\t\t\tNxJoint\t*j = testWorld->getScene()->getNextJoint();\r\n\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\t\t\tif ( mJoint )\r\n\t\t\t{\r\n\t\t\t\tif (mJoint==lastJ)// avoid double clone\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (mJoint->GetVTEntA() == srcBody->GetVT3DObject() || mJoint->GetVTEntB() == srcBody->GetVT3DObject() )\r\n\t\t\t\t{\r\n\t\t\t\t\tpJoint *clone = pFactory::cloneJoint(mJoint,src,dst,copyFlags);\r\n\t\t\t\t\tif (clone )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ((copyFlags & PB_CF_LIMIT_PLANES))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tint limitPlanes = pFactory::cloneLimitPlanes(mJoint,clone,src,dst);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tlastJ = mJoint;\r\n\t\t}\r\n\t}\r\n}\r\n\r\npJointPointOnLine*pFactory::createPointOnLineJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_PointOnLine) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\tNxPointOnLineJointDesc desc;\r\n\tdesc.actor[0] = a0;\r\n\tdesc.actor[1] = a1;\r\n\tdesc.setGlobalAxis(getFrom(axis));\r\n\tdesc.setGlobalAnchor(getFrom(anchor));\r\n\r\n\tif (!desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tNxPointOnLineJoint*\tnxJoint = (NxPointOnLineJoint*)world->getScene()->createJoint(desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointPointOnLine*joint = new pJointPointOnLine(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tjoint->setWorld(world);\r\n\treturn joint;\r\n}\r\n\r\npJointPointInPlane*pFactory::createPointInPlaneJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_PointInPlane) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\tNxPointInPlaneJointDesc desc;\r\n\tdesc.actor[0] = a0;\r\n\tdesc.actor[1] = a1;\r\n\tdesc.setGlobalAxis(getFrom(axis));\r\n\tdesc.setGlobalAnchor(getFrom(anchor));\r\n\r\n\tif (!desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tNxPointInPlaneJoint*\tnxJoint = (NxPointInPlaneJoint*)world->getScene()->createJoint(desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointPointInPlane*joint = new pJointPointInPlane(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tjoint->setWorld(world);\r\n\treturn joint;\r\n}\r\n\r\npJointCylindrical*pFactory::createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_Cylindrical) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\tNxCylindricalJointDesc desc;\r\n\tdesc.actor[0] = a0;\r\n\tdesc.actor[1] = a1;\r\n\tdesc.setGlobalAxis(getFrom(axis));\r\n\tdesc.setGlobalAnchor(getFrom(anchor));\r\n\r\n\tif (!desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\t\t\r\n\tNxCylindricalJoint*\tnxJoint = (NxCylindricalJoint*)world->getScene()->createJoint(desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointCylindrical*joint = new pJointCylindrical(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tjoint->setWorld(world);\r\n\treturn joint;\r\n\r\n}\r\npJointPrismatic *pFactory::createPrismaticJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n{\r\n\r\n\t\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_Prismatic) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\tNxPrismaticJointDesc desc;\r\n\tdesc.actor[0] = a0;\r\n\tdesc.actor[1] = a1;\r\n\tdesc.setGlobalAxis(getFrom(axis));\r\n\tdesc.setGlobalAnchor(getFrom(anchor));\r\n\t\r\n\tif (!desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tNxPrismaticJoint*\tnxJoint = (NxPrismaticJoint*)world->getScene()->createJoint(desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointPrismatic*joint = new pJointPrismatic(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tjoint->setWorld(world);\r\n\treturn joint;\r\n\t\r\n}\r\npJointRevolute*pFactory::createRevoluteJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_Revolute) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\r\n\tif (!ba && !bb)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"No body specified\");\r\n\t\treturn NULL;\r\n\t}\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world && bb)\r\n\t{\r\n\t\tworld = bb->getWorld();\r\n\t}\r\n\r\n\r\n\tNxRevoluteJointDesc descr;\r\n\t\r\n\t/*descr.projectionDistance = (NxReal)0.05;\r\n\tdescr.projectionAngle= (NxReal)0.05;\r\n\tdescr.projectionMode = NX_JPM_POINT_MINDIST;*/\r\n\r\n\t\r\n\r\n\tif (ba)\r\n\t{\r\n\t\tdescr.actor[0]=ba->getActor();\r\n\t}\r\n\t\r\n\tif (bb)\r\n\t{\r\n\t\tdescr.actor[1]=bb->getActor();\r\n\t}\r\n\t\r\n\tNxRevoluteJoint *nxJoint=(NxRevoluteJoint*)world->getScene()->createJoint(descr);\r\n\t\r\n\tif (!descr.isValid())\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"Revolute joint invalid!\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tnxJoint->setGlobalAnchor(getFrom(anchor));\r\n\tnxJoint->setGlobalAxis(getFrom(axis));\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointRevolute*joint = new pJointRevolute(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setWorld(world);\r\n\tjoint->setJoint(nxJoint);\r\n\r\n\r\n\r\n\treturn joint;\r\n\r\n\r\n\r\n}\r\n\r\n\r\npJointPulley* pFactory::createPulleyJoint( CK3dEntity*a,CK3dEntity*b,VxVector pulley0,VxVector pulley1, VxVector anchor0, VxVector anchor1 )\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_Pulley) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tVxVector globalAxis(0,1,0);\r\n\tfloat distance = 10.0f;\r\n\tfloat ratio = 1.0f;\r\n\tfloat stiffness = 1.0f;\r\n\tint flags = 0 ; \r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\r\n\tif (!ba && !bb)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"You need two bodies for a pulley joint!\");\r\n\t\treturn NULL;\r\n\t}\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\tnx object : \r\n\tNxPulleyJointDesc descr;\r\n\tdescr.setToDefault();\r\n\r\n\tdescr.actor[0]=ba->getActor();\r\n\tdescr.actor[1]=bb->getActor();\r\n\tdescr.localAnchor[0] = pMath::getFrom(anchor0);\r\n\tdescr.localAnchor[1] = pMath::getFrom(anchor1);\r\n\tdescr.setGlobalAxis(pMath::getFrom(globalAxis));\r\n\r\n\r\n\r\n\tdescr.pulley[0] = pMath::getFrom(pulley0); \t// suspension points of two bodies in world space.\r\n\tdescr.pulley[1] = pMath::getFrom(pulley1); \t// suspension points of two bodies in world space.\r\n\tdescr.distance = distance;\t\t// the rest length of the rope connecting the two objects. The distance is computed as ||(pulley0 - anchor0)|| + ||(pulley1 - anchor1)|| * ratio.\r\n\tdescr.stiffness = stiffness;\t\t// how stiff the constraint is, between 0 and 1 (stiffest)\r\n\tdescr.ratio = ratio;\t\t\t// transmission ratio\r\n\tdescr.flags = flags;\t// This is a combination of the bits defined by ::NxPulleyJointFlag. \r\n\r\n\tif (!descr.isValid())\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"Pully joint invalid!\");\r\n\t\treturn NULL;\r\n\t}\r\n\tNxPulleyJoint *nxJoint = (NxPulleyJoint*)world->getScene()->createJoint(descr);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointPulley*joint = new pJointPulley(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setWorld(world);\r\n\tjoint->setJoint(nxJoint);\r\n\treturn joint;\r\n\r\n\r\n\t//descr.motor = gMotorDesc;\r\n\t//\tpulleyDesc.projectionMode = NX_JPM_NONE;\r\n\t//\tpulleyDesc.projectionMode = NX_JPM_POINT_MINDIST;\r\n\t//\tpulleyDesc.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\treturn NULL;\r\n}\r\n\r\npJointFixed*pFactory::createFixedJoint(CK3dEntity *a, CK3dEntity *b)\r\n{\r\n\r\n\t\t\r\n\tif (jointCheckPreRequisites(a,b,JT_Fixed) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\r\n\tNxFixedJointDesc descr;\r\n\tdescr.actor[0] = a0;\r\n\tdescr.actor[1] = a1;\r\n\r\n\tif (!descr.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tNxJoint *nxJoint = (NxDistanceJoint*)world->getScene()->createJoint(descr);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointFixed*joint = new pJointFixed(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setWorld(world);\r\n\tjoint->setJoint(nxJoint);\r\n\treturn joint;\r\n\r\n}\r\n\r\npJointD6*pFactory::createD6Joint(CK3dEntity *a, CK3dEntity *b, VxVector globalAnchor,VxVector globalAxis,int collision)\r\n{\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_D6) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\r\n\tNxD6JointDesc d6Desc;\r\n\td6Desc.actor[0] = a0;\r\n\td6Desc.actor[1] = a1;\r\n\td6Desc.setGlobalAnchor(pMath::getFrom(globalAnchor));\r\n\td6Desc.setGlobalAxis(pMath::getFrom(globalAxis));\r\n\tif (collision)\r\n\t{\r\n\t\t//d6Desc.flags \r\n\t\td6Desc.jointFlags|=NX_JF_COLLISION_ENABLED;\r\n\t}\r\n\t\r\n\t\r\n\t\t\r\n\tif (!d6Desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tNxJoint *nxJoint = (NxDistanceJoint*)world->getScene()->createJoint(d6Desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointD6 *joint = new pJointD6(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\r\n\tjoint->setWorld(world);\r\n\tjoint->setJoint(nxJoint);\r\n\treturn joint;\r\n\r\n}\r\n\r\npJointBall *pFactory::createBallJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector swingAxis)\r\n{\r\n\r\n\tpJointBall *result;\r\n\r\n\tif (jointCheckPreRequisites(a,b,JT_Spherical) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\tif (!world)\r\n\t{\r\n\t\tworld = GetPMan()->getWorldByBody(b);\r\n\t}\r\n\r\n\tNxActor *a0 = NULL;\r\n\tif (ba)\r\n\t{\r\n\t\ta0 = ba->getActor();\r\n\t}\r\n\tNxActor *a1 = NULL;\r\n\tif (bb)\r\n\t{\r\n\t\ta1 = bb->getActor();\r\n\t}\r\n\r\n\r\n\tNxSphericalJointDesc desc;\r\n\tdesc.actor[0] = a0;\r\n\tdesc.actor[1] = a1;\r\n\tdesc.swingAxis = pMath::getFrom(swingAxis);\r\n\t/*desc.projectionDistance = (NxReal)0.15;\r\n\tdesc.projectionMode = NX_JPM_POINT_MINDIST;*/\r\n\r\n\t\r\n\tif (!desc.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Description failed\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tNxSphericalJoint*\tnxJoint = (NxSphericalJoint*)world->getScene()->createJoint(desc);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointBall*joint = new pJointBall(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tnxJoint->setGlobalAnchor(pMath::getFrom(anchor));\r\n\tjoint->setWorld(world);\r\n\t\r\n\treturn joint;\r\n}\r\n\r\nint pFactory::jointCheckPreRequisites(CK3dEntity*_a,CK3dEntity*_b,int type)\r\n{\r\n\r\n\t\tpRigidBody *a = GetPMan()->getBody(_a);\r\n\t\tpRigidBody *b = GetPMan()->getBody(_b);\r\n\r\n\t\t//bodies have already a joint together ? \r\n\t\tif ( !a && !b)\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\r\n\t\tif (a && !a->isValid() )\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\r\n\t\tif (a && !GetPMan()->getWorldByBody(_a))\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\r\n\t\tif (b && !GetPMan()->getWorldByBody(_b))\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\r\n\t\tif (b && !b->isValid())\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\r\n\r\n\t\tif ( a && b )\r\n\t\t{\r\n\t\t\tpWorld*worldA = GetPMan()->getWorldByBody(_a);\r\n\t\t\tpWorld*worldB = GetPMan()->getWorldByBody(_b);\r\n\t\t\tif (!worldA || !worldB || (worldA!=worldB) || !worldA->isValid() )\r\n\t\t\t{\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\treturn 1;\r\n}\r\n\r\npJointDistance*pFactory::createDistanceJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor0,VxVector anchor1,float minDistance,float maxDistance,pSpring sSettings)\r\n{\r\n\tif (jointCheckPreRequisites(a,b,JT_Distance) == -1 )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tpRigidBody *ba = GetPMan()->getBody(a);\r\n\tpRigidBody *bb = GetPMan()->getBody(b);\r\n\tpWorld*world = GetPMan()->getWorldByBody(a);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\tnx object : \r\n\tNxDistanceJointDesc descr;\r\n\tdescr.actor[0]=ba->getActor();\r\n\tdescr.actor[1]= b ? bb->getActor() : NULL ;\r\n\r\n\r\n\r\n\r\n\tdescr.localAnchor[0] = pMath::getFrom(anchor0);\r\n\tdescr.localAnchor[1] = pMath::getFrom(anchor1);\r\n\r\n\tdescr.minDistance = minDistance;\r\n\tdescr.maxDistance = maxDistance;\r\n\t\r\n\tif (minDistance!=0.0f)\r\n\t\t descr.flags|=NX_DJF_MIN_DISTANCE_ENABLED;\r\n\tif (maxDistance!=0.0f)\r\n\t\t descr.flags|=NX_DJF_MAX_DISTANCE_ENABLED;\r\n\t\r\n\tif(sSettings.damper!=0.0f || sSettings.damper!=0.0f )\r\n\t{\t\r\n\t\tdescr.flags|=NX_DJF_SPRING_ENABLED;\r\n\t\tNxSpringDesc sDescr;\r\n\t\tsDescr.damper = sSettings.damper;\r\n\t\tsDescr.spring = sSettings.spring;\r\n\t\tsDescr.targetValue = sSettings.targetValue;\r\n\t\tdescr.spring = sDescr;\r\n\r\n\t}\r\n\t\r\n\tNxDistanceJoint *nxJoint = (NxDistanceJoint*)world->getScene()->createJoint(descr);\r\n\tif (!nxJoint)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"failed by PhysX-SDK\");\r\n\t\tint v = descr.isValid();\r\n\t\treturn NULL;\r\n\t}\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////,\r\n\t//\t\tvt object :\r\n\tpJointDistance *joint = new pJointDistance(ba,bb);\r\n\tnxJoint->userData = joint;\r\n\tjoint->setJoint(nxJoint);\r\n\tjoint->setWorld(world);\r\n\r\n\treturn joint;\r\n\r\n}\r\npJoint*pFactory::createJoint(CK3dEntity*_a,CK3dEntity*_b,int type)\t\r\n{\r\n\treturn NULL ;\r\n}\r\n\r\n\r\npJointSettings*pFactory::CreateJointSettings(const XString nodeName/* = */,const TiXmlDocument * doc /* = NULL */)\r\n{\r\n\r\n\t/*\r\n\tpJointSettings *result = new pJointSettings();\r\n\tif (nodeName.Length() && doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = GetFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"JointSettings\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName.CStr() ) )\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tfloat vF=0.0f;\r\n\t\t\t\t\t\t\tint res;\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"LowStop\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->LowStop(vF);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"HiStop\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->HighStop(vF);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"LowStop2\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->LowStop2(vF);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"HiStop2\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->HighStop2(vF);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\npJointSettings*pFactory::CreateJointSettings(const char* nodeName,const char *filename)\r\n{\r\n\r\n\t/*\r\n\tXString fname(filename);\r\n\tXString nName(nodeName);\r\n\tif ( nName.Length() && fname.Length() )\r\n\t{\r\n\t\tTiXmlDocument * document = getDocument(fname);\r\n\t\tif (document)\r\n\t\t{\r\n\t\t\tpJointSettings *result = CreateJointSettings(nodeName,document);\r\n\t\t\tif ( result)\r\n\t\t\t{\r\n\t\t\t\tdelete document;\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn NULL;\r\n\r\n}\r\n\r\npJointLimit pFactory::createLimitFromParameter(CKParameter *par)\r\n{\r\n\r\n\r\n\tpJointLimit result;\r\n\t\r\n\tCKContext *ctx = GetPMan()->GetContext();\r\n\r\n\r\n\tif (par)\r\n\t{\r\n\t\t\tCKParameter* pout = NULL;\r\n\t\t\tCK_ID* ids = (CK_ID*)par->GetReadDataPtr();\r\n\t\t\t\r\n\t\t\tfloat value,restitution,hardness;\r\n\t\t\t\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[0]);\r\n\t\t\tpout->GetValue(&value);\r\n\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[1]);\r\n\t\t\tpout->GetValue(&restitution);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[2]);\r\n\t\t\tpout->GetValue(&hardness);\r\n\r\n\t\t\t\r\n\t\t\tresult.value = value;\r\n\t\t\tresult.restitution = restitution;\r\n\t\t\tresult.hardness =hardness;\r\n\t\t\treturn result;\r\n\t}\r\n\treturn result;\r\n\r\n}\r\n\r\npSpring pFactory::createSpringFromParameter(CKParameter *par)\r\n{\r\n\t\r\n\tpSpring result;\r\n\r\n\tCKContext *ctx = GetPMan()->GetContext();\r\n\r\n\r\n\r\n\tif (par)\r\n\t{\r\n\t\t\tCKParameter* pout = NULL;\r\n\t\t\tCK_ID* ids = (CK_ID*)par->GetReadDataPtr();\r\n\t\t\t\r\n\t\t\tfloat damping,spring,targetValue;\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[0]);\r\n\t\t\tpout->GetValue(&damping);\r\n\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[1]);\r\n\t\t\tpout->GetValue(&spring);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[2]);\r\n\t\t\tpout->GetValue(&targetValue);\r\n\r\n\t\t\tresult.spring = spring;\r\n\t\t\tresult.damper = damping;\r\n\t\t\tresult.targetValue = targetValue;\r\n\t\t\treturn result;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\npMotor pFactory::createMotorFromParameter(CKParameter *par)\r\n{\r\n\tpMotor result;\r\n\tCKContext *ctx = GetPMan()->GetContext();\r\n\r\n\r\n\r\n\tif (par)\r\n\t{\r\n\t\tCKParameter* pout = NULL;\r\n\t\tCK_ID* ids = (CK_ID*)par->GetReadDataPtr();\r\n\r\n\t\tfloat targetVel,maxF;\r\n\t\tint freeSpin;\r\n\t\tpout = (CKParameterOut*)ctx->GetObject(ids[0]);\r\n\t\tpout->GetValue(&targetVel);\r\n\r\n\t\tpout = (CKParameterOut*)ctx->GetObject(ids[1]);\r\n\t\tpout->GetValue(&maxF);\r\n\t\tpout = (CKParameterOut*)ctx->GetObject(ids[2]);\r\n\t\tpout->GetValue(&freeSpin);\r\n\t\tresult.targetVelocity = targetVel;\r\n\t\tresult.maximumForce = maxF;\r\n\t\tresult.freeSpin = freeSpin;\r\n\t\treturn result;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\npJoint*pFactory::GetJoint(CK3dEntity*_a,CK3dEntity*_b)\r\n{\r\n\t\r\n\t/*\r\n\tif (!_a ||!_b)\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpRigidBody *ba = getBody(_a);\r\n\tpRigidBody *bb = getBody(_b);\r\n\r\n\tif ( !ba || !bb || ba == bb )\r\n\t\treturn NULL;\r\n\r\n\t//we check whether both associated bodies are in the same world : \r\n\tif ( ba->World() != bb->World() )\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tOdeBodyType oba = ba->GetOdeBody();\r\n\tOdeBodyType obb = bb->GetOdeBody();\r\n\t\r\n\tif ( !oba || !obb )\r\n\t\treturn NULL;\r\n\r\n\r\n\tfor (int i = 0 ; i < dBodyGetNumJoints(oba) ; i++)\r\n\t{\r\n\t\tdJointID jID = dBodyGetJoint(oba,i);\r\n\t\tpJoint *joint = static_cast(dJointGetData(jID));\r\n\t\tif (joint && joint->GetOdeBodyB() == obb)\r\n\t\t{\r\n\t\t\treturn joint;\r\n\t\t}\r\n\t}\r\n\r\n\tfor (int i = 0 ; i < dBodyGetNumJoints(obb) ; i++)\r\n\t{\r\n\t\tdJointID jID = dBodyGetJoint(obb,i);\r\n\t\tpJoint *joint = static_cast(dJointGetData(jID));\r\n\t\tif (joint && joint->GetOdeBodyB() == oba)\r\n\t\t{\r\n\t\t\treturn joint;\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\n// --------------------------------------------------------------------------\r\n//\t\t\t\t\twww.UnitedBusinessTechnologies.com\r\n//\t\t\t Copyright (c) 1998 - 2002 All Rights Reserved.\r\n//\r\n// Source in this file is released to the public under the following license:\r\n// --------------------------------------------------------------------------\r\n// This toolkit may be used free of charge for any purpose including corporate\r\n// and academic use. For profit, and Non-Profit uses are permitted.\r\n//\r\n// This source code and any work derived from this source code must retain \r\n// this copyright at the top of each source file.\r\n// \r\n// UBT welcomes any suggestions, improvements or new platform ports.\r\n// email to: \r\n// --------------------------------------------------------------------------\r\n#include \"pch.h\"\r\n#include \"DirectoryListing.h\"\r\n#include \"GString.h\"\r\n#include \"GException.h\"\r\n//#include \t\t\t\r\n\r\n// #include \r\n\r\n//\t#include \"Winbase.h\"\r\n#include \r\n#include \r\n#include // for: mkdir\r\n\r\n\r\n\r\n\r\n\r\nconst char *CDirectoryListing::LastLeaf(const char *pzFullPath, char chSlash/*= 0*/)\r\n{\r\n\tstatic GString strReturnValue;\r\n\tstrReturnValue = \"\";\r\n\tif (pzFullPath && pzFullPath[0])\r\n\t{\r\n\t\tstrReturnValue = pzFullPath;\r\n\t\tint nLen = strlen(pzFullPath);\r\n\t\tif (chSlash)\r\n\t\t{\r\n\t\t\tif (pzFullPath[nLen - 1] == chSlash)\r\n\t\t\t\tnLen--;\r\n\r\n\t\t}\r\n\t\telse if ( pzFullPath[nLen - 1] == '\\\\' || pzFullPath[nLen - 1] == '/')\r\n\t\t{\r\n\t\t\tnLen--; // if the input value is \"/etc/bin/\" start searching behind the last '/'\r\n\t\t\t\t\t// so that the return leaf value is \"bin\"\r\n\t\t}\r\n\r\n\t\tfor(int i = nLen-1; i > -1; i-- )\r\n\t\t{\r\n\t\t\tif (chSlash)\r\n\t\t\t{\r\n\t\t\t\tif (pzFullPath[i] == chSlash)\r\n\t\t\t\t{\r\n\t\t\t\t\tstrReturnValue = &pzFullPath[i+1];\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if (pzFullPath[i] == '\\\\' || pzFullPath[i] == '/')\t\r\n\t\t\t{\r\n\t\t\t\tstrReturnValue = &pzFullPath[i+1];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn strReturnValue;\r\n}\r\n\r\n\r\n\r\n\r\nvoid CDirectoryListing::CreatePath(const char *pzPathOnlyOrPathAndFileName, int bPathHasFileName)\r\n{\r\n\t// cast off the const, we'll modify then restore the string\r\n\tchar *pzFileAndPath = (char *)pzPathOnlyOrPathAndFileName;\r\n\r\n\tif (!pzFileAndPath)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tint nLen = strlen(pzFileAndPath);\r\n\tfor(int i=0;iAddLast(strFullPath);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// now add the final slash for a string like this \"/myPath/SubDir/\"\r\n\t\t\t\tstrFullPath += chSlash;\r\n\r\n\t\t\t\t// go down into that directory now.\r\n\t\t\t\tRecurseFolder(strFullPath, strDirs, strFiles);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(strFiles)\r\n\t\t{\r\n\t\t\tCDirectoryListing files(pzDir, 1); // files only\r\n\t\t\tGStringIterator it2(&files);\r\n\t\t\twhile (it2())\r\n\t\t\t{\r\n\t\t\t\t// pzDir may be \"/myPath\" to begin with\r\n\t\t\t\tGString strFullPath(pzDir);\r\n\t\t\t\tif ( strFullPath.GetAt(strFullPath.GetLength() - 1) != '\\\\' && \r\n\t\t\t\t\t strFullPath.GetAt(strFullPath.GetLength() - 1) != '/')\r\n\t\t\t\t{\r\n\t\t\t\t\t// strFullPath will now end with a slash like \"/myPath/\" \r\n\t\t\t\t\tstrFullPath += chSlash;\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\tconst char *pzFile = it2++;\r\n\t\t\t\tstrFullPath += pzFile;\r\n\t\t\t\tstrFiles->AddLast((const char *)strFullPath);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tcatch( GenericException & )\r\n\t{\r\n\t\t// ignore the directory we can't access \r\n\t\t// rErr.GetDescription();\r\n\t}\r\n}\r\n\r\n\r\nvoid CDirectoryListing::Init(const char *szDirPath, int nMode)\r\n{\r\n\tstatic GString dotdot(\"..\");\r\n\tstatic GString dot(\".\");\r\n\t\r\n\tbool bIncludeSubDirs = (nMode == 2 || nMode == 3) ? 1 : 0;\r\n\tbool bIncludeFiles = (nMode == 1 || nMode == 3) ? 1 : 0;\r\n\t\r\n\t\r\n\tGString strPathWithTrailingSlash(szDirPath);\r\n\tGString strPathWithNoTrailingSlash(szDirPath);\r\n\r\n\t// if szDirPath ends with a slash\r\n\tif ( strPathWithNoTrailingSlash.Right(1) == \"/\" ||\r\n\t\t strPathWithNoTrailingSlash.Right(1) == \"\\\\\" )\r\n\t{\r\n\t\t// if the path is \"/\" leave it alone\r\n\t\tif (strPathWithNoTrailingSlash.Length() > 1)\r\n\t\t\tstrPathWithNoTrailingSlash = strPathWithNoTrailingSlash.Left(strPathWithNoTrailingSlash.Length() - 1);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tstrPathWithTrailingSlash += \"\\\\\";\r\n\r\n\t}\r\n\r\n\tif( _access( (const char *)strPathWithNoTrailingSlash, 0 ) )\r\n\t{\r\n\t\tthrow GenericException(\"GDirectoryListing\",0,(const char *)strPathWithNoTrailingSlash, errno);\r\n\t}\r\n\r\n\t// FindFirstFile & FindNextFile\r\n\tHANDLE hFindFile;\r\n\tWIN32_FIND_DATA find;\r\n\tBOOL fRet = TRUE;\r\n\tGString strSearch( strPathWithTrailingSlash );\r\n\tstrSearch += \"*.*\";\r\n\thFindFile = FindFirstFile((const char *)strSearch, &find);\r\n\twhile (hFindFile != (HANDLE)-1 && fRet == TRUE) \r\n\t{\r\n\t\tGString strTemp( strPathWithTrailingSlash );\r\n\t\tstrTemp += find.cFileName;\r\n\t\tstruct stat sstruct;\r\n\r\n\t\tint result = stat(strTemp, &sstruct);\r\n\t\tif (result == 0)\r\n\t\t{\r\n\t\t\tif ( !(sstruct.st_mode & _S_IFDIR) )\r\n\t\t\t{\r\n\t\t\t\t// Add the file\r\n\t\t\t\tif (bIncludeFiles)\r\n\t\t\t\t{\r\n\t\t\t\t\tAddLast((const char *)find.cFileName);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if (bIncludeSubDirs)\r\n\t\t\t{\r\n\t\t\t\tGString strFileName( LastLeaf( (char *)(const char *)strTemp,'\\\\') );\r\n\t\t\t\tif ( ( dotdot.Compare(strFileName) != 0 ) && ( dot.Compare(strFileName) != 0 ))\r\n\t\t\t\t{\r\n\t\t\t\t\tGString strFormattedDir;\r\n\t\t\t\t\tstrFormattedDir.Format(\"[dir] %s\", LastLeaf( (char *)(const char *)strFileName,'\\\\') );\r\n\t\t\t\t\tAddLast((const char *)strFormattedDir);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\tfRet = FindNextFile(hFindFile, &find);\r\n\t}\r\n\tFindClose(hFindFile);\r\n}\r\n\r\n\r\nCDirectoryListing::CDirectoryListing(const char *szPath)\r\n{\r\n\tInit(szPath, 1);\r\n}\r\n\r\n// nMode = 1 files, 2 dirs, 3 both\r\nCDirectoryListing::CDirectoryListing(const char *szPath, int nMode)\r\n{\r\n\tInit(szPath, nMode);\r\n}\r\n\r\nCDirectoryListing::~CDirectoryListing()\r\n{\r\n}\r\n\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOOwnerChangedDecl();\r\nCKERROR CreateDOOwnerChangedProto(CKBehaviorPrototype **);\r\nint DOOwnerChanged(const CKBehaviorContext& behcontext);\r\nCKERROR DOOwnerChangedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOOwnerChangedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOOwnerChanged\");\t\r\n\tod->SetDescription(\"Returns the current owner of a distributed object\");\r\n\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x34f668cc,0x43c51c58));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOOwnerChangedProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDOOwnerChangedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOOwnerChanged\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"New Owner\");\r\n\tproto->DeclareOutput(\"Object Released\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"test\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Owner ID\", CKPGUID_ID, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DOOwnerChanged);\r\n\tproto->SetBehaviorCallbackFct(DOOwnerChangedCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOOwnerChanged(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t}\r\n\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateOutput(1);\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object :\r\n\tCK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tif (!obj)\r\n\t{\r\n\t\tbeh->ActivateOutput(4);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\tXString errorMesg(\"distributed object creation failed,no network connection !\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(4);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\r\n\tIDistributedObjects*doInterface = cin->getDistObjectInterface();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\txDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());\r\n\tif (!dobj)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\tXString errorMesg(\"There is no such an object\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(4);\r\n\t}else\r\n\t{\r\n\t\tif (dobj->getOwnershipState().test(1 << E_DO_OS_RELEASED) && dobj->getOwnershipState().test( 1 << E_DO_OS_OWNERCHANGED) )\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(3);\r\n\t\t}\r\n\r\n\t\tif (dobj->getOwnershipState().testStrict(1 << E_DO_OS_OWNERCHANGED))\r\n\t\t{\r\n\t\t\tdobj->getOwnershipState().set( 1<getUserID();\r\n\t\t\tbeh->SetOutputParameterValue(0,&newCLientID);\r\n\t\t\tbeh->ActivateOutput(2);\r\n\t\t}\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR DOOwnerChangedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorExecBBDecl();\r\nCKERROR CreateExecBBProto(CKBehaviorPrototype **pproto);\r\nint ExecBB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKERROR ZipCallBack(const CKBehaviorContext& behcontext);\r\nCKObjectDeclaration\t*FillBehaviorExecBBDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"ExecBB\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetCategory(\"Narratives/Files\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6b62506d,0x3dd1067));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateExecBBProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\n\r\nCKERROR CreateExecBBProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"ExecBB\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Execute\");\r\n\t\r\n\tproto->DeclareOutput(\"Ok\");\r\n\tproto->DeclareOutput(\"Failed\");\r\n\t\r\n\tproto->DeclareInParameter(\"Filename\", CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"Directory\", CKPGUID_STRING);\r\n\r\n\tproto->DeclareOutParameter(\"last error\", CKPGUID_INT);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\tproto->SetFunction(ExecBB);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n#include \r\n\t\r\nBOOL RunAndForgetProcess(char *pCmdLine,\r\n char *pRunningDir,\r\n int *nRetValue)\r\n{\r\n\tint nError;\r\n\tSTARTUPINFO stInfo;\r\n\tPROCESS_INFORMATION prInfo;\r\n\tBOOL bResult;\r\n\tZeroMemory( &stInfo, sizeof(stInfo) );\r\n\tstInfo.cb = sizeof(stInfo);\r\n\tstInfo.dwFlags=STARTF_USESHOWWINDOW;\r\n\tstInfo.wShowWindow=SW_SHOW;\r\n\tbResult = CreateProcess(NULL,\r\n\t\t\t\t\t\t (LPSTR)pCmdLine,\r\n\t\t\t\t\t\t NULL,\r\n\t\t\t\t\t\t NULL,\r\n\t\t\t\t\t\t TRUE,\r\n\t\t\t\t\t\t CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP\r\n//\t\t\t\t\t\t DETACHED_PROCESS\r\n\t\t\t\t\t\t | NORMAL_PRIORITY_CLASS ,\r\n\t\t\t\t\t\t NULL,\r\n\t\t\t\t\t\t (LPSTR)pRunningDir ,\r\n\t\t\t\t\t\t &stInfo,\r\n\t\t\t\t\t\t &prInfo);\r\n\t*nRetValue = nError = GetLastError();\r\n\t// Don't write these two lines if you need\r\n\tCloseHandle(prInfo.hThread);\r\n\t// to use these handles\r\n\tCloseHandle(prInfo.hProcess);\r\n\tif (!bResult) return FALSE;\r\n\t\treturn TRUE;\r\n}\r\nint ExecBB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\t\r\n\t\r\n\tchar* filename = ((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\tchar* dirname = ((CKSTRING) beh->GetInputParameterReadDataPtr(1)) ;\r\n\r\n\r\n\tif (!strlen(dirname))\r\n\t\tdirname = NULL;//argh....... ?\r\n\r\n\tint ret = 0;\r\n\r\n\tbool res = RunAndForgetProcess(filename,dirname,&ret);\r\n\t\r\n\t\r\n\tbeh->SetOutputParameterValue(0,&ret);\r\n\t\r\n\tif (res)\r\n\t\tbeh->ActivateOutput(0);\r\n\telse \r\n\t\tbeh->ActivateOutput(1);\r\n\r\n\t\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n\r\n#include \"pCallbackSignature.h\"\r\n#include \"vtBBHelper.h\"\r\n#include \"xDebugTools.h\"\r\n#include \"pCallbackSignature.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetCallbackDecl();\r\nCKERROR CreatePBSetCallbackProto(CKBehaviorPrototype **pproto);\r\nint PBSetCallback(const CKBehaviorContext& behcontext);\r\nCKERROR PBSetCallbackCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_FetchSignature,\r\n\tbbI_ContactTypeMask,\r\n\tbbI_TriggerTypeMask,\r\n\tbbI_Threshold,\r\n\tbbI_Reserved,\r\n\tbbI_Reserved2,\r\n\tbbI_Contact,\r\n\tbbI_ContactModification,\r\n\tbbI_Trigger,\r\n\tbbI_WheelContact,\r\n\tbbI_RayCastHit,\r\n\tbbI_PreProcess,\r\n\tbbI_PostProcess,\r\n\tbbI_Copy,\r\n\tbbI_Delete\r\n//\tbbI_JointBreak,\r\n};\r\n\r\n\r\nvoid creatInputParameters(BBParameter pArray[],int size,CKBehavior *beh)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// remove all \r\n\t//\r\n\twhile(beh->GetInputParameterCount())\r\n\t{\r\n\t\tCKParameterIn* pi = beh->RemoveInputParameter(0);\r\n\t\tCKDestroyObject(pi);\r\n\t}\r\n\tfor(int i = 0 ; i < size ; i ++ )\r\n\t{\r\n\t\tBBParameter *par = &pArray[i];\r\n\t\tbeh->CreateInputParameter( par->name.Str(), par->guid);\r\n\t}\r\n}\r\n\r\nvoid creatOutputParameters(BBParameter pArray[],int size,CKBehavior *beh)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// remove all \r\n\t//\r\n\twhile(beh->GetOutputParameterCount())\r\n\t{\r\n\t\tCKParameterOut* pi = beh->RemoveOutputParameter(0);\r\n\t\tCKDestroyObject(pi);\r\n\t}\r\n\tfor(int i = 0 ; i < size ; i ++ )\r\n\t{\r\n\t\tBBParameter *par = &pArray[i];\r\n\t\tbeh->CreateOutputParameter( par->name.Str(), par->guid);\r\n\t}\r\n}\r\n\r\n#define BB_SSTART 6\r\n\r\nBBParameter pInMap221[] =\r\n{\r\n\tBB_PIN(bbI_FetchSignature,CKPGUID_BOOL,\"Create Parameters Only\",\"\"),\r\n\tBB_PIN(bbI_ContactTypeMask,VTF_COLLISIONS_EVENT_MASK,\"Contact Event Mask\",\"\"),\r\n\tBB_PIN(bbI_TriggerTypeMask,VTF_TRIGGER,\"Trigger Event Mask\",\"\"),\r\n\tBB_PIN(bbI_Threshold,CKPGUID_FLOAT,\"Contact Threshold\",\"\"),\r\n\tBB_PIN(bbI_Reserved,CKPGUID_FLOAT,\"Stub\",\"\"),\r\n\tBB_PIN(bbI_Reserved2,CKPGUID_FLOAT,\"Stub\",\"\"),\r\n\tBB_SPIN(bbI_Contact,CKPGUID_BEHAVIOR,\"Contact Notification\",\"\"),\r\n\tBB_SPIN(bbI_ContactModification,CKPGUID_BEHAVIOR,\"Contact Modification\",\"\"),\r\n\tBB_SPIN(bbI_Trigger,CKPGUID_BEHAVIOR,\"Trigger Event\",\"\"),\r\n\tBB_SPIN(bbI_WheelContact,CKPGUID_BEHAVIOR,\"Wheel Contact Modify\",\"\"),\r\n\tBB_SPIN(bbI_RayCastHit,CKPGUID_BEHAVIOR,\"Raycast Hit\",\"\"),\r\n\tBB_SPIN(bbI_PreProcess,CKPGUID_BEHAVIOR,\"Pre Process\",\"\"),\r\n\tBB_SPIN(bbI_PostProcess,CKPGUID_BEHAVIOR,\"Post Process\",\"\"),\r\n\tBB_SPIN(bbI_Copy,CKPGUID_BEHAVIOR,\"Copy\",\"\"),\r\n\tBB_SPIN(bbI_Delete,CKPGUID_BEHAVIOR,\"Delete\",\"\")\r\n\t//BB_SPIN(bbI_JointBreak,CKPGUID_BEHAVIOR,\"Joint Break\",\"\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMap221\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetCallbackDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBSetCallback\");\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Sets a callback script for the manager post process.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x1db50304,0x371a786b));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBSetCallbackProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreatePBSetCallbackProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBSetCallback\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PBSetCallback\r\n\r\n\tPBSetCallback is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSetCallback.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body or its sub shape.\r\n\t
\r\n\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBSetCallbackCB );\r\n\r\n\tBB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(pInMap221)\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PBSetCallback);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetCallback\r\n// FullName: PBSetCallback\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBSetCallback(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\tpFactory *pf = pFactory::Instance();\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tBB_DECLARE_PIMAP;\r\n\tint fetchSignature = GetInputParameterValue(beh,BB_IP_INDEX(bbI_FetchSignature));\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object :\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target && !fetchSignature ) \r\n\t\t\tbbErrorME(\"No Reference Object specified\");\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world && !fetchSignature)\r\n\t\t\tbbErrorME(\"No valid world object found\");\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body && !fetchSignature)\t\r\n\t\t\tbbErrorME(\"Object not physicalized\");\r\n\r\n\t\t\r\n\r\n\t\tint contactMask = GetInputParameterValue(beh,BB_IP_INDEX(bbI_ContactTypeMask));\r\n\t\tint triggerMask = GetInputParameterValue(beh,BB_IP_INDEX(bbI_TriggerTypeMask));\r\n\r\n\r\n\t\tBBSParameterM(bbI_Contact,BB_SSTART);\r\n\t\tBBSParameterM(bbI_Trigger,BB_SSTART);\r\n\t\tBBSParameterM(bbI_ContactModification,BB_SSTART);\r\n\t\tBBSParameterM(bbI_RayCastHit,BB_SSTART);\r\n\t\t\r\n\t\tBBSParameterM(bbI_Copy,BB_SSTART);\r\n\t\tBBSParameterM(bbI_Delete,BB_SSTART);\r\n\t\tBBSParameterM(bbI_WheelContact,BB_SSTART);\r\n\t\tBBSParameterM(bbI_PreProcess,BB_SSTART);\r\n\t\tBBSParameterM(bbI_PostProcess,BB_SSTART);\r\n\t\t//BBSParameterM(bbI_JointBreak,BB_SSTART);\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// update contact threshold\r\n\t\t//\r\n\t\tfloat threshold = GetInputParameterValue(beh,BB_IP_INDEX(bbI_Threshold));\r\n\t\tif (body && !fetchSignature && sbbI_Contact && (body->getFlags() & BF_Moving ))\r\n\t\t\tbody->setContactReportThreshold(threshold);\r\n\t\tif (sbbI_Delete || sbbI_Copy || sbbI_PostProcess || sbbI_PostProcess || sbbI_RayCastHit)\r\n\t\t{\r\n\t\t\tbbErrorME(\"Not Implemented yet\");\r\n\t\t}\r\n\t\tXString errMessg;\r\n \r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// collision notify\r\n\t\t//\r\n\t\tif (sbbI_Contact)\r\n\t\t{\r\n\r\n\r\n\t\t\tCK_ID contactScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_Contact));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(contactScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for contact notification enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature){\r\n\t\t\t\t\tcreatInputParameters(pInMapContactCallback,BB_PMAP_SIZE(pInMapContactCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tbody->setContactScript(contactScript,contactMask);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// wheel contact modify\r\n\t\t//\r\n\t\tif (sbbI_WheelContact)\r\n\t\t{\r\n\t\t\tCK_ID wheelContactModifyScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_WheelContact));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(wheelContactModifyScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for wheel contact modification enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature){\r\n\t\t\t\t\tcreatInputParameters(pInMapWheelContactModifyCallback,BB_PMAP_SIZE(pInMapWheelContactModifyCallback),cScript);\r\n\t\t\t\t\tcreatOutputParameters(pOutMapWheelContactModifyCallback,BB_PMAP_SIZE(pOutMapWheelContactModifyCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\r\n\t\t\t\t\tpWheel2 *w = body->getWheel2(target);\r\n\t\t\t\t\tw->setWheelContactScript(wheelContactModifyScript);\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// collision notify\r\n\t\t//\r\n\t\tif (sbbI_Trigger)\r\n\t\t{\r\n\r\n\r\n\t\t\tCK_ID triggerScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_Trigger));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(triggerScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for trigger notification enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature){\r\n\t\t\t\t\tcreatInputParameters(pInMapTriggerCallback,BB_PMAP_SIZE(pInMapTriggerCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tbody->setTriggerScript(triggerScript,triggerMask,target);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// collision notify\r\n\t\t//\r\n\t\tif (sbbI_ContactModification)\r\n\t\t{\r\n\t\t\tCK_ID contactModifyScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_ContactModification));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(contactModifyScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for contact modification enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature)\r\n\t\t\t\t{\r\n\t\t\t\t\tcreatInputParameters(pInMapContactModifyCallback,BB_PMAP_SIZE(pInMapContactModifyCallback),cScript);\r\n\t\t\t\t\tcreatOutputParameters(pOutMapContactModifyCallback,BB_PMAP_SIZE(pOutMapContactModifyCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tbody->setContactModificationScript(contactModifyScript);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// raycast \r\n\t\t//\r\n\t\tif (sbbI_RayCastHit)\r\n\t\t{\r\n\t\t\tbbErrorME(\"Not Implemented yet\");\r\n\r\n\t\t\tCK_ID raycastScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_RayCastHit));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(raycastScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for raycast hit reports enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature)\r\n\t\t\t\t{\r\n\t\t\t\t\tcreatInputParameters(pInMapRaycastHitCallback,BB_PMAP_SIZE(pInMapRaycastHitCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tbody->setRayCastScript(raycastScript);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// raycast \r\n\t\t//\r\n\t\t/*if (sbbI_JointBreak)\r\n\t\t{\r\n\t\t\tCK_ID jointBreakScript = GetInputParameterValue(beh,BB_IP_INDEX(bbI_JointBreak));\r\n\t\t\tCKBehavior * cScript = (CKBehavior*)GetPMan()->GetContext()->GetObject(jointBreakScript);\r\n\t\t\tif (!cScript)\r\n\t\t\t{\r\n\t\t\t\terrMessg.Format(\"Callback for joint breaks enabled but input script invalid\");\r\n\t\t\t\tbbWarning(errMessg.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tif (fetchSignature)\r\n\t\t\t\t{\r\n\t\t\t\t\tcreatInputParameters(pInMapJointBreakCallback,BB_PMAP_SIZE(pInMapJointBreakCallback),cScript);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tbody->setJointBreakScript(jointBreakScript);\r\n\t\t\t}\r\n\t\t}\r\n\t\t*/\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetCallbackCB\r\n// FullName: PBSetCallbackCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBSetCallbackCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\nvoid __newpVehicleDescr(BYTE *iAdd)\r\n{\r\n\r\n\tnew (iAdd)pVehicleDesc();\r\n}\r\n\r\nvoid __newpVehicleMotorDesc(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pVehicleMotorDesc();\r\n}\r\n\r\nvoid __newpVehicleGearDesc(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pVehicleGearDesc();\r\n}\r\nvoid PhysicManager::_RegisterVSLVehicle()\r\n{\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// vehicle base types\r\n\t//\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleMotorDesc)\r\n\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpmToGearUp)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpmToGearDown)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpm)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotorDesc,void,setToCorvette)\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleGearDesc)\r\n\tDECLAREMEMBER(pVehicleGearDesc,int,nbForwardGears)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToDefault)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToCorvette)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,bool,isValid)\r\n\r\n\r\n\tDECLAREOBJECTTYPE(pVehicleDesc)\r\n\tDECLARECTOR_0(__newpVehicleDescr)\r\n\tDECLAREMEMBER(pVehicleDesc,float,digitalSteeringDelta)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringSteerPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringTurnPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,float,steeringMaxAngle)\r\n\tDECLAREMEMBER(pVehicleDesc,float,transmissionEfficiency)\r\n\tDECLAREMEMBER(pVehicleDesc,float,differentialRatio)\r\n\tDECLAREMEMBER(pVehicleDesc,float,maxVelocity)\r\n\tDECLAREMEMBER(pVehicleDesc,float,motorForce)\r\n\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleGearDesc*,getGearDescription)\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleMotorDesc*,getMotorDescr)\r\n\tDECLAREMETHOD_0(pVehicleDesc,void,setToDefault)\r\n\r\n\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}#ifndef _XDISTRIBUTED_SESSION_H_\r\n#define _XDISTRIBUTED_SESSION_H_\r\n\r\n\r\n#include \"xNetTypes.h\"\r\n#include \"xDistributedObject.h\"\r\nclass xDistributedClient;\r\n\r\n\r\nclass xDistributedSession : public xDistributedObject\r\n{\r\n\r\n\t\t\r\n\ttypedef xDistributedObject Parent;\r\n\tpublic :\r\n\t\txDistributedSession();\r\n\t\t~xDistributedSession();\r\n\r\n\r\n\t\tenum MaskBits {\n\t\t\tInitialMask = BIT(0), ///< This mask bit is never set explicitly, so it can be used for initialization data.\n\t\t\tPositionMask = BIT(1), ///< This mask bit is set when the position information changes on the server.\n\t\t};\r\n\t\r\n\t\t\r\n\r\n\t\tint getSessionType() const { return mSessionType; }\r\n\t\tvoid setSessionType(int val) { mSessionType = val; }\r\n\t\t\r\n\t\tbool isLocked();\r\n\t\t\r\n\t\txNString getPassword();\r\n\t\tvoid setPassword(xNString val);\r\n\r\n\t\t\r\n\t\tint getMaxUsers();\r\n\t\tvoid setMaxUsers(int val);\r\n\t\t\r\n\t\tint getSessionID() const { return mSessionID; }\r\n\t\tvoid setSessionID(int val) { mSessionID = val; }\r\n\r\n\t\tbool isPrivate();\r\n\t\tint getNumUsers();\r\n\t\tvoid setNumUsers(int val);\r\n\t\tbool isFull();\r\n\r\n\r\n\t\tTNL::BitSet32& getSessionFlags() { return mSessionFlags; }\r\n\t\tvoid setSessionFlags(TNL::BitSet32 val) { mSessionFlags = val; }\r\n\r\n\t\txClientArrayType *mClientTable;\r\n\t\txClientArrayType&getClientTable() { return *mClientTable; }\r\n\t\tbool isClientJoined(int userID);\r\n\t\tvoid addUser(xDistributedClient *client);\r\n\t\tvoid removeUser(xDistributedClient *client);\r\n\r\n\r\n\t\tvoid onGhostRemove();\r\n\t\tbool onGhostAdd(TNL::GhostConnection *theConnection);\n\t\tvoid onGhostAvailable(TNL::GhostConnection *theConnection);\n\t\tTNL::U32 packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream);\n\t\tvoid unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream);\r\n\t\tvoid performScopeQuery(TNL::GhostConnection *connection);\r\n\r\n\r\n\t\tvoid pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvoid prepare();\r\n\r\n\t\tvoid initProperties();\r\n\t\txDistributedProperty *getProperty(int nativeType);\r\n\t\txDistributedProperty *getUserProperty(const char*name);\r\n\r\n\t\tint mSessionType;\r\n\t\tint mMaxUsers;\r\n\t\txNString mPassword;\r\n\t\txNString mSessionMaster;\r\n\t\tbool mPrivate;\r\n\t\tbool mLocked;\r\n\t\tint mSessionID;\r\n\t\t\r\n\t\tint mUsers;\r\n\t\tTNL::BitSet32 mSessionFlags;\r\n\t\r\n\r\n\t\tuxString print(TNL::BitSet32 flags);\r\n\r\npublic:\r\n\tTNL_DECLARE_CLASS(xDistributedSession);\r\n\r\n};\r\n\r\n#endif/*\n * Tcp4u v 3.31 Created may 93 - Last Revision 20/10/1997 3.20\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tcp4u.c\n * Purpose: main functions for tcp management\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n#define TCP4U_SENDTIMEOUT 3600l /* one hour */\n\n\n\n\n/* ******************************************************************* */\n/* */\n/* Partie I : constructeurs /Destructeurs */\n/* */\n/* */\n/* Tcp4uInit, Tcp4uCleanup */\n/* */\n/* */\n/* ******************************************************************* */\n\n/* ------------------------------------------------------------------ */\n/* Initialisation */\n/* ------------------------------------------------------------------ */\nint API4U Tcp4uInit (void)\n{\nint Rc=0;\n\n Tcp4uLog (LOG4U_PROC, \"Tcp4uInit\");\n\n Skt4uInit ();\n# ifdef _WINDOWS\n {\n /* enregistrement aupres de Winsock.Dll */\n WSADATA WSAData;\n Tcp4uLog (LOG4U_CALL, \"WSAStartup, Winsock 1.1 required\");\n Rc = WSAStartup (MAKEWORD (1,1), & WSAData);\n }\n# endif\n Tcp4uLog (LOG4U_EXIT, \"Tcp4uInit\");\nreturn Rc==0 ? TCP4U_SUCCESS : TCP4U_ERROR;\n} /* Tcp4uInit */\n\n\n\n/* ------------------------------------------------------------------ */\n/* Destructeurs */\n/* ------------------------------------------------------------------ */\nint API4U Tcp4uCleanup (void)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"Tcp4uCleanup\");\n Rc = Skt4uCleanup ();\n Tcp4uLog (LOG4U_EXIT, \"Tcp4uCleanup\");\nreturn Rc;\n} /* Tcp4wCleanup */\n\n\n\n/* ------------------------------------------------------------------ */\n/* WINDOWS : Fin de vie de la DLL */\n/* ------------------------------------------------------------------ */\n#ifdef TCP4W_DLL\nint API4U WEP (int nExitType)\n{\n Tcp4uLog (LOG4U_PROC, \"WEP\");\n Skt4uCleanup ();\n nExitType=0; /* suppress warning */\n Tcp4uLog (LOG4U_EXIT, \"WEP\");\nreturn 1; /* definition Windows */\n} /* WEP */\n#endif\n\n\n\n/* ------------------------------------------------------------------ */\n/* Aliases : Tcp4uxInit/Tcp4uxCleanup ; Tcp4wInit/Tcp4wCleanup */\n/* ------------------------------------------------------------------ */\n#ifdef _WINDOWS\n int API4U Tcp4wInit (void) { return Tcp4uInit (); }\n int API4U Tcp4wCleanup (void) { return Tcp4uCleanup (); }\n#endif\n#ifdef UNIX\n int API4U Tcp4uxInit (void) { return Tcp4uInit (); }\n int API4U Tcp4uxCleanup (void) { return Tcp4uCleanup (); }\n#endif\n\n\n/* ******************************************************************* */\n/* */\n/* Partie I : Fonctions de bas niveau TCP */\n/* */\n/* */\n/* TcpAbort */\n/* TcpAccept */\n/* TcpConnect */\n/* TcpClose */\n/* TcpFlush */\n/* TcpGetListenSocket */\n/* TcpRecv */\n/* TcpSend */\n/* */\n/* ******************************************************************* */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpAbort: Stoppe un appel bloquant */\n/* Retourne TCP4U_SUCCESS */\n/* ------------------------------------------------------------ */\nint API4U TcpAbort (void)\n{\n Tcp4uLog (LOG4U_PROC, \"TcpAbort\");\n if (WSAIsBlocking ()) \n {\n Tcp4uLog (LOG4U_CALL, \"WSACancelBlockingCall\");\n WSACancelBlockingCall ();\n }\n else Tcp4uLog (LOG4U_ERROR, \"TcpAbort: No calling process to cancel\");\n Tcp4uLog (LOG4U_EXIT, \"TcpAbort\");\nreturn TCP4U_SUCCESS;\n} /* TcpAbort */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpAccept : itablissement d'une connexion TCP avec Timeout */\n/* Retourne TCP4U_ERROR, TCP4U_TIMEOUT, TCP4U_SUCCESS */\n/* ou TCP4U_BUFFERFREED si pConnectSock n'existe plus */\n/* En cas de succes la variable pConnectSock est */\n/* renseignee. */\n/* ------------------------------------------------------------ */\nint API4U TcpAccept (SOCKET far *pCSock, SOCKET ListenSock, UINT nTO)\n{\nstruct timeval TO; /* Time Out structure */\nfd_set ReadMask; /* select mask */\nSOCKET ConSock;\nstruct sockaddr_in saSockAddr; /* specifications pour le Accept */\nstruct linger sling = { TRUE, 5 }; /* 5-seconds timeout */\nint nAddrLen = sizeof saSockAddr;\nint Rc;\n\n Tcp4uLog (LOG4U_PROC, \"TcpAccept. Listen socket %d, Timeout %d\", ListenSock, nTO);\n /* prepare select */\n FD_ZERO (& ReadMask); /* mise a zero du masque */\n FD_SET (ListenSock, & ReadMask); /* Attente d'evenement en lecture */\n TO.tv_sec = (long) nTO; /* secondes */\n TO.tv_usec = 0; /* microsecondes */\n /* s+1 normally unused but better for a lot of bugged TCP Stacks */\n Tcp4uLog (LOG4U_CALL, \"select on socket %d\", ListenSock);\n Rc = select (1+ListenSock, & ReadMask, NULL, NULL, nTO==0 ? NULL : & TO);\n if (Rc<0) \n {\n Tcp4uLog (LOG4U_ERROR, \"select on socket %d\", ListenSock);\n return IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR; /* erreur reseau */\n }\n if (Rc==0)\n {\n Tcp4uLog (LOG4U_ERROR, \"select on socket %d: Timeout\", ListenSock);\n return TCP4U_TIMEOUT;\n }\n\n Tcp4uLog (LOG4U_CALL, \"accept on listen socket %d\", ListenSock);\n ConSock = accept (ListenSock, (struct sockaddr far *) &saSockAddr, &nAddrLen);\n if (ConSock==INVALID_SOCKET) \n {\n Tcp4uLog (LOG4U_ERROR, \"accept on socket %d\", ListenSock);\n return IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR;\n }\n Skt4uRcd (ConSock, STATE_SERVER);\n\n Tcp4uLog (LOG4U_CALL, \"setsockopt SOL_LINGER on socket %d\", ConSock);\n setsockopt (ConSock, SOL_SOCKET, SO_LINGER,(LPSTR) &sling, sizeof sling);\n /* validite des pointeurs */\n if (IsBadWritePtr (pCSock, sizeof *pCSock))\n {\n TcpClose (& ConSock);\n Tcp4uLog (LOG4U_ERROR, \"TcpAccept. invalid pointer\");\n return TCP4U_BUFFERFREED;\n }\n else\n {\n *pCSock = ConSock;\n Tcp4uLog (LOG4U_EXIT, \"TcpAccept\");\n return TCP4U_SUCCESS;\n }\n} /* TcpAccept */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpClose - Fermeture d'une socket */\n/* La socket pointie par pS est fermie, *pS est */\n/* mise ` INVALID_SOCKET. */\n/* - Retourne 1 en cas de succhs, -1 sinon (en giniral */\n/* du ` l'erreur WSAEINTR) */\n/* constantes (TCP4U_SUCCESS et TCP4U_ERROR) */\n/* ------------------------------------------------------------ */\nint API4U TcpClose (SOCKET far *pS)\n{\nSOCKET s;\nstruct timeval TO; /* Time Out structure */\nstruct S_HistoSocket *pStat; /* stats about socket */\n\n Tcp4uLog (LOG4U_PROC, \"TcpClose socket %d\", *pS);\n\n if (*pS==(unsigned) INVALID_SOCKET) return TCP4U_SUCCESS; /* bien passe */\n s = *pS;\n pStat = Skt4uGetStats (s);\n if (pStat!=NULL && pStat->nState==STATE_LISTEN)\n {\n /* Ici une petite tempo pour les winsockets qui n'apprecient */\n /* pas la succession trop rapide Accept/Close */\n TO.tv_sec = 0;\n TO.tv_usec = 100000l; /* microsecondes */\n select (s+1, NULL, NULL, NULL, & TO);\n } /* pause */\n\n /* Si on effectue un shutdown (s, 2), certaines winsocket */\n /* n'envoie plus la trame de longueur 0 caracteristique */\n /* de la fin de connexion. */\n /* On le remplace donc par le TcpFlush */\n if (pStat!=NULL && pStat->nState!=STATE_LISTEN) TcpFlush (s);\n\n Tcp4uLog (LOG4U_CALL, \"closesocket socket %d\", s);\n if (CloseSocket (s)==0)\n {\n Skt4uUnRcd (s);\n if (!IsBadWritePtr(pS, sizeof *pS)) *pS =(unsigned) INVALID_SOCKET;\n else \t\t\t \t\t\t\tTcp4uLog (LOG4U_ERROR, \"TcpClose: Invalid pointer\");\n\n Tcp4uLog (LOG4U_EXIT, \"TcpClose\");\n return TCP4U_SUCCESS;\n }\n Tcp4uLog (LOG4U_ERROR, \"closesocket socket %d\", s);\n\nreturn TCP4U_ERROR;\n} /* TcpClose */\n\n\n\n/* --------------------------------------------------------------------- */\n/* TcpConnect : Tentative d'etablissemnt d'une connexion TCP */\n/* Retourne TCP4U_ERROR, TCP4U_SUCCESS, TCP4U_HOSTUNKNONW */\n/* --------------------------------------------------------------------- */\nint API4U TcpConnect (SOCKET far *pS, LPCSTR szHost,\n LPCSTR szService, unsigned short far *lpPort)\n{\nint Rc;\nstruct sockaddr_in saSockAddr;\nstruct servent far * lpServEnt;\nSOCKET connect_skt;\nunsigned short Zero = 0;\n\n Tcp4uLog (LOG4U_PROC, \"TcpConnect. Host %s, service %s, port %u\", \n szHost, \n szService==NULL ? \"none\" : szService, \n lpPort==NULL ? -1 : *lpPort);\n\n *pS = INVALID_SOCKET; /* par defaut erreur */\n if (lpPort==NULL) lpPort = & Zero; /* evite de tester sans arret */\n /* --- 1er champ de saSockAddr : Port */\n if (szService==NULL) lpServEnt = NULL ;\n else\n {\n Tcp4uLog (LOG4U_DBCALL, \"getservbyname %s/tcp\", szService);\n lpServEnt = getservbyname (szService, \"tcp\") ;\n }\n saSockAddr.sin_port = lpServEnt!=NULL ? lpServEnt->s_port : htons(*lpPort);\n if (saSockAddr.sin_port == 0) return TCP4U_BADPORT; /* erreur dans port */\n /* --- 2eme champ de saSockAddr : Addresse serveur */\n saSockAddr.sin_addr = Tcp4uGetIPAddr (szHost);\n if (saSockAddr.sin_addr.s_addr==INADDR_NONE) return TCP4U_HOSTUNKNOWN;\n /* --- Dernier champ : liaison connectie */\n saSockAddr.sin_family = AF_INET; /* on utilise le mode connecte TCP */\n /* --- creation de la socket */\n Tcp4uLog (LOG4U_CALL, \"socket PF_INET, SOCK_STREAM\");\n if ( (connect_skt = socket (PF_INET, SOCK_STREAM, 0))==SOCKET_ERROR)\n {\n Tcp4uLog (LOG4U_ERROR, \"socket\");\n return TCP4U_NOMORESOCKET;\n }\n /* --- connect retourne INVALID_SOCKET ou numero valide */\n Tcp4uLog (LOG4U_CALL, \"connect on host %s\", inet_ntoa (saSockAddr.sin_addr));\n Rc = connect (connect_skt,(struct sockaddr far *) & saSockAddr, sizeof saSockAddr);\n /* --- enregistrement dans notre table */\n if (Rc==SOCKET_ERROR)\n {\n Tcp4uLog (LOG4U_ERROR, \"connect\");\n CloseSocket (connect_skt); /* release buffer */\n }\n else Skt4uRcd (connect_skt, STATE_CLIENT);\n *lpPort = htons (saSockAddr.sin_port);\n if (IsBadWritePtr (pS, sizeof *pS)) \n {\n Tcp4uLog (LOG4U_ERROR, \"TcpConnect: invalid pointer\");\n return TCP4U_BUFFERFREED;\n }\n else *pS = Rc==SOCKET_ERROR ? INVALID_SOCKET : connect_skt;\n \n Tcp4uLog (LOG4U_EXIT, \"TcpConnect\");\nreturn Rc==SOCKET_ERROR ? TCP4U_CONNECTFAILED : TCP4U_SUCCESS;\n} /* TcpConnect */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpFlush: Vide le buffer relatif a une socket */\n/* Retourne TCP4U_ERROR, TCP4U_SUCCESS, TCP4U_CLOSEDSOCKET */\n/* ------------------------------------------------------------ */\nint API4U TcpFlush (SOCKET s)\n{\nint nBR=-1;\nchar szBuf[64];\n\n Tcp4uLog (LOG4U_PROC, \"TcpFlush on socket %d\", s);\n\n if (s==INVALID_SOCKET) return TCP4U_ERROR;\n while ( TcpIsDataAvail (s) && (nBR=recv (s,szBuf,sizeof szBuf,0)) > 0 )\n Tcp4uDump (szBuf, nBR, \"Flushed\");\n while ( TcpIsOOBDataAvail (s) &&(nBR=recv (s,szBuf,sizeof szBuf,MSG_OOB))>0 )\n\t Tcp4uDump (szBuf, nBR, \"Flushed\");\n\n Tcp4uLog (LOG4U_EXIT, \"TcpFlush\");\nif (nBR<0) return IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR;\nif (nBR==0) return TCP4U_SOCKETCLOSED;\nreturn TCP4U_SUCCESS;\n} /* TcpFlush */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpGetListenSocket */\n/* Retourne TCP4U_ERROR, TCP4U_SUCCESS */\n/* ------------------------------------------------------------ */\nint API4U TcpGetListenSocket (SOCKET far *pS, LPCSTR szService,\n unsigned short far *lpPort, int nPendingConnection)\n{\nstruct sockaddr_in saSockAddr; /* specifications pour le Accept */\nint nAddrLen;\nSOCKET ListenSock;\nint One=1;\nint Rc;\nunsigned short Zero = 0;\nstruct servent far * lpServEnt;\n\n Tcp4uLog (LOG4U_PROC, \"TcpGetListenSocket on service %s, port %u\", \n szService==NULL ? \"none\" : szService, \n lpPort==NULL ? 0 : *lpPort);\n\n *pS = INVALID_SOCKET;\n if (lpPort==NULL) lpPort = & Zero;\n /* --- 1er champ de saSockAddr : Port */\n if (szService==NULL) lpServEnt = NULL ;\n else\n {\n Tcp4uLog (LOG4U_DBCALL, \"getservbyname %s/tcp\", szService);\n lpServEnt = getservbyname (szService, \"tcp\") ;\n }\n saSockAddr.sin_port = (lpServEnt!=NULL) ? lpServEnt->s_port : htons(*lpPort);\n#ifdef CONTROL_EN_TROP\n if (saSockAddr.sin_port==0) return TCP4U_BADPORT; /* erreur attribution Port */\n#endif \n /* create socket */\n Tcp4uLog (LOG4U_CALL, \"socket AF_INET, SOCK_STREAM\");\n ListenSock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);\n if (ListenSock==INVALID_SOCKET)\n {\n Tcp4uLog (LOG4U_ERROR, \"socket\");\n return TCP4U_NOMORESOCKET;\n }\n saSockAddr.sin_family = AF_INET;\n saSockAddr.sin_addr.s_addr=INADDR_ANY;\n /* set options ReuseAddress and Linger */\n Tcp4uLog (LOG4U_CALL, \"setsockopt SO_REUSEADDR on sock %d\", ListenSock);\n setsockopt (ListenSock, SOL_SOCKET, SO_REUSEADDR, (char far *)&One, sizeof One);\n Tcp4uLog (LOG4U_CALL, \"setsockopt SO_LINGER on sock %d\", ListenSock);\n setsockopt (ListenSock, SOL_SOCKET, SO_LINGER,(char far *)&One, sizeof One);\n /* Bind name to socket */\n Tcp4uLog (LOG4U_CALL, \"bind socket %d to %s\", ListenSock, inet_ntoa (saSockAddr.sin_addr));\n Rc = bind (ListenSock,(struct sockaddr far *) & saSockAddr, sizeof(struct sockaddr));\n if (Rc != SOCKET_ERROR)\n {\n Tcp4uLog (LOG4U_CALL, \"listen on socket %d. %d pendind connections\", ListenSock, nPendingConnection);\n Rc = listen (ListenSock, nPendingConnection);\n }\n if (Rc==SOCKET_ERROR)\n {\n Tcp4uLog (LOG4U_ERROR, \"bind or listen on socket %d\", WSAGetLastError (), ListenSock);\n CloseSocket (ListenSock);\n return TCP4U_BINDERROR;\n }\n /* Get port id with getsockname */\n nAddrLen = sizeof saSockAddr;\n memset (& saSockAddr, 0, sizeof(struct sockaddr) );\n Tcp4uLog (LOG4U_DBCALL, \"getsockname on socket %d\", ListenSock);\n getsockname (ListenSock, (struct sockaddr far *) &saSockAddr, &nAddrLen);\n *lpPort = htons (saSockAddr.sin_port);\n Skt4uRcd (ListenSock, STATE_LISTEN);\n if (IsBadWritePtr (pS, sizeof *pS)) \n {\n\t Tcp4uLog (LOG4U_ERROR, \"TcpGetListenSocket: invalid pointer\");\n \t return TCP4U_BUFFERFREED;\n }\n else *pS = ListenSock;\n\n Tcp4uLog (LOG4U_EXIT, \"TcpGetListenSocket\");\nreturn TCP4U_SUCCESS;\n} /* TcpGetListenSock */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpRecv - Lecture d'une trame avec Timeout */\n/* TcpRecv recoit uBufSize octets de donnies */\n/* la fonction s'arrjte avant si la socket est fermie */\n/* ou si une timeout arrive. */\n/* - Retourne le nombre d'octets lus, */\n/* TCP4U_SOCKETCLOSED si la socket a iti fermie */\n/* TCP4U_ERROR sur une erreur de lecture */\n/* TCP4U_TIMEOUT sur un TO */\n/* TCP4U_BUFFERFREED si libiration des buffers */\n/* - Remarque : Pour iviter que le buffer appelant soit */\n/* libere de manihre asynchrone, la fonction utilise */\n/* ses propres buffers. */\n/* - Ajout des modes TCP4U_WAITFOREVER et TCP4U_WAIT */\n/* ------------------------------------------------------------ */\n\n/* forme avec log */\nint API4U TcpRecv (SOCKET s, LPSTR szBuf, unsigned uBufSize,\n unsigned uTimeOut, HFILE hLogFile)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"TcpRecv on socket %d. Timeout %d, bufsize %d\", s, uTimeOut, uBufSize);\n Rc = InternalTcpRecv (s, szBuf, uBufSize, uTimeOut, hLogFile);\n if (Rc>=TCP4U_SUCCESS) Tcp4uDump (szBuf, Rc, DUMP4U_RCVD);\n Tcp4uLog (LOG4U_EXIT, \"TcpRecv\");\nreturn Rc;\n} /* TcpRecv */\n\n\n/* forme sans log */\nint InternalTcpRecv (SOCKET s, LPSTR szBuf, unsigned uBufSize, \n unsigned uTimeOut, HFILE hLogFile)\n{\nchar cBuf;\nLPSTR p = NULL;\nint Rc, nUpRc; /* Return Code of select and recv */\nstruct timeval TO; /* Time Out structure */\nstruct timeval *pTO; /* Time Out structure */\nfd_set ReadMask; /* select mask */\n\n\n if (s==INVALID_SOCKET) return TCP4U_ERROR;\n FD_ZERO (& ReadMask); /* mise a zero du masque */\n FD_SET (s, & ReadMask); /* Attente d'evenement en lecture */\n\n /* detail des modes */\n switch (uTimeOut)\n {\n case TCP4U_WAITFOREVER : pTO = NULL; \n break;\n case TCP4U_DONTWAIT : TO.tv_sec = TO.tv_usec=0 ; \n pTO = & TO;\n break;\n /* Otherwise uTimeout is really the Timeout */\n default : TO.tv_sec = (long) uTimeOut;\n TO.tv_usec=0;\n pTO = & TO;\n break;\n }\n /* s+1 normally unused but better for a lot of bugged TCP Stacks */\n Tcp4uLog (LOG4U_CALL, \"select on socket %d\", s);\n Rc = select (s+1, & ReadMask, NULL, NULL, pTO);\n if (Rc<0) \n {\n Tcp4uLog (LOG4U_ERROR, \"select on socket %d\", s);\n return IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR;\n }\n if (Rc==0)\n {\n Tcp4uLog (LOG4U_ERROR, \"select on socket %d: Timeout\", s);\n return TCP4U_TIMEOUT; /* timeout en reception */\n }\n if (szBuf==NULL || uBufSize==0) \n {\n Tcp4uLog (LOG4U_EXIT, \"TcpRecv\");\n\treturn TCP4U_SUCCESS;\n }\n if (uBufSize==1) /* cas frequent : lecture caractere par caractere */\n p = & cBuf;\n else\n {\n p = Calloc (uBufSize, 1);\n if (p==NULL) return TCP4U_INSMEMORY;\n }\n \n Tcp4uLog (LOG4U_CALL, \"recv socket %d, buffer %d bytes\", s, uBufSize);\n Rc = recv (s, p, uBufSize, 0); /* chgt 11/01/95 */\n \n switch (Rc)\n {\n case SOCKET_ERROR : \n Tcp4uLog (LOG4U_ERROR, \"recv socket %d\", s);\n nUpRc = IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR ; \n break;\n case 0 : \n Tcp4uLog (LOG4U_ERROR,\"socket %d: Host has closed connection\", s);\n nUpRc = TCP4U_SOCKETCLOSED ; \n break;\n default :\n if (hLogFile!=HFILE_ERROR) Write (hLogFile, p, Rc);\n if (IsBadWritePtr (szBuf, 1)) nUpRc = TCP4U_BUFFERFREED;\n else memcpy (szBuf, p, nUpRc=Rc);\n break;\n } /* translation des codes d'erreurs */\n if (p!=NULL && uBufSize!=1) Free (p);\nreturn nUpRc;\n} /* TcpRecv */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpSend : Envoi de uBufSize octets vers le distant */\n/* Retourne TCP4U_ERROR ou TCP4U_SUCCESS */\n/* ------------------------------------------------------------ */\n\n/* forme avec log */\nint API4U TcpSend (SOCKET s, LPCSTR szBuf, unsigned uBufSize,\n BOOL bHighPriority, HFILE hLogFile)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC,\"TcpSend on socket %d. %d bytes to be sent\",s,uBufSize);\n Rc = InternalTcpSend (s, szBuf, uBufSize, bHighPriority, hLogFile);\n if (Rc==TCP4U_SUCCESS) Tcp4uDump (szBuf, uBufSize, DUMP4U_SENT);\n Tcp4uLog (LOG4U_EXIT, \"TcpSend\");\nreturn Rc;\n} /* TcpSend */\n\n/* forme sans log */\nint InternalTcpSend (SOCKET s, LPCSTR szBuf, unsigned uBufSize,\n BOOL bHighPriority, HFILE hLogFile)\n{\nint Rc;\nunsigned Total;\nLPSTR p;\n\n if (s==INVALID_SOCKET) return TCP4U_ERROR;\n p = Calloc (uBufSize, 1);\n if (p==NULL) return TCP4U_INSMEMORY;\n memcpy (p, szBuf, uBufSize);\n if (hLogFile!=HFILE_ERROR) Write (hLogFile, p, uBufSize);\n\n for ( Total = 0, Rc = 1 ; Total < uBufSize && Rc > 0 ; Total += Rc)\n {\n Tcp4uLog (LOG4U_CALL, \"send on socket %d. %d bytes to be sent\", \n s, uBufSize-Total);\n Rc = send (s, & p[Total], uBufSize-Total, bHighPriority ? MSG_OOB : 0);\n if (Rc<=0) Tcp4uLog (LOG4U_ERROR, \"send on socket %d.\", s);\n }\n Free(p);\n \nreturn Total>=uBufSize ? TCP4U_SUCCESS : IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR;\n} /* TcpSend */\n\n\n\n\n/* ******************************************************************* */\n/* */\n/* Partie I (suite) : Fonctions d'information */\n/* */\n/* TcpGetLocalID */\n/* TcpGetRemoteID */\n/* TcpIsDataAvail */\n/* */\n/* ******************************************************************* */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpGetLocalID: Retourne nom et adresse IP de la station */\n/* Retourne TCP4U_SUCCESS, TCP4U_ERROR */\n/* ------------------------------------------------------------ */\nint API4U TcpGetLocalID (LPSTR szStrName, int uNameSize, DWORD far *lpAddress)\n{\nchar szName[128];\nstruct hostent far *lpHostEnt;\nint Rc;\n\n Tcp4uLog (LOG4U_PROC, \"TcpGetLocalID\");\n\n if (lpAddress!=NULL) memset (lpAddress, 0, sizeof (DWORD));\n /* on envisage 2 methodes pour obtenir le nom du PC */\n /* d'abord un appel a gethostname */\n Tcp4uLog (LOG4U_DBCALL, \"gethostname\");\n if (gethostname (szName, sizeof szName)==SOCKET_ERROR) return TCP4U_ERROR;\n if (lpAddress != NULL)\n {\n Tcp4uLog (LOG4U_DBCALL, \"gethostbyname on host %s\", szName);\n lpHostEnt = gethostbyname (szName);\n if (lpHostEnt==NULL) return TCP4U_ERROR;\n memcpy (lpAddress, lpHostEnt->h_addr_list[0], lpHostEnt->h_length);\n }\n if (szStrName!=NULL)\n {\n Strcpyn (szStrName, szName, uNameSize);\n Rc = Strlen(szName)>Strlen(szStrName) ? TCP4U_OVERFLOW : TCP4U_SUCCESS;\n }\n else Rc = TCP4U_SUCCESS;\n\n Tcp4uLog (LOG4U_EXIT, \"TcpGetLocalID\");\nreturn TCP4U_SUCCESS; \n} /* TcpGetLocalID */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpGetRemoteID: Retourne nom et adresse IP du distant */\n/* Retourne TCP4U_SUCCESS, TCP4U_ERROR */\n/* ------------------------------------------------------------ */\nint API4U TcpGetRemoteID (SOCKET s, LPSTR szStrName, int uNameSize, \n DWORD far *lpAddress)\n{\nstruct sockaddr_in SockAddr;\nint SockAddrLen=sizeof SockAddr;\nstruct hostent far *lpHostEnt;\n\n Tcp4uLog (LOG4U_PROC, \"TcpGetRemoteID on socket %d\", s);\n\n /* determiner l'adress IP de la station distante */\n Tcp4uLog (LOG4U_DBCALL, \"getpeername on socket %d\", s);\n if (getpeername (s, (struct sockaddr far *) & SockAddr, & SockAddrLen)==SOCKET_ERROR) \n {\n Tcp4uLog (LOG4U_ERROR, \"getpeername on socket %d\", s);\n return TCP4U_ERROR;\n }\n if (lpAddress!=NULL) \n memcpy (lpAddress, & SockAddr.sin_addr.s_addr,\n sizeof SockAddr.sin_addr.s_addr);\n if (szStrName!=NULL && uNameSize > 0) \n {\n /* determiner par gethostbyaddr le nom de la station */\n szStrName[0]=0; /* si erreur */\n Tcp4uLog (LOG4U_DBCALL, \"gethostbyaddr on host %s\", inet_ntoa (SockAddr.sin_addr));\n lpHostEnt = gethostbyaddr ((LPSTR) & SockAddr.sin_addr.s_addr, 4, PF_INET);\n if (lpHostEnt!=NULL) Strcpyn (szStrName, lpHostEnt->h_name, uNameSize);\n else Tcp4uLog (LOG4U_ERROR, \"gethostbyaddr\");\n }\n\n Tcp4uLog (LOG4U_EXIT, \"TcpGetRemoteID\");\nreturn TCP4U_SUCCESS;\n} /* TcpGetRemoteID */\n\n\n\n/* ------------------------------------------------------------- */\n/* TcpIsDataAvail: Retourne VRAI si des donnees sont disponibles */\n/* ------------------------------------------------------------- */\nBOOL API4U TcpIsDataAvail (SOCKET s)\n{\nunsigned long ulData;\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"TcpIsDataAvail on socket %d\", s);\n\n Tcp4uLog (LOG4U_CALL, \"Ioctl FIONREAD on socket %d\", s);\n Rc = IoctlSocket (s, FIONREAD, & ulData);\n Tcp4uLog (LOG4U_EXIT, \"TcpIsDataAvail\");\nreturn Rc==0 && ulData>0;\n} /* TcpIsDataAvail */\n\n\n/* ------------------------------------------------------------- */\n/* TcpIsOOBDataAvail: Retourne VRAI si des donnees Out Of Band */\n/* sont disponibles */\n/* ------------------------------------------------------------- */\nBOOL API4U TcpIsOOBDataAvail (SOCKET s)\n{\nunsigned long ulData;\nint Rc;\n\n Tcp4uLog (LOG4U_PROC, \"TcpIsOOBDataAvail on socket %d\", s);\n\n Rc = IoctlSocket (s, SIOCATMARK, & ulData);\n Tcp4uLog (LOG4U_EXIT, \"TcpIsOOBDataAvail\");\nreturn Rc==0 && ! ulData;\n} /* TcpIsOOBDataAvail */\n\n\n\n/* ******************************************************************* */\n/* */\n/* Partie II : Gestion d'un mini- protocole */\n/* */\n/* */\n/* TcpPPSend - TcpPPRecv */\n/* */\n/* */\n/* ******************************************************************* */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpPPRecv - Lecture d'une trame avec Timeout */\n/* TcpPPRecv recoit uBufSize octets de donnies */\n/* la fonction s'arrjte avant si la socket est fermie */\n/* ou si un timeout arrive. */\n/* - Retourne le nombre d'octets lus, */\n/* TCP4U_SOCKETCLOSED si la socket a iti fermie */\n/* TCP4U_ERROR sur une erreur de lecture */\n/* TCP4U_TIMEOUT sur un TO */\n/* TCP4U_BUFFERFREED si libiration des buffers */\n/* - Remarque : Pour iviter que le buffer appelant soit */\n/* libiri de manihre asynchrone, la fonction utilise */\n/* ses propres buffers. */\n/* ------------------------------------------------------------ */\nint API4U TcpPPRecv (SOCKET s, LPSTR szBuf, unsigned uBufSize,\n unsigned uTimeOut, BOOL bExact, HFILE hLogFile)\n{\nLPSTR p, q;\nint Rc, nUpRc; /* Return Code of select and recv */\nunsigned short nToBeReceived, nReceived;\n\n Tcp4uLog (LOG4U_PROC, \"TcpPPRecv on socket %d. Timeout %d, buffer %d bytes\", s, uTimeOut, uBufSize);\n\n if (s==INVALID_SOCKET) return TCP4U_ERROR;\n Rc = TcpRecv (s, (LPSTR) & nToBeReceived, 2, uTimeOut, hLogFile);\n if (Rc0 && nReceived= TCP4U_SUCCESS)\n {\n if (IsBadWritePtr (szBuf, nToBeReceived)) nUpRc = TCP4U_BUFFERFREED;\n else memcpy (szBuf, p, nUpRc=nToBeReceived);\n }\n Free (p);\n\n Tcp4uLog (LOG4U_EXIT, \"TcpPPRecv\");\nreturn nUpRc;\n} /* TcpPPRecv */\n\n\n\n/* -------------------------------------------------------------- */\n/* TcpPPSend : Envoi de uBufSize octets vers le distant */\n/* Retourne TCP4U_ERROR ou TCP4U_SUCCESS */\n/* -------------------------------------------------------------- */\nint API4U TcpPPSend (SOCKET s, LPCSTR szBuf, unsigned uBufSize, HFILE hLogFile)\n{\nint Rc;\nunsigned short Total;\n\n Tcp4uLog (LOG4U_PROC, \"TcpPPSend on socket %d. %d bytes to send\", s, uBufSize);\n\n if (s==INVALID_SOCKET) return TCP4U_ERROR;\n /* Envoi de la longueur de la trame sur 2 octets */\n Total = htons ((unsigned short) uBufSize);\n Rc = TcpSend (s, (void far *) & Total, 2, FALSE, hLogFile);\n\n /* cas d'une sequence vide -> envoi de 0 OK: retour OK */\n if (Rc>=TCP4U_SUCCESS && uBufSize>0)\n /* maintenant on envoie la sequence (qui n'est pas vide) */\n Rc = TcpSend (s, szBuf, uBufSize, FALSE, hLogFile);\n\n Tcp4uLog (LOG4U_EXIT, \"TcpPPSend\");\nreturn Rc;\n} /* TcpPPSend */\n\n\n\n\n/* ******************************************************************* */\n/* */\n/* Partie III : Lecture Jusqu'a ... */\n/* */\n/* */\n/* ******************************************************************* */\n\n\n\n/* ------------------------------------------------------------ */\n/* TcpRecvUntilStr */\n/* Recois des donnees jusqu'a */\n/* - Une erreur */\n/* - Une Fermeture de socket */\n/* - un timeout */\n/* - la reception de la chaine szStop */\n/* - le remplissage du buffer */\n/* Le Retour soit un code d'erreur, soit TCP4U_SUCCESS */\n/* Si c'est TCP4U_OVERFLOW, uBufSize octes ont iti lus, mais */\n/* la chaine szStop n'a pas iti trouvie */\n/* Si c'est TCP4U_SOCKETCLOSED, le distant a ferme la connexion */\n/* La chaine szStop n'est pas ajoutie au buffer */\n/* lpBufSize contient le nombre d'octets lus */\n/* NOTE: Cette fonction est incompatible avec La pile de Novell */\n/* LAN Workplace */\n/* ------------------------------------------------------------ */\n\n/* redeclaration de tolower: MSCV2 semble avoir des problemes avec */\nstatic char ToLower (char c)\n{\nreturn (c>='A' && c<='Z') ? c + ('a' -'A') : c;\n} /* ToLower */\n\n/* compare les chaines s1 et s2 sur nLength caracteres */\n/* retourne TRUE si les deux chaines sont identiques */\nstatic BOOL uMemcmp (LPSTR s1, LPSTR s2, int nLength, BOOL bCaseSensitive)\n{\nint Evan;\n if (bCaseSensitive)\n return memcmp (s1, s2, nLength)==0;\n else\n {\n for (Evan=0 ; Evan=ns2-*npProx && uMemcmp (s1, & s2[*npProx], ns2-*npProx, bCaseSensitive))\n { return 0; }\n } /* traitement des antecedents */\n\n for ( Ark=0, bNotFound=TRUE;\n Ark<=ns1-ns2 && (bNotFound= ! uMemcmp (& s1[Ark], s2, ns2, bCaseSensitive)) ;\n Ark++) ; /* recherche de s2 */\n if (bNotFound)\n {\n for ( *npProx = min (ns1, ns2-1) ;\n *npProx>0 && !uMemcmp (& s1[ns1-*npProx], s2, *npProx, bCaseSensitive);\n (*npProx)-- );\n }\nreturn bNotFound ? -1 : Ark; /* si bNotFounf, *npProx est positionne */\n} /* FindPos */\n\nint API4U TcpRecvUntilStr (SOCKET s, LPSTR szBuf,unsigned far *lpBufSize,\n LPSTR szStop, unsigned uStopSize, BOOL bCaseSensitive,\n unsigned uTimeOut, HFILE hLogFile)\n{\nint Rc;\n Tcp4uLog ( LOG4U_PROC, \n \"TcpRecvUntilStr on socket %d. Timeout %d, buffer %d bytes\", \n s, uTimeOut, *lpBufSize);\n Rc = InternalTcpRecvUntilStr (s, szBuf, lpBufSize, szStop, uStopSize, \n bCaseSensitive, uTimeOut, hLogFile);\n if (Rc==TCP4U_SUCCESS) Tcp4uDump (szBuf, *lpBufSize, DUMP4U_RCVD);\n if (Rc==TCP4U_OVERFLOW) Tcp4uDump (szBuf, *lpBufSize, \"Overflow\");\n Tcp4uLog (LOG4U_EXIT, \"TcpRecvUntilStr\");\nreturn Rc;\n} /* TcpRecvUntilStr */\n\n\nint InternalTcpRecvUntilStr (SOCKET s, LPSTR szBuf,unsigned far *lpBufSize,\n LPSTR szStop, unsigned uStopSize, BOOL bCaseSensitive,\n unsigned uTimeOut, HFILE hLogFile)\n{\nunsigned uNbRecus;\nstatic int nProxy; /* Proxy sert si clef partagee sur 2 trames */\nLPSTR pTest = NULL;\nint Rc;\nint Idx;\n\n#define XX_RETURN(x,s) \\\n{ if (pTest!=NULL) Free(pTest); \\\n *lpBufSize=uNbRecus; \\\n Tcp4uLog (LOG4U_ERROR, IsCancelled() ? \"call cancelled\" : s); \\\n return IsCancelled() ? TCP4U_CANCELLED : x; }\n\n if (s==INVALID_SOCKET || *lpBufSize==0) return TCP4U_ERROR;\n /* On prend un buffer qui permet de lire la trame, */\n /* la chaine de stop et qui soit toujours 0-terminee */\n /* Le recv suivant est sur de ne pas bloquer, vu que */\n /* le PEEK a rendu OK */\n pTest = Calloc (*lpBufSize+uStopSize+1, 1);\n if (pTest==NULL) return TCP4U_INSMEMORY;\n uNbRecus = 0;\n do\n {\n Rc = InternalTcpRecv (s, NULL, 0, uTimeOut, HFILE_ERROR);\n /* ereur select */\n if (Rc != TCP4U_SUCCESS) XX_RETURN (Rc, \"Timeout\");\n\n /* Lecture en MSG_PEEK */\n Tcp4uLog (LOG4U_CALL, \"recv on socket %d. MSG_PEEK, buffer %d bytes\", \n s, *lpBufSize + uStopSize - uNbRecus);\n Rc = recv (s, & pTest[uNbRecus], *lpBufSize+uStopSize-uNbRecus, MSG_PEEK);\n if (Rc<=0) XX_RETURN (Rc, \"TcpRecvUntilStr\");\n\n /* --- Maintenant on distingue 2 cas: */\n /* Cas 1 : la clef est dans le buffer, */\n Idx = FindPos (& pTest[uNbRecus], Rc, szStop, uStopSize, \n & nProxy, bCaseSensitive);\n if (Idx!=-1) /* la clef est disponible -> pas de probleme */\n {\n if ( IsBadWritePtr (& szBuf[uNbRecus], Idx) )\n XX_RETURN (TCP4U_BUFFERFREED, \"TcpRecvUntilStr: invalid pointer\")\n else\n {\n if (Idx!=0)\n {\n InternalTcpRecv (s, & szBuf[uNbRecus], Idx, 0, hLogFile);\n uNbRecus += Idx;\n }\n else uNbRecus -= nProxy;\n *lpBufSize = uNbRecus;\n InternalTcpRecv (s, pTest, uStopSize - (Idx==0 ? nProxy:0), \n 0, hLogFile);\n nProxy = 0; /* pour la prochaine recherche */\n Free (pTest);\n return TCP4U_SUCCESS;\n }\n } /* chaine trouvee */\n else\n /* Cas 2 : la clef n'est pas dans le buffer */\n {int nToBeReceived = min (Rc, (signed) (*lpBufSize-uNbRecus));\n if (IsBadWritePtr (& szBuf[uNbRecus], nToBeReceived) )\n { \n Free (pTest);\n Tcp4uLog (LOG4U_ERROR, \"TcpRecvUntilStr: invalid pointer\");\n return TCP4U_BUFFERFREED; \n }\n else\n {\n InternalTcpRecv (s, & szBuf[uNbRecus], nToBeReceived , 0, hLogFile);\n uNbRecus += nToBeReceived;\n }\n } /* chaine pas trouvee */\n }\n while (uNbRecus<*lpBufSize);\n Free (pTest);\n *lpBufSize = uNbRecus;\n\n#undef XX_RETURN\nreturn TCP4U_OVERFLOW;\n} /* InternalTcpRecvUntilStr */\n\n#include \"StdAfx.h\"\r\n#include \"InitMan.h\"\r\n\r\n\r\n\r\n#include \"Dll_Tools.h\"\r\n#include \"vt_python_funcs.h\"\r\n\r\nstatic vt_python_man *_im;\r\n\r\n#include \"PythonModule.h\"\r\n#ifdef RegisterClassA\r\n#undef RegisterClassA\r\n#endif\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \r\nvt_python_man::vt_python_man(CKContext* context):CKBaseManager(context,INIT_MAN_GUID,\"vt_python_man\")//Name as used in profiler\r\n{\r\n\tm_Context->RegisterNewManager(this);\r\n\t_im = this;\r\n}\r\n\r\nvoid\r\nvt_python_man::RegisterVSL(){\r\n\r\n\t\t\r\n\t\tSTARTVSLBIND(m_Context)\r\n\r\n\t\tDECLAREPOINTERTYPE(PythonModule)\r\n\r\n\t\tDECLARESTATIC_3(PythonModule,PythonModule*,CreatePythonModule,const char*,const char*,int)\r\n\r\n\r\n DECLAREFUN_C_0(void,vpCInit)\r\n\t\tDECLAREFUN_C_1(void,vpCPyRun_SimpleString,const char*)\r\n\t\t//DECLAREFUN_S_3(const char*,vpSimpleTest,const char*,const char*,const char*)\r\n\t\tDECLAREFUN_C_0(void,DestroyPython)\r\n\t\tDECLAREFUN_C_0(void,PythonLoad)\r\n \r\n\t\t\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Variable|Parameter Stuff */\r\n\t\t/************************************************************************/\r\n\r\n\t\t\r\n\t\t//DECLAREFUN_C_3(BOOL,VT_SetVariableValue,const char*, int,bool )\r\n\t\t\r\n\r\n\r\n\t\t//DECLAREFUN_C_1(BOOL,ImportVars,const char*)\r\n\t\t/*DECLAREFUN_C_4(BOOL, WriteIniValue, const char* ,const char*,const char*,const char*)\r\n\t\tDECLAREFUN_C_1(BOOL, CreatePath,const char*)\r\n\t\tDECLAREFUN_C_0(void, testAll)\r\n\r\n\t\tDECLAREFUN_C_2(BOOL, ShowNodalDebug,CKGroup*,BOOL)*/\r\n\r\n\r\n\t\t\t\t\r\n\t\t\r\n\tSTOPVSLBIND\r\n\r\n\t\t\r\n\r\n\r\n}/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetInMidiPort\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateSetInMidiPortProto(CKBehaviorPrototype **);\r\nint SetInMidiPort(const CKBehaviorContext& behcontext);\r\nCKERROR SetInMidiPortCallBack(const CKBehaviorContext& behcontext); // CallBack Functioon\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorSetInMidiPortDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Midi Input Port\");\t\r\n\tod->SetDescription(\"Sets the Midi Input Port (usally 0).\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE );\r\n\tod->SetGuid(CKGUID(0x42d96c11,0x64242546));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetInMidiPortProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Midi\");\r\n\treturn od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateSetInMidiPortProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Midi Input Port\");\r\n if(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Midi Input Port\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetInMidiPort);\r\n\r\n proto->SetBehaviorCallbackFct( SetInMidiPortCallBack );\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint SetInMidiPort(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n beh->ActivateInput(0, FALSE);\r\n beh->ActivateOutput(0);\r\n\r\n mm->DesiredmidiDevice = 0;\r\n beh->GetInputParameterValue(0, &mm->DesiredmidiDevice);\r\n\r\n return CKBR_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR SetInMidiPortCallBack(const CKBehaviorContext& behcontext){\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n \r\n switch( behcontext.CallbackMessage ){\r\n\r\n case CKM_BEHAVIORATTACH:\r\n case CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tmm->AddMidiBBref();\r\n\t\t} break;\r\n case CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tmm->RemoveMidiBBref();\r\n\t\t} break;\r\n \r\n }\r\n \r\n return CKBR_OK; \r\n}\r\n/******************************************************************************\r\nFile : CustomPlayerDefines.h\r\n\r\nDescription: This file contains some defines/enums/types used by the project.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#if !defined(CUSTOMPLAYERDEFINES_H)\r\n#define CUSTOMPLAYERDEFINES_H\r\n\r\n\r\n/************************************************************************/\r\n/* Error Codes : */\r\n/************************************************************************/\r\n\r\n#define INIT_ERROR\t\t\t\t\t\t\"Initialisation Error\"\r\n#define CANNOT_READ_CONFIG\t\t\t\t\"Cannot read configuration/command line.\\nPlayer will quit!\"\r\n#define FAILED_TO_CREATE_WINDOWS\t\t\"Unable to create windows.\\nPlayer will quit!\"\r\n#define UNABLE_TO_INIT_PLUGINS\t\t\t\"Unable to initialize plugins.\\nPlayer will quit!\"\r\n#define UNABLE_TO_LOAD_RENDERENGINE\t\t\"Unable to load a RenderEngine.\\nPlayer will quit!\"\r\n#define UNABLE_TO_INIT_CK\t\t\t\t\"Unable to initialize CK Engine.\\nPlayer will quit!\"\r\n#define UNABLE_TO_INIT_MANAGERS\t\t\t\"Unable to initialize Managers.\\nPlayer will quit!\"\r\n#define UNABLE_TO_INIT_DRIVER\t\t\t\"Unable to initialize display driver.\\nPlayer will quit!\"\r\n#define UNABLE_TO_CREATE_RENDERCONTEXT\t\"Cannot initialize RenderContext.\\nPlayer will quit!\"\r\n#define CANNOT_FIND_LEVEL\t\t\t\t\"Cannot find Level.\\nPlayer will quit!\"\r\n\r\n#define MAINWINDOW_TITLE\t\t\t\t\"Virtools Custom Player\"\r\n#define MAINWINDOW_CLASSNAME\t\t\t\"CustomPlayer\"\r\n#define RENDERWINDOW_CLASSNAME\t\t\t\"CustomPlayerRender\"\r\n#define MISSINGUIDS_LOG\t\t\t\t\t\"CustomPlayerMissingGuids.log\"\r\n\r\n\r\n\r\n// [11/28/2007 mc007] //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\tPROFILE LOAD ERRORS\r\n//\r\n#define CPE_OK 0\r\n#define CPE_PROFILE_STARTING_ERROR 0\r\n#define CPE_PROFILE_ERROR_FILE_ERROR\t\t\t\t\t\t\t\t\t\t\t\t\t(CPE_PROFILE_STARTING_ERROR + 10)\r\n\r\n#define CPE_PROFILE_ERROR_FILE_INCORRECT\t\t\t\t\t\t\t\t\t\t\t(CPE_PROFILE_ERROR_FILE_ERROR + 1)\r\n#define CPE_PROFILE_ERROR_FILE_INCORRECT_DESC\t\t\t\t\t\t\t\t\t\"Couldnt Load File\"\r\n\r\n#define CPE_PROFILE_ERROR_ENTRY_INCORRECT\t\t\t\t\t\t\t\t\t\t\t(CPE_PROFILE_ERROR_FILE_ERROR + 2)\r\n#define CPE_PROFILE_ERROR_ENTRY_INCORRECT_DESC\t\t\t\t\t\t\t\t\t\"Couldnt find entry\"\r\n\r\n#define CPE_PROFILE_ERROR_PROFILEID_INCORRECT_PARAM (CPE_PROFILE_ERROR_FILE_ERROR + 2)\r\n#define CPE_PROFILE_ERROR_PROFILEID_INCORRECT_PARAM_DESC \"Missing or incorrect parameter provided\"\r\n\r\n\r\n#define CUSTOM_PLAYER_CONFIG_FILE\t\"player.ini\"\r\n\r\n// [12/15/2007 mc007]\t//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\tApplication Requirements :\r\n\r\n#define CPR_CHECK_DIRECTX\t1\t\t//\tthis leads to a directx check, is using xUtils.dll\r\n#define CPR_MINIMUM_DIRECTX_VERSION 9\t\t// this is our minimum version\r\n#define CPR_MINIMUM_DIRECTX_VERSION_FAIL_URL\t\"http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=2da43d38-db71-4c1b-bc6a-9b6652cd92a3\"\r\n#define CPR_OFFER_INTERNAL_DIRECTX_INSTALLER 0\t\t// not implemented \r\n\r\n#define CPR_CHECK_RAM\t1\t//performes a memory check, is using xUtils.dll and it needs a directx !!!\r\n#define CPR_MINIMUM_RAM\t256\t//our minimum pRam\r\n#define CPR_MINIMUM_RAM_FAIL_ABORT 0\t// this leads to a application exit !\r\n\r\n\r\n#define CP_SUPPORT_EMAIL \"\" // \r\n\r\n// [12/16/2007 mc007]\t//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\tApplication Features : \r\n\r\n\r\n#define CPF_SPLASH_FILE\t\"splash.bmp\" //not used !\r\n#define CPF_SPLASH_TEXT_TYPE\t\"MicrogrammaDBolExt\" \r\n#define CPF_SPLASH_TEXT_FORMAT (DT_SINGLELINE | DT_RIGHT | DT_BOTTOM)\r\n\r\n\r\n\r\n// [12/17/2007 mc007]\r\n#define CPA_SHOW_ABOUT_TAB 1\t//adds an about tab, is using about.txt from \\project source folder \\res\r\n#define CPA_SHOW_LICENSE_TAB 0\t//adds an about tab, is using license.txt from \\project source folder \\res\r\n#define CPA_SHOW_ERROR_TAB 1\r\n#define CPA_ABORT_ON_ERROR 1\t// aborts when the requirements are failing\r\n\r\n//////////////////////////////////////////////////////////////////////////\t\r\n\r\n\r\n#define PUBLISHING_RIGHT_TITLE\t\t\"AtlantisVR.com\"\r\n#define PUBLISHING_RIGHT_TEXT\t\\\r\n\t\"Click Okay for hooray\\n\"\t\\\r\n\t\"code prior to compilation).\\n\\n\"\t\\\r\n\t\"This dialog box serves to remind you that publishing rights, a.k.a. runtime\\n\"\t\\\r\n\t\"fees, are due when building any custom executable (like the player you just\\n\"\t\\\r\n\t\"compiled). Contact for more information.\\n\"\r\n\r\n\r\nenum EConfigPlayer\r\n{\r\n\teAutoFullscreen\t= 1,\t// -auto_fullscreen (or -f) on command line\r\n\teDisableKeys\t= 2\t\t// -disable_keys (or -d) on command line\r\n};\r\n\r\n#endif // CUSTOMPLAYERDEFINES_H#ifndef __P_ERRROR_STREAM_H__\r\n#define __P_ERRROR_STREAM_H__\r\n\r\n#include \"pTypes.h\"\r\n#include \"NxUserOutputStream.h\"\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\nclass pErrorStream : public NxUserOutputStream\r\n{\r\n\r\npublic:\r\n\tpErrorStream(){}\r\n\tvoid reportError(NxErrorCode e, const char* message, const char* file, int line);\r\n\tNxAssertResponse reportAssertViolation(const char* message, const char* file, int line);\r\n\tvoid print(const char* message);\r\n};\r\n\r\n}\r\n\r\n#endif#include \"BaseMacros.hpp\"\r\n#include \"pch.h\"\r\n#include \"CKAll.h\"\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n\tAPI_EXPORT int API_cDECL InitPyVTModule(CKContext** _ctx);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#include \r\nusing namespace std;\r\n\r\n#include \r\nnamespace python = boost::python;\r\n\r\nclass Player\r\n{\r\npublic:\r\n\r\n\tPlayer() {}\r\n\r\n\tPlayer( std::string name ) \r\n\t\t: m_name(name) {}\r\n\r\n\tPlayer( std::string name, int score ) \r\n\t\t: m_name(name),\r\n\t\t m_score(score) {}\r\n\r\n\tvoid setName( std::string name ) { m_name = name; }\r\n\tstd::string getName() { return m_name; }\r\n\r\n\tvoid setScore( int score ) { m_score = score; }\r\n\tint getScore() { return m_score; }\r\n\r\nprivate:\r\n\r\n\tstd::string m_name;\r\n\tint m_score;\r\n};\r\n\r\n\r\nBOOST_PYTHON_MODULE( PyVT )\r\n{\t\r\n\r\n\tpython::class_(\"Player\")\r\n\t\t.def( python::init() ) // Overloaded constructor version #1\r\n\t\t.def( python::init() ) // Overloaded constructor version #2\r\n\t\t.def( \"setName\", &Player::setName )\r\n\t\t.def( \"getName\", &Player::getName )\r\n\t\t.def( \"setScore\", &Player::setScore )\r\n\t\t.def( \"getScore\", &Player::getScore )\r\n\t\t;\r\n}\r\n\r\n\r\n\r\nBOOL APIENTRY DllMain( HANDLE hModule, \r\n\t\t\t\t\t DWORD ul_reason_for_call, \r\n\t\t\t\t\t LPVOID lpReserved\r\n\t\t\t\t\t )\r\n{\r\n\r\n\r\n\r\n\r\n\tswitch (ul_reason_for_call)\r\n\t{\r\n\tcase DLL_PROCESS_ATTACH:\t \r\n\t\t{\r\n\t\t//DisableThreadLibraryCalls(NULL);\r\n\t\t//MessageBox(NULL,\"\",\"attach\",0);\r\n\r\n\t\t//\tint y = 0;\r\n\r\n\r\n\t\t}\r\n\r\n\tcase DLL_THREAD_ATTACH:\r\n\tcase DLL_THREAD_DETACH:\r\n\tcase DLL_PROCESS_DETACH:\r\n\t\tbreak;\r\n\t}\r\n\treturn TRUE;\r\n}\r\n\r\n#include \"pch.h\"\r\n#include \"CKAll.h\"\r\nCKContext *mctx=NULL;\r\n\r\nint InitPyVTModule(CKContext ** _ctx)\r\n{\r\n\t//MessageBox(NULL,\"\",\"asd\",0);\r\n\t\r\n\tDebugBreak();\r\n\tif( PyImport_AppendInittab( \"PyVT\", initPyVT ) == -1 )\r\n\t\tthrow runtime_error( \"Failed to add \\\"testDerived\\\" to the \"\r\n\t\t\"interpreter's built-in modules\" );\r\n\r\n\r\n\tif(*_ctx)\r\n\t{\r\n\t\t\r\n\t\tmctx = *_ctx;\r\n\t\tmctx->OutputToConsole(\"ASDASD\");\r\n\t\tprintf((\"asdasdasd\"));\r\n\t\treturn 1;\r\n\t}\r\n\treturn 0;\r\n}\t/********************************************************************\r\n\tcreated:\t2007/11/28\r\n\tcreated:\t28:11:2007 16:25\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\\CustomPlayerConfigurationDialog.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Dialogs\r\n\tfile base:\tCustomPlayerConfigurationDialog\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\r\n//\r\n//\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\n\r\n\r\n\r\nvtPlayer::Structs::xEApplicationMode\r\nCCustomPlayer::PGetApplicationMode(const char* pstrCommandLine)\r\n{\r\n\r\n\tusing namespace vtPlayer::Structs;\r\n\t\r\n\t// Skip the first part of the command line, which is the full path \r\n\t// to the exe. If it contains spaces, it will be contained in quotes.\r\n\tif (*pstrCommandLine == TEXT('\\\"'))\r\n\t{\r\n\t\tpstrCommandLine++;\r\n\t\twhile (*pstrCommandLine != TEXT('\\0') && *pstrCommandLine != TEXT('\\\"'))\r\n\t\t\tpstrCommandLine++;\r\n\t\tif( *pstrCommandLine == TEXT('\\\"') )\r\n\t\t\tpstrCommandLine++;\r\n\t}\r\n\telse\r\n\t{\r\n\t\twhile (*pstrCommandLine != TEXT('\\0') && *pstrCommandLine != TEXT(' '))\r\n\t\t\tpstrCommandLine++;\r\n\t\tif( *pstrCommandLine == TEXT(' ') )\r\n\t\t\tpstrCommandLine++;\r\n\t}\r\n\r\n\t// Skip along to the first option delimiter \"/\" or \"-\"\r\n\twhile ( *pstrCommandLine != TEXT('\\0') && *pstrCommandLine != TEXT('/') && *pstrCommandLine != TEXT('-') )\r\n\t\tpstrCommandLine++;\r\n\r\n\t// If there wasn't one, then must be config mode\r\n\tif ( *pstrCommandLine == TEXT('\\0') )\r\n\t\treturn normal;\r\n\r\n\t// Otherwise see what the option was\r\n\tswitch ( *(++pstrCommandLine) )\r\n\t{\r\n\tcase 'p':\r\n\tcase 'P':\r\n\t\tpstrCommandLine++;\r\n\t\twhile ( *pstrCommandLine && !isdigit(*pstrCommandLine) )\r\n\t\t\tpstrCommandLine++;\r\n\t\tif ( isdigit(*pstrCommandLine) )\r\n\t\t{\r\n#ifdef _WIN64\r\n\t\t\tCHAR strCommandLine[2048];\r\n\t\t\tDXUtil_ConvertGenericStringToAnsiCb(strCommandLine, pstrCommandLine, sizeof(strCommandLine));\r\n\t\t\tm_hWndParent = (HWND)(_atoi64(strCommandLine));\r\n#else\r\n\t\t\tm_hWndParent = (HWND)LongToHandle(_ttol(pstrCommandLine));\r\n\r\n#endif\r\n\t\t}\r\n\t\treturn preview;\r\n\r\n\t\t// call config dialog : \r\n\t\tcase 'C':\r\n\t\tcase 'c':\r\n\t\t\treturn config;\r\n\t\tcase 'D':\r\n\t\tcase 'd':\r\n\t\t\treturn popup;\r\n\t\tbreak;\r\n\tdefault:\r\n\t\t// All other options => run the screensaver (typically this is \"/s\")\r\n\t\treturn normal;\r\n\t}\r\n\treturn normal;\r\n}\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xMessageTypes.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSetParametersDecl();\r\nCKERROR CreateNSetParametersProto(CKBehaviorPrototype **);\r\nint NSetParameters(const CKBehaviorContext& behcontext);\r\nCKERROR NSetParametersCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_MIN_MANAGER,\r\n\tBB_IP_MIN_MESSAGE_TICK,\r\n\tBB_IP_MESSAGE_TIMEOUT,\r\n\tBB_IP_CONNECTION_TIMEOUT,\r\n\tBB_IP_PACKET_LOSS,\r\n\tBB_IP_LATENCY,\r\n\tBB_IP_MIN_SEND_PERIOD,\r\n\tBB_IP_MIN_RECV_PERIOD,\r\n\tBB_IP_MAX_SEND_BANDWITH,\r\n\tBB_IP_MAX_RECV_BANDWITH\r\n\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_ERROR,\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_ERROR,\r\n};\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSetParametersDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSetParameters\");\t\r\n\tod->SetDescription(\"Sends a Message to a Network.\");\r\n\t\r\n\tod->SetCategory(\"TNL/Misc\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7dc37c6f,0x524f7732));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNSetParametersProto);\r\n\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNSetParametersProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSetParameters\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Min Tick Time Manager\", CKPGUID_FLOAT, \"50\");\r\n\tproto->DeclareInParameter(\"Min Tick Time Message Send\", CKPGUID_FLOAT, \"50\");\r\n\tproto->DeclareInParameter(\"Message Timeout\", CKPGUID_FLOAT, \"300\");\r\n\tproto->DeclareInParameter(\"Connection Timeout\", CKPGUID_FLOAT, \"3000\");\r\n\tproto->DeclareInParameter(\"Packet Loss\", CKPGUID_FLOAT, \"0.1\");\r\n\tproto->DeclareInParameter(\"Latency\",CKPGUID_INT, \"100\");\r\n\tproto->DeclareInParameter(\"MinPacketSendPeriod\",CKPGUID_INT,\"50\");\r\n\tproto->DeclareInParameter(\"MinPacketRecvPeriod\",CKPGUID_INT,\"50\");\r\n\tproto->DeclareInParameter(\"MaxSendBandwidth\",CKPGUID_INT,\"2000\");\r\n\tproto->DeclareInParameter(\"MaxRecvBandwidth\",CKPGUID_INT,\"2000\");\r\n\r\n\tproto->DeclareSetting(\"Only Client\", CKPGUID_BOOL, \"FALSE\");\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\t\r\n\tproto->SetFunction(NSetParameters);\r\n\tproto->SetBehaviorCallbackFct(NSetParametersCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NSetParameters(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tbbNoError(E_NWE_OK);\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tfloat minManagerTick = GetInputParameterValue(beh,BB_IP_MIN_MANAGER);\r\n\tfloat messageTick = GetInputParameterValue(beh,BB_IP_MIN_MESSAGE_TICK);\r\n\tfloat messageTimeout = GetInputParameterValue(beh,BB_IP_MESSAGE_TIMEOUT);\r\n\tfloat connectionTimeout = GetInputParameterValue(beh,BB_IP_CONNECTION_TIMEOUT);\r\n\tfloat packetLoss = GetInputParameterValue(beh,BB_IP_PACKET_LOSS);\r\n\tint latency = GetInputParameterValue(beh,BB_IP_LATENCY);\r\n\r\n\tint MinPacketSendPeriod = GetInputParameterValue(beh,BB_IP_MIN_SEND_PERIOD);\r\n\tint MinPacketRecvPeriod = GetInputParameterValue(beh,BB_IP_MIN_RECV_PERIOD);\r\n\tint MaxSendBandwidth = GetInputParameterValue(beh,BB_IP_MAX_SEND_BANDWITH);\r\n\tint MaxRecvBandwidth = GetInputParameterValue(beh,BB_IP_MAX_RECV_BANDWITH);\r\n\r\n\tint clientOnly = false;\r\n\tbeh->GetLocalParameterValue(0,&clientOnly);\r\n\r\n\t//void NetConnection::\r\n\t//setFixedRateParameters(U32 minPacketSendPeriod, U32 minPacketRecvPeriod, U32 maxSendBandwidth, U32 maxRecvBandwidth)\r\n\t//setFixedRateParameters(50, 50, 2000, 2000);\r\n\r\n\tif (minManagerTick < 50)\r\n\t{\r\n\t\tminManagerTick = 50.0f;\r\n\t}\r\n\tif (messageTick < 50)\r\n\t{\r\n\t\tmessageTick = 50.0f;\r\n\t}\r\n\tif (messageTimeout< 150)\r\n\t{\r\n\t\tmessageTimeout = 150.0f;\r\n\t}\r\n\tif (connectionTimeout < 200.0f)\r\n\t{\r\n\t\tconnectionTimeout = 200.0f;\r\n\t}\r\n\tif (latency < 0)\r\n\t{\r\n\t\tlatency = 0;\r\n\t}\r\n\tif (packetLoss < 0.0f)\r\n\t{\r\n\t\tpacketLoss = 0.0f;\r\n\t}\r\n\tif (packetLoss > 1.0f)\r\n\t{\r\n\t\tpacketLoss= 1.0f;\r\n\t}\r\n\r\n\r\n\tGetNM()->setMinTickTime(minManagerTick);\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (cin)\r\n\t{\r\n\t\tif (cin->isValid())\r\n\t\t{\r\n\t\t\tvtConnection *con = cin->getConnection();\r\n\t\t\tif (con)\r\n\t\t\t{\r\n\t\t\t\tcon->setSimulatedNetParams(packetLoss,latency);\r\n\t\t\t\tcon->setPingTimeouts(connectionTimeout,3);\r\n\t\t\t\tcin->setFixedRateParameters(MinPacketSendPeriod,MinPacketRecvPeriod,MaxSendBandwidth,MaxRecvBandwidth,false);\r\n\t\t\t}\r\n\t\t}\r\n\t\tcin->getMessagesInterface()->setMessageTimeout(messageTimeout);\r\n\t\tcin->getMessagesInterface()->setMinSendTime(messageTick);\r\n\t}\r\n\r\n\tif (!clientOnly)\r\n\t{\r\n\t\tcin = GetNM()->GetServerNetInterface();\r\n\t\tif (cin)\r\n\t\t{\r\n\t\t\tcin->getMessagesInterface()->setMessageTimeout(messageTimeout);\r\n\t\t\tcin->getMessagesInterface()->setMinSendTime(messageTick);\r\n\t\t\tcin->setFixedRateParameters(MinPacketSendPeriod,MinPacketRecvPeriod,MaxSendBandwidth,MaxRecvBandwidth,true);\r\n\t\t}\r\n\t}\r\n\t\t\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR NSetParametersCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#ifndef __vtNetEnumerations_h\r\n#define __vtNetEnumerations_h\r\n\r\n#define xBIT(x) (1 << (x)) ///< Returns value with bit x set (2^x)\r\n\r\n\r\ntypedef enum E_DV_STATE\r\n{\r\n\r\n\tE_DV_OK,\r\n\tE_DV_UPDATED\r\n};\r\nenum SuperType\r\n{\r\n\tvtSTRING = 1,\r\n\tvtFLOAT = 2,\r\n\tvtINTEGER = 3,\r\n\tvtVECTOR = 4,\r\n\tvtVECTOR2D = 5,\r\n\tvtCOLOUR = 6,\r\n\tvtMATRIX = 7,\r\n\tvtQUATERNION = 8,\r\n\tvtRECTANGLE\t\t= 9,\r\n\tvtBOX\t\t= 10,\r\n\tvtBOOL\t\t= 11,\r\n\tvtENUMERATION = 12,\r\n\tvtFLAGS = 13,\r\n\tvtFile = 14,\r\n\tvtOBJECT = 16,\r\n\tvtUNKNOWN = 17\r\n};\r\n\r\ntypedef enum E_DO_FLAGS\r\n{\r\n\tE_DO_OK=0x0000,\r\n\tE_DO_NEEDS_SEND=0x0001,\r\n};\r\n\r\n\r\ntypedef enum E_DP_FLAGS\r\n{\r\n\tE_DP_OK=0x0000,\r\n\tE_DP_NEEDS_SEND=0x0001,\r\n};\r\n\r\ntypedef enum E_DO_UPDATE_FLAGS\r\n{\r\n\tE_DO_NONE=0x0000,\r\n\tE_DO_POSITION=0x0001,\r\n\tE_DO_ROTATION=0x0002,\r\n};\r\n\r\n\r\n\r\ntypedef enum E_DO_INTERFACE_FLAGS\r\n{\r\n\tE_DO_CREATED=0x0001,\r\n\tE_DO_PROCESSED=0x0002,\r\n\tE_DO_BINDED=0x0004\r\n};\r\n\r\n\r\n\r\ntypedef enum E_XNETWORK_INTERFACE_STATUS\r\n{\r\n\r\n\tE_NI_CREATED,\r\n\tE_NI_CONNECTING,\r\n\tE_NI_CONNECTED,\r\n\tE_NI_ERROR\r\n};\r\n\r\nenum E_DO_DELETE_STATE\n{\n\tE_DO_DS_DELETED,\n\tE_DO_DS_DELETE_NOTIFIED,\n\n};\r\n\r\nenum USER_FLAG\n{\n\tUSER_NEW,\n\tUSER_OK,\n\tUSER_DELETED,\n\tUSERNAME_CHANGED,\n\tUSERNAME_OK\n};\n\n/*enum USERNAME_FLAG\n{\n\tUSERNAME_CHANGED,\n\tUSERNAME_OK\n};*/\r\n\r\n\r\ntypedef enum E_DO_OWNERSHIP_STATUS\r\n{\r\n\tE_DO_OS_OWNER,\r\n\tE_DO_OS_REQUEST,\r\n\tE_DO_OS_OTHER,\r\n\tE_DO_OS_BIND,\r\n\tE_DO_OS_RELEASED\r\n};\r\n\r\ntypedef enum E_DO_OWNERSHIP_REQUEST\r\n{\r\n\r\n\tE_DO_OSR_PROGRESS,\r\n\tE_DO_OSR_FAILED,\r\n\tE_DO_OSR_ACCEPTED\r\n};\r\n\r\ntypedef enum E_DO_CREATION_FLAGS\r\n{\r\n\r\n\tE_DO_CREATION_NONE,\r\n\tE_DO_CREATION_INCOMPLETE,\r\n\tE_DO_PENDING_ID_REQUESTED,\r\n\tE_DO_CREATION_CREATED,\r\n\tE_DO_CREATION_COMPLETE,\r\n\tE_DO_CREATION_TIMEOUT,\r\n\tE_DO_CREATION_ERROR\r\n};\r\n\r\n\r\ntypedef enum E_PREDICTION_TYPE\r\n{\r\n\r\n\tE_PTYPE_PREDICTED,\r\n\tE_PTYPE_RELIABLE,\r\n\tE_PTYPE_NON_RELIABLE\r\n};\r\n\r\n\r\n\r\n\r\ntypedef enum E_DC_BASE_TYPE\r\n{\r\n\r\n\tE_DC_BTYPE_3D_ENTITY,\r\n\tE_DC_BTYPE_2D_ENTITY,\r\n\tE_DC_BTYPE_CLIENT,\r\n\tE_DC_BTYPE_SESSION\r\n};\r\n\r\n\r\n\r\ntypedef enum E_DC_PROPERTY_TYPE\r\n{\r\n\r\n\tE_DC_PTYPE_3DVECTOR,\r\n\tE_DC_PTYPE_QUATERNION,\r\n\tE_DC_PTYPE_2DVECTOR,\r\n\tE_DC_PTYPE_FLOAT,\r\n\tE_DC_PTYPE_INT,\r\n\tE_DC_PTYPE_BOOL,\r\n\tE_DC_PTYPE_STRING,\r\n\tE_DC_PTYPE_UNKNOWN,\r\n};\r\n\r\n\r\n/*\r\ntypedef enum E_DCI_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DCI_3D_NP_LOCAL_POSITION,\r\n\tE_DCI_3D_NP_LOCAL_ROTATION,\r\n\tE_DCI_3D_NP_LOCAL_SCALE,\r\n\tE_DCI_3D_NP_WORLD_POSITION,\r\n\tE_DCI_3D_NP_WORLD_ROTATION,\r\n\tE_DCI_3D_NP_WORLD_SCALE,\r\n\tE_DCI_3D_NP_VISIBILITY,\r\n\tE_DCI_3D_NP_UNKNOWN\r\n};*/\r\n\r\n\r\ntypedef enum E_DCF_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DCF_3D_NP_LOCAL_POSITION=0x0001,\r\n\tE_DCF_3D_NP_LOCAL_ROTATION=0x0002,\r\n\tE_DCF_3D_NP_LOCAL_SCALE=0x0004,\r\n\tE_DCF_3D_NP_WORLD_POSITION=0x0008,\r\n\tE_DCF_3D_NP_WORLD_ROTATION=0x0010,\r\n\tE_DCF_3D_NP_WORLD_SCALE=0x0020,\r\n\tE_DCF_3D_NP_VISIBILITY=0x0040,\r\n\tE_DCF_3D_NP_USER_0=0x0080,\r\n\tE_DCF_3D_NP_USER_1=0x0100,\r\n\tE_DCF_3D_NP_USER_2=0x0200,\r\n\tE_DCF_3D_NP_USER_3=0x0400,\r\n\tE_DCF_3D_NP_USER_4=0x0800,\r\n\r\n};\r\n\r\n\r\ntypedef enum E_DC_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DC_3D_NP_LOCAL_POSITION=1,\r\n\tE_DC_3D_NP_LOCAL_ROTATION=2,\r\n\tE_DC_3D_NP_LOCAL_SCALE=3,\r\n\tE_DC_3D_NP_WORLD_POSITION=4,\r\n\tE_DC_3D_NP_WORLD_ROTATION=5,\r\n\tE_DC_3D_NP_WORLD_SCALE=6,\r\n\tE_DC_3D_NP_VISIBILITY=7,\r\n\tE_DC_3D_NP_USER=8\r\n};\r\n/*typedef enum E_DC_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DC_3D_NP_LOCAL_POSITION=1,\r\n\tE_DC_3D_NP_LOCAL_ROTATION=2,\r\n\tE_DC_3D_NP_LOCAL_SCALE=4,\r\n\tE_DC_3D_NP_WORLD_POSITION=8,\r\n\tE_DC_3D_NP_WORLD_ROTATION=16,\r\n\tE_DC_3D_NP_WORLD_SCALE=32,\r\n\tE_DC_3D_NP_VISIBILITY=64,\r\n\tE_DC_3D_NP_USER=128\r\n};*/\r\n\r\ntypedef enum E_DO_UPDATE_STATE\r\n{\r\n\tE_DO_US_OK,\r\n\tE_DO_US_PENDING,\r\n\tE_DO_US_SEND,\r\n};\r\ntypedef enum E_C_PACKET\r\n{\r\n\tE_C_CLIENT_NONE=0x000,\r\n\tE_C_CLIENT_OBJECT_UPDATE=0x0001\r\n};\r\n\r\n\r\n#endif\r\n#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n\r\n#include \"tnlRandom.h\"\n#include \"tnlSymmetricCipher.h\"\n#include \"tnlAsymmetricKey.h\"\r\n#include \r\n#include \r\n\r\n\r\nstatic const char *localBroadcastAddress = \"IP:broadcast:28999\";\nstatic const char *localHostAddress = \"IP:127.0.0.1:28999\";\r\n\r\nTNL::SafePtrm_NetInterfaceServer = NULL;\r\nTNL::SafePtrm_NetInterfaceClient = NULL;\r\n\r\nxNetInterface* GetNetInterfaceServer() \r\n{\t\r\n\treturn m_NetInterfaceServer ; \r\n}\r\n\r\n\r\nvoid SetNetInterfaceClient(xNetInterface *cInterface)\r\n{\t\r\n\r\n\tif (m_NetInterfaceClient!=NULL)\r\n\t{\r\n\t\tm_NetInterfaceClient->destroy();\r\n\t\tdelete m_NetInterfaceClient;\r\n\t\tm_NetInterfaceClient = NULL;\r\n\t}\r\n\tm_NetInterfaceClient = cInterface;\r\n}\r\nvoid SetNetInterfaceServer(xNetInterface *cInterface)\r\n{\r\n\r\n\tif (m_NetInterfaceServer!=NULL)\r\n\t{\r\n\t\tm_NetInterfaceServer->destroy();\r\n\t\tdelete m_NetInterfaceServer;\r\n\t\tm_NetInterfaceServer = NULL;\r\n\t}\r\n\tm_NetInterfaceServer = cInterface;\r\n}\r\n\r\nxNetInterface *GetNetInterfaceClient(){\treturn m_NetInterfaceClient;}\r\n\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint\r\nvtNetworkManager::Init()\r\n{\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint vtNetworkManager::ConnectToServer(bool deleteExisting,const char *address)\r\n{\r\n\tint result = 0 ;\r\n\tif(GetNetInterfaceClient())\r\n\t{\r\n\t\tTNL::Address addr = TNL::Address(address);\r\n\t\tGetNetInterfaceClient()->setConnection(new vtConnection());\r\n\t\tGetNetInterfaceClient()->getConnection()->connect(m_NetInterfaceClient,addr,true,false);\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint vtNetworkManager::CreateClient(bool deleteExisting,int port,const char *address)\r\n{\r\n\tif (m_NetInterfaceClient && !deleteExisting )\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\tif (deleteExisting)\r\n\t{\r\n\t\tdelete m_NetInterfaceClient;\r\n\t}\r\n\r\n\tm_NetInterfaceClient = new xNetInterface(false,TNL::Address(TNL::IPProtocol, TNL::Address::Any, 0),TNL::Address(localBroadcastAddress));\r\n\t\r\n\tTNL::AsymmetricKey *theKey = new TNL::AsymmetricKey(32);\n\tm_NetInterfaceClient->setPrivateKey(theKey);\n\tm_NetInterfaceClient->setRequiresKeyExchange(true);\r\n\tm_NetInterfaceClient->initBaseClasses(0);\r\n\r\n\t\r\n\tif (m_NetInterfaceClient)\r\n\t{\r\n\t\tm_NetInterfaceClient->getDistObjectInterface()->setNetInterface(m_NetInterfaceClient);\r\n\t\treturn 1;\r\n\t}else\r\n\t\treturn 0;\r\n\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint vtNetworkManager::CreateServer(bool deleteExisting,int port,const char *address)\r\n{\r\n\t/*if (m_NetInterfaceServer && !deleteExisting )\r\n\t{\r\n\t\treturn 0;\r\n\t}*/\r\n\r\n\tif (deleteExisting && m_NetInterfaceServer)\r\n\t{\r\n\t\tSetServerNetInterface(NULL);\r\n\t}\r\n\r\n\tTNL::Address add(address);\r\n\tm_NetInterfaceServer = new xNetInterface(true,add,TNL::Address(localBroadcastAddress));\r\n\tif (m_NetInterfaceServer)\r\n\t{\r\n\r\n\t\tTNL::Socket *socket = &m_NetInterfaceServer->getSocket();\r\n\t\tif (socket)\r\n\t\t{\r\n\t\t\tif (!socket->isValid())\r\n\t\t\t{\r\n\t\t\t\tSetServerNetInterface(NULL);\r\n\t\t\t\treturn E_NWE_INVALID_PARAMETER;\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tTNL::AsymmetricKey *theKey = new TNL::AsymmetricKey(32);\n\tm_NetInterfaceServer->setPrivateKey(theKey);\r\n\tm_NetInterfaceServer->setRequiresKeyExchange(false);\r\n\tm_NetInterfaceServer->initBaseClasses(0);\r\n\r\n\tif (m_NetInterfaceServer)\r\n\t{\r\n\t\tGetNetInterfaceServer()->setAllowsConnections(true);\r\n\r\n\t}\r\n\r\n\treturn E_NWE_OK;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint \r\nvtNetworkManager::CreateLocalConnection()\r\n{\r\n\r\n\tint result = 0 ; \r\n\tif (localConnection)\r\n\t{\r\n\t\tdelete localConnection;\r\n\t}\r\n\r\n\tif (GetNetInterfaceServer())\t\r\n\t\tCreateClient(true,0,localHostAddress);\r\n\r\n\r\n\tif (GetNetInterfaceClient() && GetNetInterfaceServer())\r\n\t{\r\n\t\tGetNetInterfaceClient()->setConnection(new vtConnection());\r\n\t\tresult = GetNetInterfaceClient()->getConnection()->connectLocal(m_NetInterfaceClient,m_NetInterfaceServer);\r\n\t}\r\n\treturn result;\r\n}\r\n/*****************************************************************************\r\n*\r\n* THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF\r\n* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\r\n* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR\r\n* A PARTICULAR PURPOSE.\r\n*\r\n* Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.\r\n*\r\n******************************************************************************\r\n*\r\n* SMF.H\r\n*\r\n* Public include file for Standard MIDI File access routines.\r\n*\r\n*****************************************************************************/\r\n\r\n#ifndef _SMF_\r\n#define _SMF_\r\n\r\n//#include \"global.h\" \r\n\r\ntypedef DWORD SMFRESULT;\r\ntypedef DWORD TICKS;\r\ntypedef TICKS *PTICKS;\r\ntypedef BYTE *HPBYTE;\r\n\r\n#define MAX_TICKS ((TICKS)0xFFFFFFFFL)\r\n\r\n#define SMF_SUCCESS (0L)\r\n#define SMF_INVALID_FILE (1L)\r\n#define SMF_NO_MEMORY (2L)\r\n#define SMF_OPEN_FAILED (3L)\r\n#define SMF_INVALID_TRACK (4L)\r\n#define SMF_META_PENDING (5L)\r\n#define SMF_ALREADY_OPEN (6L)\r\n#define SMF_END_OF_TRACK (7L)\r\n#define SMF_NO_META (8L)\r\n#define SMF_INVALID_PARM (9L)\r\n#define SMF_INVALID_BUFFER (10L)\r\n#define SMF_END_OF_FILE (11L)\r\n#define SMF_REACHED_TKMAX (12L)\r\n\r\nDECLARE_HANDLE(HSMF);\r\n\r\ntypedef struct tag_smfopenstruct\r\n{\r\n LPSTR pstrName;\r\n DWORD dwTimeDivision;\r\n HSMF hSmf;\r\n} SMFOPENFILESTRUCT,\r\n *PSMFOPENFILESTRUCT;\r\n\r\nextern SMFRESULT smfOpenFile(\r\n PSMFOPENFILESTRUCT psofs);\r\n\r\nextern SMFRESULT smfCloseFile(\r\n HSMF hsmf);\r\n\r\ntypedef struct tag_smffileinfo\r\n{\r\n DWORD dwTracks;\r\n DWORD dwFormat;\r\n DWORD dwTimeDivision;\r\n TICKS tkLength;\r\n} SMFFILEINFO,\r\n *PSMFFILEINFO;\r\n\r\nextern SMFRESULT smfGetFileInfo(\r\n HSMF hsmf,\r\n PSMFFILEINFO psfi);\r\n\r\nextern DWORD smfTicksToMillisecs(\r\n HSMF hsmf,\r\n TICKS tkOffset);\r\n\r\nextern DWORD smfMillisecsToTicks(\r\n HSMF hsmf,\r\n DWORD msOffset);\r\n\r\nextern SMFRESULT smfReadEvents(\r\n HSMF hsmf,\r\n LPMIDIHDR lpmh,\r\n TICKS tkMax);\r\n\r\nextern SMFRESULT smfSeek(\r\n HSMF hsmf,\r\n TICKS tkPosition,\r\n LPMIDIHDR lpmh);\r\n\r\nextern DWORD smfGetStateMaxSize(\r\n void);\r\n\r\n/* Buffer described by LPMIDIHDR is in polymsg format, except that it\r\n** can contain meta-events (which will be ignored during playback by\r\n** the current system). This means we can use the pack functions, etc.\r\n*/\r\n#define PMSG_META ((BYTE)0xC0)\r\n\r\n#endif\r\n#ifndef _XNET_ENUMERATIONS_H_\r\n#define _XNET_ENUMERATIONS_H_\r\n\r\n#define xBIT(x) (1 << (x)) ///< Returns value with bit x set (2^x)\r\n\r\n\r\ntypedef enum E_MESSAGE_FLAGS\r\n{\r\n\r\n\tE_MF_NEW,\r\n\tE_MF_SENDING,\r\n\tE_MF_SENT,\r\n\tE_MF_TIMEOUT,\r\n\tE_MF_FINISH,\r\n\tE_MF_OUTGOING,\r\n\tE_MF_INCOMING,\r\n\tE_MF_SEND_TO_ALL,\r\n\tE_MF_DELETED,\r\n};\r\n\r\ntypedef enum E_MESSAGE_WRITE_FLAGS\r\n{\r\n\r\n\tE_MWF_UPDATE_SERVER,\r\n\tE_MWF_SEND_SRC_USER_ID,\r\n\tE_MWF_SEND_TARGET_USER_ID,\r\n\tE_MWF_UPDATE_GHOST,\r\n\tE_MWF_SERVER_UPDATE,\r\n};\r\n\r\ntypedef enum E_MESSAGE_READ_FLAGS\r\n{\r\n\tE_MRF_UPDATE_BY_GHOST,\r\n\tE_MRF_READ_SRC_USER_ID,\r\n\tE_MRF_READ_TARGET_USER_ID,\r\n\tE_MRF_UPDATE_GHOST,\r\n\tE_MRF_SERVER_UPDATE,\r\n};\r\ntypedef enum E_OBJECT_TYPE\r\n{\r\n\r\n\tE_OT_DIST_OBJECT,\r\n\tE_OT_DIST_PROPERTY,\r\n\tE_OT_CLASS,\r\n\tE_OT_MESSAGE,\r\n};\r\n\r\ntypedef enum E_LOG_ITEMS\r\n{\r\n\r\n\tE_LI_CLIENT,\r\n\tE_LI_SESSION,\r\n\tE_LI_3DOBJECT,\r\n\tE_LI_2DOBJECT,\r\n\tE_LI_DISTRIBUTED_BASE_OBJECT,\r\n\tE_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\r\n\tE_LI_MESSAGES,\r\n\tE_LI_ARRAY_MESSAGES,\r\n\tE_LI_CONNECTION,\r\n\tE_LI_NET_INTERFACE,\r\n\tE_LI_GHOSTING,\r\n\tE_LI_STATISTICS,\r\n\tE_LI_BUILDINGBLOCKS,\r\n\tE_LI_VSL,\r\n\tE_LI_CPP,\r\n\tE_LI_ASSERTS,\r\n\tE_LI_PREDICTION,\r\n\tE_LI_SERVER_MESSAGES\r\n};\r\n\r\ntypedef enum E_LOG_FLAGS\r\n{\r\n\tE_LF_CPP_FUNCS,\r\n\tE_LF_CPP_FUNC_SIGNATURE,\r\n\tE_LF_BB_NAME,\r\n\tE_LF_BB_OWNER,\r\n\tE_LF_TIMESTAMPS,\r\n\r\n\r\n};\r\n\r\ntypedef enum E_DV_STATE\r\n{\r\n\r\n\tE_DV_OK,\r\n\tE_DV_UPDATED\r\n};\r\n\r\nenum SuperType\r\n{\r\n\tvtSTRING = 1,\r\n\tvtFLOAT = 2,\r\n\tvtINTEGER = 3,\r\n\tvtVECTOR = 4,\r\n\tvtVECTOR2D = 5,\r\n\tvtCOLOUR = 6,\r\n\tvtMATRIX = 7,\r\n\tvtQUATERNION = 8,\r\n\tvtRECTANGLE\t\t= 9,\r\n\tvtBOX\t\t= 10,\r\n\tvtBOOL\t\t= 11,\r\n\tvtENUMERATION = 12,\r\n\tvtFLAGS = 13,\r\n\tvtFile = 14,\r\n\tvtOBJECT = 16,\r\n\tvtUNKNOWN = 17\r\n};\r\n\r\ntypedef enum E_DO_FLAGS\r\n{\r\n\tE_DO_OK=0x0000,\r\n\tE_DO_NEEDS_SEND=0x0001,\r\n};\r\n\r\n\r\ntypedef enum E_DP_FLAGS\r\n{\r\n\tE_DP_OK=0x0000,\r\n\tE_DP_NEEDS_SEND=0x0001,\r\n};\r\n\r\ntypedef enum E_DO_UPDATE_FLAGS\r\n{\r\n\tE_DO_NONE=0x0000,\r\n\tE_DO_POSITION=0x0001,\r\n\tE_DO_ROTATION=0x0002,\r\n};\r\n\r\n\r\n\r\ntypedef enum E_DO_INTERFACE_FLAGS\r\n{\r\n\tE_DO_CREATED=0x0001,\r\n\tE_DO_PROCESSED=0x0002,\r\n\tE_DO_BINDED=0x0004\r\n};\r\n\r\n\r\n\r\ntypedef enum E_XNETWORK_INTERFACE_STATUS\r\n{\r\n\r\n\tE_NI_CREATED,\r\n\tE_NI_CONNECTING,\r\n\tE_NI_CONNECTED,\r\n\tE_NI_DESTROYED_BY_SERVER,\r\n\tE_NI_ERROR\r\n};\r\n\r\nenum E_DO_DELETE_STATE\n{\n\tE_DO_DS_DELETED,\n\tE_DO_DS_DELETE_NOTIFIED,\n\n};\r\n\r\nenum USER_FLAG\n{\n\tUSER_NEW,\n\tUSER_OK,\n\tUSER_DELETED,\n\tUSERNAME_CHANGED,\n\tUSERNAME_OK\n};\n\r\ntypedef enum E_DO_OWNERSHIP_STATUS\r\n{\r\n\tE_DO_OS_OWNER,\r\n\tE_DO_OS_OWNERCHANGED,\r\n\tE_DO_OS_REQUEST,\r\n\tE_DO_OS_OTHER,\r\n\tE_DO_OS_NONE,\r\n\tE_DO_OS_BIND,\r\n\tE_DO_OS_RELEASED\r\n};\r\n\r\ntypedef enum E_DO_OWNERSHIP_REQUEST\r\n{\r\n\r\n\tE_DO_OSR_PROGRESS,\r\n\tE_DO_OSR_FAILED,\r\n\tE_DO_OSR_ACCEPTED\r\n};\r\n\r\ntypedef enum E_DO_STATE_FLAGS\r\n{\r\n\tE_DOSF_UNPACKED,\r\n\tE_DOSF_SHOWN,\r\n\tE_DOSF_SESSION_LEFT,\r\n\tE_DOSF_DELETED,\r\n\tE_DOSF_INITIAL_STATE_SEND\r\n};\r\ntypedef enum E_DO_CREATION_FLAGS\r\n{\r\n\r\n\tE_DO_CREATION_NONE,\r\n\tE_DO_CREATION_INCOMPLETE,\r\n\tE_DO_PENDING_ID_REQUESTED,\r\n\tE_DO_CREATION_CREATED,\r\n\tE_DO_CREATION_COMPLETE,\r\n\tE_DO_CREATION_TIMEOUT,\r\n\tE_DO_CREATION_ERROR\r\n};\r\n\r\n\r\ntypedef enum E_PREDICTION_TYPE\r\n{\r\n\r\n\tE_PTYPE_PREDICTED,\r\n\tE_PTYPE_RELIABLE,\r\n\tE_PTYPE_NON_RELIABLE\r\n};\r\n\r\ntypedef enum E_DC_BASE_TYPE\r\n{\r\n\r\n\tE_DC_BTYPE_3D_ENTITY,\r\n\tE_DC_BTYPE_2D_ENTITY,\r\n\tE_DC_BTYPE_CLIENT,\r\n\tE_DC_BTYPE_SESSION\r\n};\r\ntypedef enum E_DC_PROPERTY_TYPE\r\n{\r\n\r\n\tE_DC_PTYPE_3DVECTOR,\r\n\tE_DC_PTYPE_QUATERNION,\r\n\tE_DC_PTYPE_2DVECTOR,\r\n\tE_DC_PTYPE_FLOAT,\r\n\tE_DC_PTYPE_INT,\r\n\tE_DC_PTYPE_BOOL,\r\n\tE_DC_PTYPE_STRING,\r\n\tE_DC_PTYPE_UNKNOWN,\r\n};\r\n\r\n\r\ntypedef enum E_DCF_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DCF_3D_NP_LOCAL_POSITION=0x0001,\r\n\tE_DCF_3D_NP_LOCAL_ROTATION=0x0002,\r\n\tE_DCF_3D_NP_LOCAL_SCALE=0x0004,\r\n\tE_DCF_3D_NP_WORLD_POSITION=0x0008,\r\n\tE_DCF_3D_NP_WORLD_ROTATION=0x0010,\r\n\tE_DCF_3D_NP_WORLD_SCALE=0x0020,\r\n\tE_DCF_3D_NP_VISIBILITY=0x0040,\r\n\tE_DCF_3D_NP_USER_0=0x0080,\r\n\tE_DCF_3D_NP_USER_1=0x0100,\r\n\tE_DCF_3D_NP_USER_2=0x0200,\r\n\tE_DCF_3D_NP_USER_3=0x0400,\r\n\tE_DCF_3D_NP_USER_4=0x0800,\r\n\r\n};\r\n\r\n\r\ntypedef enum E_DC_3D_NATIVE_PROPERTIES\r\n{\r\n\tE_DC_3D_NP_LOCAL_POSITION=1,\r\n\tE_DC_3D_NP_LOCAL_ROTATION=2,\r\n\tE_DC_3D_NP_LOCAL_SCALE=3,\r\n\tE_DC_3D_NP_WORLD_POSITION=4,\r\n\tE_DC_3D_NP_WORLD_ROTATION=5,\r\n\tE_DC_3D_NP_WORLD_SCALE=6,\r\n\tE_DC_3D_NP_VISIBILITY=7,\r\n\tE_DC_3D_NP_USER=8\r\n};\r\n\r\ntypedef enum E_DC_SESSION_NATIVE_PROPERTIES\r\n{\r\n\tE_DC_S_NP_MAX_USERS=1,\r\n\tE_DC_S_NP_PASSWORD=2,\r\n\tE_DC_S_NP_TYPE=3,\r\n\tE_DC_S_NP_LOCKED=4,\r\n\tE_DC_S_NP_NUM_USERS=5,\r\n\tE_DC_S_NP_USER=6,\r\n};\r\n\r\ntypedef enum E_DO_UPDATE_STATE\r\n{\r\n\tE_DO_US_OK,\r\n\tE_DO_US_PENDING,\r\n\tE_DO_US_SEND,\r\n};\r\ntypedef enum E_C_PACKET\r\n{\r\n\tE_C_CLIENT_NONE=0x000,\r\n\tE_C_CLIENT_OBJECT_UPDATE=0x0001\r\n};\r\n\r\n\r\ntypedef enum E_CLIENT_FLAGS\r\n{\r\n\tE_CF_CONNECTED,\r\n\tE_CF_CONNECTION_LOST,\r\n\tE_CF_SESSION_JOINED,\r\n\tE_CF_SESSION_DESTROYED,\r\n\tE_CF_REMOVED,\r\n\tE_CF_ADDING,\r\n\tE_CF_ADDED,\r\n\tE_CF_DELETING,\r\n\tE_CF_DELETED,\r\n\tE_CF_NM_FREE,\r\n\tE_CF_NM_SENDING,\r\n\tE_CF_NM_SENT,\r\n\r\n};\r\n\r\ntypedef enum E_SESSION_FLAGS\r\n{\r\n\tE_SF_INCOMPLETE,\r\n\tE_SF_PARAMETER_ATTACHED,\r\n\tE_SF_POPULATE_PARAMETERS,\r\n\tE_SF_COMPLETE,\r\n\tE_SF_LOCKED\r\n};\r\n\r\ntypedef enum E_NETWORK_ERROR\r\n{\r\n\tE_NWE_OK,\r\n\tE_NWE_INTERN,\r\n\tE_NWE_NO_CONNECTION,\r\n\tE_NWE_NO_SESSION,\r\n\tE_NWE_SESSION_WRONG_PASSWORD,\r\n\tE_NWE_SESSION_LOCKED,\r\n\tE_NWE_SESSION_EXISTS,\r\n\tE_NWE_SESSION_FULL,\r\n\tE_NWE_NOT_SESSION_MASTER,\r\n\tE_NWE_INVALID_PARAMETER,\r\n\tE_NWE_NO_SUCH_USER,\r\n\tE_NWE_DIST_CLASS_EXISTS,\r\n\tE_NWE_NO_SERVER,\r\n\tE_NWE_SESSION_ALREADY_JOINED,\r\n\tE_NWE_NO_SUCH_SESSION\r\n};\r\n\r\ntypedef enum E_OBJECT_PRINT_FLAGS\r\n{\r\n\r\n\tE_OPF_NAME,\r\n\tE_OPF_GHOST_ID,\r\n\tE_OPF_USER_ID,\r\n\tE_OPF_SESSION_ID,\r\n\tE_OPF_CLASS,\r\n\tE_OPF_NUM_PROPS,\r\n\tE_OPF_PROPS,\r\n\tE_OPF_NATIVE_PROPERTIES,\r\n\tE_OPF_USER_PROPERTIES,\r\n\tE_OPF_SESSION_LOCKED,\r\n\tE_OPF_SESSION_USERS,\r\n\tE_OPF_SESSION_NAME,\r\n\tE_OPF_SESSION_PRIVATE,\r\n\tE_OPF_SESSION_MAXUSERS,\r\n\tE_OPF_SESSION_MASTER,\r\n\tE_OPF_CLIENT_USERNAME,\r\n\tE_OPF_CLIENT_LOCAL_ADDRESS,\r\n\tE_OPF_CLIENT_LOCAL_GHOST_IDS,\r\n\tE_OPF_CLIENT_CONNECTION_SETUP,\r\n\r\n};\r\n\r\ntypedef enum E_PROPERTY_PRINT_FLAGS\r\n{\r\n\tE_PPF_NAME,\r\n\tE_PPF_VALUE_TYPE,\r\n\tE_PPF_NATIVE_TYPE,\r\n\tE_PPF_PREDICTION_TYPE,\r\n\tE_PPF_SERVER_VALUE,\r\n\tE_PPF_LAST_VALUE,\r\n\tE_PPF_CURRENT_VALUE,\r\n\tE_PPF_DIFFERENCE,\r\n\tE_PPF_MIN_TIME,\r\n\tE_PPF_MIN_THRESHOLD\r\n};\r\n\r\n#endif\r\n#ifndef __DLL_TOOLS_H__\r\n#define __DLL_TOOLS_H__\r\n\r\n#include \r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\nnamespace DllTools\r\n{\r\n\r\n\t/*************************************************************************/\r\n\t/* class : DllFunc\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\r\n\tthis is a small helper to bind an exported dll-func to a prototyyp\t\t\t\t\t\t\t\t \r\n\r\n\texample, you want to replace a load/save function for custom parameter at run-time: \r\n\r\n\ttypedef void (*_CGBLCISAVELOADFUNC_proto)(CKParameter *,CKStateChunk **,CKBOOL);\r\n\r\n\tDllFunc<_CGBLCISAVELOADFUNC_proto>CGBLCISAVELOADFUNC_proto(_T(\"proto.dll\"),\"CGBLCISAVELOADFUNC\");\r\n\r\n\r\n\tCGBLCISAVELOADFUNC_proto.Load(); // binds the func to the functor\r\n\r\n\tCGBLCISAVELOADFUNC_proto.Release(); // unbind, but keeps infos about dll-name/func.\r\n\r\n\t(*CGBLCISAVELOADFUNC_proto)(par,chunk,true); for executing .\r\n\r\n\tYou can use this for dynamic dll to vsl mapping ! : see last comment.\r\n\r\n\r\n\t*/\r\n\ttemplate class DllFunc \r\n\t{\r\n\t\tpublic:\r\n\r\n\t\tDllFunc(\tconst char* _dllName, const char* _fnName ,const bool logging = TRUE ) :\r\n\t\tdllName(_dllName) , fn(0) , fnName(_fnName)\r\n\t\t{\r\n\t\t\tif (logging && !dllHandle)\r\n\t\t\t{ \r\n\t\t\t\tprintf(\"couldn't found DLL\\n\");\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t\toperator T()\r\n\t\t{\r\n\r\n\t\t\tprintf(\"executing func : %s \",fnName);\r\n\r\n\t\t\treturn fn; \r\n\t\t}\r\n\t\tvoid Release()\r\n\t\t{\r\n\r\n\t\t\tFreeLibrary(dllHandle);\r\n\t\t\tfn = 0;\r\n\r\n\t\t}\r\n\t\tvoid Load()\r\n\t\t{\r\n\t\t\tFreeLibrary(dllHandle);\r\n\t\t\tprintf(\"loading lib : %s for function\",dllName,fnName);\r\n\t\t\tdllHandle = ( LoadLibrary (dllName) );\r\n\t\t\tfn = ( T )GetProcAddress(dllHandle, fnName);\r\n\t\t\tif (!fn)\r\n\t\t\t{ \r\n\t\t\t\tprintf(\"couldn't attach fnc \\n\");\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\r\n\r\n\tpublic:\r\n\t\tT fn;\r\n\t\tHMODULE dllHandle;\r\n\t\tconst char* dllName;\r\n\t\tconst char* fnName;\r\n\t};\r\n\r\n}/*end namespace */\r\n\r\n#endif/********************************************************************\r\ncreated:\t2008/01/14\r\ncreated:\t14:1:2008 12:14\r\nfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\CustomPlayerDialogErrorPage.cpp\r\nfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\nfile base:\tCustomPlayerDialogErrorPage\r\nfile ext:\tcpp\r\nauthor:\t\tmc007\r\n\r\npurpose:\tDisplays an Error Tab, the text is set by CustomPlayerDialog.InitDialog !\r\n*********************************************************************/\r\n// CErrorPage dialog\r\n#pragma once\r\n#include \"resourceplayer.h\"\r\n#include \"afxwin.h\"\r\n#include \"afxcmn.h\"\r\nclass CustomPlayerDialogErrorPage : public CPropertyPage\r\n{\r\n// Construction\r\npublic:\r\n\tCustomPlayerDialogErrorPage();\r\n\r\n// Dialog Data\r\n\t//{{AFX_DATA(CErrorPage)\r\n\tenum { IDD = IDD_ERROR };\r\n\t//}}AFX_DATA\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generate virtual function overrides\r\n\t//{{AFX_VIRTUAL(CErrorPage)\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n// Implementation\r\nprotected:\r\n\t\r\n\t// Generated message map functions\r\n\t//{{AFX_MSG(CErrorPage)\r\n\t\t// NOTE: the ClassWizard will add member functions here\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\npublic:\r\n\t\r\n\tCRichEditCtrl m_ErrorRichText;\r\n\tafx_msg void OnEnSetfocusErrorRichtText();\r\n\tCString errorText;\r\n\r\n\tafx_msg void OnEnLinkErrorRichtText(NMHDR *pNMHDR, LRESULT *pResult);\r\n};\r\n#ifndef InitMAN_H\r\n#define InitMAN_H\r\n\r\n\r\n#include \"CKBaseManager.h\"\r\n\r\n\r\n#include \r\n#include \r\n\r\n\r\n\r\n#define S_PARAMETER_GUID CKGUID(0x7a7104e2,0x72c56435)\r\n\r\n#define SFLOAT_PARAMETER_GUID CKGUID(0x6a5b2ec3,0x63f84a40)\r\n\r\n#define SCOLOR_PARAMETER_GUID CKGUID(0x47cc15d2,0xf366299)\r\n#define SINT_PARAMETER_GUID CKGUID(0x31d3196f,0x787306e1)\r\n\r\n\r\n\r\n#define CKPGUID_LOOPMODE\t\tCKDEFINEGUID(0x63942d15,0x5ac51a7)\r\n\r\n\r\ntypedef enum QAD_OBJECT_TYPE {\r\n\r\n\tCHARACTER = 1,\r\n\tPUSHBOX\t\t = 2,\r\n\tBALL\t\t\t = 3,\r\n\tSTONE\t\t\t= 4,\r\n\tCOIN\t\t\t = 5,\r\n\tFUEL\t\t\t = 6,\r\n\tROCKET\t\t = 7,\r\n\tMOVINGBOARD = 8,\r\n\tSPRINGPAIR\t\t=9,\r\n}\r\nQAD_OBJECT_TYPE;\r\n//////////////////////////////////////////////////////////////////////////\r\n#define VLEFT VxVector(-1.0f,0.0f,0.0f)\r\n#define VRIGHT VxVector(1.0f,0.0f,0.0f)\r\n#define VUP VxVector(1.0f,1.0f,0.0f)\r\n#define VDOWN VxVector(0.0f,-1.0f,0.0f)\r\n#define VZERO VxVector(0.0f,0.0f,0.0f)\r\n\r\n#define PHYSIC_OBJECT_2D_PARAMETER CKDEFINEGUID(0x57ba4ee6,0x4d8740a9)\r\n\r\n#define PHYSIC_OBJECT_SIMULATION_FILTER CKDEFINEGUID(0x248f1f51,0x72070f85)\r\n\r\n#define PHYSIC_OBJECT_2D_WORLDSPRING_PARAMETER CKDEFINEGUID(0x1b8e268b,0x11041fa0)\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"typedefs.h\"\r\n#include \"ZipDll.h\"\r\n#include \"UnzipDll.h\"\r\n#include \"ZCallBck.h\"\r\n\r\nBOOL __stdcall DefaultZipCallback(CZipCallbackData *pData);//thanks\r\n\r\n\r\n#include \"sharedStructs.h\"\r\n\r\n\r\n\r\n#define INIT_MAN_GUID\t\tCKGUID(0x35824c8a,0x4e320ac4)\r\n\r\nclass InitMan : public CKBaseManager\r\n{\r\n\r\n\tpublic:\r\n\t\t//Ctor\r\n\t\tInitMan(CKContext* ctx);\r\n\t\t//Dtor\r\n\t\t~InitMan();\r\n\t\tstatic InitMan* GetInstance();\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//virtual file mapping , used for command pipe:\r\n\t\tHANDLE m_hMMFile;\r\n\t\tvtExternalEvent *m_pData;\r\n\r\n\t\ttypedef XHashTablevtExternalEventQueueType;\r\n\t\tvtExternalEventQueueType incomingEvents;\r\n\t\tvoid PerformMessages();\r\n\t\tvoid InitMessages(int flags,XString name);\r\n\r\n\t\t// Initialization\t\r\n\t\tvirtual CKERROR OnCKInit();\r\n\t\tvirtual CKERROR OnCKEnd();\r\n\t\tvirtual CKERROR OnCKReset();\r\n\t\tCKERROR PreProcess();\r\n\t\tCKERROR PostProcess();\r\n\t\tvirtual CKERROR PostClearAll();\r\n\t\tvirtual CKERROR OnCKPlay();\r\n\r\n\r\n\tCKDWORD\tGetValidFunctionsMask()\t\r\n\t{ return CKMANAGER_FUNC_OnCKInit|\r\n\t\tCKMANAGER_FUNC_OnCKEnd|\r\n\t\tCKMANAGER_FUNC_OnCKReset|\r\n\t\tCKMANAGER_FUNC_PreProcess|\r\n\t\tCKMANAGER_FUNC_PostProcess|\r\n\t\tCKMANAGER_FUNC_PostClearAll|\r\n\t\tCKMANAGER_FUNC_OnCKPlay; \r\n\t}\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* Parameter Functions\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\r\n\tint move_object_att;\tint moving_board_att;\tint rocket_att; \tint keyboard_config_att;\tint att_character_keyboard_config;\tint att_character_anim_messages;\tint att_character_anims;\tint att_character_ckof;\tint att_character_object_set;\tint att_spring_pair;\r\n\r\n\r\n\tVxVector Position(CK3dEntity *ent);\r\n\r\n\tint att_rigid_body_2D;\r\n\tint att_rigid_body_2D_worldspring;\r\n\tint att_need_update;\r\n\tint att_do_physics;\r\n\tint att_sim_filter;\r\n\r\n\r\n\tvoid RegisterVSL();\r\n\tvoid RegisterRacknetVSL();\r\n\t\r\n\tvoid RegisterCEGUI_VSL(CKContext *ctx);\r\n\r\n void RegisterParameters();\r\n\tvoid RegisterParameters2();\r\n\t//void RegisterHUD();\r\n\r\n \r\n\t\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* zip lib */\r\n\t/************************************************************************/\r\n\r\n\t\r\n\r\n\tZipJobList zili;\r\n\r\n\t\t\r\n\tbool AddFileEntry(XString ArchiveName,XString FileEntry);\r\n\r\n\t\t\r\n\tBOOL LoadZipDll();//from the projects resource\r\n\tBOOL UnLoadZipDll();\r\n\tvoid SetDefaultZipValues(CZipParams *pParams);\r\n\tint GetZipDllVersion();\r\n\t\t\r\n\r\n\t/************************************************************************/\r\n\t/* decompressing funcs\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/************************************************************************/\r\n\r\n\tBOOL LoadUnzipDll();\r\n\tBOOL UnLoadUnZipDll();\r\n\tvoid SetDefaultUnZipValues(CUnzipParams * pParams);\r\n\tint GetUnzipDllVersion();\r\n\t\t\t\r\n\r\n\tUINT m_uiLastError;//unused\r\n\t\r\n\t/************************************************************************/\r\n\t/* compress\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\tHINSTANCE m_ZipDllHandle;\r\n\tchar ZipDllTempFile[MAX_PATH];\r\n\tCZipDllExec m_ZipDllExec;\r\n\tCGetZipDllVersion m_GetZipDllVersion;\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* decompress\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/************************************************************************/\r\n\r\n\tHINSTANCE m_UnzipDllHandle;\r\n\tchar UnZipDllTempFile[MAX_PATH];\r\n\tCGetUnzipDllVersion m_GetUnzipDllVersion;\r\n\tCUnzipDllExec m_UnzipDllExec;\r\n\r\n\r\n\tprivate:\r\n\r\n\t\r\n};\r\n\r\n#define GetIManager() InitMan::GetInstance()\r\n\r\n\r\n#endif\r\n#include \"StdAfx.h\"\r\n#include \"InitMan.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \r\nusing std::cout;\r\n#include \r\n#include \"pyembed.h\"\r\n//#include \"VSLManagerSDK.h\"\r\n/*#include \r\n#include \"pyembed.h\"\r\n*/\r\n\r\n\r\n\r\n//************************************\r\n// Method: ClearModules\r\n// FullName: vt_python_man::ClearModules\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nvoid\r\nvt_python_man::ClearModules()\r\n{\r\n\r\n\tPModulesIt begin = GetPModules().begin();\r\n\tPModulesIt end = GetPModules().end();\r\n\twhile(begin!=end)\r\n\t{\r\n\r\n\t\tif (begin->second)\r\n\t\t{\r\n\t\t\tPy_XDECREF(begin->second);\r\n\t\t\tbegin->second = NULL;\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\tGetPModules().clear();\r\n}\r\n\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,long& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n\r\n}\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,double& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,std::string& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n}\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,Arg_mmap *args,XString func)\r\n{\r\n\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr());\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid \r\nvt_python_man::CallPyModule(CK_ID id,XString func)\r\n{\r\n\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr());\r\n\t\t}\r\n\t}\r\n}\r\n//************************************\r\n// Method: RemovePModule\r\n// FullName: vt_python_man::RemovePModule\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n//************************************\r\nvoid\r\nvt_python_man::RemovePModule(CK_ID id)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it != GetPModules().end() )\r\n\t\t{\r\n if (it->second)\r\n {\r\n\t\t\t\tPy_DECREF(it->second);\r\n\t\t\t\tit->second = NULL;\r\n\t\t\t\tGetPModules().erase(it);\r\n }\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//************************************\r\n// Method: GetPModule\r\n// FullName: vt_python_man::GetPModule\r\n// Access: public \r\n// Returns: PyObject*\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n//************************************\r\nPyObject*\r\nvt_python_man::GetPModule(CK_ID id)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it != GetPModules().end() )\r\n\t\t{\r\n\t\t\treturn it->second;\r\n\t\t}else\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//************************************\r\n// Method: InsertPModule\r\n// FullName: vt_python_man::InsertPModule\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n// Parameter: XString name\r\n// Parameter: bool reload\r\n//************************************\r\nPyObject*\r\nvt_python_man::InsertPModule(CK_ID id,XString name,bool reload)\r\n{\r\n CKObject* obj = m_Context->GetObject(id);\r\n\r\n\tif(obj)\r\n\t{\r\n\t\tif (GetPModule(id))\r\n\t\t{\r\n\t\t\tRemovePModule(id);\r\n\t\t}\r\n\t\t//bit = BArray.insert(BArray.end(),std::make_pair(target,bodyI));\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it == GetPModules().end() )\r\n\t\t{\r\n\r\n\t\t\ttry \r\n\t\t\t{\r\n\r\n\t\t\t\tPyObject* namep = PyString_FromString( name.CStr() );\r\n\t\t\t\tPyObject* module = PyImport_Import(namep); \r\n\r\n\t\t\t\tif (reload)\r\n\t\t\t\t\tPyImport_ReloadModule(module);\r\n\r\n\t\t\t\tPy_DECREF(namep);\r\n\t\t\t\tGetPModules().insert( GetPModules().end(),std::make_pair(id,module ) );\r\n\r\n\t\t\t\tif (!module)\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::ostringstream oss;\r\n\t\t\t\t\tm_Context->OutputToConsoleEx(\"PyErr : \\t Failed to load module\" );\r\n\t\t\t\t\treturn NULL;\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn module;\r\n\t\t\t}\tcatch (Python_exception ex)\r\n\t\t\t{\r\n\t\t\t\tm_Context->OutputToConsoleEx(\"PyErr : \\t %s\",(CKSTRING)ex.what());\r\n\t\t\t\tstd::cout << ex.what() << \"pyexeption in beh : \";\r\n\t\t\t\tPyErr_Clear();\r\n\t\t\t\t//beh->ActivateOutput(1,TRUE);\r\n\t\t\t}\r\n \r\n\r\n\t\t\t/*if (!module)\r\n\t\t\t{\r\n\t\t\t\tstd::ostringstream oss;\r\n\t\t\t\toss << \"Failed to load module <\" << name.CStr() << \">\";\r\n\t\t\t\tthrow Python_exception(oss.str());\r\n\t\t\t\treturn NULL;\r\n\t\t\t}*/\r\n\r\n\t\t\t//GetPModules().insert( GetPModules().end(),std::make_pair(id,module ) );\r\n\t\t\t//return module;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\nvoid\r\nvt_python_man::InsertPVSLModule(PythonModule *pMod)\r\n{\r\n\tif (pMod)\r\n\t{\r\n\r\n\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\n#ifndef __G_CONFIG_H__\r\n#define __G_CONFIG_H__\r\n\r\n#ifdef _DEBUG\r\n\tstatic bool GC_SHOWPARAMETER = true;\r\n#else\r\n\tstatic BOOL GC_SHOWPARAMETER = false;\r\n#endif\r\n\r\n\r\n//#define\t\tBBC_JOYSTICK\r\n#define\t\tBBC_TOOLS\r\n#define\t\tBB_TOOLS\r\n#define\t\tHAS_CONFIG\r\n\r\n#define\t\tBBC_VEHICLES\r\n\r\n\r\n#define\t\tBBC_CLOTHES\r\n#define\t\tBBC_JOINTS\r\n\r\n\r\n#define\t\tCORE_CLOTH\r\n#define\t\tCORE_PARTICLE\r\n\r\n\r\n\r\n#endif#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDODestroyedDecl();\r\nCKERROR CreateDODestroyedProto(CKBehaviorPrototype **);\r\nint DODestroyed(const CKBehaviorContext& behcontext);\r\nCKERROR DODestroyedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDODestroyedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DODestroyed\");\t\r\n\tod->SetDescription(\"Notifies about a deleted Object\");\r\n\t\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x440a6b7a,0x2efb0cee));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDODestroyedProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDODestroyedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DODestroyed\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Stop\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\tproto->DeclareOutput(\"Object\");\r\n\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Object\", CKPGUID_BEOBJECT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Object ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_INT, \"-1\");\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DODestroyed);\r\n\tproto->SetBehaviorCallbackFct(DODestroyedCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DODestroyed(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\r\n\tint connectionID=-1;\r\n\tbeh->GetInputParameterValue(0,&connectionID);\r\n\t\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\t\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn 0;\r\n\r\n\t}\r\n\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin || !cin->isValid() )\r\n\t{\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\tTNL::Vector&clientTable = cin->getDistDeleteTable();\r\n\r\n\tfor (int i = 0 ; i < clientTable.size() ; i++ )\r\n\t{\r\n\t\txDistDeleteInfo*cInfo = clientTable[i];\r\n\t\tif (cInfo->deleteState == E_DO_DS_DELETED )\r\n\t\t{\r\n\t\t\tint sID = cInfo->serverID;\r\n\t\t\tbeh->SetOutputParameterValue(1,&sID);\r\n\t\t\tCKBeObject * obj = (CKBeObject*)ctx->GetObject(cInfo->entityID);\r\n\t\t\tif (obj)\r\n\t\t\t{\r\n\t\t\t\tbeh->SetOutputParameterObject(0,obj);\r\n\t\t\t}\r\n\t\t\tbeh->ActivateOutput(2);\r\n\t\t\tclientTable.erase(i);\r\n\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR DODestroyedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#ifndef __PREREQUISITES_MODULE_H__\r\n\t#define __PREREQUISITES_MODULE_H__\r\n\r\nclass PhysicManager;\r\n\r\n//################################################################\r\n//\r\n// Physic Types \r\n//\r\nclass pContactReport;\r\nclass pTriggerReport;\r\nclass pRayCastReport;\r\nclass pContactModify;\r\n\r\n\r\nclass pRigidBody;\r\nclass pObjectDescr;\r\n\r\nclass pJointSettings;\r\nclass pJoint;\r\nclass pJointBall;\r\nclass pJointFixed;\r\nclass pJointPulley;\r\n\r\nclass pJointPointOnLine;\r\nclass pJointPointInPlane;\r\nclass pJointRevolute;\r\nclass pJointDistance;\r\nclass pJointD6;\r\nclass pJointPrismatic;\r\nclass pJointCylindrical;\r\nclass pClothDesc;\r\nclass pCloth;\r\n\r\nclass pFluid;\r\nclass pFluidDesc;\r\nclass pFluidEmitterDesc;\r\nclass pFluidEmitter;\r\nclass pFluidRenderSettings;\r\nclass pWheelContactData;\r\nclass pSerializer;\r\nclass pWorld;\r\nclass pFactory;\r\nclass pSoftBody;\r\n\r\n\r\nclass pWheelDescr;\r\nclass pWheel;\r\nclass pWheel1;\r\nclass pWheel2;\r\n\r\nclass pVecicleDescr;\r\nclass pVehicle;\r\n\r\nclass pVehicleMotor;\r\nclass pVehicleGears;\r\nclass pVehicleMotorDesc;\r\nclass pVehicleGearDesc;\r\n\r\n\r\nclass pBoxController;\r\n\r\nclass pObjectDescr;\r\n\r\n\r\n\r\nclass IParameter;\r\nstruct pRigidBodyRestoreInfo;\r\n\r\n\r\n\r\nnamespace vtAgeia\r\n{\r\n\tclass pWorldSettings;\r\n\tclass pSleepingSettings;\r\n\tclass pShape;\r\n\tclass pErrorStream;\r\n\tclass pCollisionsListener;\r\n}\r\n\r\nclass pLogger;\r\nclass ContactInfo;\r\n\r\nnamespace vtTools\r\n{\r\n\r\n\tnamespace ParameterTools\r\n\t{\r\n\t\tclass CustomStructure;\r\n\t}\r\n}\r\n\r\n\r\nusing namespace vtAgeia;\r\n\r\n#endif\r\n\r\n/*\n * Tcp4u v 3.31 Last Revision 27/06/1997 3.10\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: http4u.c\n * Purpose: manage http 1.0 protocol\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by and \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\nstatic char szWhat[]=\"@(#)http4u by and version 3.11\";\n\n#include \"build.h\"\n\n /******************************\n * Http4u internal structures\n ******************************/\n\n/* status-line for http 1.0 answers */\nstruct S_HttpStatus \n{\n int nVersion; /* version should be 1 */\n int nMinor; /* revision (0 or 1) */\n int code; /* status-code (ex: 200 ) */\n char reason[64]; /* reason (ex: \"OK\") */\n};\n\n\n/*******************************\n * A few globals variables\n *******************************/\nstatic unsigned int s_uHttp4uTimeout = DFLT_TIMEOUT;\nstatic unsigned int s_uHttp4uBufferSize = DFLT_BUFFERSIZE;\nstatic DO_NOT_LOG = HFILE_ERROR;\n\n/*=====================================================================\n * PRIVATE FUNCTION SOURCES\n *===================================================================*/\n\n\n/*######################################################################\n *##\n *## NAME: HttpProcessAnswer\n *##\n *## PURPOSE: get HTTP version + HTTP return code + data string\n *## fully reeentrant\n *##\n *####################################################################*/\nstatic int HttpProcessAnswer (LPCSTR szAns, int far *pnVer, int far *pnMinor, \n int far *pnAnswer, LPSTR szData, int nDataSize)\n{\nLPCSTR p;\n\n Tcp4uLog (LOG4U_INTERN, \"HttpProcessAnswer\");\n\n if (memcmp (szAns, \"HTTP/\", sizeof (\"HTTP/\") - 1)!=0)\n {\n\t Tcp4uLog (LOG4U_ERROR, \"HttpProcessAnswer: bad protocol returned (%s)\", szAns);\n return HTTP4U_PROTOCOL_ERROR; \n }\n /* 27/06/97: ignore version numbers (RFC2145) */\n *pnAnswer=1; *pnMinor=0;\n /* search for a space character, then skip it */\n p = szAns + sizeof \"HTTP/\";\n while (*p!=0 && !isspace(*p)) p++;\n while (*p!=0 && isspace(*p)) p++;\n if (*p==0)\n {\n\t Tcp4uLog (LOG4U_ERROR, \"HttpProcessAnswer: bad protocol returned (%s)\", szAns);\n return HTTP4U_PROTOCOL_ERROR; \n }\n *pnAnswer = Tcp4uAtoi (p);\n /* continue only if szData is to be filled */\n if (szData!=NULL && nDataSize>0)\n {\n /* search for a non-digit then skips spaces */\n while (*p!=0 && isdigit(*p)) p++;\n while (*p!=0 && isspace(*p)) p++;\n Strcpyn (szData, p, nDataSize);\n }\nreturn HTTP4U_SUCCESS;\n} /* HttpProcessAnswer */\n\n\n/*######################################################################\n *##\n *## NAME: HttpSendAdditionnalHeader\n *##\n *## PURPOSE: Send a http 1.0 general-header \n *##\n *####################################################################*/\nstatic int HttpSendAdditionnalHeader(SOCKET CSock)\n{\n int Ark;\n int Rc;\n static LPCSTR szAdditionnalStrings[] = \n {\n \"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\",\n \"User-Agent: Http4u by and \",\n \"\",\n };\n\n Tcp4uLog (LOG4U_INTERN, \"HttpSendAdditionnalHeader\");\n\n /* sending request, if successful send Request Header */\n for (Rc=TCP4U_SUCCESS,Ark=0 ; Rc==TCP4U_SUCCESS && Ark 0) szAnswer[0]=0;\n /* If ye can keep user's buffer */\n if (szAnswer!=NULL && nAnswerSize >= RECV_BUF_SIZE)\n {\n sBufStatus = szAnswer;\n nBufStatusLen = nAnswerSize;\n }\n else\n {\n sBufStatus = Calloc (RECV_BUF_SIZE, sizeof (char));\n if (sBufStatus == NULL) return HTTP4U_INSMEMORY; \n }\n\n /* receive data */\n Rc = TnReadLine (CSock,sBufStatus,nBufStatusLen,s_uHttp4uTimeout, DO_NOT_LOG);\n switch(Rc) \n {\n case TCP4U_SUCCESS: break;\n case TCP4U_OVERFLOW: return HTTP4U_OVERFLOW;\n case TCP4U_TIMEOUT: return HTTP4U_TIMEOUT;\n case TCP4U_CANCELLED: return HTTP4U_CANCELLED;\n case TCP4U_ERROR: return HTTP4U_TCP_FAILED;\n case TCP4U_SOCKETCLOSED: return HTTP4U_PROTOCOL_ERROR;\n default: return HTTP4U_TCP_FAILED;\n }\n /* control format */\n Rc = HttpProcessAnswer ( sBufStatus, \n & saRespStatus->nVersion, \n & saRespStatus->nMinor, \n & saRespStatus->code, \n saRespStatus->reason, \n sizeof saRespStatus->reason);\n /* Copy data, free buffer */\n if (sBufStatus != szAnswer) \n {\n if (szAnswer != NULL) Strcpyn (szAnswer, sBufStatus, nAnswerSize);\n Free (sBufStatus);\n }\n\nreturn Rc;\n#undef RECV_BUF_SIZE\n} /* END HttpRecvRespStatus */\n\n\n/*######################################################################\n *##\n *## NAME: HttpRecvHeaders10\n *##\n *## PURPOSE: Return the headers section of the http respons\n *## sBufHeaders Can not be NULL, but sBufHeadersLen can !! \n *##\n *####################################################################*/\nstatic int HttpRecvHeaders10 (SOCKET CSock,\n LPSTR sBufHeaders,\n int nBufHeadersLen)\n{\nint Rc;\nint nRcvd, nLineLength;\nLPSTR p;\n#define EMPTY(s) ((s)[0]=='\\r' || (s)[0]=='\\n')\n\n Tcp4uLog (LOG4U_INTERN, \"Http4RecvHeaders10\");\n\n if (sBufHeaders==NULL) return HTTP4U_BAD_PARAM;\n memset(sBufHeaders, 0, nBufHeadersLen);\n /* Keep space for last ending line and nul character */\n nBufHeadersLen -= sizeof SYSTEM_EOL;\n \n /* receive data from distant http server. Must use loop on TcpRecvUntilStr */\n /* since some unix servers send \\n\\n instead of regular \\n\\r\\n.... */\n nRcvd = 0 ; \n do\n { \n p = & sBufHeaders[nRcvd];\n Rc = InternalTnReadLine (CSock, \n p, nBufHeadersLen-nRcvd,\n s_uHttp4uTimeout, DO_NOT_LOG); \n Strcat (p, SYSTEM_EOL);\n nLineLength = Strlen (p); /* 0 on error */\n nRcvd += nLineLength;\n } /* loop until error or empty line */\n while (Rc==TCP4U_SUCCESS && !EMPTY(p) && nRcvd < nBufHeadersLen);\n /* translate return code */\n switch(Rc) \n {\n /* remember to put the last \\n into destination string */\n case TCP4U_SUCCESS: Tcp4uDump (sBufHeaders, nRcvd, DUMP4U_RCVD);\n return nRcvd >= nBufHeadersLen ?\n HTTP4U_OVERFLOW : HTTP4U_SUCCESS;\n case TCP4U_OVERFLOW: return HTTP4U_OVERFLOW;\n case TCP4U_TIMEOUT: return HTTP4U_TIMEOUT;\n case TCP4U_CANCELLED: return HTTP4U_CANCELLED;\n case TCP4U_ERROR: return HTTP4U_TCP_FAILED;\n case TCP4U_INSMEMORY: return HTTP4U_INSMEMORY;\n case TCP4U_SOCKETCLOSED: return HTTP4U_PROTOCOL_ERROR;\n default: return HTTP4U_TCP_FAILED;\n } /* END switch(Rc) */\n#undef EMPTY\n} /* END HttpRecvHeaders10 */\n\n\n\n/*=====================================================================\n * PUBLIC FUNCTION SOURCES\n *===================================================================*/\n \n/*######################################################################\n *##\n *## NAME: HttpGetHeaders10 \n *##\n *## PURPOSE: Return the header section of the http request\n *##\n *####################################################################*/\nint HttpGetHeaders10( LPCSTR szURL, /* URL target */\n LPSTR szResponse, /* user's buffer for HTTP response */ \n int nResponseSize, /* */\n LPSTR szData, /* user's buffer for HTTP headers */ \n int nDataSize /* */)\n{\nint Rc;\nSOCKET CSock = INVALID_SOCKET;\nchar szService[SERVICE_LENGTH];\nchar szHost[HOST_LENGTH];\nchar szFichier[FILE_LENGTH];\nunsigned short usPort;\nstruct S_HttpStatus saRespStatus;\n\n Tcp4uLog (LOG4U_INTERN, \"HttpGetHeaders10\");\n\n /* control the URL's validity and receive the URL distinct components */\n if (!HttpIsValidURL(szURL,\n &usPort,\n szService, sizeof szService ,\n szHost, sizeof szHost ,\n szFichier, sizeof szFichier )) \n return HTTP4U_BAD_URL;\n\n /* connect to the http server */\n Rc = TcpConnect(&CSock,\n szHost,\n szService,\n &usPort);\n switch (Rc)\n {\n case TCP4U_SUCCESS : break; /* continue */\n case TCP4U_HOSTUNKNOWN : return HTTP4U_HOST_UNKNOWN;\n default : return HTTP4U_TCP_CONNECT;\n }\n\n /* Send request-line method \"HEAD\" then receive the status-line answer */\n /* then receive headers */\n (Rc = HttpSendRequest10 (CSock,\"HEAD \", szURL)) == HTTP4U_SUCCESS\n && (Rc = HttpRecvRespStatus (CSock, & saRespStatus, \n szResponse, nResponseSize)) == HTTP4U_SUCCESS\n && (Rc = HttpRecvHeaders10 (CSock, szData, nDataSize)) == HTTP4U_SUCCESS ;\n\n TcpClose (&CSock);\nreturn Rc;\n} /* END HttpGetHeaders10 */\n\n\n\n\n/*######################################################################\n *##\n *## NAME: Http4uSetTimeout\n *##\n *## PURPOSE: Sets user preference of the timeout value\n *##\n *####################################################################*/\nvoid API4U Http4uSetTimeout(\n unsigned int uTimeout /* timeout value in sec */)\n{\n Tcp4uLog (LOG4U_HIPROC, \"Http4uSetTimeout\");\n s_uHttp4uTimeout = uTimeout;\n} /* END Http4uSetTimeout */\n\n\n/*######################################################################\n *##\n *## NAME: Http4uSetBufferSize\n *##\n *## PURPOSE: Sets user preference of the buffer size\n *##\n *####################################################################*/\nvoid API4U Http4uSetBufferSize(\n unsigned int uBufferSize /* buffer size in bytes */)\n{\n Tcp4uLog (LOG4U_HIPROC, \"Http4uSetbufferSize\");\n s_uHttp4uBufferSize = uBufferSize;\n} /* END Http4uSetBufferSize */\n\n\n/*######################################################################\n *##\n *## NAME: HttpGetFileEx\n *##\n *## PURPOSE: Return headers and body of a http request \n *##\n *####################################################################*/\nint API4U HttpGetFileEx( \n LPCSTR szURL, \n LPCSTR szProxyURL, \n LPCSTR szLocalFile,\n LPCSTR szHeaderFile,\n HTTP4U_CALLBACK CbkTransmit,\n long lUserValue,\n LPSTR szResponse, int nResponseSize,\n LPSTR szHeaders, int nHeadersSize\n )\n{\nSOCKET CSock = INVALID_SOCKET;\nint Rc;\nint hHeaderFile = HFILE_ERROR;\nchar szService[SERVICE_LENGTH];\nchar szHost[HOST_LENGTH];\nchar szFichier[FILE_LENGTH];\nLPSTR szData = NULL;\nLPSTR p;\nLPCSTR szRequest;\nlong RealBodySize = -1;\n\nstruct S_HttpStatus saRespStatus;\nunsigned short usPort = 0;\n\n Tcp4uLog (LOG4U_HIPROC, \"HttpGetFileEx\");\n\n#define XX_RETURN(a) {if (szData!=NULL) Free(szData);\\\n if (hHeaderFile!=HFILE_ERROR){\\\n Close(hHeaderFile);\\\n Unlink(szHeaderFile);\\\n }\\\n if (CSock != INVALID_SOCKET) TcpClose(&CSock);\\\n\t\t\t\t Tcp4uLog (LOG4U_HIEXIT, \"HttpGetFileEx with return code %d\", a); \\\n return a;\\\n }\n#ifdef UNIX\n /* use \"hidden\" env variable in order to send logs to stdout */\n if (getenv (\"http4u_log\")!=NULL) DO_NOT_LOG = fileno(stdout);\n#endif\n\n /* control URL's validity and receive URL's components. If a proxy */\n /* is used, send the connection components into usPort, szService */\n /* and szHost. */\n if ( ! HttpIsValidURL( szURL,\n & usPort,\n szService, sizeof szService ,\n szHost, sizeof szHost ,\n szFichier, sizeof szFichier )\n || ( szProxyURL!=NULL \n && ! HttpIsValidURL (szProxyURL, & usPort, \n szService, sizeof szService,\n szHost, sizeof szHost, NULL, 0))\n )\n {\n XX_RETURN (HTTP4U_BAD_URL);\n }\n\n /* allocate buffer */\n if ( (szData = Calloc(1,s_uHttp4uBufferSize)) == NULL) \n {\n XX_RETURN (HTTP4U_INSMEMORY);\n } \n\n /* connect to http server, or proxy server : we don't care now */\n Rc = TcpConnect(& CSock,\n szHost,\n usPort==0 ? szService : NULL,\n & usPort);\n switch (Rc)\n {\n case TCP4U_SUCCESS : break; /* continue */\n case TCP4U_HOSTUNKNOWN : XX_RETURN (HTTP4U_HOST_UNKNOWN);\n default : XX_RETURN (HTTP4U_TCP_CONNECT);\n }\n\n /* send a request-line method \"GET\", receive reply, receive data */\n szRequest= szProxyURL==NULL? szFichier : szURL; /* if no proxy, simple ! */\n if ( (Rc=HttpSendRequest10 (CSock, \"GET \", szRequest)) != HTTP4U_SUCCESS\n || (Rc=HttpRecvRespStatus (CSock, & saRespStatus, \n szResponse,nResponseSize)) != HTTP4U_SUCCESS )\n {\n XX_RETURN (Rc);\n }\n\n /* an answer has been received, let us have a look on it */\n switch(saRespStatus.code) \n {\n case 200: break; /* reason-phrase OK */ \n case 204: XX_RETURN (HTTP4U_NO_CONTENT);\n case 300:\n case 301: XX_RETURN (HTTP4U_MOVED);\n case 400: XX_RETURN (HTTP4U_BAD_REQUEST);\n case 401:\n case 403: XX_RETURN (HTTP4U_FORBIDDEN);\n case 404: XX_RETURN (HTTP4U_NOT_FOUND);\n default: XX_RETURN (HTTP4U_PROTOCOL_ERROR);\n }\n\n /* read headers */\n Rc = HttpRecvHeaders10(CSock, szData, s_uHttp4uBufferSize);\n /* copy headers into user buffer even if return incorrect */\n if (szHeaders != NULL) \n Strcpyn (szHeaders, szData, min(s_uHttp4uBufferSize, (unsigned) nHeadersSize));\n\n if (Rc!=HTTP4U_SUCCESS) XX_RETURN (Rc);\n\n /* write headers into the user local file */\n if (szHeaderFile != NULL ) \n {\n if ((hHeaderFile = Open(szHeaderFile, WRITE_CR)) == HFILE_ERROR) \n {\n XX_RETURN (HTTP4U_FILE_ERROR);\n }\n /* write */\n if (Write(hHeaderFile, szData, Strlen(szData)) == HFILE_ERROR) \n {\n XX_RETURN(HTTP4U_FILE_ERROR);\n }\n Close(hHeaderFile);\n hHeaderFile = HFILE_ERROR;\n } /* szHeaderFile not NULL */\n\n /* if we do not need something else, just close the connection */\n /* not really nice, but HTTP servers are used to deal with it */ \n if (szLocalFile==NULL && CbkTransmit==NULL) \n {\n XX_RETURN (HTTP4U_SUCCESS);\n }\n\n /* search real length of the body */ \n RealBodySize = -1; /* can not compute it */\n szData[s_uHttp4uBufferSize-1] = '\\0';\n p = Tcp4uStrIStr (szData, \"content-length:\");\n if (p!=NULL) \n {\n p += sizeof(\"Content-Length:\");\n while (isspace(*p)) p++; /* skip space character */\n RealBodySize = Tcp4uAtol (p);\n }\n \n /* read Body of the respons */\n Rc=TcpRecvUntilClosedEx (& CSock,\n szLocalFile,\n (FARPROC) CbkTransmit,\n s_uHttp4uTimeout,\n s_uHttp4uBufferSize,\n lUserValue,\n RealBodySize);\n\n switch (Rc)\n {\n case TCP4U_SUCCESS: Rc = HTTP4U_SUCCESS; break; \n case TCP4U_TIMEOUT: Rc = HTTP4U_TIMEOUT; break; \n case TCP4U_FILE_ERROR : Rc = HTTP4U_FILE_ERROR; break; \n case TCP4U_INSMEMORY : Rc = HTTP4U_INSMEMORY; break; \n case TCP4U_CANCELLED : Rc = HTTP4U_CANCELLED; break; \n default: Rc = HTTP4U_TCP_FAILED; break; \n \n }\nXX_RETURN (Rc);\n#undef XX_RETURN\n} /* HttpGetFileEx */\n\n\n/*######################################################################\n *##\n *## NAME: HttpGetFile \n *##\n *## PURPOSE: Return body associate with the URL's parameter \n *##\n *####################################################################*/\nint API4U HttpGetFile( \n LPCSTR szURL, \n LPCSTR szProxyURL, \n LPCSTR szLocalFile\n )\n{\nint Rc;\n Tcp4uLog (LOG4U_HIPROC, \"HttpGetFile\");\n /* Appel sans callback */\n Rc = HttpGetFileEx(szURL, /* the URL to be retrieved */\n szProxyURL, /* The proxy to be used or NULL */\n szLocalFile, /* the file to be written */\n NULL, /* No header file */\n NULL, 0, /* No callback */\n NULL, 0, /* No memory allocated for response */\n NULL, 0 /* No memory allocated for header */\n ); \n Tcp4uLog (LOG4U_HIEXIT, \"HttpGetFile\");\nreturn Rc;\n} /* END HttpGetFile */\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n#include \"pVehicleAll.h\"\r\n#define RR_RAD_DEG_FACTOR\t57.29578f\t// From radians to degrees\"\r\n\r\n\r\nfloat pWheel2::getSteerAngle()\r\n{\r\n\r\n\treturn mWheelShape->getSteerAngle();\r\n\r\n}\r\nvoid pWheel2::setSteering(float angle)\r\n{\r\n\tif(angle>lock)angle=lock;\r\n\telse if(angle<-lock)angle=-lock;\r\n\trotation.y=angle+toe;\r\n\t// Apply Ackerman effect\r\n\tif((ackermanFactor<0&&angle<0)||(ackermanFactor>0&&angle>0))\r\n\t\trotation.y*=fabs(ackermanFactor);\r\n\r\n\tfloat a = rotation.y;\r\n\t\r\n\tfloat steerangle= rotation.y * lastStepTimeSec;\r\n\r\n\t\r\n\twhile (steerangle > NxTwoPi)\t//normally just 1x\r\n\t\tsteerangle-= NxTwoPi;\r\n\twhile (steerangle< -NxTwoPi)\t//normally just 1x\r\n\t\tsteerangle+= NxTwoPi;\r\n\r\n\tgetWheelShape()->setSteerAngle(steerangle);\r\n\r\n\r\n\r\n\r\n}\r\n\r\n\r\nbool pWheel2::getContact(pWheelContactData&dst)\r\n{\r\n\r\n\tNxWheelContactData wcd; \r\n\tNxShape* contactShape = mWheelShape->getContact(wcd);\r\n\tdst.contactEntity = NULL;\r\n\tif (contactShape)\r\n\t{\r\n\r\n\t\tdst.contactForce = wcd.contactForce;\r\n\t\tdst.contactNormal = getFrom(wcd.contactNormal);\r\n\t\tdst.contactPoint= getFrom(wcd.contactPoint);\r\n\t\tdst.contactPosition= wcd.contactPosition;\r\n\r\n\r\n\t\tdst.lateralDirection= getFrom(wcd.lateralDirection);\r\n\t\tdst.lateralImpulse= wcd.lateralImpulse;\r\n\t\tdst.lateralSlip = wcd.lateralSlip;\r\n\r\n\t\tdst.longitudalDirection = getFrom(wcd.longitudalDirection);\r\n\t\tdst.longitudalImpulse = wcd.longitudalImpulse;\r\n\t\tdst.longitudalSlip= wcd.longitudalSlip;\r\n\r\n\t\tpSubMeshInfo *sInfo = static_cast(contactShape->userData);\r\n\t\tif (sInfo->entID)\r\n\t\t{\r\n\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\tif (obj)\r\n\t\t\t{\r\n\t\t\t\tdst.contactEntity = (CK3dEntity*)obj;\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tdst.contactEntity = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tdst.otherShapeMaterialIndex = contactShape->getMaterial();\r\n\r\n\t\tNxMaterial* otherMaterial = contactShape->getActor().getScene().getMaterialFromIndex(contactShape->getMaterial());\r\n\t\tif (otherMaterial)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(dst.otherMaterial,otherMaterial);\r\n\t\t}\r\n\r\n\t\treturn true;\r\n\r\n\t}\r\n\t\r\n\treturn false;\r\n}\r\npWheelContactData* pWheel2::getContact()\r\n{\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape)\r\n\t{\r\n\t\treturn new pWheelContactData();\r\n\t}\r\n\t\r\n\tNxWheelContactData wcd; \r\n\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\r\n\tpWheelContactData result;\r\n\tresult.contactEntity = NULL;\r\n\r\n\r\n\tif (contactShape)\r\n\t{\r\n\r\n\t\tresult.contactForce = wcd.contactForce;\r\n\t\tresult.contactNormal = getFrom(wcd.contactNormal);\r\n\t\tresult.contactPoint= getFrom(wcd.contactPoint);\r\n\t\tresult.contactPosition= wcd.contactPosition;\r\n\r\n\t\t\r\n\t\tresult.lateralDirection= getFrom(wcd.lateralDirection);\r\n\t\tresult.lateralImpulse= wcd.lateralImpulse;\r\n\t\tresult.lateralSlip = wcd.lateralSlip;\r\n\t\t\r\n\t\tresult.longitudalDirection = getFrom(wcd.longitudalDirection);\r\n\t\tresult.longitudalImpulse = wcd.longitudalImpulse;\r\n\t\tresult.longitudalSlip= wcd.longitudalSlip;\r\n\r\n\t\tpSubMeshInfo *sInfo = static_cast(contactShape->userData);\r\n\t\tif (sInfo->entID)\r\n\t\t{\r\n\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\tif (obj)\r\n\t\t\t{\r\n\t\t\t\tresult.contactEntity = (CK3dEntity*)obj;\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tresult.contactEntity = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tresult.otherShapeMaterialIndex = contactShape->getMaterial();\r\n\t\t\r\n\t\tNxMaterial* otherMaterial = contactShape->getActor().getScene().getMaterialFromIndex(contactShape->getMaterial());\r\n\t\tif (otherMaterial)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(result.otherMaterial,otherMaterial);\r\n\t\t}\r\n\t}\r\n\treturn &result;\r\n}\r\n\r\nvoid pWheel2::_updateVirtoolsEntity(bool position,bool rotation)\r\n{\r\n\r\n\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(getEntID()));\r\n\tif (ent && position) \r\n\t{\r\n\r\n\t\tNxWheelShape *wShape = getWheelShape();\r\n\t\tNxMat34 pose = wShape->getGlobalPose();\r\n\t\tNxWheelContactData wcd; \r\n\t\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\tNxVec3 suspensionOffsetDirection;\r\n\t\tpose.M.getColumn(1, suspensionOffsetDirection);\r\n\t\tsuspensionOffsetDirection =-suspensionOffsetDirection;\r\n\r\n\t\tif (contactShape && wcd.contactForce > -1000)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tNxVec3 toContact = wcd.contactPoint - pose.t;\r\n\t\t\tdouble alongLength = suspensionOffsetDirection.dot(toContact);\r\n\t\t\tNxVec3 across = toContact - alongLength * suspensionOffsetDirection;\r\n\t\t\tdouble r = wShape->getRadius();\r\n\t\t\tdouble pullBack = sqrt(r*r - across.dot(across));\r\n\t\t\tpose.t += (alongLength - pullBack) * suspensionOffsetDirection;\r\n\t\t} else {\r\n\t\t\tpose.t += wShape->getSuspensionTravel() * suspensionOffsetDirection;\r\n\t\t}\r\n\r\n\t\tVxVector oPos = getFrom(pose.t);\r\n\t\tent->SetPosition(&oPos);\r\n\r\n\t\tif (hasGroundContact())\r\n\t\t{\r\n\r\n\t\t\tNxWheelShape *wShape = getWheelShape();\r\n\t\t\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n/*\t\t\tNxWheelContactData wcd;\r\n\t\t\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\t\t\tNxReal stravel = wShape->getSuspensionTravel();\r\n\t\t\tNxReal radius = wShape->getRadius();\r\n\r\n\t\t\tVxVector gPos = getFrom(getWheelPose().t);\r\n\r\n\t\t\t/*\r\n\t\t\tif( cShape && wcd.contactPosition <= (stravel + radius) ) \r\n\t\t\t{\r\n\t\t\t}*/\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t/*VxVector gPos = getFrom(getWheelPose().t);\r\n\t\t\t//gPos*=-1.0f;\r\n\t\t\tgPos -=getWheelPos();\r\n\t\t\tV\t3.\r\n\t\t\t\txVector gPos2 = getFrom(getWheelShape()->getLocalPose().t);\r\n\t\t\tent->SetPosition(&gPos2,getBody()->GetVT3DObject());\r\n\t\t\t*/\r\n\t\t}else\r\n\t\t{\r\n//\t\t\tVxVector gPos = getWheelPos();\r\n//\t\t\tent->SetPosition(&gPos,getBody()->GetVT3DObject());\r\n\t\t}\r\n\t}\r\n\tif (ent && rotation)\r\n\t{\r\n\r\n\r\n\t\t//float rollAngle = getWheelRollAngle();\r\n\t\t//rollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n \r\n\t\tVxQuaternion rot = pMath::getFrom( getWheelPose().M );\r\n\t\tent->SetQuaternion(&rot,NULL);\r\n\t}\r\n\r\n\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\r\n\t//NxWheelShape *wShape = getWheelShape();\r\n/*\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\t//rollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n\trollAngle+=wShape->getAxleSpeed() * ((1/60) * 0.01f);\r\n*/\r\n\t\r\n\r\n\t\r\n\r\n\t/*\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\r\n\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\tNxWheelContactData wcd;\r\n\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( cShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\tfloat rAngle = rollAngle;\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rollAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n\r\n\t\r\n*/\r\n\t\r\n}\r\n\r\nvoid pWheel2::_updateAgeiaShape(bool position,bool rotation)\r\n{\r\n\r\n}\r\n\r\nfloat pWheel2::getRadius()const\r\n{\r\n\treturn mWheelShape->getRadius();\r\n}\r\n\r\nfloat pWheel2::getRpm() const\r\n{\r\n\r\n\tfloat a = NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * 60.0f;\r\n\tif (getVehicle())\r\n\t{\r\n\r\n\t\tfloat b = NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * getVehicle()->_lastDT;\r\n\t\treturn b;\r\n\t}\r\n\t\r\n\treturn NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * 60.0f;\r\n}\r\nVxVector pWheel2::getWheelPos() const\r\n{\r\n\treturn getFrom(mWheelShape->getLocalPosition());\r\n}\r\n\r\nvoid pWheel2::setAngle(float angle)\r\n{\r\n\tmWheelShape->setSteerAngle(-angle);\r\n}\r\n\r\nNxActor*pWheel2::getTouchedActor()const\r\n{\r\n\tNxWheelContactData wcd;\r\n\tNxShape * s = mWheelShape->getContact(wcd);\t\r\n\tif (s)\r\n\t{\r\n\t\tif (&s->getActor())\r\n\t\t{\r\n\t\t\treturn &s->getActor();\r\n\t\t}else\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t\t\r\n\t}else\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\treturn NULL;\r\n\t//return s ? &s->getActor() : NULL;\r\n}\r\nfloat pWheel2::getAxleSpeed()const\r\n{\r\n\tif (mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getAxleSpeed();\r\n\t}\r\n\treturn -1.f;\r\n\r\n}\r\nbool pWheel2::hasGroundContact() const\r\n{\r\n\treturn getTouchedActor() != NULL; \r\n}\r\nvoid pWheel2::tick(bool handBrake, float motorTorque, float brakeTorque, float dt)\r\n{\r\n\tif(handBrake && getWheelFlag(WF_AffectedByHandbrake))\r\n\t\tbrakeTorque = 1000.0f;\r\n\r\n\tif(getWheelFlag(WF_Accelerated)) \r\n\t\tmWheelShape->setMotorTorque(motorTorque);\r\n\t\r\n\tmWheelShape->setBrakeTorque(brakeTorque);\r\n\r\n\t/*\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\trollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\tNxWheelContactData wcd;\r\n\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( cShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\tfloat rAngle = rollAngle;\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rollAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n\t*/\r\n}\r\nVxVector pWheel2::getGroundContactPos()const\r\n{\r\n\tVxVector pos = getWheelPos()+VxVector(0, -mWheelShape->getRadius(), 0);\r\n\r\n\tif (pos.Magnitude())\r\n\t{\r\n\t\tint op2 = 0 ; \r\n\t\top2++;\r\n\t}\r\n\treturn pos;\r\n}\r\n\r\nfloat pWheel2::getSuspensionTravel()const\r\n{\r\n\r\n\tif (mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getSuspensionTravel();\r\n\t}\r\n\treturn 0.0f;\r\n}\r\n\r\n\r\nbool pWheel2::setSuspensionSpring(const pSpring& spring)\r\n{\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\twShape->setSuspension(sLimit);\r\n\treturn true;\r\n}\r\n\r\nvoid pWheel2::setAxleSpeed(float speed)\r\n{\r\n\r\n\tgetWheelShape()->setAxleSpeed(speed);\r\n}\r\n\r\nvoid pWheel2::setMotorTorque(float torque)\r\n{\r\n\tgetWheelShape()->setMotorTorque(torque);\r\n}\r\nvoid pWheel2::setBreakTorque(float torque)\r\n{\r\n\tgetWheelShape()->setBrakeTorque(torque);\r\n}\r\n\r\nvoid pWheel2::setSuspensionTravel(float travel)\r\n{\r\n\tgetWheelShape()->setSuspensionTravel(travel);\r\n}\r\npWheel2::pWheel2(pRigidBody *body,pWheelDescr *descr,CK3dEntity *wheelShapeReference): pWheel(body,descr) ,xEngineObjectAssociation(wheelShapeReference,wheelShapeReference->GetID())\r\n{\r\n\tthis->setBody(body);\r\n\tthis->setEntity(wheelShapeReference);\r\n\r\n\r\n\r\n\r\n\tbrakingFactor = 0.05f;\r\n\tfrictionCoeff = 1.0f;\r\n\trollingCoeff = 1.0f;\r\n\r\n\tmWheelShape = NULL;\r\n\tmWheelFlags = descr->wheelFlags;\r\n\t_wheelRollAngle = 0.0f;\r\n\tmVehicle = NULL;\r\n\tlastContactData = new pWheelContactData();\r\n\tdifferentialSide=0;\r\n\tdifferential = NULL;\r\n\thadContact = false;\r\n\r\n\r\n\tslip2FCVelFactor = 1.0f;\r\n\r\n\t\r\n\ttanSlipAngle=0;\r\n\t slipAngle=0;\r\n\t slipRatio=0;\r\n\t lastU=0;\r\n\t signU=1; // u>=0\r\n\t differentialSlipRatio=0;\r\n\r\n\tmaxBrakingTorque = 400.0;\r\n\r\n\r\n\t\r\n\t\r\n\t\r\n\tlock = 80.0f;\r\n\tackermanFactor=1.1f;\r\n\ttireRate = 180000;\r\n\tmass = 10.0f;\r\n\r\n\r\n\t\r\n\tradius = descr->radius.value;\r\n\tradiusLoaded = descr->radius.value;\r\n\r\n\tSetInertia(5.3f);\r\n\t\t\t\t\r\n\trelaxationLengthLat=0.91f;\r\n\trelaxationLengthLong=0.091f;\r\n\t\r\n\tdampingSpeed = 0.15f;\r\n\tdampingCoefficientLong = 1.5f;\r\n\tdampingFactorLat=0.75;\r\n\tdampingFactorLong=1.5f;\r\n\tdampingCoefficientLat = 1.066f;\r\n\r\n\r\n\ttoe =-(1.0f/RR_RAD_DEG_FACTOR);\r\n\r\n\trotation.Set(0,0,0);\r\n\trotation.y = toe;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// pacejka\r\n\t//\r\n\tpacejka.setToDefault();\r\n\t//Statistical data (SR, SA in radians)\r\n\toptimalSR=0.09655f;\r\n\toptimalSA=0.18296f;\r\n\r\n\r\n\r\n\r\n\r\n\tstateFlags = 0;\r\n\tlowSpeedFactor = 0.0f;\r\n\tslipAngle = 0.0f;\r\n\tslipRatio = 0.0f;\r\n\t\r\n\toverrideMask = 0;\r\n\tcallMask.set(CB_OnPostProcess,1);\r\n\tcallMask.set(CB_OnPreProcess,1);\r\n\r\n\r\n\tpreScript = postScript = 0;\r\n\tentity = NULL;\r\n\t\r\n\twheelContactModifyCallback =NULL;\r\n\r\n\tdifferential = NULL;\r\n\tdifferentialSide =-1;\r\n\r\n\r\n\r\n\r\n}\r\nvoid pWheel2::setDifferential(pDifferential *diff,int side)\r\n{\r\n\tdifferential=diff; differentialSide=side; \r\n\r\n}\r\nfloat pWheel2::getEndBrakingTorqueForWheel()\r\n{\r\n\tif(differential)\r\n\t{\r\n\t\treturn differential->GetBreakTorqueOut(differentialSide);\r\n\t}\r\n\treturn 0.0f;\r\n}\r\nfloat pWheel2::getEndTorqueForWheel()\r\n{\r\n\tif(differential)\r\n\t{\r\n//*2*PI/60.0f\r\n\t\treturn differential->GetTorqueOut(differentialSide);\r\n\t}\r\n\treturn 0.0f;\r\n}\r\n\r\nfloat pWheel2::getEndAccForWheel()\r\n{\r\n\tif(differential)\r\n\t{\r\n\t\treturn differential->GetAccOut(differentialSide);\r\n\t}\r\n\treturn 0.0f;\r\n}\r\n\r\nfloat pWheel2::getWheelBreakTorque()\r\n{\r\n\tif(mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getBrakeTorque();\r\n\t}\r\n\treturn 0.0f;\r\n}\r\nfloat pWheel2::getWheelTorque()\r\n{\r\n\tif(mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getMotorTorque();\r\n\t}\r\n\treturn 0.0f;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n\r\nvoid pWheel2::_tick(float dt)\r\n{\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape) return;\r\n\r\n\r\n\tNxVec3 _localVelocity;\r\n\tbool _breaking=false;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\r\n\t//\r\n\tNxWheelContactData wcd; \r\n\tNxShape* contactShape = wShape->getContact(wcd);\r\n\r\n\tif (contactShape)\r\n\t{\r\n\r\n\t\tNxVec3 relativeVelocity;\r\n\t\tif ( !contactShape->getActor().isDynamic())\r\n\t\t{\r\n\t\t\trelativeVelocity = getActor()->getLinearVelocity();\r\n\t\t} else {\r\n\t\t\trelativeVelocity = getActor()->getLinearVelocity() - contactShape->getActor().getLinearVelocity();\r\n\t\t}\r\n\t\tNxQuat rotation = getActor()->getGlobalOrientationQuat();\r\n\r\n\t\t_localVelocity = relativeVelocity;\r\n\t\trotation.inverseRotate(_localVelocity);\r\n\t\t_breaking = false; //NxMath::abs(_localVelocity.z) < ( 0.1 );\r\n\t\t//\t\t\t\t\twShape->setAxleSpeed()\r\n\t}\r\n\r\n\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\t\r\n\trollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n\t//rollAngle+=wShape->getAxleSpeed() * (1.0f/60.0f /*dt* 0.01f*/);\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( contactShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\r\n\tfloat rAngle = getWheelRollAngle();\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxVec3 p0;\r\n\tNxVec3 dir;\r\n\t/*\r\n\tgetWorldSegmentFast(seg);\r\n\tseg.computeDirection(dir);\r\n\tdir.normalize();\r\n\t*/\r\n\tNxReal r = wShape->getRadius();\r\n\tNxReal st = wShape->getSuspensionTravel();\r\n\tNxReal steerAngle = wShape->getSteerAngle();\r\n\tp0 = wheelPose.t; //cast from shape origin\r\n\twheelPose.M.getColumn(1, dir);\r\n\tdir = -dir;\t//cast along -Y.\r\n\tNxReal castLength = r + st;\t//cast ray this long\r\n\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n}\r\n\r\npWheelContactData* pWheel2::getContact()\r\n{\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape)\r\n\t{\r\n\t\treturn new pWheelContactData();\r\n\t}\r\n\t\r\n\tNxWheelContactData wcd; \r\n\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\r\n\tpWheelContactData result;\r\n\tresult.contactEntity = NULL;\r\n\r\n\r\n\tif (contactShape)\r\n\t{\r\n\r\n\t\tresult.contactForce = wcd.contactForce;\r\n\t\tresult.contactNormal = getFrom(wcd.contactNormal);\r\n\t\tresult.contactPoint= getFrom(wcd.contactPoint);\r\n\t\tresult.contactPosition= wcd.contactPosition;\r\n\r\n\t\t\r\n\t\tresult.lateralDirection= getFrom(wcd.lateralDirection);\r\n\t\tresult.lateralImpulse= wcd.lateralImpulse;\r\n\t\tresult.lateralSlip = wcd.lateralSlip;\r\n\t\t\r\n\t\tresult.longitudalDirection = getFrom(wcd.longitudalDirection);\r\n\t\tresult.longitudalImpulse = wcd.longitudalImpulse;\r\n\t\tresult.longitudalSlip= wcd.longitudalSlip;\r\n\r\n\t\tpSubMeshInfo *sInfo = static_cast(contactShape->userData);\r\n\t\tif (sInfo->entID)\r\n\t\t{\r\n\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\tif (obj)\r\n\t\t\t{\r\n\t\t\t\tresult.contactEntity = (CK3dEntity*)obj;\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tresult.contactEntity = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tresult.otherShapeMaterialIndex = contactShape->getMaterial();\r\n\t\t\r\n\t\tNxMaterial* otherMaterial = contactShape->getActor().getScene().getMaterialFromIndex(contactShape->getMaterial());\r\n\t\tif (otherMaterial)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(result.otherMaterial,otherMaterial);\r\n\t\t}\r\n\t}\r\n\treturn &result;\r\n}\r\n\r\nvoid pWheel2::_updateVirtoolsEntity(bool position,bool rotation)\r\n{\r\n\r\n\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(getEntID()));\r\n\tif (ent && position) \r\n\t{\r\n\r\n\t\tNxWheelShape *wShape = getWheelShape();\r\n\t\tNxMat34 pose = wShape->getGlobalPose();\r\n\t\tNxWheelContactData wcd; \r\n\t\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\tNxVec3 suspensionOffsetDirection;\r\n\t\tpose.M.getColumn(1, suspensionOffsetDirection);\r\n\t\tsuspensionOffsetDirection =-suspensionOffsetDirection;\r\n\r\n\t\tif (contactShape && wcd.contactForce > -1000)\r\n\t\t{\r\n\t\t\tNxVec3 toContact = wcd.contactPoint - pose.t;\r\n\t\t\tdouble alongLength = suspensionOffsetDirection.dot(toContact);\r\n\t\t\tNxVec3 across = toContact - alongLength * suspensionOffsetDirection;\r\n\t\t\tdouble r = wShape->getRadius();\r\n\t\t\tdouble pullBack = sqrt(r*r - across.dot(across));\r\n\t\t\tpose.t += (alongLength - pullBack) * suspensionOffsetDirection;\r\n\t\t} else {\r\n\t\t\tpose.t += wShape->getSuspensionTravel() * suspensionOffsetDirection;\r\n\t\t}\r\n\r\n\t\tVxVector oPos = getFrom(pose.t);\r\n\t\tent->SetPosition(&oPos);\r\n\r\n\t\tif (hasGroundContact())\r\n\t\t{\r\n\r\n\t\t\tNxWheelShape *wShape = getWheelShape();\r\n\t\t\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n/*\t\t\tNxWheelContactData wcd;\r\n\t\t\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\t\t\tNxReal stravel = wShape->getSuspensionTravel();\r\n\t\t\tNxReal radius = wShape->getRadius();\r\n\r\n\t\t\tVxVector gPos = getFrom(getWheelPose().t);\r\n\r\n\t\t\t/*\r\n\t\t\tif( cShape && wcd.contactPosition <= (stravel + radius) ) \r\n\t\t\t{\r\n\t\t\t}*/\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t/*VxVector gPos = getFrom(getWheelPose().t);\r\n\t\t\t//gPos*=-1.0f;\r\n\t\t\tgPos -=getWheelPos();\r\n\t\t\tV\t3.\r\n\t\t\t\txVector gPos2 = getFrom(getWheelShape()->getLocalPose().t);\r\n\t\t\tent->SetPosition(&gPos2,getBody()->GetVT3DObject());\r\n\t\t\t*/\r\n\t\t}else\r\n\t\t{\r\n//\t\t\tVxVector gPos = getWheelPos();\r\n//\t\t\tent->SetPosition(&gPos,getBody()->GetVT3DObject());\r\n\t\t}\r\n\t}\r\n\tif (ent && rotation)\r\n\t{\r\n\r\n\r\n\t\t//float rollAngle = getWheelRollAngle();\r\n\t\t//rollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n \r\n\t\tVxQuaternion rot = pMath::getFrom( getWheelPose().M );\r\n\t\tent->SetQuaternion(&rot,NULL);\r\n\t}\r\n\r\n\r\n\t/*\r\n\r\n\r\n\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\r\n\t\r\n\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\r\n\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\tNxWheelContactData wcd;\r\n\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( cShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\tfloat rAngle = rollAngle;\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rollAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n\r\n\t*/\r\n}\r\n\r\nvoid pWheel2::_updateAgeiaShape(bool position,bool rotation)\r\n{\r\n\r\n}\r\n\r\nfloat pWheel2::getRadius()const\r\n{\r\n\treturn mWheelShape->getRadius();\r\n}\r\n\r\nfloat pWheel2::getRpm() const\r\n{\r\n\r\n\tfloat a = NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * 60.0f;\r\n\tif (getVehicle())\r\n\t{\r\n\r\n\t\tfloat b = NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * getVehicle()->_lastDT;\r\n\t\treturn b;\r\n\t}\r\n\t\r\n\treturn NxMath::abs(mWheelShape->getAxleSpeed())/NxTwoPi * 60.0f;\r\n}\r\nVxVector pWheel2::getWheelPos() const\r\n{\r\n\treturn getFrom(mWheelShape->getLocalPosition());\r\n}\r\n\r\nvoid pWheel2::setAngle(float angle)\r\n{\r\n\tmWheelShape->setSteerAngle(-angle);\r\n}\r\n\r\nNxActor*pWheel2::getTouchedActor()const\r\n{\r\n\tNxWheelContactData wcd;\r\n\tNxShape * s = mWheelShape->getContact(wcd);\t\r\n\tif (s)\r\n\t{\r\n\t\tif (&s->getActor())\r\n\t\t{\r\n\t\t\treturn &s->getActor();\r\n\t\t}else\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t\t\r\n\t}else\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\treturn NULL;\r\n\t//return s ? &s->getActor() : NULL;\r\n}\r\nfloat pWheel2::getAxleSpeed()const\r\n{\r\n\tif (mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getAxleSpeed();\r\n\t}\r\n\treturn -1.f;\r\n\r\n}\r\nbool pWheel2::hasGroundContact() const\r\n{\r\n\treturn getTouchedActor() != NULL; \r\n}\r\nvoid pWheel2::tick(bool handBrake, float motorTorque, float brakeTorque, float dt)\r\n{\r\n\tif(handBrake && getWheelFlag(WF_AffectedByHandbrake))\r\n\t\tbrakeTorque = 1000.0f;\r\n\r\n\tif(getWheelFlag(WF_Accelerated)) \r\n\t\tmWheelShape->setMotorTorque(motorTorque);\r\n\t\r\n\tmWheelShape->setBrakeTorque(brakeTorque);\r\n\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tfloat rollAngle = getWheelRollAngle();\r\n\trollAngle+=wShape->getAxleSpeed() * (dt* 0.01f);\r\n\r\n\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\trollAngle-= NxTwoPi;\r\n\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\trollAngle+= NxTwoPi;\r\n\r\n\tsetWheelRollAngle(rollAngle);\r\n\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\tNxWheelContactData wcd;\r\n\tNxShape* cShape = wShape->getContact(wcd);\t\r\n\tNxReal stravel = wShape->getSuspensionTravel();\r\n\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( cShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + getRadius(), wheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - getSuspensionTravel(), wheelPose.t.z );\r\n\t}\r\n\r\n\tfloat rAngle = rollAngle;\r\n\tfloat steer = wShape->getSteerAngle();\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( wShape->getSteerAngle() );\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(rollAngle);\r\n\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\tsetWheelPose(wheelPose);\r\n}\r\nVxVector pWheel2::getGroundContactPos()const\r\n{\r\n\tVxVector pos = getWheelPos()+VxVector(0, -mWheelShape->getRadius(), 0);\r\n\r\n\tif (pos.Magnitude())\r\n\t{\r\n\t\tint op2 = 0 ; \r\n\t\top2++;\r\n\t}\r\n\treturn pos;\r\n}\r\n\r\nfloat pWheel2::getSuspensionTravel()const\r\n{\r\n\r\n\tif (mWheelShape)\r\n\t{\r\n\t\treturn mWheelShape->getSuspensionTravel();\r\n\t}\r\n\treturn 0.0f;\r\n}\r\n\r\n\r\nbool pWheel2::setSuspensionSpring(const pSpring& spring)\r\n{\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tNxWheelShape *wShape = getWheelShape();\r\n\tif (!wShape)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\twShape->setSuspension(sLimit);\r\n\treturn true;\r\n}\r\n\r\nvoid pWheel2::setAxleSpeed(float speed)\r\n{\r\n\r\n\tgetWheelShape()->setAxleSpeed(speed);\r\n}\r\n\r\nvoid pWheel2::setMotorTorque(float torque)\r\n{\r\n\tgetWheelShape()->setMotorTorque(torque);\r\n}\r\nvoid pWheel2::setBreakTorque(float torque)\r\n{\r\n\tgetWheelShape()->setBrakeTorque(torque);\r\n}\r\n\r\nvoid pWheel2::setSuspensionTravel(float travel)\r\n{\r\n\tgetWheelShape()->setSuspensionTravel(travel);\r\n}\r\n\r\n\r\npWheel2::pWheel2(pRigidBody *body, pWheelDescr *descr) : pWheel(body,descr)\r\n{\r\n\tthis->setBody(body);\r\n\tmWheelShape = NULL;\r\n\tmWheelFlags = descr->wheelFlags;\r\n\t_wheelRollAngle = 0.0f;\r\n\tmVehicle = NULL;\r\n\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointPrismatic::pJointPrismatic(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Prismatic)\r\n{\r\n\r\n}\r\n\r\n\r\nvoid pJointPrismatic::setGlobalAnchor(VxVector anchor)\r\n{\r\n\r\n\r\n\tNxPrismaticJointDesc descr;\t\t\r\n\tNxPrismaticJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAnchor(getFrom(anchor));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointPrismatic::setGlobalAxis(VxVector axis)\r\n{\r\n\r\n\r\n\tNxPrismaticJointDesc descr;\t\t\r\n\tNxPrismaticJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAxis(getFrom(axis));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointPrismatic::enableCollision(int collision)\r\n{\r\n\tNxPrismaticJointDesc descr;\t\t\r\n\tNxPrismaticJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}#include \"IDistributedClasses.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n#include \"xLogger.h\"\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIDistributedClasses::deployClass(xDistributedClass*_class)\r\n{\r\n\tif (!_class)return;\r\n\t\r\n\txNetInterface *nInterface = getNetInterface();\r\n\tif (!nInterface)return;\r\n\r\n\tif (nInterface->IsServer())return;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//pickup some data :\r\n \r\n\tTNL::StringPtr className(_class->getClassName().getString());\r\n\tTNL::Int<16>entityType = _class->getEnitityType();\r\n\r\n\tTNL::VectorpropertyNames;\r\n\tTNL::Vector >nativeTypes;\r\n\tTNL::Vector >valueTypes;\r\n\tTNL::Vector >predictionTypes;\r\n\t\r\n\txDistributedPropertiesListType &props = *_class->getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\tpropertyNames.push_back( TNL::StringPtr(dInfo->mName) );\r\n\t\tnativeTypes.push_back(dInfo->mNativeType);\r\n\t\tvalueTypes.push_back(dInfo->mValueType);\r\n\t\tpredictionTypes.push_back(dInfo->mPredictionType);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we call this on the server : \r\n\tif (nInterface->getConnection())\r\n\t{\r\n\t\tnInterface->getConnection()->c2sDeployDistributedClass(className,entityType,propertyNames,nativeTypes,valueTypes,predictionTypes);\r\n\t}\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: IDistributedClasses::IDistributedClasses\r\n*\r\n* Description: \r\n* Distributed class interface destructor. \r\n* Parameters: \r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedClasses::~IDistributedClasses()\r\n{\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedClasses::IDistributedClasses(xNetInterface *netInterface) : m_NetInterface(netInterface) , m_DistrutedClasses(new xDistributedClassesArrayType() )\r\n{\r\n\t//m_DistrutedClasses = new XDistributedClassesArrayType();\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClassesArrayType* IDistributedClasses::getDistrutedClassesPtr()\r\n{\r\n\treturn m_DistrutedClasses;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClass*IDistributedClasses::createClass(const char* name,int templatetype)\r\n{\r\n\r\n\tif (!strlen(name))\t\treturn NULL;\r\n\r\n\txDistributedClassesArrayType *_classes = getDistrutedClassesPtr();\r\n\r\n\txDistributedClass *result = get(name);\r\n\r\n\tif (result ==NULL )\r\n\t{\r\n\t\tswitch(templatetype)\r\n\t\t{\r\n\t\tcase E_DC_BTYPE_3D_ENTITY:\r\n\t\t\t{\r\n\r\n\t\t\t\tresult = new xDistributed3DObjectClass();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase E_DC_BTYPE_CLIENT:\r\n\t\t\t{\r\n\t\t\t\tresult = new xDistributedClass();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase E_DC_BTYPE_SESSION:\r\n\t\t\t{\r\n\t\t\t\tresult = new xDistributedSessionClass();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tdefault:\r\n\t\t\t{\r\n\t\t\t\tresult = new xDistributedClass();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tresult->setClassName(name);\r\n\t\tresult->setEnitityType(templatetype);\r\n\t\t_classes->insert(std::make_pair(name,result));\r\n\t\t//xLogger::xLog(ELOGINFO,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"Distributed class created : %s : type : %d\",name,templatetype);\r\n\t\t//xLogger::xLog(XL_START,ELOGINFO,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"Distributed class created : %s : type : %d\",name,templatetype);\r\n\t\treturn result;\r\n\t}else\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClass*\r\nIDistributedClasses::getByIndex(int index)\r\n{\r\n\t/*if (index > 0 && index < getDistrutedClassesPtr()->size() )\r\n\t{\r\n\t\treturn *getDistrutedClassesPtr()->GetByIndex(index);\r\n\t}*/\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint \r\nIDistributedClasses::destroyClass(xDistributedClass *_class)\r\n{\r\n\tif (_class ==NULL )\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"invalid object\");\r\n\t\treturn -1;\r\n\t}\r\n\r\n\txDistributedClassesArrayType *_classes = getDistrutedClassesPtr();\r\n\txDistClassIt begin = _classes->begin();\r\n\txDistClassIt end = _classes->end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedClass *_tclass = begin->second;\r\n\t\tif (_tclass == _class)\r\n\t\t{\r\n\t\t\txNString cName = _class->getClassName().getString();\r\n\t\t\t_classes->erase(begin);\r\n\t\t\tdelete _tclass;\r\n\t\t\t//xLogger::xLog(XL_START,ELOGINFO,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"%s removed and destroyed! Classes left :%d \",cName.getString(),_classes->size());\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"couldn't find object\");\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint IDistributedClasses::getNumClasses(){\treturn getDistrutedClassesPtr()->size();}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClass*IDistributedClasses::get(const char* name)\r\n{\r\n\txDistributedClassesArrayType *_classes = getDistrutedClassesPtr();\r\n\txDistClassIt begin = _classes->begin();\r\n\txDistClassIt end = _classes->end();\r\n\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedClass *_class = begin->second;\r\n\t\tif (_class)\r\n\t\t{\r\n\t\t\tif (!strcmp(_class->getClassName().getString(),name) )\r\n\t\t\t{\r\n\t\t\t\treturn _class;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClass*IDistributedClasses::get(const char* name,int entityType)\r\n{\r\n\txDistributedClassesArrayType *_classes = getDistrutedClassesPtr();\r\n\txDistClassIt begin = _classes->begin();\r\n\txDistClassIt end = _classes->end();\r\n\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedClass *_class = begin->second;\r\n\t\tif (_class)\r\n\t\t{\r\n\t\t\tif (!strcmp(_class->getClassName().getString(),name) && _class->getEnitityType() == entityType)\r\n\t\t\t{\r\n\t\t\t\treturn _class;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IDistributedClasses::destroy()\r\n{\r\n\txDistributedClassesArrayType *_classes = getDistrutedClassesPtr();\r\n\txDistClassIt begin = _classes->begin();\r\n\txDistClassIt end = _classes->end();\r\n\t_classes->clear();\r\n\treturn;\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedClass *_class = begin->second;\r\n\t\tif (_class)\r\n\t\t{\r\n\t\t\tdelete _class;\r\n\t\t\t_class = NULL;\r\n\t\t\tbegin = _classes->begin();\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxNetInterface* IDistributedClasses::getNetInterface(){ return m_NetInterface; }\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"xDistTools.h\"\r\n\r\nxDistributedSessionClass::xDistributedSessionClass() : xDistributedClass()\r\n{\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\n int xDistributedSessionClass::getFirstUserField(){ return 6; }\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\n int\r\nxDistributedSessionClass::getUserFieldBitValue(int walkIndex)\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\tif (dInfo->mNativeType==E_DC_S_NP_USER )\r\n\t\t{\r\n\t\t\tif (i ==walkIndex)\r\n\t\t\t{\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tuserTypeCounter++;\r\n\t\t}\r\n\t}\r\n\tint result = getFirstUserField();\r\n result +=userTypeCounter;\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nint\r\nxDistributedSessionClass::getInternalUserFieldIndex(int inputIndex)\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\tif (dInfo->mNativeType==E_DC_S_NP_USER)\r\n\t\t{\r\n\t\t\tif (userTypeCounter == inputIndex)\r\n\t\t\t{\r\n\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t\tuserTypeCounter++;\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nint xDistributedSessionClass::getUserFieldCount()\r\n{\r\n\tint userTypeCounter = 0;\r\n\txDistributedPropertiesListType &props = *getDistributedProperties();\r\n\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t{\r\n\t\tif (props[i]->mNativeType==E_DC_S_NP_USER)\r\n\t\t\tuserTypeCounter++;\r\n\t}\r\n\treturn userTypeCounter;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributedSessionClass::addProperty(int nativeType,int predictionType)\r\n{\r\n\txDistributedPropertyInfo *result = exists(nativeType);\r\n\tif (!result)\r\n\t{\r\n\t\tTNL::StringPtr name = NativeTypeToString(nativeType);\r\n\t\tint valueType = NativeTypeToValueType(nativeType);\r\n\t\tresult = new xDistributedPropertyInfo( name ,valueType , nativeType ,predictionType );\r\n\t\tgetDistributedProperties()->push_back( result );\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:\r\n*\r\n* Description:\r\n*\r\n* Parameters:\r\n*\r\n* Returns:\r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributedSessionClass::addProperty(const char*name,int type,int predictionType)\r\n{\r\n\txDistributedPropertyInfo *result = exists(name);\r\n\tif (!result)\r\n\t{\r\n\t\tresult = new xDistributedPropertyInfo( name ,type,E_DC_S_NP_USER ,predictionType );\r\n\t\tgetDistributedProperties()->push_back( result );\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxNString xDistributedSessionClass::NativeTypeToString(int nativeType)\r\n{\r\n\r\n\tswitch(nativeType)\r\n\t{\r\n\tcase E_DC_S_NP_MAX_USERS:\r\n\t\treturn TNL::StringPtr(\"Max Users\");\r\n\t\tbreak;\r\n\tcase E_DC_S_NP_PASSWORD:\r\n\t\treturn TNL::StringPtr(\"Password\");\r\n\t\tbreak;\r\n\tcase E_DC_S_NP_LOCKED:\r\n\t\treturn TNL::StringPtr(\"Is Locked\");\r\n\tcase E_DC_S_NP_NUM_USERS:\r\n\t\treturn TNL::StringPtr(\"Num Users\");\r\n\tcase E_DC_S_NP_TYPE:\r\n\t\treturn TNL::StringPtr(\"Session Type\");\r\n\tdefault:\r\n\t\treturn TNL::StringPtr(\"Unknown\");\r\n\t\tbreak;\r\n\t}\r\n\treturn TNL::StringPtr(\"null\");\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint xDistributedSessionClass::NativeTypeToValueType(int nativeType)\r\n{\r\n\tint result = 0;\r\n\tswitch(nativeType)\r\n\t{\r\n\t\tcase E_DC_S_NP_TYPE:\r\n\t\tcase E_DC_S_NP_LOCKED:\r\n\t\tcase E_DC_S_NP_NUM_USERS:\r\n\t\tcase E_DC_S_NP_MAX_USERS:\r\n\t\t\treturn E_DC_PTYPE_INT;\r\n\t\tcase E_DC_S_NP_PASSWORD:\r\n\t\t\treturn E_DC_PTYPE_STRING;\r\n\t}\r\n\treturn E_DC_PTYPE_UNKNOWN;\r\n}/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Bend\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorBendDecl();\r\nCKERROR CreateBendProto(CKBehaviorPrototype **);\r\nint Bend(const CKBehaviorContext& behcontext);\r\n//CKERROR MeshModificationsCallBack(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorBendDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Bend2\");\t\r\n\tod->SetDescription(\"Bends a mesh uniformly along an axis with an angle and a direction of bending.\");\r\n\t/* rem:\r\n\tIn : triggers the process.
\r\n\tExit : is activated when the process is completed.
\r\n\t
\r\n\tAngle : angle to bend from the vertical plane.
\r\n\tDirection : direction of the bend relative to the horizontal plane.
\r\n\tAxis : vector that specifies the axis that the object will bend along.
\r\n\tReset Mesh: if TRUE, the mesh is resetted to its initial conditions at activation.
\r\n\t
\r\n\tThe model need to be somewhat facetted for a good result.
\r\n\t*/\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7c9a7008,0x6b0f1d1f));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00020000);\r\n\tod->SetCreationFunction(CreateBendProto);\r\n\tod->SetCompatibleClassId(CKCID_3DOBJECT);\r\n\tod->SetCategory(\"Mesh Modifications/Deformation\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateBendProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"Bend\");\r\n\tif(!proto) \treturn CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Exit\");\r\n\t\r\n\tproto->DeclareInParameter(\"Angle\", CKPGUID_ANGLE, \"0:90\" );\r\n\tproto->DeclareInParameter(\"Direction\", CKPGUID_FLOAT ,\"0.0\");\r\n\t// To change by Radio buttons\r\n\tproto->DeclareInParameter(\"Axis\", CKPGUID_VECTOR, \"0,0,1\" );\r\n\tproto->DeclareInParameter(\"Reset Mesh\", CKPGUID_BOOL, \"TRUE\" );\r\n\tproto->DeclareInParameter(\"Normal Recalculation\", CKPGUID_BOOL, \"TRUE\" );\r\n\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_VOIDBUF );\t// Data\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_BOX );\t\t// Initial Box\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Bend);\r\n\r\n//\tproto->SetBehaviorCallbackFct(MeshModificationsCallBack);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint Bend(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\t\r\n\t// we get the entity\r\n\tCK3dEntity *ent = (CK3dEntity *) beh->GetTarget();\r\n\r\n\t// we get the angle\r\n\tfloat angle;\r\n\tbeh->GetInputParameterValue(0,&angle);\r\n\tangle *= 0.5f;\r\n\r\n\t// we get the direction\r\n\tfloat direction;\r\n\tbeh->GetInputParameterValue(1,&direction);\r\n\r\n\t// we get the axis\r\n\tVxVector axis;\r\n\tbeh->GetInputParameterValue(2,&axis);\r\n\tint naxis=0;\r\n\twhile (axis[naxis]==0.0f) naxis++;\r\n\r\n\t// we get the mesh\r\n\tCKMesh *mesh = ent->GetCurrentMesh();\r\n\tCKDWORD vStride=0;\r\n\tBYTE* varray = (BYTE*)mesh->GetModifierVertices(&vStride);\r\n\tint pointsNumber = mesh->GetModifierVertexCount();\r\n/*\r\n\tCKBOOL resetmesh = TRUE;\r\n\tbeh->GetInputParameterValue(3,&resetmesh);\r\n\tif (resetmesh) { // The Mesh must be resetted\r\n\t\tif(beh->GetVersion() < 0x00020000) { // Old Version with vertices stuffed inside\r\n\t\t\t// we get the saved position\r\n\t\t\tVxVector* savePos = (VxVector*)beh->GetLocalParameterWriteDataPtr(0);\r\n\t\t\t\r\n\t\t\tBYTE* temparray = varray;\r\n\t\t\tfor(int i=0;iGetObjectInitialValue(mesh);\t\t\t\t\r\n\t\t\tif(chunk) mesh->LoadVertices(chunk);\r\n\t\t\tvarray\t\t\t= (BYTE*)mesh->GetModifierVertices(&vStride);\r\n\t\t\tpointsNumber\t= mesh->GetModifierVertexCount();\r\n\t\t\tconst VxBbox& bbox = mesh->GetLocalBox();\r\n\t\t\tbeh->SetLocalParameterValue(1,&bbox);\r\n\t\t}\r\n\t}\r\n\r\n\tVxBbox bbox;\r\n\tbeh->GetLocalParameterValue(1,&bbox);\r\n\r\n\tVxMatrix mat;\r\n\tswitch (naxis) {\r\n\tcase 0: { VxVector vz(0.0f,1.0f,0.0f); Vx3DMatrixFromRotation(mat,vz,-HALFPI); } break; //x\r\n\tcase 1:\t{ VxVector vx(0.0f,0.0f,1.0f); Vx3DMatrixFromRotation(mat,vx,-HALFPI); } break; //y\r\n\tcase 2: { mat = VxMatrix::Identity(); } break; //z\r\n\t}\r\n\r\n\t// attention inversion y / z\r\n\tif (direction) {\r\n\t\tVxMatrix rot;\r\n\t\tVxVector vz(0.0f,0.0f,1.0f); \r\n\t\tVx3DMatrixFromRotation(rot,vz,direction);\r\n\t\tVx3DMultiplyMatrix(mat,rot,mat);\r\n\t}\r\n\r\n\tfloat r,len;\r\n\tswitch (naxis) {\r\n\tcase 0: len = bbox.Max.x - bbox.Min.x; break;\r\n\tcase 1:\t len = bbox.Max.y - bbox.Min.y; break;\r\n\tcase 2: len = bbox.Max.z - bbox.Min.z; break;\r\n\t}\r\n\t\r\n\t// Skip the singularity\r\n\tif (fabs(angle) <0.0001) {\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t} else {\r\n\t\tr = len/angle;\r\n\t}\t\r\n\t\r\n\t\r\n\tVxMatrix invmat;\r\n\tVx3DInverseMatrix(invmat,mat);\r\n\t\r\n\t// we move all the points\r\n\tfloat x,y,c,s,yr;\r\n\tVxVector v,n;\r\n\t\r\n\tfloat invr = 1.0f/r;\r\n\r\n\tCKBOOL normalc = TRUE;\r\n\tbeh->GetInputParameterValue(4,&normalc);\r\n\r\n\tCKDWORD nStride=0;\r\n\tBYTE* narray = (BYTE*)mesh->GetNormalsPtr(&nStride);\r\n\tif (CKIsChildClassOf(mesh,CKCID_PATCHMESH) || !normalc) narray = NULL;\r\n\t\r\n\tfor(int i=0;iModifierVertexMove(FALSE,TRUE);\t\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0,TRUE);\r\n\t*/\r\n\treturn CKBR_OK;\r\n}\r\n#include \"CPStdAfx.h\"\r\n#include \r\n\r\n\r\n#include \"profile/GProfile.h\"\r\n\t\r\n//used from LoadProfile\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* Enigne Parameter Initiating \t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nengine_profile\r\nvtBaseWindow::LoadProfile(const char* _iniFile){\r\n\r\n\t\r\n\tengine_profile res;\r\n\r\n\t\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,_iniFile);\r\n\r\n\tGProfile PProfile(Ini);\r\n\tPProfile.Load();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Path stuff :\r\n\t\r\n\tGProfile::Section *pSection = (GProfile::Section*)PProfile.FindSection(\"PATHS\");\r\n\t\r\n\t\tstrcpy(res.RenderPath,PProfile.FindKey(\"RenderPath\",pSection)->m_strValue);\r\n\t\tstrcpy(res.ManagerPath,PProfile.FindKey(\"ManagerPath\",pSection)->m_strValue);\r\n\t\tstrcpy(res.BehaviorPath,PProfile.FindKey(\"BehaviorPath\",pSection)->m_strValue);\r\n\t\tstrcpy(res.PluginPath,PProfile.FindKey(\"PluginPath\",pSection)->m_strValue);\r\n\t\tstrcpy(res.LoadFile,PProfile.FindKey(\"LoadFile\",pSection)->m_strValue);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Engine Stuff\r\n\r\n\tpSection = (GProfile::Section*)PProfile.FindSection(\"Engine\");\r\n\r\n\t\tres.g_DisableSwitch = PProfile.GetInt(pSection->m_strName,\"DisableSwitch\",false);\r\n\t\tres.g_Width = PProfile.GetInt(pSection->m_strName,\"Width\",false);\r\n\t\tres.g_Height= PProfile.GetInt(pSection->m_strName,\"Height\",false);\r\n\t\tres.g_Bpp = PProfile.GetInt(pSection->m_strName,\"Bpp\",false);\r\n\t\tres.g_FullScreenDriver = PProfile.GetInt(pSection->m_strName,\"Driver\",false);\r\n\t\tres.g_GoFullScreen = PProfile.GetInt(pSection->m_strName,\"FullScreen\",false);\r\n\t\tres.g_RefreshRate = PProfile.GetInt(pSection->m_strName,\"RefreshRate\",false);\r\n\t\tres.g_Mode = PProfile.GetInt(pSection->m_strName,\"Mode\",false);\r\n\t\t\r\n\tPProfile.Destroy();\r\n\t\r\n\r\n\treturn res;\r\n\t\r\n}#pragma once\r\n\r\n//by default these functions are called in vtAgeiaInterfacecallback.cpp\r\n//if you do not use callback (do not have vtAgeiaInterfacecallback.cpp), you should call these functions manually\r\n\r\n//to add a menu in Virtools Dev main menu.\r\nvoid InitMenu();\r\n//to remove the menu from Virtools Dev main menu\r\nvoid RemoveMenu();\r\n//to fill menu with your own commands\r\nvoid UpdateMenu();\r\n\r\n#define STR_MAINMENUNAME\t\"vtAgeiaInterface Menu\"\r\n#ifndef __VTCXPRECOMP_H\r\n#define __VTCXPRECOMP_H\r\n\r\n#include \"VxMath.h\"\r\n#include \"CKAll.h\"\r\n\r\n\r\n#undef min\r\n#undef max\r\n\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"NXU_helper.h\" // NxuStream helper functions.\r\n#include \"NXU_PhysicsInstantiator.h\"\r\n\r\n#include \"UserAllocator.h\"\r\n#include \"ErrorStream.h\"\r\n#include \"Utilities.h\"\r\n\r\nstatic ErrorStream gErrorStream;\r\nstatic pSerializer *gSerializer = NULL;\r\n\r\nvoid pSerializer::parseFile(const char*filename,int flags)\r\n{\r\n\r\n\tif(!GetPMan()->getPhysicsSDK())\r\n\t\treturn;\r\n\r\n\r\n\tif (!loadCollection(filename,1))\r\n\t{\r\n\t\treturn ;\r\n\t}\r\n\r\n\r\n\tNXU::instantiateCollection(mCollection, *GetPMan()->getPhysicsSDK(), 0, 0, 0);\r\n\tNXU::NxuPhysicsInstantiator Instantiator(mCollection);\r\n\tInstantiator.instantiate(*GetPMan()->getPhysicsSDK());\r\n\tint sCount = mCollection->mScenes.size();\r\n\r\n\tfor (NxU32 i=0; imScenes.size(); i++)\r\n\t{\r\n\t\tNXU::NxSceneDesc *sd = mCollection->mScenes[i];\r\n\r\n\t\tfor (NxU32 j=0; jmActors.size(); j++)\r\n\t\t{\r\n\r\n\t\t\tNXU::NxActorDesc *ad = sd->mActors[j];\r\n\t\t\tconst char*name = ad->name;\r\n\t\t\tXString nameStr(name);\r\n\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)ctx()->GetObjectByNameAndClass(nameStr.Str(),CKCID_3DOBJECT);\r\n\t\t\tif (ent)\r\n\t\t\t{\r\n\t\t\t\tpRigidBody *body = GetPMan()->getBody(nameStr.CStr());\r\n\t\t\t\tif (body)\r\n\t\t\t\t\tbody->readFrom(ad,0);\r\n\t\t\t\telse\r\n\t\t\t\t\tbody = pFactory::Instance()->createBody(ent,NULL,ad,1);\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif ( ad->mHasBody ) // only for dynamic actors\r\n\t\t\t{\r\n\t\t\t\tfor (NxU32 k=0; kmShapes.size(); k++)\r\n\t\t\t\t{\r\n\t\t\t\t\tNXU::NxShapeDesc *shape = ad->mShapes[k];\r\n\t\t\t\t\tNxVec3 locPos = shape->localPose.t;\r\n\t\t\t\t\tNxQuat localQuad = shape->localPose.M;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\nclass MyUserNotify: public NXU_userNotify, public NXU_errorReport\r\n{\r\npublic:\r\n\tvirtual void NXU_errorMessage(bool isError, const char *str)\r\n\t{\r\n\t\tif (isError)\r\n\t\t{\r\n\t\t\tprintf(\"NxuStream ERROR: %s\\r\\n\", str);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tprintf(\"NxuStream WARNING: %s\\r\\n\", str);\r\n\t\t}\r\n\t}\r\n\r\n\tvirtual void\tNXU_notifyScene(NxU32 sno,\tNxScene\t*scene,\tconst\tchar *userProperties)\r\n\t{\r\n\t\r\n\t};\r\n\r\n\t\r\n\r\n};\r\nMyUserNotify gUserNotify;\r\n\r\n\r\n\r\n\r\n\r\nbool pSerializer::overrideBody(pRigidBody *body,int flags)\r\n{\r\n\r\n\tif (!mCollection)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tNXU::instantiateCollection(mCollection, *GetPMan()->getPhysicsSDK(), 0, 0, 0);\r\n\tNXU::NxuPhysicsInstantiator Instantiator(mCollection);\r\n\tInstantiator.instantiate(*GetPMan()->getPhysicsSDK());\r\n\r\n\tint sCount = mCollection->mScenes.size();\r\n\tfor (NxU32 i=0; imScenes.size(); i++)\r\n\t{\r\n\r\n\t\tNXU::NxSceneDesc *sd = mCollection->mScenes[i];\r\n\r\n\t\tfor (NxU32 j=0; jmActors.size(); j++)\r\n\t\t{\r\n\r\n\t\t\tNXU::NxActorDesc *ad = sd->mActors[j];\r\n\t\t\tconst char*name = ad->name;\r\n\t\t\tXString nameStr(name);\r\n\r\n\r\n\t\t\tif ( ad->mHasBody ) // only for dynamic actors\r\n\t\t\t{\r\n\t\t\t\tfor (NxU32 k=0; kmShapes.size(); k++)\r\n\t\t\t\t{\r\n\t\t\t\t\tNXU::NxShapeDesc *shape = ad->mShapes[k];\r\n\t\t\t\t\tNxVec3 locPos = shape->localPose.t;\r\n\t\t\t\t\tNxQuat localQuad = shape->localPose.M;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn true;\r\n}\r\n\r\n\r\nint pSerializer::loadCollection(const char*fileName,int flags)\r\n{\r\n\tif (mCollection)\r\n\t{\r\n\t\treleaseCollection(mCollection);\r\n\t\tmCollection = NULL;\r\n\t}\r\n\tmCollection = getCollection(fileName,flags);\r\n\tif (mCollection)\r\n\t{\r\n\t\treturn 1;\r\n\t}else\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n}\r\n\r\n\r\npSerializer::pSerializer()\r\n{\r\n\tgSerializer = this;\r\n\tmCollection = NULL;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: Instance\r\n// FullName: vtAgeia::pSerializer::Instance\r\n// Access: public static \r\n// Returns: pSerializer*\r\n// Qualifier:\r\n//************************************\r\npSerializer*pSerializer::Instance()\r\n{\r\n\r\n\r\n\tif (!gSerializer)\r\n\t{\r\n\t\tgSerializer = new pSerializer();\r\n\t}\r\n\r\n\treturn gSerializer;\r\n}\r\n\r\nNXU::NxuPhysicsCollection* pSerializer::getCollection(const char *pFilename,int type)\r\n{\r\n\r\n\tNXU::NxuPhysicsCollection* c = NULL;\r\n\tc = NXU::loadCollection(pFilename,(NXU::NXU_FileType)type);\r\n\tif (!c)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\treturn c;\r\n}\r\n\r\n\r\nint pSerializer::saveCollection(const char*filename)\r\n{\r\n\t\r\n\tchar SaveFilename[512];\r\n\t//GetTempFilePath(SaveFilename);\r\n\tstrcat(SaveFilename, filename);\r\n\r\n\tNXU::setUseClothActiveState(false);\r\n\tNXU::setUseSoftBodyActiveState(false);\r\n\r\n\tNXU::setErrorReport(&gUserNotify);\r\n\tNXU::setEndianMode(isProcessorBigEndian());\r\n\r\n\tNXU::NxuPhysicsCollection *c = NXU::extractCollectionScene(GetPMan()->getDefaultWorld()->getScene());\r\n\tif (c)\r\n\t{\r\n\t\tchar scratch[512];\r\n\t\tXString fName(filename);\r\n\t\t//fName << \"\\0\";\r\n\t\tsprintf(scratch, \"%s.xml\", SaveFilename);\r\n\t\tprintf(\"Saving NxuStream XML file to '%s'\\r\\n\", scratch);\r\n\t\tNXU::saveCollection(c, fName.CStr(), NXU::FT_BINARY, false, false);\r\n\t\tNXU::releaseCollection(c);\r\n\r\n\t}\r\n\r\n\treleaseCollection(c);\r\n\treturn 0;\r\n}\r\n#include \r\n#include \"CKAll.h\"\r\nCKObjectDeclaration\t*FillBehaviorGetNextBBIdDecl();\r\nCKERROR CreateGetNextBBIdProto(CKBehaviorPrototype **);\r\nint GetNextBBId(const CKBehaviorContext& behcontext);\r\nCKERROR GetNextBBIdCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetNextBBIdDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"GetNextBBId\");\t\r\n\tod->SetDescription(\"Returns behavior id of first found and connected building block or behavior graph\");\r\n\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x572066cc,0x58402b59));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetNextBBIdProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Narratives\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateGetNextBBIdProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"GetNextBBId\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareOutParameter(\"ID\",CKPGUID_INT);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( GetNextBBId );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint GetNextBBId(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\t\r\n\tint count = beh->GetParent()->GetSubBehaviorLinkCount();\r\n\tint result = -1;\r\n \r\n\tfor (int i=0; iGetParent()->GetSubBehaviorLink(i);\r\n\t\tif (link->GetInBehaviorIO() == beh->GetOutput(0))\r\n\t\t{\r\n\t\t\tresult = link->GetOutBehaviorIO()->GetOwner()->GetID();\r\n\t\t\tbeh->SetOutputParameterValue(0,&result);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tCKBehavior *script = static_cast(ctx->GetObject(result));\r\n\tif (script)\r\n\t{\r\n\t\tint bc = script->GetOutputCount();\r\n\r\n\t\tint bc2 = script->GetInputCount();\r\n\r\n\t}\r\n\r\n\r\n\tbeh->ActivateOutput(0);\r\n\tbeh->SetOutputParameterValue(0,&result);\r\n\treturn CKBR_OK;\r\n}\r\nREM createSolutions402003.bat\r\nREM createSolutions412005.bat\r\nREM createSolutions52005.bat\r\n\r\nrmdir ..\\TEMP /s /q\r\nrmdir ..\\BIN /s /q\r\n\r\npremake4 --ExternalVTDirectory=./VTPaths.lua --DeployDirect=TRUE --Dev=Dev40 --file=\"./premake4.lua\" vs2003\r\npremake4 --ExternalVTDirectory=./VTPaths.lua --DeployDirect=TRUE --Dev=Dev41 --file=\"./premake4.lua\" vs2005\r\npremake4 --ExternalVTDirectory=./VTPaths.lua --DeployDirect=TRUE --Dev=Dev5 --file=\"./premake4.lua\" vs2005\r\n\r\nstart _build4Msvc7.bat\r\nstart _build41Msvc8.bat\r\nstart _build5Msvc8.bat\r\n\r\nReleaseDemoPost.bat\r\n\r\n\r\n\r\n\r\nREM -----------------------------------------------------\r\nREM --\r\nREM --\t\tCopy to release\r\nREM --\r\nREM --\r\n\r\n\r\n\r\n\r\n// DistributedNetworkClassDialogEditorDlg.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx.h\"\r\n#include \"DistributedNetworkClassDialogEditor.h\"\r\n#include \"DistributedNetworkClassDialogEditorDlg.h\"\r\n#include \".\\distributednetworkclassdialogeditordlg.h\"\r\n\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nDllEditorDlg* fCreateEditorDlg(HWND parent)\r\n{\r\n\tHRESULT r = CreateDllDialog(parent,IDD_EDITOR,&g_Editor);\r\n\treturn (DllEditorDlg*)g_Editor;\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogEditorDlg dialog\r\n\r\n\r\nDistributedNetworkClassDialogEditorDlg::DistributedNetworkClassDialogEditorDlg(CWnd* pParent /*=NULL*/)\r\n\t: DllEditorDlg(DistributedNetworkClassDialogEditorDlg::IDD, pParent),m_SplitMain(3,1)\r\n{\r\n\t//{{AFX_DATA_INIT(DistributedNetworkClassDialogEditorDlg)\r\n\t\t// NOTE: the ClassWizard will add member initialization here\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\n\r\nvoid DistributedNetworkClassDialogEditorDlg::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tDllEditorDlg::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(DistributedNetworkClassDialogEditorDlg)\r\n\t\t// NOTE: the ClassWizard will add DDX and DDV calls here\r\n\t//}}AFX_DATA_MAP\r\n}\r\n\r\n\r\nBEGIN_MESSAGE_MAP(DistributedNetworkClassDialogEditorDlg, DllEditorDlg)\r\n\t//{{AFX_MSG_MAP(DistributedNetworkClassDialogEditorDlg)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogEditorDlg message handlers\r\n\r\nLRESULT DistributedNetworkClassDialogEditorDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\t\r\n\treturn DllEditorDlg::WindowProc(message, wParam, lParam);\r\n}\r\n\r\nBOOL DistributedNetworkClassDialogEditorDlg::PreTranslateMessage(MSG* pMsg) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\t\r\n\r\n\treturn DllEditorDlg::PreTranslateMessage(pMsg);\r\n}\r\n\r\nBOOL DistributedNetworkClassDialogEditorDlg::OnInitDialog() \r\n{\r\n\tDllEditorDlg::OnInitDialog();\r\n\t\r\n\t// TODO: Add extra initialization here\r\n\r\n\r\n\treturn TRUE; // return TRUE unless you set the focus to a control\r\n\t // EXCEPTION: OCX Property Pages should return FALSE\r\n}\r\n\r\n//this is the almost equivalent of OnInitDialog you should use if you want to\r\n//use the PluginInterface with GetInterface or if you want to be sure the toolbar is present\r\nvoid DistributedNetworkClassDialogEditorDlg::OnInterfaceInit()\r\n{\r\n\t//sample code : here we ask to listen to the _CKFILELOADED notification\r\n\t//which is send when a file is loaded from Virtools Dev's user interface\r\n\tObserveNotification(CUIK_NOTIFICATION_CKFILELOADED);\r\n\t\r\n\r\n\t_SetupSplitters();\r\n\r\n}\r\n\r\n\r\nBOOL DistributedNetworkClassDialogEditorDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) \r\n{\r\n\tMSGFILTER* filter = (MSGFILTER*)lParam;\r\n\r\n\t\r\n\treturn DllEditorDlg::OnNotify(wParam, lParam, pResult);\r\n}\r\n\r\n//-----------------------------------------------------------------------------\r\nvoid DistributedNetworkClassDialogEditorDlg::OnSize(UINT nType, int cx, int cy) \r\n{\r\n\tif (m_SplitMain.m_hWnd)\r\n\t{\r\n\t\tRECT rect;\r\n\t\tGetClientRect(&rect);\r\n\t\tm_SplitMain.MoveWindow(&rect);\r\n\t\t//m_SplitEditorTitle.SetHorizontalSplitbarPosition(0, LAYOUT_EDITORTITLE-5);\r\n\t}\r\n\r\n\tDllEditorDlg::OnSize(nType, cx, cy);\r\n}\r\nvoid\r\nDistributedNetworkClassDialogEditorDlg::_SetupSplitters()\r\n{\r\n\r\n\r\n\tRECT rect;\r\n\tGetClientRect(&rect);\r\n\tint\twidth = 1140;\r\n\tint height = 381;\r\n\r\n\t//\t\tint\t\t\t\t\t\t\t\t: column count\r\n\t//\t\tint\t\t\t\t\t\t\t\t: row count\r\n\t//\t\tint\t\t\t\t\t\t\t\t: width of window RECT at saving time\r\n\t//\t\tint\t\t\t\t\t\t\t\t: height of window RECT at saving time\r\n\t//\t\tarray of int (column count-1)\t: SplitBars X positions (in pixel or percentage if percent==TRUE)\r\n\t//\t\tarray of int (row count-1)\t\t: SplitBars Y positions (in pixel or percentage if percent==TRUE)\r\n\tint SplitMainState[] = { 3, 1, width, height, 0, 0};\r\n\t_SplitterLoadState(m_SplitMain, SplitMainState, sizeof(SplitMainState) / sizeof(int));\r\n\tm_SplitMain.Create(-1, rect, this, IDC_SPLIT_MAIN);\r\n\r\n\r\n}\r\nvoid DistributedNetworkClassDialogEditorDlg::_SplitterLoadState(VISplitterWnd &splitter, int statebuf[], int num) const\r\n{\r\n\tXArray state;\r\n\tfor (int i = 0; i < num; ++i)\r\n\t\tstate.PushBack(statebuf[i]);\r\n\tsplitter.LoadState(state);\r\n}\r\n\r\n\r\n//called on WM_DESTROY\r\nvoid DistributedNetworkClassDialogEditorDlg::OnInterfaceEnd() \r\n{\r\n}\r\n\r\nHRESULT DistributedNetworkClassDialogEditorDlg::ReceiveNotification(UINT MsgID,DWORD Param1,DWORD Param2,CKScene* Context)\r\n{\r\n\tswitch(MsgID)\r\n\t{\r\n\t//sample code : \r\n\tcase CUIK_NOTIFICATION_CKFILELOADED:\r\n\t\t{\r\n\t\t}break;\r\n\t}\r\n\treturn 0;\r\n}#ifndef __VT_AGEIA_H__\r\n#define __VT_AGEIA_H__\r\n\r\n\r\n#include \"pFactory.h\"\r\n#include \"pWorldSettings.h\"\r\n#include \"pSleepingSettings.h\"\r\n#include \"pWorld.h\"\r\n#include \"pRigidBody.h\"\r\n#include \"pJoint.h\"\r\n\r\n\r\n\r\n\r\n#endif/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t OrthographicZoom\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetOrthographicZoomDecl();\r\nCKERROR CreateSetOrthographicZoomProto(CKBehaviorPrototype **pproto);\r\nint SetOrthographicZoom(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetOrthographicZoomDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Orthographic Zoom\");\t\r\n\tod->SetDescription(\"Emulates a zoom when the viewing mode is orthographic.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tZoom: zoom value. The higher the value, the greater the zooming in. Typical values are between 0 and 3.
\r\n
\r\n See Also: 'Set Projection'.
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x0a125555, 0x0eee5488));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00020000);\r\n\tod->SetCreationFunction(CreateSetOrthographicZoomProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetOrthographicZoomProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Orthographic Zoom\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Zoom\", CKPGUID_FLOAT, \"1\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetOrthographicZoom);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint SetOrthographicZoom(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n // Get Zoom\r\n\tfloat zoom=1.0f;\r\n \r\n beh->GetInputParameterValue(0, &zoom);\r\n if( beh->GetVersion()<0x00020000 ) zoom *= 0.01f;\r\n\r\n\tcam->SetOrthographicZoom( zoom );\r\n\r\n\treturn CKBR_OK;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2009/06/01\r\n\tcreated:\t1:6:2009 14:19\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick\\dInputShared.h\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\vtTools\\Sdk\\Src\\Behaviors\\JoyStick \r\n\tfile base:\tdInputShared\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tshared functions for joystick\r\n*********************************************************************/\r\n#ifndef __DINPUT_SHARED_H__\r\n#define __DINPUT_SHARED_H__\r\n\r\n#define STRICT\r\n#define DIRECTINPUT_VERSION 0x0800\r\n\r\n#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }\r\n#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }\r\n#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }\r\n\r\n#include \r\n\r\n//-----------------------------------------------------------------------------\r\n// Function-prototypes\r\n//-----------------------------------------------------------------------------\r\nINT_PTR CALLBACK MainDialogProc( HWND, UINT, WPARAM, LPARAM );\r\nBOOL CALLBACK EnumFFDevicesCallback2( LPCDIDEVICEINSTANCE pDDI, VOID* pvRef );\r\nBOOL CALLBACK EnumAndCreateEffectsCallback2( LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef );\r\n\r\nHRESULT InitDirectInput2( HWND hDlg );\r\nHRESULT FreeDirectInput2();\r\nVOID EmptyEffectList2();\r\nHRESULT OnReadFile2( HWND hDlg,const char*file);\r\nHRESULT OnPlayEffects2( HWND hDlg );\r\nHRESULT SetDeviceForcesXY(float x,float y);\r\n#endif/*\n * Tcp4u v 3.31\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: dimens.h\n * Purpose: Internal header file\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\nvoid Tcp4uLog (unsigned uLevel, LPCSTR szText, ...);\n\n\n/* internal dimensions */\n#define HOST_LENGTH 256\n#define SERVICE_LENGTH 64\n#define FILE_LENGTH 512\n\n/* les symboles des sump */\n#define DUMP4U_SENT \">\"\n#define DUMP4U_RCVD \"<\"\n\n/* internal functions */\n/* these interface are subject to change */\nint Tcp4uAtoi (LPCSTR p);\nlong Tcp4uAtol (LPCSTR p);\nint Tcp4uStrncasecmp (LPCSTR s1, LPCSTR s2, size_t n);\nLPSTR Tcp4uStrIStr (LPCSTR s1, LPCSTR s2);\nstruct in_addr Tcp4uGetIPAddr (LPCSTR szHost);\n\n/* Tcp4u.c internal cals */\nint InternalTcpSend (SOCKET s, LPCSTR szBuf, unsigned uBufSize,\n BOOL bHighPriority, HFILE hLogFile);\nint InternalTcpRecv (SOCKET s, LPSTR szBuf, unsigned uBufSize, \n unsigned uTimeOut, HFILE hLogFile);\nint InternalTcpRecvUntilStr (SOCKET s, LPSTR szBuf,unsigned far *lpBufSize,\n LPSTR szStop, unsigned uStopSize, BOOL bCaseSensitive,\n unsigned uTimeOut, HFILE hLogFile);\n/* tn4u.c internal cals */\nint InternalTnReadLine (SOCKET s,LPSTR szBuf,UINT uBufSize,UINT uTimeOut,\n HFILE hf);\n/* Udp4u.c internal cals */\nint InternalUdpRecv (LPUDPSOCK pUdp, LPSTR sData, int nDataSize, \n unsigned uTimeOut, HFILE hLogFile);\nint InternalUdpSend (LPUDPSOCK Udp,LPCSTR sData, int nDataSize,\n BOOL bHighPriority, HFILE hLogFile);\n\n//////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n//\t\t NeoSetMousePos\r\n//////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n//#include \r\n#include \"CKAll.h\"\r\n#include \"windows.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorNeoSetMousePosDecl();\r\nCKERROR CreateNeoSetMousePosProto(CKBehaviorPrototype **);\r\nint NeoSetMousePos(const CKBehaviorContext& BehContext);\r\nint NeoSetMousePosCallBack(const CKBehaviorContext& BehContext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorNeoSetMousePosDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Mouse Pos\");\t\r\n\t\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetVersion(0x0000001);\r\n\tod->SetCreationFunction(CreateNeoSetMousePosProto);\r\n\tod->SetDescription(\"Set Mouse Position\");\r\n\tod->SetCategory(\"Controllers/Mouse\");\r\n\tod->SetGuid(CKGUID(0xa72d87d4, 0x882b89a6));\r\n\tod->SetAuthorGuid(CKGUID(0x56495254,0x4f4f4c53));\r\n\tod->SetAuthorName(\"Neo\");\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateNeoSetMousePosProto(CKBehaviorPrototype** pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Mouse Pos\");\r\n\tif (!proto) {\r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\t}\r\n\r\n//--- Inputs declaration\n\tproto->DeclareInput(\"Set\");\n\r\n//--- Outputs declaration\n\tproto->DeclareOutput(\"Done\");\n\r\n//--- Input Parameters declaration\n\tproto->DeclareInParameter(\"X\", CKPGUID_INT,\"100\");\n\tproto->DeclareInParameter(\"Y\", CKPGUID_INT,\"100\");\n\tproto->DeclareInParameter(\"Keep Active\", CKPGUID_BOOL, \"TRUE\");\n//\tproto->DeclareSetting(\"Keep Active\",CKPGUID_BOOL,\"TRUE\");\n//\tproto->DeclareLocalParameter(\"KeepActive\", CKPGUID_BOOL);\n\r\n\r\n//----\tLocal Parameters Declaration\r\n\r\n//----\tSettings Declaration\r\n\r\n\tproto->SetBehaviorCallbackFct(NeoSetMousePosCallBack, NULL);\r\n\tproto->SetFunction(NeoSetMousePos);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint NeoSetMousePos(const CKBehaviorContext& BehContext)\r\n{\r\n\tCKBehavior* beh = BehContext.Behavior;\r\n\tint x, y;\r\n\t\r\n \tbeh->GetInputParameterValue(0,&x);\r\n\tbeh->GetInputParameterValue(1,&y);\r\n\tSetCursorPos(x,y);\r\n\tbeh->ActivateOutput(0);\r\n\tCKBOOL keepActive;\r\n\tbeh->GetInputParameterValue(2,&keepActive);\r\n\tif(keepActive)return CKBR_ACTIVATENEXTFRAME;\r\n\treturn CKBR_OK;\r\n}\r\n\r\nint NeoSetMousePosCallBack(const CKBehaviorContext& BehContext)\n{\n\treturn CKBR_OK;\n}\r\n\r\n\r\n/*--------------------------------------------------------------------- NVMH5 -|----------------------\r\nPath: Sdk\\Demos\\Direct3D9\\src\\GetGPUAndSystemInfo\\\r\nFile: GetGPUAndSystemInfo.h\r\n\r\nCopyright NVIDIA Corporation 2003\r\nTO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* AND NVIDIA AND\r\nAND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA\r\nOR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER\r\nINCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF\r\nBUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS\r\nSOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r\n\r\n\r\nComments:\r\nA simple class to demonstrate the use of DXDiagNVUtil which is a convenient wrapper for\r\nthe IDxDiagContainer interface from Microsoft.\r\n\r\nGetGPUAndSystemInfo gets only a small fraction of the information that IDxDiagContainer\r\nmakes available.\r\n\r\nSince this class is simple to create and destroy, there is no specific handling for when\r\nthe D3D device is lost. Simply Free() and re Initialize() the class if that should happen.\r\n\r\n-------------------------------------------------------------------------------|--------------------*/\r\n\r\n\r\n#ifndef H_GETGPUANDSYSTEMINFO_GJ_H\r\n#define H_GETGPUANDSYSTEMINFO_GJ_H\r\n\r\n#include \"3D\\DXDiagNVUtil.h\"\r\n\r\n#include \t\t\t\t// for wstring\r\n\r\nstruct IDirect3D9;\r\n\r\n\r\nstruct FloatingPointBlendModes\r\n{\r\n\tbool m_bR16f;\r\n\tbool m_bR32f;\r\n\tbool m_bG16R16f;\r\n\tbool m_bG32R32f;\r\n\tbool m_bA16B16G16R16f;\r\n\tbool m_bA32B32G32R32f;\r\n\tbool m_bA8R8G8B8;\t\t// not an fp mode, but there for good measure\r\n};\r\n\r\n\r\nclass GetGPUAndSystemInfo\r\n{\r\npublic:\r\n\t// DXDiagNVUtil is a utility class for creating and querring the IDxDiagContainer interface\r\n\tDXDiagNVUtil\tm_DXDiagNVUtil;\r\n\r\n\t// Data fields that will be filled in by the GetData() function\r\n\tDWORD\t\tm_dwNumDisplayDevices;\r\n\tfloat\t\tm_fDriverVersion;\r\n\twstring\t\tm_wstrDeviceDesc;\r\n\tint\t\t\tm_nDeviceMemoryMB;\r\n\tfloat\t\tm_fSystemPhysicalMemoryMB;\r\n\tstring\t\tm_strAGPStatus;\r\n\tstring\t\tm_strMachineName;\r\n\r\n\tDWORD\t\tm_dwDXVersionMajor;\r\n\tDWORD\t\tm_dwDXVersionMinor;\r\n\tchar\t\tm_cDXVersionLetter;\r\n\r\n\twstring\t\tm_wstrDxDebugLevels;\r\n\r\n\tFloatingPointBlendModes\t\tm_FPBlendModes;\r\n\r\n\t// ---- Main interface functions --------\r\n\tHRESULT\t\tGetData();\r\n\tHRESULT\t\tIsFPBlendingSupported( IDirect3D9 * pD3D9, FloatingPointBlendModes * pOutResult );\r\n\r\n\t// --------------------------------------\r\n\r\nprotected:\r\n\tvoid\tSetAllNull()\r\n\t{\r\n\t};\r\npublic:\r\n\tGetGPUAndSystemInfo()\r\n\t{\r\n\t\tSetAllNull();\r\n\t};\r\n\t~GetGPUAndSystemInfo()\r\n\t{\r\n\t\tSetAllNull();\r\n\t}\r\n};\r\n\r\n\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothFreeVertexDecl();\r\nCKERROR CreatePClothFreeVertexProto(CKBehaviorPrototype **pproto);\r\nint PClothFreeVertex(const CKBehaviorContext& behcontext);\r\nCKERROR PClothFreeVertexCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_VertexIndex,\r\n\t\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothFreeVertexDecl\r\n// FullName: FillBehaviorPClothFreeVertexDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothFreeVertexDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothFreeVertex\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Frees a previously attached cloth point.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x718e795d,0x5006d9d));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothFreeVertexProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothFreeVertexProto\r\n// FullName: CreatePClothFreeVertexProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothFreeVertexProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothFreeVertex\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothFreeVertex \r\n\r\n\tPClothFreeVertex is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tFrees a previously attached cloth point.
\r\n\r\n\t@see pCloth::freeVertex()\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothFreeVertex.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t
\r\n\tVertex Index: Index of the vertex to free.\r\n\t
\r\n\t
\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothFreeVertexCB );\r\n\r\n\tproto->DeclareInParameter(\"Vertex Index\",CKPGUID_INT);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothFreeVertex);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothFreeVertex\r\n// FullName: PClothFreeVertex\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothFreeVertex(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tpWorld *world = GetPMan()->getDefaultWorld();\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tint vertexIndex = GetInputParameterValue(beh,bbI_VertexIndex);\r\n\t\tcloth->freeVertex(vertexIndex);\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothFreeVertexCB\r\n// FullName: PClothFreeVertexCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothFreeVertexCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSJoinObjectDecl();\r\nCKERROR CreateNSJoinObjectProto(CKBehaviorPrototype **);\r\nint NSJoinObject(const CKBehaviorContext& behcontext);\r\nCKERROR NSJoinObjectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 5\r\n#define BEH_OUT_MIN_COUNT 2\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_SESSION_ID,\r\n\tBB_IP_SESSION_PASSWORD\r\n\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_JOINED,\r\n\tBB_O_WAITING,\r\n\tBB_O_ERROR\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_MASTER_ID,\r\n\tBB_OP_ERROR\r\n \r\n};\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSJoinObjectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSJoin\");\t\r\n\tod->SetDescription(\"Joins to a session\");\r\n\r\n\tod->SetCategory(\"TNL/Sessions\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5a42f45,0x49eb1634));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNSJoinObjectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNSJoinObjectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSJoin\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\t\r\n\tproto->DeclareOutput(\"Joined\");\r\n\tproto->DeclareOutput(\"Waiting For Answer\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Session ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareInParameter(\"Password\", CKPGUID_STRING, \"none\");\r\n\r\n\tproto->DeclareOutParameter(\"Master ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\t\r\n\tproto->DeclareLocalParameter(\"state\", CKPGUID_INT, \"0\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS));\r\n\tproto->SetFunction(NSJoinObject);\r\n\tproto->SetBehaviorCallbackFct(NSJoinObjectCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\ntypedef std::vectorxSessions;\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint NSJoinObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t\r\n\tbbNoError(E_NWE_OK);\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\t\r\n\tISession *sInterface = cin->getSessionInterface();\r\n\tint connectionID = GetInputParameterValue(beh,BB_IP_CONNECTION_ID);\r\n\tint sessionID = GetInputParameterValue(beh,BB_IP_SESSION_ID);\r\n\tXString password ((CKSTRING) beh->GetInputParameterReadDataPtr(BB_IP_SESSION_PASSWORD));\r\n\t\r\n\t\r\n\txDistributedSession *session = sInterface->get(sessionID);\r\n\tif (!session)\r\n\t{\r\n\t\tbbError(E_NWE_NO_SUCH_SESSION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\t\t\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tif (session && session->isFull())\r\n\t\t{\r\n\t\t\tbbError(E_NWE_SESSION_FULL);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (session && session->isLocked())\r\n\t\t{\r\n\t\t\t\r\n\t\t\tbbError(E_NWE_SESSION_LOCKED);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\tif (session && session->isPrivate() && strcmp(password.CStr(),session->getPassword() ) )\r\n\t\t{\r\n\t\t\tbbError(E_NWE_SESSION_WRONG_PASSWORD);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\tif (isFlagOn(myClient->getClientFlags(),E_CF_SESSION_JOINED ))\r\n\t\t{\r\n\t\t\t\r\n\t\t\tbbError(E_NWE_SESSION_ALREADY_JOINED);\r\n\t\t\treturn 0;\r\n\t\t}\r\n sInterface->joinClient(cin->getMyClient(),sessionID,xNString(password.Str()));\r\n\t}\r\n\r\n\r\n\tif (!myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED ))\r\n\t{\r\n\t\tbbNoError(E_NWE_OK);\r\n\t\tbeh->ActivateOutput(BB_O_WAITING);\r\n\t}\r\n\r\n\t\r\n\r\n\tif (session && myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED) )\r\n\t{\r\n\r\n\r\n\t\tbeh->ActivateOutput(BB_O_JOINED);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we tag all existing users as new : \r\n\t\txDistributedClient *myClient = cin->getMyClient();\r\n\t\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\t\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\t\txDistObjectIt begin = distObjects->begin();\r\n\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\tif (distObject)\r\n\t\t\t{\r\n\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\tif (_class)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\tif (distClient && distClient->getSessionID() == sessionID)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (isFlagOn(distClient->getClientFlags(),E_CF_SESSION_JOINED))\r\n\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_ADDING);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbegin++;\r\n\t\t}\r\n\r\n\t\t//we output all attached parameters:\r\n\r\n\r\n\t\t\r\n\t\tint sessionMasterID = session->getUserID();\r\n\t\tbeh->SetOutputParameterValue(BB_OP_MASTER_ID,&sessionMasterID);\r\n\r\n\r\n\t\tif ( beh->GetOutputParameterCount() > BEH_OUT_MIN_COUNT )\r\n\t\t{\r\n\t\t\txDistributedSessionClass *_class = (xDistributedSessionClass*)session->getDistributedClass();\r\n\r\n\t\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\t\tfor (int i = BEH_OUT_MIN_COUNT ; i < beh->GetOutputParameterCount() ; i++ )\r\n\t\t\t{\r\n\t\t\t\tCKParameterOut *ciIn = beh->GetOutputParameter(i);\r\n\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\txDistributedPropertyArrayType &props = *session->getDistributedPorperties();\r\n\r\n\t\t\t\tint propID = _class->getInternalUserFieldIndex(i - BEH_OUT_MIN_COUNT);\r\n\t\t\t\tint startIndex = _class->getFirstUserField();\r\n\t\t\t\tint pSize = props.size();\r\n\t\t\t\tif (propID==-1 || propID > props.size() )\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->ActivateOutput(BB_O_ERROR);\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\txDistributedProperty *prop = props[propID];\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\t//we set the update flag in the prop by hand : \r\n\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\tif (propInfo)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\r\n\t\t\t\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tfloat vvalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedPoint2F * dpoint3F = (xDistributedPoint2F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVx2DVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxQuaternion vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedString * propValue = (xDistributedString*)prop;\r\n\t\t\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tTNL::StringPtr ovalue = propValue->mCurrentValue;\r\n\t\t\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(i);\r\n\t\t\t\t\t\t\t\t\t\tXString errorMesg(ovalue.getString());\r\n\t\t\t\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedInteger * dpoint3F = (xDistributedInteger*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint ovalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&ovalue);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_UNKNOWN:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(BB_O_JOINED);\r\n\t\treturn 0;\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR NSJoinObjectCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCTriggerEventDecl();\r\nCKERROR CreatePCTriggerEventProto(CKBehaviorPrototype **pproto);\r\nint PCTriggerEvent(const CKBehaviorContext& behcontext);\r\nCKERROR PCTriggerEventCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCTriggerEventDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCTriggerEvent\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Triggers output if body stays,enter or leaves a body .\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7e866b0f,0x5935367c));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePCTriggerEventProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePCTriggerEventProto\r\n// FullName: CreatePCTriggerEventProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePCTriggerEventProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCTriggerEvent\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PCTriggerEvent \r\n\r\n\tPCTriggerEvent is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tTriggers outputs if the body enters,stays or leaves another body .
\r\n\tSee pBTriggerEvent.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PCTriggerEvent.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\t\r\n\tNo Event: Nothing touched.\r\n\t
\r\n\tEntering: Body entered.\r\n\t
\r\n\tLeaving: Body leaved.\r\n\t
\r\n\tStay: Inside body .\r\n\t
\r\n\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\tTouched Object: The touched body.\r\n\t
\r\n\t\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note


\r\n\t\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pRigidBody::addForce().
\r\n\t\r\n\t*/\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\tproto->DeclareOutput(\"No Event\");\r\n\tproto->DeclareOutput(\"Entering\");\r\n\tproto->DeclareOutput(\"Stay\");\r\n\tproto->DeclareOutput(\"Leaving\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Touched Object\",CKPGUID_3DENTITY,0);\r\n\r\n\t//proto->DeclareSetting(\"Trigger on Enter\",CKPGUID_BOOL,\"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PCTriggerEvent);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Enter,\r\n\tbbO_Stay,\r\n\tbbO_Leave,\r\n};\r\n\r\n//************************************\r\n// Method: PCTriggerEvent\r\n// FullName: PCTriggerEvent\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PCTriggerEvent(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t//world->getScene()->setFilterOps()\r\n\t// body exists already ? clean and delete it : \r\n\tpRigidBody*result = GetPMan()->getBody(target);\r\n\tif (!result)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbO_None);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\tif (GetPMan()->getTriggers().Size()==0)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbO_None);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tif (GetPMan()->getTriggers().Size())\r\n\t\t{\r\n\r\n\r\n\t\t\tint nbEntries = GetPMan()->getTriggers().Size() ; \r\n\t\t\tfor (int i = 0 ; i < GetPMan()->getTriggers().Size(); i++ )\r\n\t\t\t{\r\n\t\t\t\tpTriggerEntry &entry = *GetPMan()->getTriggers().At(i);\r\n\r\n\t\t\t\tif (!entry.triggered)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_ENTER)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Enter);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_STAY)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Stay);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(entry.triggerEvent == NX_TRIGGER_ON_LEAVE)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_Leave);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tnbEntries--;\r\n\t\t\t\t\tentry.triggered = true;\r\n\r\n\r\n\t\t\t\t\tNxActor *triggerActor = &entry.shapeA->getActor();\r\n\t\t\t\t\tNxActor *otherActor = &entry.shapeB->getActor();\r\n\r\n\t\t\t\t\tpRigidBody *triggerBody = NULL;\r\n\t\t\t\t\tpRigidBody *otherBody = NULL;\r\n\r\n\t\t\t\t\tif (triggerActor)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttriggerBody = static_cast(triggerActor->userData);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (otherActor)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\totherBody = static_cast(otherActor->userData);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (triggerBody && result == triggerBody)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCK_ID id = otherBody->getEntID();\r\n\t\t\t\t\t\tCKObject *entOut= (CK3dEntity*)ctx->GetObject(id);\r\n\t\t\t\t\t\tbeh->SetOutputParameterObject(0,entOut);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (otherBody && result == otherBody )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCK_ID id = triggerBody->getEntID();\r\n\t\t\t\t\t\tCKObject *entOut= (CK3dEntity*)ctx->GetObject(id);\r\n\t\t\t\t\t\tbeh->SetOutputParameterObject(0,entOut);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tbeh->SetOutputParameterObject(0,NULL);\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PCTriggerEventCB\r\n// FullName: PCTriggerEventCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PCTriggerEventCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n/*************************************************************************/\r\n/*\tFile : MidiManager.h\r\n/*\r\n/*\tAuthor : \r\n/*\tLast Modification : \r\n/*\r\n/*************************************************************************/\r\n\r\n#include \"CKBaseManager.h\"\r\n#include \"XList.h\"\r\n#ifdef _XBOX\r\n\t#include \"Xtl.h\"\r\n#else\r\n\t#include \"windows.h\"\r\n#endif\r\n\r\n//_________________Struct midiMessage\r\nstruct midiMessage {\r\n unsigned char channel;\r\n unsigned char command;\r\n unsigned char note;\r\n unsigned char attack;\r\n UINT time;\r\n};\r\n\r\ntypedef XList midiMessageList;\r\n\r\n\r\nclass MidiManager :public CKMidiManager{\r\n\t////////////////////////////////////////////////////////\r\n\t// Public Part ////\r\n\t////////////////////////////////////////////////////////\r\npublic :\r\n\r\n\t// Midi Sound Playing Functions\r\n\tvirtual void* Create(void* hwnd) ;\r\n\tvirtual void\tRelease(void* source) ;\r\n\tvirtual CKERROR SetSoundFileName(void* source,CKSTRING filename) ;\r\n\tvirtual CKSTRING GetSoundFileName(void* source) ;\r\n\tvirtual CKERROR Play(void* source) ;\r\n\tvirtual CKERROR Restart(void* source) ;\r\n\tvirtual CKERROR Stop(void* source) ;\r\n\tvirtual CKERROR Pause(void* source,CKBOOL pause=TRUE) ;\r\n\tvirtual CKBOOL IsPlaying(void* source) ;\r\n\tvirtual CKBOOL IsPaused(void* source) ;\r\n\tvirtual CKERROR OpenFile(void* source) ;\r\n\tvirtual CKERROR CloseFile(void* source) ;\r\n\tvirtual CKERROR Preroll(void* source) ;\r\n\tvirtual CKERROR Time(void* source,CKDWORD* pTicks) ;\r\n\tvirtual CKDWORD MillisecsToTicks(void* source,CKDWORD msOffset) ;\r\n\tvirtual CKDWORD TicksToMillisecs(void* source,CKDWORD tkOffset) ;\r\n\t\r\n\t// Initialization\t\r\n\tvirtual CKERROR OnCKInit();\r\n\tvirtual CKERROR OnCKEnd();\r\n\tvirtual CKERROR OnCKReset();\r\n\tvirtual CKERROR PreProcess();\r\n\tvirtual CKERROR PostProcess();\r\n\tvirtual CKERROR PostClearAll();\r\n\tvirtual CKERROR OnCKPlay();\r\n\t\r\n\tvirtual CKDWORD\tGetValidFunctionsMask()\t{ return CKMANAGER_FUNC_OnCKInit|\r\n CKMANAGER_FUNC_OnCKEnd|\r\n CKMANAGER_FUNC_OnCKReset|\r\n CKMANAGER_FUNC_PreProcess|\r\n CKMANAGER_FUNC_PostProcess|\r\n CKMANAGER_FUNC_PostClearAll|\r\n CKMANAGER_FUNC_OnCKPlay; }\r\n\t//{secret}\t\r\n\tMidiManager(CKContext *ctx);\r\n\t//{secret}\r\n\t~MidiManager();\r\n\r\n //----- Midi Methodes\r\n void ActivateNote( int note, int channel, CKBOOL state=TRUE);\r\n CKBOOL IsNoteActive( int note, int channel );\r\n CKERROR OpenMidiIn(int);\t//Try to open the midi device passed as paramter\r\n CKERROR CloseMidiIn();\r\n\r\n CKERROR OpenMidiOut(int);\t//Try to open the midi device passed as paramter\r\n CKERROR CloseMidiOut();\r\n\r\n\r\n\t\r\n\tinline void AddMidiBBref(){ ++midiDeviceBBrefcount; }\r\n\tinline void RemoveMidiBBref(){ --midiDeviceBBrefcount; }\r\n\r\n \r\n\r\npublic:\r\n HMIDIIN midiDeviceHandle; // Device Handle\r\n HMIDIOUT midiDeviceOutHandle;\r\n\r\n int midiCurrentDevice; // current used Device ID\r\n int midiCurrentOutDevice; // current used Device ID\r\n\r\n \r\n int DesiredmidiDevice; //midi device to which the user would like to change during runtime\r\n int DesiredmidiOutDevice; //midi device to which the user would like to change during runtime\r\n\r\n\r\n CKBOOL midiDeviceIsOpen; // tells whether the current Device is open or not\r\n CKBOOL midiOutDeviceIsOpen; // tells whether the current Device is open or not\r\n\r\n int midiDeviceBBrefcount;\r\n\r\n \r\n midiMessageList listFromCallBack;\r\n midiMessageList listForBehaviors;\r\n\r\n#define MIDI_MAXNOTES 256\r\n unsigned char noteState[MIDI_MAXNOTES]; // nb of channels * nb of note = 16 * 128 = 2048 bits = 256 bytes\r\n\r\n};\r\n\r\n\r\n\r\n#ifndef _XNET_MATH_H_\r\n#define _XNET_MATH_H_\r\n\r\n#ifndef _XNET_TYPES_H_\r\n\t#include \"xNetTypes.h\"\r\n#endif\r\n\r\n#ifndef _XPOINT_H_\r\n\t#include \"xPoint.h\"\r\n#endif\r\n\r\n#ifndef _MQUAT_H_\r\n#include \"xQuat.h\"\r\n#endif\r\n\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\n#include \"pFluidEmitterDesc.h\"\r\n#include \"pFluidEmitter.h\"\r\n\r\npFluidEmitter::pFluidEmitter()\r\n{\r\n\tmFluid = NULL;\r\n\tmEmitter = NULL;\r\n\tmEntityReference = 0;\r\n\tmRenderSettings = NULL;\r\n}\r\n#endif // HAS_FLUIDS/********************************************************************\r\n\tcreated:\t2007/12/12\r\n\tcreated:\t12:12:2007 11:54\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\\vtCXPlatform32.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\inlcude\r\n\tfile base:\tvtCXPlatform32\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#include \r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//Macros :\r\n/*\r\n\tFrom winnt.h : \r\n*/\r\n#ifndef MAKEWORD\r\n\t#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))\r\n#endif\r\n\r\n#ifndef LOWORD\r\n\t#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))\r\n#endif\r\n\r\n#ifndef HIWORD\r\n\t#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))\r\n#endif\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachVertexToShapeDecl();\r\nCKERROR CreatePClothAttachVertexToShapeProto(CKBehaviorPrototype **pproto);\r\nint PClothAttachVertexToShape(const CKBehaviorContext& behcontext);\r\nCKERROR PClothAttachVertexToShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_ShapeReference, \r\n\tbbI_AttachmentFlags,\r\n\tbbI_VertexIndex,\r\n\tbbI_LocalPosition\r\n};\r\n\r\n\r\nenum bSettings\r\n{\r\n\tbbS_USE_DEFAULT_WORLD,\r\n\tbbS_ADD_ATTRIBUTES\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothAttachVertexToShapeDecl\r\n// FullName: FillBehaviorPClothAttachVertexToShapeDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachVertexToShapeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothAttachVertexToShape\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Attaches a cloth vertex to another shape.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x27970ee2,0x1247425d));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothAttachVertexToShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothAttachVertexToShapeProto\r\n// FullName: CreatePClothAttachVertexToShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothAttachVertexToShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothAttachVertexToShape\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothAttachVertexToShape \r\n\r\n\tPClothAttachVertexToShape is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAttaches a cloth vertex to a shape .
\r\n\r\n\t@see pCloth::attachVertexToShape()\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothAttachVertexToShape.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\tShape Reference: Shape to which the cloth should be attached to.\r\n\r\n\t@see pCloth::attachToShape()\r\n\t
\r\n\t
\r\n\r\n\tAttachment Flags: One or two way interaction, tearable or non-tearable\r\n\r\n\tDefault: PCAF_ClothAttachmentTwoway\r\n\r\n\t@see pClothAttachmentFlag\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t
\r\n\tVertex Index: Index of the vertex to attach.\r\n\t
\r\n\t
\r\n\r\n\tLocal Position: The position relative to the pose of the shape.\r\n\t
\r\n\t
\r\n\r\n\r\n\r\n\t\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include pCloth.cpp\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothAttachVertexToShapeCB );\r\n\r\n\tproto->DeclareInParameter(\"Shape Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Attachment Flags\",VTE_CLOTH_ATTACH_FLAGS);\r\n\tproto->DeclareInParameter(\"Vertex Index\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Local Position\",CKPGUID_VECTOR);\r\n\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothAttachVertexToShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachVertexToShape\r\n// FullName: PClothAttachVertexToShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothAttachVertexToShape(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tCK3dEntity*shapeReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_ShapeReference);\r\n\t\tif (!shapeReference)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpWorld *world = GetPMan()->getDefaultWorld();\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\r\n\t\tint flags = GetInputParameterValue(beh,bbI_AttachmentFlags);\r\n\t\tint vertexIndex = GetInputParameterValue(beh,bbI_VertexIndex);\r\n\t\tVxVector localPosition = GetInputParameterValue(beh,bbI_LocalPosition);\r\n\r\n\r\n\t\tNxShape *shape = world->getShapeByEntityID(shapeReference->GetID());\r\n\t\tif(shape)\r\n\t\t{\r\n\t\t\tcloth->attachVertexToShape(vertexIndex,(CKBeObject*)shapeReference,localPosition,flags);\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachVertexToShapeCB\r\n// FullName: PClothAttachVertexToShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothAttachVertexToShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//Macros :\r\n/*\r\n\tFrom winnt.h :\r\n*/\r\n#ifndef MAKEWORD\r\n\t#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))\r\n#endif\r\n\r\n#ifndef LOWORD\r\n\t#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))\r\n#endif\r\n\r\n#ifndef HIWORD\r\n\t#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))\r\n#endif\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\n#include \"xLogger.h\"\n#include \"IMessages.h\"\r\n#include \"xMessageTypes.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\nTNL_IMPLEMENT_NETOBJECT(xDistributedClient); \r\n\r\n\r\nusing namespace TNL;\r\n\r\nint messageIDCounter2 = 0;\r\nint messageINCounter = 0;\r\n\r\n\r\n\r\nuxString\r\nxDistributedClient::print(TNL::BitSet32 flags)\r\n{\r\n\r\n\treturn Parent::print(flags);\r\n}\r\n\r\n\r\nvoid\r\nxDistributedClient::setCurrentOutMessage(xMessage* msg)\r\n{\r\n\r\n\r\n\t\r\n\t//xMessage *currentMsg = getCurrentMessage();\r\n\r\n\t/*if (currentMsg && isFlagOn(currentMsg->getFlags(),E_MF_SENT))\r\n\t{\r\n\tgetNetInterface()->getMessagesInterface()->deleteMessage(currentMsg);\r\n\t}*/\r\n\r\n\tif (msg)\r\n\t{\r\n\t\tenableFlag(getClientFlags(),E_CF_NM_SENDING);\r\n\t}else\r\n\t{\r\n\t\tmCurrentMessage = NULL;\r\n\t}\r\n\r\n\tmCurrentMessage = msg;\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributedClient::pack(TNL::BitStream *bstream)\r\n{\r\n\t//Parent::pack(bstream);\r\n\txMessage *currentMsg = getCurrentMessage();\r\n\r\n\tIMessages *mInterface = getNetInterface()->getMessagesInterface();\r\n\r\n\r\n\tif (currentMsg)\r\n\t{\r\n\t\tTNL::BitSet32 writeFlags=0;\r\n\t\tenableFlag(writeFlags,E_MWF_UPDATE_SERVER);\r\n\t\tdisableFlag(writeFlags,E_MWF_SEND_SRC_USER_ID);\r\n\r\n\t\tif (!isFlagOn(currentMsg->getFlags(),E_MF_SEND_TO_ALL))\r\n\t\t{\r\n\t\t\tenableFlag(writeFlags,E_MWF_SEND_TARGET_USER_ID);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tmInterface->writeToStream(currentMsg,bstream,writeFlags);\r\n\t\t\r\n\t\tenableFlag(currentMsg->getFlags(),E_MF_SENT);\r\n\t\tenableFlag(currentMsg->getFlags(),E_MF_DELETED);\r\n\t\t\r\n\t\tsetCurrentOutMessage(NULL);\r\n\t\tdisableFlag(getClientFlags(),E_CF_NM_SENDING);\r\n\r\n\t}\r\n\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedClient::unpack( TNL::BitStream *bstream,float sendersOneWayTime )\r\n{\r\n\r\n\tIMessages *mInterface = getNetInterface()->getMessagesInterface();\r\n\r\n\tTNL::BitSet32 readFlags=0;\r\n\tenableFlag(readFlags,E_MRF_UPDATE_BY_GHOST);\r\n\tdisableFlag(readFlags,E_MRF_READ_SRC_USER_ID);\r\n\tenableFlag(readFlags,E_MRF_READ_TARGET_USER_ID);\r\n\r\n\txMessage *msg = mInterface->readFromStream(bstream,readFlags);\r\n\tif (msg)\r\n\t{\r\n\t\txDistributedClient *client = static_cast(getOwnerConnection()->resolveGhostParent(getLastUpdater()));\r\n\t\tif (client)\r\n\t\t{\r\n\t\t\tmsg->setSrcUser(client->getUserID());\r\n\t\t\tmsg->setClientSource(client);\r\n\t\t\t\r\n\t\t\tenableFlag(msg->getFlags(),E_MF_NEW);\r\n\t\t\tenableFlag(msg->getFlags(),E_MF_OUTGOING);\r\n\t\t\t\r\n\t\t\tmInterface->getMessages()->push_back(msg);\r\n\r\n\t\t\txDistributedSession *session = NULL;\r\n\r\n\t\t\tsession = getNetInterface()->getSessionInterface()->get(msg->getClientSource()->getSessionID());\r\n\t\t\tif (!session)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MESSAGES,\"no session object\");\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\tint numUsers = session->getNumUsers() -1;\r\n\r\n\r\n\t\t\tif (isFlagOn(msg->getFlags(),E_MF_SEND_TO_ALL))\r\n\t\t\t{\r\n\t\t\r\n\t\t\t\tif (msg->getIgnoreSessionMaster() && client->getUserID() !=session->getUserID() )\r\n\t\t\t\t{\r\n numUsers--;\r\n\t\t\t\t}\r\n\r\n/*\t\t\t\tif (client->getUserID())\r\n\t\t\t\t{\r\n\t\t\t\t}\r\n*/\r\n\t\t\t}else\r\n\t\t\t{\r\n//\t\t\t\txDistributedClient *dstclient = (xDistributedClient*)client->getOwnerConnection()->resolveGhostParent(msg->getDstUser());\r\n\t\t\t\txDistributedClient *dstclient = static_cast(getNetInterface()->getDistObjectInterface()->getByUserID(msg->getDstUser(),E_DC_BTYPE_CLIENT));\r\n\t\t\t\t//TNL::logprintf(\"server msg received from user : %d| to %d \",client->getUserID(),msg->getClientSource()->getOwnerConnection()->getGhostIndex(dstclient),msg->getDstUser());\r\n\r\n\t\t\t\tnumUsers = 1;\r\n\t\t\t}\r\n\r\n\t\t\tmsg->setNumUsers(numUsers);\r\n\t\t\t//TNL::logprintf(\"server msg received from user : %d,num users : %d | dst :%d\",client->getUserID(),numUsers,msg->getDstUser());\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL::U32 \r\nxDistributedClient::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tIMessages *mInterface = netInterface->getMessagesInterface();\r\n\tISession *sInterface = netInterface->getSessionInterface();\r\n\tif (netInterface)\r\n\t{\r\n\r\n\t\t//server side only : \r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//the first time ? : we write out all necessary attributes for the client : \r\n\t\t\tif(stream->writeFlag(updateMask & InitialMask))\r\n\t\t\t{\r\n\t\t\t\tif(stream->writeFlag(true))\r\n\t\t\t\t{\r\n\t\t\t\t\tParent::packUpdate(connection,updateMask,stream);\r\n\t\t\t\t\t//write out users local address string :\r\n\t\t\t\t\tstream->writeString(getLocalAddress().getString());\r\n\t\t\t\t\tstream->writeString(getUserName().getString());\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif(stream->writeFlag(updateMask & NameMask))\r\n\t\t\t{\r\n\t\t\t\tstream->writeString(getUserName().getString());\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\txMessage*msg = getCurrentMessage();\r\n\t\t\t\r\n\t\t\txDistributedSession *session = NULL;\r\n\t\t\t\r\n\t\t\tsession = msg ? getNetInterface()->getSessionInterface()->get(msg->getClientSource()->getSessionID()) : NULL;\r\n\t\t\tif (msg && !session)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MESSAGES,\"no session object\");\r\n\t\t\t\tstream->writeFlag(false);\r\n\t\t\t\tenableFlag(msg->getFlags(),E_MF_SENT);\r\n\t\t\t\tenableFlag(msg->getFlags(),E_MF_DELETED);\r\n\t\t\t\tsetCurrentOutMessage(NULL);\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\t}\r\n\t\t\tif (msg)\r\n\t\t\t{\r\n\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\r\n\t\t\t\t//int ghostIndexFrom = con->getGhostIndex( msg->getClientSource() );\t\t\r\n\t\t\t\tint ignore = msg->getIgnoreSessionMaster(); \r\n\r\n\r\n\t\t\t\tif (msg->getClientSource()->getOwnerConnection() == connection)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"going to msg source :%d !\",getUserID());\r\n\t\t\t\t\tstream->writeFlag(false);\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (ignore && session && con->getUserID() == session->getUserID())\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"going to session master :%d !\",getUserID());\r\n\t\t\t\t\tstream->writeFlag(false);\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!isFlagOn(msg->getFlags(),E_MF_SEND_TO_ALL))\r\n\t\t\t\t{\r\n\t\t\t\t\tIDistributedObjects *doInterface = netInterface->getDistObjectInterface();\r\n\t\t\t\t\txDistributedClient *dstClient = static_cast(doInterface->getByUserID(msg->getDstUser(),E_DC_BTYPE_CLIENT));\r\n\t\t\t\t\tif (con->getUserID() != msg->getDstUser() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"wrong destination :%d !\",con->getUserID());\r\n\t\t\t\t\t\tstream->writeFlag(false);\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tstream->writeFlag(true);\r\n \r\n\t\t\t\tTNL::BitSet32 writeFlags=0;\r\n\t\t\t\tenableFlag(writeFlags,E_MWF_UPDATE_GHOST);\r\n\t\t\t\tdisableFlag(writeFlags,E_MWF_SEND_TARGET_USER_ID);\r\n\t\t\t\tenableFlag(writeFlags,E_MWF_SEND_SRC_USER_ID);\r\n\r\n\t\t\t\tmInterface->writeToStream(msg,stream,writeFlags);\r\n\r\n\t\t\t\t//TNL::logprintf(\"msg stats : sendCount %d , numUsers %d\",msg->getSendCount() , msg->getNumUsers() );\r\n\r\n\t\t\t\t\r\n\t\t\t\tif (msg->getSendCount() == msg->getNumUsers() )\r\n\t\t\t\t{\r\n\t\t\t\t\tenableFlag(msg->getFlags(),E_MF_SENT);\r\n\t\t\t\t\tenableFlag(msg->getFlags(),E_MF_DELETED);\r\n\t\t\t\t\tsetCurrentOutMessage(NULL);\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"message complete\");\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\t\r\n\t\t\t\tstream->writeFlag(false);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxDistributedClient::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)\r\n{\r\n\r\n\txNetInterface *netInterface = (xNetInterface*) connection->getInterface();\r\n\tvtConnection *vconnection = (vtConnection*)connection;\r\n\tif (netInterface)\r\n\t{\r\n\t\t//client side only : \r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//initial update ? \r\n\t\t\tif(stream->readFlag())\r\n\t\t\t{\r\n\t\t\t\tif(stream->readFlag())\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tParent::unpackUpdate(connection,stream);\r\n\t\t\t\t\tchar localAddress[256];stream->readString(localAddress);\t// retrieve the local address\r\n\t\t\t\t\tchar userName[256];stream->readString(userName);\t// retrieve the user name \r\n\t\t\t\t\t\r\n\t\t\t\t\tsetServerID(connection->getGhostIndex((NetObject*)this));\r\n\t\t\t\t\tsetObjectFlags(E_DO_CREATION_CREATED);\r\n\r\n\t\t\t\t\tsetLocalAddress(localAddress);\r\n\t\t\t\t\t\r\n\t\t\t\t\tvtConnection *con = (vtConnection*)connection;\r\n\t\t\t\t\tsetOwnerConnection(con);\r\n\r\n\r\n\t\t\t\t\tif (con->getUserID() == getUserID())\r\n\t\t\t\t\t\tenableFlag(getClientFlags(),E_CF_ADDED);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tenableFlag(getClientFlags(),E_CF_ADDING);\r\n\r\n\t\t\t\t\tsetUserName(userName);\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif(stream->readFlag())\r\n\t\t\t{\r\n\t\t\t\tchar oName[256];stream->readString(oName);\t// retrieve objects name : \r\n\t\t\t\tsetUserName(oName);\r\n\t\t\t\tsetUserFlags(USERNAME_CHANGED);\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_CLIENT,\"name changed\");\r\n\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\r\n\t\t\tbool msgRecieved = stream->readFlag();\r\n\t\t\tif (msgRecieved)\r\n\t\t\t{\r\n\t\t\t\tIMessages *mInterface = getNetInterface()->getMessagesInterface();\r\n\t\t\t\tTNL::BitSet32 readFlags=0;\r\n\t\t\t\tenableFlag(readFlags,E_MRF_SERVER_UPDATE);\r\n\t\t\t\tdisableFlag(readFlags,E_MRF_READ_TARGET_USER_ID);\r\n\t\t\t\tenableFlag(readFlags,E_MRF_READ_SRC_USER_ID);\r\n\r\n\t\t\t\txMessage *msg = mInterface->readFromStream(stream,readFlags);\r\n\t\t\t\tif (msg)\r\n\t\t\t\t{\r\n\t\t\t\t\tenableFlag(msg->getFlags(),E_MF_INCOMING);\r\n\t\t\t\t\tenableFlag(msg->getFlags(),E_MF_NEW);\r\n\t\t\t\t\tenableFlag(msg->getFlags(),E_MF_FINISH);\r\n\t\t\t\t\tmsg->setMessageID(messageINCounter);\r\n\t\t\t\t\tmessageINCounter++;\r\n\t\t\t\t\tmInterface->getMessages()->push_back(msg);\r\n\t\t\t\t\t//xDistributedObject *dobj = static_cast(getNetInterface()->getConnection()->(msg->getSrcUser()));\r\n\t\t\t\t\t//TNL::logprintf(\"msg by %d\",dobj->getUserID());\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\n\r\nvoid\r\nxDistributedClient::calculateUpdateBits()\r\n{\r\n\r\n\tIMessages *mInterface = getNetInterface()->getMessagesInterface();\r\n\txMessage *msg = getCurrentMessage();\r\n\r\n\tgetUpdateBits().clear();\r\n\r\n\tif (msg && isFlagOn(msg->getFlags(),E_MF_NEW) && !isFlagOn(msg->getFlags(),E_MF_DELETED) )\r\n\t{\r\n\r\n\t\tgetUpdateBits().set(BIT(1),true);\r\n\t\t//&& (msg->getLifeTime() < mInterface->getMessageTimeout())\r\n\t\t/*int index = 1 ; \r\n\t\tfor (int i =0 ; msg->getParameters().size() ; i++)\r\n\t\t{\r\n\r\n\t\t\txDistributedProperty *prop = msg->getParameters().at(i);\r\n\t\t\tgetUpdateBits().set(BIT(index),prop->getFlags() & E_DP_NEEDS_SEND );\r\n\t\t\t\r\n\r\n\t\t}*/\r\n\t\t\r\n\t\txDistributedPropertyArrayIterator begin = msg->getParameters().begin();\r\n\t\txDistributedPropertyArrayIterator end = msg->getParameters().end();\r\n\r\n\t\tint index = 2 ; \r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\txDistributedProperty *prop = *begin;\r\n\t\t\tif (prop==NULL)\r\n\t\t\t{\r\n\t\t\t\tint op2 = 2;\r\n\t\t\t}\r\n\t\t\tgetUpdateBits().set(BIT(index),prop->getFlags() & E_DP_NEEDS_SEND );\r\n\t\t\tindex++;\r\n\t\t\tbegin++;\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\n\r\n\r\n\r\n\r\nTNL_IMPLEMENT_NETOBJECT_RPC(xDistributedClient,rpcSetName,\r\n\t\t\t\t\t\t\t(TNL::StringPtr name),(name),\r\n\t\t\t\t\t\t\tTNL::NetClassGroupGameMask, TNL::RPCGuaranteedOrdered,TNL::RPCToGhostParent, 0)\r\n{\r\n\r\n\tsetUserName(name);\r\n\tsetMaskBits(NameMask);\r\n\t\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxDistributedClient::onGhostRemove()\r\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (!netInterface)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n//\tif (netInterface->IsServer())\r\n//\t{\r\n\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_CLIENT,\"Remove clients ghost %d\",getUserID());\r\n//\t}\r\n\tnetInterface->removeClient(getUserID());\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedClient::writeControlState(TNL::BitStream *stream)\r\n{\r\n\tstream->writeFlag(true);\r\n\tstream->writeRangedU32(10, 0, 63);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedClient::readControlState(TNL::BitStream * bstream)\r\n{\r\n\tbstream->readFlag();\r\n\tU32 count = bstream->readRangedU32(0, 63);\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedClient::destroy()\r\n{\r\n\tParent::destroy();\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClient::xDistributedClient() : xDistributedObject()\r\n{\r\n\tm_DistributedClass=NULL;\r\n\tm_EntityID = 0;\r\n\tmClientFlags=0;\r\n\tmCurrentMessage = NULL;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedClient::~xDistributedClient()\r\n{\r\n\tdestroy();\r\n \r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedClient::performScopeQuery(TNL::GhostConnection *connection)\r\n{\r\n\r\n\t\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (!netInterface)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\tif (!distObjects)\r\n\t{ \r\n\t\treturn;\r\n\t}\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\txDistributedObject*dobject = *begin;\r\n\t\tif (dobject)\r\n\t\t{\t\r\n\r\n\t\t\tvtConnection *con =(vtConnection*)connection;\r\n\t\t\tint conUID = ((vtConnection*)connection)->getUserID();\r\n\t\t\tint conUIDT = dobject->getUserID();\r\n\r\n\t\t\tint thisID = getSessionID();\r\n\t\t\t\r\n\t\t\tint targetID = dobject->getSessionID();\r\n \r\n\t\t\tif (dobject->getDistributedClass()->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t{\r\n\t\t\t\tif (getSessionID() == dobject->getSessionID())\r\n\t\t\t\t{\r\n\t\t\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (dobject->getDistributedClass()->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t{\r\n\t\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (conUID == conUIDT)\r\n\t\t\t{\r\n\t\t\t\tint op = 0;\r\n\t\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t\t\tbegin++;\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tif (getSessionID() >1 && dobject->getSessionID() >1 && (getSessionID() == dobject->getSessionID()))\r\n\t\t\t{\r\n\t\t\t\tconnection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\t//connection->objectInScope((TNL::NetObject*) dobject );\r\n\t\t\t\tint op2 = 2;\r\n\t\t\t\top2++;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nvoid xDistributedClient::onGhostAvailable(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (netInterface->IsServer())\r\n\t\t{\r\n\t\t\tif (getServerID()==-1)\r\n\t\t\t{\r\n\t\t\t\tsetServerID(theConnection->getGhostIndex(this));\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_CLIENT,\"Server id %d\",getServerID());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tif (netInterface->IsServer())\r\n\t{\r\n\t\t//setServerID(theConnection->getGhostIndex((TNL::NetObject*)this));\r\n\t\t\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool xDistributedClient::onGhostAdd(TNL::GhostConnection *theConnection)\r\n{\r\n\txNetInterface *netInterface = (xNetInterface*) theConnection->getInterface();\r\n\tvtConnection *con = (vtConnection*)theConnection;\r\n\tif (netInterface)\r\n\t{\r\n\t\tif (!netInterface->IsServer())\r\n\t\t{\r\n\t\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\tenableFlag(getClientFlags(),E_CF_ADDING);\r\n\t\t\tdistObjects->push_back(this);\r\n\t\t\tsetNetInterface(netInterface);\r\n\t\t\tif ( con->getUserID() == getUserID() )\r\n\t\t\t{\r\n\t\t\t\tnetInterface->setMyClient(this);\r\n\t\t\t}\r\n \r\n\t\t\tint sessionID = getSessionID();\r\n\t\t\tISession *sInterface = netInterface->getSessionInterface();\r\n\t\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\t\tif (session)\r\n\t\t\t{\r\n\t\t\t\tsession->addUser(this);\r\n\t\t\t\tenableFlag(getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\t}\r\n\t\t}else{\r\n\r\n\t\t\tsetServerID(theConnection->getGhostIndex(this));\r\n\t\t\tTNL::logprintf(\"on add ServerID %d | Name : %s\",getServerID(),GetName().getString());\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n// vtAgeiaInterfaceEditor.h : main header file for the EDITOR DLL\r\n//\r\n\r\n#pragma once\r\n\r\n#ifndef __AFXWIN_H__\r\n\t#error include 'stdafx.h' before including this file for PCH\r\n#endif\r\n\r\n#include \"resource.h\"\t\t// main symbols\r\n\r\nclass vtAgeiaInterfaceEditorDlg;\r\nclass vtAgeiaInterfaceToolbarDlg;\r\n\r\nextern vtAgeiaInterfaceEditorDlg*\t\tg_Editor;\r\nextern vtAgeiaInterfaceToolbarDlg*\t\tg_Toolbar;\r\n\r\n//plugin interface for communication with Virtools Dev\r\nextern PluginInterface*\t\ts_Plugininterface;\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CEditorApp\r\n// See Editor.cpp for the implementation of this class\r\n//\r\n\r\n\r\n#include \"PhysicManager.h\"\r\n\r\n\r\nclass vtAgeiaInterfaceEditorApp : public CWinApp\r\n{\r\nprotected:\r\n\tvoid\tInitImageList();\r\n\tvoid\tDeleteImageList();\r\n\tCImageList\t\tm_ImageList;\r\n\r\npublic:\r\n\tvtAgeiaInterfaceEditorApp();\r\n\r\n\tCKContext *mContext;\r\n\tPhysicManager *pMan;\r\n\tPhysicManager *getPMan(){return pMan;}\r\n\tCKContext *getContext(){return mContext;}\r\n\r\n\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(vtAgeiaInterfaceCEditorApp)\r\n\tpublic:\r\n\tvirtual BOOL InitInstance();\r\n\tvirtual int ExitInstance();\r\n\t//}}AFX_VIRTUAL\r\n\r\n\t//{{AFX_MSG(vtAgeiaInterfaceCEditorApp)\r\n\t\t// NOTE - the ClassWizard will add and remove member functions here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code !\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n//{{AFX_INSERT_LOCATION}}\r\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorJD6SetSoftLimitDecl();\r\nCKERROR CreateJD6SetSoftLimitProto(CKBehaviorPrototype **pproto);\r\nint JD6SetSoftLimit(const CKBehaviorContext& behcontext);\r\nCKERROR JD6SetSoftLimitCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyA=0,\r\n\tbbI_BodyB,\r\n\tbbI_Anchor,\r\n\tbbI_AnchorRef,\r\n\tbbI_Axis,\r\n\tbbI_AxisRef\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJD6SetSoftLimitDecl\r\n// FullName: FillBehaviorJD6SetSoftLimitDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJD6SetSoftLimitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJD6SetSoftLimit\");\t\r\n\tod->SetCategory(\"Physic/D6\");\r\n\tod->SetDescription(\"Sets the soft limits in a D6 joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x536d5df9,0x4e5b275c));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJD6SetSoftLimitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJD6SetSoftLimitProto\r\n// FullName: CreateJD6SetSoftLimitProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJD6SetSoftLimitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJD6SetSoftLimit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\t/*! \\page PJD6SetSoftLimit\r\n\r\n\r\n\t
\r\n\tPJD6SetSoftLimit is categorized in \\ref D6\r\n\t
\r\n\t
See PJD6.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies D6 joint limits.\r\n\t
\r\n\t
\r\n\t

Technical Information

\r\n\r\n\t\\image html PJD6SetSoftLimit.png\r\n\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body to identfy the joint.\r\n\t
\r\n\t
\r\n\r\n\tLimit Axis: The target limit axis. See #D6LimitAxis.\r\n\t
\r\n\tSoft Limit: The new limit. See #pJD6SoftLimit. \r\n\t
\r\n\t
\r\n\r\n\t
\r\n\r\n\tSee \\ref D6AngularLimitGuide \"Angular Limits\"
\r\n\r\n\tSee \\ref D6LinearLimitGuide \"Linear Limits\"
\r\n\t\r\n\t\t*/\r\n\r\n\t\r\n\t\r\n\tproto->SetBehaviorCallbackFct( JD6SetSoftLimitCB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Limit Axis\",VTE_JOINT_LIMIT_AXIS,0);\r\n\r\n\tproto->DeclareInParameter(\"Soft Limit\",VTS_JOINT_SLIMIT);\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JD6SetSoftLimit);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JD6SetSoftLimit\r\n// FullName: JD6SetSoftLimit\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JD6SetSoftLimit(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointD6 *joint =static_cast(worldA->getJoint(target,targetB,JT_D6));\r\n\t\t\tD6LimitAxis limitAxis = GetInputParameterValue(beh,1); \r\n\t\t\tpJD6SoftLimit softLimit;\r\n\r\n\t\t\tCKParameter* pout = beh->GetInputParameter(2)->GetRealSource();\r\n\t\t\tCK_ID* ids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\tfloat damping,spring,value,restitution;\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[0]);\r\n\t\t\tpout->GetValue(&damping);\r\n\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[1]);\r\n\t\t\tpout->GetValue(&spring);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[2]);\r\n\t\t\tpout->GetValue(&value);\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(ids[3]);\r\n\t\t\tpout->GetValue(&restitution);\r\n\r\n\t\t\tsoftLimit.damping = damping;\r\n\t\t\tsoftLimit.spring = spring;\r\n\t\t\tsoftLimit.value = value;\r\n\t\t\tsoftLimit.restitution = restitution;\r\n\r\n\r\n\t\t\t\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tswitch(limitAxis)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase D6LA_Linear:\r\n\t\t\t\t\t\tjoint->setLinearLimit(softLimit);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6LA_Swing1:\r\n\t\t\t\t\t\tjoint->setSwing1Limit(softLimit);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6LA_Swing2:\r\n\t\t\t\t\t\tjoint->setSwing2Limit(softLimit);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6LA_TwistHigh:\r\n\t\t\t\t\t\tjoint->setTwistHighLimit(softLimit);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6LA_TwistLow:\r\n\t\t\t\t\t\tjoint->setTwistLowLimit(softLimit);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JD6SetSoftLimitCB\r\n// FullName: JD6SetSoftLimitCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JD6SetSoftLimitCB(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn CKBR_OK;\r\n}\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetAsActiveCamera \r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetAsActiveCameraDecl();\r\nCKERROR CreateSetAsActiveCameraProto(CKBehaviorPrototype **pproto);\r\nint SetAsActiveCamera(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetAsActiveCameraDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set As Active Camera\");\t\r\n\tod->SetDescription(\"Tells the camera to be the active one.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tThis building block enables you to switch dynamically between cameras.
\r\n See Also: 'Get Current Camera'.
\r\n */\r\n\tod->SetCategory(\"Cameras/Montage\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x368f0ab1,0x2d8957e4));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetAsActiveCameraProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetAsActiveCameraProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set As Active Camera\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetAsActiveCamera);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint SetAsActiveCamera(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n CKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\tif(behcontext.CurrentRenderContext)\r\n\t\tbehcontext.CurrentRenderContext->AttachViewpointToCamera( cam );\r\n\r\n\treturn CKBR_OK;\r\n}\r\n/*\n * Tcp4u v 3.31 Last Revision 27/02/1998 3.30\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tn_proto.c\n * Purpose: telnet based-protocol transactions\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n\n/* ------------------------------------------------------------------------- */\n/* This function does the dirty job of any protocol a la telnet */\n/* it sends an order accepting variable length parameter, then waits for the */\n/* response. The response is compared with an array if strings passed by the */\n/* calling function. The result is the matching integer if any or */\n/* TN_UNEXPECTED */\n/* ------------------------------------------------------------------------- */\nint API4U TnProtoExchange (SOCKET s, \n LPCSTR szCommande,\n LPSTR szResponse, \n UINT uBufSize, \n TNPROTOEXCHG_CBK TnProtoRecv,\n struct S_TnProto far *tTranslation, \n int nTabSize,\n BOOL bCaseCmp,\n UINT uTimeout,\n HFILE hLogFile)\n{\nint Rc;\nint Ark;\nint (far * fCompare) (LPCSTR, LPCSTR, size_t);\n#define XX_RETURN(x) { \\\n Tcp4uLog (LOG4U_EXIT, \"TnReadAnswerCode: return code %d\", x); \\\n return (x); }\n\n\n Tcp4uLog (LOG4U_PROC, \"TnProtoExchange\");\n\n if (szCommande != NULL)\n {\n Rc = TnSend (s, szCommande, FALSE, hLogFile);\n if (Rc != TN_SUCCESS) XX_RETURN (Rc);\n }\n\n /* waits for answer. NOte the final test */\n Rc = TnProtoRecv (s, szResponse, uBufSize, uTimeout, hLogFile);\n if (Rc#include \"StdAfx.h\"\n#include \"pGearbox.h\"\n#include \"vtPhysXAll.h\"\n\n#include \"pVehicleAll.h\"\n\n#include \n\n#define DEF_SIZE .25\n#define DEF_MAXRPM 5000\n#define DEF_MAXPOWER 100\n#define DEF_FRICTION 0\n#define DEF_MAXTORQUE 340 // ~ F1 Jos Verstappen\n#define DEF_TORQUE 100 // In case no curve is present\n#define USE_HARD_REVLIMIT\n\n\nfloat pGearBox::GetInertiaForWheel(pWheel2 *w)\n// Return effective inertia as seen in the perspective of wheel 'w'\n// Takes into account any clutch effects\n{\n\tfloat totalInertia;\n\t\n\tfloat inertiaBehindClutch;\n\tfloat NtfSquared,NfSquared;\n\t//rfloat rotationA;\n\tpWheel *wheel;\n\tint i;\n\n\t// Calculate total ratio multiplier; note the multipliers are squared,\n\t// and not just a multiplier for the inertia. See Gillespie's book,\n\t// 'Fundamentals of Vehicle Dynamics', page 33.\n\tNtfSquared=gearRatio[curGear]*endRatio;\n\tNtfSquared*=NtfSquared;\n\n\t/*\n\t// Calculate total inertia that is BEHIND the clutch\n\tNfSquared=endRatio*endRatio;\n\tinertiaBehindClutch=gearInertia[curGear]*NtfSquared+inertiaDriveShaft*NfSquared;\n\t\n\t/*\n\t// Add inertia of attached and powered wheels\n\t// This is a constant, so it should be cached actually (except\n\t// when a wheel breaks off)\n\tfor(i=0;iGetWheels();i++)\n\t{\n\t\twheel=car->GetWheel(i);\n\t\tif(wheel->IsPowered()&&wheel->IsAttached())\n\t\t\tinertiaBehindClutch+=wheel->GetRotationalInertia()->x;\n\t}\n\n\t// Add the engine's inertia based on how far the clutch is engaged\n\ttotalInertia=inertiaBehindClutch+clutch*inertiaEngine*NtfSquared;*/\n\treturn totalInertia;\n}\n\nfloat pGearBox::GetTorqueForWheel(pWheel2 *w)\n// Return effective torque for wheel 'w'\n// Takes into account any clutch effects\n{\n\tfloat clutch =car->getDriveLine()->GetClutchApplication();\n\t\n\tfloat torque = car->getDifferential(0)->GetTorqueOut(w->differentialSide);\n\tendRatio = car->getEngine()->GetCumulativeRatio();\n\n\n\n\n\t//car->getDriveLine()->\n\n\t\n\t\n\n\n\t//qdbg(\"clutch=%f, T=%f, ratio=%f\\n\",clutch,torque,gearRatio[curGear]*endRatio);\n\treturn clutch*torque*gearRatio[curGear]*endRatio;\n}\n\n\nvoid pGearBox::SetGear(int gear)\n{\n\tcurGear=gear;\n\tfloat cRatio = gearRatio[curGear];\n\tfloat cInertia = gearInertia[curGear];\n\tSetRatio(gearRatio[curGear]);\n\tSetInertia(gearInertia[curGear]);\n\tcar->PreCalcDriveLine();\n}\nvoid pGearBox::CalcForces()\n{\n\n}\nvoid pGearBox::Integrate()\n// Based on current input values, adjust the engine\n{\n int t;\n bool ac=true;// RMGR->IsEnabled(RManager::ASSIST_AUTOCLUTCH);\n\n pDriveLineComp::Integrate();\n\n // The shifting process\n if(autoShiftStart)\n {\n\n\t\n t=GetPMan()->GetContext()->GetTimeManager()->GetAbsoluteTime()-autoShiftStart;\n\t\n\tif(ac){\n\t\tcar->getDriveLine()->EnableAutoClutch();\n\t}\n\t\n // We are in a shifting operation\n if(curGear!=futureGear)\n {\n\t\n // We are in the pre-shift phase\n if(t>=timeToDeclutch)\n {\n // Declutch is ready, change gear\n SetGear(futureGear);\n // Trigger gear shift sample\n if(ac && (car->_currentStatus & VS_IsAccelerated) )\n\t\t\tcar->getDriveLine()->SetClutchApplication(1.0f);\n } else\n {\n // Change clutch\n if(ac && (car->_currentStatus & VS_IsAccelerated) )\n car->getDriveLine()->SetClutchApplication((t*1000/timeToDeclutch)/1000.0f);\n }\n\t \n } else\n {\n // We are in the post-shift phase\n if(t>=timeToClutch+timeToDeclutch)\n {\n // Clutch is ready, end shifting process\n\n // Conclude the shifting process\n autoShiftStart=0;\n if(ac)\n {\n\t\t\n car->getDriveLine()->SetClutchApplication(0.0f);\n car->getDriveLine()->DisableAutoClutch();\n }\n } else\n {\n // Change clutch\n \n\t\t if(ac && (car->_currentStatus & VS_IsAccelerated))\n\t\t\t car->getDriveLine()->SetClutchApplication(((t-timeToClutch)*1000/timeToDeclutch)/1000.0f);\n\t\t\n }\n }\n }\n}\n\nvoid pGearBox::processFutureGear()\n{\n\n\t//qdbg(\"pGearBox:OnGfxFrame()\\n\");\n\n\tif(autoShiftStart==0)\n\t{\n\t\t// No shift in progress; check shift commands from the controllers\n\t\tif(car->_cShiftStateUp)\n\t\t{\n\t\t\t//qdbg(\"Shift Up!\\n\");\n\t\t\tif(curGearGetContext()->GetTimeManager()->GetAbsoluteTime();\n\t\t\t\tswitch(curGear)\n\t\t\t\t{\n\t\t\t\t\tcase 0: futureGear=2; break; // From neutral to 1st\n\t\t\t\t\tcase 1: futureGear=0; break; // From reverse to neutral\n\t\t\t\t\tdefault: futureGear=curGear+1; break;\n\t\t\t\t}\n\t\t\t}\n\t\t}else if(car->_cShiftStateDown)\n\t\t{\n\t\t\tautoShiftStart=GetPMan()->GetContext()->GetTimeManager()->GetAbsoluteTime();\n\t\t\tif(curGear!=1) // Not in reverse?\n\t\t\t{\n\t\t\t\tswitch(curGear)\n\t\t\t\t{\n\t\t\t\t\tcase 0: futureGear=1; break; // From neutral to reverse\n\t\t\t\t\tcase 2: futureGear=0; break; // From 1st to neutral\n\t\t\t\t\tdefault: futureGear=curGear-1; break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//qdbg(\"Switch back to futureGear=%d\\n\",futureGear);\n\t\t}\n\t}\n}\n\nvoid pGearBox::setToDefault()\n{\n\n\tgears = 6;\n\t\n\tgearRatio[0]=1.0f;\n\tgearInertia[0]=0.0f;\n\n\tgearRatio[1]=-3.59f;\n\tgearInertia[1]=0.9f;\n\t\n\tgearRatio[2]=3.61f;\n\tgearInertia[2]=0.13f;\n\n\tgearRatio[3]=4.36f;\n\tgearInertia[3]=0.4f;\n\n\tgearRatio[4]=1.69f;\n\tgearInertia[4]=0.07f;\n\n\tgearRatio[5]=1.29f;\n\tgearInertia[5]=0.05f;\n\n\tgearRatio[6]=1.03f;\n\tgearInertia[6]=0.04f;\n\n\tgearRatios.insert(0,-3.61f);\n\tgearTensors.insert(0,0.13f);\n\t\n\tgearRatios.insert(1,3.61f);\n\tgearTensors.insert(1,0.13f);\n\t\n\tgearRatios.insert(2,2.36f);\n\tgearTensors.insert(2,0.09f);\n\n\tgearRatios.insert(3,1.69f);\n\tgearTensors.insert(3,0.07f);\n\n\n\tgearRatios.insert(4,1.29f);\n\tgearTensors.insert(4,0.05f);\n\n\tgearRatios.insert(5,1.03f);\n\tgearTensors.insert(5,0.04f);\n\n\n\tautoShiftStart = 0;\n\ttimeToClutch=300;\n\ttimeToDeclutch=300.0f;\n\tshiftDownRPM= 1110.0f;\n\tshiftUpRPM=5500.0f;\n\tfutureGear = 0;\n\t\n\n\n\n\n}\n\npGearBox::pGearBox(pVehicle *_car)\n: pDriveLineComp()\n{\n\tSetName(\"gearbox\");\n\tcar=_car;\n\tReset();\n}\npGearBox::~pGearBox()\n{\n}\n\nvoid pGearBox::Reset()\n// Reset all variables\n{\n\tint i;\n\n\tflags=0;\n\ttimeToDeclutch=timeToClutch=0;\n\tautoShiftStart=0;\n\tfutureGear=0;\n\tfor(i=0;i#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"tinyxml.h\"\r\n\r\n#include \r\n\r\n\r\nNxMaterialDesc* pFactory::createMaterialFromEntity(CKBeObject*object)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!object )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tif (!object->HasAttribute(GetPMan()->att_surface_props))\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCKParameterManager *pm = object->GetCKContext()->GetParameterManager();\r\n\tint parameterType = pm->ParameterGuidToType(VTE_XML_MATERIAL_TYPE);\r\n\r\n\tNxMaterialDesc *result = new NxMaterialDesc();\r\n\tusing namespace vtTools::AttributeTools;\r\n\tXString nodeName;\r\n\r\n\r\n\tint enumID = GetValueFromAttribute(object,GetPMan()->att_surface_props,0);\r\n\tif (enumID==0)\r\n\t{\r\n\t\tgoto takeFromAttribute;\r\n\t}\r\n\r\n\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(parameterType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\t\t\tif(i == enumID)\r\n\t\t\t{\r\n\t\t\t\tnodeName = enumStruct->GetEnumDescription(i);\r\n\t\t\t\tif (nodeName.Length())\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = createMaterialFromXML(nodeName.CStr(),getDefaultDocument());\r\n\t\t\t\t\tif (result)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\ntakeFromAttribute :\r\n\t{\r\n\t\tfloat dynamicFriction = GetValueFromAttribute(object,GetPMan()->att_surface_props,1);\r\n\t\tif (dynamicFriction >=0.0f)\r\n\t\t{\r\n\t\t\tresult->dynamicFriction =dynamicFriction;\r\n\t\t}\r\n\r\n\t\tfloat statFriction = GetValueFromAttribute(object,GetPMan()->att_surface_props,2);\r\n\t\tif (statFriction>=0.0f)\r\n\t\t{\r\n\t\t\tresult->staticFriction=statFriction;\r\n\t\t}\r\n\r\n\t\tfloat rest = GetValueFromAttribute(object,GetPMan()->att_surface_props,3);\r\n\t\tif (rest>=0.0f)\r\n\t\t{\r\n\t\t\tresult->restitution=rest;\r\n\t\t}\r\n\r\n\t\tfloat dynamicFrictionV = GetValueFromAttribute(object,GetPMan()->att_surface_props,4);\r\n\t\tif (dynamicFrictionV >=0.0f)\r\n\t\t{\r\n\t\t\tresult->dynamicFrictionV =dynamicFrictionV;\r\n\t\t}\r\n\r\n\t\tfloat staticFrictionV = GetValueFromAttribute(object,GetPMan()->att_surface_props,5);\r\n\t\tif (staticFrictionV>=0.0f)\r\n\t\t{\r\n\t\t\tresult->staticFriction=staticFrictionV;\r\n\t\t}\r\n\r\n\t\tVxVector anis = GetValueFromAttribute(object,GetPMan()->att_surface_props,6);\r\n\t\tif (anis.Magnitude()>=0.01f)\r\n\t\t{\r\n\t\t\tresult->dirOfAnisotropy=pMath::getFrom(anis);\r\n\t\t}\r\n\r\n\t\tint fMode = GetValueFromAttribute(object,GetPMan()->att_surface_props,7);\r\n\t\tif (fMode !=-1)\r\n\t\t{\r\n\t\t\tresult->frictionCombineMode=(NxCombineMode)fMode;\r\n\t\t}\r\n\t\tint rMode = GetValueFromAttribute(object,GetPMan()->att_surface_props,8);\r\n\t\tif (rMode !=-1)\r\n\t\t{\r\n\t\t\tresult->restitutionCombineMode=(NxCombineMode)rMode;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\r\n\r\n\t}\r\n\r\n\r\n\treturn result;\r\n\r\n\r\n}\r\n\r\nbool pFactory::copyTo(pMaterial&dst,NxMaterial*src)\r\n{\r\n\r\n\tif (!src)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tdst.xmlLinkID = (int)src->userData;\r\n\tdst.dirOfAnisotropy = getFrom(src->getDirOfAnisotropy());\r\n\tdst.dynamicFriction = src->getDynamicFriction();\r\n\tdst.dynamicFrictionV = src->getDynamicFrictionV();\r\n\tdst.staticFriction = src->getStaticFriction();\r\n\tdst.staticFrictionV = src->getStaticFrictionV();\r\n\tdst.frictionCombineMode = (CombineMode)src->getFrictionCombineMode();\r\n\tdst.restitutionCombineMode = (CombineMode)src->getRestitutionCombineMode();\r\n\tdst.restitution = src->getRestitution();\r\n\tdst.flags = src->getFlags();\r\n\tdst.setNxMaterialID(src->getMaterialIndex());\r\n\r\n\treturn false;\r\n}\r\nbool pFactory::copyTo(NxMaterialDesc &dst, const pMaterial &src)\r\n{\r\n\r\n\tdst.dirOfAnisotropy = getFrom(src.dirOfAnisotropy);\r\n\tdst.dynamicFriction = src.dynamicFriction;\r\n\tdst.dynamicFrictionV = src.dynamicFrictionV;\r\n\tdst.staticFriction = src.staticFriction;\r\n\tdst.staticFrictionV = src.staticFrictionV;\r\n\tdst.frictionCombineMode = (NxCombineMode)src.frictionCombineMode;\r\n\tdst.restitutionCombineMode = (NxCombineMode)src.restitutionCombineMode;\r\n\tdst.restitution = src.restitution;\r\n\tdst.flags = src.flags;\r\n\r\n\r\n\treturn true;\r\n\r\n}\r\n\r\nbool pFactory::copyTo(pMaterial& dst,CKParameter*src)\r\n{\r\n\tif (!src)return false;\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\t\r\n\tdst.xmlLinkID = GetValueFromParameterStruct(src,E_MS_XML_TYPE);\r\n\tdst.dirOfAnisotropy = GetValueFromParameterStruct(src,E_MS_ANIS);\r\n\tdst.dynamicFriction = GetValueFromParameterStruct(src,E_MS_DFRICTION);\r\n\tdst.dynamicFrictionV = GetValueFromParameterStruct(src,E_MS_DFRICTIONV);\r\n\tdst.staticFriction = GetValueFromParameterStruct(src,E_MS_SFRICTION);\r\n\tdst.staticFrictionV = GetValueFromParameterStruct(src,E_MS_SFRICTIONV);\r\n\tdst.restitution= GetValueFromParameterStruct(src,E_MS_RESTITUTION);\r\n\tdst.restitutionCombineMode= (CombineMode)GetValueFromParameterStruct(src,E_MS_RCMODE);\r\n\tdst.frictionCombineMode= (CombineMode)GetValueFromParameterStruct(src,E_MS_FCMODE);\r\n\tdst.flags= GetValueFromParameterStruct(src,E_MS_FLAGS);\r\n\treturn true;\r\n\r\n\r\n\r\n}\r\n\r\nbool pFactory::findSettings(pMaterial& dst,CKBeObject*src)\r\n{\r\n\r\n\tif (!src)return false;\r\n\r\n\tCKParameterOut *parMaterial = src->GetAttributeParameter(GetPMan()->att_surface_props);\r\n\t\r\n\tif (parMaterial){\r\n\t\tpFactory::Instance()->copyTo(dst,(CKParameter*)parMaterial);\r\n\t\tgoto EVALUATE;\r\n\t}\r\n\r\n\r\n\t\r\n\tCK3dEntity *ent3D = static_cast(src);\r\n\tif (ent3D)\r\n\t{\r\n\t\tCKMesh *mesh = ent3D->GetCurrentMesh();\r\n\t\tif (mesh)\r\n\t\t{\r\n\t\t\tparMaterial = mesh->GetAttributeParameter(GetPMan()->att_surface_props);\r\n\t\t\tif (!parMaterial)\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < mesh->GetMaterialCount() ; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKMaterial *entMaterial = mesh->GetMaterial(i);\r\n\t\t\t\t\tparMaterial = entMaterial->GetAttributeParameter(GetPMan()->att_surface_props);\r\n\t\t\t\t\tif (parMaterial)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (!parMaterial)\t\treturn false;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//copy parameter content to c++ \r\n\tpFactory::Instance()->copyTo(dst,(CKParameter*)parMaterial);\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tEvaluate from XML\r\n\t//\r\n\r\n\t \r\nEVALUATE:\r\n\r\n\tif ( dst.xmlLinkID !=0 )\r\n\t{\r\n\t\tXString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,dst.xmlLinkID);\r\n\t\tbool err = loadFrom(dst,nodeName.Str(),getDefaultDocument());\r\n\t\tif (err)\r\n\t\t{\r\n\t\t\tcopyTo(parMaterial,dst);\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nbool pFactory::copyTo(CKParameterOut*dst,const pMaterial&src)\r\n{\r\n\tif (!dst)return false;\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//@todo : find the xml name !\r\n\r\n\tSetParameterStructureValue(dst,E_MS_XML_TYPE,src.xmlLinkID,false);\r\n\tSetParameterStructureValue(dst,E_MS_DFRICTION,src.dynamicFriction,false);\r\n\tSetParameterStructureValue(dst,E_MS_DFRICTIONV,src.dynamicFrictionV,false);\r\n\tSetParameterStructureValue(dst,E_MS_SFRICTION,src.staticFriction,false);\r\n\tSetParameterStructureValue(dst,E_MS_SFRICTIONV,src.staticFrictionV,false);\r\n\tSetParameterStructureValue(dst,E_MS_FCMODE,src.frictionCombineMode,false);\r\n\tSetParameterStructureValue(dst,E_MS_RCMODE,src.restitutionCombineMode,false);\r\n\tSetParameterStructureValue(dst,E_MS_RESTITUTION,src.restitution,false);\r\n\tSetParameterStructureValue(dst,E_MS_XML_TYPE,src.xmlLinkID,false);\r\n\tSetParameterStructureValue(dst,E_MS_FLAGS,src.flags,false);\r\n\tSetParameterStructureValue(dst,E_MS_ANIS,src.dirOfAnisotropy,false);\r\n\r\n}\r\n\r\npMaterial pFactory::loadMaterial(const char* nodeName,int& error)\r\n{\r\n\tpMaterial result;\r\n\tif(loadFrom(result,nodeName,getDefaultDocument()))\r\n\t{\r\n\t\terror = 0;\r\n\t}else\r\n\t\terror =1;\r\n\r\n\treturn result;\r\n\r\n\r\n\r\n}\r\nbool pFactory::loadMaterial(pMaterial&dst,const char* nodeName/* = */)\r\n{\r\n\treturn loadFrom(dst,nodeName,getDefaultDocument());\r\n}\r\nbool pFactory::loadFrom(pMaterial &dst,const char *nodeName,const TiXmlDocument *doc)\r\n{\r\n\t\r\n\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif ( strlen(nodeName) && doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"material\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\t\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"DynamicFriction\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tdst.dynamicFriction = (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFriction\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tdst.staticFriction= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Restitution\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tdst.restitution= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"DynamicFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tdst.dynamicFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tdst.staticFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* dirOfAnisotropy = NULL;\r\n\t\t\t\t\t\t\t\t\tdirOfAnisotropy = sube->Attribute(\"DirOfAnisotropy\");\r\n\t\t\t\t\t\t\t\t\tif (dirOfAnisotropy && strlen(dirOfAnisotropy))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxVector vec = _str2Vec(dirOfAnisotropy);\r\n\t\t\t\t\t\t\t\t\t\tdst.dirOfAnisotropy = vec;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tconst char* flags = NULL;\r\n\t\t\t\t\t\t\t\t\tflags = sube->Attribute(\"Flags\");\r\n\t\t\t\t\t\t\t\t\tif (flags && strlen(flags))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.flags = _str2MaterialFlag(flags);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* FrictionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tFrictionCombineMode = sube->Attribute(\"FrictionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (FrictionCombineMode && strlen(FrictionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(FrictionCombineMode);\r\n\t\t\t\t\t\t\t\t\t\tdst.frictionCombineMode = (CombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* RestitutionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tRestitutionCombineMode = sube->Attribute(\"RestitutionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (RestitutionCombineMode && strlen(RestitutionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(RestitutionCombineMode);\r\n\t\t\t\t\t\t\t\t\t\tdst.restitutionCombineMode= (CombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\nNxMaterialDesc*pFactory::createMaterialFromXML(const char* nodeName/* = */,const TiXmlDocument * doc /* = NULL */)\r\n{\r\n\r\n\t\r\n\t\r\n\tNxMaterialDesc *result = new NxMaterialDesc();\r\n\tresult->setToDefault();\r\n\r\n\tif (doc ==NULL)\r\n\t\treturn result;\r\n\r\n\tif (!getFirstDocElement(doc->RootElement()))\r\n\t\treturn result;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif ( strlen(nodeName) && doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"material\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\t\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"DynamicFriction\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dynamicFriction = (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFriction\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->staticFriction= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Restitution\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->restitution= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"DynamicFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dynamicFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->staticFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* dirOfAnisotropy = NULL;\r\n\t\t\t\t\t\t\t\t\tdirOfAnisotropy = sube->Attribute(\"DirOfAnisotropy\");\r\n\t\t\t\t\t\t\t\t\tif (dirOfAnisotropy && strlen(dirOfAnisotropy))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxVector vec = _str2Vec(dirOfAnisotropy);\r\n\t\t\t\t\t\t\t\t\t\tif (vec.Magnitude() >0.1f)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresult->flags = NX_MF_ANISOTROPIC;\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dirOfAnisotropy = pMath::getFrom(vec);\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dirOfAnisotropy = pMath::getFrom(VxVector(0,0,0));\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\t//result->setGravity(vec);\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* FrictionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tFrictionCombineMode = sube->Attribute(\"FrictionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (FrictionCombineMode && strlen(FrictionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(FrictionCombineMode);\r\n\t\t\t\t\t\t\t\t\t\tresult->frictionCombineMode = (NxCombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* RestitutionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tRestitutionCombineMode = sube->Attribute(\"RestitutionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (RestitutionCombineMode && strlen(RestitutionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(RestitutionCombineMode);\r\n\t\t\t\t\t\t\t\t\t\tresult->restitutionCombineMode= (NxCombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}import sys\r\nimport socket\r\n\r\ndef main():\r\n server = server_create('localhost', 9090)\r\n while 1:\r\n #accept connections from outside\r\n (client, address) = server.accept()\r\n\r\n msg = message_get(client)\r\n if (msg):\r\n print \"recieved(%s)\" % (msg)\r\n message_send(client, sys.argv[1])\r\n print \"sent(%s)\" % (sys.argv[1])\r\n else:\r\n break\r\n\r\ndef server_create(host, port):\r\n #create an INET, STREAMing socket\r\n server = socket.socket(\r\n socket.AF_INET, socket.SOCK_STREAM)\r\n #bind the socket to a public host, \r\n # and a well-known port\r\n server.bind((host, port))\r\n #become a server socket\r\n server.listen(5)\r\n\r\n return server\r\n\r\n### Common ####\r\nMSGLEN = 1024\r\n\r\ndef message_get(sock):\r\n msg = ''\r\n while len(msg) < MSGLEN:\r\n chunk = sock.recv(MSGLEN-len(msg))\r\n if chunk == '':\r\n raise RuntimeError, \"socket connection broken\"\r\n msg = msg + chunk\r\n return msg\r\n return 0\r\n\r\ndef message_send(sock, message):\r\n msgfmt = \"%-\" + \"%ds\" % (MSGLEN)\r\n msg = msgfmt % (message)\r\n\r\n totalsent = 0\r\n while totalsent < MSGLEN:\r\n sent = sock.send(msg[totalsent:])\r\n if sent == 0:\r\n raise RuntimeError, \"socket connection broken\"\r\n totalsent = totalsent + sent\r\n return 1\r\n\r\nmain()#include \r\n\r\n#include \"pCrossTypes.h\"\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtStructHelper.h\"\r\n#include \"vtAttributeHelper.h\"\r\n\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* Dominance Setup */\r\n/************************************************************************/\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\tDominance help member : \r\n//\r\nStructurMember dominanceConstraint[] =\r\n{\r\n\t\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Dominance 0\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Dominance 1\",\"1.0\"),\r\n};\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\tDominance help member : \r\n//\r\nStructurMember dominanceItem[] =\r\n{\r\n\r\n\tSTRUCT_ATTRIBUTE(VTE_PHYSIC_DOMINANCE_GROUP,\"Dominance Group A\",\"1\"),\r\n\tSTRUCT_ATTRIBUTE(VTE_PHYSIC_DOMINANCE_GROUP,\"Dominance Group B\",\"2\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_CONSTRAINT,\"Dominance Constraint\",\"1.0,0.0\"),\r\n\r\n};\r\n\r\nStructurMember dominanceSetup[] =\r\n{\r\n\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_ITEM,\"Settings 1\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_ITEM,\"Settings 2\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_ITEM,\"Settings 3\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_ITEM,\"Settings 4\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DOMINANCE_ITEM,\"Settings 5\",\"0\"),\r\n};\r\n//STRUCT_ATTRIBUTE(CKPGUID_2DCURVE,\"Settings 5\",\"0\"),\r\n\r\nvoid PhysicManager::_RegisterWorldParameters()\r\n{\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\tCKParameterTypeDesc* param_type = NULL;\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Dominance Structs\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pWDominanceConstraint\",PS_W_DOMINANCE_CONSTRAINT,VTS_PHYSIC_DOMINANCE_CONSTRAINT,dominanceConstraint,true);\r\n\r\n\t// Dominance group as user friendly enumeration \r\n\tpm->RegisterNewEnum(VTE_PHYSIC_DOMINANCE_GROUP,\"pDominanceGroup\",\"None=0,First=1,Second=2\");\r\n\tparam_type=pm->GetParameterTypeDescription(VTE_PHYSIC_DOMINANCE_GROUP);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_USER;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_TOSAVE;\r\n\r\n\r\n\t//if (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pDominanceItem\",PS_W_DOIMINANCE,VTS_PHYSIC_DOMINANCE_ITEM,dominanceItem,true);\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pDominanceSetup\",PS_W_DOIMINANCE_SETUP,VTS_PHYSIC_DOMINANCE_SCENE_SETTINGS,dominanceSetup,true);\r\n\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"Dominance Group Setup\",PS_W_DOIMINANCE_SETUP,PHYSIC_BODY_CAT,VTS_PHYSIC_DOMINANCE_SCENE_SETTINGS,CKCID_3DENTITY,dominanceSetup,true);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* world */\r\n\t/************************************************************************/\r\n\r\n\t/*pm->RegisterNewEnum(VTE_PHYSIC_BODY_COLL_GROUP,\"pBCollisionsGroup\",\"All=0,MyObstacles=1,MyWheels=2\");\r\n\tparam_type=pm->GetParameterTypeDescription(VTE_PHYSIC_BODY_COLL_GROUP);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_USER;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\t*/\r\n\r\n\r\n\tpm->RegisterNewStructure(VTS_PHYSIC_WORLD_PARAMETER,\t\t\"pWorldSettings\", \"Gravity,SkinWith\",\t\tCKPGUID_VECTOR,\t\tCKPGUID_FLOAT\t\t);\r\n\r\n\tatt_world_object = attman->RegisterNewAttributeType(\"World\",VTS_PHYSIC_WORLD_PARAMETER,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_world_object,\"Physic\");\r\n\r\n\r\n\r\n\r\n\r\n}\r\nswig.exe -c++ -csharp csWindow.i\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJAddLimitPlaneDecl();\r\nCKERROR CreatePJAddLimitPlaneProto(CKBehaviorPrototype **pproto);\r\nint PJAddLimitPlane(const CKBehaviorContext& behcontext);\r\nCKERROR PJAddLimitPlaneCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Type,\r\n\tbI_Res,\r\n\tbI_LPoint,\r\n\tbI_LPointRef,\r\n\tbI_IsOnBodyB,\r\n\tbI_Anchor,\r\n\tbI_AnchorRef,\r\n\tbI_Axis,\r\n\tbI_AxisRef,\r\n\tbI_Coll\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJAddLimitPlaneDecl\r\n// FullName: FillBehaviorPJAddLimitPlaneDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJAddLimitPlaneDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJAddLimitPlane\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Adds a limit plane to a joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x150a1e5a,0xebc0c00));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJAddLimitPlaneProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJAddLimitPlaneProto\r\n// FullName: CreatePJAddLimitPlaneProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJAddLimitPlaneProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJAddLimitPlane\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\t/*! \\page PJAddLimitPlane \r\n\r\n\t
\r\n\tPJAddLimitPlane is categorized in \\ref Joints\r\n\t
\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAdds a limit plane. \r\n\t
\r\n\t
See PJPointInPlane.cmo.\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJAddLimitPlane.png\r\n\r\n\tThis building blocks invokes #pJoint::setLimitPoint() and afterwards #pJoint::addLimitPlane() internally.\r\n \r\n\r\n\tIn: triggers the process.\r\n\t
\r\n\t
\r\n\t\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t\r\n\t\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\r\n\tJoint Type: The joint type. This helps the building block to identify a joint constraint. As usual there can be only one joint of the type x between two bodies.
\r\n\r\n\r\n\tRestitution: Restitution of the limit plane.
\r\n\t-\tRange: [0,1.0f)\r\n\t-\tDefault: 0.0 \r\n\r\n\r\n\tLimit Point:The point specified in global coordinate frame.
\r\n\t-\tRange: [Position Vector)\r\n\r\n\tLimit Point Reference:Reference to transform limit point (local) into world space.
\r\n\r\n\tPoint is Body B:Set to true if the point is attached to the second actor.Otherwise it is attached to the first.
\r\n\r\n\tPoint in Plane:Point in the limit plane in global coordinates.
\r\n\t-\tRange: [Position Vector)\r\n\r\n\tPoint in Plane Reference:Reference to transform plane \"Point in Plane\"(local then) into global coordinates.
\r\n\r\n\tNormal:Normal for the limit plane in global coordinates.
\r\n\t-\tRange: [Position Vector)\r\n\r\n\tNormal Reference:Reference to transform plane \"Normal\"(local up then) into global coordinates.
\r\n\r\n\t\r\n\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\t\\include pJAddLimitPlane.vsl\r\n\t\r\n\r\n\t\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #joint::setLimitPoint() #joint::addLimitPlane()\r\n\r\n\t*/\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->SetBehaviorCallbackFct( PJAddLimitPlaneCB );\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Type\",VTE_JOINT_TYPE,\"\");\r\n\tproto->DeclareInParameter(\"Restitution\",CKPGUID_FLOAT,\"0.0f\");\r\n\t\r\n\tproto->DeclareInParameter(\"Limit Point\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Limit Point Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Point Is On Body B\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Point In Plane\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Point In Plane Reference\",CKPGUID_3DENTITY);\r\n\r\n\tproto->DeclareInParameter(\"Normal\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Normal Reference\",CKPGUID_3DENTITY);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJAddLimitPlane);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJAddLimitPlane\r\n// FullName: PJAddLimitPlane\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJAddLimitPlane(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\r\n\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Revolute))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA && ! worldB )\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor0 = GetInputParameterValue(beh,bI_LPoint);\r\n\t\tVxVector anchorOut0 = anchor0;\r\n\t\tCK3dEntity*anchorReference0 = (CK3dEntity *) beh->GetInputParameterObject(bI_LPointRef);\r\n\t\tif (anchorReference0)\r\n\t\t{\r\n\t\t\tanchorReference0->Transform(&anchorOut0,&anchor0);\r\n\t\t}\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor = GetInputParameterValue(beh,bI_Anchor);\r\n\t\tVxVector anchorOut = anchor;\r\n\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);\r\n\t\tif (anchorReference)\r\n\t\t{\r\n\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t}\r\n\t\t//swing axis\r\n\t\tVxVector Axis = GetInputParameterValue(beh,bI_Axis);\r\n\t\tVxVector axisOut = Axis;\r\n\t\tCK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);\r\n\r\n\t\tif (axisReference)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\taxisReference->GetOrientation(&dir,&up,&right);\r\n\t\t\taxisReference->TransformVector(&axisOut,&up);\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint type = GetInputParameterValue(beh,bI_Type);\r\n\t\tint isOnBodyB = GetInputParameterValue(beh,bI_IsOnBodyB);\r\n\t\tfloat res = GetInputParameterValue(beh,bI_Res);\r\n\t\tpJoint*joint = (worldA->getJoint(target,targetB,(JType)type));\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tif (XAbs(anchorOut0.SquareMagnitude()) >=0.01f)\r\n\t\t\t\t\tjoint->setLimitPoint(anchorOut0,isOnBodyB);\r\n\t\r\n\t\t\t\tVxVector b = anchorOut;\r\n\t\t\t\tjoint->addLimitPlane(axisOut,anchorOut,res);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJAddLimitPlaneCB\r\n// FullName: PJAddLimitPlaneCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJAddLimitPlaneCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\r\n/*\t\t\r\n\t\t\tDWORD twistLimit;\r\n\t\t\tbeh->GetLocalParameterValue(1,&twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_HighLimit,twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_LowLimit,twistLimit);\r\n\r\n\t\t\tDWORD springSwing;\r\n\t\t\tbeh->GetLocalParameterValue(0,&springSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_Spring,springSwing);\r\n\r\n\t\t\tDWORD motor;\r\n\t\t\tbeh->GetLocalParameterValue(2,&motor);\r\n\t\t\tbeh->EnableInputParameter(bbI_Motor,motor);\r\n*/\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2007/12/15\r\n\tcreated:\t15:12:2007 22:33\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\plugins\\xUtils\\src\\xUtils.cpp\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\plugins\\xUtils\\src\r\n\tfile base:\txUtils\r\n\tfile ext:\tcpp\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#include \t\t/// DWORD,\r\n#include \r\n#include \"xUtils.h\"\r\n\r\n\r\n\r\n\r\n#include \"d3d9.h\"\r\n\r\n#include \"3d/DXDiagNVUtil.h\"\r\n\r\n//************************************\r\n// Method: GetPhysicalMemoryInMB\r\n// FullName: xUtils::system::GetPhysicalMemoryInMB\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n//************************************\r\nint\r\nxUtils::system::GetPhysicalMemoryInMB()\r\n{\r\n\r\n\tDXDiagNVUtil nvutil;\r\n\tnvutil.InitIDxDiagContainer();\r\n\r\n\r\n\tfloat ret = -1;\r\n\tnvutil.GetPhysicalMemoryInMB(&ret);\r\n\tnvutil.FreeIDxDiagContainer();\r\n\r\n\treturn static_cast(ret);\r\n}\r\n//is defined in GetDXVer.cpp : \r\nextern HRESULT GetDXVersion( DWORD* pdwDirectXVersion, TCHAR* strDirectXVersion, int cchDirectXVersion );\r\n\r\n//************************************\r\n// Method: GetDirectVersion\r\n// FullName: xUtils::GetDirectVersion\r\n// Access: private static \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: char*&version\r\n// Parameter: int& minor\r\n// Description : \r\n//************************************\r\nHRESULT\r\nxUtils::system::GetDirectVersion(char*&version,DWORD& minor)\r\n{\r\n\r\n\tHRESULT hr;\r\n\tTCHAR strResult[128];\r\n\tDWORD dwDirectXVersion = 0;\r\n\tTCHAR strDirectXVersion[10];\r\n\r\n\thr = GetDXVersion( &minor,strResult, 10 );\r\n\tversion = new char[strlen(strResult)];\r\n\tstrcpy(version,strResult);\r\n\treturn hr;\r\n\t//strcpy(version,strDirectXVersion);\r\n}\r\n\r\nint GetPhysicalMemoryInMB()\r\n{\r\n\tDXDiagNVUtil nvutil;\r\n\tnvutil.InitIDxDiagContainer();\r\n\r\n\r\n\tfloat ret = -1;\r\n\tnvutil.GetPhysicalMemoryInMB(&ret);\r\n\tnvutil.FreeIDxDiagContainer();\r\n\r\n\treturn ret;\r\n}\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t AddNodalLink\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"StdAfx.h\"\r\n#include \"virtools/vtcxglobal.h\"\r\n#include \"windows.h\"\r\n#include \"Python.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \"pyembed.h\"\r\n#include \"InitMan.h\"\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetNextBBIdDecl();\r\nCKERROR CreateGetNextBBIdProto(CKBehaviorPrototype **);\r\nint GetNextBBId(const CKBehaviorContext& behcontext);\r\nCKERROR GetNextBBIdCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetNextBBIdDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"GetNextBBId\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x572066cc,0x58402b59));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetNextBBIdProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Python\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateGetNextBBIdProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"GetNextBBId\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t//proto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareOutParameter(\"ck_id\",CKPGUID_INT);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( GetNextBBId );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint GetNextBBId(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\t\r\n\tint count = beh->GetParent()->GetSubBehaviorLinkCount();\r\n\tint result = -1;\r\n \r\n\tfor (int i=0; iGetParent()->GetSubBehaviorLink(i);\r\n\t\tif (link->GetInBehaviorIO() == beh->GetOutput(0))\r\n\t\t{\r\n\t\t\tresult = link->GetOutBehaviorIO()->GetOwner()->GetID();\r\n\t\t\tbeh->SetOutputParameterValue(0,&result);\r\n\t\t\t//threadInfo->targetBeh = link->GetOutBehaviorIO()->GetOwner();\r\n\r\n\t\t\t/*int targetInputs = threadInfo->targetBeh->GetInputCount();\r\n\t\t\tif (targetInputs == 1)\r\n\t\t\t{\r\n\t\t\t\t//threadInfo->targetInputToActivate = 0;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tfor (int j=0; jGetOutBehaviorIO() == threadInfo->targetBeh->GetInput(j))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//threadInfo->targetInputToActivate = j;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}*/\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t\r\n\tCKBehavior *script = static_cast(ctx->GetObject(result));\r\n\tif (script)\r\n\t{\r\n\t\tint bc = script->GetOutputCount();\r\n\r\n\t\tint bc2 = script->GetInputCount();\r\n\r\n\t}\r\n\r\n\r\n\tbeh->ActivateOutput(0);\r\n\tbeh->SetOutputParameterValue(0,&result);\r\n\treturn CKBR_OK;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 9:07\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\ModulePrerequisites.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\r\n\tfile base:\tModulePrerequisites\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tInclude of all prerequisites\r\n*********************************************************************/\r\n#ifndef __PREREQUISITES_ALL_H__\r\n#define __PREREQUISITES_ALL_H__\r\n\r\n//################################################################\r\n//\r\n//\tCommon forward declarations :\r\n//\r\n\r\n//################################################################\r\n//\r\n// Virtools related forward declarations :\r\n//\r\n#include \"Prerequisites_Virtools.h\"\r\n\r\n//################################################################\r\n//\r\n// 3th party forward declarations : \r\n//\r\n//\t+ TinyXML\r\n//\t+ NXUStream\r\n//\r\n#include \"Prerequisites_3thParty.h\"\r\n\r\n//################################################################\r\n//\r\n// Main library forward declarations :\r\n//\r\n#include \"Prerequisites_PhysX.h\"\r\n\r\n//################################################################\r\n//\r\n// Forward declarations for this module itself : \r\n//\r\n#include \"Prerequisites_Module.h\"\r\n\r\n#include \"Timing.h\"\r\n\r\n\r\n\r\n\r\n#endif\r\n\r\n#ifndef __P_GEARBOX_H__\n#define __P_GEARBOX_H__\n\n#include \"vtPhysXBase.h\"\n#include \"XString.h\"\n#include \"pDriveline.h\"\n\n#include \"pLinearInterpolation.h\"\n\n\nclass MODULE_API pGearBox : public pDriveLineComp\n{\n public:\n enum Max\n { MAX_GEAR=10 // #gears possible\n };\n enum Flags\n {\n AUTOMATIC=1 // Auto shifting\n };\n\n //----------------------------------------------------------------\n //\n // public access \n //\n pLinearInterpolation gearRatios;\n pLinearInterpolation gearTensors;\n \n pLinearInterpolation& getGearTensors() { return gearTensors; }\n void setGearTensors(pLinearInterpolation val) { gearTensors = val; }\n\n pLinearInterpolation& getGearRatios(){ return gearRatios; }\n void setGearRatios(pLinearInterpolation val) { gearRatios = val; }\n \n void setToDefault();\n\n int getGears() const { return gears; }\n void setGears(int val) { gears = val; }\n \n float getShiftUpRPM() const { return shiftUpRPM; }\n void setShiftUpRPM(float val) { shiftUpRPM = val; }\n float getShiftDownRPM() const { return shiftDownRPM; }\n void setShiftDownRPM(float val) { shiftDownRPM = val; }\n\n int& getFlags(){return flags;};\n void setFlags(int val);\n \n int getTimeToDeclutch() const { return timeToDeclutch; }\n void setTimeToDeclutch(int val) { timeToDeclutch = val; }\n \n int getTimeToClutch() const { return timeToClutch; }\n void setTimeToClutch(int val) { timeToClutch = val; }\n public:\n // Semi-fixed properties\n pVehicle *car; // The car to which we belong\n\n // Physical attributes\n int flags;\n \n float gearRatio[MAX_GEAR];\n int gears;\n \n float gearInertia[MAX_GEAR]; // Rotational inertia per gear\n // Shifting (static)\n int timeToDeclutch; // Auto-shifting time\n int timeToClutch;\n \n float shiftUpRPM; // Automatic transmissions\n float shiftDownRPM; \n \n \n\n // State (dynamic output)\n int curGear; // Selected gear\n int autoShiftStart; // Time of auto shift initiation\n int futureGear; // Gear to shift to\n\n public:\n pGearBox(pVehicle *car);\n ~pGearBox();\n\n void Reset(); // Reset all vars\n\n // Definition\n \n /*\n bool Load(QInfo *info,cstring path=0);\n bool LoadState(QFile *f);\n bool SaveState(QFile *f);\n */\n\n float endRatio; // Final drive ratio\n\n // Attribs\n#ifdef OBS\n // Engine torque generation\n float GetMinTorque(float rpm);\n float GetMaxTorque(float rpm);\n float GetTorqueAtDifferential();\n#endif\n\n //float GetEngineInertia(){ return inertiaEngine; }\n float GetGearInertia(){ return gearInertia[curGear]; }\n float GetInertiaAtDifferential();\n float GetInertiaForWheel(pWheel2 *w);\n float GetTorqueForWheel(pWheel2 *w);\n\n\n int GetGears(){ return gears; }\n int GetGear(){ return curGear; }\n float GetGearRatio(int n);\n //float GetEndRatio();\n void SetGear(int n);\n XString GetGearName(int gear);\n bool IsNeutral(){ if(curGear==0)return true; return false; }\n\n void processFutureGear();\n \n // Input\n void SetInput(int ctlThrottle,int ctlClutch);\n \n // Graphics\n void Paint();\n\n // Physics\n void CalcForces();\n void Integrate();\n void OnGfxFrame();\n};\n\n#endif\n#ifndef __VT_BASE_MACROS_H__\r\n#define __VT_BASE_MACROS_H__\r\n\r\n\r\n#include \"vtModuleConstants.h\"\r\n\r\n//################################################################\r\n//\r\n// Universal macros\r\n//\r\n\r\n#define VTCX_API_ENTRY(F) VTCX_API_PREFIX##F\r\n#define VTCX_API_CUSTOM_BB_CATEGORY(F) VTCX_API_PREFIX##F\t\r\n\r\n\r\n#ifndef XINLINE \r\n\t#define XINLINE inline\r\n#endif\r\n\r\n#endif// racer/engine.h\n// 30-12-01: Gearbox split from engine into class RGearBox\n\n#ifndef __P_ENGINE_H__\n#define __P_ENGINE_H__\n\n#include \"vtPhysXBase.h\"\n#include \"pDriveline.h\"\n#include \"pVehicleTypes.h\"\n\n\nclass RWheel;\n\nclass MODULE_API pEngine : public pDriveLineComp\n{\n public:\n enum Flags\n {\n STALLED=1, // Engine is turned off\n HAS_STARTER=2, // Start engine present?\n START_STALLED=4, // When reset, don't autostart engine?\n AUTOCLUTCH_ACTIVE=8 // Assist on?\n };\n\n enum Max\n { MAX_GEAR=10 // #gears possible\n };\n\n \n //----------------------------------------------------------------\n //\n // public interface \n //\n\n\n \n\n public:\n pVehicle *ownerVehicle; // The car to which we belong\n \n\n // Static data\n float size;\n VxVector position;\n float mass;\n \n int flags;\n \n int& getFlags() { return flags; }\n void setFlags(int val);\n\n // To calculate engine braking\n\n float idleThrottle, // Always open by this much 0..1\n throttleRange; // Effective throttle range\n float maxTorque; // Factor for normalize torque curve\n \n float maxRPM; // Hard maximum\n\n float getMaxTorque() const { return maxTorque; }\n void setMaxTorque(float val) { maxTorque = val; }\n float getMaxRPM() const { return maxRPM; }\n void setMaxRPM(float val) { maxRPM = val; }\n float getClutch() const { return clutch; }\n void setClutch(float val) { clutch = val; }\n \n int getFrictionMethod() { return FC_GENTA ;}\n \n \n\n\n float clutch; // Clutch 0..1 (1=fully locked)\n \n \n\n //int autoShiftStart; // Time of auto shift initiation\n //int futureGear; // Gear to shift to\n //float rotationV; // Engine rotation speed\n float torqueWheels, // Torque available for the wheels\n\t torqueEngine;\n //----------------------------------------------------------------\n //\n // customizable attributes\n //\n \n float starterTorque; // Torque generated by starter\n float idleRPM; // RPM when no throttle/friction\n float forceFeedbackScale;\n\npublic :\n\t\n\tfloat getForceFeedbackScale() const { return forceFeedbackScale; }\n\tvoid setForceFeedbackScale(float val) { forceFeedbackScale = val; }\n\n float getStarterTorque() const { return starterTorque; }\n void setStarterTorque(float val);\n float getIdleRPM() const { return idleRPM; }\n void setIdleRPM(float val);\n float getStallRPM() const { return stallRPM; }\n void setStallRPM(float val) { stallRPM = val; }\n \n float getBrakingCoeff() const { return brakingCoeff; }\n void setBrakingCoeff(float val);\n \n float getFriction() const { return friction; }\n void setFriction(float val);\n \n float getStartRPM() const { return startRPM; }\n void setStartRPM(float val);\n \n float getAutoClutchRPM() const { return autoClutchRPM; }\n void setAutoClutchRPM(float val) { autoClutchRPM = val; }\n\n float stallRPM; // At which point does the engine stall\n float startRPM; // At which point does it turn on again?\n float autoClutchRPM; // When to start applying the clutch\n float friction; // Friction coeff of motor itself\n float brakingCoeff; \n \n \n //----------------------------------------------------------------\n //\n // unknown \n //\n \n float torqueReaction; // Amount (0..1) at which engine\n\n // Dynamic data (some (tEngine) is stored in RDriveLineComp)\n \n // torque reaches the body\n \n // Physical attributes\n // Inertia\n float inertiaEngine, // Engine internal rotation\n inertiaDriveShaft; // Differential\n // Gearbox\n float gearRatio[MAX_GEAR];\n int gears;\n float endRatio; // Final drive ratio\n float gearInertia[MAX_GEAR]; // Rotational inertia per gear\n // Shifting\n int timeToDeclutch, // Auto-shifting time\n timeToClutch;\n float shiftUpRPM, // Automatic transmissions\n shiftDownRPM;\n\n\n // State (dynamic output)\n int curGear; // Selected gear\n float force; // Force put out\n float torque; // Torque sent to drivetrain\n \n\n // Input\n float throttle;\n float brakes;\n\n pLinearInterpolation torqueCurve;\n \n public:\n pEngine(pVehicle *car);\n ~pEngine();\n\n void setToDefault();\n \n pLinearInterpolation* getTorqueCurve(){ return &torqueCurve; }\n void setTorqueCurve(pLinearInterpolation val);\n\n pVehicle * getVehicle(){ return ownerVehicle; }\n void getVehicle(pVehicle * val) { ownerVehicle = val; }\n\n \n float getRPM(){ return (GetRotationVel()/(2*PI))*60.0f; }\n void setRPM(float rpm);\n float getTorque(){ return GetEngineTorque(); }\n \n \n\n // Definition\n\n void clean(); // clean all vars\n void initData(); // Initialize usage of engine\n void preStep(); // Precalculate some variables\n\n // Attribs\n float GetMass(){ return mass; }\n \n bool IsStalled(){ if(flags&STALLED)return TRUE; return FALSE; }\n void EnableStall(){ flags|=STALLED; }\n void DisableStall(){ flags&=~STALLED; }\n bool HasStarter(){ if(flags&HAS_STARTER)return TRUE; return FALSE; }\n\n\n /*\n bool IsAutoClutchActive()\n { if(flags&AUTOCLUTCH_ACTIVE)return TRUE; return FALSE; }\n float GetAutoClutch(){ return autoClutch; }\n */\n\n\n // Engine torque generation\n float GetMinTorque(float rpm);\n float GetMaxTorque(float rpm);\n float GetTorqueAtDifferential();\n\n float GetEngineInertia(){ return inertiaEngine; }\n float GetGearInertia(){ return gearInertia[curGear]; }\n float GetInertiaAtDifferential();\n float GetInertiaForWheel(pWheel2 *w);\n float GetTorqueForWheel(pWheel2 *w);\n\n\n // Gearbox\n int GetGears(){ return gears; }\n int GetGear(){ return curGear; }\n float GetGearRatio(int n);\n float GetEndRatio();\n void SetGear(int n);\n\n\n // Input\n \n void updateUserControl(int ctlThrottle);\n \n\n // Physics\n void CalcForces();\n void CalcAccelerations();\n \n void Integrate();\n\n\n float GetForce(){ return force; }\n float GetTorqueReaction(){ return torqueReaction; }\n\n float getEndBrakingTorqueForWheel(CK3dEntity *wheelReference);\n float getEndTorqueForWheel(CK3dEntity *wheelReference);\n float getEndAccForWheel(CK3dEntity *wheelReference);\n\n float rotationalEndFactor;\n\n float timeScale;\n \n float getTimeScale() const { return timeScale; }\n void setTimeScale(float val) { timeScale = val; }\n\n float getEndRotationalFactor() { return rotationalEndFactor; }\n void setEndRotationalFactor(float val) { rotationalEndFactor = val; }\n\n\n //float GetRollingFrictionCoeff(){ return rollingFrictionCoeff; }\n\n};\n\n#endif\n#include \"Manager.h\"\r\n\r\n#ifdef CK_LIB\r\n\t#define RegisterBehaviorDeclarations\tRegister_CSHARP_BehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\t_CSHARP_InitInstance\r\n\t#define ExitInstance\t\t\t\t\t_CSHARP_ExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGet_CSHARP_PluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGet_CSHARP_PluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_CSHARP_PluginInfo\r\n#else\r\n\t#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\tInitInstance\r\n\t#define ExitInstance\t\t\t\t\tExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\n\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n#define ADDONS2_BEHAVIOR\tCKGUID(0x119d47be,0x74c0241b)\r\n\r\nCKPluginInfo g_PluginInfo;\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount() { return\t 2; }\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n\tCSManager* csman =new CSManager(context);\r\n\treturn CK_OK;\r\n}\t\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\tCSManager* cman =(CSManager*)context->GetManagerByGuid(INIT_MAN_GUID);\r\n\tdelete cman;\r\n\treturn CK_OK;\r\n}\t\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tswitch (Index) \r\n\t{\r\n\tcase 0:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"tool building blocks\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= ADDONS2_BEHAVIOR;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"CSharp BB\";\r\n\t\tbreak;\r\n\r\n\tcase 1:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"tool Manager \";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= InitInstance;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= ExitInstance;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_MAN_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"CSharpManager\";\r\n\t\tbreak;\r\n\t}\r\n\treturn &g_PluginInfo;\r\n\r\n}\r\n\r\n/**********************************************************************************/\r\n/**********************************************************************************/\r\n\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\t\r\n\tRegisterBehavior(reg, FillBehaviorSendCSMessageDecl);\r\n\t/*\r\n\t// Get Nearest Vertex\r\n\tRegisterBehavior(reg, FillBehaviorGetNearestVertexDecl);\r\n\t// Scene Antialias\r\n\tRegisterBehavior(reg, FillBehaviorSceneAntialiasDecl);\r\n\t// Merge Mesh\r\n\tRegisterBehavior(reg, FillBehaviorMergeMeshDecl);\r\n\t// Get Host Platform\r\n\tRegisterBehavior(reg, FillBehaviorGetHostPlatformDecl);\r\n\t//Open File\r\n\tRegisterBehavior(reg, FillBehaviorOpenFileDecl);*/\r\n\t\r\n}\r\n\r\n\r\nFAQ : \r\n\r\n\r\nWhere to set fade in/out time, splash bitmap, bitmap trancparency, text position for loading text, or the font type ? \r\n\r\n -> go in the project xSplash -> xSplash.cpp -> function CreateSplashEx(...)\r\n \r\n : \r\n\r\n#define CSS_FADEIN\t\t0x0001\r\n#define CSS_FADEOUT\t\t0x0002\r\n#define CSS_FADE\t\tCSS_FADEIN | CSS_FADEOUT\r\n#define CSS_SHADOW\t\t0x0004\r\n#define CSS_CENTERSCREEN\t0x0008\r\n#define CSS_CENTERAPP\t\t0x0010\r\n#define CSS_HIDEONCLICK\t\t0x0020\r\n\r\n#define CSS_TEXT_NORMAL\t\t0x0000\r\n#define CSS_TEXT_BOLD\t\t0x0001\r\n#define CSS_TEXT_ITALIC\t\t0x0002\r\n#define CSS_TEXT_UNDERLINE\t0x0004\r\n \r\n\r\nWhere to change the \"Load ...90%\" Text ? \r\n\r\n->CustomPlayer.cpp -> LoadCallback() (last function)\r\n\r\n if (loaddata.NbObjetsLoaded % 10 == 0) : means, update text each 10th object !\r\n \r\n\r\nWhere to change the about tab text ?\r\n\r\n - goto \\res\\about.txt !\r\n you can use mailto: or www.playgen.com for links.\r\n\r\n\r\nWhere to change global settings ? \r\n\r\nin CustomPlayerDefines.h ! : \r\n\r\n#define CPR_CHECK_DIRECTX\t1\t\t//\tthis leads to a directx check, is using xUtils.dll\r\n#define CPR_MINIMUM_DIRECTX_VERSION\t8\t\t// this is our minimum version, always write at least 3 letters like 10.0\r\n#define CPR_MINIMUM_DIRECTX_VERSION_FAIL_URL\t\"www.microsoft.com\"\r\n#define CPR_OFFER_INTERNAL_DIRECTX_INSTALLER 0\t\t// not implemented \r\n\r\n#define CPR_CHECK_RAM\t1\t//performes a memory check, is using xUtils.dll and it needs a directx !!!\r\n#define CPR_MINIMUM_RAM\t256\t//our minimum pRam\r\n#define CPR_MINIMUM_RAM_FAIL_ABORT 0\t// this leads to a application exit !\r\n\r\n\r\n#define CP_SUPPORT_EMAIL \"\" // \r\n\r\n// [12/16/2007 mc007]\t//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\tApplication Features : \r\n#define CPF_HAS_SPLASH\t1\t//\tdisplays a splash, is using xsplash.dll ! it also adds a loading callback\r\n#define CPF_SPLASH_FILE\t\"splash.bmp\" //not used !\r\n#define CPF_SPLASH_TEXT_TYPE\t\"MicrogrammaDBolExt\" \r\n#define CPF_SPLASH_TEXT_FORMAT (DT_SINGLELINE | DT_RIGHT | DT_BOTTOM) \r\n\r\n\r\n// [12/17/2007 mc007]\r\n#define CPA_SHOW_ABOUT_TAB 1\t//adds an about tab, is using about.txt from \\project source folder \\res\r\n#define CPA_SHOW_LICENSE_TAB 0\t//adds an about tab, is using license.txt from \\project source folder \\res\r\n#define CPA_SHOW_ERROR_TAB 1\r\n#define CPA_ABORT_ON_ERROR 1\t// aborts when the requirements are failing\r\n\r\n\r\n \r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pVehicleMotor.h\"\r\n#include \"pVehicleGears.h\"\r\n\r\n#include \r\n#include \"NxArray.h\"\r\n\r\n\r\n\r\nint pVehicle::_calculateCurrentStatus()\r\n{\r\n\r\n\tint result = 0;\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is moving ? \r\n\t//\r\n\t{\r\n\r\n\t\t_computeLocalVelocity();\r\n\t\tif ( NxMath::abs(_localVelocity.z) > 0.1f)\r\n\t\t\tresult |=VS_IsMoving;\r\n\t}\r\n\r\n\tNxVec3 _loc = _localVelocity;\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is accelerated ?\r\n\t//\r\n\t\r\n\tif ( _cAcceleration > 0.1f )\r\n\t\tresult |=VS_IsAcceleratedForward;\r\n\t\r\n\tif ( _cAcceleration < 0.0f )\r\n\t\tresult |=VS_IsAcceleratedBackward;\r\n\t\r\n\tif ( (result & VS_IsAcceleratedForward) || (result & VS_IsAcceleratedBackward) )\r\n\t\tresult |=VS_IsAccelerated;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is Braking ?\r\n\t//\r\n\tif ( (result & VS_IsMoving ) )\r\n\t{\r\n\t\tif ( _localVelocity.z > 0.0f && ( result & VS_IsAcceleratedBackward ) )\r\n\t\t{\r\n\t\t\tresult |=VS_IsBraking;\r\n\t\t}\r\n\r\n\t\tif ( _localVelocity.z < 0.0f && (result & VS_IsAcceleratedForward ) )\r\n\t\t{\r\n\t\t\tresult |=VS_IsBraking;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is steering \r\n\t//\r\n\tif( XAbs(_cSteering) > 0.01f )\r\n\t\tresult|=VS_IsSteering;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is falling + handbrake\r\n\t//\r\n\t\r\n\t_nbNotTouching =0;\r\n\t_nbTouching =0;\r\n\t_nbHandbrakeOn =0;\r\n\t\r\n\tint nbWheels = _wheels.size();\r\n\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif (!wheel->hasGroundContact())\r\n\t\t{\r\n\t\t\t_nbNotTouching++;\r\n\t\t} else {\r\n\t\t\t_nbTouching++;\r\n\t\t}\r\n\t\t\r\n\t\tif(_cHandbrake && wheel->getWheelFlag(WF_AffectedByHandbrake))\r\n\t\t{\r\n\t\t\t_nbHandbrakeOn++;\r\n\t\t} \r\n\t}\r\n\tif (_nbNotTouching == _wheels.size())\r\n\t\tresult |= VS_IsFalling;\r\n\r\n\tif (_cHandbrake && _nbHandbrakeOn )\r\n\t{\r\n\t\tresult|=VS_Handbrake;\r\n\t}\r\n\t\r\n\r\n\t/*\r\n\tif ( !(result & VS_IsBraking) )\r\n\t{\r\n\t\tmBreakLastFrame = false;\r\n\t\tmTimeBreaking = 0.0f;\r\n\t}\r\n\t*/\r\n\r\n\t_accelerationPedal = _cAcceleration;\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\n\r\nvoid pVehicle::updateControl(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake)\r\n{\r\n\tsetControlState(E_VCS_ACCELERATION,acceleration);\r\n\tsetControlState(E_VCS_HANDBRAKE,handBrake);\r\n\tsetControlState(E_VCS_STEERING,steering);\r\n\tsetControlMode(E_VCS_ACCELERATION,analogAcceleration ? E_VCSM_ANALOG : E_VCSM_DIGITAL);\r\n\tsetControlMode(E_VCS_STEERING, analogSteering ? E_VCSM_ANALOG : E_VCSM_DIGITAL);\r\n\r\n\r\n}\r\nvoid pVehicle::control(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake)\r\n{\r\n\t\r\n\tif (steering != 0 || acceleration != 0 || handBrake)\r\n\t\tgetActor()->wakeUp(0.05);\r\n\r\n\treturn;\r\n\r\n\t_controlSteering(steering, analogSteering);\r\n\t_computeLocalVelocity();\r\n\r\n\tNxVec3 locVel = _localVelocity;\r\n\tfloat lcx = locVel.x;\r\n\tfloat lcz = locVel.z;\r\n\t\r\n\t\r\n\tfloat test = _localVelocity.z * acceleration < ( NxMath::sign(-acceleration) );\r\n\tfloat test2 = _localVelocity.z * acceleration < ( -0.1f );\r\n\tfloat test3 = XAbs(_localVelocity.z) * acceleration < ( -0.1f );\r\n\r\n\r\n\tif (!_braking || _releaseBraking)\r\n\t{\r\n\t\t//_braking = _localVelocity.x * acceleration < (-0.1f /** NxMath::sign(-acceleration) */);\r\n\t\t_braking = _localVelocity.z * acceleration < ( -0.1 /*NxMath::sign(acceleration) */ );\r\n\r\n\t\t//_braking = _localVelocity.z * acceleration < ( NxMath::sign(acceleration));\r\n\t\t_releaseBraking = false;\r\n\t}\r\n\r\n\tif(_handBrake != handBrake)\r\n\t{\r\n\t\t_handBrake = handBrake;\r\n\t\t_brakePedalChanged;\r\n\t}\r\n\t//printf(\"Braking: %s, Handbrake: %s\\n\", _braking?\"true\":\"false\", handBrake?\"true\":\"false\");\r\n\t_controlAcceleration(acceleration, analogAcceleration);\r\n}\r\n\r\n\r\nvoid pVehicle::updateVehicle( float lastTimeStepSize )\r\n{\r\n\t_lastDT = lastTimeStepSize;\r\n\r\n\t_currentStatus = _calculateCurrentStatus();\r\n\r\n\t\r\n\r\n\r\n\tVehicleStatus status = (VehicleStatus)_currentStatus;\r\n\r\n\tif (_cSteering != 0 || _cAcceleration != 0 || _cHandbrake)\r\n\t\tgetActor()->wakeUp(0.05);\r\n\r\n\t_performAcceleration(lastTimeStepSize);\r\n\t_performSteering(lastTimeStepSize);\r\n\r\n\tif (getMotor())\r\n\t{\r\n\t\t_currentStatus |= E_VSF_HAS_MOTOR;\r\n\t}\r\n\r\n\tif (getGears())\r\n\t{\r\n\t\t_currentStatus |= E_VSF_HAS_GEARS;\r\n\t}\r\n\r\n\tsetVSFlags(_currentStatus);\r\n\r\n\tif (engine && gearbox && driveLine )\r\n\t{\r\n\t\t\r\n\t\tdoEngine(0,lastTimeStepSize);\r\n\r\n\t}\r\n\r\n\t\r\n\treturn;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// old code \r\n\t//\r\n\r\n\t//control(_cSteering,_cAnalogSteering,_cAcceleration,_cAnalogAcceleration,_cHandbrake);\r\n\t//printf(\"updating %x\\n\", this);\r\n\r\n\tNxReal distanceSteeringAxisCarTurnAxis = _steeringSteerPoint.x - _steeringTurnPoint.x;\r\n\tNX_ASSERT(_steeringSteerPoint.z == _steeringTurnPoint.z);\r\n\tNxReal distance2 = 0;\r\n\tif (NxMath::abs(_steeringWheelState) > 0.01f)\r\n\t\tdistance2 = distanceSteeringAxisCarTurnAxis / NxMath::tan(_steeringWheelState * _steeringMaxAngleRad);\r\n\t\r\n\tNxU32 nbTouching = 0;\r\n\tNxU32 nbNotTouching = 0; \r\n\tNxU32 nbHandBrake = 0;\r\n\tint wSize = _wheels.size();\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_SteerableInput))\r\n\t\t{\r\n\t\t\tif(distance2 != 0)\r\n\t\t\t{\r\n\t\t\t\tNxReal xPos = wheel->getWheelPos().x;\r\n\t\t\t\tNxReal xPos2 = _steeringSteerPoint.x- wheel->getWheelPos().x;\r\n\t\t\t\tNxReal zPos = wheel->getWheelPos().z;\r\n\t\t\t\tNxReal dz = -zPos + distance2;\r\n\t\t\t\tNxReal dx = xPos - _steeringTurnPoint.x;\r\n\t\t\t\tfloat atan3 = NxMath::atan(dx/dz);\r\n\r\n\t\t\t\tfloat angle =(NxMath::atan(dx/dz));\r\n\t\t\t\tif (dx < 0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tangle*=-1.0f;\r\n\t\t\t\t}\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t\t//errMessage.Format(\"w%d dz:%f dx:%f dx2%f distance:%f atan3:%f\",i,dz,dx,xPos2,distance2,atan3);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\r\n\r\n\t\t\t} else {\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t}\r\n\t\t\t//printf(\"%2.3f\\n\", wheel->getAngle());\r\n\r\n\t\t} else if(wheel->getWheelFlag(WF_SteerableAuto))\r\n\t\t{\r\n\t\t\tNxVec3 localVelocity = getActor()->getLocalPointVelocity(getFrom(wheel->getWheelPos()));\r\n\t\t\tNxQuat local2Global = getActor()->getGlobalOrientationQuat();\r\n\t\t\tlocal2Global.inverseRotate(localVelocity);\r\n\t\t\t//\t\t\tprintf(\"%2.3f %2.3f %2.3f\\n\", wheel->getWheelPos().x,wheel->getWheelPos().y,wheel->getWheelPos().z);\r\n\t\t\tlocalVelocity.y = 0;\r\n\t\t\tif(localVelocity.magnitudeSquared() < 0.1f)\r\n\t\t\t{\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t} else {\r\n\t\t\t\tlocalVelocity.normalize();\r\n\t\t\t\t//\t\t\t\tprintf(\"localVelocity: %2.3f %2.3f\\n\", localVelocity.x, localVelocity.z);\r\n\t\t\t\tif(localVelocity.x < 0)\r\n\t\t\t\t\tlocalVelocity = -localVelocity;\r\n\t\t\t\tNxReal angle = NxMath::clamp((NxReal)atan(localVelocity.z / localVelocity.x), 0.3f, -0.3f);\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// now the acceleration part\r\n\t\tif(!wheel->getWheelFlag(WF_Accelerated))\r\n\t\t\tcontinue;\r\n\r\n\t\tif(_handBrake && wheel->getWheelFlag(WF_AffectedByHandbrake))\r\n\t\t{\r\n\t\t\tnbHandBrake++;\r\n\t\t} \r\n\t\telse\r\n\t\t{\r\n\t\t\tif (!wheel->hasGroundContact())\r\n\t\t\t{\r\n\t\t\t\tnbNotTouching++;\r\n\t\t\t} else {\r\n\t\t\t\tnbTouching++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tNxReal motorTorque = 0.0; \r\n\tfloat _acc = NxMath::abs(_accelerationPedal);\r\n\t\r\n\tXString errMessage;\r\n\tif(nbTouching && NxMath::abs(_accelerationPedal) > 0.1f ) \r\n\t{\r\n\t\tNxReal axisTorque = _computeAxisTorque();\r\n\t\tNxReal wheelTorque = axisTorque / (NxReal)(_wheels.size() - nbHandBrake);\r\n\t\tNxReal wheelTorqueNotTouching = nbNotTouching>0?wheelTorque*(NxMath::pow(0.5f, (NxReal)nbNotTouching)):0;\r\n\t\tNxReal wheelTorqueTouching = wheelTorque - wheelTorqueNotTouching;\r\n\t\tmotorTorque = wheelTorqueTouching / (NxReal)nbTouching; \r\n\t} else {\r\n\t\t_updateRpms();\r\n\t}\r\n\t\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\twheel->tick(_handBrake, motorTorque, _brakePedal, lastTimeStepSize);\r\n\t\t//wheel->tick(_handBrake, motorTorque, _brakePedal, 1/60);\r\n\t}\r\n\r\n}\r\n\r\n\r\npWheel*pVehicle::getWheel(CK3dEntity *wheelReference)\r\n{\r\n\r\n\tif (!wheelReference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\t\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif (wheel->getEntID() == wheelReference->GetID())\r\n\t\t{\r\n\t\t\treturn wheel;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\nvoid pVehicle::handleContactPair(NxContactPair* pair, int carIndex)\r\n{\r\n\tNxContactStreamIterator i(pair->stream);\r\n\r\n\twhile(i.goNextPair())\r\n\t{\r\n\t\tNxShape * s = i.getShape(carIndex);\r\n\r\n\t\twhile(i.goNextPatch())\r\n\t\t{\r\n\t\t\tconst NxVec3& contactNormal = i.getPatchNormal();\r\n\r\n\t\t\twhile(i.goNextPoint())\r\n\t\t\t{\r\n\t\t\t\t//user can also call getPoint() and getSeparation() here\r\n\r\n\t\t\t\tconst NxVec3& contactPoint = i.getPoint();\r\n\r\n\t\t\t\t//add forces:\r\n\r\n\t\t\t\t//assuming front wheel drive we need to apply a force at the wheels.\r\n\t\t\t\tif (s->is(NX_SHAPE_CAPSULE) && s->userData != NULL) {\r\n\t\t\t\t\t//assuming only the wheels of the car are capsules, otherwise we need more checks.\r\n\t\t\t\t\t//this branch can't be pulled out of loops because we have to do a full iteration through the stream\r\n\r\n\r\n\t\t\t\t\tNxQuat local2global = s->getActor().getGlobalOrientationQuat();\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tNxWheel* w = (NxWheel*)s->userData;\r\n\t\t\t\t\tif (!w->getWheelFlag(E_WF_USE_WHEELSHAPE))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tNxWheel1 * wheel = static_cast(w);\r\n\t\t\t\t\t\twheel->contactInfo.otherActor = pair.actors[1-carIndex];\r\n\t\t\t\t\t\twheel->contactInfo.contactPosition = contactPoint;\r\n\r\n\t\t\t\t\t\twheel->contactInfo.contactPositionLocal = contactPoint;\r\n\t\t\t\t\t\twheel->contactInfo.contactPositionLocal -= _bodyActor->getGlobalPosition();\r\n\t\t\t\t\t\tlocal2global.inverseRotate(wheel->contactInfo.contactPositionLocal);\r\n\r\n\t\t\t\t\t\twheel->contactInfo.contactNormal = contactNormal;\r\n\t\t\t\t\t\tif (wheel->contactInfo.otherActor->isDynamic()) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNxVec3 globalV = s->getActor().getLocalPointVelocity(wheel->getWheelPos());\r\n\t\t\t\t\t\t\tglobalV -= wheel->contactInfo.otherActor->getLinearVelocity();\r\n\t\t\t\t\t\t\tlocal2global.inverseRotate(globalV);\r\n\t\t\t\t\t\t\twheel->contactInfo.relativeVelocity = globalV.x;\r\n\t\t\t\t\t\t\t//printf(\"%2.3f (%2.3f %2.3f %2.3f)\\n\", wheel->contactInfo.relativeVelocity,\r\n\t\t\t\t\t\t\t//\tglobalV.x, globalV.y, globalV.z);\r\n\t\t\t\t\t\t} \r\n\t\t\t\t\t\telse \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tNxVec3 vel = s->getActor().getLocalPointVelocity(wheel->getWheelPos());\r\n\t\t\t\t\t\t\tlocal2global.inverseRotate(vel);\r\n\t\t\t\t\t\t\twheel->contactInfo.relativeVelocity = vel.x;\r\n\t\t\t\t\t\t\twheel->contactInfo.relativeVelocitySide = vel.z;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tNX_ASSERT(wheel->hasGroundContact());\r\n\t\t\t\t\t\t//printf(\" Wheel %x is touching\\n\", wheel);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t*/\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\t\t\r\n\t}\r\n\t//printf(\"----\\n\");\r\n}\r\nfloat pVehicle::_computeAxisTorqueV2()\r\n{\r\n\tif(_vehicleMotor != NULL)\r\n\t{\r\n\t\tNxReal rpm = _computeRpmFromWheels();\r\n\t\tNxReal motorRpm = _computeMotorRpm(rpm);\r\n\t\t_vehicleMotor->setRpm(motorRpm);\r\n\t\tfloat acc = _accelerationPedal;\r\n\t\tNxReal torque = _accelerationPedal * _vehicleMotor->getTorque();\r\n\t\tNxReal v = getActor()->getLinearVelocity().magnitude();\r\n\r\n\t\t/*\r\n\t\tprintf(\"v: %2.3f m/s (%2.3f km/h)\\n\", v, v*3.6f);\r\n\t\tprintf(\"rpm %2.3f, motorrpm %2.3f, torque %2.3f, realtorque %2.3f\\n\",\r\n\t\t\trpm, motorRpm, torque, torque*_getGearRatio()*_differentialRatio*_transmissionEfficiency);\r\n\t\t*/\r\n\t\treturn torque * _getGearRatio() * _differentialRatio * _transmissionEfficiency;\r\n\t} else {\r\n\t\t_computeRpmFromWheels();\r\n\t\treturn _cAcceleration * _motorForce;\r\n\t}\r\n}\r\nfloat pVehicle::_computeRpmFromWheels()\r\n{\r\n\tNxReal wheelRpms = 0;\r\n\tNxI32 nbWheels = 0;\r\n\tint nbAcc=0;\r\n\tint nbNotAcc=0;\r\n\t\r\n\tint s = _wheels.size();\r\n\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif (wheel->getWheelFlag(WF_Accelerated))\r\n\t\t{\r\n\t\t\tnbWheels++;\r\n\t\t\twheelRpms += wheel->getRpm();\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t}\r\n\treturn wheelRpms / (NxReal)nbWheels;\r\n}\r\n\r\n\r\nfloat pVehicle::_getGearRatio()\r\n{\r\n\tif(_vehicleGears == NULL)\r\n\t{\r\n\t\treturn 1;\r\n\t} else {\r\n\t\treturn _vehicleGears->getCurrentRatio();\r\n\t}\r\n}\r\nvoid pVehicle::gearUp()\r\n{\r\n\tif (_vehicleGears)\r\n\t{\r\n\t\tprintf(\"Changing gear from %d to\", _vehicleGears->getGear());\r\n\t\t_vehicleGears->gearUp();\r\n\t\tprintf(\" %d\\n\", _vehicleGears->getGear());\r\n\t} else {\r\n\t\tprintf(\"gearUp not supported if no gears available\\n\");\r\n\t}\r\n}\r\nvoid pVehicle::gearDown()\r\n{\r\n\tif(_vehicleGears)\r\n\t{\r\n\t\tprintf(\"Changing gear from %d to\", _vehicleGears->getGear());\r\n\t\t_vehicleGears->gearDown();\r\n\t\tprintf(\" %d\\n\", _vehicleGears->getGear());\r\n\t} else {\r\n\t\tprintf(\"gearDown not supported if no gears available\\n\");\r\n\t}\r\n}\r\n\r\nvoid pVehicle::setAutomaticMode(bool autoMode)\r\n{\r\n\tmAutomaticMode=autoMode;\r\n\r\n}\r\nfloat pVehicle::_computeMotorRpm(float rpm)\r\n{\r\n\tNxReal temp = _getGearRatio() * _differentialRatio;\r\n\tNxReal motorRpm = rpm * temp;\r\n\tNxI32 change = -1;\r\n\tif(_vehicleMotor)\r\n\t{\r\n\t\tNxI32 change;\r\n\t\tif(_vehicleGears && (change = _vehicleMotor->changeGears(_vehicleGears, 0.2f)))\r\n\t\t{\r\n\t\t\tchange = _vehicleMotor->changeGears(_vehicleGears, 0.2f);\r\n\t\t\tif(change == 1 && mAutomaticMode )\r\n\t\t\t{\r\n\t\t\t\tgearUp();\r\n\t\t\t} else {\r\n\t\t\t\tNX_ASSERT(change == -1);\r\n\t\t\t\tgearDown();\r\n\t\t\t}\r\n\t\t}\r\n\t\ttemp = _getGearRatio() * _differentialRatio;\r\n\t\tmotorRpm = NxMath::max(rpm * temp, _vehicleMotor->getMinRpm());\r\n\t}\r\n\treturn motorRpm;\r\n}\r\nvoid pVehicle::_updateRpms()\r\n{\r\n\tNxReal rpm = _computeRpmFromWheels();\r\n\tif(_vehicleMotor != NULL)\r\n\t{\r\n\t\tNxReal motorRpm = _computeMotorRpm(rpm);\r\n\t\t_vehicleMotor->setRpm(motorRpm);\r\n\t}\r\n}\r\nNxActor* pVehicle::getActor(){ return mActor; }\r\n\r\n\r\n\r\nfloat pVehicle::getDriveVelocity()\r\n{\r\n\treturn NxMath::abs(_localVelocity.x);\r\n}\r\n\r\nconst pWheel*pVehicle::getWheel(int i)\r\n{\r\n\tNX_ASSERT(i < _wheels.size()); \r\n\treturn _wheels[i]; \r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid pVehicle::_computeLocalVelocity()\r\n{\r\n\t_computeMostTouchedActor();\r\n\tNxVec3 relativeVelocity;\r\n\tif (_mostTouchedActor == NULL || !_mostTouchedActor->isDynamic())\r\n\t{\r\n\t\trelativeVelocity = getActor()->getLinearVelocity();\r\n\t} else {\r\n\t\trelativeVelocity = getActor()->getLinearVelocity() - _mostTouchedActor->getLinearVelocity();\r\n\t}\r\n\tNxQuat rotation = getActor()->getGlobalOrientationQuat();\r\n\tNxQuat global2Local;\r\n\t_localVelocity = relativeVelocity;\r\n\trotation.inverseRotate(_localVelocity);\r\n\tchar master[512];\r\n\r\n\t//sprintf(master,\"Velocity: %2.3f %2.3f %2.3f\\n\", _localVelocity.x, _localVelocity.y, _localVelocity.z);\r\n\t//OutputDebugString(master);\r\n}\r\nvoid pVehicle::_controlSteering(float steering, bool analogSteering)\r\n{\r\n\tif(analogSteering)\r\n\t{\r\n\t\t_steeringWheelState = steering;\r\n\t} else if (NxMath::abs(steering) > 0.0001f) {\r\n\t\t_steeringWheelState += NxMath::sign(steering) * getDigitalSteeringDelta();\r\n\t} else if (NxMath::abs(_steeringWheelState) > 0.0001f) {\r\n\t\t_steeringWheelState -= NxMath::sign(_steeringWheelState) * getDigitalSteeringDelta();\r\n\t}\r\n\t_steeringWheelState = NxMath::clamp(_steeringWheelState, 1.f, -1.f);\r\n}\r\n\r\nvoid pVehicle::_computeMostTouchedActor()\r\n{\r\n\tstd::map actors;\r\n\ttypedef std::map Map;\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tNxActor* curActor = _wheels[i]->getTouchedActor();\r\n\t\tMap::iterator it = actors.find(curActor);\r\n\t\tif (it == actors.end())\r\n\t\t{\r\n\t\t\tactors[curActor] = 1;\r\n\t\t} else {\r\n\t\t\tit->second++;\r\n\t\t}\r\n\t}\r\n\r\n\tNxU32 count = 0;\r\n\t_mostTouchedActor = NULL;\r\n\tfor(Map::iterator it = actors.begin(); it != actors.end(); ++it)\r\n\t{\r\n\t\tif(it->second > count)\r\n\t\t{\r\n\t\t\tcount = it->second;\r\n\t\t\t_mostTouchedActor = it->first;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nint pVehicle::initWheels(int flags)\r\n{\r\n\tgetWheels().clear();\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t{\r\n\t\t\t\tpWheel *wheel = sinfo->wheel;\r\n\t\t\t\tpWheel2* wheel2 = (pWheel2*)wheel;\r\n\t\t\t\tNxWheelShape *wShape = wheel2->getWheelShape();\r\n\t\t\t\tif (!wShape) continue;\r\n\t\t\t\tif (wheel2->getWheelFlag(WF_VehicleControlled) )\r\n\t\t\t\t{\r\n\t\t\t\t\tgetWheels().push_back(wheel);\r\n\t\t\t\t\twheel2->setVehicle(this);\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn getWheels().size();\r\n\r\n\r\n\t/*\r\n\tint result = 0 ; \r\n\r\n\tif (!getBody() || !getBody()->isValid() )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tgetWheels().clear();\r\n\r\n\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= getBody()->GetVT3DObject()->HierarchyParser(subEntity) )\r\n\t{\r\n\t\tif (subEntity->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t\t{\r\n\t\t\tpObjectDescr *subDescr = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t\t{\r\n\t\t\t\tif (subDescr->hullType == HT_Wheel)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (subEntity->HasAttribute(GetPMan()->att_wheelDescr ))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCKParameter *par = subEntity->GetAttributeParameter(GetPMan()->att_wheelDescr );\r\n\t\t\t\t\t\tif (par)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpWheelDescr *wDescr = pFactory::Instance()->createWheelDescrFromParameter(par);\r\n\t\t\t\t\t\t\tif (wDescr)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tpWheel *wheel = pFactory::Instance()->createWheel(getBody(),*wDescr);\r\n\t\t\t\t\t\t\t\tif (wheel)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tNxWheelShape *wShape = static_cast(getBody()->_getSubShapeByEntityID(subEntity->GetID()));\r\n\r\n\t\t\t\t\t\t\t\t\tif(wDescr->wheelFlags & E_WF_USE_WHEELSHAPE)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tpWheel2 *wheel2 = static_cast(wheel);\r\n\t\t\t\t\t\t\t\t\t\tif (wheel2)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tif(wShape)\r\n\t\t\t\t\t\t\t\t\t\t\t\twheel2->setWheelShape(wShape);\r\n\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\twheel->setEntID(subEntity->GetID());\r\n\t\t\t\t\t\t\t\t\tgetWheels().push_back(wheel);\r\n//\t\t\t\t\t\t\t\t\tsubEntity->SetParent(NULL);\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\treturn getWheels().size();\r\n\t*/\r\n}\r\n\r\nvoid pVehicle::findDifferentialWheels(int& wheel1Index,int& wheel2Index)\r\n{\r\n\tpWheel *wheel1 = NULL;\r\n\tpWheel* wheel2 = NULL;\r\n\twheel1 = wheel2 = 0;\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\r\n\r\n\t\tpWheel *cW = _wheels[i];\r\n\r\n\t\tif (cW->getWheelFlag(WF_AffectedByDifferential))\r\n\t\t{\r\n\t\t\tif (!wheel1){\r\n\t\t\t\twheel1 = cW; wheel1Index=i;\t}\r\n\t\t\telse{\r\n\t\t\t\twheel2 = cW;wheel2Index=i;\t}\r\n\t\t}\r\n\t}\r\n\tif (!wheel1)\r\n\t{\r\n\t\txWarning(\"couldn't find first differential wheel\");\r\n\t\twheel1Index = -1;\r\n\t}\r\n\r\n\tif (!wheel2)\r\n\t{\r\n\t\txWarning(\"couldn't find second differential wheel\");\r\n\t\twheel2Index = -1;\r\n\t}\r\n}\r\n\r\npVehicle::pVehicle()\r\n{\r\n\r\n}\r\nvoid pVehicle::setControlState(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake)\r\n{\r\n\t_cAcceleration = acceleration;\r\n\t_cSteering = steering;\r\n\r\n\t_cAnalogAcceleration = analogAcceleration;\r\n\t_cAnalogSteering = analogSteering;\r\n\t_cHandbrake = handBrake;\r\n\r\n}\r\npVehicle::pVehicle(pVehicleDesc descr)\r\n{\r\n\t_digitalSteeringDelta = descr.digitalSteeringDelta;\r\n\t_steeringSteerPoint = descr.steeringSteerPoint;\r\n\t_steeringTurnPoint = descr.steeringTurnPoint;\r\n\t_steeringMaxAngleRad = NxMath::degToRad(descr.steeringMaxAngle);\r\n\t_transmissionEfficiency = descr.transmissionEfficiency;\r\n\t_differentialRatio = descr.differentialRatio;\r\n\t_maxVelocity = descr.maxVelocity;\r\n\t_motorForce = descr.motorForce;\r\n\r\n\t_cSteering = 0.0f;\r\n\t_cAcceleration = 0.0f;\r\n\t_cAnalogAcceleration = false;\r\n\t_cAnalogSteering = false;\r\n\t_cHandbrake = false;\r\n\tmAutomaticMode = true;\r\n\r\n\tsetBody(descr.body);\r\n\r\n\t_vehicleMotor = NULL;\r\n\t_vehicleGears = NULL;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Break settings\r\n\t//\r\n\r\n\tmBreakLastFrame = false;\r\n\tmTimeBreaking = 0.0f;\r\n\tmBrakeMediumThresold = 1.5f;\r\n\tmBrakeHighThresold = 3.0f;\r\n\r\n\tmBreakPressures[BL_Small] = 0.1f;\r\n\tmBreakPressures[BL_Medium] = 0.3f;\r\n\tmBreakPressures[BL_High] = 1.0f;\r\n\r\n\tuseBreakTable = false;\r\n\r\n\tmSmallBrakeTable.brakeEntries[0] = 10.0f;\r\n\tmSmallBrakeTable.brakeEntries[1] = 20.0f;\r\n\tmSmallBrakeTable.brakeEntries[2] = 30.0f;\r\n\tmSmallBrakeTable.brakeEntries[3] = 40.0f;\r\n\tmSmallBrakeTable.brakeEntries[4] = 50.0f;\r\n\tmSmallBrakeTable.brakeEntries[5] = 100.0f;\r\n\tmSmallBrakeTable.brakeEntries[6] = 200.0f;\r\n\tmSmallBrakeTable.brakeEntries[7] = 400.0f;\r\n\tmSmallBrakeTable.brakeEntries[8] = 1000.0f;\r\n\tmSmallBrakeTable.brakeEntries[9] = 1000.0f;\r\n\r\n\tmMediumBrakeTable.brakeEntries[0] = 400.0f;\r\n\tmMediumBrakeTable.brakeEntries[1] = 450.0f;\r\n\tmMediumBrakeTable.brakeEntries[2] = 550.0f;\r\n\tmMediumBrakeTable.brakeEntries[3] = 650.0f;\r\n\tmMediumBrakeTable.brakeEntries[4] = 725.0f;\r\n\tmMediumBrakeTable.brakeEntries[5] = 900.0f;\r\n\tmMediumBrakeTable.brakeEntries[6] = 1050.0f;\r\n\tmMediumBrakeTable.brakeEntries[7] = 1000.0f;\r\n\tmMediumBrakeTable.brakeEntries[8] = 1000.0f;\r\n\r\n\tmHighBrakeTable.brakeEntries[0] = 700.0f;\r\n\tmHighBrakeTable.brakeEntries[1] = 775.0f;\r\n\tmHighBrakeTable.brakeEntries[2] = 950.0f;\r\n\tmHighBrakeTable.brakeEntries[3] = 1100.0f;\r\n\tmHighBrakeTable.brakeEntries[4] = 1200.0f;\r\n\tmHighBrakeTable.brakeEntries[5] = 1250.0f;\r\n\tmHighBrakeTable.brakeEntries[6] = 1500.0f;\r\n\tmHighBrakeTable.brakeEntries[7] = 2000.0f;\r\n\tmHighBrakeTable.brakeEntries[8] = 1000.0f;\r\n\tmHighBrakeTable.brakeEntries[9] = 1000.0f;\r\n\r\n\tbreakConditionLevels[BC_NoUserInput]=BL_Small;\r\n\tbreakConditionLevels[BC_DirectionChange]=BL_High;\r\n\tbreakConditionLevels[BC_Handbrake]=BL_Medium;\r\n\tbreakConditionLevels[BC_UserBreak]=BL_Medium;\r\n\r\n\r\n}\r\n\r\n\r\npVehicleDesc::pVehicleDesc()\t//constructor sets to default\r\n{\r\n\tsetToDefault();\r\n}\r\n\r\nvoid pVehicleDesc::setToDefault()\r\n{\r\n\tuserData = NULL;\r\n\ttransmissionEfficiency = 1.0f;\r\n\tdifferentialRatio = 1.0f;\r\n\tmaxVelocity = 80;\r\n\tmotorForce = 100.0f;\r\n\r\n\tbody = NULL;\r\n\tgearDescription = NULL;//new pVehicleGearDesc();\r\n\tmotorDescr = NULL;//new pVehicleMotorDesc();\r\n\tsteeringMaxAngle = 30;\r\n\tsteeringSteerPoint = VxVector(0,0,0);\r\n\tsteeringTurnPoint = VxVector(0,0,0);\r\n\tdigitalSteeringDelta = 0.04f;\r\n\r\n}\r\n\r\n\r\nbool pVehicleDesc::isValid() const\r\n{\r\n\t/*for (NxU32 i = 0; i < carWheels.size(); i++) {\r\n\t\tif (!carWheels[i]->isValid())\r\n\t\t\treturn false;\r\n\t}\r\n\t*/\r\n\tif (mass < 0)\r\n\t\treturn false;\r\n\r\n\treturn true;\r\n}\r\n\r\n\r\nvoid pVehicle::setControlState(int parameter,float value)\r\n{\r\n\r\n\tswitch (parameter)\r\n\t{\r\n\r\n\tcase E_VCS_GUP:\r\n\t\t_cShiftStateUp = (int)value;\r\n\t\tbreak;\r\n\t\r\n\tcase E_VCS_GDOWN:\r\n\t\t_cShiftStateDown = (int)value;\r\n\t\tbreak;\r\n\tcase E_VCS_ACCELERATION:\r\n\t\t_cAcceleration = value;\r\n\t\tbreak;\r\n\r\n\tcase E_VCS_STEERING:\r\n\t\t_cSteering = value;\r\n\t\tbreak;\r\n\r\n\tcase E_VCS_HANDBRAKE:\r\n\t\t_cHandbrake= (int)value;\r\n\t\tbreak;\r\n\t}\r\n}\r\n\r\nvoid pVehicle::setControlMode(int parameter,int mode)\r\n{\r\n\tswitch (parameter)\r\n\t{\r\n\tcase E_VCS_ACCELERATION:\r\n\t\t_cAnalogAcceleration = (mode == E_VCSM_ANALOG) ? true : false; \t\t\r\n\t\tbreak;\r\n\r\n\tcase E_VCS_STEERING:\r\n\t\t_cAnalogSteering = (mode == E_VCSM_ANALOG) ? true : false;\r\n\t\tbreak;\r\n\t}\r\n}\r\n\r\nfloat pVehicle::_computeAxisTorque()\r\n{\r\n\tif(_vehicleMotor != NULL)\r\n\t{\r\n\t\tNxReal rpm = _computeRpmFromWheels();\r\n\t\tNxReal motorRpm = _computeMotorRpm(rpm);\r\n\t\t_vehicleMotor->setRpm(motorRpm);\r\n\t\tNxReal torque = _accelerationPedal * _vehicleMotor->getTorque();\r\n\t\tNxReal v = getActor()->getLinearVelocity().magnitude();\r\n\t\t//printf(\"v: %2.3f m/s (%2.3f km/h)\\n\", v, v*3.6f);\r\n\t\t//printf(\"rpm %2.3f, motorrpm %2.3f, torque %2.3f, realtorque %2.3f\\n\",\r\n\t\t//\trpm, motorRpm, torque, torque*_getGearRatio()*_differentialRatio*_transmissionEfficiency);\r\n\t\treturn torque * _getGearRatio() * _differentialRatio * _transmissionEfficiency;\r\n\t} else {\r\n\t\t_computeRpmFromWheels();\r\n\t\treturn _accelerationPedal * _motorForce;\r\n\t}\r\n}\r\nvoid pVehicle::getControlState(int parameter,float &value,int &mode)\r\n{\r\n\tswitch (parameter)\r\n\t{\r\n\tcase E_VCS_ACCELERATION:\r\n\t\tvalue = _cAcceleration;\r\n\t\tmode = _cAnalogAcceleration;\r\n\t\tbreak;\r\n\r\n\tcase E_VCS_STEERING:\r\n\t\tvalue = _cSteering;\r\n\t\tmode = _cAnalogSteering;\r\n\t\tbreak;\r\n\r\n\tcase E_VCS_HANDBRAKE:\r\n\t\tvalue = ((float)_cHandbrake);\r\n\t\tmode = _cHandbrake;\r\n\t\tbreak;\r\n\r\n\t}\r\n\r\n}#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetDecl();\r\nCKERROR CreateBodySetProto(CKBehaviorPrototype **pproto);\r\nint BodySet(const CKBehaviorContext& behcontext);\r\nCKERROR BodySetCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Vel=0,\r\n\tbbI_AVel,\r\n\tbbI_Torque,\r\n\tbbI_Force,\r\n\tbbI_Pos,\r\n\tbbI_Rot\r\n\r\n};\r\n\r\nenum bSettings\r\n{\r\n\tbbS_Vel=0,\r\n\tbbS_AVel,\r\n\tbbS_Torque,\r\n\tbbS_Force,\r\n\tbbS_Pos,\r\n\tbbS_Rot\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPBSetDecl\r\n// FullName: FillBehaviorPBSetDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBSetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBSet\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Sets physical quantities.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6915390d,0x1d775a96));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateBodySetProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\nCKERROR CreateBodySetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBSet-Obsolete\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->SetBehaviorCallbackFct( BodySetCB );\r\n\t\r\n\t\r\n\r\n\t/*\r\n\tPBSet \r\n\r\n\tPBSet is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSet.png\r\n\r\n\tIn:triggers the process\r\n\t
\r\n\tOut:is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tLinear Velocity: The linear velocity.See pRigidBody::setLinearVelocity().\r\n\t
\r\n\tAngular Velocity: The angular velocity.See pRigidBody::setAngularVelocity().\r\n\t
\r\n\tAgular Momentum: The angular momentum.See pRigidBody::getAngularMomentum().\r\n\t
\r\n\tLinear Momentum: The linear momentum.See pRigidBody::getLinearMomentum(). \r\n\t
\r\n\tPosition: The position.See pRigidBody::setPosition(). \r\n\t
\r\n\t
\r\n\t\r\n\tLinear Velocity: Enables output for linear velocity.\r\n\t
\r\n\tAngular Velocity: Enables output for angular velocity.\r\n\t
\r\n\tAgular Momentum: Enables output for angular momentum.\r\n\t
\r\n\tLinear Momentum: Enables output for linear momentum. \r\n\t
\r\n\tPosition: Enables output for position. \r\n\t
\r\n\tOrientation: Enables output for orientation. \r\n\t
\r\n\t
\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager .\r\n\t
\r\n\t
\r\n\t\r\n\t\tThe known building block \"Set Position\" has new settings avaiable.\r\n\t\tEnable there \"Update Physics\" in order to transfer the new position on the body automatically!\r\n\t\r\n\r\n\t

VSL


\r\n\t\r\n\t\t\\include PBSet.cpp\r\n\t\r\n\r\n\t*/\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Linear Velocity\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Angular Velocity\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Angular Momentum\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Linear Momentum\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Position\",CKPGUID_VECTOR,\"0.0f,0.0f,0.0f\");\r\n\tproto->DeclareInParameter(\"Orientation\",CKPGUID_QUATERNION);\r\n\r\n\t\r\n\tproto->DeclareSetting(\"Velocity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Angular Velocity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Torque\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Force\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Position\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Rotation\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(BodySet);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint BodySet(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\t// body exists already ? clean and delete it : \r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(result)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//velocity : \r\n\t\t\tDWORD vel=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Vel,&vel);\r\n\t\t\tif (vel)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = GetInputParameterValue(beh,bbI_Vel);\r\n\t\t\t\tresult->setLinearVelocity(vec);\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//angular velocity \r\n\t\t\tDWORD avel=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_AVel,&avel);\r\n\t\t\tif (avel)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = GetInputParameterValue(beh,bbI_AVel);\r\n\t\t\t\tresult->setAngularVelocity(vec);\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//torque\r\n\t\t\tDWORD torque=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Torque,&avel);\r\n\t\t\tif (torque)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = GetInputParameterValue(beh,bbI_Torque);\r\n\t\t\t\tresult->setAngularMomentum(vec);\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//force\r\n\t\t\tDWORD force=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Force,&force);\r\n\t\t\tif (force)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = GetInputParameterValue(beh,bbI_Force);\r\n\t\t\t\tresult->setLinearMomentum(vec);\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//force\r\n\t\t\tDWORD pos=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Pos,&pos);\r\n\t\t\tif (pos)\r\n\t\t\t{\r\n\r\n\t\t\t\tVxVector vec = GetInputParameterValue(beh,bbI_Pos);\r\n\t\t\t\tresult->setPosition(vec);\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tDWORD rot=0;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Rot,&rot);\r\n\t\t\tif (rot)\r\n\t\t\t{\r\n\r\n\t\t\t\tVxQuaternion vec = GetInputParameterValue(beh,bbI_Rot);\r\n\t\t\t\tresult->setRotation(vec);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: BodySetCB\r\n// FullName: BodySetCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR BodySetCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tDWORD vel;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Vel,&vel);\r\n\t\t\tbeh->EnableInputParameter(bbI_Vel,vel);\r\n\t\t\t\r\n\t\t\tDWORD avel;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_AVel,&avel);\r\n\t\t\tbeh->EnableInputParameter(bbI_AVel,avel);\r\n\r\n\t\t\tDWORD torque;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Torque,&torque);\r\n\t\t\tbeh->EnableInputParameter(bbI_Torque,torque);\r\n\r\n\t\t\tDWORD force;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Force,&force);\r\n\t\t\tbeh->EnableInputParameter(bbI_Force,force);\r\n\t\t\t\r\n\t\t\tDWORD pos;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Pos,&pos);\r\n\t\t\tbeh->EnableInputParameter(bbI_Pos,pos);\r\n\t\t\tDWORD rot;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Rot,&rot);\r\n\t\t\tbeh->EnableInputParameter(bbI_Rot,rot);\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"vtStructHelper.h\"\r\n#include \"vtAttributeHelper.h\"\r\n\r\n#include \"gConfig.h\"\r\n\r\n\r\n#define PHYSIC_JOINT_CAT \"Physic Constraints\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\nStructurMember bodyDamping[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Linear Damping\",\"0.1\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Angular Damping\",\"0.1\"),\r\n};\r\n\r\nStructurMember bodySleeping[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Linear Sleep Velocity\",\"0.1\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Angular Sleep Velocity\",\"0.1\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Sleep Energy Threshold\",\"0.1\"),\r\n};\r\n\r\nStructurMember bodyXMLSetup[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_ACTOR_XML_SETTINGS_INTERN,\"Internal\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_ACTOR_XML_SETTINGS_EXTERN,\"External\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_ACTOR_XML_IMPORT_FLAGS,\"Import Flags\",\"Stub\"),\r\n};\r\n\r\nStructurMember bodyCCDSettings[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Motion Threshold\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_PHYSIC_CCD_FLAGS,\"Flags\",\"Stub\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Mesh Scale\",\"1.0f\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BEOBJECT,\"Shape Reference\",\"None\"),\r\n};\r\n\r\nStructurMember bodyCollisionsSettings[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTE_PHYSIC_BODY_COLL_GROUP,\"Collisions Group\",\"All\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_FILTER_GROUPS,\"Group Mask\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Skin Width\",\"-1.0\"),\r\n\t//STRUCT_ATTRIBUTE(VTS_PHYSIC_CCD_SETTINGS,\"CCD Settings\",\"None\"),\r\n};\r\n\r\nStructurMember bodyCollisionsSetup[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_COLLISIONS_SETTINGS,\"Collisions Settings\",\"None\"),\r\n\t//STRUCT_ATTRIBUTE(VTS_PHYSIC_CCD_SETTINGS,\"CCD Settings\",\"0\"),\r\n};\r\n\r\nStructurMember bodyOptimistationSettings[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTF_BODY_TRANS_FLAGS,\"Transformation Locks\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_DAMPING_PARAMETER,\"Damping Settings\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_SLEEP_SETTINGS,\"Sleeping Settings\",\"None\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_INT,\"Solver Iterations\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTE_PHYSIC_DOMINANCE_GROUP,\"Dominance Group\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_INT,\"Compartment Id\",\"\"),\r\n};\r\n\r\nStructurMember bodyCommonSettings[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTE_COLLIDER_TYPE,\"Hull Type\",\"1\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Density\",\"1\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_BODY_FLAGS,\"Flags\",\"Moving Object,World Gravity,Enabled,Collision\"),\r\n/*\tSTRUCT_ATTRIBUTE(VTF_BODY_TRANS_FLAGS,\"Transformation Locks\",\"\"),*/\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"World\",\"pWorldDefault\"),\r\n};\r\n\r\nStructurMember bodyGeomtryOverride[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Offset Linear\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_EULERANGLES,\"Offset Angular\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Offset Reference\",\"\"),\r\n};\r\n\r\nStructurMember bodyMassSetup[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"New Density\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Total Mass\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Offset Linear\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_EULERANGLES,\"Offset Angular\",\"0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Mass Offset Reference\",\"0.0\"),\r\n};\r\n\r\nStructurMember bodySetup[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_ACTOR_XML_SETUP,\"XML Links\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_PHYSIC_BODY_COMMON_SETTINGS,\"Common Settings\",\"0\"),\r\n\t/*STRUCT_ATTRIBUTE(VTS_PHYSIC_PIVOT_OFFSET,\"Pivot\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_MASS_SETUP,\"Mass Setup\",\"0\"),*/\r\n\tSTRUCT_ATTRIBUTE(VTS_PHYSIC_COLLISIONS_SETTINGS,\"Collisions Setup\",\"0\"),\r\n\t/*STRUCT_ATTRIBUTE(VTS_PHYSIC_ACTOR_OPTIMIZATION,\"Optimization\",\"0\"),*/\r\n};\r\n\r\nStructurMember axisReferencedLength[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Value\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BEOBJECT,\"Reference Object\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_AXIS,\"Local Axis\",\"0\"),\r\n};\r\n\r\n\r\n\r\nStructurMember customCapsule[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(VTS_AXIS_REFERENCED_LENGTH,\"Radius\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_AXIS_REFERENCED_LENGTH,\"Width\",\"0\"),\r\n};\r\nStructurMember customConvexCylinder[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_INT,\"Approximation\",\"10\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_AXIS_REFERENCED_LENGTH,\"Radius\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_AXIS_REFERENCED_LENGTH,\"Width\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Forward Axis\",\"0.0,0.0,-1.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Forward Axis Reference\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Down Axis\",\"0.0,-1.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Down Axis Reference\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Right Axis\",\"1.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Right Axis Reference\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Build Lower Half Only\",\"0\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_CONVEX_FLAGS,\"Convex Flags\",\"0\"),\r\n};\r\n\r\n//#define gSMapJDistance myStructJDistance\r\nextern void\tPObjectAttributeCallbackFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);\r\n\r\ntypedef CKERROR (*bodyParameterDefaultFunction)(CKParameter*);\r\n\r\nbodyParameterDefaultFunction bodyCreateFuncOld = NULL;\r\n/*\r\n#define REGISTER_CUSTOM_STRUCT(NAME,ENUM_TYPE,GUID,MEMBER_ARRAY,HIDDEN) DECLARE_STRUCT(ENUM_TYPE,NAME,GUID,MEMBER_ARRAY,STRUCT_SIZE(MEMBER_ARRAY)); \\\r\n\tXArray ListGuid##ENUM_TYPE = STRUCT_MEMBER_GUIDS(ENUM_TYPE);\\\r\n\tpm->RegisterNewStructure(GUID,NAME,STRUCT_MEMBER_NAMES(ENUM_TYPE).Str(),ListGuid##ENUM_TYPE);\\\r\n\tCKParameterTypeDesc* param_type##ENUM_TYPE=pm->GetParameterTypeDescription(GUID);\\\r\n\tif (param_type##ENUM_TYPE && HIDDEN) param_type##ENUM_TYPE->dwFlags|=CKPARAMETERTYPE_HIDDEN;\\\r\n\t_getCustomStructures().Insert(GUID,(CustomStructure*)&MEMBER_ARRAY)\r\n\r\n*/\r\n\r\nvoid bodyDefaultFunctionMerged(CKParameter*in)\r\n{\r\n\t\r\n\tCKStructHelper sHelper(in);\r\n\t//if ( ==0 )\t//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\t\r\n\r\n\tXString msg;\r\n\r\n\tmsg.Format(\"parameter members : %d\",sHelper.GetMemberCount());\r\n\tif(bodyCreateFuncOld!=0 )\r\n\t{\r\n\t\tbodyCreateFuncOld(in);\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,msg.Str());\r\n\t}\r\n\t\r\n\treturn;\r\n\r\n//\tCKParameter\r\n\t//CKAttributeManager::SetAttributeDefaultValue()\r\n\r\n\r\n}\r\nvoid PhysicManager::_RegisterBodyParameterFunctions()\r\n{\r\n\treturn;\r\n\r\n\tCKContext* ctx = GetContext();\r\n\r\n\tCKParameterManager *pm = ctx->GetParameterManager();\r\n\tCKParameterTypeDesc *param_desc = pm->GetParameterTypeDescription(VTF_PHYSIC_BODY_COMMON_SETTINGS);\r\n\tif( !param_desc ) return;\r\n\tif (param_desc->CreateDefaultFunction!=0)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"has function\");\r\n\t\tbodyCreateFuncOld = param_desc->CreateDefaultFunction;\r\n\t\tparam_desc->CreateDefaultFunction = (CK_PARAMETERCREATEDEFAULTFUNCTION)bodyDefaultFunctionMerged;\r\n\t}\r\n\t\r\n\t//param_desc->UICreatorFunction = CKActorUIFunc;\r\n\t\t//param_desc->UICreatorFunction = CKDoubleUIFunc;\r\n\r\n\r\n}\r\nvoid PhysicManager::_RegisterBodyParameters()\r\n{\r\n\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\r\n\tint attRef=0;\r\n\t//################################################################\r\n\t//\r\n\t// Geometry Related \r\n\t//\r\n\r\n\t//\tObject and Axis Related Length :\r\n\tREGISTER_CUSTOM_STRUCT(\"pAxisReferencedLength\",PS_AXIS_REFERENCED_LENGTH,VTS_AXIS_REFERENCED_LENGTH,axisReferencedLength,false);\r\n\tREGISTER_CUSTOM_STRUCT(\"pCustomConvexCylinder\",PS_CUSTOM_CONVEX_CYLINDER_DESCR,VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR,customConvexCylinder,false);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pCustomConvexCylinder\",PS_CUSTOM_CONVEX_CYLINDER_DESCR,PHYSIC_BODY_CAT,VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR,CKCID_3DOBJECT,customConvexCylinder,true);\r\n\r\n\t\r\n\tREGISTER_CUSTOM_STRUCT(\"pCapsule\",PS_CAPSULE,VTS_CAPSULE_SETTINGS_EX,customCapsule,false);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pCapsule\",PS_CAPSULE,PHYSIC_BODY_CAT,VTS_CAPSULE_SETTINGS_EX,CKCID_3DOBJECT,customCapsule,true);\r\n \t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tCollision Common Structs : \r\n\t//\r\n\t\r\n\tpm->RegisterNewFlags(VTF_COLLISIONS_EVENT_MASK,\"pCollisionEventMask\",\"Ignore=1,Start Touch=2,End Touch=4,Touch=8,Impact=16,Roll=32,Slide=64,Forces=128,Start Touch Force Threshold=256,End Touch Force Threshold=512,Touch Force Threshold=1024,Contact Modification=65536\");\r\n\t\r\n\tpm->RegisterNewFlags(VTF_WHEEL_CONTACT_MODIFY_FLAGS,\"pWheelContactModifyFlags\",\"Point=1,Normal=2,Position=4,Force=8,Material=16\");\r\n\r\n\r\n\t\r\n\tpm->RegisterNewFlags(VTF_CONTACT_MODIFY_FLAGS,\"pContactModifyFlags\",\"None=0,Min Impulse=1,Max Impulse=2,Error=4,Target=8,Local Position0=16,Local Position1=32,Local Orientation0=64,Local Orientation1=128,Static Friction0=256,Static Friction1=512,Dynamic Friction0=1024,Dynamic Friction1=2048,Restitution=4096,Force32=2147483648\");\r\n\tpm->RegisterNewFlags(VTF_CONVEX_FLAGS,\"pConvexFlags\",\"Flip Normals=1,16 Bit Indices=2,Compute Convex=4,Inflate Convex=8,Uncompressed Normals=64\");\r\n\tpm->RegisterNewFlags(VTF_TRIGGER,\"pTriggerFlags\",\"Disable=8,OnEnter=1,OnLeave=2,OnStay=4\");\r\n\tpm->RegisterNewEnum(VTE_FILTER_OPS,\"pFilterOp\",\"And=0,Or=1,Xor=2,Nand=3,Nor=4,NXor=5\");\r\n\tpm->RegisterNewFlags(VTE_FILTER_MASK,\"pFilterMask\",\"0,1,2,3\");\r\n\tpm->RegisterNewStructure(VTS_FILTER_GROUPS,\"pFilterGroups\",\"bits0,bits1,bits2,bits3\",VTE_FILTER_MASK,VTE_FILTER_MASK,VTE_FILTER_MASK,VTE_FILTER_MASK);\r\n\tpm->RegisterNewFlags(VTF_SHAPES_TYPE,\"pShapesTypes\",\"Static=1,Dynamic=2\");\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tBody Sub Structs : \r\n\t//\r\n\r\n\tpm->RegisterNewFlags(VTF_BODY_FLAGS,\"pBFlags\",\"Moving Object=1,World Gravity=2,Collision=4,Kinematic Object=8,Sub Shape=16,Hierarchy=32,Add Attributes=64,Trigger Shape=128,Deformable=256,Collision Notify=512,Collisions Force=1024,Contact Modify=2048,Sleep=4096\");\r\n\tpm->RegisterNewFlags(VTF_BODY_TRANS_FLAGS,\"pBTFlags\",\"FrozenPositionX=2,FrozenPositionY=4,FrozenPositionZ=8,FrozenRotationX=16,FrozenRotationY=32,FrozenRotationZ=64\");\r\n\tpm->RegisterNewEnum(VTE_COLLIDER_TYPE,\"pBHullType\",\"Sphere=0,Box=1,Capsule=2,Plane=3,Mesh=4,Convex Mesh=5,Height Field=6,Wheel=7,Cloth=8,Convex Cylinder\");\r\n\r\n\tpm->RegisterNewStructure(VTS_PHYSIC_PARAMETER,\"pObject\", \"Geometry,Physic Flags,Density,Skin Width,Mass Offset,Pivot Offset,Hierarchy,World,New Density,Total Mass,Collision Group\",VTE_COLLIDER_TYPE,VTF_BODY_FLAGS,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_VECTOR,CKPGUID_VECTOR,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_INT);\r\n\r\n\tint currentAttributeType = -1;\r\n\r\n\tatt_physic_object= attman->RegisterNewAttributeType(\"Object\",VTS_PHYSIC_PARAMETER,CKCID_3DOBJECT);\r\n\tattman->SetAttributeDefaultValue(att_physic_object,\"1;Moving Object,World Gravity,Enabled,Collision;1;-1;0,0,0;0,0,0;FALSE,pDefaultWorld\");\r\n\t\r\n\tattman->SetAttributeCategory(att_physic_object,\"Physic\");\r\n\r\n\r\n\tpm->RegisterNewEnum(VTE_BODY_FORCE_MODE,\"pBForceMode\",\"Force=0,Impulse=1,Velocity Change=2,Smooth Impulse=3,Smooth Velocity Change=4,Acceleration=5\");\r\n\tattman->SetAttributeCategory(att_physic_limit,\"Physic\");\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tCapsule : \r\n\t//\r\n\tpm->RegisterNewStructure(VTS_CAPSULE_SETTINGS,\"Capsule\", \"Local Length Axis,Local Radius Axis,Length,Radius\",CKPGUID_AXIS,CKPGUID_AXIS,CKPGUID_FLOAT,CKPGUID_FLOAT);\r\n\r\n\tCKParameterTypeDesc* param_type=pm->GetParameterTypeDescription(VTS_CAPSULE_SETTINGS);\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\r\n\t/*\r\n\tatt_capsule = attman->RegisterNewAttributeType(\"Capsule\",VTS_CAPSULE_SETTINGS,CKCID_BEOBJECT);\r\n\tattman->SetAttributeDefaultValue(att_capsule,\"1;0;-1.0;-1.0f\");\r\n\tattman->SetAttributeCategory(att_capsule,\"Physic\");\r\n\t*/\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy flags\r\n\t//\r\n\tpm->RegisterNewFlags(VTF_PHYSIC_ACTOR_COPY_FLAGS,\"pBCopyFlags\",\"Physics=1,Shared=2,Pivot=4,Mass=8,Collision=16,CCD=32,Material=64,Optimization=128,Capsule=256,Convex Cylinder=512,Force=1024,Velocities=2048,Joints=4096,Limit Planes=8192,Swap Joint References=16384,Override Body Flags=32768,Copy IC=65536,Restore IC=131072\");\r\n\t/*\r\n\tparam_type=pm->GetParameterTypeDescription(VTF_PHYSIC_ACTOR_COPY_FLAGS);\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_TOSAVE;\r\n\t*/\r\n\r\n \r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tBody Collision Setup \r\n\t//\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tCCD Settings : \r\n\t//\t\r\n\t// Custom Enumeration to setup ccd flags\r\n\tpm->RegisterNewFlags(VTF_PHYSIC_CCD_FLAGS,\"pBCCDFlags\",\"None=1,Shared=2,DynamicDynamic=4\");\r\n\tREGISTER_CUSTOM_STRUCT(\"pBCCDSettings\",PS_B_CCD,VTS_PHYSIC_CCD_SETTINGS,bodyCCDSettings,GC_SHOWPARAMETER);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBCCDSettings\",PS_B_CCD,PHYSIC_BODY_CAT,VTS_PHYSIC_CCD_SETTINGS,CKCID_3DOBJECT,bodyCCDSettings,true,attRef);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// Collisions Settings\r\n\t//\r\n\tpm->RegisterNewEnum(VTE_PHYSIC_BODY_COLL_GROUP,\"pBCollisionsGroup\",\"All=0,MyObstacles=1,MyWheels=2\");\r\n\tparam_type=pm->GetParameterTypeDescription(VTE_PHYSIC_BODY_COLL_GROUP);\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_USER;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_TOSAVE;\r\n\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pBCollisionSettings\",PS_B_COLLISON,VTS_PHYSIC_COLLISIONS_SETTINGS,bodyCollisionsSettings,GC_SHOWPARAMETER);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBCollisionSettings\",PS_B_COLLISON,PHYSIC_BODY_CAT,VTS_PHYSIC_COLLISIONS_SETTINGS,CKCID_3DOBJECT,bodyCollisionsSettings,true,attRef);\r\n\r\n\r\n\t/*\t\tMerged */\r\n\tREGISTER_CUSTOM_STRUCT(\"pBCSetup\",PS_B_COLLISION_SETUP,VTS_PHYSIC_COLLISIONS_SETUP,bodyCollisionsSetup,GC_SHOWPARAMETER );\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// XML Setup \r\n\tpm->RegisterNewFlags(VTS_PHYSIC_ACTOR_XML_IMPORT_FLAGS,\"pBXMLFlags\",\"None=0,Stub=1\");\r\n\tparam_type=pm->GetParameterTypeDescription(VTS_PHYSIC_ACTOR_XML_IMPORT_FLAGS);\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pBXMLSetup\",PS_BODY_XML_SETUP,VTS_PHYSIC_ACTOR_XML_SETUP,bodyXMLSetup,false);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tCommon\r\n\tREGISTER_CUSTOM_STRUCT(\"pBCommon\",PS_BODY_COMMON,VTF_PHYSIC_BODY_COMMON_SETTINGS,bodyCommonSettings,false);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tSleep\r\n\tREGISTER_CUSTOM_STRUCT(\"pBSleepSettings\",PS_B_SLEEPING,VTS_PHYSIC_SLEEP_SETTINGS,bodySleeping,GC_SHOWPARAMETER);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tDamping\r\n\tREGISTER_CUSTOM_STRUCT(\"pBDamping\",PS_B_DAMPING,VTS_PHYSIC_DAMPING_PARAMETER,bodyDamping,GC_SHOWPARAMETER);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tOptimization\r\n\tREGISTER_CUSTOM_STRUCT(\"pBOptimisation\",PS_B_OPTIMISATION,VTS_PHYSIC_ACTOR_OPTIMIZATION,bodyOptimistationSettings,GC_SHOWPARAMETER);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBOptimisation\",PS_B_OPTIMISATION,PHYSIC_BODY_CAT,VTS_PHYSIC_ACTOR_OPTIMIZATION,CKCID_3DOBJECT,bodyOptimistationSettings,true,attRef);\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tGeometry\r\n\tREGISTER_CUSTOM_STRUCT(\"pBPivotSettings\",PS_B_PIVOT,VTS_PHYSIC_PIVOT_OFFSET,bodyGeomtryOverride,GC_SHOWPARAMETER);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBPivotSettings\",PS_B_PIVOT,PHYSIC_BODY_CAT,VTS_PHYSIC_PIVOT_OFFSET,CKCID_3DOBJECT,bodyGeomtryOverride,true,attRef);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tMass Override\r\n\tREGISTER_CUSTOM_STRUCT(\"pBMassSettings\",PS_B_MASS,VTS_PHYSIC_MASS_SETUP,bodyMassSetup,false);\r\n\tparam_type=pm->GetParameterTypeDescription(VTS_PHYSIC_MASS_SETUP);\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_USER;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_TOSAVE;\r\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBMassSettings\",PS_B_MASS,PHYSIC_BODY_CAT,VTS_PHYSIC_MASS_SETUP,CKCID_3DOBJECT,bodyMassSetup,true,attRef);\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// this is the new replacement for the \"Object\" attribute.\t\r\n\t//\t\r\n\tREGISTER_CUSTOM_STRUCT(\"pBSetup\",PS_BODY_SETUP,VTS_PHYSIC_ACTOR,bodySetup,FALSE);\r\n\tREGISTER_STRUCT_AS_ATTRIBUTE(\"pBSetup\",PS_BODY_SETUP,PHYSIC_BODY_CAT,VTS_PHYSIC_ACTOR,CKCID_3DOBJECT,bodySetup,attRef);\r\n\r\n\r\n}\r\n/*\n * Tcp4u v 3.31 Last Revision 09/03/1997 3.31-00\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: udp4u.c\n * Purpose: main functions for udp protocol management\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n#include \"build.h\"\n\nstatic char szWhat[] =\"@(#)Udp4u by Ph. Jounin version 3.31\";\n\n/* ------------------------------------------------------------------------- */\n/* Fonction de traduction Service -> port */\n/* ------------------------------------------------------------------------- */\nunsigned short API4U Udp4uServiceToPort (LPCSTR szService)\n{\nunsigned short uPort = 0;\nstruct servent far * lpServEnt;\n\n if (szService!=NULL)\n {\n Tcp4uLog (LOG4U_CALL, \"getservbyname service %s\", szService);\n lpServEnt = getservbyname (szService, \"udp\") ;\n if (lpServEnt==NULL)\n Tcp4uLog (LOG4U_ERROR, \"getservbyname service %s\", szService);\n else uPort = ntohs (lpServEnt->s_port);\n }\nreturn uPort;\n} /* Udp4uServiceToPort */\n\n\n/* ------------------------------------------------------------------------- */\n/* initialisation UDP */\n/* ------------------------------------------------------------------------- */\nint API4U UdpInit (LPUDPSOCK far *pUdp, LPCSTR szHost, \n unsigned short uRemotePort, unsigned short uLocalPort)\n{\nint Rc;\nSOCKET UdpSock = INVALID_SOCKET;\nstruct sockaddr_in saSendAddr; /* structure identifiant le destinataire */\nstruct sockaddr_in saBindAddr; /* structure limitant les clients */\n\n Tcp4uLog (LOG4U_PROC, \"UdpInit, host %s\", szHost);\n\n memset (& saBindAddr, 0, sizeof saBindAddr);\n memset (& saSendAddr, 0, sizeof saSendAddr); \n /* --- 1. calcul de saSendAddr : RemoteService et szHost */\n saSendAddr.sin_family = AF_INET;\n saSendAddr.sin_port = htons (uRemotePort) ;\n if (szHost!=NULL)\n {\n saSendAddr.sin_addr = Tcp4uGetIPAddr (szHost);\n if (saSendAddr.sin_addr.s_addr==INADDR_NONE) \n {\n\t Tcp4uLog (LOG4U_ERROR, \"UdpInit: host Unknown\");\n \t return TCP4U_HOSTUNKNOWN;\n }\n } /* szHost is specified */\n \n /* --- autres champs de saBindAddr */\n saBindAddr.sin_port = htons (uLocalPort);\n saBindAddr.sin_family = AF_INET;\n saBindAddr.sin_addr.s_addr = INADDR_ANY;\n\n /* --- Allocation de la socket */\n Tcp4uLog (LOG4U_CALL, \"socket PF_INET SOCK_DGRAM\");\n UdpSock = socket (PF_INET, SOCK_DGRAM, 0);\n if (UdpSock<0) \n {\n Tcp4uLog (LOG4U_ERROR, \"socket PF_INET SOCK_DGRAM\");\n return TCP4U_NOMORESOCKET;\n }\n\n /* --- do a bind, thus all packets to be received will come on given port */\n Tcp4uLog (LOG4U_CALL, \"bind to %s\", inet_ntoa (saBindAddr.sin_addr));\n Rc = bind (UdpSock, (struct sockaddr far *) & saBindAddr, \n sizeof(struct sockaddr));\n if (Rc<0) \n { \n Tcp4uLog (LOG4U_ERROR, \"bind to %s\", inet_ntoa (saBindAddr.sin_addr));\n CloseSocket (UdpSock); \n return TCP4U_BINDERROR; \n }\n\n /* --- Allocation de la structure */\n *pUdp = Calloc (sizeof (UDPSOCK), 1);\n if (*pUdp==NULL) { CloseSocket (UdpSock); return TCP4U_INSMEMORY; }\n (*pUdp)->UdpSock = UdpSock;\n (*pUdp)->saSendAddr = saSendAddr; \n (*pUdp)->bSemiConnected = FALSE; /* can receive data from any host */\n\n Tcp4uLog (LOG4U_EXIT, \"UdpInit\");\nreturn TCP4U_SUCCESS;\n} /* UdpInit */\n\n\n/* ------------------------------------------------------------------------ */\n/* UdpBind: Restrict socket to listen only from previous client */\n/* ------------------------------------------------------------------------ */\nint API4U UdpBind (LPUDPSOCK pUdp, BOOL bFilter, int nMode)\n{\n Tcp4uLog (LOG4U_PROC, \"UdpBind Mode %s\", \n nMode==UDP4U_CLIENT ? \"client\" : \"server\");\n\n if (bFilter)\n {\n switch (nMode)\n {\n /* le client ne peut recevoir que de la machine serveur */\n /* le serveur que depuis la machine d'ou il a deja recu des infos */\n /* en mode serveur, l'adresse de destination devient l'adresse */\n /* du dernier host. */\n case UDP4U_CLIENT : pUdp->saFilter = pUdp->saSendAddr.sin_addr ; \n break;\n case UDP4U_SERVER : pUdp->saFilter = pUdp->saRecvAddr.sin_addr;\n pUdp->saSendAddr = pUdp->saRecvAddr;\n break;\n default : return TCP4U_ERROR;\n } /* selon mode */\n } /* si filtre positionne */\n /* filtre ou pas filtre */\n pUdp->bSemiConnected = bFilter;\n \n Tcp4uLog (LOG4U_EXIT, \"UdpBind\");\nreturn TCP4U_SUCCESS;\n} /* UdpBind */\n\n\n\n/* ------------------------------------------------------------------------- */\n/* destructeur : UdpCleanup */\n/* ------------------------------------------------------------------------- */\nint API4U UdpCleanup (LPUDPSOCK Udp)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"UdpCleanup sock %d\", Udp->UdpSock);\n\n Tcp4uLog (LOG4U_CALL, \"closesocket sock %d\", Udp->UdpSock);\n Rc = CloseSocket (Udp->UdpSock);\n if (Rc!=0)\n {\n Tcp4uLog (LOG4U_ERROR, \"closesocket sock %d\", Udp->UdpSock);\n return TCP4U_ERROR;\n }\n Free (Udp);\n\n Tcp4uLog (LOG4U_EXIT, \"UdpCleanup\");\nreturn TCP4U_SUCCESS;\n} /* UdpCleanup */\n\n\n/* ------------------------------------------------------------------------- */\n/* Envoi d'une trame UDP */\n/* ------------------------------------------------------------------------- */\nint API4U UdpSend (LPUDPSOCK Udp, LPCSTR sData, int nDataSize,\n BOOL bHighPriority, HFILE hLogFile)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"UdpSend sock %d, %d bytes to be sent \", \n Udp->UdpSock, nDataSize);\n Rc = InternalUdpSend (Udp, sData, nDataSize, bHighPriority, hLogFile);\n if (Rc==TCP4U_SUCCESS) Tcp4uDump (sData, nDataSize, DUMP4U_SENT);\n Tcp4uLog (LOG4U_EXIT, \"UdpSend\");\nreturn Rc;\n} /* UdpSend */\n\nint InternalUdpSend (LPUDPSOCK Udp,LPCSTR sData, int nDataSize,\n BOOL bHighPriority, HFILE hLogFile)\n{\nint Rc;\n\n Tcp4uLog (LOG4U_CALL, \"sendto host %s sock %d, %d bytes to be sent \", \n inet_ntoa (Udp->saSendAddr.sin_addr), \n Udp->UdpSock, nDataSize);\n Rc = sendto ( Udp->UdpSock, \n sData, nDataSize, \n bHighPriority ? MSG_OOB : 0, \n (struct sockaddr far *) &Udp->saSendAddr, \n sizeof Udp->saSendAddr);\n /* --- Analyser la valeur retounee */\n if (Rc<0)\n {\n Tcp4uLog (LOG4U_ERROR, \"sendto host %s\", inet_ntoa (Udp->saSendAddr.sin_addr) );\n return TCP4U_ERROR;\n }\n if (hLogFile!=HFILE_ERROR) Write (hLogFile, sData, Rc);\n\nreturn Rc==nDataSize ? TCP4U_SUCCESS : TCP4U_OVERFLOW;\n} /* InternalUdpSend */\n\n\n/* ------------------------------------------------------------------------- */\n/* La fonction reciproque : UdpRecv */\n/* ------------------------------------------------------------------------- */\nint API4U UdpRecv (LPUDPSOCK pUdp, LPSTR sData, int nDataSize, \n unsigned uTimeOut, HFILE hLogFile)\n{\nint Rc;\n Tcp4uLog (LOG4U_PROC, \"UdpRecv sock %d, buffer %d bytes\", pUdp->UdpSock, nDataSize);\n Rc = InternalUdpRecv (pUdp, sData, nDataSize, uTimeOut, hLogFile);\n if (Rc>=TCP4U_SUCCESS) Tcp4uDump (sData, Rc, DUMP4U_RCVD);\n Tcp4uLog (LOG4U_EXIT, \"UdpRecv %d bytes received\", Rc);\nreturn Rc;\n} /* UdpRecv */\n \n\nint InternalUdpRecv (LPUDPSOCK pUdp, LPSTR sData, int nDataSize, \n unsigned uTimeOut, HFILE hLogFile)\n{\nint Rc;\nstruct timeval TO;\nfd_set ReadMask; /* select mask */\nint Len = sizeof (struct sockaddr_in);\n\n if (pUdp->UdpSock==INVALID_SOCKET) return TCP4U_ERROR;\n /* bug 1 : Timeout kept in Loop, should be decremented */\n /* (can be done by the select function) */\n /* bug 2 : some frames are read even if they do not concern this process */\n TO.tv_sec = (long) uTimeOut; /* secondes */\n TO.tv_usec = 0; /* microsecondes */\n do\n {\n FD_ZERO (& ReadMask); /* mise a zero du masque */\n FD_SET (pUdp->UdpSock, & ReadMask); /* Attente d'evenement en lecture */\n /* s+1 normally unused but better for a lot of bugged TCP Stacks */\n Tcp4uLog (LOG4U_CALL, \"select Timeout %d\", uTimeOut);\n Rc = select ( pUdp->UdpSock+1, \n & ReadMask, NULL, NULL, \n uTimeOut==0? NULL: &TO);\n if (Rc<0)\n {\n Tcp4uLog (LOG4U_ERROR, \"select\");\n return IsCancelled() ? TCP4U_CANCELLED : TCP4U_ERROR;\n }\n if (Rc==0)\n {\n Tcp4uLog (LOG4U_ERROR, \"select: Timeout\");\n return TCP4U_TIMEOUT; /* timeout en reception */\n } \n \n Tcp4uLog (LOG4U_CALL, \"recvfrom host %s\", inet_ntoa (pUdp->saRecvAddr.sin_addr));\n Rc = recvfrom (pUdp->UdpSock, sData, nDataSize, 0, \n (struct sockaddr far *) & pUdp->saRecvAddr, & Len);\n if (Rc<0)\n {\n Tcp4uLog (LOG4U_ERROR, \"recvfrom\");\n return TCP4U_ERROR;\n }\n }\n while ( pUdp->bSemiConnected \n && memcmp (& pUdp->saRecvAddr.sin_addr, \n & pUdp->saFilter, \n sizeof pUdp->saFilter) != 0);\n\n if (hLogFile!=HFILE_ERROR) Write (hLogFile, sData, Rc);\nreturn Rc;\n} /* InternalUdpRecv */\n\n\n// OGGReader.cpp: implementation of the OGGReader class.\r\n//\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"StdAfx.h\"\r\n//#include \"URLMon.h\"\r\n\r\n#include \r\n#include \r\n\r\n/* debug context\r\nCKContext *g_pContext;\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n g_pContext = context;\r\n\treturn CK_OK;\r\n}\r\n*/\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Construction\r\n\r\nOGGReader::OGGReader()\r\n{\r\n// Init data members\r\n m_FormatInfo.cbSize = 0;\r\n m_FormatInfo.nAvgBytesPerSec = 0;\r\n m_FormatInfo.nBlockAlign = 0;\r\n m_FormatInfo.nChannels = 0;\r\n m_FormatInfo.nSamplesPerSec = 0;\r\n m_FormatInfo.wBitsPerSample = 0;\r\n m_FormatInfo.wFormatTag = 0;\r\n\r\n m_EOF = 0;\r\n m_CurrentSection = -1;\r\n\r\n\tm_pBuffer = new BYTE[BUFFERSIZE];\r\n\tm_BufferDataRead = 0;\r\n\r\n\tm_FileOpen = false;\r\n\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Destruction\r\n\r\nOGGReader::~OGGReader()\r\n{\r\n // Close Ogg file\r\n if(m_FileOpen)\r\n\t\tov_clear(&m_VorbisFile);\r\n\r\n\tdelete [] m_pBuffer;\r\n}\r\n\r\n//CKERROR OGGReader::ReadMemory(void* memory, int size)\r\n//{\r\n//\treturn CKSOUND_READER_GENERICERR;\r\n//}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Opens a file\r\n\r\nbool isExist(const char* filepath)\r\n{\r\n FILE* f = 0;\r\n if (filepath && (f=fopen(filepath,\"r\")) != 0)\r\n fclose(f);\r\n return f != 0;\r\n}\r\n\r\nCKERROR OGGReader::OpenFile(char *file)\r\n{\r\n CKERROR fRtn = CK_OK; // assume success\r\n\tint ovResult;\r\n\r\n if (!file || strlen(file) == 0)\r\n goto OPEN_ERROR;\r\n\r\n\tif(isExist(file) == FALSE)\r\n\t\tgoto OPEN_ERROR;\r\n\r\n // Make a C-style file stream out of the cached path\r\n FILE *pOggFile;\r\n if (!(pOggFile = fopen(file, \"rb\")))\r\n\t\tgoto OPEN_ERROR;\r\n\r\n // Open the vorbis file\r\n ovResult = ov_open(pOggFile, &m_VorbisFile, NULL, 0);\r\n\r\n if(ovResult < 0)\r\n\t\tgoto OPEN_ERROR;\r\n\t\r\n\tm_FileOpen = true;\r\n vorbis_info *pVorbisInfo;\r\n if(!(pVorbisInfo = ov_info(&m_VorbisFile, -1))) {\r\n // g_pContext->OutputToConsole(\"Ogg Error\", false);\r\n goto OPEN_ERROR;\r\n }\r\n\r\n m_FormatInfo.wFormatTag = 1;\r\n m_FormatInfo.nChannels = pVorbisInfo->channels;\r\n m_FormatInfo.nSamplesPerSec = pVorbisInfo->rate;\r\n m_FormatInfo.wBitsPerSample = BITSPERSAMPLE;\r\n m_FormatInfo.nBlockAlign = (pVorbisInfo->channels * m_FormatInfo.wBitsPerSample) / 8;\r\n// m_FormatInfo.nAvgBytesPerSec = ov_bitrate(m_VorbisFile, -1) / 8;\r\n m_FormatInfo.nAvgBytesPerSec = m_FormatInfo.nBlockAlign * m_FormatInfo.nSamplesPerSec;\r\n m_FormatInfo.cbSize = 0;\r\n\r\n\t/*\r\n sprintf(str, \"Channels: %i\", m_FormatInfo.nChannels);\r\n g_pContext->OutputToConsole(str, false);\r\n sprintf(str, \"SamplesPerSec: %i\", m_FormatInfo.nSamplesPerSec);\r\n g_pContext->OutputToConsole(str, false);\r\n sprintf(str, \"BlockAlign: %i\", m_FormatInfo.nBlockAlign);\r\n g_pContext->OutputToConsole(str, false);\r\n sprintf(str, \"AvgBytesPerSec: %i\", m_FormatInfo.nAvgBytesPerSec);\r\n g_pContext->OutputToConsole(str, false);\r\n\t*/\r\n\r\n\t//return CK_OK;\r\n\treturn fRtn;\r\n\r\n\r\nOPEN_ERROR:\r\n \r\n\t// Handle all errors here\r\n fRtn = CKSOUND_READER_GENERICERR;\r\n // Close Ogg file\r\n //ov_clear(&m_VorbisFile);\r\n\treturn CKSOUND_READER_GENERICERR;\r\n\t\r\n }\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Decodes 'n' stuff\r\n\r\n// Decodes next chunk of data, use get data buffer to get decoded data\r\nCKERROR OGGReader::Decode() \r\n{\r\n\r\n\tm_BufferDataRead = 0;\r\n int startSection = m_CurrentSection;\r\n\r\n long result = ov_read(&m_VorbisFile,\r\n (char *)m_pBuffer,\r\n BUFFERSIZE,\r\n 0,\r\n 2,\r\n 1,\r\n &m_CurrentSection);\r\n// char str[256];\r\n// sprintf(str, \"ov_read result: %i\", result);\r\n// g_pContext->OutputToConsole(str, true);\r\n\r\n // End Of File\r\n if (result == 0) {\r\n m_EOF = true;\r\n //g_pContext->OutputToConsole(\"E-O-F\", true);\r\n return CKSOUND_READER_EOF;\r\n }\r\n // Error in the bitstram\r\n else if (result < 0) {\r\n //g_pContext->OutputToConsole(\"Error in the bitstram in Decode\", false);\r\n return CKSOUND_READER_GENERICERR;\r\n }\r\n\r\n // Successfully read some stuff\r\n m_BufferDataRead = result;\r\n\r\n if (m_CurrentSection != startSection) {\r\n vorbis_info *pVorbisInfo;\r\n\r\n m_FormatInfo.wFormatTag = 1;\r\n m_FormatInfo.nChannels = pVorbisInfo->channels;\r\n m_FormatInfo.nSamplesPerSec = pVorbisInfo->rate;\r\n m_FormatInfo.wBitsPerSample = BITSPERSAMPLE;\r\n m_FormatInfo.nBlockAlign = (pVorbisInfo->channels * m_FormatInfo.wBitsPerSample) / 8;\r\n// m_FormatInfo.nAvgBytesPerSec = ov_bitrate(m_VorbisFile, -1) / 8;\r\n m_FormatInfo.nAvgBytesPerSec = m_FormatInfo.nBlockAlign * m_FormatInfo.nSamplesPerSec;\r\n m_FormatInfo.cbSize = 0;\r\n }\r\n\r\n return CK_OK;\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Gets the last decoded buffer\r\n\r\nCKERROR OGGReader::GetDataBuffer(BYTE **buf, int *size)\r\n{\r\n\t*buf = m_pBuffer;\r\n\t*size = m_BufferDataRead;\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Gets the ogg format of decoded datas\r\n\r\nCKERROR OGGReader::GetWaveFormat(CKWaveFormat *wfe)\r\n{\r\n\tmemcpy(wfe, &m_FormatInfo, sizeof(CKWaveFormat));\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Gets whole decoded data size\r\n\r\nint OGGReader::GetDataSize()\r\n{\r\n\treturn (int)(ov_pcm_total(&m_VorbisFile, -1) * m_FormatInfo.nBlockAlign); // * m_FormatInfo.nSamplesPerSec * m_FormatInfo.nBlockAlign);\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Gets the play time length\r\n\r\nint OGGReader::GetDuration()\r\n{\r\n\treturn (int)(ov_time_total(&m_VorbisFile, -1) * 1000);\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Seek some shit\r\n\r\nCKERROR OGGReader::Seek(int pos)\r\n{\r\n if(ov_seekable(&m_VorbisFile)) {\r\n ov_time_seek(&m_VorbisFile, pos);\r\n }\r\n else {\r\n //g_pContext->OutputToConsole(\"Tried to seek a non-seekable file!\", false);\r\n return CKSOUND_READER_GENERICERR;\r\n }\r\n \r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Play\r\n\r\nCKERROR OGGReader::Play()\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Stop\r\n\r\nCKERROR OGGReader::Stop()\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////////////////\r\n// Release\r\n\r\nvoid OGGReader::Release()\r\n{\r\n\tdelete this;\r\n}\r\n#include \"InitMan.h\"\r\n#include \"CKAll.h\"\r\n\r\n#include \"VSLManagerSDK.h\"\r\n\r\n#ifdef RACKNET\r\n\r\n#include \r\n#include \"network/racknet/NetworkStructures.h\"\r\n#include \"network/racknet/PacketEnumerations.h\"\r\n\r\n#include \"network/laser_point.h\"\r\n#include \"network/rNetStructs.h\"\r\n\r\n#pragma comment (lib,\"RakNet.lib\")\r\n\r\nextern InitMan *_im;\r\nstatic rNetServer *server = NULL;\r\n\r\nunsigned char GetPacketIdentifier(Packet *p);\r\nlaser_pointers *lPointers;\r\n\r\nlpoint pointers[5];\r\nboolean recieved =false;\r\nint packetDelay;\r\nint prevPacketCount;\r\n\r\nint pCount =0;\r\nint GetPacketDT();\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nBOOL rNetServerCreate(const char*server_name,int server_port);\r\nBOOL rNetServerStart(){\r\n\treturn server->start();\r\n}\r\nvoid rNetServerDestroy(){\r\n\tif(server->realInterface){\r\n\t\tserver->destroy();\r\n\t}\r\n}\r\nint rNetServerGetClientCount(){\r\n\r\n\t\r\n\treturn server->GetClientCount();\r\n\r\n\r\n}\r\n\r\nint rNetServerGetBytesReceivedPerSecond(){\r\n\t\r\n\t\treturn server->realInterface->GetBytesReceivedPerSecond();\r\n\r\n\treturn -1;\r\n\r\n}\r\n\r\nint GetPacketOutputBufferSize(){\r\n\treturn server->realInterface->GetPacketOutputBufferSize();\r\n\t}\r\n\r\n\r\n\r\nint rGetPacketsPerSecond(){\r\n\r\n\r\n\tint just = server->realInterface->GetReceivedPacketCount();\r\n\tint res = just - prevPacketCount;\r\n\tprevPacketCount = just;\r\n\t\r\n\treturn res;\r\n\r\n}\r\nint rGetPaketCount(){\r\n\t\r\n\treturn server->realInterface->GetReceivedPacketCount();\r\n\t\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nlpoint GetCoord(int index){\r\n\t\r\n\tif(recieved){\r\n\t\treturn pointers[index];\r\n\t}\r\n\treturn lpoint(-1,-1,-1);\r\n\r\n}\r\n\r\nVxRect rNetRecieve(){\r\n\r\n\tPacket* p = server->realInterface->Receive();\r\n\t\r\n\tif (p!=0){\r\n recieved =true;\r\n\t\tlPointers = ((laser_pointers*)p->data);\r\n \r\n\t\t/*\r\n\t\tfor (int i = 0 ; i < 10 ; i++){\r\n pointers[i].x = lPointers->LArray[i].x;\r\n\t\t\tpointers[i].y = lPointers->LArray[i].y;\r\n\r\n\t\t}\r\n \r\n\t\t//Vx2DVector coord = GetLPCoord(0);\r\n\t\tchar buffer[400];\r\n\t\tlpoint coord = GetCoord(0);\r\n\t\tsprintf(buffer,\"x : %d, y: %d\",coord.x,coord.y);\r\n\t\t_im->m_Context->OutputToConsole(buffer,false);\r\n\t\t*/\r\n \r\n\t\tVxRect m (lPointers->LArray[0].x,lPointers->LArray[0].y,lPointers->LArray[0].x,lPointers->LArray[0].x);\r\n\r\n// \t\tserver->realInterface->DeallocatePacket(p);\r\n// \t\tserver->realInterface->DesynchronizeAllMemory();\r\n\t\tpCount =1;\r\n\t\treturn m;\r\n\r\n\t}\r\n\tpCount = -1;\r\n\trecieved = false;\r\n\r\n\treturn VxRect(-1,-1,-1,-1);\r\n\t}\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nVx2DVector GetLPCoord(int index){\r\n\r\n\tif (recieved)\r\n\t\treturn Vx2DVector((const float)pointers[index].x,(const float)pointers[index].y);\r\n\treturn Vx2DVector(-1,-1);\r\n\t}\r\n\r\n\r\n\r\nlaser_pointers& GetLaserPointerArray(){\r\n\t/*\r\n\tPacket* p = server->realInterface->Receive();\r\n\r\n\tif (p!=0){\r\n\t\t\trecieved =true;\r\n\t\t\tlaser_pointers *tmpArray = ((laser_pointers*)p->data);\r\n\t\t\t\r\n\t\t\tfor (int i = 0 ; i < 99 ; i++){\r\n\t\t\t\tpointers[i].x = tmpArray->LArray[i].x;\r\n\t\t\t\tpointers[i].y = tmpArray->LArray[i].y;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tchar buffer[400];\r\n\t\t\tSYSTEMTIME time;\r\n\t\t\tGetSystemTime(&time);\r\n\t\t\tpacketDelay = time.wMilliseconds - tmpArray->sStamp.miliseconds;\r\n\t\t\tWORD sDT = time.wSecond - tmpArray->sStamp.seconds;\r\n\r\n\r\n\t\t\t//sprintf(buffer,\"dtSec : %d, dtMSec: %d\", sDT, msDT );\r\n\t\t\tsprintf(buffer,\"x : %f, y: %f\", pointers[0].x ,pointers[0].y);\r\n\t\t\t_im->m_Context->OutputToConsole(buffer,false);\r\n\r\n\r\n\t\t\tserver->realInterface->DeallocatePacket(p);\r\n\t\t\tserver->realInterface->DesynchronizeAllMemory();\r\n\r\n\t\t\treturn laser_pointers();\r\n\r\n\t\t}\r\n\trecieved = false ; */\r\n\t\r\n\treturn laser_pointers();\r\n}\r\n\r\n\r\n\r\nvoid\r\nlaser_pointers::GetCoord(Vx2DVector& target,int index){\r\n\t\r\n\tif (lPointers){\r\n\t\ttarget.x = (float)pointers[index].x;\r\n\t\ttarget.y = (float)pointers[index].y;\r\n\t\t}\r\n}\r\n\r\n\r\nvoid\r\nInitMan::RegisterRacknetVSL(){\r\n\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Variable|Parameter Stuff */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREFUN_C_2(BOOL,rNetServerCreate,const char*, int )\r\n\t\tDECLAREFUN_C_0(BOOL,rNetServerStart)\r\n\t\tDECLAREFUN_C_0(void,rNetServerDestroy)\r\n\t\tDECLAREFUN_C_0(int,rGetPaketCount)\r\n\t\t\r\n\t\tDECLAREFUN_C_0(int,GetPacketDT)\r\n\r\n\t\tDECLAREFUN_C_0(int,rGetPacketsPerSecond)\r\n\t\t\r\n\t\tDECLAREFUN_C_0(int,rNetServerGetClientCount)\r\n\t\tDECLAREFUN_C_0(int,rNetServerGetBytesReceivedPerSecond)\r\n\t\tDECLAREFUN_C_0(VxRect,rNetRecieve)\r\n\t\tDECLAREFUN_C_0(int,GetPacketOutputBufferSize)\r\n\r\n\t\t\r\n\t\tDECLAREOBJECTTYPE(lpoint)\r\n\t\tDECLAREMEMBER(lpoint,int,x)\r\n\t\tDECLAREMEMBER(lpoint,int,y)\r\n\t\tDECLAREFUN_C_1(lpoint,GetCoord,int)\r\n\t\t\r\n\t\tDECLAREPOINTERTYPE(laser_pointers)\r\n\t\t\r\n\t\tDECLAREMETHODC_1(laser_pointers,lpoint,GetPointByIndex,int)\r\n\r\n\t\tDECLAREFUN_C_0(laser_pointers&,GetLaserPointerArray) \r\n\r\n\t\tDECLAREMETHODC_2(laser_pointers,void,GetCoord,Vx2DVector&,int)\r\n\t\tDECLAREFUN_C_1(Vx2DVector,GetLPCoord,int)\r\n\r\n\tSTOPVSLBIND\r\n\r\n}\r\n\r\n\r\nCKERROR InitMan::PostProcess(){\r\n\t\r\n\t/*\r\n\tif (server->realInterface && server->isStarted){\r\n\r\n\t\tPacket* p = server->realInterface->Receive();\r\n\r\n\t\tif (p!=0){\r\n\t\t\tlPointers = ((laser_pointers*)p->data);\r\n\t\t\t\r\n\t\t\tm_Context->OutputToConsole(\"processing incoming packets\",false);\r\n\t\t\r\n\t\t/*\r\n\t\t\t\r\n\t\t\t\t\tchar buffer[400];\r\n\t\t\t\t\tSYSTEMTIME time;\r\n\t\t\t\t\tGetSystemTime(&time);\r\n\t\t\t\t\tpacketDelay = time.wMilliseconds - lPointers->sStamp.miliseconds;\r\n\t\t\t\t\tWORD sDT = time.wSecond - lPointers->sStamp.seconds;\r\n\t\t*/\r\n\t\t\r\n\r\n\r\n/*\r\n\t\t\tfor (int i = 0 ; i < 4 ; i++)\r\n\t\t\t{\r\n\t\t\t\t//pointers[i].x = lPointers->LArray[i].x;\r\n\t\t\t\t//pointers[i].y = lPointers->LArray[i].y;\r\n\t\t\t}*/\r\n/*\r\n\t\t\tchar buffer[400];\r\n\t\t\tlpoint coord = GetCoord(0);\r\n\t\t\tsprintf(buffer,\"x : %d, y: %d\",coord.x,coord.y);\r\n\r\n\t\t\tm_Context->OutputToConsole(buffer,false);\r\n*/\r\n\t\t\t//server->realInterface->DeallocatePacket(p);\r\n\t\t\t//server->realInterface->DesynchronizeAllMemory();\r\n\r\n\t\t//}\r\n\r\n\r\n\r\n\t\treturn CK_OK;\r\n\r\n\t//}\r\n}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\nunsigned char GetPacketIdentifier(Packet *p)\r\n{\r\n\tif (p==0)\r\n\t\treturn 255;\r\n\r\n\tif ((unsigned char)p->data[0] == ID_TIMESTAMP)\r\n\t{\r\n\t\tassert(p->length > sizeof(unsigned char) + sizeof(unsigned long));\r\n\t\treturn (unsigned char) p->data[sizeof(unsigned char) + sizeof(unsigned long)];\r\n\t}\r\n\telse\r\n\t\treturn (unsigned char) p->data[0];\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nBOOL rNetServerCreate(const char*server_name,int server_port){\r\n\r\n\tserver = new rNetServer(server_name,server_port);\r\n\tlPointers = new laser_pointers();\r\n\treturn true;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nint GetPacketDT(){\r\n\treturn packetDelay;\r\n}\r\n\r\n\r\n#endif\r\n\r\n// OGGReader.h: interface for the OGGReader class.\r\n//\r\n//////////////////////////////////////////////////////////////////////\r\n\r\n#if !defined(AFX_OGGReader_H__1ACADF42_5A21_11D3_BA37_00105A669BB5__INCLUDED_)\r\n#define AFX_OGGReader_H__1ACADF42_5A21_11D3_BA37_00105A669BB5__INCLUDED_\r\n\r\n#if _MSC_VER > 1000\r\n#pragma once\r\n#endif // _MSC_VER > 1000\r\n\r\n#include \r\n#include \r\n\r\n// buffer and size\r\n#define BUFFERSIZE 16384\r\n#define BITSPERSAMPLE 16\r\n\r\n//CKERROR InitInstance(CKContext *context);\r\n\r\nclass OGGReader : public CKSoundReader \r\n{\r\npublic:\r\n\tOGGReader();\r\n\tvirtual ~OGGReader();\r\n\r\n\tvirtual void Release();\r\n\r\n\tvirtual CKPluginInfo * GetReaderInfo();\r\n\r\n\t// Get Options Count\r\n\tvirtual int GetOptionsCount() { return 0; }\r\n\t// Get Options Description\r\n\tvirtual CKSTRING GetOptionDescription(int i) {return NULL; }\r\n\t\r\n\t// Get Flags\r\n\tvirtual CK_DATAREADER_FLAGS GetFlags() { return (CK_DATAREADER_FLAGS) (CK_DATAREADER_FILELOAD | CK_DATAREADER_MEMORYLOAD); }\r\n\r\npublic:\r\n\t// Opens a file\r\n\tvirtual CKERROR OpenFile(char *file);\r\n\r\n\t//virtual CKERROR ReadMemory(void* memory, int size);\r\n\t\r\n\t// Decodes next chunk of data, use get data buffer to get decoded data\r\n\tvirtual CKERROR Decode();\r\n\r\n\t// Gets the last decoded buffer\r\n\tvirtual CKERROR GetDataBuffer(BYTE **buf, int *size);\r\n\t\r\n\t// Gets the wave format of decoded datas\r\n\tvirtual CKERROR GetWaveFormat(CKWaveFormat *wfe);\r\n\r\n\t// Gets whole decoded data size\r\n\tvirtual int GetDataSize();\r\n\t\r\n\t// Gets the play time length\r\n\tvirtual int GetDuration();\r\n\r\n\t// Seek\r\n\tvirtual CKERROR Seek(int pos);\r\n\t// Play;\r\n\tvirtual CKERROR Play();\r\n\t// Stop\r\n\tvirtual CKERROR Stop();\r\n\r\n\tvirtual CKERROR Pause(){return CK_OK;}\r\n\tvirtual CKERROR Resume(){return CK_OK;}\r\n\r\nprotected:\r\n/*\r\n\tint DataRead(int count, char* buf); \r\n\tint DataRead(long pos, int count, char* buf);\r\n\tint DataSeek(long pos);\r\n*/\r\n OggVorbis_File m_VorbisFile;\r\n CKWaveFormat m_FormatInfo;\r\n bool m_EOF;\r\n\tbool m_FileOpen;\r\n int m_CurrentSection;\r\n/*\r\n UINT m_nBlockAlign; // ogg data block alignment spec\r\n UINT m_nAvgDataRate; // average ogg data rate\r\n UINT m_nBytesPlayed; // offset into data chunk\r\n\tBOOL m_IsPcm;\r\n\r\n\tunsigned long m_OutDataSize;\t// size of in data chunk\r\n\tunsigned long m_InDataSize;\t\t// size of out data chunk\r\n\t\r\n\tunsigned long m_InDataCursor;\r\n*/\r\n// PCM Data\r\n\r\n\tBYTE *m_pBuffer;\t\t// Data Buffer;\r\n\tint m_BufferDataRead;\r\n\r\n\t\r\n};\r\n\r\n#endif // !defined(AFX_OGGReader_H__1ACADF42_5A21_11D3_BA37_00105A669BB5__INCLUDED_)\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBGetParameterDecl();\r\nCKERROR CreatePBGetParameterProto(CKBehaviorPrototype **pproto);\r\nint PBGetParameter(const CKBehaviorContext& behcontext);\r\nCKERROR PBGetParameterCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools;\r\nusing namespace BehaviorTools;\r\n\r\n\r\n\r\nenum bbI_Inputs\r\n{\r\n\tbbI_BodyReference,\r\n\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbO_CollisionGroup,\r\n\tbbO_GroupsMask,\r\n\tbbO_Flags,\r\n\tbbO_TFlags,\r\n\tbbO_LinDamp,\r\n\tbbO_AngDamp,\r\n\tbbO_MassOffset,\r\n\tbbO_ShapeOffset,\r\n\r\n};\r\nBBParameter pOutMap12[] = \r\n{\r\n\tBB_SPOUT(bbO_CollisionGroup,CKPGUID_INT,\"Collision Group\",\"0.0\"),\r\n\tBB_SPOUT(bbO_GroupsMask,VTS_FILTER_GROUPS,\"Groups Mask\",\"\"),\r\n\tBB_SPOUT(bbO_Flags,VTF_BODY_FLAGS,\"Body Flags\",\"\"),\r\n\tBB_SPOUT(bbO_TFlags,VTF_BODY_TRANS_FLAGS,\"Transformation Lock Flags\",\"\"),\r\n\tBB_SPOUT(bbO_LinDamp,CKPGUID_FLOAT,\"Linear Damping\",\"0.0\"),\r\n\tBB_SPOUT(bbO_AngDamp,CKPGUID_FLOAT,\"Angular Damping\",\"0.0\"),\r\n\tBB_SPOUT(bbO_MassOffset,CKPGUID_VECTOR,\"Mass Offset\",\"0.0\"),\r\n\tBB_SPOUT(bbO_ShapeOffset,CKPGUID_VECTOR,\"Pivot Offset\",\"0.0\"),\r\n\r\n};\r\n\r\n#define gOPMap pOutMap12\r\n\r\n\r\nCKERROR PBGetParameterCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tint cb = behcontext.CallbackMessage;\r\n\tBB_DECLARE_PMAP;\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t\t{\r\n\t\t\t\tBB_LOAD_POMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\t\t\t\tBB_DESTROY_PMAP;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\t{\r\n\t\t\t\tBB_INIT_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t\t{\r\n\t\t\t\tBB_REMAP_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBGetParameterDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBGetPar\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Retrieves rigid bodies parameters\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x59a670a,0x59a557ec));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBGetParameterProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBGetParameterProto\r\n// FullName: CreatePBGetParameterProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBGetParameterProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBGetPar\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*\r\n\tPBGetPar\r\n\tPBGetPar is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRetrieves various physical informations.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBGetPar.png\r\n\r\n\t\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body or the sub shape is part of.See pRigidBody::getCollisionsGroup().\r\n\t
\r\n\tGroupsmask: Sets 128-bit mask used for collision filtering. It can be sub shape specific.See comments for ::pGroupsMask and pRigidBody::setGroupsMask()\r\n\t
\r\n\tFlags: The current flags. See pRigidBody::getFlags() \r\n\t
\r\n\tTransformation Locks: Current transformations locks.\r\n\t
\r\n\tLinear Damping: The linear damping scale.\r\n\t
\r\n\tAngular Damping: The linear damping scale.\r\n\t
\r\n\tMass Offset: The mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: The shapes position in the bodies local space. See pRigidBody::getLocalShapePosition().\r\n\t
\r\n\r\n\t

Warning

\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBGetParameterCB );\r\n\r\n\r\n\tBB_EVALUATE_SETTINGS(gOPMap);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBGetParameter);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBGetParameter\r\n// FullName: PBGetParameter\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBGetParameter(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tBB_DECLARE_PMAP;\r\n\r\n\t\tBBSParameter(bbO_CollisionGroup);\r\n\t\tBBSParameter(bbO_GroupsMask);\r\n\t\t\r\n\t\tBBSParameter(bbO_Flags);\r\n\t\tBBSParameter(bbO_TFlags);\r\n\t\t\r\n\t\tBBSParameter(bbO_LinDamp);\r\n\t\tBBSParameter(bbO_AngDamp);\r\n\t\t\r\n\t\tBBSParameter(bbO_MassOffset);\r\n\t\tBBSParameter(bbO_ShapeOffset);\r\n\r\n\t\tbody->recalculateFlags(0);\r\n\t\t\r\n\t\tBB_O_SET_VALUE_IF(int,bbO_CollisionGroup,body->getCollisionsGroup(target));\r\n\t\tBB_O_SET_VALUE_IF(int,bbO_Flags,body->getFlags());\r\n\t\tBB_O_SET_VALUE_IF(int,bbO_TFlags,body->getTransformationsLockFlags());\r\n\t\tBB_O_SET_VALUE_IF(float,bbO_LinDamp,body->getLinearDamping());\r\n\t\tBB_O_SET_VALUE_IF(float,bbO_AngDamp,body->getAngularDamping());\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_MassOffset,body->getMassOffset());\r\n\t\tBB_O_SET_VALUE_IF(VxVector,bbO_ShapeOffset,body->getPivotOffset(target));\r\n\r\n\t\tif (sbbO_GroupsMask)\r\n\t\t{\r\n\t\t\tpGroupsMask gMask = body->getGroupsMask(target);\r\n\t\t\tCKParameterOut *poutMask = beh->GetOutputParameter(BB_OP_INDEX(bbO_GroupsMask));\r\n\r\n\t\t\tif (poutMask)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(poutMask,gMask);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBGetParameterCB\r\n// FullName: PBGetParameterCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n#ifndef __xDistributedProperty_h\r\n#define __xDistributedProperty_h\r\n\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nnamespace TNL\r\n{\r\n\tclass BitStream;\r\n}\r\n\r\nclass xPredictionSetting;\r\nclass xDistributedPropertyInfo;\r\n\r\nclass xDistributedProperty \r\n{\r\n\r\n\tpublic:\r\n\t\r\n\r\n\t\txDistributedProperty(xDistributedPropertyInfo *propInfo);\r\n\t\tvirtual ~xDistributedProperty(){}\r\n\t\t\r\n\t\txDistributedPropertyInfo *m_PropertyInfo;\r\n\r\n\t\txDistributedPropertyInfo * getPropertyInfo() { return m_PropertyInfo; }\r\n\t\tvoid setPropertyInfo(xDistributedPropertyInfo * val) { m_PropertyInfo = val; }\r\n\t\t\r\n\t\txTimeType mLastTime;\r\n\t\txTimeType getLastTime() const { return mLastTime; }\r\n\t\tvoid setLastTime(xTimeType val) { mLastTime = val; }\r\n\t\t\r\n\t\txTimeType mThresoldTicker;\r\n\t\t\r\n\t\txTimeType getThresoldTicker() const { return mThresoldTicker; }\r\n\t\tvoid setThresoldTicker(xTimeType val) { mThresoldTicker = val; }\r\n\r\n\t\txTimeType mCurrentTime;\r\n\t\txTimeType mLastDeltaTime;\r\n\t\txTimeType getCurrentTime() const { return mCurrentTime; }\r\n\t\tvoid setCurrentTime(xTimeType val) { mCurrentTime = val; }\r\n\r\n\t\tint mFlags;\r\n\t\tTNL::U32 mGhostId;\r\n\t\t\r\n\t\tTNL::U32 getGhostId() const { return mGhostId; }\r\n\t\tvoid setGhostId(TNL::U32 val) { mGhostId = val; }\r\n\t\t\r\n\t\tint getFlags() const { return mFlags; }\r\n\t\tvoid setFlags(int val) { mFlags = val; }\r\n\t\t\r\n\t\tvirtual void pack(TNL::BitStream *bstream);\r\n\t\tvirtual void unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvirtual int getBlockIndex(){return m_BlockIndex;}\r\n\t\tvirtual void setBlockIndex(int index){m_BlockIndex = index;}\r\n\t\tint m_BlockIndex;\r\n\r\n\t\tfloat mLastTime2;\r\n\t\tfloat mLastDeltaTime2;\r\n\t\tfloat mThresoldTicker2;\r\n\t\tvoid advanceTime(xTimeType time1,float lastDeltaTime2 );\r\n\t\txPredictionSetting *m_PredictionSettings;\r\n\t\t\r\n\t\txPredictionSetting *getPredictionSettings() const { return m_PredictionSettings; }\r\n\t\tvoid setPredictionSettings(xPredictionSetting * val) { m_PredictionSettings = val; }\r\n\r\n\t\tvirtual void updateGhostValue(TNL::BitStream *stream){}\r\n\t\tvirtual void updateFromServer(TNL::BitStream *stream){}\r\n \r\n\t\tfloat m_ownersOneWayTime;\r\n\t\tfloat getOwnersOneWayTime() const { return m_ownersOneWayTime; }\r\n\t\tvoid setOwnersOneWayTime(float val) { m_ownersOneWayTime = val; }\r\n\r\n\t\tint mValueState;\r\n\t\tint getValueState() const { return mValueState; }\r\n\t\tvoid setValueState(int val) { mValueState = val; }\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n\r\n\t\t\r\n\r\n\r\n};\r\n\r\n#endif\r\n#ifndef __P_VEHICLE_GEARS_H__\r\n\r\n#define __P_VEHICLE_GEARS_H__\r\n\r\n#include \"pVehicleTypes.h\"\r\n#include \"NxArray.h\"\r\n\r\n\r\n#define NX_VEHICLE_MAX_NB_GEARS 32\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\nclass MODULE_API pVehicleGearDesc {\r\npublic:\r\n\tpVehicleGearDesc() { setToDefault(); }\r\n\tvoid setToDefault();\r\n\tvoid setToCorvette();\r\n\tbool isValid() const;\r\n\tint\t\t\t\t\t\t\t\t\tgetMaxNumOfGears() const { return NX_VEHICLE_MAX_NB_GEARS; }\r\n\r\n\r\n\t//NxArray\tforwardGears;\r\n\t//NxArray\t\t\t\t\t\t\tforwardGearRatios;\r\n\tint\t\t\t\t\t\t\t\t\tnbForwardGears;\r\n\tpLinearInterpolation\t\t\tforwardGears[NX_VEHICLE_MAX_NB_GEARS];\r\n\tfloat\t\t\t\t\t\t\t\t\tforwardGearRatios[NX_VEHICLE_MAX_NB_GEARS];\r\n\r\n\t//NxLinearInterpolationValues\t\t\t\tbackwardGear;\r\n\tfloat\t\t\t\t\t\t\t\t\tbackwardGearRatio;\r\n};\r\n\r\n/**\r\n\\brief A abstract base class for a vehicle gear box.\r\n*/\r\nclass MODULE_API pVehicleGears {\r\n\r\npublic:\r\n\t//NxArray\t_forwardGears;\r\n\t//NxArray\t\t\t\t\t\t\t_forwardGearRatios;\r\n\tint\t\t\t\t\t\t\t\t\t_nbForwardGears;\r\n\tpLinearInterpolation\t\t\t\t_forwardGears[NX_VEHICLE_MAX_NB_GEARS];\r\n\tfloat\t\t\t\t\t\t\t\t\t_forwardGearRatios[NX_VEHICLE_MAX_NB_GEARS];\r\n\r\n\t//NxLinearInterpolationValues\t\t\t\t_backwardGear;\r\n\tfloat\t\t\t\t\t\t\t\t\t_backwardGearRatio;\r\n\r\n\tint\t\t\t\t\t\t\t\t\t_curGear;\r\n\r\n\r\npublic:\r\n\tpVehicleGears(): _curGear(1) { }\r\n\r\n\t//static NxVehicleGears* createVehicleGears(const NxVehicleGearDesc& gearDesc);\r\n\r\n\tfloat\t\t\t\t\tgetCurrentRatio() const;\r\n\tfloat\t\t\t\t\tgetRatio(int gear) const;\r\n\tint\t\t\t\t\tgetGear() const { return _curGear; }\r\n\tint\t\t\t\t\tgetMaxGear() const { return _nbForwardGears; }\r\n\tvoid\t\t\t\t\tgearUp() { _curGear = NxMath::min(_curGear+1, (int)_nbForwardGears); }\r\n\tvoid\t\t\t\t\tgearDown() { _curGear = NxMath::max(_curGear-1, -1); }\r\n};\r\n\r\n/** @} */\r\n\r\n#endif/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n// include file used for the static configuration\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\nextern CCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\nBOOL CCustomPlayer::_FinishLoad()\r\n{\r\n\r\n\t// retrieve the level\r\n\tm_Level = m_CKContext->GetCurrentLevel();\r\n\tif (!m_Level) {\r\n\t\tMessageBox(NULL,CANNOT_FIND_LEVEL,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif(m_RenderContext)\r\n\t{\r\n\t\t// Add the render context to the level\r\n\t\tm_Level->AddRenderContext(m_RenderContext,TRUE);\r\n\r\n\t\t// Take the first camera we found and attach the viewpoint to it.\r\n\t\t// (in case it is not set by the composition later)\r\n\t\tconst XObjectPointerArray cams = m_CKContext->GetObjectListByType(CKCID_CAMERA,TRUE);\r\n\t\tif(cams.Size()) {\r\n\t\t\tm_RenderContext->AttachViewpointToCamera((CKCamera*)cams[0]);\r\n\t\t}\r\n\r\n\t\t// Hide curves ?\r\n\t\tint curveCount = m_CKContext->GetObjectsCountByClassID(CKCID_CURVE);\r\n\t\tCK_ID* curve_ids = m_CKContext->GetObjectsListByClassID(CKCID_CURVE);\r\n\t\tfor (int i=0;iGetObject(curve_ids[i]))->GetCurrentMesh();\r\n\t\t\tif(mesh)\r\n\t\t\t\tmesh->Show(CKHIDE);\r\n\t\t}\r\n\r\n\t\t// retrieve custom player attributes\r\n\t\t// from an exemple about using this attributes see sample.cmo which is delivered with this player sample\r\n\t\t// simply set the \"Quit\" attribute to quit the application\r\n\t\tm_QuitAttType = m_AttributeManager->GetAttributeTypeByName(\"Quit\");\r\n\t\t// simply set the \"Switch Fullscreen\" attribute to make the player switch between fullscreen and windowed mode\r\n\t\tm_SwitchFullscreenAttType = m_AttributeManager->GetAttributeTypeByName(\"Switch Fullscreen\");\r\n\t\t// simply set the \"Switch Resolution\" attribute to make the player change its resolution according\r\n\t\t// to the \"Windowed Resolution\" or \"Fullscreen Resolution\" (depending on the current mode)\r\n\t\tm_SwitchResolutionAttType = m_AttributeManager->GetAttributeTypeByName(\"Switch Resolution\");\r\n\t\t// simply set the \"Switch Mouse Clipping\" attribute to make the player clip/unclip the mouse to the render window\r\n\t\tm_SwitchMouseClippingAttType = m_AttributeManager->GetAttributeTypeByName(\"Switch Mouse Clipping\");\r\n\t\t// the windowed resolution\r\n\t\tm_WindowedResolutionAttType = m_AttributeManager->GetAttributeTypeByName(\"Windowed Resolution\");\r\n\t\t// the fullscreen resolution\r\n\t\tm_FullscreenResolutionAttType = m_AttributeManager->GetAttributeTypeByName(\"Fullscreen Resolution\");\r\n\t\t// the fullscreen bpp\r\n\t\tm_FullscreenBppAttType = m_AttributeManager->GetAttributeTypeByName(\"Fullscreen Bpp\");\r\n\r\n\t\t// remove attributes (quit,switch fullscreen and switch resolution) if present\r\n\t\tif (m_Level->HasAttribute(m_QuitAttType)) {\r\n\t\t\tm_Level->RemoveAttribute(m_QuitAttType);\r\n\t\t}\r\n\t\tif (m_Level->HasAttribute(m_SwitchFullscreenAttType)) {\r\n\t\t\tm_Level->RemoveAttribute(m_SwitchFullscreenAttType);\r\n\t\t}\r\n\t\tif (m_Level->HasAttribute(m_SwitchResolutionAttType)) {\r\n\t\t\tm_Level->RemoveAttribute(m_SwitchResolutionAttType);\r\n\t\t}\r\n\t\tif (m_Level->HasAttribute(m_SwitchMouseClippingAttType)) {\r\n\t\t\tm_Level->RemoveAttribute(m_SwitchMouseClippingAttType);\r\n\t\t}\r\n\r\n\t\t// set the attributes so it match the current player configuration\r\n\t\t_SetResolutions();\r\n\r\n\t\t// set a fake last cmo loaded\r\n\t\t// we build a filename using the exe full filename\r\n\t\t// remplacing exe by vmo.\r\n\t\t{\r\n\t\t\tchar path[MAX_PATH];\r\n\t\t\tif (::GetModuleFileName(0,path,MAX_PATH)) {\r\n\t\t\t\tchar drive[MAX_PATH];\r\n\t\t\t\tchar dir[MAX_PATH];\r\n\t\t\t\tchar filename[MAX_PATH];\r\n\t\t\t\tchar ext[MAX_PATH];\r\n\t\t\t\t_splitpath(path,drive,dir,filename,ext);\r\n\t\t\t\t_makepath(path,drive,dir,filename,\"vmo\");\r\n\t\t\t\tm_CKContext->SetLastCmoLoaded(path);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t// we launch the default scene\r\n\tm_Level->LaunchScene(NULL);\r\n\r\n\t// ReRegister OnClick Message in case it changed\r\n\tm_MsgClick = m_MessageManager->AddMessageType(\"OnClick\");\r\n\tm_MsgDoubleClick = m_MessageManager->AddMessageType(\"OnDblClick\");\r\n\r\n\t// render the first frame\r\n\tif (m_RenderContext)\r\n\t\tm_RenderContext->Render();\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nCKERROR CCustomPlayer::_Load(const char* str) \r\n{\r\n\t// the composition from a file\r\n\r\n\t// validate the filename\r\n\tif(!str || !(*str) || strlen(str)<=0) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// here we decompose the loading from a file to manage the missing guids case\r\n\r\n\t// create a ckfile\r\n\tCKFile *f = m_CKContext->CreateCKFile();\t\r\n\tXString resolvedfile = str;\t\r\n\t// resolve the filename using the pathmanager\r\n\t{\r\n\t\tCKPathManager *pm = m_CKContext->GetPathManager();\t\r\n\t\tif(pm) {\r\n\t\t\tpm->ResolveFileName(resolvedfile,0);\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// dbo - modification - displaying a bitmap during the load process\r\n\t// init - BEGIN\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCKSprite* loadingScreen = NULL;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// dbo mod - init - END\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t// open the file\r\n\tDWORD res = CKERR_INVALIDFILE;\r\n\tres = f->OpenFile(resolvedfile.Str(),(CK_LOAD_FLAGS) (CK_LOAD_DEFAULT | CK_LOAD_CHECKDEPENDENCIES));\r\n\tif (res!=CK_OK) {\r\n\t\t// something failed\r\n\t\tif (res==CKERR_PLUGINSMISSING) {\r\n\t\t\t// log the missing guids\r\n\t\t\t_MissingGuids(f,resolvedfile.CStr());\r\n\t\t}\r\n\t\t//m_CKContext->DeleteCKFile(f);\r\n\t\t//return res;\r\n\t}\r\n\r\n\tCKPathSplitter ps(resolvedfile.Str());\r\n\tCKPathMaker mp(ps.GetDrive(),ps.GetDir(),NULL,NULL);\r\n\tif(strcmp(mp.GetFileName(),CKGetStartPath())){\r\n\t\tCKPathManager *pm = m_CKContext->GetPathManager();\r\n\t\tXString XStr = XString(mp.GetFileName());\r\n\t\tpm->AddPath(BITMAP_PATH_IDX,XStr);\r\n\t\tXStr = XString(mp.GetFileName());\r\n\t\tpm->AddPath(DATA_PATH_IDX,XStr);\r\n\t\tXStr = XString(mp.GetFileName());\r\n\t\tpm->AddPath(SOUND_PATH_IDX,XStr);\t\t\t\r\n\t}\r\n\r\n\tCKObjectArray *array = CreateCKObjectArray();\t\r\n\tres = f->LoadFileData(array);\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// loading is done either as failed, or ok. Let's deleted the loading sprite\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t/*if (loadingScreen)\r\n\t{\r\n\t\tm_CKContext->DestroyObject(loadingScreen->GetID());\r\n\t\tm_Level->RemoveRenderContext(m_RenderContext);\r\n\t\tm_CKContext->DestroyObject(m_Level->GetID());\r\n\r\n\t\t// in case we changed it, it might have side effects, so we restore to black\r\n\t\tm_RenderContext->GetBackgroundMaterial()->SetDiffuse(VxColor(0,0,0).GetRGB());\r\n\t}*/\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\tif(res != CK_OK) {\r\n\t\tm_CKContext->DeleteCKFile(f);\r\n\t\tDeleteCKObjectArray(array);\r\n\t\treturn res;\r\n\t}\r\n\r\n\tm_CKContext->DeleteCKFile(f);\r\n\r\n\tDeleteCKObjectArray(array);\t\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR CCustomPlayer::_Load(const void* iMemoryBuffer,int iBufferSize)\r\n{\r\n\tCKFile *f = m_CKContext->CreateCKFile();\t\r\n\r\n\tDWORD res = CKERR_INVALIDFILE;\r\n\tres = f->OpenMemory((void*)iMemoryBuffer,iBufferSize,(CK_LOAD_FLAGS) (CK_LOAD_DEFAULT | CK_LOAD_CHECKDEPENDENCIES));\r\n\tif (res!=CK_OK) {\r\n\t\tif (res==CKERR_PLUGINSMISSING) {\r\n\t\t\t_MissingGuids(f,0);\r\n\t\t}\r\n\t\t//m_CKContext->DeleteCKFile(f);\r\n\t\t//return res;\r\n\t}\r\n\r\n\tCKObjectArray *array = CreateCKObjectArray();\t\r\n\tres = f->LoadFileData(array);\t\r\n\tif(res != CK_OK) {\r\n\t\tm_CKContext->DeleteCKFile(f);\r\n\t\treturn res;\r\n\t}\r\n\r\n\tm_CKContext->DeleteCKFile(f);\r\n\r\n\tDeleteCKObjectArray(array);\t\r\n\treturn CK_OK;\r\n}\r\n#ifndef __PYTHON_MODULE_H_\r\n#define __PYTHON_MODULE_H_\r\n#endif\r\n\r\n#include \"pyembed.h\"\r\n\r\nclass PythonModule\r\n{\r\n\r\npublic:\r\n\tPythonModule(const char*file,const char*func,int bid);\r\n\r\n\r\n\r\n\tint m_BehaviourID;\r\n\tint GetBehaviourID() const { return m_BehaviourID; }\r\n\tvoid SetBehaviourID(int val) { m_BehaviourID = val; }\r\n \r\n\tPyObject *m_PObject;\r\n \r\n\tstatic PythonModule* CreatePythonModule(const char*file,const char*func,int bid=0);\r\n\tstatic PythonModule* GetPythonModule(int id);\r\n\r\n\r\n\r\n\tprivate:\r\n\t\r\n\t\tconst char* m_File;\r\n\t\r\n\t\tconst char* m_Func;\r\n \r\n};#ifndef __XNETINTERFACE_H_\r\n#define __XNETINTERFACE_H_\r\n\r\n#include \"xNetTypes.h\"\r\n#include \"tnl.h\"\n#include \"tnlNetInterface.h\"\r\n\r\n#include \"vtConnection.h\"\r\n\r\nclass IMessages;\r\nclass IDistributedObjects;\r\nclass IDistributedClasses;\r\n\r\nstruct xClientInfo;\r\nstruct xDistDeleteInfo;\r\n\r\nclass xDistributedObject;\r\nclass xDistributedClient;\r\nclass xDistributedSession;\r\nclass ISession;\r\n\r\n\r\nclass xNetInterface : public TNL::NetInterface\r\n{\r\n\t \r\n\ttypedef TNL::NetInterface Parent;\r\n\tpublic:\r\n\r\n\r\n\t\tISession* getSessionInterface() const { return mISession; }\r\n\t\tvoid setSessionInterface(ISession* val) { mISession = val; }\r\n\r\n\t\txSessionArrayType& getSessions() { return *mSessions; }\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\txNetworkMessageArrayType *m_NetworkMessages;\r\n\t\txNetworkMessageArrayType& getNetworkMessages() { return *m_NetworkMessages; }\r\n\t\tIMessages * getMessagesInterface() { return m_IMessages; }\r\n\t\tvoid setMessagesInterface(IMessages * val) { m_IMessages = val; }\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\r\n\t\txMessageArrayType* mMessages; \r\n\t\txMessageArrayType* getMessages() { return mMessages; }\r\n\t\t \r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//user : \r\n\r\n\t\tTNL::Vectorm_ClientInfoTable;\r\n\t\tTNL::Vector&getClientInfoTable() { return m_ClientInfoTable; }\r\n\t\t\r\n\t\tTNL::Vectorm_DistDeleteTable;\r\n\t\tTNL::Vector&getDistDeleteTable() { return m_DistDeleteTable; }\r\n\t\tvoid addDeleteObject(xDistributedObject* object);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// Distributed Classes Interface\r\n\t\tIDistributedClasses *getDistributedClassInterface();\r\n\t\tvoid setDistributedClassInterface(IDistributedClasses *distClassInterface);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//Distributed Objects\r\n\t\txDistributedObjectsArrayType * getDistributedObjects() { return m_DistributedObjects; }\r\n\t\tvoid setDistributedObjects(xDistributedObjectsArrayType * val) { m_DistributedObjects = val; }\r\n\r\n\t\tIDistributedObjects * getDistObjectInterface() { return m_DistObjectInterface; }\r\n\t\tvoid setDistObjectInterface(IDistributedObjects * val) { m_DistObjectInterface = val; }\r\n\r\n\r\n\t\ttypedef TNL::NetInterface Parent;\r\n\t\t/// Constants used in this NetInterface\n\t\tenum Constants {\n\t\t\tPingDelayTime = 2000, ///< Milliseconds to wait between sending GamePingRequest packets.\n\t\t\tGamePingRequest = FirstValidInfoPacketId, ///< Byte value of the first byte of a GamePingRequest packet.\n\t\t\tGamePingResponse, ///< Byte value of the first byte of a GamePingResponse packet.\n\t\t\tScanPingRequest,\n\t\t\tScanPingResponse\n\t\t};\r\n\r\n\t\tbool pingingServers; ///< True if this is a client that is pinging for active servers.\n\t\tTNL::U32 lastPingTime; ///< The last platform time that a GamePingRequest was sent from this network interface.\n\t\tbool m_IsServer; ///< True if this network interface is a server, false if it is a client.\n\t\tbool IsServer() const { return m_IsServer; }\r\n\t\tvoid IsServer(bool val) { m_IsServer = val; }\r\n\t\tTNL::SafePtrconnectionToServer; ///< A safe pointer to the current connection to the server, if this is a client.\n\t\t\r\n\t\t\r\n\r\n\t\tvtConnection* getConnection() const { return connectionToServer; }\r\n\t\tvoid setConnection(vtConnection* val);\r\n \r\n\t\tTNL::Address pingAddress; ///< Network address to ping in searching for a server. This can be a specific host address or it can be a LAN broadcast address.\n\n\t\txNetInterface();\n\t\t/// Constructor for this network interface, called from the constructor for TestGame.\n\t\t/// The constructor initializes and binds the network interface, as well as sets\n\t\t/// parameters for the associated game and whether or not it is a server.\n\t\txNetInterface(bool server, const TNL::Address &bindAddress, const TNL::Address &pingAddr);\n\t\t\n\t\t/// handleInfoPacket overrides the method in the NetInterface class to handle processing\n\t\t/// of the GamePingRequest and GamePingResponse packet types.\n\t\tvoid handleInfoPacket(const TNL::Address &address, TNL::U8 packetType, TNL::BitStream *stream);\n\n\t\t/// sendPing sends a GamePingRequest packet to pingAddress of this TestNetInterface.\n\t\tvoid sendPing();\n\n\t\t/// Tick checks to see if it is an appropriate time to send a ping packet, in addition\n\t\t/// to checking for incoming packets and processing connections.\n\t\tvoid tick();\n\n\t\tvoid *m_UserData;\n\t\tvoid * GetUserData() const { return m_UserData; }\r\n\t\tvoid SetUserData(void * val) { m_UserData = val; }\r\n\r\n\t\tvoid processPacket(const TNL::Address &sourceAddress, TNL::BitStream *pStream);\r\n\t\t\r\n\t\tfloat elapsedConnectionTime;\r\n\t\tfloat getElapsedConnectionTime() const { return elapsedConnectionTime; }\r\n\t\tvoid setElapsedConnectionTime(float val) { elapsedConnectionTime = val; }\r\n\r\n\t\tfloat connectionTimeOut;\r\n\t\tfloat getConnectionTimeOut() const { return connectionTimeOut; }\r\n\t\tvoid setConnectionTimeOut(float val) { connectionTimeOut = val; }\r\n\r\n\t\tbool connectionInProgress;\r\n\t\tbool isConnectionInProgress() const { return connectionInProgress; }\r\n\t\tvoid setConnectionInProgress(bool val) { connectionInProgress = val; }\r\n\r\n\t\tvoid sendPing(TNL::Address addr,int type=GamePingRequest);\r\n\t\tbool isValid();\r\n\t\tbool m_isConnected;\r\n\t\tbool isConnected() const { return m_isConnected; }\r\n\t\tvoid setConnected(bool val) { m_isConnected = val; }\r\n\r\n\t\tvoid destroy();\r\n\r\n\t\tvoid createScopeObject();\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* user table */\r\n\t\t/************************************************************************/\r\n\t\t\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* clean funcs :\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\tint mConnectionIDCounter;\r\n\t\tint getConnectionIDCounter() const { return mConnectionIDCounter; }\r\n\t\tvoid setConnectionIDCounter(int val) { mConnectionIDCounter = val; }\r\n\r\n\t\tint m_DOCounter;\r\n\t\tint getDOCounter() const { return m_DOCounter; }\r\n\t\tvoid setDOCounter(int val) { m_DOCounter = val; }\r\n\r\n\t\tTNL::U32& getObjectUpdateCounter() { return m_ObjectUpdateCounter; }\r\n\t\tvoid setObjectUpdateCounter(TNL::U32 val) { m_ObjectUpdateCounter = val; }\r\n\t\t\r\n\t\tTNL::U32 m_ObjectUpdateCounter;\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\t\tvoid updateDistributedObjects(int flags,float deltaTime);\r\n\r\n\t\tfloat mLastTime;\r\n\t\tfloat mDeltaTime;\r\n\t\tfloat mLastSendTime;\r\n\t\t\r\n\t\tfloat getLastOneWayTime() { return mLastSendTime; }\r\n\t\t\r\n\t\tfloat mLastRoundTripTime;\r\n\t\t\r\n\t\tfloat getLastRoundTripTime() { return mLastRoundTripTime; }\r\n\t\t\r\n\t\t\r\n\t\tint mLastTime2;\r\n\t\tfloat mLastDeltaTime2;\r\n\t\tfloat getLastDeltaTime2() const { return mLastDeltaTime2; }\r\n\t\tvoid setLastDeltaTime2(float val) { mLastDeltaTime2 = val; }\r\n\t\tvoid advanceTime(xTimeType timeNow,float deltaTime);\r\n \r\n\t\tfloat GetConnectionTime(){ return mLastSendTime ;}\r\n\t\tvoid writeDistributedProperties(TNL::BitStream *bstream);\r\n\t\tvoid calculateUpdateCounter();\r\n \r\n\t\tfloat mCurrentThresholdTicker;\r\n\t\tfloat& getCurrentThresholdTicker(){ return mCurrentThresholdTicker; }\r\n\t\tvoid setCurrentThresholdTicker(float val) { mCurrentThresholdTicker = val; }\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\t\tvoid removeClient(int clientID);\r\n\t\t\t\r\n\t\tvirtual void checkConnections();\r\n\t\tint getNumConnections();\r\n\t\tint getNumSessions();\r\n\t\tvoid checkOwners();\r\n\t\tvoid disconnect(int connectionID);\r\n\t\tint getNumDistributedObjects(int templateType);\r\n\r\n\t\tbool mCheckObjects;\r\n\t\tbool getCheckObjects() const { return mCheckObjects; }\r\n\t\tvoid setCheckObjects(bool val) { mCheckObjects = val; }\r\n\t\tvoid checkObjects();\r\n\r\n\t\tvoid initBaseClasses(int flags);\r\n\r\n\t\tvoid deploySessionClasses(TNL::GhostConnection *connection);\r\n\r\n\r\n\t\txDistributedSession * getCurrentSession() { return mCurrentSession; }\r\n\t\tvoid setCurrentSession(xDistributedSession * val) { mCurrentSession = val; }\r\n\r\n\t\tint getMyUserID() const { return mMyUserID; }\r\n\t\tvoid setMyUserID(int val) { mMyUserID = val; }\r\n\t\t\r\n\t\txDistributedClient * getMyClient() { return mMyClient; }\r\n\t\tvoid setMyClient(xDistributedClient * val) { mMyClient = val; }\r\n\t\tvoid checkSessions();\r\n\t\tvoid printObjects(int type, int flags);\r\n\r\n\r\n\t\tstd::vector& getLocalLanServers() { return mLocalLanServers; }\r\n\t\tvoid setLocalLanServers(std::vector val) { mLocalLanServers = val; }\r\n\r\n\t\tvoid enableLogLevel(int type,int verbosity,int value);\r\n\t\tTNL::BitSet32& getInterfaceFlags() { return mInterfaceFlags; }\r\n\t\tvoid setInterfaceFlags(TNL::BitSet32 val) { mInterfaceFlags = val; }\r\n\r\n\t\tvoid setFixedRateParameters(TNL::U32 minPacketSendPeriod, TNL::U32 minPacketRecvPeriod, TNL::U32 maxSendBandwidth, TNL::U32 maxRecvBandwidth,bool global=false);\r\n\r\n\tprotected:\r\n\tprivate:\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// [5/5/2008 mc007] : final\r\n\t\tIDistributedClasses *m_DistributedClassInterface;\r\n\t\tIDistributedObjects *m_DistObjectInterface;\r\n\t\txDistributedObjectsArrayType *m_DistributedObjects;\r\n\t\tIMessages *m_IMessages;\r\n\t\tISession*mISession;\r\n\t\txSessionArrayType* mSessions;\r\n\t\txDistributedSession *mCurrentSession;\r\n\t\tint mMyUserID;\r\n\t\txDistributedClient *mMyClient;\r\n\r\n\t\tstd::vectormLocalLanServers;\r\n\t\tTNL::BitSet32 mInterfaceFlags;\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n};\r\n\r\n#endif\r\n#ifndef DataManager_H\r\n#define DataManager_H \"$Id:$\"\r\n\r\n#include \"CKBaseManager.h\"\r\n\r\n// define whether we use the manager to relay data or the global variable\r\n#define USE_MANAGER\r\n\r\n\r\n// [4/13/2009 macro willson] new headers for external access added\r\n\r\n#include \"gConfig.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// External access \r\n//\r\n#ifdef G_EXTERNAL_ACCESS\r\n\r\n\r\n\r\n\t#include \t//! @todo : HANDLE type \r\n\r\n\t#include \"MemoryFileMappingTypes.h\"\t//! todo : use forwards\r\n\r\n#endif // G_EXTERNAL_ACCESS\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// unique object identifiers \r\n//\r\n#define DataManagerGUID CKGUID(0x5164ef93, 0x384edab9)\r\n\r\nclass DataManager : public CKBaseManager \r\n{\r\n//##############################################################\r\n// Public Part \r\n//##############################################################\r\npublic :\r\n\tDataManager(CKContext* Context);\r\n\t~DataManager();\t\r\n\t\r\n\tVxVector _vPos;\r\n\r\n\r\n#ifdef G_EXTERNAL_ACCESS\r\n\t\r\n\t// [4/13/2009 macro willson]\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// External access : data members \r\n\t//\r\n\tHANDLE m_hMMFile;\r\n\tvtExternalEvent *m_pData;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// External access : functions\r\n\t//\r\n\r\n\r\n\t/*!\r\n\r\n\t\\brief\tinitiates shared memory helper objects. Must be called due CKInit\r\n\t*/\r\n\tint _initSharedMemory(int);\r\n\r\n\t/*\r\n\t\\brief handles messages. Must be called in a PreProcess.\r\n\t*/\r\n\tint _SharedMemoryTick(int);\r\n\r\n\r\n\t/*\r\n\t\\brief Might be silly. Just to clean up. Must be called in PostProcess.\r\n\t*/\r\n\tint _SharedMemoryTickPost(int);\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n#endif\t\r\n\r\n\r\n\t// [4/13/2009 macro willson] : enabled for external access\r\n\t/*!\r\n\t\\brief Called at the end of each process loop.\r\n\t*/\r\n\tvirtual CKERROR PostProcess();\r\n\r\n\t//--- Called at the beginning of each process loop.\r\n\tvirtual CKERROR PreProcess();\r\n\r\n\t// -- Called once at CKPlay. Needed to initiate shared memory\r\n\tCKERROR OnCKInit();\r\n\r\n\t//-\tset function mask for pre and post process callbacks\r\n\tvirtual CKDWORD GetValidFunctionsMask()\t\r\n\t{ \r\n\t\treturn CKMANAGER_FUNC_OnCKInit|CKMANAGER_FUNC_PostProcess|CKMANAGER_FUNC_PreProcess;\r\n\t\t\t\r\n\t}\r\n\r\n\t// [4/14/2009 macro willson] : end external access\t----------------------------------------------------------------\r\n\r\n\r\n\r\n\t\r\n//--------------------------------------------------------------\r\n// Unused methods\r\n//--------------------------------------------------------------\r\n\r\n/*\r\n\r\n\r\n\r\n\t\r\n\r\n//--- Called after the composition has been restarted.\r\n\tvirtual CKERROR OnCKPostReset();\r\n\r\n//--- Called before the composition is reset.\r\n\tvirtual CKERROR OnCKReset();\r\n\r\n//--- Called when the process loop is started.\r\n\tvirtual CKERROR OnCKPlay();\r\n\r\n//--- Called when the process loop is paused.\r\n\tvirtual CKERROR OnCKPause();\r\n\r\n//--- Called before a scene becomes active.\r\n\tvirtual CKERROR PreLaunchScene(CKScene* OldScene, CKScene* NewScene);\r\n\r\n//--- Called after a scene became active.\r\n\tvirtual CKERROR PostLaunchScene(CKScene* OldScene, CKScene* NewScene);\r\n\r\n//--- Called at the beginning of a copy.\r\n\tvirtual CKERROR OnPreCopy(CKDependenciesContext& context);\r\n\r\n//--- Called at the end of a copy.\r\n\tvirtual CKERROR OnPostCopy(CKDependenciesContext& context);\r\n\r\n//--- Called when objects are added to a scene.\r\n\tvirtual CKERROR SequenceAddedToScene(CKScene* scn, CK_ID* objids, int count);\r\n\r\n//--- Called when objects are removed from a scene.\r\n\tvirtual CKERROR SequenceRemovedFromScene(CKScene* scn, CK_ID* objids, int count);\r\n\r\n//--- Called just before objects are deleted.\r\n\tvirtual CKERROR SequenceToBeDeleted(CK_ID* objids, int count);\r\n\r\n//--- Called after objects have been deleted.\r\n\tvirtual CKERROR SequenceDeleted(CK_ID* objids, int count);\r\n\r\n//--- Called before the rendering of the 3D objects.\r\n\tvirtual CKERROR OnPreRender(CKRenderContext* dev);\r\n\r\n//--- Called after the rendering of the 3D objects.\r\n\tvirtual CKERROR OnPostRender(CKRenderContext* dev);\r\n\r\n//--- Called after the rendering of 2D entities.\r\n\tvirtual CKERROR OnPostSpriteRender(CKRenderContext* dev);\r\n\r\n//--- Called before the backbuffer is presented.\r\n\tvirtual CKERROR OnPreBackToFront(CKRenderContext* dev);\r\n\r\n//--- Called after the backbuffer is presented.\r\n\tvirtual CKERROR OnPostBackToFront(CKRenderContext* dev);\r\n\r\n//--- Called before switching to/from fullscreen.\r\n\tvirtual CKERROR OnPreFullScreen(BOOL Going2Fullscreen, CKRenderContext* dev);\r\n\r\n//--- Called after switching to/from fullscreen.\r\n\tvirtual CKERROR OnPostFullScreen(BOOL Going2Fullscreen, CKRenderContext* dev);\r\n\r\n//--- Called at the end of the creation of a CKContext.\r\n\t\r\n\r\n//--- Called at deletion of a CKContext.\r\n\tvirtual CKERROR OnCKEnd();\r\n\r\n//--- Called at the beginning of a load operation.\r\n\tvirtual CKERROR PreLoad();\r\n\r\n//--- Called to load manager data.\r\n\tvirtual CKERROR LoadData(CKStateChunk* chunk, CKFile* LoadedFile) { return CK_OK; }\r\n\r\n//--- Called at the end of a load operation.\r\n\tvirtual CKERROR PostLoad();\r\n\r\n//--- Called at the beginning of a save operation.\r\n\tvirtual CKERROR PreSave();\r\n\r\n//--- Called to save manager data. return NULL if nothing to save.\r\n\tvirtual CKStateChunk* SaveData(CKFile* SavedFile) { return NULL; }\r\n\r\n//--- Called at the end of a save operation.\r\n\tvirtual CKERROR PostSave();\r\n\r\n//--- Called at the beginning of a CKContext::ClearAll operation.\r\n\tvirtual CKERROR PreClearAll();\r\n\r\n//--- Called at the end of a CKContext::ClearAll operation.\r\n\tvirtual CKERROR PostClearAll();\r\n\r\n\r\n*/\r\n//##############################################################\r\n// Protected Part \r\n//##############################################################\r\nprotected :\r\n\t\r\n};\r\n\r\n#endif\r\n\r\n#ifndef __xDOStructs_h\r\n#define __xDOStructs_h\r\n\r\n#include \"xNetTypes.h\"\r\n#include \"xPoint.h\"\r\n\r\nstruct x3DPositionState\r\n{\r\n\r\n\tPoint3F state;\r\n\tF32 stateDeltaTime;\r\n\tPoint3F stateVelocity;\r\n\r\n\tx3DPositionState()\r\n\t{\r\n\t\tstate = Point3F(0,0,0);\r\n\t\tstateDeltaTime = 0.0f;\r\n\t\tstateVelocity = Point3F(0,0,0);\r\n\t}\r\n};\r\n\r\nstruct x3DObjectData\r\n{\r\n\tx3DPositionState *prevState;\r\n\tx3DPositionState *currentState;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//Position\r\n Point3F lastPostion;\r\n\tPoint3F currentPosition;\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tfloat dT;\r\n\tfloat currentTime;\r\n\tfloat lastTime;\r\n\tint warpCount;\r\n\r\n\tint UpdateFlags;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tx3DObjectData() : currentPosition(Point3F(0,0,0))\r\n\t{\r\n\t\tcurrentTime = 0.0f;\r\n\t\tlastTime = 0.0f;\r\n\t\tdT = 0.0f;\r\n\t\tprevState = new x3DPositionState();\r\n\t\tcurrentState = new x3DPositionState();\r\n\t\tUpdateFlags = 0 ; \r\n\t\twarpCount = 0;\r\n\r\n\t}\r\n};\r\n\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWSetCollisionGroupFlagDecl();\r\nCKERROR CreatePWSetCollisionGroupFlagProto(CKBehaviorPrototype **pproto);\r\nint PWSetCollisionGroupFlag(const CKBehaviorContext& behcontext);\r\nCKERROR PWSetCollisionGroupFlagCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWSetCollisionGroupFlagDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PWSetCollisionGroupFlag\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Enables collision between two collisions groups.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x44961cc7,0x2d104ced));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePWSetCollisionGroupFlagProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePWSetCollisionGroupFlagProto\r\n// FullName: CreatePWSetCollisionGroupFlagProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePWSetCollisionGroupFlagProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PWSetCollisionGroupFlag\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PWSetCollisionGroupFlagCB );\r\n\t\r\n\tproto->DeclareInParameter(\"Collisions Group A\",CKPGUID_INT,\"0\");\r\n\tproto->DeclareInParameter(\"Collisions Group A\",CKPGUID_INT,\"0\");\r\n\tproto->DeclareInParameter(\"Enabled\",CKPGUID_BOOL,\"0\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PWSetCollisionGroupFlag);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PWSetCollisionGroupFlag\r\n// FullName: PWSetCollisionGroupFlag\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PWSetCollisionGroupFlag(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorld(target); \r\n\t\tint collGA = GetInputParameterValue(beh,0);\r\n\t\tint collGB = GetInputParameterValue(beh,1);\r\n\t\tint value = GetInputParameterValue(beh,2);\r\n\t\tif(world)\r\n\t\t\tworld->cSetGroupCollisionFlag(collGA,collGB,value);\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PWSetCollisionGroupFlagCB\r\n// FullName: PWSetCollisionGroupFlagCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PWSetCollisionGroupFlagCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetZoom Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetZoomDecl();\r\nCKERROR CreateSetZoomProto(CKBehaviorPrototype **pproto);\r\nint SetZoom(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetZoomDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Zoom\");\t\r\n\tod->SetDescription(\"Sets the Zoom (or Lens) of a perspective camera (millimeter).\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tFocal Length: lens size expressed in millimeters.\r\n
\r\n See Also: 'Set FOV'.
\r\n\t*/\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x40540a0d, 0x000aaaaa));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetZoomProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetZoomProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Zoom\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Focal Length (mm)\", CKPGUID_FLOAT, \"50\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetZoom);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint SetZoom(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n float zoom = 50; // Zoom in mm\r\n beh->GetInputParameterValue(0, &zoom);\r\n\r\n float fov = 2.0f * atanf(18.0f / zoom);\r\n cam->SetFov( fov );\r\n\r\n beh->ActivateInput(0, FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pVehicleMotor.h\"\r\n#include \"pVehicleGears.h\"\r\n#include \"pSteer.h\"\r\n\r\n#include \r\n#include \"NxArray.h\"\r\n\r\n\r\nfloat pVehicle::getBrakeAmountFromTable(pVehicleBreakLevel brakeLevel)\r\n{\r\n\r\n\tint value = abs((int(getMPH()) / 10));\r\n\tif(value > BREAK_TABLE_ENTRIES - 1)\r\n\t\tvalue = BREAK_TABLE_ENTRIES - 1;\r\n\tif(value < 0 || value == BREAK_TABLE_ENTRIES)\r\n\t{\r\n\t\treturn 1.0f;\r\n\t}\r\n\t\r\n\tswitch(brakeLevel)\r\n\t{\r\n\t\tcase BL_Small:\r\n\t\t\treturn mSmallBrakeTable.brakeEntries[brakeLevel];\r\n\t\tcase BL_Medium:\r\n\t\t\treturn mMediumBrakeTable.brakeEntries[brakeLevel];\r\n\t\tcase BL_High:\r\n\t\t\treturn mHighBrakeTable.brakeEntries[brakeLevel];\r\n\t}\r\n\r\n\treturn 1.0f;\r\n\r\n}\r\n\r\npVehicleBreakCase pVehicle::calculateBreakCase(int currentAccelerationStatus)\r\n{\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// is rolling or no user input ?\r\n\t//\r\n\tif( !(currentAccelerationStatus & VS_Handbrake )\t&&\r\n\t\t (currentAccelerationStatus & VS_IsMoving )\t\t&&\r\n\t\t!(currentAccelerationStatus & VS_IsAccelerated)\r\n\t )\r\n\t\treturn BC_NoUserInput;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// direction change ?\r\n\t//\r\n\tif( !(currentAccelerationStatus & VS_Handbrake )\t&&\r\n\t\t (currentAccelerationStatus & VS_IsBraking )\t&& \r\n\t\t (currentAccelerationStatus & VS_IsMoving )\t\t&&\r\n\t\t (currentAccelerationStatus & VS_IsAccelerated)\r\n\t )\r\n\t\treturn BC_DirectionChange;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// handbrake \r\n\t//\r\n\tif( (currentAccelerationStatus & VS_Handbrake ) )\r\n\t\treturn BC_Handbrake;\r\n\r\n\treturn BC_NoUserInput;\r\n\r\n}\r\n\r\n\r\nvoid pVehicle::doSteering()\r\n{\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel2* wheel = (pWheel2*)_wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_SteerableInput))\r\n\t\t{\r\n\t\t\tint i;\n\t\t\t// Send steering angle through to steering wheels\n\t\t\tfloat factor=steer->GetLock()/wheel->GetLock()*2.0f;\n\t\t\tfloat angle = steer->GetAngle();\n\t\t\tfloat rAngle = wheel->getWheelShape()->getSteerAngle();\n\t\t\twheel->setSteering(steer->GetAngle()/factor);\n\r\n\t\t}\r\n\t}\r\n}\r\nint pVehicle::_performSteering(float dt)\r\n{\r\n\t_controlSteering(_cSteering, _cAnalogSteering);\r\n\r\n\tNxReal distanceSteeringAxisCarTurnAxis = _steeringSteerPoint.x - _steeringTurnPoint.x;\r\n\t//NX_ASSERT(_steeringSteerPoint.z == _steeringTurnPoint.z);\r\n\tNxReal distance2 = 0;\r\n\tif (NxMath::abs(_steeringWheelState) > 0.01f)\r\n\t\tdistance2 = distanceSteeringAxisCarTurnAxis / NxMath::tan(_steeringWheelState * getMaxSteering());\r\n\r\n\tfloat tanS = NxMath::tan(_steeringWheelState * getMaxSteering());\r\n\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_SteerableInput))\r\n\t\t{\r\n\t\t\tif(distance2 != 0)\r\n\t\t\t{\r\n\r\n\t\t\t\t//NxReal xPos = wheel->getWheelPos().x;\r\n\t\t\t\tNxReal xPos = ((pWheel2*)wheel)->getWheelShape()->getLocalPosition().x;\r\n\t\t\t\t//NxReal xPos2 = _steeringSteerPoint.x- wheel->getWheelPos().x;\r\n\t\t\t\t//NxReal xPos2 = _steeringSteerPoint.x- ((pWheel2*)wheel)->getWheelShape()->getLocalPosition().z;\r\n\t\t\t\tNxReal zPos = ((pWheel2*)wheel)->getWheelShape()->getLocalPosition().z;\r\n\t\t\t\t//NxReal zPos = wheel->getWheelPos().z;\r\n\r\n\t\t\t\tNxReal dz = -zPos + distance2;\r\n\t\t\t\tNxReal dx = xPos - _steeringTurnPoint.x;\r\n\t\t\t\tfloat angle =(NxMath::atan(dx/dz));\r\n\t\t\t\tif (dx < 0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tangle*=-1.0f;\r\n\t\t\t\t}\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t} else {\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t}\r\n\r\n\t\t} else if(wheel->getWheelFlag(WF_SteerableAuto))\r\n\t\t{\r\n\t\t\tNxVec3 localVelocity = getActor()->getLocalPointVelocity(getFrom(wheel->getWheelPos()));\r\n\t\t\tNxQuat local2Global = getActor()->getGlobalOrientationQuat();\r\n\t\t\tlocal2Global.inverseRotate(localVelocity);\r\n\t\t\t//\t\t\tprintf(\"%2.3f %2.3f %2.3f\\n\", wheel->getWheelPos().x,wheel->getWheelPos().y,wheel->getWheelPos().z);\r\n\t\t\tlocalVelocity.y = 0;\r\n\t\t\tif(localVelocity.magnitudeSquared() < 0.1f)\r\n\t\t\t{\r\n\t\t\t\twheel->setAngle(0.0f);\r\n\t\t\t} else {\r\n\t\t\t\tlocalVelocity.normalize();\r\n\t\t\t\t//\t\t\t\tprintf(\"localVelocity: %2.3f %2.3f\\n\", localVelocity.x, localVelocity.z);\r\n\t\t\t\tif(localVelocity.x < 0)\r\n\t\t\t\t\tlocalVelocity = -localVelocity;\r\n\t\t\t\tNxReal angle = NxMath::clamp((NxReal)atan(localVelocity.z / localVelocity.x), 0.3f, -0.3f);\r\n\t\t\t\twheel->setAngle(angle);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\treturn 0;\r\n}\r\nfloat pVehicle::calculateBraking(float dt)\r\n{\r\n\r\n\tfloat breakTorque = 0.0f;\r\n\r\n\t\r\n\tpVehicleBreakCase currentBreakCase = calculateBreakCase(_currentStatus);\r\n\r\n\t/*\r\n\tint currentBreakLevel = getBreaklevelForCase(currentBreakCase);\r\n\t*/\r\n\tbool calculateBreaking = false;\r\n\tXString errMessage;\r\n\r\n\r\n\tif( \r\n\t\t((_currentStatus & VS_IsBraking ) && (_currentStatus & VS_IsMoving)) \r\n\t\t)\tcalculateBreaking = true;\r\n\r\n\r\n\tif (\t(_currentStatus & VS_IsMoving )\t\t&& \r\n\t\t(getBreakFlags() & VBF_Autobreak)\t&& \r\n\t\t(currentBreakCase == BC_NoUserInput)&& \r\n\t\t(_currentStatus & VS_IsMoving )\t\t&&\r\n\t\t!(_currentStatus & VS_IsAccelerated )\r\n\t\t)\r\n\t{\r\n\t\tcalculateBreaking = true;\r\n\t\t/*\t\terrMessage.Format(\"autobreak\");*/\r\n\t\t//xInfo(errMessage.Str());\r\n\t}\r\n\r\n\r\n\tif (_currentStatus & VS_Handbrake)\r\n\t{\r\n\t\t/*errMessage.Format(\"handbrake\");\r\n\t\txInfo(errMessage.Str());*/\r\n\t\tgoto performAcceleration;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// calculate break torque \r\n\t//\r\n\tif ( calculateBreaking )\r\n\t{\r\n\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// increase break time counter\r\n\t\t//\r\n\t\tif(mBreakLastFrame)\r\n\t\t\tmTimeBreaking+=dt;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// determine break amount by table \r\n\t\t//\r\n\t\tif ( (getBreakFlags() & VBF_UseTable) )\r\n\t\t{\r\n\r\n\t\t\tif(mTimeBreaking < mBrakeMediumThresold)\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = getBrakeAmountFromTable(BL_Small);\r\n\t\t\t\terrMessage.Format(\"breaking at small : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\r\n\t\t\t}else if(mTimeBreaking >= mBrakeMediumThresold && mTimeBreaking < mBrakeHighThresold )\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = getBrakeAmountFromTable(BL_Medium);\r\n\t\t\t\terrMessage.Format(\"breaking at medium : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = getBrakeAmountFromTable(BL_High);\r\n\t\t\t\terrMessage.Format(\"breaking at high : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// use break pressures\r\n\t\t\t//\r\n\t\t\tfloat mCurrentBrakeTorque = getBrakeTorque()*0.01f;\r\n\t\t\tfloat AmountToBrakeFinal = 0.0f;\r\n\t\t\tif(mTimeBreaking < mBrakeMediumThresold)\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = mCurrentBrakeTorque * mBreakPressures[BL_Small];\r\n\t\t\t\terrMessage.Format(\"breaking at small : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\r\n\t\t\t}\r\n\t\t\telse if(mTimeBreaking >= mBrakeMediumThresold && mTimeBreaking < mBrakeHighThresold )\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = mCurrentBrakeTorque * mBreakPressures[BL_Medium];\r\n\t\t\t\terrMessage.Format(\"breaking at medium : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tbreakTorque = mCurrentBrakeTorque * mBreakPressures[BL_High];\r\n\t\t\t\terrMessage.Format(\"breaking at high : bt : %f at %f\",breakTorque,mTimeBreaking);\r\n\t\t\t\t//xInfo(errMessage.Str());\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif (breakTorque > 1000.f)\r\n\t\t\t{\r\n\t\t\t\tbreakTorque= 1000.0f;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t}else\r\n\t{\r\n\t\tmBreakLastFrame = false;\r\n\t\tmTimeBreaking = 0.0f;\r\n\t}\r\n\r\n\r\n\tperformAcceleration:\r\n\r\n\tif (breakTorque > 0.0f)\r\n\t{\r\n\t\tmBreakLastFrame = true;\r\n\t}\r\n\r\n\treturn breakTorque;\r\n}\r\nint pVehicle::_performAcceleration(float dt)\r\n{\r\n\r\n\tmotorTorque = 0.0f;\r\n\r\n\tif ( _nbTouching && _currentStatus & VS_IsAccelerated )\r\n\t{\r\n\t\tNxReal axisTorque = _computeAxisTorqueV2();\r\n\t\tNxReal wheelTorque = axisTorque / (NxReal)(_wheels.size() - _nbHandbrakeOn );\r\n\t\tNxReal wheelTorqueNotTouching = _nbNotTouching > 0 ? wheelTorque * ( NxMath::pow(0.5f, (NxReal) _nbNotTouching )):0;\r\n\t\tNxReal wheelTorqueTouching = wheelTorque - wheelTorqueNotTouching;\r\n\t\tmotorTorque = wheelTorqueTouching / (NxReal)_nbTouching; \r\n\t}else\r\n\t{\r\n\t\t_updateRpms();\r\n\t}\r\n\r\n\t\r\n\treturn 1;\r\n}\r\n\r\nvoid pVehicle::postStep()\r\n{\r\n\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++) \r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// determine break torque :\r\n\t\t//\r\n\r\n\t\t// is moving in the opposite direction than its accelerated \r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\twheel->tick( ( _currentStatus & VS_Handbrake) , motorTorque, breakTorque , _lastDT );\r\n\r\n\t}\r\n\r\n}\r\n\r\nvoid pVehicle::setBreakPressure(int breakLevel,float pressure)\r\n{\r\n\tmBreakPressures[breakLevel]=pressure;\r\n}\r\nvoid pVehicle::setBreakCaseLevel(pVehicleBreakCase breakCase,pVehicleBreakLevel level)\r\n{\r\n\tbreakConditionLevels[breakCase]=level;\r\n}\r\n\r\n// ( X * 10 * 60) / (5280* 12) * 100 = X * 0.9469696\r\n//return (-((10 * GetWheelSizeWidth() * NxPi * mOurWheels[BACK_LEFT]->getAxleSpeed() * 60) / (5280 * 12)) * 100);\r\n//return -0.9469696 * GetWheelSizeWidth() * NxPi * mOurWheels[BACK_LEFT]->getAxleSpeed();\r\n\r\nfloat pVehicle::getBrakeTorque()\r\n{\r\n\tint nbAWheels =0;\r\n\tfloat radius = 0.0;\r\n\tfloat axleSpeed = 0.0;\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_Accelerated))\r\n\t\t{\r\n\t\t\tnbAWheels++;\r\n\t\t\tif (wheel->getRadius() > radius)\r\n\t\t\t\tradius = wheel->getRadius();\r\n\r\n\t\t\tpWheel2* w2 = (pWheel2*)wheel;\r\n\t\t\tif (w2->getWheelShape()->getAxleSpeed() > axleSpeed)\r\n\t\t\t{\r\n\t\t\t\taxleSpeed = w2->getWheelShape()->getAxleSpeed();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif(fabs(axleSpeed) != 0)\r\n\t{\r\n\t\treturn ((5252 * getMotorForce()) / (fabs(axleSpeed) * 10));\r\n\t}\r\n\r\n\treturn 0.0f;\r\n}\r\n\r\nfloat pVehicle::getMPH(int type)\r\n{\r\n\r\n\tint nbAWheels =0;\r\n\tfloat radius = 0.0;\r\n\tfloat axleSpeed = 0.0;\r\n\tfor(NxU32 i = 0; i < _wheels.size(); i++)\r\n\t{\r\n\t\tpWheel* wheel = _wheels[i];\r\n\t\tif(wheel->getWheelFlag(WF_Accelerated))\r\n\t\t{\r\n\t\t\tnbAWheels++;\r\n\t\t\tif (wheel->getRadius() > radius)\r\n\t\t\t\tradius = wheel->getRadius();\r\n\r\n\t\t\tpWheel2* w2 = (pWheel2*)wheel;\r\n\t\t\tif (w2->getWheelShape()->getAxleSpeed() > axleSpeed)\r\n\t\t\t{\r\n\t\t\t\taxleSpeed = w2->getWheelShape()->getAxleSpeed();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t// ( X * 10 * 60) / (5280* 12) * 100 = X * 0.9469696\r\n\t//return (-((10 * GetWheelSizeWidth() * NxPi * mOurWheels[BACK_LEFT]->getAxleSpeed() * 60) / (5280 * 12)) * 100);\r\n\treturn 0.9469696 * radius * NxPi * axleSpeed;\r\n\r\n}\r\nvoid pVehicle::_controlAcceleration(float acceleration, bool analogAcceleration)\r\n{\r\n\tif(NxMath::abs(acceleration) < 0.001f)\r\n\t{\r\n\t\t_releaseBraking = true;\r\n\t\t//xInfo(\"set release breaking = true\");\r\n\t}\r\n\r\n\tif(!_braking)\r\n\t{\r\n\t\t_accelerationPedal = NxMath::clamp(acceleration, 1.f, -1.f);\r\n\t\t_brakePedalChanged = _brakePedal == 0;\r\n\t\t_brakePedal = 0;\r\n\t\t//xInfo(\"breaking = false : clamp accPedal 1|-1\");\r\n\t} else {\r\n\t\t//xInfo(\"breaking = true : accPeal = 0\");\r\n\t\t_accelerationPedal = 0;\r\n\t\tNxReal newv = NxMath::clamp(NxMath::abs(acceleration), 1.f, 0.f);\r\n\t\t_brakePedalChanged = _brakePedal == newv;\r\n\t\t_brakePedal = newv;\r\n\t}\r\n\tchar master[512];\r\n\tsprintf(master,\"Acceleration: %2.3f, Braking %2.3f\\n\", _accelerationPedal, _brakePedal);\r\n\txInfo(master);\r\n\t//OutputDebugString(master);\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n// vtAgeiaInterfaceToolbarDlg.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceEditor.h\"\r\n#include \"vtAgeiaInterfaceToolbarDlg.h\"\r\n\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nDllToolbarDlg*\tfCreateToolbarDlg(HWND parent)\r\n{\r\n\tHRESULT r = CreateDllDialog(parent,IDD_TOOLBAR,&g_Toolbar);\r\n\treturn (DllToolbarDlg*)g_Toolbar;\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceToolbarDlg dialog\r\n\r\n\r\nvtAgeiaInterfaceToolbarDlg::vtAgeiaInterfaceToolbarDlg(CWnd* pParent /*=NULL*/)\r\n\t: DllToolbarDlg(vtAgeiaInterfaceToolbarDlg::IDD, pParent)\r\n{\r\n\t//{{AFX_DATA_INIT(vtAgeiaInterfaceToolbarDlg)\r\n\t\t// NOTE: the ClassWizard will add member initialization here\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\n\r\nvoid vtAgeiaInterfaceToolbarDlg::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tDllToolbarDlg::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(vtAgeiaInterfaceToolbarDlg)\r\n\t\t// NOTE: the ClassWizard will add DDX and DDV calls here\r\n\t//}}AFX_DATA_MAP\r\n}\r\n\r\n\r\nBEGIN_MESSAGE_MAP(vtAgeiaInterfaceToolbarDlg, DllToolbarDlg)\r\n\t//{{AFX_MSG_MAP(vtAgeiaInterfaceToolbarDlg)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceToolbarDlg message handlers\r\n\r\nBOOL vtAgeiaInterfaceToolbarDlg::PreTranslateMessage(MSG* pMsg) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\tif (\r\n\t\tpMsg->message >= WM_MOUSEFIRST &&\r\n\t\tpMsg->message <= WM_MOUSELAST)\r\n\t{\r\n\t\tMSG msg;\r\n\t\t::CopyMemory(&msg, pMsg, sizeof(MSG));\r\n\t\tm_wndToolTip.RelayEvent(pMsg);\r\n\t}\r\n\t\r\n\treturn DllToolbarDlg::PreTranslateMessage(pMsg);\r\n}\r\n\r\nBOOL vtAgeiaInterfaceToolbarDlg::OnInitDialog() \r\n{\r\n\tDllToolbarDlg::OnInitDialog();\r\n\t\r\n\t// TODO: Add extra initialization here\r\n\t\r\n//\tEnableToolTips(TRUE);\r\n//\tCreateTooltip();\r\n\t\r\n\tActivateClosebutton();\r\n\treturn TRUE; // return TRUE unless you set the focus to a control\r\n\t // EXCEPTION: OCX Property Pages should return FALSE\r\n}\r\n\r\n//this is the almost equivalent of OnInitDialog you should use if you want to\r\n//use the PluginInterface with GetInterface or if you want to be sure the editor is present\r\nvoid vtAgeiaInterfaceToolbarDlg::OnInterfaceInit()\r\n{\r\n}\r\n\r\n//called on WM_DESTROY\r\nvoid vtAgeiaInterfaceToolbarDlg::OnInterfaceEnd() \r\n{\r\n}\r\n\r\nHRESULT vtAgeiaInterfaceToolbarDlg::ReceiveNotification(UINT MsgID,DWORD Param1,DWORD Param2,CKScene* Context)\r\n{\r\n\treturn 0;\r\n}\r\n\r\nvoid vtAgeiaInterfaceToolbarDlg::CreateTooltip()\r\n{\r\n\t//m_wndToolTip.Create(this);\r\n//\tm_wndToolTip.Activate(TRUE);\r\n\r\n\t//delay after which the tooltip apppear, value of 1 is immediate, 0 is default (that is 500 for windows)\r\n\t//m_wndToolTip.SetDelayTime(500);\r\n\r\n\t//change tooltip back color\r\n\t//m_wndToolTip.SetTipBkColor(CZC_176);\t\r\n\t//change tooltip text color\r\n\t//m_wndToolTip.SetTipTextColor(CZC_BLACK);\r\n\r\n\t//for each control you want to add a tooltip on, add the following line\r\n\t//m_wndToolTip.AddTool(CWnd* target,const char* tooltip_string);\r\n\r\n\t//delay after which the tooltip will auto close itself\r\n\t/*\r\n\tm_wndToolTip.SetDelayTime(TTDT_AUTOPOP,5000);\r\n\r\n\tm_wndToolTip.SetWindowPos(&(CWnd::wndTopMost),0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);\r\n\r\n\t//if you want multiline tooltip, you must add the following line (note that this represent the max tooltip width in pixel)\r\n\tm_wndToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, 500);\r\n\t*/\r\n}\r\n#include \"PCommonDialog.h\"\r\n#include \"PBodySetup.h\"\r\n#include \"PBXMLSetup.h\"\r\n#include \"resource.h\"\r\n#include \"VITabCtrl.h\"\r\n\r\n#include \"VIControl.h\"\r\n\r\n\r\n#define LAYOUT_STYLE\t\t\t(WS_CHILD|WS_VISIBLE)\r\n#define LAYOUT_ShaderREE\t\t130\r\n\r\n/*\r\nMultiParamEditDlg* CPBXMLSetup::refresh(CKParameter*src)\r\n{\treturn this;\t}\r\n*/\r\nvoid CPBXMLSetup::Init(CParameterDialog *parent){}\r\nCPBXMLSetup::~CPBXMLSetup(){\t_destroy();}\r\nvoid CPBXMLSetup::_destroy(){\t::CPSharedBase::_destroy();}\r\n\r\n/*\r\nCPBXMLSetup::CPBXMLSetup(\r\n\t\t\t\t\t CKParameter* Parameter,\r\n\t\t\t\t\t CK_CLASSID Cid)\t: \r\nCParameterDialog(Parameter,Cid) , \r\nCPSharedBase(this,Parameter)\r\n{\r\n\r\n\tsetEditedParameter(Parameter);\r\n}\r\n*/\r\n\r\n\r\nLRESULT CPBXMLSetup::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\r\n\tcase WM_LBUTTONDOWN:\r\n\tcase WM_LBUTTONDBLCLK:\r\n\t\t{\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\tcase WM_ERASEBKGND:\r\n\t\t{\r\n\t\t\t/*RECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);\r\n\t\t\tpDC->FillSolidRect(&r,RGB(200,200,200));\r\n\t\t\treturn 1;*/\r\n\t\t}break;\r\n\tcase CKWM_OK:\r\n\t\t{\r\n\t\t\t//CEdit *valueText = (CEdit*)GetDlgItem(IDC_EDIT);\r\n\t\t\t/*CString l_strValue;\r\n\t\t\tvalueText->GetWindowText(l_strValue);\r\n\r\n\t\t\tdouble d;\r\n\t\t\tif (sscanf(l_strValue,\"%Lf\",&d)) {\r\n\t\t\tparameter->SetValue(&d);\r\n\t\t\t}*/\r\n\t\t} break;\r\n\r\n\tcase CKWM_INIT:\r\n\t\t{\r\n\r\n\t\t\tRECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\t/*\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);*/\r\n\t\t\t//initSplitter();\r\n\t\t\tchar temp[64];\r\n\t\t\tdouble d;\r\n\t\t} break;\r\n\t}\r\n\treturn CDialog::WindowProc(message, wParam, lParam);\r\n}\r\n\r\nvoid CPBXMLSetup::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\r\n\t//CDialog::DoDataExchange(pDX);\r\n\tCParameterDialog::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CPBXMLSetup)\r\n\r\n\t//}}AFX_DATA_MAP\r\n\r\n}\r\n\r\n\r\n\r\nBEGIN_MESSAGE_MAP(CPBXMLSetup, CParameterDialog)\r\nEND_MESSAGE_MAP()\r\n\r\n#ifndef __VT_TOOLS_H__\r\n\t#define __VT_TOOLS_H__\r\n\r\n#include \"CKAll.h\"\r\n\r\n#ifndef _INC_STDLIB\r\n\t#include \r\n#endif\r\n\r\n#ifndef _VECTOR_\r\n\t#include \r\n#endif\r\n\r\n//#ifndef __VT_BB_MACROS_H__\r\n//\t#include \r\n//#endif\r\n\r\n//#ifndef __VT_BB_HELPER_H__\r\n//#include \r\n//#endif\r\nnamespace vtTools\r\n{\r\n\t/*************************************************************************/\r\n\t/* common enumerations\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/* \t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\tnamespace Enums\r\n\t{\r\n\t\t/*\r\n\t\t\tRepresents a virtools super type.\r\n\t\t\tSee GetVirtoolsSuperType.\r\n\t\t*/\r\n\t\tenum SuperType\r\n\t\t{\r\n\t\t\tvtSTRING = 1,\r\n\t\t\tvtFLOAT = 2,\r\n\t\t\tvtINTEGER = 3,\r\n\t\t\tvtVECTOR = 4,\r\n\t\t\tvtVECTOR2D = 5,\r\n\t\t\tvtCOLOUR = 6,\r\n\t\t\tvtMATRIX = 7,\r\n\t\t\tvtQUATERNION = 8,\r\n\t\t\tvtRECTANGLE\t\t= 9,\r\n\t\t\tvtBOX\t\t= 10,\r\n\t\t\tvtBOOL\t\t= 11,\r\n\t\t\tvtENUMERATION = 12,\r\n\t\t\tvtFLAGS = 13,\r\n\t\t\tvtFile = 14,\r\n\t\t\tvtOBJECT = 16,\r\n\t\t\tvtUNKNOWN = 17\r\n\t\t};\r\n \r\n\t\t/*\tAuthor: gunther.baumgart\r\n\t\t\tRepresents the c++ equivalent for TGBLWidgetType\r\n\t\t\tpm->RegisterNewEnum(EVTWIDGETTYPE,\"EVTWidgetType\",\r\n\t\t\t\"StaticText=1,\r\n\t\t\tTextEdit=2,\r\n\t\t\tCheckButton=4,\r\n\t\t\tPushButton=8,\r\n\t\t\tListBox=16,\r\n\t\t\tComboBox=32,\r\n\t\t\tFileSelector=64,\r\n\t\t\tColorSelector=128\" );\r\n\t\t*/\r\n\r\n\t\tenum EVTWidgetType\r\n\t\t{\r\n\t\t\tEVT_WIDGET_STATIC_TEXT\t\t= 1,\r\n\t\t\tEVT_WIDGET_EDIT_TEXT\t\t\t=2,\r\n\t\t\tEVT_WIDGET_CHECK_BUTTON =3,\r\n\t\t\tEVT_WIDGET_LIST_BOX\t\t\t=5,\r\n\t\t\tEVT_WIDGET_COMBO_BOX\t\t=6,\r\n\t\t\tEVT_WIDGET_FILE_SELECTION\t\t=7,\r\n\t\t\tEVT_WIDGET_COLOR_SELECTION\t=8\r\n\t\t};\r\n\r\n\t\t/*\r\n\r\n\t\t*/\r\n\r\n\t}/* end namespace typedefs */\r\n\r\n\t/*************************************************************************/\r\n\t/* common Structs\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace Structs\r\n\t{\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t/*\r\n\t\t\tParameterInfo is used to describe a virtools parameter type. \r\n\t\t\tExample : Matrix\t = horizontalItems = 4,\r\n\t\t\t\t\t\t\t\t\t\t\t verticalItems = 4\r\n\t\t\t\t\t\t\t\t\t\t\t memberType =vtFLOAT,\r\n\t\t\t\t\t\t\t\t\t\t\t superType= vtMATRIX\r\n\t\t*/\r\n\t\tstruct ParameterInfo\r\n\t\t{\r\n\t\t\tint horizontalItems;\r\n\t\t\tint verticalItems;\r\n\r\n\t\t\tEnums::SuperType superType;\r\n\t\t\tEnums::SuperType memberType;\r\n\r\n\t\t};\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t/*\r\n\t\t\tSGBL_WidgetInfo describes an parameter for using GBLWidgets\r\n\t\t\tGBL-Widgets. \r\n\t\t*/\r\n\t\tstruct WidgetInfo\r\n\t\t{\r\n\t\t\tstruct WidgetInfoItem\r\n\t\t\t{\t\r\n\t\t\t\tEnums::SuperType baseType;\r\n\t\t\t\tEnums::EVTWidgetType widgetType;\t\t//with which widget \r\n\t\t\t\tXString value;\r\n\t\t\t\tXString label;\r\n\r\n\t\t\t};\r\n\t\t\tXArrayitems;\r\n\t\t\tStructs::ParameterInfo parameterInfo;\r\n\t\t};\r\n\t}/* end namespace Structs */\r\n\r\n\t/************************************************************************/\r\n\t/* parameter tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace ParameterTools\t\r\n\t{\r\n\r\n\t\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: IsNumeric()\r\n\t\t*\r\n\t\t* Description :\t\tCheck each character of the string\r\n\t\t\t\t\t\t\t\t\tIf a character at a certain position is not a digit,\r\n\t\t\t\t\t\t\t\t\tthen the string is not a valid natural number\r\n\t\t\r\n\t\t* Parameters :\tchar*Str,r : the string to test\r\n\t\t* Returns : int\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tint IsNumeric(const char* Str,Enums::SuperType superType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterMemberInfo()\r\n\t\t*\r\n\t\t* Description :\tGetParameterMemberInfo returns the type super type of the used structure members.\r\n\t\t\t\t\t\t\t\tExample : vtVECTOR returns vtFLOAT \t\t\t\t\r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t* Returns : CO_EVT_VirtoolsSuperType\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tEnums::SuperType GetParameterMemberInfo(CKContext* context,CKParameterType parameterType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterInfo()\r\n\t\t*\r\n\t\t* Description :\tGetParameterInfo returns an info about a virtools type. \r\n\t\t\t\t\t\t\t\tExample : Vector4D returns :\r\n\t\t\t\t\t\t\t\tresult.horizontalItems = 4 ;\r\n\t\t\t\t\t\t\t\tresult.verticalItems = 1 ;\r\n\t\t\t\t\t\t\t\tresult.memberType = vtFLOAT\r\n\t\t\t\t\t\t\t\tresult.superType = vtQUATERNION; \r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t* Returns : ParameterInfo\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tStructs::ParameterInfo GetParameterInfo(CKContext* context,CKParameterType parameterType);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: CreateWidgetInfo()\r\n\t\t*\r\n\t\t* Description :\tCreateWidgetInfo returns an handy info about an parameter type and a\r\n\t\t\t\t\t\t\t\tgiven string value of this parameter.\r\n\r\n\t\t* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t\t\t\t\t\t\tXString stringValue,r : the string value of the given type.\r\n\r\n\t\t* Returns : WidgetInfo\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tStructs::WidgetInfo* CreateWidgetInfo(CKContext* context,CKParameterType parameterType,XString stringValue);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetWidgetType()\r\n\t\t*\r\n\t\t* Description :\tGetWidgetType returns the type of the GBLWidget which should used for a \r\n\t\t\t\t\t\t\t\tspecific virtools super type. \r\n\t\t\t\t\t\t\t\tExample : vtBOOL = CheckBox\r\n\t\t\t\t\t\t\t\t\t\t\t\tvtENUMERATION = ComboBox\r\n\t\t*\r\n\t\t* Parameters :\tCO_EVT_VirtoolsSuperType superType, r : the given virtools super type\r\n\t\t* Returns : EWidgetType\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tEnums::EVTWidgetType GetWidgetType(Enums::SuperType superType);\r\n\t\t/*\r\n\t\t *******************************************************************\r\n\t\t * Function: TypeCheckedParameterCopy()\r\n\t\t *\r\n\t\t * Description : Copies the source parameter to a destination parameter. On a type mismatch \r\n\t\t *\t\t\t\t\t\tit tries to copy as string. This also works for nested virtools structures. See \r\n\t\t\t\t\t\t\t\tCO_EVT_VirtoolsSuperType for supported types.\r\n\t\t *\r\n\t\t * Parameters :\tCKParameter*dest,rw : the destination parameter\r\n\t\t\t\t\t\t\t\t\tCKParameter*src,r : the source parameter\r\n\t\t * Returns : bool = true if succesful.\r\n\t\t * todo:: return copied diff\r\n\t\t *\r\n\t\t *******************************************************************\r\n\t\t*/\r\n\t\tint TypeCheckedParameterCopy( CKParameter*dest, CKParameter*src);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: GetParameterAsString()\r\n\t\t *\r\n\t\t * Description : Returns the string value a CKParameter.\r\n\t\t *\r\n\t\t * Parameters :\tCKParameter*src ,r the given parameter\r\n\t\t \r\n\t\t * Returns : CKSTRING \r\n\t\t *\r\n\t\t *******************************************************************\r\n\t\t */\r\n\t\t CKSTRING GetParameterAsString( CKParameter*src);\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: CompareStringRep()\r\n\t\t*\r\n\t\t* Description : This function compares the string representation of the two CKParameters.\r\n\t\t*\r\n\t\t* Parameters :\tCKParameter* valueA,r : the first parameter \r\n\t\t\t\t\t\t\t\tCKParameter* valueB,r : the second parameter \r\n\t\t* Returns : int (like strcmp)\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/\r\n\t\tint CompareStringRep(CKParameter*valueA, CKParameter*valueB);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetVirtoolsSuperType()\r\n\t\t*\r\n\t\t* Description : GetVirtoolsSuperType returns the base type of a virtools parameter. \r\n\t\t\t\t\t\t\t\tThis is very useful to determine whether a parameter can be used for \r\n\t\t\t\t\t\t\t\tnetwork or a database.\r\n\t\t*\r\n\t\t* Parameters : CKContext *ctx, r : the virtools context\r\n\t\t\t\t\t\t\t\t CKGUID guid, r : the guid of the parameter\r\n\t\t*\r\n\t\t* Returns : CO_EVT_VirtoolsSuperType, \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tEnums::SuperType GetVirtoolsSuperType(CKContext *ctx,const CKGUID guid);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function: TypeIsSerializable()\r\n\t\t* Description : Returns true if the given type can be stored as string. \r\n\t\t+ It also checks custom virtools structures recursive.\r\n\t\t+ it checks only\r\n\t\t*\r\n\t\t* Parameters :\t\tCKContext *ctx,\tr : the virtools context\r\n\t\tCKParameterType type,\tr : the type\r\n\t\t* Returns : bool \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tbool TypeIsSerializable(CKContext *ctx,CKParameterType type);\r\n\t\t/*\r\n\t\t\t*******************************************************************\r\n\t\t\t* Function: IsValidStruct()\r\n\t\t\t*\r\n\t\t\t* Description : Like TypeIsSerializable, even checks a custom virtools structure, recursive.\r\n\t\t\t*\r\n\t\t\t* Parameters :\t\tCKContext *ctx,r : the virtools context\r\n\t\t\t\t\t\t\t\t\t\tCKGUID type,r : the type to check\r\n\r\n\t\t\t* Returns : bool\r\n\t\t\t*\r\n\t\t\t*******************************************************************\r\n\t\t*/ \r\n\t\tbool IsValidStruct(CKContext *ctx,CKGUID type);\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:SetParameterStructureValue()\r\n\t\t*\r\n\t\t* Description : \tSets a specific value in a custom structure.\r\n\t\t*\r\n\t\t* Parameters : CKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structure\r\n\t\t\t\t\t\t\t\tT value, r : the value.\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : is a void \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplatevoid SetParameterStructureValue(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\r\n\t\t\tT value,\r\n\t\t\tbool update = TRUE\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tassert(par && StructurIndex>=0 );\r\n\t\t\tCK_ID* paramids = (CK_ID*)par->GetReadDataPtr(update);\r\n\t\t\tCKParameterOut *pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\tpout->SetValue(&value);\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:SetParameterStructureValue() \r\n\t\t*\r\n\t\t* Description : This is a template function specialization for CKSTRING.\r\n\t\t*\t\t\t\t\t\tSets a specific value in a custom structure.\r\n\t\t*\t\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structure\r\n\t\t\t\t\t\t\t\tT value, r : the value.\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : is a void \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline void SetParameterStructureValue\r\n\t\t\t(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\r\n\t\t\tCKSTRING value,\r\n\t\t\tbool update\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tassert(par && StructurIndex>=0 );\r\n\t\t\tstatic_cast(par->GetCKContext()->GetObject( static_cast(par->GetReadDataPtr(update))[StructurIndex]))->SetStringValue(value);\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetValueFromParameterStruct()\r\n\t\t*\r\n\t\t* Description : returns a object from a custom structure. \r\n\t\t*\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structures\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\t\t* Returns : T. \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromParameterStruct(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\t\r\n\t\t\tbool update=false)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tassert(par);\r\n\t\t\tCK_ID* paramids = static_cast(par->GetReadDataPtr(update));\t\r\n\t\t\tCKParameterOut* pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\tpout->GetValue(&value); \r\n\t\t\treturn value;\r\n\t\t}\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetValueFromParameterStruct()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKSTRING\r\n\t\t*\t\t\t\t\t\tGets a specific value from custom structure.\r\n\t\t*\r\n\t\t* Parameters : \tCKParameter *par,\t\t\t\tr : the virtools virtools parameter\r\n\t\t\t\t\t\t\t\tconst unsigned short StructurIndex,\tr : the index within the custom structures\r\n\t\t\t\t\t\t\t\tbool update,r : If this function is part of a virtools parameter operation, this \r\n\t\t\t\t\t\t\t\tshould set to false, otherwise it is an infinity loop.\r\n\r\n\t\t* Returns : CKSTRING. \r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKSTRING GetValueFromParameterStruct(\r\n\t\t\tCKParameter *par,\r\n\t\t\tconst unsigned short StructurIndex,\t\r\n\t\t\tbool update)\r\n\t\t{\r\n\t\t\tassert( par && StructurIndex >=0 );\r\n\t\t\tCK_ID* paramids = static_cast(par->GetReadDataPtr(update));\t\r\n\t\t\tCKParameterOut* pout = static_cast(par->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\tCKSTRING stringValue = static_cast(pout->GetReadDataPtr(update));\r\n\t\t\treturn stringValue;\r\n\r\n\t\t}\r\n\r\n\t\t__inline CKParameterOut* GetParameterFromStruct(CKParameter *par,const int index,bool update=false) \r\n\t\t{\r\n\t\t\tCK_ID* paramids = static_cast(par->GetReadDataPtr(update));\t\r\n\t\t\tif (paramids)\r\n\t\t\t{\r\n\t\t\t\treturn static_cast(par->GetCKContext()->GetObject(paramids[index]));\r\n\t\t\t}\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t} /*end namespace virtools parameter tools */\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* building block tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace BehaviorTools\t\r\n\t{\r\n\r\n\t\t\r\n\r\n\t\t\r\n\r\n\t\t__inline void Error(CKBehavior *beh,CKSTRING errorString,int errorOutputIndex,bool trigger=false,int outTrigger=0,bool outputOnConsole = false)\r\n\t\t{\r\n\t\t\tif(!beh)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tif(!strlen(errorString))\r\n\t\t\t\treturn;\r\n\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(errorOutputIndex);\r\n\t\t\tpout->SetStringValue(errorString);\r\n\t\t\tif (trigger)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(outTrigger);\r\n\t\t\t}\r\n\t\t\tCKContext* ctx = beh->GetCKContext();\r\n\t\t\tif(outputOnConsole && ctx)\r\n\t\t\t\tctx->OutputToConsole(errorString,FALSE);\r\n\r\n\t\t}\r\n\t\t__inline void Error(CKBehavior *beh,int error,int errorOutputIndex,CKSTRING errorString,bool trigger=false,int outTrigger=0,bool outputOnConsole = false)\r\n\t\t{\r\n\t\t\tif(!beh)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tbeh->SetOutputParameterValue(errorOutputIndex,&error);\r\n\t\t\tif (trigger)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(outTrigger);\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif(!strlen(errorString))\r\n\t\t\t\treturn;\r\n\r\n\t\t\tCKContext* ctx = beh->GetCKContext();\r\n\t\t\tif(outputOnConsole && ctx)\r\n\t\t\t\tctx->OutputToConsole(errorString,FALSE);\r\n\r\n\t\t}\r\n\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline void SetOutputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tT value)\r\n\t\t{\r\n\t\t\t#ifdef _DEBUG\r\n\t\t\t\tassert(beh);\r\n\t\t\t#endif\r\n\t\t\t\r\n\t\t\tT val = value;\r\n\t\t\tbeh->SetOutputParameterValue(pos,&val);\r\n\t\t}\r\n\r\n\t\ttemplate__inline void SetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tT value)\r\n\t\t{\r\n\t\t\tT val = value;\r\n\t\t\tCKParameterOut *inPar = (CKParameterOut*)(beh->GetInputParameter(pos)->GetRealSource());\r\n\t\t\tif (inPar)\r\n\t\t\t{\r\n\t\t\t\tinPar->SetValue(&val);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*\r\n\t\t*/\r\n\t\ttemplate<>__inline void SetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tCKSTRING val)\r\n\t\t{\r\n\t\t\tCKParameterIn*inPar = beh->GetInputParameter(pos);\r\n\t\t\tif (inPar && val && strlen(val) )\r\n\t\t\t{\r\n\t\t\t\tCKParameter*par = inPar->GetRealSource();\r\n\t\t\t\tif (par)\r\n\t\t\t\t\tpar->SetStringValue(val);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline void SetOutputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tCKSTRING val)\r\n\t\t{\r\n\t\t\t#ifdef _DEBUG\r\n\t\t\t\tassert(beh);\r\n\t\t\t#endif // _DEBUG\r\n\r\n\t\t\t\tif(strlen(val))\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(pos);\r\n\t\t\t\t\tif (pout)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tpout->SetStringValue(val);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t}\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline void SetOutputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tconst char *val)\r\n\t\t{\r\n\t\t\t#ifdef _DEBUG\r\n\t\t\t\t\t\tassert(beh);\r\n\t\t\t#endif // _DEBUG\r\n\t\t\tif(strlen(val))\r\n\t\t\t{\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(pos);\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpout->SetStringValue(const_cast(val));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\tT value ;\r\n\t\t\tbeh->GetInputParameterValue(pos,&value);\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : T\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetOutputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\tT value ;\r\n\t\t\tbeh->GetOutputParameterValue(pos,&value);\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description : This is a template function specialization for CKSTRING.\r\n\t\t\t\t\t\t\t Returns an input parameter value.\r\n\t\t*\r\n\t\t* Parameters : CKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKSTRING\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKSTRING GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\treturn static_cast(beh->GetInputParameterReadDataPtr(pos));\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t*******************************************************************\r\n\t\t* Function:GetInputParameterValue()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate<>__inline CKObject* GetInputParameterValue(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos)\r\n\t\t{\r\n\t\t\tassert(beh);\r\n\t\t\treturn beh->GetInputParameterObject(pos);\r\n\t\t}\r\n\r\n\t\tvoid __inline EnablePOutputBySettings(CKBehavior *beh,int index)\r\n\t\t{\r\n\t\t\tint cond;\r\n\t\t\tbeh->GetLocalParameterValue(index,&cond);\r\n\t\t\tbeh->EnableOutputParameter(index,cond);\r\n\t\t}\r\n\r\n\t\tvoid __inline EnablePInputBySettings(CKBehavior *beh,int index)\r\n\t\t{\r\n\t\t\tint cond;\r\n\t\t\tbeh->GetLocalParameterValue(index,&cond);\r\n\t\t\tbeh->EnableInputParameter(index,cond);\r\n\t\t}\r\n\r\n\t\t//void SetOutputParameterValueBySettings\r\n\r\n\t\t\r\n\t\ttemplate__inline T SetOutputParameterBySettings(\r\n\t\t\tCKBehavior *beh,\r\n\t\t\tconst int pos,\r\n\t\t\tT value)\r\n\t\t{\r\n\t\t\tint cond;\r\n\t\t\tbeh->GetLocalParameterValue(pos,&cond);\r\n\t\t\tif (cond)\r\n\t\t\t{\r\n\t\t\t\tSetOutputParameterValue(beh,pos,value);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\t\t//todo : parametric log / debug forwarding!!! - > g.baumgart !\r\n\t\t\r\n\t\t\r\n\r\n\t}/* end namespace behavior tools*/\r\n\r\n\r\n\t/**************************************************************************/\r\n\t/* attribute tools\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/* \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\tnamespace AttributeTools\r\n\t{\r\n\t\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T* GetObjectFromAttribute(CKContext *ctx,CKObject *_e,const int attributeID,const int StructurIndex)\r\n\t\t{\r\n\t\t\tT *value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tCK_ID* paramids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\tpout = (CKParameterOut*)ctx->GetObject(paramids[StructurIndex]);\r\n\t\t\tvalue = (T*)ctx->GetObject(*(CK_ID*)pout->GetReadDataPtr());\r\n\t\t\treturn value ? value : NULL;\r\n\t\t}\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline void SetAttributeValue(CKBeObject *_e,const int attributeID,const int StructurIndex,T* value)\r\n\t\t{\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif(pout)\r\n\t\t\t{\r\n\t\t\t\tCK_ID* paramids = (CK_ID*)pout->GetReadDataPtr();\r\n\t\t\t\tpout = (CKParameterOut*)_e->GetCKContext()->GetObject(paramids[StructurIndex]);\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpout->SetValue(value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\t\t\t\t\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\t\t\t\t\t\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromAttribute(CKBeObject *_e,int attributeID,int StructurIndex)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif (pout)\r\n\t\t\t{\r\n\t\t\t\tCK_ID* paramids = static_cast(pout->GetReadDataPtr());\r\n\t\t\t\tpout = static_cast(_e->GetCKContext()->GetObject(paramids[StructurIndex]));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpout->GetValue(&value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\t******************************************************************\r\n\t\t* Function:GetObjectFromAttribute()\r\n\t\t*\r\n\t\t* Description :\tThis is a template function specialization for CKBeObject*.\r\n\t\tReturns a input parameter value from a building block.\r\n\t\t*\r\n\t\t* Parameters :\t\tCKBehavior *beh,\tr : the behavior context\r\n\t\tconst unsigned short pos,\tr : the parameter input index\r\n\t\t* Returns : CKBeObject.\r\n\t\t*\r\n\t\t*******************************************************************\r\n\t\t*/ \r\n\t\ttemplate__inline T GetValueFromAttribute(CKBeObject *_e,int attributeID)\r\n\t\t{\r\n\t\t\tT value;\r\n\t\t\tCKParameterOut* pout = _e->GetAttributeParameter(attributeID);\r\n\t\t\tif (pout)\r\n\t\t\t{\r\n\t\t\t\tpout->GetValue(&value);\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t}\r\n\t\t\r\n\t}/* end namespace attribute tools*/\r\n}\r\n\r\n#endif\r\n#include \r\n\r\n#include \".\\GBLAsyncBlock.h\"\r\n\r\n\r\n/*\r\n *******************************************************************\r\n * Function: CKObjectDeclaration *FillBehaviour( void )\r\n *\r\n * Description : As its name infers, this function describes each Building Block\r\n * on a functional level : what it can be applied to, its GUID, its \r\n * creation function, etc.. \r\n *\t\t\r\n *\r\n * Paramters :\r\n * None\r\n *\r\n * Returns : CKObjectDeclaration *, containing:\r\n * - The type of object declaration ( Must Be CKDLL_BEHAVIORPROTOTYPE )\r\n * - The function that will create the CKBehaviorPrototype for this behavior.\r\n * - A short description of what the behavior is supposed to do.\r\n * - The category in which this behavior will appear in the Virtools interface.\r\n * - A unique CKGUID\r\n * - Author and Version info\r\n * - The class identifier of objects to which the behavior can be applied to.\r\n *\r\n *******************************************************************\r\n */\r\nCKObjectDeclaration * ExeInThread::FillBehaviour( void )\r\n{\r\n CKObjectDeclaration *objectDeclaration = CreateCKObjectDeclaration( \"ExecuteBBInThread\" );\t\r\n \r\n objectDeclaration->SetType( CKDLL_BEHAVIORPROTOTYPE );\r\n objectDeclaration->SetCreationFunction( ExeInThread::CreatePrototype );\r\n objectDeclaration->SetDescription( \"Executes a BB in a Thread\" );\r\n objectDeclaration->SetCategory( \"Narratives/Script Management\" );\r\n objectDeclaration->SetGuid( CKGUID( 0x72387e71,0x89d786d) );\r\n objectDeclaration->SetVersion( 0x00000001 );\r\n objectDeclaration->SetAuthorGuid( VTCX_AUTHOR_GUID );\r\n objectDeclaration->SetAuthorName( VTCX_AUTHOR );\r\n objectDeclaration->SetCompatibleClassId( CKCID_BEOBJECT );\r\n \r\n return objectDeclaration;\r\n}\r\n\r\n\r\n/*\r\n *******************************************************************\r\n * Function: CKERROR CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr )\r\n *\r\n * Description : The prototype creation function will be called the first time \r\n * a behavior must be created to create the CKBehaviorPrototype \r\n * that contains the description of the behavior.\r\n *\r\n * Paramters :\r\n * behaviorPrototypePtr w Pointer to a CKBehaviorPrototype object that \r\n * describes the behavior's internal structure \r\n * and relationships with other objects.\r\n *\r\n * Returns : CKERROR\r\n *\r\n *******************************************************************\r\n */\r\nCKERROR ExeInThread::CreatePrototype( CKBehaviorPrototype** behaviorPrototypePtr )\r\n{\r\n CKBehaviorPrototype *behaviorPrototype = CreateCKBehaviorPrototype( \"ExecuteBBInThread\" );\r\n if ( !behaviorPrototype ) \r\n {\r\n return CKERR_OUTOFMEMORY;\r\n }\r\n \r\n\t//--- Inputs declaration\r\n\tbehaviorPrototype->DeclareInput( \"In\" );\r\n\r\n\t//--- Outputs declaration\r\n\tbehaviorPrototype->DeclareOutput( \"Out\" );\r\n\r\n\r\n\r\n //----\tLocal Parameters Declaration\r\n\r\n\tbehaviorPrototype->DeclareLocalParameter(\"thethread\", CKPGUID_POINTER, \"0\");\r\n\tbehaviorPrototype->DeclareLocalParameter(\"thestatus\", CKPGUID_INT, \"0\");\r\n\r\n\r\n \r\n //----\tSettings Declaration\r\n\r\n\tbehaviorPrototype->SetBehaviorCallbackFct( ExeInThread::CallBack, CKCB_BEHAVIORATTACH|CKCB_BEHAVIORDETACH|CKCB_BEHAVIORDELETE|CKCB_BEHAVIOREDITED|CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORPRESAVE|CKCB_BEHAVIORPOSTSAVE|CKCB_BEHAVIORRESUME|CKCB_BEHAVIORPAUSE|CKCB_BEHAVIORRESET|CKCB_BEHAVIORRESET|CKCB_BEHAVIORDEACTIVATESCRIPT|CKCB_BEHAVIORACTIVATESCRIPT|CKCB_BEHAVIORREADSTATE, NULL );\r\n behaviorPrototype->SetFunction( ExeInThread::BehaviourFunction );\r\n \r\n *behaviorPrototypePtr = behaviorPrototype;\r\n return CK_OK;\r\n}\r\n\r\n/*\r\n *******************************************************************\r\n * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )\r\n *\r\n * Description : The execution function is the function that will be called \r\n * during the process loop of the behavior engine, if the behavior \r\n * is defined as using an execution function. This function is not \r\n * called if the behavior is defined as a graph. This function is the \r\n * heart of the behavior: it should compute the essence of the behavior, \r\n * in an incremental way. The minimum amount of computing should be \r\n * done at each call, to leave time for the other behaviors to run. \r\n * The function receives the delay in milliseconds that has elapsed \r\n * since the last behavioral process, and should rely on this value to \r\n * manage the amount of effect it has on its computation, if the effect \r\n * of this computation relies on time.\r\n *\r\n * Paramters :\r\n * behaviourContext r Behavior context reference, which gives access to \r\n * frequently used global objects ( context, level, manager, etc... )\r\n *\r\n * Returns : int, If it is done, it should return CKBR_OK. If it returns \r\n * CKBR_ACTIVATENEXTFRAME, the behavior will again be called \r\n * during the next process loop.\r\n *\r\n *******************************************************************\r\n */\r\nint ExeInThread::BehaviourFunction( const CKBehaviorContext& behaviorContext )\r\n{\r\n\tCKBehavior* beh = behaviorContext.Behavior;\r\n\tCKContext* ctx = beh->GetCKContext();\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tVxThread *VXT; \r\n\r\n\t\tint status = 0;\r\n\t\tbeh->GetLocalParameterValue(1,&status);\r\n\r\n\t\tif (status == ThreadStatus::Requested)\r\n\t\t{\t\r\n\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t}\r\n\r\n\t\tif (status == ThreadStatus::Active)\r\n\t\t{\t\r\n\t\t\tstatus = ThreadStatus::Requested;\r\n\t\t\tbeh->SetLocalParameterValue(1,&status);\r\n\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t}\r\n\r\n\t\tVXT = new VxThread();\r\n\t\tVXT->SetName(\"Thread\");\t\r\n\t\tVXT->SetPriority(VXTP_NORMAL);\t\t\r\n\t\tAsyncThreadInfo * threadInfo;\r\n\r\n\t\tthreadInfo = new AsyncThreadInfo;\r\n\r\n\t\tthreadInfo->targetBeh = NULL;\r\n\r\n\t\tint count = beh->GetParent()->GetSubBehaviorLinkCount();\r\n\r\n\t\tfor (int i=0; iGetParent()->GetSubBehaviorLink(i);\r\n\t\t\tif (link->GetInBehaviorIO() == beh->GetOutput(0))\r\n\t\t\t{\r\n\t\t\t\tthreadInfo->targetBeh = link->GetOutBehaviorIO()->GetOwner();\r\n\r\n\t\t\t\tint targetInputs = threadInfo->targetBeh->GetInputCount();\r\n\t\t\t\tif (targetInputs == 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tthreadInfo->targetInputToActivate = 0;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (int j=0; jGetOutBehaviorIO() == threadInfo->targetBeh->GetInput(j))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthreadInfo->targetInputToActivate = j;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (threadInfo->targetBeh == NULL)\r\n\t\t{\r\n\t\t\tdelete threadInfo;\r\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t}\r\n\r\n\t\tVXT->CreateThread(BlockingThreadFunction,threadInfo);\r\n\t\tbeh->SetLocalParameterValue(0,&VXT,sizeof(VxThread *));\r\n\r\n\t\tstatus = ThreadStatus::Active;\r\n\t\tbeh->SetLocalParameterValue(1,&status);\r\n\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n\t}\r\n\telse\r\n\t{\r\n\t\tVxThread *VXT; \r\n\t\tbeh->GetLocalParameterValue(0,&VXT);\r\n\r\n\t\tunsigned int status = -1;\r\n\r\n\t\tVXT->GetExitCode(status);\r\n\r\n\t\tif (status == VXT_OK)\r\n\t\t{\r\n\t\t\tVXT->Close();\r\n\t\t\tdelete VXT;\r\n\t\t\tVXT=NULL;\r\n\t\t\tbeh->SetLocalParameterValue(0,&VXT);\r\n\r\n\t\t\t\r\n\r\n\t\t\tint status;\r\n\t\t\tbeh->GetLocalParameterValue(1,&status);\r\n\t\r\n\t\t\tif (status == ThreadStatus::Requested)\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateInput(0);\r\n\t\t\t\tstatus = ThreadStatus::Idle;\r\n\t\t\t\tbeh->SetLocalParameterValue(1,&status);\r\n\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tstatus = ThreadStatus::Idle;\r\n\t\t\tbeh->SetLocalParameterValue(1,&status);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: int Callback( const CKBehaviorContext& behaviorContext )\r\n*\r\n* Description : The Behavior Callback function is called by Virtools when various events happen \r\n* in the life of a BuildingBlock. Exactly which events trigger a call to the \r\n* Behavior Callback function is defined in the Behavior Prototype, along with the \r\n* declaration of the function pointer \r\n*\r\n* Parameters :\r\n* behaviourContext r Behavior context reference, which gives \r\n* access to frequently used global objects \r\n* ( context, level, manager, etc... )\r\n*\r\n* Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values.\r\n*\r\n*******************************************************************\r\n*/\r\nint ExeInThread::CallBack( const CKBehaviorContext& behaviorContext )\r\n{\r\n\tswitch ( behaviorContext.CallbackMessage )\r\n\t{\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORDELETE:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIOREDITED:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORPRESAVE:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORPOSTSAVE:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORRESUME:\r\n\t\t{\r\n\t\t\tint status = ThreadStatus::Idle;\r\n\t\t\tbehaviorContext.Behavior->SetLocalParameterValue(1,&status);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\tcase CKM_BEHAVIORPAUSE:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORRESET:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORNEWSCENE:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORACTIVATESCRIPT:\r\n\t\t\tbreak;\r\n\t\tcase CKM_BEHAVIORREADSTATE:\r\n\t\t\tbreak;\r\n\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nunsigned int BlockingThreadFunction(void *arg)\r\n{\r\n\tExeInThread::AsyncThreadInfo* threadInfo = (ExeInThread::AsyncThreadInfo*)arg;\r\n\r\n\tthreadInfo->targetBeh->ActivateInput(threadInfo->targetInputToActivate);\r\n\r\n\tint res;\r\n\r\n\tdo\r\n\t{\r\n\t\tres = threadInfo->targetBeh->Execute(0);\r\n\t}\r\n\twhile (res == CKBR_ACTIVATENEXTFRAME);\r\n\tdelete threadInfo;\r\n\treturn VXT_OK;\r\n}\r\n\r\n\r\n#include \"CKAll.h\"\r\nCKObjectDeclaration\t*FillBehaviorSetMousPosDecl();\r\n\r\nCKERROR CreateSetMousPosProto(CKBehaviorPrototype **pproto);\r\nint SetMousPos(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetMousPosDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"SetMousePos\");\t\r\n\tod->SetCategory(\"Narratives/Mouse\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7938083c,0x32f03a3d));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetMousPosProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateSetMousPosProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"SetMousePos\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Create Zip File\");\r\n\r\n\t\r\n\tproto->DeclareOutput(\"Zip File created\");\r\n\r\n\tproto->DeclareInParameter(\"IsServer\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"IsServer\",CKPGUID_FLOAT);\r\n\t\t\r\n\tproto->DeclareOutParameter(\"UP\",CKPGUID_INT);\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetMousPos);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n#include \r\n\r\nint SetMousPos(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\tif( beh->IsInputActive(0) ){\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n DWORD data = 0;\r\n DWORD flags = MOUSEEVENTF_ABSOLUTE;\r\n \r\n // - Has the pointer moved since the last event?\r\n \r\n \r\n flags |= MOUSEEVENTF_MOVE;\r\n\r\n mouse_event(flags, 100,100, data, 0);\r\n \r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n}\r\n#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n\r\n#include \"tnlRandom.h\"\n#include \"tnlSymmetricCipher.h\"\n#include \"tnlAsymmetricKey.h\"\r\n\r\n#include \"xNetworkTypes.h\"\r\n\r\nextern xNetInterface* GetNetInterfaceServer();\r\nextern xNetInterface *GetNetInterfaceClient();\r\nextern void SetNetInterfaceClient(xNetInterface *cInterface);\r\nextern void SetNetInterfaceServer(xNetInterface *cInterface);\r\n\r\n\r\nvoid vtNetworkManager::SetClientNetInterface(xNetInterface *cinterface) {\tSetNetInterfaceClient(cinterface);}\r\nvoid vtNetworkManager::SetServerNetInterface(xNetInterface *cinterface){\t SetNetInterfaceServer(cinterface); }\r\n\r\n\r\nxNetInterface* vtNetworkManager::GetServerNetInterface() { return GetNetInterfaceServer(); }\r\nxNetInterface*vtNetworkManager::GetClientNetInterface(){ \treturn GetNetInterfaceClient(); }\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\nvoid vtNetworkManager::DeleteServer(int flags)\r\n{\r\n\r\n\r\n\r\n}\r\n#ifndef _BASE_\r\n#define _BASE_\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n\r\nextern \"C\" {\r\n#include \r\n#include \r\n#include \r\n#include \r\n//#include \r\n}\r\n\r\n// instantiate unit tests\r\n#ifdef DEBUG\r\n#define INSTANTIATE_TEST_SUITES2\r\nextern bool _abortOnAssertionFailure;\r\n#endif\r\n\r\n\r\nnamespace base {\r\n typedef unsigned char Byte;\r\n typedef int SInt;\r\n typedef unsigned int Int;\r\n typedef long unsigned int LInt;\r\n typedef std::string String;\r\n typedef double Real; // Real & GLreal must be the same built-in type\r\n\r\n /// throw a std::runtime_error(errorstring). If DEBUG, output an assertion failure message\r\n /// to the Log and abort() if abortOnAssertionFailure mode set\r\n void assertionFailure(const String& errorstring);\r\n\r\n template inline void tassert(A assertion, const String& errorstring)\r\n {\r\n if (!assertion)\r\n assertionFailure(errorstring);\r\n }\r\n\r\n template void clearMemory(T* start, Int length)\r\n { memset(start, 0, size_t(length*sizeof(T))); }\r\n\r\n template void copyMemory(const T* src, T* dest, Int length)\r\n { memcpy(dest, src, length*sizeof(T)); }\r\n\r\n // convenience: subscripting & indexing for list ( O(n) )\r\n template const T& elementAt(const std::list& l, typename std::list::size_type i)\r\n {\r\n typename std::list::const_iterator it = l.begin();\r\n while ((it != l.end()) && (i > 0)) {\r\n ++it; --i;\r\n }\r\n if (it == l.end()) throw std::out_of_range(\"elementAt - specified index not present\");\r\n return *it;\r\n }\r\n\r\n template T& elementAt(std::list& l, typename std::list::size_type i)\r\n {\r\n typename std::list::iterator it = l.begin();\r\n while ((it != l.end()) && (i > 0)) {\r\n ++it; --i;\r\n }\r\n if (it == l.end()) throw std::out_of_range(\"elementAt - specified index not present\");\r\n return *it;\r\n }\r\n\r\n\r\n\r\n class DeleteObject {\r\n public:\r\n template void operator()(const T* ptr) const { delete ptr; }\r\n };\r\n\r\n template void delete_all(C& c)\r\n {\r\n for_all(c, DeleteObject());\r\n }\r\n\r\n\r\n template\r\n OutputIterator copy_if(InputIterator begin, InputIterator end,\r\n\t\t\t OutputIterator destBegin, Predicate p)\r\n {\r\n while(begin!=end) {\r\n if (p(*begin)) *destBegin++=*begin;\r\n ++begin;\r\n }\r\n return destBegin;\r\n }\r\n\r\n String intToString(Int i);\r\n String realToString(Real r);\r\n Int stringToInt(const String& s);\r\n Real stringToReal(const String& s);\r\n\r\n template String toString(const T& t)\r\n {\r\n std::ostringstream oss;\r\n oss << t;\r\n return oss.str();\r\n }\r\n\r\n template T fromString(const String& s)\r\n {\r\n std::istringstream iss(s);\r\n T t;\r\n iss >> t;\r\n return t;\r\n }\r\n\r\n\r\n\r\n class Cloneable;\r\n template C& clone(const C& c)\r\n {\r\n return dynamic_cast( static_cast(c).clone());\r\n }\r\n\r\n#ifndef VIRTOOLS\r\n\r\n extern std::ostream& _Debug;\r\n extern std::ostream& _Log;\r\n extern std::ostream& _Console;\r\n#else\r\n\r\n extern std::ostream& _Debug;\r\n extern std::ostream& _Log;\r\n extern std::ostream& _Console;\r\n\r\n#endif\r\n\r\n /// convert typeid().name() string into demangled form (e.g. \"base::Object\")\r\n String demangleTypeidName(const String& typeidName);\r\n\r\n /// convert type_info into qualified class name (calls demangleTypeidName() )\r\n String className(const std::type_info& ti);\r\n\r\n extern int _currentDebugVerbosity;\r\n\r\n // make narrow casting explicit for readability\r\n template <\r\n typename Sub,\r\n typename Super>\r\n //inline Sub* narrow_cast(Select< SUPERSUBCLASS_STRICT(Super,Sub),Super*,NullType>::Result p) { return static_cast(p); }\r\n inline Sub* narrow_cast(Super* p) { return static_cast(p); }\r\n\r\n template <\r\n typename Sub,\r\n typename Super>\r\n //inline Sub& narrow_cast(Select< SUPERSUBCLASS_STRICT(Super,Sub),Super&,NullType>::Result p) { return static_cast(p); }\r\n inline Sub& narrow_cast(Super& p) { return static_cast(p); }\r\n\r\n} // base\r\n\r\n\r\n\r\n\r\n\r\n// global names\r\nusing std::for_each;\r\nusing std::mem_fun;\r\nusing base::narrow_cast;\r\n\r\n\r\n\r\n\r\n// Use Log() funcions to output to the log file. This will remain in\r\n// release code. Use Debug() if you want output that will dissapear\r\n// in release code. Use Console() to write on the graphical console\r\n// (e.g. for user status messages etc.)\r\n// NB: see debugtools header for Debug() usage.\r\n\r\n//#include \r\n\r\n#ifdef __mips\r\n#define __func__ String(\"unknown\")\r\n#endif\r\n\r\n#ifdef __GNUC_\r\n#define _LOG_CALLER_NAME __PRETTY_FUNCTION__ << \" -- \"\r\n#else\r\n#define _LOG_CALLER_NAME base::className(typeid(*this)) << \"::\" << __FUNCTION__ << \" -- \"\r\n#endif\r\n\r\n#define Log(o) { base::_Log << _LOG_CALLER_NAME << o; }\r\n#define Logln(o) { base::_Log << _LOG_CALLER_NAME << o << \"\\n\"; }\r\n#define Logc(o) { base::_Log << o; }\r\n#define Logcln(o) { base::_Log << o << \"\\n\"; }\r\n\r\n#define Logf(o) { base::_Log << __func__ << \" -- \" << o; }\r\n#define Logfln(o) { base::_Log << __func__ << \" -- \" << o << \"\\n\"; }\r\n#define Logfc(o) Logc(o)\r\n#define Logfcln(o) Logcln(o)\r\n\r\n\r\n#define Console(o) { base::_Console << o; }\r\n#define Consoleln(o) { base::_Console << o << std::endl; }\r\n\r\n// Often, when an Assert() fails, it is not clear where the exception\r\n// was raised from the message alone. Enabling this flag will cause\r\n// the program to abort() from inside Assert() so that a debugger\r\n// stack trace can show the point of failure.\r\n#ifdef DEBUG\r\n extern bool _abortOnAssertionFailure;\r\n #define abortOnAssertionFailureEnabled(e) _abortOnAssertionFailure=(e)\r\n#else\r\n #define abortOnAssertionFailureEnabled(e)\r\n#endif\r\n\r\n\r\n// During development it is not unusual for exceptions to be thrown in unexpected places. For example,\r\n// from a function declared with throw(). It also happens when an exception tries to propagate\r\n// through C code in the call stack. For example, this is common if the main loop of the app\r\n// is being executed from a C library callback (e.g. from GLUT).\r\n// This typically results in a call to abort() before the exception is caught. The only way to trace where\r\n// the exception was thrown in that case is via the debugger. To make life a little easier, in DEBUG mode\r\n// the Exception() macro is defined to print the exception text upon construction - so it can be seen even if\r\n// the exception is not caught. However, this can be annoying in circumstances when exceptions are\r\n// expected (for example, in test cases that test for correct exception throwing). Consequently, it may\r\n// be disabled.\r\n#ifdef DEBUG\r\n extern bool _outputExceptionOnConstruction;\r\n #define exceptionOutputEnabled(e) _outputExceptionOnConstruction=(e)\r\n#else\r\n #define exceptionOutputEnabled(e)\r\n#endif\r\n\r\n\r\n\r\n#ifdef __GNUC__\r\n\r\n #ifdef DEBUG\r\n #define Exception(o) (( (_outputExceptionOnConstruction?(printf(\"constructing exception: %s\\n\", \\\r\n (String(__PRETTY_FUNCTION__)+\" (line \"+base::intToString(__LINE__)+\") - \"+String(o)).c_str())):(0)) ), \\\r\n String(String(\"exception thrown: \")+__PRETTY_FUNCTION__+\":\\n - \"+String(o)))\r\n\r\n\r\n #else // ndef DEBUG\r\n #define Exception(o) String(String(\"exception thrown: \")+__PRETTY_FUNCTION__+\" - \"+String(o))\r\n #endif // DEBUG\r\n\r\n #define Exceptionf(o) String(String(\"exception thrown: \")+__PRETTY_FUNCTION__+\":\\n - \"+String(o))\r\n #define Assertion(o) String(String(\"assertion failed: \")+__PRETTY_FUNCTION__+\" (line \"+base::intToString(__LINE__)+\") - \"+String(o))\r\n #define Assertionf(o) String(String(\"assertion failed: \")+__PRETTY_FUNCTION__+\" (line \"+base::intToString(__LINE__)+\") - \"+String(o))\r\n\r\n\r\n#else // ndef __GNUC__\r\n\r\n #ifdef DEBUG\r\n #define Exception(o) (( (_outputExceptionOnConstruction?(printf(\"constructing exception: %s\\n\", \\\r\n (String(base::className(typeid(*this)))+\"::\"+String(__func__)+\" - \"+String(o)).c_str())):(0) )), \\\r\n String(String(\"exception thrown: \")+String(base::className(typeid(*this)))+\"::\"+String(__func__)+\":\\n - \"+String(o)))\r\n #else\r\n #define Exception(o) String(String(\"exception thrown: \")+String(base::className(typeid(*this)))+\"::\"+String(__func__)+\":\\n - \"+String(o))\r\n #endif\r\n #define Exceptionf(o) String(String(\"exception thrown: \")+String(__func__)+\":\\n - \"+String(o))\r\n #define Assertion(o) String(String(\"assertion failed: \")+String(base::className(typeid(*this)))+\"::\"+String(__func__)+\" - \"+String(o))\r\n #define Assertionf(o) String(String(\"assertion failed: \")+String(__func__)+\" - \"+String(o))\r\n\r\n#endif // __GNUC__\r\n\r\n#ifdef DEBUG\r\n\r\n #define Assert(a) { if (!(a)) base::assertionFailure(Assertion(#a)); }\r\n #define Assertf(a) { if (!(a)) base::assertionFailure(Assertionf(#a)); }\r\n #define Assertm(a,s) { if (!(a)) base::assertionFailure(Assertion(s)); }\r\n #define Assertmf(a,s) { if (!(a)) base::assertionFailure(Assertionf(s)); }\r\n#else // ndef DEBUG\r\n #define Assert(a)\r\n #define Assertf(a)\r\n #define Assertm(a,s)\r\n #define Assertmf(a,s)\r\n#endif // DEBUG\r\n\r\n#define Assertifm(f,a,s) Assertm(!f || a,s)\r\n#define Assertifmf(f,a,s) Assertmf(!f || a,s)\r\n\r\n#define instanceof(var,type) (dynamic_cast(&var) != 0)\r\n\r\n\r\n#endif\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Noise\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNoiseDecl();\r\nCKERROR CreateNoiseProto(CKBehaviorPrototype **);\r\nint Noise(const CKBehaviorContext& behcontext);\r\n//CKERROR MeshModificationsCallBack(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNoiseDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Noise2\");\t\r\n\tod->SetDescription(\"Displaces the vertices of the mesh with a random vector.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tSeed: generates a random starting point from the number you set.
\r\n\tScale: size of noise effect (not strength).
\r\n\tAxis: strength of the noise effect along each of three axes.
\r\n\tReset Mesh: if TRUE, the mesh is reseted to its initial conditions at activation.
\r\n\t*/\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6d300730,0x26c83f42));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00020000);\r\n\tod->SetCreationFunction(CreateNoiseProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Mesh Modifications/Deformation\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNoiseProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"Noise2\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Seed\", CKPGUID_FLOAT,\"0.1\" );\r\n\tproto->DeclareInParameter(\"Scale\", CKPGUID_FLOAT ,\"50.0\");\r\n\t// To change by Radio buttons\r\n\tproto->DeclareInParameter(\"Axis\", CKPGUID_VECTOR, \"0.1,0,0\" );\r\n\tproto->DeclareInParameter(\"Reset Mesh\", CKPGUID_BOOL, \"TRUE\" );\r\n\r\n\r\n\tproto->DeclareInParameter(\"target\", CKPGUID_3DENTITY);\r\n\r\n\r\n\tproto->DeclareLocalParameter(\"data\", CKPGUID_VOIDBUF );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Noise);\r\n\r\n\t//proto->SetBehaviorCallbackFct(MeshModificationsCallBack);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n#define B 0x100\r\n#define BM 0xff\r\n\r\n#define N 0x1000\r\n#define NP 12 /* 2^N */\r\n#define NM 0xfff\r\n\r\nstatic int p[B + B + 2];\r\nstatic float g3[B + B + 2][3];\r\nstatic float g2[B + B + 2][2];\r\nstatic float g1[B + B + 2];\r\nstatic int start = 1;\r\n\r\nstatic void init(void);\r\n\r\n#define s_curve(t) ( t * t * (3.0f - 2.0f * t) )\r\n\r\n#define lerp(t, a, b) ( a + t * (b - a) )\r\n\r\n#define setup(i,b0,b1,r0,r1)\\\r\n\tt = vec[i] + N;\\\r\n\tb0 = ((int)t) & BM;\\\r\n\tb1 = (b0+1) & BM;\\\r\n\tr0 = t - (int)t;\\\r\n\tr1 = r0 - 1.0f;\r\n\r\nfloat noise3(const VxVector &vect)\r\n{\r\n\tconst float *vec = vect.v;\r\n\tint bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;\r\n\tfloat rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;\r\n\tregister int i, j;\r\n\r\n\tif (start) {\r\n\t\tstart = 0;\r\n\t\tinit();\r\n\t}\r\n\r\n\tsetup(0, bx0,bx1, rx0,rx1);\r\n\tsetup(1, by0,by1, ry0,ry1);\r\n\tsetup(2, bz0,bz1, rz0,rz1);\r\n\r\n\ti = p[ bx0 ];\r\n\tj = p[ bx1 ];\r\n\r\n\tb00 = p[ i + by0 ];\r\n\tb10 = p[ j + by0 ];\r\n\tb01 = p[ i + by1 ];\r\n\tb11 = p[ j + by1 ];\r\n\r\n\tt = s_curve(rx0);\r\n\tsy = s_curve(ry0);\r\n\tsz = s_curve(rz0);\r\n\r\n#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )\r\n\r\n\tq = g3[ b00 + bz0 ] ; u = at3(rx0,ry0,rz0);\r\n\tq = g3[ b10 + bz0 ] ; v = at3(rx1,ry0,rz0);\r\n\ta = lerp(t, u, v);\r\n\r\n\tq = g3[ b01 + bz0 ] ; u = at3(rx0,ry1,rz0);\r\n\tq = g3[ b11 + bz0 ] ; v = at3(rx1,ry1,rz0);\r\n\tb = lerp(t, u, v);\r\n\r\n\tc = lerp(sy, a, b);\r\n\r\n\tq = g3[ b00 + bz1 ] ; u = at3(rx0,ry0,rz1);\r\n\tq = g3[ b10 + bz1 ] ; v = at3(rx1,ry0,rz1);\r\n\ta = lerp(t, u, v);\r\n\r\n\tq = g3[ b01 + bz1 ] ; u = at3(rx0,ry1,rz1);\r\n\tq = g3[ b11 + bz1 ] ; v = at3(rx1,ry1,rz1);\r\n\tb = lerp(t, u, v);\r\n\r\n\td = lerp(sy, a, b);\r\n\r\n\treturn lerp(sz, c, d);\r\n}\r\n\r\nstatic void normalize2(float v[2])\r\n{\r\n\tfloat s;\r\n\r\n\ts = 1.0f / sqrtf(v[0] * v[0] + v[1] * v[1]);\r\n\tv[0] = v[0] * s;\r\n\tv[1] = v[1] * s;\r\n}\r\n\r\nstatic void normalize3(float v[3])\r\n{\r\n\tfloat s;\r\n\r\n\ts = 1.0f / sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);\r\n\tv[0] = v[0] * s;\r\n\tv[1] = v[1] * s;\r\n\tv[2] = v[2] * s;\r\n}\r\n\r\nstatic void init(void)\r\n{\r\n\tint i, j, k;\r\n\r\n\tfor (i = 0 ; i < B ; i++) {\r\n\t\tp[i] = i;\r\n\r\n\t\tg1[i] = (float)((rand() % (B + B)) - B) / B;\r\n\r\n\t\tfor (j = 0 ; j < 2 ; j++)\r\n\t\t\tg2[i][j] = (float)((rand() % (B + B)) - B) / B;\r\n\t\tnormalize2(g2[i]);\r\n\r\n\t\tfor (j = 0 ; j < 3 ; j++)\r\n\t\t\tg3[i][j] = (float)((rand() % (B + B)) - B) / B;\r\n\t\tnormalize3(g3[i]);\r\n\t}\r\n\r\n\twhile (--i) {\r\n\t\tk = p[i];\r\n\t\tp[i] = p[j = rand() % B];\r\n\t\tp[j] = k;\r\n\t}\r\n\r\n\tfor (i = 0 ; i < B + 2 ; i++) {\r\n\t\tp[B + i] = p[i];\r\n\t\tg1[B + i] = g1[i];\r\n\t\tfor (j = 0 ; j < 2 ; j++)\r\n\t\t\tg2[B + i][j] = g2[i][j];\r\n\t\tfor (j = 0 ; j < 3 ; j++)\r\n\t\t\tg3[B + i][j] = g3[i][j];\r\n\t}\r\n}\r\n\r\nint Noise(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\t\r\n\t// we get the 3d entity\r\n\tCK3dEntity *ent = (CK3dEntity *) beh->GetInputParameterObject(4);\r\n\tif(!ent) return 0;\r\n\t\r\n\t// we get the seed value\r\n\tfloat seed=0.1f;\r\n\tCKParameterIn *pin = beh->GetInputParameter(0);\r\n\tif( pin->GetGUID() == CKPGUID_INT ){ // back compatibility\r\n\t\tint seed_int = 0;\r\n\t\tpin->GetValue( &seed_int );\r\n\t\tseed = (float)seed_int;\r\n\t}\telse {\r\n\t\tbeh->GetInputParameterValue(0,&seed);\r\n\t}\r\n\tseed *= 0.01f;\r\n\t\r\n\t// we get the scale value\r\n\tfloat scale;\r\n\tbeh->GetInputParameterValue(1,&scale);\r\n\t\r\n\t// we get the amount value\r\n\tVxVector axis;\r\n\tbeh->GetInputParameterValue(2,&axis);\r\n\t\r\n\t// we get the mesh\r\n\tCKMesh *mesh = ent->GetCurrentMesh();\r\n\tCKDWORD vStride=0;\r\n\tBYTE* varray = (BYTE*)mesh->GetModifierVertices(&vStride);\r\n\tint pointsNumber = mesh->GetModifierVertexCount();\r\n\r\n\tCKBOOL resetmesh = TRUE;\r\n\tbeh->GetInputParameterValue(3,&resetmesh);\r\n\tif (resetmesh) { // The Mesh must be reseted\r\n\t\tif(beh->GetVersion() < 0x00020000) { // Old Version with vertices stuffed inside\r\n\t\t\t// we get the saved position\r\n\t\t\tVxVector* savePos = (VxVector*)beh->GetLocalParameterWriteDataPtr(0);\r\n\t\t\t\r\n\t\t\tBYTE* temparray = varray;\r\n\t\t\tfor(int i=0;iGetObjectInitialValue(mesh);\t\t\t\t\r\n\t\t\tif(chunk) mesh->LoadVertices(chunk);\r\n\t\t\tvarray\t\t\t= (BYTE*)mesh->GetModifierVertices(&vStride);\r\n\t\t\tpointsNumber\t= mesh->GetModifierVertexCount();\r\n\t\t}\r\n\t}\r\n\r\n\t// we move all the points\r\n\tVxVector v,sp,d(0,0,0);\r\n\tVxVector offset(0.5f,0.5f,0.5f);\r\n\tVxVector noise_vect(0,0,seed);\r\n\tfor(int i=0;iModifierVertexMove(TRUE,TRUE);\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\t\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#ifndef InitMAN_H\r\n#define InitMAN_H\r\n\r\n#include \"CKBaseManager.h\"\r\n\r\n#define INIT_MAN_GUID\t\tCKGUID(0x6add640f,0x1acc1484)\r\n\r\nclass Python;\r\nclass PythonModule;\r\n\r\n\r\n#include \r\n#include \r\n\r\n#include \"pyembed.h\"\r\n\r\ntypedef std::mapPModules;\r\ntypedef std::map::iterator PModulesIt;\r\n\r\n\r\ntypedef std::mapVSLPModules;\r\ntypedef std::map::iterator VSLPModulesIt;\r\n\r\nclass vt_python_man : public CKBaseManager\r\n{\r\n\r\n\tpublic:\r\n\t\t//Ctor\r\n\t\tvt_python_man(CKContext* ctx);\r\n\t\t//Dtor\r\n\t\t~vt_python_man();\r\n\t\t\r\n\t\tPython *py;\r\n\r\n\t\tstatic vt_python_man*GetPyMan();\r\n\r\n\t\t\r\n\t\tPModules m_pModules;\r\n\t\tCK_ID m_CurrentId;\r\n\t\t\r\n\t\tCK_ID CurrentId() const { return m_CurrentId; }\r\n\t\tvoid CurrentId(CK_ID val) { m_CurrentId = val; }\r\n\r\n\r\n\t\tPModules& GetPModules(){return m_pModules;} \r\n\r\n\t\tPyObject *InsertPModule(CK_ID id,XString name,bool reload);\r\n\t\tvoid RemovePModule(CK_ID id);\r\n\t\tPyObject *GetPModule(CK_ID id);\r\n\t\tvoid CallPyModule(CK_ID id,XString func);\r\n\t\tvoid CallPyModule(CK_ID id,Arg_mmap *args,XString func);\r\n\t\tvoid CallPyModule(CK_ID id,XString func,const Arg_mmap& args,std::string& ret);\r\n\t\tvoid CallPyModule(CK_ID id,XString func,const Arg_mmap& args,double& ret);\r\n\t\tvoid CallPyModule(CK_ID id,XString func,const Arg_mmap& args,long& ret);\r\n\t\tvoid ClearModules();\r\n\r\n\r\n\t\tVSLPModules m_PVSLModules;\r\n\t\tVSLPModules& GetVSLPModules(){ return m_PVSLModules;}\r\n\r\n\t\tPythonModule *CreatePythonModule(char*file,char*func,CK_ID bid);\r\n\t\tPythonModule *DestroyPythonModule(CK_ID bid);\r\n\t\tPythonModule *GetPythonModule(CK_ID bid);\r\n\t\tvoid ClearPythonModules();\r\n\t\t\r\n\t\tvoid InsertPVSLModule(PythonModule *pMod);\r\n \r\n\t\tXString m_stdOut;\r\n\t\tXString m_stdErr;\r\n\r\n\t\tint InitPythonModules();\r\n\t\r\n\t\t// Initialization\t\r\n\t\tvirtual CKERROR OnCKInit();\r\n\t\tvirtual CKERROR OnCKEnd();\r\n\t\tvirtual CKERROR OnCKReset();\r\n\t\tvirtual CKERROR PreProcess();\r\n\t\tvirtual CKERROR PostProcess();\r\n\t\tvirtual CKERROR PostClearAll();\r\n\t\tvirtual CKERROR OnCKPlay();\r\n\r\n\r\n\tvirtual CKDWORD\tGetValidFunctionsMask()\t\r\n\t{ return CKMANAGER_FUNC_OnCKInit|\r\n\t\tCKMANAGER_FUNC_PostProcess|\r\n\t\tCKMANAGER_FUNC_OnCKEnd|\r\n\t\tCKMANAGER_FUNC_OnCKReset|\r\n\t\tCKMANAGER_FUNC_PreProcess|\r\n\t\tCKMANAGER_FUNC_PostClearAll|\r\n\t\tCKMANAGER_FUNC_OnCKPlay; \r\n\t}\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* Parameter Functions\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\r\n\tvoid RegisterVSL();\r\n\tbool pLoaded;\r\n};\r\n\r\n\r\n\r\n\r\n#endif\r\n#include \"xDistributedProperty.h\"\r\n#include \"xPredictionSetting.h\"\r\n\r\n\r\nuxString \r\nxDistributedProperty::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nxDistributedProperty::xDistributedProperty(xDistributedPropertyInfo *propInfo) : m_PropertyInfo( propInfo)\r\n{\r\n\tm_BlockIndex = 0;\r\n\tmLastTime = 0;\r\n\tmThresoldTicker =0;\r\n\tmCurrentTime =0;\r\n\tmLastDeltaTime =0;\r\n\r\n\tmThresoldTicker2 =0.0f;\r\n\tmLastTime2 = 0.0f;\r\n\tmLastDeltaTime2 =0.0;\r\n\tm_PredictionSettings = new xPredictionSetting();\r\n\tm_PredictionSettings->setMinDifference(1.0f);\r\n\tm_PredictionSettings->setMinSendTime(50.0f);\r\n\tm_PredictionSettings->setPredictionFactor( 10.0f);\r\n\r\n}\r\n\r\nvoid\r\nxDistributedProperty::advanceTime(xTimeType time1,float lastDeltaTime2 )\r\n{\r\n\r\n\tmLastTime2 = mLastTime2 + lastDeltaTime2;\r\n\tmLastDeltaTime2 = lastDeltaTime2;\r\n\tmThresoldTicker2 = mThresoldTicker2 + lastDeltaTime2;\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedProperty::unpack( xNStream *bstream,float sendersOneWayTime )\r\n{\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedProperty::pack(xNStream *bstream)\r\n{\r\n\r\n}\r\nDEV35DIR=\"x:/sdk/dev35\"\r\nDEV40DIR=\"x:/sdk/dev4\"\r\nDEV41DIR=\"x:/sdk/dev41R\"\r\nDEV5DIR=\"x:/sdk/dev5GA\"\r\nWEBPLAYERDIR=\"c:/Programme/Virtools/3D Life Player\"\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"vtLogTools.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOCreateDistributedObjectDecl();\r\nCKERROR CreateDOCreateDistributedObjectProto(CKBehaviorPrototype **);\r\nint DOCreateDistributedObject(const CKBehaviorContext& behcontext);\r\nCKERROR DOCreateDistributedObjectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_OBJECT,\r\n\tBB_IP_OBJECT_NAME,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\r\n\tBB_O_EXIT,\r\n\tBB_O_CREATED,\r\n\tBB_O_ERROR\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\r\n\tBB_OP_OBJECT_ID,\r\n\tBB_OP_ERROR\r\n};\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOCreateDistributedObjectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOCreate\");\t\r\n\tod->SetDescription(\"Creates an distributed object\");\r\n\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x4b134dfa,0xaca30cb));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOCreateDistributedObjectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDOCreateDistributedObjectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOCreate\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\r\n\r\n\tproto->DeclareOutput(\"Exit In\");\r\n\tproto->DeclareOutput(\"Created\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"test\");\r\n\tproto->DeclareInParameter(\"Object Name\", CKPGUID_STRING, \"test\");\r\n\r\n\tproto->DeclareOutParameter(\"Distributed Object ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\tproto->DeclareSetting(\"Class\", CKPGUID_STRING, \"My3DClass\");\r\n\tproto->DeclareSetting(\"Timeout\", CKPGUID_TIME, \"0\");\r\n\tproto->DeclareLocalParameter(\"elapsed time\", CKPGUID_FLOAT, \"0.0f\");\r\n\tproto->DeclareLocalParameter(\"Creation Status\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DOCreateDistributedObject);\r\n\tproto->SetBehaviorCallbackFct(DOCreateDistributedObjectCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOCreateDistributedObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object :\r\n\tCK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tif (!obj)\r\n\t{\r\n\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//use objects name, if not specified : \r\n\tCKSTRING name=vtTools::BehaviorTools::GetInputParameterValue(beh,2);\r\n\tif (!strlen(name))\r\n\t{\r\n\t\tname = obj->GetName();\r\n\t}\r\n\r\n\t\r\n\tIDistributedObjects*doInterface = cin->getDistObjectInterface();\r\n\tIDistributedClasses*cInterface = cin->getDistributedClassInterface();\r\n \r\n\tXString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));\r\n\txDistributedClass *classTemplate = cInterface->get(className.CStr());\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class ok ? \r\n\tif (!classTemplate)\r\n\t{\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\tint classType = classTemplate->getEnitityType();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//reset elapsed time :\r\n\t\tfloat elapsedTime = 0.0f;\r\n\t\tbeh->SetLocalParameterValue(2,&elapsedTime);\r\n\r\n\t\t//reset status to incomplete\r\n\t\tint creationStatus = E_DO_CREATION_INCOMPLETE;\r\n\t\tbeh->SetLocalParameterValue(3,&creationStatus);\r\n\t\t\r\n\t\t\r\n\t\txDistributedObject *dobj = doInterface->get(name);\r\n\t\tif (!dobj)\r\n\t\t{\r\n\t\t\tdoInterface->create(name,className.CStr());\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by loop : \r\n\r\n\r\n\t//pickup the creations state : \r\n\tint creationState=0;\r\n\tbeh->GetLocalParameterValue(3,&creationState);\r\n\r\n\r\n\tif (creationState == E_DO_CREATION_INCOMPLETE )\r\n\t{\r\n\t\t//we requested a dist object already, check the its timeout :\r\n\t\tfloat elapsedTime = 0.0f;\r\n\t\tbeh->GetLocalParameterValue(2,&elapsedTime);\r\n\t\t\r\n\t\t//pickup creations timeout settings : \r\n\t\tfloat timeOut=0.0f;\r\n\t\tbeh->GetLocalParameterValue(1,&timeOut);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//timeout reached : reset everything back \r\n\t\tif (elapsedTime > timeOut)\r\n\t\t{\r\n\t\t\t//reset output server id : \r\n\t\t\tint ids = -1;\r\n\t\t\tbeh->SetOutputParameterValue(0,&ids);\r\n\r\n\t\t\t//output an error string :\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\tXString errorMesg(\"distributed object creation failed, timeout reached\");\r\n\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\r\n\r\n\t\t\t//store state : \r\n\t\t\tint state = E_DO_CREATION_NONE;\r\n\t\t\tbeh->SetLocalParameterValue(3,&state);\r\n\r\n\t\t\t//finish, activate error output trigger: \r\n\t\t\tbeh->ActivateOutput(2);\r\n\t\t\treturn 0; \r\n\r\n\t\t}\r\n\t\telse\t// increase and store elapsed time : \r\n\t\t{\r\n\r\n\t\t\tfloat dt = ctx->GetTimeManager()->GetLastDeltaTime();\r\n\t\t\telapsedTime+=dt;\r\n\t\t\tbeh->SetLocalParameterValue(2,&elapsedTime);\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we are within the timeout range, check we have a successfully created object by the server : \r\n\r\n\t\txDistributedObject *dobj = doInterface->get(name);\r\n\t\tif (dobj && isFlagOn(dobj->getObjectStateFlags(),E_DOSF_UNPACKED) &&\r\n\t\t\t!isFlagOn(dobj->getObjectStateFlags(),E_DOSF_SHOWN))\r\n\t\t{\r\n\r\n\t\t\tenableFlag(dobj->getObjectStateFlags(),E_DOSF_SHOWN);\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_3DOBJECT,\"distributed object creation finish\");\r\n\r\n\t\t\tif (obj)\r\n\t\t\t{\r\n\t\t\t\tdobj->setEntityID(obj->GetID());\r\n\t\t\t\txDistributed3DObject *dobj3D = static_cast(dobj);\r\n\t\t\t\tif (dobj3D)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//store state : \r\n\t\t\tint state = E_DO_CREATION_NONE;\r\n\t\t\tbeh->SetLocalParameterValue(3,&state);\r\n\r\n\t\t\t//store elapsed time : \r\n\t\t\telapsedTime = 0.0f;\r\n\t\t\tbeh->SetLocalParameterValue(2,&elapsedTime);\r\n\r\n\t\t\t//output server id : \r\n\t\t\tint index = dobj->getServerID();\r\n\t\t\tbeh->SetOutputParameterValue(0,&index);\r\n\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\tXString errorMesg(\"No Error\");\r\n\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\r\n\t\t\t//return : \r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t\treturn 0; \r\n\t\t}\r\n\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR DOCreateDistributedObjectCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}SET devdir=X:\\sdk\\msvc\\Common7\\IDE\\\r\nSET devexe=X:\\sdk\\msvc\\Common7\\IDE\\devenv.com\r\nSET solution=X:\\ProjectRoot\\svn\\pearls-media\\private\\virtools\\vtPhysX\\build4\\vs2003Dev40\\vtPhysX.sln\r\n\r\nREM cd %devdir%\r\n%devexe% %solution% /out x:\\logDev42003.txt /Build \"ReleaseDemo\"\r\n\r\n\r\n\r\n#pragma once\r\n\r\n/////////////////////////////////////////////////////////////\r\n// Externs binding must use these macro\r\n\r\n// This macro is duplicated in VSL projet,\r\n// because we don't want to provide VSL src in the SDK\r\n#define NODEFAULT\t\t\t\t\t\t\t\tnodefault\r\n\r\n#define STARTVSLBIND(context)\t\t\t\t\tusing namespace VSL; \\\r\n\t\t\t\t\t\t\t\t\t\t\t\tVSLManager *VSLM = (VSLManager *)context->GetManagerByGuid(VSLMANAGER_GUID); \\\r\n\t\t\t\t\t\t\t\t\t\t\t\tif (VSLM) { VSLM->RegisterSpace();\r\n#define STOPVSLBIND\t\t\t\t\t\t\t\t}\r\n#define REGISTERVSLGUID(iGUID, iClassName)\t\tVSLM->RegisterGUID(iGUID, iClassName);\r\n\r\n/////////////////////////////////////////////////////////////\r\n// Type Declaration\r\n// TODO : 3 param = alias type::RawName()\r\n\r\n// Special class option for CKObjects\r\n#ifndef VCLASSOPTION_USERDATA\r\n\t#define VCLASSOPTION_USERDATA(x)\t((x << 24) & 0xFF000000)\r\n#endif\r\n#define VCLASSOPTION_CKOBJECT\t\tVCLASSOPTION_USERDATA(1)\r\n#define VCLASSOPTION_PINBYPOINTER\tVCLASSOPTION_USERDATA(2)\r\n\r\n#define DECLARETYPE(type)\t\t\t\t\t\t\t\tVSLM->RegisterClass(#type, sizeof(type));\r\n#define DECLARETYPEALIAS(type,alias)\t\t\t\t\tVSLM->RegisterClass(#type, sizeof(type), alias);\r\n#define DECLARETYPEWITHREF(type,ref)\t\t\t\t\tVSLM->RegisterClass(#type, ref);\r\n#define DECLARETYPEALIASWITHREF(type,ref,alias)\t\t\tVSLM->RegisterClass(#type, ref, alias);\r\n\r\n#if defined(_DEBUG) && !defined(VIRTOOLS_USER_SDK)\r\n\t#define DECLAREDOCSDKLINK(type,link)\t\t\t\tVSLM->RegisterClassDocSDKLink(#type, link);\r\n#else\r\n\t#define DECLAREDOCSDKLINK(type,link)\r\n#endif\r\n\r\n#define DECLAREPOINTERTYPE(type)\t\t\t\t\t\tVSLM->RegisterClass(#type, sizeof(type), NULL, VCLASSOPTION_POINTERCOPY);\r\n#define DECLAREPOINTERTYPEALIAS(type,alias)\t\t\t\tVSLM->RegisterClass(#type, sizeof(type), alias, VCLASSOPTION_POINTERCOPY);\r\n#define DECLARECKOBJECTTYPEALIAS(type,alias)\t\t\tVSLM->RegisterClass(#type, sizeof(type), alias, VCLASSOPTION_POINTERCOPY|VCLASSOPTION_CKOBJECT);\r\n\r\n#define DECLAREOBJECTTYPE(type)\t\t\t\t\t\t\tVSLM->RegisterClass(#type, sizeof(type), NULL, VCLASSOPTION_MEMCOPY);\r\n#define DECLAREOBJECTTYPEALIAS(type,alias)\t\t\t\tVSLM->RegisterClass(#type, sizeof(type), alias, VCLASSOPTION_MEMCOPY);\r\n#define DECLAREOBJECTTYPEALIAS_PINBYPOINTER(type,alias)\tVSLM->RegisterClass(#type, sizeof(type), alias, VCLASSOPTION_MEMCOPY|VCLASSOPTION_PINBYPOINTER);\r\n\r\n#define DECLAREINHERITANCESIMPLE(a,b)\tVSLM->RegisterHeritage(a,b,0);\r\n#define DECLAREINHERITANCEDOUBLE(a,b,c)\tVSLM->RegisterHeritage(a,b,c,0);\r\n\r\n#define REGISTERCONST(name,type,data)\tVSLM->RegisterConstant(name,type,data);\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// Enum\r\n\r\n#define DECLAREENUM(enumName)\t\t\t\t\t\tVSLM->RegisterEnum(enumName);\r\n#define DECLAREENUMVALUE(enumName,valueName,value)\tVSLM->RegisterEnumMember(enumName,valueName,value);\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// Enum\r\n\r\nenum BindedConstType\r\n{\r\n\tBIND_BOOL,\r\n\tBIND_CHAR,\r\n\tBIND_INT,\r\n\tBIND_FLOAT\r\n};\r\n\r\n#define DECLARECONST(constName,constType,value)\t\tVSLM->RegisterConstant(constName,constType,value);\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// Member Declaration\r\n\r\n#if defined(macintosh) || defined(PSX2) || defined(PSP) || (_XBOX_VER>=200)\r\n\r\n#define DECLAREMEMBER(classe,mtype,member) { \\\r\n\tclasse* instance = NULL; \\\r\n\tint offset = (int) &(instance->member); \\\r\n\tXASSERT((offset + sizeof(mtype)) <= sizeof(classe)); \\\r\n\tVSLM->RegisterMember(#classe,#member,#mtype, offset);\\\r\n}\r\n\r\n#else\r\n\r\n#define DECLAREMEMBER(classe,mtype,member) { \\\r\n\ttypedef mtype (classe::*mptr); \\\r\n\tmptr var = (mptr)(&classe::member); \\\r\n\tvoid* ptr = (void*)*(DWORD*)&var; \\\r\n\tVSLM->RegisterMember(#classe,#member,#mtype,(int)ptr);\\\r\n}\r\n\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////////////////////////\r\n// function Declaration\r\n\r\n#define DECLAREFUN_0(ret,func,callconv) {\\\r\n\ttypedef ret (*fptr)(); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,0,#ret);\\\r\n}\r\n#define DECLAREFUN_C_0(ret,func) DECLAREFUN_0(ret,func,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_0(ret,func) DECLAREFUN_0(ret,func,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_1(ret,func,arg1,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREFUN_1_WITH_DEF_VALS(ret,func,arg1,defVal1,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,1,#ret,#arg1\" = \"#defVal1);\\\r\n}\r\n\r\n#define DECLAREFUN_C_1(ret,func,arg1) DECLAREFUN_1(ret,func,arg1,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_1(ret,func,arg1) DECLAREFUN_1(ret,func,arg1,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_1_WITH_DEF_VALS(ret,func,arg1,defVal1) DECLAREFUN_1_WITH_DEF_VALS(ret,func,arg1,defVal1,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_1_WITH_DEF_VALS(ret,func,arg1,defVal1) DECLAREFUN_1_WITH_DEF_VALS(ret,func,arg1,defVal1,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_2(ret,func,arg1,arg2,callconv) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,2,#ret,#arg1,#arg2); \\\r\n}\r\n\r\n#define DECLAREFUN_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,callconv) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,2,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2); \\\r\n}\r\n\r\n#define DECLAREFUN_C_2(ret,func,arg1,arg2) DECLAREFUN_2(ret,func,arg1,arg2,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_2(ret,func,arg1,arg2) DECLAREFUN_2(ret,func,arg1,arg2,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2) DECLAREFUN_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2) DECLAREFUN_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_3(ret,func,arg1,arg2,arg3,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n#define DECLAREFUN_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,3,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3);\\\r\n}\r\n\r\n#define DECLAREFUN_C_3(ret,func,arg1,arg2,arg3) DECLAREFUN_3(ret,func,arg1,arg2,arg3,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_3(ret,func,arg1,arg2,arg3) DECLAREFUN_3(ret,func,arg1,arg2,arg3,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3) DECLAREFUN_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3) DECLAREFUN_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_4(ret,func,arg1,arg2,arg3,arg4,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n\r\n#define DECLAREFUN_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4);\\\r\n}\r\n\r\n#define DECLAREFUN_C_4(ret,func,arg1,arg2,arg3,arg4) DECLAREFUN_4(ret,func,arg1,arg2,arg3,arg4,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_4(ret,func,arg1,arg2,arg3,arg4) DECLAREFUN_4(ret,func,arg1,arg2,arg3,arg4,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) DECLAREFUN_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) DECLAREFUN_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_5(ret,func,arg1,arg2,arg3,arg4,arg5,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,5,#ret,#arg1,#arg2,#arg3,#arg4,#arg5);\\\r\n}\r\n\r\n#define DECLAREFUN_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,5,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5);\\\r\n}\r\n\r\n#define DECLAREFUN_C_5(ret,func,arg1,arg2,arg3,arg4,arg5) DECLAREFUN_5(ret,func,arg1,arg2,arg3,arg4,arg5,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_5(ret,func,arg1,arg2,arg3,arg4,arg5) DECLAREFUN_5(ret,func,arg1,arg2,arg3,arg4,arg5,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) DECLAREFUN_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) DECLAREFUN_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,VCALLTYPE_STDCALL)\r\n\r\n#define DECLAREFUN_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,6,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6);\\\r\n}\r\n\r\n#define DECLAREFUN_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,6,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6);\\\r\n}\r\n\r\n#define DECLAREFUN_C_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6) DECLAREFUN_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6) DECLAREFUN_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,VCALLTYPE_STDCALL)\r\n#define DECLAREFUN_C_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) DECLAREFUN_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,VCALLTYPE_CDECL)\r\n#define DECLAREFUN_S_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) DECLAREFUN_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,VCALLTYPE_STDCALL)\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// Function Declaration with a different name\r\n\r\n#define DECLAREFUNALIAS_0(name,ret,func,callconv) {\\\r\n\ttypedef ret (*fptr)(); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,0,#ret); \\\r\n}\r\n\r\n#define DECLAREFUNALIAS_C_0(name,ret,func) DECLAREFUNALIAS_0(name,ret,func,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_0(name,ret,func) DECLAREFUNALIAS_0(name,ret,func,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_1(name,ret,func,arg1,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,1,#ret,#arg1);\\\r\n}\r\n#define DECLAREFUNALIAS_C_1(name,ret,func,arg1) DECLAREFUNALIAS_1(name,ret,func,arg1,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_1(name,ret,func,arg1) DECLAREFUNALIAS_1(name,ret,func,arg1,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_2(name,ret,func,arg1,arg2,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,2,#ret,#arg1,#arg2);\\\r\n}\r\n#define DECLAREFUNALIAS_C_2(name,ret,func,arg1,arg2) DECLAREFUNALIAS_2(name,ret,func,arg1,arg2,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_2(name,ret,func,arg1,arg2) DECLAREFUNALIAS_2(name,ret,func,arg1,arg2,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_3(name,ret,func,arg1,arg2,arg3,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n#define DECLAREFUNALIAS_C_3(name,ret,func,arg1,arg2,arg3) DECLAREFUNALIAS_3(name,ret,func,arg1,arg2,arg3,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_3(name,ret,func,arg1,arg2,arg3) DECLAREFUNALIAS_3(name,ret,func,arg1,arg2,arg3,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_4(name,ret,func,arg1,arg2,arg3,arg4,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n#define DECLAREFUNALIAS_C_4(name,ret,func,arg1,arg2,arg3,arg4) DECLAREFUNALIAS_4(name,ret,func,arg1,arg2,arg3,arg4,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_4(name,ret,func,arg1,arg2,arg3,arg4) DECLAREFUNALIAS_4(name,ret,func,arg1,arg2,arg3,arg4,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_5(name,ret,func,arg1,arg2,arg3,arg4,arg5,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,(fptr)ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4,arg5);\\\r\n}\r\n#define DECLAREFUNALIAS_C_5(name,ret,func,arg1,arg2,arg3,arg4,arg5) DECLAREFUNALIAS_5(name,ret,func,arg1,arg2,arg3,arg4,arg5,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_5(name,ret,func,arg1,arg2,arg3,arg4,arg5) DECLAREFUNALIAS_5(name,ret,func,arg1,arg2,arg3,arg4,arg5,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n#define DECLAREFUNALIAS_6(name,ret,func,arg1,arg2,arg3,arg4,arg5,arg6,callconv) {\\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(name,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4,arg5,arg6);\\\r\n}\r\n#define DECLAREFUNALIAS_C_6(name,ret,func,arg1,arg2,arg3,arg4,arg5,arg6) DECLAREFUNALIAS_6(name,ret,func,arg1,arg2,arg3,arg4,arg5,arg6,(VSL::VCallType)(VCALLTYPE_CDECL|VCALLTYPE_ALIAS))\r\n#define DECLAREFUNALIAS_S_6(name,ret,func,arg1,arg2,arg3,arg4,arg5,arg6) DECLAREFUNALIAS_6(name,ret,func,arg1,arg2,arg3,arg4,arg5,arg6,(VSL::VCallType)(VCALLTYPE_STDCALL|VCALLTYPE_ALIAS))\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// constructor Declaration\r\n\r\n#define DECLARENEW_0(ret,func,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,0,#ret);\\\r\n}\r\n#define DECLARECTOR_0(func) DECLARENEW_0(void,func,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_1(ret,func,arg1,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,1,#ret,#arg1);\\\r\n}\r\n#define DECLARECTOR_1(func,arg1) DECLARENEW_1(void,func,arg1,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_2(ret,func,arg1,arg2,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,2,#ret,#arg1,#arg2);\\\r\n}\r\n#define DECLARECTOR_2(func,arg1,arg2) DECLARENEW_2(void,func,arg1,arg2,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_3(ret,func,arg1,arg2,arg3,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n\r\n#define DECLARECTOR_3(func,arg1,arg2,arg3) DECLARENEW_3(void,func,arg1,arg2,arg3,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_4(ret,func,arg1,arg2,arg3,arg4,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n\t}\r\n#define DECLARECTOR_4(func,arg1,arg2,arg3,arg4) DECLARENEW_4(void,func,arg1,arg2,arg3,arg4,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_5(ret,func,arg1,arg2,arg3,arg4,arg5,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4,arg5);\\\r\n\t}\r\n#define DECLARECTOR_5(func,arg1,arg2,arg3,arg4,arg5) DECLARENEW_5(void,func,arg1,arg2,arg3,arg4,arg5,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_6(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4,arg5,arg6);\\\r\n\t}\r\n#define DECLARECTOR_6(func,arg1,arg2,arg3,arg4,arg5,arg6) DECLARENEW_6(void,func,arg1,arg2,arg3,arg4,arg5,arg6,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_7(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,arg7,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1,#arg2,#arg3,#arg4,arg5,arg6,arg7);\\\r\n\t}\r\n#define DECLARECTOR_7(func,arg1,arg2,arg3,arg4,arg5,arg6,arg7) DECLARENEW_7(void,func,arg1,arg2,arg3,arg4,arg5,arg6,arg7,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_8(ret,func,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,8,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7,#arg8);\\\r\n\t}\r\n#define DECLARECTOR_8(func,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) DECLARENEW_8(void,func,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,VCALLTYPE_CDECL)\r\n\r\n// With Def Values\r\n\r\n#define DECLARENEW_1_WITH_DEF_VALS(ret,func,arg1,defVal1,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,1,#ret,#arg1\" = \"#defVal1);\\\r\n}\r\n#define DECLARECTOR_1_WITH_DEF_VALS(func,arg1) DECLARENEW_1_WITH_DEF_VALS(void,func,arg1,defVal1,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_2_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,2,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2);\\\r\n}\r\n#define DECLARECTOR_2_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2) DECLARENEW_2_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_3_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,3,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3);\\\r\n}\r\n#define DECLARECTOR_3_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3) DECLARENEW_3_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_4_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,4,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4);\\\r\n\t}\r\n#define DECLARECTOR_4_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) DECLARENEW_4_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_5_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,5,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5);\\\r\n\t}\r\n#define DECLARECTOR_5_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) DECLARENEW_5_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_6_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,6,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6);\\\r\n\t}\r\n#define DECLARECTOR_6_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) DECLARENEW_6_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_7_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,7,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7);\\\r\n\t}\r\n#define DECLARECTOR_7_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7) DECLARENEW_7_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,VCALLTYPE_CDECL)\r\n\r\n#define DECLARENEW_8_WITH_DEF_VALS(ret,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8,callconv) {\\\r\n\ttypedef ret (*fptr)(BYTE*,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,callconv,8,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8);\\\r\n\t}\r\n#define DECLARECTOR_8_WITH_DEF_VALS(func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8) DECLARENEW_8_WITH_DEF_VALS(void,func,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8,VCALLTYPE_CDECL)\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// destructor Declaration\r\n\r\n\r\n#ifdef __GNUC__\r\n\t#define DECLAREDESTRUCTORFUNCTION(classe) void __dest##classe(classe *obj){obj->~classe();}\r\n\t#define DECLAREDESTRUCTORFUNCTIONALIAS(classe, alias) void __dest##alias(classe *obj){obj->~classe();}\r\n#else\r\n\t#define DECLAREDESTRUCTORFUNCTION(classe) void __dest##classe(classe *obj){obj->~##classe();}\r\n\t#define DECLAREDESTRUCTORFUNCTIONALIAS(classe, alias) void __dest##alias(classe *obj){obj->~##classe();}\r\n#endif\r\n\r\n#define DECLAREDESTRUCTOR(func) {\\\r\n\ttypedef void (*fptr)(BYTE*); \\\r\n\tfptr rawPtr = (fptr) func; \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &rawPtr); \\\r\n\tVSLM->RegisterFunction(#func,ptr,VCALLTYPE_CDECL,0,\"void\");\\\r\n}\r\n///////////////////////////////////////////////////////////////////\r\n// class method Declaration\r\n\r\n#define FPTR(a) (fptr) a\r\n\r\n#define DECLAREMETHOD_0(classe,ret,method) { \\\r\n\ttypedef ret (classe::*fptr)(); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREMETHODC_0(classe,ret,method) { \\\r\n\ttypedef ret (classe::*fptr)() const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREMETHOD_1(classe,ret,method,arg1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREMETHOD_1_WITH_DEF_VALS(classe,ret,method,arg1,defVal1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1\" = \"#defVal1);\\\r\n}\r\n\r\n#define DECLAREMETHODC_1(classe,ret,method,arg1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREMETHODC_1_WITH_DEF_VALS(classe,ret,method,arg1,defVal1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1\" = \"#defVal1);\\\r\n}\r\n\r\n#define DECLAREMETHOD_2(classe,ret,method,arg1,arg2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n#define DECLAREMETHOD_2_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2); \\\r\n\tfptr var = FPTR(fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2);\\\r\n}\r\n\r\n\r\n#define DECLAREMETHODC_2(classe,ret,method,arg1,arg2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n#define DECLAREMETHODC_2_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2);\\\r\n}\r\n\r\n#define DECLAREMETHOD_3(classe,ret,method,arg1,arg2,arg3) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n#define DECLAREMETHOD_3_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,3,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3);\\\r\n}\r\n\r\n#define DECLAREMETHODC_3(classe,ret,method,arg1,arg2,arg3) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n#define DECLAREMETHODC_3_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,3,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3);\\\r\n}\r\n\r\n#define DECLAREMETHOD_4(classe,ret,method,arg1,arg2,arg3,arg4) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n\r\n#define DECLAREMETHODC_4(classe,ret,method,arg1,arg2,arg3,arg4) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n\r\n#define DECLAREMETHOD_4_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,4,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4);\\\r\n}\r\n\r\n#define DECLAREMETHODC_4_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,4,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4);\\\r\n}\r\n\r\n#define DECLAREMETHOD_5(classe,ret,method,arg1,arg2,arg3,arg4,arg5) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,5,#ret,#arg1,#arg2,#arg3,#arg4,#arg5);\\\r\n}\r\n\r\n#define DECLAREMETHODC_5(classe,ret,method,arg1,arg2,arg3,arg4,arg5) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,5,#ret,#arg1,#arg2,#arg3,#arg4,#arg5);\\\r\n}\r\n\r\n#define DECLAREMETHOD_5_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,5,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5);\\\r\n}\r\n\r\n#define DECLAREMETHODC_5_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,5,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5);\\\r\n}\r\n\r\n#define DECLAREMETHOD_6(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,6,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6);\\\r\n}\r\n\r\n#define DECLAREMETHODC_6(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,6,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6);\\\r\n}\r\n\r\n#define DECLAREMETHOD_6_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,6,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6);\\\r\n}\r\n\r\n#define DECLAREMETHODC_6_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,6,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6);\\\r\n}\r\n\r\n#define DECLAREMETHOD_7(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,7,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7);\\\r\n}\r\n\r\n#define DECLAREMETHODC_7(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,7,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7);\\\r\n}\r\n\r\n\r\n#define DECLAREMETHOD_7_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,7,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7);\\\r\n}\r\n\r\n#define DECLAREMETHODC_7_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,7,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7);\\\r\n}\r\n\r\n#define DECLAREMETHOD_8(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,8,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7,#arg8);\\\r\n}\r\n\r\n#define DECLAREMETHODC_8(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,8,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7,#arg8);\\\r\n}\r\n\r\n#define DECLAREMETHOD_8_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,8,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8);\\\r\n}\r\n\r\n#define DECLAREMETHODC_8_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) const; \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,TRUE,ptr,VCALLTYPE_STDCALL,8,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8);\\\r\n}\r\n#define DECLAREMETHOD_9_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8,arg9,defVal9) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,9,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8,#arg9\" = \"#defVal9);\\\r\n}\r\n\r\n#define DECLAREMETHOD_10_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8,arg9,defVal9,arg10,defVal10) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,10,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8,#arg9\" = \"#defVal9,#arg10\" = \"#defVal10);\\\r\n}\r\n\r\n#define DECLAREMETHOD_11_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8,arg9,defVal9,arg10,defVal10,arg11,defVal11) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11); \\\r\n\tfptr var = FPTR(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,FALSE,FALSE,ptr,VCALLTYPE_STDCALL,11,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8,#arg9\" = \"#defVal9,#arg10\" = \"#defVal10,#arg11\" = \"#defVal11);\\\r\n}\r\n\r\n\r\n\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// class operator Declaration\r\n\r\ninline const char* extractOperator(const char* opname)\r\n{\r\n\tconst char* s = opname+8;\r\n\twhile (*s == ' ') ++s;\r\n\treturn s;\r\n}\r\n\r\n#define DECLAREOP_0(classe,ret,op) { \\\r\n\ttypedef ret (classe::*fptr)(); \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,FALSE,ptr,VCALLTYPE_STDCALL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREOP_1(classe,ret,op,arg1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1); \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,FALSE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREOP_2(classe,ret,op,arg1,arg2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2); \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,FALSE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n// constant versions\r\n\r\n#define DECLAREOPC_0(classe,ret,op) { \\\r\n\ttypedef ret (classe::*fptr)() const; \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,TRUE,ptr,VCALLTYPE_STDCALL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREOPC_1(classe,ret,op,arg1) { \\\r\n\ttypedef ret (classe::*fptr)(arg1) const; \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,TRUE,ptr,VCALLTYPE_STDCALL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREOPC_2(classe,ret,op,arg1,arg2) { \\\r\n\ttypedef ret (classe::*fptr)(arg1,arg2) const; \\\r\n\tfptr var = (fptr)(&classe::op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateMethodPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,extractOperator(#op),FALSE,TRUE,ptr,VCALLTYPE_STDCALL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// friend method Declaration\r\n\r\n#define DECLAREFRIEND_0(ret,method) { \\\r\n\ttypedef ret (*fptr)(); \\\r\n\tfptr var = (fptr)(&method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(#method,ptr,VCALLTYPE_CDECL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREFRIEND_1(ret,method,arg1) { \\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr var = (fptr)(&method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(#method,ptr,VCALLTYPE_CDECL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREFRIEND_2(ret,method,arg1,arg2) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr var = (fptr)(&method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(#method,ptr,VCALLTYPE_CDECL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n#define DECLAREFRIEND_3(ret,method,arg1,arg2,arg3) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr var = (fptr)(&method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(#method,ptr,VCALLTYPE_CDECL,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n#define DECLAREFRIEND_4(ret,method,arg1,arg2,arg3,arg4) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr var = (fptr)(&method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(#method,ptr,VCALLTYPE_CDECL,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// friend operator\r\n\r\n#define DECLAREFRIENDOP_0(ret,op) { \\\r\n\ttypedef ret (*fptr)(); \\\r\n\tfptr var = (fptr)(&op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(extractOperator(#op),ptr,VCALLTYPE_CDECL,0,#ret);\\\r\n}\r\n\r\n#define DECLAREFRIENDOP_1(ret,op,arg1) { \\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr var = (fptr)(&op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(extractOperator(#op),ptr,VCALLTYPE_CDECL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLAREFRIENDOP_2(ret,op,arg1,arg2) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr var = (fptr)(&op); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterFunction(extractOperator(#op),ptr,VCALLTYPE_CDECL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// static method Declaration\r\n\r\n#define DECLARESTATIC_0(classe,ret,method) { \\\r\n\ttypedef ret (*fptr)(); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,0,#ret);\\\r\n}\r\n\r\n#define DECLARESTATIC_1(classe,ret,method,arg1) { \\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,1,#ret,#arg1);\\\r\n}\r\n\r\n#define DECLARESTATIC_2(classe,ret,method,arg1,arg2) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,2,#ret,#arg1,#arg2);\\\r\n}\r\n\r\n#define DECLARESTATIC_3(classe,ret,method,arg1,arg2,arg3) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,3,#ret,#arg1,#arg2,#arg3);\\\r\n}\r\n\r\n#define DECLARESTATIC_4(classe,ret,method,arg1,arg2,arg3,arg4) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,4,#ret,#arg1,#arg2,#arg3,#arg4);\\\r\n}\r\n\r\n#define DECLARESTATIC_5(classe,ret,method,arg1,arg2,arg3,arg4,arg5) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,5,#ret,#arg1,#arg2,#arg3,#arg4,#arg5);\\\r\n}\r\n\r\n#define DECLARESTATIC_6(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,6,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6);\\\r\n}\r\n\r\n#define DECLARESTATIC_7(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,7,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7);\\\r\n}\r\n\r\n#define DECLARESTATIC_8(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,8,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7,#arg8);\\\r\n}\r\n\r\n#define DECLARESTATIC_9(classe,ret,method,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8, arg9) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,9,#ret,#arg1,#arg2,#arg3,#arg4,#arg5,#arg6,#arg7,#arg8,#arg9);\\\r\n}\r\n\r\n// With Default Values\r\n\r\n#define DECLARESTATIC_1_WITH_DEF_VALS(classe,ret,method,arg1,defVal1) { \\\r\n\ttypedef ret (*fptr)(arg1); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,1,#ret,#arg1#defVal1);\\\r\n}\r\n\r\n#define DECLARESTATIC_2_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,2,#ret,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2);\\\r\n}\r\n\r\n#define DECLARESTATIC_3_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,3,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3);\\\r\n}\r\n\r\n#define DECLARESTATIC_4_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,4,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4);\\\r\n}\r\n\r\n#define DECLARESTATIC_5_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,5,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5);\\\r\n}\r\n\r\n#define DECLARESTATIC_6_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,6,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6);\\\r\n}\r\n\r\n#define DECLARESTATIC_7_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,7,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7);\\\r\n}\r\n\r\n#define DECLARESTATIC_8_WITH_DEF_VALS(classe,ret,method,arg1,defVal1,arg2,defVal2,arg3,defVal3,arg4,defVal4,arg5,defVal5,arg6,defVal6,arg7,defVal7,arg8,defVal8) { \\\r\n\ttypedef ret (*fptr)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); \\\r\n\tfptr var = (fptr)(&classe::method); \\\r\n\tTPtrToRoutine ptr; \\\r\n\tptr.CreateFunctionPtr((void**) &var); \\\r\n\tVSLM->RegisterMethod(#classe,#method,TRUE,FALSE,ptr,VCALLTYPE_CDECL,8,#ret,#arg1\" = \"#defVal1,#arg2\" = \"#defVal2,#arg3\" = \"#defVal3,#arg4\" = \"#defVal4,#arg5\" = \"#defVal5,#arg6\" = \"#defVal6,#arg7\" = \"#defVal7,#arg8\" = \"#defVal8);\\\r\n}\r\n\r\n\r\n///////////////////////////////////////////////////////////////////\r\n// Enum for array of GUID used by binded function GetGUID\r\n\r\nenum PGUID\r\n{\r\n\tPGUID_NONE = 0,\r\n\tPGUID_VOIDBUF,\r\n\tPGUID_FLOAT,\r\n\tPGUID_ANGLE,\r\n\tPGUID_PERCENTAGE,\r\n\tPGUID_INT,\r\n\tPGUID_KEY,\r\n\tPGUID_BOOL,\r\n\tPGUID_STRING,\r\n\tPGUID_RECT,\r\n\tPGUID_VECTOR,\r\n\tPGUID_2DVECTOR,\r\n\tPGUID_QUATERNION,\r\n\tPGUID_EULERANGLES,\r\n\tPGUID_MATRIX,\r\n\tPGUID_COLOR,\r\n\tPGUID_BOX,\r\n\tPGUID_OBJECTARRAY,\r\n\tPGUID_OBJECT,\r\n\tPGUID_BEOBJECT,\r\n\tPGUID_MESH,\r\n\tPGUID_MATERIAL,\r\n\tPGUID_TEXTURE,\r\n\tPGUID_SPRITE,\r\n\tPGUID_3DENTITY,\r\n\tPGUID_CURVEPOINT,\r\n\tPGUID_LIGHT,\r\n\tPGUID_TARGETLIGHT,\r\n\tPGUID_ID,\r\n\tPGUID_CAMERA,\r\n\tPGUID_TARGETCAMERA,\r\n\tPGUID_SPRITE3D,\r\n\tPGUID_OBJECT3D,\r\n\tPGUID_BODYPART,\r\n\tPGUID_CHARACTER,\r\n\tPGUID_CURVE,\r\n\tPGUID_2DCURVE,\r\n\tPGUID_LEVEL,\r\n\tPGUID_PLACE,\r\n\tPGUID_GROUP,\r\n\tPGUID_2DENTITY,\r\n\tPGUID_RENDEROBJECT,\r\n\tPGUID_SPRITETEXT,\r\n\tPGUID_SOUND,\r\n\tPGUID_WAVESOUND,\r\n\tPGUID_MIDISOUND,\r\n\tPGUID_OBJECTANIMATION,\r\n\tPGUID_ANIMATION,\r\n\tPGUID_KINEMATICCHAIN,\r\n\tPGUID_SCENE,\r\n\tPGUID_BEHAVIOR,\r\n\tPGUID_MESSAGE,\r\n\tPGUID_SYNCHRO,\r\n\tPGUID_CRITICALSECTION,\r\n\tPGUID_STATE,\r\n\tPGUID_ATTRIBUTE,\r\n\tPGUID_CLASSID,\r\n\tPGUID_DIRECTION,\r\n\tPGUID_BLENDMODE,\r\n\tPGUID_FILTERMODE,\r\n\tPGUID_BLENDFACTOR,\r\n\tPGUID_FILLMODE,\r\n\tPGUID_LITMODE,\r\n\tPGUID_SHADEMODE,\r\n\tPGUID_GLOBALEXMODE,\r\n\tPGUID_ZFUNC,\r\n\tPGUID_ADDRESSMODE,\r\n\tPGUID_WRAPMODE,\r\n\tPGUID_3DSPRITEMODE,\r\n\tPGUID_FOGMODE,\r\n\tPGUID_LIGHTTYPE,\r\n\tPGUID_SPRITEALIGN,\r\n\tPGUID_SCRIPT,\r\n\tPGUID_LAYERTYPE,\r\n\tPGUID_STATECHUNK,\r\n\tPGUID_DATAARRAY,\r\n\tPGUID_COMPOPERATOR,\r\n\tPGUID_BINARYOPERATOR,\r\n\tPGUID_SETOPERATOR,\r\n\tPGUID_SPRITETEXTALIGNMENT,\r\n\tPGUID_OBSTACLEPRECISION,\r\n\tPGUID_OBSTACLEPRECISIONBEH,\r\n\tPGUID_OBSTACLE,\r\n\tPGUID_PATCHMESH,\r\n\tPGUID_POINTER,\r\n\tPGUID_ENUMS,\r\n\tPGUID_STRUCTS,\r\n\tPGUID_FLAGS,\r\n\tPGUID_FILTER,\r\n\tPGUID_TIME,\r\n\tPGUID_OLDTIME,\r\n\tPGUID_COPYDEPENDENCIES,\r\n\tPGUID_DELETEDEPENDENCIES,\r\n\tPGUID_SAVEDEPENDENCIES,\r\n\tPGUID_REPLACEDEPENDENCIES,\r\n\tPGUID_SCENEACTIVITYFLAGS,\r\n\tPGUID_SCENEOBJECT,\r\n\tPGUID_SCENERESETFLAGS,\r\n\tPGUID_ARRAYTYPE,\r\n\tPGUID_RENDEROPTIONS,\r\n\tPGUID_PARAMETERTYPE,\r\n\tPGUID_MATERIALEFFECT,\r\n\tPGUID_TEXGENEFFECT,\r\n\tPGUID_TEXGENREFEFFECT,\r\n\tPGUID_COMBINE2TEX,\r\n\tPGUID_COMBINE3TEX,\r\n\tPGUID_BUMPMAPPARAM,\r\n\tPGUID_TEXCOMBINE,\r\n\tPGUID_PIXELFORMAT,\r\n\tPGUID_AXIS,\r\n\tPGUID_SUPPORT,\r\n\tPGUID_BITMAP_SYSTEMCACHING,\r\n\tPGUID_OLDMESSAGE,\r\n\tPGUID_OLDATTRIBUTE,\r\n\tPGUID_3DPOINTCLOUD,\r\n\tPGUID_VIDEO,\r\n\tPGUID_RTVIEW,\r\n\r\n\tPGUID_LASTGUID // must stay in last position\r\n};\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 1 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n/* Version 1.2 ------------------------------------------------------------- */\r\n/* 23.02.95 : Correction d'un mauvais code de retour */\r\n/* 27.02.95 : Ajout du code de retour 250 pour les transferts de */\r\n/* fichiers (retour de MVS) */\r\n/* 02.03.95 : Ajout de la fonction Ftp4wVer */\r\n/* 07.03.95 : FtpRelease : Destruction de la fenêtre avant */\r\n/* l'appel à UnregisterClass */\r\n\r\n/* Version 2.0 ------------------------------------------------------------- */\r\n/* 10.03.95 : Réorganisation du code */\r\n/* 14.03.95 : Ajout de FtpPWD, FtpMKD, FtpRMD, FtpCDUP */\r\n/* Rajout des lignes */\r\n/* case 502,504: return FTPERR_CMDNOTIMPLEMENTED */\r\n/* Ajout de FtpDelete */\r\n/* 15.03.95 : Ajout du mode Passif */\r\n/* Reste peut-être une petite erreur : si le fichier */\r\n/* n'existe pas, la socket n'est pas forcément fermée */\r\n/* 16.03.95 : Suppression des warnings de compilation */\r\n/* 27.03.95 : Ajout de la commande FtpSyst */\r\n/* 27.03.95 : Ajout de la commande FtpRenameFile */\r\n/* 29.03.95 : Modification du fonctionnement de FtpSyst */\r\n/* 29.03.95 : Ajout de la fonction FtpAppendToRemoteFile */\r\n/* 29.03.95 : Correction d'un bug dans la fonction Ftp4wVer */\r\n/* 31.03.95 : WSACleanUp est appele apres les close dans WEP */\r\n/* Version 2.1 ------------------------------------------------------------- */\r\n/* 3.04.95 : Utilisation de la bibliotheque Tcp4w/Tn4w */\r\n/* 4.04.95 : Fonctionnement en Automate */\r\n/* Version 2.2 ------------------------------------------------------------- */\r\n/* 7.04.95 : Ajout de FtpAppendToLocalFile */\r\n/* Ajout des constantes FTPMODE_APPEND, FTPMODE_READ */\r\n/* 12.04.95 : Elimination du delai sur reception synchrone */ \r\n/* 21.04.95 Integration des primitives Telnet */\r\n/* 28.04.95 Modification des parametres Slices */\r\n/* 6.06.95 Modification pour le support de LAN WorkPlace */\r\n/* 12.06.95 Compilation pour Version 2.2j (CICA) */ \r\n/* 17.07.95 Correction du bug SetDefaultPort Version 2.2k */\r\n/* 08.08.95 Bug: Changement de la macro RETURN */\r\n/* Version 2.3 ------------------------------------------------------------- */\r\n/* 29.08.95 Suppression du WEP */ \r\n/* 29.08.95 Ajout de la fonction FtpSendAccount */ \r\n/* 12.10.95 changement de fonctionnement du TcpClose */\r\n/* Ajout d'un type par defaut dans Recv/Send */\r\n/* 3.11.95 FtpOpenConnection retourne FTERR_CANCELBYUSER, si */\r\n/* il est interrompu par un FtpAbort */\r\n/* Version 2.4 ------------------------------------------------------------- */\r\n/* 16.11.95 Implementation des commandes FtpRestartSend/Recv */\r\n/* Ajout du parametre lByte ds ToolsSetDataConnection */\r\n/* Implementation de la commande FtpRestart */ \r\n/* Extension de l'utilisation de Tcp4w */\r\n/* 21.11.95 Correction dans le Calcul de la jauge (%) pour */\r\n/* FtpRestartSendFile */\r\n/* 25.11.95 Portage 32 bits: Ajout des fichiers Port32.h et */\r\n/* Port32.c */\r\n/* Version 2.5 ------------------------------------------------------------- */\r\n/* 8.02.96 Ajout des commandes FtpOpenDataConnection, */\r\n/* FtpCloseDataConnection, FtpSendThroughDataConn... */\r\n/* 20.02.96 AJout de FtpFirewallLogin */ \r\n/* 14.03.96 Ajout de FtpErrorString, FtpMGet (module WFTP4W_E) */\r\n/* 1.04.96 Ajout de FtpBufferPtr */\r\n/* 10.04.96 Utilisation de Tcp4u Version 2.0 */\r\n/* Version 2.6 ------------------------------------------------------------- */\r\n/* 22.05.96 Passage en environnement Gulliver */\r\n/* 11.06.96 Externalisation de IntFtpGetAnswerCode */\r\n/* et création de IntTnSend (pour Firewall code) */\r\n/* 12.06.96 Elimination du htons devant FtpSetDefaultPort */\r\n/* Version 2.7 ------------------------------------------------------------- */\r\n/* 05.08.96 Premier essai de MultiThread avec FtpMtInit */\r\n/*\t\t\t\t\t\t Correction d'une mauvaise detection de timeout */\r\n/* 27.11.96 Ajout du code retour 257 sur RMD (WAR FTP server) */\r\n/*\t\t\t 06.12.96 Détails codes retour sur Get(Connect/Listen)Socket */\r\n\r\n/* Version 3.0 ------------------------------------------------------------- */\r\n/*\t\t\t 31.01.97 Nouvelle annee, nouvelle version */\r\n/* Fin du suppotr de la DLL 16 bits -> V2.7 */\r\n/*\t\t\t\t\t\t Division du code en petits modules */\r\n/*\t\t\t 06.12.97 Ajout du code 230 Acct Unisys */\r\n/*\t\t\t 08.12.97 Utilisation du Debug de Tcp4u */\r\n\r\n\r\n#define FTP4W_INCLUDES_AND_GENERAL +\r\n\r\n#include \r\n#include \r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include /* external header file */ \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\" /* external header file */ \r\n#include \"ftp4w_in.h\" /* internal header file */\r\n#include \"rfc959.h\" /* only for error codes */ \r\n\r\n\r\n#define FTP4W_CLASS_NAME \"Ftp4wClassName\"\r\n\r\n\r\n/* ------------------------------------------------------------------------- */\r\n/* Variables */\r\n/* ------------------------------------------------------------------------- */\r\n\r\n/* Pointeur sur l'index de la première connexion */\r\nLPProcData pFirstProcData=NULL;\r\n \r\nint Protection (void);\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie IV : Allocations/libérations des ressources */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n\r\n/* --------------------------------------------------------------*/\r\n/* Fonction DLL FtpInit */\r\n/* Création d'une structure de travail */\r\n/* ouverture d'une fenêtre interne */\r\n/* Initialisation de la structure */\r\n/* ------------------------------------------------------------- */\r\nint _export PASCAL FAR FtpInit (HWND hParentWnd)\r\n{\r\nLPProcData pProcData, pLast;\r\nHWND hFtpWnd;\r\nint Rc;\r\n \r\n if (ToolsLocateProcData () != NULL) return FTPERR_SESSIONUSED;\r\n\r\n Rc=Tcp4uInit ();\r\n if (Rc!=TCP4U_SUCCESS) return FTPERR_WINSOCKNOTUSABLE; \r\n\r\n if (pFirstProcData==NULL || IsBadWritePtr(pFirstProcData, sizeof *pFirstProcData))\r\n { \r\n pProcData = pFirstProcData = Calloc (1, sizeof *pProcData);\r\n if (pProcData==NULL) return FTPERR_INSMEMORY;\r\n pProcData->Next = pProcData->Prev = NULL;\r\n }\r\n else \r\n {\r\n for ( pLast=pFirstProcData ; pLast->Next!=NULL ; pLast= pLast->Next );\r\n pLast->Next = pProcData = Calloc (1, sizeof *pProcData);\r\n if (pProcData==NULL) return FTPERR_INSMEMORY;\r\n pProcData->Prev = pLast;\r\n pProcData->Next = NULL;\r\n }\r\n\r\n /* Get task information */ \r\n pProcData->hInstance = GetTaskInstance (hParentWnd); /* port32.c */\r\n /* fIdentifyThread callback sur l'appelant, nThread sa valeur */\r\n pProcData->fIdentifyThread = GetCurrentThreadId;\r\n pProcData->nThreadIdent = GetCurrentThreadId();\r\n\r\n\r\n /* est-ce que la fenetre interne a deja ete creee */\r\n if (pProcData==pFirstProcData)\r\n {WNDCLASS wndClass;\r\n\t /* lstrcpy (szFTPDLL_CLASSNAME, FTP4W_CLASS_NAME); */\r\n\t /* EnregistreClasse : Enregistre la classe de notre fenêtre */\r\n\t memset (& wndClass, 0, sizeof wndClass); \r\n\t wndClass.lpszClassName = FTP4W_CLASS_NAME;\r\n\t wndClass.hInstance = pProcData->hInstance;\r\n\t wndClass.lpfnWndProc = (WNDPROC) DLLWndProc;\r\n Rc = RegisterClass (&wndClass);\r\n\t if (! Rc) { FtpRelease(); return FTPERR_CANTCREATEWINDOW; } \r\n\t}\r\n#ifdef UNE_FENETRE \r\n if (pProcData==pFirstProcData)\r\n {\r\n#endif \r\n /* création de la fenêtre */ \r\n hFtpWnd=CreateWindow (FTP4W_CLASS_NAME,/* window class name */\r\n \"\", 0, /* window title, style */\r\n 0, 0, 0, 0, /* x, y, cx, xy */\r\n hParentWnd, /* a parent for this window */\r\n NULL, /* use the class menu */\r\n pProcData->hInstance, /* who created this wndw */\r\n NULL ); /* no parms to pass on */\r\n\t if (hFtpWnd==NULL) \r\n { \r\n FtpRelease ();\r\n return FTPERR_CANTCREATEWINDOW;\r\n }\r\n\t pProcData->hFtpWnd = hFtpWnd; \r\n#ifdef UNE_FENETRE \r\n } /* pas d'instance deja cree -> creation de la fenetre interne */\r\n\t /* si la fenetre interne existe, on la reutilise simplement */ \r\n else\r\n\t pProcData->hFtpWnd = pFirstProcData->hFtpWnd;\r\n#endif\r\n\r\n /* On remplit les infos relatives à la tâche */ \r\n pProcData->hParentWnd = hParentWnd;\r\n /* renseignements FTP : Pas de session existante */\r\n pProcData->ftp.ctrl_socket = INVALID_SOCKET;\r\n pProcData->ftp.data_socket = INVALID_SOCKET;\r\n /* juste pour noyer l'appel */\r\n pProcData->ftp.bVerbose = Protection (); /* Protection rend FALSE */\r\n pProcData->ftp.nTimeOut = FTP_DEFTIMEOUT;\r\n pProcData->ftp.hLogFile = HFILE_ERROR;\r\n pProcData->ftp.bPassif = FALSE;\r\n pProcData->ftp.nPort = FTP_DEFCTRLPORT;\r\n /* renseignement fichier */\r\n pProcData->File.bAborted = FALSE;\r\n pProcData->File.bNotify = FALSE;\r\n pProcData->File.bAsyncMode = TRUE;\r\n pProcData->File.hf = HFILE_ERROR;\r\n pProcData->File.nAsyncAlone= FTP_DEFASYNCALONE;\r\n pProcData->File.nAsyncMulti= FTP_DEFASYNCMULTI;\r\n pProcData->File.nDelay = FTP_DEFDELAY;\r\nreturn FTPERR_OK;\r\n}; /* FtpInit */\r\n\r\n\r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* tentative de Multithread */\r\n/* L'utilisateur donne un callback retournant un DWORD (typiquement */\r\n/* GetCurrentThreadId() appele a chaque appel Ftp4w32\t\t\t\t */\r\n/* Cet appel n'est pas fait dans la DLL car l'id retourne par Windows*/\r\n/* serait identique d'uin thread a l'autre (pas de difference a */\r\n/* l'interieur d'une DLL\t\t\t\t\t\t\t\t\t\t\t */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n/* Note warning \"voulu\" en compil 16 bits -> THREADID -> HANDLE */\r\n/* et déclaration en DWORD dans le .H */\r\nint _export PASCAL FAR FtpMtInit ( HWND hParentWnd, THREADID (CALLBACK *f)(void) )\r\n{\r\nLPProcData pProcData;\r\n\r\n /* Init comme d'habitude */\r\n int Rc=FtpInit (hParentWnd);\r\n if (Rc==FTPERR_OK) \r\n {\r\n\t /* et ecrasement des identifiants de thread */\r\n pProcData = ToolsLocateProcData ();\r\n pProcData->fIdentifyThread = f;\r\n pProcData->nThreadIdent = (*f) ();\r\n }\r\nreturn Rc; \r\n} /* FtpMtInit */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRelease */\r\n/* Libère les ressources Windows (fenêtre et */\r\n/* structure) prises par FtpInit */\r\n/* ------------------------------------------------------------ */\r\n\r\nint _export PASCAL FAR FtpRelease (void)\r\n{\r\nLPProcData pProcData;\r\n\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOACTIVESESSION;\r\n\r\n if (Tcp4uCleanup ()!=TCP4U_SUCCESS) return FTPERR_STILLCONNECTED;\r\n \r\n\r\n /* si une seule appli est enregistre detruire la fenetre */\r\n#ifdef UNE_FENETRE\r\n if (pProcData==pFirstProcData && pProcData->Next==NULL)\r\n {\r\n\t DestroyWindow (pProcData->hFtpWnd); /* Avant le UnregisterClass */\r\n UnregisterClass (FTP4W_CLASS_NAME, pProcData->hInstance);\r\n }\r\n#else \r\n DestroyWindow (pProcData->hFtpWnd); /* Avant le UnregisterClass */\r\n if (pProcData==pFirstProcData && pProcData->Next==NULL)\r\n\t UnregisterClass (FTP4W_CLASS_NAME, pProcData->hInstance);\r\n#endif\t \r\n if (pProcData->Next != NULL) pProcData->Next->Prev = pProcData->Prev;\r\n if (pProcData->Prev != NULL) pProcData->Prev->Next = pProcData->Next;\r\n else pFirstProcData = pProcData->Next;\r\n Free (pProcData);\r\nreturn FTPERR_OK;\r\n} /* FtpRelease */\r\n\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpLocalClose */\r\n/* Ferme les ressources Winsockets */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpLocalClose (void)\r\n{\r\nLPProcData pProcData;\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n FtpCloseFileTransfer (pProcData, FALSE);\r\n TcpClose (& pProcData->ftp.ctrl_socket);\r\nreturn pProcData->ftp.ctrl_socket==INVALID_SOCKET \r\n && pProcData->ftp.data_socket==INVALID_SOCKET ? \r\n FTPERR_OK : FTPERR_CANTCLOSE;\r\n} /* FtpLocalClose */\r\n\r\n\r\n \r\n/* ----------------------------------------------------------- */\r\n/* Procédure de fin de vie de la DLL */\r\n/* Libération des ressources Windows en cours */\r\n/* On essaie aussi de libérer les sockets utilisées */\r\n/* La procédure doit rendre 1 pour que le module soit */\r\n/* libéré */\r\n/* ----------------------------------------------------------- */\r\nint _export CALLBACK WEP (int nType)\r\n{\r\n nType=1; /* suppress warning */\r\nreturn 1;\r\n} /* WEP */\r\n\r\n\r\n\r\n\r\n/* --------------------------------------------------------------*/\r\n/* Fonction DLL FtpNOOP */\r\n/* Vide le buffer de control */\r\n/* ------------------------------------------------------------- */\r\nint _export PASCAL FAR FtpFlush (void)\r\n{\r\nLPProcData pProcData;\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n TcpFlush (pProcData->ftp.ctrl_socket);\r\nreturn FTPERR_OK;\r\n} /* FtpFlush () */\r\n\r\n\r\n\r\n/********************************************************************\r\n\tcreated:\t2008/05/29\r\n\tcreated:\t29:5:2008 13:06\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\svnLocal\\vtTnlMaster\\Manager\\xNetObject.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_plugins\\svnLocal\\vtTnlMaster\\Manager\r\n\tfile base:\txNetObject\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef _XNETOBJECT_H_\r\n#define _XNETOBJECT_H_\r\n\r\n#include \"tnl.h\"\r\n#include \"tnlNetObject.h\"\r\n#include \"xNetTypes.h\"\r\n\r\nclass xNetInterface;\r\nclass vtConnection;\r\n\r\nclass xNetObject : public TNL::NetObject\r\n{\r\n\r\n\t\r\npublic:\r\n\txNetObject();\r\n\txNetObject(xNString name);\r\n\tvirtual ~xNetObject();\r\n\ttypedef NetObject Parent;\r\n\r\nprotected:\r\n\txNString m_Name;\r\n\txNetInterface *m_NetInterface;\r\n\tint m_UserID;\r\n\tvtConnection *mOwnerConnection;\r\npublic :\r\n\txNString GetName() { return m_Name; }\r\n\tvoid SetName(xNString val) { m_Name = val; }\r\n\r\n\t\r\n\r\n\txNetInterface * getNetInterface() { return m_NetInterface; }\r\n\tvoid setNetInterface(xNetInterface * val) { m_NetInterface = val; }\r\n\r\n\t\r\n\tint getUserID() const { return m_UserID; }\r\n\tvoid setUserID(int val) { m_UserID = val; }\r\n\r\n\tvirtual void Destroy();\r\n\t\r\n\tvtConnection * getOwnerConnection() const { return mOwnerConnection; }\r\n\tvoid setOwnerConnection(vtConnection * val) { mOwnerConnection = val; }\r\n\r\n};\r\n\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pConfig.h\"\r\n\r\nint demoTimerExpired=0;\r\n\r\n\r\nvoid PhysicManager::advanceTime(float time)\r\n{\r\n\t\r\n\ttimer +=time;\r\n\tfloat timeNow = timer;\r\n\r\n\tmLastStepTime = time;\r\n\r\n}\r\n\r\nvoid PhysicManager::update(float stepsize)\r\n{\r\n\r\n\tadvanceTime(stepsize);\r\n\r\n#ifdef SESSION_LIMIT\r\n\t#ifndef REDIST\r\n\t\t\r\n\t\tif (timer >(SESSION_MAX))\r\n\t\t{\r\n\t\t\tif (demoTimerExpired==0)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"Demo expires after 15 mins\");\r\n\t\t\t\tdemoTimerExpired = 1;\r\n\t\t\t}\r\n\t\t\treturn ;\r\n\t\t}\r\n\t#endif\r\n#endif\r\n\t\r\n\r\n#ifdef REDIST\r\n\r\n\tif (m_Context->IsInInterfaceMode())\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"This is a redist Dll\");\r\n\t\treturn;\r\n\t}\r\n\t#pragma message(\"-------------------------------PManager ::Update REDIST\" )\r\n#endif\r\n\t\r\n#if PROFILER\r\n\t//CKTimeProfiler(const char* iTitle, CKContext* iContext, int iStartingCount = 4):\r\n\t//CKTimeProfiler MyProfiler(\"PhysX Step\",GetContext(),8);\r\n#endif\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tw->step(stepsize);\r\n\t\tit++;\r\n\t}\r\n\r\n\t//float pTime = MyProfiler\r\n\t//float a = pTime;\r\n}\r\n\r\nCKERROR PhysicManager::PostProcess()\r\n{\r\n\r\n\t\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\t//w->getCollisions().Clear();\r\n\t\tit++;\r\n\t}\r\n\r\n\tcleanAttributePostObjects();\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR PhysicManager::PreProcess()\r\n{\r\n\r\n\tfloat timeCtx = GetContext()->GetTimeManager()->GetLastDeltaTimeFree();\r\n\tupdate(timeCtx);\r\n\treturn CK_OK;\r\n}\r\n#pragma once\r\n\r\n#include \"StdAfx2.h\"\r\n#include \"VIControls.h\"\r\n#include \"ParameterDialog.h\"\r\n#include \"CKShader.h\"\r\n#include \"ParameterDialog.h\"\r\n//#include \"CUIKNotificationReceiver.h\"\r\n\r\n//--- Include \"GenericObjectParameterDialog.h\" from CK2UI define IDDs to mak it compile\r\n#define IDD_GENOBJECTDIALOG 2011\r\n#define IDD_BASEPARAMDIALOG 2000\r\n#include \"Parameters\\GenericObjectParameterDialog.h\"\r\n\r\n#include \"resource.h\"\r\n\r\n\r\n//--- Some constants\r\n#define MFC_NAME_OF_DIALOG \"#32770\"\r\n#define CHECK_MATERIAL_TIMER 57\r\n\r\nclass CPBCommonDialog : public CParameterDialog\r\n{\r\n\r\npublic:\r\n\t\r\n\r\n\tbool InitChildWin( CDialog* pDlg, UINT iWinID,int otherID );\r\n\tLRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\t\r\n\t//virtual BOOL Create(UINT nIDTemplate, CWnd* pParentWnd /* = NULL */);\r\n\r\n\tVIComboBox\t\t\tHType;\r\n\tVIStaticText LBL_HType;\r\n\tVIStaticText LBL_Flags;\r\n\tVIStaticText LBL_DFlags;\r\n\r\n\t\t\r\n\tVICheckButton\t\t\tBF_Move;\r\n\tVICheckButton\t\t\tBF_Grav;\r\n\tVICheckButton\t\t\tBF_Collision;\r\n\tVICheckButton\t\t\tBF_CollisionNotify;\r\n\t\r\n\tVICheckButton\t\t\tBF_Kinematic;\r\n\tVICheckButton\t\t\tBF_TriggerShape;\r\n\tVICheckButton\t\t\tBF_SubShape;\r\n\tVICheckButton\t\t\tBF_Sleep;\r\n\tVICheckButton\t\t\tBF_Hierarchy;\r\n\r\n\tVICheckButton\t\t\tBF_Deformable;\r\n\r\n\tVIStaticRectangle\t\tBF_BG_Rect;\r\n\tVIStaticRectangle\t\tBF_FLEX_Rect;\r\n\r\n\tCButton\t\tFlexButton;\r\n\tCStatic mPlaceHolder;\r\n\r\n\r\n\tVIStaticRectangle mDynaFlagsRect;\r\n\r\n\r\n\tVICheckButton\t\t\tTF_POS;\r\n\tVICheckButton\t\t\tTF_ROT;\r\n\t\r\n\r\n\r\n\tVICheckButton\t\t\tTF_PX;\t\tVICheckButton\t\t\tTF_RX;\r\n\tVICheckButton\t\t\tTF_PY;\t\tVICheckButton\t\t\tTF_RY;\r\n\tVICheckButton\t\t\tTF_PZ;\t\tVICheckButton\t\t\tTF_RZ;\r\n\r\n\r\n\tCToolTipCtrl *m_tt;\r\n\r\n\r\n\tint\t\t\t\t\tm_paramType;\r\n\r\n\tCPBCommonDialog(CKParameter* Parameter,CK_CLASSID Cid=CKCID_OBJECT) : CParameterDialog(Parameter,Cid) \r\n\t{\t\t\r\n\t\tsetEditedParameter(Parameter); \t\r\n\t\tm_tt =NULL;\r\n\r\n\t\t\r\n\r\n\r\n\t}\r\n\tvirtual ~CPBCommonDialog() {\t}\r\n\r\n\tCKParameter *m_EditedParameter;\r\n\t\r\n\tCKParameter * getEditedParameter() const { return m_EditedParameter; }\r\n\tvoid setEditedParameter(CKParameter * val) { m_EditedParameter = val; }\r\n\tvirtual CKBOOL On_Init();\r\n\r\n\t// associated resource id :\r\n\tenum { IDD = IDD_PBCOMMON };\r\n\t\r\n\t// Overrides\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(CPBCommonDialog)\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n\tvoid fillHullType();\r\n\tvoid fillFlags();\r\n\tvoid fillTransformationFlags();\r\n\r\npublic:\r\n\r\n\t\r\n\t\r\n\tvirtual BOOL On_UpdateFromParameter(CKParameter* p){\r\n\r\n//\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n//\t\tif(!p) return FALSE;\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\tvirtual BOOL On_UpdateToParameter(CKParameter* p){\r\n\r\n\r\n/*\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\tif(!p) return FALSE;\r\n\r\n\t\tCString cstr;\r\n/*\r\n\t\t\r\n\t\t\r\n*/\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\t\t\r\n\t\r\n\t\r\n\tvirtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r\n\t\r\n\r\npublic:\r\n\r\n\r\n\tCKParameter *parameter;\r\n\tVIEdit editValue;\r\n\tVIStaticText textValue;\r\n\tDECLARE_MESSAGE_MAP()\r\n\tvirtual BOOL OnInitDialog();\r\n\tvirtual BOOL PreTranslateMessage(MSG* pMsg);\r\n\tafx_msg void OnStnClickedDynaFlagsRect();\r\n};#pragma once\r\n\r\n#include \"StdAfx2.h\"\r\n#include \"VIControls.h\"\r\n#include \"ParameterDialog.h\"\r\n#include \"CKShader.h\"\r\n#include \"ParameterDialog.h\"\r\n#include \"MultiParamEditDlg.h\"\r\n\r\n//#include \"CUIKNotificationReceiver.h\"\r\n\r\n//--- Include \"GenericObjectParameterDialog.h\" from CK2UI define IDDs to mak it compile\r\n#define IDD_GENOBJECTDIALOG 2011\r\n#define IDD_BASEPARAMDIALOG 2000\r\n#include \"Parameters\\GenericObjectParameterDialog.h\"\r\n\r\n#include \"resource.h\"\r\n\r\n\r\n\r\n#include \"PCommonDialog.h\"\r\n\r\n\r\n//--- Some constants\r\n#define MFC_NAME_OF_DIALOG \"#32770\"\r\n#define CHECK_MATERIAL_TIMER 57\r\n\r\nclass CPBXMLSetup : public MultiParamEditDlg , public CPSharedBase\r\n{\r\n\r\npublic:\r\n\r\n\t//\tvirtual void PreSubclassWindow();\r\n\r\n\tint\t\t\t\t\tm_paramType;\r\n\r\n\tCPBXMLSetup(CKContext* context,CWnd* parent = NULL);\r\n\tCPBXMLSetup(CKParameter* Parameter,CK_CLASSID Cid=CKCID_OBJECT);\r\n\tvirtual ~CPBXMLSetup();\r\n\tvoid _destroy();\r\n\r\n\t//virtual BOOL Create(UINT nIDTemplate, CWnd* pParentWnd);\r\n\tvirtual void Init(CParameterDialog *parent);\r\n\r\n\tCParameterDialog* refresh(CKParameter*src);\r\n\t/************************************************************************/\r\n\t/* Overrides \r\n\t*/\r\n\t/************************************************************************/\r\n\tvoid OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);\r\n\tLRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Accessors */\r\n\t/************************************************************************/\r\n\tCKParameter * getEditedParameter() const { return mParameter; }\r\n\tvoid setEditedParameter(CKParameter * val) { mParameter= val; }\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Virtools mParameter transfer callbacks : */\r\n\t/************************************************************************/\r\n\tvirtual BOOL On_UpdateFromParameter(CKParameter* p){\r\n\r\n\t\t//\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\t//\t\tif(!p) return FALSE;\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\tvirtual BOOL On_UpdateToParameter(CKParameter* p)\r\n\t{\r\n\r\n\t\t/*\r\n\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\tif(!p) return FALSE;\r\n\t\tCString cstr;*/\r\n\t\treturn TRUE;\r\n\r\n\t}\r\n\r\n\r\n\r\n\t// associated resource id :\r\n\tenum { IDD = IDD_PBCOMMON_DEFORMABLE };\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* MFC\t */\r\n\t/************************************************************************/\r\n\t//{{AFX_VIRTUAL(CPBXMLSetup)\r\nprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n\r\n\t//{{AFX_MSG(CPBXMLSetup)\r\n\t//ON_REGISTERED_MESSAGE(_afxMsgMouseWheel, OnRegisteredMouseWheel);\r\n\t//afx_msg void OnMouseMove(UINT nFlags, CPoint point);\r\n\t//afx_msg void OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);\r\n\r\n\t//}}AFX_MSG\r\n\r\npublic:\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Low Level passes */\r\n\t/************************************************************************/\r\n\tLRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Members */\r\n\t/************************************************************************/\r\n\r\n\r\npublic:\r\n\r\n\r\n\tCKParameter *mParameter;\r\n\tVIEdit editValue;\r\n\tVIStaticText textValue;\r\n\tVIComboBox\t\t\ttype;\r\n\r\n\tDECLARE_MESSAGE_MAP()\r\n\r\n\t\r\n};\r\n#ifndef __PSHAPE_H_\r\n#define __PSHAPE_H_\r\n\r\n\r\n#include \"vtOdeEnums.h\"\r\n#include \"vtOdeTypes.h\"\r\n#include \"pPrereqs.h\"\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\tclass pShape\r\n\t{\r\n\t\tpublic :\r\n\r\n\t\tpShape()\r\n\t\t{\r\n\r\n\t\t}\r\n\t\tvirtual ~pShape(){}\r\n\t\tdGeomID m_OdeGeomID;\r\n\t\t\r\n\t\tdGeomID OdeGeomID() const { return m_OdeGeomID; }\r\n\t\tvoid OdeGeomID(dGeomID val) { m_OdeGeomID = val; }\r\n\r\n\t\tvoid SetOffsetPosition (VxVector position);\r\n\t\tvoid setOffsetQuaternion(VxQuaternion quad);\r\n\r\n\t\tvoid setOffsetWorldPosition(VxVector position);\t\t\r\n\t\tvoid setOffsetWorldQuaternion(VxQuaternion orientation) ;\r\n\r\n\t};\r\n\r\n\r\n}\r\n\r\n\r\n#endif#ifndef __VT_PYTHON_FUNCS_H_\r\n#define __VT_PYTHON_FUNCS_H_\r\n\r\n//class PythonModule;\r\n\r\n\tint vpInitModules();\r\n\tint vpCInit();\r\n\tvoid vpCPyRun_SimpleString(const char*);\r\n\tvoid DestroyPython();\r\n\tconst char* vpSimpleTest(const char*,const char*,const char*);\r\n\tbool PythonLoad();\r\n\tvoid PySetupStdRedirect(void);\r\n\r\n\tint syspath_append( char *dirname );\n\n\t//PythonModule* CreatePythonModule(const char*file,const char*func,int bid);\n\n\t\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pVTireFunction.h\"\r\n\r\n pTireFunction::pTireFunction()\r\n{\r\n\tsetToDefault();\r\n}\r\n\r\n void pTireFunction::setToDefault()\r\n{\r\n\textremumSlip = 1.0f;\r\n\textremumValue = 0.02f;\r\n\tasymptoteSlip = 2.0f;\r\n\tasymptoteValue = 0.01f;\t\r\n\tstiffnessFactor = 1000000.0f;\t//quite stiff by default.\r\n\txmlLink =0;\r\n\r\n}\r\n\r\n bool pTireFunction::isValid() const\r\n{\r\n\tif(!(0.0f < extremumSlip))\t\t\treturn false;\r\n\tif(!(extremumSlip < asymptoteSlip))\treturn false;\r\n\tif(!(0.0f < extremumValue))\t\t\treturn false;\r\n\tif(!(0.0f < asymptoteValue))\t\treturn false;\r\n\tif(!(0.0f <= stiffnessFactor))\t\treturn false;\r\n\r\n\treturn true;\r\n}\r\n\r\n\r\n float pTireFunction::hermiteEval(float t) const\r\n{\r\n\r\n\t// This fix for TTP 3429 & 3675 is from Sega.\r\n\t// Assume blending functions (look these up in a graph):\r\n\t// H0(t) = 2ttt - 3tt + 1\r\n\t// H1(t) = -2ttt + 3tt\r\n\t// H2(t) = ttt - 2tt + t\r\n\t// H3(t) = ttt - tt \r\n\r\n\tfloat v = NxMath::abs(t);\r\n\tfloat s = (t>=0) ? 1.0f : -1.0f;\r\n\r\n\tfloat F;\r\n\r\n\tif(vREM lua5.1.exe -e \"io.stdout:setvbuf 'no'\" --Dev=Dev35 --file=\"./premake4.lua\" -A vs2003\r\n\r\npremake4 --ExternalVTDirectory=./VTPaths.lua --DeployDirect=TRUE --Dev=Dev40 --file=\"./premake4.lua\" vs2003\r\nREM premake4 --ExternalVTDirectory=./VTPaths.lua --DeployDirect=TRUE --Dev=Dev40 --file=\"./premake4.lua\" vs2005\r\nREM lua5.1.exe -e \"io.stdout:setvbuf 'no'\" --Dev=Dev40 --file=\"./premake4.lua\" -A vs2008\r\nREM lua5.1.exe -e \"io.stdout:setvbuf 'no'\" --Dev=Dev41 --file=\"./premake4.lua\" -A vs2005\r\nREM Please install CMAKE BEFORE !!!!!\r\n\r\ncd Scripts\r\nfindDevDirs.bat\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"CK3dPointCloud.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\nint RenderParticles_P(CKRenderContext *dev,CKRenderObject *obj,void *arg);\r\n\r\nvoid pFactory::copyToEmitterDesc(NxFluidEmitterDesc&dst,pFluidEmitterDesc src)\r\n{\r\n\r\n\r\n\tdst.dimensionX = src.dimensionX;\r\n\tdst.dimensionY = src.dimensionY;\r\n\tdst.flags = (NxFluidEmitterFlag)src.flags;\r\n\tdst.fluidVelocityMagnitude = src.fluidVelocityMagnitude;\r\n\tdst.maxParticles = src.maxParticles;\r\n\tdst.particleLifetime = src.particleLifetime;\r\n\tdst.randomAngle = src.randomAngle;\r\n\tdst.randomPos = getFrom( src.randomPos);\r\n\tdst.rate = src.rate;\r\n\tdst.type = (NxEmitterType)src.type;\r\n\tdst.repulsionCoefficient = src.repulsionCoefficient;\r\n\tif (src.frameShape)\r\n\t{\r\n\t\tpWorld *w = GetPMan()->getWorldByShapeReference(src.frameShape);\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tNxShape *shape = w->getShapeByEntityID(src.frameShape->GetID());\r\n\t\t\tif (shape)\r\n\t\t\t{\r\n\t\t\t\tdst.frameShape = shape;\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tdst.frameShape = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\t\r\n\r\n\r\n}\r\n\r\nvoid pFactory::initParticles(pFluidDesc &desc,NxParticleData&dst,CK3dEntity*srcReference,CK3dEntity*dstEntity)\r\n{\r\n\r\n\t\r\n\tCKMesh *mesh = dstEntity->GetCurrentMesh();\r\n\tif (!mesh)\r\n\treturn;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tmesh->SetVertexCount(desc.maxParticles);\r\n\tCKDWORD stride;\r\n\tvoid*\tptr = mesh->GetPositionsPtr(&stride);\r\n\tXPtrStrided vpos(ptr,stride);\r\n\r\n\tVxVector pos(0,0,0);\r\n\r\n\tfor (int i = 0 ; i < mesh->GetVertexCount();i++ )\r\n\t{\r\n\t\tpos.x +=(float)(i*0.0001f);\r\n\t\tmesh->SetVertexPosition(i,&pos);\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tmesh->VertexMove();\r\n\r\n\tchar* bufferPos = reinterpret_cast(dst.bufferPos);\r\n\tchar* bufferVel = reinterpret_cast(dst.bufferVel);\r\n\tchar* bufferLife = reinterpret_cast(dst.bufferLife);\r\n\r\n\t\r\n//\tif(bufferPos == NULL && bufferVel == NULL && bufferLife == NULL)\r\n//\t\treturn;\r\n/*\r\n\tNxVec3 aabbDim;\r\n\taabb.getExtents(aabbDim);\r\n\taabbDim *= 2.0f;\r\n*/\r\n\t(*dst.numParticlesPtr) = 0;\r\n\r\n\tfor (int j = 0 ; j < desc.maxParticles ; j ++ )\r\n\t{\r\n\t\tVxVector mPos;\r\n\t\tmesh->GetVertexPosition(j,&mPos);\r\n\r\n\t\tsrcReference->Transform(&mPos,&mPos);\r\n\r\n\t\tNxVec3 p(mPos.x,mPos.y,mPos.z);\r\n\r\n\r\n\t\tNxVec3& position = *reinterpret_cast(bufferPos);\r\n\t\tposition = p;\r\n\t\tint stride = dst.bufferPosByteStride;\r\n\t\tbufferPos += dst.bufferPosByteStride;\r\n\r\n\r\n\t\tNxVec3& velocity = *reinterpret_cast(bufferVel);\r\n\t\tNxVec3 vel;\r\n\t\tvelocity = vel;\r\n\t\tbufferVel += dst.bufferVelByteStride;\r\n\r\n\t\tif (bufferLife)\r\n\t\t{\r\n\t\t\tNxReal& life = *reinterpret_cast(bufferLife);\r\n\t\t\tlife = 0.0f;\r\n\t\t\tbufferLife += dst.bufferLifeByteStride;\r\n\t\t}\r\n\r\n\t\t(*dst.numParticlesPtr)++;\r\n\t}\r\n\r\n}\r\n\r\npFluid* pFactory::createFluid(CK3dEntity *srcReference ,pFluidDesc desc)\r\n{\r\n\r\n\t//Create a set of initial particles\r\n\t\r\n\tpParticle*\tinitParticle = new pParticle[desc.maxParticles];\r\n\tunsigned initParticlesNum = 0;\r\n\r\n\t//Setup structure to pass initial particles.\r\n\tNxParticleData initParticleData;\r\n\tinitParticleData.numParticlesPtr\t\t= &initParticlesNum;\r\n\tinitParticleData.bufferPos\t\t\t\t= &initParticle[0].position.x;\r\n\tinitParticleData.bufferPosByteStride\t= sizeof(pParticle);\r\n\tinitParticleData.bufferVel\t\t\t\t= &initParticle[0].velocity.x;\r\n\tinitParticleData.bufferVelByteStride\t= sizeof(pParticle);\r\n\r\n\tCK3dEntity *particleEntity = createFluidEntity();\r\n\r\n\tCKMesh *mesh = particleEntity->GetCurrentMesh();\r\n\tmesh->SetVertexCount(desc.maxParticles);\r\n\t\r\n\tVxVector pos;\r\n\r\n\tsrcReference->GetPosition(&pos);\r\n\tparticleEntity->SetPosition(&pos);\r\n\r\n\tCK3dPointCloud *cloud = createPointCloud(desc);\r\n\tif (cloud)\r\n\t{\r\n\t\tcloud->SetReferentialPosition(pos);\r\n\t}\r\n\r\n\t//initParticles(desc,initParticleData,srcReference,particleEntity);\r\n\t\r\n\r\n\t//Setup fluid descriptor\r\n\tNxFluidDesc fluidDesc;\r\n\tfluidDesc.setToDefault();\r\n\r\n\tcopyToFluidDescr(fluidDesc,desc);\r\n\r\n\t/*fluidDesc.maxParticles = desc.maxParticles;\r\n\tfluidDesc.kernelRadiusMultiplier\t\t= 2.0f;\r\n\tfluidDesc.restParticlesPerMeter\t\t\t= 10.0f;\r\n\tfluidDesc.motionLimitMultiplier\t\t\t= 3.0f;\r\n\tfluidDesc.packetSizeMultiplier\t\t\t= 8;\r\n\tfluidDesc.collisionDistanceMultiplier = 0.1;\r\n\tfluidDesc.stiffness\t\t\t\t\t\t= 50.0f;\r\n\tfluidDesc.viscosity\t\t\t\t\t\t= 40.0f;\r\n\tfluidDesc.restDensity\t\t\t\t\t= 1000.0f;\r\n\tfluidDesc.damping\t\t\t\t\t\t= 0.0f;\r\n\tfluidDesc.restitutionForStaticShapes\t= 0.2f;\r\n\tfluidDesc.dynamicFrictionForStaticShapes= 0.05f;\r\n\tfluidDesc.simulationMethod\t\t\t\t= NX_F_SPH;*/\r\n\tfluidDesc.flags &= ~NX_FF_HARDWARE;\r\n\r\n\r\n\t//Add initial particles to fluid creation.\r\n\tfluidDesc.initialParticleData\t\t\t= initParticleData;\r\n\r\n\r\n\t//Create user fluid.\r\n\t//- create NxFluid in NxScene\r\n\t//- setup the buffers to read from data from the SDK\r\n\t//- set NxFluid::userData field to MyFluid instance\r\n\tbool trackUserData = false;\r\n\tbool provideCollisionNormals = false;\r\n\r\n\tpFluid* fluid = new pFluid(fluidDesc, trackUserData, provideCollisionNormals, getFrom(NxVec3(0.4f,0.5f,0.9f)), 0.03f);\r\n\r\n\t\r\n\tif (fluidDesc.flags & NX_FF_HARDWARE)\r\n\t{\r\n\t\tint op = 2;\r\n\t}\r\n\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\tCK3dEntity*worldReference = (CK3dEntity*)GetPMan()->m_Context->GetObject(desc.worldReference);\r\n\r\n\tif (!worldReference)\r\n\t{\r\n\t\tif (GetPMan()->getDefaultWorld())\r\n\t\t{\r\n\t\t\tworldReference = GetPMan()->getDefaultWorld()->getReference();\r\n\t\t}else\r\n\t\t\treturn NULL;\r\n\t}\r\n\r\n\tpWorld*world = GetPMan()->getWorld(worldReference->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\treturn NULL;\r\n\r\n\t}\r\n\r\n\tint s = fluidDesc.isValid(); \r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\tNxFluid* xfluid = world->getScene()->createFluid(fluidDesc);\r\n\tif (xfluid)\r\n\t{\r\n\t\txfluid->userData = fluid;\r\n\t\tfluid->setFluid( xfluid );\r\n\t\tfluid->setEntityID( particleEntity->GetID() );\r\n\r\n\t\tparticleEntity->SetRenderCallBack(RenderParticles_P,fluid);\r\n\r\n\t\treturn fluid;\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nvoid pFactory::copyToFluidDescr(NxFluidDesc &dst , pFluidDesc src )\r\n{\r\n\r\n\tdst.attractionForDynamicShapes = src.attractionForDynamicShapes;\r\n\tdst.attractionForStaticShapes = src.attractionForStaticShapes;\r\n\tdst.collisionDistanceMultiplier = src.collisionDistanceMultiplier;\r\n\tdst.collisionGroup = src.collisionGroup;\r\n\tdst.collisionMethod = src.collisionMethod;\r\n\tdst.collisionResponseCoefficient =src.collisionResponseCoefficient;\r\n\tdst.damping = src.damping;\r\n\tdst.dynamicFrictionForDynamicShapes = src.dynamicFrictionForDynamicShapes;\r\n\tdst.dynamicFrictionForStaticShapes = src.dynamicFrictionForStaticShapes;\r\n\tdst.externalAcceleration = getFrom(src.externalAcceleration);\r\n\tdst.fadeInTime = src.fadeInTime;\r\n\tdst.kernelRadiusMultiplier = src.kernelRadiusMultiplier;\r\n\tdst.packetSizeMultiplier = src.packetSizeMultiplier;\r\n\tdst.maxParticles = src.maxParticles;\r\n\tdst.motionLimitMultiplier = src.motionLimitMultiplier;\r\n\tdst.numReserveParticles = src.numReserveParticles;\r\n\tdst.packetSizeMultiplier = src.packetSizeMultiplier;\r\n\tdst.restitutionForDynamicShapes = src.restitutionForDynamicShapes;\r\n\tdst.restitutionForStaticShapes =src.restitutionForStaticShapes;\r\n\tdst.restParticlesPerMeter = src.restParticlesPerMeter;\r\n\tdst.restDensity = src.restDensity;\r\n\tdst.simulationMethod = src.simulationMethod;\r\n\tdst.staticFrictionForDynamicShapes = src.staticFrictionForDynamicShapes;\r\n\tdst.staticFrictionForStaticShapes = src.staticFrictionForStaticShapes;\r\n\tdst.stiffness = src.stiffness;\r\n\tdst.surfaceTension =src.surfaceTension;\r\n\tdst.viscosity =src.viscosity;\r\n\tdst.flags = src.flags;\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\nCK3dEntity*pFactory::createFluidEntity()\r\n{\r\n\r\n\tCK3dEntity *result = NULL;\r\n\tCK_OBJECTCREATION_OPTIONS creaoptions = CK_OBJECTCREATION_DYNAMIC;\r\n\r\n\tXString name;\r\n\tname << \"_Decal\";\r\n\r\n\tCK3dEntity* decal = (CK3dEntity*)ctx()->CreateObject(CKCID_3DOBJECT,name.Str(),creaoptions);\r\n\r\n\tname << \"Mesh\";\r\n\tCKMesh* decalmesh = (CKMesh*)ctx()->CreateObject(CKCID_MESH,name.Str(),creaoptions);\r\n\tif (!decalmesh) return NULL;\r\n\r\n\t// Add to the level\r\n\tCKLevel* level = ctx()->GetCurrentLevel();\r\n\tCKScene* scene = ctx()->GetCurrentScene();\r\n\r\n\tlevel->AddObject(decal);\r\n\tlevel->AddObject(decalmesh);\r\n\r\n\t// And to the current scene if any\r\n\tif (scene != level->GetLevelScene()) {\r\n\t\tscene->AddObject(decal);\r\n\t\tscene->AddObject(decalmesh);\r\n\t}\r\n\r\n\t// 3DEntity\r\n\tdecal->SetWorldMatrix(VxMatrix::Identity());\r\n\tdecal->SetCurrentMesh(decalmesh);\r\n\r\n\treturn decal;\r\n\r\n}\r\n\r\n\r\nCK3dPointCloud*pFactory::createPointCloud(const pFluidDesc&descr)\r\n{\r\n\r\n\tCK3dPointCloud*result = NULL;\r\n\tCK_OBJECTCREATION_OPTIONS creaoptions = CK_OBJECTCREATION_DYNAMIC;\r\n\r\n\tXString name;\r\n\tname << \"_FluidCloud\";\r\n\r\n\tresult = (CK3dPointCloud*)ctx()->CreateObject(CKCID_3DPOINTCLOUD,name.Str(),creaoptions);\r\n\t// Add to the level\r\n\tCKLevel* level = ctx()->GetCurrentLevel();\r\n\tCKScene* scene = ctx()->GetCurrentScene();\r\n\r\n\tlevel->AddObject((CKObject*)result);\r\n\r\n\t// And to the current scene if any\r\n\tif (scene != level->GetLevelScene()) {\r\n\t\tscene->AddObject((CKSceneObject*)result);\r\n\t}\r\n\r\n\t// 3DEntity\r\n\tresult->SetWorldMatrix(VxMatrix::Identity());\r\n\t//decal->SetCurrentMesh(decalmesh);\r\n\r\n\treturn result;\r\n\r\n\r\n\r\n\r\n}\r\n\r\n#endif // HAS_FLUIDS\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n\r\n#include \"xNetTypes.h\"\r\n#include \"tnl.h\"\r\n#include \"tnlPlatform.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"tnlGhostConnection.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n\r\n#include \"xPredictionSetting.h\"\r\n\r\n\r\n\r\nCKGUID GetNetManagerGUID() { \treturn NET_MAN_GUID;}\r\nextern xNetInterface* GetNetInterfaceServer();\r\nextern xNetInterface *GetNetInterfaceClient();\r\n\r\nxNetInterface*\r\nGetNetInterface()\r\n{\r\n\r\n\tif (GetNetInterfaceClient())\r\n\t{\r\n\t\treturn GetNetInterfaceClient();\r\n\t}\r\n\tif (GetNetInterfaceServer())\r\n\t{\r\n\t\treturn GetNetInterfaceServer();\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\n\r\n#include \"xLogger.h\"\r\n\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#define VIRTOOLS_DEV35\r\n\r\n\r\nvoid xSConsoleMessage(const char *msg)\r\n{\r\n\t//TNL::logprintf(msg);\r\n\txLogger::xLog(ELOGWARNING,E_LI_VSL,\"vsl message : %s\",msg);\r\n}\r\nvoid xSConsoleError(const char *msg)\r\n{\r\n\t//TNL::logprintf(msg);\r\n\txLogger::xLog(ELOGERROR,E_LI_VSL,\"vsl message : %s\",msg);\r\n}\r\n\r\nconst char*\r\nxSGetCommandLine()\r\n{\r\n\treturn GetCommandLine();\r\n\r\n}\r\nvoid vtNetworkManager::RegisterVSL()\r\n{\r\n\r\n\t\t//TNLLogEnable(LogGhostConnection, true);\r\n\t\t//TNLLogEnable(LogNetInterface,true);\r\n\t\t//TNLLogEnable(LogConnectionProtocol,true);\r\n\t\t//TNLLogEnable(LogNetConnection,true);\r\n\r\n\t\tSTARTVSLBIND(m_Context)\r\n\r\n\r\n\t\tDECLAREFUN_C_0(CKGUID, GetNetManagerGUID)\r\n\t\tDECLAREFUN_C_1(void,xSConsoleMessage,const char*)\r\n\t\tDECLAREFUN_C_1(void,xSConsoleError,const char*)\r\n\t\tDECLAREFUN_C_0(const char*,xSGetCommandLine)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Dist Object enumerations */\r\n\t\t/************************************************************************/\r\n\r\n\t\tDECLAREENUM(\"E_DC_BASE_TYPE\")\r\n\t\tDECLAREENUMVALUE(\"E_DC_BASE_TYPE\",\"E_DC_BTYPE_3D_ENTITY\",0)\r\n\t\tDECLAREENUMVALUE(\"E_DC_BASE_TYPE\",\"E_DC_BTYPE_2D_ENTITY\",1)\r\n\t\tDECLAREENUMVALUE(\"E_DC_BASE_TYPE\",\"E_DC_BTYPE_CLIENT\",2)\r\n\t\tDECLAREENUMVALUE(\"E_DC_BASE_TYPE\",\"E_DC_BTYPE_SESSION\",3)\r\n\r\n\t\tDECLAREENUM(\"E_OBJECT_TYPE\")\r\n\t\tDECLAREENUMVALUE(\"E_OBJECT_TYPE\",\"E_OT_DIST_OBJECT\",0)\r\n\t\tDECLAREENUMVALUE(\"E_OBJECT_TYPE\",\"E_OT_DIST_PROPERTY\",1)\r\n\t\tDECLAREENUMVALUE(\"E_OBJECT_TYPE\",\"E_OT_CLASS\",2)\r\n\r\n\r\n\r\n\r\n\t\tDECLAREENUM(\"E_DC_PROPERTY_TYPE\")\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_3DVECTOR\",0)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_QUATERNION\",1)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_2DVECTOR\",2)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_FLOAT\",3)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_INT\",4)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_BOOL\",5)\r\n\t\tDECLAREENUMVALUE(\"E_DC_PROPERTY_TYPE\",\"E_DC_PTYPE_STRING\",6)\r\n\r\n\t\tDECLAREENUM(\"E_DC_3D_NATIVE_PROPERTIES\")\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_LOCAL_POSITION\",1)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_LOCAL_ROTATION\",2)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_LOCAL_SCALE\",3)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_WORLD_POSITION\",4)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_WORLD_ROTATION\",5)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_WORLD_SCALE\",6)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_VISIBILITY\",7)\r\n\t\tDECLAREENUMVALUE(\"E_DC_3D_NATIVE_PROPERTIES\",\"E_DC_3D_NP_USER_0\",8)\r\n\r\n\r\n\t\tDECLAREENUM(\"E_PREDICTION_TYPE\")\r\n\t\tDECLAREENUMVALUE(\"E_PREDICTION_TYPE\",\"E_PTYPE_PREDICTED\",0)\r\n\t\tDECLAREENUMVALUE(\"E_PREDICTION_TYPE\",\"E_PTYPE_RELIABLE\",1)\r\n\t\tDECLAREENUMVALUE(\"E_PREDICTION_TYPE\",\"E_PTYPE_NON_RELIABLE\",2)\r\n\t\t\r\n\r\n\t\tDECLAREPOINTERTYPE(xDistributedClass)\r\n\t\tDECLAREPOINTERTYPE(xDistributed3DObjectClass)\r\n\t\tDECLAREPOINTERTYPE(IDistributedClasses)\r\n\t\tDECLAREPOINTERTYPE(IDistributedObjects)\r\n\t\t\r\n\t\tDECLAREPOINTERTYPE(xDistributedObject)\r\n\t\tDECLAREPOINTERTYPE(xDistributed3DObject)\r\n\r\n\t\tDECLAREPOINTERTYPE(xDistributedPropertyInfo)\r\n\t\tDECLAREPOINTERTYPE(xDistributedProperty)\r\n\t\tDECLAREPOINTERTYPE(xPredictionSetting)\r\n \r\n\r\n\t\tDECLAREPOINTERTYPE(vtConnection)\r\n\t\tDECLAREPOINTERTYPE(xNetInterface)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Distributed Network Classes :\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\t\r\n\t\tDECLAREMETHOD_2(IDistributedClasses,xDistributedClass*,createClass,const char*,int)\r\n\t\tDECLAREMETHOD_1(IDistributedClasses,xDistributedClass*,get,const char*)\r\n\t\tDECLAREMETHOD_1(IDistributedClasses,xDistributedClass*,getByIndex,int)\r\n\t\tDECLAREMETHOD_1(IDistributedClasses,xDistributedClass*,getByIndex,int)\r\n\t\tDECLAREMETHOD_0(IDistributedClasses,int,getNumClasses)\r\n\r\n#ifndef VIRTOOLS_DEV35\r\n\r\n\t\tDECLAREMETHOD_1(IDistributedClasses,int,destroyClass,xDistributedClass*)\r\n\t\tDECLAREMETHOD_1(IDistributedClasses,void,deployClass,xDistributedClass*)\r\n\r\n\t\tDECLAREMETHOD_1(xDistributedClass,xDistributedClass*,cast,xDistributed3DObjectClass*) \r\n\t\tDECLAREMETHOD_1(xDistributedClass,xDistributed3DObjectClass*,cast,int)\r\n\r\n#endif\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\r\n\t\t//\r\n\t\t//\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tDECLAREMETHOD_2(xDistributedClass,void,addProperty,int,int)\r\n\t\tDECLAREMETHOD_3(xDistributedClass,void,addProperty,const char*,int,int)\r\n\r\n\r\n\t\tDECLAREOBJECTTYPE(vtNetworkManager)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Network Manager :\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\r\n\t\tDECLARESTATIC_1(vtNetworkManager,vtNetworkManager*,Cast,CKBaseManager* iM)\r\n\t\tDECLAREMETHOD_3(vtNetworkManager,int,CreateClient,bool,int,const char*)\r\n\t\tDECLAREMETHOD_3(vtNetworkManager,int,CreateServer,bool,int,const char*)\r\n\t\tDECLAREMETHOD_2(vtNetworkManager,int,ConnectToServer,bool,const char*)\r\n\t\tDECLAREMETHOD_0(vtNetworkManager,int,CreateLocalConnection)\r\n\t\t\r\n#ifndef VIRTOOLS_DEV35\r\n\t\tDECLAREMETHOD_1(vtNetworkManager,int,DeleteServer,int)\r\n\t\tDECLAREMETHOD_0(vtNetworkManager,float,getMinTickTime)\r\n\t\tDECLAREMETHOD_1(vtNetworkManager,void,setMinTickTime,float)\r\n#endif\r\n\t\t\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_0(vtNetworkManager,xNetInterface*,GetServerNetInterface)\r\n\t\tDECLAREMETHOD_0(vtNetworkManager,xNetInterface*,GetClientNetInterface)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* net interface methods : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREFUN_C_0(xNetInterface*, GetNetInterface)\r\n\t\tDECLAREMETHOD_0(xNetInterface,IDistributedObjects*,getDistObjectInterface)\r\n\t\tDECLAREMETHOD_0(xNetInterface,void,createScopeObject)\r\n\t\tDECLAREMETHOD_0(xNetInterface,IDistributedClasses*,getDistributedClassInterface)\r\n\t\tDECLAREMETHOD_1(xNetInterface,int,getNumDistributedObjects,int)\r\n\t\tDECLAREMETHOD_2(xNetInterface,void,printObjects,int,int)\r\n\t\tDECLAREMETHOD_3(xNetInterface,void,enableLogLevel,int,int,int)\r\n\r\n\t\tDECLAREMETHOD_0(xNetInterface,float,getLastOneWayTime)\r\n\t\tDECLAREMETHOD_0(xNetInterface,float,getLastRoundTripTime)\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/*IDistObjects : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_2(IDistributedObjects,void,create,const char*,const char*)\r\n\t\tDECLAREMETHOD_3(IDistributedObjects,xDistributedObject*,create,int,const char*,const char*)\r\n\t\tDECLAREMETHOD_1(IDistributedObjects,xDistributedObject*,get,int)\r\n\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* xDistributed Objects : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(xDistributedObject,xDistributed3DObject*,cast,xDistributedObject*)\r\n\t\tDECLAREMETHOD_0(xDistributed3DObject,void,updateAll)\r\n\t\tDECLAREMETHOD_0(xDistributed3DObject,void,doInitUpdate)\r\n\r\n\r\n#ifndef VIRTOOLS_DEV35\r\n\t\tDECLAREMETHOD_0(xDistributedObject,void,getGhostDebugID)\r\n\t\tDECLAREMETHOD_1(xDistributedObject,void,setGhostDebugID,int)\r\n\t\tDECLAREMETHOD_1(xDistributedObject,void,setSessionID,int)\r\n\t\tDECLAREMETHOD_0(xDistributedObject,int,getSessionID)\r\n\r\n\r\n\t\tDECLAREMETHOD_1(xDistributedObject,xDistributedProperty*,getProperty,int)\r\n\t\tDECLAREMETHOD_1(xDistributedObject,xDistributedProperty*,getUserProperty,const char*)\r\n\t\tDECLAREMETHOD_0(xDistributedProperty,xPredictionSetting*,getPredictionSettings)\r\n\t\tDECLAREMETHOD_1(xDistributedObject,xDistributedProperty*,getProperty,int)\r\n\r\n\t\tDECLAREMETHOD_1(xPredictionSetting,void,setMinSendTime,float)\r\n\t\tDECLAREMETHOD_0(xPredictionSetting,float,getMinSendTime)\r\n\r\n\t\tDECLAREMETHOD_1(xPredictionSetting,void,setMinDifference,float)\r\n\t\tDECLAREMETHOD_0(xPredictionSetting,float,getMinDifference)\r\n\r\n\t\tDECLAREMETHOD_1(xPredictionSetting,void,setPredictionFactor,float)\r\n\t\tDECLAREMETHOD_0(xPredictionSetting,float,getPredictionFactor)\r\n\r\n#endif\r\n\t\t\r\n\t\tSTOPVSLBIND\r\n\r\n\r\n\t\t\r\n}#pragma once\r\n\r\nvoid PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface);\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xMathStream.h\"\r\n#include \"xPredictionSetting.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\n\r\nuxString \r\nxDistributedQuatF::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedQuatF::updateFromServer(xNStream *stream)\r\n{\r\n\r\n\txMath::stream::mathRead(*stream,&mLastServerValue);\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\txMath::stream::mathRead(*stream,&mLastServerDifference);\r\n\t}\r\n\t\r\n\tsetValueState(E_DV_UPDATED);\r\n}\r\n\r\nvoid\r\nxDistributedQuatF::updateGhostValue(xNStream *stream)\r\n{\r\n\txMath::stream::mathWrite(*stream,mCurrentValue);\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t\txMath::stream::mathWrite(*stream,mDifference);\r\n\t\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedQuatF::unpack(xNStream *bstream,float sendersOneWayTime)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tsendersOneWayTime *= 0.001f;\r\n\t\t\r\n\t\tQuatF p;\r\n\t\txMath::stream::mathRead(*bstream,&p);\r\n\t\tQuatF v;\t\r\n\t\txMath::stream::mathRead(*bstream,&v);\r\n\r\n\t\tmLastValue = mCurrentValue;\r\n\t\tmCurrentValue = p;\r\n\t\tmDifference= v;\r\n\r\n\r\n\t\tQuatF predictedPos;// = p + v * sendersOneWayTime;\r\n\t\tsetOwnersOneWayTime(sendersOneWayTime);\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tQuatF p;\r\n\t\txMath::stream::mathRead(*bstream,&p);\r\n\t\r\n\t\tmLastValue = p;\r\n\t\tmCurrentValue = p;\r\n\t}\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedQuatF::pack(xNStream *bstream)\r\n{\r\n\t\r\n\t\r\n\txMath::stream::mathWrite(*bstream,mCurrentValue);\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t\txMath::stream::mathWrite(*bstream,mDifference);\r\n\r\n\r\n\tint flags = getFlags();\r\n\tflags &= (~E_DP_NEEDS_SEND);\r\n\tsetFlags(flags);\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedQuatF::updateValue(QuatF value,xTimeType currentTime)\r\n{\r\n\tbool result = false;\r\n\t\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue = mCurrentValue;\r\n mCurrentValue = value;\r\n\tmDifference = mCurrentValue - mLastValue;\r\n\t\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\tfloat lengthDiff = fabsf(mCurrentValue.angleBetween(mLastValue));\r\n\tfloat timeDiffMs = ((float)mThresoldTicker) / 1000.f;\r\n \r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\t\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\r\n\t\t\r\n\t\tif (lengthDiff > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tQuatF serverDiff = mCurrentValue-mLastServerValue ;\r\n\t\tfloat serverDiff2 = fabsf(mCurrentValue.angleBetween(mLastServerValue));\r\n\r\n\r\n\r\n\t\tif ( serverDiff2 > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > (getPredictionSettings()->getMinSendTime() * 0.2f) )\r\n\t\t\t{\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t{\r\n\t\t\tmThresoldTicker2 = 0 ;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\r\n\t}\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\tresult = true ;\r\n\t\tmLastValue = value;\r\n\t\tmCurrentValue = value;\r\n\t}\r\n\tsetFlags(flags);\r\n\t\r\n\treturn result;\r\n}premake4 --ExternalVTDirectory=./VTPaths.lua --Dev=Dev41 --file=\"./premake4.lua\" vs2005\r\n#include \"CKAll.h\"\r\n#include \"Manager/InitMan.h\"\r\n\r\n\r\n\r\n#ifdef CK_LIB\r\n#define RegisterBehaviorDeclarations\tRegister_TOOLS_BehaviorDeclarations\r\n#define InitInstance\t\t\t\t\t_TOOLS_InitInstance\r\n#define ExitInstance\t\t\t\t\t_TOOLS_ExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGet_TOOLS_PluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGet_TOOLS_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_TOOLS_PluginInfo\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n#define InitInstance\t\t\t\t\tInitInstance\r\n#define ExitInstance\t\t\t\t\tExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\nCKPluginInfo g_PluginInfo;\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount(){return 2;}\r\n\r\n#ifdef Dev25\r\n#include \"vslmanagersdk.h\"\r\n#endif\r\n\r\n#ifdef Dev3\r\n#include \"VSLManager.h\"\r\n#endif\r\n\r\n\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tInitMan* initman =new InitMan(context);\r\n\tinitman->RegisterVSL();\r\n\r\n\t\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\tInitMan* initman =(InitMan*)context->GetManagerByGuid(INIT_MAN_GUID);\r\n\r\n\tdelete initman;\r\n\treturn CK_OK;\r\n}\r\n#define INIT_BEH_GUID\t\tCKGUID(0x64cb5f9a,0x1aac3b37)\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tswitch (Index) \r\n\t{\r\n\tcase 0:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"mw\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"tool building blocks\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_BEH_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"tool BB's\";\r\n\t\tbreak;\r\n\r\n\tcase 1:\r\n\t\tg_PluginInfo.m_Author\t\t\t= \"mw\";\r\n\t\tg_PluginInfo.m_Description\t\t= \"tool Manager \";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= InitInstance;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= ExitInstance;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_MAN_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"tool Manager\";\r\n\t\tbreak;\r\n\r\n\r\n\t}\r\n\treturn &g_PluginInfo;\r\n}\r\n\r\n\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\r\n\r\n\t\r\n\r\n\tRegisterBehavior(reg,FillBehaviorAddNodalLinkDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorDirToArrayDecl);\r\n\tRegisterBehavior(reg,FillBehaviorSetNodalDifficultDecl);\r\n\tRegisterBehavior(reg,FillBehaviorCopyFileBBDecl);\r\n\tRegisterBehavior(reg,FillBehaviorExecBBDecl);\r\n\t\r\n\r\n\t// [11/6/2004] // FTP\r\n\r\n\t/*\r\n\tRegisterBehavior(reg,FillBehaviorFTPLoginDecl);\r\n\tRegisterBehavior(reg,FillBehaviorGetFileDecl);\r\n\tRegisterBehavior(reg,FillBehaviorSendFileDecl);*\r\n\r\n\r\n\t// [11/6/2004] //Zip\r\n\tRegisterBehavior(reg,FillBehaviorLoadUnZipLibraryDecl);\r\n\tRegisterBehavior(reg,FillBehaviorLoadZipLibraryDecl);\r\n\tRegisterBehavior(reg,FillBehaviorUnzipFilesDecl);\r\n\tRegisterBehavior(reg,FillBehaviorZipFilesDecl);\t**/\r\n\tRegisterBehavior(reg,FillBehaviorSaveObjectsDecl);\r\n\t\r\n\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorTextureSinusDecl);\r\n\tRegisterBehavior(reg,FillBehaviorNoiseDecl);\r\n\r\n\t\n\tRegisterBehavior(reg, FillBehaviorHasFFEffectsDecl);\n\tRegisterBehavior(reg, FillBehaviorJSetXYForceDecl);\n\n\n\tRegisterBehavior(reg,FillBehaviorGetCurrentPathDecl);\r\n\r\n\r\n\r\n\tRegisterBehavior(reg,FillBehaviorResolveFileNameDecl);\r\n\tRegisterBehavior(reg,FillBehaviorMimicDecl);\r\n\t/*\r\n\t\r\n\tRegisterBehavior(reg,*/\r\n//\tRegisterBehavior(reg,FillBehaviorCharacterControllerDecl);\r\n}\r\n\r\n\r\n\r\nFIND_PATH(VTDEV35DIR\r\n NAMES dev.exe devr.exe\r\n PATHS\r\n [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Virtools\\\\Dev\\\\3.5;InstallPath]\r\n \"X:/sdk/dev322/\"\r\n )\r\nMARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)\r\nSET(VTDEV35 1)\r\n\r\n#include \"pTypes.h\"\r\n\r\n\r\n/** \\addtogroup Cloth\r\n@{\r\n*/\r\n//! Collection of flags describing the behavior of a cloth object.\r\nenum pClothFlag\r\n{\r\n\t/**\r\n\t\\brief Enable/disable pressure simulation. \r\n\t\tNote: Pressure simulation only produces meaningful results for closed meshes.\r\n\t*/\r\n\tPCF_Pressure\t\t\t = (1<<0),\r\n\r\n\t/**\r\n\t\\brief Makes the cloth static. \r\n\t*/\r\n\tPCF_Static = (1<<1),\r\n\t/**\r\n\t\\brief \r\n\tPCF_Static\t\t\t = (1<<1),/*!cloth interaction (one way).\r\n\r\n\tWith this flag set, cloth->object interaction is turned on as well.\r\n\t*/\r\n\tPCAF_ClothAttachmentTwoway\t\t\t = (1<<0),\r\n\r\n\t/**\r\n\t\\brief When this flag is set, the attachment is tearable.\r\n\r\n\t\\note If the cloth is attached to a dynamic shape using two way interaction\r\n\thalf way torn attachments can generate unexpected impluses on the shape.\r\n\tTo prevent this, only attach one row of cloth vertices to the shape.\r\n\t@see pClothDesc.attachmentTearFactor\r\n\t*/\r\n\tPCAF_ClothAttachmentTearable\t\t = (1<<1),\r\n};\r\n\r\n/** @} */#include \r\n#include \"vtPhysXAll.h\"\r\n#include \r\n\r\n\r\nclass PhysicVariableWatcher : public CKVariableManager::Watcher \r\n{\r\npublic:\r\n\tPhysicVariableWatcher(CKContext* context, XString variableName, XString currentValue);\r\n\r\n\tvirtual void PostWrite(const char* iName);\r\nprivate:\r\n\tPhysicVariableWatcher();\r\n\r\n\tCKContext* context;\r\n\tCKBOOL manualSetInProgress;\r\n\tXString variableName;\r\n\tXString currentValue;\r\n};\r\n\r\nPhysicVariableWatcher::PhysicVariableWatcher(CKContext* context, XString variableName, XString currentValue)\r\n{\r\n\tthis->context = context;\r\n\tthis->manualSetInProgress = FALSE;\r\n\tthis->variableName = variableName;\r\n\tthis->currentValue = currentValue;\r\n}\r\n\r\nstatic PhysicVariableWatcher *watcherConsole=NULL;\r\n\r\n\r\nvoid PhysicVariableWatcher::PostWrite(const char* iName)\r\n{\r\n\r\n\t\r\n\tXString newValue;\r\n\tXString msg;\r\n\r\n\t// Check if we are currently manually setting the value\r\n\tif (this->manualSetInProgress)\r\n\treturn;\r\n\r\n\tif( !context || !context->GetVariableManager())\r\n\t\treturn;\r\n\r\n\tif(!GetPMan())\r\n\t\treturn;\r\n\r\n\t// Get new value\r\n\tint a=0;\r\n\tcontext->GetVariableManager()->GetValue(iName, &GetPMan()->_LogToConsole);\r\n\txLogger::GetInstance()->enableConsoleOutput(GetPMan()->_LogToConsole);\r\n\r\n\r\n\treturn ;\r\n\r\n\r\n\t// Validate value\r\n\r\n\tif (0 == newValue.Length())\r\n\t{\r\n\t\t// This is valid, it means disable the GBL platform\r\n\t}\r\n\telse\r\n\t{\r\n\r\n\t\tint LogConsole = newValue.ToInt();\r\n\t\tif ( LogConsole ==1 )\r\n\t\t{\r\n\t\t\t// Restore back to previous value\r\n\t//\t\tthis->manualSetInProgress = TRUE;\r\n\t//\t\tcontext->GetVariableManager()->SetValue(this->variableName.CStr(), this->currentValue.CStr());\r\n\t//\t\tthis->manualSetInProgress = FALSE;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// Remember current value\r\n\t\t\t//this->currentValue = newValue;\r\n\r\n\t\t\t// Write back in preferred format\r\n\t\t\t//newValue.Format(\"(0x%08x,0x%08x)\", laid.guid.d1, laid.guid.d2);\r\n\r\n\t\t\t//this->manualSetInProgress = TRUE;\r\n\t\t\t//context->GetVariableManager()->SetValue(this->variableName.CStr(), newValue.CStr());\r\n\t\t\t//this->manualSetInProgress = FALSE;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nvoid\r\nPhysicManager::_registerWatchers(CKContext*context)\r\n{\r\n\tconst char* nameConsoleLogger = \"Physic Console Logger/Console\";\r\n\twatcherConsole = new PhysicVariableWatcher(context, nameConsoleLogger, \"0\");\r\n\tcontext->GetVariableManager()->RegisterWatcher(nameConsoleLogger, watcherConsole);\r\n\r\n}#ifndef __xDistributedPropertyInfo_h\r\n#define __xDistributedPropertyInfo_h\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nclass xDistributedPropertyInfo\r\n{\r\n\r\n\tpublic:\r\n\t\txDistributedPropertyInfo() : mName(NULL) , mValueType(-1) , mNativeType(-1) , mPredictionType(-1)\t\t{\t\t}\r\n\t\txDistributedPropertyInfo( xNString name , int valueType,int nativeType, int predictionType ) : mName(name) , mValueType(valueType) , mNativeType(nativeType) , mPredictionType(predictionType)\r\n\t\t{\r\n\t\t}\r\n\t\tvirtual ~xDistributedPropertyInfo(){}\r\n\t\txNString mName;\r\n\t\tint mValueType;\r\n\t\tint mNativeType;\r\n\t\tint mPredictionType;\r\n\r\n};\r\n\r\n#endif\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetUserNameDecl();\r\nCKERROR CreateSetUserNameProto(CKBehaviorPrototype **);\r\nint SetUserName(const CKBehaviorContext& behcontext);\r\nCKERROR SetUserNameCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetUserNameDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSetUserName\");\t\r\n\tod->SetDescription(\"Sets your user name\");\r\n\t\r\n\tod->SetCategory(\"TNL/User Management\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x68be0952,0xb376cd4));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetUserNameProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_ERROR,\r\n\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_ERROR\r\n};\r\n\r\nCKERROR CreateSetUserNameProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSetUserName\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"User Name \", CKPGUID_STRING, \"MyNetName\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(SetUserName);\r\n\tproto->SetBehaviorCallbackFct(SetUserNameCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint SetUserName(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\tint connectionID=-1;\r\n\tbeh->GetInputParameterValue(0,&connectionID);\r\n\t\r\n\tXString userName((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tbbNoError(E_NWE_OK);\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\r\n\r\n\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClient *client = static_cast(dobj);\r\n\t\t\t\t\tif (client)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (client->getUserID() == cin->getConnection()->getUserID() )\r\n\t\t\t\t\t\t{\r\n client->rpcSetName(userName.CStr());\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR SetUserNameCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n} PhysicManager pm = GetPhysicManager();\r\n pRigidBody b = pm.getBody(body);\r\n if(b)\r\n {\r\n\tb.setPosition(myPosition);\r\n\tb.setRotation(myQuat);\r\n\tb.setLinearMomentum(theNewForce);\r\n\tb.setAngularMomentum(theNewTorque);\r\n\tb.setLinearVelocity(theNewVelocity);\r\n\tb.setAngularVelocity(theNewVelocity);\r\n\t\r\n }\r\n\r\n RenderEngines = RenderEngines\r\n ManagerPath = Managers\r\n BehaviorPath = BuildingBlocks\r\n PluginPath = Plugins\r\n LoadFile = pBPhysicalizeExSamples.cmo\r\n LoadFile1 = GFXMenu.cmo\r\n InstallDirectory = X:\\sdk\\dev4\r\n\r\n\r\n DisableSwitch = 0\r\n WindowWidth = 800\r\n WindowHeight = 600\r\n FullscreenWidth = 1024\r\n FullscreenHeight = 768\r\n Bpp = 32\r\n Driver = 0\r\n FullScreen = 0\r\n RefreshRate = 60\r\n Mode = 0\r\n AntiAlias = 0\r\n HasResolutionMask = 0\r\n XResolutions = 400,1024,800\r\n YResolutions = 300,768,600\r\n OpenGLVersions = 2.0\r\n\r\n\r\n MouseDragsWindow = 1\r\n OwnerDrawed = 0\r\n Render = 1\r\n AlwayOnTop = 0\r\n ScreenSaverMode = 0\r\n MouseMovesTerminatePlayer = 0\r\n Resizeable = 1\r\n CaptionBar = 1\r\n ShowDialog = 1\r\n ShowAboutTab = 0\r\n ShowConfigTab = 1\r\n MinDirectXVersion = 9\r\n MinRAM = 256\r\n SizeBox = 1\r\n Title = vtPhysX - Unit - Test\r\n UseSplash = 0\r\n ShowLoadingProcess = 0\r\n\r\n\r\n entry0 = Resource\\3DChatResourceDB\\Textures\r\n entry1 = Resource\\3DChatResourceDB\\Textures\\Dialogs\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include \"xLogger.h\"\r\n#include \"uxString.h\"\r\n#include \"xBitSet.h\"\r\n#include \r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\t#include \"CKAll.h\"\r\n#endif\r\n\r\n#include \r\n\r\nusing xUtils::xLogger;\r\nusing xUtils::xLoggerFlags;\r\nusing namespace xUtils;\r\n\r\nConStream *consoleStream = NULL;\r\n\r\n//\tconsoleStream = new ConStream();\r\n\r\nvoid\r\nxLogger::enableConsoleOutput(bool enable)\r\n{\r\n\tif (enable)\r\n\t{\r\n\t\tif (!consoleStream)\r\n\t\t{\r\n\t\t\tm_LogOutChannels |= ELOGGER_CONSOLE;\r\n\t\t\tconsoleStream = new ConStream();\r\n\t\t\tconsoleStream->Open();\r\n\t\t}else{\r\n consoleStream->Open();\r\n\t\t}\r\n\r\n\t}\r\n\tif (!enable && consoleStream)\r\n\t{\r\n\t\tconsoleStream->Close();\r\n\t}\r\n}\r\n\r\nxLogConsumer *xLogConsumer::mLinkedList = NULL;\r\nvoid xLogConsumer::logString(const char *string)\r\n{\r\n\tOutputDebugString(string);\r\n\tOutputDebugString(\"\\n\");\r\n}\r\n\r\nxLogConsumer::xLogConsumer()\r\n{\r\n\tmNextConsumer = mLinkedList;\r\n\tif(mNextConsumer)\r\n\t\tmNextConsumer->mPrevConsumer = this;\r\n\tmPrevConsumer = NULL;\r\n\tmLinkedList = this;\r\n}\r\n\r\nxLogConsumer::~xLogConsumer()\r\n{\r\n\tif(mNextConsumer)\r\n\t\tmNextConsumer->mPrevConsumer = mPrevConsumer;\r\n\tif(mPrevConsumer)\r\n\t\tmPrevConsumer->mNextConsumer = mNextConsumer;\r\n\telse\r\n\t\tmLinkedList = mNextConsumer;\r\n}\r\n\r\n\r\n\r\nstatic xLogger *xlog=NULL;\r\n\r\nconst char*formatLine(const char *msg,...);\r\nvoid printMessage(const char*buffer);\r\n\r\n\r\n#define ANSI /* Comment out for UNIX version */\r\n#ifdef ANSI /* ANSI compatible version */\r\n\t#include \r\n\tint average( int first, ... );\r\n#else /* UNIX compatible version */\r\n\t#include \r\n\tint average( va_list );\r\n#endif\r\n\r\n\r\n\r\n\r\nvoid xLogger::finalPrint(const char*string)\r\n{\r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\r\n\tif (getVirtoolsContext())\r\n\t{\r\n\t\tgetVirtoolsContext()->OutputToConsole(const_cast(string),FALSE);\r\n\t}\r\n#endif\r\n\r\n\tif (strlen(string))\r\n\t{\r\n\t\tprintf(string);\r\n\t\tOutputDebugString(string);\r\n\t}\r\n\t\r\n\tfor(xLogConsumer *walk = xLogConsumer::getLinkedList(); walk; walk = walk->getNext())\r\n\t\twalk->logString(string);\r\n\r\n}\r\n\r\n\r\nvoid xLogger::enableLoggingLevel(int item,int level,int enable)\r\n{\r\n\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n\r\n\t\txBitSet& flags = it->second;\r\n\t\tif (level !=8)\r\n\t\t{\r\n\t\t\tflags.set( 1 << level,enable);\r\n\t\t}else\r\n\t\t\tflags.set();\r\n\t\t\r\n\t}\r\n}\r\n\r\nxBitSet xLogger::getLogLevel(int item)\r\n{\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n\t\treturn it->second;\r\n\t}\r\n\r\n\txBitSet result;\r\n\tresult.set();\r\n\treturn result;\r\n\r\n\r\n}\r\n\r\nvoid xLogger::addLogItem(int item)\r\n{\r\n\r\n\r\n\txBitSet flags;\r\n\tflags.set(1 << ELOGWARNING,true);\r\n\tflags.set(1 << ELOGERROR,true);\r\n\tflags.set(1 << ELOGINFO,true);\r\n\r\n\tgetLogItems().insert(std::make_pair(item,flags));\r\n\r\n\r\n}\r\n\r\nvoid xLogger::setLoggingLevel(int item,xBitSet flags)\r\n{\r\n\r\n\tstd::map::iterator it = getLogItems().find(item);\r\n\r\n\tif ( it !=getLogItems().end() )\r\n\t{\r\n xBitSet& lflags = it->second;\r\n\t\tlflags = flags;\r\n \r\n\t}\r\n\r\n}\r\n\r\nsigned int dVsprintf(char *buffer, unsigned int bufferSize, const char *format, void *arglist)\r\n{\r\n#ifdef TNL_COMPILER_VISUALC\r\n\tsigned int len = _vsnprintf(buffer, bufferSize, format, (va_list) arglist);\r\n#else\r\n\tsigned int len = vsnprintf(buffer, bufferSize, format, (char *) arglist);\r\n#endif\r\n\treturn len;\r\n}\r\n\r\nvoid xLogger::xLog(char *cppText,int type,int component,const char *header, ...)\r\n{\r\n\r\n\r\n\tGetInstance()->lastTyp = type;\r\n\tGetInstance()->lastComponent = component;\r\n\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\t\tva_start( s, header );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tchar headerout[4096];\r\n\tif (strlen(cppText))\r\n\t{\t\t\r\n\t\tsprintf(headerout,\"%s::%s\\n\",cppText,header);\r\n\t\txLog(type,component,headerout,buffer);\r\n\t}else\r\n\t{\r\n\t\txLog(type,component,header,buffer);\r\n\t}\r\n\r\n}\r\n\r\n\r\nvoid xLogger::xLog(xBitSet styleFlags,int type,int component,const char *header, ...)\r\n{\r\n\r\n\t/*\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\tchar headerBuffer[4096];\r\n\tchar verbosityStr[512];\r\n\tchar componentString[256];\r\n\tsprintf(componentString,\"%s\",sLogItems[component]);\r\n\r\n\r\n\tuxString leadIn(\"\");\r\n\r\n\tif (type > 4)\t{\t\ttype =4;\t} \r\n\tif (type < 0)\t{\t\ttype =0;\t} \r\n\r\n\tif ( styleFlags.test(E_PSF_PRINT_LOG_TYPE) )\r\n\t{\r\n\t\tleadIn << \"\\n<-----------------> \" << sLogTypes[type] << \" : \";\r\n\t}\r\n\t\r\n\tif ( styleFlags.test(E_PSF_PRINT_COMPONENT) )\r\n\t{\r\n\t\tleadIn << \"|---\" << componentString << \"--|\";\r\n\t}\r\n\r\n\tleadIn << \"\\n\";\r\n\t\r\n\r\n\r\n\tswitch(type)\r\n\t{\r\n\t\tcase ELOGINFO:\r\n\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t\tbreak;\r\n\t\tcase ELOGTRACE:\r\n\t\t\tSetConsoleTextAttribute(hConsole, 11);\r\n\t\t\tbreak;\r\n\t\tcase ELOGERROR:\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t\tbreak;\r\n\t\tcase ELOGWARNING:\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);\r\n\t\t\tbreak;\r\n\t}\r\n\r\n\tif ( styleFlags.test(E_PSF_PRINT_LOG_TYPE) || styleFlags.test(E_PSF_PRINT_COMPONENT) )\r\n\t\tTNL::logprintf(leadIn.CStr());\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\tchar buffer2[4096];\r\n\tsprintf(buffer2,\" : %s \",buffer);\r\n\tTNL::logprintf(buffer2);\r\n\r\n\t\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n*/\r\n\treturn;\r\n\r\n}\r\n\r\nvoid xLogger::xLog(int type,int component,const char *header, ...)\r\n{\r\n\r\n\tGetInstance()->lastTyp = type;\r\n\tGetInstance()->lastComponent = component;\r\n\r\n\tif (!xLogger::GetInstance()->getLogLevel(component).test(1<< type) )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\t\r\n\tchar headerBuffer[4096];\r\n\tchar verbosityStr[512];\r\n\tchar componentString[256];\r\n\r\n\tint descriptionS = xLogger::GetInstance()->getItemDescriptions().size();\r\n\tconst char* cString = GetInstance()->getItemDescriptions().at(component);\r\n\tif(component <= xLogger::GetInstance()->getItemDescriptions().size() )\r\n\t\tsprintf(componentString,\"%s\",GetInstance()->getItemDescriptions().at(component));\r\n\telse\r\n\t\tsprintf(componentString,\"UNKNOWN COMPONENT\");\r\n\r\n\r\n\r\n\t\r\n\tswitch(type)\r\n\t{\r\n\tcase ELOGINFO:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"->\tINFO : %s \",componentString);\r\n\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGTRACE:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"->TRACE: %s\",componentString);\r\n\t\t\tSetConsoleTextAttribute(hConsole, 11);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGERROR:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"->ERROR:%s\",componentString);\r\n\t\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t}\r\n\t\tbreak;\r\n\tcase ELOGWARNING:\r\n\t\t{\r\n\t\t\tsprintf(verbosityStr,\"->WARNING : %s\",componentString);\r\n\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN);\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\tsprintf(headerBuffer,\"%s\",verbosityStr);\r\n\t//GetInstance()->finalPrint(headerBuffer);\r\n\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\tchar buffer2[4096];\r\n\tsprintf(buffer2,\":%s :%s\",headerBuffer,buffer);\r\n\tGetInstance()->finalPrint(buffer2);\r\n\r\n\r\n\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\treturn;\r\n\r\n}\r\n\r\nvoid xLogger::xLogExtro(int style,const char *header, ...)\r\n{\r\n\r\n\r\n\tchar buffer[4096];\r\n\tunsigned int bufferStart = 0;\r\n\r\n\tva_list s;\r\n\tva_start( s, header );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, header, s);\r\n\tva_end(s);\r\n\r\n\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\r\n\tchar headerBuffer[4096];\r\n\r\n\tsprintf(headerBuffer,\"%s\\n\",header);\r\n\tGetInstance()->finalPrint(buffer);\r\n\treturn;\r\n}\r\n\r\nvoid xLogger::xLog(int verbosity,const char *header,const char*msg,...)\r\n{\r\n\t\r\n\t\tchar buffer[4096];\r\n\t\tunsigned int bufferStart = 0;\r\n\r\n\t\tva_list s;\r\n\t\tva_start( s, msg );\r\n\t\tdVsprintf(buffer + bufferStart, sizeof(buffer) - bufferStart, msg, s);\r\n\t\tva_end(s);\r\n\r\n\t\tHANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r\n\r\n\t\r\n\t\tchar headerBuffer[4096];\r\n\t\tchar verbosityStr[512];\r\n\t\r\n\t\tswitch(verbosity)\r\n\t\t{\r\n\t\t\tcase ELOGINFO:\r\n\t\t\t\t{\r\n\t\t\t\t\tsprintf(verbosityStr,\"--------------------------------------INFO\t\\n-\\n\");\r\n\t\t\t\t\tSetConsoleTextAttribute(hConsole, 10);\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\tcase ELOGERROR:\r\n\t\t\t\t{\r\n\t\t\t\t\tsprintf(verbosityStr,\"ooo--------------------------------ERROR\t\\n-\\n\");\r\n\t\t\t\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\t\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tsprintf(headerBuffer,\"%s %s-\\n--\",verbosityStr,header);\r\n\t\tprintf(headerBuffer);\r\n\t\t\r\n\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN);\r\n\r\n\t\tprintf(\"--->%s\\n \",buffer);\r\n\t\r\n\t\t\r\n\t\tSetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),\r\n\t\t\tFOREGROUND_INTENSITY | FOREGROUND_RED |\r\n\t\t\tFOREGROUND_GREEN | FOREGROUND_BLUE);\r\n\r\n\r\n\r\n\t\treturn;\r\n\r\n\t\tva_list va;\r\n\t\tva_start (va,msg);\r\n\t\tchar bufferN[1024] = { 0 } ; \r\n\t\tvsprintf(bufferN,msg,va );\r\n\t\tva_end (va);\r\n\t\tprintMessage(bufferN);\r\n\t\r\n\r\n}\r\n\r\nxBitSet& xLogger::getLogFlags()\r\n{\r\n\treturn GetInstance()->mLogFlags ;\r\n}\r\n\r\n\r\nxBitSet& xLogger::getVerbosityFlags()\r\n{\r\n\treturn GetInstance()->m_VerbosityFlags;\r\n}\r\n\r\nbool xLogger::isLogging(int logItem)\r\n{ \r\n\treturn GetInstance()->getVerbosityFlags().test(1<getVerbosityFlags().set(1<< logItem,enbabled); \r\n}\r\n\r\nvoid xLogger::Init()\r\n{\r\n\t#ifdef CONSOLE_OUTPUT\r\n\t\t//consoleStream->Open();\r\n\t\t\r\n\t#endif \r\n}\r\n\r\nxLogger::xLogger()\r\n{\r\n\txlog = this;\r\n\tm_LogOutChannels = ELOGGER_NONE;\r\n\r\n\tlastTyp = 0;\r\n\tlastComponent = 0;\r\n\r\n#ifdef CONSOLE_OUTPUT\r\n\t//m_LogOutChannels |= ELOGGER_CONSOLE;\r\n\t//consoleStream = new ConStream();\r\n#endif \r\n\t\r\n\t#ifdef VIRTOOLS_USER_SDK\r\n\t\tmContext = NULL;\r\n\t#endif\r\n}\r\nxLogger*xLogger::GetInstance()\r\n{\r\n\tif (xlog ==NULL)\t{\r\n\t\txlog = new xLogger();\t}\r\n\treturn xlog;\r\n}\r\n\r\nvoid printMessage(const char*buffer)\r\n{\r\n\tusing namespace xUtils;\r\n\r\n#ifdef CONSOLE_OUTPUT\r\n\r\n\tif ( consoleStream )\r\n\t{\r\n\t\tConsoleln(buffer);\r\n\t\tfflush (stderr);\r\n\t\tfflush (stdout);\r\n\t\tstrcpy(consoleStream->buf,buffer);\r\n\t}\r\n#endif\r\n\r\n}\r\n\r\n\r\nxLogger::~xLogger()\r\n{\r\n\r\n}\r\n/*\n * Tcp4u v 3.31 Last Revision 27/06/1997 3.10\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tcp4u_ex.c\n * Purpose: Add-on to Tcp4u library\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n\n#include \"build.h\"\n\n\n#ifndef trace\n#define trace 1\n#endif\n\n/*######################################################################\n *##\n *## NAME: TCPRecvUntilClosedEx\n *##\n *## PURPOSE: Receive Tcp data until socket connection closed by server\n *##\n *####################################################################*/\nint API4U TcpRecvUntilClosedEx \n (SOCKET far *pCSock, /* socket comm.*/\n LPCSTR szLocalFile, /* local file transfer */\n TRANSFER_CBK CbkTransmit, /* callback transfer */\n unsigned uTimeout, /* timeout */\n unsigned int uBufSize, /* buffer transfer size */\n long lUserValue, /* user value */\n long lTotalBytes) /* */\n{\nint Rc;\nlong lBytesTransferred = 0;\nHFILE hFile = HFILE_ERROR;\nLPSTR sBufRead = NULL;\n\n#define XX_RETURN(a) {\\\n if (hFile != HFILE_ERROR) Close(hFile);\\\n if (sBufRead != NULL) Free(sBufRead);\\\n\t\t\t\t\t Tcp4uLog (LOG4U_EXIT, \"TcpRecvUntilClosedEx, return code %d\", a); \\\n return a;\\\n }\n\n Tcp4uLog (LOG4U_PROC, \"TcpRecvUntilClosedEx\");\n\n /* open user local file */\n if (szLocalFile!=NULL && (hFile=Open(szLocalFile, WRITE_CR)) == HFILE_ERROR) \n {\n /* open failed */\n XX_RETURN (TCP4U_FILE_ERROR);\n }\n\n /* allocate buffer */\n if ( (sBufRead = Calloc(uBufSize<128 ? 128 : uBufSize,1)) == NULL) \n {\n XX_RETURN(TCP4U_INSMEMORY);\n }\n\n /* first call to user callback */\n if (CbkTransmit != NULL && (*CbkTransmit)(lBytesTransferred,\n lTotalBytes,\n lUserValue,\n sBufRead,\n 0) == FALSE) \n {\n /* user stop order */\n XX_RETURN (TCP4U_CANCELLED);\n }\n\n /* read data from http server */\n do \n {\n /* read one data frame */\n Rc=TcpRecv(*pCSock,\n sBufRead, /* adress */\n uBufSize,\n uTimeout,\n HFILE_ERROR);\n if (Rc >= TCP4U_SUCCESS) \n {\n /* write to the user local file --> Warning signed/unsigned mismatch */\n if (hFile != HFILE_ERROR && Write(hFile, sBufRead, Rc) != Rc) \n {\n XX_RETURN(TCP4U_FILE_ERROR);\n }\n\n lBytesTransferred += (long) Rc;\n\n /* appel du callback */\n if (CbkTransmit != NULL && (*CbkTransmit)(lBytesTransferred,\n lTotalBytes,\n lUserValue,\n sBufRead,\n Rc) == FALSE) {\n XX_RETURN (TCP4U_CANCELLED);\n }\n }\n } while (Rc >= TCP4U_SUCCESS); /* END do while */\n\n /* close all files and free allocated buffers */\n XX_RETURN(Rc == TCP4U_SOCKETCLOSED ? TCP4U_SUCCESS : Rc);\n\n#undef XX_RETURN\n} /* END TcpRecvUntilClosedEx */\n#ifndef __vtModuleConstants_h__\r\n#define __vtModuleConstants_h__\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\t\tInclude of system headers \r\n//\r\n\r\n#include // float max \r\n\r\n//################################################################\r\n//\r\n// Component specific names, prefixes,etc....\r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Global API prefix\r\n//\r\n#define VTCX_API_PREFIX \"vt\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Module name, merged with module suffix \"vt\" with see #VTCX_API_PREFIX\r\n//\r\n#define VTCMODULE_NAME VTCX_API_PREFIX(\"Physic\")\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Modules attribute category prefix , using module name above\r\n//\r\n#define VTCMODULE_ATTRIBUTE_CATAEGORY VTCMODULE_NAME\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Error enumerations\r\n//\r\n#include \"vtModuleErrorCodes.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Error strings\r\n//\r\n#include \"vtModuleErrorStrings.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Guids of the plug-in it self \r\n//\r\n#include \"vtModuleGuids.h\"\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Math oriented values\r\n//\r\n\r\n#define pSLEEP_INTERVAL (20.0f*0.02f)\r\n#define pFLOAT_MAX FLT_MAX\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Constants for building blocks\r\n//\r\n#ifndef VTCX_AUTHOR\r\n\t#define\tVTCX_AUTHOR\t\t\t\t\"\"\r\n#endif\r\n\r\n#ifndef VTCX_AUTHOR_GUID\r\n\t#define\tVTCX_AUTHOR_GUID\t\t\tCKGUID(0x79ba75dd,0x41d77c63)\r\n#endif\r\n\r\n#endif // vtModuleConstants_h__#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"tinyxml.h\"\r\n\r\nint pFactory::loadFrom(pTireFunction& dst,const char* nodeName,const TiXmlDocument * doc )\r\n{\r\n\tint result = 0 ;\r\n\tif (!strlen(nodeName))\t{\treturn -1;\t}\r\n\tif (!doc)\t{ return -1;\t}\r\n\tconst TiXmlElement *root = pFactory::Instance()->getFirstDocElement(doc->RootElement());\r\n\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t{\r\n\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t{\r\n\t\t\tXString name = child->Value();\r\n\t\t\tif (!strcmp(child->Value(), \"tireFunction\" ) )\r\n\t\t\t{\r\n\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t{\t\r\n\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"ExtremumSlip\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.extremumSlip = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"ExtremumValue\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.extremumValue = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"AsymptoteSlip\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.asymptoteSlip = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"AsymptoteValue\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.asymptoteValue = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StiffnessFactor\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.stiffnessFactor = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint pFactory::loadWheelDescrFromXML(pWheelDescr& dst,const char* nodeName,const TiXmlDocument * doc )\r\n{\r\n\tint result = 0 ;\r\n\tif (!strlen(nodeName))\t{\treturn -1;\t}\r\n\tif (!doc)\t{ return -1;\t}\r\n\tconst TiXmlElement *root = pFactory::Instance()->getFirstDocElement(doc->RootElement());\r\n\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t{\r\n\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t{\r\n\t\t\tXString name = child->Value();\r\n\t\t\tif (!strcmp(child->Value(), \"wheel\" ) )\r\n\t\t\t{\r\n\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t{\t\r\n\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"Suspension\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.wheelSuspension = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Restitution\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.springRestitution = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Damping\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.springDamping = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Bias\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.springBias= static_cast(v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"MaxBreakForce\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.maxBrakeForce = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"FrictionToSide\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.frictionToSide = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"FrictionToFront\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.frictionToFront = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"InverseWheelMass\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.inverseWheelMass = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tconst char* flags = NULL;\r\n\t\t\t\t\t\t\t\tflags = sube->Attribute(\"Flags\");\r\n\t\t\t\t\t\t\t\tif (flags && strlen(flags))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tdst.wheelFlags = (WheelFlags)_str2WheelFlag(flags);\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\r\n\t\t\t\t\t\t\t\tconst char* latFunc = NULL;\r\n\t\t\t\t\t\t\t\tlatFunc = sube->Attribute(\"LateralFunction\");\r\n\t\t\t\t\t\t\t\tif (latFunc && strlen(latFunc))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tint index = getEnumIndex(getManager()->GetContext()->GetParameterManager(),VTE_XML_TIRE_SETTINGS,latFunc);\r\n\t\t\t\t\t\t\t\t\tif (index!=0)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tloadFrom(dst.latFunc,latFunc,doc);\r\n\t\t\t\t\t\t\t\t\t\tdst.latFunc.xmlLink = index;\r\n\t\t\t\t\t\t\t\t\t\tif (!dst.latFunc.isValid())\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Lateral Tire Function from XML was incorrect, setting to default\");\r\n\t\t\t\t\t\t\t\t\t\t\tdst.latFunc.setToDefault();\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tconst char* longFunc = NULL;\r\n\t\t\t\t\t\t\t\tlongFunc = sube->Attribute(\"LongitudeFunction\");\r\n\t\t\t\t\t\t\t\tif (longFunc && strlen(longFunc))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tint index = getEnumIndex(getManager()->GetContext()->GetParameterManager(),VTE_XML_TIRE_SETTINGS,longFunc);\r\n\t\t\t\t\t\t\t\t\tif (index!=0)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tloadFrom(dst.longFunc,longFunc,doc);\r\n\t\t\t\t\t\t\t\t\t\tdst.longFunc.xmlLink = index;\r\n\t\t\t\t\t\t\t\t\t\tif (!dst.longFunc.isValid())\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Longitude Tire Function from XML was incorrect, setting to default\");\r\n\t\t\t\t\t\t\t\t\t\t\tdst.longFunc.setToDefault();\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\nint pFactory::loadVehicleDescrFromXML(pVehicleDesc& dst,const char* nodeName,const TiXmlDocument * doc )\r\n{\r\n\t\r\n\t\r\n\tint result = 0 ;\r\n\tif (!strlen(nodeName))\t{\treturn -1;\t}\r\n\tif (!doc)\t{ return -1;\t}\r\n\tconst TiXmlElement *root = pFactory::Instance()->getFirstDocElement(doc->RootElement());\r\n\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t{\r\n\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t{\r\n\t\t\tXString name = child->Value();\r\n\t\t\tif (!strcmp(child->Value(), \"vehicle\" ) )\r\n\t\t\t{\r\n\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t{\t\r\n\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"Mass\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.mass = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"Mass\",&v);\r\n\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdst.mass = static_cast(v);\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t*/\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint pFactory::_str2WheelFlag(XString _in)\r\n{\r\n\r\n\t\r\n\tshort nb = 0 ; \r\n\tint result = 0;\r\n\tXStringTokenizer\ttokizer(_in.CStr(), \"|\");\r\n\tconst char*tok = NULL;\r\n\twhile ((tok=tokizer.NextToken(tok)) && nb < 3)\r\n\t{\r\n\t\tXString tokx(tok);\r\n\r\n\t\tif ( _stricmp(tokx.CStr(),\"Steerable\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_SteerableInput;\r\n\t\t}\r\n\t\t\r\n\t\tif ( _stricmp(tokx.CStr(),\"VehicleControlled\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_VehicleControlled;\r\n\t\t}\r\n\t\tif ( _stricmp(tokx.CStr(),\"SteerableAuto\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_SteerableAuto;\r\n\t\t}\r\n\t\tif ( _stricmp(tokx.CStr(),\"Handbrake\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_AffectedByHandbrake;\r\n\t\t}\r\n\t\t\r\n\t\tif ( _stricmp(tokx.CStr(),\"Accelerated\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_Accelerated;\r\n\t\t}\r\n\t\t\r\n\t\t/*if ( _stricmp(tokx.CStr(),\"Wheelshape\") == 0 ) \r\n\t\t{\t\r\n\t\t\tresult |= WF_UseWheelShape;\r\n\t\t}*/\r\n\t\t\r\n\t\tnb++;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n\r\nint pVehicle::loadFromXML(const char* nodeName,const TiXmlDocument * doc )\r\n{\r\n\tNxMaterialDesc *result = new NxMaterialDesc();\r\n\tresult->setToDefault();\r\n\r\n\tint res = 0;\r\n\t\r\n\tif (!strlen(nodeName))\t{\treturn -1;\t}\r\n\tif (!doc)\t{ return -1;\t}\r\n\r\n\r\n\tif ( strlen(nodeName) && doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = pFactory::Instance()->getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\t\t\t\tif (!strcmp(child->Value(), \"vehicle\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\t\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"Mass\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t//setMass() = \r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFriction\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->staticFriction= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"Restitution\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->restitution= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"DynamicFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dynamicFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryDoubleAttribute(\"StaticFrictionV\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif(v >=0.0f){\r\n\t\t\t\t\t\t\t\t\t\t\tresult->staticFrictionV= (float)v;\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* dirOfAnisotropy = NULL;\r\n\t\t\t\t\t\t\t\t\tdirOfAnisotropy = sube->Attribute(\"DirOfAnisotropy\");\r\n\t\t\t\t\t\t\t\t\tif (dirOfAnisotropy && strlen(dirOfAnisotropy))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxVector vec = pFactory::Instance()->_str2Vec(dirOfAnisotropy);\r\n\t\t\t\t\t\t\t\t\t\tif (vec.Magnitude() >0.1f)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresult->flags = NX_MF_ANISOTROPIC;\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dirOfAnisotropy = pMath::getFrom(vec);\r\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresult->dirOfAnisotropy = pMath::getFrom(VxVector(0,0,0));\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\t//result->setGravity(vec);\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* FrictionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tFrictionCombineMode = sube->Attribute(\"FrictionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (FrictionCombineMode && strlen(FrictionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n//\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(FrictionCombineMode);\r\n//\t\t\t\t\t\t\t\t\t\tresult->frictionCombineMode = (NxCombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* RestitutionCombineMode = NULL;\r\n\t\t\t\t\t\t\t\t\tRestitutionCombineMode = sube->Attribute(\"RestitutionCombineMode\");\r\n\t\t\t\t\t\t\t\t\tif (RestitutionCombineMode && strlen(RestitutionCombineMode))\r\n\t\t\t\t\t\t\t\t\t{\r\n//\t\t\t\t\t\t\t\t\t\tint fMode = _str2CombineMode(RestitutionCombineMode);\r\n//\t\t\t\t\t\t\t\t\t\tresult->restitutionCombineMode= (NxCombineMode)fMode;\r\n\t\t\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\t\r\n//\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\treturn 0;\r\n}\r\n*/\r\n\r\n\r\n\r\n///\r\n////////////////////////////////////////////////////////\r\n// xLogger.h\r\n// Implementation of the Class xLogger\r\n// Created on: 10-Feb-2007 12:40:39\r\n///////////////////////////////////////////////////////////\r\n\r\n#if !defined __X_LOGGER_H__\r\n#define __X_LOGGER_H__\r\n\r\n#include \r\n//#include \r\n#include \r\n//#include \r\n#include \r\n\r\n#include \r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\n\r\n\r\n#ifndef DEBUG_CALLER\r\n\t#define DEBUG_CALLER\r\n#endif\r\n\r\n#ifndef TNL_COMPILER_VISUALC\r\n\t#define TNL_COMPILER_VISUALC\r\n#endif\r\n\r\n#ifndef DEBUG_CALLERS_FUNC\r\n\t#define DEBUG_CALLERS_FUNC\r\n#endif\r\n\r\n\r\n\r\n#ifndef this\r\n\t#define XL_PREFIX __FUNCTION__\r\n#else\r\n\t#define XL_PREFIX typeid(this).name()\r\n#endif\r\n\r\n#ifndef this\r\n\t#define XL_OBJECT_PREFIX(T) \"FN:\"##T\r\n#else\r\n\t#define XL_OBJECT_PREFIX(T) \"Call in Class:\"##T\r\n#endif\r\n\r\n\r\n#define XL_START XL_OBJECT_PREFIX(XL_PREFIX)\r\n\r\n\r\n#define XLOG_PREFIX0 \r\n\r\n\r\n#ifdef VIRTOOLS_USER_SDK\r\n\tclass CKContext;\r\n#endif\r\n\r\n\r\nnamespace xUtils\r\n{\r\n \r\n\r\n\ttypedef enum xLoggerFlags { \r\n\t\tELOGGER_NONE=0,\r\n\t\tELOGGER_CONSOLE=2,\r\n\t\tELOGGER_MCORE=4,\r\n\t\tELOGGER_CEGUI=8,\r\n\t\tELOGGER_OUT_OBJECTS=16\r\n\t}xLoggerFlags;\r\n\r\n\tenum ELOGTYPE\r\n\t{\r\n\t\tELOGDEBUG,\r\n\t\tELOGTRACE,\r\n\t\tELOGERROR,\r\n\t\tELOGWARNING,\r\n\t\tELOGINFO,\r\n\t\tELOGALL,\r\n\t};\r\n\r\n\ttypedef enum E_PRINT_STYLE_FLAGS\r\n\t{\r\n\r\n\t\tE_PSF_PRINT_LOG_TYPE=1,\r\n\t\tE_PSF_PRINT_COMPONENT,\r\n\t\tE_PSF_PRINT_NEWLINE,\r\n\t\tE_PSF_PRINT_TAB,\r\n\r\n\t};\r\n\r\n\tstatic char* sLogTypes[]=\r\n\t{\r\n\t\t\"DEBUG\",\r\n\t\t\"TRACE\",\r\n\t\t\"ERROR\",\r\n\t\t\t\"WARNING\",\r\n\t\t\t\"INFO\",\r\n\t};\r\n\r\n\t/// xLogConsumer is the base class for the message logging system in TNL.\n\t///\n\t/// TNL by default doesn't log messages anywhere, but users of the library\n\t/// can instantiate subclasses that override the logString method.\n\t/// Any instantiated subclass of xLogConsumer will receive all general\n\t/// logprintf's, as well as any log messages that are enabled via\n\t/// the TNLLogEnable macro.\n\tclass xLogConsumer\n\t{\n\t\txLogConsumer *mNextConsumer; ///< Next xLogConsumer in the global linked list of log consumers.\n\t\txLogConsumer *mPrevConsumer; ///< Previous xLogConsumer in the global linked list of log consumers.\n\n\t\tstatic xLogConsumer *mLinkedList; ///< Head of the global linked list of log consumers.\n\n\tpublic:\n\t\t/// Constructor adds this xLogConsumer to the global linked list.\n\t\txLogConsumer();\n\n\t\t/// Destructor removes this xLogConsumer from the global linked list, and updates the log flags.\n\t\tvirtual ~xLogConsumer();\n\n\t\t/// Returns the head of the linked list of all log consumers.\n\t\tstatic xLogConsumer *getLinkedList() { return mLinkedList; }\n\n\t\t/// Returns the next xLogConsumer in the linked list.\n\t\txLogConsumer *getNext() { return mNextConsumer; }\n\n\t\t/// Writes a string to this instance of xLogConsumer.\n\t\t///\n\t\t/// By default the string is sent to the Platform::outputDebugString function. Subclasses\n\t\t/// might log to a file, a remote service, or even a message box.\n\t\tvirtual void logString(const char *string);\n\t};\r\n\r\n\tclass MODULE_API xLogger\r\n\t{\r\n\t\r\n\t\tpublic:\r\n\r\n\t\t\t\r\n\t\t\t\r\n\r\n\t\t\txLogger();\r\n\t\t\tvirtual ~xLogger();\r\n\t\t\tvoid Init();\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tstatic xBitSet& getVerbosityFlags();\r\n\t\t\tvoid setVerbosityFlags(xBitSet val) { m_VerbosityFlags = val; }\r\n\r\n\t\t\tstatic xBitSet& getLogFlags();\r\n\t\t\tvoid setLogFlags(xBitSet val) { mLogFlags = val; }\r\n\t\t\tstatic bool isLogging(int logItem);\r\n\t\t\tstatic void enableLogItem(int logItem,bool enbabled=true);\r\n\r\n\t\t\tstatic void xLog(int verbosity,const char *header,const char*msg,...);\r\n\t\t\tstatic void xLog(int type,int component,const char *header, ...);\r\n\t\t\tstatic void xLog(xBitSet styleFlags,int type,int component,const char *header, ...);\r\n\t\t\tstatic void xLog(char *cppText,int type,int component,const char *header, ...);\r\n\t\t\tstatic void xLogExtro(int style,const char *header, ...);\r\n\t\t\t\r\n\r\n\t\t\tstatic xLogger*GetInstance();\r\n\r\n\t\t\tvoid DoProcessing(float eTime/* =0::0f */);\r\n\r\n\t\t\t\r\n\t\t\ttypedef std::mapxLogItems;\r\n\t\t\ttypedef std::vectoritemDescriptionArray;\r\n\t\t\t\r\n\t\t\titemDescriptionArray mItemsDescriptions;\r\n\t\t\titemDescriptionArray& getItemDescriptions(){return xLogger::GetInstance()->mItemsDescriptions;}\r\n\t\t\t\r\n\t\t\tinline void addItemDescription(const char*descr){ mItemsDescriptions.push_back(descr); }\r\n\r\n\t\t\tconst char*getItemDescription();\r\n\r\n\r\n\t\t\txLogItems mLogItems;\r\n\t\t\txUtils::xLogger::xLogItems& getLogItems() { return mLogItems; }\r\n\t\t\tvoid setLogItems(xUtils::xLogger::xLogItems val) { mLogItems = val; }\r\n\r\n\t\t\tvoid addLogItem(int item);\r\n\t\t\tvoid setLoggingLevel(int item,xBitSet flags);\r\n xBitSet getLogLevel(int item);\r\n\t\t\tvoid enableLoggingLevel(int item,int level,int enable);\r\n\r\n\t\t\tvoid finalPrint(const char*string);\r\n\r\n\t\t\t#ifdef VIRTOOLS_USER_SDK\r\n\t\t\t\tCKContext * getVirtoolsContext() const { return mContext; }\r\n\t\t\t\tvoid setVirtoolsContext(CKContext * val) { mContext = val; }\r\n\t\t\t#endif\r\n\r\n\t\t\tvoid enableConsoleOutput(bool enable);\r\n\r\n\t\t\tprotected :\r\n\r\n\t\t\t#ifdef VIRTOOLS_USER_SDK\r\n\t\t\t\tCKContext *mContext;\r\n\t\t\t#endif\r\n\r\n\t\t\t\txBitSet mLogFlags;\r\n\t\t\t\txBitSet m_VerbosityFlags;\r\n\t\t\t\tint m_Verbosity;\r\n\t\t\t\tint m_LogOutChannels;\r\n\r\n\r\n\tpublic :\r\n\t\t\t\tint lastTyp;\r\n\t\t\t\tint lastComponent;\r\n\t\t\t\t\r\n\r\n\t\t};\r\n}\r\n\r\n\r\nusing namespace xUtils;\r\n\r\n\r\n#endif // !defined(EA_3DFA15A6_382B_4624_9E00_4531365CB9AF__INCLUDED_)\r\n\r\n/********************************************************************\r\n\tcreated:\t2004/11/06\r\n\tcreated:\t6:11:2004 16:53\r\n\tfilename: \tD:\\projects new\\vt tools\\Manager\\typedefs.h\r\n\tfile path:\tD:\\projects new\\vt tools\\Manager\r\n\tfile base:\ttypedefs\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tgBaumgart\r\n*********************************************************************/\r\n\r\n\r\n#ifndef TYPEDEFS_H\r\n\t#define TYPEDEFS_H\r\n\t\r\n\t#include \"CKAll.h\"\r\n\r\n\r\n\r\n\t#include \r\n\t#include \r\n\t#include \r\n/*\r\n\tThe following template \"Hashfunc\" only meets the requests of std::map. the reason for it is the standard compare.(result : int, but bool is used)\r\n\r\n\tfrom XString.h:\r\n\t\r\n\t int operator == (const XBaseString& iStr) const\r\n\t { return !Compare(iStr); }\r\n\r\n\tif i donŽt use this help class iŽll get the following warning:\r\n\r\n \"\r\n D:\\SDK\\VC98\\INCLUDE\\functional(86) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)\r\n D:\\SDK\\VC98\\INCLUDE\\functional(86) : while compiling class-template member function 'bool __thiscall std::less::operator ()(const class XString &,const class XString &) const'\r\n \"\r\n by call ZipJobList zili.find(XXX)\r\n\r\n\r\n or use simply :\r\n struct XStringCMP{\t\r\n\t\tbool operator() (const XString& p, const XString& q) const\r\n\t\t\t\t{\treturn strcmp(p.CStr(),q.CStr())<0; }\r\n\t };\r\n */\r\n\r\ntemplate struct HashFunc{\r\n\tbool operator ()(const T& x,const T& y)const;\r\n};\r\n\r\n\r\n//the XString special:\r\ntemplate <> struct HashFunc{\r\n\tbool operator ()(const XString& In1,const XString& In2)const{\r\n\t\t\t\r\n\t\treturn strcmp(In1.CStr(),In2.CStr())<0;\r\n\t\t/* or : \r\n\t\tsize_t out = 0;\r\n\t\tconst char* key = In1.CStr();\r\n\t\twhile (*key) out = (out <<1)^*key++;//an integer rep of a c-string\r\n\t\t*/\r\n\t}\r\n};\r\n\r\n/*\t\r\n\tZipJobList\r\n\t+Keystring\t\t|\t\tFilelist\r\n\t+......\t\t\r\n*/\r\n\r\ntypedef std::listXFileList;\r\ntypedef std::list::iterator XFileListIterator;\r\n\r\ntypedef std::map >ZipJobList; \r\ntypedef std::map >::iterator ZiJoIt;\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\tnone zip stuff\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\n/************************************************************************/\r\n/*\t a workin array container\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n/*\r\n template class fake_container{\r\n\r\npublic:\r\n\t\r\n\t //standard stuff:\r\n\ttypedef T value_type;\r\n\r\n\ttypedef T* iterator;\r\n\r\n\ttypedef const T*const_iterator;\r\n\ttypedef T& reference;\r\n\ttypedef const T& const_reference;\r\n\t\r\n\r\n\ttypedef const T* const_iterator;\r\n\tT v[amount];\r\n\toperator T*() {return v;}\r\n\t\r\n\t//ops: \r\n\titerator& operator++(){return v+1;}\r\n\titerator& operator--(){return v-1;}\r\n\t//..........................................................\r\n\r\n\t//nice:\r\n\treference operator[] (ptrdiff_t i) { return v[i] ; }\r\n\tconst_reference operator[] (ptrdiff_t i) const { return v[i] ; }\r\n\t\r\n\titerator begin() {return v;}\r\n\tconst_iterator begin() const {return v;}\r\n\titerator end() {return v+amount;}\r\n\tconst_iterator end() const {return v + amount;}\r\n\tsize_t size () const { return amount;}\r\n\t\t\r\n\tprotected:\r\n\t};\r\n*/\r\n\r\n\r\n/************************************************************************/\r\n/* tests\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n/************************************************************************/\r\n\r\n\r\n//this should become pointer array, but very strange\r\n/*\r\ntemplate class Vector{\r\n\tT*v;\r\n\tint sz;\r\n\t\r\n\tpublic:\r\n\tVector();\r\n//\t\texplicit Vector(int);\r\n\r\n//\t\tVector();\r\n//\t\toperator T*() {return v;}\r\n\r\n//T& elem(int i){return v[i];}\r\n//T& operator[](int i);\r\n};\r\n*/\r\n//thats becomes a vector - void - pointer - special template\r\n/*\r\ntemplate<> class Vector{\r\n\tvoid **p;\r\n\tvoid *&operator[](int i);\r\n};\r\n*/\r\n\r\n/************************************************************************/\r\n/* the void* specialist: */\r\n/************************************************************************/\r\n/*\r\ntemplate class Vector : private Vector{\r\n\r\n\tpublic:\r\n \ttypedef Vector Base;\r\n\r\n\tVector() : Base(){}\r\n\tpuplicit Vector()(int i) : Base(i){}\r\n\tT*elem(int i){ return static_cast(Base::elem(i));}\r\n\tT*& operator[](int i){return static_cast(Base::operator [](i));}\r\n};\r\n\r\n*/\r\n\r\n/*\r\ntemplate class Vector{\r\n\tT*v;\r\n\tint sz;\r\n\t\r\n\tpublic:\r\n\tVector();\r\n\texplicit Vector(int);\r\n\toperator T*() {return v;}\r\n\tT& elem(int i){return v[i];}\r\n\tT& operator[](int i);\r\n};\r\n*/\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SwitchOnMidi\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateSwitchOnMidiProto(CKBehaviorPrototype **);\r\nint SwitchOnMidi(const CKBehaviorContext& behcontext);\r\n\r\nCKERROR SwitchOnMidiCallBack(const CKBehaviorContext& behcontext); // CallBack Functioon\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorSwitchOnMidiDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Switch On Midi\");\t\r\n\tod->SetDescription(\"Activates the appropriate output when receiving a Midi event.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE );\r\n\tod->SetGuid(CKGUID(0x624b1bec,0x509400a8));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSwitchOnMidiProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Controllers/Midi\");\r\n\treturn od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateSwitchOnMidiProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Switch On Midi\");\r\n if(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\r\n\tproto->DeclareOutput(\"Out 1\");\r\n\r\n\tproto->DeclareInParameter(\"Channel\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Note 1\", CKPGUID_INT, \"0\");\r\n\r\n proto->DeclareOutParameter(\"Nop\", CKPGUID_NONE);\r\n proto->DeclareOutParameter(\"Attack 1\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEOUTPUTS| CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS| CKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS));\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SwitchOnMidi);\r\n\r\n\tproto->SetBehaviorCallbackFct( SwitchOnMidiCallBack );\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint SwitchOnMidi(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n\r\n if( beh->IsInputActive(1) ){ // OFF\r\n beh->ActivateInput(1, FALSE);\r\n\r\n return CKBR_OK;\r\n }\r\n \r\n if( beh->IsInputActive(0) ){ // ON\r\n beh->ActivateInput(0, FALSE);\r\n }\r\n\r\n int channel=0; // Channel\r\n beh->GetInputParameterValue(0, &channel);\r\n\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n int note, attack, count = beh->GetInputParameterCount();\r\n\r\n for( int a=1 ; aGetInputParameterValue(a, &note);\r\n if( mm->IsNoteActive(note, channel) ){\r\n beh->ActivateOutput(a-1);\r\n }\r\n\r\n //--- Attack part\r\n XListIt it;\r\n for( it = mm->listForBehaviors.Begin() ; it!=mm->listForBehaviors.End() ; it++ ){\r\n if( (*it).channel==channel ){\r\n if( (*it).command==9 || (*it).command==8 ){ // start a note\r\n if( note == (*it).note ){\r\n attack = (*it).attack;\r\n beh->SetOutputParameterValue(a, &attack);\r\n }\r\n }\r\n }\r\n }\r\n //---\r\n }\r\n\r\n \r\n return CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR SwitchOnMidiCallBack(const CKBehaviorContext& behcontext){\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n switch( behcontext.CallbackMessage ){\r\n\r\n case CKM_BEHAVIOREDITED:\r\n\t\t{\r\n\t\t\tint c_out = beh->GetOutputCount();\r\n\t\t\tint c_pin = beh->GetInputParameterCount()-1;\r\n\t\t\t\r\n\t\t\tchar str[16];\r\n\r\n while( c_pin < c_out ){ // we must add Input Params / Ouput Params\r\n\t\t\t\tsprintf( str, \"Note %d\", c_pin+1);\r\n\t\t\t\tbeh->CreateInputParameter(str, CKPGUID_INT);\r\n\r\n sprintf( str, \"Attack %d\", c_pin+1);\r\n beh->CreateOutputParameter(str, CKPGUID_INT);\r\n \r\n ++c_pin;\r\n\t\t\t}\r\n\r\n while( c_pin > c_out ){ // we must remove Input Params / Ouput Params\r\n CKDestroyObject(beh->RemoveInputParameter(c_pin));\r\n CKDestroyObject(beh->RemoveOutputParameter(c_pin));\r\n --c_pin;\r\n }\r\n\r\n CKBehaviorIO *out;\r\n while( c_out ){\r\n --c_out;\r\n out = beh->GetOutput(c_out);\r\n sprintf( str, \"Out %d\", c_out+1);\r\n out->SetName(str);\r\n }\r\n }\r\n break;\r\n \r\n case CKM_BEHAVIORATTACH:\r\n case CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tmm->AddMidiBBref();\r\n\t\t} break;\r\n case CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tmm->RemoveMidiBBref();\r\n\t\t} break;\r\n \r\n\t}\r\n\t\r\n\treturn CKBR_OK; \r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBPhysicalizeExDecl();\r\nCKERROR CreatePBPhysicalizeExProto(CKBehaviorPrototype **pproto);\r\nint PBPhysicalizeEx(const CKBehaviorContext& behcontext);\r\nCKERROR PBPhysicalizeExCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_HullType,\r\n\tbbI_Flags,\r\n\tbbI_Density,\r\n\tbbI_XML,//\tfrom here optional parameters\r\n\tbbI_World,\t\r\n\tbbI_Pivot,\r\n\tbbI_Mass,\r\n\tbbI_Collision,\r\n\tbbI_CCD,\r\n\tbbI_Material,\r\n\tbbI_Optimization,\r\n\tbbI_Capsule,\r\n\tbbI_CCylinder,\r\n};\r\n\r\n\r\n#define BB_SSTART 3\r\n#define gPIMAP pInMap232\r\nBBParameter pInMap232[] =\r\n{\r\n\r\n\tBB_PIN(bbI_HullType,VTE_COLLIDER_TYPE,\"Hull Type\",\"Sphere\"),\r\n\tBB_PIN(bbI_Flags,VTF_BODY_FLAGS,\"Flags\",\"Moving Object,World Gravity,Collision\"),\r\n\tBB_PIN(bbI_Density,CKPGUID_FLOAT,\"Density\",\"1.0\"),\r\n\tBB_SPIN(bbI_XML,VTS_PHYSIC_ACTOR_XML_SETUP,\"XML Setup\",\"\"),// from here optional parameters\r\n\tBB_SPIN(bbI_World,CKPGUID_3DENTITY,\"World Reference\",\"pDefaultWorld\"),\r\n\tBB_SPIN(bbI_Pivot,VTS_PHYSIC_PIVOT_OFFSET,\"Pivot\",\"\"),\r\n\tBB_SPIN(bbI_Mass,VTS_PHYSIC_MASS_SETUP,\"Mass\",\"\"),\r\n\tBB_SPIN(bbI_Collision,VTS_PHYSIC_COLLISIONS_SETTINGS,\"Collision\",\"All,0,0.025f\"),\r\n\tBB_SPIN(bbI_CCD,VTS_PHYSIC_CCD_SETTINGS,\"CCD\",\"\"),\r\n\tBB_SPIN(bbI_Material,VTS_MATERIAL,\"Material\",\"\"),\r\n\tBB_SPIN(bbI_Optimization,VTS_PHYSIC_ACTOR_OPTIMIZATION,\"Optimization\",\"\"),\r\n\tBB_SPIN(bbI_Capsule,VTS_CAPSULE_SETTINGS_EX,\"Capsule Settings\",\"\"),\r\n\tBB_SPIN(bbI_CCylinder,VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR,\"Convex Cylinder Settings\",\"\"),\r\n};\r\nCKObjectDeclaration\t*FillBehaviorPBPhysicalizeExDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBPhysicalizeEx\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Adds an entity to the physic engine.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x16b33c81,0x8a96d3e));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBPhysicalizeExProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBPhysicalizeExProto\r\n// FullName: CreatePBPhysicalizeExProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBPhysicalizeExProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBPhysicalizeEx\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PBPhysicalizeEx \r\n\r\n\tPBPhysicalizeEx is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRegisters an object in the physic engine.
\r\n\tSee PBPhysicalizeEx.cmo for example.\r\n\t\r\n\t

Technical Information

\r\n\r\n\t\\image html PBPhysicalizeEx.png\r\n\r\n\tIn: triggers the process
\r\n\t\r\n\tOut: is activated when the process is completed
\r\n\t\r\n\t
\r\n\t\r\n\tTarget:The 3D Entity associated to the rigid body
\r\n\t\r\n\tFlags: Flags to determine common properties for the desired body.It is possible to alter certain flags after creation. See #BodyFlags for more information
\r\n\r\n\t\t-\tRange: [BodyFlags] \r\n\t\t-\tDefault:Moving,Collision,World Gravity
\r\n\r\n\t\t-\tWays to alter flags :\r\n\t\t\t-\tUsing \\ref PBSetPar\r\n\t\t\t-\tUsing VSL : #pRigidBody::updateFlags()\r\n\r\n\tHull Type: The desired shape type. The intial shape can NOT be changed after creation. See #HullType for more information
\r\n\t\r\n\t\t-\tRange: [HullType]
\r\n\t\t-\tDefault:Sphere
\r\n\r\n\tDensity: Density of the initial shape
\r\n\t\r\n\t\t-\tRange: [0,inf]
\r\n\t\t-\tDefault:1.0f
\r\n\t\r\n\t\t-\tWays to change the mass : \r\n\t\t\t-\tEnable \"Mass\" in building block settings and set \"New Density\" or \"Total Mass\" non-zero. \r\n\t\t\t-\tUsing VSL #pRigidBody::updateMassFromShapes()\r\n\r\n\t
\r\n\t\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createRigidBody().
\r\n\r\n\t\r\n\r\n\r\n\t

Optional Parameters

\r\n\r\n\tAll more specific parameters such as material or pivot offset must be enabled by the building block settings
\r\n\r\n\tPBPhysicalizeEx all settings enabled :
\r\n\t\r\n\t\\image html PBPhysicalizeExCollapsed.jpg\r\n\r\n\r\n\tXML Setup: This parameter is not being used in this release
\r\n\t\r\n\t
\r\n\tWorld Reference: World associated with this rigid body. Leave blank to use default world (3D - Frame \"pDefaultWorld\" with world attribute)
\r\n\r\n\t\t-\tRange: [object range]
\r\n\t\t-\tDefault:NULL
\r\n\r\n
\r\n\r\n\r\n\tPivot: Specifies the rigid bodies local shape offset (#pPivotSettings)

\r\n\t\\image html pBPivotParameter.jpg\r\n\r\n\t\t-\tOffset Linear: \\copydoc pPivotSettings::localPosition\r\n\t\t-\tOffset Angular: \\copydoc pPivotSettings::localOrientation\r\n\t\t-\tOffset Reference: \\copydoc pPivotSettings::pivotReference\r\n\r\n\t\t

Notes


\r\n\r\n\t\t-\tAlter or set the shape offset : \r\n\t\t\t-\tUsing the built-in building blocks with \"Physics\" settings enabled : \r\n\t\t\t\t-\t\"Set Position\" \r\n\t\t\t\t-\t\"Translate\"\r\n\t\t\t\t-\t\"Set Orientation\"\r\n\t\t\t-\t#pRigidBody::setPosition() or #pRigidBody::setRotation()\r\n\t\t\t-\tAttach attribute \"Physics\\pBPivotSettings\" to :\t\r\n\t\t\t\t-\t3D-Entity\r\n\t\t\t\t-\tits mesh\r\n\t\t\t\t-\tor to the meshes material
\r\n\r\n
\r\n\t\r\n\tMass: Overrides mass setup (#pMassSettings)

\r\n\t\\image html pBMassParameter.jpg\r\n\r\n\t-\tNew Density:\t\\copydoc pMassSettings::newDensity\r\n\r\n\t-\tTotal Mass:\t\\copydoc pMassSettings::totalDensity\r\n\r\n\t-\tOffset Linear:\t\\copydoc pMassSettings::localPosition\r\n\r\n\t-\tOffset Angular:\t\\copydoc pMassSettings::localOrientation\r\n\r\n\t-\tOffset Reference:\t\\copydoc pMassSettings::massReference\r\n\r\n\t

Notes


\r\n\t-\tAlter or set mass settings : \r\n\t\t-\tAttach attribute \"Physics\\pBOptimization\" to the :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material
\r\n\t\t-\t#pRigidBody::updateMassFromShapes()\r\n\r\n
\r\n\t\r\n\t\t\r\n\t\r\n\tCollision: Overrides collsion settings (#pCollisionSettings)

\r\n\t\\image html pBCollisionParameter.jpg\r\n\r\n\t-\tCollision Group: \t\\copydoc pCollisionSettings::collisionGroup\r\n\t\r\n\t-\tGroup Mask:\t\\copydoc pCollisionSettings::groupsMask\r\n\r\n\t-\tSkin Width:\\copydoc pCollisionSettings::skinWidth\r\n\r\n\t

Notes


\r\n\t-\tAlter or set collisions settings : \r\n\t\t\t-\t\\ref PBSetPar. Collisions group can be set per sub shape.\r\n\t\t\t-\tpRigidBody::setCollisionsGroup()\r\n\t\t\t-\tpRigidBody::setGroupsMask()\r\n\t\t\t-\tAttach attribute \"Physics\\pBCollisionSettings\" to :\t\r\n\t\t\t\t-\t3D-Entity\r\n\t\t\t\t-\tits mesh\r\n\t\t\t\t-\tor to the meshes material
\r\n\t\r\n\t-\tPlease create custom groups in the Virtools \"Flags and Enum manager\" : \"pBCollisionsGroup\". This enumeration is stored in the cmo
\r\n\r\n
\r\n\r\n\tCCD: Specifies a CCD mesh. This parameter is NOT being used in this release.

\r\n\t\\image html pBCCSettingsParameter.jpg\r\n\r\n
\r\n\r\n\r\n\r\n\t\r\n\tMaterial: Specifies a physic material(#pMaterial)

\r\n\t\\image html pBMaterial.jpg\r\n\r\n\t-\tXML Link : \\copydoc pMaterial::xmlLinkID\r\n\t-\tDynamic Friction : \\copydoc pMaterial::dynamicFriction\r\n\t-\tStatic Friction: \\copydoc pMaterial::staticFriction\r\n\t-\tRestitution: \\copydoc pMaterial::restitution\r\n\t-\tDynamic Friction V: \\copydoc pMaterial::dynamicFrictionV\r\n\t-\tStatic Friction V : \\copydoc pMaterial::staticFrictionV\r\n\t-\tDirection Of Anisotropy: \\copydoc pMaterial::dirOfAnisotropy\r\n\t-\tFriction Combine Mode: \\copydoc pMaterial::frictionCombineMode\r\n\t-\tRestitution Combine Mode: \\copydoc pMaterial::restitutionCombineMode\r\n\t-\tFlags: \\copydoc pMaterial::flags\r\n\r\n\t

Notes


\r\n\r\n\t-\tAlter or set a physic material is also possible by :\r\n\t\t-\t\\ref PBSetMaterial\r\n\t\t-\t#pRigidBody::updateMaterialSettings()\r\n\t\t-\tAttach attribute \"Physics\\pBMaterial\" to :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material\r\n\t\t-\tUsing VSL : \r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t\\include pBMaterialSetup.vsl\r\n\t\t\t\r\n\t\r\n\t-\tThe enumeration \"XML Link\" is being populated by the file \"PhysicDefaults.xml\" and gets updated on every reset. \r\n\t-\tIf using settings from XML, the parameter gets updated too
\r\n\r\n
\r\n\r\n\r\n\tOptimization: Specifies various optimizations(#pOptimization)

\r\n\t\\image html pBOptimization.jpg\r\n\r\n\t-\tTransformation Locks : Flags to lock a rigid body in certain degree of freedom. See also #pRigidBody::lockTransformation\r\n\t-\tDamping: \r\n\t\t\r\n\t\t\t-\tLinear Damping : \\copydoc pRigidBody::setLinearDamping\r\n\r\n\t\t\t-\tAngular Damping : \\copydoc pRigidBody::setAngularDamping\r\n\r\n\t-\tSleeping: \r\n\t\t\r\n\t\t\t-\tLinear Sleep Velocity : \\copybrief pRigidBody::setSleepLinearVelocity\r\n\r\n\t\t\t-\tAngular Sleep Velocity : \\copydoc pRigidBody::setSleepAngularVelocity\r\n\r\n\t\t\t-\tSleep Energy Threshold : \\copydoc pRigidBody::setSleepEnergyThreshold\r\n\t\r\n\t-\tSolver Iteration : \\copydoc pRigidBody::setSolverIterationCount\r\n\r\n\t-\tDominance Group : \\copydoc pRigidBody::setDominanceGroup\r\n\r\n\t-\tCompartment Id : Not Implemented\r\n\r\n\t

Notes


\r\n\r\n\t-\tAlter or set a rigid bodies optimization is also possible by :\r\n\t\t-\t\\ref PBSetPar\r\n\t\t-\t#pRigidBody::updateOptimizationSettings()\r\n\t\t-\tAttach the attribute \"Physics\\pBOptimization\" to :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material
\r\n\t\t-\tUsing VSL before creation :\r\n\r\n\t\t\r\n\t\t\\include pBOptimizationCreation.vsl\r\n\t\t\r\n\r\n\t\t-\tUsing VSL after creation :\r\n\r\n\t\t\r\n\t\t\t\\include pBOptimizationAfterCreation.vsl\r\n\t\t\r\n\r\n\t\t\r\n\r\n
\r\n\r\n\tCapsule Settings: Overrides capsule default dimensions(#pCapsuleSettingsEx)

\r\n\t\\image html pBCapsuleSettings.jpg\r\n\r\n\t-\tRadius : \\copydoc pCapsuleSettingsEx::radius\r\n\t-\tHeight : \\copydoc pCapsuleSettingsEx::height\r\n\r\n\r\n\t

Notes


\r\n\r\n\t-\tSetting a rigid bodies capsule dimension is also possible by :\r\n\t-\tAttach the attribute \"Physics\\pCapsule\" to :\t\r\n\t\t-\t3D-Entity\r\n\t\t-\tits mesh\r\n\t\t-\tor to the meshes material\r\n\t\r\n\t-\tVSL :\r\n\t\r\n\t\r\n\t\t\\include pBCapsuleEx.vsl\r\n\t\r\n\t\r\n
\r\n\r\n\r\n\r\n\r\n\tConvex Cylinder Settings: Overrides default convex cylinder settings(#pConvexCylinderSettings)

\r\n\t\\image html pBConvexCylinder.jpg\r\n\r\n\t-\tApproximation : \\copydoc pConvexCylinderSettings::approximation\r\n\t\r\n\t-\tRadius : \\copydoc pConvexCylinderSettings::radius\r\n\t-\tHeight : \\copydoc pConvexCylinderSettings::height\r\n\t\r\n\t-\tForward Axis : \\copydoc pConvexCylinderSettings::forwardAxis\r\n\t-\tForward Axis Reference: \\copydoc pConvexCylinderSettings::forwardAxisRef\r\n\r\n\t-\tDown Axis : \\copydoc pConvexCylinderSettings::downAxis\r\n\t-\tDown Axis Reference: \\copydoc pConvexCylinderSettings::downAxisRef\r\n\r\n\t-\tRight : \\copydoc pConvexCylinderSettings::rightAxis\r\n\t-\tRight Axis Reference: \\copydoc pConvexCylinderSettings::rightAxisRef\r\n\r\n\t-\tBuild Lower Half Only : \\copydoc pConvexCylinderSettings::buildLowerHalfOnly\r\n\r\n\t-\tConvex Flags : \\copydoc pConvexCylinderSettings::convexFlags\r\n\r\n\r\n\t

Notes


\r\n\r\n\t-\tSet a rigid bodies convex cylinder parameters by :\r\n\t\t-\tAttach the attribute \"Physics\\pConvexCylinder\" to :\t\r\n\t\t\t-\t3D-Entity\r\n\t\t\t-\tits mesh\r\n\t\t\t-\tor to the meshes material\r\n\t-\tVSL :\r\n\r\n\t\t\r\n\t\t\t\\include pBConvexCylinder.vsl\r\n\t\t\r\n\r\n
\r\n\t\r\n*/\r\n\r\n\r\n\tBB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(gPIMAP)\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct( PBPhysicalizeExCB );\r\n\tproto->SetFunction(PBPhysicalizeEx);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBPhysicalizeEx\r\n// FullName: PBPhysicalizeEx\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBPhysicalizeEx(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tobjects\t\t\r\n\t//\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\t//the object :\r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t//the world reference, optional used\r\n\tCK3dEntity*worldRef = NULL;\r\n\r\n\t//the world object, only used when reference has been specified\r\n\tpWorld *world = NULL;\r\n\r\n\t//final object description \r\n\tpObjectDescr *oDesc = new pObjectDescr();\r\n\r\n\tpRigidBody *body = NULL;\r\n\tXString errMesg;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks \r\n\t//\r\n\r\n\r\n\t// rigid body \r\n\t GetPMan()->getBody(target);\r\n\tif( body){\r\n\t\terrMesg.Format(\"Object %s already registered.\",target->GetName());\r\n\t\tbbErrorME(errMesg.Str());\r\n\r\n\t}\r\n \r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\tif (!GetPMan()->isValid())\r\n\t\tGetPMan()->performInitialization();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tCollecting data. Stores all settings in a pObjectDescr.\r\n\t//\r\n\r\n\t//get the parameter array\r\n\tBB_DECLARE_PIMAP;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// generic settings\r\n\t//\r\n\toDesc->hullType = (HullType)GetInputParameterValue(beh,bbI_HullType);\r\n\toDesc->flags = (BodyFlags)GetInputParameterValue(beh,bbI_Flags);\r\n\toDesc->density = GetInputParameterValue(beh,bbI_Density);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tworld\t\t \r\n\t//\r\n\tBBSParameterM(bbI_World,BB_SSTART);\r\n\tif (sbbI_World)\r\n\t{\r\n\t\tworldRef = (CK3dEntity *) beh->GetInputParameterObject(BB_IP_INDEX(bbI_World));\r\n\t\tif (worldRef)\r\n\t\t{\r\n\t\t\tworld = GetPMan()->getWorld(worldRef,target); \r\n\t\t\tif (!world)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"World reference has been specified but no valid world object found. Switching to default world\");\r\n\t\t\t\tgoto errorFound;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n \r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tPivot\r\n\t//\r\n\tBBSParameterM(bbI_Pivot,BB_SSTART);\r\n\tif (sbbI_Pivot)\r\n\t{\r\n\t\tCKParameter*pivotParameter = beh->GetInputParameter(BB_IP_INDEX(bbI_Pivot))->GetRealSource();\r\n\t\tif (pivotParameter)\r\n\t\t{\r\n\t\r\n\t\t\tIParameter::Instance()->copyTo(oDesc->pivot,pivotParameter);\r\n\t\t\toDesc->mask |= OD_Pivot;\r\n\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tmass\r\n\t//\r\n\tBBSParameterM(bbI_Mass,BB_SSTART);\r\n\tif (sbbI_Mass)\r\n\t{\r\n\r\n\t\tCKParameter*massParameter = beh->GetInputParameter(BB_IP_INDEX(bbI_Mass))->GetRealSource();\r\n\t\tif (massParameter)\r\n\t\t{\r\n\t\t\r\n\t\t\tIParameter::Instance()->copyTo(oDesc->mass,massParameter);\r\n\t\t\toDesc->mask |= OD_Mass;\r\n\t\t}\r\n\t\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcollision\r\n\t//\r\n\tBBSParameterM(bbI_Collision , BB_SSTART);\r\n\tif (sbbI_Collision)\r\n\t{\r\n\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Collision))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\toDesc->collisionGroup = GetValueFromParameterStruct(par,PS_BC_GROUP,false);\r\n\r\n\t\t\tCKParameterOut* maskPar = GetParameterFromStruct(par,PS_BC_GROUPSMASK);\r\n\t\t\tif (maskPar)\r\n\t\t\t{\r\n\t\t\t\toDesc->groupsMask.bits0 = GetValueFromParameterStruct(maskPar,0);\r\n\t\t\t\toDesc->groupsMask.bits1 = GetValueFromParameterStruct(maskPar,1);\r\n\t\t\t\toDesc->groupsMask.bits2 = GetValueFromParameterStruct(maskPar,2);\r\n\t\t\t\toDesc->groupsMask.bits3 = GetValueFromParameterStruct(maskPar,3);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\toDesc->skinWidth = GetValueFromParameterStruct(par,PS_BC_SKINWITDH,false);\r\n\r\n\t\t\tIParameter::Instance()->copyTo(oDesc->collision,par);\r\n\t\t\toDesc->mask |= OD_Collision;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcollision : CCD \r\n\t//\r\n\tBBSParameterM(bbI_CCD, BB_SSTART);\r\n\tif (sbbI_CCD)\r\n\t{\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_CCD))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc->ccd,par);\r\n\t\t\toDesc->mask |= OD_CCD;\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\toptimization\r\n\t//\r\n\tBBSParameterM(bbI_Optimization, BB_SSTART);\r\n\tif (sbbI_Optimization)\r\n\t{\r\n\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Optimization))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tIParameter::Instance()->copyTo(oDesc->optimization,par);\r\n\t\t\toDesc->mask |= OD_Optimization;\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tMaterial\r\n\t//\r\n\tBBSParameterM(bbI_Material, BB_SSTART);\r\n\tif (sbbI_Material)\r\n\t{\r\n\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Material))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(oDesc->material,par);\r\n\t\t\toDesc->mask |= OD_Material;\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tcapsule\r\n\t//\r\n\tBBSParameterM(bbI_Capsule, BB_SSTART);\r\n\tif (sbbI_Capsule)\r\n\t{\r\n\t\tif (oDesc->hullType == HT_Capsule)\r\n\t\t{\r\n\t\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_Capsule))->GetRealSource();\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tIParameter::Instance()->copyTo(oDesc->capsule,par);\r\n\t\t\t\toDesc->mask |= OD_Capsule;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\terrMesg.Format(\"You attached a capsule parameter but the hull type is not capsule\");\r\n\t\t\tbbWarning(errMesg.Str());\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\toptional\r\n\t//\t\tconvex cylinder\r\n\t//\r\n\tBBSParameterM(bbI_CCylinder, BB_SSTART);\r\n\tif (sbbI_CCylinder)\r\n\t{\r\n\t\tif (oDesc->hullType == HT_ConvexCylinder)\r\n\t\t{\r\n\t\t\tCKParameter*par = beh->GetInputParameter(BB_IP_INDEX(bbI_CCylinder))->GetRealSource();\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(oDesc->convexCylinder,par,true);\r\n\t\t\t\toDesc->mask |= OD_ConvexCylinder;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\terrMesg.Format(\"You attached a convex cylinder parameter but the hull type is not a convex cylinder\");\r\n\t\t\tbbWarning(errMesg.Str());\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\toDesc->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tbody creation\r\n\t//\r\n\tif (!body)\r\n\t{\r\n\r\n\t\tif(! (oDesc->flags & BF_SubShape) )\r\n\t\t{\r\n\t\t\tbody = pFactory::Instance()->createRigidBody(target,*oDesc);\r\n\t\t}\r\n\t}\r\n\r\n\tif (!body)\r\n\t{\r\n\t\tSAFE_DELETE(oDesc);\r\n\t\tbbErrorME(\"No Reference Object specified\");\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tattribute creation, attach settings \t\t\r\n\t//\r\n\tif (oDesc->flags & BF_AddAttributes )\r\n\t{\r\n\t\t//body->saveToAttributes(oDesc);\r\n\t\tGetPMan()->copyToAttributes(*oDesc,target);\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// update input parameters\r\n\t//\r\n\tif (sbbI_Material)\r\n\t{\r\n\t\tCKParameterOut *par = (CKParameterOut*)beh->GetInputParameter(BB_IP_INDEX(bbI_Material))->GetRealSource();\r\n\t\tif (par)\r\n\t\t{\r\n\t\t\tpFactory::Instance()->copyTo(par,oDesc->material);\r\n\t\t}\r\n\t}\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// cleanup \r\n\t//\r\n\t//SAFE_DELETE(oDesc);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// error out\r\n\t//\r\n\terrorFound:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_GENERICERROR;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// All ok\r\n\t//\r\n\tallOk:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBPhysicalizeExCB\r\n// FullName: PBPhysicalizeExCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBPhysicalizeExCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\n#include \"ResourceTools.h\"\r\n\r\nHINSTANCE GetModulefromResource(HMODULE hModule,int name,char *tempfile){\r\n\r\n\tBYTE *data;\r\n\tHANDLE hfile;\r\n\tDWORD len,c;\r\n\tchar temppath[MAX_PATH];\r\n\tHRSRC hres;\r\n\r\n\tif (hres=FindResource((HMODULE)hModule,MAKEINTRESOURCE(name),RT_RCDATA)){\r\n\t\t\tlen=SizeofResource(hModule,hres);\r\n\t\t\thres=(HRSRC)LoadResource(hModule,hres);\r\n\t\t\tdata=(BYTE*)LockResource((HRSRC)hres);\r\n\r\n\r\n\t}\r\n\tGetTempPath(MAX_PATH,temppath);\r\n\tGetTempFileName(temppath,\"tostrong\",0,tempfile);\r\n\thfile=CreateFile(tempfile,GENERIC_WRITE|FILE_SHARE_DELETE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY,NULL);\r\n\tWriteFile(hfile,data,len,&c,NULL);\r\n\tCloseHandle(hfile);\r\n\tdelete data;\r\n\treturn LoadLibrary(tempfile);\r\n}\r\n\r\nHMODULE\tGetParentModule(CK_PLUGIN_TYPE type,CKGUID guid){\r\n\t\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tfor (int i=0;iGetPluginDllCount();i++){\r\n\t\tCKPluginEntry* desc=ThePluginManager->GetPluginInfo(type,i); \r\n\t\tCKPluginDll* dll =ThePluginManager->GetPluginDllInfo(desc->m_PluginDllIndex); \r\n\t\tif (desc->m_PluginInfo.m_GUID == guid)return ((HMODULE)dll->m_DllInstance);\r\n\t}\r\n\treturn NULL;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pWorldCallbacks.h\"\r\n\r\nbool pContactModify::onContactConstraint(NxU32& changeFlags, const NxShape* shape0, const NxShape* shape1, const NxU32 featureIndex0, const NxU32 featureIndex1, NxContactCallbackData& data)\r\n{\r\n\r\n\tbool result = true;\r\n\t\r\n\tNxActor *actor0 = &shape0->getActor();\r\n\tNxActor *actor1 = &shape1->getActor();\r\n\t\r\n\tpRigidBody *body0 = NULL;\r\n\tpRigidBody *body1 = NULL;\r\n\r\n\tif (actor0)\r\n\t{\r\n\t\tbody0 = static_cast(actor0->userData);\r\n\t\t\r\n\t}\r\n\tif (actor1)\r\n\t{\r\n\t\tbody1 = static_cast(actor1->userData);\r\n\t}\r\n\r\n\tpContactModifyData cData;\r\n\tcData.dynamicFriction0 = data.dynamicFriction0;\r\n\tcData.dynamicFriction1 = data.dynamicFriction1;\r\n\tcData.staticFriction0 = data.staticFriction0;\r\n\tcData.staticFriction1 = data.staticFriction1;\r\n\tcData.localorientation0 = getFrom(data.localorientation0);\r\n\tcData.localorientation1 = getFrom(data.localorientation1);\r\n\tcData.localpos0 = getFrom(data.localpos0);\r\n\tcData.localpos1 = getFrom(data.localpos1);\r\n\tcData.restitution = data.restitution;\r\n\tcData.minImpulse = data.minImpulse;\r\n\tcData.maxImpulse = data.maxImpulse;\r\n\tcData.target = getFrom(data.target);\r\n\tcData.error = getFrom(data.error);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// execute callback scripts\r\n\t//\r\n\tif (body0 )\r\n\t{\r\n\t\tif (body0->getFlags() & BF_ContactModify )\r\n\t\t{\r\n\t\t\tresult = body0->onContactConstraint((int&)changeFlags,body0->GetVT3DObject(),body1->GetVT3DObject(),&cData);\r\n\t\t\tif (!result)\r\n\t\t\t\treturn false;\r\n\t\t\t\r\n\t\t\tif (changeFlags == CMM_None )\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (body1)\r\n\t{\r\n\t\tif (body1->getFlags() & BF_ContactModify)\r\n\t\t{\r\n\t\t\tresult = body1->onContactConstraint((int&)changeFlags,body1->GetVT3DObject(),body0->GetVT3DObject(),&cData);\r\n\t\t\tif (!result)\r\n\t\t\t\treturn false;\r\n\r\n\t\t\tif (changeFlags == CMM_None )\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// copy result back to sdk\r\n\t//\r\n\tif (changeFlags!=CMM_None)\r\n\t{\r\n\t\tdata.dynamicFriction0 = cData.dynamicFriction0;\r\n\t\tdata.dynamicFriction1 = cData.dynamicFriction1;\r\n\t\tdata.staticFriction0 = cData.staticFriction0;\r\n\t\tdata.staticFriction1 = cData.staticFriction1;\r\n\t\tdata.localorientation0 = getFrom(cData.localorientation0);\r\n\t\tdata.localorientation1 = getFrom(cData.localorientation1);\r\n\t\tdata.localpos0 = getFrom(cData.localpos0);\r\n\t\tdata.localpos1 = getFrom(cData.localpos1);\r\n\t\tdata.restitution = cData.restitution;\r\n\t\tdata.minImpulse = cData.minImpulse;\r\n\t\tdata.maxImpulse = cData.maxImpulse;\r\n\t\tdata.target = getFrom(cData.target);\r\n\t\tdata.error = getFrom(cData.error);\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nvoid pContactReport::onContactNotify(NxContactPair& pair, NxU32 events)\r\n{\r\n\r\n\tpRigidBody *bodyA = NULL;\r\n\tpRigidBody *bodyB = NULL;\r\n\r\n\tif (pair.actors[0])\r\n\t{\r\n\t\tbodyA = static_cast(pair.actors[0]->userData);\r\n\t}\r\n\tif (pair.actors[1])\r\n\t{\r\n\t\tbodyB = static_cast(pair.actors[1]->userData);\r\n\t}\r\n\r\n\tif (bodyA) \r\n\t{\r\n\t\t/*\r\n\t\tif (bodyA->hasWheels())\r\n\t\t{\r\n\t\t\tbodyA->handleContactPair(&pair,0);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t\t*/\r\n\r\n\t\t/*\r\n\t\tif (bodyA->getVehicle())\r\n\t\t{\r\n\t\t\tpVehicle* v = bodyA->getVehicle();\r\n\t\t\tv->handleContactPair(&pair, 0);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t\t*/\r\n\t}\r\n\tif ( bodyB ) \r\n\t{\r\n\t\t/*\r\n\t\tif (bodyB->hasWheels())\r\n\t\t{\r\n\t\t\tbodyB->handleContactPair(&pair,1);\r\n\t\t\treturn ;\r\n\t\t}\r\n\r\n\t\tif (bodyB->getVehicle())\r\n\t\t{\r\n\t\t\tpVehicle* v = bodyB->getVehicle();\r\n\t\t\tv->handleContactPair(&pair, 1);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t\t*/\r\n\r\n\t\t\r\n\t}\r\n\r\n\t// Iterate through contact points\r\n\tNxContactStreamIterator i(pair.stream);\r\n\t//user can call getNumPairs() here\r\n\twhile(i.goNextPair())\r\n\t{\r\n\t\t//user can also call getShape() and getNumPatches() here\r\n\t\twhile(i.goNextPatch())\r\n\t\t{\r\n\t\t\t//user can also call getPatchNormal() and getNumPoints() here\r\n\t\t\tconst NxVec3& contactNormal = i.getPatchNormal();\r\n\t\t\twhile(i.goNextPoint())\r\n\t\t\t{\r\n\t\t\t\t//user can also call getPoint() and getSeparation() here\r\n\t\t\t\tconst NxVec3& contactPoint = i.getPoint();\r\n\t\t\t\t\r\n\t\t\t\tpCollisionsEntry entry;\r\n\t\t\t\tentry.point = pMath::getFrom(contactPoint);\r\n\t\t\t\tNxU32 faceIndex = i.getFeatureIndex0();\r\n\t\t\t\tif(faceIndex==0xffffffff)faceIndex = i.getFeatureIndex1();\r\n\t\t\t\tif(faceIndex!=0xffffffff)entry.faceIndex = faceIndex;\r\n\r\n\t\t\t\tentry.actors[0] = pair.actors[0];\r\n\t\t\t\tentry.actors[1] = pair.actors[1];\r\n\t\t\t\tentry.faceIndex = faceIndex;\r\n\t\t\t\tentry.sumNormalForce = pMath::getFrom(pair.sumNormalForce);\r\n\t\t\t\tentry.sumFrictionForce = pMath::getFrom(pair.sumFrictionForce);\r\n\t\t\t\tentry.faceNormal = pMath::getFrom(contactNormal);\r\n\t\t\t\tentry.eventType = events;\r\n\t\t\t\tentry.pointNormalForce=i.getPointNormalForce();\r\n\t\t\t\tentry.distance = i.getSeparation();\r\n\r\n\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//store shapes\r\n\r\n\r\n\t\t\t\tNxShape *shapeA = i.getShape(0);\r\n\t\t\t\tif (shapeA)\r\n\t\t\t\t{\r\n\t\t\t\t\tpSubMeshInfo *shapeInfo= static_cast(shapeA->userData);\r\n\t\t\t\t\tif (shapeInfo)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tentry.shapeEntityA = shapeInfo->entID;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tshapeA = i.getShape(1);\r\n\t\t\t\tif (shapeA)\r\n\t\t\t\t{\r\n\t\t\t\t\tpSubMeshInfo *shapeInfo= static_cast(shapeA->userData);\r\n\t\t\t\t\tif (shapeInfo)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tentry.shapeEntityB = shapeInfo->entID;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\r\n\t\t\t\tpRigidBody *bodyA = NULL;\r\n\t\t\t\tpRigidBody *bodyB = NULL;\r\n\t\t\t\tif (pair.actors[0])\r\n\t\t\t\t{\r\n\t\t\t\t\tbodyA = static_cast(pair.actors[0]->userData);\r\n\t\t\t\t}\r\n\t\t\t\tif (pair.actors[1])\r\n\t\t\t\t{\r\n\t\t\t\t\tbodyB = static_cast(pair.actors[1]->userData);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\r\n\t\t\t\tif (bodyA && bodyA->getActor() /*&& (bodyA->getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH ) */)\r\n\t\t\t\t{\r\n\t\t\t\t\tentry.bodyA = bodyA;\r\n\t\t\t\t\tentry.bodyB = bodyB;\r\n\t\t\t\t\tbodyA->getCollisions().Clear();\r\n\t\t\t\t\tbodyA->getCollisions().PushBack(entry);\r\n\t\t\t\t\tbodyA->onContactNotify(&entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (bodyB && bodyB->getActor()/* && (bodyB->getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH ) */)\r\n\t\t\t\t{\r\n\t\t\t\t\tentry.bodyA = bodyA;\r\n\t\t\t\t\tentry.bodyB = bodyB;\r\n\t\t\t\t\tbodyB->getCollisions().Clear();\r\n\t\t\t\t\tbodyB->getCollisions().PushBack(entry);\r\n\t\t\t\t\tbodyB->onContactNotify(&entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//\t\t\t\tresult->getActor()->setContactReportFlags(NX_NOTIFY_ON_TOUCH);\r\n\t\t\t\t/*\r\n\t\t\t\t{\r\n\t\t\t\tentry.bodyA = body;\r\n\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\tbody->getCollisions().PushBack(entry);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (pair.actors[1])\r\n\t\t\t\t{\r\n\t\t\t\tpRigidBody *body = static_cast(pair.actors[1]->userData);\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\tentry.bodyB = body;\r\n\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\tbody->getCollisions().PushBack(entry);\r\n\r\n\t\t\t\t}\r\n\t\t\t\t}*/\r\n\t\t\t\t/*getWorld()->getCollisions().PushBack(entry);*/\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nint pWorld::overlapOBBShapes(const VxBbox& worldBounds, CK3dEntity*shapeReference, pShapesType shapeType,CKGroup *shapes,int activeGroups/* =0xffffffff */, const pGroupsMask* groupsMask/* =NULL */, bool accurateCollision/* =false */)\r\n{\r\n\r\n\tint result=0;\r\n\r\n\tNxBox box;\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\r\n\t\tNxShape *shape = getShapeByEntityID(shapeReference->GetID());\r\n\t\tif (shape)\r\n\t\t{\r\n\t\t\t//shape->checkOverlapAABB()\r\n\r\n\t\t\tNxBoxShape*boxShape = static_cast(shape->isBox());\r\n\t\t\tif (boxShape)\r\n\t\t\t{\r\n\t\t\t\tboxShape->getWorldOBB(box);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}else{\r\n\r\n\t\tbox.center = getFrom(worldBounds.GetCenter());\r\n\t\tbox.extents = getFrom(worldBounds.GetSize());\r\n\t}\r\n\r\n\tint total = 0;\r\n\tif (shapeType & ST_Dynamic )\r\n\t{\r\n\t\ttotal+=getScene()->getNbDynamicShapes();\r\n\t}\r\n\r\n\tif (shapeType & ST_Static)\r\n\t{\r\n\t\ttotal+=getScene()->getNbStaticShapes();\r\n\t}\r\n\r\n\tNxShape** _shapes = (NxShape**)NxAlloca(total*sizeof(NxShape*));\r\n\tfor (NxU32 i = 0; i < total; i++) _shapes[i] = NULL;\r\n\r\n\r\n\r\n\tNxGroupsMask mask;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask.bits0 = groupsMask->bits0;\r\n\t\tmask.bits1 = groupsMask->bits1;\r\n\t\tmask.bits2 = groupsMask->bits2;\r\n\t\tmask.bits3 = groupsMask->bits3;\r\n\t}else{\r\n\r\n\t\tmask.bits0 = 0;\r\n\t\tmask.bits1 = 0;\r\n\t\tmask.bits2 = 0;\r\n\t\tmask.bits3 = 0;\r\n\r\n\t}\r\n\tresult = getScene()->overlapOBBShapes(box,(NxShapesType)shapeType,total,_shapes,NULL,activeGroups,&mask,accurateCollision);\r\n\r\n\tif (_shapes && shapes )\r\n\t{\r\n\t\tfor (int i = 0 ; i < result ; i++)\r\n\t\t{\r\n\t\t\tNxShape *s = _shapes[i];\r\n\t\t\tif (s)\r\n\t\t\t{\r\n\t\t\t\tconst char* name =s->getName();\r\n\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\tif (obj)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tshapes->AddObject((CKBeObject*)obj);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tint op=2;\r\n\r\n\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pWorld::overlapSphereShapes(const VxSphere& worldSphere,CK3dEntity*shapeReference,pShapesType shapeType,CKGroup*shapes,int activeGroups/* =0xffffffff */, const pGroupsMask* groupsMask/* =NULL */, bool accurateCollision/* =false */)\r\n{\r\n\r\n\tint result=0;\r\n\r\n\tNxSphere sphere;\r\n\t\r\n\tif (shapeReference)\r\n\t{\r\n\t\t\r\n\t\t\tNxShape *shape = getShapeByEntityID(shapeReference->GetID());\r\n\t\t\tif (shape)\r\n\t\t\t{\r\n\t\t\t\t//shape->checkOverlapAABB()\r\n\r\n\t\t\t\tNxSphereShape *sphereShape = static_cast(shape->isSphere());\r\n\t\t\t\tif (sphereShape)\r\n\t\t\t\t{\r\n\t\t\t\t\tsphere.radius = sphereShape->getRadius() + worldSphere.Radius();\r\n\r\n\t\t\t\t\t//ori : \r\n\t\t\t\t\tVxVector ori = worldSphere.Center();\r\n\t\t\t\t\tVxVector oriOut = ori;\r\n\t\t\t\t\tif (shapeReference)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tshapeReference->Transform(&oriOut,&ori);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tsphere.center = getFrom(oriOut);\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t}else{\r\n\r\n\t\tsphere.center = getFrom(worldSphere.Center());\r\n\t\tsphere.radius = worldSphere.Radius();\r\n\r\n\t}\r\n\r\n\tint total = 0;\r\n\tif (shapeType & ST_Dynamic )\r\n\t{\r\n\t\ttotal+=getScene()->getNbDynamicShapes();\r\n\t}\r\n\t\r\n\tif (shapeType & ST_Static)\r\n\t{\r\n\t\ttotal+=getScene()->getNbStaticShapes();\r\n\t}\r\n\r\n\tNxShape** _shapes = (NxShape**)NxAlloca(total*sizeof(NxShape*));\r\n\tfor (NxU32 i = 0; i < total; i++) _shapes[i] = NULL;\r\n\r\n\r\n\r\n\tNxGroupsMask mask;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask.bits0 = groupsMask->bits0;\r\n\t\tmask.bits1 = groupsMask->bits1;\r\n\t\tmask.bits2 = groupsMask->bits2;\r\n\t\tmask.bits3 = groupsMask->bits3;\r\n\t}else{\r\n\r\n\t\tmask.bits0 = 0;\r\n\t\tmask.bits1 = 0;\r\n\t\tmask.bits2 = 0;\r\n\t\tmask.bits3 = 0;\r\n\r\n\t}\r\n\t\r\n\r\n\r\n\r\n\tresult = getScene()->overlapSphereShapes(sphere,(NxShapesType)shapeType,total,_shapes,NULL,activeGroups,&mask,accurateCollision);\r\n\r\n\tif (_shapes && shapes )\r\n\t{\r\n\t\tfor (int i = 0 ; i < result ; i++)\r\n\t\t{\r\n\t\t\tNxShape *s = _shapes[i];\r\n\t\t\tif (s)\r\n\t\t\t{\r\n\t\t\t\tconst char* name =s->getName();\r\n\t\t\t\tpSubMeshInfo *sInfo = static_cast(s->userData);\r\n\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\tif (obj)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tshapes->AddObject((CKBeObject*)obj);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tint op=2;\r\n\r\n\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pWorld::raycastAllShapes(const VxRay& worldRay, pShapesType shapesType, int groups, float maxDist, pRaycastBit hintFlags, const pGroupsMask* groupsMask)\r\n{\r\n\r\n\tint result = 0;\r\n\r\n\tNxRay rayx;\r\n\trayx.dir = getFrom(worldRay.m_Direction);\r\n\trayx.orig = getFrom(worldRay.m_Origin);\r\n\r\n\tpRayCastReport &report = *getRaycastReport();\r\n\r\n\tNxGroupsMask *mask = NULL;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask = new NxGroupsMask();\r\n\t\tmask->bits0 = groupsMask->bits0;\r\n\t\tmask->bits1 = groupsMask->bits1;\r\n\t\tmask->bits2 = groupsMask->bits2;\r\n\t\tmask->bits3 = groupsMask->bits3;\r\n\r\n\t}\r\n\t\r\n\tresult = getScene()->raycastAllShapes(rayx,report,(NxShapesType)shapesType,groups,maxDist,hintFlags,mask);\r\n\treturn result;\r\n\r\n\r\n}\r\nbool pWorld::raycastAnyBounds(const VxRay& worldRay, pShapesType shapesType, pGroupsMask *groupsMask/* =NULL */,int groups/* =0xffffffff */, float maxDist/* =NX_MAX_F32 */)\r\n{\r\n\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tNxRay _worldRay;\r\n\t_worldRay.dir = getFrom(worldRay.m_Direction);\r\n\t_worldRay.orig = getFrom(worldRay.m_Origin);\r\n\t\r\n\tNxShapesType _shapesType = (NxShapesType)shapesType;\r\n\t\r\n\tNxReal _maxDist=maxDist;\r\n\t\r\n\tNxGroupsMask *mask = NULL;\r\n\tif (groupsMask)\r\n\t{\r\n\t\tmask = new NxGroupsMask();\r\n\t\tmask->bits0 = groupsMask->bits0;\r\n\t\tmask->bits1 = groupsMask->bits1;\r\n\t\tmask->bits2 = groupsMask->bits2;\r\n\t\tmask->bits3 = groupsMask->bits3;\r\n\r\n\t}\r\n\tbool result = getScene()->raycastAnyBounds(_worldRay,_shapesType,groups,_maxDist,mask);\r\n\treturn result;\r\n\r\n}\r\n\r\nvoid pWorld::cIgnorePair(CK3dEntity *_a, CK3dEntity *_b, int ignore)\r\n{\r\n\r\n\tpRigidBody *a = GetPMan()->getBody(_a);\r\n\tpRigidBody *b = GetPMan()->getBody(_b);\r\n\tif (a&&b && a->getActor() && b->getActor() )\r\n\t{\r\n\t\tif (getScene())\r\n\t\t{\r\n\t\t\tgetScene()->setActorPairFlags(*a->getActor(),*b->getActor(),ignore ? NX_IGNORE_PAIR : NX_NOTIFY_ALL );\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pWorld::cSetGroupCollisionFlag(int g1 , int g2,int enabled)\r\n{\r\n\r\n\tif (getScene())\r\n\t{\r\n\t\tif (g1 >=0 && g1 <= 31 && g2 >=0 && g2 <= 31)\r\n\t\t{\r\n\t\t\tif (enabled==0 || enabled ==1)\r\n\t\t\t{\r\n\t\t\t\tgetScene()->setGroupCollisionFlag(g1,g2,enabled);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid pTriggerReport::onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status)\r\n{\r\n\r\n\tNxActor *triggerActor = &triggerShape.getActor();\r\n\tNxActor *otherActor = &otherShape.getActor();\r\n\tpRigidBody *triggerBody = NULL;\r\n\tpRigidBody *otherBody = NULL;\r\n\r\n\tif (triggerActor)\r\n\t{\r\n\t\ttriggerBody = static_cast(triggerActor->userData);\r\n\t\t//triggerBody->getTriggers().Clear();\r\n\t}\r\n\r\n\tif (otherActor)\r\n\t{\r\n\t\totherBody = static_cast(otherActor->userData);\r\n\t\t//otherBody->getTriggers().Clear();\r\n\t}\r\n\t\r\n\r\n\tpTriggerEntry entry;\r\n\tentry.shapeA = &triggerShape;\r\n\tentry.shapeB = &otherShape;\r\n\tentry.triggerEvent = status;\r\n\r\n\tentry.triggerBodyB = triggerBody;\r\n\tentry.otherBodyB = otherBody;\r\n\r\n\r\n\tentry.triggerBody = triggerBody->GetVT3DObject();\r\n\tpSubMeshInfo *sInfo = (pSubMeshInfo*)otherShape.userData;\r\n\tif (sInfo)\r\n\t{\r\n\t\tentry.otherObject = (CK3dEntity*)GetPMan()->GetContext()->GetObject(sInfo->entID);\r\n\t}\r\n\r\n\tpSubMeshInfo *sInfoOri = (pSubMeshInfo*)triggerShape.userData;\r\n\tif (sInfo)\r\n\t{\r\n\t\tentry.triggerShapeEnt = (CK3dEntity*)GetPMan()->GetContext()->GetObject(sInfoOri->entID);\r\n\t}\r\n\r\n\tif (triggerBody)\r\n\t{\r\n\t\t//triggerBody->getTriggers().PushBack(entry);\r\n triggerBody->onTrigger(&entry);\r\n\t\tGetPMan()->getTriggers().PushBack(entry);\r\n\t}\r\n}\r\n\r\n\r\nvoid pWorld::initUserReports()\r\n{\r\n\t\r\n\tcontactReport = new pContactReport();\r\n\tcontactReport->setWorld(this);\r\n\r\n\ttriggerReport = new pTriggerReport();\r\n\ttriggerReport->setWorld(this);\r\n\r\n\traycastReport = new pRayCastReport();\r\n\traycastReport->setWorld(this);\r\n\r\n\tcontactModify = new pContactModify();\r\n\tcontactModify->setWorld(this);\r\n\r\n\r\n\t//getScene()->raycastAllShapes()\r\n}\r\nbool pRayCastReport::onHit(const NxRaycastHit& hit)\r\n{\r\n\r\n\tCKBehavior *beh =(CKBehavior*)GetPMan()->m_Context->GetObject(mCurrentBehavior);\r\n\tif ( beh )\r\n\t{\r\n\t\tpRayCastHits *carray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&carray);\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\t//carray->clear();\r\n\t\t}else\r\n\t\t{\r\n\t\t\tcarray = new pRayCastHits();\r\n\t\t}\r\n\r\n\t\t//carray->push_back(const_cast(&hit));\r\n\r\n\t\tNxRaycastHit *_hit = new NxRaycastHit();\r\n\r\n\t\t_hit->distance = hit.distance;\r\n\t\t_hit->faceID = hit.faceID;\r\n\t\t_hit->flags = hit.flags;\r\n\t\t_hit->internalFaceID = hit.internalFaceID;\r\n\t\t_hit->materialIndex = hit.materialIndex;\r\n\t\t_hit->shape = hit.shape;\r\n\t\t_hit->u = hit.u;\r\n\t\t_hit->v = hit.v;\r\n\t\t_hit->worldImpact = hit.worldImpact;\r\n\t\t_hit->worldNormal = hit.worldNormal;\r\n\t\t\r\n\t\tconst char *name = hit.shape->getName();\r\n\t\t\r\n\t\tcarray->push_back(_hit);\r\n\t\tbeh->SetLocalParameterValue(0,&carray);\r\n\r\n\r\n\t}\r\n\treturn true;\r\n}\r\n\r\nvoid pWorld::setFilterOps(pFilterOp op0,pFilterOp op1, pFilterOp op2)\r\n{\r\n\tgetScene()->setFilterOps((NxFilterOp)op0,(NxFilterOp)op1,(NxFilterOp)op2);\r\n}\r\n\r\nvoid pWorld::setFilterBool(bool flag){\tgetScene()->setFilterBool(flag);}\r\nvoid pWorld::setFilterConstant0(const pGroupsMask& mask)\r\n{\r\n\tNxGroupsMask _mask;\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\t\r\n\tgetScene()->setFilterConstant0(_mask);\r\n}\r\n\r\nvoid pWorld::setFilterConstant1(const pGroupsMask& mask)\r\n{\r\n\tNxGroupsMask _mask;\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\r\n\tgetScene()->setFilterConstant1(_mask);\r\n}\r\n\r\nbool pWorld::getFilterBool()const{\treturn getScene()->getFilterBool();}\r\npGroupsMask pWorld::getFilterConstant0()const\r\n{\r\n\tNxGroupsMask mask = getScene()->getFilterConstant0();\r\n\tpGroupsMask _mask;\r\n\t\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\r\n\treturn _mask;\r\n\r\n}\r\n\r\npGroupsMask pWorld::getFilterConstant1()const\r\n{\r\n\tNxGroupsMask mask = getScene()->getFilterConstant1();\r\n\tpGroupsMask _mask;\r\n\t_mask.bits0=mask.bits0;\r\n\t_mask.bits1=mask.bits1;\r\n\t_mask.bits2=mask.bits2;\r\n\t_mask.bits3=mask.bits3;\r\n\treturn _mask;\r\n}\r\n\r\n\r\n\r\n// --------------------------------------------------------------------------\r\n//\t\t\t\t\twww.UnitedBusinessTechnologies.com\r\n//\t\t\t Copyright (c) 1998 - 2002 All Rights Reserved.\r\n//\r\n// Source in this file is released to the public under the following license:\r\n// --------------------------------------------------------------------------\r\n// This toolkit may be used free of charge for any purpose including corporate\r\n// and academic use. For profit, and Non-Profit uses are permitted.\r\n//\r\n// This source code and any work derived from this source code must retain \r\n// this copyright at the top of each source file.\r\n// \r\n// UBT welcomes any suggestions, improvements or new platform ports.\r\n// email to: \r\n// --------------------------------------------------------------------------\r\n#include \"pch.h\"\r\n#include \"GString.h\"\r\n#include \"GException.h\"\r\n\r\n#include // for: memcpy(), strlen(), strcmp(), memmove(), strchr(), \r\n\t\t\t\t\t// strstr(), strncmp()\r\n#include // for: isdigit()\r\n#include // for: atof(), atoi(), atol(), abs(), and strtol()\r\n#include // for: sprintf(), vsprintf(), FILE, fopen(), fwrite(), \r\n\t\t\t\t\t// fclose(), fseek(), fread()\r\n#include // for: va_start(), va_end */\r\n\r\n\r\n// Global default format specifiers that affect all GStrings\r\nGString\tGString::g_FloatFmt(\"%.6g\");\r\nGString\tGString::g_DoubleFmt(\"%.6g\");\t\t\r\nGString\tGString::g_LongDoubleFmt(\"%.6Lg\");\r\n\r\n\r\n\r\n#ifndef _WIN32\r\n\t#ifndef __int64\r\n\t\t#define\t__int64 long long\r\n\t#endif\r\n#endif\r\n\r\n\r\n\r\nstatic void x64toa ( \r\n unsigned __int64 val,\r\n char *buf,\r\n unsigned radix,\r\n int is_neg\r\n )\r\n{\r\n char *p; /* pointer to traverse string */\r\n char *firstdig; /* pointer to first digit */\r\n char temp; /* temp char */\r\n unsigned digval; /* value of digit */\r\n\r\n p = buf;\r\n\r\n if ( is_neg )\r\n {\r\n *p++ = '-'; /* negative, so output '-' and negate */\r\n val = (unsigned __int64)(-(__int64)val);\r\n }\r\n\r\n firstdig = p; /* save pointer to first digit */\r\n\r\n do {\r\n digval = (unsigned) (val % radix);\r\n val /= radix; /* get next digit */\r\n\r\n /* convert to ascii and store */\r\n if (digval > 9)\r\n *p++ = (char) (digval - 10 + 'a'); /* a letter */\r\n else\r\n *p++ = (char) (digval + '0'); /* a digit */\r\n } while (val > 0);\r\n\r\n /* We now have the digit of the number in the buffer, but in reverse\r\n order. Thus we reverse them now. */\r\n\r\n *p-- = '\\0'; /* terminate string; p points to last digit */\r\n\r\n do {\r\n temp = *p;\r\n *p = *firstdig;\r\n *firstdig = temp; /* swap *p and *firstdig */\r\n --p;\r\n ++firstdig; /* advance to next two digits */\r\n } while (firstdig < p); /* repeat until halfway */\r\n}\r\n\r\n\r\n// long long to ascii\r\nchar * lltoa ( __int64 val,char *buf,int radix)\r\n{\r\n x64toa((unsigned __int64)val, buf, radix, (radix == 10 && val < 0));\r\n return buf;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n#define CommonConstruct(nInitialSize)\t\t\t\t\\\r\n\t_str = 0;\t\t\t\t\t\t\t\t\t\t\\\r\n\t_len = 0;\t\t\t\t\t\t\t\t\t\t\\\r\n\t_strIsOnHeap = 0;\t\t\t\t\t\t\t\t\\\r\n\t_max = nInitialSize;\t\t\t\t\t\t\t\\\r\n\tif (nInitialSize == 256)\t\t\t\t\t\t\\\r\n\t\t_str = _initialbuf;\t\t\t\t\t\t\t\\\r\n\telse\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\t_initialbuf[0] = 0;\t\t\t\t\t\t\t\\\r\n\t\t_str = new char[nInitialSize];\t\t\t\t\\\r\n\t\t_strIsOnHeap = 1;\t\t\t\t\t\t\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tif (!_str)\t\t\t\t\t\t\t\t\t\t\\\r\n\t\tthrow GenericException(\"String\", 0);\t\t\\\r\n\t_str[_len] = 0;\r\n\r\n\r\nvoid GString::AppendEscapeXMLReserved(const char *Src, int nLen/* = -1*/)\r\n{\r\n\tconst unsigned char *src = (const unsigned char *)Src;\r\n\twhile (*src && (nLen != 0))\r\n\t{\r\n\t\tif (nLen != -1) // -1 means to append until a null in src\r\n\t\t\tnLen--;\r\n\r\n\t\tswitch (*src)\r\n\t\t{\r\n\t\t\tcase '<' :\r\n\t\t\tcase '>' :\r\n\t\t\tcase '&' :\r\n\t\t\tcase '\"' :\r\n\t\t\tcase '\\'' :\r\n\t\t\t\tthis->write(\"&#\",2);\r\n\t\t\t\t(*this) += (unsigned int)(unsigned char)*src;\r\n\t\t\t\t(*this) += ';';\r\n\t\t\t\tbreak;\r\n\t\t\tdefault :\r\n\t\t\t\t// IE can't deal with special chars(йвезкли....) so escape them too\r\n\t\t\t\tif ((*src > 127) || (*src < 32))\r\n\t\t\t\t{\r\n\t\t\t\t\tthis->write(\"&#\",2);\r\n\t\t\t\t\t(*this) += (unsigned int)(unsigned char)*src;\r\n\t\t\t\t\t(*this) += ';';\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t}\r\n\t\t\t\telse // most cases, append normal char to this GString\r\n\t\t\t\t{\r\n\t\t\t\t\t// inline operator += code\r\n\t\t\t\t\tif (_len >= _max)\r\n\t\t\t\t\t\tresize();\r\n\t\t\t\t\t_str[_len] = *src;\r\n\t\t\t\t\t_len++;\r\n\r\n\t\t\t\t\tif (_len >= _max)\r\n\t\t\t\t\t\tresize();\r\n\t\t\t\t\t_str[_len] = 0;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\tsrc++;\r\n\t}\r\n}\r\n\r\nvoid GString::AppendXMLTabs( int nTabs )\r\n{\r\n\tstatic const char* TABS =\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\"\t\r\n\t\"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\";\r\n\tconst int MAX_TABS = 80;\r\n\r\n\r\n\tif (_len)\r\n#ifdef _WIN32\r\n\t\t(*this) << \"\\r\\n\";\r\n#else\r\n\t\t(*this) << \"\\n\";\r\n#endif\r\n\r\n\r\n\twrite( TABS, (nTabs > MAX_TABS) ? MAX_TABS : nTabs );\r\n}\r\n\r\n\r\nvoid GString::EscapeXMLReserved()\r\n{\r\n\tGString str_xml( Length() + 1024 );\r\n\tconst unsigned char *src = (const unsigned char *)(const char *)(*this);\r\n\r\n\twhile (*src)\r\n\t{\r\n\t\tswitch (*src)\r\n\t\t{\r\n\t\t\tcase '<' :\r\n\t\t\tcase '>' :\r\n\t\t\tcase '&' :\r\n\t\t\tcase '\"' :\r\n\t\t\tcase '\\'' :\r\n\t\t\t\tstr_xml << \"&#\" << (unsigned int)*src << ';';\t\t\t\t\r\n\t\t\t\tbreak;\r\n\t\t\tdefault :\r\n\t\t\t\tif ((*src > 127) || (*src < 32))\r\n\t\t\t\t{\r\n\t\t\t\t\tstr_xml << \"&#\" << (unsigned int)((unsigned char)*src) << ';';\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tstr_xml << *src;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\tsrc++;\r\n\t}\r\n\r\n\t(*this) = str_xml;\r\n}\r\n\r\n\r\nvoid GString::resize()\r\n{\r\n\t// double the size of the buffer\r\n\t_max <<= 1;\r\n\tchar *nstr = new char[_max];\r\n\t\r\n\t// not enough memory for resize\r\n\tif (!nstr)\r\n\t\tthrow GenericException(\"String\", 0);\r\n\r\n\tnstr[0] = 0;\r\n\t\r\n\tif (_str)\r\n\t{\r\n\t\tmemcpy(nstr, _str, _len);\r\n\t\tif (_strIsOnHeap)\r\n\t\t\tdelete [] _str;\r\n\t}\r\n\r\n\t_str = nstr;\r\n\t_strIsOnHeap = 1;\r\n\t_initialbuf[0] = 0;\r\n}\r\n\r\n// constructs an empty string\r\nGString::GString(long nInitialSize)\r\n{\r\n\tCommonConstruct(nInitialSize);\r\n}\r\n\r\n// constructs a copy of the source string \r\nGString::GString(const GString &src )\r\n{\r\n\tlong l = (src._len > 256) ? src._len + 256 : 256;\r\n\tCommonConstruct( l );\r\n\r\n\t_len = ___min(_max, src._len);\r\n\tmemcpy(_str, src._str, _len);\r\n\t_str[_len] = 0;\r\n}\r\n\r\nGString::GString(const GString &src, int nCnt)\r\n{\r\n\tlong l = (src._len > 256) ? src._len + 256 : 256;\r\n\tCommonConstruct(l);\r\n\r\n\t_len = ___min(_max, ___min(src._len, nCnt));\r\n\tmemcpy(_str, src._str, _len);\r\n\t_str[_len] = 0;\r\n}\r\n\r\n// constructs a copy of the character string\r\nGString::GString(const char *src)\r\n{\r\n\tlong srcLen = (src) ? strlen(src) : 256;\r\n\tlong nInitialSize = (srcLen > 256) ? srcLen + 256 : 256;\r\n\r\n\tCommonConstruct(nInitialSize);\r\n\r\n\twhile (src && *src)\r\n\t{\r\n\t\t_str[_len] = *src;\r\n\t\t_len++;\r\n\t\tsrc++;\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t}\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n}\r\n\r\n\r\n\r\nGString::GString(const char *src, int nCnt)\r\n{\r\n\tlong nInitialSize = (nCnt > 256) ? nCnt + 256 : 256;\r\n\r\n\tCommonConstruct(nInitialSize);\r\n\r\n\t_len = 0;\r\n\tif (src)\r\n\t{\r\n\t\tint i;\r\n\t\t_len = ___min(_max - 1, nCnt);\r\n\t\tfor (i = 0; i < _len && src[i]; i++)\r\n\t\t\t_str[i] = src[i];\r\n\t\t_len = i;\r\n\t}\r\n\r\n\t_str[_len] = 0;\r\n}\r\n\r\n// constructs a string with ch repeated nCnt times\r\nGString::GString(char ch, short nCnt)\r\n{\r\n\tlong nInitialSize = (nCnt > 256) ? nCnt + 256 : 256;\r\n\r\n\tCommonConstruct(nInitialSize);\r\n\r\n\t_len = ___min(_max - 1, nCnt);\r\n\tint i;\r\n\tfor (i = 0; i < _len; i++)\r\n\t\t_str[i] = ch;\r\n\r\n\t_len = i;\r\n\t_str[_len] = 0;\r\n}\r\n\r\nGString::~GString()\r\n{\r\n\tif (_strIsOnHeap)\r\n\t\tdelete [] _str;\r\n}\r\n/*\r\n.h declaration: GString & operator=(const strstreambuf &);\r\n\r\nGString & GString::operator=(const strstreambuf &buf)\r\n{\r\n\t_max = ((strstreambuf &)buf).seekoff(0, ios::cur, ios::in | ios::out) + 1;\r\n\tchar *nstr = new char[_max];\r\n\t\r\n\t// not enough memory for resize\r\n\tif (!nstr)\r\n\t\tthrow GenericException(\"String\", 0);\r\n\r\n\tnstr[0] = 0;\r\n\t\r\n\tif (_str)\r\n\t{\r\n\t\tif (_strIsOnHeap)\r\n\t\t\tdelete [] _str;\r\n\t}\r\n\r\n\t_str = nstr;\r\n\t_strIsOnHeap = 1;\r\n\t_initialbuf[0] = 0;\r\n\r\n\t_len = _max - 1;\r\n\tstrncpy(_str, ((strstreambuf &)buf).str(), _len);\r\n\t_str[_len] = 0;\r\n\t((strstreambuf &)buf).freeze(0);\r\n\r\n\treturn *this;\r\n}*/\r\n\r\nGString & GString::operator=(char _p)\r\n{\r\n\tif (!_max)\r\n\t{\r\n\t\t_max = 2;\r\n\t\tresize();\r\n\t}\r\n\r\n\t_len = 0;\r\n\t_str[_len] = _p;\r\n\t_len++;\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(__int64 _p)\r\n{\r\n\tchar szBuffer[256];\r\n//\tsprintf(szBuffer, \"%I64d\", _p);\r\n\tlltoa ( _p,szBuffer,10);\r\n\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(const char * _p)\r\n{\r\n\t_len = 0;\r\n\twhile (_p && *_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = *_p;\r\n\t\t_p++;\r\n\t\t_len++;\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(const signed char * _p)\r\n{\r\n\t*this = (const char *)_p;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(unsigned char _p)\r\n{\r\n\t*this = (char)_p;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(signed char _p)\r\n{\r\n\t*this = (char)_p;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(short _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%hi\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(unsigned short _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%hu\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(int _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%li\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(unsigned int _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%lu\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(long _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%li\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(unsigned long _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%lu\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(float _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, g_FloatFmt._str, _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\n\r\n\r\nGString & GString::operator=(double _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, \"%.6g\", _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(long double _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, \"%.6Lg\", _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\tfor (_len = 0; _len < nLen; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator=(const GString & _p)\r\n{\r\n\tfor (_len = 0; _len < _p._len; _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p._str[_len];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\n\r\nGString & GString::operator+=(__int64 _p)\r\n{\r\n\tchar szBuffer[25];\r\n//\tsprintf(szBuffer, \"%I64d\", _p);\r\n\tlltoa ( _p,szBuffer,10);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\n\r\n\r\nGString & GString::operator+=(const signed char * _p)\r\n{\r\n\twhile (_p && *_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = *_p;\r\n\t\t_p++;\r\n\t\t_len++;\r\n\t}\r\n\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(const char * _p)\r\n{\r\n\twhile (_p && *_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = *_p;\r\n\t\t_p++;\r\n\t\t_len++;\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\n\r\nvoid GString::write(const char *p,int nSize)\r\n{\r\n\twhile (_len + nSize + 1 >= _max)\r\n\t\tresize();\r\n\tmemcpy(&_str[_len],p,nSize);\r\n\t_len += nSize;\r\n\t_str[_len] = 0;\r\n}\r\n\r\nGString & GString::operator+=(char _p)\r\n{\r\n\tif (_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p;\r\n\t\t_len++;\r\n\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = 0;\r\n\t}\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(unsigned char _p)\r\n{\r\n\tif (_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p;\r\n\t\t_len++;\r\n\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = 0;\r\n\t}\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(signed char _p)\r\n{\r\n\tif (_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p;\r\n\t\t_len++;\r\n\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = 0;\r\n\t}\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(short _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%hi\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(unsigned short _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%hu\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(int _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%li\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(unsigned int _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%lu\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(long _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%ld\", _p);\r\n\r\n\tint nLen = strlen(szBuffer);\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(unsigned long _p)\r\n{\r\n\tchar szBuffer[25];\r\n\tsprintf(szBuffer, \"%lu\", _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(float _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, g_FloatFmt._str, _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(double _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, \"%.6g\", _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(long double _p)\r\n{\r\n\tchar szBuffer[50];\r\n\tsprintf(szBuffer, \"%.6Lg\", _p);\r\n\tint nLen = strlen(szBuffer);\r\n\r\n\r\n\tfor (int i = 0; i < nLen; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = szBuffer[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator+=(const GString & _p)\r\n{\r\n\twhile (_len + _p._len + 1 >= _max)\r\n\t\tresize();\r\n\tmemcpy(&_str[_len],_p._str,_p._len);\r\n\t_len += _p._len;\r\n\t_str[_len] = 0;\r\n\treturn *this;\r\n/*\r\n\tfor (int i = 0; i < _p._len; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p._str[i];\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n*/\r\n}\r\n\r\nGString & GString::operator<<(__int64 _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(const char * _p)\r\n{\r\n\twhile (_p && *_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = *_p;\r\n\t\t_p++;\r\n\t\t_len++;\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator<<(const signed char * _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(char _p)\r\n{\r\n\tif (_p)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = _p;\r\n\t\t_len++;\r\n\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = 0;\r\n\t}\r\n\treturn *this;\r\n}\r\n\r\nGString & GString::operator<<(unsigned char _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(signed char _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(short _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(unsigned short _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(int _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(unsigned int _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(long _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(unsigned long _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(float _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(double _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\nGString & GString::operator<<(long double _p)\r\n{\r\n\treturn *this += _p;\r\n}\r\n\r\n\r\nGString & GString::operator<<(const GString & _p)\r\n{\r\n//\treturn *this += _p;\r\n\twhile (_len + _p._len + 1 >= _max)\r\n\t\tresize();\r\n\tmemcpy(&_str[_len],_p._str,_p._len);\r\n\t_len += _p._len;\r\n\t_str[_len] = 0;\r\n\treturn *this;\r\n}\r\n\r\nGString operator+(GString &_p1, GString &_p2)\r\n{\r\n\tGString strRet(_p1._len + _p2._len + 1);\r\n\tint i;\r\n\tfor (i = 0; i < _p1._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\r\n\tfor (i = 0; i < _p2._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(GString &_p1, const char *_p2)\r\n{\r\n\tGString strRet;\r\n\r\n\tfor (int i = 0; i < _p1._len; strRet._len++, i++)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\t}\r\n\r\n\twhile (_p2 && *_p2)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = *_p2;\r\n\t\t_p2++;\r\n\t\tstrRet._len++;\r\n\t}\r\n\r\n\tif (strRet._len >= strRet._max)\r\n\t\tstrRet.resize();\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(const char *_p1, GString &_p2)\r\n{\r\n\tGString strRet;\r\n\r\n\twhile (_p1 && *_p1)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = *_p1;\r\n\t\t_p1++;\r\n\t\tstrRet._len++;\r\n\t}\r\n\r\n\tfor (int i = 0; i < _p2._len; strRet._len++, i++)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\t}\r\n\r\n\tif (strRet._len >= strRet._max)\r\n\t\tstrRet.resize();\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(GString &_p1, const signed char *_p2)\r\n{\r\n\tGString strRet;\r\n\r\n\tfor (int i = 0; i < _p1._len; strRet._len++, i++)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\t}\r\n\r\n\twhile (_p2 && *_p2)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = *_p2;\r\n\t\t_p2++;\r\n\t\tstrRet._len++;\r\n\t}\r\n\r\n\tif (strRet._len >= strRet._max)\r\n\t\tstrRet.resize();\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(const signed char *_p1, GString &_p2)\r\n{\r\n\tGString strRet;\r\n\r\n\twhile (_p1 && *_p1)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = *_p1;\r\n\t\t_p1++;\r\n\t\tstrRet._len++;\r\n\t}\r\n\r\n\tfor (int i = 0; i < _p2._len; strRet._len++, i++)\r\n\t{\r\n\t\tif (strRet._len >= strRet._max)\r\n\t\t\tstrRet.resize();\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\t}\r\n\r\n\tif (strRet._len >= strRet._max)\r\n\t\tstrRet.resize();\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(GString &_p1, char _p2)\r\n{\r\n\tGString strRet(_p1._len + 2);\r\n\r\n\tfor (int i = 0; i < _p1._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\r\n\tstrRet._str[strRet._len] = _p2;\r\n\tstrRet._len++;\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(char _p1, GString &_p2)\r\n{\r\n\tGString strRet(_p2._len + 2);\r\n\r\n\tstrRet._str[strRet._len] = _p1;\r\n\tstrRet._len++;\r\n\r\n\tfor (int i = 0; i < _p2._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(GString &_p1, unsigned char _p2)\r\n{\r\n\tGString strRet(_p1._len + 2);\r\n\r\n\tfor (int i = 0; i < _p1._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\r\n\tstrRet._str[strRet._len] = _p2;\r\n\tstrRet._len++;\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(unsigned char _p1, GString &_p2)\r\n{\r\n\tGString strRet(_p2._len + 2);\r\n\r\n\tstrRet._str[strRet._len] = _p1;\r\n\tstrRet._len++;\r\n\r\n\tfor (int i = 0; i < _p2._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(GString &_p1, signed char _p2)\r\n{\r\n\tGString strRet(_p1._len + 2);\r\n\r\n\tfor (int i = 0; i < _p1._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p1._str[i];\r\n\r\n\tstrRet._str[strRet._len] = _p2;\r\n\tstrRet._len++;\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\nGString operator+(signed char _p1, GString &_p2)\r\n{\r\n\tGString strRet(_p2._len + 2);\r\n\r\n\tstrRet._str[strRet._len] = _p1;\r\n\tstrRet._len++;\r\n\r\n\tfor (int i = 0; i < _p2._len; strRet._len++, i++)\r\n\t\tstrRet._str[strRet._len] = _p2._str[i];\r\n\r\n\tstrRet._str[strRet._len] = 0;\r\n\r\n\treturn strRet;\r\n}\r\n\r\n//ostream& operator<<(ostream &os, GString &s)\r\n//{\r\n//\tos << s._str;\r\n//\treturn os;\r\n//}\r\n\r\nint GString::operator > (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) > 0;\r\n}\r\n\r\nint GString::operator >= (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) >= 0;\r\n}\r\n\r\nint GString::operator == (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) == 0;\r\n}\r\n\r\nint GString::operator < (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) < 0;\r\n}\r\n\r\nint GString::operator <= (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) <= 0;\r\n}\r\n\r\nint GString::operator != (const GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str) != 0;\r\n}\r\n\r\nint GString::operator > (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) > 0;\r\n}\r\n\r\nint GString::operator >= (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) >= 0;\r\n}\r\n\r\nint GString::operator == (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) == 0;\r\n}\r\n\r\nint GString::operator < (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) < 0;\r\n}\r\n\r\nint GString::operator <= (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) <= 0;\r\n}\r\n\r\nint GString::operator != (const char *s) const\r\n{\r\n\treturn strcmp(_str, s) != 0;\r\n}\r\n\r\nint GString::Compare(const char *s) const\r\n{\r\n\treturn strcmp(_str, s);\r\n}\r\n\r\nint GString::Compare(GString &s) const\r\n{\r\n\treturn strcmp(_str, s._str);\r\n}\r\n\r\nint GString::CompareNoCase(const char *s) const\r\n{\r\n\tint i = 0; // start at the beginning\r\n\r\n\t// loop through the two strings comparing case insensitively\r\n\twhile ((toupper(_str[i]) == toupper(s[i])) && // the two strings are equal\r\n\t\t (_str[i] != '\\0')) // the first hasn't ended\r\n\t\ti++;\r\n\r\n\t// the difference between the characters that ended it is\r\n\t// indicative of the direction of the comparison. if this\r\n\t// is negative, the first was before the second. if it is\r\n\t// positive, the first was after the second. if it is zero,\r\n\t// the two are equal (and the != '\\0' condition stopped the\r\n\t// loop such that the two were of equal length).\r\n\treturn (short)toupper(_str[i]) - (short)toupper(s[i]);\r\n}\r\n\r\nint GString::CompareNoCase(const GString &s) const\r\n{\r\n\tint i = 0; // start at the beginning\r\n\r\n\t// loop through the two strings comparing case insensitively\r\n\twhile ((toupper(_str[i]) == toupper(s._str[i])) && // the two strings are equal\r\n\t\t (_str[i] != '\\0'))\t\t\t\t\t\t\t// the first hasn't ended\r\n\t\ti++;\r\n\r\n\t// the difference between the characters that ended it is\r\n\t// indicative of the direction of the comparison. if this\r\n\t// is negative, the first was before the second. if it is\r\n\t// positive, the first was after the second. if it is zero,\r\n\t// the two are equal (and the != '\\0' condition stopped the\r\n\t// loop such that the two were of equal length).\r\n\treturn (short)toupper(_str[i]) - (short)toupper(s._str[i]);\r\n}\r\n\r\nchar& GString::operator[](int nIdx)\r\n{\r\n\t// check for subscript out of range\r\n\tif (nIdx > _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\treturn _str[nIdx];\r\n}\r\n\r\nchar GString::GetAt(int nIdx) const\r\n{\r\n\t// check for subscript out of range\r\n\tif (nIdx > _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\treturn _str[nIdx];\r\n}\r\n\r\nvoid GString::SetAt(int nIdx, char ch)\r\n{\r\n\t// check for subscript out of range\r\n\tif (nIdx >= _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\t_str[nIdx] = ch;\r\n}\r\n\r\nvoid GString::PadLeft(int nCnt, char ch /* = ' ' */)\r\n{\r\n\tif (nCnt > _len)\r\n\t\tPrepend(nCnt - _len, ch);\r\n}\r\n\r\nvoid GString::Prepend(int nCnt, char ch /* = ' ' */)\r\n{\r\n\twhile (nCnt + _len + 1 >= _max)\r\n\t\tresize();\r\n\r\n\tmemmove(&_str[nCnt], _str, _len);\r\n\t_len += nCnt;\r\n\r\n\tfor (int i = 0; i < nCnt; i++)\r\n\t\t_str[i] = ch;\r\n\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::TrimLeft(char ch /* = ' ' */, short nCnt /* = -1 */)\r\n{\r\n\tint i = 0;\r\n\twhile ((i < _len) && (_str[i] == ch) && (nCnt != 0))\r\n\t{\r\n\t\ti++;\r\n\t\tnCnt--;\r\n\t}\r\n\r\n\tif (i != 0)\r\n\t{\r\n\t\t_len -= i;\r\n\t\tmemmove(_str, &_str[i], _len + 1);\r\n\t}\r\n}\r\n\r\n#define isWS(ch) ( ch == 0x20 || ch == 0x09 || ch == 0x0D || ch == 0x0A)\r\nvoid GString::TrimLeftWS()\r\n{\r\n\tint i = 0;\r\n\twhile ((i < _len) && (isWS(_str[i])))\r\n\t\ti++;\r\n\r\n\tif (i != 0)\r\n\t{\r\n\t\t_len -= i;\r\n\t\tmemmove(_str, &_str[i], _len + 1);\r\n\t}\r\n}\r\n\r\nvoid GString::PadRight(int nCnt, char ch /* = ' ' */)\r\n{\r\n\tif (nCnt > _len)\r\n\t\tAppend(nCnt - _len, ch);\r\n}\r\n\r\nvoid GString::Append(int nCnt, char ch /* = ' ' */)\r\n{\r\n\tfor (int i = 0; i < nCnt; i++, _len++)\r\n\t{\r\n\t\tif (_len >= _max)\r\n\t\t\tresize();\r\n\t\t_str[_len] = ch;\r\n\t}\r\n\r\n\tif (_len >= _max)\r\n\t\tresize();\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::TrimRightBytes(short nCnt)\r\n{\r\n\tif (_len >= nCnt)\r\n\t\t_len -= nCnt;\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::TrimRight(char ch /* = ' ' */, short nCnt /* = -1 */)\r\n{\r\n\twhile ((_len) && (_str[_len - 1] == ch) && (nCnt != 0))\r\n\t{\r\n\t\t_len--;\r\n\t\tnCnt--;\r\n\t}\r\n\r\n\t_str[_len] = 0;\r\n}\r\n\r\nGString GString::Left (int nCnt) const\r\n{\r\n\tif (nCnt > _len)\r\n\t\tnCnt = _len;\r\n\r\n\treturn GString(_str, nCnt);\r\n}\r\n\r\nGString GString::Mid (int nFirst) const\r\n{\r\n\tif (nFirst > _len)\r\n\t\tnFirst = _len;\r\n\r\n\treturn GString(&_str[nFirst]);\r\n}\r\n\r\nGString GString::Mid (int nFirst, int nCnt) const\r\n{\r\n\tif (nFirst > _len)\r\n\t\tnFirst = _len;\r\n\r\n\treturn GString(&_str[nFirst], nCnt);\r\n}\r\n\r\nGString GString::Right(int nCnt) const\r\n{\r\n\tif (nCnt > _len)\r\n\t\tnCnt = _len + 1;\r\n\r\n\tint nFirst = _len - nCnt;\r\n\treturn GString(&_str[nFirst]);\r\n}\r\n\r\nvoid GString::TrimRightWS()\r\n{\r\n\twhile ((_len) && (isWS(_str[_len - 1])))\r\n\t\t_len--;\r\n\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::MakeUpper()\r\n{\r\n\tfor (int i = 0; i < _len; i++)\r\n\t\t_str[i] = toupper(_str[i]);\r\n}\r\n\r\nvoid GString::MakeLower()\r\n{\r\n\tfor (int i = 0; i < _len; i++)\r\n\t\t_str[i] = tolower(_str[i]);\r\n}\r\n\r\nvoid GString::MakeReverse()\r\n{\r\n\tfor (int a = 0, b = _len - 1; a < b; a++, b--)\r\n\t{\r\n\t\tchar c = _str[b];\r\n\t\t_str[b] = _str[a];\r\n\t\t_str[a] = c;\r\n\t}\r\n}\r\n\r\nchar * stristr(const char * str1, const char * str2)\r\n{\r\n\tchar *cp = (char *) str1;\r\n\tchar *s1, *s2;\r\n\r\n\tif ( !*str2 )\r\n\t\treturn((char *)str1);\r\n\r\n\twhile (*cp)\r\n\t{\r\n\t\ts1 = cp;\r\n\t\ts2 = (char *) str2;\r\n\r\n\t\twhile ( *s1 && *s2 && !(tolower(*s1)-tolower(*s2)) )\r\n\t\t\ts1++, s2++;\r\n\r\n\t\tif (!*s2)\r\n\t\t\treturn(cp);\r\n\r\n\t\tcp++;\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint GString::FindSubStringCaseInsensitive( const char * lpszSub, int nStart/* = 0*/ ) const\r\n{\r\n\tchar *p = stristr(&_str[nStart], lpszSub);\r\n\tif (p)\r\n\t\treturn p - _str;\r\n\treturn -1;\r\n}\r\n\r\nint GString::Find( char ch ) const\r\n{\r\n\treturn Find(ch, 0);\r\n}\r\n\r\nint GString::Find( const char * lpszSub ) const\r\n{\r\n\treturn Find(lpszSub, 0);\r\n}\r\n\r\nint GString::Find( char ch, int nStart ) const\r\n{\r\n\tif (nStart >= _len)\r\n\t\treturn -1;\r\n\r\n\t// find first single character\r\n\tconst char *lpsz = strchr(_str + nStart, (int)ch);\r\n\r\n\t// return -1 if not found and index otherwise\r\n\treturn (lpsz == NULL) ? -1 : (int)(lpsz - _str);\r\n}\r\n\r\nint GString::Find( const char * lpszSub, int nStart ) const\r\n{\r\n\tif (nStart > _len)\r\n\t\treturn -1;\r\n\r\n\t// find first matching substring\r\n\tconst char *lpsz = strstr(_str + nStart, lpszSub);\r\n\r\n\t// return -1 for not found, distance from beginning otherwise\r\n\treturn (lpsz == NULL) ? -1 : (int)(lpsz - _str);\r\n}\r\n\r\nvoid GString::Insert( int nIndex, char ch )\r\n{\r\n\t// subscript out of range\r\n\tif (nIndex > _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\tif (_len + 2 >= _max)\r\n\t\tresize();\r\n\r\n\t_len++;\r\n\tmemmove(&_str[nIndex + 1], &_str[nIndex], _len - nIndex);\r\n\t_str[nIndex] = ch;\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::Insert( int nIndex, const char * pstr )\r\n{\r\n\tif (!pstr)\r\n\t\treturn;\r\n\r\n\t// subscript out of range\r\n\tif (nIndex > _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\tint nCnt = strlen(pstr);\r\n\twhile (_len + nCnt + 1 >= _max)\r\n\t\tresize();\r\n\r\n\t_len += nCnt;\r\n\tmemmove(&_str[nIndex + nCnt], &_str[nIndex], _len - nIndex);\r\n\r\n\twhile (*pstr)\r\n\t{\r\n\t\t_str[nIndex] = *pstr;\r\n\t\tpstr++;\r\n\t\tnIndex++;\r\n\t}\r\n\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::MergeMask(const char *szSrc, const char *szMask)\r\n{\r\n\tEmpty();\r\n\r\n\tif ((szSrc != 0) && (*szSrc != 0))\r\n\t{\r\n\t\twhile ((*szSrc != 0) || (*szMask != 0))\r\n\t\t{\r\n\t\t\tswitch (*szMask)\r\n\t\t\t{\r\n\t\t\t\t// copy a single character from the \r\n\t\t\t\tcase '_' :\r\n\t\t\t\t\tif (*szSrc)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t*this += *szSrc;\r\n\t\t\t\t\t\tszSrc++;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tszMask++;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t// copy the remaining characters from szSrc\r\n\t\t\t\tcase '*' :\r\n\t\t\t\t\t*this += szSrc;\r\n\t\t\t\t\twhile (*szSrc)\r\n\t\t\t\t\t\tszSrc++;\r\n\t\t\t\t\tszMask++;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t// all other characters are mask chars\r\n\t\t\t\t// with the exception of '\\' which is\r\n\t\t\t\t// used to escape '_', '*' and '\\'\r\n\t\t\t\tdefault :\r\n\t\t\t\t\tif (*szMask != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (*szMask == '\\\\')\r\n\t\t\t\t\t\t\t// skip the escape character\r\n\t\t\t\t\t\t\tszMask++;\r\n\t\t\t\t\t\tif (*szMask != 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t*this += *szMask;\r\n\t\t\t\t\t\t\tszMask++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// throw away the remaining characters in the source string\r\n\t\t\tif (*szMask == 0)\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nbool IsNaN(const char *szN, \r\n\t\t char decimal_separator,\r\n\t\t char grouping_separator,\r\n\t\t char minus_sign)\r\n{\r\n\tbool bRet = false;\r\n\r\n\tbool bDot = false;\r\n\tbool bNeg = false;\r\n\tint i = 0;\r\n\twhile ((*szN) && (!bRet))\r\n\t{\r\n\t\tbRet = !(((*szN >= '0') && (*szN <= '9')) || \r\n\t\t\t\t *szN == grouping_separator || \r\n\t\t\t\t *szN == decimal_separator ||\r\n\t\t\t\t *szN == minus_sign);\r\n\r\n\t\tif (*szN == decimal_separator)\r\n\t\t{\r\n\t\t\tif (bDot)\r\n\t\t\t\tbRet = true; // NaN\r\n\t\t\tbDot = true;\r\n\t\t}\r\n\r\n\t\tif (*szN == minus_sign)\r\n\t\t{\r\n\t\t\tif (((i) && szN[1]) || bNeg)\r\n\t\t\t\tbRet = true; // NaN\r\n\t\t\tbNeg = true;\r\n\t\t}\r\n\r\n\t\tszN++;\r\n\t\ti++;\r\n\t}\r\n\r\n\treturn bRet;\r\n}\r\n\r\nshort CountOf(const char *szN, char zero_digit)\r\n{\r\n\tint nRet = 0;\r\n\r\n\twhile (*szN)\r\n\t{\r\n\t\tif (*szN == zero_digit)\r\n\t\t\tnRet++;\r\n\r\n\t\tszN++;\r\n\t}\r\n\r\n\treturn nRet;\r\n}\r\n\r\nlong round(const char *value)\r\n{\r\n\tlong dres = (long)atof(value);\r\n\tdouble drem = atof(value);\r\n\tdrem -= dres;\r\n\tshort nAdd = 1;\r\n\tif (drem < 0) drem *= -1, nAdd *= -1;\r\n\tif (drem >= .5) dres += nAdd;\r\n\r\n\treturn dres;\r\n}\r\n\r\nvoid GString::FormatNumber(const char *szFormat, \r\n\t\t\t\t\t\t char decimal_separator,\r\n\t\t\t\t\t\t char grouping_separator,\r\n\t\t\t\t\t\t char minus_sign,\r\n\t\t\t\t\t\t const char *NaN,\r\n\t\t\t\t\t\t char zero_digit,\r\n\t\t\t\t\t\t char digit,\r\n\t\t\t\t\t\t char pattern_separator,\r\n\t\t\t\t\t\t char percent,\r\n\t\t\t\t\t\t char permille)\r\n{\r\n\tif (szFormat && *szFormat)\r\n\t{\r\n\t\t// make sure that the string is a number {0..9, '.', '-'}\r\n\t\t// if the string contains a character not in the number\r\n\t\t// subset then set the value of the string to NaN.\r\n\t\tconst char *szValue = _str;\r\n\t\tif (IsNaN(szValue, '.', ',', '-'))\r\n\t\t\t*this = NaN;\r\n\t\telse\r\n\t\t{\r\n\t\t\t// it's a number, get the whole part and the fraction part\r\n\t\t\tint nIdx = Find('.');\r\n\t\t\tGString strWhole;\r\n\t\t\tstrWhole = (nIdx == -1) ? _str : (const char *)Left(nIdx);\r\n\t\t\tGString strFraction('0', (short)1);\r\n\t\t\tnIdx = Find('.') + 1;\r\n\t\t\tif (nIdx > 0)\r\n\t\t\t\tstrFraction = Mid(nIdx);\r\n\t\t\tbool bIsNeg = (Find(minus_sign) != -1);\r\n\r\n\t\t\tlong nWhole = abs(atol((const char *)strWhole));\r\n\t\t\tlong nFract = abs(atol((const char *)strFraction));\r\n\r\n\t\t\t// check for % and ?\r\n\t\t\tif (percent == szFormat[0])\r\n\t\t\t{\r\n\t\t\t\tdouble d = atof(_str);\r\n\t\t\t\td *= 100;\r\n\t\t\t\tGString strTemp;\r\n\t\t\t\tstrTemp.Format(\"%f\", d);\r\n\t\t\t\tnIdx = strTemp.Find('.');\r\n\t\t\t\tstrFraction = (nIdx == -1) ? strTemp._str : (const char *)strTemp.Left(nIdx);\r\n\t\t\t\tnWhole = atol((const char *)strFraction);\r\n\t\t\t\tnFract = 0;\r\n\t\t\t}\r\n\t\t\tif (permille == szFormat[0])\r\n\t\t\t{\r\n\t\t\t\tdouble d = atof(_str);\r\n\t\t\t\td *= 1000;\r\n\t\t\t\tGString strTemp;\r\n\t\t\t\tstrTemp.Format(\"%f\", d);\r\n\t\t\t\tnIdx = strTemp.Find('.');\r\n\t\t\t\tstrFraction = (nIdx == -1) ? strTemp._str : (const char *)strTemp.Left(nIdx);\r\n\t\t\t\tnWhole = atol((const char *)strFraction);\r\n\t\t\t\tnFract = 0;\r\n\t\t\t}\r\n\r\n\t\t\t// if the number is negative, get the negative pattern out of the format.\r\n\t\t\t// if a negative pattern doesn't exist, the minus_sign will be prepended\r\n\t\t\t// to the positive pattern.\r\n\t\t\tGString strFormat(szFormat);\r\n\t\t\tnIdx = strFormat.Find(pattern_separator);\r\n\t\t\tif (bIsNeg)\r\n\t\t\t{\r\n\t\t\t\tif (nIdx != -1)\r\n\t\t\t\t\tstrFormat = strFormat.Mid(nIdx + 1);\r\n\t\t\t\telse\r\n\t\t\t\t\tstrFormat.Format(\"%c%s\", minus_sign, (const char *)strFormat);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (nIdx != -1)\r\n\t\t\t\t\tstrFormat = strFormat.Left(nIdx);\r\n\t\t\t}\r\n\r\n\t\t\tGString strFormatWhole(strFormat);\r\n\t\t\tGString strFormatDecimal('#', (short)1);\r\n\r\n\t\t\t// determine the number of digits per group\r\n\t\t\tint nGroup = 0;\r\n\t\t\tnIdx = strFormat.Find(',');\r\n\t\t\tif (nIdx != -1)\r\n\t\t\t{\r\n\t\t\t\tnIdx++;\r\n\t\t\t\tint nNext = strFormat.Find(',', nIdx);\r\n\t\t\t\tif (nNext == -1)\r\n\t\t\t\t\tnNext = strFormat.Find('.', nIdx);\r\n\t\t\t\tif (nNext == -1)\r\n\t\t\t\t\tnNext = strFormat.Length();\r\n\t\t\t\tnGroup = (nNext - nIdx);\r\n\t\t\t}\r\n\r\n\t\t\t// determine the number of decimals to display\r\n\t\t\tint nDecimals = 0;\r\n\t\t\tnIdx = strFormat.Find('.');\r\n\t\t\tif ((nIdx != -1) && \r\n\t\t\t\t(percent != szFormat[0]) &&\r\n\t\t\t\t(permille != szFormat[0]))\r\n\t\t\t{\r\n\t\t\t\tif (nGroup)\r\n\t\t\t\t\tstrFormatWhole = strFormat.Mid(nIdx - nGroup, nGroup);\r\n\t\t\t\telse\r\n\t\t\t\t\tstrFormatWhole = strFormat.Left(nIdx);\r\n\t\t\t\tnIdx++;\r\n\t\t\t\tstrFormatDecimal = strFormat.Mid(nIdx);\r\n\t\t\t\tnDecimals = (strFormat.Length() - nIdx);\r\n\t\t\t}\r\n\r\n\t\t\t// Format the whole part of the number\r\n\t\t\tint nCount = CountOf((const char *)strFormatWhole, zero_digit);\r\n\t\t\tstrWhole.Format(\"%0ld\", nWhole);\r\n\t\t\tif (strWhole.Length() < nCount)\r\n\t\t\t{\r\n\t\t\t\tGString temp(zero_digit, (short)(nCount - (short)strWhole.Length()));\r\n\t\t\t\tstrWhole.Format(\"%s%s\", (const char *)temp, (const char *)strWhole);\r\n\t\t\t}\r\n\r\n\t\t\tEmpty();\r\n\r\n\t\t\t// add all prefix characters\r\n\t\t\tnIdx = 0;\r\n\t\t\tconst char *szP = (const char *)strFormat;\r\n\t\t\twhile (*szP)\r\n\t\t\t{\r\n\t\t\t\tif (*szP == digit ||\r\n\t\t\t\t\t*szP == zero_digit ||\r\n\t\t\t\t\t*szP == decimal_separator ||\r\n\t\t\t\t\t*szP == grouping_separator ||\r\n\t\t\t\t\t*szP == percent ||\r\n\t\t\t\t\t*szP == permille)\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tszP++;\r\n\t\t\t\tnIdx++;\r\n\t\t\t}\r\n\t\t\tstrFormat = strFormat.Left(nIdx);\r\n\r\n\t\t\tstrFormat.MakeReverse();\r\n\r\n\t\t\tint i, j;\r\n\t\t\tfor (i = 0, j = strWhole.Length() - 1; j >= 0; j--, i++)\r\n\t\t\t{\r\n\t\t\t\tif ((nGroup) && (i == nGroup))\r\n\t\t\t\t{\r\n\t\t\t\t\t*this += grouping_separator;\r\n\t\t\t\t\ti = 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t*this += strWhole[j];\r\n\t\t\t}\r\n\t\t\t*this += strFormat;\r\n\r\n\t\t\tMakeReverse();\r\n\r\n\t\t\tif (nDecimals)\r\n\t\t\t{\r\n\t\t\t\t*this += decimal_separator;\r\n\r\n\t\t\t\tstrFraction.Format(\"%ld\", nFract);\r\n\t\t\t\tconst char *szF1 = (const char *)strFormatDecimal;\r\n\t\t\t\tconst char *szF2 = (const char *)strFraction;\r\n\t\t\t\ti = 0;\r\n\t\t\t\twhile (*szF1)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (*szF2)\r\n\t\t\t\t\t\t*this += *szF2;\r\n\t\t\t\t\telse if (*szF1 == zero_digit)\r\n\t\t\t\t\t\t*this += zero_digit;\r\n\t\t\t\t\telse if (*szF1 != digit) // add all sufix characters\r\n\t\t\t\t\t\t*this += *szF1;\r\n\t\t\t\t\tif (*szF2)\r\n\t\t\t\t\t\tszF2++;\r\n\t\t\t\t\tif (*szF1)\r\n\t\t\t\t\t\tszF1++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (percent == szFormat[0])\r\n\t\t\t\t*this += percent;\r\n\t\t\tif (permille == szFormat[0])\r\n\t\t\t\t*this += permille;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#define FORCE_ANSI 0x10000\r\n#define FORCE_UNICODE 0x20000\r\n#define FORCE_INT64 0x40000\r\n\r\nvoid GString::FormatV(const char *lpszFormat, va_list argList)\r\n{\r\n\tva_list argListSave = argList;\r\n\r\n\t// make a guess at the maximum length of the resulting string\r\n\tint nMaxLen = 0;\r\n\tfor (const char *lpsz = lpszFormat; *lpsz != '\\0'; lpsz++)\r\n\t{\r\n\t\t// handle '%' character, but watch out for '%%'\r\n\t\tif (*lpsz != '%' || *(lpsz = lpsz + 1) == '%')\r\n\t\t{\r\n\t\t\tnMaxLen += strlen(lpsz);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tint nItemLen = 0;\r\n\r\n\t\t// handle '%' character with format\r\n\t\tint nWidth = 0;\r\n\t\tfor (; *lpsz != '\\0'; lpsz++)\r\n\t\t{\r\n\t\t\t// check for valid flags\r\n\t\t\tif (*lpsz == '#')\r\n\t\t\t\tnMaxLen += 2; // for '0x'\r\n\t\t\telse if (*lpsz == '*')\r\n\t\t\t\tnWidth = va_arg(argList, int);\r\n\t\t\telse if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' ||\r\n\t\t\t\t*lpsz == ' ')\r\n\t\t\t\t;\r\n\t\t\telse // hit non-flag character\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t// get width and skip it\r\n\t\tif (nWidth == 0)\r\n\t\t{\r\n\t\t\t// width indicated by\r\n\t\t\tnWidth = atoi(lpsz);\r\n\t\t\tfor (; *lpsz != '\\0' && isdigit(*lpsz); lpsz++)\r\n\t\t\t\t;\r\n\t\t}\r\n\t\t(nWidth >= 0);\r\n\r\n\t\tint nPrecision = 0;\r\n\t\tif (*lpsz == '.')\r\n\t\t{\r\n\t\t\t// skip past '.' separator (width.precision)\r\n\t\t\tlpsz++;\r\n\r\n\t\t\t// get precision and skip it\r\n\t\t\tif (*lpsz == '*')\r\n\t\t\t{\r\n\t\t\t\tnPrecision = va_arg(argList, int);\r\n\t\t\t\tlpsz++;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tnPrecision = atoi(lpsz);\r\n\t\t\t\tfor (; *lpsz != '\\0' && isdigit(*lpsz); lpsz++)\r\n\t\t\t\t\t;\r\n\t\t\t}\r\n\t\t\t(nPrecision >= 0);\r\n\t\t}\r\n\r\n\t\t// should be on type modifier or specifier\r\n\t\tint nModifier = 0;\r\n\t\tif (strncmp(lpsz, \"I64\", 3) == 0)\r\n\t\t{\r\n\t\t\tlpsz += 3;\r\n\t\t\tnModifier = FORCE_INT64;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tswitch (*lpsz)\r\n\t\t\t{\r\n\t\t\t// modifiers that affect size\r\n\t\t\tcase 'h':\r\n\t\t\t\tnModifier = FORCE_ANSI;\r\n\t\t\t\tlpsz++;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'l':\r\n\t\t\t\tnModifier = FORCE_UNICODE;\r\n\t\t\t\tlpsz++;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// modifiers that do not affect size\r\n\t\t\tcase 'F':\r\n\t\t\tcase 'N':\r\n\t\t\tcase 'L':\r\n\t\t\t\tlpsz++;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// now should be on specifier\r\n\t\tswitch (*lpsz | nModifier)\r\n\t\t{\r\n\t\t// single characters\r\n\t\tcase 'c':\r\n\t\tcase 'C':\r\n\t\t\tnItemLen = 2;\r\n#ifdef WIN32 \r\n\t\t\tva_arg(argList, char);\r\n#else\r\n\t\t\t// gcc says: \"`char' is promoted to `int' when passed through ...\r\n\t\t\t// so we pass 'int' not 'char' to va_arg\"\r\n\t\t\tva_arg(argList, int);\r\n#endif\r\n\t\t\tbreak;\r\n\r\n\t\t// strings\r\n\t\tcase 's':\r\n\t\t\t{\r\n\t\t\t\tconst char *pstrNextArg = va_arg(argList, const char *);\r\n\t\t\t\tif (pstrNextArg == NULL)\r\n\t\t\t\t nItemLen = 6; // \"(null)\"\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t nItemLen = strlen(pstrNextArg);\r\n\t\t\t\t nItemLen = ___max(1, nItemLen);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 's'|FORCE_ANSI:\r\n\t\tcase 'S'|FORCE_ANSI:\r\n\t\t\t{\r\n\t\t\t\tconst char * pstrNextArg = va_arg(argList, const char *);\r\n\t\t\t\tif (pstrNextArg == NULL)\r\n\t\t\t\t nItemLen = 6; // \"(null)\"\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t nItemLen = strlen(pstrNextArg);\r\n\t\t\t\t nItemLen = ___max(1, nItemLen);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t// adjust nItemLen for strings\r\n\t\tif (nItemLen != 0)\r\n\t\t{\r\n\t\t\tif (nPrecision != 0)\r\n\t\t\t\tnItemLen = ___min(nItemLen, nPrecision);\r\n\t\t\tnItemLen = ___max(nItemLen, nWidth);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tswitch (*lpsz)\r\n\t\t\t{\r\n\t\t\t// integers\r\n\t\t\tcase 'd':\r\n\t\t\tcase 'i':\r\n\t\t\tcase 'u':\r\n\t\t\tcase 'x':\r\n\t\t\tcase 'X':\r\n\t\t\tcase 'o':\r\n\t\t\t\tif (nModifier & FORCE_INT64)\r\n\t\t\t\t\tva_arg(argList, __int64);\r\n\t\t\t\telse\r\n\t\t\t\t\tva_arg(argList, int);\r\n\t\t\t\tnItemLen = 32;\r\n\t\t\t\tnItemLen = ___max(nItemLen, nWidth+nPrecision);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'e':\r\n\t\t\tcase 'g':\r\n\t\t\tcase 'G':\r\n\t\t\t\tva_arg(argList, double);\r\n\t\t\t\tnItemLen = 128;\r\n\t\t\t\tnItemLen = ___max(nItemLen, nWidth+nPrecision);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'f':\r\n\t\t\t\t{\r\n\t\t\t\t\tdouble f;\r\n\t\t\t\t\t// 312 == strlen(\"-1+(309 zeroes).\")\r\n\t\t\t\t\t// 309 zeroes == max precision of a double\r\n\t\t\t\t\t// 6 == adjustment in case precision is not specified,\r\n\t\t\t\t\t// which means that the precision defaults to 6\r\n\t\t\t\t\tchar *pszTemp = new char[___max(nWidth, 312+nPrecision+6)];\r\n\r\n\t\t\t\t\tf = va_arg(argList, double);\r\n\t\t\t\t\tsprintf( pszTemp, \"%*.*f\", nWidth, nPrecision+6, f );\r\n\t\t\t\t\tnItemLen = strlen(pszTemp);\r\n\r\n\t\t\t\t\tdelete [] pszTemp;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'p':\r\n\t\t\t\tva_arg(argList, void*);\r\n\t\t\t\tnItemLen = 32;\r\n\t\t\t\tnItemLen = ___max(nItemLen, nWidth+nPrecision);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t// no output\r\n\t\t\tcase 'n':\r\n\t\t\t\tva_arg(argList, int*);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// adjust nMaxLen for output nItemLen\r\n\t\tnMaxLen += nItemLen;\r\n\t}\r\n\r\n\tif (nMaxLen + 1 > _max)\r\n\t{\r\n\t\tif (_strIsOnHeap)\r\n\t\t\tdelete _str;\r\n\t\t_max = nMaxLen + 1;\r\n\t\t_str = new char[_max];\r\n\t\t_strIsOnHeap = 1;\r\n\t\t_initialbuf[0] = 0;\r\n\t}\r\n\r\n\t_len = vsprintf(_str, lpszFormat, argListSave);\r\n\r\n\tva_end(argListSave);\r\n\r\n\tif (_len < 0)\r\n\t{\r\n\t\t_len = 0;\r\n\t\t_str[_len] = 0;\r\n\t}\r\n}\r\n\r\n// Load an error from the active ErrorProfile() owned by GException.cpp\r\nvoid GString::LoadResource(const char* szSystem, int error, ...)\r\n{\r\n\tint nerror = error;\r\n\r\n\tGProfile &ErrorProfile = GetErrorProfile();\r\n\tint nsubSystem = atoi(ErrorProfile.GetString(szSystem, \"SubSystem\"));\r\n\r\n\tGString strKey;\r\n\tstrKey.Format(\"%ld\", error);\r\n\tstrKey = ErrorProfile.GetString(szSystem, (const char *)strKey);\r\n\r\n\tva_list argList;\r\n\tva_start(argList, error);\r\n\tFormatV((const char *)strKey, argList);\r\n\tva_end(argList);\r\n\r\n}\r\n\r\n\r\nvoid GString::Format(const char *lpszFormat, ...)\r\n{\r\n\tva_list argList;\r\n\tva_start(argList, lpszFormat);\r\n\tFormatV(lpszFormat, argList);\r\n\tva_end(argList);\r\n}\r\n\r\nint GString::ToFileAppend(const char* pzFileName, bool bThrowOnFail /*= 1*/)\r\n{\r\n\tFILE *fp = fopen(pzFileName,\"a\");\r\n\tif (fp)\r\n\t{\r\n\t\tfwrite(_str,1,_len,fp);\r\n\t\tfclose(fp);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t// the file could not be opened for writing\r\n\t\tif (bThrowOnFail)\r\n\t\t\tthrow GenericException(\"String\", 3, pzFileName);\r\n\t\t\r\n\t\t// fail\r\n\t\treturn 0;\r\n\t}\r\n\t// success\r\n\treturn 1;\r\n}\r\n\r\nint GString::ToFile(const char* pzFileName, bool bThrowOnFail/* = 1*/)\r\n{\r\n\tFILE *fp = fopen(pzFileName,\"wb\");\r\n\tif (fp)\r\n\t{\r\n\t\tfwrite(_str,1,_len,fp);\r\n\t\tfclose(fp);\r\n\t}\r\n\telse\r\n\t{\r\n\t\t// the file could not be opened for writing\r\n\t\tif (bThrowOnFail)\r\n\t\t\tthrow GenericException(\"String\", 3, pzFileName);\r\n\t\t\r\n\t\t// fail\r\n\t\treturn 0;\r\n\t}\r\n\t// success\r\n\treturn 1;\r\n}\r\n\r\nint GString::FromFile(const char* pzFileName, bool bThrowOnFail/* = 1*/)\r\n{\r\n\tFILE *fp = fopen(pzFileName,\"rb\");\r\n\tif (fp)\r\n\t{\r\n\t\t// get the size of the file\r\n\t\tfseek(fp,0,SEEK_END);\r\n\t\tlong lBytes = ftell(fp);\r\n\t\tfseek(fp,0,SEEK_SET);\r\n\t\t\r\n\t\tif (_strIsOnHeap)\r\n\t\t\tdelete [] _str;\r\n\r\n\t\t// pre-alloc the GString\r\n\t\t_str = new char[lBytes + 1];\r\n\t\t_strIsOnHeap = 1;\r\n\t\t_initialbuf[0] = 0;\r\n\r\n\t\tint n = fread(_str,sizeof(char),lBytes,fp);\r\n\t\t_len = lBytes;\r\n\t\t_str[_len] = 0;\r\n\t\tfclose(fp);\r\n\t}\r\n\telse \r\n\t{\r\n\t\t// the file could not be opened.\r\n\t\tif (bThrowOnFail)\r\n\t\t\tthrow GenericException(\"String\", 2, pzFileName);\r\n\t\t\r\n\t\t// fail\r\n\t\treturn 0;\r\n\t}\r\n\t// success\r\n\treturn 1;\r\n}\r\n\r\n/*\r\nint GString::GStringFromFile(GString &strDest, \r\n\t\t\t\t\t\t\t const char* pzFileName, \r\n\t\t\t\t\t\t\t int nMode)\r\n{\r\n\tfstream fs(pzFileName, nMode);\r\n \tif (fs.good())\r\n\t{\r\n\t\tfs.seekg( 0, ios::end );\r\n\t\tlong lFileBytes = fs.tellg();\r\n\t\tfs.seekg( 0, ios::beg );\r\n\r\n\t\tif (strDest._strIsOnHeap)\r\n\t\t\tdelete [] strDest._str;\r\n\t\tstrDest._str = new char[lFileBytes + 1];\r\n\t\tstrDest._strIsOnHeap = 1;\r\n\t\tstrDest._initialbuf[0] = 0;\r\n\r\n\t\tfs.read(strDest._str, lFileBytes);\r\n\t\tstrDest._len = lFileBytes;\r\n\t\tstrDest._str[strDest._len] = 0;\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn 0; // Failed to open input file\r\n\t}\r\n\treturn 1; // success\r\n}\r\n\r\nint GString::GStringFromFile(ostream &strDest, \r\n\t\t\t\t\t\t\t const char* pzFileName,\r\n\t\t\t\t\t\t\t int nMode)\r\n{\r\n\tfstream fs(pzFileName, nMode);\r\n \tif (fs.good())\r\n\t{\r\n\t\tfs.seekg( 0, ios::end );\r\n\t\tlong lFileBytes = fs.tellg();\r\n\t\tfs.seekg( 0, ios::beg );\r\n\r\n\t\tchar *buf = new char[lFileBytes];\r\n\t\tfs.read(buf,lFileBytes);\r\n\r\n\t\tif (strDest.tellp())\r\n\t\t\tstrDest.seekp(strDest.tellp() - 1);\r\n\t\r\n\t\tstrDest.write(buf,lFileBytes);\r\n\t\tdelete buf;\r\n\r\n\t\tstrDest << ends;\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn 0; // Failed to open input file\r\n\t}\r\n\treturn 1; // success\r\n}\r\n*/\r\n\r\nvoid GString::ReplaceCaseInsensitive( const char * szWhat, const char *szRep, int nStart/* = 0*/ )\r\n{\r\n\tif ((!szWhat) || (!szRep))\r\n\t\treturn;\r\n\r\n\tint nPos = FindSubStringCaseInsensitive(szWhat, nStart);\r\n\tint nLen = strlen(szRep);\r\n\r\n\twhile (nPos != -1)\r\n\t{\r\n\t\tRemove(nPos, strlen(szWhat));\r\n\t\tif (nLen)\r\n\t\t\tInsert(nPos, szRep);\r\n\r\n\t\tnPos += nLen;\r\n\r\n\t\tnPos = FindSubStringCaseInsensitive(szWhat, nPos);\r\n\t}\r\n}\r\n\r\n\r\nvoid GString::Replace( const char * szWhat, const char *szRep )\r\n{\r\n\tif ((!szWhat) || (!szRep))\r\n\t\treturn;\r\n\r\n\tint nPos = Find(szWhat);\r\n\tint nLen = strlen(szRep);\r\n\r\n\twhile (nPos != -1)\r\n\t{\r\n\t\tRemove(nPos, strlen(szWhat));\r\n\t\tif (nLen)\r\n\t\t\tInsert(nPos, szRep);\r\n\r\n\t\tnPos += nLen;\r\n\r\n\t\tnPos = Find(szWhat, nPos);\r\n\t}\r\n}\r\n\r\nvoid GString::Replace( char chWhat, char chRep )\r\n{\r\n\tchar szWhat[2];\r\n\tszWhat[0] = chWhat;\r\n\tszWhat[1] = 0;\r\n\r\n\tchar szRep[2];\r\n\tszRep[0] = chRep;\r\n\tszRep[1] = 0;\r\n\r\n\tReplace( (const char *)szWhat, (const char *)szRep );\r\n}\r\n\r\nvoid GString::Replace( const char * szWhat, char chRep )\r\n{\r\n\tchar szRep[2];\r\n\tszRep[0] = chRep;\r\n\tszRep[1] = 0;\r\n\r\n\tReplace( (const char *)szWhat, (const char *)szRep );\r\n}\r\n\r\nvoid GString::Replace( char chWhat, const char *szRep )\r\n{\r\n\tchar szWhat[2];\r\n\tszWhat[0] = chWhat;\r\n\tszWhat[1] = 0;\r\n\r\n\tReplace( (const char *)szWhat, (const char *)szRep );\r\n}\r\n\r\nvoid GString::Remove( int nStart, int nLen )\r\n{\r\n\t// subscript out of range\r\n\tif (nStart + nLen > _len)\r\n\t\tthrow GenericException(\"String\", 1);\r\n\r\n\tmemmove(&_str[nStart], &_str[nStart + nLen], _len - (nStart + nLen));\r\n\t_len -= nLen;\r\n\t_str[_len] = 0;\r\n}\r\n\r\nvoid GString::StripQuotes()\r\n{\r\n\tif ((_len >= 2) && (_str[0] == _str[_len - 1]))\r\n\t{\r\n\t\tif ((_str[0] == '\\'') || (_str[0] == '\"'))\r\n\t\t{\r\n\t\t\tmemmove(&_str[0], &_str[1], _len - 2);\r\n\t\t\t_len -= 2;\r\n\t\t\t_str[_len] = 0;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nvoid GString::NormalizeSpace()\r\n{\r\n\tint nBegWS = -1;\r\n\tint nEndWS = -1;\r\n\r\n\tfor (int i = 0; i < _len; i++)\r\n\t{\r\n\t\tif (isWS(_str[i]))\r\n\t\t{\r\n\t\t\tnEndWS = i;\r\n\t\t\tif (nBegWS == -1)\r\n\t\t\t\tnBegWS = i;\r\n\t\t}\r\n\t\telse if ((nBegWS != -1) && \r\n\t\t\t\t (nEndWS != -1))\r\n\t\t{\r\n\t\t\tnEndWS++;\r\n\t\t\tRemove(nBegWS, nEndWS - nBegWS);\r\n\t\t\tInsert(nBegWS, ' ');\r\n\t\t\ti = nBegWS;\r\n\t\t\tnBegWS = -1;\r\n\t\t\tnEndWS = -1;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tnBegWS = -1;\r\n\t\t\tnEndWS = -1;\r\n\t\t}\r\n\t}\r\n\r\n\tif ((nBegWS != -1) && \r\n\t\t(nEndWS != -1))\r\n\t{\r\n\t\t\tnEndWS++;\r\n\t\t\tRemove(nBegWS, nEndWS - nBegWS);\r\n\t\t\tInsert(nBegWS, ' ');\r\n\t}\r\n\r\n\tTrimLeftWS();\r\n\tTrimRightWS();\r\n}\r\n\r\nvoid GString::Translate(const char *szConvert, const char *szTo)\r\n{\r\n\tif ((szConvert) && (szTo))\r\n\t{\r\n\t\tint nTranslate = ___min(strlen(szConvert), strlen(szTo));\r\n\t\tfor (int i = 0; i < _len; i++)\r\n\t\t{\r\n\t\t\tfor (int j = 0; j < nTranslate; j++)\r\n\t\t\t{\r\n\t\t\t\tif (_str[i] == szConvert[j])\r\n\t\t\t\t\t_str[i] = szTo[j];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n// replace each char in pzReplaceChars with %nn where\r\n// nn is a two byte hex value of the byte that was replaced.\r\n// example: GString s(\"ABC\"); \r\n//\t\t\ts.EscapeWithHex(\"XYZB\");\r\n//\t\t\ts == \"A%42C\"\r\n//\t42 is hex for 66 that is the ASCII of a B\r\n//\r\n// example: GString s(\"A\\nC\"); \r\n//\t\t\ts.EscapeWithHex(\"\\r\\n\\t\");\r\n//\t\t\ts == \"A%0AC\"\r\n//\r\nconst char *GString::EscapeWithHex(const char *pzEscapeChars)\r\n{\r\n\tGString strDestrination;\r\n\tGString strEscapeChars(pzEscapeChars);\r\n\tchar *pSrc = (char *)(const char *)(*this);\r\n\tint nSourceBytes = strlen(pSrc);\r\n\t\r\n\tfor(int i=0;i < nSourceBytes; i++)\r\n\t{\r\n\t\t// escape special chars\r\n\t\tif ( strEscapeChars.Find(pSrc[i]) > -1 )\r\n\t\t{\r\n\t\t\tchar buf[20];\r\n\t\t\tsprintf(buf,\"%%%02X\",pSrc[i]);\r\n\t\t\tstrDestrination += buf;\r\n\t\t}\r\n\t\telse \r\n\t\t{\r\n\t\t\tstrDestrination += pSrc[i];\r\n\t\t}\r\n\t}\r\n\t*this = strDestrination;\r\n\treturn *this;\r\n}\r\n\r\n// reverse of GString::EscapeWithHex()\r\nvoid GString::UnEscapeHexed()\r\n{\r\n\tconst char *pSource = *this;\r\n\tchar *pDest = new char [strlen(pSource) + 1];\r\n\r\n\tchar *pszQuery = (char *)pSource;\r\n\tchar *t = pDest;\r\n\twhile (*pszQuery)\r\n\t{\r\n\t\tswitch (*pszQuery)\r\n\t\t{\r\n\t\tcase '%' :\r\n\t\t\t{\r\n\t\t\t\tpszQuery++;\r\n\t\t\t\tchar chTemp = pszQuery[2];\r\n\t\t\t\tpszQuery[2] = 0;\r\n\t\t\t\tchar *pStart = pszQuery;\r\n\t\t\t\tchar *pEnd;\r\n\t\t\t\t*t = (char)strtol(pStart, &pEnd, 16);\r\n\t\t\t\tpszQuery[2] = chTemp;\r\n\t\t\t\tpszQuery = pEnd;\r\n\t\t\t\tt++;\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tdefault :\r\n\t\t\t*t = *pszQuery;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tpszQuery++;\r\n\t\tt++;\r\n\t}\r\n\t*t = 0;\r\n\t*this = pDest;\r\n\tdelete pDest;\r\n}\r\n///////////////////////////////////////////////////////////////////////////////\r\n///////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t Functions for the Camera Orbits behaviors\r\n//\r\n///////////////////////////////////////////////////////////////////////////////\r\n///////////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"GeneralCameraOrbit.h\"\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tGeneral Creation Function\r\n//\r\n// Note : Creates the common inputs, outputs, settings and local parameters.\r\n//\t\t And sets the common flags.\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR FillGeneralCameraOrbitProto(CKBehaviorPrototype *proto)\r\n{\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\r\n\t// Default Inputs\r\n\tproto->DeclareInParameter(\"Target Position\", CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Target Referential\", CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Move Speed\", CKPGUID_ANGLE, \"0:100\");\r\n\tproto->DeclareInParameter(\"Return Speed\", CKPGUID_ANGLE, \"0:200\");\r\n\tproto->DeclareInParameter(\"Min Horizontal\", CKPGUID_ANGLE, \"0:-180\");\r\n\tproto->DeclareInParameter(\"Max Horizontal\", CKPGUID_ANGLE, \"0:180\");\r\n\tproto->DeclareInParameter(\"Min Vertical\", CKPGUID_ANGLE, \"0:-180\");\r\n\tproto->DeclareInParameter(\"Max Vertical\", CKPGUID_ANGLE, \"0:180\");\r\n\tproto->DeclareInParameter(\"Zoom Speed\", CKPGUID_FLOAT, \"40\");\r\n\tproto->DeclareInParameter(\"Zoom Min\", CKPGUID_FLOAT, \"-40\");\r\n\tproto->DeclareInParameter(\"Zoom Max\", CKPGUID_FLOAT, \"10\");\r\n\r\n\tproto->DeclareLocalParameter(\"Initial Angles & Radius\",CKPGUID_VECTOR);\r\n\tproto->DeclareLocalParameter(\"Rotation Angles & Radius\",CKPGUID_VECTOR);\r\n\tproto->DeclareLocalParameter(\"Stopping\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->DeclareSetting(\"Limits\", CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareSetting(\"Returns\", CKPGUID_BOOL,\"TRUE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tMain General Function\r\n//\r\n// Note : We use the polar angle of the camera in the target referential to \r\n// turn around it. Therefore, if the target moves, the camera moves with it\r\n// to stay around it.\r\n// Takes a specific input processing function.\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nint GeneralCameraOrbit(const CKBehaviorContext& behcontext,INPUTPROCESSFUNCTION InputFunction)\r\n{\r\n\t// Get the behavior\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tfloat delta = behcontext.DeltaTime;\r\n\r\n\t// Current state of the behavior\r\n\tCKBOOL stopping;\r\n\r\n\t// Indicates the behavior we are stopping if returns, stop otherwise\r\n\tCKBOOL Returns = TRUE;\r\n\tbeh->GetLocalParameterValue(LOCAL_RETURN,&Returns);\r\n\r\n\t// Stop Entrance, we stop\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\t// Set IO State\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\r\n\t\t// A protection in case we stop the behavior before having started it\r\n\t\tVxVector InitialAngles;\r\n\t\tbeh->GetLocalParameterValue(LOCAL_INIT,&InitialAngles);\r\n\r\n\t\t// Get current position\r\n\t\tVxVector RotationAngles;\r\n\t\tbeh->GetLocalParameterValue(LOCAL_ROT,&RotationAngles);\r\n\r\n\t\t// Stopping Now\r\n\t\tstopping = TRUE;\r\n\t\tbeh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);\r\n\t\tif ( !Returns || ((RotationAngles.x == 0) && (RotationAngles.y == 0)) ) {\r\n\t\t\tbeh->ActivateOutput(1,TRUE);\r\n\t\t\treturn CKBR_OK;\r\n\t\t}\r\n\t}\r\n\r\n\t// Gets the current camera\r\n\tCKCamera *Camera = (CKCamera *) beh->GetTarget();\r\n\tif( !Camera ) return CKBR_OWNERERROR;\r\n\r\n\t// Gets the target informations\r\n\tVxVector TargetPosition;\r\n\tbeh->GetInputParameterValue(IN_TARGET_POS,&TargetPosition);\r\n\r\n\tCK3dEntity* TargetRef = (CK3dEntity*)beh->GetInputParameterObject(IN_TARGET_REF);\r\n\r\n\r\n\t//////////////////////////////////////////////\r\n\t// Gets the input parameters of the behavior\r\n\t//////////////////////////////////////////////\r\n\tVxVector InitialAngles(0,0,0), RotationAngles(0,0,0);\r\n\r\n\t// First entrance, sets the initial values here only\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\t// Sets IO State\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0,TRUE);\r\n\r\n\t\t// Not Stopping\r\n\t\tstopping = FALSE;\r\n\t\tbeh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);\r\n\r\n\t\t// Compute the Initial Angles, the radius\r\n\t\tVxVector InitialPosition;\r\n\t\tCamera->GetPosition(&InitialPosition, TargetRef);\r\n\t\r\n\t\tInitialPosition -= TargetPosition;\r\n\t\tInitialAngles.z = Magnitude(InitialPosition);\r\n\t\tif ( InitialAngles.z == 0.0f ) {\r\n\t\t\tInitialAngles.x = 0.0f;\r\n\t\t\tInitialAngles.y = 0.0f;\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// Vertical Polar Angle\r\n\t\t\tfloat d;\r\n\t\t\tInitialPosition.Normalize();\r\n\t\t\td = DotProduct(InitialPosition,VxVector::axisY());\r\n\r\n\t\t\t// bound the value of d to avoid errors due to precision.\r\n\t\t\tif (d < -1)\r\n\t\t\t\td = -1;\r\n\t\t\telse if (d > 1)\r\n\t\t\t\td = 1;\r\n \t\t\tInitialAngles.y = acosf(d);\r\n\r\n\t\t\t// Horizontal Polar Angle\r\n\t\t\tInitialPosition.y = 0;\r\n\t\t\tif ( (InitialPosition.x == 0.0f) && (InitialPosition.y == 0.0f) && (InitialPosition.z == 0.0f) )\r\n\t\t\t\tInitialAngles.x = PI/2;\r\n\t\t\telse {\r\n\t\t\t\tInitialPosition.Normalize();\r\n\t\t\t\td = DotProduct(InitialPosition,VxVector::axisX());\r\n\t\t\t\t// bound the value of d to avoid eroors due to precision.\r\n\t\t\t\tif (d < -1)\r\n\t\t\t\t\td = -1;\r\n\t\t\t\telse if (d > 1)\r\n\t\t\t\t\td = 1;\r\n\t\t\t\tInitialAngles.x = acosf(d);\r\n\t\t\t\td = DotProduct(InitialPosition,VxVector::axisZ());\r\n\t\t\t\tif (d < 0)\r\n\t\t\t\tInitialAngles.x *= -1;\r\n\t\t\t}\r\n\r\n\t\t\t// In case the camera has the head down, we need to inverse the commands when we go\r\n\t\t\t// Up otherwise, the user will have the feeling to turn on the wrong direction.\r\n\t\t\tVxVector CamUp;\r\n\t\t\tCamera->GetOrientation(NULL,&CamUp,NULL,NULL);\r\n\t\t\tif ( CamUp.y < 0 )\r\n\t\t\t{\r\n\t\t\t\tInitialAngles.x += PI;\r\n\t\t\t\tInitialAngles.y *= -1;\r\n\t\t\t\tInitialAngles.x = (float)fmod(InitialAngles.x,2*PI);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Reset stopping\r\n\t\tstopping = FALSE;\r\n\r\n\t\t// Sets the values in memory\r\n\t\tbeh->SetLocalParameterValue(LOCAL_INIT,&InitialAngles);\r\n\t\tbeh->SetLocalParameterValue(LOCAL_ROT,&RotationAngles);\r\n\t\tbeh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);\r\n\r\n\t\t// Only initialization on \"On\" entrance\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t// Auto-activation of the behavior\r\n\tbeh->GetLocalParameterValue(LOCAL_INIT,&InitialAngles);\r\n\tbeh->GetLocalParameterValue(LOCAL_ROT,&RotationAngles);\r\n\tbeh->GetLocalParameterValue(LOCAL_STOPPING,&stopping);\r\n\r\n\t// Get the input manager\r\n\tCKInputManager *input = (CKInputManager*)behcontext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n\r\n\t// Call the input processing function\r\n\tInputFunction (&RotationAngles,beh,input,delta,Returns,stopping);\r\n\r\n\t// Do nothing when initial angle were not initialized.\r\n\t// Simply stop the BB. No output activated.\r\n\tif ( (InitialAngles.x == INF) || (RotationAngles.x == INF) )\r\n\t\treturn CKBR_OK;\r\n\r\n\t// When we are exactly on the top or the bottom of the target, +/-90°,\r\n\t// The LookAt BB won't rotate the camera when we turn right or left as \r\n\t// it already looks at the target. Therefore, when we are at +/-90°, we\r\n\t// add or remove a little something.\r\n\tif ( (RotationAngles.y==PI/2) || (RotationAngles.y == -PI/2) )\r\n\t{\r\n\t\t// Get Min, Max\r\n\t\t// If equals, nothing to change, it is the given value.\r\n\t\tfloat MinH = -PI/2;\r\n\t\tfloat MaxH = PI/2;\r\n\t\tbeh->GetInputParameterValue(IN_MIN_H, &MinH);\r\n\t\tbeh->GetInputParameterValue(IN_MAX_H, &MaxH);\r\n\t\tif ( MaxH - MinH > 2 * STEP )\r\n\t\t{\r\n\t\t\tfloat sign = (RotationAngles.y > 0) ? 1.0f : -1.0f;\r\n\t\t\tif ( MaxH >= sign * PI/2 + STEP )\r\n\t\t\t\t\tRotationAngles.y += STEP;\r\n\t\t\t\telse\r\n\t\t\t\t\tRotationAngles.y -= STEP;\r\n\t\t}\r\n\t}\r\n\r\n\t// We memorize the new state with modulos\r\n\tRotationAngles.x = (float)fmod(RotationAngles.x,2*PI);\r\n\tRotationAngles.y = (float)fmod(RotationAngles.y,2*PI);\r\n\tbeh->SetLocalParameterValue(LOCAL_ROT,&RotationAngles);\r\n\r\n\t// Computes the coordinates of the camera in the target referential thanks to the \r\n\t// current polar angles and radius informations. And moves the camera\r\n\tVxVector Position;\r\n\tPosition = InitialAngles + RotationAngles;\r\n\tPosition = Position.z * (cosf(Position.x) * sinf(Position.y) * VxVector::axisX() + sinf(Position.x) * sinf(Position.y) * VxVector::axisZ() + cosf(Position.y) * VxVector::axisY());\r\n\tPosition += TargetPosition;\r\n\tCamera->SetPosition(&Position, TargetRef, FALSE);\r\n\r\n\t// Does the camera has a Target ?\r\n\tCK3dEntity *CameraTarget;\r\n\tCKBOOL CameraHasTarget = CKIsChildClassOf(Camera,CKCID_TARGETCAMERA)\r\n\t\t\t\t\t\t\t\t&& (CameraTarget=((CKTargetCamera*)Camera)->GetTarget());\r\n\r\n\r\n\t// Orients the Camera. The LookAt implies that when the camera reach\r\n\t// the 90°, it may be flipped and suddently have the head up and down.\r\n\t// Therefore we use the target for target cameras as we have to use the\r\n\t// target. But for free cameras, we do our own look at using our rotation\r\n\t// angle to avoid this problem.\r\n\tif (CameraHasTarget)\r\n\t\tCameraTarget->SetPosition(&TargetPosition, TargetRef, TRUE);\r\n\telse {\r\n\t\t// New direction\r\n\t\tVxVector Dir;\r\n\t\tDir = TargetPosition - Position;\r\n\r\n\t\t// Temp Right Value\r\n\t\tVxMatrix mat;\r\n\t\tVxVector R(0,0,-1); // Up for (0,0) angle\r\n\t\tVx3DMatrixFromRotationAndOrigin(mat,VxVector::axisY(),VxVector(0,0,0),InitialAngles.x + RotationAngles.x);\r\n\t\tR.Rotate(mat);\r\n\r\n\t\t// Get Up\r\n\t\tVxVector Up;\r\n\t\tUp = CrossProduct(R,Dir);\r\n\r\n\t\tCamera->SetOrientation(&Dir,&Up,NULL,TargetRef);\r\n\t\t//Camera->LookAt(&TargetPosition,TargetRef);\r\n\t}\r\n\r\n\t// Stop is finished, reset values.\t\r\n\tif ( stopping && ((RotationAngles.x == 0) && (RotationAngles.y == 0)) )\r\n\t{ \r\n\t\tbeh->ActivateOutput(1,TRUE);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\telse\r\n\t\t// Come back next frame\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tCallback Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR GeneralCameraOrbitCallback(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior* beh = context.Behavior;\r\n\r\n\tswitch(context.CallbackMessage)\r\n\t{\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tVxVector InitialAngles(INF,INF,INF);\r\n\t\t\tbeh->SetLocalParameterValue(LOCAL_INIT,&InitialAngles);\r\n\r\n\t\t\tVxVector RotationAngles(0,0,0);\r\n\t\t\tbeh->SetLocalParameterValue(LOCAL_ROT,&RotationAngles);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t// Update the needed input for \"returns\"\r\n\t\t\tCKBOOL Returns = TRUE;\r\n\t\t\tbeh->GetLocalParameterValue(LOCAL_RETURN,&Returns);\r\n\t\t\tbeh->EnableInputParameter(IN_SPEED_RETURN, Returns);\r\n\r\n\t\t\t// Updates the needed inputs for limiting the move\r\n\t\t\tCKBOOL Limited = TRUE;\r\n\t\t\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_H,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_H,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_V,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_V,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_ZOOM,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_ZOOM,Limited);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\tdefault:\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn CKBR_OK; \r\n}\r\n/********************************************************************\r\n\tcreated:\t2007/12/15\r\n\tcreated:\t15:12:2007 22:28\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\plugins\\xUtils\\include\\xUtils.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\current\\vt_player\\exKamPlayer\\plugins\\xUtils\\include\r\n\tfile base:\txUtils\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __X_UTILS_H_\r\n#define __X_UTILS_H_\r\n\r\n#include \r\n\r\nnamespace xUtils\r\n{\r\n\r\n\tnamespace system\r\n\r\n\t{\r\n\r\n\t\r\n\t\t MODULE_API HRESULT GetDirectVersion(char*&version,DWORD& minor);\r\n\t\t MODULE_API int GetPhysicalMemoryInMB();\r\n\t\r\n\t}\r\n\r\n}\r\n\r\n#endif\r\n\r\n#include \r\n#include \"vtPhysXBase.h\"\r\n#include \"xAssertion.h\"\r\n\r\n#include \"xAssertCustomization.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// global data\r\n//\r\nCAssertionFailedProcedure xAssertionEx::g_fnAssertFailureHandler = NULL;\r\nxErrorHandlerFn xAssertionEx::g_fnAssertHandler = NULL;\r\n\r\nxAssertionEx* gAssertionEx = NULL;\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// \r\n//\r\n\r\nxAssertionEx*xAssertionEx::Instance()\r\n{\r\n\tif (!gAssertionEx)\r\n\t\tgAssertionEx = &xAssertionEx();\r\n\r\n\treturn gAssertionEx;\r\n}\r\n\r\nxAssertionEx::xAssertionEx()\r\n{\r\n\tgAssertionEx = this;\r\n}\r\n\r\n/*\r\nxErrorHandlerFn xAssertionEx::getErrorHandler()\r\n{\r\n\treturn g_fnAssertHandler;\r\n}\r\n\r\nvoid xAssertionEx::setErrorHandler(xErrorHandlerFn fnFailureProcedure)\r\n{\r\n\tg_fnAssertHandler = fnFailureProcedure;\r\n}\r\n*/\r\n//----------------------------------------------------------------\r\n//\r\n// \r\n//\r\nvoid assert_notify_failure(const char* str)\r\n{\r\n\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,str);\r\n\t//std::cerr << str << \" failed\" << std::endl;\r\n}\r\n\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_BITSTREAM_H_\n#define _TNL_BITSTREAM_H_\n\n#ifndef _TNL_BYTEBUFFER_H_\n#include \"tnlByteBuffer.h\"\n#endif\n\n#ifndef _TNL_CONNECTIONSTRINGTABLE_H_\n#include \"tnlConnectionStringTable.h\"\n#endif\n\nnamespace TNL {\n\nclass SymmetricCipher;\n\n/// Point3F is used by BitStream for transmitting 3D points and vectors.\n///\n/// Users of the TNL should provide conversion operators to and from\n/// this TNL-native type.\nstruct Point3f\n{\n F32 x; ///< the X coordinate\n F32 y; ///< the Y coordinate\n F32 z; ///< the Z coordinate\n};\n\n/// Helper macro used in BitStream declaration.\n///\n/// @note DeclareTemplatizedReadWrite macro declares a read and write function\n/// for the specified type. This is a macro because MSVC6 has seriously\n/// broken template functionality. Thanks MS!\n#define DeclareTemplatizedReadWrite(T) \\\ninline bool write(T value) { T temp = convertHostToLEndian(value); return write(sizeof(T), &temp); } \\\ninline bool read(T *value) { T temp; bool success = read(sizeof(T), &temp); *value = convertLEndianToHost(temp); return success;}\n\n/// BitStream provides a bit-level stream interface to a data buffer.\nclass BitStream : public ByteBuffer\n{\nprotected:\n enum {\n ResizePad = 1500,\n };\n U32 bitNum; ///< The current bit position for reading/writing in the bit stream.\n bool error; ///< Flag set if a user operation attempts to read or write past the max read/write sizes.\n bool mCompressRelative; ///< Flag set if the bit stream should compress points relative to a compression point.\n Point3f mCompressPoint; ///< Reference point for relative point compression.\n U32 maxReadBitNum; ///< Last valid read bit position.\n U32 maxWriteBitNum; ///< Last valid write bit position.\n ConnectionStringTable *mStringTable; ///< String table used to compress StringTableEntries over the network.\n /// String buffer holds the last string written into the stream for substring compression.\n char mStringBuffer[256];\n\n bool resizeBits(U32 numBitsNeeded);\npublic:\n\n /// @name Constructors\n ///\n /// Note that the BitStream essentially wraps an existing buffer, so to use a bitstream you must\n /// have an existing buffer for it to work with!\n ///\n /// @{\n\n /// Default to maximum write size being the size of the buffer.\n BitStream(U8 *bufPtr, U32 bufSize) : ByteBuffer(bufPtr, bufSize) { setMaxSizes(bufSize, bufSize); reset(); }\n\n /// Optionally, specify a maximum write size.\n BitStream(U8 *bufPtr, U32 bufSize, U32 maxWriteSize) \n : ByteBuffer(bufPtr, bufSize) { setMaxSizes(bufSize, maxWriteSize); reset(); }\n\n /// Creates a resizable BitStream\n BitStream() : ByteBuffer() { setMaxSizes( getBufferSize(), getBufferSize() ); reset(); }\n /// @}\n\n /// Sets the maximum read and write sizes for the BitStream.\n void setMaxSizes(U32 maxReadSize, U32 maxWriteSize = 0);\n\n /// Sets the maximum read and write bit sizes for the BitStream.\n void setMaxBitSizes(U32 maxReadBitSize, U32 maxWriteBitSize = 0);\n\n /// resets the read/write position to 0 and clears any error state.\n void reset();\n\n /// clears the string compression buffer.\n void clearStringBuffer() { mStringBuffer[0] = 0; }\n\n /// sets the ConnectionStringTable for compressing string table entries across the network\n void setStringTable(ConnectionStringTable *table) { mStringTable = table; }\n\n /// clears the error state from an attempted read or write overrun\n void clearError() { error = false; }\n\n /// Returns a pointer to the next byte in the BitStream from the current bit position\n U8* getBytePtr();\n\n /// Returns the current position in the stream rounded up to the next byte.\n U32 getBytePosition() const;\n /// Returns the current bit position in the stream\n U32 getBitPosition() const;\n /// Sets the position in the stream to the first bit of byte newPosition.\n void setBytePosition(const U32 newPosition);\n /// Sets the position in the stream to newBitPosition.\n void setBitPosition(const U32 newBitPosition);\n /// Advances the position in the stream by numBits.\n void advanceBitPosition(const S32 numBits);\n\n /// Returns the maximum readable bit position\n U32 getMaxReadBitPosition() const { return maxReadBitNum; }\n\n /// Returns the number of bits that can be written into the BitStream without resizing\n U32 getBitSpaceAvailable() const { return maxWriteBitNum - bitNum; }\n\n /// Pads the bits up to the next byte boundary with 0's.\n void zeroToByteBoundary();\n\n /// Writes an unsigned integer value between 0 and 2^(bitCount - 1) into the stream.\n void writeInt(U32 value, U8 bitCount);\n /// Reads an unsigned integer value between 0 and 2^(bitCount - 1) from the stream.\n U32 readInt(U8 bitCount);\n\n /// Writes an unsigned integer value between 0 and 2^(bitCount -1) into the stream at the specified position, without changing the current write position.\n void writeIntAt(U32 value, U8 bitCount, U32 bitPosition);\n\n /// Writes a signed integer value between -2^(bitCount-1) and 2^(bitCount-1) - 1.\n void writeSignedInt(S32 value, U8 bitCount);\n /// Reads a signed integer value between -2^(bitCount-1) and 2^(bitCount-1) - 1.\n S32 readSignedInt(U8 bitCount);\n\n /// Writes an unsigned integer value in the range rangeStart to rangeEnd inclusive.\n void writeRangedU32(U32 value, U32 rangeStart, U32 rangeEnd);\n /// Reads an unsigned integer value in the range rangeStart to rangeEnd inclusive.\n U32 readRangedU32(U32 rangeStart, U32 rangeEnd);\n\n /// Writes an enumeration value in the range of 0 ... enumRange - 1.\n void writeEnum(U32 enumValue, U32 enumRange);\n /// Reads an enumeration value in the range 0 ... enumRange - 1.\n U32 readEnum(U32 enumRange);\n\n /// Writes a float from 0 to 1 inclusive, using bitCount bits of precision.\n void writeFloat(F32 f, U8 bitCount);\n /// Reads a float from 0 to 1 inclusive, using bitCount bits of precision.\n F32 readFloat(U8 bitCount);\n\n /// Writes a signed float from -1 to 1 inclusive, using bitCount bits of precision.\n void writeSignedFloat(F32 f, U8 bitCount);\n /// Reads a signed float from -1 to 1 inclusive, using bitCount bits of precision.\n F32 readSignedFloat(U8 bitCount);\n\n /// Writes an object's class ID, given its class type and class group.\n void writeClassId(U32 classId, U32 classType, U32 classGroup);\n /// Reads a class ID for an object, given a class type and class group. Returns -1 if the class type is out of range\n U32 readClassId(U32 classType, U32 classGroup);\n\n /// Writes a normalized vector into the stream, using bitCount bits for the precision of angles phi and theta.\n void writeNormalVector(const Point3f &vec, U8 bitCount);\n /// Reads a normalized vector from the stream, using bitCount bits for the precision of angles phi and theta.\n void readNormalVector(Point3f *vec, U8 bitCount);\n\n /// Uses the same method as in writeNormalVector to reduce the precision of a normal vector\n /// to determine what will be read from the stream.\n static Point3f dumbDownNormal(const Point3f& vec, U8 bitCount);\n\n /// Writes a normalized vector by writing a z value and theta angle.\n void writeNormalVector(const Point3f& vec, U8 angleBitCount, U8 zBitCount);\n /// Reads a normalized vector by reading a z value and theta angle.\n void readNormalVector(Point3f *vec, U8 angleBitCount, U8 zBitCount);\n\n /// Sets a reference point for subsequent compressed point writing.\n void setPointCompression(const Point3f &p);\n /// Disables compression of point.\n void clearPointCompression();\n /// Writes a point into the stream, to a precision denoted by scale.\n void writePointCompressed(const Point3f &p, F32 scale);\n /// Reads a compressed point from the stream, to a precision denoted by scale.\n void readPointCompressed(Point3f *p, F32 scale);\n\n /// Writes bitCount bits into the stream from bitPtr.\n bool writeBits(U32 bitCount, const void *bitPtr);\n /// Reads bitCount bits from the stream into bitPtr.\n bool readBits(U32 bitCount, void *bitPtr);\n\n /// Writes a ByteBuffer into the stream. The ByteBuffer can be no larger than 1024 bytes in size.\n bool write(const ByteBuffer *theBuffer);\n\n /// Reads a ByteBuffer in from the stream.\n bool read(ByteBuffer *theBuffer);\n\n /// Writes a single boolean flag (bit) into the stream, and returns the boolean that was written.\n ///\n /// This is set up so you can do...\n ///\n /// @code\n /// if(stream->writeFlag(foo == bar))\n /// {\n /// ... write other stuff ...\n /// }\n /// @endcode\n bool writeFlag(bool val);\n\n /// Reads a single bit from the stream.\n ///\n /// This is set up so you can do...\n ///\n /// @code\n /// if(stream->readFlag())\n /// {\n /// ... read other stuff ...\n /// }\n /// @endcode\n bool readFlag();\n\n bool write(bool value) { writeFlag(value); return !error; }\n bool read(bool *value) { *value = readFlag(); return !error; }\n\n /// Writes a huffman compressed string into the stream.\n void writeString(const char *stringBuf, U8 maxLen=255);\n /// Reads a huffman compressed string from the stream.\n void readString(char stringBuf[256]);\n\n /// Writes a string table entry into the stream\n void writeStringTableEntry(const StringTableEntry &ste);\n\n /// Reads a string table entry from the stream\n void readStringTableEntry(StringTableEntry *ste);\n\n /// Writes byte data into the stream.\n bool write(const U32 in_numBytes, const void* in_pBuffer);\n /// Reads byte data from the stream.\n bool read(const U32 in_numBytes, void* out_pBuffer);\n\n /// @name Various types that the BitStream can read and write...\n /// @{\n\n ///\n DeclareTemplatizedReadWrite(U8);\n DeclareTemplatizedReadWrite(S8);\n DeclareTemplatizedReadWrite(U16);\n DeclareTemplatizedReadWrite(S16);\n DeclareTemplatizedReadWrite(U32);\n DeclareTemplatizedReadWrite(S32);\n DeclareTemplatizedReadWrite(S64);\n DeclareTemplatizedReadWrite(U64);\n DeclareTemplatizedReadWrite(F32);\n DeclareTemplatizedReadWrite(F64);\n\n /// @}\n\n /// Sets the bit at position bitCount to the value of set\n bool setBit(U32 bitCount, bool set);\n /// Tests the value of the bit at position bitCount.\n bool testBit(U32 bitCount);\n\n /// Returns whether the BitStream writing has exceeded the write target size.\n bool isFull() { return bitNum > (getBufferSize() << 3); }\n /// Returns whether the stream has generated an error condition due to reading or writing past the end of the buffer.\n bool isValid() { return !error; }\n\n /// Hashes the BitStream, writing the hash digest into the end of the buffer, and then encrypts with the given cipher\n void hashAndEncrypt(U32 hashDigestSize, U32 encryptStartOffset, SymmetricCipher *theCipher);\n\n /// Decrypts the BitStream, then checks the hash digest at the end of the buffer to validate the contents\n bool decryptAndCheckHash(U32 hashDigestSize, U32 decryptStartOffset, SymmetricCipher *theCipher);\n};\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\n\n\ninline U32 BitStream::getBytePosition() const\n{\n return (bitNum + 7) >> 3;\n}\n\ninline U32 BitStream::getBitPosition() const\n{\n return bitNum;\n}\n\ninline void BitStream::setBytePosition(const U32 newPosition)\n{\n bitNum = newPosition << 3;\n}\n\ninline void BitStream::setBitPosition(const U32 newBitPosition)\n{\n bitNum = newBitPosition;\n}\n\ninline void BitStream::advanceBitPosition(const S32 numBits)\n{\n setBitPosition(getBitPosition() + numBits);\n}\n\ninline void BitStream::zeroToByteBoundary()\n{\n if(bitNum & 0x7)\n writeInt(0, 8 - (bitNum & 0x7));\n}\n\ninline bool BitStream::write(const U32 in_numBytes, const void* in_pBuffer)\n{\n return writeBits(in_numBytes << 3, in_pBuffer);\n}\n\ninline bool BitStream::read(const U32 in_numBytes, void* out_pBuffer)\n{\n return readBits(in_numBytes << 3, out_pBuffer);\n}\n\ninline bool BitStream::readFlag()\n{\n if(bitNum > maxReadBitNum)\n {\n error = true;\n TNLAssert(false, \"Out of range read\");\n return false;\n\n }\n S32 mask = 1 << (bitNum & 0x7);\n bool ret = (*(getBuffer() + (bitNum >> 3)) & mask) != 0;\n bitNum++;\n return ret;\n}\n\ninline void BitStream::writeIntAt(U32 value, U8 bitCount, U32 bitPosition)\n{\n U32 curPos = getBitPosition();\n setBitPosition(bitPosition);\n writeInt(value, bitCount);\n setBitPosition(curPos);\n}\n\ninline void BitStream::writeRangedU32(U32 value, U32 rangeStart, U32 rangeEnd)\n{\n TNLAssert(value >= rangeStart && value <= rangeEnd, \"Out of bounds value!\");\n TNLAssert(rangeEnd >= rangeStart, \"error, end of range less than start\");\n\n U32 rangeSize = rangeEnd - rangeStart + 1;\n U32 rangeBits = getNextBinLog2(rangeSize);\n\n writeInt(S32(value - rangeStart), S32(rangeBits));\n}\n\ninline U32 BitStream::readRangedU32(U32 rangeStart, U32 rangeEnd)\n{\n TNLAssert(rangeEnd >= rangeStart, \"error, end of range less than start\");\n\n U32 rangeSize = rangeEnd - rangeStart + 1;\n U32 rangeBits = getNextBinLog2(rangeSize);\n\n U32 val = U32(readInt(S32(rangeBits)));\n return val + rangeStart;\n}\n\ninline void BitStream::writeEnum(U32 enumValue, U32 enumRange)\n{\n writeInt(enumValue, getNextBinLog2(enumRange));\n}\n\ninline U32 BitStream::readEnum(U32 enumRange)\n{\n return U32(readInt(getNextBinLog2(enumRange)));\n}\n\n/// PacketStream provides a network interface to the BitStream for easy construction of data packets.\nclass PacketStream : public BitStream\n{\n typedef BitStream Parent;\n U8 buffer[MaxPacketDataSize]; ///< internal buffer for packet data, sized to the maximum UDP packet size.\npublic:\n /// Constructor assigns the internal buffer to the BitStream.\n PacketStream(U32 targetPacketSize = MaxPacketDataSize) : BitStream(buffer, targetPacketSize, MaxPacketDataSize) {}\n /// Sends this packet to the specified address through the specified socket.\n NetError sendto(Socket &outgoingSocket, const Address &theAddress);\n /// Reads a packet into the stream from the specified socket.\n NetError recvfrom(Socket &incomingSocket, Address *recvAddress);\n};\n\n\n};\n#endif //_TNL_BITSTREAM_H_\n#ifndef __P_CLOTH_H__\r\n#define __P_CLOTH_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n\r\n\r\n\r\n/** \\addtogroup Cloth\r\n@{\r\n*/\r\n\r\n\r\n\r\n/**\r\nbrief2 Class for clothes.\r\n*/\r\nclass MODULE_API pCloth\r\n{\r\npublic:\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tvoid releaseReceiveBuffers();\r\n\tvoid allocateClothReceiveBuffers(int numVertices, int numTriangles);\r\n\t\r\n\tCK_ID getEntityID() const { return mEntityID; }\r\n\tvoid setEntityID(CK_ID val) { mEntityID = val; }\r\n\r\n\tNxCloth * getCloth() const { return mCloth; }\r\n\tvoid setCloth(NxCloth * val) { mCloth = val; }\r\n\r\n\tpCloth();\r\n\tvirtual ~pCloth();\r\n\r\n\tNxMeshData * getReceiveBuffers() const { return mReceiveBuffers; }\r\n\tvoid setReceiveBuffers(NxMeshData * val) { mReceiveBuffers = val; }\r\n\r\n\tbool cookMesh(NxClothMeshDesc* desc);\r\n\r\n\tvoid releaseMeshDescBuffers(const NxClothMeshDesc* desc);\r\n\tbool generateMeshDesc(pClothDesc cDesc,NxClothMeshDesc *desc, CKMesh*mesh);\r\n\r\n\tpWorld * getWorld() const { return mWorld; }\r\n\tvoid setWorld(pWorld * val) { mWorld = val; }\r\n\r\n\tNxClothMesh * getClothMesh() const { return mClothMesh; }\r\n\tvoid setClothMesh(NxClothMesh * val) { mClothMesh = val; }\r\n\r\n\tvoid updateVirtoolsMesh();\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\t/**\r\n\t\\brief Sets the cloth bending stiffness in the range from 0 to 1.\r\n\r\n\t\\param[in] stiffness The stiffness of this cloth.\r\n\t@see pClothDesc.bendingStiffness getBendingStiffness()\r\n\t*/\r\n\tvoid setBendingStiffness(float stiffness);\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth bending stiffness.\r\n\r\n\t\\return Bending stiffness of cloth.\r\n\t@see pClothDesc.bendingStiffness setBendingStiffness()\r\n\t*/\r\n\tfloat getBendingStiffness() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth stretching stiffness in the range from 0 to 1.\r\n\r\n\tNote: The stretching stiffness must be larger than 0.\r\n\r\n\t\\param[in] stiffness Stiffness of cloth.\r\n\t@see pClothDesc.stretchingStiffness getStretchingStiffness()\r\n\t*/\r\n\tvoid setStretchingStiffness(float stiffness);\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth stretching stiffness.\r\n\r\n\t\\return stretching stiffness of cloth.\r\n\r\n\t@see pClothDesc.stretchingStiffness setStretchingStiffness()\r\n\t*/\r\n\tfloat getStretchingStiffness() const;\r\n\r\n\t/**\r\n\t\\brief Sets the damping coefficient in the range from 0 to 1.\r\n\r\n\t\\param[in] dampingCoefficient damping coefficient of cloth.\r\n\t@see pClothDesc.dampingCoefficient getDampingCoefficient()\r\n\t*/\r\n\tvoid setDampingCoefficient(float dampingCoefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves the damping coefficient.\r\n\r\n\t\\return damping coefficient of cloth.\r\n\t@see pClothDesc.dampingCoefficient setDampingCoefficient()\r\n\t*/\r\n\tfloat getDampingCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth friction coefficient in the range from 0 to 1.\r\n\r\n\t\\param[in] friction The friction of the cloth.\r\n\t@see pClothDesc.friction getFriction()\r\n\t*/\r\n\tvoid setFriction(float friction);\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth friction coefficient.\r\n\r\n\t\\return Friction coefficient of cloth.\r\n\t@see pClothDesc.friction setFriction()\r\n\t*/\r\n\tfloat getFriction() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth pressure coefficient (must be non negative).\r\n\r\n\t\\param[in] pressure The pressure applied to the cloth.\r\n\r\n\t@see pClothDesc.pressure getPressure()\r\n\t*/\r\n\tvoid setPressure(float pressure);\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth pressure coefficient.\r\n\r\n\t\\return Pressure of cloth.\r\n\t@see pClothDesc.pressure setPressure()\r\n\t*/\r\n\tfloat getPressure() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth tear factor (must be larger than one).\r\n\r\n\t\\param[in] factor The tear factor for the cloth\r\n\r\n\t@see pClothDesc.tearFactor getTearFactor()\r\n\t*/\r\n\tvoid setTearFactor(float factor);\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth tear factor.\r\n\r\n\t\\return tear factor of cloth.\r\n\t@see pClothDesc.tearFactor setTearFactor()\r\n\t*/\r\n\tfloat getTearFactor() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth attachment tear factor (must be larger than one).\r\n\r\n\t\\param[in] factor The attachment tear factor for the cloth\r\n\t@see pClothDesc.attachmentTearFactor getAttachmentTearFactor()\r\n\t*/\r\n\tvoid setAttachmentTearFactor(float factor);\r\n\r\n\t/**\r\n\t\\brief Retrieves the attachment cloth tear factor.\r\n\r\n\t\\return tear attachment factor of cloth.\r\n\t@see pClothDesc.attachmentTearFactor setAttachmentTearFactor()\r\n\t*/\r\n\tfloat getAttachmentTearFactor() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth thickness (must be positive).\r\n\r\n\t\\param[in] thickness The thickness of the cloth.\r\n\t@see pClothDesc.thickness getThickness()\r\n\t*/\r\n\tvoid setThickness(float thickness);\r\n\r\n\t/**\r\n\t\\brief Gets the cloth thickness.\r\n\r\n\t\\return thickness of cloth.\r\n\t@see pClothDesc.thickness setThickness()\r\n\t*/\r\n\tfloat getThickness() const;\r\n\r\n\t/**\r\n\t\\brief Gets the cloth density.\r\n\r\n\t\\return density of cloth.\r\n\t@see pClothDesc.density\r\n\t*/\r\n\tfloat getDensity() const;\r\n\r\n\t/**\r\n\t\\brief Gets the relative grid spacing for the broad phase.\r\n\tThe cloth is represented by a set of world aligned cubical cells in broad phase.\r\n\tThe size of these cells is determined by multiplying the length of the diagonal\r\n\tof the AABB of the initial cloth size with this constant.\r\n\r\n\t\\return relative grid spacing.\r\n\t@see pClothDesc.relativeGridSpacing\r\n\t*/\r\n\tfloat getRelativeGridSpacing() const;\r\n\r\n\t/**\r\n\t\\brief Retrieves the cloth solver iterations.\r\n\r\n\t\\return solver iterations of cloth.\r\n\t@see pClothDesc.solverIterations setSolverIterations()\r\n\t*/\r\n\tint getSolverIterations() const;\r\n\r\n\t/**\r\n\t\\brief Sets the cloth solver iterations.\r\n\r\n\t\\param[in] iterations The new solver iteration count for the cloth.\r\n\t@see pClothDesc.solverIterations getSolverIterations()\r\n\t*/\r\n\tvoid setSolverIterations(int iterations);\r\n\r\n\t/**\r\n\t\\brief Returns a world space AABB enclosing all cloth points.\r\n\r\n\t\\param[out] bounds Retrieves the world space bounds.\r\n\t@see NxBounds3\r\n\t*/\r\n\tvoid getWorldBounds(VxBbox & bounds) const;\r\n\r\n\t/**\r\n\t\\brief Attaches the cloth to a shape. All cloth points currently inside the shape are attached.\r\n\r\n\t\\note This method only works with primitive and convex shapes. Since the inside of a general \r\n\ttriangle mesh is not clearly defined.\r\n\r\n\t\\param[in] shape Shape to which the cloth should be attached to.\r\n\t\\param[in] attachmentFlags One or two way interaction, tearable or non-tearable\r\n\t@see NxClothAttachmentFlag freeVertex() attachToCollidingShapes()\r\n\t*/\r\n\tvoid attachToShape(CKBeObject *shape, int attachmentFlags);\r\n\r\n\t/**\r\n\t\\brief Attaches the cloth to all shapes, currently colliding. \r\n\r\n\t\\note This method only works with primitive and convex shapes. Since the inside of a general \r\n\ttriangle mesh is not clearly defined.\r\n\r\n\t\\param[in] attachmentFlags One or two way interaction, tearable or non-tearable\r\n\t@see NxClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex()\r\n\t*/\r\n\tvoid attachToCollidingShapes(int attachmentFlags);\r\n\r\n\t/**\r\n\t\\brief Detaches the cloth from a shape it has been attached to before. \r\n\r\n\tIf the cloth has not been attached to the shape before, the call has no effect.\r\n\r\n\t\\param[in] shape Shape from which the cloth should be detached.\r\n\t@see NxClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex() attachToShape()\r\n\t*/\r\n\tvoid detachFromShape(CKBeObject *shape);\r\n\r\n\t/**\r\n\t\\brief Attaches a cloth vertex to a local position within a shape.\r\n\r\n\t\\param[in] vertexId Index of the vertex to attach.\r\n\t\\param[in] shape Shape to attach the vertex to.\r\n\t\\param[in] localPos The position relative to the pose of the shape.\r\n\t\\param[in] attachmentFlags One or two way interaction, tearable or non-tearable\r\n\r\n\tPlatform:\r\n\t\\li PC SW: Yes\r\n\t\\li PPU : Yes\r\n\t\\li PS3 : Yes\r\n\t\\li XB360: Yes\r\n\r\n\t@see NxShape freeVertex() NxClothAttachmentFlag attachToShape()\r\n\t*/\r\n\tvoid attachVertexToShape(int vertexId, CKBeObject *shape, const VxVector &localPos, int attachmentFlags);\r\n\r\n\t/**\r\n\t\\brief Attaches a cloth vertex to a position in world space.\r\n\r\n\t\\param[in] vertexId Index of the vertex to attach.\r\n\t\\param[in] pos The position in world space.\r\n\t@see pClothAttachmentFlag pClothDesc.attachmentTearFactor pClothDesc.attachmentResponseCoefficient freeVertex() attachToShape()\r\n\t*/\r\n\tvoid attachVertexToGlobalPosition(const int vertexId, const VxVector &pos);\r\n\r\n\t/**\r\n\t\\brief Frees a previously attached cloth point.\r\n\r\n\t\\param[in] vertexId Index of the vertex to free.\r\n\t@see attachVertexToGlobalPosition() attachVertexToShape() detachFromShape()\r\n\t*/\r\n\tvoid freeVertex(const int vertexId);\r\n\r\n\t/**\r\n\t\\brief Changes the weight of a vertex in the cloth solver for a period of time.\r\n\r\n\tIf this method is called for some vertex, the cloth solver will, during a time\r\n\tperiod of length expirationTime, assign a different weight to the vertex\r\n\twhile internal cloth constraints (i.e. bending & stretching) are being resolved.\r\n\r\n\tWith a high dominanceWeight, the modified vertex will force neighboring vertices\r\n\tto strongly accommodate their positions while its own is kept fairly constant. \r\n\tThe reverse holds for smaller dominanceWeights. \r\n\r\n\tUsing a dominanceWeight of +infinity has a similar effect as temporarily attaching \r\n\tthe vertex to a global position. However, unlike using attachments, the velocity \r\n\tof the vertex is kept intact when using this method.\r\n\r\n\t\\note The current implementation will not support the full range of dominanceWeights.\r\n\tAll dominanceWeights > 0.0 are treated equally as being +infinity.\r\n\r\n\t\\note An expiration time of 0.0 is legal and will result in dominance being\r\n\tapplied throughout one substep before being discarded immediately.\r\n\r\n\t\\note Having a large number of vertices dominant at once may result in a performance penalty.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\t\\param[in] expirationTime Time period where dominance will be active for this vertex.\r\n\t\\param[in] dominanceWeight Dominance weight for this vertex.\r\n\r\n\t@see attachVertexToGlobalPosition()\r\n\t*/\r\n\tvoid dominateVertex(int vertexId, float expirationTime, float dominanceWeight);\r\n\r\n\t/**\r\n\t\\brief Return the attachment status of the given vertex.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\r\n\t@see getVertexAttachmentShape() getVertexAttachmentPosition()\r\n\t*/\r\n\txU16 getVertexAttachmentStatus(int vertexId) const;\r\n\r\n\t/**\r\n\t\\brief Returns the pointer to an attached shape pointer of the given vertex.\r\n\r\n\tIf the vertex is not attached or attached to a global position, NULL is returned.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\r\n\t@see getVertexAttachmentStatus() getVertexAttachmentPosition()\r\n\t*/\r\n\tNxShape* getVertexAttachmentShape(int vertexId) const;\r\n\r\n\t/**\r\n\t\\brief Returns the attachment position of the given vertex.\r\n\r\n\tIf the vertex is attached to shape, the position local to the shape's pose is returned.\r\n\tIf the vertex is not attached, the return value is undefined.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\t@see getVertexAttachmentStatus() getVertexAttachmentShape()\r\n\t*/\r\n\tVxVector getVertexAttachmentPosition(int vertexId) const;\r\n\r\n\t/**\r\n\t\\brief Attaches the cloth to an actor. \r\n\r\n\t\\note Call this function only once right after the cloth is created.\r\n\tTurning cloth into metal and vice versa during the simulation is not recommended.\r\n\r\n\t\\note This feature is well suited for volumetric objects like barrels. \r\n\tIt cannot handle two dimensional flat pieces well.\r\n\r\n\tAfter this call, the cloth is infinitely stiff between collisions and simply \r\n\tmoves with the actor. At impacts with an impact impulse greater than impulseThreshold, \r\n\tthe cloth is plastically deformed. Thus, a cloth with a core behaves like a piece of metal.\r\n\r\n\tThe core actor's geometry is adjusted automatically. Its size also depends on the \r\n\tcloth thickness. Thus, it is recommended to choose small values for the thickness.\r\n\tAt impacts, colliding objects are moved closer to the cloth by the value provided in \r\n\tpenetrationDepth which causes a more dramatic collision result.\r\n\r\n\tThe core actor must have at least one shape, and currently supported shapes are \r\n\tspheres, capsules, boxes and compounds of spheres.\r\n\tIt is recommended to specify the density rather than the mass of the core body. \r\n\tThis way the mass and inertia tensor are updated when the core deforms.\r\n\r\n\tThe maximal deviation of cloth particles from their initial positions\r\n\t(modulo the global rigid body transforms translation and rotation) can be\r\n\tspecified via the parameter maxDeformationDistance. Setting this parameter to\r\n\tzero means that the deformation is not limited. \r\n\r\n\t\\param actor The core actor to attach the cloth to.\r\n\t\\param impulseThreshold Threshold for when deformation is allowed.\r\n\t\\param penetrationDepth Amount by which colliding objects are brought closer to the cloth.\r\n\t\\param maxDeformationDistance Maximum deviation of cloth particles from initial position.\r\n\r\n\t*/\r\n\tvoid attachToCore(CK3dEntity *body, float impulseThreshold, float penetrationDepth, float maxDeformationDistance);\r\n\r\n\t/**\r\n\t\\brief Tears the cloth at a given vertex. \r\n\r\n\tFirst the vertex is duplicated. The triangles on one side of the split plane keep \r\n\tthe original vertex. For all triangles on the opposite side the original vertex is \r\n\treplaced by the new one. The split plane is defined by the world location of the \r\n\tvertex and the normal provided by the user.\r\n\r\n\tNote: TearVertex performs a user defined vertex split in contrast to an automatic split\r\n\tthat is performed when the flag NX_CLF_TEARABLE is set. Therefore, tearVertex works \r\n\teven if NX_CLF_TEARABLE is not set in pClothDesc.flags.\r\n\r\n\tNote: For tearVertex to work, the clothMesh has to be cooked with the flag\r\n\tNX_CLOTH_MESH_TEARABLE set in NxClothMeshDesc.flags.\r\n\r\n\t\\param[in] vertexId Index of the vertex to tear.\r\n\t\\param[in] normal The normal of the split plane.\r\n\t\\return true if the split had an effect (i.e. there were triangles on both sides of the split plane)\r\n\r\n\t@see NxClothFlag, NxClothMeshFlags, pClothDesc.flags NxSimpleTriangleMesh.flags\r\n\r\n\tPlatform:\r\n\t\\li PC SW: Yes\r\n\t\\li PPU : Yes\r\n\t\\li PS3 : Yes\r\n\t\\li XB360: Yes\r\n\t*/\r\n\tbool tearVertex(const int vertexId, const VxVector &normal);\r\n\r\n\t/**\r\n\t\\brief Executes a raycast against the cloth.\r\n\r\n\t\\param[in] worldRay The ray in world space.\r\n\t\\param[out] hit The hit position.\r\n\t\\param[out] vertexId Index to the nearest vertex hit by the raycast.\r\n\r\n\t\\return true if the ray hits the cloth.\r\n\t*/\r\n\t//BOOL raycast(const NxRay& worldRay, VxVector &hit, int &vertexId);\r\n\r\n\t/**\r\n\t\\brief Sets which collision group this cloth is part of.\r\n\r\n\t\\param[in] collisionGroup The collision group for this cloth.\r\n\r\n\t@see NxCollisionGroup\r\n\t*/\r\n\tvoid setGroup(int collisionGroup);\r\n\r\n\t/**\r\n\t\\brief Retrieves the value set with #setGroup().\r\n\r\n\t\\return The collision group this cloth belongs to.\r\n\r\n\t@see NxCollisionGroup\r\n\t*/\r\n\tint getGroup() const;\r\n\r\n\t/**\r\n\t\\brief Sets 128-bit mask used for collision filtering.\r\n\r\n\t\\param[in] groupsMask The group mask to set for the cloth.\r\n\t@see getGroupsMask() NxGroupsMask\r\n\t*/\r\n\tvoid setGroupsMask(const pGroupsMask& groupsMask);\r\n\r\n\t/**\r\n\t\\brief Sets 128-bit mask used for collision filtering.\r\n\r\n\t\\return The group mask for the cloth.\r\n\r\n\t@see setGroupsMask() NxGroupsMask\r\n\t*/\r\n\tconst pGroupsMask getGroupsMask() const;\r\n\r\n\r\n\t/**\r\n\t\\brief Sets the valid bounds of the cloth in world space.\r\n\r\n\tIf the flag NX_CLF_VALIDBOUNDS is set, these bounds defines the volume\r\n\toutside of which cloth particle are automatically removed from the simulation. \r\n\r\n\t\\param[in] validBounds The valid bounds.\r\n\r\n\t@see pClothDesc.validBounds getValidBounds() NxBounds3\r\n\t*/\r\n\tvoid setValidBounds(const VxBbox& validBounds);\r\n\r\n\t/**\r\n\t\\brief Returns the valid bounds of the cloth in world space.\r\n\r\n\t\\param[out] validBounds The valid bounds.\r\n\r\n\r\n\t@see pClothDesc.validBounds setValidBounds() NxBounds3\r\n\t*/\r\n\tvoid getValidBounds(NxBounds3& validBounds) const;\r\n\r\n\t/**\r\n\t\\brief Sets the position of a particular vertex of the cloth.\r\n\r\n\t\\param[in] position New position of the vertex.\r\n\t\\param[in] vertexId Index of the vertex.\r\n\r\n\t@see getPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles()\r\n\t*/\r\n\tvoid setPosition(const VxVector& position, int vertexId);\r\n\r\n\t/**\r\n\t\\brief Sets the positions of the cloth.\r\n\r\n\tThe user must supply a buffer containing all positions (i.e same number of elements as number of particles).\r\n\r\n\t\\param[in] buffer The user supplied buffer containing all positions for the cloth.\r\n\t\\param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of VxVector.\r\n\t@see getPositions() setVelocities() getVelocities() getNumberOfParticles()\r\n\t*/\r\n\tvoid setPositions(void* buffer, int byteStride = sizeof(VxVector));\r\n\r\n\t/**\r\n\t\\brief Gets the position of a particular vertex of the cloth.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\t@see setPosition() setPositions() getPositions() setVelocity() getVelocity() getNumberOfParticles()\r\n\t*/\r\n\tVxVector getPosition(int vertexId) const;\r\n\r\n\t/**\r\n\t\\brief Gets the positions of the cloth.\r\n\r\n\tThe user must supply a buffer large enough to hold all positions (i.e same number of elements as number of particles).\r\n\r\n\t\\param[in] buffer The user supplied buffer to hold all positions of the cloth.\r\n\t\\param[in] byteStride The stride in bytes between the position vectors in the buffer. Default is size of VxVector.\r\n\t@see setPositions() setVelocities() getVelocities() getNumberOfParticles()\r\n\t*/\r\n\tvoid getPositions(void* buffer, int byteStride = sizeof(VxVector));\r\n\r\n\t/**\r\n\t\\brief Sets the velocity of a particular vertex of the cloth.\r\n\r\n\t\\param[in] position New velocity of the vertex.\r\n\t\\param[in] vertexId Index of the vertex.\r\n\t@see setPosition() getPosition() getVelocity() setVelocities() getVelocities() getNumberOfParticles()\r\n\t*/\r\n\tvoid setVelocity(const VxVector& velocity, int vertexId);\r\n\r\n\t/**\r\n\t\\brief Sets the velocities of the cloth.\r\n\r\n\tThe user must supply a buffer containing all velocities (i.e same number of elements as number of particles).\r\n\r\n\t\\param[in] buffer The user supplied buffer containing all velocities for the cloth.\r\n\t\\param[in] byteStride The stride in bytes between the velocity vectors in the buffer. Default is size of VxVector.\r\n\t@see getVelocities() setPositions() getPositions() getNumberOfParticles()\r\n\t*/\r\n\tvoid setVelocities(void* buffer, int byteStride = sizeof(VxVector));\r\n\r\n\t/**\r\n\t\\brief Gets the velocity of a particular vertex of the cloth.\r\n\r\n\t\\param[in] vertexId Index of the vertex.\r\n\t@see setPosition() getPosition() setVelocity() setVelocities() getVelocities() getNumberOfParticles()\r\n\t*/\r\n\tVxVector getVelocity(int vertexId) const;\r\n\r\n\r\n\t/**\r\n\t\\brief Sets the collision response coefficient.\r\n\r\n\t\\param[in] coefficient The collision response coefficient (0 or greater).\r\n\t@see pClothDesc.collisionResponseCoefficient getCollisionResponseCoefficient()\r\n\t*/\r\n\tvoid setCollisionResponseCoefficient(float coefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves the collision response coefficient.\r\n\r\n\t\\return The collision response coefficient.\r\n\r\n\t@see pClothDesc.collisionResponseCoefficient setCollisionResponseCoefficient()\r\n\t*/\r\n\tfloat getCollisionResponseCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Sets the attachment response coefficient\r\n\r\n\t\\param[in] coefficient The attachment response coefficient in the range from 0 to 1.\r\n\t@see pClothDesc.attachmentResponseCoefficient getAttachmentResponseCoefficient()\r\n\t*/\r\n\tvoid setAttachmentResponseCoefficient(float coefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves the attachment response coefficient\r\n\r\n\t\\return The attachment response coefficient.\r\n\r\n\t@see pClothDesc.attachmentResponseCoefficient setAttachmentResponseCoefficient()\r\n\t*/\r\n\tfloat getAttachmentResponseCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Sets the response coefficient for collisions from fluids to this cloth\r\n\r\n\t\\param[in] coefficient The response coefficient \r\n\t@see pClothDesc.fromFluidResponseCoefficient getFromFluidResponseCoefficient()\r\n\t*/\r\n\tvoid setFromFluidResponseCoefficient(float coefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves response coefficient for collisions from fluids to this cloth\r\n\r\n\t\\return The response coefficient.\r\n\t@see pClothDesc.fromFluidResponseCoefficient setFromFluidResponseCoefficient()\r\n\t*/\r\n\tfloat getFromFluidResponseCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Sets the response coefficient for collisions from this cloth to fluids\r\n\r\n\t\\param[in] coefficient The response coefficient \r\n\r\n\t@see pClothDesc.toFluidResponseCoefficient getToFluidResponseCoefficient()\r\n\t*/\r\n\tvoid setToFluidResponseCoefficient(float coefficient);\r\n\r\n\t/**\r\n\t\\brief Retrieves response coefficient for collisions from this cloth to fluids\r\n\r\n\t\\return The response coefficient.\r\n\r\n\t@see pClothDesc.toFluidResponseCoefficient setToFluidResponseCoefficient()\r\n\t*/\r\n\tfloat getToFluidResponseCoefficient() const;\r\n\r\n\t/**\r\n\t\\brief Sets an external acceleration which affects all non attached particles of the cloth\r\n\r\n\t\\param[in] acceleration The acceleration vector (unit length / s^2)\r\n\t@see pClothDesc.externalAcceleration getExternalAcceleration()\r\n\t*/\r\n\tvoid setExternalAcceleration(VxVector acceleration);\r\n\r\n\t/**\r\n\t\\brief Retrieves the external acceleration which affects all non attached particles of the cloth\r\n\r\n\t\\return The acceleration vector (unit length / s^2)\r\n\r\n\t@see pClothDesc.externalAcceleration setExternalAcceleration()\r\n\t*/\r\n\tVxVector getExternalAcceleration() const;\r\n\r\n\t/**\r\n\t\\brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame \r\n\tof the attached actor. \r\n\r\n\tThis feature is useful when the cloth is attached to a fast moving character.\r\n\tIn that case the cloth adheres to the shape it is attached to while only \r\n\tvelocities below the parameter minAdhereVelocity are used for secondary effects.\r\n\r\n\t\\param[in] velocity The minimal velocity for cloth to adhere (unit length / s)\r\n\r\n\t@see pClothDesc.minAdhereVelocity getMinAdhereVelocity()\r\n\t*/\r\n\tvoid setMinAdhereVelocity(float velocity);\r\n\r\n\t/**\r\n\t\\brief If the NX_CLF_ADHERE flag is set the cloth moves partially in the frame \r\n\tof the attached actor. \r\n\r\n\tThis feature is useful when the cloth is attached to a fast moving character.\r\n\tIn that case the cloth adheres to the shape it is attached to while only \r\n\tvelocities below the parameter minAdhereVelocity are used for secondary effects.\r\n\r\n\t\\return Returns the minimal velocity for cloth to adhere (unit length / s)\r\n\t@see pClothDesc.minAdhereVelocity setMinAdhereVelocity()\r\n\t*/\r\n\tfloat getMinAdhereVelocity() const;\r\n\r\n\t/**\r\n\t\\brief Sets an acceleration acting normal to the cloth surface at each vertex.\r\n\r\n\t\\param[in] acceleration The acceleration vector (unit length / s^2)\r\n\t@see pClothDesc.windAcceleration getWindAcceleration()\r\n\t*/\r\n\tvoid setWindAcceleration(VxVector acceleration);\r\n\r\n\t/**\r\n\t\\brief Retrieves the acceleration acting normal to the cloth surface at each vertex.\r\n\r\n\t\\return The acceleration vector (unit length / s^2)\r\n\t@see pClothDesc.windAcceleration setWindAcceleration()\r\n\t*/\r\n\tVxVector getWindAcceleration() const;\r\n\r\n\t/**\r\n\t\\brief Returns true if this cloth is sleeping.\r\n\r\n\tWhen a cloth does not move for a period of time, it is no longer simulated in order to save time. This state\r\n\tis called sleeping. However, because the object automatically wakes up when it is either touched by an awake object,\r\n\tor one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user.\r\n\r\n\tIf a cloth is asleep after the call to NxScene::fetchResults() returns, it is guaranteed that the position of the cloth \r\n\tvertices was not changed. You can use this information to avoid updating dependent objects.\r\n\r\n\t\\return True if the cloth is sleeping.\r\n\t@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep()\r\n\t*/\r\n\tbool isSleeping() const;\r\n\r\n\t/**\r\n\t\\brief Returns the linear velocity below which a cloth may go to sleep.\r\n\r\n\tA cloth whose linear velocity is above this threshold will not be put to sleep.\r\n\r\n\t@see isSleeping\r\n\r\n\t\\return The threshold linear velocity for sleeping.\r\n\t@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep() setSleepLinearVelocity()\r\n\t*/\r\n\tfloat getSleepLinearVelocity() const;\r\n\r\n\t/**\r\n\t\\brief Sets the linear velocity below which a cloth may go to sleep.\r\n\r\n\tA cloth whose linear velocity is above this threshold will not be put to sleep.\r\n\r\n\tIf the threshold value is negative,\tthe velocity threshold is set using the NxPhysicsSDK's \r\n\tNX_DEFAULT_SLEEP_LIN_VEL_SQUARED parameter.\r\n\r\n\t\\param[in] threshold Linear velocity below which a cloth may sleep. Range: (0,inf]\r\n\t@see isSleeping() getSleepLinearVelocity() wakeUp() putToSleep()\r\n\t*/\r\n\tvoid setSleepLinearVelocity(float threshold);\r\n\r\n\t/**\r\n\t\\brief Wakes up the cloth if it is sleeping. \r\n\r\n\tThe wakeCounterValue determines how long until the cloth is put to sleep, a value of zero means \r\n\tthat the cloth is sleeping. wakeUp(0) is equivalent to NxCloth::putToSleep().\r\n\r\n\t\\param[in] wakeCounterValue New sleep counter value. Range: [0,inf]\r\n\t@see isSleeping() getSleepLinearVelocity() putToSleep()\r\n\t*/\r\n\tvoid wakeUp(float wakeCounterValue = pSLEEP_INTERVAL);\r\n\r\n\t/**\r\n\t\\brief Forces the cloth to sleep. \r\n\r\n\tThe cloth will fall asleep.\r\n\t@see isSleeping() getSleepLinearVelocity() wakeUp()\r\n\t*/\r\n\tvoid putToSleep();\r\n\r\n\t/**\r\n\t\\brief Sets the flags, a combination of the bits defined by the enum ::NxClothFlag.\r\n\r\n\t\\param[in] flags #NxClothFlag combination.\r\n\t@see pClothDesc.flags NxClothFlag getFlags()\r\n\t*/\r\n\tvoid setFlags(int flags);\r\n\r\n\t/**\r\n\t\\brief Retrieves the flags.\r\n\r\n\t\\return The cloth flags.\r\n\t@see pClothDesc.flags NxClothFlag setFlags()\r\n\t*/\r\n\tint getFlags() const;\r\n\r\n\t/**\r\n\t\\brief Sets a name string for the object that can be retrieved with getName().\r\n\r\n\tThis is for debugging and is not used by the SDK. The string is not copied by \r\n\tthe SDK, only the pointer is stored.\r\n\r\n\t\\param[in] name String to set the objects name to.\r\n\t@see getName()\r\n\t*/\r\n\tvoid setName(const char* name);\r\n\r\n\t/**\r\n\t\\brief Applies a force (or impulse) defined in the global coordinate frame, to a particular \r\n\tvertex of the cloth. \r\n\r\n\tBecause forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\t::NxForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] force Force/impulse to add, defined in the global frame. Range: force vector\r\n\t\\param[in] vertexId Number of the vertex to add the force at. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse \r\n\t(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange)\r\n\t@see ForceMode \r\n\t*/\r\n\tvoid addForceAtVertex(const VxVector& force, int vertexId, ForceMode mode = FM_Force);\r\n\r\n\t/**\r\n\t\\brief Applies a radial force (or impulse) at a particular position. All vertices\r\n\twithin radius will be affected with a quadratic drop-off. \r\n\r\n\tBecause forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\t::NxForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] position Position to apply force at.\r\n\t\\param[in] magnitude Magnitude of the force/impulse to apply.\r\n\t\\param[in] radius The sphere radius in which particles will be affected. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse \r\n\t(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange).\r\n\t@see ForceMode \r\n\t*/\r\n\tvoid addForceAtPos(const VxVector& position, float magnitude, float radius, ForceMode mode = FM_Force);\r\n\r\n\t/**\r\n\t\\brief Applies a directed force (or impulse) at a particular position. All vertices\r\n\twithin radius will be affected with a quadratic drop-off. \r\n\r\n\tBecause forces are reset at the end of every timestep, \r\n\tyou can maintain a total external force on an object by calling this once every frame.\r\n\r\n\t::NxForceMode determines if the force is to be conventional or impulsive.\r\n\r\n\t\\param[in] position Position to apply force at.\r\n\t\\param[in] force Force to apply.\r\n\t\\param[in] radius The sphere radius in which particles will be affected. Range: position vector\r\n\t\\param[in] mode The mode to use when applying the force/impulse \r\n\t(see #ForceMode, supported modes are FM_Force, FM_Impulse, FM_Acceleration, FM_VelocityChange).\r\n\t@see ForceMode \r\n\t*/\r\n\tvoid addDirectedForceAtPos(const VxVector& position, const VxVector& force, float radius, ForceMode mode = FM_Force);\r\n\r\n\t/**\r\n\t\\brief Finds triangles touching the input bounds.\r\n\r\n\t\\warning This method returns a pointer to an internal structure using the indices member. Hence the\r\n\tuser should use or copy the indices before calling any other API function.\r\n\r\n\t\\param[in] bounds Bounds to test against in world space. Range: See #NxBounds3\r\n\t\\param[out] nb Retrieves the number of triangle indices touching the AABB.\r\n\t\\param[out] indices Returns an array of touching triangle indices. \r\n\tThe triangle indices correspond to the triangles referenced to by pClothDesc.meshdata (#NxMeshData).\r\n\tTriangle i has the vertices 3i, 3i+1 and 3i+2 in the array NxMeshData.indicesBegin.\r\n\t\\return True if there is an overlap.\r\n\r\n\t@see NxBounds3 pClothDesc NxMeshData\r\n\t*/\r\n\tbool overlapAABBTriangles(const NxBounds3& bounds, int& nb, const int*& indices) const;\r\n\r\n\r\n\r\nprotected:\r\nprivate:\r\n\tNxMeshData *mReceiveBuffers;\r\n\t\r\n\tCK_ID mEntityID;\r\n\tNxCloth *mCloth;\r\n\tNxClothMesh *mClothMesh;\r\n\t\r\n\tpWorld *mWorld;\r\n};\r\n\r\n/** @} */\r\n\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2003/12/01\r\n\tfilename: \tH:\\XLANG PROJECTS\\BASE\\INCLUDES\\Dll_Tools.h\r\n\tfile path:\t H:\\XLANG PROJECTS\\BASE\\INCLUDES\r\n\tfile base:\t Dll_Tools\r\n\tfile ext:\t h\r\n\tauthor:\t\t\r\n\tpurpose:\trum DLL´eln\r\n*********************************************************************/\r\n\r\n\r\n\r\n#ifndef __Dll_Tools_h_\r\n#define __Dll_Tools_h_ \"$Id:$\"\r\n\r\n\r\n\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//ie:\r\n\t\t\t//\tthe fnc prototyp :\ttypedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);\r\n\t\t\t// the fill :\tDLL::DllFunc<_ShellExec_proto>_ShellExec(_T(\"shell32.dll\"),\"ShellExecute\");\r\n\r\n\t\t\ttemplate class DllFunc \r\n\t\t\t{\r\n\t\t\tpublic:\r\n\t\t\t\t\r\n\t\t\t\t\tDllFunc(const char* dllName, const char* fnName ,const bool logging = TRUE ) :\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\tdllHandle( LoadLibrary (dllName) ) , fn(0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t if (!dllHandle && logging)\r\n\t\t\t\t\t\t { \r\n\t\t\t\t\t\t\t //loggin @:\r\n\t\t\t\t\t\t\t return;\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t\t fn = ( T )GetProcAddress(dllHandle, fnName);\r\n\t\t\t\t\r\n\t\t\t\t\t\t if (!fn)\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];\r\n\t\t\t\t\t\t\t GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );\r\n\t\t\t\t\t\t\t // loggin @:\r\n\t\t\t\t\t\t\t sprintf ( logmsg , \"%s %s %s\" , modName , \"couldn´t get function with prototyp : \", typeid(fn).name() ) ;\r\n\t\t\t\t\t\t\t sprintf( _path , \"%s%s\", modName ,\".log\" )\t ;\r\n\t\t\t\t\t\t\t //loggin :\r\n\t\t\t\t\t\t\t return;\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t\t \r\n\t\t\t\t\t }\r\n\t\t\t\t\toperator T(){\r\n\t\t\t\t\t\treturn fn; \r\n\t\t\t\t\t}\r\n\t\t\tpublic:\r\n\t\t\t\t\tT fn;\r\n\t\t\t\t\tHMODULE dllHandle;\r\n\t\t\t\t\tvoid *ret;\r\n\t\t\t};\r\n\r\n\r\n\r\n\r\n#endif //__win32Tools_h_\r\n\t\t\t\t\t /*\r\nDLL::DynamicFn<_ShellExec_proto>_ShellExec(_T(\"shell32.dll\"),\"ShellExecuteA\");\r\n\t\t\r\n\t//\tDLL::DynamicFn_ShellExec(_T(\"shell32.dll\"),\"ShellExecuteA\");\r\n\t\t \r\n\t\treturn (*_ShellExec)(NULL,\"open\",\"www.gmx.net\",NULL,NULL, SW_MAXIMIZE);*/\r\n\r\n\r\n\t\t\t/*\r\n\t\t\t/********************************************************************\r\n\t\t\tcreated:\t2003/12/01\r\n\t\t\tfilename: \tH:\\XLANG PROJECTS\\BASE\\INCLUDES\\Dll_Tools.h\r\n\t\t\tfile path:\t H:\\XLANG PROJECTS\\BASE\\INCLUDES\r\n\t\t\tfile base:\t Dll_Tools\r\n\t\t\tfile ext:\t h\r\n\t\t\tauthor:\t\t\r\n\t\t\tpurpose:\trum DLL´eln\r\n\t\t\t*********************************************************************/\r\n\r\n\r\n\r\n#ifndef __Dll_Tools_h_\r\n#define __Dll_Tools_h_ \"$Id:$\"\r\n\r\n\r\n\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//ie:\r\n\t\t\t//\tthe fnc prototyp :\ttypedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);\r\n\t\t\t// the fill :\tDLL::DllFunc<_ShellExec_proto>_ShellExec(_T(\"shell32.dll\"),\"ShellExecute\");\r\n\r\n\t\t\ttemplate class DllFunc \r\n\t\t\t\t{\r\n\t\t\t\tpublic:\r\n\r\n\t\t\t\t\tDllFunc(const char* dllName, const char* fnName ,const bool logging = TRUE ) :\r\n\r\n\t\t\t\t\t dllHandle( LoadLibrary (dllName) ) , fn(0)\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t if (!dllHandle && logging)\r\n\t\t\t\t\t\t\t { \r\n\t\t\t\t\t\t\t char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];\r\n\t\t\t\t\t\t\t GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );\r\n\t\t\t\t\t\t\t sprintf ( logmsg , \"%s %s %s\" , modName , \"couldn´t find \", dllName ) ;\r\n\t\t\t\t\t\t\t sprintf( _path , \"%s%s\", modName ,\".log\" )\t ;\r\n\r\n\t\t\t\t\t\t\t return;\r\n\t\t\t\t\t\t\t }\r\n\t\t\t\t\t\t fn = ( T )GetProcAddress(dllHandle, fnName);\r\n\r\n\t\t\t\t\t\t if (!fn)\r\n\t\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\t char modName[_MAX_PATH],logmsg [400],_path[_MAX_PATH];\r\n\t\t\t\t\t\t\t GetModuleFileName( GetModuleHandle(NULL) ,modName,_MAX_PATH );\r\n\t\t\t\t\t\t\t // loggin\r\n\t\t\t\t\t\t\t sprintf ( logmsg , \"%s %s %s\" , modName , \"couldn´t get function with prototyp : \", typeid(fn).name() ) ;\r\n\t\t\t\t\t\t\t sprintf( _path , \"%s%s\", modName ,\".log\" )\t ;\r\n\t\t\t\t\t\t\t return;\r\n\t\t\t\t\t\t\t }\r\n\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t operator T(){\r\n\t\t\t\t\t\t return fn; \r\n\t\t\t\t\t\t }\r\n\t\t\t\tpublic:\r\n\t\t\t\t\tT fn;\r\n\t\t\t\t\tHMODULE dllHandle;\r\n\t\t\t\t\tvoid *ret;\r\n\t\t\t\t};\r\n\r\n\r\n\r\n\r\n#endif //__win32Tools_h_\r\n\t\t\t#include \"pch.h\"\r\n#include \"CKAll.h\"\r\n\r\n\r\n#include \"FTP4W.H\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendFileDecl();\r\nCKERROR CreateSendFileProto(CKBehaviorPrototype **pproto);\r\nint SendFile(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendFileDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Send File\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetCategory(\"Narratives/Files\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x637664ae,0x57df7e83));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSendFileProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSendFileProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Send File\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Start Upload\");\r\n\t\r\n\tproto->DeclareOutput(\"Upload Started\");\r\n\r\n\tproto->DeclareOutput(\"Finish\");\r\n\r\n\tproto->DeclareInParameter(\"LocalFile\", CKPGUID_STRING);\r\n\tproto->DeclareInParameter(\"RemoteFile\", CKPGUID_STRING);\r\n\r\n\t\r\n\tproto->DeclareOutParameter(\"Legth\", CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Current Download in Bytes\", CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Current Download in %\", CKPGUID_PERCENTAGE);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SendFile);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint SendFile(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\tint Length=0;\r\n\r\n\t// Start by In0\r\n\tif( beh->IsInputActive(0)){\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tXString LocalFile((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\tXString RemoteFile((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\r\n\t\t\r\n\t\tchar *Type = \"Type_B\";\r\n\t\tint Send = FtpSendFile(LocalFile.Str(),RemoteFile.Str(),*Type, FALSE,NULL,NULL);\r\n\r\n\t\tLength = FtpBytesToBeTransferred();\r\n\r\n\t\tbeh->SetOutputParameterValue(0,&Length);\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\tbeh->GetOutputParameterValue(0,&Length);\r\n\r\n\tint down=FtpBytesTransferred(); \r\n\tbeh->SetOutputParameterValue(1,&down);\r\n\tfloat progress=(float)(down*100.0f/Length); // percentage of file downloaded\r\n\tprogress /=100.0f;\r\n\tbeh->SetOutputParameterValue(2,&progress);\r\n\t\r\n\tif ( down == Length){\r\n\r\n\t\t\tbeh->ActivateOutput(1);\r\n\t\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\r\n}\r\n#include \"vtConnection.h\"\r\n#include \"xNetInterface.h\"\r\n\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"IParameter.h\"\r\n\r\n#include \r\nint pRigidBody::addCollider(pObjectDescr objectDescr,CK3dEntity*srcRefEntity)\r\n{\r\n\r\n\tint result = 0 ; \r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\tCK3dEntity* child = NULL;\r\n\tCKMesh *srcMesh = NULL;\r\n\r\n\tif (!srcRefEntity ||!srcRefEntity->GetCurrentMesh())\r\n\t\treturn 0;\r\n\tbool isChild = vtAgeia::isChildOf(GetVT3DObject(), srcRefEntity);\r\n\r\n\tobjectDescr.subEntID = srcRefEntity->GetID();\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// essential values\r\n\t//\r\n\tVxVector box_s = BoxGetZero(srcRefEntity);\r\n\t\r\n\tfloat radius = 1.0f;\r\n\tradius = srcRefEntity->GetCurrentMesh()->GetRadius();\r\n\r\n\tVxQuaternion refQuad;\r\n\tsrcRefEntity->GetQuaternion(&refQuad,GetVT3DObject());\r\n\tVxVector relPos;\r\n\tsrcRefEntity->GetPosition(&relPos,GetVT3DObject());\r\n\t\r\n\tNxQuat rot = pMath::getFrom(refQuad);\r\n\r\n\tsrcMesh = srcRefEntity->GetCurrentMesh();\r\n\r\n\tpWheel *wheel =NULL;\r\n\tNxShape *shape = NULL;\r\n\r\n\r\n\tif (objectDescr.hullType != HT_Wheel)\r\n\t{\r\n\t\tshape = pFactory::Instance()->createShape(GetVT3DObject(),objectDescr,srcRefEntity,srcMesh,relPos,refQuad);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tiAssertW( objectDescr.wheel.isValid(),objectDescr.wheel.setToDefault());\r\n\t\tiAssertW( objectDescr.wheel.radius.isValid(),objectDescr.wheel.radius.evaluate(srcRefEntity));\r\n\t\tshape = pFactory::Instance()->createWheelShape2(GetVT3DObject(),srcRefEntity, objectDescr.wheel );\r\n\t}\r\n\r\n\tif (!shape)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create sub shape!\");\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\r\n\tsInfo->meshID = srcMesh->GetID();\r\n\tsInfo->mesh =(CKBeObject*)srcMesh;\r\n\r\n\tsInfo->entID = srcRefEntity->GetID();\r\n\tsInfo->refObject = (CKBeObject*)srcRefEntity;\r\n\tsInfo->wheel = NULL;\r\n\t\r\n\tshape->setName(srcRefEntity->GetName());\r\n\tshape->userData = (void*)sInfo;\r\n\tsInfo->initDescription = objectDescr;\r\n\r\n\tgetActor()->wakeUp();\r\n\r\n\r\n\tif ( (!objectDescr.flags &BF_Hierarchy) )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\t/*\r\n\r\n\t//################################################################\r\n\t//\r\n\t// If more entities in hierarchy, invoke this function recursively \r\n\t//\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= srcRefEntity->HierarchyParser(subEntity) )\r\n\t{\r\n\r\n\t\tpObjectDescr *subDescr = NULL;\r\n\r\n\t\t//-try old version : \r\n\t\tif (subEntity->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t\t{\r\n\t\t\tsubDescr = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t}\r\n\r\n\t\t//-try new version\r\n\t\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\t\tif (subEntity->HasAttribute(attTypePBSetup))\r\n\t\t{\r\n\t\t\tsubDescr = new pObjectDescr();\r\n\t\t\tCKParameterOut *par = subEntity->GetAttributeParameter(attTypePBSetup);\r\n\t\t\tIParameter::Instance()->copyTo(subDescr,par);\r\n\t\t\tsubDescr->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\r\n\t\t}\r\n\r\n\t\tif (!subDescr)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t{\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif (subDescr->hullType != HT_Cloth)\r\n\t\t\t{\r\n\t\t\t\taddSubShape(NULL,*subDescr,subEntity);\r\n\t\t\t}\r\n\r\n\t\t\tif (subDescr->hullType == HT_Cloth)\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn 1;\r\n}\r\n\r\n\r\n\r\n\r\nint pRigidBody::addSubShape( CKMesh *mesh,pObjectDescr& objectDescr,CK3dEntity*srcRefEntity,VxVector localPosition,VxQuaternion localRotation)\r\n{\r\n\t\r\n\r\n\tint result = 0 ; \r\n\r\n\tint att = GetPMan()->GetPAttribute();\r\n\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\tbool isNewType = ( objectDescr.version == pObjectDescr::E_OD_VERSION::OD_DECR_V1) ? true : false ;\r\n\r\n\t\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\r\n\r\n\tCK3dEntity* child = NULL;\r\n\tbool isChild = false;\r\n\twhile (child = GetVT3DObject()->HierarchyParser(child) )\r\n\t{\r\n\t\tif (child == srcRefEntity )\r\n\t\t{\r\n\t\t\tisChild = true;\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* parameters for final composition : */\r\n\t/************************************************************************/\r\n\tCKMesh *srcMesh = NULL;\r\n\tfloat density = 0.0f;\r\n\tVxVector mOffset;\r\n\tVxVector sOffset;\r\n\tfloat skinWidth;\r\n\tint hType = 0;\r\n\r\n\r\n\tif (!mesh && !srcRefEntity )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tif (!mesh && srcRefEntity && !srcRefEntity->GetCurrentMesh() )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tCKBeObject *attObject = NULL;\r\n\tif (mesh && (mesh->HasAttribute(att) || isNewType) )\r\n\t{\r\n\t\tattObject = (CKBeObject*)mesh;\r\n\t}\r\n\tif (srcRefEntity && (srcRefEntity->HasAttribute(att) || isNewType ) )\r\n\t{\r\n\t\tattObject = (CKBeObject*)srcRefEntity;\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Fill sub shapes object description. \r\n\t//\r\n\t\r\n\tif (attObject && !isNewType ) //we have attribute values:\r\n\t{\r\n\t\tobjectDescr.density = GetValueFromAttribute(attObject ,att, E_PPS_DENSITY);\r\n\t\tobjectDescr.massOffset= GetValueFromAttribute(attObject ,att, E_PPS_MASS_OFFSET);\r\n\t\tobjectDescr.shapeOffset = GetValueFromAttribute(attObject ,att, E_PPS_SHAPE_OFFSET);\r\n\t\tobjectDescr.skinWidth = GetValueFromAttribute(attObject,att, E_PPS_SKIN_WIDTH);\r\n\t\tobjectDescr.hullType = GetValueFromAttribute(attObject,att,E_PPS_HULLTYPE);\r\n\t\tobjectDescr.hirarchy = GetValueFromAttribute(attObject,att,E_PPS_HIRARCHY);\r\n\t\tobjectDescr.collisionGroup = GetValueFromAttribute(attObject,att,E_PPS_COLL_GROUP);\r\n\t\tobjectDescr.newDensity = GetValueFromAttribute(attObject,att,E_PPS_NEW_DENSITY);\r\n\t\tobjectDescr.totalMass = GetValueFromAttribute(attObject,att,E_PPS_TOTAL_MASS);\r\n\t}\r\n\r\n\tif (srcRefEntity)\r\n\t{\r\n\t\tobjectDescr.subEntID = srcRefEntity->GetID();\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t//\tTransformation values \r\n\t//\r\n\tVxVector box_s;\r\n\r\n\tif (!mesh && srcRefEntity)\r\n\t{\r\n\t\tbox_s = BoxGetZero(srcRefEntity);\r\n\t}\r\n\tif (!srcRefEntity && mesh)\r\n\t{\r\n\t\tbox_s = mesh->GetLocalBox().GetSize();\r\n\t}\r\n\tif (srcRefEntity && mesh )\r\n\t{\r\n\t\tbox_s = mesh->GetLocalBox().GetSize();\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Determine radius\r\n\t//\r\n\tfloat radius = 1.0f;\r\n\tif ( mesh && !srcRefEntity )\r\n\t{\r\n\t\tradius = mesh->GetRadius();\r\n\t}\r\n\tif (!mesh && srcRefEntity && srcRefEntity->GetCurrentMesh() )\r\n\t{\r\n\t\tradius = srcRefEntity->GetCurrentMesh()->GetRadius();\r\n\t}\r\n\tif (mesh && srcRefEntity)\r\n\t{\r\n\t\tradius = mesh->GetRadius();\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Calculate destination matrix\r\n\t//\r\n\tVxMatrix v_matrix ;\r\n\tVxVector pos,scale;\t\t\r\n\tVxQuaternion quat;\t\r\n\r\n\r\n\tif (srcRefEntity)\r\n\t{\r\n\t\tif (isChild)\r\n\t\t{\r\n\t\t\tv_matrix = srcRefEntity->GetLocalMatrix();\r\n\t\t}else\r\n\t\t{\r\n\t\t\tv_matrix = srcRefEntity->GetWorldMatrix();\r\n\t\t}\r\n\t}\r\n\tVx3DDecomposeMatrix(v_matrix,quat,pos,scale);\r\n\t\r\n\r\n\tif (mesh && !srcRefEntity)\r\n\t{\r\n\t\tpos = localPosition;\r\n\t\tquat = localRotation;\r\n\t}\r\n\r\n\tif (mesh && srcRefEntity )\r\n\t{\r\n\r\n\t\tVxQuaternion refQuad2;\r\n\t\tsrcRefEntity->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\tVxVector relPos;\r\n\t\tsrcRefEntity->GetPosition(&relPos,GetVT3DObject());\r\n\t\tif (!isChild)\r\n\t\t{\r\n\t\t\tpos = relPos;\r\n\t\t\tquat = refQuad2;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!mesh && srcRefEntity )\r\n\t{\r\n\t\tVxVector relPos;\r\n\t\tsrcRefEntity->GetPosition(&relPos,GetVT3DObject());\r\n\t\tVxQuaternion refQuad2;\r\n\t\tsrcRefEntity->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\tpos = relPos;\r\n\t\tquat = refQuad2;\r\n\t}\r\n\tNxQuat rot = pMath::getFrom(quat);\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Determine the mesh \r\n\t//\r\n\tif (mesh && srcRefEntity==NULL )\r\n\t{\r\n\t\tsrcMesh = mesh;\r\n\t}\r\n\tif (!mesh && srcRefEntity && srcRefEntity->GetCurrentMesh() )\r\n\t{\r\n\t\tsrcMesh = srcRefEntity->GetCurrentMesh();\r\n\t}\r\n\r\n\tif (mesh && srcRefEntity && srcRefEntity->GetCurrentMesh())\r\n\t{\r\n\t\tsrcMesh = mesh;\r\n\t}\r\n\r\n\tCK_ID srcID = 0 ; \r\n\tif (srcMesh)\r\n\t{\r\n\t\tsrcID = srcMesh->GetID();\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Create the final sub shape\r\n\t//\r\n\r\n\tpSubMeshInfo *sInfo = new pSubMeshInfo();\r\n\tbool isWheel1 = false;\r\n\tpWheel *wheel =NULL;\r\n\tNxShape *shape = NULL;\r\n\r\n\r\n\tif (objectDescr.hullType != HT_Wheel)\r\n\t{\r\n\t\tshape = pFactory::Instance()->createShape(GetVT3DObject(),objectDescr,srcRefEntity,srcMesh,pos,quat);\r\n\t}else\r\n\t{\r\n\t\twheel = pFactory::Instance()->createWheelSubShape(this,srcRefEntity,srcMesh,&objectDescr,pos,quat,shape);\r\n\t\tif (wheel)\r\n\t\t{\r\n\t\t\tsInfo->wheel = wheel;\r\n\t\t\tpWheel1* w1 = dynamic_cast(wheel);\r\n\t\t\tif (w1){\r\n\r\n\t\t\t\tisWheel1 = true;\r\n\t\t\t\tshape = (NxShape*)w1->getWheelConvex();\r\n\t\t\t}\r\n\r\n\t\t\tpWheel2* w2 = dynamic_cast(wheel);\r\n\t\t\tif (w2)\r\n\t\t\t{\r\n\t\t\t\tshape =(NxShape*)w2->getWheelShape();\r\n\t\t\t}\r\n \t\t\t\r\n\t\t}else\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Creating wheel sub shape failed\");\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\r\n\tif (!shape)\r\n\t{\r\n\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create sub shape!\");\r\n\t}\r\n\r\n\tif (shape)\r\n\t{\r\n\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t// Setup the material\r\n\t\t//\r\n\t\tint materialIndex = 0;\r\n\r\n\t\tpMaterial bMaterial;\r\n\t\tbool hasMaterial = pFactory::Instance()->findSettings(bMaterial,srcRefEntity);\r\n\t\tif (!hasMaterial)\r\n\t\t{\r\n\t\t\thasMaterial = pFactory::Instance()->findSettings(bMaterial,mesh);\r\n\t\t}\r\n\r\n\t\tif (hasMaterial)\r\n\t\t{\r\n\t\t\tNxMaterialDesc nxMatDescr;\r\n\t\t\tpFactory::Instance()->copyTo(nxMatDescr,bMaterial);\r\n\t\t\tNxMaterial *nxMaterial = getWorld()->getScene()->createMaterial(nxMatDescr);\r\n\t\t\tif (nxMaterial)\r\n\t\t\t{\r\n\t\t\t\tmaterialIndex = nxMaterial->getMaterialIndex();\r\n\t\t\t\tnxMaterial->userData = (void*)&bMaterial;\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tmaterialIndex = getWorld()->getDefaultMaterial()->getMaterialIndex();\r\n\t\t}\r\n\t\tshape->setMaterial(materialIndex);\r\n\r\n\t\t//################################################################\r\n\t\t//\r\n\t\t// Store meta info in shape user data. \r\n\t\t//\r\n\t\t\r\n\t\tshape->setGroup(objectDescr.collisionGroup);\r\n\t\t\r\n\r\n\r\n\t\tif (srcMesh)\r\n\t\t{\r\n\t\t\tsInfo->meshID = srcMesh->GetID();\r\n\t\t\tsInfo->mesh =(CKBeObject*)srcMesh;\r\n\t\t\tshape->setName(srcMesh->GetName());\r\n\t\t}\r\n\r\n\t\tif(srcRefEntity)\r\n\t\t{\r\n\t\t\tsInfo->entID = srcRefEntity->GetID();\r\n\t\t\tsInfo->refObject = (CKBeObject*)srcRefEntity;\r\n\t\t\tshape->setName(srcRefEntity->GetName());\r\n\t\t}\r\n\r\n\t\tshape->userData = (void*)sInfo;\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Wheel Type one has an additional capsule swept shape\r\n\t// We store the shape meta data there as well\r\n\tif (\r\n\t\tisWheel1 && \r\n\t\twheel && \r\n\t\tdynamic_cast(wheel) &&\r\n\t\t(pWheel1*)(dynamic_cast(wheel))->getWheelCapsule()\r\n\t\t)\r\n\t{\r\n\t\t((pWheel1*)(dynamic_cast(wheel)))->getWheelCapsule()->userData = sInfo;\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Modify mass \r\n\t//\r\n\tif (objectDescr.mass.newDensity!=0.0f || objectDescr.mass.totalMass!=0.0f )\r\n\t{\r\n\t\tgetActor()->updateMassFromShapes(objectDescr.mass.newDensity,objectDescr.mass.totalMass);\r\n\t}\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// Post routine\r\n\t//\r\n\tgetActor()->wakeUp();\r\n\tif(mesh)\r\n\t\treturn result;\r\n\r\n\tif (!objectDescr.hirarchy)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif (!srcRefEntity)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// If more entities in hierarchy, invoke this function recursively \r\n\t//\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= srcRefEntity->HierarchyParser(subEntity) )\r\n\t{\r\n\t\r\n\t\tpObjectDescr *subDescr = NULL;\r\n\r\n\t\t//-try old version : \r\n\t\tif (subEntity->HasAttribute(GetPMan()->GetPAttribute()))\r\n\t\t{\r\n\t\t\tsubDescr = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t}\r\n\r\n\t\t//-try new version\r\n\t\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\t\tif (subEntity->HasAttribute(attTypePBSetup))\r\n\t\t{\r\n\t\t\tsubDescr = new pObjectDescr();\r\n\t\t\tCKParameterOut *par = subEntity->GetAttributeParameter(attTypePBSetup);\r\n\t\t\tIParameter::Instance()->copyTo(subDescr,par);\r\n\t\t\tsubDescr->version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\r\n\t\t}\r\n\r\n\t\tif (!subDescr)\r\n\t\t\tcontinue;\r\n\r\n\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t{\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tif (subDescr->hullType != HT_Cloth)\r\n\t\t\t{\r\n\t\t\t\taddSubShape(NULL,*subDescr,subEntity);\r\n\t\t\t}\r\n\r\n\t\t\tif (subDescr->hullType == HT_Cloth)\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\nvoid pRigidBody::setBoxDimensions( const VxVector&dimension,CKBeObject* subShapeReference/*=NULL*/ )\r\n{\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxBoxShape *box = static_cast(getMainShape()->isBox());\r\n\t\tif (!box)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a box!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbox->setDimensions(getFrom(dimension));\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxBoxShape *box = static_cast(s->isBox());\r\n\t\tif (!box)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a box!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbox->setDimensions(getFrom(dimension));\r\n\t}\r\n}\r\nVxVector pRigidBody::getBoxDimensions(CKBeObject* subShapeReference)\r\n{\r\n\tVxVector result(-1.f,-1.f,-1.f);\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxBoxShape *box = static_cast(getMainShape()->isBox());\r\n\t\tif (!box)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a box!\");\r\n\t\t\treturn result;\r\n\t\t}\r\n\t\treturn getFrom(box->getDimensions());\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxBoxShape *box = static_cast(s->isBox());\r\n\t\tif (!box)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a box!\");\r\n\t\t\treturn result;\r\n\t\t}\r\n\t\tgetFrom(box->getDimensions());\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\n\r\n\r\nvoid pRigidBody::setSphereRadius(float radius,CKBeObject* subShapeReference/* =NULL */)\r\n{\r\n\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxSphereShape *sphere = static_cast(getMainShape()->isSphere());\r\n\t\tif (!sphere)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a sphere!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tsphere->setRadius(radius);\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxSphereShape*sphere = static_cast(s->isSphere());\r\n\t\tif (!sphere)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a sphere!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tsphere->setRadius(radius);\r\n\t}\r\n}\r\n\r\n\r\n\r\nfloat pRigidBody::getSphereRadius(CKBeObject* subShapeReference/* =NULL */)\r\n{\r\n\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn -1.0f;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxSphereShape *sphere = static_cast(getMainShape()->isSphere());\r\n\t\tif (!sphere)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a sphere!\");\r\n\t\t\treturn -1.0f;\r\n\t\t}\r\n\t\treturn sphere->getRadius();\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxSphereShape*sphere = static_cast(s->isSphere());\r\n\t\tif (!sphere)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a sphere!\");\r\n\t\t\treturn -1.0f;\r\n\t\t}\r\n\t\treturn sphere->getRadius();\r\n\t}\r\n\treturn -1.0f;\r\n}\r\n\r\n\r\n\r\n\r\nvoid pRigidBody::setCapsuleDimensions(float radius,float length,CKBeObject* subShapeReference)\r\n{\r\n\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxCapsuleShape *capsule = static_cast(getMainShape()->isCapsule());\r\n\t\tif (!capsule)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a capsule!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tcapsule->setHeight(length);\r\n\t\tcapsule->setRadius(radius);\r\n\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxCapsuleShape*capsule = static_cast(s->isCapsule());\r\n\t\tif (!capsule)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a capsule!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tcapsule->setHeight(length);\r\n\t\tcapsule->setRadius(radius);\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::getCapsuleDimensions(float& radius,float& length,CKBeObject* subShapeReference)\r\n{\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tNxCapsuleShape *capsule = static_cast(getMainShape()->isCapsule());\r\n\t\tif (!capsule)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a capsule!\");\r\n\t\t\tradius = -1.0f;\r\n\t\t\tlength = -1.0f;\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tradius = capsule->getRadius();\r\n\t\tlength = capsule->getHeight();\r\n\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try a mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tNxCapsuleShape*capsule = static_cast(s->isCapsule());\r\n\t\tif (!capsule)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"target shape is not a capsule!\");\r\n\t\t\tradius = -1.0f;\r\n\t\t\tlength = -1.0f;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tradius = capsule->getRadius();\r\n\t\tlength = capsule->getHeight();\r\n\t}\r\n\r\n}\r\nHullType pRigidBody::getShapeType(CKBeObject* subShapeReference)\r\n{\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn HT_Unknown;\r\n\t}\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\treturn (HullType)vtAgeia::getHullTypeFromShape(getMainShape());\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try a mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"couldn't find sub shape!\");\r\n\t\t\treturn HT_Unknown;\r\n\t\t}\r\n\t\treturn (HullType)vtAgeia::getHullTypeFromShape(s);\r\n\t}\r\n\treturn HT_Unknown;\r\n}\r\n\r\nfloat pRigidBody::getSkinWidth(CKBeObject* subShapeReference)\r\n{\r\n\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\treturn -1.0f;\r\n\t}\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL && !getMainShape() )\r\n\t{\r\n\t\treturn mSkinWidth;\r\n\r\n\t}\r\n\tif(subShapeReference == NULL && getMainShape() )\r\n\t{\r\n\t\treturn getMainShape()->getSkinWidth();\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try a mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"couldn't find sub shape!\");\r\n\t\t\treturn -1.0f;\r\n\t\t}\r\n\t\treturn s->getSkinWidth();\r\n\t}\r\n\treturn -1.0f;\r\n}\r\n\r\nvoid pRigidBody::setSkinWidth(const float skinWidth,CKBeObject* subShapeReference)\r\n{\r\n\tif (!isValid() || !getMainShape() )\r\n\t{\r\n\t\tmSkinWidth = mSkinWidth;\r\n\t\treturn;\r\n\t}\r\n\t/// shape is specified -> modify bodies first shape :\r\n\tif (subShapeReference == NULL && !getMainShape() )\r\n\t{\r\n\t\tmSkinWidth = skinWidth;\r\n\t}\r\n\tif(subShapeReference == NULL && getMainShape() )\r\n\t{\r\n\t\tgetMainShape()->setSkinWidth(skinWidth);\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try a mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"couldn't find sub shape!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\ts->setSkinWidth(skinWidth);\r\n\t}\r\n}\r\n\r\n\r\nint pRigidBody::removeSubShape( CKBeObject *reference,float newensity/*=0.0f*/,float totalMass/*=0.0f*/ )\r\n{\r\n\r\n\r\n\tint result = -1;\r\n\tif (!reference || !getActor())\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tNxShape *subShape = NULL;\r\n\tbool found = false;\r\n\twhile(subShape = _getSubShape(reference->GetID()))\r\n\t{\r\n\t\tgetActor()->releaseShape(*subShape);\r\n\t\tfound =true;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tif (!found)\r\n\t{\r\n\t\twhile(subShape = _getSubShape(reference->GetID()))\r\n\t\t{\r\n\t\t\tgetActor()->releaseShape(*subShape);\r\n\t\t\tfound =true;\r\n\t\t}\r\n\t}\r\n\r\n\tif (found && newensity !=0.0f || totalMass!=0.0f )\r\n\t{\r\n\t\tgetActor()->updateMassFromShapes(newensity,totalMass);\r\n\t}\r\n\tgetActor()->wakeUp();\r\n\r\n\treturn 1;\r\n}\r\n\r\nNxShape * pRigidBody::_getSubShapeByEntityID( CK_ID id )\r\n{\r\n\tif (!getActor())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->entID == id)\r\n\t\t\t{\r\n\t\t\t\treturn s;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\nbool pRigidBody::isSubShape(CKBeObject *object)\r\n{\r\n\r\n\tbool result = false;\r\n\tif (!object)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif ( _getSubShape(object->GetID()) || _getSubShapeByEntityID(object->GetID() ))\r\n\t{\r\n\t\treturn true ;\r\n\t}\r\n\treturn result;\r\n}\r\nNxShape *pRigidBody::_getSubShape(CK_ID meshID)\r\n{\r\n\r\n\tif (!getActor())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->meshID == meshID)\r\n\t\t\t{\r\n\t\t\t\treturn s;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n\r\nint pRigidBody::updateMassFromShapes( float density, float totalMass )\r\n{\r\n\r\n\t\r\n\tif (getActor())\r\n\t{\r\n\t\treturn getActor()->updateMassFromShapes(density,totalMass);\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n\r\nNxShape *pRigidBody::getShapeByIndex(int index/* =0 */)\r\n{\r\n\r\n\tNxU32 nbShapes = getActor()->getNbShapes();\r\n\tif ( nbShapes )\r\n\t{\r\n\t\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\t\tfor (NxU32 j=0; jreadActorFlag(NX_AF_DISABLE_COLLISION);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn !subShape->getFlag(NX_SF_DISABLE_COLLISION);\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\nvoid pRigidBody::enableCollision( bool enable,CK3dEntity* subShapeReference/*=NULL*/ )\r\n{\r\n\tNxShape *subShape = getSubShape(subShapeReference);\r\n\r\n\tif (!subShape)\r\n\t{\r\n\t\tsubShape==getMainShape();\r\n\t}\r\n\tif (subShape )\r\n\t{\r\n\t\tif (subShape ==getMainShape())\r\n\t\t{\r\n\t\t\tif (!enable)\r\n\t\t\t{\r\n\t\t\t\tgetActor()->raiseActorFlag(NX_AF_DISABLE_COLLISION);\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tgetActor()->clearActorFlag(NX_AF_DISABLE_COLLISION);\r\n\t\t\t}\r\n\t\t}else{\r\n\r\n\t\t\tsubShape->setFlag(NX_SF_DISABLE_RESPONSE, !enable );\r\n\t\t}\r\n\t}\r\n}\r\nvoid pRigidBody::enableTriggerShape( bool enable,CK3dEntity* subShapeReference/*=NULL*/ )\r\n{\r\n\r\n\tNxShape *subShape = getSubShape(subShapeReference);\r\n\tif (subShape)\r\n\t{\r\n\t\tsubShape->setFlag(NX_TRIGGER_ENABLE,enable);\r\n\t}\r\n}\r\n\r\nbool pRigidBody::isTriggerShape( CK3dEntity* subShapeReference/*=NULL*/ )\r\n{\r\n\tNxShape *subShape = getSubShape(subShapeReference);\r\n\tif (subShape)\r\n\t{\r\n\t\treturn subShape->getFlag(NX_TRIGGER_ENABLE);\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nbool pRigidBody::isCollisionsNotifyEnabled()\r\n{\r\n\r\n\treturn ( getActor()->getContactReportFlags() & NX_NOTIFY_ON_TOUCH );\r\n}\r\n\r\nvoid pRigidBody::enableCollisionsNotify( bool enable )\r\n{\r\n\tif (enable)\r\n\t{\r\n\t\tgetActor()->setContactReportFlags(NX_NOTIFY_ON_TOUCH);\r\n\t}else\r\n\t\tgetActor()->setContactReportFlags(NX_IGNORE_PAIR);\r\n}\r\n\r\nvoid pRigidBody::enableContactModification(bool enable)\r\n{\r\n\r\n\tint& flags = m_sFlags;\r\n\tif (getActor())\r\n\t{\r\n\t\tif (enable){\r\n\t\t\tgetActor()->raiseActorFlag(NX_AF_CONTACT_MODIFICATION);\r\n\r\n\t\t\t\r\n\t\t\tflags|=BF_ContactModify;\r\n\t\t}\r\n\t\telse{\r\n\t\t\tgetActor()->clearActorFlag(NX_AF_CONTACT_MODIFICATION);\r\n\t\t\tflags&=~(BF_ContactModify);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nvoid pRigidBody::enableCollisionForceCalculation(bool enable,CK3dEntity* subShapeReference/* =NULL */)\r\n{\r\n\r\n\tNxShape *subShape = getSubShape(subShapeReference);\r\n\tif (subShape)\r\n\t{\r\n\t\tint o = subShape->getFlag(NX_SF_POINT_CONTACT_FORCE);\r\n\t\tsubShape->setFlag(NX_SF_POINT_CONTACT_FORCE,enable);\r\n\t\tint o2 = subShape->getFlag(NX_SF_POINT_CONTACT_FORCE);\r\n\t\tint o3 = subShape->getFlag(NX_SF_POINT_CONTACT_FORCE);\r\n\t}\r\n\r\n}\r\n\r\nVxVector pRigidBody::getPivotOffset(CK3dEntity*shapeReference)\r\n{\r\n\r\n\tNxShape *subshape = getSubShape(shapeReference);\r\n\tif (subshape)\treturn getFrom(subshape->getLocalPosition());\r\n\r\n\treturn VxVector();\r\n}\r\n\r\nNxShape*pRigidBody::getSubShape(CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\t\r\n\t\tNxShape *inputShape = _getSubShapeByEntityID(shapeReference->GetID());\r\n\t\tif (getMainShape() ==inputShape)\r\n\t\t{\r\n\t\t\treturn getMainShape();\r\n\t\t}else{\r\n\t\t\treturn inputShape;\r\n\t\t}\r\n\t}\r\n\r\n\treturn getMainShape();\r\n\r\n}\r\nvoid pRigidBody::setShapeMaterial(pMaterial&material,CK3dEntity*shapeReference/* =NULL */)\r\n{\r\n\t\r\n\tNxShape *dstShape = NULL;\r\n\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\t\tdstShape = _getSubShapeByEntityID(shapeReference->GetID());\r\n\t}else{\r\n\t\tdstShape = getMainShape();\r\n\t}\r\n\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(dstShape);\r\n\t#endif\r\n\r\n\t\t\r\n\tint materialIndex = dstShape->getMaterial();\r\n\r\n\tNxMaterial *currentMaterial = getActor()->getScene().getMaterialFromIndex(materialIndex);\r\n\r\n\tif (!material.isValid())\r\n\t\treturn;\r\n\r\n\tNxMaterialDesc nxMatDescr;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tWe dont alter the default material ! We create a new one !!\r\n\t//\r\n\r\n\tint defaultID = getWorld()->getDefaultMaterial()->getMaterialIndex();\r\n\tif ( !currentMaterial || materialIndex ==0 || materialIndex == getWorld()->getDefaultMaterial()->getMaterialIndex() )\r\n\t{\r\n\t\t\r\n\t\tpFactory::Instance()->copyTo(nxMatDescr,material);\r\n\r\n\t\tNxMaterial *newMaterial = getActor()->getScene().createMaterial(nxMatDescr);\r\n\t\tif (newMaterial){\r\n\t\t\tdstShape->setMaterial(newMaterial->getMaterialIndex());\r\n\t\t\tnewMaterial->userData = (void*)&material;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\t\r\n\t\tpFactory::Instance()->copyTo(nxMatDescr,material);\r\n\t\tcurrentMaterial->loadFromDesc(nxMatDescr);\r\n\t\t//currentMaterial->userData = (void*)&material;\r\n\r\n\r\n\t}\r\n\r\n\r\n}\r\npMaterial&pRigidBody::getShapeMaterial(CK3dEntity *shapeReference/* =NULL */)\r\n{\r\n\r\n\tpMaterial result;\r\n\r\n\tif (shapeReference && !isSubShape(shapeReference))\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tNxShape *srcShape = NULL;\r\n\tCK3dEntity *ent = GetVT3DObject();\r\n\t\r\n\tif (shapeReference)\r\n\t{\r\n\t\tsrcShape = getSubShape(shapeReference);\r\n\t}else{\r\n\t\tsrcShape = getMainShape();\r\n\t}\r\n\r\n\t#ifdef _DEBUG\r\n\t\tassert(srcShape);\r\n\t#endif\r\n\r\n\tint index = srcShape->getMaterial();\r\n\tNxMaterial *mat = getActor()->getScene().getMaterialFromIndex(srcShape->getMaterial());\r\n\r\n\tpFactory::Instance()->copyTo(result,getActor()->getScene().getMaterialFromIndex(srcShape->getMaterial()));\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\nvoid pRigidBody::_checkForRemovedSubShapes()\r\n{\r\n\r\n\r\n}\r\n\r\nvoid pRigidBody::_checkForNewSubShapes()\r\n{\r\n\r\n\tpObjectDescr *oDescr = pFactory::Instance()->createPObjectDescrFromParameter(GetVT3DObject()->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\tif (!oDescr)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (! ( getFlags() & BF_Hierarchy ) ) \r\n\t{\r\n\t\treturn ;\r\n\t}\r\n\r\n\tCK3dEntity* subEntity = NULL;\r\n\twhile (subEntity= GetVT3DObject()->HierarchyParser(subEntity) )\r\n\t{\r\n\t\tif ( !_getSubShapeByEntityID(subEntity->GetID()) )\r\n\t\t{\r\n\t\t\tCKSTRING name = subEntity->GetName();\r\n\t\t\tint s = isSubShape(subEntity);\r\n\r\n\t\t\tif ( subEntity->HasAttribute(GetPMan()->GetPAttribute()\t) )\r\n\t\t\t{\r\n\t\t\t\tpObjectDescr *subDescr = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\t\tif (subDescr->flags & BF_SubShape)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (subDescr->hullType != HT_Cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\taddSubShape(NULL,*oDescr,subEntity);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (subDescr->hullType == HT_Cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//pClothDesc *cloth = pFactory::Instance()->createPObjectDescrFromParameter(subEntity->GetAttributeParameter(GetPMan()->GetPAttribute()));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (( getFlags() & BF_Hierarchy ))\r\n\t{\r\n\t\tif (oDescr->newDensity!=0.0f || oDescr->totalMass!=0.0f )\r\n\t\t{\r\n\t\t\tupdateMassFromShapes(oDescr->newDensity,oDescr->totalMass);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nint pRigidBody::updateSubShape(bool fromPhysicToVirtools/* =true */,bool position/* =true */,bool rotation/* =true */,CK3dEntity *childObject/* =NULL */,bool hierarchy/* =true */)\r\n{\r\n\tif(!getActor())\r\n\t\treturn -1;\r\n\tNxU32 nbShapes = getActor()->getNbShapes();\r\n\tif ( nbShapes )\r\n\t{\r\n\t\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\tif (info)\r\n\t\t\t\t{\r\n\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\tif (ent)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tif (s == getMainShape())\r\n\t\t\t\t\t\t\tcontinue;\r\n\r\n\r\n\t\t\t\t\t\tif (fromPhysicToVirtools)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//pVehicle *v =getVehicle(); \r\n\t\t\t\t\t\t\tpWheel* wheel = (pWheel*)getWheel(ent);\r\n\t\t\t\t\t\t\tif (wheel)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\twheel->_updateVirtoolsEntity(position,rotation);\r\n\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\tif (position)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVxVector gPos = getFrom(s->getLocalPose().t);\r\n\t\t\t\t\t\t\t\t\tent->SetPosition(&gPos,GetVT3DObject());\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (rotation)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVxQuaternion rot = pMath::getFrom( s->getLocalPose().M );\r\n\t\t\t\t\t\t\t\t\tif(s->isWheel())\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tent->SetQuaternion(&rot,GetVT3DObject());\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}else//Virtools to Ageia !\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (position)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tVxVector relPos;\r\n\t\t\t\t\t\t\t\tent->GetPosition(&relPos,GetVT3DObject());\r\n\t\t\t\t\t\t\t\ts->setLocalPosition(getFrom(relPos));\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tif (rotation)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tVxQuaternion refQuad2;\r\n\t\t\t\t\t\t\t\tent->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\t\t\t\t\t\t\ts->setLocalOrientation(getFrom(refQuad2));\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint pRigidBody::updateSubShapes(bool fromPhysicToVirtools/* = true */,bool position/* =true */,bool rotation/* =true */,CK3dEntity *childObject)\r\n{\r\n\r\n\r\n\tif(!getActor())\r\n\t\treturn -1;\r\n\tNxU32 nbShapes = getActor()->getNbShapes();\r\n\tif ( nbShapes )\r\n\t{\r\n\t\tbool hierarchy = (getFlags() & BF_Hierarchy ) ? true : false;\r\n\t\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\tif (info)\r\n\t\t\t\t{\r\n\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\tif (ent)\r\n\t\t\t\t\t{\r\n\r\n \t\t\t\t\t\tif (fromPhysicToVirtools)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//pVehicle *v =getVehicle(); \r\n\t\t\t\t\t\t\tpWheel* wheel = (pWheel*)getWheel(ent);\r\n\t\t\t\t\t\t\tif (wheel)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\twheel->_updateVirtoolsEntity(position,rotation);\r\n\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t{\r\n\t\r\n\t\t\t\t\t\t\t\tif (position)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif ( s != getMainShape()){\r\n\t\t\t\t\t\t\t\t\t\tVxVector gPos = getFrom(s->getLocalPose().t);\r\n\t\t\t\t\t\t\t\t\t\tent->SetPosition(&gPos,GetVT3DObject());\r\n\t\t\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tVxVector gPos = getFrom(s->getGlobalPose().t);\r\n\t\t\t\t\t\t\t\t\t\t\tent->SetPosition(&gPos,NULL,!hierarchy);\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t/*pivot correction*/\r\n\t\t\t\t\t\t\t\t\t\t\tVxVector diff = getFrom(s->getLocalPosition());\r\n\t\t\t\t\t\t\t\t\t\t\tif (XAbs(diff.SquareMagnitude()) > 0.01f)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tdiff *=-1.0f;\r\n\t\t\t\t\t\t\t\t\t\t\t\tent->SetPosition(&diff,ent,!hierarchy);\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (rotation)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif ( s != getMainShape()){\r\n\r\n\t\t\t\t\t\t\t\t\tVxQuaternion rot = pMath::getFrom( s->getLocalPose().M );\r\n\t\t\t\t\t\t\t\t\tent->SetQuaternion(&rot,GetVT3DObject());\r\n\t\t\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\t\t\tVxQuaternion rot = pMath::getFrom( s->getGlobalPose().M );\r\n\t\t\t\t\t\t\t\t\t\tent->SetQuaternion(&rot,NULL,!hierarchy);\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}else//Virtools to Ageia !\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (position)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tVxVector relPos;\r\n\t\t\t\t\t\t\t\tent->GetPosition(&relPos,GetVT3DObject());\r\n\t\t\t\t\t\t\t\ts->setLocalPosition(getFrom(relPos));\r\n\t\t\t\t\t\t\t\t//onKinematicMove(fromPhysicToVirtools,position,false,childObject);\r\n\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tif (rotation)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tVxQuaternion refQuad2;\r\n\t\t\t\t\t\t\t\tent->GetQuaternion(&refQuad2,GetVT3DObject());\r\n\t\t\t\t\t\t\t\ts->setLocalOrientation(getFrom(refQuad2));\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\treturn 0;\r\n}\r\nint pRigidBody::getCollisionsGroup( CK3dEntity* subShapeReference/*=NULL*/ )\r\n{\r\n\r\n\tNxShape *subShape = getSubShape(subShapeReference);\r\n\tif (subShape)\r\n\t{\r\n\t\treturn subShape->getGroup();\r\n\t}\r\n\treturn -1;\r\n}\r\nvoid pRigidBody::setCollisionsGroup( int index,CK3dEntity* subShapeReference/*=NULL*/ )\r\n{\r\n\tif(!getActor())\r\n\t\treturn;\r\n\tif (subShapeReference == NULL)\r\n\t{\r\n\t\tif(index>=0 && index <=32)\r\n\t\t\tgetActor()->setGroup(index);\r\n\r\n\t\tNxU32 nbShapes = getActor()->getNbShapes();\r\n\t\tif ( nbShapes )\r\n\t\t{\r\n\t\t\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\t\t\tfor (NxU32 j=0; j=0 && index <=32)\r\n\t\t\t\t\t\ts->setGroup(index);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// shape reference is specified - > modify sub shape : \r\n\tif (subShapeReference !=NULL && isSubShape(subShapeReference) )\r\n\t{\r\n\t\t// try an entity : \r\n\t\tNxShape *s = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\t//try an mesh :\r\n\t\t\ts = _getSubShape(subShapeReference->GetID());\r\n\t\t}\r\n\r\n\t\tif (!s)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"there is no such sub shape!\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t\ts->setGroup(index);\r\n\t}\r\n}\r\n\r\nvoid pRigidBody::setGroupsMask(CK3dEntity *shapeReference,const pGroupsMask& mask)\r\n{\r\n\r\n\r\n\tNxShape *mainshape = getMainShape();\r\n\tNxShape *dstShape = getMainShape();\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\t\tNxShape *inputShape = _getSubShapeByEntityID(shapeReference->GetID());\r\n\t\tif (mainshape==inputShape)\r\n\t\t{\r\n\t\t\tdstShape = mainshape;\r\n\t\t}else{\r\n\t\t\tdstShape = inputShape;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tNxGroupsMask mask1;\r\n\tmask1.bits0 = mask.bits0;\r\n\tmask1.bits1 = mask.bits1;\r\n\tmask1.bits2 = mask.bits2;\r\n\tmask1.bits3 = mask.bits3;\r\n\r\n\tif (dstShape)\r\n\t{\r\n\t\tdstShape->setGroupsMask(mask1);\r\n\t}\r\n\r\n}\r\n\r\n\r\npGroupsMask pRigidBody::getGroupsMask(CK3dEntity *shapeReference)\r\n{\r\n\r\n\tNxShape *mainshape = getMainShape();\r\n\tNxShape *dstShape = getMainShape();\r\n\r\n\tif (shapeReference)\r\n\t{\r\n\t\tNxShape *inputShape = _getSubShapeByEntityID(shapeReference->GetID());\r\n\t\tif (mainshape==inputShape)\r\n\t\t{\r\n\t\t\tdstShape = mainshape;\r\n\t\t}else{\r\n\t\t\tdstShape = inputShape;\r\n\t\t}\r\n\t}\r\n\r\n\tif (dstShape)\r\n\t{\r\n\r\n\t\tNxGroupsMask gMask = dstShape->getGroupsMask();\r\n\r\n\t\tpGroupsMask vtGMask;\r\n\r\n\t\tvtGMask.bits0 = gMask.bits0;\r\n\t\tvtGMask.bits1 = gMask.bits1;\r\n\t\tvtGMask.bits2 = gMask.bits2;\r\n\t\tvtGMask.bits3 = gMask.bits3;\r\n\t\treturn vtGMask;\r\n\r\n\t}\r\n\r\n\r\n\treturn pGroupsMask();\r\n\r\n}\r\n\r\n/*\r\nif (srcRefEntity && srcRefEntity->HasAttribute(GetPMan()->att_wheelDescr ))\r\n{\r\n\tCKParameterOut *par = srcRefEntity->GetAttributeParameter(GetPMan()->att_wheelDescr );\r\n\tif (par)\r\n\t{\r\n\t\tpWheelDescr *wDescr = new pWheelDescr();\r\n\t\tint err = pFactory::Instance()->copyTo(wDescr,par);\r\n\r\n\t\tif (wDescr && !wDescr->isValid() )\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Wheel Description was invalid\");\r\n\t\t\tdelete wDescr;\r\n\t\t}\r\n\r\n\t\tif (wDescr)\r\n\t\t{\r\n\t\t\tpWheel *wheel = pFactory::Instance()->createWheel(this,*wDescr);\r\n\r\n\t\t\tshape = pFactory::Instance()->createWheelShape(getActor(),&objectDescr,wDescr,srcRefEntity,srcMesh,pos,quat);\r\n\t\t\tif (shape)\r\n\t\t\t{\r\n\r\n\t\t\t\tif(wDescr->wheelFlags & E_WF_USE_WHEELSHAPE)\r\n\t\t\t\t{\r\n\t\t\t\t\tpWheel2 * wheel2 = (pWheel2*)wheel;\r\n\t\t\t\t\twheel2->setWheelShape((NxWheelShape*)shape);\r\n\r\n\t\t\t\t}else{\t\r\n\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (wheel->getWheelFlag(E_WF_VEHICLE_CONTROLLED) && mVehicle)\r\n\t\t\t\t\tmVehicle->getWheels().push_back(wheel);\r\n\r\n\t\t\t\twheel->mWheelFlags = wDescr->wheelFlags;\r\n\t\t\t\tsInfo->wheel = wheel;\r\n\t\t\t\twheel->setEntID(srcRefEntity->GetID());\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n*/// DistributedNetworkClassDialogToolbarDlg.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx.h\"\r\n#include \"DistributedNetworkClassDialogEditor.h\"\r\n#include \"DistributedNetworkClassDialogToolbarDlg.h\"\r\n\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nDllToolbarDlg*\tfCreateToolbarDlg(HWND parent)\r\n{\r\n\tHRESULT r = CreateDllDialog(parent,IDD_TOOLBAR,&g_Toolbar);\r\n\treturn (DllToolbarDlg*)g_Toolbar;\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogToolbarDlg dialog\r\n\r\n\r\nDistributedNetworkClassDialogToolbarDlg::DistributedNetworkClassDialogToolbarDlg(CWnd* pParent /*=NULL*/)\r\n\t: DllToolbarDlg(DistributedNetworkClassDialogToolbarDlg::IDD, pParent)\r\n{\r\n\t//{{AFX_DATA_INIT(DistributedNetworkClassDialogToolbarDlg)\r\n\t\t// NOTE: the ClassWizard will add member initialization here\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\n\r\nvoid DistributedNetworkClassDialogToolbarDlg::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tDllToolbarDlg::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(DistributedNetworkClassDialogToolbarDlg)\r\n\t\t// NOTE: the ClassWizard will add DDX and DDV calls here\r\n\t//}}AFX_DATA_MAP\r\n}\r\n\r\n\r\nBEGIN_MESSAGE_MAP(DistributedNetworkClassDialogToolbarDlg, DllToolbarDlg)\r\n\t//{{AFX_MSG_MAP(DistributedNetworkClassDialogToolbarDlg)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogToolbarDlg message handlers\r\n\r\nBOOL DistributedNetworkClassDialogToolbarDlg::PreTranslateMessage(MSG* pMsg) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\t\r\n\treturn DllToolbarDlg::PreTranslateMessage(pMsg);\r\n}\r\n\r\nBOOL DistributedNetworkClassDialogToolbarDlg::OnInitDialog() \r\n{\r\n\tDllToolbarDlg::OnInitDialog();\r\n\t\r\n\t// TODO: Add extra initialization here\r\n\t\r\n\t\r\n\tActivateClosebutton();\r\n\treturn TRUE; // return TRUE unless you set the focus to a control\r\n\t // EXCEPTION: OCX Property Pages should return FALSE\r\n}\r\n\r\n//this is the almost equivalent of OnInitDialog you should use if you want to\r\n//use the PluginInterface with GetInterface or if you want to be sure the editor is present\r\nvoid DistributedNetworkClassDialogToolbarDlg::OnInterfaceInit()\r\n{\r\n}\r\n\r\n//called on WM_DESTROY\r\nvoid DistributedNetworkClassDialogToolbarDlg::OnInterfaceEnd() \r\n{\r\n}\r\n\r\nHRESULT DistributedNetworkClassDialogToolbarDlg::ReceiveNotification(UINT MsgID,DWORD Param1,DWORD Param2,CKScene* Context)\r\n{\r\n\treturn 0;\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"IParameter.h\"\r\n#include \r\n\r\nbool pPivotSettings::isValid()\r\n{\r\n\treturn true;\r\n\r\n}\r\n\r\nbool pObjectDescr::setToDefault()\r\n{\r\n\r\n\thullType =HT_Sphere;\r\n\tdensity = 1.0f;\r\n\tmassOffset = VxVector();\r\n\tshapeOffset = VxVector();\r\n\tflags = (BodyFlags)0;\r\n\tskinWidth =0.0f;\r\n\tnewDensity = 0.0f;\r\n\ttotalMass = 0.0f;\r\n\tcollisionGroup = 0;\r\n\thirarchy = 0;\r\n\tsubEntID = -1;\r\n\ttransformationFlags = 0;\r\n\tworlReference = 0;\r\n\r\n\r\n\tinternalXmlID = externalXmlID = xmlImportFlags = 0;\r\n\r\n\tmassOffsetReference = 0;\r\n\r\n\tpivotOffsetReference = 0;\r\n\r\n\r\n\tccdMotionThresold = 0.0;\r\n\tccdFlags = 0 ;\r\n\tccdMeshReference =NULL;\r\n\tccdScale = 1.0f;\r\n\r\n\tlinearDamping = angularDamping = 0.0f;\r\n\r\n\tlinearSleepVelocity = angularSleepVelocity = sleepingEnergyThresold = 0.0f;\r\n\r\n\tsolverIterations = dominanceGroups = compartmentID = 0;\r\n\r\n\tversion = OD_DECR_V0;\r\n\tmask = (pObjectDescrMask)0;\r\n\r\n\tgroupsMask.bits0=0;\r\n\tgroupsMask.bits1=0;\r\n\tgroupsMask.bits2=0;\r\n\tgroupsMask.bits3=0;\r\n\r\n\r\n\twheel.setToDefault();\r\n\toptimization.setToDefault();\r\n\tmaterial.setToDefault();\r\n\tcollision.setToDefault();\r\n\tpivot.setToDefault();\r\n\t//mass.setToDefault();\r\n\tccd.setToDefault();\r\n\r\n\r\n\treturn true;\r\n}\r\n\r\nbool pCollisionSettings::setToDefault()\r\n{\r\n\tcollisionGroup = 0;\r\n\tcollisionGroup = 0;\r\n\tskinWidth = 0.025f;\r\n\treturn true;\r\n}\r\n\r\nbool pPivotSettings::setToDefault()\r\n{\r\n\tpivotReference = 0;\r\n\treturn true;\r\n}\r\nbool pCCDSettings::setToDefault()\r\n{\r\n\tmotionThresold = 0.0;\r\n\tflags = 0 ;\r\n\tmeshReference =0;\r\n\tscale = 1.0f;\r\n\r\n\treturn true;\r\n}\r\n\r\nbool pOptimization::setToDefault()\r\n{\r\n\ttransformationFlags = (BodyLockFlags)0;\r\n\r\n\tlinDamping = angDamping = 0.0f;\r\n\tsolverIterations = 24 ;\r\n\tdominanceGroup=0;\r\n\tcompartmentGroup=0;\r\n\tsleepEnergyThreshold =0.0f;\r\n\tlinSleepVelocity = angSleepVelocity = 0.0;\r\n\r\n\treturn true;\r\n\r\n}\r\nbool pOptimization::isValid()\r\n{\r\n\r\n\tbool result = true;\r\n\t\r\n\tiAssertWR( X_IS_BETWEEN(solverIterations,1,255) ,solverIterations=24,result );\r\n\tiAssertWR( !(linDamping < 0) ,\"\",result );\r\n\tiAssertWR( !(angDamping< 0) ,\"\",result );\r\n\tiAssertWR( !(transformationFlags < 0) ,transformationFlags=((BodyLockFlags)0),result );\r\n\tiAssertWR( !(linSleepVelocity < 0) ,\"\",result );\r\n\tiAssertWR( !(angSleepVelocity < 0) ,\"\",result );\r\n\r\n\r\n\treturn true;\r\n\r\n}\r\nbool pMaterial::isValid()\r\n{\r\n\tbool result = true;\r\n\r\n\t\r\n\tiAssertWR( !(dynamicFriction < 0.0f) ,\"\",result );\r\n\tiAssertWR( !(staticFriction < 0.0f) ,\"\",result );\r\n\tiAssertWR( !(restitution < 0.0f || restitution > 1.0f) ,\"\",result );\r\n\r\n\tif (flags & 1)\r\n\t{\r\n\t\tfloat sMagnitude = dirOfAnisotropy.SquareMagnitude();\r\n\t\tiAssertWR( sMagnitude > 0.98f || sMagnitude < 1.03f ,\"\",result );\r\n\t\tiAssertWR( !(dynamicFrictionV < 0.0f) ,\"\",result );\r\n\t\tiAssertWR( !(staticFrictionV < 0.0f) ,\"\",result );\r\n\t}\r\n\t\r\n\tiAssertWR( frictionCombineMode <= 4 ,\"\",result );\r\n\tiAssertWR( restitutionCombineMode <= 4 ,\"\",result );\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nbool pConvexCylinderSettings::setToDefault()\r\n{\r\n\tradius.setToDefault();\r\n\theight.setToDefault();\r\n\tapproximation = 4;\r\n\r\n\tdownAxis.Set(0,-1,0);\r\n\trightAxis.Set(1,0,0);\r\n\tforwardAxis.Set(0,0,1);\r\n\r\n\tconvexFlags = CF_ComputeConvex;\r\n\r\n\r\n\treturn true;\r\n\r\n}\r\nbool pConvexCylinderSettings::isValid()\r\n{\r\n\r\n\tbool result=true;\r\n\tiAssertWR(radius.isValid(),\"\",result);\r\n\tiAssertWR(height.isValid(),\"\",result);\r\n\tiAssertWR(approximation >= 4 && approximation > 0,\"\",result);\r\n\tiAssertWR( XAbs(forwardAxis.SquareMagnitude()) > 0.1f || forwardAxisRef,\"\",result);\r\n\tiAssertWR( XAbs(downAxis.SquareMagnitude()) > 0.1f || downAxisRef,\"\",result);\r\n\tiAssertWR( XAbs(rightAxis.SquareMagnitude()) > 0.1f || rightAxisRef,\"\",result);\r\n\r\n\treturn result;\r\n}\r\n\r\nbool pAxisReferencedLength::isValid()\r\n{\r\n\treturn ( referenceAxis<3\t&& referenceAxis >=0) && (value > 0.0f || reference ) ;\r\n}\r\n\r\nbool pAxisReferencedLength::evaluate(CKBeObject *referenceObject)\r\n{\r\n\tif (!reference && referenceObject)\r\n\t{\r\n\t\tthis->reference = referenceObject;\r\n\t}\r\n\t\r\n\tif (reference)\r\n\t{\r\n\t\tVxVector size;\r\n\t\t\r\n\t\tif (reference->GetClassID() == CKCID_3DOBJECT )\r\n\t\t{\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)reference;\r\n\t\t\tif (ent && ent->GetCurrentMesh() )\r\n\t\t\t\tsize = ent->GetCurrentMesh()->GetLocalBox().GetSize();\r\n\t\t}\r\n\t\telse if(reference->GetClassID() == CKCID_MESH)\r\n\t\t{\r\n\t\t\tCKMesh *mesh = (CKMesh*)reference;\r\n\t\t\tif (mesh)\r\n\t\t\t{\r\n\t\t\t\tsize = mesh->GetLocalBox().GetSize();\r\n\t\t\t}\r\n\t\t}\r\n\t\tvalue = size[referenceAxis];\r\n\t\treturn XAbs(size.SquareMagnitude()) >0.0f;\r\n\t}\r\n\treturn false;\r\n}\r\nbool pAxisReferencedLength::setToDefault()\r\n{\r\n\tvalue=0.0f;\r\n\treferenceAxis = 0;\r\n\treference = NULL;\r\n\r\n\treturn true;\r\n}\r\n\r\nbool pCapsuleSettingsEx::setToDefault()\r\n{\r\n\tradius.setToDefault();\r\n\theight.setToDefault();\r\n\treturn true;\r\n}\r\nbool pCapsuleSettingsEx::isValid()\r\n{\r\n\treturn radius.isValid() && height.isValid();\r\n}\r\n\r\n\r\n#include \"pDifferential.h\"\n\n\nvoid pDifferential::setToDefault()\n{\n\n\ttype = 1;\n\tSetRatio(2.53f);\n\tSetInertia(0.15f);\n\tlockingCoeff = 275.0f;\n\t\n\n}\npDifferential::pDifferential(pVehicle *_car)\n : pDriveLineComp()\n{\n SetName(\"differential\");\n\n car=_car;\n type=FREE;\n lockingCoeff=0;\n powerAngle=coastAngle=0;\n clutches=0;\n clutchFactor=0;\n flags=0;\n Reset();\n\n setToDefault();\n}\npDifferential::~pDifferential()\n{\n}\n\nvoid pDifferential::Reset()\n{\n torqueIn=0;\n torqueOut[0]=torqueOut[1]=0;\n torqueBrakingOut[0]=torqueBrakingOut[1]=0;\n inertiaIn=0;\n inertiaOut[0]=inertiaOut[1]=0;\n accIn=0;\n accOut[0]=accOut[1]=0;\n torqueLock=0;\n rotVdriveShaft=0;\n \n velASymmetric=0;\n locked=0;\n\n engine=0;\n wheel[0]=wheel[1]=0;\n \n pDriveLineComp::Reset();\n}\n/********\n* Input *\n********/\nvoid pDifferential::Lock(int wheel)\n// Lock a side (0 or 1)\n// The wheel calls this function as soon as it sees rotational\n// velocity reversal (the wheel from moving forward suddenly starts\n// moving backward due to (mostly) braking or rolling resistance)\n// In CalcForces(), the side can be unlocked again if the reaction\n// torques exceed the (potential) braking torque.\n{\n locked|=(1<'s naming convention\n float j1,j2,j3, // Inertia of output1/output2/input\n jw, // Total inertia of wheels\n jt, // Total inertia of all attached components\n jd; // Difference of wheel inertia's\n float m0, // Locking torque\n m1, // Output1 torque\n m2, // Output2 torque\n m3; // Input torque (from the engine probably)\n float mt, // Total net torque\n md; // Asymmetric torque (?)\n float det;\n\n // Check that everything is ok\n if(!engine)return;\n if(wheel[0]==0||wheel[1]==0)return;\n \n // Note that no ratios are used here; the input and outputs\n // are geared 1:1:1. This makes the formulas easier. To add\n // a differential ratio, the other functions for the input torques\n // take care of this.\n#ifdef LTRACE\n\tqdbg(\"RDiff:CalcForces()\\n\");\n#endif\n // Retrieve current effective inertia\n // The base is the driveshaft; the accelerations and torques are\n // related to its position in the drivetrain.\n#ifdef ND_DRIVELINE\n inertiaIn=engine->GetInertiaAtDifferential();\n inertiaOut[0]=wheel[0]->GetRotationalInertia()->x;\n inertiaOut[1]=wheel[1]->GetRotationalInertia()->x;\n#else\n inertiaIn=1;\n inertiaOut[0]=1;\n inertiaOut[1]=1;\n#endif\n \n // Retrieve torques at all ends\n // Notice that inside the diff, there can be a ratio. If this is 2 for\n // example, the driveshaft will rotate twice as fast as the wheel axles.\n#ifdef ND_DRIVELINE\n torqueIn=engine->GetTorqueAtDifferential();\n#else\n torqueIn=1;\n#endif\n /*\n torqueOut[0]=wheel[0]->GetTorqueFeedbackTC()->x;\n torqueOut[1]=wheel[1]->GetTorqueFeedbackTC()->x;\n */\n // Retrieve potential braking torque; if bigger than the reaction\n // torque, the output will become unlocked. If not, the output is\n // locked.\n // Note that the braking torque already points in the opposite\n // direction of the output (mostly a wheel) rotation. This is contrary\n // to Gregor Veble's approach, which only calculates the direction\n // in the formulae below.\n \n /*\n\ttorqueBrakingOut[0]=wheel[0]->GetTorqueBrakingTC()->x;\n\ttorqueBrakingOut[1]=wheel[1]->GetTorqueBrakingTC()->x;\n */\n#ifdef LTRACE\n\tqdbg(\" torqueIn=%f, torqueOut0=%f, 1=%f\\n\",torqueIn,torqueOut[0],torqueOut[1]);\n#endif\n\n // Proceed to Gregor's naming convention and algorithm\n // Determine locking\n switch(type)\n {\n case FREE:\n // No locking; both wheels run free\n m0=0;\n break;\n case VISCOUS:\n// velASymmetric=wheel[1]->GetRotationV()-wheel[0]->GetRotationV();\n m0=-lockingCoeff*velASymmetric;\n#ifdef LTRACE\nqdbg(\" velASymm=%f, lockCoeff=%f => m0=%f\\n\",velASymmetric,lockingCoeff,m0);\n#endif\n break;\n case SALISBURY:\n // Salisbury diff locks based on the ratio of reaction torques on\n // the tires.\n // Calculate torque bias ratio\n if(fabs(torqueOut[1])>D3_EPSILON)\n torqueBiasRatio=torqueOut[0]/torqueOut[1];\n else if(fabs(torqueOut[0])>D3_EPSILON)\n torqueBiasRatio=torqueOut[1]/torqueOut[0];\n else\n torqueBiasRatio=1; // Both wheels doing pretty much nothing\n // Get a number which always has a ratio>1\n if(torqueBiasRatio<1.0)torqueBiasRatioAbs=1.0f/torqueBiasRatio;\n else torqueBiasRatioAbs=torqueBiasRatio;\n // Is the ratio exceeded?\n//xxxx continue here\n if(torqueIn>0)\n {\n // Power\n if(torqueBiasRatioAbs>maxBiasRatioPower);\n }\n m0=0; break;\n default:\n m0=0; break;\n }\n m3=torqueIn; // Entails engine braking already\n#ifdef LTRACE\nqdbg(\" torqueIn=%f, locked=%d\\n\",m3,locked);\n#endif\n\n j1=inertiaOut[0];\n j2=inertiaOut[1];\n j3=inertiaIn;\n jw=j1+j2;\n jt=jw+j3;\n jd=j1-j2; // Inertia difference (of outputs)\n // Calculate determinant of 2x2 matrix\n det=4.0f*j1*j2+j3*jw;\n\n m3=torqueIn;\n switch(locked)\n {\n case 0: // No outputs locked\n m1=torqueOut[0]+torqueBrakingOut[0];\n m2=torqueOut[1]+torqueBrakingOut[1];\n//qdbg(\" m1=%f, m2=%f\\n\",m1,m2);\n break;\n case 1:\n // Output 0 is locked, output 1 is unlocked\n m2=torqueOut[1]+torqueBrakingOut[1];\n m1=(m2*j3-2.0f*m3*j2-m0*(2.0f*j2+j3))/(4.0f*j2+j3);\n if(fabs(m1-torqueOut[0])>fabs(torqueBrakingOut[0]))\n locked=0;\n break;\n case 2:\n // Output 1 is locked, output 0 is unlocked\n m1=torqueOut[0]+torqueBrakingOut[0];\n m2=(m1*j3-2.0f*m3*j1+m0*(2.0f*j1+j3))/(4.0f*j1+j3);\n if(fabs(m2-torqueOut[1])>fabs(torqueBrakingOut[1]))\n locked=0;\n break;\n case 3:\n // Both outputs locked\n m1=-m3/2.0f;\n m2=m1;\n m0=0;\n if(fabs(m1-torqueOut[0])>fabs(torqueBrakingOut[0]))\n locked^=1;\n if(fabs(m2-torqueOut[1])>fabs(torqueBrakingOut[1]))\n locked^=2;\n break;\n default:\n //qerr(\"Bug: pDifferential locked not in 0..3 (%d)\",locked);\n m1=m2=0;\n break;\n }\n mt=m1+m2+m3;\n md=m2-m1+m0;\n\n // Calculate asymmetric acceleration\n accASymmetric=md/jw;\n#ifdef ND_OLD_NAMES\n accASymmetric=(torqueOut[1]-torqueOut[0]+torqueLock)/\n (inertiaOut[0]+inertiaOut[1]);\n#endif\n\n // Calculate total acceleration based on all torques\n // (which is in fact the driveshaft rotational acceleration)\n accIn=mt/jt;\n#ifdef ND_OLD_NAMES\n accIn=(torqueIn+torqueOut[0]+torqueOut[1])/\n (inertiaIn+inertiaOut[0]+inertiaOut[1]);\n#endif\n \n // Derive from these the acceleration of the 2 output parts\n accOut[1]=accIn+accASymmetric;\n accOut[0]=accIn-accASymmetric;\n \n // Add torque to body because of the accelerating drivetrain\n // This gives a bit of the GPL effect where your car rolls when\n // you throttle with the clutch disengaged.\n/* \n float tr=car->GetEngine()->GetTorqueReaction();\n if(tr>0)\n {\n DVector3 torque(0,0,accIn*inertiaIn*tr);\n//qdbg(\"torque.z=%f\\n\",torque.z);\n car->GetBody()->AddBodyTorque(&torque);\n }\n*/\n\n#ifdef LTRACE\n\tqdbg(\"inertia: I%f, O %f, %f\\n\",inertiaIn,inertiaOut[0],inertiaOut[1]);\n\tqdbg(\"torqueBraking: I%f, O %f, %f\\n\",0,torqueBrakingOut[0],\n\ttorqueBrakingOut[1]);\n\tqdbg(\"torque: I%f, O %f, %f, locking %f\\n\",m3,m1,m2,m0);\n\tqdbg(\"Vel: wheel0=%f, wheel1=%f\\n\",wheel[0]->GetRotationV(),\n\twheel[1]->GetRotationV());\n\tqdbg(\"Acc: asym %f, in %f, out %f, %f\\n\",accASymmetric,accIn,\n\taccOut[0],accOut[1]);\n#endif\n}\n\nfloat pDifferential::CalcLockingTorque()\n// Calculates the locking torque of the differential\n{\n float m0;\n\n switch(type)\n {\n case FREE:\n // No locking; both wheels run free\n m0=0;\n break;\n case VISCOUS:\n //velASymmetric=wheel[1]->GetRotationV()-wheel[0]->GetRotationV();\n m0=-lockingCoeff*velASymmetric;\n#ifdef LTRACE\nqdbg(\" velASymm=%f, lockCoeff=%f => m0=%f\\n\",velASymmetric,lockingCoeff,m0);\n#endif\n break;\n case SALISBURY:\n // Salisbury diff locks based on the ratio of reaction torques on\n // the tires.\n // Calculate torque bias ratio\n if(fabs(torqueOut[1])>D3_EPSILON)\n torqueBiasRatio=torqueOut[0]/torqueOut[1];\n else if(fabs(torqueOut[0])>D3_EPSILON)\n torqueBiasRatio=torqueOut[1]/torqueOut[0];\n else\n torqueBiasRatio=1; // Both wheels doing pretty much nothing\n // Get a number which always has a ratio>1\n if(torqueBiasRatio<1.0)torqueBiasRatioAbs=1.0f/torqueBiasRatio;\n else torqueBiasRatioAbs=torqueBiasRatio;\n // Is the ratio exceeded?\n//xxxx continue here\n if(torqueIn>0)\n {\n // Power\n if(torqueBiasRatioAbs>maxBiasRatioPower);\n }\n m0=0; break;\n default:\n //qwarn(\"pDifferential:CalcLockingTorque(); unknown diff type\");\n m0=0; break;\n }\n return m0;\n}\n\nvoid pDifferential::CalcSingleDiffForces(float torqueIn,float inertiaIn)\n// Special version in case there is only 1 differential.\n// Differences with regular operating:\n// - 'torqueIn' is directly passed in from the driveline root (engine).\n// - 'inertiaIn' is directly passed from the driveline (engine's eff. inertia)\n// Calculates accelerations of the 3 sides of the differential\n// based on incoming torques and inertia's.\n// Also unlocks sides (only the wheels can be locked for now)\n// if the engine torques exceeds the reaction/braking torque\n// (if that side was locked, see Lock())\n{\n // 's naming convention\n float j1,j2,j3, // Inertia of output1/output2/input\n jw, // Total inertia of wheels\n jt, // Total inertia of all attached components\n jd; // Difference of wheel inertia's\n float m0, // Locking torque\n m1, // Output1 torque\n m2, // Output2 torque\n m3; // Input torque (from the engine probably)\n float mt, // Total net torque\n md; // Asymmetric torque (?)\n float det;\n\n // Check that everything is ok\n if(!engine)return;\n if(wheel[0]==0||wheel[1]==0)return;\n \n // Note that no ratios are used here; the input and outputs\n // are geared 1:1:1. This makes the formulas easier. To add\n // a differential ratio, the other functions for the input torques\n // take care of this.\n#ifdef LTRACE\nqdbg(\"RDiff:CalcSingleDiffForces(%.2f)\\n\",torqueIn);\n#endif\n // Retrieve current effective inertia\n // The base is the driveshaft; the accelerations and torques are\n // related to its position in the drivetrain.\n //inertiaIn=engine->GetInertiaAtDifferential();\n\n\t//inertiaOut[0]=wheel[0]->GetInertia();\n\t//inertiaOut[1]=wheel[1]->GetInertia();\n \n // Retrieve torques at all ends\n // Notice that inside the diff, there can be a ratio. If this is 2 for\n // example, the driveshaft will rotate twice as fast as the wheel axles.\n //torqueIn=engine->GetTorqueAtDifferential();\n// torqueOut[0]=wheel[0]->GetTorqueFeedbackTC()->x;\n //torqueOut[1]=wheel[1]->GetTorqueFeedbackTC()->x;\n\n // Retrieve potential braking torque; if bigger than the reaction\n // torque, the output will become unlocked. If not, the output is\n // locked.\n // Note that the braking torque already points in the opposite\n // direction of the output (mostly a wheel) rotation. This is contrary\n // to 's approach, which only calculates the direction\n // in the formulae below.\n// torqueBrakingOut[0]=wheel[0]->GetTorqueBrakingTC()->x;\n// torqueBrakingOut[1]=wheel[1]->GetTorqueBrakingTC()->x;\n#ifdef LTRACE\nqdbg(\" torqueIn=%f, torqueOut0=%f, 1=%f\\n\",torqueIn,\n torqueOut[0],torqueOut[1]);\n#endif\n\n // Proceed to Gregor's naming convention and algorithm\n // Determine locking\n m0=CalcLockingTorque();\n#ifdef OBS\n switch(type)\n {\n case FREE:\n // No locking; both wheels run free\n m0=0;\n break;\n case VISCOUS:\n velASymmetric=wheel[1]->GetRotationV()-wheel[0]->GetRotationV();\n m0=-lockingCoeff*velASymmetric;\n#ifdef LTRACE\nqdbg(\" velASymm=%f, lockCoeff=%f => m0=%f\\n\",velASymmetric,lockingCoeff,m0);\n#endif\n break;\n case SALISBURY:\n // Salisbury diff locks based on the ratio of reaction torques on\n // the tires.\n // Calculate torque bias ratio\n if(fabs(torqueOut[1])>D3_EPSILON)\n torqueBiasRatio=torqueOut[0]/torqueOut[1];\n else if(fabs(torqueOut[0])>D3_EPSILON)\n torqueBiasRatio=torqueOut[1]/torqueOut[0];\n else\n torqueBiasRatio=1; // Both wheels doing pretty much nothing\n // Get a number which always has a ratio>1\n if(torqueBiasRatio<1.0)torqueBiasRatioAbs=1.0f/torqueBiasRatio;\n else torqueBiasRatioAbs=torqueBiasRatio;\n // Is the ratio exceeded?\n//xxxx continue here\n if(torqueIn>0)\n {\n // Power\n if(torqueBiasRatioAbs>maxBiasRatioPower);\n }\n m0=0; break;\n default:\n m0=0; break;\n }\n#endif\n\n m3=torqueIn; // Entails engine braking already\n#ifdef LTRACE\nqdbg(\" torqueIn=%f, locked=%d\\n\",m3,locked);\n#endif\n\n j1=inertiaOut[0];\n j2=inertiaOut[1];\n j3=inertiaIn;\n jw=j1+j2;\n jt=jw+j3;\n jd=j1-j2; // Inertia difference (of outputs)\n // Calculate determinant of 2x2 matrix\n det=4.0f*j1*j2+j3*jw;\n\n m3=torqueIn;\n switch(locked)\n {\n case 0: // No outputs locked\n m1=torqueOut[0]+torqueBrakingOut[0];\n m2=torqueOut[1]+torqueBrakingOut[1];\n//qdbg(\" m1=%f, m2=%f\\n\",m1,m2);\n break;\n case 1:\n // Output 0 is locked, output 1 is unlocked\n m2=torqueOut[1]+torqueBrakingOut[1];\n m1=(m2*j3-2.0f*m3*j2-m0*(2.0f*j2+j3))/(4.0f*j2+j3);\n if(fabs(m1-torqueOut[0])>fabs(torqueBrakingOut[0]))\n locked=0;\n break;\n case 2:\n // Output 1 is locked, output 0 is unlocked\n m1=torqueOut[0]+torqueBrakingOut[0];\n m2=(m1*j3-2.0f*m3*j1+m0*(2.0f*j1+j3))/(4.0f*j1+j3);\n if(fabs(m2-torqueOut[1])>fabs(torqueBrakingOut[1]))\n locked=0;\n break;\n case 3:\n // Both outputs locked\n m1=-m3/2.0f;\n m2=m1;\n m0=0;\n if(fabs(m1-torqueOut[0])>fabs(torqueBrakingOut[0]))\n locked^=1;\n if(fabs(m2-torqueOut[1])>fabs(torqueBrakingOut[1]))\n locked^=2;\n break;\n default:\n //qerr(\"Bug: pDifferential locked not in 0..3 (%d)\",locked);\n m1=m2=0;\n break;\n }\n mt=m1+m2+m3;\n md=m2-m1+m0;\n\n // Calculate asymmetric acceleration\n accASymmetric=md/jw;\n#ifdef ND_OLD_NAMES\n accASymmetric=(torqueOut[1]-torqueOut[0]+torqueLock)/\n (inertiaOut[0]+inertiaOut[1]);\n#endif\n\n // Calculate total acceleration based on all torques\n // (which is in fact the driveshaft rotational acceleration)\n accIn=mt/jt;\n#ifdef ND_OLD_NAMES\n accIn=(torqueIn+torqueOut[0]+torqueOut[1])/\n (inertiaIn+inertiaOut[0]+inertiaOut[1]);\n#endif\n \n // Derive from these the acceleration of the 2 output parts\n accOut[1]=accIn+accASymmetric;\n accOut[0]=accIn-accASymmetric;\n \n // Add torque to body because of the accelerating drivetrain\n // This gives a bit of the GPL effect where your car rolls when\n // you throttle with the clutch disengaged.\n /*\n float tr=car->GetEngine()->GetTorqueReaction();\n if(tr>0)\n {\n DVector3 torque(0,0,accIn*inertiaIn*tr);\n//qdbg(\"torque.z=%f\\n\",torque.z);\n car->GetBody()->AddBodyTorque(&torque);\n }\n */\n\n#ifdef LTRACE\n\tqdbg(\"inertia: I%f, O %f, %f\\n\",inertiaIn,inertiaOut[0],inertiaOut[1]);\n\tqdbg(\"torqueBraking: I%f, O %f, %f\\n\",0,torqueBrakingOut[0],\n\ttorqueBrakingOut[1]);\n\tqdbg(\"torque: I%f, O %f, %f, locking %f\\n\",m3,m1,m2,m0);\n\tqdbg(\"Vel: wheel0=%f, wheel1=%f\\n\",wheel[0]->GetRotationV(),\n\twheel[1]->GetRotationV());\n\tqdbg(\"Acc: asym %f, in %f, out %f, %f\\n\",accASymmetric,accIn,\n\taccOut[0],accOut[1]);\n#endif\n}\n/************\n* Integrate *\n************/\nvoid pDifferential::Integrate()\n// Maintain differential objects rotations\n{\n float rotAds;\n \n // Check that everything is ok\n if(!engine)return;\n if(wheel[0]==0||wheel[1]==0)return;\n \n // Driveshaft rotation\n rotAds=accIn;\n#ifdef OBS_DIRECTLY_LINKED_TO_WHEELS\n rotVdriveShaft+=rotAds*RR_TIMESTEP;\n#endif\n //rotVdriveShaft=(wheel[0]->GetRotationV()+wheel[1]->GetRotationV())/2.0f;\n}\n\n\n/*\nbool pDifferential::LoadState(QFile *f)\n{\n\tRDriveLineComp::LoadState(f);\n\tf->Read(&rotVdriveShaft,sizeof(rotVdriveShaft));\n\tf->Read(&locked,sizeof(locked));\n\treturn TRUE;\n}\nbool pDifferential::SaveState(QFile *f)\n{\n\tRDriveLineComp::SaveState(f);\n\tf->Write(&rotVdriveShaft,sizeof(rotVdriveShaft));\n\tf->Write(&locked,sizeof(locked));\n\treturn TRUE;\n}\n\nbool pDifferential::Load(QInfo *info,cstring path)\n// Read settings from the car file\n{\n\tchar buf[256];\n\n\tsprintf(buf,\"%s.type\",path);\n\ttype=info->GetInt(buf);\n\t// Read the ratio\n\tsprintf(buf,\"%s.ratio\",path);\n\tif(info->PathExists(buf))\n\t{\n\t\tSetRatio(info->GetFloat(buf));\n\t\t//qdbg(\"Diff ratio (%s) = %.2f\\n\",buf,ratio);\n\t} else\n\t{\n\t\t// Backward compatible (v0.4.9 and before); use old gearbox setting\n\t\tqwarn(\"No differential ratio in car.ini; using gearbox.end_ratio instead\");\n\t\tqwarn(\"(this is obsolete; use differential.diff.ratio from now on)\");\n\t\tSetRatio(info->GetFloat(\"gearbox.end_ratio\"));\n\t}\n\tsprintf(buf,\"%s.inertia\",path);\n\tSetInertia(info->GetFloat(buf));\n\n\t// Type-specific parameters\n\tif(type==VISCOUS)\n\t{\n\t\t// Viscous locking differential\n\t\tsprintf(buf,\"%s.locking_coeff\",path);\n\t\tlockingCoeff=info->GetFloat(buf);\n\t} else if(type==SALISBURY)\n\t{\n\t\t// Salisbury (known from GPL)\n\t\tsprintf(buf,\"%s.power_angle\",path);\n\t\tpowerAngle=info->GetFloat(buf)/RR_RAD2DEG;\n\t\tsprintf(buf,\"%s.coast_angle\",path);\n\t\tcoastAngle=info->GetFloat(buf)/RR_RAD2DEG;\n\t\tsprintf(buf,\"%s.clutches\",path);\n\t\tclutches=info->GetInt(buf);\n\t\tsprintf(buf,\"%s.clutch_factor\",path);\n\t\tclutchFactor=info->GetFloat(buf);\n\n\t\t// Calculate resulting constants\n\t\tmaxBiasRatioPower=cos(powerAngle)*(1.0+2.0*clutches)*clutchFactor;\n\t\tmaxBiasRatioCoast=cos(coastAngle)*(1.0+2.0*clutches)*clutchFactor;\n\t}\n\treturn TRUE;\n}\n*/#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xMathTools.h\"\r\n\r\n\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n\r\nvoid\r\nvtNetworkManager::updateLocalRotation(xDistributedObject* distObject,CK3dEntity *target,xDistributedProperty*prop)\r\n{\r\n\r\n\r\n\tif (!distObject || !target || !prop)return;\r\n\r\n\txDistributedQuatF*propValue = static_cast(prop);\r\n\tif (!propValue)return;\r\n\r\n\txDistributed3DObject *dobj3D = static_cast(distObject);\r\n\tif (!dobj3D)return;\r\n\r\n\tswitch(prop->getPropertyInfo()->mNativeType)\r\n\t{\r\n\tcase E_DC_3D_NP_WORLD_ROTATION:\r\n\t\t{\r\n\t\t\tQuatF currentRot = propValue->mLastServerValue;\r\n\t\t\tVxQuaternion t(currentRot.x,currentRot.y,currentRot.z,currentRot.w);\r\n\t\t\ttarget->SetQuaternion(&t,NULL,false,TRUE);\r\n\r\n\t\t\t/*\r\n\t\t\tPoint4F currentPos = propValue->mLastServerValue;\r\n\t\t\tPoint4F velocity = propValue->mLastServerDifference;\r\n\r\n\t\t\tVxVector realPos;\r\n\t\t\ttarget->GetPosition(&realPos);\r\n\t\t\tPoint3F realPos2(realPos.x,realPos.y,realPos.z);\r\n\r\n\r\n\t\t\tfloat oneWayTime = (distObject->GetNetInterface()->GetConnectionTime() / 1000.0f);\r\n\t\t\toneWayTime +=oneWayTime * prop->getPredictionSettings()->getPredictionFactor();\r\n\t\t\tPoint3F predictedPos = currentPos + velocity * oneWayTime;\r\n\t\t\tPoint3F realPosDiff = - predictedPos - realPos2 ;\r\n\r\n\t\t\tVxVector posNew(predictedPos.x,predictedPos.y,predictedPos.z);\r\n\t\t\ttarget->SetPosition(&posNew);*/\r\n\r\n\t\t\t/*\r\n\t\t\tVxVector v = posNew - realPos;\r\n\t\t\tfloat current_d = Magnitude( v );\r\n\t\t\tif( current_d < 0.001f )\r\n\t\t\t{\r\n\t\t\tcurrent_d = 0.001f;\r\n\t\t\tv.Set(0,0,0.001f);\r\n\t\t\t}\r\n\r\n\t\t\tfloat attenuation = 15.0f;\r\n\t\t\t// Get the distance wanted\r\n\t\t\tfloat wanted_d = 1.0f;\r\n\t\t\twanted_d = current_d - wanted_d;\r\n\t\t\tfloat tmp;\r\n\t\t\tif(tmp = current_d * (attenuation+1.0f) )\r\n\t\t\t{\r\n\t\t\tfloat f = wanted_d / tmp;\r\n\t\t\tv *= f;\r\n\t\t\t}\r\n\t\t\t*/\r\n\t\t\t//target->Translate(&v);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid\r\nvtNetworkManager::updateLocalPosition(xDistributedObject* distObject,CK3dEntity *target,xDistributedProperty*prop)\r\n{\r\n\r\n\r\n\tif (!distObject || !target || !prop)return;\r\n\r\n\txDistributedPoint3F *propValue = static_cast(prop);\r\n\tif (!propValue)return;\r\n\r\n\txDistributed3DObject *dobj3D = static_cast(distObject);\r\n\tif (!dobj3D)return;\r\n\t\r\n\tswitch(prop->getPropertyInfo()->mNativeType)\r\n\t{\r\n\t\tcase E_DC_3D_NP_WORLD_POSITION:\r\n\t\t{\r\n\t\t\tPoint3F currentPos = propValue->mLastServerValue;\r\n\t\t\tPoint3F velocity = propValue->mLastServerDifference;\r\n\r\n\t\t\tVxVector realPos;\r\n\t\t\ttarget->GetPosition(&realPos);\r\n\t\t\tPoint3F realPos2(realPos.x,realPos.y,realPos.z);\r\n\r\n\r\n\t\t\tfloat oneWayTime = (distObject->getNetInterface()->GetConnectionTime() / 1000.0f);\r\n\t\t\toneWayTime +=oneWayTime * prop->getPredictionSettings()->getPredictionFactor();\r\n\t\t\tPoint3F predictedPos = currentPos + velocity * oneWayTime;\r\n\t\t\tPoint3F realPosDiff = - predictedPos - realPos2 ;\r\n\t\t\t\r\n\t\t\tVxVector posNew(predictedPos.x,predictedPos.y,predictedPos.z);\r\n\t\t\ttarget->SetPosition(&posNew);\r\n\r\n\t\t\t/*\r\n\t\t\tVxVector v = posNew - realPos;\r\n\t\t\tfloat current_d = Magnitude( v );\r\n\t\t\tif( current_d < 0.001f )\r\n\t\t\t{\r\n\t\t\t\tcurrent_d = 0.001f;\r\n\t\t\t\tv.Set(0,0,0.001f);\r\n\t\t\t}\r\n\r\n\t\t\tfloat attenuation = 15.0f;\r\n\t\t\t// Get the distance wanted\r\n\t\t\tfloat wanted_d = 1.0f;\r\n\t\t\twanted_d = current_d - wanted_d;\r\n\t\t\tfloat tmp;\r\n\t\t\tif(tmp = current_d * (attenuation+1.0f) )\r\n\t\t\t{\r\n\t\t\t\tfloat f = wanted_d / tmp;\r\n\t\t\t\tv *= f;\r\n\t\t\t}\r\n\t\t\t*/\r\n\t\t\t//target->Translate(&v);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pLogger.h\"\r\n#include \"pErrorStream.h\"\r\n\r\n\r\nstatic pErrorStream gErrorStream;\r\n\r\npLogger::pLogger()\r\n{\r\n\r\n\tmErrorStream = &gErrorStream;\r\n\r\n}\r\n\r\n/* A Bison parser, made by GNU Bison 2.3. */\n\n/* Skeleton interface for Bison's Yacc-like parsers in C\n\n Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006\n Free Software Foundation, Inc.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2, or (at your option)\n any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor,\n Boston, MA 02110-1301, USA. */\n\n/* As a special exception, you may create a larger work that contains\n part or all of the Bison parser skeleton and distribute that work\n under terms of your choice, so long as that work isn't itself a\n parser generator using the skeleton or a modified version thereof\n as a parser skeleton. Alternatively, if you modify or redistribute\n the parser skeleton itself, you may (at your option) remove this\n special exception, which will cause the skeleton and the resulting\n Bison output files to be licensed under the GNU General Public\n License without this special exception.\n\n This special exception was added by the Free Software Foundation in\n version 2.2 of Bison. */\n\n/* Tokens. */\n#ifndef YYTOKENTYPE\n# define YYTOKENTYPE\n /* Put the tokens into the symbol table, so that GDB and other debuggers\n know about them. */\n enum yytokentype {\n ID = 258,\n HBLOCK = 259,\n POUND = 260,\n STRING = 261,\n INCLUDE = 262,\n IMPORT = 263,\n INSERT = 264,\n CHARCONST = 265,\n NUM_INT = 266,\n NUM_FLOAT = 267,\n NUM_UNSIGNED = 268,\n NUM_LONG = 269,\n NUM_ULONG = 270,\n NUM_LONGLONG = 271,\n NUM_ULONGLONG = 272,\n TYPEDEF = 273,\n TYPE_INT = 274,\n TYPE_UNSIGNED = 275,\n TYPE_SHORT = 276,\n TYPE_LONG = 277,\n TYPE_FLOAT = 278,\n TYPE_DOUBLE = 279,\n TYPE_CHAR = 280,\n TYPE_WCHAR = 281,\n TYPE_VOID = 282,\n TYPE_SIGNED = 283,\n TYPE_BOOL = 284,\n TYPE_COMPLEX = 285,\n TYPE_TYPEDEF = 286,\n TYPE_RAW = 287,\n TYPE_NON_ISO_INT8 = 288,\n TYPE_NON_ISO_INT16 = 289,\n TYPE_NON_ISO_INT32 = 290,\n TYPE_NON_ISO_INT64 = 291,\n LPAREN = 292,\n RPAREN = 293,\n COMMA = 294,\n SEMI = 295,\n EXTERN = 296,\n INIT = 297,\n LBRACE = 298,\n RBRACE = 299,\n PERIOD = 300,\n CONST_QUAL = 301,\n VOLATILE = 302,\n REGISTER = 303,\n STRUCT = 304,\n UNION = 305,\n EQUAL = 306,\n SIZEOF = 307,\n MODULE = 308,\n LBRACKET = 309,\n RBRACKET = 310,\n ILLEGAL = 311,\n CONSTANT = 312,\n NAME = 313,\n RENAME = 314,\n NAMEWARN = 315,\n EXTEND = 316,\n PRAGMA = 317,\n FEATURE = 318,\n VARARGS = 319,\n ENUM = 320,\n CLASS = 321,\n TYPENAME = 322,\n PRIVATE = 323,\n PUBLIC = 324,\n PROTECTED = 325,\n COLON = 326,\n STATIC = 327,\n VIRTUAL = 328,\n FRIEND = 329,\n THROW = 330,\n CATCH = 331,\n EXPLICIT = 332,\n USING = 333,\n NAMESPACE = 334,\n NATIVE = 335,\n INLINE = 336,\n TYPEMAP = 337,\n EXCEPT = 338,\n ECHO = 339,\n APPLY = 340,\n CLEAR = 341,\n SWIGTEMPLATE = 342,\n FRAGMENT = 343,\n WARN = 344,\n LESSTHAN = 345,\n GREATERTHAN = 346,\n MODULO = 347,\n DELETE_KW = 348,\n LESSTHANOREQUALTO = 349,\n GREATERTHANOREQUALTO = 350,\n EQUALTO = 351,\n NOTEQUALTO = 352,\n QUESTIONMARK = 353,\n TYPES = 354,\n PARMS = 355,\n NONID = 356,\n DSTAR = 357,\n DCNOT = 358,\n TEMPLATE = 359,\n OPERATOR = 360,\n COPERATOR = 361,\n PARSETYPE = 362,\n PARSEPARM = 363,\n PARSEPARMS = 364,\n CAST = 365,\n LOR = 366,\n LAND = 367,\n OR = 368,\n XOR = 369,\n AND = 370,\n RSHIFT = 371,\n LSHIFT = 372,\n MINUS = 373,\n PLUS = 374,\n MODULUS = 375,\n SLASH = 376,\n STAR = 377,\n LNOT = 378,\n NOT = 379,\n UMINUS = 380,\n DCOLON = 381\n };\n#endif\n/* Tokens. */\n#define ID 258\n#define HBLOCK 259\n#define POUND 260\n#define STRING 261\n#define INCLUDE 262\n#define IMPORT 263\n#define INSERT 264\n#define CHARCONST 265\n#define NUM_INT 266\n#define NUM_FLOAT 267\n#define NUM_UNSIGNED 268\n#define NUM_LONG 269\n#define NUM_ULONG 270\n#define NUM_LONGLONG 271\n#define NUM_ULONGLONG 272\n#define TYPEDEF 273\n#define TYPE_INT 274\n#define TYPE_UNSIGNED 275\n#define TYPE_SHORT 276\n#define TYPE_LONG 277\n#define TYPE_FLOAT 278\n#define TYPE_DOUBLE 279\n#define TYPE_CHAR 280\n#define TYPE_WCHAR 281\n#define TYPE_VOID 282\n#define TYPE_SIGNED 283\n#define TYPE_BOOL 284\n#define TYPE_COMPLEX 285\n#define TYPE_TYPEDEF 286\n#define TYPE_RAW 287\n#define TYPE_NON_ISO_INT8 288\n#define TYPE_NON_ISO_INT16 289\n#define TYPE_NON_ISO_INT32 290\n#define TYPE_NON_ISO_INT64 291\n#define LPAREN 292\n#define RPAREN 293\n#define COMMA 294\n#define SEMI 295\n#define EXTERN 296\n#define INIT 297\n#define LBRACE 298\n#define RBRACE 299\n#define PERIOD 300\n#define CONST_QUAL 301\n#define VOLATILE 302\n#define REGISTER 303\n#define STRUCT 304\n#define UNION 305\n#define EQUAL 306\n#define SIZEOF 307\n#define MODULE 308\n#define LBRACKET 309\n#define RBRACKET 310\n#define ILLEGAL 311\n#define CONSTANT 312\n#define NAME 313\n#define RENAME 314\n#define NAMEWARN 315\n#define EXTEND 316\n#define PRAGMA 317\n#define FEATURE 318\n#define VARARGS 319\n#define ENUM 320\n#define CLASS 321\n#define TYPENAME 322\n#define PRIVATE 323\n#define PUBLIC 324\n#define PROTECTED 325\n#define COLON 326\n#define STATIC 327\n#define VIRTUAL 328\n#define FRIEND 329\n#define THROW 330\n#define CATCH 331\n#define EXPLICIT 332\n#define USING 333\n#define NAMESPACE 334\n#define NATIVE 335\n#define INLINE 336\n#define TYPEMAP 337\n#define EXCEPT 338\n#define ECHO 339\n#define APPLY 340\n#define CLEAR 341\n#define SWIGTEMPLATE 342\n#define FRAGMENT 343\n#define WARN 344\n#define LESSTHAN 345\n#define GREATERTHAN 346\n#define MODULO 347\n#define DELETE_KW 348\n#define LESSTHANOREQUALTO 349\n#define GREATERTHANOREQUALTO 350\n#define EQUALTO 351\n#define NOTEQUALTO 352\n#define QUESTIONMARK 353\n#define TYPES 354\n#define PARMS 355\n#define NONID 356\n#define DSTAR 357\n#define DCNOT 358\n#define TEMPLATE 359\n#define OPERATOR 360\n#define COPERATOR 361\n#define PARSETYPE 362\n#define PARSEPARM 363\n#define PARSEPARMS 364\n#define CAST 365\n#define LOR 366\n#define LAND 367\n#define OR 368\n#define XOR 369\n#define AND 370\n#define RSHIFT 371\n#define LSHIFT 372\n#define MINUS 373\n#define PLUS 374\n#define MODULUS 375\n#define SLASH 376\n#define STAR 377\n#define LNOT 378\n#define NOT 379\n#define UMINUS 380\n#define DCOLON 381\n\n\n\n\n#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED\ntypedef union YYSTYPE\n#line 1349 \"parser.y\"\n{\n char *id;\n List *bases;\n struct Define {\n String *val;\n String *rawval;\n int type;\n String *qualifier;\n String *bitfield;\n Parm *throws;\n String *throwf;\n } dtype;\n struct {\n char *type;\n String *filename;\n int line;\n } loc;\n struct {\n char *id;\n SwigType *type;\n String *defarg;\n ParmList *parms;\n short have_parms;\n ParmList *throws;\n String *throwf;\n } decl;\n Parm *tparms;\n struct {\n String *op;\n Hash *kwargs;\n } tmap;\n struct {\n String *type;\n String *us;\n } ptype;\n SwigType *type;\n String *str;\n Parm *p;\n ParmList *pl;\n int ivalue;\n Node *node;\n}\n/* Line 1489 of yacc.c. */\n#line 344 \"y.tab.h\"\n\tYYSTYPE;\n# define yystype YYSTYPE /* obsolescent; will be withdrawn */\n# define YYSTYPE_IS_DECLARED 1\n# define YYSTYPE_IS_TRIVIAL 1\n#endif\n\nextern YYSTYPE yylval;\n\n#include \"precomp.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"xNetworkFactory.h\"\r\n#include \"tnlRandom.h\"\r\n#include \"tnlSymmetricCipher.h\"\r\n#include \"tnlAsymmetricKey.h\"\r\n\r\n#include \"vtTools.h\"\r\n#include \"xNetworkTypes.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorArrayNetMessageWaiterDecl();\r\nCKERROR CreateArrayNetMessageWaiterProto(CKBehaviorPrototype **);\r\nint ArrayNetMessageWaiter(const CKBehaviorContext& behcontext);\r\nCKERROR ArrayNetMessageWaiterCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n//int msgCounter = 0;\r\n\r\nCKObjectDeclaration\t*FillBehaviorArrayNetMessageWaiterDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Network Wait Array Message\");\t\r\n\tod->SetDescription(\"Waits for a Message from the Network.\");\r\n\t\r\n\tod->SetCategory(\"TNL/Message\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x3bf873ad,0x5a2e47bd));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateArrayNetMessageWaiterProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateArrayNetMessageWaiterProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Network Wait Array Message\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Stop\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Message\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Message\", CKPGUID_MESSAGE, \"OnClick\");\r\n\tproto->DeclareInParameter(\"Array\", CKPGUID_DATAARRAY, \"netArray\");\r\n\tproto->DeclareInParameter(\"First Column\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Append\", CKPGUID_BOOL, \"false\");\r\n\r\n\r\n\r\n\tproto->DeclareOutParameter(\"Sender ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Private\", CKPGUID_BOOL, \"false\");\r\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_INT, \"0\");\r\n\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(ArrayNetMessageWaiter);\r\n\tproto->SetBehaviorCallbackFct(ArrayNetMessageWaiterCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint ArrayNetMessageWaiter(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\t\r\n\tint Msg=vtTools::BehaviorTools::GetInputParameterValue(beh,1);\r\n\tXString msgName(mm->GetMessageTypeName(Msg));\r\n\t\r\n\tCKDataArray *array = static_cast(vtTools::BehaviorTools::GetInputParameterValue(beh,2));\r\n\r\n\tint firstC = vtTools::BehaviorTools::GetInputParameterValue(beh,3);\r\n\r\n\tbool append = vtTools::BehaviorTools::GetInputParameterValue(beh,4);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\r\n\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif(cin->GetConnection())\r\n\t{\r\n\t\tif (!cin->isValid())\r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::Enums;\r\n\r\n\tXArrayNetworkMessageTypeIterator begin = GetNM()->GetArrayNetworkMessages().Begin();\r\n\tXArrayNetworkMessageTypeIterator end = GetNM()->GetArrayNetworkMessages().End();\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\tvtArrayNetworkMessage*msg = *begin;\r\n\t\tif (msg)\r\n\t\t{\t\r\n\t\t\t\r\n\t\t\tif ( msg->complete )\r\n\t\t\t{\r\n\t\t\t\tvtArrayNetworkMessage::ArrayTypeIterator parBegin = msg->columns.begin();\r\n\t\t\t\tvtArrayNetworkMessage::ArrayTypeIterator parEnd = msg->columns.end();\r\n\t\t\t\t\r\n\t\t\t\tint subIndex=0;\r\n\r\n\t\t\t\tint startR = append ? array->GetRowCount() : 0;\r\n\t\t\t\twhile(parBegin!=parEnd)\r\n\t\t\t\t{\r\n\t\t\t\t\tvtArrayNetworkMessage::ColumnType column = parBegin->second;\r\n\t\t\t\t\tfor (int i = 0 ; i < column.size() ; i++ )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCKParameter* para = column[i];\r\n\t\t\t\t\t\tint value = 0 ;\r\n\t\t\t\t\t\tpara->GetValue(&value);\r\n\t\t\t\t\t\tlogprintf(\"msgarray value %d\",value);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (append)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tarray->AddRow();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tarray->SetElementValueFromParameter(startR,firstC,para);\r\n\r\n\t\t\t\t\t\tstartR++;\r\n\t\t\t\t\t\tsubIndex++;\r\n\t\t\t\t\t\tCK_ID id = para->GetID();\r\n\t\t\t\t\t\tctx()->DestroyObject(id);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tparBegin++;\r\n\t\t\t\t}\r\n\t\t\t\tGetNM()->GetArrayNetworkMessages().Remove(begin);\r\n\t\t\t\tlogprintf(\"removing array by bb message !\");\r\n\t\t\t\tbegin = GetNM()->GetArrayNetworkMessages().Begin();\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\t/*int startC = 0 ; \r\n\tif (firstC < array->GetColumnCount())\r\n\t{\r\n\t}*/\r\n\r\n\t/*if (strcmp(msg->name.Str(),msgName.Str()))\r\n\t{\r\n\tcontinue;\r\n\t}*/\r\n\r\n\t/*vtArrayNetworkMessage::ArrayTypeIterator parBegin = msg->columns.begin();\r\n\tvtArrayNetworkMessage::ArrayTypeIterator parEnd = msg->columns.end();\r\n\r\n\tint subIndex=0;\r\n\twhile(parBegin!=parEnd)\r\n\t{\r\n\tvtArrayNetworkMessage::ColumnType column = parBegin->second;\r\n\r\n\tfor (int i = 0 ; i < column.size() ; i++ )\r\n\t{\r\n\tCKParameter *pin = column[i];\r\n\tCK_ID id = pin->GetID();\r\n\tctx()->DestroyObject(id);\r\n\t}\r\n\tparBegin++;\r\n\t}\r\n\tGetArrayNetworkMessages().Remove(begin);\r\n\tlogprintf(\"removing array message !\");\r\n\tbegin = GetArrayNetworkMessages().Begin();*/\r\n\r\n\r\n\t/*\r\n\tXNetworkMessagesTypeIterator begin = GetNM()->GetXNetworkMessages().Begin();\r\n\tXNetworkMessagesTypeIterator end = GetNM()->GetXNetworkMessages().End();\r\n\t\r\n\tif (!GetNM()->GetXNetworkMessages().Size())\r\n\t{\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\twhile (begin != end)\r\n\t{\r\n\t\tvtNetworkMessage*msg = *begin;\r\n\t\tif (msg)\r\n\t\t{\r\n\t\t\tif (strcmp(msg->name.Str(),msgType.Str()))\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tif ( msg->complete )\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t//logprintf(\"broadcast message recieved:%a\",msg->name.Str());\r\n\t\t\t\tvtNetworkMessage::MessageParameterArrayTypeIterator parBegin = msg->m_RecievedParameters.begin();\r\n\t\t\t\tvtNetworkMessage::MessageParameterArrayTypeIterator parEnd = msg->m_RecievedParameters.end();\r\n\r\n\t\t\t\tint subIndex=0;\r\n\t\t\t\twhile(parBegin!=parEnd)\r\n\t\t\t\t{\r\n\t\t\t\t\tCKParameter *pin = parBegin->second;\r\n\t\t\t\t\tCKParameterType pType = pin->GetType();\r\n\t\t\t\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\r\n\t\t\t\t\tswitch (sType)\r\n\t\t\t\t\t{\r\n\t\t\t\t\tcase vtSTRING:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ( (beh->GetOutputParameterCount() - BEH_OUT_MIN_COUNT ) + subIndex > 0 )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BEH_OUT_MIN_COUNT + subIndex );\r\n\t\t\t\t\t\t\t\tif (pout)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (pout->GetType() == pin->GetType() )\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tpout->CopyValue(pin);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tCK_ID id = pin->GetID();\r\n\t\t\t\t\t\t\t\tctx->DestroyObject(id);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tcase vtFLOAT:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ( (beh->GetOutputParameterCount() - BEH_OUT_MIN_COUNT ) + subIndex > 0 )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BEH_OUT_MIN_COUNT + subIndex );\r\n\t\t\t\t\t\t\t\tif (pout)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (pout->GetType() == pin->GetType() )\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tpout->CopyValue(pin);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tCK_ID id = pin->GetID();\r\n\t\t\t\t\t\t\t\tctx->DestroyObject(id);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tcase vtINTEGER:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif ( (beh->GetOutputParameterCount() - BEH_OUT_MIN_COUNT ) + subIndex > 0 )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BEH_OUT_MIN_COUNT + subIndex );\r\n\t\t\t\t\t\t\t\tif (pout)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (pout->GetType() == pin->GetType() )\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tpout->CopyValue(pin);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tCK_ID id = pin->GetID();\r\n\t\t\t\t\t\t\t\tctx->DestroyObject(id);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdefault :\r\n\t\t\t\t\t\tXString err(\"wrong input parameter type: \");\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tsubIndex++;\r\n\t\t\t\t\tparBegin++;\r\n\t\t\t\t}\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\tbeh->SetOutputParameterValue(0,&msg->srcUserID);\r\n\t\t\t\tGetNM()->GetXNetworkMessages().Remove(begin);\r\n\t\t\t\tbegin = GetNM()->GetXNetworkMessages().Begin();\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}*/\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR ArrayNetMessageWaiterCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"ISession.h\"\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xMessageTypes.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNMWaiterDecl();\r\nCKERROR CreateNMWaiterProto(CKBehaviorPrototype **);\r\nint NMWaiter(const CKBehaviorContext& behcontext);\r\nCKERROR NMWaiterCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_STOP,\r\n\tBB_IT_NEXT\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_MESSAGE,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_MESSAGE,\r\n\tBB_O_ERROR,\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_SENDER_ID,\r\n\tBB_OP_PRIVATE,\r\n\tBB_OP_ERROR,\r\n};\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNMWaiterDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NMWaiter\");\t\r\n\tod->SetDescription(\"Waits for a Message from the Network.\");\r\n\t\r\n\tod->SetCategory(\"TNL/Message\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5707744b,0x43b2301c));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNMWaiterProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNMWaiterProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NMWaiter\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareInParameter(\"Message\", CKPGUID_MESSAGE, \"OnClick\");\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Stop\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Message\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareOutParameter(\"Sender ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Private\", CKPGUID_BOOL, \"false\");\r\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_INT);\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(NMWaiter);\r\n\tproto->SetBehaviorCallbackFct(NMWaiterCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NMWaiter(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id + session name : \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tint connectionID = GetInputParameterValue(beh,BB_IP_CONNECTION_ID);\r\n\tint Msg=-1;\r\n\tbeh->GetInputParameterValue(BB_IP_MESSAGE,&Msg);\r\n\tXString msgType(mm->GetMessageTypeName(Msg));\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\t\t\t\r\n\t\t//bbError(E_NWE_NO_CONNECTION);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\t\t//bbError(E_NWE_INTERN);\r\n\t\t//Error(beh,\"No client object created\",BB_OP_SESSION_ERROR,TRUE,BB_O_ERROR);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tISession *sInterface = cin->getSessionInterface();\r\n\tIMessages *mInterface = cin->getMessagesInterface();\r\n\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\t\t//bbError(E_NWE_INTERN);\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\t/*\r\n\txDistributedSession *session = sInterface->get(myClient->getSessionID());\r\n\tif (!session)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_NO_SESSION);\r\n\t\treturn 0;\r\n\t}*/\r\n\r\n\tif (beh->IsInputActive(BB_IT_STOP))\r\n\t{\r\n\t\tbeh->ActivateInput(BB_IT_STOP,FALSE);\r\n\t\tbeh->ActivateOutput(BB_O_OUT);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\r\n\t\txMessage *msg = mInterface->getNextInMessage(msgType.CStr());\r\n\t\tif (!msg)return CKBR_ACTIVATENEXTFRAME;\r\n\r\n\t\tif ( beh->GetOutputParameterCount() > BEH_OUT_MIN_COUNT )\r\n\t\t{\r\n\r\n\t\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\t\tfor (int i = BEH_OUT_MIN_COUNT ; i < beh->GetOutputParameterCount() ; i++ )\r\n\t\t\t{\r\n\t\t\t\tCKParameterOut *ciIn = beh->GetOutputParameter(i);\r\n\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\r\n\t\t\t\tint propID = i - BEH_OUT_MIN_COUNT;\r\n\t\t\t\tif (propID>msg->getNumParameters() )\r\n\t\t\t\t{\r\n\t\t\t\t\tgoto MESSAGE_END;\r\n\t\t\t\t}\r\n\r\n\t\t\t\txDistributedProperty *prop = msg->getParameters().at(propID);\r\n\t\t\t\tif (!prop) goto MESSAGE_END;\r\n\t\t\t\t\r\n\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\tif (!propInfo) goto MESSAGE_END;\r\n\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) !=sType )\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedString * propValue = (xDistributedString*)prop;\r\n\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tTNL::StringPtr ovalue = propValue->mCurrentValue;\r\n\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(i);\r\n\t\t\t\t\t\t\tXString errorMesg(ovalue.getString());\r\n\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfloat vvalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tVxVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\txDistributedPoint2F * dpoint3F = (xDistributedPoint2F*)prop;\r\n\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tVx2DVector vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedInteger * dpoint3F = (xDistributedInteger*)prop;\r\n\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tint ovalue = dpoint3F->mLastServerValue;\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&ovalue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tVxQuaternion vvalue = xMath::getFrom(dpoint3F->mLastServerValue);\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcase E_DC_PTYPE_UNKNOWN:\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tdefault :\r\n\t\t\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n \r\n\t\tgoto MESSAGE_END;\r\n\r\n\t\tMESSAGE_END:\r\n\t\t{\r\n\r\n\t\t\t//IDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\t\t\t//xDistributedClient *dstClient = static_cast(doInterface->get(msg->getSrcUser()));\r\n\t\t\t//if (dstClient)\r\n\t\t\t//{\r\n\t\t\t\tSetOutputParameterValue(beh,BB_OP_SENDER_ID,msg->getSrcUser());\r\n\r\n\t\t\t//}\r\n\r\n\t\t\tenableFlag(msg->getFlags(),E_MF_DELETED); \r\n\t\t\tbeh->ActivateOutput(BB_O_MESSAGE);\r\n\r\n\t\t}\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR NMWaiterCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"CKAll.h\"\r\n\r\n\r\n/*****************************************************************************\r\n*\r\n* THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF\r\n* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\r\n* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR\r\n* A PARTICULAR PURPOSE.\r\n*\r\n* Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.\r\n*\r\n******************************************************************************\r\n*\r\n* SMFRead.C\r\n*\r\n* MIDI File access routines.\r\n*\r\n*****************************************************************************/\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \"muldiv32.h\"\r\n#include \"smf.h\"\r\n#include \"smfi.h\"\r\n\r\nstatic UINT grbChanMsgLen[] =\r\n{ \r\n 0, /* 0x not a status byte */\r\n 0, /* 1x not a status byte */\r\n 0, /* 2x not a status byte */\r\n 0, /* 3x not a status byte */\r\n 0, /* 4x not a status byte */\r\n 0, /* 5x not a status byte */\r\n 0, /* 6x not a status byte */\r\n 0, /* 7x not a status byte */\r\n 3, /* 8x Note off */\r\n 3, /* 9x Note on */\r\n 3, /* Ax Poly pressure */\r\n 3, /* Bx Control change */\r\n 2, /* Cx Program change */\r\n 2, /* Dx Chan pressure */\r\n 3, /* Ex Pitch bend change */\r\n 0, /* Fx SysEx (see below) */ \r\n} ;\r\n\r\n/******************************************************************************\r\n*\r\n* smfBuildFileIndex\r\n*\r\n* Preliminary parsing of a MIDI file.\r\n*\r\n* ppSmf - Pointer to a returned SMF structure if the\r\n* file is successfully parsed.\r\n*\r\n* Returns\r\n* SMF_SUCCESS The events were successfully read.\r\n* SMF_NO_MEMORY Out of memory to build key frames.\r\n* SMF_INVALID_FILE A disk or parse error occured on the file.\r\n* \r\n* This function validates the format of and existing MIDI or RMI file\r\n* and builds the handle structure which will refer to it for the\r\n* lifetime of the instance.\r\n* \r\n* The file header information will be read and verified, and\r\n* smfBuildTrackIndices will be called on every existing track\r\n* to build keyframes and validate the track format.\r\n*\r\n*****************************************************************************/\r\nSMFRESULT smfBuildFileIndex(\r\n PSMF * ppSmf)\r\n{\r\n SMFRESULT smfrc;\r\n UNALIGNED CHUNKHDR * pCh;\r\n FILEHDR FAR * pFh;\r\n DWORD idx;\r\n PSMF pSmf,\r\n pSmfTemp;\r\n PTRACK pTrk;\r\n WORD wMemory;\r\n DWORD dwLeft;\r\n HPBYTE hpbImage;\r\n \r\n DWORD idxTrack;\r\n EVENT event;\r\n BOOL fFirst;\r\n DWORD dwLength;\r\n HLOCAL hLocal;\r\n PTEMPOMAPENTRY pTempo;\r\n\r\n //assert(ppSmf != NULL);\r\n\r\n pSmf = *ppSmf;\r\n\r\n //assert(pSmf != NULL);\r\n\r\n /* MIDI data image is already in hpbImage (already extracted from\r\n ** RIFF header if necessary).\r\n */\r\n\r\n /* Validate MIDI header\r\n */\r\n dwLeft = pSmf->cbImage;\r\n hpbImage = pSmf->hpbImage;\r\n \r\n if (dwLeft < sizeof(CHUNKHDR))\r\n return SMF_INVALID_FILE;\r\n\r\n pCh = (CHUNKHDR FAR *)hpbImage;\r\n\r\n dwLeft -= sizeof(CHUNKHDR);\r\n hpbImage += sizeof(CHUNKHDR);\r\n \r\n if (pCh->fourccType != FOURCC_MThd)\r\n return SMF_INVALID_FILE;\r\n\r\n dwLength = DWORDSWAP(pCh->dwLength);\r\n if (dwLength < sizeof(FILEHDR) || dwLength > dwLeft)\r\n return SMF_INVALID_FILE;\r\n\r\n pFh = (FILEHDR *)hpbImage;\r\n\r\n dwLeft -= dwLength;\r\n hpbImage += dwLength;\r\n \r\n pSmf->dwFormat = (DWORD)(WORDSWAP(pFh->wFormat));\r\n pSmf->dwTracks = (DWORD)(WORDSWAP(pFh->wTracks));\r\n pSmf->dwTimeDivision = (DWORD)(WORDSWAP(pFh->wDivision));\r\n\r\n /*\r\n ** We've successfully parsed the header. Now try to build the track\r\n ** index.\r\n ** \r\n ** We only check out the track header chunk here; the track will be\r\n ** preparsed after we do a quick integretiy check.\r\n */\r\n wMemory = sizeof(SMF) + (WORD)(pSmf->dwTracks*sizeof(TRACK));\r\n pSmfTemp = (PSMF)LocalReAlloc((HLOCAL)pSmf, wMemory, LMEM_MOVEABLE|LMEM_ZEROINIT);\r\n\r\n if (NULL == pSmfTemp)\r\n {\r\n return SMF_NO_MEMORY;\r\n }\r\n\r\n pSmf = *ppSmf = pSmfTemp;\r\n pTrk = pSmf->rTracks;\r\n \r\n for (idx=0; idxdwTracks; idx++)\r\n {\r\n if (dwLeft < sizeof(CHUNKHDR))\r\n return SMF_INVALID_FILE;\r\n\r\n pCh = (CHUNKHDR *)hpbImage;\r\n\r\n dwLeft -= sizeof(CHUNKHDR);\r\n hpbImage += sizeof(CHUNKHDR);\r\n\r\n if (pCh->fourccType != FOURCC_MTrk)\r\n return SMF_INVALID_FILE;\r\n \r\n pTrk->idxTrack = (DWORD)(hpbImage - pSmf->hpbImage);\r\n pTrk->smti.cbLength = DWORDSWAP(pCh->dwLength);\r\n\r\n if (pTrk->smti.cbLength > dwLeft)\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n dwLeft -= pTrk->smti.cbLength;\r\n hpbImage += pTrk->smti.cbLength;\r\n\r\n pTrk++;\r\n }\r\n\r\n /* File looks OK. Now preparse, doing the following:\r\n ** (1) Build tempo map so we can convert to/from ticks quickly\r\n ** (2) Determine actual tick length of file\r\n ** (3) Validate all events in all tracks\r\n */ \r\n pSmf->tkPosition = 0;\r\n pSmf->fdwSMF &= ~SMF_F_EOF;\r\n \r\n for (pTrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; pTrk++)\r\n {\r\n pTrk->pSmf = pSmf;\r\n pTrk->tkPosition = 0;\r\n pTrk->cbLeft = pTrk->smti.cbLength;\r\n pTrk->hpbImage = pSmf->hpbImage + pTrk->idxTrack;\r\n pTrk->bRunningStatus = 0;\r\n pTrk->fdwTrack = 0;\r\n }\r\n\r\n while (SMF_SUCCESS == (smfrc = smfGetNextEvent(pSmf, (EVENT *)&event, MAX_TICKS)))\r\n {\r\n if (MIDI_META == event.abEvent[0] && \r\n MIDI_META_TEMPO == event.abEvent[1])\r\n {\r\n if (3 != event.cbParm)\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n if (pSmf->cTempoMap == pSmf->cTempoMapAlloc)\r\n {\r\n if (NULL != pSmf->hTempoMap)\r\n {\r\n LocalUnlock(pSmf->hTempoMap);\r\n }\r\n \r\n pSmf->cTempoMapAlloc += C_TEMPO_MAP_CHK;\r\n fFirst = FALSE;\r\n if (0 == pSmf->cTempoMap)\r\n {\r\n hLocal = LocalAlloc(LHND, (UINT)(pSmf->cTempoMapAlloc*sizeof(TEMPOMAPENTRY)));\r\n fFirst = TRUE;\r\n }\r\n else\r\n {\r\n hLocal = LocalReAlloc(pSmf->hTempoMap, (UINT)(pSmf->cTempoMapAlloc*sizeof(TEMPOMAPENTRY)), LHND);\r\n }\r\n\r\n if (NULL == hLocal)\r\n {\r\n return SMF_NO_MEMORY;\r\n }\r\n\r\n pSmf->pTempoMap = (PTEMPOMAPENTRY)LocalLock(pSmf->hTempoMap = hLocal);\r\n }\r\n\r\n if (fFirst && pSmf->tkPosition != 0)\r\n {\r\n /* Inserting first event and the absolute time is zero.\r\n ** Use defaults of 500,000 uSec/qn from MIDI spec\r\n */\r\n \r\n pTempo = &pSmf->pTempoMap[pSmf->cTempoMap++];\r\n\r\n pTempo->tkTempo = 0;\r\n pTempo->msBase = 0;\r\n pTempo->dwTempo = MIDI_DEFAULT_TEMPO;\r\n\r\n fFirst = FALSE;\r\n }\r\n\r\n pTempo = &pSmf->pTempoMap[pSmf->cTempoMap++];\r\n\r\n pTempo->tkTempo = pSmf->tkPosition;\r\n if (fFirst)\r\n pTempo->msBase = 0;\r\n else\r\n {\r\n /* NOTE: Better not be here unless we're q/n format!\r\n */\r\n pTempo->msBase = (pTempo-1)->msBase +\r\n muldiv32(pTempo->tkTempo-((pTempo-1)->tkTempo),\r\n (pTempo-1)->dwTempo,\r\n 1000L*pSmf->dwTimeDivision);\r\n }\r\n pTempo->dwTempo = (((DWORD)event.hpbParm[0])<<16)|\r\n (((DWORD)event.hpbParm[1])<<8)|\r\n ((DWORD)event.hpbParm[2]);\r\n }\r\n }\r\n\r\n\tif (0 == pSmf->cTempoMap)\r\n\t{\r\n\t\thLocal = LocalAlloc(LHND, sizeof(TEMPOMAPENTRY));\r\n\t\tif (!hLocal)\r\n\t\t\treturn SMF_NO_MEMORY;\r\n\r\n pSmf->pTempoMap = (PTEMPOMAPENTRY)LocalLock(pSmf->hTempoMap = hLocal);\r\n\t\tpSmf->cTempoMap = 1;\r\n\t\tpSmf->cTempoMapAlloc = 1;\r\n\r\n\t\tpSmf->pTempoMap->tkTempo = 0;\r\n pSmf->pTempoMap->msBase = 0;\r\n pSmf->pTempoMap->dwTempo = MIDI_DEFAULT_TEMPO;\r\n\t}\r\n\r\n if (SMF_END_OF_FILE == smfrc || SMF_SUCCESS == smfrc)\r\n {\r\n pSmf->tkLength = pSmf->tkPosition;\r\n smfrc = SMF_SUCCESS;\r\n }\r\n \r\n return smfrc;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfGetNextEvent\r\n*\r\n* Read the next event from the given file.\r\n*\r\n* pSmf - File to read the event from.\r\n*\r\n* pEvent - Pointer to an event structure which will receive\r\n* basic information about the event.\r\n*\r\n* tkMax - Tick destination. An attempt to read past this\r\n* position in the file will fail.\r\n*\r\n* Returns\r\n* SMF_SUCCESS The events were successfully read.\r\n* SMF_END_OF_FILE There are no more events to read in this track.\r\n* SMF_REACHED_TKMAX No event was read because

was reached.\r\n* SMF_INVALID_FILE A disk or parse error occured on the file.\r\n*\r\n* This is the lowest level of parsing for a raw MIDI stream. The basic\r\n* information about one event in the file will be returned in pEvent.\r\n*\r\n* Merging data from all tracks into one stream is performed here.\r\n* \r\n* pEvent->tkDelta will contain the tick delta for the event.\r\n*\r\n* pEvent->abEvent will contain a description of the event.\r\n* pevent->abEvent[0] will contain\r\n* F0 or F7 for a System Exclusive message.\r\n* FF for a MIDI file meta event.\r\n* The status byte of any other MIDI message. (Running status will\r\n* be tracked and expanded).\r\n*\r\n* pEvent->cbParm will contain the number of bytes of paramter data\r\n* which is still in the file behind the event header already read.\r\n* This data may be read with . Any unread\r\n* data will be skipped on the next call to .\r\n*\r\n* Channel messages (0x8? - 0xE?) will always be returned fully in\r\n* pevent->abEvent.\r\n*\r\n* Meta events will contain the meta type in pevent->abEvent[1].\r\n*\r\n* System exclusive events will contain only an 0xF0 or 0xF7 in\r\n* pevent->abEvent[0].\r\n*\r\n* The following fields in pTrk are used to maintain state and must\r\n* be updated if a seek-in-track is performed:\r\n*\r\n* bRunningStatus contains the last running status message or 0 if\r\n* there is no valid running status.\r\n*\r\n* hpbImage is a pointer into the file image of the first byte of\r\n* the event to follow the event just read.\r\n*\r\n* dwLeft contains the number of bytes from hpbImage to the end\r\n* of the track.\r\n*\r\n*\r\n* Get the next due event from all (in-use?) tracks\r\n*\r\n* For all tracks\r\n* If not end-of-track\r\n* decode event delta time without advancing through buffer\r\n* event_absolute_time = track_tick_time + track_event_delta_time\r\n* relative_time = event_absolute_time - last_stream_time\r\n* if relative_time is lowest so far\r\n* save this track as the next to pull from, along with times\r\n*\r\n* If we found a track with a due event\r\n* Advance track pointer past event, saving ptr to parm data if needed\r\n* track_tick_time += track_event_delta_time\r\n* last_stream_time = track_tick_time\r\n* Else\r\n* Mark and return end_of_file\r\n*\r\n*****************************************************************************/\r\nSMFRESULT smfGetNextEvent(\r\n PSMF pSmf,\r\n EVENT * pEvent,\r\n TICKS tkMax)\r\n{\r\n PTRACK pTrk;\r\n PTRACK pTrkFound;\r\n DWORD idxTrack;\r\n TICKS tkEventDelta;\r\n TICKS tkRelTime;\r\n TICKS tkMinRelTime;\r\n BYTE bEvent;\r\n DWORD dwGotTotal;\r\n DWORD dwGot;\r\n DWORD cbEvent;\r\n\r\n //assert(pSmf != NULL);\r\n //assert(pEvent != NULL);\r\n\r\n if (pSmf->fdwSMF & SMF_F_EOF)\r\n {\r\n return SMF_END_OF_FILE;\r\n }\r\n\r\n pTrkFound = NULL;\r\n tkMinRelTime = MAX_TICKS;\r\n \r\n for (pTrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; pTrk++)\r\n {\r\n if (pTrk->fdwTrack & SMF_TF_EOT)\r\n continue;\r\n\r\n \r\n if (!smfGetVDword(pTrk->hpbImage, pTrk->cbLeft, (DWORD *)&tkEventDelta))\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n tkRelTime = pTrk->tkPosition + tkEventDelta - pSmf->tkPosition;\r\n\r\n if (tkRelTime < tkMinRelTime)\r\n {\r\n tkMinRelTime = tkRelTime;\r\n pTrkFound = pTrk;\r\n }\r\n }\r\n\r\n if (!pTrkFound)\r\n {\r\n pSmf->fdwSMF |= SMF_F_EOF;\r\n return SMF_END_OF_FILE;\r\n }\r\n\r\n pTrk = pTrkFound;\r\n\r\n if (pSmf->tkPosition + tkMinRelTime >= tkMax)\r\n {\r\n return SMF_REACHED_TKMAX;\r\n }\r\n \r\n\r\n pTrk->hpbImage += (dwGot = smfGetVDword(pTrk->hpbImage, pTrk->cbLeft, (DWORD *)&tkEventDelta));\r\n pTrk->cbLeft -= dwGot;\r\n\r\n /* We MUST have at least three bytes here (cause we haven't hit\r\n ** the end-of-track meta yet, which is three bytes long). Checking\r\n ** against three means we don't have to check how much is left\r\n ** in the track again for any short event, which is most cases.\r\n */\r\n if (pTrk->cbLeft < 3)\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n pTrk->tkPosition += tkEventDelta;\r\n pEvent->tkDelta = pTrk->tkPosition - pSmf->tkPosition;\r\n pSmf->tkPosition = pTrk->tkPosition;\r\n\r\n bEvent = *pTrk->hpbImage++;\r\n \r\n if (MIDI_MSG > bEvent)\r\n {\r\n if (0 == pTrk->bRunningStatus)\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n dwGotTotal = 1;\r\n pEvent->abEvent[0] = pTrk->bRunningStatus;\r\n pEvent->abEvent[1] = bEvent;\r\n if (3 == grbChanMsgLen[(pTrk->bRunningStatus >> 4) & 0x0F])\r\n {\r\n pEvent->abEvent[2] = *pTrk->hpbImage++;\r\n dwGotTotal++;\r\n }\r\n }\r\n else if (MIDI_SYSEX > bEvent)\r\n {\r\n pTrk->bRunningStatus = bEvent;\r\n \r\n dwGotTotal = 2;\r\n pEvent->abEvent[0] = bEvent;\r\n pEvent->abEvent[1] = *pTrk->hpbImage++;\r\n if (3 == grbChanMsgLen[(bEvent >> 4) & 0x0F])\r\n {\r\n pEvent->abEvent[2] = *pTrk->hpbImage++;\r\n dwGotTotal++;\r\n }\r\n }\r\n else\r\n {\r\n pTrk->bRunningStatus = 0;\r\n if (MIDI_META == bEvent)\r\n {\r\n pEvent->abEvent[0] = MIDI_META;\r\n if (MIDI_META_EOT == (pEvent->abEvent[1] = *pTrk->hpbImage++))\r\n {\r\n pTrk->fdwTrack |= SMF_TF_EOT;\r\n }\r\n\r\n dwGotTotal = 2;\r\n }\r\n else if (MIDI_SYSEX == bEvent || MIDI_SYSEXEND == bEvent)\r\n {\r\n pEvent->abEvent[0] = bEvent;\r\n dwGotTotal = 1;\r\n }\r\n else\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n \r\n if (0 == (dwGot = smfGetVDword(pTrk->hpbImage, pTrk->cbLeft - 2, (DWORD *)&cbEvent)))\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n pTrk->hpbImage += dwGot;\r\n dwGotTotal += dwGot;\r\n\r\n if (dwGotTotal + cbEvent > pTrk->cbLeft)\r\n {\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n pEvent->cbParm = cbEvent;\r\n pEvent->hpbParm = pTrk->hpbImage;\r\n\r\n pTrk->hpbImage += cbEvent;\r\n dwGotTotal += cbEvent;\r\n }\r\n\r\n //assert(pTrk->cbLeft >= dwGotTotal);\r\n\r\n pTrk->cbLeft -= dwGotTotal;\r\n\r\n return SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfGetVDword\r\n*\r\n* Reads a variable length DWORD from the given file.\r\n*\r\n* hpbImage - Pointer to the first byte of the VDWORD.\r\n*\r\n* dwLeft - Bytes left in image\r\n*\r\n* pDw - Pointer to a DWORD to store the result in.\r\n* track.\r\n*\r\n* Returns the number of bytes consumed from the stream.\r\n*\r\n* A variable length DWORD stored in a MIDI file contains one or more\r\n* bytes. Each byte except the last has the high bit set; only the\r\n* low 7 bits are significant.\r\n* \r\n*****************************************************************************/\r\nDWORD smfGetVDword(\r\n HPBYTE hpbImage, \r\n DWORD dwLeft, \r\n DWORD * pDw)\r\n{\r\n BYTE b;\r\n DWORD dwUsed = 0;\r\n\r\n //assert(hpbImage != NULL);\r\n //assert(pDw != NULL);\r\n \r\n *pDw = 0;\r\n\r\n do\r\n {\r\n if (!dwLeft)\r\n {\r\n return 0;\r\n }\r\n\r\n b = *hpbImage++;\r\n dwLeft--;\r\n dwUsed++;\r\n \r\n *pDw = (*pDw << 7) | (b & 0x7F);\r\n } while (b&0x80);\r\n\r\n return dwUsed;\r\n}\r\n//////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n//\t\t DataManager\r\n//////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"DataManager.h\"\r\n\r\nDataManager::DataManager(CKContext *Context) : \r\nCKBaseManager(Context, DataManagerGUID, \"DataManager\")\r\n{\r\n\tContext->RegisterNewManager(this);\r\n\t_vPos.Set(0,0,0);\r\n}\r\n\r\nDataManager::~DataManager()\r\n{\r\n\r\n}\r\n\r\n\r\nCKERROR DataManager::OnCKInit()\r\n{\r\n\r\n#ifdef G_EXTERNAL_ACCESS\r\n\t_initSharedMemory(0);\r\n#endif\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR DataManager::PostProcess()\r\n{\r\n\r\n\t#ifdef G_EXTERNAL_ACCESS\r\n\t\t_SharedMemoryTickPost(0);\r\n\t#endif\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR DataManager::PreProcess()\r\n{\r\n\r\n\t#ifdef G_EXTERNAL_ACCESS\r\n\t\t_SharedMemoryTick(0);\r\n\t#endif\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n// PBRootForm.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx2.h\"\r\n\r\n#include \"PBRootForm.h\"\r\n\r\n\r\n// PBRootForm\r\n\r\nIMPLEMENT_DYNCREATE(PBRootForm, CFormView)\r\n\r\nPBRootForm::PBRootForm()\r\n\t: CFormView(PBRootForm::IDD)\r\n{\r\n\r\n}\r\n\r\nPBRootForm::~PBRootForm()\r\n{\r\n}\r\n\r\nvoid PBRootForm::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tCFormView::DoDataExchange(pDX);\r\n}\r\n\r\nBEGIN_MESSAGE_MAP(PBRootForm, CFormView)\r\nEND_MESSAGE_MAP()\r\n\r\n\r\n// PBRootForm diagnostics\r\n\r\n#ifdef _DEBUG\r\nvoid PBRootForm::AssertValid() const\r\n{\r\n\tCFormView::AssertValid();\r\n}\r\n\r\n#ifndef _WIN32_WCE\r\nvoid PBRootForm::Dump(CDumpContext& dc) const\r\n{\r\n\tCFormView::Dump(dc);\r\n}\r\n#endif\r\n#endif //_DEBUG\r\n\r\n\r\n// PBRootForm message handlers\r\n/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n// include file used for the static configuration\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\n#include \"vtTools.h\"\r\n\r\nextern CCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\nBOOL CCustomPlayerApp::_CreateWindows()\r\n{\r\n\tRECT mainRect;\r\n\tint k = CCustomPlayer::Instance().WindowedWidth();\r\n\tint k1 = CCustomPlayer::Instance().WindowedHeight();\r\n\r\n\t// compute the main window rectangle, so the window is centered\r\n\tmainRect.left = (GetSystemMetrics(SM_CXSCREEN)-CCustomPlayer::Instance().WindowedWidth())/2;\r\n\tmainRect.right = CCustomPlayer::Instance().WindowedWidth()+mainRect.left;\r\n\tmainRect.top = (GetSystemMetrics(SM_CYSCREEN)-CCustomPlayer::Instance().WindowedHeight())/2;\r\n\tmainRect.bottom = CCustomPlayer::Instance().WindowedHeight()+mainRect.top;\r\n\tBOOL ret = AdjustWindowRect(&mainRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\r\n\tDWORD dwStyle;\r\n\r\n\t// create the main window\r\n\r\n\tswitch(GetPlayer().PGetApplicationMode())\r\n\t{\r\n\t\tcase normal:\r\n\t\t\t{\r\n\t\t\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),GetPlayer().GetPAppStyle()->g_AppTitle.Str(),(WS_EX_ACCEPTFILES|WS_OVERLAPPEDWINDOW) & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t\t\t\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t\t\t\t\tNULL,NULL,m_hInstance,NULL);\r\n\t\t\t\t//m_MainWindow = CreateWindowEx(WS_EX_ACCEPTFILES|WS_EX_TOPMOST,m_PlayerClass.CStr(),GetPlayer().GetPAppStyle()->g_AppTitle.Str(),WS_VISIBLE,mainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,NULL,NULL,m_hInstance,this);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase preview:\r\n\t\t\t{\r\n\t\t\t\tRECT rc;\r\n\t\t\t\tGetClientRect( GetPlayer().m_hWndParent, &rc );\r\n\t\t\t\tdwStyle = WS_VISIBLE | WS_CHILD;\r\n\t\t\t\tAdjustWindowRect( &rc, dwStyle, FALSE );\r\n\t\t\t\tm_MainWindow = GetPlayer().m_hWndParent;\r\n\t\t\t\tGetPlayer().m_WindowedWidth = rc.right - rc.left ; \r\n\t\t\t\tGetPlayer().m_WindowedHeight = rc.bottom - rc.top;\r\n\t\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_VISIBLE)&~WS_CAPTION,rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,m_MainWindow,NULL,m_hInstance,this);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase popup:\r\n\t\t\t{\r\n\t\t\t\tdwStyle = (WS_OVERLAPPEDWINDOW); \r\n\t\t\t\t//m_MainWindow = CreateWindowEx( dwStyle , m_PlayerClass.CStr(), GetPlayer().GetPAppStyle()->g_AppTitle.Str(), WS_POPUP, mainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top , m_MainWindow, NULL,m_hInstance, NULL );\r\n\t\t\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),\"asd\",WS_POPUP,mainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,NULL,NULL,m_hInstance,NULL);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tdefault:\r\n\t\t\t\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),GetPlayer().GetPAppStyle()->g_AppTitle.Str(),WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t\t\t\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t\t\t\t\tNULL,NULL,m_hInstance,NULL);\r\n\t\tbreak;\r\n\t}\r\n\r\n\r\n\r\n\t//\tm_MainWindow = CreateWindow(m_PlayerClass.CStr(),\"asd\",WS_OVERLAPPEDWINDOW & ~(WS_SIZEBOX|WS_MAXIMIZEBOX),\r\n\t//\t\tmainRect.left,mainRect.top,mainRect.right-mainRect.left,mainRect.bottom-mainRect.top,\r\n\t//\t\tNULL,NULL,m_hInstance,NULL);\r\n\r\n\tif(!m_MainWindow) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif(GetPlayer().PGetApplicationMode() != preview)\r\n\t{\r\n\r\n\t\tint w = CCustomPlayer::Instance().FullscreenWidth();\r\n\t\tint h = CCustomPlayer::Instance().FullscreenHeight();\r\n\r\n\t\t// create the render window\r\n\t\tif (( GetPlayer().GetEWindowInfo()->g_GoFullScreen )) \r\n\t\t{\r\n\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_OVERLAPPED|WS_VISIBLE)&~WS_CAPTION,\r\n\t\t\t\t0,0,CCustomPlayer::Instance().FullscreenWidth(),CCustomPlayer::Instance().FullscreenHeight(),m_MainWindow,NULL,m_hInstance,0);\r\n\t\t} else {\r\n\t\t\tm_RenderWindow = CreateWindowEx(WS_EX_TOPMOST,m_RenderClass.CStr(),\"\",(WS_CHILD|WS_OVERLAPPED|WS_VISIBLE)&~WS_CAPTION,\r\n\t\t\t\t0,0,CCustomPlayer::Instance().WindowedWidth(),CCustomPlayer::Instance().WindowedHeight(),m_MainWindow,NULL,m_hInstance,0);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tif(!m_RenderWindow) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\treturn TRUE;\r\n}\r\n#include \r\n#include \"PCommonDialog.h\"\r\n#include \"PBodySetup.h\"\r\n#include \"PBXMLSetup.h\"\r\n\r\n\r\n#include \"resource.h\"\r\n#include \"VITabCtrl.h\"\r\n#include \"VIControl.h\"\r\n#include \"..\\..\\include\\interface\\pbxmlsetup.h\"\r\n\r\n\r\nvoid CPBXMLSetup::fillXMLLinks()\r\n{\r\n\r\n\tXMLExternLink.AddString(\"None\");\r\n\tXMLInternLink.AddString(\"None\");\r\n\r\n\tXMLExternLink.SetCurSel(0);\r\n\tXMLInternLink.SetCurSel(0);\r\n\r\n\r\n}\r\n\r\nint CPBXMLSetup::OnSelect(int before/* =-1 */)\r\n{\r\n\treturn -1;\r\n}\r\n\r\n\r\nBOOL CPBXMLSetup::OnInitDialog()\r\n{\r\n\r\n\t\t\r\n\tfillXMLLinks();\r\n\tCDialog::OnInitDialog();\r\n\t/*getXMLSetup().SetMode(MultiParamEditDlg::MODELESSEDIT|MultiParamEditDlg::USER_CUSTOM_BUTTONS|MultiParamEditDlg::AUTOCLOSE_WHEN_MODELESS|MultiParamEditDlg::CREATEPARAM);\r\n\t//getXMLSetup().AttachControlSite(this,IDC_MAIN_VIEW_XML);\r\n\r\n\tCRect rcValue;\r\n\tGetWindowRect( &rcValue ); // Use picture box position.\r\n\tScreenToClient( &rcValue );\r\n*/\r\n\treturn TRUE;\r\n}\r\n\r\n\r\n\r\n\r\n\r\nCPBXMLSetup::~CPBXMLSetup(){\t_destroy();}\r\nvoid CPBXMLSetup::_destroy(){\t::CPSharedBase::_destroy();}\r\n\r\nCPBXMLSetup::CPBXMLSetup(CKParameter* Parameter,CK_CLASSID Cid)\t: \r\nCParameterDialog(Parameter,Cid) , CPSharedBase(this,Parameter)\r\n{\r\n\tsetEditedParameter(Parameter);\r\n}\r\n\r\nCPBXMLSetup::CPBXMLSetup(CKParameter* Parameter,CWnd *parent,CK_CLASSID Cid) : \r\nCParameterDialog(Parameter,Cid) , CPSharedBase(this,Parameter)\r\n{\r\n\tsetEditedParameter(Parameter);\r\n}\r\n\r\nvoid CPSharedBase::_dtrBodyXMLDlg(){}\r\nCPBXMLSetup*CPBXMLSetup::refresh(CKParameter*src){\treturn this;}\r\n\r\n\r\nHWND CPBXMLSetup::getDlgWindowHandle(UINT templateID)\r\n{\r\n\tHWND result = NULL;\r\n\tGetDlgItem(templateID,&result);\r\n\treturn result;\r\n}\r\nLRESULT CPBXMLSetup::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\r\n\tcase WM_LBUTTONDOWN:\r\n\tcase WM_LBUTTONDBLCLK:\r\n\t\t{\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\tcase WM_ERASEBKGND:\r\n\t\t{\r\n\t\t\t/*RECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\tCDC* pDC=CDC::FromHandle((HDC)wParam);\r\n\t\t\tpDC->FillSolidRect(&r,RGB(200,200,200));\r\n\t\t\treturn 1;*/\r\n\t\t}break;\r\n\tcase CKWM_OK:\r\n\t\t{\r\n\t\t\t//CEdit *valueText = (CEdit*)GetDlgItem(IDC_EDIT);\r\n\t\t\t/*CString l_strValue;\r\n\t\t\tvalueText->GetWindowText(l_strValue);\r\n\r\n\t\t\tdouble d;\r\n\t\t\tif (sscanf(l_strValue,\"%Lf\",&d)) {\r\n\t\t\tparameter->SetValue(&d);\r\n\t\t\t}*/\r\n\t\t} break;\r\n\r\n\tcase CKWM_INIT:\r\n\t\t{\r\n\r\n\t\t\tRECT r;\r\n\t\t\tGetClientRect(&r);\r\n\t\t\tfillXMLLinks();\r\n\t\t\t\r\n\t\t} break;\r\n\t}\r\n\treturn CDialog::WindowProc(message, wParam, lParam);\r\n}\r\n\r\n\r\n\r\nvoid CPBXMLSetup::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\r\n\t//CDialog::DoDataExchange(pDX);\r\n\tCParameterDialog::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CPBXMLSetup)\r\n\tDDX_Control(pDX, IDC_XINTERN_LINK2, XMLInternLink);\r\n\tDDX_Control(pDX, IDC_XEXTERN_LINK, XMLExternLink);\r\n\t//}}AFX_DATA_MAP\r\n\r\n}\r\n\r\nBEGIN_MESSAGE_MAP(CPBXMLSetup, CParameterDialog)\r\n\r\n\tON_STN_CLICKED(IDC_XML_MAIN_VIEW, OnStnClickedXmlMainView)\r\nEND_MESSAGE_MAP()\r\n\r\n\r\nvoid CPBXMLSetup::OnStnClickedXmlMainView()\r\n{\r\n\t// TODO: Add your control notification handler code here\r\n}\r\n#pragma once\r\n\r\n#include \"CKAll.h\"\r\n\r\nclass vtGUID\r\n{\r\nprivate:\r\n CKGUID guid;\r\n\r\npublic:\r\n\r\n\tCKGUID GetVirtoolsGUID()\r\n\t{\r\n\t\treturn guid;\r\n\t}\r\n vtGUID( DWORD d1=0, DWORD d2=0 ):guid(d1,d2) {}\r\n\r\n XString ToString( void )\r\n {\r\n XString laid;\r\n\r\n laid << DecimalToHex( guid.d1 );\r\n laid << DecimalToHex( guid.d2 );\r\n\r\n return laid;\r\n }\r\n\r\n bool FromString( const XString laid )\r\n {\r\n\r\n\t\tif( laid.Length() != 16 )\r\n\t\t\treturn false;\r\n\r\n\t\tXString d1(laid);\r\n XString d2(laid);\r\n\r\n d1.Crop( 0, 8 );\r\n d2.Crop( 8, 8 );\r\n\r\n HexToDecimalHI( d1.Str(), guid.d1 );\r\n HexToDecimalLO( d2.Str(), guid.d2 );\r\n\r\n return true;\r\n }\r\n\r\n vtGUID & operator =( const CKGUID& ckguid )\r\n {\r\n guid.d1 = ckguid.d1;\r\n guid.d2 = ckguid.d2;\r\n\r\n return *this;\r\n }\r\n\r\n operator XString() { return ToString(); }\r\n\r\nprivate:\r\n XString DecimalToHex( int decimal )\r\n {\r\n XString hexStr;\r\n\t\tchar hexstring[17];\r\n\t\titoa( decimal, hexstring, 16);\r\n\r\n\t\tint length = strlen(hexstring);\r\n\t\tif (length < 8)\r\n\t\t{\r\n\t\t\tint add = 8 - length;\r\n\t\t\tfor (int i = 0; i < add; i++)\r\n\t\t\t{\r\n\t\t\t\thexStr << \"0\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\thexStr << hexstring;\r\n\r\n\t\treturn hexStr;\r\n\r\n }\r\n\r\n bool HexToDecimalHI (char* HexNumber, unsigned int& Number)\r\n {\r\n char* pStopString;\r\n Number = strtol (HexNumber, &pStopString, 16);\r\n return (bool)(Number != LONG_MAX);\r\n }\r\n\tbool HexToDecimalLO(char* HexNumber, unsigned int& Number)\r\n\t{\r\n\t\tchar* pStopString;\r\n\t\tNumber = strtoul(HexNumber, &pStopString, 16);\r\n\t\treturn (bool)(Number != LONG_MAX);\r\n\t}\r\n};\r\n#ifndef __X_SPLASH_H_\r\n#define __X_SPLASH_H_\r\n\r\n#include \r\n\r\nclass CSplashScreenEx;\r\n\r\nnamespace xSplash\r\n{\r\n\t\r\n\r\n\tMODULE_API CSplashScreenEx *GetSplash();\r\n\tMODULE_API void CreateSplash(HINSTANCE hinst,int w,int h);\r\n\tMODULE_API void CreateSplashEx(CWnd *parent,int w,int h);\r\n\tMODULE_API void HideSplash();\r\n\tMODULE_API void ShowSplash();\r\n\tMODULE_API void SetText(const char* text);\r\n\r\n}//end of namespace xSplash\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2008/01/14\r\n\tcreated:\t14:1:2008 12:14\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\CustomPlayerDialogErrorPage.cpp\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\n\tfile base:\tCustomPlayerDialogErrorPage\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\tDisplays an Error Tab, the text is set by CustomPlayerDialog.InitDialog !\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"resourceplayer.h\"\r\n\r\n#include \"CustomPlayerDialogErrorPage.h\"\r\n#include \"CustomPlayerDialog.h\"\r\n\r\n\r\n#ifdef _DEBUG\r\n#undef THIS_FILE\r\nstatic char BASED_CODE THIS_FILE[] = __FILE__;\r\n#endif\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CErrorPage dialog\r\n\r\n\r\n\r\nCustomPlayerDialogErrorPage::CustomPlayerDialogErrorPage() : CPropertyPage(CustomPlayerDialogErrorPage::IDD)\r\n{\r\n\t//{{AFX_DATA_INIT(CErrorPage)\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\nvoid CustomPlayerDialogErrorPage::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tCPropertyPage::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CErrorPage)\r\n\t//}}AFX_DATA_MAP\r\n\tDDX_Control(pDX, IDC_ERROR_RICHT_TEXT, m_ErrorRichText);\r\n}\r\n\r\n\r\n\r\nBEGIN_MESSAGE_MAP(CustomPlayerDialogErrorPage, CPropertyPage)\r\n\t//{{AFX_MSG_MAP(CErrorPage)\r\n\t\t// NOTE: the ClassWizard will add message map macros here\r\n\t//}}AFX_MSG_MAP\r\n\tON_EN_SETFOCUS(IDC_ERROR_RICHT_TEXT, OnEnSetfocusErrorRichtText)\r\n\tON_NOTIFY(EN_LINK, IDC_ERROR_RICHT_TEXT, OnEnLinkErrorRichtText)\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CErrorPage message handlers\r\n\r\nvoid CustomPlayerDialogErrorPage::OnEnSetfocusErrorRichtText()\r\n{\r\n\tif (m_ErrorRichText)\r\n\t{\r\n\t\tCRect rc;\r\n\t\tm_ErrorRichText.GetWindowRect(rc);\r\n\t\tScreenToClient(rc);\r\n\t\tDWORD newStyle= ES_CENTER;\r\n\t\tDWORD style= m_ErrorRichText.GetStyle();\r\n\t\tstyle&= ~ES_CENTER;\r\n\t\tstyle|= newStyle;\r\n\t\tstyle|= WS_VSCROLL;\r\n\r\n\t\tDWORD exstyle= m_ErrorRichText.GetExStyle();\r\n\t\tm_ErrorRichText.SetAutoURLDetect();\r\n\t\tm_ErrorRichText.SetEventMask(ENM_LINK);\r\n\t\tm_ErrorRichText.SetFont(GetFont());\r\n\r\n\t\tm_ErrorRichText.SetWindowText(errorText);\r\n\t\tm_ErrorRichText.UpdateData();\r\n\t\tm_ErrorRichText.UpdateWindow();\r\n\t\tm_ErrorRichText.HideCaret();\r\n\r\n\t}\r\n\t\r\n}\r\n\r\nvoid CustomPlayerDialogErrorPage::OnEnLinkErrorRichtText(NMHDR *pNMHDR, LRESULT *pResult)\r\n{\r\n\t\r\n\tENLINK *el= reinterpret_cast(pNMHDR);\r\n\t*pResult = 0;\r\n\r\n\tif (el->msg == WM_LBUTTONDOWN)\r\n\t{\r\n\t\tCString link;\r\n\t\tm_ErrorRichText.GetTextRange(el->chrg.cpMin, el->chrg.cpMax, link);\r\n\r\n\t\tShellExecute(*this, NULL, link, NULL, _T(\"\"), SW_SHOWNORMAL);\r\n\t}\r\n}\r\n#include \"pch.h\"\r\n#include \"xString.h\"\r\n\r\nxString::xString()\t\t\t\t\t\t\t\t// Default constructor, just creates an empty string.\r\n{\r\n\tText = NULL;\r\n\tLen = Size = 0;\r\n}\r\nxString::xString(const xString& input)\t// Copy constructor, makes an instance an exact copy of\r\n{\t\t\t\t\t\t\t\t\t\t\t// another string.\r\n\tAssignFrom(input);\r\n}\r\n\t\r\n#ifdef _UNICODE\r\n\r\n#include \r\n\r\nxString::xString(const TUnicodeChar *input)\t\t// Constructor building an ANSI string from a regular C\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t// string in Unicode format (used for doing conversions).\r\n\tif (input == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t{\r\n\t\tText = NULL;\r\n\t\tSize = Len = 0;\r\n\t\treturn;\r\n\t}\r\n\tSize = wcslen(input) + 1;\t\t\t\t// Use Unicode wcslen function\r\n\tLen = Size-1;\r\n\tText = AllocStr(Size);\r\n\tfor (int i=0 ; iANSI char-by-char\r\n\t\tText[i] = (TAnsiChar)input[i];\r\n\tText[Len] = __xA('\\0');\r\n}\r\n\r\n#endif\r\n\r\nint \r\nxString::GetLength()const\t// Returns the length of the string currently\r\n{\t\t\t\t\t\t\t\t\t\t// held by an instance of the string class.\r\n\treturn Len;\r\n}\r\nxString::~xString()\t\t\t\t\t\t// Destructor. The use of virtual is recommended in C++\r\n{\t\t\t\t\t\t\t\t\t\t\t\t// for all destructors that can potentially be overloaded.\r\n\tif (Size && Text != NULL)\t\t\t// Free the memory used by the string\r\n\t\tFreeStr(Text);\r\n}\r\n//=======================================================\r\n//\r\n// Accessors\r\n//\r\nTChar*\r\nxString::GetString()\t\t// Returns a pointer to the actual string data.\r\n{\r\n\treturn Text;\r\n}\r\n\r\nconst TAnsiChar*\r\nxString::CStr() const\t\t// Returns a pointer to the actual string data.\r\n{\r\n\treturn Text ? Text : NULL;\r\n}\r\n\r\n\r\nbool \r\nxString::IsNull()const\t\t// Returns true if a NULL string is held by an instance.\r\n{\r\n\treturn (Text == NULL || !_tcslen(Text));\r\n}\r\nbool \r\nxString::IsValidIndex(const int Index)const\t// Returns true if the character index\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// specified is within the bounds of the string.\r\n\treturn (Index >= 0 && Index < Len);\r\n}\r\n\r\n//=======================================================\r\n//\r\n// Regular transformation functions\r\n//\t\r\nint \r\nxString::Compare(const xString&ins, bool IgnoreCase) const\r\n{\t\r\n\r\n\tif (IsNull() && !ins.IsNull())\r\n\t\treturn 1;\r\n\telse if (!IsNull() && ins.IsNull())\r\n\t\treturn -1;\r\n\telse if (IsNull() && ins.IsNull())\r\n\t\treturn 0;\r\n\tif (IgnoreCase)\r\n\t\treturn _tcsicmp(Text, ins.Text);\r\n\telse\r\n\t\treturn _tcscmp(Text, ins.Text);\r\n\r\n}\r\nbool xString::Find(xString&Str, int& Pos, bool IgnoreCase)const\t// Finds a substring within this string.\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Returns true if found (position in Pos).\r\n\tif (IsNull() || Str.IsNull())\r\n\t\treturn false;\r\n\r\n\t// Define a function pointer that will be used to call the appropriate\r\n\t// compare function based on the value of IgnoreCase.\r\n\tint (* cmpfn)(const TCHAR*, const TCHAR*, size_t) = (IgnoreCase) ? _tcsnicmp : _tcsncmp;\r\n\t\r\n\tfor (Pos=0 ; Pos<=(Len-Str.Len) ; Pos++)\r\n\t{\r\n\t\tif (cmpfn(&Text[Pos], Str.Text, Str.Len) == 0)\r\n\t\t\treturn true;\r\n\t}\r\n\r\n\treturn false;\r\n}\r\nvoid xString::Delete(int Pos, int Count)\t\t\t\t\t\t// Deletes the specified number of characters,\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// starting at the specified position.\r\n\tif (Pos > Len || Count==0)\t\t\t\t\t\t\t// Start is outside string or nothing to delete?\r\n\t\treturn;\r\n\tif (Pos + Count > Len)\t\t\t\t\t\t\t\t// Clamp Count to string length\r\n\t\tCount = (Len - Pos);\r\n\r\n\t// Characters are deleted by moving up the data following the region to delete.\r\n\tfor (int i=Pos ; iLen)\r\n\t\treturn;\r\n\r\n\tGrow(1);\t\t\t\t\t\t\t\t\t// Grow the string by one byte to be able to hold character\r\n\r\n\t// Move down rest of the string.\r\n\t// Copying overlapping memory blocks requires the use of memmove() instead of memcpy().\r\n\tmemmove((void *)&Text[Pos+1], (const void *)&Text[Pos], Len-Pos);\r\n\tText[Pos] = c;\r\n\tText[++Len] = __xT('\\0');\r\n}\r\nvoid xString::Insert(int Pos, const xString& input)\t\t// Inserts a complete string at the given\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// location.\r\n\tif (Pos<0 || Pos>Len || input.IsNull())\r\n\t\treturn;\r\n\r\n\tTChar *New = AllocStr(input.Len + Len + 1);\r\n\tif (Pos > 0)\t\t\t\t\t\t\t\t\t// Set the string portion before the inserted string\r\n\t\t_tcsncpy(New, Text, Pos);\r\n\t_tcsncpy(&New[Pos], input.Text, input.Len);\t\t\t// Insert the string\r\n\tif (Len-Pos > 0)\t\t\t\t\t\t\t\t\t\t\t\t\t// Insert rest of orignal string\r\n\t\t_tcsncpy(&New[Pos+input.Len], &Text[Pos], Len-Pos);\r\n\r\n\tAssignFrom(New);\t\t\t\t\t\t\t// Copy new string back into stringobject\r\n}\r\nxString \r\nxString::GetSubString(int Start, int Count, xString& Dest)\t\t// Crops out a substring.\r\n{\r\n\tif (!IsValidIndex(Start) || Count <= 0)\t\t// Valid operation?\r\n\t{\r\n\t\tDest = __xT(\"\");\r\n\t\treturn Dest;\r\n\t}\r\n\r\n\tTChar *Temp = AllocStr(Count + 1);\r\n\t_tcsncpy(Temp, &Text[Start], Count);\r\n\tTemp[Count] = __xT('\\0');\r\n\r\n\tDest = Temp;\r\n\tFreeStr(Temp);\r\n\treturn Dest;\r\n}\r\n\r\n//=======================================================\r\n//\r\n// Special transformation functions\r\n//\r\nvoid xString::VarArg(TChar *Format, ...)\t\t// Allows you to fill a string object with data in the\r\n{\t\t\t\t\t\t\t\t\t\t\t\t// same way you use sprintf()\r\n\r\n\tTChar Buf[0x1000]; // Need lots of space\r\n\tva_list argptr;\r\n\r\n\tva_start(argptr, Format);\r\n#ifdef _UNICODE\r\n\tvswprintf(Buf, Format, argptr);\r\n#else\r\n\tvsprintf(Buf, Format, argptr);\r\n#endif\r\n\tva_end(argptr);\r\n\r\n\tSize = _tcslen(Buf) + 1;\r\n\tLen = _tcslen(Buf);\r\n\tFreeStr(Text);\r\n\tText = AllocStr(Size);\r\n\tif (Len > 0)\r\n\t\t_tcscpy(Text, Buf);\r\n\telse\r\n\t\tText[0] = __xT('\\0');\r\n\t\r\n}\r\nvoid xString::EatLeadingWhitespace()\t\t// Convenient function that removes all whitespace\r\n{\t\t\t\t\t\t\t\t\t\t\t// (tabs and spaces) at the beginning of a string.\r\n\tif (IsNull())\r\n\t\treturn;\r\n\r\n\tint i=0;\r\n\tfor (i=0 ; i=0 ; i--)\r\n\t{\r\n\t\tif (Text[i] != 0x20 && Text[i] != 0x09)\r\n\t\t\tbreak;\r\n\t}\r\n\tDelete(i+1, Len-i-1);\r\n\t\r\n}\r\n\r\n\t\r\n//=======================================================\r\n//\r\n// Conversion functions\r\n//\r\nTAnsiChar*\r\nxString::ToAnsi(TAnsiChar *Buffer, int BufferLen) const\t// Converts the string to an ANSI string.\r\n{\r\n\tint i, ConvertLen;\r\n\r\n\tif (BufferLen <= 0)\r\n\t{\r\n\t\tBuffer = NULL;\r\n\t\treturn Buffer;\r\n\t}\r\n\r\n\tif (BufferLen >= Len)\r\n\t\tConvertLen = Len;\r\n\telse\r\n\t\tConvertLen = BufferLen-1;\r\n\r\n\tfor (i=0 ; i 255)\t\t// If character is a non-ANSI Unicode character, fill with\r\n\t\t\tBuffer[i] = 0x20;\t\t// space instead.\r\n\t\telse\r\n#endif\r\n\t\t\tBuffer[i] = (TAnsiChar)Text[i];\r\n\t}\r\n\tBuffer[i] = __xA('\\0');\r\n\treturn Buffer;\r\n}\r\nTUnicodeChar *\r\nxString::ToUnicode(TUnicodeChar *Buffer, int BufferLen) const\t\t// Converts the string\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// to a Unicode string.\r\n\tint i, ConvertLen;\r\n\r\n\tif (BufferLen <= 0)\r\n\t{\r\n\t\tBuffer = NULL;\r\n\t\treturn Buffer;\r\n\t}\r\n\r\n\tif (BufferLen >= Len)\r\n\t\tConvertLen = Len;\r\n\telse\r\n\t\tConvertLen = BufferLen-1;\r\n\r\n\tfor (i=0 ; i(iValue);\r\n\tif ( rValue )\r\n\t{\r\n\t\t_attachRight(rValue);\r\n\r\n\t}else\r\n\t\treturn *this;\r\n\r\n}\r\nxString& \r\nxString::operator<<(const int iValue)\r\n{\r\n\txString buffer(\"\");\r\n#ifdef _UNICODE\r\n\t_itow(iValue,buffer.GetString(),10); \r\n#else\r\n\t_itot(iValue,buffer.GetString(),10); \r\n#endif\r\n\t_attachRight(buffer);\r\n\treturn *this; \t\t\r\n}\r\n\r\nxString& \r\nxString::operator<<(const TChar* rValue)\r\n{\r\n\r\n\tOptimize();\r\n\txString rBuffer(rValue);\r\n\trBuffer.Optimize();\r\n\r\n\treturn operator +=(rBuffer);\r\n\r\n\tconst TChar* buffer = static_cast(rValue);\r\n\tif ( buffer )\r\n\t{\r\n\t\t_attachRight(buffer);\r\n\t\tdelete buffer;\r\n\t}else\r\n\t\treturn *this;\r\n\r\n}\r\n//=======================================================\r\n//\r\n// Concatenation operators\r\n//\r\n//friend xString operator +(const xString& Str1, const xString& Str2);\t// Concatenates two strings (see text)\r\n\r\n//friend xString operator +(const xString& Str1, const xString& Str2);\t// Concatenates two strings (see text)\r\n\r\n\r\n\r\n\r\n\r\n//=======================================================\r\n//\r\n// Access operators\r\n//\r\nTAnsiChar*\r\nxString::Str()\r\n{\t\r\n\treturn operator TAnsiChar*();\r\n}\r\nTChar& \r\nxString::operator [](int Pos)\t// Returns a character reference at a\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t// specific location.\r\n\tif (Pos < 0)\t\t\t\t\t\t\t\t// If underrun, just return first character\r\n\t\treturn Text[0];\r\n\telse if (Pos >= Len)\t\t\t\t\t\t// If overrun, expand string in accordance\r\n\t{\r\n\t\tGrow(Pos+2);\r\n\t\treturn Text[Pos];\r\n\t}\r\n\telse\t\t\t\t\t\t\t\t\t\t\t// Otherwise, just return character\r\n\t\treturn Text[Pos];\r\n}\r\n\r\n\r\n\r\n//=======================================================\r\n//\r\n// Protected low-level functions\r\n//\r\nvoid xString::Optimize()\t\t\t// Discards any unused space allocated for the string\r\n{\r\n\tSize = Len + 1;\r\n\tTChar *Temp = AllocStr(Size);\r\n\t_tcscpy(Temp, Text);\r\n\tFreeStr(Text);\r\n\tText = Temp;\r\n}\r\nvoid xString::Grow(int Num)\t\t// Allocates some more memory so the string can hold an additional Num characters\r\n{\r\n\tSize += Num;\r\n\tTChar *Temp = AllocStr(Size);\r\n\t_tcscpy(Temp, Text);\r\n\tFreeStr(Text);\r\n\tText = Temp;\r\n}\r\nvoid xString::AssignFrom(const xString& Str)\t\t\t// Does the hard work for all non-converting assignments\r\n{\r\n\tSize = Str.Size;\r\n\tLen = Str.Len;\r\n\tif (Size && Len)\t\t\t\t\t\t// No point copying an empty string\r\n\t{\r\n\t\tText = AllocStr(Size);\r\n\t\t_tcscpy(Text, Str.Text);\r\n\t}\r\n\telse\r\n\t{\r\n\t\tText = NULL;\r\n\t}\r\n}\r\n\r\n\r\nTChar *\r\nxString::AllocStr(int Size)\t\t// Allocates a new character array. You can modify this\r\n{\t\t\t\t\t\t\t\t\t\t\t\t// function if you for instance use a custom memory manager.\r\n\t//return new TChar[Size];\r\n\treturn (TChar *)calloc(Size, sizeof(TChar));\r\n}\r\nvoid xString::FreeStr(TChar *Ptr)\t\t// Ditto\r\n{\r\n\tif (Ptr == NULL)\r\n\t\treturn;\r\n\t//delete Ptr;\r\n\t//return;\r\n \r\n\tfree(Ptr);\r\n}\r\n//=======================================================\r\n//\r\n// Concatenation function (must be global for reasons stated in the text)\r\n//\r\n/*\r\n\r\nxString::operator +(const xString& Str1, const TChar& Str2)\r\n{\r\n\r\nTChar *Temp = xString::AllocStr(Str1.Size + Str2.Size);\t\t// Allocate memory for new string\r\nif (Str1.Len)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Copy first string into dest\r\n\t_tcscpy(Temp, Str1.Text);\r\nif (Str2.Len)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Copy second string into dest\r\n\t_tcscpy(&Temp[Str1.Len], Str2.Text);\r\n\r\nxString Result = Temp;\r\nreturn Result;\r\n}*/#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorUserNameModifiedDecl();\r\nCKERROR CreateUserNameModifiedProto(CKBehaviorPrototype **);\r\nint UserNameModified(const CKBehaviorContext& behcontext);\r\nCKERROR UserNameModifiedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorUserNameModifiedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NUserNameModified\");\t\r\n\tod->SetDescription(\"User changed name\");\r\n\t\r\n\tod->SetCategory(\"TNL/User Management\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x6f94031a,0x3e3a1714));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateUserNameModifiedProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_STOP,\r\n\tBB_IT_NEXT\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_USER_ID,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_NAME_CHANGED,\r\n\tBB_O_ERROR\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_USER_ID,\r\n\tBB_OP_USER_NAME,\r\n\tBB_OP_ERROR\r\n};\r\n\r\nCKERROR CreateUserNameModifiedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NUserNameModified\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Stop\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"User\");\r\n\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\t\r\n\tproto->DeclareOutParameter(\"User ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"User Name\", CKPGUID_STRING, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(UserNameModified);\r\n\tproto->SetBehaviorCallbackFct(UserNameModifiedCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint UserNameModified(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\r\n\tint connectionID=-1;\r\n\tbeh->GetInputParameterValue(0,&connectionID);\r\n\t\r\n\tXString userName((CKSTRING) beh->GetInputParameterReadDataPtr(1));\r\n\t\t\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tbbNoError(E_NWE_OK);\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\r\n\tusing namespace vtTools::BehaviorTools;\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t\r\n\tvtConnection *con = cin->getConnection();\r\n\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClient *client = static_cast(dobj);\r\n\t\t\t\t\tif (client)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (client->getUserFlags() == USERNAME_CHANGED && client->getUserID() !=con->getUserID() )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tclient->setUserFlags(USER_OK);\r\n\t\t\t\t\t\t\tint userID = client->getUserID();\r\n\t\t\t\t\t\t\tbeh->SetOutputParameterValue(0,&userID);\r\n\t\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\t\t\t\t\tpout->SetStringValue(const_cast(client->getUserName().getString()));\r\n\t\t\t\t\t\t\txLogger::xLog(ELOGINFO,E_LI_CLIENT,\"User %d changed his name to %s\",userID,client->getUserName().getString());\r\n\t\t\t\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR UserNameModifiedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t/*\tCKParameterIn* pin = beh->GetInputParameter(0);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve first input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tif (pin->GetGUID()!=CKPGUID_MESSAGE) {\r\n\t\t\tpin->SetGUID(CKPGUID_MESSAGE,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : first input parameter type must be \\\"Message\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}\r\n\r\n\t\tpin = beh->GetInputParameter(1);\r\n\t\tif (!pin) {\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : failed to retrieve second input parameter\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\r\n\t\tif (!behcontext.ParameterManager->IsDerivedFrom(pin->GetGUID(),CKPGUID_OBJECT)) {\r\n\t\t\tpin->SetGUID(CKPGUID_BEOBJECT,FALSE);\r\n\r\n\t\t\tCKBehavior* pbeh = beh;\r\n\t\t\tXString name;\r\n\t\t\twhile ((pbeh=pbeh->GetParent())) {\r\n\t\t\t\tname << pbeh->GetName() << \"->\";\r\n\t\t\t}\r\n\t\t\tname << beh->GetName();\r\n\r\n\t\t\tXString str;\r\n\t\t\tstr << '[' << name << \"] : second input parameter type must derived from \\\"BeObject\\\"!\";\r\n\t\t\tbehcontext.Context->OutputToConsole(str.Str(),TRUE);\r\n\t\t}*/\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#ifndef __P_FLUID_H__\r\n#define __P_FLUID_H__\r\n\r\n#include \"pTypes.h\"\r\n#include \"NxPlane.h\"\r\n#include \"pFluidFlags.h\"\r\n\r\n#include \"pTypes.h\"\r\n\r\nclass CK3dPointCloud;\r\n\r\n\r\n/** \\addtogroup Fluid\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief2 Describes an pFluidDesc.\r\n*/\r\nclass MODULE_API pFluidDesc\r\n{\r\npublic:\r\n\r\n\t/**\r\n\t\\brief Sets the maximal number of particles for the fluid used in the simulation.\r\n\r\n\tIf more particles are added directly, or more particles are emitted into the\r\n\tfluid after this limit is reached, they are simply ignored.\r\n\r\n\t*/\r\n\tint\t\t\t\t\t\tmaxParticles;\r\n\r\n\t/**\r\n\t\\brief Defines the number of particles which are reserved for creation at runtime.\r\n\r\n\tIf pFluidDesc.flags.PFF_PriorityMode is set the oldest particles are removed until \r\n\tthere are no more than (maxParticles - numReserveParticles) particles left. This removal\r\n\tis carried out for each simulation step, on particles which have a finite life time \r\n\t(i.e. > 0.0). The deletion guarantees a reserve of numReserveParticles particles which \r\n\tcan be added for each simulaiton step. Note that particles which have equal lifetime can \r\n\tget deleted at the same time. In order to avoid this, the particle lifetimes \r\n\tcan be varied randomly.\r\n\r\n\tThis parameter must be smaller than pFluidDesc.maxParticles.\r\n\t*/\r\n\tint\t\t\t\t\t\tnumReserveParticles;\r\n\r\n\t/**\r\n\t\\brief The particle resolution given as particles per linear meter measured when the fluid is\r\n\tin its rest state (relaxed).\r\n\r\n\tEven if the particle system is simulated without particle interactions, this parameter defines the \r\n\temission density of the emitters.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\trestParticlesPerMeter;\r\n\r\n\t/**\r\n\t\\brief Target density for the fluid (water is about 1000).\r\n\r\n\tEven if the particle system is simulated without particle interactions, this parameter defines \r\n\tindirectly in combination with restParticlesPerMeter the mass of one particle \r\n\t( mass = restDensity/(restParticlesPerMeter^3) ).\r\n\r\n\tThe particle mass has an impact on the repulsion effect on emitters and actors.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\trestDensity;\r\n\r\n\t/**\r\n\t\\brief Radius of sphere of influence for particle interaction.\r\n\r\n\tThis parameter is relative to the rest spacing of the particles, which is defined by the parameter\r\n\trestParticlesPerMeter\r\n\r\n\t( radius = kernelRadiusMultiplier/restParticlesPerMeter ).\r\n\r\n\tThis parameter should be set around 2.0 and definitely below 2.5 for optimal performance and simulation quality.\r\n\r\n\t@see restParticlesPerMeter\r\n\t*/\r\n\tfloat\t\t\t\t\t\tkernelRadiusMultiplier;\r\n\r\n\t/**\r\n\t\\brief Maximal distance a particle is allowed to travel within one timestep.\r\n\r\n\tThis parameter is relative to the rest spacing of the particles, which is defined by the parameter\r\n\trestParticlesPerMeter:\r\n\r\n\t( maximal travel distance = motionLimitMultiplier/restParticlesPerMeter ).\r\n\r\n\tDefault value is 3.6 (i.e., 3.0 * kernelRadiusMultiplier).\r\n\r\n\tThe value must not be higher than the product of packetSizeMultiplier and kernelRadiusMultiplier.\r\n\r\n\t@see restParticlesPerMeter\r\n\t*/\r\n\tfloat\t\t\t\t\t\tmotionLimitMultiplier;\r\n\r\n\t/**\r\n\t\\brief Defines the distance between particles and collision geometry, which is maintained during simulation.\r\n\r\n\tFor the actual distance, this parameter is divided by the rest spacing of the particles, which is defined by the parameter\r\n\trestParticlesPerMeter:\r\n\r\n\t( distance = collisionDistanceMultiplier/restParticlesPerMeter ).\r\n\r\n\tIt has to be positive and not higher than packetSizeMultiplier*kernelRadiusMultiplier.\r\n\tDefault value is 0.12 (i.e., 0.1 * kernelRadiusMultiplier).\r\n\r\n\t@see restParticlesPerMeter, kernelRadiusMultiplier\r\n\t*/\r\n\tfloat\t\t\t\t\t\tcollisionDistanceMultiplier;\r\n\r\n\t/**\r\n\t\\brief This parameter controls the parallelization of the fluid.\r\n\r\n\tThe spatial domain is divided into so called packets, equal sized cubes, aligned in a grid.\r\n\r\n\tThe parameter given defines the edge length of such a packet. This parameter is relative to the interaction \r\n\tradius of the particles, given as kernelRadiusMultiplier/restParticlesPerMeter.\r\n\r\n\tIt has to be a power of two, no less than 4.\r\n\r\n\t*/\r\n\tint\t\t\t\t\t\tpacketSizeMultiplier;\r\n\r\n\t/**\r\n\t\\brief The stiffness of the particle interaction related to the pressure.\r\n\r\n\tThis factor linearly scales the force which acts on particles which are closer to each other than \r\n\tthe rest spacing.\r\n\r\n\tSetting\tthis parameter appropriately is crucial for the simulation. The right value depends on many factors\r\n\tsuch as viscosity, damping, and kernelRadiusMultiplier. Values which are too high will result in an\r\n\tunstable simulation, whereas too low values will make the fluid appear \"springy\" (the fluid\r\n\tacts more compressible).\r\n\r\n\tMust be positive.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tstiffness;\r\n\r\n\t/**\r\n\t\\brief \tThe viscosity of the fluid defines its viscous behavior.\r\n\r\n\tHigher values will result in a honey-like behavior. Viscosity is an effect which depends on the \r\n\trelative velocity of neighboring particles; it reduces the magnitude of the relative velocity.\r\n\r\n\tMust be positive.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tviscosity;\r\n\r\n\t/**\r\n\t\\brief \tThe surfaceTension of the fluid defines an attractive force between particles\r\n\r\n\tHigher values will result in smoother surfaces.\r\n\tMust be nonnegative.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tsurfaceTension;\r\n\r\n\t/**\r\n\t\\brief Velocity damping constant, which is globally applied to each particle.\r\n\r\n\tIt generally reduces the velocity of the particles. Setting the damping to 0 will leave the \r\n\tparticles unaffected.\r\n\r\n\tMust be nonnegative.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tdamping;\r\n\r\n\t/**\r\n\t\\brief Defines a timespan for the particle \"fade-in\".\r\n\r\n\tThis feature is experimental. When a particle is created it has no influence on the simulation. \r\n\tIt takes fadeInTime until the particle has full influence. If set to zero, the particle has full \r\n\tinfluence on the simulation from start.\r\n\r\n\tDefault: 0.0
\r\n\tRange: [0,inf)\r\n\t*/\r\n\tfloat\t\t\t\t\t\tfadeInTime;\r\n\r\n\t/**\r\n\t\\brief Acceleration (m/s^2) applied to all particles at all time steps.\r\n\r\n\tUseful to simulate smoke or fire.\r\n\tThis acceleration is additive to the scene gravity. The scene gravity can be turned off \r\n\tfor the fluid, using the flag PFF_DisableGravity.\r\n\r\n\t@see pFluid.getExternalAcceleration() pFluid.setExternalAcceleration()\r\n\t*/\r\n\tVxVector\t\t\t\t\t\texternalAcceleration;\r\n\r\n\t/**\r\n\t\\brief Defines the plane the fluid particles are projected to. This parameter is only used if\r\n\tPFF_ProjectToPlane is set.\r\n\r\n\tDefault: XY plane\r\n\r\n\t@see PFF_ProjectToPlane pFluid.getProjectionPlane() pFluid.setProjectionPlane()\r\n\t*/\r\n\tNxPlane\t\t\t\t\t\tprojectionPlane;\r\n\r\n\t/**\r\n\t\\brief Defines the restitution coefficient used for collisions of the fluid particles with static shapes.\r\n\r\n\tMust be between 0 and 1.\r\n\r\n\tA value of 0 causes the colliding particle to get a zero velocity component in the\r\n\tdirection of the surface normal of the static shape at the collision location; i.e.\r\n\tit will not bounce.\r\n\r\n\tA value of 1 causes a particle's velocity component in the direction of the surface normal to invert;\r\n\ti.e. the particle bounces off the surface with the same velocity magnitude as it had before collision. \r\n\t(Caution: values near 1 may have a negative impact on stability)\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\trestitutionForStaticShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the dynamic friction of the fluid regarding the surface of a static shape.\r\n\r\n\tMust be between 0 and 1.\r\n\r\n\tA value of 1 will cause the particle to lose its velocity tangential to\r\n\tthe surface normal of the shape at the collision location; i.e. it will not slide\r\n\talong the surface.\r\n\r\n\tA value of 0 will preserve the particle's velocity in the tangential surface\r\n\tdirection; i.e. it will slide without resistance on the surface.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tdynamicFrictionForStaticShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the static friction of the fluid regarding the surface of a static shape.\r\n\r\n\tThis feature is currently unimplemented! \r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tstaticFrictionForStaticShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the strength of attraction between the particles and static rigid bodies on collision. \r\n\r\n\tThis feature is currently unimplemented! \r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tattractionForStaticShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the restitution coefficient used for collisions of the fluid particles with dynamic shapes.\r\n\r\n\tMust be between 0 and 1.\r\n\r\n\t(Caution: values near 1 may have a negative impact on stability)\r\n\r\n\t@see restitutionForStaticShapes\r\n\t*/\r\n\tfloat\t\t\t\t\t\trestitutionForDynamicShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the dynamic friction of the fluid regarding the surface of a dynamic shape.\r\n\r\n\tMust be between 0 and 1.\r\n\r\n\t@see dynamicFrictionForStaticShapes\r\n\t*/\r\n\tfloat\t\t\t\t\t\tdynamicFrictionForDynamicShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the static friction of the fluid regarding the surface of a dynamic shape.\r\n\r\n\tThis feature is currently unimplemented! \r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tstaticFrictionForDynamicShapes;\r\n\r\n\t/**\r\n\t\\brief Defines the strength of attraction between the particles and the dynamic rigid bodies on collision. \r\n\r\n\tThis feature is currently unimplemented! \r\n\r\n\t*/\r\n\tfloat\t\t\t\t\t\tattractionForDynamicShapes;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from fluid to colliding rigid bodies.\r\n\r\n\tOnly has an effect if PFF_CollisionTwoway is set.\r\n\r\n\tDefault: 0.2
\r\n\tRange: [0,inf)\r\n\r\n\t@see PFF_CollisionTwoway pFluid.setCollisionResponseCoefficient()\r\n\t*/\r\n\tfloat\t\t\t\t\t\tcollisionResponseCoefficient;\r\n\r\n\t/**\r\n\t\\brief pFluidSimulationMethod flags. Defines whether or not particle interactions are considered \r\n\tin the simulation.\r\n\r\n\t@see pFluidSimulationMethod\r\n\t*/\r\n\tpFluidSimulationMethod\t\t\t\t\t\tsimulationMethod;\r\n\r\n\t/**\r\n\t\\brief pFluidCollisionMethod flags. Selects whether static collision and/or dynamic collision \r\n\twith the environment is performed.\r\n\r\n\t@see pFluidCollisionMethod\r\n\t*/\r\n\tpFluidCollisionMethod\t\t\t\t\t\tcollisionMethod;\r\n\r\n\t/**\r\n\t\\brief Sets which collision group this fluid is part of.\r\n\r\n\tDefault: 0\r\n\r\n\tpFluid.setCollisionGroup()\r\n\t*/\r\n\tint collisionGroup;\r\n\r\n\r\n\t/**\r\n\t\\brief Sets the 128-bit mask used for collision filtering.\r\n\r\n\tDefault: 0\r\n\r\n\t@see NxGroupsMask pFluid.setGroupsMask() pFluid.getGroupsMask()\r\n\t*/\r\n\tNxGroupsMask groupsMask;\r\n\r\n\t/**\r\n\t\\brief Flags defining certain properties of the fluid.\r\n\r\n\t@see pFluidFlag\r\n\t*/\r\n\tunsigned int\t\t\t\t\t\tflags;\r\n\r\n\tvoid*\t\t\t\t\t\tuserData;\t//!< Will be copied to NxFluid::userData\r\n\tconst char*\t\t\t\t\tname;\t\t//!< Possible debug name. The string is not copied by the SDK, only the pointer is stored.\r\n\r\n\t/**\r\n\t\\brief Constructor sets to default.\r\n\r\n\t*/\r\n\tpFluidDesc();\t\r\n\t/**\r\n\t\\brief (Re)sets the structure to the default.\t\r\n\r\n\t*/\r\n\tvoid setToDefault();\r\n\t/**\r\n\t\\brief Returns true if the current settings are valid\r\n\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n\r\n\t/**\r\n\t\\brief Retrieve the fluid desc type.\r\n\r\n\t\\return The fluid desc type. See #pFluidDescType\r\n\t*/\r\n\txU16 getType() const;\r\n\r\n\tCK_ID worldReference;\r\n\r\nprotected:\r\n\r\n\tNxFluidDescType\t\t\ttype;\r\n\r\n};\r\n\r\n\r\nstruct pParticle\r\n{\r\n\tNxVec3\tposition;\r\n\tNxVec3 velocity;\r\n\tfloat\tdensity;\r\n\tfloat lifetime;\r\n\tunsigned int\tid;\r\n\tNxVec3\tcollisionNormal;\r\n};\r\n\r\n/**\r\n\\brief The fluid class represents the main module for the particle based fluid simulation.\r\nSPH (Smoothed Particle Hydrodynamics) is used to animate the particles.\r\n\r\nThere are two kinds of particle interaction forces which govern the behavior of the fluid:\r\n

    \r\n
  1. \r\n\tPressure forces: These forces result from particle densities higher than the\r\n\t\"rest density\" of the fluid. The rest density is given by specifying the inter-particle\r\n\tdistance at which the fluid is in its relaxed state. Particles which are closer than\r\n\tthe rest spacing are pushed away from each other.\r\n
  2. \r\n\tViscosity forces: These forces act on neighboring particles depending on the difference\r\n\tof their velocities. Particles drag other particles with them which is used to simulate the\r\n\tviscous behaviour of the fluid.\r\n
\r\n\tThe fluid class manages a set of particles.\r\n\tParticles can be created in two ways:\r\n
    \r\n
  1. \r\n\tParticles can be added by the user directly.\r\n
  2. \r\n\tThe user can add emitters to the fluid and configure the parameters of the emission.\r\n\t(See pFluidEmitter)\r\n
\r\n\tParticles can be removed in two ways as well:\r\n
    \r\n
  1. \r\n\tThe user can specify a lifetime for the particles. When its lifetime expires, a particle is deleted.\r\n
  2. \r\n\tShapes can be configured to act as drains. When a particle intersects with a drain, the particle is deleted.\r\n\t(See pShapeFlag)\r\n
\r\n\r\nParticles collide with static and dynamic shapes. Particles are also affected by the scene gravity and a user force, \r\nas well as global velocity damping. In order to render a fluid, the user can supply the fluid instance with a \r\nuser buffer into which the particle state is written after each simuation step.\r\n\r\nFor a good introduction to SPH fluid simulation,\r\nsee http://graphics.ethz.ch/~mattmuel/publications/sca03.pdf\r\n\r\n@see pFluidDesc, pFluidEmitter, pFluidEmitterDesc, pShapeFlag\r\n*/\r\nclass pFluid\r\n{\r\n\tpublic:\r\n\t\tpFluid(NxFluidDesc &desc, bool trackUserData, bool provideCollisionNormals, const VxVector& color, float particleSize);\r\n\t\t~pFluid();\r\n\r\n\t\tNxFluid*\t\t\t\tgetNxFluid() { return mFluid; }\r\n\r\n\t\tpParticle*\t\tgetParticles() { return mParticleBuffer; }\r\n\t\tunsigned\t\t\t\tgetParticlesNum() { return mParticleBufferNum; }\r\n\r\n\t\tconst unsigned*\t\t\tgetCreatedIds() { return mCreatedParticleIds; }\r\n\t\tunsigned\t\t\t\tgetCreatedIdsNum() { return mCreatedParticleIdsNum; }\r\n\r\n\t\tconst unsigned*\t\t\tgetDeletedIds() { return mDeletedParticleIds; }\r\n\t\tunsigned\t\t\t\tgetDeletedIdsNum() { return mDeletedParticleIdsNum; }\r\n\r\n\t\tvoid\t\t\t\t\tsetParticleSize(float size) { mParticleSize = size; }\r\n\t\tfloat\t\t\t\t\tgetParticleSize() { return mParticleSize; }\r\n\r\n\t\tvoid draw();\r\n\t\t\r\n\t\tNxFluid* getFluid() const { return mFluid; }\r\n\t\tvoid setFluid(NxFluid* val) { mFluid = val; }\r\n\t\t\r\n\t\tCK_ID getEntityID() const { return entityID; }\r\n\t\tvoid setEntityID(CK_ID val) { entityID = val; }\r\n\t\tvoid updateVirtoolsMesh();\r\n\r\n\t\tCK3dEntity *getParticleObject();\r\n\r\n\t\tpParticle*\t\tmParticleBuffer;\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* emitter operations :\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t\t/************************************************************************/\r\n\r\n\t\t/**\r\n\t\t\\brief Creates an emitter for this fluid.\r\n\r\n\t\tpFluidEmitterDesc::isValid() must return true.\r\n\r\n\t\t\\param desc The fluid emitter descriptor. See #pFluidEmitterDesc.\r\n\t\t\\return The new fluid.\r\n\r\n\t\t@see pFluidEmitter\r\n\t\t*/\r\n\t\tpFluidEmitter*\t\tcreateEmitter(const pFluidEmitterDesc& desc);\r\n\r\n\t\t/**\r\n\t\t\\brief Deletes the specified emitter.\r\n\r\n\t\tThe emitter must belong to this fluid. Do not keep a reference to the deleted instance.\r\n\t\tAvoid release calls while the scene is simulating (in between simulate() and fetchResults() calls).\r\n\r\n\t\t\\param emitter The emitter to release.\r\n\r\n\t\t*/\r\n\t\tvoid\t\t\t\treleaseEmitter(pFluidEmitter& emitter);\r\n\r\n\t\t/**\r\n\t\t\\brief Returns the number of emitters.\r\n\r\n\t\t\\return The number of emitters.\r\n\t\t*/\r\n\t\tint getNbEmitters()const;\r\n\r\n\r\n\r\n\t\tCK3dPointCloud* mPointCloud;\r\n\t\t\r\n\t\tCK3dPointCloud* getPointCloud() const { return mPointCloud; }\r\n\t\tvoid setPointCloud(CK3dPointCloud* val) { mPointCloud = val; }\r\n\r\n\t\tvoid updateCloud();\r\n\r\n\r\n\r\n\r\n\r\nprivate:\r\n\r\n\tunsigned\t\t\tmParticleBufferNum;\r\n\t\r\n\r\n\tNxFluid*\t\t\tmFluid;\r\n\t\r\n\tVxVector\t\t\t\tmParticleColor;\r\n\tfloat\t\t\t\tmParticleSize;\r\n\tunsigned int\t\t\t\tmMaxParticles;\r\n\t\r\n\tCK_ID\tentityID;\r\n\t\r\n\r\n\t/**\r\n\tThese fields are only relevant for tracking user particle data (MyParticle)\r\n\t*/\r\n\tbool\t\t\t\tmTrackUserData;\r\n\tpFluid*\t\t\tmMyParticleBuffer;\r\n\tunsigned int\t\t\t\tmCreatedParticleIdsNum;\r\n\tunsigned int*\t\t\t\tmCreatedParticleIds;\r\n\tunsigned int\t\t\t\tmDeletedParticleIdsNum;\r\n\tunsigned int*\t\t\t\tmDeletedParticleIds;\r\n\r\n\t//rendering\r\n\tfloat*\t\t\t\tmRenderBuffer;\r\n\tfloat*\t\t\t\tmRenderBufferUserData;\r\n\r\n\tprotected:\r\n\tprivate:\r\n};\r\n\r\n\r\n/** @} */\r\n\r\n#endif\r\n/********************************************************************\r\n\tcreated:\t2007/10/29\r\n\tcreated:\t29:10:2007 15:16\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\\xSystem3D.h\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\r\n\tfile base:\txSystem3D\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#include \r\n\r\nnamespace xSystem3DHelper\r\n{\r\n\r\n\t\tMODULE_API int xSGetAvailableTextureMem();\r\n\t\tMODULE_API float xSGetPhysicalMemoryInMB();\r\n\t\tMODULE_API int xSGetPhysicalGPUMemoryInMB(int device);\r\n\t\tMODULE_API void xSSaveAllDxPropsToFile(char*file);\r\n\t\tMODULE_API void xSGetDXVersion(char*& versionstring,int& minor);\r\n\r\n}copy X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\examples\\*.cmo X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\doxyOutput\\html /y\r\ncopy X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\examples\\vehicle\\*.cmo X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\doxyOutput\\html /y\r\n\r\ncopy X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\scenes\\*.cmo X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\doxyOutput\\html /y\r\ncopy X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\scenes\\vehicle\\*.cmo X:\\ProjectRoot\\svn\\cellador\\virtools\\vtPhysX\\Doc\\doxyOutput\\html /y\r\n\r\n\r\n\r\ndoxygen .\\doxyConfig.dox\r\n\r\n\r\n\r\n\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmod_vtAgeia\\Doc /y\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmodsvn\\Plugins\\vtAgeia\\Documentation /y\r\n\r\n\r\n\r\n\r\n\r\ncmake_minimum_required(VERSION 2.6)\r\n\r\nSET( CMAKE_CURRENT_SOURCE_DIR \"./CMAKEFiles\")\r\nSET( CMAKE_HOST_WIN32 \"TRUE\")\r\n\r\n\r\n#--------Looking for Dev 35 Directory ! Stored in variable \"VTDEV35DIR\"\r\n\r\ninclude (\"CMakeFindMakeVTDev35.cmake\")\r\n\r\nIF(VTDEV35DIR)\r\n\tMESSAGE(STATUS \"\\n\\n\\t Virtools Dev Directory 3.5 found : ${VTDEV35DIR} \\n \\n\")\r\nELSE(VTDEV35DIR)\r\n\tMESSAGE(ERROR \"\\n\\n\\t Virtools Dev Directory 3.5 NOT found !!!\t\\n \\n\")\r\nENDIF(VTDEV35DIR)\r\nfile(APPEND \"VTPaths.lua\" \"DEV35DIR=\\\"${VTDEV35DIR}\\\"\t\\n\" )\r\n\r\n\r\n\r\n\r\n\r\n\r\n#--------Looking for Dev 40 Directory ! Stored in variable \"VTDEV40DIR\"\r\n\r\ninclude (\"CMakeFindMakeVTDev40.cmake\")\r\n\r\nIF(VTDEV40DIR)\r\n\t\tMESSAGE(STATUS \"\\n\\n\\t Virtools Dev Directory 4.0 found : ${VTDEV40DIR} \\n \\n\")\r\nELSE(VTDEV40DIR)\r\n\tMESSAGE(ERROR \"\\n\\n\\t Virtools Dev Directory 4.0 NOT found !!!\t\\n \\n\")\r\nENDIF(VTDEV40DIR)\r\nfile(APPEND \"VTPaths.lua\" \"DEV40DIR=\\\"${VTDEV40DIR}\\\" \\n\" )\r\n\r\n\r\n#--------Looking for Dev 41 Directory ! Stored in variable \"VTDEV41DIR\"\r\n\r\ninclude (\"CMakeFindMakeVTDev41.cmake\")\r\n\r\nIF(VTDEV41DIR)\r\n\t\tMESSAGE(STATUS \"\\n\\n\\t Virtools Dev Directory 4.1 found : ${VTDEV41DIR} \\n \\n\")\r\nELSE(VTDEV41DIR)\r\n\tMESSAGE(ERROR \"\\n\\n\\t Virtools Dev Directory 4.1 NOT found !!!\t\\n \\n\")\r\nENDIF(VTDEV41DIR)\r\n\r\nfile(APPEND \"VTPaths.lua\" \"DEV41DIR=\\\"${VTDEV41DIR}\\\"\t\\n\" )\r\n\r\n#--------Looking for Virtools WebaPlayer ! Stored in variable \"WEBPLAYER\"\r\n\r\ninclude (\"CMakeFindMakeWebPlayer.cmake\")\r\n\r\nIF(WEBPLAYER)\r\n\t\tMESSAGE(STATUS \"\\n\\n\\t Virtools Web Player found : ${WEBPLAYERDIR} \\n \\n\")\r\nELSE(WEBPLAYER)\r\n\tMESSAGE(ERROR \"\\n\\n\\t Virtools WebPlayer 4.1 NOT found !!!\t\\n \\n\")\r\nENDIF(WEBPLAYER)\r\n\r\nfile(APPEND \"VTPaths.lua\" \"WEBPLAYERDIR=\\\"${WEBPLAYERDIR}\\\"\t\\n\" )\r\n\r\n\r\n\r\n#include \"vtConnection.h\"\r\n#include \"xNetInterface.h\"\r\n\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"xDistTools.h\"\r\n\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xLogger.h\"\r\n\r\n\r\nTNL_IMPLEMENT_NETCONNECTION(vtConnection, TNL::NetClassGroupGame, true);\r\nint userIDCounter = 0;\r\n//extern int sessionIDCounter;\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSession.h\"\r\n\r\n\r\n\r\n\r\n\r\nTNL_IMPLEMENT_RPC(vtConnection, s2cAddServerLogEntry, \r\n\t\t\t\t (TNL::StringPtr entry),\r\n\t\t\t\t (entry),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\r\n\r\n}\r\n\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sDeleteSession_RPC, \r\n\t\t\t\t (TNL::Int<16>sessionID),\r\n\t\t\t\t (sessionID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\r\n\t//xLogger::xLog(ELOGINFO,XL_START,\"server : deleting session%d\",sessionID);\r\n\txDistributedSession *session = sInterface->get(sessionID);\r\n\r\n\tif (!session)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,XL_START,\"client : leaving user %d fails : session doesn't exists\",getUserID());\r\n\t}\r\n\tif (session)\r\n\t{\r\n\r\n\t\tif (!session->isClientJoined(getUserID()))\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGINFO,XL_START,\"client : deleting session fails, user not joined :%d \",getUserID());\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\toInterface->deleteObject(session->getServerID());\r\n\t\t\r\n\t\t//xLogger::xLog(ELOGINFO,XL_START,\"client : user %d left session : %d \",client->getUserID(),session->getSessionID());\r\n\t\t/*client->setSessionID(-1);\r\n\t\tclient->getClientFlags().set(1 << E_CF_SESSION_JOINED,false);\r\n\t\tclient->getClientFlags().set(1 << E_CF_DELETING,true);\r\n\t\tclient->setUserFlags(USER_DELETED);*/\r\n\t}\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sLockSession_RPC, \r\n\t\t\t\t (TNL::Int<16>sessionID),\r\n\t\t\t\t (sessionID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\r\n\t/*\r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\tif (!client)\r\n\t{\r\n\t\txLogger::xLog(ELOGINFO,XL_START,\"server : leaving user %d fails : client doesn't exists\",userID);\r\n\r\n\t}\r\n\tif (client)\r\n\t{\r\n\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\r\n\t\t\tif (!session->isClientJoined(userID))\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGINFO,XL_START,\"server : leaving user fails :%d on session : %d , user not joined\",client->getUserID(),session->getSessionID());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tsession->removeUser(client);\r\n\t\t\tclient->setSessionID(-1);\r\n\t\t\tsetSessionID(-1);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_SESSION_JOINED,false);\r\n\r\n\t\t\txLogger::xLog(ELOGINFO,XL_START,\"server : user %d left session %d\",userID,sessionID);\r\n\r\n\t\t\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\t\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t\t{\r\n\t\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\t\tcon->s2cUserLeftSession_RPC(client->getUserID(),sessionID);\r\n\t\t\t}\r\n\t\t}\r\n\t}*/\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, s2cUserLeftSession_RPC, \r\n\t\t\t\t (TNL::Int<16>userID,TNL::Int<16>sessionID),\r\n\t\t\t\t (userID,sessionID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\r\n\r\n\tif (!nInterface->getCurrentSession())\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Client : leaving user %d failed : You not joined any Session\",userID);\r\n\t}\r\n\r\n\r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\tif (!client)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Removing user %d from session %d failed : client object doesn't exists\",userID,sessionID);\r\n\t}\r\n\r\n\r\n\tif (client)\r\n\t{\r\n\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\tif (!session)\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Removing user %d from session %d failed : session doesn't exists\",userID,sessionID);\r\n\t\t}\r\n\t\tif (session)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (!session->isClientJoined(userID))\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Removing user %d from session %d failed : \\n\\t %s\",userID,sessionID,\"user not present in this session !\");\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tsession->removeUser(client);\r\n\r\n\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"client : user %d left session : %d \",client->getUserID(),session->getSessionID());\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Removed user %d from session %d !\",userID,sessionID);\r\n\r\n\t\t\tclient->setSessionID(-1);\r\n\t\t\tdisableFlag(client->getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\tenableFlag(client->getClientFlags(),E_CF_DELETING);\r\n\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sLeaveSession_RPC, \r\n\t\t\t\t (TNL::Int<16>userID,TNL::Int<16>sessionID,TNL::Int<16>destroy),\r\n\t\t\t\t (userID,sessionID,destroy),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\tif (client)\r\n\t{\r\n\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\t\t\r\n\t\t\tif (getUserID()!=session->getUserID() && getUserID()!=userID )\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : removing user %d from session :%d failed ! : you must be session master ! \",client->getUserID(),session->getSessionID());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (!session->isClientJoined(userID))\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : leaving user fails :%d on session : %d , user not joined\",client->getUserID(),session->getSessionID());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tsession->removeUser(client);\r\n\t\t\tclient->setSessionID(-1);\r\n\t\t\tsetSessionID(-1);\r\n disableFlag(client->getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\t\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server : user %d left session %d\",userID,sessionID);\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : user %d left session %d\",userID,sessionID);\r\n\r\n\t\t\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\t\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t\t{\r\n\t\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\t\tcon->s2cUserLeftSession_RPC(client->getUserID(),sessionID);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (destroy && getUserID()==session->getUserID() )\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : session master %d left !, deleting session %d\",userID,sessionID);\r\n\t\t\t\tsInterface->deleteSession(session->getSessionID());\r\n\t\t\t\t//sessionIDCounter--;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : joining user %d on session : %d failed :\\n\\t\t\t\\\r\n\t\t\t\t\t\t\t\t\t\t\t , couldn't find session object !\",userID,sessionID);\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : joining user %d on session : %d failed :\\n\\t\t\t\\\r\n\t\t\t\t\t\t\t\t\t\t\t, couldn't find client object \",userID,sessionID);\r\n\t}\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sJoinSession_RPC, \r\n\t\t\t\t (TNL::Int<16>userID,TNL::Int<16>sessionID,TNL::StringPtr password),\r\n\t\t\t\t (userID,sessionID,password),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n \r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\tif (client)\r\n\t{\r\n\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\r\n\t\t\tif (session->isPrivate())\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tif ( strcmp(session->getPassword().getString() , password.getString() ) )\r\n\t\t\t\t{\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server : joining user fails :%d on session : %d , password incorrect\",client->getUserID(),session->getSessionID());\r\n\t\t\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : joining user %d on session : %d failed :\\n\\t , password incorrect\",client->getUserID(),session->getSessionID());\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (session->isLocked())\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_SESSION,\"Server : joining user %d on session : %d failed :, session locked\",client->getUserID(),session->getSessionID());\r\n\t\t\t\treturn;\r\n\r\n\t\t\t}\r\n\t\t\tif (session->isClientJoined(userID))\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_SESSION,\"Server : joining user %d on session %d failed : \\n\\t\t user already joined\",client->getUserID(),session->getSessionID());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tsession->addUser(client);\r\n\t\t\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\t\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t\t{\r\n\t\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\t\tcon->s2cUserJoinedSession_RPC(client->getUserID(),sessionID);\r\n\t\t\t}\r\n\r\n\t\t\tclient->setSessionID(sessionID);\r\n\t\t\tsetSessionID(sessionID);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_SESSION_JOINED,true);\r\n\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"server : joining user :%d on session : %d \",client->getUserID(),session->getSessionID());\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : user :%d on session %d joined\",client->getUserID(),session->getSessionID());\r\n\r\n\t\t}else{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : joining user %d on session : %d failed :\\n\\t , couldn't find session object !\",userID,sessionID);\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : joining user %d on session : %d failed :\\n\\t\t, couldn't find client object \",userID,sessionID);\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, s2cUserJoinedSession_RPC, \r\n\t\t\t\t (TNL::Int<16>userID,TNL::Int<16>sessionID),\r\n\t\t\t\t (userID,sessionID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\tISession *sInterface = nInterface->getSessionInterface();\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\r\n\t\r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\tif (client)\r\n\t{\r\n\t\txDistributedSession *session = sInterface->get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,\"session user size : %d \",session->getClientTable().size());\r\n\t\t}\r\n\t\tif (session && !session->isClientJoined(client->getUserID()))\r\n\t\t{\r\n\t\t\tsession->addUser(client);\r\n\t\t\t\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_SESSION_JOINED,true);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_ADDING,true);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_SESSION_DESTROYED,false);\r\n\t\t\tclient->setSessionID(sessionID);\r\n\t\t\r\n\t\t\tif (userID == getUserID() )\r\n\t\t\t{\r\n\t\t\t\tnInterface->setCurrentSession(session);\r\n\t\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,\"we entered session, user size : %d \",session->getClientTable().size());\r\n\r\n\r\n\r\n\t\t\t\txDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();\r\n\t\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\t\t\twhile (begin!=end)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\t\t\tif (distObject)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\t\t\tif (_class)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n/*\t\t\t\t\t\t\t\tif (session->isClientJoined(distClient->getUserID()))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"client %d is in table\",distClient->getUserID());\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (isFlagOn(distClient->getClientFlags(),E_CF_SESSION_JOINED))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"client %d is has joined flag\",distClient->getUserID());\r\n\t\t\t\t\t\t\t\t}\r\n*/\r\n\t\t\t\t\t\t\t\tif (distClient && distClient->getSessionID() ==session->getSessionID() )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);\r\n\t\t\t\t\t\t\t\t\tenableFlag(distClient->getClientFlags(),E_CF_ADDING);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbegin++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Client : user :%d joined on session : %d ,table size : %d\",client->getUserID(),session->getSessionID(),session->getClientTable().size());\r\n\t\t}\r\n\t\t/*xLogger::xLog(ELOGERROR,E_LI_SESSION,\"Client : joining user %d on session %d failed : \\n\\t\t\\\r\n\t\t\t\t\t\t\t\t\t\t\t Couldn't find Client object for user %d\",client->getUserID(),session->getSessionID());*/\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sCreateSession_RPC, \r\n\t\t\t\t (TNL::StringPtr name,TNL::Int<16>type,TNL::Int<16>maxUsers,TNL::StringPtr password),\r\n\t\t\t\t (name,type,maxUsers,password),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class \r\n\r\n\txDistributedSessionClass *classTemplate = (xDistributedSessionClass*)cInterface->get(name.getString());\r\n\tif (!classTemplate)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server : creating session %s by user %d failed : \\n\\t %s\"\t\t\\\r\n\t\t\t,name.getString(),getUserID(),\"Session class not found \");\r\n\t\treturn;\r\n\t}\r\n\r\n\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : Deploying session class for session :%s\",classTemplate->getClassName().getString());\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\tfor(int i = 0; i < con_list.size(); i++)\r\n\t{\r\n\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\tif (con->getUserID() != getUserID() )\r\n\t\t{\r\n\t\t\tnInterface->deploySessionClasses(con);\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the distObject :\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedSession *distObject = (xDistributedSession*)doInterface->get( name.getString(),E_DC_BTYPE_SESSION);\r\n\tif (distObject)\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_SESSION,\"Server :session %s already exists!\",name.getString());\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tdistObject = new xDistributedSession();\r\n\tdistObject->setDistributedClass(classTemplate);\r\n\tdistObject->setObjectFlags(E_DO_CREATION_COMPLETE);\r\n\r\n\tdistObject->setEntityID(-1);\r\n\tdistObject->setServerID(getGhostIndex(distObject));\r\n\r\n\tnInterface->setDOCounter(nInterface->getDOCounter()+1);\r\n\tdistObject->SetName(name.getString());\r\n\tdistObject->setNetInterface(nInterface);\r\n\r\n \r\n\t\r\n\tdistObject->setUserID(getUserID());\r\n\r\n\tnInterface->getDistributedObjects()->push_back(distObject);\r\n\tdistObject->initProperties();\r\n\tdistObject->setMaxUsers(maxUsers);\r\n\tdistObject->setPassword();\r\n\r\n\t((xDistributedSession*)distObject)->setPassword(password);\r\n\r\n\tfloat time = (float)Platform::getRealMilliseconds();\r\n\tint uid = getUserID();\r\n\tdistObject->setCreationTime(time);\r\n\t\r\n\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : Client created session %s\",name.getString());\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, c2sDORequestOwnerShip, \r\n\t\t\t\t (TNL::S32 userID,TNL::Int<16>serverID),\r\n\t\t\t\t (userID,serverID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\r\n\t\r\n\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the distObject :\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedObject *distObject = doInterface->get( serverID );\r\n\tif (distObject)\r\n\t{\r\n\t\txLogger::xLog(ELOGINFO,XL_START,\"user : %d is requesting ownership for object :%d|currentOwner:%d\",getUserID(),serverID,distObject->getUserID());\r\n\t\tdistObject->setUserID(userID);\r\n\r\n\t}\r\n\t\r\n\r\n\tif (distObject /*&& distObject->getUserID() != getUserID() */)\r\n\t{\r\n\r\n\t\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t{\r\n\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\tcon->s2cDOChangeOwnershipState(serverID,userID,E_DO_OS_OWNERCHANGED);\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, s2cDOChangeOwnershipState, \r\n\t\t\t\t (TNL::Int<16>serverID,TNL::S32 newOwnerID,TNL::S32 state),\r\n\t\t\t\t (serverID,newOwnerID,state),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\r\n\t\r\n\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the distObject :\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedObject *distObject = doInterface->get( serverID );\r\n\tif (distObject)\r\n\t{\r\n\t\txLogger::xLog(ELOGINFO,XL_START,\"user. %d : ownerchange retrieved for obj :%d from user %d\",getUserID(),serverID,newOwnerID );\r\n\t\t\r\n\t\t//distObject->getOwnershipState().set( 1<getUserID() !=newOwnerID );\r\n\t\tdistObject->getOwnershipState().set( 1<setUserID(newOwnerID);\r\n\t\tdistObject->getOwnershipState().set( 1<getUserID() == getUserID() );\r\n\t\tdistObject->getOwnershipState().set( 1 << E_DO_OS_BIND , !distObject->isOwner() );\r\n distObject->getOwnershipState().set( 1 << E_DO_OS_RELEASED, newOwnerID ? true : false ); \r\n\t}\r\n}\r\n\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::writePacket(TNL::BitStream *bstream,TNL::NetConnection::PacketNotify*notify)\r\n{\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\r\n\tif(isConnectionToServer())\n\t{\r\n\t\tU32 firstSendIndex = highSendIndex[0];\n\t\tif(firstSendIndex < firstMoveIndex)\n\t\t\tfirstSendIndex = firstMoveIndex;\n\n\t\tbstream->write(getControlCRC());\n\n\t\tbstream->write(firstSendIndex);\n\t\tU32 skipCount = firstSendIndex - firstMoveIndex;\n\t\tU32 moveCount = 0 - skipCount;\n\n\t\tbstream->writeRangedU32(moveCount, 0, MaxPendingMoves);\r\n\t\tint updateCount =nInterface->getObjectUpdateCounter();\r\n\t\t\r\n\t\tint flag = NO_UPDATE;\r\n\t\tif (updateCount)\r\n\t\t{\r\n\t\t\tmWriteTypeTracker=0;\r\n\t\t\tflag = GHOST_UPDATE;\r\n\t\t}else\r\n\t\t{\r\n\t\t\t((GamePacketNotify *) notify)->updateType=NO_UPDATE;\r\n\t\t}\r\n\r\n\t\t//sending update flag :\r\n\t\tbstream->writeRangedU32(flag, 0, MaxPendingMoves);\r\n\r\n\t\tif (flag == GHOST_UPDATE)\r\n\t\t{\r\n\t\t\t//Sending object count : \r\n\t\t\tbstream->writeRangedU32(updateCount, 0, MaxPendingMoves);\r\n\r\n\t\t\txDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();\r\n\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\txDistObjectIt end = distObjects->end();\r\n\t\t\twhile (begin!=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedObject *cobj = *begin;\n\t\t\t\tif (cobj && cobj->getUpdateState()==E_DO_US_PENDING)\r\n\t\t\t\t{\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//writing out objects id : \r\n\t\t\t\t\tS32 ghostIndex = getGhostIndex(cobj);\r\n\t\t\t\t\tbstream->writeInt(ghostIndex, GhostConnection::GhostIdBitSize);\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//writing objects state : \r\n\t\t\t\t\tcobj->pack(bstream);\r\n\t\t\t\t\tcobj->setUpdateState(E_DO_US_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\t}\r\n\telse\r\n\t{\r\n\t\tS32 ghostIndex = -1;\n\t\tif(scopeObject.isValid())\n\t\t{\n\t\t\tghostIndex = getGhostIndex(scopeObject);\n\t\t}\n\t\tmCompressPointsRelative = bstream->writeFlag(ghostIndex != -1);\n\t\tif(bstream->writeFlag(getControlCRC() != mLastClientControlCRC))\n\t\t{\n\t\t\tif(ghostIndex != -1)\n\t\t\t{\n\t\t\t\tbstream->writeInt(ghostIndex, GhostConnection::GhostIdBitSize);\n\t\t\t\tscopeObject->writeControlState(bstream);\n\t\t\t}\n\t\t}\r\n\t}\n\t\t\r\n\t//xLogger::xLog(ELOGINFO,XL_START,\"pkt w\");\r\n\tParent::writePacket(bstream, notify);\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::readPacket(TNL::BitStream *bstream)\n{\n\t//xLogger::xLog(ELOGINFO,XL_START,\"pkt\");\n\n\txNetInterface *nInterface = static_cast(getInterface());\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\n\t\n\tbool replayControlObjectMoves = false;\n\n\n\tif(isConnectionToClient())\n\t{\n\t\tbstream->read(&mLastClientControlCRC);\n\n\t\tU32 firstMove;\n\t\tbstream->read(&firstMove);\n\t\tU32 count = bstream->readRangedU32(0, MaxPendingMoves);\n\t\tcount +=0;\n\n\t\t//retrieving update flag :\n\t\tU32 flag = bstream->readRangedU32(0, MaxPendingMoves);\n\n\t\tif ( flag == GHOST_UPDATE)\r\n\t\t{\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"ghost update received\");\r\n\t\t\t//retrieve object counter : \r\n\t\t\tU32 ocounter = bstream->readRangedU32(0, MaxPendingMoves);\r\n\t\t\t\r\n\t\t\tfor (unsigned int i = 0 ; ireadInt(GhostConnection::GhostIdBitSize);\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t/*xDistributedClient *dstClient = static_cast(doInterface->getByUserID(getUserID(),E_DC_BTYPE_CLIENT));\r\n\t\t\t\tif (dstClient)\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGINFO,XL_START,\"ghost update received from %d\",getUserID());\r\n\t\t\t\t\tdstClient->setLastUpdater(getUserID());\r\n\t\t\t\t\tdstClient->unpack(bstream,getOneWayTime());\r\n\r\n\t\t\t\t}*/\r\n\r\n\t\t\t\t\r\n\t\t\t\txDistributedObject *dobj = static_cast(resolveGhostParent(ghostIndex));\r\n\t\t\t\tif (dobj)\r\n\t\t\t\t{\r\n\t\t\t\t\tdobj->setLastUpdater(ghostIndex);\r\n\t\t\t\t\tdobj->unpack(bstream,getOneWayTime());\r\n\t\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"ghost update received from %d for object :%d | foundbyIndex %d\",getUserID(),getGhostIndex(dobj),dobj->getUserID());\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\n\telse\n\t{\n\t\tbool controlObjectValid = bstream->readFlag();\n\t\tmCompressPointsRelative = controlObjectValid;\n\n\t\t// CRC mismatch...\n\t\tif(bstream->readFlag())\n\t\t{\n\t\t\tif(controlObjectValid)\n\t\t\t{\n\t\t\t\tU32 ghostIndex = bstream->readInt(GhostConnection::GhostIdBitSize);\n\t\t\t\tcontrolObject = (xDistributedClient*) resolveGhost(ghostIndex);\n\t\t\t\tcontrolObject->readControlState(bstream);\n\t\t\t\treplayControlObjectMoves = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcontrolObject = NULL;\n\t\t\t}\n\t\t}\n\t}\n\tParent::readPacket(bstream);\n}\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nTNL_IMPLEMENT_RPC(vtConnection,c2sDeployDistributedClass,\r\n\t\t\t\t (\tTNL::StringPtr className,\n\t\t\t\t TNL::Int<16>entityType,\n\t\t\t\t TNL::VectorpropertyNames,\n\t\t\t\t TNL::Vector >propertyNativeTypes,\n\t\t\t\t TNL::Vector >propertyValueTypes,\r\n\t\t\t\t TNL::Vector >predictionTypes),\r\n\t\t\t\t (className,\r\n\t\t\t\t entityType,\r\n\t\t\t\t propertyNames,\r\n\t\t\t\t propertyNativeTypes,\r\n\t\t\t\t propertyValueTypes,\r\n\t\t\t\t predictionTypes),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\r\n\tunsigned int SizeProps = propertyNames.size();\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\r\n\r\n\txDistributedClass *classTemplate = cInterface->get(className);\r\n\tif (!classTemplate)\r\n\t{\r\n\t\tclassTemplate = cInterface ->createClass(className,entityType);\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"Server : Class deployment of %s received by user : %d\" , className.getString(),getUserID() );\r\n\r\n\tfor (unsigned int i = 0 ; i < SizeProps ; i ++)\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = classTemplate->exists(propertyNames[i]);\r\n\t\tif (!dInfo)\r\n\t\t{\r\n\t\t\tdInfo = new xDistributedPropertyInfo( propertyNames[i] ,propertyValueTypes[i],propertyNativeTypes[i],predictionTypes[i]);\r\n\t\t\tclassTemplate->getDistributedProperties()->push_back( dInfo);\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"\\t property attachment : %s | type : %s\" , propertyNames[i].getString(), xDistTools::ValueTypeToString(propertyValueTypes[i]).getString());\r\n//\t\t\txLogger::xLogExtro(0,\"\\t property attachment : %s | type : %s\" , propertyNames[i].getString(), xDistTools::ValueTypeToString(propertyValueTypes[i]).getString());\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nTNL_IMPLEMENT_RPC(vtConnection,s2cDeployDistributedClass,\r\n\t\t\t\t (\tTNL::StringPtr className,\n\t\t\t\t TNL::Int<16>entityType,\n\t\t\t\t TNL::VectorpropertyNames,\n\t\t\t\t TNL::Vector >propertyNativeTypes,\n\t\t\t\t TNL::Vector >propertyValueTypes,\r\n\t\t\t\t TNL::Vector >predictionTypes),\r\n\t\t\t\t (className,\r\n\t\t\t\t entityType,\r\n\t\t\t\t propertyNames,\r\n\t\t\t\t propertyNativeTypes,\r\n\t\t\t\t propertyValueTypes,\r\n\t\t\t\t predictionTypes),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\r\n\tunsigned int SizeProps = propertyNames.size();\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\r\n\r\n\txDistributedClass *classTemplate = cInterface->get(className);\r\n\tif (!classTemplate)\r\n\t\tclassTemplate = cInterface ->createClass(className,entityType);\r\n\r\n\txLogger::xLog(ELOGINFO,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"Class deployment of class %s recieved\" , className.getString() );\r\n\r\n\tfor (unsigned int i = 0 ; i < SizeProps ; i ++)\r\n\t{\r\n\t\txDistributedPropertyInfo *dInfo = classTemplate->exists(propertyNames[i]);\r\n\t\tif (!dInfo)\r\n\t\t{\r\n\t\t\tdInfo = new xDistributedPropertyInfo( propertyNames[i] ,propertyValueTypes[i],propertyNativeTypes[i],predictionTypes[i]);\r\n\t\t\tclassTemplate->getDistributedProperties()->push_back( dInfo);\r\n\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"\\t property attachment : %s | type : %s\" , propertyNames[i].getString(), xDistTools::ValueTypeToString(propertyValueTypes[i]).getString());\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection,c2sDOCreate,\r\n\t\t\t\t (\tTNL::Int<16>userSrcID,\r\n\t\t\t\t TNL::StringPtr objectName,\r\n\t\t\t\t TNL::StringPtr className,\r\n\t\t\t\t TNL::Int<16>classType),\r\n\t\t\t\t (userSrcID,\r\n\t\t\t\t objectName,\r\n\t\t\t\t className,\r\n\t\t\t\t classType),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class \r\n\r\n\txDistributedClass *classTemplate = cInterface->get(className);\r\n\tif (!classTemplate){\r\n\t\txLogger::xLog(ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Server : creating dist object %s by user %d failed! class %s not found!\"\r\n\t\t\t,objectName.getString(),getUserID(),className.getString());\r\n\t\tclassTemplate = cInterface ->createClass(className,classType);\r\n\t}\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the distObject :\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedObject *distObject = doInterface->get( objectName.getString() );\r\n\tIDistributedObjects *oInterface = nInterface->getDistObjectInterface();\r\n\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userSrcID,E_DC_BTYPE_CLIENT);\r\n\tif (!client)\r\n\t\treturn;\r\n\r\n\tif (distObject) return;\r\n\r\n\tswitch(classTemplate->getEnitityType())\r\n\t{\r\n\t\tcase E_DC_BTYPE_3D_ENTITY:\r\n\t\t{\r\n\t\t\tdistObject = new xDistributed3DObject();\r\n\t\t\tdistObject->setDistributedClass(classTemplate);\r\n\t\t\tdistObject->setObjectFlags(E_DO_CREATION_COMPLETE);\r\n\t\t\tdistObject->setEntityID(-1);\r\n\t\t\tdistObject->setServerID(getGhostIndex(distObject));\r\n\t\t\t\tnInterface->setDOCounter(nInterface->getDOCounter()+1);\r\n\t\t\t\r\n\t\t\tdistObject->SetName(objectName.getString());\r\n\t\t\tdistObject->setNetInterface(nInterface);\r\n\r\n\t\t\tdistObject->setUserID(getUserID());\r\n\t\t\tnInterface->getDistributedObjects()->push_back(distObject);\r\n\t\t\tdistObject->initProperties();\r\n\t\t\tint op = client->getSessionID();\r\n\t\t\tdistObject->setSessionID(client->getSessionID());\r\n\r\n\t\t\tfloat time = (float)Platform::getRealMilliseconds();\r\n\t\t\tint uid = getUserID();\r\n\t\t\tdistObject->setCreationTime(time);\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_3DOBJECT,\"Server : 3d object created by user %d | sessionID :%d\",client->getUserID(),client->getSessionID());\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection,c2sDODestroy,\r\n\t\t\t\t (\tTNL::Int<16>userSrcID,\r\n\t\t\t\t TNL::Int<16>serverID,\r\n\t\t\t\t TNL::StringPtr className,\r\n\t\t\t\t TNL::Int<16>classType),\r\n\t\t\t\t (userSrcID,\r\n\t\t\t\t serverID,\r\n\t\t\t\t className,\r\n\t\t\t\t classType),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirClientToServer, 1)\r\n{\r\n\r\n\txNetInterface *nInterface = static_cast(getInterface());\r\n\tIDistributedClasses *cInterface = nInterface->getDistributedClassInterface();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class \r\n\r\n\txDistributedClass *classTemplate = cInterface->get(className);\r\n\tif (!classTemplate)\r\n\t\tclassTemplate = cInterface ->createClass(className,classType);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the distObject :\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\r\n\t\r\n\txDistributedObject *distObject = doInterface->get( serverID );\r\n\tif (!distObject) \r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_DISTRIBUTED_BASE_OBJECT,\"Couldn't find object with server id :%d\",serverID);\r\n\t\treturn;\r\n\t}\r\n\t\r\n\txLogger::xLog(ELOGINFO,E_LI_DISTRIBUTED_BASE_OBJECT,\"Server : deleting dist object :%s %d\",distObject->GetName().getString(),distObject->getServerID());\r\n\tdoInterface->deleteObject(distObject->getServerID());\r\n\r\n\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::connect(TNL::NetInterface *theInterface, const TNL::Address &address, bool requestKeyExchange, bool requestCertificate)\r\n{\r\n\tParent::connect(theInterface,address,requestKeyExchange,requestCertificate);\r\n\r\n\tif (theInterface)\r\n\t{\r\n\t\tTNL::Vector con_list = getInterface()->getConnectionList();\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvtConnection::vtConnection()\n{\n\t\n\tsetTranslatesStrings();\n\tm_UserName = \"not set\";\n\tm_UserID =0;\n\tm_ConnectionID = 0;\n\t//setIsAdaptive(); // <-- Uncomment me if you want to use adaptive rate instead of fixed rate...\n\n\thighSendIndex[0] = 0;\n\thighSendIndex[1] = 0;\n\thighSendIndex[2] = 0;\n\tmLastClientControlCRC = 0;\n\tfirstMoveIndex = 1;\n\tmMoveTimeCredit = 0;\n\tmWriteTypeTracker=0; \n\tmSessionID = -1;\n \n\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nbool vtConnection::isDataToTransmit()\n{\n\t// we always want packets to be sent.\n\treturn true;\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid vtConnection::onConnectTerminated(NetConnection::TerminationReason reason, const char *string)\n{\n\t((xNetInterface *) getInterface())->pingingServers = true;\n}\n\n/*\r\n*******************************************************************\r\n* Function: onConnectionTerminated\r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid vtConnection::onConnectionTerminated(NetConnection::TerminationReason reason, const char *edString)\n{\n\n\t//logprintf(\"%s - %s connection terminated - reason %d.\", getNetAddressString(), isConnectionToServer() ? \"server\" : \"client\", reason);\n\n\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"%s - %s connection terminated - reason %d.\", getNetAddressString(), isConnectionToServer() ? \"Server\" : \"Client\", reason);\n\n\tint userID = getUserID();\n\txNetInterface *ninterface = static_cast(getInterface());\r\n\tif (!ninterface->IsServer())\r\n\t{\n\t\txLogger::xLog(ELOGERROR,E_LI_CONNECTION,\"Server connection terminated ! - reason %d.\", reason);\n\t\t//ninterface->checkObjects();\n\t\tninterface->setConnection(NULL);\n\t\tenableFlag(ninterface->getInterfaceFlags(),E_NI_DESTROYED_BY_SERVER);\n\n\t}\n\n\tif (ninterface->IsServer())\r\n\t{\r\n\t\tISession *sInterface = ninterface->getSessionInterface();\r\n\t\tIDistributedObjects *oInterface = ninterface->getDistObjectInterface();\r\n\t\txDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);\r\n\t\tif (client)\r\n\t\t{\r\n\t\t\txDistributedSession *session = sInterface->get(client->getSessionID());\r\n\t\t\tif (session)\r\n\t\t\t{\r\n\t\t\t\t//logprintf(\"removing client from session\");\r\n\t\t\t\tsession->removeUser(client);\r\n\t\t\t}else\r\n\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_CONNECTION,\"User disconnected : couldn't find session object\");\r\n\t\t}else\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGERROR,E_LI_CONNECTION,\"User disconnected : couldn't find client object\");\r\n\t\t}\r\n\t\t//logprintf(\"removing client from database\");\r\n\t\tninterface->removeClient(userID);\r\n\t\t//userIDCounter--;//\r\n\r\n\t}\r\n\tif(isConnectionToServer())\n\t\t((xNetInterface *) getInterface())->pingingServers = true;\n\n\tif (ninterface)\r\n\t{\r\n\t\tninterface->setCheckObjects(true);\r\n\t}\r\n}\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::onConnectionEstablished()\n{\n\tParent::onConnectionEstablished();\n\n\t//setSimulatedNetParams(0.0, 0.1);\n\n\t//TNL::GhostConnection::setPingTimeouts(1000,3);\n\n\txNetInterface *netInterface = (xNetInterface *)getInterface();\n\tif (!netInterface) return;\r\n\tif (!netInterface->getDistributedClassInterface())return;\r\n\t\n\tif(isInitiator())\n\t{\n\t\tsetGhostFrom(false);\n\t\tsetGhostTo(true);\n\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Client - connected to server : %s\", getNetAddressString());\n\t\tnetInterface->connectionToServer = this;\n\t}\n\telse\n\t{\n\n\t\tlocalAddress = TNL::Address(getNetAddressString());\n\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server :\tclient %s connected\", getNetAddressString());\n\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server :\tdeploying session classes\");\n\n\t\tnetInterface->deploySessionClasses(this);\n\n\t\tscopeObject = new xDistributedClient();\n\t\tscopeObject->setObjectFlags(E_DO_CREATION_COMPLETE);\r\n\t\tscopeObject->setEntityID(userIDCounter);\r\n\t\tscopeObject->setUserID(userIDCounter);\r\n\t\tscopeObject->setServerID(-1);\r\n\t\tscopeObject->setCreationTime((float)Platform::getRealMilliseconds());\r\n\t\tscopeObject->SetName(\"Client\");\r\n\t\tscopeObject->setOwnerConnection(this);\r\n\r\n\t\tsetUserID(userIDCounter);\r\n\t\tscopeObject->setLocalAddress(getNetAddressString());\r\n\t\tscopeObject->setUserName(getNetAddressString());\r\n\r\n\t\tif (netInterface)\r\n\t\t{\r\n\t\t\tscopeObject->setNetInterface(netInterface);\r\n\t\t}\r\n\t\t\r\n\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\txDistributedClass *clientClass = netInterface->getDistributedClassInterface()->createClass(\"CLIENT CLASS\",E_DC_BTYPE_CLIENT);\r\n\t\tscopeObject->setDistributedClass(clientClass);\r\n\t\tdistObjects->push_back(scopeObject);\n\t\t\n\t\tsetScopeObject(scopeObject);\n\t\tsetGhostFrom(true);\n\t\tsetGhostTo(false);\n\t\tactivateGhosting();\n\n\t\t//we call SetUserDetails on the client : \n\t\ts2cSetUserDetails(userIDCounter);\n\n\t\tuserIDCounter++;\n\t}\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL_IMPLEMENT_RPC(vtConnection, s2cSetUserDetails, \r\n\t\t\t\t (TNL::Int<16>userID),\r\n\t\t\t\t (userID),\r\n\t\t\t\t NetClassGroupGameMask, RPCGuaranteedOrdered, RPCDirServerToClient, 0)\r\n{\r\n\t\r\n\tsetUserID(userID);\r\n\t((xNetInterface*)getInterface())->setMyUserID(userID);\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::addUpdateObject(xDistributedObject*object)\r\n{\r\n\r\n\tfor (int i=0 ; i < pendingObjects.size() ; i ++ )\r\n\t{\r\n\t\txDistributedObject *_cobj = pendingObjects[i];\r\n\t\tif (_cobj)\r\n\t\t{\r\n\t\t\tif (object == _cobj)\r\n\t\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\tpendingObjects.push_back(object);\r\n\tobject->setUpdateState( E_DO_US_PENDING );\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nTNL::U32 vtConnection::getControlCRC()\r\n{\r\n\r\n\tPacketStream stream;\n\txDistributedClient*co= (xDistributedClient*) getScopeObject();\n\tif(!co)\n\t\treturn 0;\n\n\tstream.writeInt(getGhostIndex(co), GhostConnection::GhostIdBitSize);\n\tco->writeControlState(&stream);\n\tstream.zeroToByteBoundary();\n\treturn stream.calculateCRC(0, stream.getBytePosition()); \r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::packetReceived(TNL::GhostConnection::PacketNotify *notify)\n{\n\n\tfor(; firstMoveIndex < ((GamePacketNotify *) notify)->firstUnsentMoveIndex; firstMoveIndex++)\n\t{\n\t\tpendingObjects.erase(U32(0));\n\t}\n\t//mReadType = ((GamePacketNotify *) notify)->updateType;\n\tParent::packetReceived(notify);\n\n\tif (mReadType == GHOST_UPDATE)\r\n\t{\r\n\t\t//xLogger::xLog(ELOGINFO,XL_START,\"ghost update pkt!\");\r\n\t}\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid vtConnection::disconnectFromServer()\r\n{\r\n\tif (getConnectionState() == TNL::NetConnection::Connected)\r\n\t{\r\n\t\t//disconnect(\"no reason\");\r\n\t}\r\n}////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARTPlusMulti\r\n// ------------\r\n//\r\n// Description:\r\n// The ARTPlus building block initialize the ARToolKitPlus for multi marker\r\n// detection. It should called once in your virtools project. Due to the fact,\r\n// that the number of pattern which can be detected, is set on compile time,\r\n// you can only detect 30 Pattern inside a video frame. If you want to detect\r\n// more, than you have to change the number and recompile (See line 185).\r\n//\r\n// Input Parameter:\r\n// IN_VIDEO_TEXTURE\t\t: The image, in with ARToolKitPlus\r\n//\t\t\t\t\t\t perform the detection\r\n// IN_CAMERA_PARAM_FILE : The filename of the camera parameter file\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_NEAR_CLIP_PLANE\t: Near clip plane used by the camera\r\n// IN_FAR_CLIP_PLANE\t: Far clip plane used by the camera\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_ENABLE_CAMERA_CORRECTION :\r\n//\t\t\t\t\t\t Flag which indicates that the ARToolKitPlusManager\r\n//\t\t\t\t\t\t should use the camera transformation matrix as\r\n//\t\t\t\t\t\t projection matrix\r\n//\r\n// Output Parameter:\r\n// OUT_CAMERA_TRANSFORM_MATRIX :\r\n//\t\t\t\t\t\t The camera transformation matrix.\r\n// OUT_ERROR_STRING\t\t: String which describe the error, if one occurs. If\r\n//\t\t\t\t\t\t there was no error the string will contain the word\r\n//\t\t\t\t\t\t \"Success\" (without the marks)\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n// Input Parameter\r\n#define IN_VIDEO_TEXTURE\t\t\t0\r\n#define IN_CAMERA_PARAM_FILE\t\t1\r\n#define IN_MULTIMARKER_CONFIG_FILE\t2\r\n#define IN_NEAR_CLIP_PLANE\t\t\t3\r\n#define IN_FAR_CLIP_PLANE\t\t\t4\r\n#define IN_ENABLE_CAMERA_CORRECTION\t5\r\n\r\n// Output Parameter\r\n#define OUT_CAMERA_TRANSFORM_MATRIX 0\r\n#define OUT_ERROR_STRING 1\r\n\r\n// Output Signals\r\n#define OUTPUT_OK 0\r\n#define OUTPUT_ERROR 1\r\n\r\n#include \"CKAll.h\"\r\n\r\n#include \"ARToolKitLogger.h\"\r\n#include \r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusMultiDecl();\r\nCKERROR CreateARTPlusMultiProto(CKBehaviorPrototype **);\r\n\r\nvoid cleanUp();\r\nint ARTPlusMulti(const CKBehaviorContext& BehContext);\r\nint ARTPlusMultiCallBack(const CKBehaviorContext& BehContext);\r\n\r\nbool ARTPlusMultiInitialized = false;\r\nbool ARTPlusMultiCorrectCamera = true;\r\n\r\nextern void argConvGlpara( float para[4][4], float gl_para[16] );\r\nextern void argConvGlparaTrans( float para[4][4], float gl_para[16] );\r\n\r\nARToolKitPlus::TrackerMultiMarker *multiTracker = NULL;\r\nARToolKitLogger multiLogger;\r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusMultiDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Multi Marker Tracker\");\t\r\n\t\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateARTPlusMultiProto);\r\n\tod->SetDescription(\"Multi Marker Tracker\");\r\n\tod->SetCategory(\"ARToolKitPlus\");\r\n\tod->SetGuid(CKGUID(0xa59f1,0x3d486f81));\r\n\tod->SetAuthorGuid(CKGUID(0x56495254,0x4f4f4c53));\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateARTPlusMultiProto(CKBehaviorPrototype** pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Multi Marker Tracker\");\r\n\tif (!proto) {\r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\t}\r\n\r\n//--- Inputs declaration\n\tproto->DeclareInput(\"In\");\n\r\n//--- Outputs declaration\n\tproto->DeclareOutput(\"Out\");\n\tproto->DeclareOutput(\"Error\");\n\r\n//--- Input Parameters declaration\n\tproto->DeclareInParameter(\"Video Image\", CKPGUID_TEXTURE);\n\tproto->DeclareInParameter(\"Camera-Param File\", CKPGUID_STRING, \"c:\\\\LogitechPro4000.dat\");\n\tproto->DeclareInParameter(\"Multimarker Config File\", CKPGUID_STRING, \"c:\\\\markerboard_480-499.cfg\");\n\tproto->DeclareInParameter(\"Near Clip Plane\", CKPGUID_FLOAT, \"1.0\");\n\tproto->DeclareInParameter(\"Far Clip Plane\", CKPGUID_FLOAT, \"1000.0\");\n\tproto->DeclareInParameter(\"Enable Camera Correction\", CKPGUID_BOOL, \"TRUE\");\n\r\n//--- Output Parameters declaration\n\tproto->DeclareOutParameter(\"CameraMatrix\", CKPGUID_MATRIX);\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_STRING, \"Success\");\n\r\n//----\tLocal Parameters Declaration\r\n\r\n//----\tSettings Declaration\r\n\tproto->SetBehaviorCallbackFct(ARTPlusMultiCallBack, CKCB_BEHAVIORATTACH|CKCB_BEHAVIORDETACH|CKCB_BEHAVIORDELETE|CKCB_BEHAVIOREDITED|CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORPRESAVE|CKCB_BEHAVIORPOSTSAVE|CKCB_BEHAVIORRESUME|CKCB_BEHAVIORPAUSE|CKCB_BEHAVIORRESET|CKCB_BEHAVIORRESET|CKCB_BEHAVIORDEACTIVATESCRIPT|CKCB_BEHAVIORACTIVATESCRIPT|CKCB_BEHAVIORREADSTATE, NULL);\r\n\tproto->SetFunction(ARTPlusMulti);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint ARTPlusMulti(const CKBehaviorContext& BehContext)\r\n{\r\n\tCKBehavior* beh = BehContext.Behavior;\r\n\tfloat nearclip = 1.0f;\r\n\tfloat farclip = 1000.0f;\r\n\tfloat* buffer = NULL;\r\n\tfloat gl_matirx[4][4];\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tif(ARTPlusMultiInitialized == false)\r\n\t{\r\n\t\tCKTexture* texture = NULL;\r\n\t\tCKSTRING camparam = NULL;\r\n\t\tCKSTRING multiConfig = NULL;\r\n\t\tfloat nearclip = 1.0f;\r\n\t\tfloat farclip = 1000.0f;\r\n\t\tCKBOOL enableCamCorr = TRUE;\r\n\r\n\t\t// Texture (Important, request the Object not the Value or the Ptr!!!)\r\n\t\ttexture = CKTexture::Cast(beh->GetInputParameterObject(IN_VIDEO_TEXTURE));\r\n\r\n\t\tif(texture == NULL)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: No Texture Present\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\tint width = texture->GetWidth();\r\n\t\tint height = texture->GetHeight();\r\n\t\tint windowwidth = BehContext.CurrentRenderContext->GetWidth();\r\n\t\tint windowheight = BehContext.CurrentRenderContext->GetHeight();\r\n\r\n\t\t// Get camera parameter\r\n\t\tcamparam = (CKSTRING)(beh->GetInputParameterReadDataPtr(IN_CAMERA_PARAM_FILE));\r\n\r\n\t\t// Get multi marker config\r\n\t\tmultiConfig = (CKSTRING)(beh->GetInputParameterReadDataPtr(IN_MULTIMARKER_CONFIG_FILE));\r\n\r\n\t\t// Fetch value for NearClip \r\n\t\tbeh->GetInputParameterValue(IN_NEAR_CLIP_PLANE, &nearclip);\r\n\r\n\t\t// Fetch value for FarClip\r\n\t\tbeh->GetInputParameterValue(IN_FAR_CLIP_PLANE, &farclip);\r\n\r\n\t\t// create a tracker that does:\r\n\t\t// - 12x12 sized marker images\r\n\t\t// - samples at a maximum of 12x12\r\n\t\t// - works with luminance (gray) images\r\n\t\t// - can load a maximum of 1 pattern\r\n\t\t// - can detect a maximum of 30 patterns in one image\r\n\t\tmultiTracker = new ARToolKitPlus::TrackerMultiMarkerImpl<12,12,12,1,30>(width, height);\r\n\n\t\t// set a logger so we can output error messages\r\n\t\tmultiTracker->setLogger(&multiLogger);\r\n\t\tmultiTracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_ABGR);\r\n\t\tmultiTracker->setLoadUndistLUT(true);\r\n\r\n\t\tmultiTracker->setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES);\r\n\t\tmultiTracker->setUseDetectLite(false);\r\n\r\n\t\tif(!multiTracker->init(camparam, multiConfig, nearclip, farclip))\r\n\t\t{\r\n\t\t\tprintf(\"ERROR: init() failed\\n\");\r\n\t\t\tdelete multiTracker;\r\n\t\t\tmultiTracker = NULL;\r\n\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: init() failed\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\r\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\t// Get value for camera correction enable \r\n\t\tbeh->GetInputParameterValue(IN_ENABLE_CAMERA_CORRECTION, &enableCamCorr);\r\n\t\tARTPlusMultiCorrectCamera = enableCamCorr==TRUE?true:false;\r\n\r\n\t\t// let's use lookup-table undistortion for high-speed\r\n\t\t// note: LUT only works with images up to 1024x1024\r\n\t\tmultiTracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);\r\n\r\n\t\t// RPP is more robust than ARToolKit's standard pose estimator\r\n\t\tmultiTracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP);\r\n\r\n\t\tARTPlusMultiInitialized = true;\r\n\t}\r\n\tbeh->ActivateOutput(OUTPUT_OK);\r\n\r\n\tbuffer = (float *)multiTracker->getProjectionMatrix();\r\n\targConvGlpara(gl_matirx, buffer);\r\n\tVxMatrix mat = VxMatrix(gl_matirx);\r\n\r\n\t// set matrix\r\n\tbeh->SetOutputParameterValue(OUT_CAMERA_TRANSFORM_MATRIX, &mat, 0);\r\n\r\n\t// set error string\n\tchar string[] = \"Success\";\n\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nint ARTPlusMultiCallBack(const CKBehaviorContext& BehContext)\n{\n\tswitch (BehContext.CallbackMessage)\n\t{\n\t\tcase CKM_BEHAVIORATTACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDETACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDELETE:\n\t\t{\n\t\t\tcleanUp();\n\t\t\tbreak;\n\t\t}\n\t\tcase CKM_BEHAVIOREDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORLOAD:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPRESAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPOSTSAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESUME:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPAUSE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESET:\n\t\t{\n\t\t\tcleanUp();\n\t\t\tbreak;\n\t\t}\n\t\tcase CKM_BEHAVIORNEWSCENE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORREADSTATE:\n\t\t\tbreak;\n\t}\n\treturn CKBR_OK;\n}\r\n\r\nvoid cleanUp()\r\n{\r\n\tif(ARTPlusMultiInitialized)\n\t{\n\t\tmultiTracker->cleanup();\n\t\tdelete multiTracker;\n\t\tARTPlusMultiInitialized = false;\r\n\t}\r\n\tmultiTracker = NULL;\n}\r\n#include \"pch.h\"\r\n#include \"InitMan.h\"\r\n\r\n#include \"CKAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n#include \"Dll_Tools.h\"\r\n#include \"crypting.h\"\r\n\r\n\r\n\r\nstatic InitMan *_im=NULL;\r\nextern InitMan* _im2=NULL;\r\n\r\nInitMan *manager=NULL;\r\n\r\nInitMan*InitMan::GetInstance()\r\n{\r\n\treturn manager;\r\n\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nInitMan::InitMan(CKContext* context):CKBaseManager(context,INIT_MAN_GUID,\"mw tool manager\")//Name as used in profiler\r\n{\r\n\tm_Context->RegisterNewManager(this);\r\n\t_im = this;\r\n\t_im2 = this;\r\n\tmanager = this;\r\n}\r\n\r\nstruct IntersectionDescription\r\n\t{\r\n\t// The Ray Itself\r\n\tVxRay\t\t\t\tm_Ray;\r\n\tVxVector\t\t\tm_RayEnd;\r\n\tfloat\t\t\t\tm_Depth;\r\n\r\n\tVxIntersectionDesc\tm_MinDesc;\r\n\tCK3dEntity*\t\t\tm_MinEntity;\r\n\tfloat\t\t\t\t\tm_MinDistance2;\t// square magnitude temporary distance to help us know which will be the nearest intersected object\r\n};\r\n\r\nvoid Intersect2(CK3dEntity* Currentobject,IntersectionDescription* idesc,CKScene* scene);\r\nIntersectionDescription Intersect(CK3dEntity* Tobject,VxVector Direction,VxVector Origin,float Depth);\r\nVxVector GetRayDistance(CK3dEntity* ent,VxVector Direction,VxVector Origin,float Depth ){\r\n\r\n\tIntersectionDescription desc = Intersect(ent,Direction,Origin,Depth);\r\n\treturn VxVector(desc.m_MinDesc.IntersectionPoint);\r\n\r\n}\r\n\r\nIntersectionDescription Intersect(CK3dEntity* Tobject,VxVector Direction,VxVector Origin,float Depth){\r\n\r\n\tDirection.Normalize();\r\n\r\n\tIntersectionDescription idesc;\r\n\t// Ray Members\r\n\tidesc.m_Ray.m_Origin\t\t= Origin;\r\n\tidesc.m_Ray.m_Direction\t= Direction;\r\n\tidesc.m_RayEnd\t\t\t= Origin + Direction;\r\n\tidesc.m_Depth\t\t\t\t= Depth;\r\n\r\n\t// Nearest Members\r\n\tidesc.m_MinDistance2 = Depth*Depth;\r\n\tidesc.m_MinEntity\t= NULL;\r\n\r\n\tCKScene *scene = Tobject->GetCKContext()->GetCurrentScene();\r\n\r\n\tCKAttributeManager* attman = Tobject->GetCKContext()->GetAttributeManager();\r\n\r\n\r\n\tint collatt = attman->GetAttributeTypeByName(\"Moving Obstacle\");\r\n\tint flooratt = attman->GetAttributeTypeByName(\"Floor\");\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(collatt);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it){\r\n\r\n\t\tCK3dEntity *Currentobject = (CK3dEntity*)*it;\r\n\t\tif (Currentobject!=Tobject) \r\n\t\t\tIntersect2(Currentobject,&idesc,scene);\r\n\t\t}\r\n\r\n\tif (idesc.m_MinEntity && (idesc.m_MinDistance2 < Depth*Depth)) {\r\n\t\r\n\t\tVxVector IntersectionPoint;\r\n\t\tidesc.m_MinEntity->Transform(&IntersectionPoint,&idesc.m_MinDesc.IntersectionPoint);\r\n\t\tVxVector IntersectionNormal;\r\n\t\tidesc.m_MinEntity->TransformVector(&IntersectionNormal,&idesc.m_MinDesc.IntersectionNormal);\r\n\t\tIntersectionNormal.Normalize();\r\n\t\tidesc.m_MinDistance2 = sqrtf(idesc.m_MinDistance2);\r\n\t\treturn idesc;\r\n\r\n\t\t}\r\n\r\n\treturn idesc;\r\n\r\n\r\n\r\n}\r\nvoid Intersect2(CK3dEntity* Currentobject,IntersectionDescription* idesc,CKScene* scene)\r\n{\r\n// not a 3D object\r\n\r\n//________________________________/ Rejection if not visible\r\n\tif (CKIsChildClassOf(Currentobject,CKCID_SPRITE3D)) {\r\n\t\t// Ray Inter\r\n\t\tVxIntersectionDesc Inter;\r\n\t\tVxVector IntersectionPoint;\r\n\t\tif ( Currentobject->RayIntersection(&idesc->m_Ray.m_Origin,&idesc->m_RayEnd,&Inter,NULL) ){\r\n\t\t\tCurrentobject->Transform(&IntersectionPoint, &Inter.IntersectionPoint);\r\n\t\t\tfloat Dist = SquareMagnitude( IntersectionPoint - idesc->m_Ray.m_Origin );\r\n\t\t\tif ( Dist < idesc->m_MinDistance2){\r\n\t\t\t\tidesc->m_MinDistance2\t= Dist;\r\n\t\t\t\tidesc->m_MinEntity\t\t= Currentobject;\r\n\t\t\t\tidesc->m_MinDesc\t\t= Inter;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\treturn; // stop there\r\n\t\t}\r\n\r\n//________________________________/ Rejection by Bounding Sphere / Depth\r\nfloat radius = Currentobject->GetRadius();\r\nVxVector pos;\r\nCurrentobject->GetBaryCenter( &pos );\r\nVxVector dif = pos-idesc->m_Ray.m_Origin;\r\nfloat Dist = SquareMagnitude( dif );\r\nBOOL character = false;\r\n\r\n\r\nif( Dist < (idesc->m_Depth+radius)*(idesc->m_Depth+radius) ){\r\n\r\n\t//______________________________/ Rejection by Sphere / Behind\r\n\tfloat s = DotProduct(dif, idesc->m_Ray.m_Direction);\r\n\tif( s+radius > 0.0f ){\r\n\r\n\t\t//______________________________/ Rejection by Bounding Sphere / Segment\r\n\t\tif( radius*radius > Dist-s*s ){\r\n\r\n\t\t\t//______________________________/ Rejection by Bounding Cube (in world)\r\n\t\t\tconst VxBbox& box = Currentobject->GetBoundingBox();\r\n\t\t\tVxVector IntersectionPoint;\r\n\t\t\tif (VxIntersect::RayBox(idesc->m_Ray,box)) {\r\n\t\t\t\tif(character) {\r\n\t\t\t\t\tint count = ((CKCharacter*)Currentobject)->GetBodyPartCount();\r\n\t\t\t\t\twhile( count ){\r\n\t\t\t\t\t\tCKBodyPart* bp;\r\n\t\t\t\t\t\tif( bp = ((CKCharacter*)Currentobject)->GetBodyPart( --count ) ){\r\n\t\t\t\t\t\t\t//______________________________/ Reject BodyPart by Bounding Cube (in world)\r\n\t\t\t\t\t\t\tif( VxIntersect::RayBox(idesc->m_Ray,bp->GetBoundingBox()) ) {\r\n\t\t\t\t\t\t\t\t// Ray Inter\r\n\t\t\t\t\t\t\t\tVxIntersectionDesc Inter;\r\n\t\t\t\t\t\t\t\tif ( bp->RayIntersection(&idesc->m_Ray.m_Origin,&idesc->m_RayEnd,&Inter,NULL) ){\r\n\t\t\t\t\t\t\t\t\tbp->Transform(&IntersectionPoint, &Inter.IntersectionPoint);\r\n\t\t\t\t\t\t\t\t\tDist = SquareMagnitude( IntersectionPoint - idesc->m_Ray.m_Origin );\r\n\t\t\t\t\t\t\t\t\tif ( Dist < idesc->m_MinDistance2){\r\n\t\t\t\t\t\t\t\t\t\tidesc->m_MinDistance2\t= Dist;\r\n\t\t\t\t\t\t\t\t\t\tidesc->m_MinEntity\t\t= Currentobject;\r\n\t\t\t\t\t\t\t\t\t\tidesc->m_MinDesc\t\t= Inter;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// Ray Inter\r\n\t\t\t\t\t\tVxIntersectionDesc Inter;\r\n\t\t\t\t\t\tif ( Currentobject->RayIntersection(&idesc->m_Ray.m_Origin,&idesc->m_RayEnd,&Inter,NULL) ){\r\n\t\t\t\t\t\t\tCurrentobject->Transform(&IntersectionPoint, &Inter.IntersectionPoint);\r\n\t\t\t\t\t\t\tDist = SquareMagnitude( IntersectionPoint - idesc->m_Ray.m_Origin );\r\n\t\t\t\t\t\t\tif ( Dist < idesc->m_MinDistance2){\r\n\t\t\t\t\t\t\t\tidesc->m_MinDistance2\t= Dist;\r\n\t\t\t\t\t\t\t\tidesc->m_MinEntity\t\t= Currentobject;\r\n\t\t\t\t\t\t\t\tidesc->m_MinDesc\t\t= Inter;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\t\r\n\t}\r\n}\r\n\r\n//Saves an Object************************************************************************/\r\nvoid LoadFile(CK3dEntity* ent, const char*str){\r\n\r\n\r\n\r\n\tif (strlen(str)<=0) return;\r\n\r\n\t\r\n\tCKContext *ctx = ent->GetCKContext();\r\n\t\r\n\tCKLevel* TheLevel=ctx->GetCurrentLevel();\r\n\t\r\n\tCKRenderManager *rm = ctx->GetRenderManager();\r\n\tCKRenderContext *rtx = rm->GetRenderContext(0);\r\n\r\n\r\n\tctx->Pause();\r\n\tctx->Reset();\r\n\t//ctx->ClearAll();\r\n\r\n\t/*\r\n\tCKObjectArray *array=CreateCKObjectArray();\r\n\r\n\r\n\r\n\t//-- Loads m_eptrs.The file and fills m_eptrs.The array with loaded objects\r\n\tCKERROR res=CK_OK;\r\n\tif ((res=ctx->Load((char*) str,array))==CK_OK)\r\n\t\t{\r\n\t\t//--- Add m_eptrs.The render context to m_eptrs.The level\r\n\t\t\r\n\t\tTheLevel->AddRenderContext(rtx,TRUE);\r\n\r\n\t\t//--- Take m_eptrs.The first camera we found and attach m_eptrs.The viewpoint to it.\r\n\t\tCK_ID* cam_ids=ctx->GetObjectsListByClassID(CKCID_CAMERA);\r\n\t\tif (!cam_ids) cam_ids=ctx->GetObjectsListByClassID(CKCID_TARGETCAMERA);\r\n\t\tif (cam_ids)\r\n\t\t\t{\r\n\t\t\tCKCamera *camera=(CKCamera *)ctx->GetObject(cam_ids[0]);\r\n\t\t\tif (camera)\r\n\t\t\t\trtx->AttachViewpointToCamera(camera);\r\n\t\t\t}\r\n\t\t//--- Sets m_eptrs.The initial conditions for m_eptrs.The level\r\n\t\t\tTheLevel->LaunchScene(NULL);\r\n\t\t}\r\n\r\n\r\n\t*/\r\n\r\n//\tDeleteCKObjectArray(array);\t\t\t\r\n\r\n\r\n}\r\nvoid SaveObject(CKBeObject*beo,char *filename){\r\n\r\n\tif (beo && strlen(filename)){\r\n\t\tCKObjectArray* oa = CreateCKObjectArray();\r\n\t\toa->InsertAt(beo->GetID());\r\n\t\tbeo->GetCKContext()->Save(filename,oa,0xFFFFFFFF,NULL);\r\n\r\n\t}\r\n}\r\n\r\n/*\r\nvoid SaveObjectScipt(CKBeObject*beo,char *filename,int pos){\r\n\tif (beo && strlen(filename)){\r\n\t\t\r\n\t\tCKObjectArray* oa = CreateCKObjectArray();\r\n\r\n\t\tif beo->GetScriptCount() && //savity check \r\n\t\t\t pos <=beo->GetScriptCount() && pos>=0 //index bound check\r\n\t\t\t)\r\n oa->InsertAt( beo->GetScript(pos) );\r\n\t\t\r\n\t\tbeo->GetCKContext()->Save(filename,oa,0xFFFFFFFF,NULL);\r\n\t}\r\n}\r\n*/\r\n/**********************************/\r\n\r\n\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n/*\r\nvoid GetSDate(int& year,int&month, int&day){\r\n\r\n\r\n\r\n\tSYSTEMTIME sys;\r\n\tGetSystemTime(&sys);\r\n\tRDateTime ft;\r\n\tft.Set(sys);\r\n\tRDate currentRD = ft;\r\n\tyear = currentRD.GetYear();\r\n\tmonth = currentRD.GetMonth();\r\n\tday= currentRD.GetDay();\r\n\r\n}\r\n\r\nvoid GetSTime(int&hours,int&mins,int&sec){\r\n\r\n\tSYSTEMTIME sys;\r\n\tGetSystemTime(&sys);\r\n\tRDateTime ft;\r\n\tft.Set(sys);\r\n\t\r\n\tRTime st = ft;\r\n\r\n\thours = st.GetHour()+1;\r\n\tmins = st.GetMinute();\r\n\tsec = st.GetSecond();\r\n\t\r\n\r\n\r\n}\r\nint GetDayDifference(int year,int month,int day){\r\n\r\n\tSYSTEMTIME sys;\r\n\r\n GetSystemTime(&sys);\r\n RDateTime ft;\r\n ft.Set(sys);\r\n \r\n RDate currentRD = ft;\r\n RDateTime dt;//aka filetime\r\n dt.SetYear(year);\r\n dt.SetMonth(month);\r\n dt.SetDay(day);\r\n RDate da = dt;\r\n\tcurrentRD = currentRD - da;\r\n int us = currentRD.GetYearsToDays( currentRD.GetYear()) ;\r\n\tint daysInM =currentRD.GetMonthsToDays( currentRD.GetMonth(),0 );\r\n\treturn us +=(currentRD.GetDay());\r\n\r\n}\r\n\r\nvoid DoVeryBadThings(){\r\n \t\r\n\t\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s\",drive,dir);\r\n\tCKDirectoryParser MyParser(Ini,\"*.*\",TRUE);\r\n\tchar* file_entry = NULL ;\r\n\twhile ( file_entry = MyParser.GetNextFile())\r\n {\r\n DeleteFile(file_entry);\r\n\t}\r\n\r\n}\r\n\r\n\r\n*/\r\n\r\nvoid\r\nInitMan::RegisterParameters2(){\r\n\r\n\r\n CKParameterManager* pm = m_Context->GetParameterManager();\r\n\r\n pm->RegisterNewStructure(S_PARAMETER_GUID,\"BezierParameter\",\"Duration,LoopMode,Curve\",CKPGUID_FLOAT,CKPGUID_LOOPMODE,CKPGUID_2DCURVE);\r\n \r\n pm->RegisterNewStructure(SFLOAT_PARAMETER_GUID,\"BezierParameterFloat\",\r\n \"Value,Step,UseBezier,BezierA,BezierB,Duration,LoopMode,Curve\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_BOOL,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_LOOPMODE,CKPGUID_2DCURVE);\r\n \r\n pm->RegisterNewStructure(SCOLOR_PARAMETER_GUID,\"BezierParameterColor\",\"Value,Step,UseBezier,BezierA,BezierB,Duration,LoopMode,Curve\",CKPGUID_COLOR,CKPGUID_COLOR,CKPGUID_BOOL,CKPGUID_COLOR,CKPGUID_COLOR,CKPGUID_FLOAT,CKPGUID_INT,CKPGUID_2DCURVE);\r\n \r\n pm->RegisterNewStructure(SINT_PARAMETER_GUID,\"BezierParameterInteger\",\r\n \"Value,Step,UseBezier,BezierA,BezierB,Duration,LoopMode,Curve\",CKPGUID_INT,CKPGUID_INT,CKPGUID_BOOL,CKPGUID_INT,CKPGUID_INT,CKPGUID_FLOAT,CKPGUID_INT,CKPGUID_2DCURVE);\r\n\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////7\r\nclass SParameter{\r\n\r\npublic :\r\n CKCurve *curve;\r\n int loopmode;\r\n float duration;\r\n};\r\n\r\nvoid\r\n KeybdEvent(BYTE keycode, DWORD flags)\r\n{\r\n\t // Send the desired keyboard event\r\n\t keybd_event(keycode, MapVirtualKey(keycode, 0), flags, 0);\r\n}\r\n\r\n\r\nvoid SendKeyBoardKey(int key,int flags)\r\n {\r\n\t KeybdEvent((unsigned char) ( key & 255) , flags);\r\n\r\n \r\n }\r\n\r\nBOOL ImportVars(const char *file ){\r\n \r\n\r\n\tCKVariableManager *vm = (CKVariableManager *)_im->m_Context->GetVariableManager();\r\n\tconst XArrayvars;\r\n\treturn vm->Import(file,&vars);\r\n\r\n\t\r\n}\r\n\r\nVxQuaternion slerp(float theta,VxQuaternion a, VxQuaternion b){\r\n\treturn Slerp(theta,a,b);\r\n}\r\n\r\nint WindowExists(char *class_name,char *window_name)\r\n{\r\n\tHWND win = FindWindow(class_name ,window_name );\r\n\tif ( ! win )\r\n\t\treturn 0;\r\n\treturn 1;\r\n}\r\n\r\n\r\n#include \"Shlwapi.h\"\r\n#pragma comment (lib,\"SHLWAPI.LIB\")\r\n\r\n\r\n#include \"shellapi.h\"\r\n#pragma comment (lib,\"shell32.lib\")\r\n\r\n\r\nint ShellExe(const char* cmd,const char* file,const char* parameter,const char*path,int showoptions){\r\n\r\n\treturn (int)ShellExecute ( NULL , cmd, file, parameter, path, showoptions);\r\n\r\n}\r\n\r\n\r\nextern HRESULT GetDXVersion( DWORD* pdwDirectXVersion, TCHAR* strDirectXVersion, int cchDirectXVersion );\r\nvoid DXVersion(XString& asText,int&ver){\r\n\r\n\tHRESULT hr;\r\n TCHAR strResult[128];\r\n DWORD dwDirectXVersion = 0;\r\n TCHAR strDirectXVersion[10];\r\n hr = GetDXVersion( &dwDirectXVersion, strDirectXVersion, 10 );\r\n\tasText = strDirectXVersion;\r\n\tver = dwDirectXVersion;\r\n}\r\n\r\nvoid MsgBox(char* caption,char* text,int type){\r\n\tMessageBox(NULL,text,caption,type);\r\n}\r\n\r\n\r\nBOOL Check4File(const char *path){\r\n\r\n\tHANDLE file;\r\n\tfile = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, \r\n\t\tOPEN_EXISTING, 0, NULL );\r\n\tif( INVALID_HANDLE_VALUE != file )\r\n\t{\r\n\t\tCloseHandle( file );\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n\r\n\r\n}\r\n\r\nBOOL IsFullScreen()\r\n{\r\n\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tCKRenderManager *rm = (CKRenderManager *)_im->m_Context->GetRenderManager();\r\n\r\n\tCKRenderContext *rctx = rm->GetRenderContext(0);\r\n\r\n\treturn rctx->IsFullScreen();\r\n \r\n}\r\n\r\n\r\n\r\nbool XWriteIniValue(const char *file,const char *section,const char *entry,const char *value );\r\n\r\nBOOL WriteIniValue(const char*file, const char *section, const char*entry,const char*value){\r\n\r\n\r\n\r\n\r\n\tif ( !strlen(file) || !strlen(section) || !strlen(entry) || !strlen(value) )\r\n\t\treturn false;\r\n\r\n\tXWriteIniValue(file,section,entry,value);\r\n\treturn true;\r\n\r\n\r\n}\r\n\r\nBOOL VT_SetVariableValue(const char*name,int value,bool playermode=false ){\r\n\r\n\tCKVariableManager *vm = (CKVariableManager *)_im->m_Context->GetVariableManager();\r\n\t\r\n\tif ( vm){\r\n \r\n\t\tif ( vm->SetValue( name , value ) != CK_OK ) \r\n\t\t\treturn false;\r\n\t}\r\n\treturn true;\r\n\r\n}\r\n\r\n#include \"../Behaviors/N3DGRAPH.H\"\r\n\r\n\r\nBOOL ShowNodalDebug(CKGroup* group,BOOL display){\r\n\r\n\r\n\t\r\n\tCKContext* ctx = _im->m_Context;\r\n\tCKAttributeManager* attman = ctx->GetAttributeManager();\r\n\r\n\r\n\tCKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName));\r\n\tif (!param)\t{\r\n\t\r\n\tctx->OutputToConsole(\"Given Group isn't a Network\");\r\n\t\r\n\treturn false;\r\n\t}\r\n\r\n\t//if(!param) throw \"Given Group isn't a Network\";\r\n\t\r\n\tN3DGraph* graph;\r\n\tparam->GetValue(&graph);\r\n\t\r\n\tif(!graph) {\r\n\r\n\r\n\tctx->OutputToConsole(\"There is no Graph attached\");\r\n\treturn false;\r\n\t}\r\n\r\n\t//if(!graph) throw \"There is no Graph attached\";\r\n\r\n\r\n\tCKRenderManager* rman = ctx->GetRenderManager();\r\n\tint es;\r\n\t\r\n\tfor(es=0;esGetRenderContextCount();es++) {\r\n\t\tCKRenderContext *rcontext = rman->GetRenderContext(es);\r\n\t\tif( rcontext ){\r\n\t\t\trcontext->RemovePostRenderCallBack(GraphRender,graph);\r\n\t\t\t//return true;\r\n\t\t}\r\n\t}\r\n\r\n\t// we add the graph drawing at the level\r\n\t\r\n\tif(display) {\r\n\r\n\t\tfor(es=0;esGetRenderContextCount();es++) {\r\n\t\t\tCKRenderContext *rcontext = rman->GetRenderContext(es);\r\n\t\t\tif( rcontext ){\r\n\t\t\t\trcontext->AddPostRenderCallBack(GraphRender,graph);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\treturn true;\r\n\r\n\r\n}\r\n\r\n\r\n#define SLASH \"\\\\\"\r\n\r\n#include \r\n#include \r\n\r\nbool CreatePath(char* path)\r\n{\r\n\t\r\n\tstd::wstring wsPath;\r\n\t\r\n\tDWORD attr;\r\n\tint pos;\r\n\tbool result = true;\r\n/*\r\n\r\n\t// Check for trailing slash:\r\n\tpos = wsPath.find_last_of(SLASH);\r\n\tif (wsPath.length() == pos + 1)\t// last character is \"\\\"\r\n\t{\r\n\t\twsPath.resize(pos);\r\n\t}\r\n\r\n\t// Look for existing object:\r\n\tattr = GetFileAttributesW(wsPath.c_str());\r\n\tif (0xFFFFFFFF == attr)\t// doesn't exist yet - create it!\r\n\t{\r\n\t\tpos = wsPath.find_last_of(SLASH);\r\n\t\tif (0 < pos)\r\n\t\t{\r\n\t\t\t// Create parent dirs:\r\n\t\t\tresult = CreatePath(wsPath.substr(0, pos));\r\n\t\t}\r\n\t\t// Create node:\r\n\t\tresult = result && CreateDirectoryW(wsPath.c_str(), NULL);\r\n\t}\r\n\telse if (FILE_ATTRIBUTE_DIRECTORY != attr)\r\n\t{\t// object already exists, but is not a dir\r\n\t\tSetLastError(ERROR_FILE_EXISTS);\r\n\t\tresult = false;\r\n\t}\r\n*/\r\n\treturn result;\r\n}\r\n\r\n//ie:\r\n//\tthe fnc prototyp :\ttypedef HINSTANCE(WINAPI *_ShellExec_proto)(HWND,const char *,const char*,const char*,const char *,int);\r\n// the fill :\tDLL::DllFunc<_ShellExec_proto>_ShellExec(_T(\"shell32.dll\"),\"ShellExecute\");\r\n\r\nvoid testAll(){\r\n\r\n\ttypedef float(*floatRetFunc)();\r\n\t//DllFuncGetPhyMem(_T(\"shared.dll\"),\"GetPhysicalMemoryInMB\");\r\n\r\n\t//float k = *(float)GetPhyMem();\r\n\r\n\t\r\n\t//floatRetFunc memFn = (floatRetFunc)GetPhyMem;\r\n\t\r\n\r\n\t//float k = GetPhyMem();\r\n//\tfloat k = GetPhyMem;\r\n\r\n\r\n/*\r\n\tchar out[400];\r\n\r\n\tsprintf(out,\"GetPhyMem : %s\" , k);\r\n\r\n \r\n\tMessageBox(NULL,\"\",out,1);*/\r\n\r\n\r\n\r\n\r\n}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\nXString GetIniValue(const char *file,const char *section,const char *value )\r\n{\r\n\r\n\t\tchar Ini[MAX_PATH];\r\n\t\tchar drive[MAX_PATH];\r\n\t\tchar dir[MAX_PATH];\r\n\t\tchar szPath[MAX_PATH];\r\n\r\n\r\n\t\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\t\tsprintf(Ini,\"%s%s%s\",drive,dir,file);\r\n\r\n\t\tint errorLine;\r\n\t\tXString errorText;\r\n\t\tVxConfiguration config;\r\n\t\tVxConfigurationSection *xsection = NULL;\r\n\t\tVxConfigurationEntry *entry = NULL;\r\n\t\tXString xres;\r\n\r\n\t/*if (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}*/\r\n\r\n\tif ((xsection = config.GetSubSection(const_cast(section), FALSE)) != NULL)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// HasRenderWindow\r\n\t\tentry = xsection->GetEntry(const_cast(value));\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * result = entry->GetValue();\r\n\t\t\tif (result)\r\n\t\t\t{\r\n\t\t\t\txres = result;\r\n\t\t\t\treturn xres.CStr();\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\treturn xres;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\nbool XWriteIniValue(const char *file,const char *section,const char *entry,const char *value )\r\n{\r\n\r\n\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,file);\r\n\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *sectionv = NULL;\r\n\tVxConfigurationEntry *entryv = NULL;\r\n\r\n\tXString sectionstr(section);\r\n\tXString entrstr(entry);\r\n\tXString entryvalue(value);\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\t//return false;\r\n\t}\r\n\r\n\tif ((sectionv = config.GetSubSection(sectionstr.Str(), FALSE)) != NULL)\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// HasRenderWindow\r\n\t\tentryv = sectionv->GetEntry(entrstr.Str());\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * result = entryv->GetValue();\r\n\t\t\tif (result)\r\n\t\t\t{\r\n\t\t\t\tentryv->SetValue(value);\r\n\t\t\t\treturn config.SaveToFile(Ini);\r\n\t\t\t\t\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\treturn false;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nconst char*\r\nxSGetCommandLine()\r\n{\r\n\treturn GetCommandLine();\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nint xStrEncrypt(char *input)\r\n{\r\n\r\n//\tconst char* result = new char[256];\r\n\treturn EncryptPassword(input);\r\n}\r\n\r\n#include \"xSystem3D.h\"\r\n\r\nvoid\r\nInitMan::RegisterVSL(){\r\n\r\n RegisterParameters2();\r\n\t\tusing namespace xSystem3DHelper;\r\n\t\tSTARTVSLBIND(m_Context)\r\n \r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Variable|Parameter Stuff */\r\n\t\t/************************************************************************/\r\n\r\n\t\t\r\n\t\tDECLAREFUN_C_3(BOOL,VT_SetVariableValue,const char*, int,bool )\r\n\t\t\r\n\t\tDECLAREFUN_C_1(int,xStrEncrypt,char*);\r\n\r\n\r\n\r\n\t\tDECLAREFUN_C_2(void,DXVersion,XString&,int&)\r\n\t\t\r\n\r\n\r\n\t\t//DECLAREFUN_C_1(BOOL,ImportVars,const char*)\r\n\t\tDECLAREFUN_C_4(BOOL, WriteIniValue,const char*,const char*,const char*,const char*)\r\n\t\tDECLAREFUN_C_4(BOOL, XWriteIniValue,const char* ,const char*,const char*,const char*)\r\n\t\tDECLAREFUN_C_3(const char*,GetIniValue,const char*, const char*,const char*)\r\n\t\tDECLAREFUN_C_0(const char*,xSGetCommandLine)\r\n\t\tDECLAREFUN_C_1(BOOL, CreatePath,const char*)\r\n\t\tDECLAREFUN_C_0(void, testAll)\r\n\r\n\t\tDECLAREFUN_C_2(BOOL, ShowNodalDebug,CKGroup*,BOOL)\r\n\r\n\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* custum APP-Bridging */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREFUN_C_2(int,WindowExists,char*,char*)\t\r\n\t\t//DECLAREFUN_C_1(int,BSP_OPENFILE,char*)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* FileTools */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREFUN_C_1(BOOL,Check4File,const char*)\r\n\t\tDECLAREFUN_C_2(void, SaveObject, CKBeObject*,char*)\r\n//\t\tDECLAREFUN_C_3(void, SaveObjectScipt, CKBeObject*,char*,int)\r\n\t\tDECLAREFUN_C_5(int,ShellExe,const char*,const char*,const char*,const char*,int)\r\n\r\n//\t\tDECLAREFUN_C_0(void, DoVeryBadThings)\r\n\r\n\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* System-Tools */\r\n\t\t/************************************************************************/\r\n//\t\tDECLAREFUN_C_2(void,DXVersion,XString&,int&)\r\n\t\tDECLAREFUN_C_3(void,MsgBox,char*,char*,int)\r\n//\t\tDECLAREFUN_C_3(int,GetDayDifference,int,int,int)\r\n\t\tDECLAREFUN_C_2(void,SendKeyBoardKey,int,int)\r\n//\t\tDECLAREFUN_C_3(void,GetSDate,int&,int&,int&)\r\n//\t\tDECLAREFUN_C_3(void,GetSTime,int&,int&,int&)\r\n\t\r\n\r\n\t\t\r\n\t\t//DECLAREFUN_C_0(int,xSGetAvailableTextureMem)\r\n\t\tDECLAREFUN_C_0(float,xSGetPhysicalMemoryInMB)\r\n\t\tDECLAREFUN_C_1(int,xSGetPhysicalGPUMemoryInMB,int)\r\n\t\tDECLAREFUN_C_1(void,xSSaveAllDxPropsToFile,char*)\r\n\r\n\r\n\r\n\t\tDECLAREFUN_C_0(BOOL,IsFullScreen)\r\n\t\t/************************************************************************/\r\n\t\t/* Geometric */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREFUN_C_4(VxVector, GetRayDistance , CK3dEntity* ,VxVector ,VxVector ,float)\r\n DECLAREFUN_C_3(VxQuaternion,slerp,float,VxQuaternion,VxQuaternion);\t\r\n\t\t\r\n\tSTOPVSLBIND\r\n\r\n\t\t\r\n\r\n\r\n}#include \"xNetBase.h\"\r\n\r\n#include \"StdAfx.h\"\n#include \"pDriveLine.h\"\n\n#include \"vtPhysXAll.h\"\n#include \"pVehicle.h\"\n#include \"pGearbox.h\"\n#include \"pDifferential.h\"\n\n\n#include \n\n\n/**********************\n* Driveline component *\n**********************/\npDriveLineComp::pDriveLineComp()\n{\n // Init member variables\n parent=0;\n child[0]=child[1]=0;\n driveLine=0;\n name=\"\";\n\n inertia=0.01f;\n ratio=invRatio=1;\n effectiveInertiaDownStream=0;\n cumulativeRatio=0;\n tReaction=tBraking=tEngine=0;\n rotV=rotA=0;\n}\npDriveLineComp::~pDriveLineComp()\n{\n}\n\n//\n// Attribs\n//\nvoid pDriveLineComp::SetParent(pDriveLineComp *_parent)\n// Set a parent for this component. Mostly, this is done implicitly\n// using AddChild().\n{\n parent=_parent;\n}\nvoid pDriveLineComp::SetRatio(float r)\n{\n if(fabs(r)0; adjusted to 1\",r);\n r=1;\n }\n ratio=r;\n // Precalculate inverse ratio for faster calculations later\n invRatio=1.0f/r;\n}\nvoid pDriveLineComp::Reset()\n// Reset variables for a fresh start (like when Shift-R is used)\n{\n rotV=rotA=0;\n}\n\npDriveLineComp *pDriveLineComp::GetChild(int n)\n{\n switch(n)\n { case 0: return child[0];\n case 1: return child[1];\n default: /*qwarn(\"RDriveLineComp:GetChild(%d) out of range\",n);*/ return 0;\n }\n}\n\nvoid pDriveLineComp::AddChild(pDriveLineComp *comp)\n// Add 'comp' as a child\n{\n if(!child[0])child[0]=comp;\n else if(!child[1])child[1]=comp;\n //else qwarn(\"RDriveLineComp:AddChild() failed; already has 2 children\");\n\n // Declare us as parent of the child\n comp->SetParent(this);\n}\n\n\n/*****************\n* Precalculation *\n*****************/\nvoid pDriveLineComp::CalcEffectiveInertia()\n// Calculate the total effective inertia for this node plus the children\n{\n\n//qdbg(\"RDLC:CalcEffectiveInertia() '%s'\\n\",name.cstr());\n effectiveInertiaDownStream=inertia*cumulativeRatio*cumulativeRatio;\n if(child[0])\n {\n child[0]->CalcEffectiveInertia();\n effectiveInertiaDownStream+=child[0]->GetEffectiveInertia();\n }\n if(child[1])\n {\n child[1]->CalcEffectiveInertia();\n effectiveInertiaDownStream+=child[1]->GetEffectiveInertia();\n }\n}\nvoid pDriveLineComp::CalcCumulativeRatio()\n// Calculate the cumulative ratio for this component and entire tree\n{\n cumulativeRatio=ratio;\n if(child[0])\n {\n child[0]->CalcCumulativeRatio();\n }\n if(child[1])\n {\n child[1]->CalcCumulativeRatio();\n }\n // Take ratio if child[0] only, since only singular links are supported\n // (like engine->gear->driveshaft)\n if(child[0])\n cumulativeRatio*=child[0]->GetCumulativeRatio();\n //cumulativeRatio*=child[0]->GetRatio();\n}\nvoid pDriveLineComp::CalcReactionForces()\n// Calculate reaction forces from the leaves up\n{\n tReaction=tBraking=0;\n if(child[0])\n {\n child[0]->CalcReactionForces();\n tReaction+=child[0]->GetReactionTorque();\n tBraking+=child[0]->GetBrakingTorque();\n }\n if(child[1])\n {\n child[1]->CalcReactionForces();\n tReaction+=child[1]->GetReactionTorque();\n tBraking+=child[1]->GetBrakingTorque();\n }\n // Multiply by the inverse ratio for upstream\n tReaction*=invRatio;\n tBraking*=invRatio;\n}\n\n// Stub base class function\nvoid pDriveLineComp::CalcForces(){}\n// Stub base class function\nvoid pDriveLineComp::CalcAccelerations(){}\n// Stub base class function\nvoid pDriveLineComp::Integrate()\n{\n//qdbg(\"RDLC:Integrate() base class\\n\");\n rotV+=rotA*lastStepTimeSec;\n //qdbg(\" rotV=%.2f (rotA=%.2f)\\n\",rotV,rotA);\n}\n\npDriveLine::pDriveLine(pVehicle *_car)\n{\n // Init members\n car=_car;\n root=0;\n preClutchInertia=postClutchInertia=totalInertia=0;\n prepostLocked=true;\n diffs=0;\n\n // Clutch defaults\n clutchMaxTorque=500;\n clutchLinearity=DEFAULT_CLUTCH_LINEARITY;\n SetClutchApplication(1);\n tClutch=0;\n // Handbrake defaults\n handbrakeApplication=0;\n autoClutch=FALSE;\n prepostLocked=FALSE;\n}\npDriveLine::~pDriveLine()\n{\n}\n// Set the root component\nvoid pDriveLine::SetRoot(pDriveLineComp *comp)\n\n{\n root=comp;\n}\n\nvoid pDriveLine::Reset()\n{\n autoClutch=false;\n prepostLocked=false;\n}\n\nvoid pDriveLine::CalcCumulativeRatios()\n{\n if(root)\n root->CalcCumulativeRatio();\n}\n\nvoid pDriveLine::CalcEffectiveInertiae()\n// Calculate all effective inertiae in the driveline\n{\n if(root)\n root->CalcEffectiveInertia();\n}\n\nvoid pDriveLine::CalcPreClutchInertia()\n// Calculate all inertia before the clutch (engine)\n{\n // Engine should be the root\n if(!root)\n {\n //qwarn(\"pDriveLine:CalcPreClutchInertia(); no root component\");\n return;\n }\n preClutchInertia=root->GetInertia();\n}\n\nvoid pDriveLine::CalcPostClutchInertia()\n// Calculate all inertia after the clutch (gearbox, diffs, wheels)\n{\n // Check for a driveline to be present\n if(!root)\n {\n //qwarn(\"pDriveLine:CalcPreClutchInertia(); no root component\");\n return;\n }\n pDriveLineComp *com =root->GetChild(0);\n float f = com->GetEffectiveInertia();\n postClutchInertia=root->GetChild(0)->GetEffectiveInertia();\n\n // Also calculate total inertia\n totalInertia=preClutchInertia+postClutchInertia;\n\n}\n\nvoid pDriveLine::SetClutchApplication(float app)\n// Set clutch application.\n{\n if(app<0)app=0; else if(app>1.0f)app=1.0f;\n // Make it undergo severe linearity; I couldn't get\n // a smooth take-off without stalling the engine.\n app=clutchLinearity*app+(1.0f-clutchLinearity)*(app*app*app);\n clutchApplication=app;\n clutchCurrentTorque=app*clutchMaxTorque;\n}\nvoid pDriveLine::DbgPrint(XString& s)\n{\n //qdbg(\"Driveline (%s); clutch: app=%.2f, maxT=%.2f, T=%.2f\\n\",s,clutchApplication,clutchMaxTorque,clutchCurrentTorque);\n // Print tree\n /*\n if(root)\n root->DbgPrint(0,s);\n */\n}\n\n/********\n* Input *\n********/\nvoid pDriveLine::SetInput(int ctlClutch,int ctlHandbrake)\n// Inputs controller state. May be overruled though is some assisting is on.\n{\n\n //float a = car->getEngine()->getAuto\n // Clutch\n bool isAc = IsAutoClutchActive();\n if(IsAutoClutchActive())\n {\n // Automatic assist is on; don't accept user input for a while\n //SetClutchApplication(car->getEngine()->GetAutoClutch());\n } else\n {\n // Manual\n SetClutchApplication(((float)ctlClutch)/1000.0f);\n }\n\n // Handbrakes\n handbrakeApplication=((float)ctlHandbrake)/1000.0f;\n if(handbrakeApplication<0)handbrakeApplication=0;\n else if(handbrakeApplication>1)handbrakeApplication=1;\n}\n\n/**********\n* Physics *\n**********/\n// Determine forces throughout the driveline.\n// Assumes the wheel reaction forces are already calculated.\nvoid pDriveLine::CalcForces()\n{\n \n\tif(root==0||gearbox==0)\n\t{\n\t\t/*qwarn(\"pDriveLine:CalcForces(); driveline not built yet\");*/\n\t\treturn;\n\t}\n\n // In neutral gear the pre and post parts are always unlocked,\n // and no clutch torque is applied.\n \n \n if(car->getGearBox()->IsNeutral())\n {\n UnlockPrePost();\n //tClutch=0;\n clutchCurrentTorque=0;\n //goto skip_clutch_calc;\n }\n \n\n // Calculate current clutch torque (including torque direction)\n if(!IsPrePostLocked())\n {\n // Engine is running separately from the rest of the driveline.\n // The clutch works to make the velocity of pre-clutch (engine) and\n // post-clutch (rest) equal.\n\t float rVel = root->GetRotationVel();\n\t float rBox = gearbox->GetRotationVel();\n\t float ratio = gearbox->GetRatio();\n\n if(root->GetRotationVel()>gearbox->GetRotationVel()*gearbox->GetRatio())\n\t{\n tClutch=GetClutchCurrentTorque();\n\t}\n\telse{\n tClutch=-GetClutchCurrentTorque();\n\t}\n\n } // else acceleration will be given by the driveline (engine rotates\n // along with the rest of the driveline as a single assembly)\n\n // Spread wheel (leaf) reaction forces all the way to the engine (root)\n root->CalcReactionForces();\n\n if(IsPrePostLocked())\n {\n // Check if pre and post are still locked\n float Te,Tr,Tb,Tc;\n Te=root->GetEngineTorque();\n Tr=root->GetReactionTorque();\n Tb=root->GetBrakingTorque();\n Tc=GetClutchCurrentTorque();\n\n if(fabs(Te-(Tr+Tb))>Tc)\n {\n//qdbg(\" pre-post gets UNLOCKED\\n\");\n UnlockPrePost();\n }\n } // else it will get locked again when velocity reversal happens\n // of the engine vs. rest of the drivetrain (=gearbox in angular velocity)\n\n if(IsSingleDiff())\n {\n \n // Special case where some optimizations can be done\n pDifferential *diff=car->getDifferential(0);\n//qdbg(\"Single diff case:\\n\");\n if(IsPrePostLocked())\n {\n \n\t\n\t\tfloat Te,r;\n\t\tTe=root->GetEngineTorque();\n\t\tr=root->GetCumulativeRatio();\n#ifdef LTRACE\n\tqdbg(\" Diff gets Te=%.2f * ratio %.2f = %.2f\\n\",Te,r,Te*r);\n#endif\n\t\n\t\tdiff->CalcSingleDiffForces(Te*r,root->GetEffectiveInertia());\n } else\n {\n\t\n\t\t// Engine spins at a different rate from the rest of the driveline\n\t\t// In this case the clutch fully works on getting the pre- and post-\n\t\t// clutch angular velocities equal.\n\t\t// Note that if the clutch is fully depressed (engine totally decoupled\n\t\t// from the rest of the driveline), this torque will be 0, and the\n\t\t// postclutch driveline will just rotate freely.\n#ifdef LTRACE\n\tqdbg(\" SingleDiff and prepost unlocked.\\n\");\n#endif\n\t\n\t\tfloat Tc,r;\n\t\tTc=GetClutchTorque();\n\t\tr=root->GetCumulativeRatio();\n\t\tfloat a1 = root->GetEffectiveInertia();\n\n#ifdef LTRACE\n\tqdbg(\" Diff gets Tc=%.2f * ratio %.2f = %.2f\\n\",Tc,r,Tc*r);\n#endif\n\t\t\n\t\tdiff->CalcSingleDiffForces(Tc*r,root->GetEffectiveInertia());\n\t \n\t}\n }\n}\nvoid pDriveLine::CalcAccelerations()\n{\n\n#ifdef LTRACE\n\tqdbg(\"pDriveLine::CalcAccelerations()\\n\");\n#endif\n\n if(IsSingleDiff())\n {\n\t// Special case with speedier calculations\n\tpDifferential *diff=car->getDifferential(0);\n\tpDriveLineComp *comp;\n\tfloat acc=diff->GetAccIn();\n\tif(IsPrePostLocked())\n\t{\n\t\t//qdbg(\"Single diff, prepost LOCKED\\n\");\n\t\t// Everything is decided by the differential acceleration\n\t\t// Wheels got their acceleration in RWheel::CalcAccelerations()\n\t\t// Pass acceleration up the tree; mind the ratios\n\t\tfor(comp=diff;comp;comp=comp->GetParent())\n\t\t{\n\t\t\tcomp->SetRotationAcc(acc);\n\t\t\tacc*=comp->GetRatio();\n#ifdef LTRACE\n\t\tqdbg(\" comp '%s' acc %.2f (ratio %.2f)\\n\",comp->GetName(),acc,comp->GetRatio());\n#endif\n\t\n }\n } else\n {\n // Separate pre- and postclutch accelerations\n // First calculate the engine's acceleration.\n root->CalcAccelerations();\n // Rest of the driveline takes its acceleration from the diff\n // Wheels got their acceleration in RWheel::CalcAccelerations()\n // Pass acceleration up the tree, EXCEPT for the engine; mind the ratios\n // May combine this into the loop above by a sentinel component\n // which is either '0' or 'root'. (for the PrePostLocked case)\n for(comp=diff;comp!=root;comp=comp->GetParent())\n {\n comp->SetRotationAcc(acc);\n acc*=comp->GetRatio();\n\t\t//qdbg(\" comp '%s' acc %.2f (ratio %.2f)\\n\",//comp->GetName(),acc,comp->GetRatio());\n }\n }\n }\n}\n\nvoid pDriveLine::Integrate()\n{\n\n float deltaVel,newDeltaVel;\n\n // Remember difference between engine and gear rotation\n float a = gearbox->GetRotationVel();\n float ab = gearbox->GetRatio();\n deltaVel=root->GetRotationVel()-gearbox->GetRotationVel()*gearbox->GetRatio();\n if(IsPrePostLocked())\n {\n // Check for the engine and gearbox (ratio'd)\n // to rotate just about equally.\n // If not, the driver may have speedshifted without\n // applying the clutch. Unfortunately, this is possible\n // but should result in damage in the future, since\n // you get a lot of gear noise.\n if(fabs(deltaVel)>DELTA_VEL_THRESHOLD)\n {\n \n // Unlock pre-post to let things catch up again\n UnlockPrePost();\n }\n }\n\n#ifdef LTRACE\n\n qdbg(\"rotV: engine=%.3f, gearbox=%.3f\\n\",root->GetRotationVel(),gearbox->GetRotationVel());\n qdbg(\" engine=%p, root=%p, gearbox=%p\\n\",car->getEngine(),root,gearbox);\n qdbg(\" rpm=%f\\n\",car->getEngine()->getRPM());\n\n int cGear =car->getGearBox()->GetGear();\n qdbg(\" currentGear=%d %s \\n\",cGear,car->getGearBox()->GetGearName(cGear).CStr());\n\n#endif\n\n\n // Engine\n if(root)root->Integrate();\n if(gearbox)gearbox->Integrate();\n\n if(!IsPrePostLocked())\n {\n // Check if gearbox is catching up with engine\n newDeltaVel=root->GetRotationVel()-gearbox->GetRotationVel()*gearbox->GetRatio();\n//qdbg(\"Check lock; oldDV=%.3f, newDV=%.3f\\n\",deltaVel,newDeltaVel);\n if((deltaVel>0&&newDeltaVel<0)||\n (deltaVel<0&&newDeltaVel>0))\n {\n\n#ifdef LTRACE\nqdbg(\" RE-LOCKED!\\n\");\n#endif\n\t\t\n\t\tLockPrePost();\n // Force engine and gearbox velocity to be the same\n#ifdef LTRACE\n\tqdbg(\" engine rotV=%.3f, gearbox rotV=%.3f\\n\",root->GetRotationVel(),gearbox->GetRotationVel());\n#endif\n\t\t\n\t\tfloat gVel = gearbox->GetRotationVel();\n\t\tfloat gRatio = gearbox->GetRatio();\n\t\tfloat a = gVel * gRatio;\n\t\troot->SetRotationVel(gearbox->GetRotationVel()*gearbox->GetRatio());\n//\t root->SetRotationVel(gRatio * gVel);\n\n }\n }\n}\n\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n\r\n\r\n#define FTP4W_INCLUDES_AND_GENERAL +\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n#include /* external header file */ \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\" /* external header file */ \r\n#include \"ftp4w_in.h\" /* internal header file */\r\n#include \"rfc959.h\" /* only for error codes */ \r\n\r\nextern LPProcData pFirstProcData;\r\n\r\n\r\n\r\n/* ************************************************************ */\r\n/* */\r\n/* Donnees Automates */\r\n/* */\r\n/* ************************************************************ */\r\n\r\n\r\n\r\nstruct S_AnswerTranslation\r\n{\r\n int nFtpAns;\r\n int n4wAns;\r\n}; /* struct S_AnswerTranslation */\r\n\r\nstruct S_OrdreSmtp \r\n{\r\n LPSTR szOrdre;\r\n struct S_AnswerTranslation s [10]; /* _S_END last answer */\r\n} \r\nstatic sOrdre []= \r\n{\r\n { NULL, /* Trame de connexion */\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 110, FTPERR_OK, },\r\n { 120, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 421, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"USER %s\", /* Trame authentification */\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 220, FTPERR_OK, },\r\n { 230, FTPERR_OK, },\r\n { 331, FTPERR_ENTERPASSWORD, },\r\n { 421, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"PASS %s\", /* Trame authentification */\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 220, FTPERR_OK, },\r\n { 230, FTPERR_OK, },\r\n { 332, FTPERR_ACCOUNTNEEDED, },\r\n { 501, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 503, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 530, FTPERR_LOGINREFUSED, }, \r\n { _S_END, 0 } } },\r\n { \"ACCT %s\", /* Trame authentification */\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 202, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 230, FTPERR_OK, },\t/* serveur Unisys */\r\n { 500, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 503, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 530, FTPERR_LOGINREFUSED, }, \r\n { _S_END, 0 } } },\r\n { \"QUIT\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 221, FTPERR_OK, },\r\n { _S_END, 0 } } },\r\n { \"HELP\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 211, FTPERR_OK, },\r\n { 214, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { _S_END, 0 } } },\r\n { \"HELP %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 211, FTPERR_OK, },\r\n { 214, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { _S_END, 0 } } },\r\n { \"DELE %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 250, FTPERR_OK, },\r\n { 450, FTPERR_FILELOCKED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"CWD %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 250, FTPERR_OK, },\r\n { 450, FTPERR_FILELOCKED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"CDUP\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 250, FTPERR_OK, },\r\n { 450, FTPERR_FILELOCKED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"MKD %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 227, FTPERR_OK, },\r\n { 257, FTPERR_OK, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 521, FTPERR_SERVERCANTEXECUTE, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"RMD %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 250, FTPERR_OK, },\r\n { 257, FTPERR_OK, },\r\n { 450, FTPERR_FILELOCKED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"PWD\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 257, FTPERR_OK, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"TYPE %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 530, FTPERR_CANNOTCHANGETYPE, },\r\n { 550, FTPERR_CANNOTCHANGETYPE, },\r\n { _S_END, 0 } } },\r\n { \"RNFR %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 350, FTPERR_OK, },\r\n { 450, FTPERR_FILELOCKED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_NOREMOTEFILE, },\r\n { _S_END, 0 } } },\r\n { \"RNTO %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 250, FTPERR_OK, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 550, FTPERR_SERVERCANTEXECUTE, },\r\n { 553, FTPERR_SERVERCANTEXECUTE, },\r\n { _S_END, 0 } } },\r\n { \"SYST\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 215, FTPERR_OK, },\r\n { 220, FTPERR_OK, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { _S_END, 0 } } },\r\n { \"NOOP\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 200, FTPERR_OK, },\r\n { 500, FTPERR_CMDNOTIMPLEMENTED, },\r\n { _S_END, 0 } } },\r\n { \"REST %s\",\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 350, FTPERR_RESTARTOK, },\r\n { 500, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 502, FTPERR_CMDNOTIMPLEMENTED, },\r\n { 504, FTPERR_CMDNOTIMPLEMENTED, },\r\n { _S_END, 0 } } },\r\n { NULL, /* EndFileTransfer */\r\n { { -1, FTPERR_NOREPLY },\r\n { 0, FTPERR_UNEXPECTEDANSWER, },\r\n { 226, FTPERR_OK, },\r\n { 250, FTPERR_OK, },\r\n { 421, FTPERR_SERVERCANTEXECUTE, },\r\n { 552, FTPERR_CANTWRITE , },\r\n { _S_END, 0 } } },\r\n\r\n}; /* sOrdre */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* FtpAutomate */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpAutomate (int nIdx, LPCSTR szParam)\r\n{\r\nLPProcData pProcData;\r\nint Rc=TN_SUCCESS;\r\nchar szBuf [FTP_REPSTRLENGTH];\r\nint Ark;\r\n \r\n /* ------- retrouve la bonne session */\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n /* ------- Nécessite d'envoyer un ordre */\r\n if (sOrdre [nIdx].szOrdre != NULL) \r\n {\r\n /* ------- traite un parametre */\r\n if (szParam!=NULL) wsprintf (szBuf, sOrdre [nIdx].szOrdre, szParam);\r\n else lstrcpy ( szBuf, sOrdre [nIdx].szOrdre );\r\n /* ------- Envoie la commande */\r\n Rc = IntTnSend ( pProcData->ftp.ctrl_socket, szBuf, FALSE, pProcData->ftp.hLogFile);\r\n if (Rc != TN_SUCCESS) return FTPERR_SENDREFUSED;\r\n }\r\n /* ------- Recupere la reponse */\r\n Rc = IntFtpGetAnswerCode (& pProcData->ftp);\r\n /* ------- Translation de la reponse */\r\n for (Ark=0 ; sOrdre [nIdx].s[Ark].nFtpAns != _S_END ; Ark++ )\r\n {\r\n if (Rc==sOrdre [nIdx].s[Ark].nFtpAns) return sOrdre [nIdx].s[Ark].n4wAns;\r\n } /* code de retour */\r\nreturn FTPERR_UNEXPECTEDANSWER;\r\n} /* FtpAutomate */\r\n\r\n\r\n\r\n\r\n\r\n/* ------------------------------------------------------------*/\r\n/* Fonction DLL FtpOpenConnection */\r\n/* ----------------------------------------------------------- */\r\nint _export PASCAL FAR FtpOpenConnection (LPCSTR szHost)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\n\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n\r\n Rc=TcpConnect(& pProcData->ftp.ctrl_socket, \r\n szHost, \r\n pProcData->ftp.nPort==FTP_DEFCTRLPORT?(LPSTR)\"ftp\":(LPSTR) NULL,\r\n & pProcData->ftp.nPort);\r\n switch (Rc)\r\n {\r\n case TCP4U_SUCCESS : pProcData->ftp.cType = TYPE_A;\r\n return FtpAutomate (_S_CONNECT, NULL);\r\n case TCP4U_HOSTUNKNOWN : return FTPERR_UNKNOWNHOST;\r\n case TCP4U_TIMEOUT : return FTPERR_TIMEOUT;\r\n case TCP4U_CONNECTFAILED : return FTPERR_CONNECTREJECTED;\r\n case TCP4U_NOMORESOCKET : return FTPERR_CANTCREATESOCKET;\r\n case TCP4U_CANCELLED : return FTPERR_CANCELBYUSER;\r\n default : return FTPERR_CANTCONNECT;\r\n } /* return FTP4W error codes */ \r\n} /* FtpOpenConnection */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpLogin */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpLogin (LPCSTR szHost, LPCSTR szUser, LPCSTR szPasswd, \r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nint Rc;\r\nLPProcData pProcData;\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n \r\n /* enregistre le message à envoyer */\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n /* demande d'ouverture de la connexion */\r\n if (szHost==NULL) return FTPERR_INVALIDPARAMETER;\r\n Rc = FtpOpenConnection (szHost);\r\n if (Rc==FTPERR_OK && szUser!=NULL) Rc = FtpSendUserName (szUser);\r\n if (Rc==FTPERR_ENTERPASSWORD && szPasswd!=NULL) \r\n Rc = FtpSendPasswd (szPasswd);\r\n RETURN (pProcData, Rc); \r\n} /* FtpLogin */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSendUserName */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSendUserName (LPCSTR szUserName)\r\n{\r\nreturn FtpAutomate (_S_USER, szUserName);\r\n} /* FtpSendUserName */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSendPasswd */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSendPasswd (LPCSTR szPasswd) \r\n{\r\nreturn FtpAutomate (_S_PASS, szPasswd);\r\n} /* FtpSendPasswd */\r\n \r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSendAccount */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSendAccount (LPCSTR szAccount) \r\n{\r\nreturn FtpAutomate (_S_ACCOUNT, szAccount);\r\n} /* FtpSendAccount */\r\n \r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpCloseConnection */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpCloseConnection (void)\r\n{\r\nint Rc;\r\n Rc = FtpAutomate (_S_QUIT, NULL);\r\n if (Rc==FTPERR_OK) FtpLocalClose ();\r\nreturn Rc;\r\n} /* FtpCloseConnection */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpHelp */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpHelp (LPCSTR szArg, LPSTR szBuf, UINT uBufSize)\r\n{\r\nint Rc;\r\nLPSTR p;\r\nLPProcData pProcData; \r\n\r\n Rc = FtpAutomate (szArg==NULL ? _S_HELP : _S_HELPCMD, szArg);\r\n if (Rc==FTPERR_OK)\r\n {\r\n pProcData = ToolsLocateProcData ();\r\n /* on élimine la dernière ligne (code de retour) */\r\n p = strrchr (pProcData->ftp.szInBuf, '\\r');\r\n if (p!=NULL) *p= 0;\r\n lstrcpyn (szBuf, & pProcData->ftp.szInBuf[4], uBufSize);\r\n }\r\nreturn Rc; \r\n} /* FtpHELP */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpDeleteFile */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpDeleteFile (LPCSTR szRemoteFile)\r\n{\r\nreturn FtpAutomate (_S_DELE, szRemoteFile);\r\n} /* FtpDelete */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpCWD */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpCWD (LPCSTR szPath)\r\n{\r\nreturn FtpAutomate (_S_CWD, szPath);\r\n} /* FtpCWD */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpCDUP */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpCDUP (void)\r\n{\r\nreturn FtpAutomate (_S_CDUP, NULL);\r\n} /* FtpCDUP */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpMKD */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpMKD (LPCSTR szPath, LPSTR szFullDir, UINT uBufSize)\r\n{\r\nint Rc;\r\nLPSTR p;\r\nLPProcData pProcData; \r\n\r\n Rc = FtpAutomate (_S_MKD, szPath);\r\n if (Rc==FTPERR_OK)\r\n {\r\n /* Voir explications RFC 959 appendix II et fonction FtpPWD */\r\n if (szFullDir==NULL || uBufSize==0) return FTPERR_OK;\r\n /* sinon on tente de rendre dans szFullDir le nom du */\r\n /* repertoire qu'on vient de créer */\r\n pProcData = ToolsLocateProcData ();\r\n if ( pProcData->ftp.szInBuf[4]=='\"' \r\n && (p=strchr (& pProcData->ftp.szInBuf[5], '\"'))!=NULL )\r\n {\r\n *p=0; /* on remplace le 2ème \" par un fin de chaine */\r\n lstrcpyn (szFullDir, & pProcData->ftp.szInBuf[5], uBufSize);\r\n }\r\n else szFullDir [0] =0; /* illisible -> on rend une chaine vide */\r\n }\r\nreturn Rc;\r\n} /* FtpMKD */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRMD */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRMD (LPCSTR szPath)\r\n{\r\nreturn FtpAutomate (_S_RMD, szPath);\r\n} /* FtpRMD */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpPWD */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpPWD (LPSTR szBuf, UINT uBufSize)\r\n{\r\nLPProcData pProcData;\r\nint Rc; \r\nLPSTR p;\r\n\r\n Rc = FtpAutomate (_S_PWD, NULL);\r\n if (Rc==FTPERR_OK)\r\n {\r\n pProcData = ToolsLocateProcData ();\r\n /* en principe pas la peine */\r\n /* Réponse standard de PWD : 257 \"full dir name\" .... */\r\n /* si reponse OK, on renvoie FTPERR_OK, si 257 mais */\r\n /* format different, on renvoie FTPERR_PWDBADFMT */\r\n \r\n if ( pProcData->ftp.szInBuf[4]=='\"' \r\n && (p=strchr (& pProcData->ftp.szInBuf[5], '\"'))!=NULL )\r\n {\r\n *p=0; /* on remplace le \" par un fin de chaine */\r\n lstrcpyn (szBuf, & pProcData->ftp.szInBuf[5], uBufSize);\r\n return FTPERR_OK;\r\n }\r\n else \r\n {\r\n lstrcpyn (szBuf, & pProcData->ftp.szInBuf[4], uBufSize);\r\n return FTPERR_PWDBADFMT;\r\n }\r\n }\r\nreturn Rc;\r\n} /* FtpPWD */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSetType */\r\n/* change the type of the data transfer (eithr ASCII or BINARY) */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSetType (char cType)\r\n{\r\nchar szTmp [5];\r\nLPProcData pProcData;\r\nint Rc;\r\n\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData==NULL) return FTPERR_NOTINITIALIZED;\r\n if ( pProcData->ftp.cType == cType ) Rc = FTPERR_OK;\r\n else\r\n {\r\n szTmp[0] = cType; \r\n if (cType!=TYPE_L8) szTmp[1] = 0; /* transfo en chaine */\r\n else { szTmp[1] = ' ', szTmp[2] = '8', szTmp[3]=0; }\r\n Rc =FtpAutomate (_S_TYPE, szTmp);\r\n if (Rc==FTPERR_OK) pProcData->ftp.cType = cType;\r\n } /* if not the current type */\r\nreturn Rc;\r\n} /* FtpSetType */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRestart */\r\n/* Ask to the server to send a file from Nth byte */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRestart (long lByteCount)\r\n{\r\nchar szByteCount [sizeof \"4294967295\"];\r\n if (lByteCount<=0) return FTPERR_RESTARTOK; /* should not happen */\r\n wsprintf (szByteCount, \"%ld\", lByteCount);\r\nreturn FtpAutomate (_S_REST, szByteCount);\r\n} /* FtpRestart */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpRenameFile */\r\n/* Change the name of a remote file */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpRenameFile (LPCSTR szFrom, LPCSTR szTo)\r\n{\r\nint Rc;\r\n Rc = FtpAutomate (_S_RNFR, szFrom);\r\nreturn Rc==FTPERR_OK ? FtpAutomate (_S_RNTO, szTo) : Rc;\r\n} /* FtprenameFile */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpQuote */\r\n/* returns either a FTP return code (ie 200), or a WFTP error code */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpQuote (LPCSTR szCmd, LPSTR szReplyBuf, UINT uBufSize)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\n\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData==NULL || szCmd==NULL) return FTPERR_NOTINITIALIZED;\r\n if (pProcData->ftp.ctrl_socket==INVALID_SOCKET) return FTPERR_NOTCONNECTED;\r\n\r\n Rc = TnSend ( pProcData->ftp.ctrl_socket, szCmd, FALSE, pProcData->ftp.hLogFile);\r\n if (Rc != TN_SUCCESS) return FTPERR_SENDREFUSED;\r\n Rc = IntFtpGetAnswerCode ( & pProcData->ftp );\r\n if (Rc==-1) return FTPERR_NOREPLY;\r\n if (szReplyBuf!=NULL) \r\n lstrcpyn ( szReplyBuf, pProcData->ftp.szInBuf, uBufSize );\r\nreturn Rc;\r\n} /* FtpQuote */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSyst */\r\n/* returns the index in the string or an error code */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSyst (LPCSTR FAR * szSystStr)\r\n{\r\nLPProcData pProcData;\r\nint Rc;\r\nchar szBuffer[128]; /* chaine retournee par le serveur */\r\n\r\n Rc= FtpAutomate (_S_SYST, NULL);\r\n if (Rc!=FTPERR_OK) return Rc;\r\n pProcData = ToolsLocateProcData ();\r\n AnsiUpper (pProcData->ftp.szInBuf);\r\n for ( Rc=0 ; szSystStr[Rc]!=NULL ; Rc++)\r\n {\r\n /* copier la chaine pour la comparaison en majuscules */\r\n lstrcpyn (szBuffer, szSystStr[Rc], sizeof szBuffer);\r\n AnsiUpper (szBuffer);\r\n if (strstr (pProcData->ftp.szInBuf, szBuffer)!=NULL) return Rc;\r\n }\r\nreturn FTPERR_SYSTUNKNOWN; /* chaine non trouvee */\r\n} /* FtpSyst */\r\n\r\n\r\n#ifndef __XTNLINTERN_ALL_H\r\n#define __XTNLINTERN_ALL_H\r\n\r\n\t\r\nusing namespace TNL;\r\n\t#include \r\n\t#include \r\n\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t ReadMidiSignal\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateReadMidiSignalProto(CKBehaviorPrototype **);\r\nint ReadMidiSignal(const CKBehaviorContext& behcontext);\r\n\r\nCKERROR ReadMidiSignalCallBack(const CKBehaviorContext& behcontext); // CallBack Functioon\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorReadMidiSignalDecl()\r\n{\r\n CKObjectDeclaration *od = CreateCKObjectDeclaration(\"Read Midi\");\t\r\n od->SetDescription(\"Reads a Midi signal.\");\r\n od->SetCategory(\"Controllers/Midi\");\r\n od->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n od->SetGuid(CKGUID(0x408c50ed,0x68ba5988));\r\n od->SetAuthorGuid(VIRTOOLS_GUID);\r\n od->SetAuthorName(\"Virtools\");\r\n od->SetVersion(0x00020000);\r\n od->SetCreationFunction(CreateReadMidiSignalProto);\r\n od->SetCompatibleClassId(CKCID_BEOBJECT);\r\n return od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateReadMidiSignalProto(CKBehaviorPrototype **pproto)\r\n{\r\n CKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Read Midi\");\r\n if(!proto) return CKERR_OUTOFMEMORY;\r\n \r\n proto->DeclareInput(\"On\");\r\n proto->DeclareInput(\"Off\");\r\n \r\n proto->DeclareOutput(\"Activated\");\r\n proto->DeclareOutput(\"Deactivated\");\r\n \r\n proto->DeclareInParameter(\"Channel\", CKPGUID_INT, \"0\");\r\n \r\n proto->DeclareOutParameter(\"Note\", CKPGUID_INT, \"-1\");\r\n proto->DeclareOutParameter(\"Attack\", CKPGUID_INT, \"-1\");\r\n\r\n proto->DeclareSetting(\"Ask For All Commands\", CKPGUID_BOOL, \"FALSE\");\r\n \r\n proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n proto->SetFunction(ReadMidiSignal);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDOUTPUTS|CKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS));\r\n\r\n proto->SetBehaviorCallbackFct( ReadMidiSignalCallBack );\r\n \r\n *pproto = proto;\r\n return CK_OK;\r\n}\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint ReadMidiSignal(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n\r\n if( beh->IsInputActive(1) ){ // OFF\r\n beh->ActivateInput(1, FALSE);\r\n\r\n return CKBR_OK;\r\n }\r\n \r\n if( beh->IsInputActive(0) ){ // ON\r\n beh->ActivateInput(0, FALSE);\r\n }\r\n \r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n // Channel\r\n int channel=0;\r\n beh->GetInputParameterValue(0, &channel);\r\n \r\n int command, note, attack;\r\n\r\n CKBOOL allCommands=FALSE;\r\n beh->GetLocalParameterValue(0, &allCommands);\r\n\r\n //________________________________________________________\r\n if( !allCommands ){ // use 9 and 8 as default commands\r\n XListIt it;\r\n for( it = mm->listForBehaviors.Begin() ; it!=mm->listForBehaviors.End() ; it++ ){\r\n\r\n if( (*it).channel==channel ){\r\n if( (*it).command==9 && (*it).attack!=0 ){ // start a note\r\n note = (*it).note;\r\n attack = (*it).attack;\r\n beh->SetOutputParameterValue(0, &note);\r\n beh->SetOutputParameterValue(1, &attack);\r\n beh->ActivateOutput(0);\r\n return CKBR_ACTIVATENEXTFRAME;\r\n }\r\n if( (*it).command==9 || (*it).command==8 ){ // stop a note\r\n note = (*it).note;\r\n attack = (*it).attack;\r\n beh->SetOutputParameterValue(0, &note);\r\n beh->SetOutputParameterValue(1, &attack);\r\n beh->ActivateOutput(1);\r\n return CKBR_ACTIVATENEXTFRAME;\r\n }\r\n }\r\n\r\n }\r\n //_____________________________________________\r\n } else { // we are interested by every commands\r\n XListIt it;\r\n for( it = mm->listForBehaviors.Begin() ; it!=mm->listForBehaviors.End() ; it++ ){\r\n\t\tif (beh->GetVersion()<0x00020000) {\r\n\t\t\tif ( command = (*it).command ){\r\n\t\t\t\tnote = (*it).note;\r\n\t\t\t\tattack = (*it).attack;\r\n\t\t\t\tbeh->SetOutputParameterValue(0, &note);\r\n\t\t\t\tbeh->SetOutputParameterValue(1, &attack);\r\n\t\t\t\tbeh->SetOutputParameterValue(2, &command);\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif ( command = (*it).command && (*it).channel == channel){\r\n\t\t\t\tnote = (*it).note;\r\n\t\t\t\tattack = (*it).attack;\r\n\t\t\t\tbeh->SetOutputParameterValue(0, &note);\r\n\t\t\t\tbeh->SetOutputParameterValue(1, &attack);\r\n\t\t\t\tbeh->SetOutputParameterValue(2, &command);\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t\t\t}\r\n\t\t}\r\n \r\n }\r\n \r\n }\r\n \r\n return CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR ReadMidiSignalCallBack(const CKBehaviorContext& behcontext){\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n \r\n switch( behcontext.CallbackMessage ){\r\n \r\n case CKM_BEHAVIORSETTINGSEDITED:\r\n {\r\n int c_out = beh->GetOutputCount();\r\n \r\n CKBOOL allCommands=FALSE;\r\n beh->GetLocalParameterValue(0, &allCommands);\r\n \r\n CKBehaviorIO *out = beh->GetOutput(0);\r\n\r\n if( c_out==2 && allCommands ){ // All Commands\r\n beh->DeleteOutput(--c_out);\r\n \t\t\tbeh->CreateOutputParameter(\"Command\", CKPGUID_INT);\r\n out->SetName(\"Message Received\");\r\n }\r\n\r\n if( c_out==1 && !allCommands ){ // just 8 and 9\r\n\t\t\t\tCKDestroyObject( beh->RemoveOutputParameter(2) );\r\n beh->CreateOutput(\"Deactivate\");\r\n out->SetName(\"Activate\");\r\n }\r\n \r\n }\r\n break;\r\n\r\n case CKM_BEHAVIORATTACH:\r\n case CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tmm->AddMidiBBref();\r\n\t\t} break;\r\n case CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tmm->RemoveMidiBBref();\r\n\t\t} break;\r\n }\r\n \r\n return CKBR_OK; \r\n}\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* Ftp4w Version 3.01 */\r\n/* FtpCheckError */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n \r\n#include \r\n#include \r\n#include \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\"\r\n#include \"ftp4w_in.h\"\r\n\r\n\r\n\r\nextern LPProcData pFirstProcData;\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie IX : C o p y r i g h t */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n/* #define CRC 1 \t\t */\r\n#define CRC_VALUE 51210\r\nstatic int nVER= 0x0301;\r\nstatic char szVER [] = \r\n\"@(#)------------------------------------------------------------------------\\n\\\r\nFTP for windows Version 3.01 by () \\n\\\r\n-----------------------------------------------------------------------------\\n\";\r\n\r\n\r\nint _export PASCAL FAR Ftp4wVer (LPSTR szVerStr, int nStrSize)\r\n{\r\nLPSTR p;\r\n if (szVerStr!=NULL && nStrSize!=0)\r\n {\r\n lstrcpyn (szVerStr, strchr (szVER, '\\n')+1, nStrSize);\r\n if ( (p=strchr (szVerStr, '\\n'))!=NULL) *p=0;\r\n }\r\nreturn nVER; \r\n} /* Ftp4wVer */\r\n\r\n\r\nint Protection ()\r\n{\r\nstatic char sz2[] = \"This is an illegal copy of FTP4W.DLL\\nPlease contact the author at ph.\\nin order to have an original version.\";\r\nunsigned Ark, Evan;\r\nunsigned short cRc;\r\n for (Ark=0, Evan= lstrlen(szVER) / sizeof cRc, cRc=216 ; ArkhFtpWnd, sz2, strchr (szVER, 'F'), MB_OK);\r\n }\r\n#ifdef CRC\r\n { \r\n char szTmp [256];\r\n wsprintf (szTmp,\"cRc Value %u\", (unsigned) cRc);\r\n MessageBox (FtpDataPtr ()->hFtpWnd, szTmp, strchr (szVER, 'F'), MB_OK);\r\n }\r\n#endif\r\nreturn FALSE;\r\n} /* Protection */\r\n \r\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* I *do* have a suggestion for you. I wrote the following function (it */\r\n/* does not cover all errors) that I thought you might want to add to */\r\n/* your dll file. Pardon the tab spacing... I call this function after */\r\n/* any ftp4w function to check for errors and report them. I pass a handle */\r\n/* to a parent window (for creation of message box, could use 0 for desktop) */\r\n/* and then I pass the return code and the name of the function that I just */\r\n/* called. Now all of this *could* be stored internal (except for the parent*/\r\n/* window handle) to the .dll file... Have a global variable that stores */\r\n/* the last return code as well as the last function called so when */\r\n/* ftpcheckerror is called, it doesn't need any parameters.. Although you */\r\n/* would definitely want to allow a char* string to be passed so the end */\r\n/* programmer can pass something to it like a line # in the c file for */\r\n/* ease of debugging. Anyways, here goes: */\r\n/* */\r\n/* */\r\n/* Texas Networking, Inc. */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n#define SizeOfTab(t) ( sizeof (t) / sizeof (t[0]) )\r\n\r\nstruct S_Ftp4wErr\r\n{\r\n int Ftp4wErrCode;\r\n LPSTR Ftp4wErrString;\r\n}; /* struct S_Ftp4wErr */\r\n\r\nstruct S_Ftp4wErr sFtp4wErr [] =\r\n{\r\n { FTPERR_OK, \"Successful function\" },\r\n { FTPERR_ENTERPASSWORD, \"Enter a password\" },\r\n { FTPERR_ENTERACCOUNT, \"Enter account\" },\r\n { FTPERR_ACCOUNTNEEDED, \"Enter account\" },\r\n { FTPERR_RESTARTOK, \"Restart command successful\" },\r\n { FTPERR_CANCELBYUSER, \"Transfer aborted by FtpAbort\" },\r\n { FTPERR_ENDOFDATA, \"Server has closed the data connection\" },\r\n { FTPERR_INVALIDPARAMETER, \"Error in parameters\" },\r\n { FTPERR_SESSIONUSED, \"User has already a FTP session\" },\r\n { FTPERR_NOTINITIALIZED, \"FtpInit has not been called\" },\r\n { FTPERR_NOTCONNECTED, \"User is not connected to a server\" },\r\n { FTPERR_CANTOPENFILE, \"Can not open specified file\" },\r\n { FTPERR_CANTOPENLOCALFILE, \"Can not open specified file\" },\r\n { FTPERR_CANTWRITE, \"Can not write into file (disk full?)\" },\r\n { FTPERR_NOACTIVESESSION, \"FtpRelease without FtpInit\" },\r\n { FTPERR_STILLCONNECTED, \"FtpRelease without any Close\" },\r\n { FTPERR_SERVERCANTEXECUTE, \"File action not taken\" },\r\n { FTPERR_LOGINREFUSED, \"Server rejects userid/passwd\" },\r\n { FTPERR_NOREMOTEFILE, \"Server can not open remote file\" },\r\n { FTPERR_TRANSFERREFUSED, \"Host refused the transfer\" },\r\n { FTPERR_WINSOCKNOTUSABLE, \"A winsock.DLL ver 1.1 is required\" },\r\n { FTPERR_CANTCLOSE, \"Close failed (cmd is in progress)\" },\r\n { FTPERR_FILELOCKED, \"Temporary error during FtpDelete\" },\r\n { FTPERR_FWLOGINREFUSED, \"Firewall rejects userid/passwd\" },\r\n { FTPERR_ASYNCMODE, \"Function available only in synchronous mode\" },\r\n { FTPERR_UNKNOWNHOST, \"Can not resolve host adress\" },\r\n { FTPERR_NOREPLY, \"Host does not send an answer\" },\r\n { FTPERR_CANTCONNECT, \"Error during connection\" },\r\n { FTPERR_CONNECTREJECTED, \"Host has no FTP server\" },\r\n { FTPERR_SENDREFUSED, \"Can not send data (network down)\" },\r\n { FTPERR_DATACONNECTION, \"Connection on data-port failed\" },\r\n { FTPERR_TIMEOUT, \"Timeout occured\" },\r\n { FTPERR_FWCANTCONNECT, \"Error during connection with Firewall \" },\r\n { FTPERR_FWCONNECTREJECTED, \"Firewall has no FTP server\" },\r\n { FTPERR_UNEXPECTEDANSWER, \"Answer was not expected\" },\r\n { FTPERR_CANNOTCHANGETYPE, \"Host rejects the TYPE command\" },\r\n { FTPERR_CMDNOTIMPLEMENTED, \"Command not implemented\" },\r\n { FTPERR_PWDBADFMT, \"PWD cmd OK, but answer has no directory\"},\r\n { FTPERR_PASVCMDNOTIMPL, \"Server don't support passive mode\" },\r\n { FTPERR_CANTCREATEWINDOW, \"Insuffisent free resources\" },\r\n { FTPERR_INSMEMORY, \"Insuffisent Heap memory\" },\r\n { FTPERR_CANTCREATESOCKET, \"No socket available\" },\r\n { FTPERR_CANTBINDSOCKET, \"Bind is not succesful\" },\r\n { FTPERR_SYSTUNKNOWN, \"Host system not in the list\" },\r\n}; /* sFtp4wErr */\r\n\r\n\r\n\r\n\r\nLPSTR _export PASCAL FAR FtpErrorString (int Rc)\r\n{\r\nint Idx;\r\n for ( Idx=0 ; \r\n Idx= SizeOfTab(sFtp4wErr) ? (LPSTR) \"Not an Ftp4w return code\" :\r\n sFtp4wErr[Idx].Ftp4wErrString;\r\n} /* FtpErrorString */\r\n\r\n\r\n#include \r\nvoid _cdecl Ftp4w_Trace (const char *szFile, const char *fmt, ...)\r\n{\r\nHFILE hFile;\r\nva_list marker;\r\nchar szBuf[512];\r\n\r\n va_start( marker, fmt );\r\n\thFile = _lopen (szFile, OF_WRITE);\r\n\r\n\tsprintf (szBuf, \"%ld: Proc %d\\t\", GetTickCount(), GetCurrentThreadId ());\r\n\tvsprintf (szBuf, fmt, marker);\r\n\tstrcat (szBuf, \"\\r\\n\");\r\n\tOutputDebugString (szBuf);\r\n} /* Ftp4w_Trace */\r\n\r\n\r\n\r\n\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_VECTOR_H_\n#define _TNL_VECTOR_H_\n\n//Includes\n#ifndef _TNL_TYPES_H_\n#include \"tnlTypes.h\"\n#endif\n\n#ifndef _TNL_PLATFORM_H_\n#include \"tnlPlatform.h\"\n#endif\n\n#define VectorBlockSize 16\n\nnamespace TNL {\n\n//-----------------------------------------------------------------------------\n\n/// VectorRep is an image of a Vector template object that is used\n/// for marshalling and unmarshalling Vectors across RPCs.\nstruct VectorRep\n{\n U32 elementCount;\n U32 arraySize;\n U8 *array;\n};\n\n// =============================================================================\n\n/// A dynamic array template class.\n///\n/// The vector grows as you insert or append\n/// elements. Insertion is fastest at the end of the array. Resizing\n/// of the array can be avoided by pre-allocating space using the\n/// reserve() method.\ntemplate class Vector\n{\n protected:\n U32 mElementCount; ///< Number of elements currently in the Vector.\n U32 mArraySize; ///< Number of elements allocated for the Vector.\n T* mArray; ///< Pointer to the Vector elements.\n\n void checkSize(U32 newElementCount);///< checks the element count against the array size and resizes the array if necessary\n void destroy(U32 start, U32 end); ///< Destructs elements from start to end-1\n void construct(U32 start, U32 end); ///< Constructs elements from start to end-1\n void construct(U32 start, U32 end, const T* array);\n public:\n Vector(const U32 initialSize = 0);\n Vector(const Vector&);\n ~Vector();\n\n /// @name VectorSTL STL interface\n ///\n /// @{\n\n ///\n typedef T value_type;\n typedef T& reference;\n typedef const T& const_reference;\n\n typedef S32 difference_type;\n typedef U32 size_type;\n\n typedef difference_type (QSORT_CALLBACK *compare_func)(T *a, T *b);\n\n Vector& operator=(const Vector& p);\n\n S32 size() const;\n bool empty() const;\n\n T& front();\n const T& front() const;\n T& back();\n const T& back() const;\n\n void push_front(const T&);\n void push_back(const T&);\n void pop_front();\n void pop_back();\n\n T& operator[](U32);\n const T& operator[](U32) const;\n\n T& operator[](S32 i) { return operator[](U32(i)); }\n const T& operator[](S32 i ) const { return operator[](U32(i)); }\n\n void reserve(U32);\n\n /// @}\n\n /// @name VectorExtended Extended Interface\n ///\n /// @{\n\n ///\n U32 memSize() const;\n T* address() const;\n U32 setSize(U32);\n void insert(U32);\n void erase(U32);\n void erase_fast(U32);\n void clear();\n void compact();\n\n void sort(compare_func f);\n T& first();\n T& last();\n const T& first() const;\n const T& last() const;\n\n void set(void * addr, U32 sz);\n\n /// @}\n};\n\ntemplate inline Vector::~Vector()\n{\n destroy(0, mElementCount);\n free(mArray);\n}\n\ntemplate inline Vector::Vector(const U32 initialSize)\n{\n mArray = 0;\n mElementCount = 0;\n mArraySize = 0;\n if(initialSize)\n reserve(initialSize);\n}\n\ntemplate inline Vector::Vector(const Vector& p)\n{\n mArray = 0;\n mArraySize = 0;\n mElementCount = 0;\n\n checkSize(p.mElementCount);\n mElementCount = p.mElementCount;\n construct(0, p.mElementCount, p.mArray);\n}\n\n\ntemplate inline void Vector::destroy(U32 start, U32 end) // destroys from start to end-1\n{\n while(start < end)\n destructInPlace(&mArray[start++]);\n}\n\ntemplate inline void Vector::construct(U32 start, U32 end) // destroys from start to end-1\n{\n while(start < end)\n constructInPlace(&mArray[start++]);\n}\n\ntemplate inline void Vector::construct(U32 start, U32 end, const T* array) // destroys from start to end-1\n{\n while(start < end)\n {\n constructInPlace(&mArray[start], &array[start]);\n start++;\n }\n}\n\ntemplate inline T* Vector::address() const\n{\n return mArray;\n}\n\ntemplate inline U32 Vector::setSize(U32 size)\n{\n checkSize(size);\n\n if(size > mElementCount)\n {\n construct(mElementCount, size);\n mElementCount = size;\n }\n else if(size < mElementCount)\n {\n destroy(size, mElementCount);\n mElementCount = size;\n if(!mElementCount)\n {\n free(mArray);\n mArray = NULL;\n mArraySize = 0;\n }\n }\n return mElementCount;\n}\n\ntemplate inline void Vector::insert(U32 index)\n{\n checkSize(mElementCount + 1);\n constructInPlace(&mArray[mElementCount]);\n mElementCount++;\n\n for(U32 i = mElementCount - 1; i > index; i--)\n mArray[i] = mArray[i - 1];\n destructInPlace(&mArray[index]);\n constructInPlace(&mArray[index]);\n}\n\ntemplate inline void Vector::erase(U32 index)\n{\n // Assert: index >= 0 && index < mElementCount\n for(U32 i = index; i < mElementCount - 1; i++)\n mArray[i] = mArray[i+1];\n destructInPlace(&mArray[mElementCount - 1]);\n mElementCount--;\n}\n\ntemplate inline void Vector::erase_fast(U32 index)\n{\n // CAUTION: this operator does NOT maintain list order\n // Copy the last element into the deleted 'hole' and decrement the\n // size of the vector.\n // Assert: index >= 0 && index < mElementCount\n\n if(index != mElementCount - 1)\n mArray[index] = mArray[mElementCount - 1];\n destructInPlace(&mArray[mElementCount - 1]);\n mElementCount--;\n}\n\ntemplate inline T& Vector::first()\n{\n return mArray[0];\n}\n\ntemplate inline const T& Vector::first() const\n{\n return mArray[0];\n}\n\ntemplate inline T& Vector::last()\n{\n TNLAssert(mElementCount != 0, \"Error, no last element of a zero sized array!\");\n return mArray[mElementCount - 1];\n}\n\ntemplate inline const T& Vector::last() const\n{\n return mArray[mElementCount - 1];\n}\n\ntemplate inline void Vector::clear()\n{\n setSize(0);\n}\n\n//-----------------------------------------------------------------------------\n\ntemplate inline Vector& Vector::operator=(const Vector& p)\n{\n destroy(0, mElementCount);\n mElementCount = 0;\n checkSize(p.mElementCount);\n construct(0, p.mElementCount, p.mArray);\n mElementCount = p.mElementCount;\n return *this;\n}\n\ntemplate inline S32 Vector::size() const\n{\n return (S32)mElementCount;\n}\n\ntemplate inline bool Vector::empty() const\n{\n return (mElementCount == 0);\n}\n\ntemplate inline T& Vector::front()\n{\n return *begin();\n}\n\ntemplate inline const T& Vector::front() const\n{\n return *begin();\n}\n\ntemplate inline T& Vector::back()\n{\n return *end();\n}\n\ntemplate inline const T& Vector::back() const\n{\n return *end();\n}\n\ntemplate inline void Vector::push_front(const T &x)\n{\n insert(0);\n mArray[0] = x;\n}\n\ntemplate inline void Vector::push_back(const T &x)\n{\n checkSize(mElementCount + 1);\n mElementCount++;\n constructInPlace(mArray + mElementCount - 1, &x);\n}\n\ntemplate inline void Vector::pop_front()\n{\n erase(U32(0));\n}\n\ntemplate inline void Vector::pop_back()\n{\n mElementCount--;\n destructInPlace(mArray + mElementCount);\n}\n\ntemplate inline T& Vector::operator[](U32 index)\n{\n return mArray[index];\n}\n\ntemplate inline const T& Vector::operator[](U32 index) const\n{\n return mArray[index];\n}\n\ntemplate inline void Vector::reserve(U32 size)\n{\n checkSize(size);\n}\n\n//template inline void Vector::set(void * addr, U32 sz)\n//{\n// setSize(sz);\n// if (addr)\n// memcpy(address(),addr,sz*sizeof(T));\n//}\n\n//-----------------------------------------------------------------------------\n\ntemplate inline void Vector::checkSize(U32 newCount)\n{\n if(newCount <= mArraySize)\n return;\n\n U32 blk = VectorBlockSize - (newCount % VectorBlockSize);\n newCount += blk;\n\n T *newArray = (T *) malloc(sizeof(T) * newCount);\n T *oldArray = mArray;\n\n mArray = newArray;\n construct(0, mElementCount, oldArray);\n mArray = oldArray;\n destroy(0, mElementCount);\n free(oldArray);\n mArray = newArray;\n mArraySize = newCount;\n}\n\ntypedef int (QSORT_CALLBACK *qsort_compare_func)(const void *, const void *);\n\ntemplate inline void Vector::sort(compare_func f)\n{\n qsort(address(), size(), sizeof(T), (qsort_compare_func) f);\n}\n\n};\n\n#endif //_TNL_TVECTOR_H_\n\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pWorldSettings.h\"\r\n#include \"pLogger.h\"\r\n#include \"pConfig.h\"\r\n\r\n/*\r\nclass myLogConsumer : public xLogConsumer \r\n{\r\n\r\npublic:\r\n\tmyLogConsumer() : xLogConsumer()\r\n\t{\r\n\r\n\t}\r\n\r\n\tvoid logString(const char *string);\r\n};\r\n\r\nvoid myLogConsumer::logString(const char *string)\r\n{\r\n\txLogConsumer::logString(string);\r\n\r\n\tint test = 2;\r\n\ttest++;\r\n\r\n\r\n}\r\n\r\nmyLogConsumer pLogConsumer;\r\n*/\r\n\r\n#include \r\n\r\nint PhysicManager::initManager(int flags/* =0 */)\r\n{\r\n\txBitSet inFlags = flags;\r\n\txBitSet resultFlags = 0;\r\n\r\n\r\n\txAssertionEx::Instance();\r\n\tcustomizeAsserts();\r\n\t\r\n\t////////////////////////////////////////Load our physic default xml document : \r\n\tif (isFlagOn(inFlags,E_MFI_LOAD_CONFIG) && getDefaultConfig())\r\n\t{\r\n\t\tdelete m_DefaultDocument;\r\n\t\tm_DefaultDocument = NULL;\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Deleted old default config\");\r\n\t} \r\n\r\n\tif (isFlagOn(inFlags,E_MFI_LOAD_CONFIG))\r\n\t{\r\n\t\tTiXmlDocument * defaultDoc = loadDefaults(\"PhysicDefaults.xml\");\r\n\t\tif (!defaultDoc)\r\n\t\t{\r\n\t\t\t//enableFlag(resultFlags,E_MF_LOADING_DEFAULT_CONFIG_FAILED);\r\n\t\t\tenableFlag(_getManagerFlags(),E_MF_LOADING_DEFAULT_CONFIG_FAILED);\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Loading default config :PhysicDefaults.xml: failed\");\r\n\t\t\tsetDefaultConfig(NULL);\r\n\t\t}else\r\n\t\t{\r\n\t\t\tsetDefaultConfig(defaultDoc);\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\t////////////////////////////////////////////////////////////////////////////factory : \r\n\tif (isFlagOn(inFlags,E_MFI_CREATE_FACTORY))\r\n\t{\r\n\t\tif (getCurrentFactory())\r\n\t\t{\r\n\t\t\t\r\n\t\t\tgetCurrentFactory()->setPhysicSDK(getPhysicsSDK());\r\n\t\t\tenableFlag(_getManagerFlags(),E_MF_FACTORY_CREATED);\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Old factory updated\");\r\n\t\t}\r\n\t\tif (!getCurrentFactory())\r\n\t\t{\r\n\r\n\t\t\tpFactory *factory = new pFactory(this,getDefaultConfig());\r\n\t\t\tfactory->setPhysicSDK(getPhysicsSDK());\r\n\t\t\tenableFlag(_getManagerFlags(),E_MF_FACTORY_CREATED);\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"New factory created\");\r\n\t\t\tsetCurrentFactory(factory);\r\n\t\t}\r\n\t}\r\n\r\n\tif (getDefaultWorldSettings())\r\n\t{\r\n\t\tSAFE_DELETE(mDefaultWorldSettings);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//world settings :\r\n\tpWorldSettings *wSettings = pFactory::Instance()->createWorldSettings(XString(\"Default\"),getDefaultConfig());\r\n\tif (!wSettings)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Couldn't load default world settings!\");\r\n\t\twSettings = new pWorldSettings();\r\n\t}\r\n\r\n\tsetDefaultWorldSettings(wSettings);\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Default world settings created\");\r\n\r\n\r\n\t//////////////////////////////////////////default world : \r\n\tif (isFlagOn(_getManagerFlags(),E_MF_FACTORY_CREATED) &&\r\n\t\tgetDefaultWorldSettings() \t)\r\n\t{\r\n\t\tif (pFactory::Instance()->createDefaultWorld(\"pDefaultWorld\"))\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Default world created\");\r\n\t\t}\r\n\t\t//else \t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Creating default world failed\");\r\n\t}\r\n\t_RegisterDynamicParameters();\r\n\r\n\tint mask = resultFlags.getMask();\r\n\treturn mask;\r\n\r\n\r\n}\r\n\r\nint PhysicManager::initPhysicEngine(int flags /* = 0 */)\r\n{\r\n\r\n\tif (getPhysicsSDK())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Physic SDK already initiated! Releasing old SDK \");\r\n\t\tNxReleasePhysicsSDK(getPhysicsSDK());\r\n\t\tsetPhysicsSDK(NULL);\r\n\t}\r\n\r\n\tNxPhysicsSDKDesc desc;\r\n\tNxSDKCreateError errorCode = NXCE_NO_ERROR;\r\n\r\n\tpErrorStream* eStream = getLogger()->getErrorStream(); \r\n\tmPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL,(NxUserOutputStream*)eStream, desc, &errorCode);\r\n\tif(mPhysicsSDK == NULL) \r\n\t{\r\n\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_AGEIA,\"Physic SDK already initiated! Releasing old SDK \");\r\n\t\tenableFlag(_getManagerFlags(),E_MF_PSDK_FAILED);\r\n\t\treturn E_PE_AGEIA_ERROR;\r\n\t}\r\n\t\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Physic SDK initiated!\");\r\n\t\r\n\tif (getDefaultConfig())\r\n\t{\r\n\t\tpRemoteDebuggerSettings rSettings = pFactory::Instance()->createDebuggerSettings(getDefaultConfig());\r\n\r\n\t\tif (rSettings.enabled)\r\n\t\t{\r\n\t\t\tmPhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect(rSettings.mHost.CStr(),rSettings.port);\r\n\t\t\t\r\n\t\t\tif (!mPhysicsSDK->getFoundationSDK().getRemoteDebugger()->isConnected())\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"couldn't connect to remote debugger !\");\r\n\t\t\t}else \r\n\t\t\t{\r\n\r\n\t\t\t\tmRemoteDebugger = mPhysicsSDK->getFoundationSDK().getRemoteDebugger();\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\r\n\t/*mPhysicsSDK->setParameter(NX_VISUALIZATION_SCALE, 1);\r\n\tmPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);\r\n\tmPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 1);\r\n\tmPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, 1);\r\n*/\r\n\t\r\n\tsetPSDKParameters(getSDKParameters());\r\n\r\n\tpRemoteDebuggerSettings &dbgSetup = getRemoteDebuggerSettings();\r\n\tif (dbgSetup.enabled)\r\n\t{\r\n\r\n\t\tmPhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect(dbgSetup.mHost.CStr(),dbgSetup.port);\r\n\t\tif (!mPhysicsSDK->getFoundationSDK().getRemoteDebugger()->isConnected())\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"couldn't connect to remote debugger !\");\r\n\t\t}else \r\n\t\t{\r\n\r\n\t\t\tmRemoteDebugger = mPhysicsSDK->getFoundationSDK().getRemoteDebugger();\r\n\t\t}\r\n\t}\r\n\r\n\tenableFlag(_getManagerFlags(),E_MF_PSDK_LOADED);\r\n\treturn E_PE_OK;\r\n}\r\nint PhysicManager::performInitialization()\r\n{\r\n\r\n\tXString buffer;\r\n\r\n#ifdef DEMO_ONLY\r\n\r\n\tSYSTEMTIME sys;\r\n\r\n\tGetSystemTime(&sys);\r\n\r\n\tint dayd = sys.wDay;\r\n\tint monthd = sys.wMonth;\r\n\tint yeard = sys.wYear;\r\n\r\n\tif (!GetContext()->IsInInterfaceMode()){\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"sorry guy, just a demo !\");\r\n\t\tMessageBox(NULL,\"just a demo !!!\",\"tzzzz...\",0);\r\n\t\treturn E_PE_INVALID_OPERATION;\r\n\t}\r\n\tif ( yeard == 2009 )\r\n\t{\r\n\t\tif (monthd <=END_MONTH && monthd >=START_MONTH )\r\n\t\t{\r\n\t\t\tgoto init;\r\n\t\t}else goto expired;\r\n\t}else goto expired;\r\n\r\n\r\nexpired : \r\n\r\n\r\n\tbuffer << \"today is the \" << dayd << \" of \" << monthd << \"\\n\";\r\n\tbuffer << \"but this release only works until : \" << END_MONTH;\r\n\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,buffer.CStr());\r\n\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Demo expired!\");\r\n\treturn E_PE_INVALID_OPERATION;\r\n\r\n#endif\r\n\r\n\r\ninit:\r\n\r\n\r\n\r\n\r\n\txBitSet initFlags = 0 ;\r\n\tenableFlag(initFlags,E_MFI_LOAD_CONFIG);\r\n\tenableFlag(initFlags,E_MFI_CREATE_FACTORY);\r\n\tint error = initManager( initFlags.getMask());\r\n\tif (error == E_PE_INVALID_OPERATION )\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\r\n\tif (isFlagOff(_getManagerFlags(),E_MF_PSDK_LOADED))\r\n\t{\r\n\t\tif (initPhysicEngine()!= E_PE_OK )\r\n\t\t{\r\n\t\t\treturn E_MF_PSDK_FAILED;\r\n\t\t}\r\n\r\n\t\tenableFlag(initFlags,E_MFI_USE_XML_WORLD_SETTINGS);\r\n\t\tenableFlag(initFlags,E_MFI_CREATE_DEFAULT_WORLD);\r\n\r\n\r\n\t\tint error = initManager( initFlags.getMask());\r\n\t\tif (error != E_PE_OK )\r\n\t\t{\r\n xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't init manager\");\r\n\t\t\treturn E_PE_INVALID_OPERATION;\r\n\t\t}\r\n\t}\r\n\treturn E_PE_OK;\r\n}\r\n\r\nbool PhysicManager::isValid()\r\n{\r\n\treturn isFlagOn(_getManagerFlags(),E_MF_PSDK_LOADED) &&\r\n\t\tisFlagOn(_getManagerFlags(),E_MF_FACTORY_CREATED) &&\r\n\t\tgetDefaultWorldSettings() && getDefaultWorld();\r\n}\r\n\r\nvoid PhysicManager::_construct(xBitSet flags /* = 0 */)\r\n{\r\n\tmManagerFlags = 0 ;\r\n\tmPhysicsSDK = NULL;\r\n\tmLogger = NULL;\r\n\tmDefaultWorldSettings = NULL;\r\n\tm_DefaultDocument = NULL;\r\n\tm_currentFactory = NULL;\r\n\tm_DefaultDocument = NULL;\r\n\tm_currentFactory = NULL;\r\n\tm_DefaultWorld = NULL;\r\n\tmRemoteDebugger = NULL;\r\n\tmIParameter = NULL;\r\n\r\n\t\r\n\t\r\n\r\n\txLogger::GetInstance()->setVirtoolsContext(m_Context);\r\n\r\n\txLogger::GetInstance()->addLogItem(E_LI_AGEIA);\r\n\txLogger::GetInstance()->addLogItem(E_LI_MANAGER);\r\n\txLogger::GetInstance()->addLogItem(E_VSL);\r\n\txLogger::GetInstance()->addLogItem(E_BB);\r\n\r\n\txLogger::GetInstance()->addItemDescription(\"AGEIA\");\r\n\txLogger::GetInstance()->addItemDescription(\"MANAGER\");\r\n\txLogger::GetInstance()->addItemDescription(\"VSL\");\r\n\txLogger::GetInstance()->addItemDescription(\"BB\");\r\n\r\n\t\r\n\r\n\r\n\txLogger::GetInstance()->enableLoggingLevel(E_BB,ELOGERROR,1);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_BB,ELOGTRACE,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_BB,ELOGWARNING,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_BB,ELOGINFO,0);\r\n\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_AGEIA,ELOGERROR,1);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_AGEIA,ELOGTRACE,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_AGEIA,ELOGWARNING,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_AGEIA,ELOGINFO,0);\r\n\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGERROR,1);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGTRACE,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGWARNING,0);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGINFO,0);\r\n/*\r\n\t#ifdef CONSOLE_OUTPUT\r\n\txLogger::GetInstance()->Init();\r\n\t#endif \r\n*/\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Initiated\");\r\n\r\n\tif (!getLogger())\r\n\t{\r\n\t\tsetLogger(new pLogger());\r\n\t}\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n#include \"pVehicleAll.h\"\n\n\npPacejka::pPacejka()\n{\n // Initial vars\n a0=a1=a2=a3=a4=a5=a6=a7=a8=a9=a10=a111=a112=a12=a13=0;\n b0=b1=b2=b3=b4=b5=b6=b7=b8=b9=b10=0;\n c0=c1=c2=c3=c4=c5=c6=c7=c8=c9=c10=c11=c12=c13=c14=c15=c16=c17=0;\n \n camber=0;\n sideSlip=0;\n slipPercentage=0;\n Fz=0;\n \n // Output\n Fx=Fy=Mz=0;\n longStiffness=latStiffness=0;\n maxForce.Set(0,0,0);\n}\nvoid pPacejka::setToDefault()\n{\n\t\t//; Pacejka constants\r\n\t\t//Lateral coefficients\r\n\r\n\t\ta0=1.30000f;\r\n\t\ta1=-49.00f;\r\n\t\ta2=1216.00f;\r\n\t\ta3=1632.00f;\r\n\t\ta4=11.00f;\r\n\t\ta5=0.00600f;\r\n\t\ta6=-0.04000f;\r\n\t\ta7=-0.40000f;\r\n\t\ta8=0.00300f;\r\n\t\ta9=-0.00200f;\r\n\t\t\r\n\t\t//;a10=0.16000\r\n\r\n\t\ta10=0.f;\r\n\t\ta111=-11.00f;\r\n\t\ta112=0.04500;\r\n\t\ta12=0.00f;\r\n\t\ta13=0.0f;\r\n\t\t\r\n\t\t//;a13=-23.50000\r\n\t\t\r\n\t\t//; Longitudinal coefficients\r\n\t\tb0=1.57000f;\r\n\t\tb1=-48.00f;\r\n\t\tb2=1338.00f;\r\n\t\tb3=6.80000;\r\n\t\tb4=444.00f;\r\n\t\tb5=0.00f;\r\n\t\tb6=0.00340f;\r\n\t\tb7=-0.00800f;\r\n\t\tb8=0.66000f;\r\n\t\tb9=0.00f;\r\n\t\tb10=0.00f;\r\n\t\t\r\n\t\t//; Aligning moment coefficients\r\n\t\tc0=2.46000f;\r\n\t\tc1=-2.77000f;\r\n\t\tc2=-2.90000f;\r\n\t\tc3=0.00f;\r\n\t\tc4=-3.60000f;\r\n\t\tc5=-0.10000f;\r\n\t\tc6=0.00040f;\r\n\t\tc7=0.22000f;\r\n\t\tc8=-2.31000f;\r\n\t\tc9=3.87000f;\r\n\t\tc10=0.00070f;\r\n\t\tc11=-0.05000f;\r\n\t\tc12=-0.00600f;\r\n\t\tc13=0.33000f;\r\n\t\tc14=-0.04000f;\r\n\t\tc15=-0.40000f;\r\n\t\tc16=0.09200f;\r\n\t\tc17=0.01140f;\r\n\t\t\r\n\t\t//Statistical data (SR, SA in radians)\r\n\t\t/*optimal_slipratio=0.09655\r\n\t\toptimal_slipangle=0.18296\n\t\t*/\n\n}\npPacejka::~pPacejka()\n{\n}\n\n\n\n/**********\n* Physics *\n**********/\nvoid pPacejka::Calculate()\n{\n // Calculate long. force (and long. stiffness plus max long. force)\n Fx=CalcFx();\n // Calculate lateral force, cornering stiffness and max lateral force\n Fy=CalcFy();\n // Aligning moment (force feedback)\n Mz=CalcMz();\n}\n\nfloat pPacejka::CalcFx()\n// Calculates longitudinal force\n// From G. Genta's book, page 63\n// Note that the units are inconsistent:\n// Fz is in kN\n// slipRatio is in percentage (=slipRatio*100=slipPercentage)\n// camber and slipAngle are in degrees\n// Resulting forces are better defined:\n// Fx, Fy are in N\n// Mz is in Nm\n{\n float B,C,D,E;\n float Fx;\n float Sh,Sv;\n float uP;\n float FzSquared;\n\n // Calculate derived coefficients\n FzSquared=Fz*Fz;\n C=b0;\n uP=b1*Fz+b2;\n D=uP*Fz;\n \n // Avoid div by 0\n if((C>-D3_EPSILON&&C-D3_EPSILON&&D-D3_EPSILON&&C-D3_EPSILON&&D-D3_EPSILON&&a4-D3_EPSILON&&C-D3_EPSILON&&DGetFloat(buf);\n\tsprintf(buf,\"%s.a1\",path); a1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a2\",path); a2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a3\",path); a3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a4\",path); a4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a5\",path); a5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a6\",path); a6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a7\",path); a7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a8\",path); a8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a9\",path); a9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a10\",path); a10=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a111\",path); a111=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a112\",path); a112=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a13\",path); a13=info->GetFloat(buf);\n\n\t// Fy\n\tsprintf(buf,\"%s.b0\",path); b0=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b1\",path); b1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b2\",path); b2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b3\",path); b3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b4\",path); b4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b5\",path); b5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b6\",path); b6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b7\",path); b7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b8\",path); b8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b9\",path); b9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b10\",path); b10=info->GetFloat(buf);\n\n\t// Mz\n\tsprintf(buf,\"%s.c0\",path); c0=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c1\",path); c1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c2\",path); c2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c3\",path); c3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c4\",path); c4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c5\",path); c5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c6\",path); c6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c7\",path); c7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c8\",path); c8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c9\",path); c9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c10\",path); c10=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c11\",path); c11=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c12\",path); c12=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c13\",path); c13=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c14\",path); c14=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c15\",path); c15=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c16\",path); c16=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c17\",path); c17=info->GetFloat(buf);\n\n\treturn TRUE;\n}\n*/\n\n/**********\n* Physics *\n**********/\n/*\nbool pPacejka::Load(QInfo *info,cstring path)\n// Get parameters from a file\n{\n\tchar buf[128];\n\n\t// Fx\n\tsprintf(buf,\"%s.a0\",path); a0=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a1\",path); a1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a2\",path); a2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a3\",path); a3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a4\",path); a4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a5\",path); a5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a6\",path); a6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a7\",path); a7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a8\",path); a8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a9\",path); a9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a10\",path); a10=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a111\",path); a111=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a112\",path); a112=info->GetFloat(buf);\n\tsprintf(buf,\"%s.a13\",path); a13=info->GetFloat(buf);\n\n\t// Fy\n\tsprintf(buf,\"%s.b0\",path); b0=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b1\",path); b1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b2\",path); b2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b3\",path); b3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b4\",path); b4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b5\",path); b5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b6\",path); b6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b7\",path); b7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b8\",path); b8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b9\",path); b9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.b10\",path); b10=info->GetFloat(buf);\n\n\t// Mz\n\tsprintf(buf,\"%s.c0\",path); c0=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c1\",path); c1=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c2\",path); c2=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c3\",path); c3=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c4\",path); c4=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c5\",path); c5=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c6\",path); c6=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c7\",path); c7=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c8\",path); c8=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c9\",path); c9=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c10\",path); c10=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c11\",path); c11=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c12\",path); c12=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c13\",path); c13=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c14\",path); c14=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c15\",path); c15=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c16\",path); c16=info->GetFloat(buf);\n\tsprintf(buf,\"%s.c17\",path); c17=info->GetFloat(buf);\n\n\treturn TRUE;\n}\n*/#ifndef __XMATH_TOOLS_H__\r\n#define __XMATH_TOOLS_H__\r\n\r\n#include \"VxMath.h\"\r\n#include \"NxQuat.h\"\r\n\r\nnamespace pMath\r\n{\r\n\r\nVxVector getFromStream(NxVec3 source);\r\nVxQuaternion getFromStream(NxQuat source);\r\n\r\nNxVec3 getFromStream(VxVector source);\r\nNxQuat getFromStream(VxQuaternion source);\r\n\r\n\r\n\r\n\r\n/*__inline NxVec3 getFrom(const VxVector& sourcein)\r\n{\r\n\r\n\treturn NxVec3(sourcein.x,sourcein.y,sourcein.z);\r\n}*/\r\n\r\n__inline NxVec3 getFrom(VxVector source)\r\n{\r\n\tNxVec3 target(0.0f,0.0f,0.0f);\r\n\ttarget.x = source.x;\r\n\ttarget.y = source.y;\r\n\ttarget.z = source.z;\r\n\treturn NxVec3(source.x,source.y,source.z);\r\n}\r\n\r\nNxQuat getFrom(VxQuaternion source);\r\nVxQuaternion getFrom(NxQuat source);\r\n\r\n__inline VxVector getFrom(NxVec3 source)\r\n{\r\n\tVxVector result;\r\n\tsource.get(result.v);\r\n\treturn result;\r\n}\r\n\r\n}\r\n\r\n#endif\r\n#ifndef __XNEtWORK_TYPES_H_\r\n#define __XNEtWORK_TYPES_H_\r\n#include \r\n\r\n//#include \"CKAll.h\"\r\n#include \"tnl.h\"\r\n#include \"tnlTypes.h\"\r\n#include \"tnlVector.h\"\r\n\r\ntypedef unsigned int xTimeType;\r\n\r\nenum vtNetObjectType\r\n{\r\n\r\n\tUnknownType = BIT(0),\n\tShipType = BIT(1),\n\tBarrierType = BIT(2),\n\tMoveableType = BIT(3),\n\tType2D = BIT(5),\n\tType3D = BIT(5),\n\tResourceItemType = BIT(6),\n\tMineType = BIT(10),\n\tTestItemType = BIT(11),\n\tFlagType = BIT(12),\n\tDeletedType = BIT(30),\n\tMotionTriggerTypes= ShipType | ResourceItemType | TestItemType,\n\tAllObjectTypes = 0xFFFFFFFF,\r\n};\r\n#endif\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnl.h\"\n#include \"tnlNetBase.h\"\n#include \"tnlNetConnection.h\"\n#include \"tnlNetInterface.h\"\n#include \"tnlLog.h\"\n#include \"tnlRandom.h\"\n#include \"tnlSymmetricCipher.h\"\n#include \"tnlAsymmetricKey.h\"\n#include \"tnlConnectionStringTable.h\"\n\n#include \n\n\nnamespace TNL {\n\nNetConnectionRep *NetConnectionRep::mLinkedList = NULL;\n\nNetConnection *NetConnectionRep::create(const char *name)\n{\n for(NetConnectionRep *walk = mLinkedList; walk; walk = walk->mNext)\n if(walk->mCanRemoteCreate && !strcmp(name, walk->mClassRep->getClassName()))\n {\n Object *obj = walk->mClassRep->create();\n\t\t if (obj)\n\t\t {\n\n\t\t\t int op =9 ; \n\t\t\t int h = 2;\n\t\t }\n\t\t \n NetConnection *ret = dynamic_cast(obj);\n TNLAssert(ret != NULL, \"Invalid TNL_IMPLEMENT_NETCONNECTION\");\n if(!ret)\n delete obj;\n return ret;\n }\n\n return NULL;\n}\n\nstatic const char *packetTypeNames[] = \n{\n \"DataPacket\",\n \"PingPacket\",\n \"AckPacket\",\n};\n\n//-----------------------------------------------------------------\n\nNetConnection::NetConnection()\n{\n mInitialSendSeq = Random::readI();\n Random::read(mConnectionParameters.mNonce.data, Nonce::NonceSize);\n\n mSimulatedLatency = 0;\n mSimulatedPacketLoss = 0;\n\n mLastPacketRecvTime = 0;\n mLastUpdateTime = 0;\n mRoundTripTime = 0;\n mSendDelayCredit = 0;\n mConnectionState = NotConnected;\n \n mNotifyQueueHead = NULL;\n mNotifyQueueTail = NULL;\n \n mLocalRate.maxRecvBandwidth = DefaultFixedBandwidth;\n mLocalRate.maxSendBandwidth = DefaultFixedBandwidth;\n mLocalRate.minPacketRecvPeriod = DefaultFixedSendPeriod;\n mLocalRate.minPacketSendPeriod = DefaultFixedSendPeriod;\n\n mRemoteRate = mLocalRate;\n mLocalRateChanged = true;\n computeNegotiatedRate();\n\n mPingSendCount = 0;\n mLastPingSendTime = 0;\n\n mLastSeqRecvd = 0;\n mHighestAckedSeq = mInitialSendSeq;\n mLastSendSeq = mInitialSendSeq; // start sending at mInitialSendSeq + 1\n mAckMask[0] = 0;\n mLastRecvAckAck = 0;\n\n // Adaptive\n cwnd = 2;\n ssthresh = 30;\n mLastSeqRecvdAck = 0;\n\n mPingTimeout = DefaultPingTimeout;\n mPingRetryCount = DefaultPingRetryCount;\n mStringTable = NULL;\n}\n\nvoid NetConnection::setInitialRecvSequence(U32 sequence)\n{ \n mInitialRecvSeq = mLastSeqRecvd = mLastRecvAckAck = sequence;\n}\n\nvoid NetConnection::clearAllPacketNotifies()\n{\n while(mNotifyQueueHead)\n handleNotify(0, false);\n}\n\nNetConnection::~NetConnection()\n{\n clearAllPacketNotifies();\n delete mStringTable;\n\n TNLAssert(mNotifyQueueHead == NULL, \"Uncleared notifies remain.\");\n}\n\n//--------------------------------------------------------------------\nvoid NetConnection::setNetAddress(const Address &addr)\n{\n mNetAddress = addr;\n}\n\nconst Address &NetConnection::getNetAddress()\n{\n return mNetAddress;\n}\n\nNetConnection::PacketNotify::PacketNotify()\n{\n rateChanged = false;\n sendTime = 0;\n}\n\nbool NetConnection::checkTimeout(U32 time)\n{\n if(!isNetworkConnection())\n return false;\n\n if(!mLastPingSendTime)\n mLastPingSendTime = time;\n\n U32 timeout = mPingTimeout;\n U32 timeoutCount = mPingRetryCount;\n\n if(isAdaptive())\n {\n if(hasUnackedSentPackets())\n {\n timeout = AdaptiveUnackedSentPingTimeout;\n }\n else\n {\n timeoutCount = AdaptivePingRetryCount;\n if(!mPingSendCount)\n timeout = AdaptiveInitialPingTimeout;\n }\n }\n if((time - mLastPingSendTime) > timeout)\n {\n if(mPingSendCount >= timeoutCount)\n return true;\n mLastPingSendTime = time;\n mPingSendCount++;\n sendPingPacket();\n }\n return false;\n}\n\nvoid NetConnection::keepAlive()\n{\n mLastPingSendTime = 0;\n mPingSendCount = 0;\n}\n\n//--------------------------------------------------------------------\n\nchar NetConnection::mErrorBuffer[256];\n\nvoid NetConnection::setLastError(const char *fmt, ...)\n{\n va_list argptr;\n va_start(argptr, fmt);\n dVsprintf(mErrorBuffer, sizeof(mErrorBuffer), fmt, argptr);\n // setLastErrors assert in debug builds\n \n TNLAssert(0, mErrorBuffer);\n va_end(argptr);\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::writeRawPacket(BitStream *bstream, NetPacketType packetType)\n{\n writePacketHeader(bstream, packetType);\n if(packetType == DataPacket)\n {\n PacketNotify *note = allocNotify();\n if(!mNotifyQueueHead)\n mNotifyQueueHead = note;\n else\n mNotifyQueueTail->nextPacket = note;\n mNotifyQueueTail = note;\n note->nextPacket = NULL;\n note->sendTime = mInterface->getCurrentTime();\n\n writePacketRateInfo(bstream, note);\n S32 start = bstream->getBitPosition();\n bstream->setStringTable(mStringTable);\n\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: START %s\", mNetAddress.toString(), getClassName()) );\n writePacket(bstream, note);\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: END %s - %d bits\", mNetAddress.toString(), getClassName(), bstream->getBitPosition() - start) );\n }\n if(!mSymmetricCipher.isNull())\n {\n mSymmetricCipher->setupCounter(mLastSendSeq, mLastSeqRecvd, packetType, 0);\n bstream->hashAndEncrypt(MessageSignatureBytes, PacketHeaderByteSize, mSymmetricCipher);\n }\n}\n\nvoid NetConnection::readRawPacket(BitStream *bstream)\n{\n if(mSimulatedPacketLoss && Random::readF() < mSimulatedPacketLoss)\n {\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: RECVDROP - %d\", mNetAddress.toString(), getLastSendSequence()));\n return;\n }\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: RECV- %d bytes\", mNetAddress.toString(), bstream->getMaxReadBitPosition() >> 3));\n\n mErrorBuffer[0] = 0;\n if(readPacketHeader(bstream))\n {\n mLastPacketRecvTime = mInterface->getCurrentTime();\n\n readPacketRateInfo(bstream);\n bstream->setStringTable(mStringTable);\n readPacket(bstream);\n\n if(!bstream->isValid() && !mErrorBuffer[0])\n NetConnection::setLastError(\"Invalid Packet.\");\n if(mErrorBuffer[0])\n getInterface()->handleConnectionError(this, mErrorBuffer);\n mErrorBuffer[0] = 0;\n }\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::writePacketHeader(BitStream *stream, NetPacketType packetType)\n{\n if(windowFull() && packetType == DataPacket)\n TNL_DEBUGBREAK();\n\n S32 ackByteCount = ((mLastSeqRecvd - mLastRecvAckAck + 7) >> 3);\n TNLAssert(ackByteCount <= MaxAckByteCount, \"ackByteCount exceeds MaxAckByteCount!\");\n \n if(packetType == DataPacket)\n mLastSendSeq++;\n \n stream->writeInt(packetType, 2);\n stream->writeInt(mLastSendSeq, 5); // write the first 5 bits of the send sequence\n stream->writeFlag(true); // high bit of first byte indicates this is a data packet.\n stream->writeInt(mLastSendSeq >> 5, SequenceNumberBitSize - 5); // write the rest of the send sequence\n stream->writeInt(mLastSeqRecvd, AckSequenceNumberBitSize);\n stream->writeInt(0, PacketHeaderPadBits);\n\n stream->writeRangedU32(ackByteCount, 0, MaxAckByteCount);\n\n U32 wordCount = (ackByteCount + 3) >> 2;\n\n for(U32 i = 0; i < wordCount; i++)\n stream->writeInt(mAckMask[i], i == wordCount - 1 ?\n (ackByteCount - (i * 4)) * 8 : 32);\n\n U32 sendDelay = mInterface->getCurrentTime() - mLastPacketRecvTime;\n if(sendDelay > 2047)\n sendDelay = 2047;\n stream->writeInt(sendDelay >> 3, 8);\n\n // if we're resending this header, we can't advance the\n // sequence recieved (in case this packet drops and the prev one\n // goes through) \n\n if(packetType == DataPacket)\n mLastSeqRecvdAtSend[mLastSendSeq & PacketWindowMask] = mLastSeqRecvd;\n\n //if(isNetworkConnection())\n //{\n // TNLLogMessageV(LogBlah, (\"SND: mLSQ: %08x pkLS: %08x pt: %d abc: %d\",\n // mLastSendSeq, mLastSeqRecvd, packetType, ackByteCount));\n //}\n\n TNLLogMessageV(LogConnectionProtocol, (\"build hdr %d %d\", mLastSendSeq, packetType));\n}\n\nbool NetConnection::readPacketHeader(BitStream *pstream)\n{\n // read in the packet header:\n //\n // 2 bits packet type\n // low 5 bits of the packet sequence number\n // 1 bit game packet\n // SequenceNumberBitSize-5 bits (packet seq number >> 5)\n // AckSequenceNumberBitSize bits ackstart seq number\n // PacketHeaderPadBits = 0 - padding to byte boundary\n // after this point, if this is an encrypted packet, all the rest of the data will be encrypted\n\n // rangedU32 - 0...MaxAckByteCount\n //\n // type is:\n // 00 data packet\n // 01 ping packet\n // 02 ack packet\n \n // next 0...ackByteCount bytes are ack flags\n //\n // return value is true if this is a valid data packet\n // or false if there is nothing more that should be read\n\n U32 pkPacketType = pstream->readInt(2);\n U32 pkSequenceNumber = pstream->readInt(5);\n bool pkDataPacketFlg = pstream->readFlag();\n pkSequenceNumber = pkSequenceNumber | (pstream->readInt(SequenceNumberBitSize - 5) << 5);\n\n U32 pkHighestAck = pstream->readInt(AckSequenceNumberBitSize);\n U32 pkPadBits = pstream->readInt(PacketHeaderPadBits);\n\n if(pkPadBits != 0)\n return false;\n\n TNLAssert(pkDataPacketFlg, \"Invalid packet header in NetConnection::readPacketHeader!\");\n\n // verify packet ordering and acking and stuff\n // check if the 9-bit sequence is within the packet window\n // (within 31 packets of the last received sequence number).\n\n pkSequenceNumber |= (mLastSeqRecvd & SequenceNumberMask);\n // account for wrap around\n if(pkSequenceNumber < mLastSeqRecvd)\n pkSequenceNumber += SequenceNumberWindowSize;\n \n // in the following test, account for wrap around from 0\n if(pkSequenceNumber - mLastSeqRecvd > (MaxPacketWindowSize - 1))\n {\n // the sequence number is outside the window... must be out of order\n // discard.\n return false;\n }\n\n pkHighestAck |= (mHighestAckedSeq & AckSequenceNumberMask);\n // account for wrap around\n \n if(pkHighestAck < mHighestAckedSeq)\n pkHighestAck += AckSequenceNumberWindowSize;\n \n if(pkHighestAck > mLastSendSeq)\n {\n // the ack number is outside the window... must be an out of order\n // packet, discard.\n return false;\n }\n \n if(!mSymmetricCipher.isNull())\n {\n mSymmetricCipher->setupCounter(pkSequenceNumber, pkHighestAck, pkPacketType, 0);\n if(!pstream->decryptAndCheckHash(MessageSignatureBytes, PacketHeaderByteSize, mSymmetricCipher))\n {\n TNLLogMessage(LogNetConnection, \"Packet failed crypto\");\n return false;\n }\n }\n\n U32 pkAckByteCount = pstream->readRangedU32(0, MaxAckByteCount);\n if(pkAckByteCount > MaxAckByteCount || pkPacketType >= InvalidPacketType)\n return false;\n \n U32 pkAckMask[MaxAckMaskSize];\n U32 pkAckWordCount = (pkAckByteCount + 3) >> 2;\n\n for(U32 i = 0; i < pkAckWordCount; i++)\n pkAckMask[i] = pstream->readInt(i == pkAckWordCount - 1 ? \n (pkAckByteCount - (i * 4)) * 8 : 32);\n\n //if(isNetworkConnection())\n //{\n // TNLLogMessageV(LogBlah, (\"RCV: mHA: %08x pkHA: %08x mLSQ: %08x pkSN: %08x pkLS: %08x pkAM: %08x\",\n // mHighestAckedSeq, pkHighestAck, mLastSendSeq, pkSequenceNumber, mLastSeqRecvd, pkAckMask[0]));\n //}\n\n U32 pkSendDelay = (pstream->readInt(8) << 3) + 4;\n\n TNLLogBlock(LogConnectionProtocol,\n for(U32 i = mLastSeqRecvd+1; i < pkSequenceNumber; i++)\n logprintf (\"Not recv %d\", i);\n logprintf(\"Recv %d %s\", pkSequenceNumber, packetTypeNames[pkPacketType]);\n );\n\n // shift up the ack mask by the packet difference\n // this essentially nacks all the packets dropped\n\n U32 ackMaskShift = pkSequenceNumber - mLastSeqRecvd;\n\n // if we've missed more than a full word of packets, shift up by words\n while(ackMaskShift > 32)\n {\n for(S32 i = MaxAckMaskSize - 1; i > 0; i--)\n mAckMask[i] = mAckMask[i-1];\n mAckMask[0] = 0;\n ackMaskShift -= 32;\n }\n\n // the first word upshifts all NACKs, except for the low bit, which is a\n // 1 if this is a data packet (i.e. not a ping packet or an ack packet)\n U32 upShifted = (pkPacketType == DataPacket) ? 1 : 0; \n\n for(U32 i = 0; i < MaxAckMaskSize; i++)\n {\n U32 nextShift = mAckMask[i] >> (32 - ackMaskShift);\n mAckMask[i] = (mAckMask[i] << ackMaskShift) | upShifted;\n upShifted = nextShift;\n }\n\n // do all the notifies...\n U32 notifyCount = pkHighestAck - mHighestAckedSeq;\n for(U32 i = 0; i < notifyCount; i++) \n {\n U32 notifyIndex = mHighestAckedSeq + i + 1;\n\n U32 ackMaskBit = (pkHighestAck - notifyIndex) & 0x1F;\n U32 ackMaskWord = (pkHighestAck - notifyIndex) >> 5;\n\n bool packetTransmitSuccess = (pkAckMask[ackMaskWord] & (1 << ackMaskBit)) != 0;\n TNLLogMessageV(LogConnectionProtocol, (\"Ack %d %d\", notifyIndex, packetTransmitSuccess));\n\n mHighestAckedSendTime = 0;\n handleNotify(notifyIndex, packetTransmitSuccess);\n\n // Running average of roundTrip time\n if(mHighestAckedSendTime)\n {\n S32 roundTripDelta = mInterface->getCurrentTime() - (mHighestAckedSendTime + pkSendDelay);\n mRoundTripTime = mRoundTripTime * 0.9f + roundTripDelta * 0.1f;\n if(mRoundTripTime < 0)\n mRoundTripTime = 0;\n } \n if(packetTransmitSuccess)\n mLastRecvAckAck = mLastSeqRecvdAtSend[notifyIndex & PacketWindowMask];\n }\n // the other side knows more about its window than we do.\n if(pkSequenceNumber - mLastRecvAckAck > MaxPacketWindowSize)\n mLastRecvAckAck = pkSequenceNumber - MaxPacketWindowSize;\n \n mHighestAckedSeq = pkHighestAck;\n\n // first things first...\n // ackback any pings or half-full windows\n\n keepAlive(); // notification that the connection is ok\n\n U32 prevLastSequence = mLastSeqRecvd;\n mLastSeqRecvd = pkSequenceNumber;\n\n if(pkPacketType == PingPacket || (pkSequenceNumber - mLastRecvAckAck > (MaxPacketWindowSize >> 1)))\n {\n // send an ack to the other side\n // the ack will have the same packet sequence as our last sent packet\n // if the last packet we sent was the connection accepted packet\n // we must resend that packet\n sendAckPacket();\n }\n return prevLastSequence != pkSequenceNumber && pkPacketType == DataPacket;\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::writePacketRateInfo(BitStream *bstream, PacketNotify *note)\n{\n note->rateChanged = mLocalRateChanged;\n mLocalRateChanged = false;\n if(bstream->writeFlag(note->rateChanged))\n {\n if(!bstream->writeFlag(mTypeFlags.test(ConnectionAdaptive)))\n {\n bstream->writeRangedU32(mLocalRate.maxRecvBandwidth, 0, MaxFixedBandwidth);\n bstream->writeRangedU32(mLocalRate.maxSendBandwidth, 0, MaxFixedBandwidth);\n bstream->writeRangedU32(mLocalRate.minPacketRecvPeriod, 1, MaxFixedSendPeriod);\n bstream->writeRangedU32(mLocalRate.minPacketSendPeriod, 1, MaxFixedSendPeriod);\n }\n }\n}\n\nvoid NetConnection::readPacketRateInfo(BitStream *bstream)\n{\n if(bstream->readFlag())\n {\n if(bstream->readFlag())\n mTypeFlags.set(ConnectionRemoteAdaptive);\n else\n {\n mRemoteRate.maxRecvBandwidth = bstream->readRangedU32(0, MaxFixedBandwidth);\n mRemoteRate.maxSendBandwidth = bstream->readRangedU32(0, MaxFixedBandwidth);\n mRemoteRate.minPacketRecvPeriod = bstream->readRangedU32(1, MaxFixedSendPeriod);\n mRemoteRate.minPacketSendPeriod = bstream->readRangedU32(1, MaxFixedSendPeriod);\n computeNegotiatedRate();\n }\n }\n}\n\nvoid NetConnection::computeNegotiatedRate()\n{\n mCurrentPacketSendPeriod = getMax(mLocalRate.minPacketSendPeriod, mRemoteRate.minPacketRecvPeriod);\n\n U32 maxBandwidth = getMin(mLocalRate.maxSendBandwidth, mRemoteRate.maxRecvBandwidth);\n mCurrentPacketSendSize = U32(maxBandwidth * mCurrentPacketSendPeriod * 0.001f);\n\n // make sure we don't try to overwrite the maximum packet size\n if(mCurrentPacketSendSize > MaxPacketDataSize)\n mCurrentPacketSendSize = MaxPacketDataSize;\n}\n\nvoid NetConnection::setIsAdaptive()\n{\n mTypeFlags.set(ConnectionAdaptive);\n mLocalRateChanged = true;\n}\n\nvoid NetConnection::setFixedRateParameters(U32 minPacketSendPeriod, U32 minPacketRecvPeriod, U32 maxSendBandwidth, U32 maxRecvBandwidth)\n{\n mTypeFlags.clear(ConnectionAdaptive);\n\n mLocalRate.maxRecvBandwidth = maxRecvBandwidth;\n mLocalRate.maxSendBandwidth = maxSendBandwidth;\n mLocalRate.minPacketRecvPeriod = minPacketRecvPeriod;\n mLocalRate.minPacketSendPeriod = minPacketSendPeriod;\n mLocalRateChanged = true;\n computeNegotiatedRate();\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::sendPingPacket()\n{\n PacketStream ps;\n writeRawPacket(&ps, PingPacket);\n TNLLogMessageV(LogConnectionProtocol, (\"send ping %d\", mLastSendSeq));\n\n sendPacket(&ps);\n}\n\nvoid NetConnection::sendAckPacket()\n{\n PacketStream ps;\n writeRawPacket(&ps, AckPacket);\n TNLLogMessageV(LogConnectionProtocol, (\"send ack %d\", mLastSendSeq));\n\n sendPacket(&ps);\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::handleNotify(U32 sequence, bool recvd)\n{\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: NOTIFY %d %s\", mNetAddress.toString(), sequence, recvd ? \"RECVD\" : \"DROPPED\"));\n\n PacketNotify *note = mNotifyQueueHead;\n TNLAssert(note != NULL, \"Error: got a notify with a null notify head.\");\n mNotifyQueueHead = mNotifyQueueHead->nextPacket;\n\n if(note->rateChanged && !recvd)\n mLocalRateChanged = true;\n\n if(recvd)\n {\n mHighestAckedSendTime = note->sendTime;\n\n if(isAdaptive())\n {\n // Deal with updating our cwnd and ssthresh...\n if(cwnd < ssthresh)\n {\n // Slow start strategy\n cwnd++;\n TNLLogMessageV(LogNetConnection, (\"PKT SSOK - ssthresh = %f cwnd=%f\", ssthresh, cwnd));\n\n } else {\n // We are in normal state..\n if(cwnd < MaxPacketWindowSize-2)\n cwnd += 1/cwnd;\n\n TNLLogMessageV(LogNetConnection, (\"PKT OK - ssthresh = %f cwnd=%f\", ssthresh, cwnd));\n\n }\n }\n\n packetReceived(note);\n }\n else\n {\n if(isAdaptive())\n {\n // Deal with updating our cwnd and ssthresh...\n ssthresh = (0.5f * ssthresh < 2) ? 2 : (0.5f * ssthresh);\n cwnd -= 1;\n if(cwnd < 2) cwnd = 2;\n\n/* TNLLogMessageV(LogNetConnection, (\" * ack=%f pktDt=%d time=%f (%d) seq=%d %d %d %d\",\n ack,\n ackDelta,\n deltaT / 1000.0f,\n deltaT,\n mLastSeqRecvd,\n mLastRecvAckAck,\n mLastSeqRecvdAck,\n mHighestAckedSeq\n )); */\n\n }\n\n packetDropped(note);\n }\n delete note;\n}\n\n//--------------------------------------------------------------------\n\nvoid NetConnection::checkPacketSend(bool force, U32 curTime)\n{\n U32 delay = mCurrentPacketSendPeriod;\n\n if(!force)\n {\n if(!isAdaptive())\n {\n if(curTime - mLastUpdateTime + mSendDelayCredit < delay)\n return;\n \n mSendDelayCredit = curTime - (mLastUpdateTime + delay - mSendDelayCredit);\n if(mSendDelayCredit > 1000)\n mSendDelayCredit = 1000;\n }\n }\n prepareWritePacket();\n if(windowFull() || !isDataToTransmit())\n {\n // there is nothing to transmit, or the window is full\n if(isAdaptive())\n {\n // Still, on an adaptive connection, we may need to send an ack here...\n\n // Check if we should ack. We use a heuristic to do this. (fuzzy logic!)\n S32 ackDelta = (mLastSeqRecvd - mLastSeqRecvdAck);\n F32 ack = ackDelta / 4.0f;\n\n // Multiply by the time since we've acked...\n // If we're much below 200, we don't want to ack; if we're much over we do.\n U32 deltaT = (curTime - mLastAckTime);\n ack = ack * deltaT / 200.0f;\n\n if((ack > 1.0f || (ackDelta > (0.75*MaxPacketWindowSize))) && (mLastSeqRecvdAck != mLastSeqRecvd))\n { \n mLastSeqRecvdAck = mLastSeqRecvd;\n mLastAckTime = curTime;\n sendAckPacket();\n }\n }\n return;\n }\n PacketStream stream(mCurrentPacketSendSize);\n mLastUpdateTime = curTime;\n\n writeRawPacket(&stream, DataPacket); \n\n sendPacket(&stream);\n}\n\nbool NetConnection::windowFull()\n{\n if(mLastSendSeq - mHighestAckedSeq >= (MaxPacketWindowSize - 2))\n return true;\n if(isAdaptive())\n return mLastSendSeq - mHighestAckedSeq >= cwnd;\n return false;\n}\n\nNetError NetConnection::sendPacket(BitStream *stream)\n{\n if(mSimulatedPacketLoss && Random::readF() < mSimulatedPacketLoss)\n {\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: SENDDROP - %d\", mNetAddress.toString(), getLastSendSequence()));\n return NoError;\n }\n\n TNLLogMessageV(LogNetConnection, (\"NetConnection %s: SEND - %d bytes\", mNetAddress.toString(), stream->getBytePosition()));\n\n // do nothing on send if this is a demo replay.\n if(isLocalConnection())\n {\n // short circuit connection to the other side.\n // handle the packet, then force a notify.\n U32 size = stream->getBytePosition();\n\n stream->reset();\n stream->setMaxSizes(size, 0);\n \n mRemoteConnection->readRawPacket(stream);\n return NoError;\n }\n else\n {\n if(mSimulatedLatency)\n {\n mInterface->sendtoDelayed(getNetAddress(), stream, mSimulatedLatency);\n return NoError;\n }\n else\n return mInterface->sendto(getNetAddress(), stream);\n }\n}\n\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n\n// these are the virtual function defs for Connection -\n// if your subclass has additional data to read / write / notify, add it in these functions.\n\nvoid NetConnection::readPacket(BitStream *bstream)\n{\n}\n\nvoid NetConnection::prepareWritePacket()\n{\n}\n\nvoid NetConnection::writePacket(BitStream *bstream, PacketNotify *note)\n{\n}\n\nvoid NetConnection::packetReceived(PacketNotify *note)\n{\n if(mStringTable)\n mStringTable->packetReceived(&note->stringList);\n}\n\nvoid NetConnection::packetDropped(PacketNotify *note)\n{\n if(mStringTable)\n mStringTable->packetDropped(&note->stringList);\n\n}\n\n//----------------------------------------------------------------------------\n//----------------------------------------------------------------------------\nvoid NetConnection::setTranslatesStrings()\n{\n if(!mStringTable) \n mStringTable = new ConnectionStringTable(this);\n}\n\nvoid NetConnection::setInterface(NetInterface *myInterface)\n{\n mInterface = myInterface;\n}\n\nNetInterface *NetConnection::getInterface()\n{\n return mInterface;\n}\n\nvoid NetConnection::setSymmetricCipher(SymmetricCipher *theCipher)\n{\n mSymmetricCipher = theCipher;\n}\n\nvoid NetConnection::connect(NetInterface *theInterface, const Address &address, bool requestKeyExchange, bool requestCertificate)\n{\n mConnectionParameters.mRequestKeyExchange = requestKeyExchange;\n mConnectionParameters.mRequestCertificate = requestCertificate;\n mConnectionParameters.mIsInitiator = true;\n\n setNetAddress(address);\n setInterface(theInterface);\n mInterface->startConnection(this);\n}\n\nvoid NetConnection::connectArranged(NetInterface *connectionInterface, const Vector
&possibleAddresses, Nonce &nonce, Nonce &serverNonce, ByteBufferPtr sharedSecret, bool isInitiator, bool requestsKeyExchange, bool requestsCertificate)\n{\n mConnectionParameters.mRequestKeyExchange = requestsKeyExchange;\n mConnectionParameters.mRequestCertificate = requestsCertificate;\n mConnectionParameters.mPossibleAddresses = possibleAddresses;\n mConnectionParameters.mIsInitiator = isInitiator;\n mConnectionParameters.mIsArranged = true;\n mConnectionParameters.mNonce = nonce;\n mConnectionParameters.mServerNonce = serverNonce;\n mConnectionParameters.mArrangedSecret = sharedSecret;\n mConnectionParameters.mArrangedSecret->takeOwnership();\n\n setInterface(connectionInterface);\n mInterface->startArrangedConnection(this); \n}\n\nvoid NetConnection::disconnect(const char *reason)\n{\n mInterface->disconnect(this, ReasonSelfDisconnect, reason);\n}\n\nvoid NetConnection::onConnectionEstablished()\n{\n if(isInitiator())\n setIsConnectionToServer();\n else\n setIsConnectionToClient();\n}\n\nvoid NetConnection::onConnectionTerminated(TerminationReason, const char *)\n{\n}\n\nvoid NetConnection::onConnectTerminated(TerminationReason, const char *)\n{\n}\n\nvoid NetConnection::writeConnectRequest(BitStream *stream)\n{\n stream->write(U32(getNetClassGroup()));\n stream->write(U32(NetClassRep::getClassGroupCRC(getNetClassGroup())));\n}\n\nbool NetConnection::readConnectRequest(BitStream *stream, const char **errorString)\n{\n U32 classGroup, classCRC;\n stream->read(&classGroup);\n stream->read(&classCRC);\n\n if(classGroup == getNetClassGroup() && classCRC == NetClassRep::getClassGroupCRC(getNetClassGroup()))\n return true;\n\n *errorString = \"CHR_INVALID\";\n return false;\n}\n\nvoid NetConnection::writeConnectAccept(BitStream *stream)\n{\n stream;\n}\n\nbool NetConnection::readConnectAccept(BitStream *stream, const char **errorString)\n{\n stream;\n errorString;\n return true;\n}\n\nbool NetConnection::connectLocal(NetInterface *connectionInterface, NetInterface *serverInterface)\n{\n Object *co = Object::create(getClassName());\n NetConnection *client = this;\n NetConnection *server = dynamic_cast(co);\n const char *error = NULL;\n PacketStream stream;\n\n if(!server)\n\t goto errorOut;\n\n client->setInterface(connectionInterface);\n client->getConnectionParameters().mIsInitiator = true;\n client->getConnectionParameters().mIsLocal = true;\n server->getConnectionParameters().mIsLocal = true;\n\n server->setInterface(serverInterface);\n\n server->setInitialRecvSequence(client->getInitialSendSequence());\n client->setInitialRecvSequence(server->getInitialSendSequence());\n client->setRemoteConnectionObject(server);\n server->setRemoteConnectionObject(client);\n\n stream.setBytePosition(0);\n client->writeConnectRequest(&stream);\n stream.setBytePosition(0);\n if(!server->readConnectRequest(&stream, &error))\n goto errorOut;\n\n stream.setBytePosition(0);\n server->writeConnectAccept(&stream);\n stream.setBytePosition(0);\n\n if(!client->readConnectAccept(&stream, &error))\n goto errorOut;\n\n client->setConnectionState(NetConnection::Connected);\n server->setConnectionState(NetConnection::Connected);\n\n client->onConnectionEstablished();\n server->onConnectionEstablished();\n connectionInterface->addConnection(client);\n serverInterface->addConnection(server);\n return true;\nerrorOut:\n delete server;\n return false;\n}\n\n};\nusing System;\r\nusing System.Drawing;\r\nusing System.Collections;\r\nusing System.ComponentModel;\r\nusing System.Windows.Forms;\r\nusing System.Data;\r\n\r\n\r\nnamespace WindowsApplication\r\n{\r\n /// \r\n /// Summary description for Form1.\r\n /// \r\n public class Form1 : System.Windows.Forms.Form\r\n {\r\n /// \r\n /// Required designer variable.\r\n /// \r\n private System.ComponentModel.Container components = null;\r\n\r\n public void CreateVTWindow(IntPtr win)\r\n {\r\n\r\n\r\n vtWin = new vtWindow();\r\n SWIGTYPE_p_long l = new SWIGTYPE_p_long(win, true);\r\n vtWin.CreateAsChild(l);\r\n\r\n\r\n }\r\n\r\n\r\n protected override void OnClosing(CancelEventArgs e)\r\n {\r\n base.OnClosing(e);\r\n if (vtWin != null)\r\n {\r\n vtWin.Terminate(0);\r\n }\r\n }\r\n\r\n //private System.Windows.Forms.Panel panel1;\r\n private System.Windows.Forms.Button sendmessage;\r\n\r\n private runme.vtPanel panel1;\r\n //some temp test values for messaging : \r\n private int m_intMTest = 0;\r\n private float m_floatMTest = 0;\r\n private String m_strMTest = \"\";\r\n\r\n public int startWidth = 400;\r\n public int startHeight = 300;\r\n\r\n private System.Windows.Forms.Button sendMsgFloat;\r\n private System.Windows.Forms.Button sendMsgStr;\r\n public System.Windows.Forms.RichTextBox richTextBox1;\r\n private System.Windows.Forms.Button CheckVirtoolsMsgBtn;\r\n private System.Windows.Forms.Button Resize;\r\n private System.Windows.Forms.Button PauseBtn;\r\n private System.Windows.Forms.Button PlayBtn;\r\n\r\n\r\n public vtWindow vtWin = null;\r\n public vtWindow VtWin\r\n {\r\n get { return vtWin; }\r\n set { vtWin = value; }\r\n }\r\n\r\n public Form1()\r\n {\r\n\r\n InitializeComponent();\r\n this.SuspendLayout();\r\n\r\n //we init our player, be aware about \"OwnerDrawed\" entry in the player.ini!\r\n //you must set this to 1, otherwise its not correct displayed in this form !\r\n CreateVTWindow(panel1.Handle);\r\n panel1.Init(this, vtWin);\r\n\r\n\r\n //we retrieve the players render bounds : \r\n int playerWidth = vtWin.GetWidth();\r\n int playerHeight = vtWin.GetHeight();\r\n\r\n\r\n\r\n // and we re-adjust our panel ! \r\n\r\n //this.panel1.Size = new System.Drawing.Size(playerWidth, playerHeight);\r\n\r\n vtWin.Run();\r\n\r\n //System.Threading.Thread.Sleep(100);\r\n\r\n vtWin.UpdateRenderSize(playerWidth, playerHeight);\r\n\r\n this.PerformLayout();\r\n\r\n\r\n\r\n\r\n\r\n }\r\n\r\n /// \r\n /// Clean up any resources being used.\r\n /// \r\n protected override void Dispose(bool disposing)\r\n {\r\n if (disposing)\r\n {\r\n if (components != null)\r\n {\r\n components.Dispose();\r\n }\r\n }\r\n base.Dispose(disposing);\r\n }\r\n\r\n #region Windows Form Designer generated code\r\n /// \r\n /// Required method for Designer support - do not modify\r\n /// the contents of this method with the code editor.\r\n /// \r\n private void InitializeComponent()\r\n {\r\n this.panel1 = new runme.vtPanel();\r\n this.sendmessage = new System.Windows.Forms.Button();\r\n this.sendMsgFloat = new System.Windows.Forms.Button();\r\n this.sendMsgStr = new System.Windows.Forms.Button();\r\n this.richTextBox1 = new System.Windows.Forms.RichTextBox();\r\n this.CheckVirtoolsMsgBtn = new System.Windows.Forms.Button();\r\n this.Resize = new System.Windows.Forms.Button();\r\n this.PauseBtn = new System.Windows.Forms.Button();\r\n this.PlayBtn = new System.Windows.Forms.Button();\r\n this.SuspendLayout();\r\n // \r\n // panel1\r\n // \r\n this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;\r\n this.panel1.Location = new System.Drawing.Point(344, 8);\r\n this.panel1.Name = \"panel1\";\r\n this.panel1.Size = new System.Drawing.Size(400, 300);\r\n this.panel1.TabIndex = 0;\r\n // \r\n // sendmessage\r\n // \r\n this.sendmessage.Location = new System.Drawing.Point(8, 8);\r\n this.sendmessage.Name = \"sendmessage\";\r\n this.sendmessage.Size = new System.Drawing.Size(96, 24);\r\n this.sendmessage.TabIndex = 1;\r\n this.sendmessage.Text = \"sendmessageInt\";\r\n this.sendmessage.Click += new System.EventHandler(this.sendmessage_Click);\r\n // \r\n // sendMsgFloat\r\n // \r\n this.sendMsgFloat.Location = new System.Drawing.Point(8, 40);\r\n this.sendMsgFloat.Name = \"sendMsgFloat\";\r\n this.sendMsgFloat.Size = new System.Drawing.Size(96, 24);\r\n this.sendMsgFloat.TabIndex = 2;\r\n this.sendMsgFloat.Text = \"sendMsgFloat\";\r\n this.sendMsgFloat.Click += new System.EventHandler(this.sendMsgFloat_Click);\r\n // \r\n // sendMsgStr\r\n // \r\n this.sendMsgStr.Location = new System.Drawing.Point(8, 72);\r\n this.sendMsgStr.Name = \"sendMsgStr\";\r\n this.sendMsgStr.Size = new System.Drawing.Size(96, 24);\r\n this.sendMsgStr.TabIndex = 3;\r\n this.sendMsgStr.Text = \"sendMsgStr\";\r\n this.sendMsgStr.Click += new System.EventHandler(this.sendMsgStr_Click);\r\n // \r\n // richTextBox1\r\n // \r\n this.richTextBox1.Location = new System.Drawing.Point(8, 144);\r\n this.richTextBox1.Name = \"richTextBox1\";\r\n this.richTextBox1.Size = new System.Drawing.Size(320, 160);\r\n this.richTextBox1.TabIndex = 4;\r\n this.richTextBox1.Text = \"playerout\";\r\n // \r\n // CheckVirtoolsMsgBtn\r\n // \r\n this.CheckVirtoolsMsgBtn.Location = new System.Drawing.Point(120, 8);\r\n this.CheckVirtoolsMsgBtn.Name = \"CheckVirtoolsMsgBtn\";\r\n this.CheckVirtoolsMsgBtn.Size = new System.Drawing.Size(120, 24);\r\n this.CheckVirtoolsMsgBtn.TabIndex = 5;\r\n this.CheckVirtoolsMsgBtn.Text = \"CheckVirtoolsMsg\";\r\n this.CheckVirtoolsMsgBtn.Click += new System.EventHandler(this.button1_Click);\r\n // \r\n // Resize\r\n // \r\n this.Resize.Location = new System.Drawing.Point(120, 40);\r\n this.Resize.Name = \"Resize\";\r\n this.Resize.Size = new System.Drawing.Size(120, 24);\r\n this.Resize.TabIndex = 6;\r\n this.Resize.Text = \"Resize\";\r\n this.Resize.Click += new System.EventHandler(this.Resize_Click);\r\n // \r\n // PauseBtn\r\n // \r\n this.PauseBtn.Location = new System.Drawing.Point(120, 72);\r\n this.PauseBtn.Name = \"PauseBtn\";\r\n this.PauseBtn.Size = new System.Drawing.Size(48, 24);\r\n this.PauseBtn.TabIndex = 7;\r\n this.PauseBtn.Text = \"Pause\";\r\n this.PauseBtn.Click += new System.EventHandler(this.PauseBtn_Click);\r\n // \r\n // PlayBtn\r\n // \r\n this.PlayBtn.Location = new System.Drawing.Point(176, 72);\r\n this.PlayBtn.Name = \"PlayBtn\";\r\n this.PlayBtn.Size = new System.Drawing.Size(40, 24);\r\n this.PlayBtn.TabIndex = 8;\r\n this.PlayBtn.Text = \"Play\";\r\n this.PlayBtn.Click += new System.EventHandler(this.PlayBtn_Click);\r\n // \r\n // Form1\r\n // \r\n this.AutoScale = false;\r\n this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);\r\n this.ClientSize = new System.Drawing.Size(768, 325);\r\n this.Controls.Add(this.PlayBtn);\r\n this.Controls.Add(this.PauseBtn);\r\n this.Controls.Add(this.Resize);\r\n this.Controls.Add(this.CheckVirtoolsMsgBtn);\r\n this.Controls.Add(this.richTextBox1);\r\n this.Controls.Add(this.sendMsgStr);\r\n this.Controls.Add(this.sendMsgFloat);\r\n this.Controls.Add(this.sendmessage);\r\n this.Controls.Add(this.panel1);\r\n this.Name = \"Form1\";\r\n this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r\n this.Text = \"Form1\";\r\n this.ResumeLayout(false);\r\n\r\n }\r\n #endregion\r\n /// \r\n /// The main entry point for the application.\r\n /// \r\n /// \r\n [STAThread]\r\n static void Main()\r\n {\r\n Application.Run(new Form1());\r\n }\r\n\r\n\r\n /*\r\n protected override void WndProc(ref Message m)\r\n {\r\n base.WndProc(ref m);\r\n if (vtWin!=null)\n {\r\n SWIGTYPE_p_long win = new SWIGTYPE_p_long(m.HWnd,true);\r\n SWIGTYPE_p_long wp = new SWIGTYPE_p_long(m.WParam,true);\r\n\r\n\r\n SWIGTYPE_p_long lp = new SWIGTYPE_p_long(m.LParam ,true);\r\n\r\n vtWin.WndProc(win,m.Msg,wp,lp);\r\n\r\n }\r\n }*/\r\n private void sendmessage_Click(object sender, System.EventArgs e)\r\n {\r\n\r\n if (vtWin != null)\r\n {\r\n\r\n //we send a message to our player : \r\n\r\n //when the player could'nt found the object by this name, then it sends\r\n //a broadcast message !\r\n\r\n\r\n String objectName = \"masterDummy\";\r\n\r\n //this message name should exist inside vt !\r\n String messageName = \"csharp\";\r\n\r\n\r\n //the function takes 3 reserved parameters. you can do what ever you want with it\r\n int id0 = 0;\r\n int id1 = 1;\r\n int id2 = 2;\r\n m_intMTest++;\r\n vtWin.SendMessage(objectName, messageName, id0, id1, id2, m_intMTest);\r\n\r\n //inside vt you only have to attach a MessageWaiter to the object and also \r\n //a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n // int,int,int,int in this case here !\r\n }\r\n }\r\n\r\n private void sendMsgFloat_Click(object sender, System.EventArgs e)\r\n {\r\n\r\n if (vtWin != null)\r\n {\r\n //we send a message to our player : \r\n\r\n //when the player could'nt found the object by this name, then it sends\r\n //a broadcast message !\r\n String objectName = \"masterDummy\";\r\n\r\n //this message name should exist inside vt !\r\n String messageName = \"csharpFloat\";\r\n\r\n //the function takes 3 reserved parameters. you can do what ever you want with it\r\n int id0 = 0;\r\n int id1 = 1;\r\n int id2 = 2;\r\n m_floatMTest += 0.23f;\r\n vtWin.SendMessage(objectName, messageName, id0, id1, id2, m_floatMTest);\r\n\r\n\r\n //inside vt you only have to attach a MessageWaiter to the object and also \r\n //a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n // int,int,int,int in this case here !\r\n }\r\n }\r\n\r\n private void sendMsgStr_Click(object sender, System.EventArgs e)\r\n {\r\n if (vtWin != null)\r\n {\r\n //we send a message to our player : \r\n\r\n //when the player could'nt found the object by this name, then it sends\r\n //a broadcast message !\r\n String objectName = \"masterDummy\";\r\n\r\n //this message name should exist inside vt !\r\n String messageName = \"csharpString\";\r\n\r\n //the function takes 3 reserved parameters. you can do what ever you want with it\r\n int id0 = 0;\r\n int id1 = 1;\r\n int id2 = 2;\r\n m_strMTest += \"asdasd\";\r\n vtWin.SendMessage(objectName, messageName, id0, id1, id2, m_strMTest);\r\n //inside vt you only have to attach a MessageWaiter to the object and also \r\n //a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n // int,int,int,int in this case here !\r\n }\r\n }\r\n\r\n\r\n //check vtWin for new messages : \r\n private void button1_Click(object sender, System.EventArgs e)\r\n {\r\n if (vtWin.HasMessages() == 1)\r\n {\r\n String console = richTextBox1.Text;\r\n\r\n for (int nbMsg = 0; nbMsg < vtWin.GetNumMessages(); nbMsg++)\r\n {\r\n console += \"\\n message recieved : \" + nbMsg + \" name : \" + vtWin.GetMessageName(nbMsg);\r\n for (int nbPar = 0; nbPar < vtWin.GetNumParameters(nbMsg); nbPar++)\r\n {\r\n int parType = vtWin.GetMessageParameterType(nbMsg, nbPar);\r\n switch (parType)\r\n {\r\n //string : \r\n case 1:\r\n {\r\n String value = vtWin.GetMessageValueStr(nbMsg, nbPar);\r\n console += \"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg, nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n //float :\r\n case 2:\r\n {\r\n float value = vtWin.GetMessageValueFloat(nbMsg, nbPar);\r\n console += \"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg, nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n //integer :\r\n case 3:\r\n {\r\n int value = vtWin.GetMessageValueInt(nbMsg, nbPar);\r\n console += \"\\n\\t parameter attached : \" + nbPar + \" : type : \" + vtWin.GetMessageParameterType(nbMsg, nbPar) + \" value : \" + value;\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //vtWin.DeleteMessage(0);\t//cleans incoming message by index\r\n\r\n vtWin.CleanMessages();\t// pop everything !\r\n richTextBox1.Text = console;\r\n }\r\n\r\n }\r\n\r\n private void Resize_Click(object sender, System.EventArgs e)\r\n {\r\n\r\n if (vtWin != null)\r\n {\r\n\r\n vtWin.Pause();\r\n System.Threading.Thread.Sleep(50);\r\n this.SuspendLayout();\r\n\r\n if (startWidth == 400)\r\n {\r\n startWidth = 640;\r\n startHeight = 480;\r\n }\r\n else\r\n {\r\n\r\n startWidth = 400;\r\n startHeight = 300;\r\n }\r\n\r\n //just a test\r\n this.panel1.Size = new System.Drawing.Size(startWidth, startHeight);\r\n\r\n vtWin.UpdateRenderSize(startWidth, startHeight);\r\n System.Threading.Thread.Sleep(2);\r\n vtWin.Play();\r\n System.Threading.Thread.Sleep(2);\r\n this.PerformLayout();\r\n\r\n\r\n }\r\n }\r\n\r\n private void PauseBtn_Click(object sender, System.EventArgs e)\r\n {\r\n\r\n if (vtWin != null)\r\n {\r\n vtWin.Pause();\r\n }\r\n }\r\n\r\n private void PlayBtn_Click(object sender, System.EventArgs e)\r\n {\r\n\r\n if (vtWin != null)\r\n {\r\n vtWin.Play();\r\n }\r\n }\r\n\r\n }\r\n}/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t CameraColorFilter\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorCameraColorFilterDecl();\r\nCKERROR CreateCameraColorFilterProto(CKBehaviorPrototype **pproto);\r\nint CameraColorFilter(const CKBehaviorContext& behcontext);\r\nvoid CameraColorFilterRender(CKRenderContext *rc, void *arg);\r\n\r\nCKObjectDeclaration\t*FillBehaviorCameraColorFilterDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Camera Color Filter\");\t\r\n\tod->SetDescription(\"Adds a color filter to the Camera.\");\r\n\t/* rem:\r\n\tOn: activates the process.
\r\n\tOff: deactivates the process.
\r\n\t
\r\n\tExit On: is activated when the building block has been activated by \"On\".
\r\n\tExit Off: is activated when the building block has been activated by \"Off\".
\r\n\t
\r\n\tFilter Color: color of the filter in RGBA.
\r\n\tDensity: how dense the filter should be, in percent.
\r\n\tHard Light: if FALSE, the filter color is added to the colors of the scene. If TRUE, the filter color is combined with the colors of the scene (resulting in greater opacity).
\r\n\t
\r\n\tThis building block is useful to simulate infrared glasses or fade in/fade out effects.
\r\n\tThis building block does not need to be looped.
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/FX\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x00cd010b, 0x00dd010b));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateCameraColorFilterProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateCameraColorFilterProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Camera Color Filter\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Exit Off\");\r\n\t\r\n\tproto->DeclareInParameter(\"Filter Color\", CKPGUID_COLOR,\"255,0,0,0\");\r\n\tproto->DeclareInParameter(\"Density\", CKPGUID_PERCENTAGE, \"20\" );\r\n\tproto->DeclareInParameter(\"Hard Light\", CKPGUID_BOOL,\"FALSE\" );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(CameraColorFilter);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint CameraColorFilter(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n if(!beh) return CKBR_BEHAVIORERROR;\r\n\t\r\n\tif( beh->IsInputActive(1) ){ // we enter by 'OFF'\r\n\t\tbeh->ActivateInput(1, FALSE);\r\n\t\tbeh->ActivateOutput(1);\r\n\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\t\r\n\tif( beh->IsInputActive(0) ){ // we enter by 'ON'\r\n\t\tbeh->ActivateInput(0, FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\r\n\tbehcontext.CurrentRenderContext->AddPostRenderCallBack(CameraColorFilterRender,(void *)beh->GetID(),TRUE);\r\n\t//behcontext.CurrentRenderContext->AddPostRenderCallBack(CameraColorFilterRender,beh,TRUE);\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n}\r\n\r\nvoid CameraColorFilterRender(CKRenderContext *rc, void *arg){\r\n\r\n CKBehavior* beh = (CKBehavior*)CKGetObject(rc->GetCKContext(),(CK_ID)arg);\r\n if (!beh) return;\r\n//\tCKBehavior* beh = (CKBehavior*)arg;\r\n \r\n if(rc->GetAttachedCamera() != beh->GetTarget()) return;\r\n\r\n\t// we get the input parameters\r\n\tVxColor fcolor(255,0,0,0);\r\n\tbeh->GetInputParameterValue(0,&fcolor);\r\n\r\n\t// we get the density of the atmosphere\r\n\tfloat density = 20.0f;\r\n\tbeh->GetInputParameterValue(1,&density);\r\n\r\n\t// we change the material according to the bool\r\n\tBOOL hardl = FALSE;\r\n\tbeh->GetInputParameterValue(2,&hardl);\r\n\r\n\tif(hardl) {\r\n\t\trc->SetState(VXRENDERSTATE_SRCBLEND, VXBLEND_SRCALPHA);\r\n\t\trc->SetState(VXRENDERSTATE_DESTBLEND, VXBLEND_INVSRCALPHA);\r\n\t\tfcolor.a = density;\r\n\t} else {\r\n\t\trc->SetState(VXRENDERSTATE_SRCBLEND, VXBLEND_ONE);\r\n\t\trc->SetState(VXRENDERSTATE_DESTBLEND, VXBLEND_ONE);\r\n\t\tfcolor *= density;\r\n\t\tfcolor.a = 1.0f;\r\n\t}\r\n\r\n\t// SET STATES\r\n\t// we don't let write to the ZBuffer\r\n\trc->SetTexture(NULL);\r\n\trc->SetState(VXRENDERSTATE_CULLMODE, VXCULL_NONE);\r\n\trc->SetState(VXRENDERSTATE_ALPHABLENDENABLE, TRUE);\r\n\trc->SetState(VXRENDERSTATE_ZENABLE , FALSE);\r\n\trc->SetState(VXRENDERSTATE_ZWRITEENABLE , FALSE);\r\n\trc->SetState(VXRENDERSTATE_FILLMODE,VXFILL_SOLID);\r\n\r\n\tVxDrawPrimitiveData* data = rc->GetDrawPrimitiveStructure(CKRST_DP_VCT,4);\r\n\r\n\t// Positions\r\n\tVxRect rect;\r\n\trc->GetViewRect(rect);\r\n\r\n\tdata->Positions[0].Set(rect.left,rect.top,0.0f,1.0f);\r\n\tdata->Positions[1].Set(rect.right,rect.top,0.0f,1.0f);\r\n\tdata->Positions[2].Set(rect.right,rect.bottom,0.0f,1.0f);\r\n\tdata->Positions[3].Set(rect.left,rect.bottom,0.0f,1.0f);\t\r\n\t\r\n\t// colors\r\n\tDWORD col = RGBAFTOCOLOR(&fcolor);\r\n\tVxFillStructure(4,data->Colors,4,&col);\r\n\r\n\t// indices\r\n\tCKWORD* indices = rc->GetDrawPrimitiveIndices(4);\r\n\tindices[0] = 0;\r\n\tindices[1] = 1;\r\n\tindices[2] = 2;\r\n\tindices[3] = 3;\r\n\r\n\trc->DrawPrimitive(VX_TRIANGLEFAN, indices, 4,data);\r\n\r\n\t// we let write to the ZBuffer\r\n\trc->SetState(VXRENDERSTATE_ZWRITEENABLE , TRUE);\r\n\trc->SetState(VXRENDERSTATE_ZENABLE , TRUE);\r\n}\r\n#ifndef __P_MISC_H__\r\n#define __P_MISC_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\tVxVector BoxGetZero(CK3dEntity* ent);\r\n\tvoid SetEulerDirection(CK3dEntity* ent,VxVector direction);\r\n\t\r\n\tXString getEnumDescription(CKParameterManager* pm,CKGUID parGuide,int parameterSubIndex);\r\n\tXString getEnumDescription(CKParameterManager* pm,CKGUID parGuide);\r\n\r\n\tint getEnumIndex(CKParameterManager* pm,CKGUID parGuide,XString enumValue);\r\n\tint getHullTypeFromShape(NxShape *shape);\r\n\tCKGUID getEnumGuid(XString name);\r\n\r\n\tint getNbOfPhysicObjects(CK3dEntity *parentObject,int flags=0);\r\n\tbool calculateOffsets(CK3dEntity*source,CK3dEntity*target,VxQuaternion &quat,VxVector& pos);\r\n\r\n\tbool isChildOf(CK3dEntity*parent,CK3dEntity*test);\r\n\tCK3dEntity* findSimilarInSourceObject(CK3dEntity *parentOriginal,CK3dEntity* partentCopied,CK3dEntity *copiedObject,CK3dEntity*prev=NULL);\r\n\r\n\tCK3dEntity *getEntityFromShape(NxShape* shape);\r\n\r\n\r\n}\r\n#endif\r\n#ifndef SOFT_VERTEX_H\r\n\r\n#define SOFT_VERTEX_H\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nenum SoftVertexType\r\n{\r\n\tSVT_TETRA_VERTEX,\r\n\tSVT_TETRA_POSITION_VERTEX,\r\n\tSVT_TETRA_DEFORM_VERTEX,\r\n\tSVT_TETRA_GRAPHICS_VERTEX,\r\n};\r\n\r\nclass SoftVertexPool;\r\n\r\nSoftVertexPool *createSoftVertexPool(SoftVertexType type);\r\nbool releaseSoftVertexPool(SoftVertexPool *vpool);\r\nunsigned int getSoftVertexIndex(SoftVertexPool *vpool,const void *vertex);\r\nvoid * getSoftVertexPoolBuffer(SoftVertexPool *vpool,unsigned int &vcount);\r\n\r\n\r\n}; // END OF SOFTBODY NAMESPACE\r\n\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothDominateVertexDecl();\r\nCKERROR CreatePClothDominateVertexProto(CKBehaviorPrototype **pproto);\r\nint PClothDominateVertex(const CKBehaviorContext& behcontext);\r\nCKERROR PClothDominateVertexCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_VertexIndex,\r\n\tbbI_expireTime,\r\n\tbbI_domWeight,\r\n\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothDominateVertexDecl\r\n// FullName: FillBehaviorPClothDominateVertexDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothDominateVertexDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothDominateVertex\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Changes the weight of a vertex in the cloth solver for a period of time.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x92979b9,0x4ced0f82));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothDominateVertexProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothDominateVertexProto\r\n// FullName: CreatePClothDominateVertexProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothDominateVertexProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothDominateVertex\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothDominateVertex \r\n\r\n\tPClothDominateVertex is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tChanges the weight of a vertex in the cloth solver for a period of time.
\r\n\r\n\tIf this method is called for some vertex, the cloth solver will, during a time\r\n\tperiod of length expirationTime, assign a different weight to the vertex\r\n\twhile internal cloth constraints (i.e. bending & stretching) are being resolved.\r\n\r\n\tWith a high dominanceWeight, the modified vertex will force neighboring vertices\r\n\tto strongly accommodate their positions while its own is kept fairly constant. \r\n\tThe reverse holds for smaller dominanceWeights. \r\n\r\n\tUsing a dominanceWeight of +infinity has a similar effect as temporarily attaching \r\n\tthe vertex to a global position. However, unlike using attachments, the velocity \r\n\tof the vertex is kept intact when using this method.\r\n\r\n\t\\note The current implementation will not support the full range of dominanceWeights.\r\n\tAll dominanceWeights > 0.0 are treated equally as being +infinity.\r\n\r\n\t\\note An expiration time of 0.0 is legal and will result in dominance being\r\n\tapplied throughout one substep before being discarded immediately.\r\n\r\n\t\\note Having a large number of vertices dominant at once may result in a performance penalty.\r\n\r\n\r\n\r\n\t@see pCloth::dominateVertex()\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothDominateVertex.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\tVertex Index: Index of the vertex.\r\n\t
\r\n\t\r\n\tExpiration Time: Time period where dominance will be active for this vertex.\r\n\t
\r\n\t
\r\n\r\n\tDominance Weight: Dominance weight for this vertex.\r\n\t
\r\n\t
\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothDominateVertexCB );\r\n\r\n\tproto->DeclareInParameter(\"Vertex Index\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Expiration Time\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Dominance Weight\",CKPGUID_FLOAT);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothDominateVertex);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDominateVertex\r\n// FullName: PClothDominateVertex\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothDominateVertex(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tpWorld *world = GetPMan()->getDefaultWorld();\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tint vertexIndex = GetInputParameterValue(beh,bbI_VertexIndex);\r\n\t\tfloat expTime = GetInputParameterValue(beh,bbI_expireTime);\r\n\t\tfloat domWeight = GetInputParameterValue(beh,bbI_domWeight);\r\n\t\tcloth->dominateVertex(vertexIndex,expTime,domWeight);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDominateVertexCB\r\n// FullName: PClothDominateVertexCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothDominateVertexCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pWorldSettings.h\"\r\n#include \"NxUserNotify.h\"\r\n#include \"NxUserContactReport.h\"\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\nstruct MyUserNotify : public NxUserNotify \r\n{ \r\npublic: \r\n\t\r\n\tvirtual bool onJointBreak(NxReal breakingImpulse, NxJoint & brokenJoint) \r\n\t{ \r\n\t\tpJoint *joint = static_cast(brokenJoint.userData);\r\n\t\tif (joint)\r\n\t\t{\r\n\t\t\tpBrokenJointEntry *entry = new pBrokenJointEntry();\r\n\t\t\tentry->joint = joint;\r\n\t\t\tentry->impulse = breakingImpulse;\r\n\t\t\tpWorld *world = joint->getWorld();\r\n\t\t\tif (world)\r\n\t\t\t{\r\n\t\t\t\tworld->getJointFeedbackList().PushBack(entry);\r\n\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Joint break!\");\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t\t/*if((&brokenJoint) == gMyBreakableJoint) \r\n\t\t{ cout << \"BANG, The joint broke\" << endl; \r\n\t\treturn true; //delete the joint \r\n\t\t} return false; //don't delete the joint */\r\n\t} \r\n\r\n\tvirtual void onSleep(NxActor **actors, NxU32 count)\r\n\t{\r\n\t\t/*\r\n\t\tNX_ASSERT(count > 0);\r\n\t\t\t\twhile (count--)\r\n\t\t\t\t{\r\n\t\t\t\t\tNxActor *thisActor = *actors;\r\n\t\t\t\t\t//Tag the actor as sleeping\r\n\t\t\t\t\tsize_t currentFlag = (size_t)thisActor->userData;\r\n\t\t\t\t\tcurrentFlag |= gSleepFlag;\r\n\t\t\t\t\tthisActor->userData = (void*)currentFlag;\r\n\t\t\r\n\t\t\t\t\tactors++;\r\n\t\t\t\t}*/\r\n\t\t\r\n\t}\r\n\r\n\tvirtual void onWake(NxActor **actors, NxU32 count)\r\n\t{\r\n\t\t\r\n\t\tif (count >0)\r\n\t\t{\r\n\t\t\twhile (count--)\r\n\t\t\t{\r\n\t\t\t\tNxActor *thisActor = *actors;\r\n\t\t\t\tif (thisActor)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *body = static_cast(thisActor->userData);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\t\t\tbody->getTriggers().Clear();\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t//Tag the actor as non-sleeping\r\n\t\t\t\t/*size_t currentFlag = (size_t)thisActor->userData;\r\n\t\t\t\tcurrentFlag &= ~gSleepFlag;\r\n\t\t\t\tthisActor->userData = (void*)currentFlag;*/\r\n\r\n\t\t\t\tactors++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}myNotify;\r\n\r\n\r\npWorld*pFactory::createWorld(CK3dEntity* referenceObject, pWorldSettings *worldSettings,pSleepingSettings *sleepSettings)\r\n{\r\n\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!referenceObject || !GetPMan() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tif (!getPhysicSDK())\r\n\t{\r\n\t\t//xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"No physic sdk loaded\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint worldAtt = GetPMan()->att_world_object;\r\n\tint surfaceAttribute = GetPMan()->att_surface_props;\r\n\r\n\t//exists ? Delete it !\r\n\tpWorld *w = GetPMan()->getWorld(referenceObject->GetID());\r\n\tif (w)\r\n\t{\r\n\t\tGetPMan()->deleteWorld(referenceObject->GetID());\r\n\t}\r\n\t\t\r\n\t//our new world : \r\n\tpWorld *result = new pWorld(referenceObject);\r\n\tGetPMan()->getWorlds()->InsertUnique(referenceObject,result);\r\n\r\n\tresult->initUserReports();\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t//there is no world settings attribute : \r\n\tif (!referenceObject->HasAttribute(worldAtt) )\r\n\t{\r\n\t\treferenceObject->SetAttribute(worldAtt);\r\n\t\tusing namespace vtTools;\r\n\t\tVxVector grav = worldSettings->getGravity();\r\n\t\tfloat sWith = worldSettings->getSkinWith();\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,worldAtt,0,&grav);\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,worldAtt,1,&sWith);\r\n\t}\r\n\r\n\r\n\tif (!worldSettings)\r\n\t{\r\n\t\tworldSettings = pFactory::Instance()->createWorldSettings(XString(\"Default\"),GetPMan()->getDefaultConfig());\r\n\t}\r\n\tif (!worldSettings)\r\n\t{\r\n\t\tworldSettings = new pWorldSettings();\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//pSDK Scene creation : \r\n\r\n\t// Create a scene\r\n\tNxSceneDesc sceneDesc;\r\n\tsceneDesc.gravity\t\t\t\t= pMath::getFrom(worldSettings->getGravity());\r\n\tsceneDesc.upAxis = 1;\r\n\tsceneDesc.flags |=NX_SF_ENABLE_ACTIVETRANSFORMS;\r\n\tsceneDesc.userNotify =&myNotify;\r\n\tsceneDesc.userContactReport = result->contactReport;\r\n \r\n\tNxScene *scene = NULL;\r\n\tif (getPhysicSDK())\r\n\t{\r\n\t\tscene = getPhysicSDK()->createScene(sceneDesc);\r\n\t\tif(scene == NULL) \r\n\t\t{\r\n xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create scene!\");\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\r\n\tresult->setScene(scene);\r\n\tscene->setUserContactReport(result->contactReport);\r\n\tscene->setUserTriggerReport(result->triggerReport);\r\n\r\n\tNxMaterialDesc *materialDescr = NULL;\r\n\tNxMaterial *material = NULL;\r\n\tif (referenceObject->HasAttribute(surfaceAttribute))\r\n\t{\r\n\t\tmaterialDescr = createMaterialFromEntity(referenceObject);\r\n\t\tmaterial = result->getScene()->createMaterial(*materialDescr);\r\n\t\tmaterial->userData = (void*)GetValueFromParameterStruct(referenceObject->GetAttributeParameter(surfaceAttribute) ,E_MS_XML_TYPE);\r\n\t}else{\r\n\t\t\r\n\t\tif (getDefaultDocument())\r\n\t\t{\r\n\t\t\t\r\n\t\t\tmaterialDescr = createMaterialFromXML(\"Default\",getDefaultDocument());\r\n\t\t}\r\n\t\t\r\n\t\tif (materialDescr)\r\n\t\t{\r\n\t\t\tmaterial = result->getScene()->createMaterial(*materialDescr);\r\n\t\t}\r\n\r\n\t\tif (!material)\r\n\t\t{\r\n\t\t\tmaterialDescr = new NxMaterialDesc();\r\n\t\t\tmaterialDescr->setToDefault();\r\n\t\t\tmaterial = result->getScene()->getMaterialFromIndex(0); \r\n\t\t\tmaterial->loadFromDesc(*materialDescr);\r\n\t\t}\r\n\t}\r\n\t\r\n\tint z = (int)material->userData;\r\n\tNxMaterial *zeroMaterial = result->getScene()->getMaterialFromIndex(0);\r\n\tzeroMaterial->setDirOfAnisotropy(material->getDirOfAnisotropy());\r\n\tzeroMaterial->setStaticFriction(material->getStaticFriction());\r\n\tzeroMaterial->setDynamicFriction(material->getDynamicFriction());\r\n\tzeroMaterial->setStaticFrictionV(material->getStaticFrictionV());\r\n\tzeroMaterial->setDynamicFrictionV(material->getDynamicFrictionV());\r\n\tzeroMaterial->setFrictionCombineMode(material->getFrictionCombineMode());\r\n\tzeroMaterial->setRestitutionCombineMode(material->getRestitutionCombineMode());\r\n\tzeroMaterial->setFlags(material->getFlags());\r\n\tzeroMaterial->userData = material->userData;\r\n\r\n\r\n\r\n\r\n\tif (!material)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create default material!\");\r\n\t}\r\n\tresult->setDefaultMaterial(material);\r\n\r\n\tscene->userData = result;\r\n\r\n\t\r\n\t//NxConstraintDominance testDom(1.0, 1.0f);\r\n\t//result->getScene()->setDominanceGroupPair(1, 2,testDom );\t//board - debris\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//there is no world settings attribute : \r\n\t/*\r\n\tif (!referenceObject->HasAttribute(GetPMan()->att_sleep_settings) )\r\n\t{\r\n\t\treferenceObject->SetAttribute(GetPMan()->att_sleep_settings);\r\n\t\tusing namespace vtTools;\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->att_sleep_settings,0,&sSettings->m_SleepSteps);\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->att_sleep_settings,1,&sSettings->m_AngularThresold);\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->att_sleep_settings,2,&sSettings->m_LinearThresold);\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,GetPMan()->att_sleep_settings,3,&sSettings->m_AutoSleepFlag);\r\n\t}\t\r\n\t*/\r\n\t\r\n\r\n\t/*\r\n\tresult->SleepingSettings(sSettings);\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tresult->Reference(referenceObject);\r\n\t\r\n\tresult->Init();\r\n*/\r\n\r\n\r\n\tresult->_checkForDominanceConstraints();\r\n\tresult->_construct();\r\n\r\n\r\n\r\n\r\n\r\n\r\n\treturn result;\r\n\t\r\n\r\n\t//return NULL;\r\n\r\n}\r\n//************************************\r\n// Method: CreateDefaultWorld\r\n// FullName: vtODE::pFactory::CreateDefaultWorld\r\n// Access: public \r\n// Returns: pWorld*\r\n// Qualifier:\r\n// Parameter: XString name\r\n//************************************\r\npWorld*pFactory::createDefaultWorld(XString name)\r\n{\r\n\t\r\n\r\n\tCK3dEntity *defaultWorldFrame = createFrame(\"pDefaultWorld\");\r\n\tpWorldSettings *wSettings = getManager()->getDefaultWorldSettings();\r\n\r\n\tpWorld* world = createWorld(defaultWorldFrame,wSettings,NULL);\r\n\tgetManager()->setDefaultWorld(world);\r\n\treturn world;\r\n\r\n\r\n\r\n\r\n\t\r\n/*\r\n\t\r\n\tpSleepingSettings *sSettings = CreateSleepingSettings(\"Default\",GetPMan()->DefaultDocument());\r\n\tpWorldSettings *wSettings = createWorldSettings(\"Default\",GetPMan()->DefaultDocument());\r\n\r\n\tGetPMan()->DefaultSleepingSettings(*sSettings);\r\n\tGetPMan()->DefaultWorldSettings(*wSettings);\r\n\r\n\tpWorld* world = CreateWorld(defaultWorldFrame,&GetPMan()->DefaultWorldSettings(),&GetPMan()->DefaultSleepingSettings());\r\n\tGetPMan()->DefaultWorld(world);\r\n\t\r\n*/\r\n//\treturn world;\r\n\r\n\treturn NULL;\r\n\r\n}\r\n\r\n/*\n * Tcp4u v 3.31 Last Revision 06/06/1997 3.1\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tcp4u_err.c\n * Purpose: version and error management \n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n\n#include \"build.h\"\n\n\n/* ------------------------------------------------------------------ */\n/* Compataibilite avec les anciennes fonctions */\n/* ------------------------------------------------------------------ */\n#ifdef _WINDOWS\n int API4U Tcp4wVer (LPSTR sz, UINT uSize) { return Tcp4uVer(sz,uSize); }\n LPSTR API4U Tcp4wErrorString (int Rc) { return Tcp4uErrorString(Rc); }\n#endif\n#ifdef UNIX \n int API4U Tcp4uxVer(LPSTR sz, UINT uSize) { return Tcp4uVer(sz,uSize); }\n LPSTR API4U Tcp4uxErrorString (int Rc) { return Tcp4uErrorString(Rc); }\n#endif\n\n\n\n/* ------------------------------------------------------------------ */\n/* Informations sur la version */\n/* ------------------------------------------------------------------ */\nstatic LPCSTR szTcp4uVersion = \n\n#ifdef _WINDOWS\n# ifdef _WIN32\n# ifdef TCP4W_DLL\n \"@(#)DLL Tcp4u Win32 by Ph.Jounin Version 3.31\";\n# else\n \"@(#)Lib Tcp4u Win32 by Ph.Jounin Version 3.31\";\n# endif /* DLL ? */\n# else\n# ifdef TCP4W_DLL\n \"@(#)DLL Tcp4u Win16 by Ph.Jounin Version 3.31\";\n# else\n \"@(#)Lib Tcp4u Win16 by Ph.Jounin Version 3.31\";\n# endif /* DLL ? */ \n# endif /* WIN32 */\n#endif /* _WINDOWS */\n#ifdef UNIX\n \"@(#)Tcp4u Unix by Ph.jounin Version 3.31\";\n#endif /* UNIX */\n\nint nTcp4uVersion = 0x0331;\n\n\n/* ------------------------------------------------------------------ */\n/* La fonction les retournant */\n/* ------------------------------------------------------------------ */\n\nint API4U Tcp4uVer (LPSTR szInfo, UINT uBufSize)\n{\n if (szInfo!=NULL) Strcpyn(szInfo, szTcp4uVersion + 4, uBufSize);\nreturn nTcp4uVersion;\n} /* Tcp4uVer */\n\n\n\n/* ------------------------------------------------------ */\n/* Fonction: */\n/* Retourne un message texte donnant la cause de l'erreur */\n/* Note: Certains messages sont specifiques a la version */\n/* Windows... Peu importe */\n/* ------------------------------------------------------ */\n\nstruct S_Tcp4Err\n{\n int Tcp4ErrCode;\n LPSTR Tcp4ErrString;\n}; /* struct S_Tcp4Err */\n\nstatic struct S_Tcp4Err sTcp4Err [] =\n{\n { TCP4U_SUCCESS, (LPSTR) \"Successful call\" },\n { TCP4U_ERROR, (LPSTR) \"Network error\" },\n { TCP4U_TIMEOUT, (LPSTR) \"Timeout in recv or accept\" },\n { TCP4U_HOSTUNKNOWN, (LPSTR) \"Reference to Unknown host\" },\n { TCP4U_NOMORESOCKET, (LPSTR) \"All sockets has been used up\" }, \n { TCP4U_NOMORERESOURCE, (LPSTR) \"No more free resource\" },\n { TCP4U_CONNECTFAILED, (LPSTR) \"Connect function has failed\" },\n { TCP4U_UNMATCHEDLENGTH, (LPSTR) \"TcpPPRecv : Error in length\" },\n { TCP4U_BINDERROR, (LPSTR) \"Bind failed (Task already started or attempt to open privileged socket )\" },\n { TCP4U_OVERFLOW, (LPSTR) \"Overflow during TcpPPRecv/TcpRecvUntilStr\"},\n { TCP4U_EMPTYBUFFER, (LPSTR) \"TcpPPRecv receives 0 byte\" },\n { TCP4U_CANCELLED, (LPSTR) \"Call cancelled by signal or TcpAbort\" }, \n { TCP4U_INSMEMORY, (LPSTR) \"Not enough memory to perform function\" },\n { TCP4U_BADPORT, (LPSTR) \"Bad port number or alias\" },\n { TCP4U_SOCKETCLOSED, (LPSTR) \"Host has closed connection\" },\n { TCP4U_FILE_ERROR, (LPSTR) \"A file operation has failed\" },\n}; /* sTcp4Err */\n\nLPSTR API4U Tcp4uErrorString (int Rc)\n{\nint Idx;\n Tcp4uLog (LOG4U_PROC, \"Tcp4uErrorString\");\n\n for ( Idx=0 ; \n Idx= SizeOfTab(sTcp4Err) ? (LPSTR) \"Not an Tcp4 return code\" :\n sTcp4Err[Idx].Tcp4ErrString;\n} /* Tcp4(w/ux)ErrorString */\n#ifndef __PWORLDCALLBACKS_H__\r\n#define __PWORLDCALLBACKS_H__\r\n\r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n\r\nclass pRayCastReport : public NxUserRaycastReport\r\n{\r\n\r\npublic:\r\n\r\n\tbool onHit(const NxRaycastHit& hit);\r\n\tpWorld *mWorld;\r\n\tpWorld * getWorld() const { return mWorld; }\r\n\tvoid setWorld(pWorld * val) { mWorld = val; }\r\n\tint mCurrentBehavior;\r\n\tint getCurrentBehavior() const { return mCurrentBehavior; }\r\n\tvoid setCurrentBehavior(int val) { mCurrentBehavior = val; }\r\n\tpRayCastReport()\r\n\t{\r\n\t\tmWorld = NULL;\r\n\t\tmCurrentBehavior=-1;\r\n\t}\r\n} ;\r\n\r\nclass pContactReport : public NxUserContactReport\r\n{\r\npublic:\r\n\tvirtual void onContactNotify(NxContactPair& pair, NxU32 events);\r\n\tpWorld *mWorld;\r\n\tpWorld * getWorld() const { return mWorld; }\r\n\tvoid setWorld(pWorld * val) { mWorld = val; }\r\n\r\n} ;\r\n\r\nclass pContactModify : public NxUserContactModify\r\n{\r\npublic:\r\n\tvirtual bool onContactConstraint(\r\n\t\tNxU32& changeFlags, \r\n\t\tconst NxShape* shape0, \r\n\t\tconst NxShape* shape1, \r\n\t\tconst NxU32 featureIndex0, \r\n\t\tconst NxU32 featureIndex1,\r\n\t\tNxContactCallbackData& data);\r\n\r\n\tpWorld *mWorld;\r\n\tpWorld * getWorld() const { return mWorld; }\r\n\tvoid setWorld(pWorld * val) { mWorld = val; }\r\n\r\n} ;\r\n\r\n\r\nclass pTriggerReport : public NxUserTriggerReport \r\n{ \r\npublic:\r\n\tvoid onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status); \r\n\tpWorld *mWorld;\r\n\tpWorld * getWorld() const { return mWorld; }\r\n\tvoid setWorld(pWorld * val) { mWorld = val; }\r\n};\r\n\r\n\r\n#endif // __PWORLDCALLBACKS_H__/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetClipping Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetClippingDecl();\r\nCKERROR CreateSetClippingProto(CKBehaviorPrototype **pproto);\r\nint SetClipping(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetClippingDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Clipping Planes\");\t\r\n\tod->SetDescription(\"Sets the near and the far clipping plane of a camera.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tNear Clip: the distance from the point of view of the Near clipping plane.
\r\n\tFar Clip: the distance from the point of view of the Far clipping plane.
\r\n\t
\r\n\tReducing the Far Clip will speed up rendering, as objects which are too far away and so non-visible will be removed from rendering process. A fog background can be added so that objects on the perimeter edge will not be clipped.
\r\n\tReducing the Near Clip will avoid clipping objects that are too close from being clipped if the camera gets too close to an object resulting in the object clipping.
\r\n\tIncreasing the Near Clip and reducing the Far Clip will help to correct Z-Buffer inaccuracy in 3d scenes modeled with objects that are too large.
\r\n\t*/\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x652316a2, 0x01aa09a9));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetClippingProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetClippingProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Clipping Planes\");\r\n\tif(!proto) \r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Near Clip\", CKPGUID_FLOAT, \"0.1\");\r\n\tproto->DeclareInParameter(\"Far Clip\", CKPGUID_FLOAT, \"200\");\r\n\r\n proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetClipping);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint SetClipping(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n float near_plane = 0.1f;\r\n beh->GetInputParameterValue(0, &near_plane);\r\n\r\n float far_plane = 200.0f;\r\n beh->GetInputParameterValue(1, &far_plane);\r\n\r\n cam->SetFrontPlane( near_plane );\r\n cam->SetBackPlane( far_plane );\r\n\r\n beh->ActivateInput(0, FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n return CKBR_OK;\r\n}\r\n\r\nusing System;\r\nusing System.Drawing;\r\nusing System.Collections;\r\nusing System.ComponentModel;\r\nusing System.Windows.Forms;\r\nusing System.Data;\r\n\r\nnamespace WindowsApplication\r\n{\r\n\t/// \r\n\t/// Summary description for Form1.\r\n\t/// \r\npublic class Form1 : System.Windows.Forms.Form\r\n{\r\n\t\t/// \r\n\t\t/// Required designer variable.\r\n\t\t/// \r\n\tprivate System.ComponentModel.Container components = null;\r\n\t\r\n\tpublic void CreateVTWindow(IntPtr win)\r\n\t{\r\n\r\n\r\n\t\tvtWin = new vtWindow();\r\n\t\tSWIGTYPE_p_long l = new SWIGTYPE_p_long(win,true);\r\n\t\tvtWin.CreateAsChild(l); \r\n\t\t\r\n\t}\r\n\tprotected override void OnClosing(CancelEventArgs e)\r\n\t{\r\n\t\tbase.OnClosing (e);\r\n\t\tif (vtWin!=null)\r\n\t\t{\r\n\t\t\tvtWin.Destroy();\r\n\t\t}\r\n\t}\r\n\r\n\tprivate System.Windows.Forms.Panel panel1;\r\n\tprivate System.Windows.Forms.Button sendmessage;\r\n\r\n\t//some temp test values for messaging : \r\n\tprivate int m_intMTest=0;\r\n\tprivate float m_floatMTest=0;\r\n\tprivate String m_strMTest=\"\";\r\n\tprivate System.Windows.Forms.Button sendMsgFloat;\r\n\tprivate System.Windows.Forms.Button sendMsgStr;\r\n\t\r\n\r\n\tpublic vtWindow vtWin = null;\r\n\tpublic vtWindow VtWin\r\n\t{\r\n\t\tget { return vtWin; }\r\n\t\tset { vtWin = value; }\r\n\t}\r\n\r\n\tpublic Form1()\r\n\t{\r\n\t\r\n\t\tInitializeComponent();\r\n\t\tthis.SuspendLayout();\r\n\t\t\r\n\t\t//we init our player, be aware about \"OwnerDrawed\" entry in the player.ini!\r\n\t\t//you must set this to 1, otherwise its not correct displayed in this form !\r\n\t\tCreateVTWindow(panel1.Handle);\r\n\r\n\t\t//we retrieve the players render bounds : \r\n\t\tint playerWidth = vtWin.GetWidth();\r\n\t\tint playerHeight = vtWin.GetHeight();\r\n\r\n\t\t// and we re-adjust our panel ! \r\n\t\tthis.panel1.Size = new System.Drawing.Size(playerWidth, playerHeight);\r\n\t\tthis.panel1.Size=new System.Drawing.Size(playerWidth, playerHeight);\r\n\t\tvtWin.UpdateRenderSize(playerWidth, playerHeight);\r\n\t\t\r\n\t\t\r\n\t\t//and go !\r\n\t\tvtWin.Run();\r\n\r\n\t\t\r\n\t\t//vtWin.Show(1);\r\n\t\t\r\n\t\tthis.PerformLayout();\r\n\r\n\r\n\r\n\t}\r\n\r\n\t/// \r\n\t/// Clean up any resources being used.\r\n\t/// \r\n\tprotected override void Dispose( bool disposing )\r\n\t{\r\n\t\tif( disposing )\r\n\t\t{\r\n\t\t\tif (components != null) \r\n\t\t\t{\r\n\t\t\t\tcomponents.Dispose();\r\n\t\t\t}\r\n\t\t}\r\n\t\tbase.Dispose( disposing );\r\n\t}\r\n\r\n\t\t#region Windows Form Designer generated code\r\n\t\t\t\t/// \r\n\t\t\t\t/// Required method for Designer support - do not modify\r\n\t\t\t\t/// the contents of this method with the code editor.\r\n\t\t\t\t/// \r\n\t\tprivate void InitializeComponent()\r\n\t\t{\r\n\t\t\tthis.panel1 = new System.Windows.Forms.Panel();\r\n\t\t\tthis.sendmessage = new System.Windows.Forms.Button();\r\n\t\t\tthis.sendMsgFloat = new System.Windows.Forms.Button();\r\n\t\t\tthis.sendMsgStr = new System.Windows.Forms.Button();\r\n\t\t\tthis.SuspendLayout();\r\n\t\t\t// \r\n\t\t\t// panel1\r\n\t\t\t// \r\n\t\t\tthis.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r\n\t\t\tthis.panel1.Location = new System.Drawing.Point(120, 16);\r\n\t\t\tthis.panel1.Name = \"panel1\";\r\n\t\t\tthis.panel1.Size = new System.Drawing.Size(328, 232);\r\n\t\t\tthis.panel1.TabIndex = 0;\r\n\t\t\t// \r\n\t\t\t// sendmessage\r\n\t\t\t// \r\n\t\t\tthis.sendmessage.Location = new System.Drawing.Point(8, 8);\r\n\t\t\tthis.sendmessage.Name = \"sendmessage\";\r\n\t\t\tthis.sendmessage.Size = new System.Drawing.Size(96, 24);\r\n\t\t\tthis.sendmessage.TabIndex = 1;\r\n\t\t\tthis.sendmessage.Text = \"sendmessageInt\";\r\n\t\t\tthis.sendmessage.Click += new System.EventHandler(this.sendmessage_Click);\r\n\t\t\t// \r\n\t\t\t// sendMsgFloat\r\n\t\t\t// \r\n\t\t\tthis.sendMsgFloat.Location = new System.Drawing.Point(8, 40);\r\n\t\t\tthis.sendMsgFloat.Name = \"sendMsgFloat\";\r\n\t\t\tthis.sendMsgFloat.Size = new System.Drawing.Size(96, 24);\r\n\t\t\tthis.sendMsgFloat.TabIndex = 2;\r\n\t\t\tthis.sendMsgFloat.Text = \"sendMsgFloat\";\r\n\t\t\tthis.sendMsgFloat.Click += new System.EventHandler(this.sendMsgFloat_Click);\r\n\t\t\t// \r\n\t\t\t// sendMsgStr\r\n\t\t\t// \r\n\t\t\tthis.sendMsgStr.Location = new System.Drawing.Point(8, 72);\r\n\t\t\tthis.sendMsgStr.Name = \"sendMsgStr\";\r\n\t\t\tthis.sendMsgStr.Size = new System.Drawing.Size(96, 24);\r\n\t\t\tthis.sendMsgStr.TabIndex = 3;\r\n\t\t\tthis.sendMsgStr.Text = \"sendMsgStr\";\r\n\t\t\tthis.sendMsgStr.Click += new System.EventHandler(this.sendMsgStr_Click);\r\n\t\t\t// \r\n\t\t\t// Form1\r\n\t\t\t// \r\n\t\t\t//this.AutoScale = false;\r\n\t\t\tthis.AutoScaleBaseSize = new System.Drawing.Size(5, 13);\r\n\t\t\tthis.ClientSize = new System.Drawing.Size(888, 645);\r\n\t\t\tthis.Controls.Add(this.sendMsgStr);\r\n\t\t\tthis.Controls.Add(this.sendMsgFloat);\r\n\t\t\tthis.Controls.Add(this.sendmessage);\r\n\t\t\tthis.Controls.Add(this.panel1);\r\n\t\t\tthis.Name = \"Form1\";\r\n\t\t\tthis.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r\n\t\t\tthis.Text = \"Form1\";\r\n\t\t\tthis.ResumeLayout(false);\r\n\r\n\t\t}\r\n\t\t#endregion\r\n\t\t\t/// \r\n\t\t\t/// The main entry point for the application.\r\n\t\t\t/// \r\n\t\t\t/// \r\n\t\t[STAThread]\r\n\t\tstatic void Main() \r\n\t\t{\r\n\t\t\tApplication.Run(new Form1());\r\n\t\t}\r\n\r\n\tprivate void sendmessage_Click(object sender, System.EventArgs e)\r\n\t{\r\n\t\r\n\t\tif (vtWin!=null)\r\n\t\t{\r\n\r\n\t\t\t//we send a message to our player : \r\n\r\n\t\t\t//when the player could'nt found the object by this name, then it sends\r\n\t\t\t//a broadcast message !\r\n\r\n\r\n\t\t\tString objectName = \"masterDummy\";\r\n\r\n\t\t\t//this message name should exist inside vt !\r\n\t\t\tString messageName = \"csharp\";\r\n\r\n\r\n\t\t\t//the function takes 3 reserved parameters. you can do what ever you want with it\r\n\t\t\tint id0 =0;\r\n\t\t\tint id1 = 1;\r\n\t\t\tint id2 = 2;\r\n\t\t\tm_intMTest++;\r\n\t\t\tvtWin.SendMessage(objectName,messageName,id0,id1,id2,m_intMTest);\r\n\r\n\t\t\t//just a test\r\n\t\t\tthis.panel1.Size=new System.Drawing.Size(400, 300);\r\n\t\t\tvtWin.UpdateRenderSize(400,300);\r\n\t\t\t\r\n\r\n\t\t\t//inside vt you only have to attach a MessageWaiter to the object and also \r\n\t\t\t//a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n\t\t\t// int,int,int,int in this case here !\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void sendMsgFloat_Click(object sender, System.EventArgs e)\r\n\t{\r\n\t\r\n\t\tif (vtWin!=null)\r\n\t\t{\r\n\t\t\t//we send a message to our player : \r\n\r\n\t\t\t//when the player could'nt found the object by this name, then it sends\r\n\t\t\t//a broadcast message !\r\n\t\t\tString objectName = \"masterDummy\";\r\n\r\n\t\t\t//this message name should exist inside vt !\r\n\t\t\tString messageName = \"csharpFloat\";\r\n\r\n\t\t\t//the function takes 3 reserved parameters. you can do what ever you want with it\r\n\t\t\tint id0 =0;\r\n\t\t\tint id1 = 1;\r\n\t\t\tint id2 = 2;\r\n\t\t\tm_floatMTest+=0.23f;\r\n\t\t\tvtWin.SendMessage(objectName,messageName,id0,id1,id2,m_floatMTest);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t//inside vt you only have to attach a MessageWaiter to the object and also \r\n\t\t\t//a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n\t\t\t// int,int,int,int in this case here !\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void sendMsgStr_Click(object sender, System.EventArgs e)\r\n\t{\r\n\t\tif (vtWin!=null)\r\n\t\t{\r\n\t\t\t//we send a message to our player : \r\n\r\n\t\t\t//when the player could'nt found the object by this name, then it sends\r\n\t\t\t//a broadcast message !\r\n\t\t\tString objectName = \"masterDummy\";\r\n\r\n\t\t\t//this message name should exist inside vt !\r\n\t\t\tString messageName = \"csharpString\";\r\n\r\n\t\t\t//the function takes 3 reserved parameters. you can do what ever you want with it\r\n\t\t\tint id0 =0;\r\n\t\t\tint id1 = 1;\r\n\t\t\tint id2 = 2;\r\n\t\t\tm_strMTest+=\"asdasd\";\r\n\t\t\tvtWin.SendMessage(objectName,messageName,id0,id1,id2,m_strMTest);\r\n\t\t\t//inside vt you only have to attach a MessageWaiter to the object and also \r\n\t\t\t//a GetMessageDataBB after the waiter with the appropriate output parameters : \r\n\t\t\t// int,int,int,int in this case here !\r\n\t\t}\r\n\t}\r\n\r\n\t}\r\n}#include \"xNetObject.h\"\r\n#include \r\n#include \"vtConnection.h\"\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxNetObject::xNetObject()\r\n{\r\n\r\n\tmNetFlags.set(Ghostable);\r\n\tsetNetInterface(NULL);\r\n\tmOwnerConnection = NULL;\r\n\r\n}\r\nvoid xNetObject::Destroy()\r\n{\r\n\r\n\tsetNetInterface(NULL);\r\n\tSetName(\"\");\r\n\r\n\t\r\n}\r\nxNetObject::~xNetObject()\r\n{\r\n\r\n\tDestroy();\r\n\r\n\t/*\r\n\txDistributedObject *distObject = static_cast(this);\r\n\tif(distObject)\r\n\t{\r\n\t\tif (GetNetInterface())\r\n\t\t{\r\n\t\t\tvtDistributedObjectsArrayType *distObjects = GetNetInterface()->getDistributedObjects();\r\n\t\t\tif (distObjects)\r\n\t\t\t{\r\n\t\t\t\tdistObjects->Remove((xDistributedObject*)this);\r\n\t\t\t\t//retrieve its class : \r\n\t\t\t\t\r\n\t\t\t\tdistObject->SetNetInterface(NULL);\r\n\t\t\t\tdistObject->SetName(\"\");\r\n\t\t\t}\r\n\t\t}\r\n\t}*/\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxNetObject::xNetObject(TNL::StringPtr name) : m_Name(name)\r\n{\r\n\tmNetFlags.set(Ghostable);\r\n\tm_NetInterface = NULL;\r\n\tm_UserID = 0;\r\n\tmOwnerConnection = NULL;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n#define PARAM_OP_TYPE_BGET_VELOCITY CKGUID(0x3b2a778c,0x293b206d)\r\n#define PARAM_OP_TYPE_BGET_AVELOCITY CKGUID(0x67ee7c4e,0x1e3b4d15)\r\n#define PARAM_OP_TYPE_BGET_TORQUE CKGUID(0x1ecd7ee4,0x4f0b7eda)\r\n#define PARAM_OP_TYPE_BGET_FORCE CKGUID(0x7dd13e61,0x40af4f99)\r\n#define PARAM_OP_TYPE_BGET_FRICTION CKGUID(0x482b3611,0x4b0a168c)\r\n#define PARAM_OP_TYPE_BGET_HTYPE CKGUID(0x68eb059e,0x26bb745a)\r\n#define PARAM_OP_TYPE_BGET_FIXED CKGUID(0x7bcd7379,0x5c950897)\r\n#define PARAM_OP_TYPE_BGET_KINEMATIC CKGUID(0x6cf414e6,0xf0a35ec)\r\n\r\n#define PARAM_OP_TYPE_BGET_GRAVITY CKGUID(0x63f81d10,0xd532a5a)\r\n#define PARAM_OP_TYPE_BGET_COLLISION CKGUID(0x57f61ee3,0xef1252a)\r\n#define PARAM_OP_TYPE_BGET_COLLISION_GROUP CKGUID(0xeea6d63,0x2d8a032d)\r\n#define PARAM_OP_TYPE_BGET_SLEEPING CKGUID(0x7ca42afe,0x2665435)\r\n\r\n#define PARAM_OP_TYPE_BIS_SUB_SHAPE_OF CKGUID(0x7ed952ce,0x5160083)\r\n\r\n\r\n#define PARAM_OP_TYPE_BGET_FLAGS CKGUID(0x19263740,0x5dd248a2)\r\n#define PARAM_OP_TYPE_BGET_MATERIAL CKGUID(0x1306375d,0x2bcc3cab)\r\n#define PARAM_OP_TYPE_BGET_ISPOBJECT CKGUID(0xa0d7467,0x76692667)\r\n\r\n\r\n#define PARAM_OP_TYPE_BGET_PVEL CKGUID(0x46bc47fc,0x1a4e6a83)\r\n#define PARAM_OP_TYPE_BGET_LPVEL CKGUID(0x1c7e07fa,0x430a084b)\r\n#define PARAM_OP_TYPE_BGET_MASS CKGUID(0x257d5234,0x362841d4)\r\n\r\n#define PARAM_OP_TYPE_BJ_ISCONNECTED CKGUID(0x51db16ef,0xfb772d0)\r\n#define PARAM_OP_TYPE_BJ_NBJOINTS CKGUID(0x29e20d6c,0x6ebc03d2)\r\n\r\n\r\n\r\n#define PARAM_OP_TYPE_BGET_LDAMP CKGUID(0x532052cd,0x97d4334)\r\n#define PARAM_OP_TYPE_BGET_LDAMPT CKGUID(0x7e6623dd,0x3beb16d1)\r\n#define PARAM_OP_TYPE_BGET_ADAMP CKGUID(0x6c620e3b,0x4c2344d8)\r\n#define PARAM_OP_TYPE_BGET_ADAMPT CKGUID(0x148b07eb,0x563c4ff7)\r\n\r\n\r\nvoid ParamOpBIsSubShape(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\r\n\tCK_ID targetID_Sub;\r\n\tp2->GetValue(&targetID_Sub);\r\n\r\n\tint result=0;\r\n\t\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tif (target->isSubShape(static_cast(context->GetObject(targetID_Sub))))\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tres->SetValue(&result);\r\n\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid ParamOpBGetLVelocity(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = target->getLinearVelocity();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpBGetAVelocity(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = target->getAngularVelocity();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpBGetForce(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = target->getLinearMomentum();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBGetTorque(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector vec = target->getAngularMomentum();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpBisFixed(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->getActor()->isDynamic();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBGetHType(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->getHullType();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpBisKinematic(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->isKinematic();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBisCollider(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->isCollisionEnabled(ent);\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBisGravity(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->isAffectedByGravity();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ParamOpBGetCollGroup(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->getCollisionsGroup();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBIsSleeping(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint value = target->isSleeping();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBGetFlags(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\ttarget->recalculateFlags(0);\r\n\t\t\t\tint value = target->getFlags();\r\n\t\t\t\tres->SetValue(&value);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBIsPObject(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tint result = 0;\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tresult = 1;\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&result);\r\n}\r\n\r\nvoid ParamOpBGetPVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector point;\r\n\t\t\t\tp2->GetValue(&point);\r\n\t\t\t\tVxVector vec = target->getPointVelocity(point);\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBGetLPVel(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tVxVector point;\r\n\t\t\t\tp2->GetValue(&point);\r\n\t\t\t\tVxVector vec = target->getLocalPointVelocity(point);\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\nvoid ParamOpBGetMass(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tfloat vec = target->getMass();\r\n\t\t\t\tres->SetValue(&vec);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid ParamOpBJIsConnected(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\r\n\tCK_ID targetIDB;\r\n\tp2->GetValue(&targetIDB);\r\n\r\n\tint result = - 1;\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tCK3dEntity *entB = static_cast(context->GetObject(targetIDB));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tpJoint *joint = target->isConnected(entB);\r\n\t\t\t\tif (joint)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = joint->getType();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tres->SetValue(&result);\r\n}\r\nvoid ParamOpBGetMaterial(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\r\n\tCK_ID targetID2;\r\n\tp2->GetValue(&targetID2);\r\n\tCK3dEntity *ent2 = static_cast(context->GetObject(targetID2));\r\n\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tpMaterial mat = target->getShapeMaterial(ent2);\r\n\t\t\t\tpFactory::Instance()->copyTo(res,mat);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nvoid ParamOpBGetNbJoints(CKContext* context, CKParameterOut* res, CKParameterIn* p1, CKParameterIn* p2)\r\n{\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\tCK_ID targetID;\r\n\tp1->GetValue(&targetID);\r\n\tCK3dEntity *ent = static_cast(context->GetObject(targetID));\r\n\tif (ent)\r\n\t{\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(ent); \r\n\t\tif (world)\r\n\t\t{\r\n\t\t\tpRigidBody*target= world->getBody(ent);\r\n\t\t\tif (target)\r\n\t\t\t{\r\n\t\t\t\tint nbJoints = target->getNbJoints();\r\n\t\t\t\tres->SetValue(&nbJoints);\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::_RegisterParameterOperationsBody()\r\n{\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BJ_NBJOINTS, \"bNbJoints\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BJ_NBJOINTS,CKPGUID_INT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetNbJoints);\r\n\r\n\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_MATERIAL, \"bMat\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_MATERIAL,VTS_MATERIAL,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpBGetMaterial);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_VELOCITY, \"bVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_VELOCITY,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetLVelocity);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_AVELOCITY, \"bAVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_AVELOCITY,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetAVelocity);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_FORCE, \"bForce\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_FORCE,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetForce);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_TORQUE, \"bTorque\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_TORQUE,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetTorque);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_HTYPE, \"bHullType\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_HTYPE,VTE_COLLIDER_TYPE,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetHType);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_FIXED, \"bDynamic\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_FIXED,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBisFixed);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_KINEMATIC, \"bKinematic\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_KINEMATIC,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBisKinematic);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_GRAVITY, \"bGravity\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_GRAVITY,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBisGravity);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_COLLISION, \"bCollider\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_COLLISION,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBisCollider);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_COLLISION_GROUP, \"bCollGroup\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_COLLISION_GROUP,CKPGUID_INT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetCollGroup);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_SLEEPING, \"bSleeping\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_SLEEPING,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBIsSleeping);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_FLAGS, \"bFlags\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_FLAGS,VTF_BODY_FLAGS,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetFlags);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_ISPOBJECT, \"bRegistered\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_ISPOBJECT,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBIsPObject);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_PVEL, \"bPointVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_PVEL,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_VECTOR,ParamOpBGetPVel);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_LPVEL, \"bLPointVel\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_LPVEL,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_VECTOR,ParamOpBGetLPVel);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BGET_MASS, \"bMass\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BGET_MASS,CKPGUID_FLOAT,CKPGUID_3DENTITY,CKPGUID_NONE,ParamOpBGetMass);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BJ_ISCONNECTED, \"bConnected\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BJ_ISCONNECTED,VTE_JOINT_TYPE,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpBJIsConnected);\r\n\r\n\tpm->RegisterOperationType(PARAM_OP_TYPE_BIS_SUB_SHAPE_OF, \"IsSubShape\");\r\n\tpm->RegisterOperationFunction(PARAM_OP_TYPE_BIS_SUB_SHAPE_OF,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_3DENTITY,ParamOpBIsSubShape);\r\n\r\n}\r\n\r\n\r\n\r\n#include \r\n\r\n\r\n\r\n#ifdef _DOC_ONLY_\r\n\t#pragma message (\"doc images only--------------------------------------------------------------------- \")\r\n#endif\r\n\r\n\r\n#ifdef DEMO_ONLY\r\n\t#pragma message (\"demo only--------------------------------------------------------------------------- \")\r\n#endif\r\n\r\n#ifdef MODULE_BASE_EXPORTS\r\n\t#pragma message (\"export dll---------------------------------------------------------------------------- \")\r\n#endif\r\n\r\n#ifdef DONGLE_VERSION\r\n\t#pragma message (\"dongle ------------------------------------------------------------------------------ \")\r\n#endif\r\n#ifndef _pch_h_\r\n\t#define _pch_h_\r\n\r\n\r\n\t#ifndef SAFE_DELETE\r\n\t#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }\r\n\t#endif \r\n\t#ifndef SAFE_DELETE_ARRAY\r\n\t#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }\r\n\t#endif \r\n\t#ifndef SAFE_RELEASE\r\n\t#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }\r\n\t#endif\r\n\r\n\t#ifndef WIN32_LEAN_AND_MEAN\r\n\t\t#define WIN32_LEAN_AND_MEAN\r\n\t\t#define VC_LEANMEAN\r\n\t#endif\r\n\r\n\r\n\t#if defined(_MSC_VER) && (_MSC_VER <= 1200)\r\n\t\t# pragma warning(disable : 4099)\r\n\t#endif\r\n\r\n\r\n\t#ifdef USEDIRECTX9\r\n\t\t#include \r\n\t\t#include \r\n\t\t#include \r\n\t\t#if defined(DEBUG) || defined(_DEBUG)\r\n\t\t#ifndef V\r\n\t\t#define V(x) { hr = x; if( FAILED(hr) ) { DXTrace( __FILE__, (DWORD)__LINE__, hr, #x, true ); } }\r\n\t\t#endif\r\n\t\t#ifndef V_RETURN\r\n\t\t#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return DXTrace( __FILE__, (DWORD)__LINE__, hr, #x, true ); } }\r\n\t\t#endif\r\n\t\t#else\r\n\t\t#ifndef V\r\n\t\t#define V(x) { hr = x; }\r\n\t\t#endif\r\n\t\t#ifndef V_RETURN\r\n\t\t#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return hr; } }\r\n\t\t#endif\r\n\t\t#endif\r\n\t#else\r\n//\t\t#include \r\n\t#endif\r\n\r\n\r\n\t#include \r\n\t#include \r\n\t#include \r\n\t#include \r\n\r\n\t#ifdef VIRTOOLS_USER_SDK\r\n\t\t#include \"CKAll.h\"\r\n\t#endif\r\n\r\n/*\t#ifdef xGUIForwards\r\n\t\t#include \r\n\t#endif\r\n*/\r\n\r\n/*\r\n\t#ifdef USE_ENIGMA\r\n\t\t#define ENIGMA_CLIENTSIDE\t\t// Set to import headers\r\n\t\t#include \"Enigma/Source/Precompiled.h\"\r\n\t\t#include \"Enigma/Source/Enigma.h\"\r\n\t#endif\r\n\r\n*/\r\n\t#ifdef D3D_DEBUG_INFO\r\n\r\n\t\t#ifndef DEBUG_VS // Uncomment this line to debug vertex shaders \r\n\t\t\t#define DEBUG_VS // Uncomment this line to debug pixel shaders \r\n\t\t#endif\r\n\r\n\t\t#ifndef DEBUG_PS // Uncomment this line to debug vertex shaders \r\n\t\t\t#define DEBUG_PS // Uncomment this line to debug pixel shaders \r\n\t\t#endif\r\n\r\n\r\n\t\t#ifdef D3D_DEBUG_INFO\r\n\t\t\t//const static long TryAtFirst = 0x00000080L;\r\n\t\t\t//const static bool ShaderDebugger = true ; \r\n\t\t#else\r\n\t\t\t//const static long TryAtFirst = 0x00000040L;\r\n\t\t\t//const static bool ShaderDebugger = false; \r\n\t\t#endif\r\n\r\n\t#endif\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBGet2Decl();\r\nCKERROR CreatePBGet2Proto(CKBehaviorPrototype **pproto);\r\nint PBGet2(const CKBehaviorContext& behcontext);\r\nCKERROR PBGet2CB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_CollisionGroup,\r\n\tbbI_Kinematic,\r\n\tbbI_Gravity,\r\n\tbbI_Collision,\r\n\tbbI_MassOffset,\r\n\tbbI_ShapeOffset,\r\n\r\n\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPBGet2Decl\r\n// FullName: FillBehaviorPBGet2Decl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBGet2Decl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBGetEx-Obsolete\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Retrieves physic related parameters.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x234334d3,0x70d06f74));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBGet2Proto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBGet2Proto\r\n// FullName: CreatePBGet2Proto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBGet2Proto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBGetEx-Obsolete\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*\r\n\tPBGetEx \r\n\r\n\tPBGet2 is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRetrieves various physical informations.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBGet2.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::getCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::isKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::isAffectedByGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::isCollisionEnabled(). \r\n\t
\r\n\t
\r\n\tCollisions Group: Enables output for collisions group.\r\n\t
\r\n\tKinematic Object: Enables output for kinematic object.\r\n\t
\r\n\tGravity: Enables output for gravity.\r\n\t
\r\n\tCollision: Enables output for collision. \r\n\t
\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\t\\include PBGetEx.cpp\r\n\t\r\n\t*/\r\n\t\r\n\r\n\t\r\n\tproto->DeclareSetting(\"Collisions Group\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Kinematic\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Mass Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Pivot Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\tproto->SetBehaviorCallbackFct( PBGet2CB );\r\n\t\r\n\tproto->DeclareOutParameter(\"Collisions Group\",CKPGUID_INT,\"0\");\r\n\tproto->DeclareOutParameter(\"Kinematic Object\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Mass Offset\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareOutParameter(\"Pivot Offset\",CKPGUID_VECTOR,\"0.0f\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBGet2);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBGet2\r\n// FullName: PBGet2\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBGet2(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\t// body exists already ? clean and delete it : \r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(result)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//linear damp : \r\n\t\t\tDWORD cGroup;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_CollisionGroup,&cGroup);\r\n\t\t\tif (cGroup)\r\n\t\t\t{\r\n\t\t\t\tint val = result->getCollisionsGroup();\r\n\t\t\t\tSetOutputParameterValue(beh,bbI_CollisionGroup,val);\r\n\t\t\t}\r\n\r\n\t\t\tDWORD kine;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Kinematic,&kine);\r\n\t\t\tif (kine)\r\n\t\t\t{\r\n\t\t\t\tint val = result->isKinematic();\r\n\t\t\t\tSetOutputParameterValue(beh,bbI_Kinematic,val);\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\tDWORD gravity;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Gravity,&gravity);\r\n\t\t\tif (gravity)\r\n\t\t\t{\r\n\t\t\t\tint val = result->getActor()->readBodyFlag(NX_BF_DISABLE_GRAVITY);\r\n\t\t\t\tSetOutputParameterValue(beh,bbI_Gravity,!val);\r\n\t\t\t}\r\n\r\n\t\t\t\t\r\n\t\t\tDWORD col;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Collision,&col);\r\n\t\t\tif (col)\r\n\t\t\t{\r\n\t\t\t\tint val = result->isCollisionEnabled();\r\n\t\t\t\tSetOutputParameterValue(beh,bbI_Collision,val);\r\n\t\t\t}\r\n\r\n\r\n\t\t\tDWORD mass;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_MassOffset,&mass);\r\n\t\t\tif (mass)\r\n\t\t\t{\r\n\t\t\t\tVxVector val = result->getMassOffset();\r\n\t\t\t\tSetOutputParameterValue(beh,bbI_MassOffset,val);\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\tDWORD pivot;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_ShapeOffset,&pivot);\r\n\t\t\tif (mass)\r\n\t\t\t{\r\n//\t\t\t\tVxVector val = result->getPivotOffset();\r\n//\t\t\t\tSetOutputParameterValue(beh,bbI_ShapeOffset,val);\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBGet2CB\r\n// FullName: PBGet2CB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBGet2CB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tDWORD collGroup;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_CollisionGroup,&collGroup);\r\n\t\t\tbeh->EnableOutputParameter(bbI_CollisionGroup,collGroup);\r\n\r\n\t\t\tDWORD kinematic;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Kinematic,&kinematic);\r\n\t\t\tbeh->EnableOutputParameter(bbI_Kinematic,kinematic);\r\n\t\t\t\r\n\t\t\tDWORD grav;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Gravity,&grav);\r\n\t\t\tbeh->EnableOutputParameter(bbI_Gravity,grav);\r\n\r\n\t\t\tDWORD coll;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_Collision,&coll);\r\n\t\t\tbeh->EnableOutputParameter(bbI_Collision,coll);\r\n\r\n\r\n\t\t\tDWORD mOff;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_MassOffset,&mOff);\r\n\t\t\tbeh->EnableOutputParameter(bbI_MassOffset,mOff);\r\n\r\n\t\t\tDWORD pOff;\r\n\t\t\tbeh->GetLocalParameterValue(bbI_ShapeOffset,&pOff);\r\n\t\t\tbeh->EnableOutputParameter(bbI_ShapeOffset,pOff);\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"ISession.h\"\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xMessageTypes.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorNCheckForLanServerDecl();\r\nCKERROR CreateNCheckForLanServerProto(CKBehaviorPrototype **);\r\nint NCheckForLanServer(const CKBehaviorContext& behcontext);\r\nCKERROR NCheckForLanServerCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_STOP,\r\n\tBB_IT_NEXT\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_MESSAGE,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_MESSAGE,\r\n\tBB_O_ERROR,\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_SENDER_ID,\r\n\tBB_OP_PRIVATE,\r\n\tBB_OP_ERROR,\r\n};\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNCheckForLanServerDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NCheckForLanServer\");\t\r\n\tod->SetDescription(\"Waits for a Message from the Network.\");\r\n\t\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x4bca58d9,0x3f4739fc));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNCheckForLanServerProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNCheckForLanServerProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NCheckForLanServer\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInParameter(\"Timeout\", CKPGUID_TIME, \"5000\");\r\n\t\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Off\");\r\n\t\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Server\");\r\n\t\r\n\t\r\n\tproto->DeclareOutParameter(\"Server Address\", CKPGUID_STRING, \"\");\r\n\tproto->DeclareLocalParameter(\"elapsed time\", CKPGUID_FLOAT,0);\r\n\r\n\t\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(NCheckForLanServer);\r\n\tproto->SetBehaviorCallbackFct(NCheckForLanServerCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NCheckForLanServer(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\tvtNetworkManager *nman = GetNM();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id + session name : \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\r\n\tfloat elapsedTime = 0.0f;\r\n\tbeh->GetLocalParameterValue(0,&elapsedTime);\r\n\r\n\tif (!nman->GetClientNetInterface())\r\n\t{\r\n\t\tnman->CreateClient(true,0,NULL);\r\n\t}\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//reset elapsed time :\r\n\t\telapsedTime = 0.0f;\r\n\t\tbeh->SetLocalParameterValue(0,&elapsedTime);\r\n\t\t\r\n\t\t//TNL::Address addr(\"IP:255.255.255.0:28999\");\r\n\t\tTNL::Address broadcastAddress(IPProtocol, Address::Broadcast, 28999);\r\n\t\tif (GetNM()->GetClientNetInterface())\r\n\t\t{\r\n\t\t\t//cin->getLocalLanServers().clear();\r\n//\t\t\tnman->GetClientNetInterface()->sendPing(broadcastAddress,xNetInterface::Constants::ScanPingRequest);\r\n\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\r\n\t}\r\n\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR NCheckForLanServerCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n#include \"IParameter.h\"\r\n\r\n#include \r\n\r\n\r\nNxShape *pFactory::cloneShape(CK3dEntity *src,CK3dEntity *dst,CK3dEntity*dstBodyReference,int copyFlags,int bodyFlags/* =0 */)\r\n{\r\n\r\n\tif (!src || !dst )\r\n\t\treturn NULL;\r\n\r\n\tpRigidBody *srcBody = GetPMan()->getBody(src);\r\n\tif (!srcBody)\r\n\t\treturn NULL;\r\n\r\n\tpRigidBody *dstBody = GetPMan()->getBody(dstBodyReference);\r\n\tif (!dstBody)\r\n\t\treturn NULL;\r\n\t\r\n\tif (dstBody->isSubShape(dst))\r\n\t\treturn NULL;\r\n\r\n\r\n\tNxShape *srcShape = srcBody->getSubShape(src);\r\n\tif (!srcShape)\r\n\t\treturn NULL;\r\n\r\n\tbool isSubShape=srcBody->isSubShape(src);\r\n\r\n\r\n\tpObjectDescr oDescr;\r\n\tint attTypePBSetup = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Try to copy it directly from the source object\r\n\t//\r\n\tif ( !src->HasAttribute(attTypePBSetup) && isSubShape )\r\n\t{\r\n\t\tpSubMeshInfo* sInfo = (pSubMeshInfo*)srcShape->userData;\r\n\t\tif (sInfo )\r\n\t\t{\r\n\t\t\tconst pObjectDescr &srcDescr = sInfo->initDescription;\r\n\t\t\tmemcpy(&oDescr,&srcDescr,sizeof(pObjectDescr));\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Try to copy it directly from the source objects attribute\r\n\t//\r\n\r\n\tif (dst->HasAttribute(attTypePBSetup))\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// fill object description\r\n\t\t//\r\n\t\t\r\n\t\tCKParameterOut *par = dst->GetAttributeParameter(attTypePBSetup);\r\n\t\tif (!par)\r\n\t\t\treturn 0;\r\n\r\n\t\tIParameter::Instance()->copyTo(&oDescr,par);\r\n\t\toDescr.version = pObjectDescr::E_OD_VERSION::OD_DECR_V1;\r\n\r\n\t}\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// adjust data\r\n\t//\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// find pivot settings \r\n\t//\r\n\tif ( (copyFlags & PB_CF_PIVOT_SETTINGS ) )\r\n\t{\r\n\t\t//check in objects attribute\r\n\t\tint attPivot = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_PIVOT_OFFSET);\r\n\t}\r\n\r\n\r\n\tif (oDescr.flags & BF_SubShape)\r\n\t{\r\n\t\tif (oDescr.hullType == HT_Wheel)\r\n\t\t{\r\n\t\t\tVxVector loc;\r\n\t\t\tpWheel *wheel = createWheel(dstBodyReference,dst,oDescr.wheel,oDescr.convexCylinder,loc);\r\n\t\t\tif(wheel && wheel->castWheel2() )\r\n\t\t\t\treturn wheel->castWheel2()->getWheelShape();\r\n\t\t\telse\r\n\t\t\t\treturn NULL;\r\n\r\n\t\t}else if( oDescr.hullType != HT_Cloth)\r\n\t\t{\r\n\r\n\t\t\tsrcBody->addSubShape(NULL,oDescr,dst);\r\n\t\t\tNxShape *result = srcBody->getSubShape(dst);\r\n\t\t\tif (result)\r\n\t\t\t{\r\n\t\t\t\t//----------------------------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Adjust mass \r\n\t\t\t\t//\r\n\t\t\t\tif ( ( copyFlags & PB_CF_MASS_SETTINGS) )\r\n\t\t\t\t{\r\n\t\t\t\t/*\tsrcBody->updateMassSettings(srcBody->getInitialDescription()->mass);\r\n\t\t\t\t\r\n\t\t\t\t\t\tresult->updateMassSettings(oDescr.mass);\r\n\t\t\t\t\telse if(pFactory::Instance()->findSettings(oDescr.mass,referenceObject))\r\n\t\t\t\t\t\tresult->updateMassSettings(oDescr.mass);\r\n\t\t\t\t\t\t*/\r\n\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n\r\n\t/*\r\n\tint sType = vtAgeia::getHullTypeFromShape(srcShape);\r\n\r\n\tswitch(sType)\r\n\t{\r\n\r\n\t\tcase HT_Sphere:\r\n\t\t\t{\r\n\t\t\t\tNxSphereShape *tShape = srcShape->isSphere();\r\n\t\t\t\tNxSphereShapeDesc old;\r\n\t\t\t\ttShape->saveToDesc(old);\r\n\r\n\t\t\t}\r\n\t}\r\n\t\r\n\r\n\t*/\r\n\r\n\r\n}\r\n\r\nNxShape *pFactory::createShape(CK3dEntity *bodyReference,pObjectDescr descr,CK3dEntity *srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation)\r\n{\r\n\t\r\n\tNxShape *result = NULL;\r\n\tif (!bodyReference || !mesh )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tpRigidBody *body=GetPMan()->getBody(bodyReference);\r\n\r\n\tif (!body)\r\n\t\treturn NULL;\r\n\r\n\tNxActor *actor = body->getActor();\r\n\r\n\tif (!actor)\r\n\t\treturn NULL;\r\n\r\n\tint hType = descr.hullType;\r\n\tVxVector box_s = mesh->GetLocalBox().GetSize();\r\n\tfloat density = descr.density;\r\n\tfloat skinWidth = descr.skinWidth;\r\n\tfloat radius = mesh->GetRadius();\r\n\tNxQuat rot = pMath::getFrom(localRotation);\r\n\tNxVec3 pos = pMath::getFrom(localPos);\r\n\tCK_ID srcID = mesh->GetID();\r\n\r\n\r\n\tpWheel *wheel = NULL;\r\n\tpSubMeshInfo *sInfo = NULL;\r\n\r\n\t\r\n\tswitch(hType)\r\n\t{\r\n\r\n\t\tcase HT_ConvexCylinder:\r\n\t\t{\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tpConvexCylinderSettings &cSettings = descr.convexCylinder;\r\n\r\n\t\t\tiAssertW( ( descr.mask & OD_ConvexCylinder),\r\n\t\t\t\tpFactory::Instance()->findSettings(cSettings,srcReference),\r\n\t\t\t\t\"Hull type has been set to convex cylinder but there is no descriptions \\\r\n\t\t\t\tpassed or activated in the pObjectDescr::mask.Trying object attributes....\");\r\n\r\n\t\t\tif (cSettings.radius.reference)\r\n\t\t\t\tcSettings.radius.evaluate(cSettings.radius.reference);\r\n\r\n\t\t\tif (cSettings.height.reference)\r\n\t\t\t\tcSettings.height.evaluate(cSettings.height.reference);\r\n\r\n\t\t\tcSettings.radius.value = cSettings.radius.value > 0.0f ? (cSettings.radius.value*0.5) : (box_s.v[cSettings.radius.referenceAxis] * 0.5f);\r\n\t\t\tcSettings.height.value = cSettings.height.value > 0.0f ? cSettings.height.value : (box_s.v[cSettings.height.referenceAxis] * 0.5f);\r\n\r\n\t\t\tiAssertW( cSettings.isValid() , cSettings.setToDefault(),\"\");\r\n\t\t\tbool resultAssert = true;\r\n\r\n\t\t\tiAssertWR( pFactory::Instance()->_createConvexCylinderMesh(&shape,cSettings,srcReference),\"\",resultAssert);\r\n\t\t\t/*\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tif (!_createConvexCylinder(&shape,srcReference))\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n*/\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.localPose.t = pos;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.skinWidth = skinWidth;\r\n\r\n\t\t\tresult = actor->createShape(shape);\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Box:\r\n\t\t{\r\n\t\t\tNxBoxShapeDesc shape;\r\n\t\t\tshape.dimensions = pMath::getFrom(box_s)*0.5f;\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.localPose.t = pos;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Sphere:\r\n\t\t{\r\n\t\t\tNxSphereShapeDesc shape;\r\n\t\t\tshape.radius = radius;\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.localPose.t = pMath::getFrom(localPos);\r\n\t\t\tif (skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Mesh:\r\n\t\t{\r\n\t\t\tNxTriangleMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\r\n\t\t\tpFactory::Instance()->createMesh(&actor->getScene(),mesh,myMesh);\r\n\r\n\t\t\tNxTriangleMeshShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookTriangleMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't cook mesh!\");\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createTriangleMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.localPose.t = pMath::getFrom(localPos);\r\n\t\t\tif (skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t\tCloseCooking();\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_ConvexMesh:\r\n\t\t{\r\n\t\t\r\n\t\t\tif (mesh->GetVertexCount()>=256 )\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Only 256 vertices for convex meshes allowed, by Ageia!\");\r\n\t\t\t\tgoto nothing;\r\n\t\t\t}\r\n\r\n\t\t\tNxConvexMeshDesc myMesh;\r\n\t\t\tmyMesh.setToDefault();\r\n\t\t\tpFactory::Instance()->createConvexMesh(&actor->getScene(),mesh,myMesh);\r\n\r\n\t\t\tNxConvexShapeDesc shape;\r\n\t\t\tbool status = InitCooking();\r\n\t\t\tif (!status) \r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\t\t\tgoto nothing;\r\n\t\t\t}\r\n\t\t\tMemoryWriteBuffer buf;\r\n\r\n\t\t\tstatus = CookConvexMesh(myMesh, buf);\r\n\t\t\tif (!status) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't cook convex mesh!\");\r\n\t\t\t\tgoto nothing;\r\n\t\t\t}\r\n\t\t\tshape.meshData\t= GetPMan()->getPhysicsSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\t\tshape.density = density;\r\n\t\t\t\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.localPose.t = pMath::getFrom(localPos);\r\n\t\t\tif (skinWidth!=-1.0f)\r\n\t\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t\tCloseCooking();\r\n\r\n\r\n\t\t\tif (myMesh.points)\r\n\t\t\t{\r\n\t\t\t\tdelete [] myMesh.points;\r\n\t\t\t}\r\n\r\n\t\t\tif (myMesh.triangles)\r\n\t\t\t{\r\n\t\t\t\tdelete []myMesh.triangles;\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Capsule:\r\n\t\t{\r\n\t\t\tNxCapsuleShapeDesc shape;\r\n\r\n\t\t\tpCapsuleSettingsEx &cSettings = descr.capsule;\r\n\t\t\t\r\n\t\t\tiAssertW( ( descr.mask & OD_Capsule),\r\n\t\t\t\tpFactory::Instance()->findSettings(cSettings,srcReference),\r\n\t\t\t\t\"Hull type has been set to convex cylinder but there is no descriptions \\\r\n\t\t\t\tpassed or activated in the pObjectDescr::mask.Trying object attributes....\");\r\n\r\n\t\t\tbool resultAssert = true;\r\n\r\n\t\t\tif (cSettings.radius.reference)\r\n\t\t\t\tcSettings.radius.evaluate(cSettings.radius.reference);\r\n\r\n\t\t\tif (cSettings.height.reference)\r\n\t\t\t\tcSettings.height.evaluate(cSettings.height.reference);\r\n\r\n\t\t\tiAssertWR(cSettings.isValid(),cSettings.setToDefault(),resultAssert);\r\n\r\n\t\t\tshape.radius = cSettings.radius.value > 0.0f ? (cSettings.radius.value*0.5) : (box_s.v[cSettings.radius.referenceAxis] * 0.5f);\r\n\t\t\tshape.height = cSettings.height.value > 0.0f ? (cSettings.height.value-( 2*shape.radius)) : (box_s.v[cSettings.height.referenceAxis] - ( 2*shape.radius)) ;\r\n\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.localPose.t = pos;\r\n\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase HT_Wheel:\r\n\t\t{\r\n\t\t\t\r\n\t\t\tpWheelDescr &wheelDescr = descr.wheel;\r\n\t\t\tCKParameterOut *wheelParameter = NULL;\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// determine wheel settings \r\n\t\t\t//\r\n\t\t\tif (!(descr.mask & OD_Wheel))\r\n\t\t\t{\r\n\t\t\t\twheelParameter = pFactory::Instance()->findSettings(wheelDescr,srcReference);\r\n\t\t\t}\r\n\r\n\t\t\tbool resultAssert = true;\r\n\t\t\tiAssertWR(wheelDescr.isValid(),wheelDescr.setToDefault(),resultAssert);\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// determine radius\r\n\t\t\t//\r\n\t\t\tif (wheelDescr.radius.reference == 0 && wheelDescr.radius.value == 0.0f )\r\n\t\t\t{\r\n\t\t\t\tfloat radiusBestFit = 0.0f;\r\n\t\t\t\tif (box_s[0] > radiusBestFit)\r\n\t\t\t\t\tradiusBestFit = box_s[0];\r\n\r\n\t\t\t\tif (box_s[1] > radiusBestFit)\r\n\t\t\t\t\tradiusBestFit = box_s[1];\r\n\t\t\t\t\r\n\t\t\t\tif (box_s[2] > radiusBestFit)\r\n\t\t\t\t\tradiusBestFit = box_s[2];\r\n\t\t\t\t\r\n\t\t\t\twheelDescr.radius.value = radiusBestFit * 0.5f;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tiAssertW(wheelDescr.radius.isValid(),wheelDescr.radius.evaluate(srcReference),\"\");\r\n\t\t\tif(!wheelDescr.radius.isValid())\r\n\t\t\t\twheelDescr.radius.value = srcReference->GetRadius();\r\n\r\n\t\t\t\r\n\t\t\tVxVector box_s = mesh->GetLocalBox().GetSize();\r\n\t\t\tfloat radius = wheelDescr.radius.value > 0.0f ? wheelDescr.radius.value : box_s.v[wheelDescr.radius.referenceAxis] * 0.5f;\r\n\r\n\t\t\tNxWheelShapeDesc shape;\r\n\t\t\tshape.setToDefault();\r\n\r\n\t\t\tshape.radius = radius;\r\n\t\t\tshape.localPose.M = rot;\r\n\t\t\tshape.localPose.t = pos;\r\n\r\n\t\t\tfloat heightModifier = (wheelDescr.wheelSuspension + radius ) / wheelDescr.wheelSuspension;\r\n\t\t\tshape.suspension.spring = wheelDescr.springRestitution*heightModifier;\r\n\t\t\tshape.suspension.damper = wheelDescr.springDamping * heightModifier;\r\n\t\t\tshape.suspension.targetValue = wheelDescr.springBias * heightModifier;\r\n\t\t\tshape.suspensionTravel = wheelDescr.wheelSuspension;\r\n\t\t\tshape.inverseWheelMass = wheelDescr.inverseWheelMass;\r\n\r\n\r\n\t\t\t\r\n\t\t\tconst pTireFunction& latFunc = wheelDescr.latFunc;\r\n\t\t\tconst pTireFunction& longFunc = wheelDescr.longFunc;\r\n\r\n\r\n\t\t\tNxTireFunctionDesc lngTFD;\r\n\t\t\tlngTFD.extremumSlip = longFunc.extremumSlip ;\r\n\t\t\tlngTFD.extremumValue = longFunc.extremumValue;\r\n\t\t\tlngTFD.asymptoteSlip = longFunc.asymptoteSlip;\r\n\t\t\tlngTFD.asymptoteValue = longFunc.asymptoteValue;\r\n\t\t\tlngTFD.stiffnessFactor = longFunc.stiffnessFactor;\r\n\r\n\t\t\tNxTireFunctionDesc latTFD;\r\n\t\t\tlatTFD.extremumSlip = latFunc.extremumSlip ;\r\n\t\t\tlatTFD.extremumValue = latFunc.extremumValue;\r\n\t\t\tlatTFD.asymptoteSlip = latFunc.asymptoteSlip;\r\n\t\t\tlatTFD.asymptoteValue = latFunc.asymptoteValue;\r\n\t\t\tlatTFD.stiffnessFactor = latFunc.stiffnessFactor;\r\n\t\t\t\r\n\t\t\tif ( !(wheelDescr.wheelFlags & WF_IgnoreTireFunction) )\r\n\t\t\t{\r\n\t\t\t\tshape.lateralTireForceFunction =latTFD;\r\n\t\t\t\tshape.longitudalTireForceFunction = lngTFD;\r\n\t\t\t}\r\n\t\t\tshape.wheelFlags =wheelDescr.wheelShapeFlags;\r\n\t\t\tshape.density = density;\r\n\t\t\tshape.skinWidth = skinWidth;\r\n\t\t\t\r\n\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// evaluate wheel settings into attribute parameters \r\n\t\t\t//\r\n\t\t\tif (wheelParameter)\r\n\t\t\t{\r\n\t\t\t\tIParameter::Instance()->copyTo(wheelParameter,descr.wheel);\r\n\r\n\t\t\t}\r\n\t\t\tresult = actor->createShape(shape);\r\n\t\t}\r\n\t}\r\n\r\n\tif(!result)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// add sub mesh meta\r\n\r\n\t//\r\n\tsInfo = new pSubMeshInfo();\r\n\r\n\tsInfo->meshID = srcID;\r\n\tsInfo->mesh = mesh;\r\n\r\n\tsInfo->entID = srcReference->GetID();\r\n\tsInfo->refObject = srcReference;\r\n\t\r\n\tresult->setName(srcReference->GetName());\r\n\tresult->userData = (void*)sInfo;\r\n\tsInfo->initDescription = descr;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// wheel extra data\r\n\t//\r\n\tif ( descr.hullType == HT_Wheel )\r\n\t{\r\n\t\tsInfo->wheel = new pWheel2(body,&descr.wheel,srcReference);\r\n\t\t((pWheel2*)sInfo->wheel)->setWheelShape((NxWheelShape*)result->isWheel());\r\n\t\t\r\n\t\tsInfo->wheel->setEntID(srcReference->GetID());\r\n\t\t((pWheel2*)sInfo->wheel)->setEntity(srcReference);\r\n\t\t//((pWheel2*)wheel)->setEntity(static_cast(GetPMan()->GetContext()->GetObject(srcReference->GetID())));\r\n\t\tsInfo->wheel->mWheelFlags = descr.wheel.wheelFlags;\r\n\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Material\r\n\t//\r\n\tif ((descr.mask & OD_Material))\r\n\t\tbody->updateMaterialSettings(descr.material,srcReference);\r\n\telse if(pFactory::Instance()->findSettings(descr.material,srcReference))\r\n\t\tbody->updateMaterialSettings(descr.material,srcReference);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Collision\r\n\t//\r\n\tif ((descr.mask & OD_Collision))\r\n\t\tbody->updateCollisionSettings(descr.collision,srcReference);\r\n\telse if(pFactory::Instance()->findSettings(descr.collision,srcReference))\r\n\t\tbody->updateCollisionSettings(descr.collision,srcReference);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Adjust pivot \r\n\t//\r\n\t\r\n\tif ( (descr.mask & OD_Pivot) )\r\n\t{\r\n\t\tiAssertW1( descr.pivot.isValid(),descr.pivot.setToDefault());\r\n\t\tbody->updatePivotSettings(descr.pivot,srcReference);\r\n\t}else if(pFactory::Instance()->findSettings(descr.pivot,srcReference))\r\n\t\tbody->updatePivotSettings(descr.pivot,srcReference);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// post \r\n\t//\r\n\tif (descr.flags & BF_TriggerShape )\r\n\t{\r\n\t\tresult->setFlag(NX_TRIGGER_ENABLE,TRUE);\r\n\t\tCKParameterOut *triggerAttributeParameter = srcReference->GetAttributeParameter(GetPMan()->att_trigger);\r\n\t\tif (triggerAttributeParameter)\r\n\t\t{\r\n\t\t\tint triggerFlags = vtTools::AttributeTools::GetValueFromAttribute(srcReference,GetPMan()->att_trigger);\r\n\t\t\tresult->setFlag(NX_TRIGGER_ON_ENTER,triggerFlags & NX_TRIGGER_ON_ENTER);\r\n\t\t\tresult->setFlag(NX_TRIGGER_ON_STAY,triggerFlags & NX_TRIGGER_ON_STAY);\r\n\t\t\tresult->setFlag(NX_TRIGGER_ON_LEAVE,triggerFlags & NX_TRIGGER_ON_LEAVE);\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Mass\r\n\t//\r\n\tif ((descr.mask & OD_Mass))\r\n\t\tbody->updateMassSettings(descr.mass);\r\n\telse if(pFactory::Instance()->findSettings(descr.mass,srcReference))\r\n\t\tbody->updateMassSettings(descr.mass);\r\n\r\n\treturn result;\r\n\r\n\tnothing : \r\n\treturn NULL;\r\n\r\n}\r\n\r\nbool pFactory::_createConvexCylinderMesh(NxConvexShapeDesc *dstShapeDescription,pConvexCylinderSettings& srcSettings,CK3dEntity*referenceObject)\r\n{\r\n\r\n\r\n\r\n#ifdef _DEBUG\r\n\tassert(referenceObject);\t// <- should never happen !\r\n#endif // _DEBUG\r\n\r\n\tbool result = false;\r\n\r\n\t\r\n/*\tsrcSettings.radius.value *=0.5f;\r\n\tsrcSettings.height.value *=0.5f;\r\n*/\r\n\tNxArray points;\r\n\tNxVec3 center(0,0,0);\r\n\r\n\tNxVec3 frontAxis = getFrom(srcSettings.forwardAxis);\t\t\t\t// = wheelDesc->downAxis.cross(wheelDesc->wheelAxis);\r\n\tNxVec3 downAxis = getFrom(srcSettings.downAxis);//downAxis *=-1.0;\t// = wheelDesc->downAxis;\r\n\tNxVec3 wheelAxis = getFrom(srcSettings.rightAxis);\t\t\t\t// = wheelDesc->wheelAxis;\r\n\r\n\r\n\t//frontAxis.normalize();\r\n\tfrontAxis *= srcSettings.radius.value;\r\n\t//downAxis.normalize();\r\n\tdownAxis *= srcSettings.radius.value;\r\n\t//wheelAxis.normalize();\r\n\twheelAxis *= srcSettings.height.value;\r\n\r\n\tNxReal step;\r\n\r\n\tif(srcSettings.buildLowerHalfOnly) \r\n\t{\r\n\t\tif((srcSettings.approximation& 0x1) == 0)\r\n\t\t\tsrcSettings.approximation++;\r\n\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(srcSettings.approximation*2);\r\n\t}\r\n\telse \r\n\t{\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(srcSettings.approximation);\r\n\t}\r\n\tfor(NxU32 i = 0; i < srcSettings.approximation; i++) \r\n\t{\r\n\t\tNxReal iReal;\r\n\t\tif(srcSettings.buildLowerHalfOnly) \r\n\t\t{\r\n\t\t\tiReal = (i > (srcSettings.approximation >> 1))?(NxReal)(i+srcSettings.approximation):(NxReal)i;\r\n\t\t} \r\n\t\telse \r\n\t\t{\r\n\t\t\tiReal = (NxReal)i;\r\n\t\t}\r\n\t\tNxReal Sin, Cos;\r\n\t\tNxMath::sinCos(step * iReal, Sin, Cos);\r\n\t\tNxVec3 insPoint = (downAxis * -Cos) + (frontAxis * Sin);\r\n\t\tpoints.pushBack(insPoint + wheelAxis);\r\n\t\tpoints.pushBack(insPoint - wheelAxis);\r\n\t}\r\n\r\n\tNxConvexMeshDesc convexDesc;\r\n\tconvexDesc.numVertices\t\t\t= points.size();\r\n\tconvexDesc.pointStrideBytes\t\t= sizeof(NxVec3);\r\n\tconvexDesc.points\t\t\t\t= &points[0].x;\r\n\r\n\r\n//\tsrcSettings.convexFlags |=NX_CF_COMPUTE_CONVEX;\r\n//\tconvexDesc.flags\t\t\t\t|= srcSettings.convexFlags;\r\n\r\n\tint cf = CF_ComputeConvex;\r\n\tcf |= srcSettings.convexFlags;\r\n\t\r\n\tconvexDesc.flags\t\t\t\t|= cf;\r\n\r\n\r\n\r\n\r\n\t// Cooking from memory\r\n\tbool status = InitCooking();\r\n\tif (!status) {\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't initiate cooking lib!\");\r\n\t\treturn NULL;\r\n\t}\r\n\tMemoryWriteBuffer buf;\r\n\tint s = convexDesc.isValid();\r\n\tif(CookConvexMesh(convexDesc, buf)) \r\n\t{\r\n\t\t//NxConvexShapeDesc convexShapeDesc;\r\n\r\n\t\tdstShapeDescription->meshData = getPhysicSDK()->createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\tdstShapeDescription->localPose.t = center;\r\n\t\tdstShapeDescription->localPose.M.setColumn(0, NxVec3( 1, 0, 0));\r\n\t\tdstShapeDescription->localPose.M.setColumn(1, NxVec3( 0,-1, 0));\r\n\t\tdstShapeDescription->localPose.M.setColumn(2, NxVec3( 0, 0, -1));\r\n\t\tif(dstShapeDescription->meshData != NULL) \r\n\t\t{\r\n\t\t\tresult = true;\r\n\t\t\t//\tNxU32 shapeNumber = actor->getNbShapes();\r\n\t\t\t//\tresult = actor->createShape(convexShapeDesc)->isConvexMesh();\r\n\t\t\t//\tif (!result) {\r\n\t\t\t//\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_AGEIA,\"Couldn't create convex cylinder mesh\");\r\n\t\t\t//\t}\r\n\t\t\t//wheel->wheelConvex->userData = wheel;\r\n\t\t}\r\n\t}\r\n\tCloseCooking();\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\n\r\nNxShape * pFactory::_createConvexCylinder(NxActor *actor,int approximation,VxVector _forwardAxis,VxVector _downAxis,VxVector _rightAxis,float height,float radius,bool buildLowerHalf,int shapeFlags)\r\n{\r\n\r\n\tif (!actor || approximation<1 )\r\n\t\treturn NULL;\r\n\r\n\tNxConvexShape *result = NULL;\r\n\tNxArray points;\r\n\tNxVec3 center(0,0,0);\r\n\r\n\tNxVec3 frontAxis = getFrom(_forwardAxis);// = wheelDesc->downAxis.cross(wheelDesc->wheelAxis);\r\n\tNxVec3 downAxis = getFrom(_downAxis);// = wheelDesc->downAxis;\r\n\r\n\tdownAxis *=-1.0;\r\n\r\n\tNxVec3 wheelAxis = getFrom(_rightAxis);// = wheelDesc->wheelAxis;\r\n\t//frontAxis.normalize();\r\n\tfrontAxis *= radius;\r\n\t//downAxis.normalize();\r\n\tdownAxis *= radius;\r\n\t//wheelAxis.normalize();\r\n\twheelAxis *= height;\r\n\r\n\tNxReal step;\r\n\r\n\tif(buildLowerHalf) \r\n\t{\r\n\t\tif((approximation & 0x1) == 0)\r\n\t\t\tapproximation++;\r\n\t\t\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(approximation*2);\r\n\t}\r\n\telse \r\n\t{\r\n\t\tstep = (NxReal)(NxTwoPi) / (NxReal)(approximation);\r\n\t}\r\n\tfor(NxU32 i = 0; i < approximation; i++) \r\n\t{\r\n\t\tNxReal iReal;\r\n\t\tif(buildLowerHalf) \r\n\t\t{\r\n\t\t\tiReal = (i > (approximation >> 1))?(NxReal)(i+approximation):(NxReal)i;\r\n\t\t} \r\n\t\telse \r\n\t\t{\r\n\t\t\tiReal = (NxReal)i;\r\n\t\t}\r\n\t\tNxReal Sin, Cos;\r\n\t\tNxMath::sinCos(step * iReal, Sin, Cos);\r\n\t\tNxVec3 insPoint = (downAxis * -Cos) + (frontAxis * Sin);\r\n\t\tpoints.pushBack(insPoint + wheelAxis);\r\n\t\tpoints.pushBack(insPoint - wheelAxis);\r\n\t}\r\n\r\n\tNxConvexMeshDesc convexDesc;\r\n\tconvexDesc.numVertices\t\t\t= points.size();\r\n\tconvexDesc.pointStrideBytes\t\t= sizeof(NxVec3);\r\n\tconvexDesc.points\t\t\t\t= &points[0].x;\r\n\tconvexDesc.flags\t\t\t\t|= shapeFlags;\r\n\t//convexDesc.flags\t\t\t\t|= NX_CF_COMPUTE_CONVEX;\r\n\r\n\t// Cooking from memory\r\n\tbool status = InitCooking();\r\n\tif (!status) {\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't initiate cooking lib!\");\r\n\t\treturn NULL;\r\n\t}\r\n\tMemoryWriteBuffer buf;\r\n\tif(CookConvexMesh(convexDesc, buf)) \r\n\t{\r\n\t\tNxConvexShapeDesc convexShapeDesc;\r\n\t\tconvexShapeDesc.meshData = actor->getScene().getPhysicsSDK().createConvexMesh(MemoryReadBuffer(buf.data));\r\n\t\tconvexShapeDesc.localPose.t = center;\r\n\t\tconvexShapeDesc.localPose.M.setColumn(0, NxVec3( 1, 0, 0));\r\n\t\tconvexShapeDesc.localPose.M.setColumn(1, NxVec3( 0,-1, 0));\r\n\t\tconvexShapeDesc.localPose.M.setColumn(2, NxVec3( 0, 0, -1));\r\n\t\tif(convexShapeDesc.meshData != NULL) \r\n\t\t{\r\n\t\t\tNxU32 shapeNumber = actor->getNbShapes();\r\n\t\t\tresult = actor->createShape(convexShapeDesc)->isConvexMesh();\r\n\t\t\tif (!result) {\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create convex cylinder mesh\");\r\n\t\t\t}\r\n\t\t\t//wheel->wheelConvex->userData = wheel;\r\n\t\t}\r\n\t}\r\n\t\r\n\tCloseCooking();\r\n\r\n\treturn result;\r\n\t\r\n}\r\n\r\nNxShapeDesc& pFactory::createShape(int hullType,CK3dEntity*ent,float density)\r\n{\r\n\r\n\tassert(ent);\r\n\tfloat radius = ent->GetRadius();\r\n\tif (ent->GetRadius() < 0.001f )\r\n\t{\r\n\t\tradius = 1.0f;\r\n\t}\r\n\r\n\tVxVector box_s= BoxGetZero(ent);\r\n\tswitch(hullType)\r\n\t{\r\n\r\n\tcase HT_Box:\r\n\t\t{\r\n\t\t\tNxBoxShapeDesc result;\r\n\t\t\t//result.setToDefault();\r\n\t\t\tresult.dimensions = pMath::getFrom(box_s);\r\n\r\n\t\t\tresult.density = density;\r\n\t\t\treturn result;\t\r\n\t\t}\r\n\tcase HT_Sphere:\r\n\t\t{\r\n\t\t\tNxSphereShapeDesc result;\r\n\t\t\t//result.setToDefault();\r\n\t\t\tresult.localPose.t = NxVec3(0,radius,0);\r\n\t\t\tresult.radius = radius;\r\n\t\t\tresult.density = density;\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}\r\n\r\n\tNxBoxShapeDesc result;\r\n\tresult.setToDefault();\r\n\tresult.dimensions = pMath::getFrom(box_s);\r\n\treturn result;\r\n}\r\n#include \"CKAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n\r\nenum vtEventState\r\n{\r\n\tEEVT_STARTED,\r\n\tEEVT_FINISHED\r\n};\r\n\r\nstruct vtExternalEvent\r\n{\r\n\tunsigned long timeOfCreation;\r\n\t\r\n\tchar command[MAX_PATH];\r\n\tchar commandArg[MAX_PATH];\r\n\tvtEventState state;\r\n};\r\n\r\nstruct TSharedMemory {\r\n\r\n\tvtExternalEvent event;\r\n};\r\n\r\nstruct haptekMsg\r\n{\r\n\tXString command;\r\n\tint k;\r\n\r\n};xcopy .\\examples\\*.* .\\doxyOutput\\html /s /e /y\r\n\r\ndoxygen doxyConfigAll.dox\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVControlDecl();\r\nCKERROR CreatePVControlProto(CKBehaviorPrototype **pproto);\r\nint PVControl(const CKBehaviorContext& behcontext);\r\nCKERROR PVControlCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\r\nenum bInTrigger\r\n{\r\n\tTI_DO,\r\n};\r\n\r\nenum bOutputs\r\n{\r\n\r\n\tO_Flags,\r\n\tO_Gear,\r\n\tO_RPM,\r\n\tO_RPM_WHEELS,\r\n\tO_RATIO,\r\n\r\n\r\n};\r\n\r\n\r\nenum bInputs\r\n{\r\n\tI_Acc,\r\n\tI_Steer,\r\n\tI_AnalogAcc,\r\n\tI_AnalogSteering,\r\n\tI_Handbrake,\r\n\t\t\r\n};\r\n\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap3[] = \r\n{\r\n\t\r\n\tBB_SPIN(I_Acc,CKPGUID_FLOAT,\"Acceleration\",\"0\"),\r\n\tBB_SPIN(I_Steer,CKPGUID_FLOAT,\"Steering\",\"0\"),\r\n\tBB_SPIN(I_AnalogAcc,CKPGUID_BOOL,\"Analog Acceleration\",\"0\"),\r\n\tBB_SPIN(I_AnalogSteering,CKPGUID_BOOL,\"Analog Steering\",\"0\"),\r\n\tBB_SPIN(I_Handbrake,CKPGUID_BOOL,\"Handbrake\",\"0\"),\r\n\r\n\r\n};\r\n\r\n#define BBIMAP pInMap3\r\n\r\nCKERROR PVControlCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(BBIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(BBIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(BBIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPVControlDecl\r\n// FullName: FillBehaviorPVControlDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPVControlDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVControl\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Controls a vehicle by real values instead of input trigger\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x550d3ca3,0x27f10ac3));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVControlProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVControlProto\r\n// FullName: CreatePVControlProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVControlProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVControl\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/* PVControl \r\n\r\n\tPVControl is categorized in \\ref Vehicles\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tControls a vehicle by real values instead of input trigger.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVControl.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the vehicle. The entity needs to be physicalized before. It needs to have at least one wheel in its hierarchy. \r\n\t
\r\n\t
\r\n\tAcceleration: The acceleration for this frame.
\r\n\tRange: [0,1]\r\n\t
\r\n\r\n\tSteering: The steering for this frame.
\r\n\tRange: [-1,1]\r\n\t
\r\n\r\n\tAnalog Acceleration: Switches between analog and digital acceleration.
\r\n\tRange: TRUE,FALSE]\r\n\t
\r\n\r\n\tAnalog Steering: Switches between analog and digital steering.
\r\n\tRange: TRUE,FALSE]\r\n\t
\r\n\r\n\tHandbrake: Sets the handbrake status to enabled for this frame.
\r\n\tRange: TRUE,FALSE]\r\n\t
\r\n\r\n\tAcceleration: Enables input for acceleration.\r\n\t
\r\n\r\n\tSteering: Enables input for steering.\r\n\t
\r\n\r\n\tAnalog Acceleration: Enables input for analog acceleration.\r\n\t
\r\n\r\n\tAnalog Steering: Enables input for analog steering.\r\n\t
\r\n\r\n\tHandbrake: Enables input for handbrake.\r\n\t
\r\n\t\r\n\t
\r\n\t

Warning

\r\n\t\tThe body must be dynamic.
\r\n\t\tThe body must have a vehicle object. See #ref PVSet\r\n\t
\r\n\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PVControlCB );\r\n\t\r\n\tproto->DeclareOutParameter(\"Flags\",VTF_VSTATE_FLAGS,\"-1\");\r\n\tproto->DeclareOutParameter(\"Gear\",CKPGUID_INT,\"-1\");\r\n\tproto->DeclareOutParameter(\"RPM\",CKPGUID_FLOAT,\"-1\");\r\n\tproto->DeclareOutParameter(\"RPM Wheels\",CKPGUID_FLOAT,\"-1\");\r\n\tproto->DeclareOutParameter(\"Motor Ratio\",CKPGUID_FLOAT,\"-1\");\r\n\r\n\t\r\n\tBB_EVALUATE_SETTINGS(BBIMAP);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVControl);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PVControl\r\n// FullName: PVControl\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n#define BBSParameter(A) DWORD s##A;\\\r\n\tbeh->GetLocalParameterValue(A,&s##A)\r\n\r\nint PVControl(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) bbSErrorME(E_PE_REF);\r\n\r\n\t\t\r\n\t\tpRigidBody *body = NULL;\r\n\t\t\r\n\t\t\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\r\n\t\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\r\n\r\n\t\tfloat acc = GetInputParameterValue(beh,BB_IP_INDEX(I_Acc));\r\n\t\tint accAnalog = GetInputParameterValue(beh,BB_IP_INDEX(I_AnalogAcc));\r\n\t\tfloat steer = GetInputParameterValue(beh,BB_IP_INDEX(I_Steer));\r\n\t\tint steerAnalog = GetInputParameterValue(beh,BB_IP_INDEX(I_AnalogSteering));\r\n\t\tint handBrake = GetInputParameterValue(beh,BB_IP_INDEX(I_Handbrake));\r\n\t\t\r\n\r\n\t\tBBSParameter(I_Acc);\r\n\t\tBBSParameter(I_AnalogAcc);\r\n\t\tBBSParameter(I_Steer);\r\n\t\tBBSParameter(I_AnalogSteering);\r\n\t\tBBSParameter(I_Handbrake);\r\n\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\r\n\t\t{\r\n\t\t\tbbSErrorME(E_PE_NoVeh);\r\n\t\t}\r\n\r\n\t\tif (sI_Acc && acc!=v->_cAcceleration)\t\r\n\t\t\tv->setControlState(E_VCS_ACCELERATION,acc);\r\n\t\t\r\n\t\tif (sI_AnalogAcc && accAnalog!=v->_cAnalogAcceleration)\t\r\n\t\t\tv->setControlMode(E_VCS_ACCELERATION,accAnalog ? E_VCSM_ANALOG : E_VCSM_DIGITAL);\r\n\r\n\t\tif (sI_Steer && steer!=v->_cSteering)\t\r\n\t\t\tv->setControlState(E_VCS_STEERING,steer);\r\n\r\n\t\tif (sI_AnalogSteering && steerAnalog!=v->_cAnalogSteering )\t\r\n\t\t\tv->setControlMode(E_VCS_STEERING,steerAnalog ? E_VCSM_ANALOG : E_VCSM_DIGITAL);\r\n\r\n\t\t\r\n\t\tif (sI_Handbrake && handBrake )\t\r\n\t\t\tv->setControlState(E_VCS_HANDBRAKE,handBrake == 1 ? true : false);\r\n\r\n\r\n\t\t\r\n\t\tDWORD flags = v->getStateFlags();\r\n\t\tbeh->SetOutputParameterValue(O_Flags,&flags);\r\n\r\n\r\n\t\tfloat ratio = v->_getGearRatio();\r\n\t\tbeh->SetOutputParameterValue(O_RATIO,&ratio);\r\n\r\n\t\tif (v->getGears())\r\n\t\t{\r\n\t\t\tint g = v->getGears()->getGear();\r\n\t\t\tbeh->SetOutputParameterValue(O_Gear,&g);\r\n\t\t}\r\n\r\n\t\tif (v->getMotor())\r\n\t\t{\r\n\t\t\tfloat rpm = v->getMotor()->getRpm();\r\n\t\t\tbeh->SetOutputParameterValue(O_RPM,&rpm);\r\n\t\t}\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 8:57\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\vtPreReqs.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\r\n\tfile base:\tvtPreReqs\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tVirtools Forward Declarations \r\n*********************************************************************/\r\n#ifndef __PREREQUISITES_VIRTOOSLS_H__\r\n#define __PREREQUISITES_VIRTOOSLS_H__\r\n\r\n//################################################################\r\n//\r\n// Common Types\r\n//\r\n\r\nclass CKBeObject;\r\nclass CKContext;\r\nclass CKParameter;\r\nclass CKParameterIn;\r\nclass CKParameterOut;\r\nclass CKParameterManager;\r\nclass CKAttributeManager;\r\n\r\n//################################################################\r\n//\r\n// 3D Types\r\n//\r\nclass CKMesh;\r\nclass CK3dEntity;\r\nclass CK3dObject;\r\nclass CK3dPointCloud;\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pWorldSettings.h\"\r\n#include \"NxUserNotify.h\"\r\n#include \"NxUserContactReport.h\"\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\nstruct MyUserNotify : public NxUserNotify \r\n{ \r\npublic: \r\n\t\r\n\r\n\t/*virtual bool onJointBreak(NxReal breakingImpulse, NxJoint & brokenJoint) \r\n\t{\r\n\t\treturn false;\r\n\t}*/\r\n\t\r\n\tvirtual bool onJointBreak(NxReal breakingImpulse, NxJoint & brokenJoint) \r\n\t{ \r\n\r\n\t\t\r\n\t\tpJoint *joint = static_cast(brokenJoint.userData);\r\n\t\tif (joint)\r\n\t\t{\r\n\t\t\tpBrokenJointEntry *entry = new pBrokenJointEntry();\r\n\t\t\t//entry->joint = joint;\r\n\t\t\tentry->impulse = breakingImpulse;\r\n\t\t\t\r\n\t\t\tentry->jType =brokenJoint.getType();\r\n\r\n\t\t\tif(joint->GetVTEntA())\r\n\t\t\t\tentry->mAEnt = joint->GetVTEntA()->GetID();\r\n\r\n\t\t\tif(joint->GetVTEntB())\r\n\t\t\t\tentry->mBEnt = joint->GetVTEntB()->GetID();\r\n\r\n\r\n\t\t\tGetPMan()->getJointFeedbackList().PushBack(entry);\r\n\t\t\t\r\n\t\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Joint break!\");\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t//\tretrieve body pointers and call callback scripts\r\n\t\t\tNxActor *a = NULL; pRigidBody *ab=NULL;\r\n\t\t\tNxActor *b = NULL; pRigidBody *bb=NULL;\r\n\r\n\t\t\tbrokenJoint.getActors(&a,&b);\r\n\t\t\tbool isRemoved = false;\r\n\r\n\t\t\tif(a)\r\n\t\t\t{\r\n\t\t\t\tab= static_cast(a->userData);\r\n\t\t\t}\r\n\t\t\tif(b)\r\n\t\t\t\tbb= static_cast(b->userData);\r\n\t\t\t\r\n\t\t\tif(ab)\r\n\t\t\t{\r\n\t\t\t\t//ab->onJointBreak(entry);\r\n\t\t\t\t//ab->hasBrokenJoint = true;\r\n\t\t\t\tif(!isRemoved)\r\n\t\t\t\t{\r\n\t\t\t\t\tisRemoved = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(bb)\r\n\t\t\t{\r\n\t\t\t\t//bb->onJointBreak(entry);\r\n\t\t\t\t//bb->hasBrokenJoint= true;\r\n\t\t\t}\r\n\r\n\t\t\t//joint->getJoint()->appData= NULL;\r\n\t\t\t//joint->getJoint()->userData= NULL;\r\n\r\n\t\t}\r\n\t\treturn false;\r\n\t} \r\n\r\n\tvirtual void onSleep(NxActor **actors, NxU32 count)\r\n\t{\r\n\t\t/*\r\n\t\tNX_ASSERT(count > 0);\r\n\t\t\t\twhile (count--)\r\n\t\t\t\t{\r\n\t\t\t\t\tNxActor *thisActor = *actors;\r\n\t\t\t\t\t//Tag the actor as sleeping\r\n\t\t\t\t\tsize_t currentFlag = (size_t)thisActor->userData;\r\n\t\t\t\t\tcurrentFlag |= gSleepFlag;\r\n\t\t\t\t\tthisActor->userData = (void*)currentFlag;\r\n\t\t\r\n\t\t\t\t\tactors++;\r\n\t\t\t\t}*/\r\n\t\tif (count >0)\r\n\t\t{\r\n\t\t\twhile (count--)\r\n\t\t\t{\r\n\t\t\t\tNxActor *thisActor = *actors;\r\n\t\t\t\tif (thisActor)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *body = static_cast(thisActor->userData);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\tint flags = body->getFlags();\r\n\t\t\t\t\tflags |=BF_Sleep;\r\n\t\t\t\t\tbody->setFlags(flags);\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tvirtual void onWake(NxActor **actors, NxU32 count)\r\n\t{\r\n\t\t\r\n\t\tif (count >0)\r\n\t\t{\r\n\t\t\twhile (count--)\r\n\t\t\t{\r\n\t\t\t\tNxActor *thisActor = *actors;\r\n\t\t\t\tif (thisActor)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *body = static_cast(thisActor->userData);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbody->getCollisions().Clear();\r\n\t\t\t\t\t\tbody->getTriggers().Clear();\r\n\r\n\t\t\t\t\t\tint flags = body->getFlags();\r\n\t\t\t\t\t\tflags &=~BF_Sleep;\r\n\t\t\t\t\t\tbody->setFlags(flags);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tactors++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}myNotify;\r\n\r\n\r\npWorld*pFactory::createWorld(CK3dEntity* referenceObject, pWorldSettings *worldSettings,pSleepingSettings *sleepSettings)\r\n{\r\n\r\n\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks : \r\n\tif (!referenceObject || !GetPMan() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tif (!getPhysicSDK())\r\n\t{\r\n\t\t//xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"No physic sdk loaded\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint worldAtt = GetPMan()->att_world_object;\r\n\tint surfaceAttribute = GetPMan()->att_surface_props;\r\n\r\n\t//exists ? Delete it !\r\n\tpWorld *w = GetPMan()->getWorld(referenceObject->GetID());\r\n\tif (w)\r\n\t{\r\n\t\tGetPMan()->deleteWorld(referenceObject->GetID());\r\n\t}\r\n\t\t\r\n\t//our new world : \r\n\tpWorld *result = new pWorld(referenceObject);\r\n\tGetPMan()->getWorlds()->InsertUnique(referenceObject,result);\r\n\r\n\tresult->initUserReports();\r\n\t\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t//there is no world settings attribute : \r\n\tif (!referenceObject->HasAttribute(worldAtt) )\r\n\t{\r\n\t\treferenceObject->SetAttribute(worldAtt);\r\n\t\tusing namespace vtTools;\r\n\t\tVxVector grav = worldSettings->getGravity();\r\n\t\tfloat sWith = worldSettings->getSkinWith();\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,worldAtt,0,&grav);\r\n\t\tAttributeTools::SetAttributeValue(referenceObject,worldAtt,1,&sWith);\r\n\t}\r\n\r\n\tworldSettings = pFactory::Instance()->createWorldSettings(XString(\"Default\"),GetPMan()->getDefaultConfig());\r\n\tif (!worldSettings)\r\n\t{\r\n\t\tworldSettings = new pWorldSettings();\r\n\t}\r\n\r\n\tGetPMan()->setPhysicFlags(worldSettings->getPhysicFlags());\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//pSDK Scene creation : \r\n\r\n\t// Create a scene\r\n\tNxSceneDesc sceneDesc;\r\n\tNxHWVersion hwCheck = getPhysicSDK()->getHWVersion();\r\n\r\n\tif(GetPMan()->physicFlags & PMF_DONT_USE_HARDWARE )\r\n\t{\r\n\t\thwCheck = NX_HW_VERSION_NONE;\r\n\t}\r\n\r\n\tif(hwCheck != NX_HW_VERSION_NONE)\r\n\t{\r\n\t\tsceneDesc.simType = NX_SIMULATION_HW;\r\n\t}\r\n\t\r\n\t//SCE_SEARCHFORCOMPUTERS.\r\n\tsceneDesc.gravity\t\t\t\t= pMath::getFrom(worldSettings->getGravity());\r\n\tsceneDesc.upAxis = 1;\r\n\t//sceneDesc.flags |=NX_SF_ENABLE_ACTIVETRANSFORMS/*|NX_SF_ENABLE_MULTITHREAD|NX_SF_SIMULATE_SEPARATE_THREAD*/;\r\n\tsceneDesc.flags = worldSettings->getSceneFlags();\r\n\tsceneDesc.userNotify =&myNotify;\r\n\tsceneDesc.userContactReport = result->contactReport;\r\n\tsceneDesc.userContactModify = result->contactModify;\r\n\tNxScene *scene = NULL;\r\n\tif (getPhysicSDK())\r\n\t{\r\n\t\tscene = getPhysicSDK()->createScene(sceneDesc);\r\n\t\tif(scene == NULL) \r\n\t\t{\r\n xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create scene!\");\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\tNxCompartment *comp = NULL;\r\n\tif(hwCheck != NX_HW_VERSION_NONE)\r\n\t{\r\n\t\tNxCompartmentDesc cdesc;\r\n\r\n\t\tcdesc.type = NX_SCT_RIGIDBODY;\r\n\t\t#if defined(WIN32) && !defined(_XBOX)\r\n\t\t\t\tcdesc.deviceCode = NX_DC_PPU_AUTO_ASSIGN;\r\n\t\t#else\r\n\t\t\t\tcdesc.deviceCode = NX_DC_CPU;\r\n\t\t#endif\r\n\t\tcomp = scene->createCompartment(cdesc);\r\n\t\tif (!comp)\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create scene's compartment\");\r\n\t}\r\n\r\n\r\n\tresult->setScene(scene);\r\n\tscene->setUserContactReport(result->contactReport);\r\n\tscene->setUserTriggerReport(result->triggerReport);\r\n\r\n\tNxMaterialDesc *materialDescr = NULL;\r\n\tNxMaterial *material = NULL;\r\n\tif (referenceObject->HasAttribute(surfaceAttribute))\r\n\t{\r\n\t\tmaterialDescr = createMaterialFromEntity(referenceObject);\r\n\t\tmaterial = result->getScene()->createMaterial(*materialDescr);\r\n\t\tmaterial->userData = (void*)GetValueFromParameterStruct(referenceObject->GetAttributeParameter(surfaceAttribute) ,E_MS_XML_TYPE);\r\n\t}else{\r\n\t\t\r\n\t\tif (getDefaultDocument())\r\n\t\t{\r\n\t\t\t\r\n\t\t\tmaterialDescr = createMaterialFromXML(\"Default\",getDefaultDocument());\r\n\t\t}\r\n\t\t\r\n\t\tif (materialDescr)\r\n\t\t{\r\n\t\t\tmaterial = result->getScene()->createMaterial(*materialDescr);\r\n\t\t}\r\n\r\n\t\tif (!material)\r\n\t\t{\r\n\t\t\tmaterialDescr = new NxMaterialDesc();\r\n\t\t\tmaterialDescr->setToDefault();\r\n\t\t\tmaterial = result->getScene()->getMaterialFromIndex(0); \r\n\t\t\tmaterial->loadFromDesc(*materialDescr);\r\n\t\t}\r\n\r\n\t\tif(material)\r\n\t\t{\r\n\t\t\tpMaterial *bmaterial = new pMaterial();\r\n\t\t\tbmaterial->setToDefault();\r\n\r\n\t\t\tcopyTo(*bmaterial,material);\r\n\r\n\t\t\tmaterial->userData = (void*)bmaterial;\r\n\r\n\t\t}\r\n\t}\r\n\t\r\n\t\r\n\tNxMaterial *zeroMaterial = result->getScene()->getMaterialFromIndex(0);\r\n\tzeroMaterial->setDirOfAnisotropy(material->getDirOfAnisotropy());\r\n\tzeroMaterial->setStaticFriction(material->getStaticFriction());\r\n\tzeroMaterial->setDynamicFriction(material->getDynamicFriction());\r\n\tzeroMaterial->setStaticFrictionV(material->getStaticFrictionV());\r\n\tzeroMaterial->setDynamicFrictionV(material->getDynamicFrictionV());\r\n\tzeroMaterial->setFrictionCombineMode(material->getFrictionCombineMode());\r\n\tzeroMaterial->setRestitutionCombineMode(material->getRestitutionCombineMode());\r\n\tzeroMaterial->setFlags(material->getFlags());\r\n\r\n\r\n\t\r\n\tif (!material)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create default material!\");\r\n\t}\r\n\tresult->setDefaultMaterial(material);\r\n\t\r\n\r\n\tscene->userData = result;\r\n\tresult->_checkForDominanceConstraints();\r\n\tresult->_construct();\r\n\tif (comp)\r\n\t{\r\n\t\tresult->setCompartment(comp);\r\n\t}\r\n\treturn result;\r\n}\r\n//************************************\r\n// Method: CreateDefaultWorld\r\n// FullName: vtODE::pFactory::CreateDefaultWorld\r\n// Access: public \r\n// Returns: pWorld*\r\n// Qualifier:\r\n// Parameter: XString name\r\n//************************************\r\npWorld*pFactory::createDefaultWorld(XString name)\r\n{\r\n\t\r\n\r\n\tCK3dEntity *defaultWorldFrame = createFrame(\"pDefaultWorld\");\r\n\tpWorldSettings *wSettings = getManager()->getDefaultWorldSettings();\r\n\r\n\tpWorld* world = createWorld(defaultWorldFrame,wSettings,NULL);\r\n\tgetManager()->setDefaultWorld(world);\r\n\treturn world;\r\n}\r\n\r\n#include \r\n\r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtStructHelper.h\"\r\n\r\n//################################################################\r\n//\r\n// Prototype\r\n//\r\nXString getDefaultValue(CKParameter *inputParameter)\r\n{\t\r\n\tCustomParametersArrayType& inputArray = GetPMan()->_getCustomStructures();\r\n\tXString result;\r\n\r\n\tint s = inputArray.Size();\r\n\r\n\r\n\r\n\tCustomParametersArrayIteratorType it = inputArray.Find(inputParameter->GetGUID());\r\n\tif (it == inputArray.End())\r\n\t\treturn result;\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint x = 0;\r\n\tCustomStructure *cStruct = *it;\r\n\tif (cStruct)\r\n\t{\r\n\t\tcStruct->getArray().size();\r\n\t}\r\n\r\n\tCKParameterTypeDesc *tdescr = GetPMan()->GetContext()->GetParameterManager()->GetParameterTypeDescription( inputParameter->GetType() );\r\n\tif( (tdescr->dwFlags & CKPARAMETERTYPE_STRUCT) == 0x00000010 )\r\n\t{\r\n\t\tint y = cStruct->getArray().size();\r\n\t\tint y2 = cStruct->getArray().size();\r\n\t}else{\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n//################################################################\r\n//\r\n// Not being used\r\n//\r\nvoid rigidBodyAttributeCallback(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg)\r\n{\r\n\r\n\t//\trecheckWorldsFunc(AttribType,Set,obj,arg);\r\n\r\n}\r\n\r\n//################################################################\r\n//\r\n// Body functions\r\n//\r\npRigidBody*PhysicManager::getBody(const char*name,int flags/* =0 */)\r\n{\r\n\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\tint nbActors = w->getScene()->getNbActors();\r\n\t\t\tNxActor** actors = w->getScene()->getActors();\r\n\t\t\twhile(nbActors--)\r\n\t\t\t{\r\n\t\t\t\tNxActor* actor = *actors++;\r\n\t\t\t\tif(actor->userData != NULL)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!strcmp(actor->getName(),name) )\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tpRigidBody* body =static_cast(actor->userData);\r\n\t\t\t\t\t\tif (body)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn body;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\npRigidBody*PhysicManager::getBody(CK3dEntity *ent)\r\n{\r\n\r\n\tpWorld* w = getWorldByBody(ent);\r\n\tif (w)\r\n\t{\r\n\r\n\t\tpRigidBody *body = w->getBody(ent);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\treturn body;\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorJD6SetParametersDecl();\r\nCKERROR CreateJD6SetParametersProto(CKBehaviorPrototype **pproto);\r\nint JD6SetParameters(const CKBehaviorContext& behcontext);\r\nCKERROR JD6SetParametersCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyA=0,\r\n\tbbI_BodyB,\r\n\tbbI_Anchor,\r\n\tbbI_AnchorRef,\r\n\tbbI_Axis,\r\n\tbbI_AxisRef\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJD6SetParametersDecl\r\n// FullName: FillBehaviorJD6SetParametersDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJD6SetParametersDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJD6SetParameters\");\t\r\n\tod->SetCategory(\"Physic/D6\");\r\n\tod->SetDescription(\"Sets parameters in a D6 joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x4b8207b2,0x57964805));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJD6SetParametersProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJD6SetParametersProto\r\n// FullName: CreateJD6SetParametersProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJD6SetParametersProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJD6SetParameters\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\r\n\t\r\n\t\r\n\tproto->SetBehaviorCallbackFct( JD6SetParametersCB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Drive Linear Velocity\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Drive Angular Velocity\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Drive Position\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Drive Orientation\",CKPGUID_QUATERNION);\r\n\t\r\n\tproto->DeclareInParameter(\"Ratio\",CKPGUID_FLOAT,\"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JD6SetParameters);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JD6SetParameters\r\n// FullName: JD6SetParameters\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JD6SetParameters(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointD6 *joint =static_cast(worldA->getJoint(target,targetB,JT_D6));\r\n\t\t\tVxVector linVel = GetInputParameterValue(beh,1); \r\n\t\t\tVxVector aVel = GetInputParameterValue(beh,2); \r\n\t\t\tVxVector pos = GetInputParameterValue(beh,3); \r\n\t\t\tVxQuaternion rot = GetInputParameterValue(beh,4); \r\n\r\n\t\t\tfloat ratio = GetInputParameterValue(beh,5); \r\n\t\t\t\r\n\t\t\t\r\n\t\t\tjoint->setDriveLinearVelocity(linVel);\r\n\t\t\tjoint->setDriveAngularVelocity(aVel);\r\n\t\t\tjoint->setRatio(ratio);\r\n\t\t\t\r\n\t\t\tjoint->setDrivePosition(pos);\r\n\t\t\tjoint->setDriveRotation(rot);\r\n\r\n\r\n\r\n\t\t}\r\n\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JD6SetParametersCB\r\n// FullName: JD6SetParametersCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JD6SetParametersCB(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn CKBR_OK;\r\n}\r\n/********************************************************************\r\n\tcreated:\t2008/01/14\r\n\tcreated:\t14:1:2008 12:08\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\CustomPlayerApp.cpp\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\n\tfile base:\tCustomPlayerApp\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n\r\n#include \"xSplash.h\"\r\n// the unique (global) instance of the winapp\r\nCCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\n#include \r\n#include \"CustomPlayerDialog.h\"\r\n\r\n\r\nBEGIN_MESSAGE_MAP(CCustomPlayerApp, CWinApp)\r\n\t//{{AFX_MSG_MAP(CCustomPlayerApp)\r\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code!\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// CCustomPlayerApp: PUBLIC METHODS\r\n//\r\n////////////////////////////////////////////////////////////////////////////////\r\n//************************************\r\n// Method: GetInstance\r\n// FullName: CCustomPlayerApp::GetInstance\r\n// Access: protected static \r\n// Returns: CCustomPlayerApp*\r\n// Qualifier:\r\n//************************************\r\n\r\nCCustomPlayerApp*\r\nCCustomPlayerApp::GetInstance()\r\n{\r\n\r\n\tif (theApp)\r\n\t{\r\n\t\treturn &theApp;\r\n\t} \r\n\telse\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n}\r\nCCustomPlayerApp::CCustomPlayerApp()\r\n:\tm_MainWindow(0),m_RenderWindow(0),\r\n\tm_PlayerClass(MAINWINDOW_CLASSNAME),m_RenderClass(RENDERWINDOW_CLASSNAME),\r\n\tm_PlayerTitle(MAINWINDOW_TITLE),\r\n\tm_Config(0)\r\n{\r\n}\r\n\r\nCCustomPlayerApp::~CCustomPlayerApp()\r\n{\r\n\t// simply destroy the windows ...\r\n\r\n\tif (m_RenderWindow) {\r\n\t\tDestroyWindow(m_RenderWindow);\r\n\t}\r\n\r\n\tif (m_MainWindow) {\r\n\t\tDestroyWindow(m_MainWindow);\r\n\t}\r\n}\r\n\r\n\r\n\r\nint CCustomPlayerApp::ExitInstance()\r\n{\r\n\tif (thePlayer) {\r\n\t\tdelete thePlayer;\r\n\t\tthePlayer = 0;\r\n\t}\r\n\r\n\treturn CWinApp::ExitInstance();\r\n}\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// CCustomPlayerApp: PROTECTED/PRIVATE METHODS\r\n//\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid CCustomPlayerApp::_DisplaySplashWindow()\r\n{\r\n\t// display the splash windows centered.\r\n/*\tRECT rect;\r\n\tm_Splash = CreateDialog(theApp.m_hInstance,(LPCTSTR)IDD_SPLASH,NULL,(DLGPROC)_LoadingDlgWndProc); \r\n\tGetWindowRect(m_Splash,&rect);\r\n\tSetWindowPos(m_Splash,NULL,(GetSystemMetrics(SM_CXSCREEN)-(rect.right-rect.left))/2,\r\n\t\t\t\t (GetSystemMetrics(SM_CYSCREEN)-(rect.bottom-rect.top))/2,0,0,SWP_NOZORDER|SWP_NOSIZE);\r\n\tShowWindow(m_Splash, SW_SHOW);\r\n\tUpdateWindow(m_Splash);\r\n\t*/\r\n}\r\n\r\nvoid CCustomPlayerApp::_PublishingRights()\r\n{\r\n\t// IMPORTANT: The following warning should be removed by you (in the source\r\n\t// code prior to compilation).\r\n\t//\r\n\t// This dialog box serves to remind you that publishing rights, a.k.a. runtime\r\n\t// fees, are due when building any custom executable (like the player you just\r\n\t// compiled). Contact for more information.\r\n\r\n\tMessageBox(NULL,PUBLISHING_RIGHT_TEXT,PUBLISHING_RIGHT_TITLE,MB_OK|MB_ICONASTERISK);\r\n}\r\n\r\n\r\n\r\nBOOL CCustomPlayerApp::_LoadInternal(XString& oFilename)\r\n{\r\n\t// parameters are:\r\n\t// -disable_keys (or -d) : disable ALT+ENTER to switch from/to fullscreen\r\n\t// and ALT+F4 to close the application\r\n\t// -auto_fullscreen (or -f) : the player start automatically in fullscreen mode\r\n\t// -file filename : specify the file to load\r\n\t// -title title : specify the title of the main window\r\n\t// -width width : specify the width in windowed mode\r\n\t// -height height : specify the height in windowed mode\r\n\t// -fwidth fullscreenwidth : specify the width in fullscreen mode\r\n\t// -fheight fullscreeneight : specify the height in fullscreen mode\r\n\t// -fbpp fullscreenbpp : specify the bit per pixel in fullscreen mode\r\n\t// -rasterizer family,flags : specify the rasterizer family (see CKRST_RSTFAMILY)\r\n\t// and flags to choose the rasterizer (see CKRST_SPECIFICCAPS)\r\n\t// default values are:\r\n\t// - title = Virtools Custom Player\r\n\t// - width = 640\r\n\t// - height = 480\r\n\t// - fullscreen width = 640\r\n\t// - fullscreen height = 480\r\n\t// - fullscreen bpp = 32\r\n\t// - rasterizer = CKRST_DIRECTX,CKRST_SPECIFICCAPS_HARDWARE|CKRST_SPECIFICCAPS_DX9\r\n\r\n\t//\tPlease note that if there are \"space\" characters in a parameter value the value must be between \" \"\r\n\r\n// ***********************************************************************************************************************\r\n\t\t\r\n\t\t//\tm_Config |= eAutoFullscreen; // KAM comment to go to windowed mode, uncomment to go directly to full screen\r\n\r\n// ***********************************************************************************************************************\r\n\r\n\t\t// parameter followed by values\r\n\r\n\t\t// -file\r\n\t\toFilename = \"a.vmo\";\r\n\t\t// -title\r\n\t\tm_PlayerTitle = \"PlayGen Player\";\r\n\t\t// -width\r\n\t\tCCustomPlayer::Instance().WindowedWidth() = 800;\r\n\t\t// -height\r\n\t\tCCustomPlayer::Instance().WindowedHeight() = 600;\r\n\t\t// -fwidth\r\n\t\tCCustomPlayer::Instance().FullscreenWidth() = 800;\r\n\t\t// -fheight\r\n\t\tCCustomPlayer::Instance().FullscreenHeight() = 600;\r\n\t\t// -fbpp\r\n\t\tCCustomPlayer::Instance().FullscreenBpp() = 32;\r\n\r\n/*\t\t// -rasterizer\r\n\t\telse if (strncmp(token,\"rasterizer\",XMin((int)(ptr-token),(int)(sizeof(\"rasterizer\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tint tmp2 = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d,%d\",&tmp,&tmp2)==2) {\r\n\t\t\t\tCCustomPlayer::Instance().RasterizerFamily() = tmp;\r\n\t\t\t\tCCustomPlayer::Instance().RasterizerFlags() = tmp2;\r\n*/\r\n\r\n\treturn TRUE; \r\n}\r\n\r\n\r\n\r\nBOOL CCustomPlayerApp::_ReadCommandLine(const char* iArguments, XString& oFilename)\r\n{\r\n\t// parameters are:\r\n\t// -disable_keys (or -d) : disable ALT+ENTER to switch from/to fullscreen\r\n\t// and ALT+F4 to close the application\r\n\t// -auto_fullscreen (or -f) : the player start automatically in fullscreen mode\r\n\t// -file filename : specify the file to load\r\n\t// -title title : specify the title of the main window\r\n\t// -width width : specify the width in windowed mode\r\n\t// -height height : specify the height in windowed mode\r\n\t// -fwidth fullscreenwidth : specify the width in fullscreen mode\r\n\t// -fheight fullscreeneight : specify the height in fullscreen mode\r\n\t// -fbpp fullscreenbpp : specify the bit per pixel in fullscreen mode\r\n\t// -rasterizer family,flags : specify the rasterizer family (see CKRST_RSTFAMILY)\r\n\t// and flags to choose the rasterizer (see CKRST_SPECIFICCAPS)\r\n\t// default values are:\r\n\t// - title = Virtools Custom Player\r\n\t// - width = 640\r\n\t// - height = 480\r\n\t// - fullscreen width = 640\r\n\t// - fullscreen height = 480\r\n\t// - fullscreen bpp = 32\r\n\t// - rasterizer = CKRST_DIRECTX,CKRST_SPECIFICCAPS_HARDWARE|CKRST_SPECIFICCAPS_DX9\r\n\r\n\t//\tPlease note that if there are \"space\" characters in a parameter value the value must be between \" \"\r\n\r\n\tXStringTokenizer st(iArguments,\"-\");\r\n\tconst char* token = 0;\r\n\tconst char* ptr = 0;\r\n\tconst char* ptr2 = 0;\r\n\twhile (token=st.NextToken(token)) {\r\n\t\tptr = _NextBlank(token);\r\n\t\tptr2 = _SkipBlank(ptr);\r\n\r\n\t\t// the parameter is not followed by a value\r\n\t\tif (*ptr2=='\\0') {\r\n\t\t\t// -disable_keys (or -d)\r\n\t\t\tif (strncmp(token,\"d\",XMin((int)(ptr-token),(int)(sizeof(\"d\")-1)))==0 ||\r\n\t\t\t\tstrncmp(token,\"disable_keys\",XMin((int)(ptr-token),(int)(sizeof(\"disable_keys\")-1)))==0) {\r\n\t\t\t\tm_Config |= eDisableKeys;\r\n\t\t\t}\r\n\t\t\t// -auto_fullscreen (or -f)\r\n\t\t\telse if (strncmp(token,\"f\",XMin((int)(ptr-token),(int)(sizeof(\"f\")-1)))==0 ||\r\n\t\t\t\t\t strncmp(token,\"auto_fullscreen\",XMin((int)(ptr-token),(int)(sizeof(\"auto_fullscreen\")-1)))==0) {\r\n\t\t\t\tm_Config |= eAutoFullscreen;\r\n\t\t\t} else {\r\n\t\t\t\t// unknow parameter\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\t// parameter followed by values\r\n\r\n\t\t// -file\r\n\t\tif (strncmp(token,\"file\",XMin((int)(ptr-token),(int)(sizeof(\"file\")-1)))==0) {\r\n\t\t\tif (!_ComputeParamValue(ptr2,oFilename)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -title\r\n\t\telse if (strncmp(token,\"title\",XMin((int)(ptr-token),(int)(sizeof(\"title\")-1)))==0) {\r\n\t\t\tif (!_ComputeParamValue(ptr2,m_PlayerTitle)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -width\r\n\t\telse if (strncmp(token,\"width\",XMin((int)(ptr-token),(int)(sizeof(\"width\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d\",&tmp)==1) {\r\n\t\t\t\tCCustomPlayer::Instance().WindowedWidth() = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -height\r\n\t\telse if (strncmp(token,\"height\",XMin((int)(ptr-token),(int)(sizeof(\"height\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d\",&tmp)==1) {\r\n\t\t\t\tCCustomPlayer::Instance().WindowedHeight() = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -fwidth\r\n\t\telse if (strncmp(token,\"fwidth\",XMin((int)(ptr-token),(int)(sizeof(\"fwidth\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d\",&tmp)==1) {\r\n\t\t\t\tCCustomPlayer::Instance().FullscreenWidth() = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -fheight\r\n\t\telse if (strncmp(token,\"fheight\",XMin((int)(ptr-token),(int)(sizeof(\"fheight\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d\",&tmp)==1) {\r\n\t\t\t\tCCustomPlayer::Instance().FullscreenHeight() = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -fbpp\r\n\t\telse if (strncmp(token,\"fbpp\",XMin((int)(ptr-token),(int)(sizeof(\"fbpp\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d\",&tmp)==1) {\r\n\t\t\t\tCCustomPlayer::Instance().FullscreenBpp() = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\t// -rasterizer\r\n\t\telse if (strncmp(token,\"rasterizer\",XMin((int)(ptr-token),(int)(sizeof(\"rasterizer\")-1)))==0) {\r\n\t\t\tXString value;\r\n\t\t\tif (!_ComputeParamValue(ptr2,value)) {\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\t\t\tint tmp = 0;\r\n\t\t\tint tmp2 = 0;\r\n\t\t\tif(sscanf(value.CStr(),\"%d,%d\",&tmp,&tmp2)==2) {\r\n\t\t\t\tCCustomPlayer::Instance().RasterizerFamily() = tmp;\r\n\t\t\t\tCCustomPlayer::Instance().RasterizerFlags() = tmp2;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// unknow parameter\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn TRUE; \r\n}\r\n\r\nBOOL CCustomPlayerApp::_ReadConfig(XString& oFilename, const char*& oBufferFile, XDWORD& oSize)\r\n{\r\n\tconst char* cmdLine = GetCommandLine();\r\n\r\n\tconst char* ptr = 0;\r\n\t// the command line start with a '\"' (it means the first parameters\r\n\t// contains at least one space)\r\n\tif (*cmdLine=='\"') {\r\n\t\t// the first parameter is something like\r\n\t\t// \"e:\\directory name\\customplayer.exe\"\r\n\t\t// here we look for the second '\"' to be after\r\n\t\t// the first parameter\r\n\t\tptr = strchr(cmdLine+1,'\"');\r\n\t\tif (!ptr) {\r\n\t\t\t// cannot find it.\r\n\t\t\t// the command line is invalid\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t\t// move on the character after the second '\"'\r\n\t\tptr++;\r\n\r\n\t\tptr = _SkipBlank(ptr);\r\n\t} else {\r\n\t\t// if there is no space in the first parameter, the\r\n\t\t// first space we can found is the one after the first parameter\r\n\t\t// if any\r\n\t\tptr = strchr(cmdLine,' ');\r\n\t\tif (ptr) {\r\n\t\t\tptr = _SkipBlank(ptr);\r\n\t\t}\r\n\t}\r\n\r\n\t/*\r\n\tif (ptr==0 || *ptr=='\\0') {\r\n\t\t// there is no parameter on the command line (excepted the name of the exe)\r\n\t\t// try to read the \"internal\" configuration\r\n\t\treturn _ReadInternalConfig(oBufferFile,oSize);\r\n\t}\r\n\t*/\r\n\r\n\t// any argument must begin with a '-'\r\n\tif (*ptr!='-') {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// read the command line\r\n\treturn _ReadCommandLine(ptr,oFilename);\r\n}\r\n\r\nBOOL CCustomPlayerApp::_ReadInternalConfig(const char*& oBufferFile, XDWORD& oSize)\r\n{\r\n\t// NOTE: the internal configuration is not supported at this time\r\n\t// The idea behind \"internal\" configuration is to embed all data needed by the player\r\n\t// in the executable itself. The vmo and the parameters can be happend to the executable file.\r\n\t// In ouput oBufferFile must contains the address where the vmo is located in memory and\r\n\t// oSize must contains the size of the vmo in memory.\r\n\treturn FALSE;\r\n}\r\n\r\nATOM CCustomPlayerApp::_RegisterClass()\r\n{\r\n\t// register window classes\r\n\r\n\r\n\tWNDCLASSEX wcex;\r\n\r\n\r\n\twcex.cbSize\t\t\t= sizeof(WNDCLASSEX); \r\n\twcex.style\t\t\t= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;\r\n\twcex.lpfnWndProc\t= (WNDPROC)_MainWindowWndProc;\r\n\twcex.cbClsExtra\t\t= 0;\r\n\twcex.cbWndExtra\t\t= 0;\r\n\twcex.hInstance\t\t= m_hInstance;\r\n\tHICON icon = NULL;\r\n\ticon = (HICON) LoadImage(NULL,TEXT(\"app.ico\"),IMAGE_ICON,16, 16,LR_LOADFROMFILE);\r\n\tif (icon)\r\n\t{\r\n\t\twcex.hIcon = icon;\r\n\t}else{\r\n\t\twcex.hIcon\t\t\t= LoadIcon(IDI_VIRTOOLS);\r\n\t}\r\n\twcex.hCursor\t\t= NULL;\r\n\twcex.hbrBackground\t= NULL;\r\n\twcex.lpszMenuName\t= NULL;\r\n\twcex.lpszClassName\t= m_PlayerClass.CStr();\r\n\twcex.hIconSm\t\t= icon;\r\n\r\n\r\n\tWNDCLASS MyRenderClass;\r\n\tZeroMemory(&MyRenderClass,sizeof(MyRenderClass));\r\n\tMyRenderClass.style\t\t\t= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;\r\n\tMyRenderClass.lpfnWndProc\t= (WNDPROC)_MainWindowWndProc;\r\n\tMyRenderClass.hInstance\t\t= m_hInstance;\r\n\tMyRenderClass.lpszClassName\t= m_RenderClass.CStr();\r\n\r\n\t::RegisterClass(&MyRenderClass);\r\n\treturn ::RegisterClassEx(&wcex);\r\n}\r\n\r\n#include \r\n\r\nvoid \r\nCCustomPlayerApp::StartMove(LPARAM lParam)\r\n{\r\n\tnMMoveX = LOWORD(lParam);\r\n\tnMMoveY = HIWORD(lParam);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid \r\nCCustomPlayerApp::DoMMove(LPARAM lParam, WPARAM wParam) {\r\n\r\n\tif(wParam & MK_LBUTTON) { //if mouse is down; window is being dragged.\r\n\t\tRECT wnrect;\r\n\t\tGetWindowRect(this->m_MainWindow,&wnrect); //get window restraints\r\n\t\tMoveWindow(this->m_MainWindow,wnrect.left+(LOWORD(lParam)-nMMoveX),wnrect.top+(HIWORD(lParam)-nMMoveY),wnrect.right - wnrect.left,wnrect.bottom - wnrect.top,true);\r\n\t}\r\n}\r\n\r\n\r\n\r\nLRESULT CALLBACK CCustomPlayerApp::_MainWindowWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)\r\n{\r\n\tswitch(message) \r\n\t{\r\n\r\n\tcase WM_DROPFILES:\t\t// Load any dropped file\r\n\t\t{\r\n\r\n\t\t\t/*char FileName[_MAX_PATH];\r\n\t\t\tHDROP hdrop=(HDROP)wParam;\r\n\t\t\tDragQueryFile(hdrop,0,FileName,_MAX_PATH);\r\n\r\n\t\t\tGetPlayer().Reset();\r\n\t\t\tGetPlayer().m_CKContext->ClearAll();\r\n\t\t\tif (GetPlayer.m_RenderContext)\r\n\t\t\t{\r\n\t\t\t\t//GetPlayer.m_RenderContext->Clear();\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tGetPlayer()._Load(FileName);\r\n\t\t\tGetPlayer()._FinishLoad();\r\n\t\t\tbreak;*/\r\n\t\t}\t\r\n\t\tcase WM_MOUSEMOVE:\r\n\t\t\t{\r\n\t\t\t\tif (GetPlayer().GetPAppStyle()->g_MouseDrag==1)\r\n\t\t\t\t{\r\n\t\t\t\t\tGetApp()->DoMMove(lParam,wParam);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\tcase WM_ACTIVATEAPP:\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tplayer.OnActivateApp(wParam);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t// Minimum size of the player window\r\n\t\tcase WM_GETMINMAXINFO:\r\n\t\t\t// this message is not very useful because\r\n\t\t\t// the main window of the player is not resizable ...\r\n\t\t\t// but perhaps it will change so we manage this message.\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tif((LPMINMAXINFO)lParam) {\r\n\t\t\t\t\t((LPMINMAXINFO)lParam)->ptMinTrackSize.x=player.MininumWindowedWidth();\r\n\t\t\t\t\t((LPMINMAXINFO)lParam)->ptMinTrackSize.y=player.MininumWindowedHeight();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t// Sends a Message \"OnClick\" or \"OnDblClick\" if any object is under mouse cursor\r\n\t\tcase WM_LBUTTONDBLCLK:\r\n\t\tcase WM_LBUTTONDOWN:\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tplayer.OnMouseClick(message);\r\n\t\t\t\tif (GetPlayer().GetPAppStyle()->g_MouseDrag==1)\r\n\t\t\t\t{\r\n\t\t\t\t\tGetApp()->StartMove(lParam);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\t\r\n\t\t// Size and focus management\r\n\t\tcase WM_SIZE:\r\n\t\t\t// if the window is maximized or minimized\r\n\t\t\t// we get/lost focus.\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tif (wParam==SIZE_MINIMIZED) {\r\n\t\t\t\t\tplayer.OnFocusChange(FALSE);\r\n\t\t\t\t} else if (wParam==SIZE_MAXIMIZED) {\r\n\t\t\t\t\tplayer.OnFocusChange(TRUE);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t// Manage system key (ALT + KEY)\r\n\t\tcase WM_SYSKEYDOWN:\t\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\treturn player.OnSysKeyDownMainWindow(theApp.m_Config,(int)wParam);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t// Repaint main frame\r\n\t\tcase WM_PAINT:\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tplayer.OnPaint();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t// The main windows has been closed by the user\r\n\t\tcase WM_CLOSE:\r\n\t\t\tPostQuitMessage(0);\r\n\t\t\tbreak;\r\n\r\n\t\t// Focus management\r\n\t\tcase WM_KILLFOCUS:\r\n\t\tcase WM_SETFOCUS:\r\n\t\t\t{\r\n\t\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\t\tplayer.OnFocusChange(message==WM_SETFOCUS);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tdefault:\r\n\t\t\treturn DefWindowProc(hWnd, message, wParam, lParam);\r\n }\r\n\r\n return DefWindowProc(hWnd, message, wParam, lParam);\r\n}\r\n\r\nLRESULT CALLBACK CCustomPlayerApp::_LoadingDlgWndProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)\r\n{\r\n\tswitch (message)\r\n\t{\r\n\t\tcase WM_COMMAND:\r\n\t\t\tif (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {\r\n\t\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t}\r\n return FALSE;\r\n}\r\n#include \r\n\r\nCKERROR CreateKeyWaiter2BehaviorProto(CKBehaviorPrototype **pproto);\r\n\r\nint KeyWaiter2(const CKBehaviorContext& behcontext);\r\nint ReadKey2(const CKBehaviorContext& behcontext);\r\nCKERROR KeyWaiter2CallBack(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorKeyWaiter2Decl()\r\n{\r\n\t\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Key Waiter2\");\r\n\tod->SetDescription(\"Waits for a key to be pressed.\");\r\n\t/* rem: \r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tKey: key to wait for. This is chosen in the parameter dialog box by first \r\n\tclicking \"Select Key\" and then pressing the key to wait for. The desired key will then appear to \r\n\tthe right of \"Select Key\".
\r\n\t
\r\n Wait For Any Key: if TRUE, the building block will wait any key to be pressed.\r\n The input parameter is deleted, and a output parameter is created; and in this case the output parameter retrieves the pressed key.
\r\n Useful for \"Press any key to continue...\" capabilities.
\r\n
\r\n Waits for a key to be pressed. If the setting parameter 'Wait Any Key' is set to FALSE, this building block will \r\n wait for a specific given key (default), if set to TRUE, then it will wait for anykey to be pressed, retrieving this key as an output parameter.
\r\n
\r\n See Also: Switch On Key, Key Event.
\r\n\t*/\r\n\tod->SetCategory(\"Controllers/Keyboard\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x60280837,0x38976869));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"mw\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateKeyWaiter2BehaviorProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateKeyWaiter2BehaviorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Key Waiter2\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"StopIt\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Key\", CKPGUID_KEY);\r\n\r\n proto->DeclareSetting(\"Wait For Any Key\", CKPGUID_BOOL, \"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(KeyWaiter2);\r\n\tproto->SetBehaviorCallbackFct(KeyWaiter2CallBack);\r\n proto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS|CKBEHAVIOR_INTERNALLYCREATEDOUTPUTPARAMS));\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR KeyWaiter2CallBack(const CKBehaviorContext& behcontext){\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tswitch( behcontext.CallbackMessage ){\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n CKBOOL anyKey=FALSE;\r\n beh->GetLocalParameterValue(0, &anyKey);\r\n\r\n CKParameterIn *pin = beh->GetInputParameter(0);\r\n if( anyKey ){ // wait any Key\r\n beh->SetFunction(ReadKey2);\r\n if( pin ){\r\n CKDestroyObject( beh->RemoveInputParameter(0) );\r\n beh->CreateOutputParameter(\"Key\", CKPGUID_KEY);\r\n }\r\n } else { // wait specific Key\r\n beh->SetFunction(KeyWaiter2);\r\n if( !pin ){\r\n CKDestroyObject( beh->RemoveOutputParameter(0) );\r\n beh->CreateInputParameter(\"Key\", CKPGUID_KEY);\r\n }\r\n }\r\n } break;\r\n\t}\r\n\t\r\n\treturn CKBR_OK; \r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* Main Function 1 */\r\n/*******************************************************/\r\nint KeyWaiter2(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKInputManager* input = (CKInputManager*)behcontext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n\tif (!input){\r\n\t\tbehcontext.Context->OutputToConsoleEx(\"Can't get the Input Manager\");\r\n\t\treturn CKBR_GENERICERROR;\r\n\t}\r\n\t\r\n\tif ( beh->IsInputActive( 1 ) )\r\n\t{\r\n\t\tbeh->ActivateInput( 0 , FALSE);\r\n\t\tbeh->ActivateInput( 1 , FALSE);\r\n\r\n\t\t\r\n\t\tbeh->ActivateOutput(0,FALSE);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n int key = 0;\r\n beh->GetInputParameterValue(0,&key);\r\n if( input->IsKeyDown(key) ){\r\n // Set IO states\r\n beh->ActivateInput(0,FALSE);\r\n beh->ActivateOutput(0,TRUE);\r\n return CKBR_OK;\r\n }\r\n \r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* Main Function 2 */\r\n/*******************************************************/\r\nint ReadKey2(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKInputManager* input = (CKInputManager*)behcontext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n\tif (!input){\r\n\t\tbehcontext.Context->OutputToConsoleEx(\"Can't get the Input Manager\");\r\n\t\treturn CKBR_GENERICERROR;\r\n\t}\r\n\r\n\tif ( beh->IsInputActive( 1 ) )\r\n\t{\r\n\t\tbeh->ActivateInput( 0 , FALSE);\r\n\t\tbeh->ActivateInput( 1 , FALSE);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0,FALSE);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\tCKDWORD key = 0;\r\n\tif(input->GetKeyFromBuffer(0,key) == KEY_PRESSED) {\r\n\t\t// Set IO states\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\t\r\n\t\t// write the key\r\n\t\tbeh->SetOutputParameterValue(0,&key);\r\n\t\t\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\t\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t General Camera Orbit\r\n//\r\n//\tNote : Defines some general functions for the\r\n//\t\t Camera Orbit Behaviors.\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#ifndef GENERALCAMERAORBIT_H\r\n#define GENERALCAMERAORBIT_H\r\n\r\n// Include the CK library\r\n\r\n// Defines a new type\r\ntypedef void (*INPUTPROCESSFUNCTION) (VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &Stopping);\r\n\r\n\r\n// Infinite Value for reference\r\n#define INF\t\t12345789\r\n#define STEP\t0.0001f\r\n\r\n// General Input Parameters\r\n#define\tIN_TARGET_POS\t\t\t0\r\n#define\tIN_TARGET_REF\t\t\t1\r\n#define\tIN_SPEED_MOVE\t\t\t2\r\n#define\tIN_SPEED_RETURN\t\t\t3\r\n#define\tIN_MIN_H\t\t\t\t4\r\n#define\tIN_MAX_H\t\t\t\t5\r\n#define\tIN_MIN_V\t\t\t\t6\r\n#define\tIN_MAX_V\t\t\t\t7\r\n#define\tIN_SPEED_ZOOM\t\t\t8\r\n#define\tIN_MIN_ZOOM\t\t\t\t9\r\n#define\tIN_MAX_ZOOM\t\t\t\t10\r\n\r\n\r\n// General Local Parameters and Settings\r\n#define LOCAL_INIT\t\t\t\t0\r\n#define LOCAL_ROT\t\t\t\t1\r\n#define LOCAL_STOPPING\t\t\t2\r\n#define LOCAL_LIMITS\t\t\t3\r\n#define LOCAL_RETURN\t\t\t4\r\n\r\n\r\n// Joystick Additional Settings\r\n#define LOCAL_JOY_NB\t\t\t5\r\n#define LOCAL_JOY_ZIN\t\t\t6\r\n#define LOCAL_JOY_ZOUT\t\t\t7\r\n#define LOCAL_JOY_INVERSE\t\t8\r\n#define LOCAL_JOY_THRESHOLD\t\t9\r\n\r\n\r\n// Mouse\r\n\r\n\r\n// Keyboard Additional Settings\r\n#define LOCAL_KEY_LEFT\t\t\t5\r\n#define LOCAL_KEY_RIGHT\t\t\t6\r\n#define LOCAL_KEY_UP\t\t\t7\r\n#define LOCAL_KEY_DOWN\t\t\t8\r\n#define LOCAL_KEY_ZIN\t\t\t9\r\n#define LOCAL_KEY_ZOUT\t\t\t10\r\n\r\n\r\n// Generic Additionnal Inputs\r\n#define INPUT_LEFT\t\t\t\t2\r\n#define INPUT_RIGHT\t\t\t\t3\r\n#define INPUT_UP\t\t\t\t4\r\n#define INPUT_DOWN\t\t\t\t5\r\n#define INPUT_ZOOMIN\t\t\t6\r\n#define INPUT_ZOOMOUT\t\t\t7\r\n#define LOCAL_RETURNING\t\t\t5\r\n\r\n\r\n// Defines the functions of this file.\r\nCKERROR FillGeneralCameraOrbitProto(CKBehaviorPrototype *proto);\r\nint GeneralCameraOrbit(const CKBehaviorContext& behcontext,INPUTPROCESSFUNCTION InputFunction);\r\nCKERROR GeneralCameraOrbitCallback(const CKBehaviorContext& behcontext);\r\n\r\n#endif\r\nSET devdir=X:\\sdk\\msvc8\\Common7\\IDE\\\r\nSET devexe=X:\\sdk\\msvc8\\Common7\\IDE\\devenv.com\r\nSET solution=X:\\ProjectRoot\\svn\\pearls-media\\private\\virtools\\vtPhysX\\build4\\vs2005Dev41\\vtPhysX.sln\r\n\r\nREM cd %devdir%\r\n%devexe% %solution% /out x:\\log52005.txt /Build \"ReleaseDemo\"\r\n\r\n\r\n\r\n\r\n\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xLogger.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOBindDecl();\r\nCKERROR CreateDOBindProto(CKBehaviorPrototype **);\r\nint DOBind(const CKBehaviorContext& behcontext);\r\nCKERROR DOBindCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOBindDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOBind\");\t\r\n\tod->SetDescription(\"Binds an distributed object to a BeObject\");\r\n\t\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x4691107e,0x59ae518d));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOBindProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\nenum bbIn\r\n{\r\n\r\n\tbbI_ON,\r\n};\r\n\r\nenum bbOut\r\n{\r\n\tbbO_ON,\r\n\tbbO_ERROR\r\n};\r\n\r\nenum bbPO_TIME\r\n{\r\n\tbbPO_ERROR\r\n};\r\n\r\n\r\nCKERROR CreateDOBindProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOBind\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t\r\n\r\n\tproto->DeclareInput(\"On\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit On\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Distributed Object ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"0\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_STRING, \"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETEROUTPUTS ));\r\n\tproto->SetFunction(DOBind);\r\n\tproto->SetBehaviorCallbackFct(DOBindCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOBind(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterOut *pout = beh->GetOutputParameter(bbPO_ERROR);\r\n\tXString errorMesg(\"No network connection !\");\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\terrorMesg = \"No network connection !\";\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(bbO_ERROR);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//we come in by input off : \r\n\tif (beh->IsInputActive(bbI_ON))\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_ON,FALSE);\r\n\t\tint doID = vtTools::BehaviorTools::GetInputParameterValue(beh,1);\r\n\t\tCKBeObject *beObject = (CKBeObject*)beh->GetInputParameterObject(2);\r\n\t\tif (!beObject)\r\n\t\t{\r\n\t\t\terrorMesg = \"No Object given !\";\r\n\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\tbeh->ActivateOutput(bbO_ERROR);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (beObject)\r\n\t\t{\r\n\r\n\t\t\tCKSTRING oName = beObject->GetName();\r\n\t\t\tint oID = beObject->GetID();\r\n\t\t\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\t\t\txDistributedObject *dObject = doInterface->get(doID);\r\n\t\t\tif (dObject)\r\n\t\t\t{\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tswitch(beObject->GetClassID())\r\n\t\t\t\t{\r\n\t\t\t\t\tcase CKCID_3DENTITY:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (dObject->getDistributedClass()->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tdObject->setEntityID(oID);\r\n\t\t\t\t\t\t\t\tDWORD doFlags = dObject->getInterfaceFlags();\r\n\t\t\t\t\t\t\t\tdoFlags |=E_DO_BINDED;\r\n\t\t\t\t\t\t\t\tdObject->setInterfaceFlags(doFlags);\r\n\t\t\t\t\t\t\t\terrorMesg = \"No error\";\r\n\t\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t\t\tbeh->ActivateOutput(bbO_ON);\r\n\t\t\t\t\t\t\t\txLogger::xLog(ELOGINFO,XL_START,\"binding object:% to dist object :%d\",beObject->GetName(),doID);\r\n\t\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t\t\t//beh->ActivateOutput(bbO_ERROR);\r\n\t\t\t\t\t\t\t}else\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\terrorMesg = \"Distributed object class doesn't match BeObject class\";\r\n\t\t\t\t\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\t\t\tbeh->ActivateOutput(bbO_ERROR);\r\n\t\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\terrorMesg = \"No distributed object found with this ID!\";\r\n\t\t\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\t\t\tbeh->ActivateOutput(bbO_ERROR);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateOutput(bbO_ON);\r\n\t}\r\n/*\r\n\r\n\t\r\n\tvtDistributedObjectsArrayType *distObjects = cin->getDistributedObjects();\r\n\tvtDistObjectIt begin = distObjects->begin();\r\n\tvtDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->GetDistributedClass();\r\n\t\t\t\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tXString name(dobj->GetName().getString()); \r\n\r\n\r\n\t\t\t\tif (_class->GetEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t{\r\n\t\t\t\t\tif (dobj->getInterfaceFlags() == E_DO_CREATED)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t//output do's creation time\r\n\t\t\t\t\t\tfloat cTime = dobj->getCreationTime()/1000.0f;\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbPO_TIME,&cTime);\r\n\r\n\r\n\t\t\t\t\t\t//output do's name \r\n\t\t\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(bbPO_NAME);\r\n\t\t\t\t\t\tpout->SetStringValue(name.Str());\r\n\t \r\n\t\t\t\t\t\t//output do's network id \r\n\t\t\t\t\t\tint serverID = dobj->GetServerID();\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbPO_OID,&serverID);\r\n\r\n\r\n\t\t\t\t\t\t//output do's network id \r\n\t\t\t\t\t\tint userID = dobj->GetUserID();\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbPO_UID,&userID);\r\n\r\n\t\t\t\t\t\t//set do's interface flags \r\n\t\t\t\t\t\tdobj->setInterfaceFlags(E_DO_PROCESSED);\r\n\t \r\n\t\t\t\t\t\tCKParameterOut *poutE = beh->GetOutputParameter(bbPO_ERROR);\r\n\t\t\t\t\t\tXString errorMesg(\"No Error\");\r\n\t\t\t\t\t\tpoutE->SetStringValue(errorMesg.Str());\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbO_OBJECT);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n*/\r\n\treturn 0;\r\n\t\r\n}\r\n\r\nCKERROR DOBindCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\t\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \"CPStdAfx.h\"\r\n\r\n#ifndef WINVER\t\t\t\t// Allow use of features specific to Windows 95 and Windows NT 4 or later.\r\n#define WINVER 0x0400\t\t// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.\r\n#endif\r\n\r\n#include // MFC core and standard components\r\n#include \t\t// CComPtr, USES_CONVERSION\r\n\r\n#include \"mdexceptions.h\"\r\n\r\n#include \"commonhelpers.h\"\r\n\r\n\r\nCString GetShellExecuteError(UINT u)\r\n{\r\n\tCString s;\r\n\r\n\tswitch (u)\r\n\t{\r\n\tcase 0:\t\t\t\t\t\ts=_T(\"The operating system is out of memory or resources.\"); break;\r\n\tcase ERROR_FILE_NOT_FOUND:\ts=_T(\"The specified file was not found.\"); break;\r\n\tcase ERROR_PATH_NOT_FOUND:\ts=_T(\"The specified path was not found.\"); break;\r\n\tcase ERROR_BAD_FORMAT:\t\ts=_T(\"The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).\"); break;\r\n\tcase SE_ERR_ACCESSDENIED:\ts=_T(\"The operating system denied access to the specified file.\"); break;\r\n\tcase SE_ERR_ASSOCINCOMPLETE:s=_T(\"The file name association is incomplete or invalid.\"); break;\r\n\tcase SE_ERR_DDEBUSY:\t\ts=_T(\"The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.\"); break;\r\n\tcase SE_ERR_DDEFAIL:\t\ts=_T(\"The DDE transaction failed.\"); break;\r\n\tcase SE_ERR_DDETIMEOUT:\t\ts=_T(\"The DDE transaction could not be completed because the request timed out.\"); break;\r\n\tcase SE_ERR_DLLNOTFOUND:\ts=_T(\"The specified dynamic-link library (DLL) was not found.\"); break;\r\n\tcase SE_ERR_NOASSOC:\t\ts=_T(\"There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.\"); break;\r\n\tcase SE_ERR_OOM:\t\t\ts=_T(\"There was not enough memory to complete the operation.\"); break;\r\n\tcase SE_ERR_SHARE:\t\t\ts=_T(\"A sharing violation occurred\"); break;\r\n\tdefault:\t\t\t\t\ts.Format(_T(\"Error Number %d\"), u); break;\r\n\t}\r\n\r\n\treturn s;\r\n}\r\n\r\n\r\nCString MyStrRetToString(const LPITEMIDLIST pidl, const STRRET *strret)\r\n{\r\n\t// StrRetToStr() is not always available (e.g. on Windows 98).\r\n\t// So we use an own function instead.\r\n\tUSES_CONVERSION;\r\n\r\n\tCString s;\r\n\r\n\tswitch (strret->uType)\r\n\t{\r\n\tcase STRRET_CSTR:\r\n\t\ts= strret->cStr;\r\n\t\tbreak;\r\n\tcase STRRET_OFFSET:\r\n\t\ts= A2T((char *)pidl + strret->uOffset);\r\n\t\tbreak;\r\n\tcase STRRET_WSTR:\r\n\t\ts= W2T(strret->pOleStr);\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn s;\r\n}\r\n\r\nvoid MyShellExecute(HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd) throw (CException *)\r\n{\r\n\tCWaitCursor wc;\r\n\r\n\tUINT h= (UINT)ShellExecute(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd);\r\n\tif (h <= 32)\r\n\t\tMdThrowStringExceptionF(_T(\"ShellExecute failed: %1!s!\"), GetShellExecuteError(h));\r\n}\r\n\r\n\r\nCString GetBaseNameFromPath(LPCTSTR path)\r\n{\r\n\tCString s= path;\r\n\tint i= s.ReverseFind(_T('\\\\'));\r\n\tif (i < 0)\r\n\t\treturn s;\r\n\treturn s.Mid(i + 1);\r\n}\r\n\r\nbool FileExists(LPCTSTR path)\r\n{\r\n\tCFileFind finder;\r\n\tBOOL b= finder.FindFile(path);\r\n\tif (b)\r\n\t{\r\n\t\tfinder.FindNextFile();\r\n\t\treturn !finder.IsDirectory();\r\n\t}\r\n\telse\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n}\r\n\r\nCString LoadString(UINT resId)\r\n{\r\n\treturn MAKEINTRESOURCE(resId);\r\n}\r\n\r\nCString GetAppFileName()\r\n{\r\n\tCString s;\r\n\tVERIFY(GetModuleFileName(NULL, s.GetBuffer(_MAX_PATH), _MAX_PATH));\r\n\ts.ReleaseBuffer();\r\n\treturn s;\r\n}\r\n\r\nCString GetAppFolder()\r\n{\r\n\tCString s= GetAppFileName();\r\n\tint i= s.ReverseFind(_T('\\\\'));\r\n\tASSERT(i >= 0);\r\n\ts= s.Left(i);\r\n\treturn s;\r\n}\r\n\r\nCString MyGetFullPathName(LPCTSTR relativePath)\r\n{\r\n\tLPTSTR dummy;\r\n\tCString buffer;\r\n\r\n\tDWORD len = _MAX_PATH;\r\n\r\n DWORD dw = GetFullPathName(relativePath, len, buffer.GetBuffer(len), &dummy);\r\n\tbuffer.ReleaseBuffer();\r\n\r\n\twhile (dw >= len)\r\n\t{\r\n\t\tlen+= _MAX_PATH;\r\n\t\tdw = GetFullPathName(relativePath, len, buffer.GetBuffer(len), &dummy);\r\n\t\tbuffer.ReleaseBuffer();\r\n\t}\r\n\r\n\tif (dw == 0)\r\n\t{\r\n\t\tTRACE(\"GetFullPathName(%s) failed: GetLastError returns %u\\r\\n\", relativePath, GetLastError());\r\n\t\treturn relativePath;\r\n\t}\r\n\r\n\treturn buffer;\r\n}\r\n\r\n#include \"StdAfx.h\"\r\n#include \"virtools/vtcxglobal.h\"\r\n#include \"windows.h\"\r\n#include \"Python.h\"\r\n\r\n#include \"vt_python_funcs.h\"\r\n#include \"pyembed.h\"\r\n#include \"InitMan.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDestroyPythonDecl();\r\nCKERROR CreateDestroyPythonProto(CKBehaviorPrototype **);\r\nint DestroyPython(const CKBehaviorContext& behcontext);\r\nCKERROR DestroyPythonCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDestroyPythonDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DestroyPython\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x78634039,0x1d845726));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDestroyPythonProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Python\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDestroyPythonProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"DestroyPython\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( DestroyPython );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint DestroyPython(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\t\r\n\tbeh->ActivateInput(0,FALSE);\r\n\t\r\n\tvt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);\r\n\tDestroyPython();\r\n\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#include \"XLoader.h\"\r\n#include \"InitGuid.h\"\r\n#include \"CKAll.h\"\r\n\r\n#include \"pCommon.h\"\r\n\r\n\r\n#define X_PLUGIN_VERSION\t\t0x0000001\r\n#define X_READER_GUID\t\t\tCKGUID(0x499d11a7,0x24aa03b6)\r\n\r\n\r\n\r\n#ifdef CK_LIB\r\n#define RegisterBehSDatorDeclarations\tRegister_SDatReader_BehaviorDeclarations\r\n#define InitInstance\t\t\t\t\t_SDatReader_InitInstance\r\n#define ExitInstance\t\t\t\t\t_SDatReader_ExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGet_SDatReader_PluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGet_SDatReader_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_SDatReader_PluginInfo\r\n#define\tCKGetReader\t\t\t\t\t\tCKGet_SDatReader_Reader\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n#define InitInstance\t\t\t\t\tInitInstance\r\n#define ExitInstance\t\t\t\t\tExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n#define g_PluginInfo\t\t\t\t\t\tg_PluginInfo\r\n#define\tCKGetReader\t\t\t\t\t\tCKGetReader\r\n#endif\r\n\r\n\r\nCKPluginInfo g_PluginInfo;\r\n\r\n/**********************************************\r\nCalled by the engine when a file with the AVI \r\nextension is being loaded, a reader has to be \r\ncreated.\r\n***********************************************/\r\nCKDataReader *CKGetReader(int pos)\r\n{\r\n\treturn new CKXReader();\r\n}\r\n\r\n\r\nCKPluginInfo* CKGetPluginInfo(int index)\r\n{\r\n\t// Not Valid under Win NT 4\r\n\tif (VxGetOs() == VXOS_WINNT4) return 0;\r\n\tg_PluginInfo.m_GUID=X_READER_GUID;\r\n\tg_PluginInfo.m_Extension=\"dae\";\r\n\tg_PluginInfo.m_Description=\"NxStream Parser\";\r\n\tg_PluginInfo.m_Author=\"\";\r\n\tg_PluginInfo.m_Summary=\"Loads xml files, created by Maya/\";\r\n\tg_PluginInfo.m_Version=X_PLUGIN_VERSION;\r\n\tg_PluginInfo.m_InitInstanceFct=NULL;\t// \r\n\tg_PluginInfo.m_Type=CKPLUGIN_MODEL_READER;\t// Plugin Type\r\n\treturn &g_PluginInfo; \r\n}\r\n\r\n\r\n\r\n\r\nCKPluginInfo g_PluginInfos;\r\nint CKGetPluginInfoCount()\r\n{\r\n\treturn 1;\r\n}\r\n\r\n\r\nCKPluginInfo* CKXReader::GetReaderInfo() {\r\n\treturn &g_PluginInfo;\r\n}\r\n/////////////////////////////////////////////////////////////////////////\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//------- Returns the name of a LPDIRECTXFILEOBJECT \r\nXString GetFileObjectName(LPDIRECTXFILEOBJECT obj)\r\n{\r\n\tif (!obj) return XString(\"\");\r\n\r\n\t\r\n\tDWORD NameSize = 0;\r\n\r\n\tif (FAILED(obj->GetName(NULL,&NameSize)))\r\n\t\treturn XString(\"\");\r\n\tif (!NameSize) \r\n\t\treturn XString(\"\");\r\n\tNameSize++;\r\n\tXString Temp(NameSize);\r\n\tif (FAILED(obj->GetName(Temp.Str(),&NameSize)))\r\n\t\treturn XString(\"\");\r\n\treturn Temp;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nCKERROR CKXReader::Load(CKContext* context,CKSTRING FileName,CKObjectArray *array,CKDWORD LoadFlags,CKCharacter *carac)\r\n{\r\n\tif(!array) return CKERR_INVALIDPARAMETER;\r\n\tif(!FileName) return CKERR_INVALIDPARAMETER;\r\n\r\n\r\n\r\n\r\n\tHRESULT hr = S_OK;\r\n\r\n\tm_Context = context;\r\n\tm_LoadFlags = LoadFlags;\r\n\tm_FileName = FileName;\r\n\r\n\t\r\n\tXString filename(FileName);\r\n\tfilename.Trim();\r\n\tint ok = context->GetPathManager()->ResolveFileName(filename,DATA_PATH_IDX,-1);\r\n\r\n\tpSerializer *ser = pSerializer::Instance();\r\n\tif (ser && ok==0 )\r\n\t{\r\n\t\tser->parseFile(filename.CStr(),0);\r\n\t\t//ser->loadCollection(filename.CStr())\r\n\t}\r\n\r\n\t\r\n\r\n\t\r\n\tint t = 0;\r\n\r\n\r\n\r\n\t//LoadFromFileC(context,FileName,false,LoadFlags,array,\"null\");\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nBOOL CKXReader::LoadFromFileC(CKContext *ctx, XString filename, CKBOOL hidden, CKDWORD loadflags, CKObjectArray* targetArray, XString password)\r\n{\r\n\tCKBOOL result = false;\r\n\r\n\treturn result;\r\n}\r\n/*\n * Tcp4u v 3.31 Last Revision 04/03/1998 3.30.02\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tn4u.c\n * Purpose: telnet based-functions\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n\n/* ******************************************************************* */\n/* */\n/* Partie II : Lecture des trames de type Telnet */\n/* */\n/* ******************************************************************* */\n\n/* ------------------------------------------------------------ */\n/* TnReadLine : Lit une ligne de donnees (jusqu'à ) */\n/* retourne TN_ERROR, TN_TIMEOUT, TN_BUFFERFREED */\n/* TN_OVERFLOW ou le nombre d'octets lus */\n/* dans les deux derniers cas le buffer szBuf est */\n/* renseigne. Si TN_SUCCESS il est -termine. */\n/* ------------------------------------------------------------ */\n\nint API4U TnReadLine (SOCKET s,LPSTR szBuf,UINT uBufSize,UINT uTimeOut,HFILE hf)\n{\nint Rc;\n\n Tcp4uLog (LOG4U_PROC, \"TnReadLine\");\n Rc = InternalTnReadLine (s, szBuf, uBufSize, uTimeOut, hf);\n if (Rc==TN_SUCCESS) Tcp4uDump (szBuf, Strlen(szBuf), DUMP4U_RCVD);\n Tcp4uLog (LOG4U_EXIT, \"TnReadLine\");\nreturn Rc;\n} /* TnReadLine */\n\n\nint InternalTnReadLine (SOCKET s,LPSTR szBuf,UINT uBufSize,UINT uTimeOut,\n HFILE hf)\n{\nint Rc;\n\n if (s==INVALID_SOCKET || uBufSize==0) return TN_ERROR; /* ??? */\n\n memset (szBuf, 0, uBufSize);\n Rc = InternalTcpRecvUntilStr (s, szBuf, & uBufSize, \"\\n\", 1, \n TRUE, uTimeOut, hf);\n if (Rc>=TCP4U_SUCCESS && szBuf[uBufSize-1]=='\\r') \n szBuf[uBufSize-1]=0 ; \n /* pas de translation des erreurs, timeout... */\nreturn (Rc>=TCP4U_SUCCESS) ? TN_SUCCESS : Rc;\n} /* InternalTnReadLine */\n\n\n\n\n\n/* ******************************************************************* */\n/* */\n/* Partie III : Etage Telnet Haut */\n/* */\n/* ******************************************************************* */\n\n/* ------------------------------------------------------------ */\n/* TnSend : Formatage d'une trame au format Telnet (terminée */\n/* par */\n/* Retour par TN_ERROR, ou TN_SUCCESS. */\n/* ------------------------------------------------------------ */\nint API4U TnSend (SOCKET s, LPCSTR szString, BOOL bHighPriority, HFILE hf)\n{\nint Rc, Z;\nLPSTR p;\n\n Tcp4uLog (LOG4U_PROC, \"TnSend\");\n\n Z = Strlen (szString)+sizeof (\"\\r\\n\")-1;\n p = Calloc (Z+1, 1);\n if (p==NULL) return TCP4U_INSMEMORY;\n Strcpy (p, szString);\n Strcat (p, \"\\r\\n\");\n Rc = InternalTcpSend (s, p, Z, bHighPriority, hf);\n if (Rc==TCP4U_SUCCESS) Tcp4uDump (p, Z, DUMP4U_SENT);\n Free (p);\n Tcp4uLog (LOG4U_EXIT, \"TnSend : return code %d\", Rc);\nreturn Rc==TCP4U_SUCCESS ? TN_SUCCESS : TN_ERROR;\n} /* TnSend */\n\n\n\n/* ------------------------------------------------------------ */\n/* TnReadMultiLine : waits for a message from the remote peer */\n/* This message can contain several lines */\n/* As said in Telnet RFC, it depends on the */\n/* 4th char. */\n/* - A TN_XX code is returned */\n/* 20.02.1998: A bug has been found and fixed by .*/\n/* The loop test was weak enough. */\n/* 04.03.1998: rewritten according to the FTP spec (RFC 959) */\n/* Should manage propoerly Text like : */\n/* 123-First line */\n/* Second line */\n/* 234 A line beginning with numbers */\n/* 123 The last line */\n/* ------------------------------------------------------------ */\nint API4U TnReadMultiLine (SOCKET ctrl_skt, LPSTR szInBuf,\n UINT uBufSize, UINT uTimeOut, HFILE hf)\n{\nint Rc, TnRc;\nunsigned nPos=0;\n \n Tcp4uLog (LOG4U_PROC, \"TnReadMultiLine\");\n\n if (szInBuf==NULL || uBufSize==0) return TN_ERROR;\n memset (szInBuf, 0, uBufSize);\n\n do\n {\n /* add the character */\n if (szInBuf[nPos] != 0) /* changed by Sergej */\n { \n nPos+=Strlen (&szInBuf[nPos]); /* pointer sur la fin de ligne */\n \t szInBuf[nPos++]='\\n';\n }\n Rc = InternalTnReadLine (ctrl_skt, &szInBuf[nPos], \n uBufSize-nPos-1, uTimeOut,hf);\n /* exit on - errors */\n /* - buffer full */\n /* - 3 digits at the beginning of the string */\n /* not followed by HYPHEN */\n }\n while ( nPos < uBufSize - 5 /* encore de la place (y compris pour \\0) */\n && Rc>=TCP4U_SUCCESS /* retour correct */\n && ! (isdigit (szInBuf[nPos]) && szInBuf[nPos+3] != '-' ) );\n\n /* supprime la derniere marque fin de ligne */\n if (Rc>=TCP4U_SUCCESS)\n { \n Rc = TCP4U_SUCCESS;\n nPos+=Strlen (&szInBuf[nPos]);\n if (szInBuf[nPos-1]=='\\r') szInBuf[nPos-1]=0;\n }\n /* translation du code de retour */\n switch (Rc)\n {\n case TCP4U_TIMEOUT : TnRc = TN_TIMEOUT;\t\tbreak;\n case TCP4U_SUCCESS : Tcp4uDump (szInBuf, nPos, DUMP4U_RCVD);\n TnRc = TN_SUCCESS; \tbreak;\n case TCP4U_OVERFLOW : Tcp4uDump (szInBuf, nPos, \"Overflow\");\n TnRc = TN_OVERFLOW; \t\tbreak;\n case TCP4U_SOCKETCLOSED : TnRc = TN_SOCKETCLOSED;\tbreak;\n case TCP4U_CANCELLED : TnRc = TN_CANCELLED;\t\tbreak;\n default : TnRc = TN_ERROR;\t\t\tbreak;\n }\n\n Tcp4uLog (LOG4U_EXIT, \"TnReadMultiLine: return code %d\", TnRc);\nreturn TnRc;\n} /* TnReadMultiLine */\n\n\n\n/* ------------------------------------------------------------ */\n/* TnSendMultiLine : Formatage d'une trame au format Telnet */\n/* expanded into */\n/* Retour par TN_ERROR, ou TN_SUCCESS. */\n/* ------------------------------------------------------------ */\nint API4U TnSendMultiLine (SOCKET s, LPCSTR szString, BOOL bEnd, HFILE hf)\n{\nint Rc, Z;\nLPCSTR p;\nLPSTR pString;\n\n Tcp4uLog (LOG4U_PROC, \"TnSendMultiLine\");\n\n \n /* counts the number of char */\n for ( Z=0, p=szString ; *p!=0 ; p++, Z++ )\n if (*p=='\\n') Z++;\n\n /* put the string into a new writeable buffer */\n pString = Calloc (Z+sizeof (\"\\r\\n\"), 1);\n if (pString==NULL) return TCP4U_INSMEMORY;\n for ( Z=0, p=szString ; *p!=0 ; p++, Z++ )\n {\n if (*p=='\\n' && (p>szString && *(p-1)!='\\r')) \n pString[Z++] = '\\r';\n pString[Z] = *p;\n }\n if (bEnd) \n {\n pString[Z++] = '\\r'; \n pString[Z++] = '\\n';\n }\n pString[Z] = 0;\n /* Job has been done, send the string and exit */\n Rc = InternalTcpSend (s, pString, Z, FALSE, hf);\n if (Rc==TCP4U_SUCCESS) \n Tcp4uDump (pString, Z, DUMP4U_SENT);\n Free (pString);\n Tcp4uLog (LOG4U_EXIT, \"TnSendMultiLine : return code %d\", Rc);\nreturn Rc==TCP4U_SUCCESS ? TN_SUCCESS : TN_ERROR;\n} /* TnSendMultiLine */\n\n\n/* ------------------------------------------------------------ */\n/* TnGetAnswerCode : Attend une réponse du serveur et rend le */\n/* code numérique (les 3 premiers octets) */\n/* renvoyé par le serveur. */\n/* - Retourne un nombre entre 100 et 999 si la */\n/* fonction s'est bien passée, sinon un code */\n/* d'erreur TN_ERROR, TN_TIMEOUT... */\n/* ------------------------------------------------------------ */\nint API4U TnGetAnswerCode (SOCKET ctrl_skt, LPSTR szInBuf,\n UINT uBufSize, UINT uTimeOut, HFILE hf)\n{\nint Rc;\n\n Tcp4uLog (LOG4U_PROC, \"TnReadAnswerCode\");\n \n Rc = TnReadMultiLine (ctrl_skt, szInBuf, uBufSize, uTimeOut, hf);\n if (Rc==TN_SUCCESS)\t\tRc = Tcp4uAtoi (szInBuf);\n \n Tcp4uLog (LOG4U_EXIT, \"TnReadAnswerCode: return code %d\", Rc); \nreturn Rc;\n} /* TnGetAnswerCode */\n\n#ifndef __PMANAGERTYPES_H__\r\n#define __PMANAGERTYPES_H__\r\n\r\n#include \"pNxSDKParameter.h\"\r\n\r\n\r\ntypedef enum pManagerFlags\r\n{\t\r\n\tPMF_DONT_DELETE_SCENES=1<<1,\r\n\tPMF_DONT_USE_HARDWARE=1<<2,\r\n};\r\n\r\nstruct pTriggerEntry\r\n{\r\n\r\n\tNxShape *shapeA;\r\n\tNxShape *shapeB;\r\n\tint triggerEvent;\r\n\tbool triggered;\r\n\tCK3dEntity *triggerBody;\r\n\tCK3dEntity *otherObject;\r\n\tCK3dEntity *triggerShapeEnt;\r\n\r\n\tpRigidBody *triggerBodyB;\r\n\tpRigidBody *otherBodyB;\r\n\r\n\r\n\tpTriggerEntry()\r\n\t{\r\n\t\tshapeA = shapeB = NULL;\r\n\t\ttriggerShapeEnt =otherObject = triggerBody = NULL;\r\n\t\t triggerBodyB = otherBodyB = NULL;\r\n\t\ttriggerEvent;\r\n\t\ttriggered = false;\r\n\t}\r\n};\r\n\r\ntypedef XArraypTriggerArray;\r\n\r\n\r\n//################################################################\r\n//\r\n// Help Structures, used by the manager only \r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Container to maintain multiple worlds\r\n//\r\ntypedef XHashTable pWorldMap;\r\ntypedef XHashTable::Iterator pWorldMapIt;\r\n\r\ntypedef XArraypBodyList;\r\ntypedef XArray::Iterator pBodyListIterator;\r\n\r\n\r\ntypedef XHashTable pRestoreMap;\r\ntypedef XHashTable::Iterator pRestoreMapIt;\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Function pointer. Used in custom parameter structures to populate\r\n//\tfound xml types\r\n//\r\ntypedef XString (pFactory::*PFEnumStringFunction)(const TiXmlDocument * doc);\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Function pointer to link object registrations per attribute type \r\n//\r\ntypedef int (*ObjectRegisterFunction)(CK3dEntity*,int,bool,bool);\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Meta data for ObjectRegisterFunction. Used for attribute callbacks.\r\n//\r\nstruct ObjectRegistration\r\n{\r\n\tCKGUID guid;\r\n\tObjectRegisterFunction rFunc;\r\n\tObjectRegistration(CKGUID _guid,ObjectRegisterFunction _func) : \r\n\tguid(_guid) , \r\n\t\trFunc(_func)\r\n\t{\r\n\r\n\t}\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief\tMeta data for attributes callbacks when the scene is playing.
\r\n//!\t\t\tVirtools is not initializing the attributes parameter correctly.\r\n//\t\t\tThs structur is used to track data to the next frame. \r\n//\r\nstruct pAttributePostObject\r\n{\r\n\r\n\tCK_ID objectId;\r\n\tObjectRegisterFunction func;\r\n\tint attributeID;\r\n\r\n\tpAttributePostObject() :\r\n\tobjectId(-1) , func(NULL) , attributeID(-1){}\r\n\r\n\tpAttributePostObject(CK_ID _id,ObjectRegisterFunction _func,int _attributeID) :\r\n\tobjectId(_id) , \r\n\t\tfunc(_func) , \r\n\t\tattributeID(_attributeID)\r\n\t{\r\n\r\n\t}\r\n\r\n};\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Container type to store objects with uninitialized attribute parameters.\r\n//\r\ntypedef XArrayPostRegistrationArrayType;\r\ntypedef XArray::Iterator PostRegistrationArrayIteratorType;\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Container to store custom function pointer per attribute type\r\n//\r\ntypedef XHashTableAttributeFunctionArrayType;\r\ntypedef XHashTable::Iterator AttributeFunctionArrayIteratorType;\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief CustomParametersArrayType is responsible to track custom structures and its default value.\r\n//!\r\ntypedef XHashTableCustomParametersArrayType;\r\ntypedef XHashTable::Iterator CustomParametersArrayIteratorType;\r\n\r\n\r\n\r\n\r\n\r\nstruct pSDKParameters\r\n{\r\n\tfloat SkinWidth;\r\n\tfloat DefaultSleepLinVelSquared ;\r\n\tfloat DefaultSleepAngVel_squared; \r\n\tfloat BounceThreshold ; \r\n\tfloat DynFrictScaling ; \r\n\tfloat StaFrictionScaling; \r\n\tfloat MaxAngularVelocity ; \r\n\tfloat ContinuousCD ; \r\n\tfloat AdaptiveForce ; \r\n\tfloat CollVetoJointed ; \r\n\tfloat TriggerTriggerCallback ; \r\n\tfloat CCDEpsilon ; \r\n\tfloat SolverConvergenceThreshold ; \r\n\tfloat BBoxNoiseLevel ; \r\n\tfloat ImplicitSweepCacheSize ; \r\n\tfloat DefaultSleepEnergy ; \r\n\tfloat ConstantFluidMaxPackets ; \r\n\tfloat ConstantFluidMaxParticlesPerStep ; \r\n\tfloat AsynchronousMeshCreation ; \r\n\tfloat ForceFieldCustomKernelEpsilon ; \r\n\tfloat ImprovedSpringSolver ; \r\n\tint disablePhysics;\r\n\r\n\tpSDKParameters()\r\n\t{\r\n\r\n\t\tSkinWidth = 0.25f;\r\n\t\tDefaultSleepLinVelSquared = 0.15f*0.15f;\r\n\t\tDefaultSleepAngVel_squared = 0.15f*0.15f; \r\n\t\tBounceThreshold = -2.0f ; \r\n\t\tDynFrictScaling =1.0f; \r\n\t\tStaFrictionScaling = 1.0f; \r\n\t\tMaxAngularVelocity = 7.0f ; \r\n\t\tContinuousCD = 0.0f; \r\n\t\tAdaptiveForce = 1.0f; \r\n\t\tCollVetoJointed = 1.0f; \r\n\t\tTriggerTriggerCallback= 1.0f ; \r\n\t\tCCDEpsilon = 0.01f; \r\n\t\tSolverConvergenceThreshold = 0.0f ; \r\n\t\tBBoxNoiseLevel =0.001f ; \r\n\t\tImplicitSweepCacheSize = 5.0f ; \r\n\t\tDefaultSleepEnergy = 0.005f; \r\n\t\tConstantFluidMaxPackets = 925.0f ; \r\n\t\tConstantFluidMaxParticlesPerStep = 4096 ; \r\n\t\tImprovedSpringSolver = 1.0f; \r\n\t\tdisablePhysics = 0;\r\n\t}\r\n};\r\n\r\n\r\nclass pRemoteDebuggerSettings\r\n{\r\n\r\npublic :\r\n\tXString mHost;\r\n\tint port;\r\n\tint enabled;\r\n\r\n\tpRemoteDebuggerSettings()\r\n\t{\r\n\t\tmHost= \"localhost\";\r\n\t\tport = 5425;\r\n\t\tenabled = 0;\r\n\t}\r\n};\r\n\r\n\r\n\r\n#endif // __PMANAGERTYPES_H__SET devdir=X:\\sdk_ide\\msvc8\\Common7\\IDE\r\nSET devexe=X:\\sdk_ide\\msvc8\\Common7\\IDE\\devenv.exe\r\nSET solution=X:\\ProjectRoot\\svnLocal\\local\\vtPhysX\\build4\\vs2005\\vtAgeia.sln\r\n\r\ncd %devdir%\r\n%devexe% %solution% /out x:\\log.txt /Build \"Debug|Win32\"\r\n\r\n\r\n\r\n\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n\r\n\r\n#include \r\n//#include \"windows.h\"\r\n\r\nTNL::RefPtrm_NetInterfaceServer = NULL;\r\nTNL::RefPtrGetServerInterface(){ return m_NetInterfaceServer;}\r\nconst char *localBroadcastAddress = \"IP:broadcast:28999\";\nconst char *localHostAddress = \"IP:127.0.0.1:28999\";\r\nconst char *localServerAddress =\"IP:Any:28999\";\n\nclass DedicatedServerLogConsumer : public TNL::LogConsumer\n{\npublic:\n\tvoid logString(const char *string)\n\t{\n\t\t//ctx()->OutputToConsoleEx(\"%s\\n\",string);\n\t\tprintf(\"%s\\n\\n\", string);\n\t}\n} gDedicatedServerLogConsumer;\n\nusing namespace TNL;\n\nint main(int argc, const char **argv)\n{\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//set up logging : \r\n\t//TNLLogEnable(LogGhostConnection, true);\r\n\tTNLLogEnable(LogNetInterface,true);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//create a server : \r\n\t//xNetworkFactory::xSCreateServerInterface(m_NetInterfaceServer,localServerAddress,localBroadcastAddress);\r\n\tTNL::Address *add = new TNL::Address(\"IP:Any:28999\");\r\n\tTNL::Address *addBC=new TNL::Address(\"IP:broadcast:28999\");\r\n\tm_NetInterfaceServer = new xNetInterface(true,*add,*addBC);\r\n\tTNL::AsymmetricKey *theKey = new TNL::AsymmetricKey(32);\n\tm_NetInterfaceServer->setPrivateKey(theKey);\r\n\tm_NetInterfaceServer->setRequiresKeyExchange(false);\r\n//\tm_NetInterfaceServer->GetDistObjectInterface()->SetNetworkInterface(m_NetInterfaceServer);\r\n\r\n\tif (m_NetInterfaceServer)\r\n\t{\r\n\t\tm_NetInterfaceServer->setAllowsConnections(true);\r\n\t\t//m_NetInterfaceServer->GetDistObjectInterface()->SetNetworkInterface(m_NetInterfaceServer);\r\n\t}\r\n\r\n\t//Sleep(2000);\r\n\tif (GetServerInterface())\r\n\t{\r\n\t\tlogprintf(\"\\t Server Created\");\r\n\t}\r\n\t\r\n\tfor (;;)\r\n\t{\r\n\r\n\t\tGetServerInterface()->tick();\r\n\t\tTNL::Platform::sleep(1);\r\n\t}\r\n\r\n\r\n\treturn 0;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetParDecl();\r\nCKERROR CreatePBSetParProto(CKBehaviorPrototype **pproto);\r\nint PBSetPar(const CKBehaviorContext& behcontext);\r\nCKERROR PBSetParCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_CollisionGroup,\r\n\tbbI_GroupsMask,\r\n\tbbI_Flags,\r\n\tbbI_TFlags,\r\n\tbbI_LinDamp,\r\n\tbbI_AngDamp,\r\n\tbbI_MassOffset,\r\n\tbbI_ShapeOffset,\r\n\t\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap22[] =\r\n{\r\n\r\n\tBB_SPIN(bbI_CollisionGroup,CKPGUID_INT,\"Collision Group\",\"\"),\r\n\tBB_SPIN(bbI_GroupsMask,VTS_FILTER_GROUPS,\"Group Mask\",\"0.0\"),\r\n\tBB_SPIN(bbI_Flags,VTF_BODY_FLAGS,\"Body Flags\",\"\"),\r\n\tBB_SPIN(bbI_TFlags,VTF_BODY_TRANS_FLAGS,\"Transformation Lock Flags\",\"\"),\r\n\tBB_SPIN(bbI_LinDamp,CKPGUID_FLOAT,\"Linear Damping\",\"0.0\"),\r\n\tBB_SPIN(bbI_AngDamp,CKPGUID_FLOAT,\"Angular Damping\",\"\"),\r\n\tBB_SPIN(bbI_MassOffset,CKPGUID_VECTOR,\"Mass Offset\",\"\"),\r\n\tBB_SPIN(bbI_ShapeOffset,CKPGUID_VECTOR,\"Pivot Offset\",\"\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMap22\r\n\r\n//************************************\r\n// Method: FillBehaviorPBSetParDecl\r\n// FullName: FillBehaviorPBSetParDecl\r\n// Access: public\r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBSetParDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBSetPar\");\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Sets physic parameters.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x137e7ec4,0x4ca85a4b));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBSetParProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBSetParProto\r\n// FullName: CreatePBSetParProto\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBSetParProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBSetPar\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PBSetPar\r\n\r\n\tPBSetPar is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSetPar.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body or its sub shape.\r\n\t
\r\n\tCollisions Group: Which collision group this body or the sub shape is part of.See pRigidBody::setCollisionsGroup().\r\n\t
\r\n\tGroupsmask: Sets 128-bit mask used for collision filtering. It can be sub shape specific.See comments for ::pGroupsMask and pRigidBody::setGroupsMask()\r\n\t
\r\n\r\n\tFlags: Changes essential physic behavior. See pRigidBody::setFlags()
\r\n\t\t-\tThis flags can be changed after the bodies registration : \r\n\t\t\t-\tGravity\t-\tSee pRigidBody::ennableGravity() \r\n\t\t\t-\tKinematic\t-\tSee pRigidBody::setKinematic() \r\n\t\t\t-\tTrigger Shape\t- See pRigidBody::enableTriggerShape() \r\n\t\t\t-\tCollisions Notify - See pRigidBody::enableCollisionsNotify()\r\n\t\t\t-\tSleep\t- pRigidBody::setSleeping() or pRigidBody::isSleeping()\r\n\t\r\n\tTransformation Locks: Locks a translation or orientation in a specific dimension.\r\n\t
\r\n\t\r\n\tLinear Damping: The new linear damping scale.\r\n\t
\r\n\tAngular Damping: The new linear damping scale.\r\n\t
\r\n\r\n\tMass Offset: The new mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: Specifies the shapes position in the bodies local space. See pRigidBody::setLocalShapePosition().\r\n\t
\r\n\t\r\n\t\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBSetParCB );\r\n\r\n\tBB_EVALUATE_SETTINGS(pInMap22)\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PBSetPar);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetPar\r\n// FullName: PBSetPar\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBSetPar(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object :\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t\tbbErrorME(\"No valid world object found\");\r\n\t\t\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"Object not physicalized\");\r\n\r\n\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/************************************************************************/\r\n\t\tBBSParameter(bbI_CollisionGroup);\r\n\t\tBBSParameter(bbI_Flags);\r\n\t\tBBSParameter(bbI_TFlags);\r\n\t\tBBSParameter(bbI_GroupsMask);\r\n\t\tBBSParameter(bbI_LinDamp);\r\n\t\tBBSParameter(bbI_AngDamp);\r\n\t\tBBSParameter(bbI_MassOffset);\r\n\t\tBBSParameter(bbI_ShapeOffset);\r\n\r\n\t\r\n\t\tif (sbbI_GroupsMask)\r\n\t\t{\r\n\t\t\tNxGroupsMask mask1;\r\n\t\t\tCKParameter *fConst1 = beh->GetInputParameter(BB_IP_INDEX(bbI_GroupsMask))->GetRealSource();\r\n\r\n\t\t\tusing namespace vtTools::BehaviorTools;\r\n\t\t\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\t\tNxShape *dstShape = NULL;\r\n\r\n\t\t\tNxShape *mainshape = body->getMainShape();\r\n\t\t\tif (mainshape==NULL)\r\n\t\t\t{\r\n\t\t\t\tint op = 2;\r\n\t\t\t\top++;\r\n\r\n\t\t\t}\r\n\t\t\tNxShape *inputShape = body->_getSubShapeByEntityID(target->GetID());\r\n\t\t\tif (mainshape==inputShape)\r\n\t\t\t{\r\n\t\t\t\tdstShape = mainshape;\r\n\t\t\t}else{\r\n\t\t\t\tdstShape = inputShape;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tmask1.bits0 = GetValueFromParameterStruct(fConst1,0);\r\n\t\t\tmask1.bits1 = GetValueFromParameterStruct(fConst1,1);\r\n\t\t\tmask1.bits2 = GetValueFromParameterStruct(fConst1,2);\r\n\t\t\tmask1.bits3 = GetValueFromParameterStruct(fConst1,3);\r\n\t\t\t\r\n\t\t\tif (dstShape)\r\n\t\t\t{\r\n\t\t\t\tdstShape->setGroupsMask(mask1);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (sbbI_CollisionGroup)\r\n\t\t{\r\n\t\t\tint collGroup = GetInputParameterValue(beh,BB_IP_INDEX(bbI_CollisionGroup));\r\n\t\t\tbody->setCollisionsGroup(collGroup,target);\r\n\t\t}\r\n\r\n\t\tif (sbbI_Flags)\r\n\t\t{\r\n\t\t\tint flags = GetInputParameterValue(beh,BB_IP_INDEX(bbI_Flags));\r\n\t\t\tbody->updateFlags(flags,target);\r\n\t\t}\r\n\r\n\t\tif (sbbI_TFlags)\r\n\t\t{\r\n\t\t\tint tflags = GetInputParameterValue(beh,BB_IP_INDEX(bbI_TFlags));\r\n\t\t\tbody->lockTransformation(tflags);\r\n\t\t}\r\n\r\n\t\tif (sbbI_LinDamp)\r\n\t\t{\r\n\t\t\tfloat lDamp = GetInputParameterValue(beh,BB_IP_INDEX(bbI_LinDamp));\r\n\t\t\tbody->setLinearDamping(lDamp);\r\n\t\t}\r\n\t\tif (sbbI_AngDamp)\r\n\t\t{\r\n\t\t\tfloat aDamp= GetInputParameterValue(beh,BB_IP_INDEX(bbI_AngDamp));\r\n\t\t\tbody->setAngularDamping(aDamp);\r\n\t\t}\r\n\r\n\t\tif (sbbI_MassOffset)\r\n\t\t{\r\n\t\t\tVxVector mOffset= GetInputParameterValue(beh,BB_IP_INDEX(bbI_MassOffset));\r\n\t\t\tbody->setMassOffset(mOffset);\r\n\t\t}\r\n\r\n\t\tif (sbbI_ShapeOffset)\r\n\t\t{\r\n\t\t\tVxVector sOffset= GetInputParameterValue(beh,BB_IP_INDEX(bbI_ShapeOffset));\r\n\t\t\tbody->setLocalShapePosition(sOffset,target);\r\n\t\t}\r\n\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetParCB\r\n// FullName: PBSetParCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBSetParCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\t\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#pragma once\r\n\r\n//by default these functions are called in DistributedNetworkClassDialogcallback.cpp\r\n//if you do not use callback (do not have DistributedNetworkClassDialogcallback.cpp), you should call these functions manually\r\n\r\n//to add a menu in Virtools Dev main menu.\r\nvoid InitMenu();\r\n//to remove the menu from Virtools Dev main menu\r\nvoid RemoveMenu();\r\n//to fill menu with your own commands\r\nvoid UpdateMenu();\r\n\r\n#define STR_MAINMENUNAME\t\"DistributedNetworkClassDialog Menu\"\r\nvtWindowConsole.exe -d=0 -mode=server#include \r\n#include \"pCommon.h\"\r\n#include \"pConfig.h\"\r\n#include \"gConfig.h\"\r\n\r\n#pragma message(__FILE__ NXPHYSXLOADERDLL_API )\r\n\r\n\r\nvoid FindResourceX();\r\n\r\n#ifdef WebPack\r\n\textern CKERROR InitInstanceCamera(CKContext* context);\r\n\textern CKERROR ExitInstanceCamera(CKContext* context);\r\n\textern int RegisterCameraBeh(XObjectDeclarationArray *reg);\r\n#endif\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Switches between static library or dll \r\n//\r\n#ifdef CK_LIB\r\n\t#define RegisterBehaviorDeclarations\tRegister_VTPHYSX_BehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\t_VTPHYSX_InitInstance\r\n\t#define ExitInstance\t\t\t\t\t_VTPHYSX_ExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGet_VTPHYSX_PluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGet_VTPHYSX_PluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#else\r\n\t#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\tInitInstance\r\n\t#define ExitInstance\t\t\t\t\tExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CKERROR InitInstance( CKContext* theContext )\r\n*\r\n* Description : If no manager is used in the plugin these functions \r\n* are optional and can be exported. Virtools will call \r\n* 'InitInstance' when loading the behavior library and \r\n* 'ExitInstance' when unloading it. It is a good place \r\n* to perform Attributes Types declaration, registering new \r\n* enums or new parameter types.\r\n*\t\t\r\n* Parameters : CKContext* theContext\r\n* \r\n*\r\n* Returns : CKERROR\r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR InitInstanceBB(CKContext* context)\r\n{\r\n\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ExitInstanceBB(CKContext* context)\r\n{\r\n\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CKERROR InitInstance( CKContext* theContext )\r\n*\r\n* Description : If no manager is used in the plugin these functions \r\n* are optional and can be exported. Virtools will call \r\n* 'InitInstance' when loading the behavior library and \r\n* 'ExitInstance' when unloading it. It is a good place \r\n* to perform Attributes Types declaration, registering new \r\n* enums or new parameter types.\r\n*\t\t\r\n* Parameters : CKContext* theContext\r\n* \r\n*\r\n* Returns : CKERROR\r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR InitInstanceIM(CKContext* context){\r\n\r\n\r\n#ifdef Webpack\r\n\tInitInstanceCamera(context);\r\n#endif\r\n\r\n\tPhysicManager* PM =new PhysicManager(context);\r\n\tcontext->ActivateManager(PM,TRUE);\r\n\r\n#ifdef DONGLE_VERSION\r\n\tPM->_initResources(0);\r\n#endif\r\n\r\n#ifndef DONGLE_VERSION\r\n\tPM->DongleHasBasicVersion =1;\r\n#endif // _DEBUG\r\n\r\n\r\n\tif(PM->DongleHasBasicVersion)\r\n\t{\r\n\r\n\t\tPM->_RegisterDynamicParameters();\r\n\t\tPM->_RegisterParameters();\r\n\t\tPM->_RegisterVSL();\r\n\r\n\r\n#ifdef HAS_FLUIDS\r\n\t\tPM->_RegisterFluid_VSL();\r\n#endif // HAS_FLUIDS\r\n\t\tPM->_RegisterParameterOperations();\r\n\t\tPM->_registerWatchers(context);\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CKERROR ExitInstance( CKContext* theContext )\r\n*\r\n* Description : This function will only be called if the dll is \r\n* unloaded explicitely by a user in Virtools Dev interface\r\n* Otherwise the manager destructor will be called by Virtools \r\n* runtime directly.\r\n*\t\t\r\n* Parameters : CKContext* theContext\r\n* \r\n* Returns : CKERROR\r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR ExitInstanceIM(CKContext* context){\r\n\tPhysicManager* PM =(PhysicManager*)context->GetManagerByGuid(GUID_MODULE_MANAGER);\r\n\tdelete PM;\r\n\r\n\t#ifdef Webpack\r\n\t\tExitInstanceCamera(context);\r\n\t#endif\r\n\r\n\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n\r\nCKPluginInfo g_PluginInfo[2];\r\n#include \"base_macros.h\"\r\n\r\n\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CKPluginInfo* CKGetPluginInfo( int index )\r\n*\r\n* Description : This function takes an index and returns a corresponding plugin desciptor\r\n*\t\t\r\n* Parameters :\r\n* index, index of the plugin information to get\r\n*\r\n* Returns : pointer to the requested plugin information\r\n*\r\n*******************************************************************\r\n*/\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index);\r\n\r\n/*\r\n*******************************************************************\r\n* Function: int CKGetPluginInfoCount() \r\n*\r\n* Description : Returns the number of plugins in this DLL\r\n*\t\t\r\n* Parameters :\r\n* None.\r\n*\r\n* Returns : Number of plugins defined in this DLL\r\n*\r\n*******************************************************************\r\n*/\r\nint CKGetPluginInfoCount(){return 2;}\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tg_PluginInfo[0].m_Author\t\t\t= VTCX_AUTHOR; \r\n\tg_PluginInfo[0].m_Description\t\t= VTCX_API_ENTRY(\"PhysX Building Blocks\");\r\n\tg_PluginInfo[0].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[0].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[0].m_Version\t\t\t= 0x000001;\r\n\tg_PluginInfo[0].m_InitInstanceFct\t= InitInstanceBB;\r\n\tg_PluginInfo[0].m_ExitInstanceFct\t= ExitInstanceBB;\r\n\tg_PluginInfo[0].m_GUID\t\t\t\t= GUID_MODULE_BUILDING_BLOCKS;\r\n\r\n\tg_PluginInfo[1].m_Author\t\t\t=VTCX_AUTHOR;\r\n\tg_PluginInfo[1].m_Description\t\t=VTCX_API_ENTRY(\"PhysX Manager\");\r\n\tg_PluginInfo[1].m_Extension\t\t\t= \"\";\r\n\tg_PluginInfo[1].m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\tg_PluginInfo[1].m_Version\t\t\t= 0x000001;\r\n\tg_PluginInfo[1].m_InitInstanceFct\t= InitInstanceIM;\r\n\tg_PluginInfo[1].m_ExitInstanceFct\t= ExitInstanceIM;\r\n\tg_PluginInfo[1].m_GUID\t\t\t\t= GUID_MODULE_MANAGER;\r\n\tg_PluginInfo[1].m_Summary =\t\tVTCX_API_ENTRY(\"PhysX Physic Manager\");\r\n\r\n\t\t\r\n\treturn &g_PluginInfo[Index];\r\n}\r\n\r\n/*\r\n******************************************************************* \r\n* Function: void RegisterBehaviorDeclarations( XObjectDeclarationArray *reg )\r\n* \r\n* Description : \r\n* \r\n* Parameters : \r\n* param rw/r/w param description \r\n* \r\n* Returns : \r\n* \r\n******************************************************************* \r\n*/ \r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// generic building blocks \r\n\t//\r\n\r\n#ifdef BBC_TOOLS\r\n\tRegisterBehavior(reg,FillBehaviorGetNextBBIdDecl);\r\n#endif\r\n/*\r\n#ifdef BBC_JOYSTICK\r\n\tRegisterBehavior(reg,FillBehaviorHasFFEffectsDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJSetXYForceDecl);\r\n#endif\r\n\t*/\r\n\r\n\t/************************************************************************/\r\n\t/* Bodies: */\r\n\t/************************************************************************/\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorPBPhysicalizeDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBAddTorqueDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddForceDecl);\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorPBAddForceAtLocalPosDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddLocalForceDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddLocalForceAtPosDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddLocalForceAtLocalPosDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddLocalTorqueDecl);\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorAddForceAtPosDecl);\r\n\t\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorPBSetDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBSet2Decl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBSetParDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBPhysicalizeExDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBAddShapeExDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBSetHardDecl);\r\n\r\n\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBGetDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBGet2Decl);\r\n\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBGetParameterDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBGetVelocitiesAndForcesDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBDestroyDecl);\r\n\r\n#ifdef BBC_JOINTS\r\n\t/************************************************************************/\r\n\t/* D6 */\r\n\t/************************************************************************/\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPJGroupBreakIteratorDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorJSetD6Decl);\r\n\tRegisterBehavior(reg,FillBehaviorJD6SetMotionModeDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJD6SetSoftLimitDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJD6SetDriveDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJD6SetParametersDecl);\r\n\r\n\t/************************************************************************/\r\n\t/* Joints */\r\n\t/************************************************************************/\r\n\tRegisterBehavior(reg,FillBehaviorJSetBallDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJSetBreakForcesDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJSetFixedDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJIsBrokenDecl);\r\n\tRegisterBehavior(reg,FillBehaviorJDestroyDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJCreateDistanceJointDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJRevoluteDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJIteratorDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPJPulleyDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJPrismaticDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJCylindricalDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJPointPlaneDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJPointOnLineDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPJAddLimitPlaneDecl);\r\n#endif // BBC_JOINTS\r\n\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* collision */\r\n\t/************************************************************************/\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorPWSetCollisionGroupFlagDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPCIgnorePairDecl);\r\n\tRegisterBehavior(reg,FillBehaviorCollisionsCheckADecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBSetTriggerMaskDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPCTriggerEventDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPCGroupTriggerEventDecl);\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* Shapes : */\r\n\t/************************************************************************/\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBAddShapeDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPBRemoveShapeDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPBSetCallbackDecl);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Clothes : */\r\n\t/************************************************************************/\r\n\r\n\r\n#ifdef DONGLE_VERSION\r\n\tif(!PhysicManager::DongleHasAdvancedVersion)\r\n\t\treturn;\r\n#endif\r\n\r\n\r\n#ifdef BBC_CLOTHES\r\n\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPClothDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothAttachToShapeDecl);\r\n\t//RegisterBehavior(reg,FillBehaviorPClothAttachToCoreDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPClothAttachVertexToShapeDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothAttachVertexToPositionDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothFreeVertexDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothDominateVertexDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothDetachFromShapeDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothDestroyDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothAddForceAtPosDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothAddForceAtVertexDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPClothAddDirectedForceAtPosDecl);\r\n\r\n#endif\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPWSetFilteringDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPWRayCastAllShapeDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPWRayCastAnyBoundsDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPWOverlapSphereDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorPWOBBOverlapDecl);\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tVehicles and Wheels : \r\n\t\r\n#ifdef BBC_VEHICLES\r\n\tRegisterBehavior(reg,FillBehaviorPVWGetDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVWSetDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVSetDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVSetExDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVControlDecl);\r\n\t\r\n\tRegisterBehavior(reg,FillBehaviorPVSetMotorValuesDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVSetGearsDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVControl2Decl);\r\n\tRegisterBehavior(reg,FillBehaviorPVSetBreakSettingsDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPVGetDecl);\r\n#endif\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tMaterial \r\n\tRegisterBehavior(reg,FillBehaviorPBSetMaterialDecl);\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tMaterial \r\n\r\n\tRegisterBehavior(reg,FillBehaviorPManagerDecl);\r\n\tRegisterBehavior(reg,FillBehaviorRegisterAttributeTypeDecl);\r\n\r\n\tRegisterBehavior(reg,FillBehaviorLogEntryDecl);\r\n\tRegisterBehavior(reg,FillBehaviorPMaterialIteratorDecl);\r\n\r\n\r\n\r\n\t#ifdef WebPack\r\n\t\tRegisterCameraBeh(reg);\r\n\t#endif\r\n\r\n}\r\n// Editor.cpp : Defines the initialization routines for the DLL.\r\n//\r\n\r\n#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceEditor.h\"\r\n#include \"vtAgeiaInterfaceEditorDlg.h\"\r\n#include \"vtAgeiaInterfaceToolbarDlg.h\"\r\n#include \"vtAgeiaInterfaceCallback.h\"\r\n\r\n#include \"resource.h\"\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nvtAgeiaInterfaceEditorDlg*\t\tg_Editor\t\t\t= NULL;\r\nvtAgeiaInterfaceToolbarDlg*\t\tg_Toolbar\t\t\t= NULL;\r\n\r\n//----------------------------------------\r\n//The Plugin Info structure that must be filled for Virtools Dev to load effectively the plugin\r\nPluginInfo g_PluginInfo0;\r\n\r\n//Returns the number of plugin contained in this dll\r\n//this function must be exported (have a .def file with its name or use __declspec( dllexport )\r\nint GetVirtoolsPluginInfoCount()\r\n{\r\n\treturn 1;\r\n}\r\n\r\n//returns the ptr of the (index)th plugininfo structure of this dll\r\n//this function must be exported (have a .def file with its name or use __declspec( dllexport )\r\nPluginInfo* GetVirtoolsPluginInfo(int index)\r\n{\r\n\tswitch(index)\r\n\t{\r\n\tcase 0:\r\n\t\treturn &g_PluginInfo0;\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n//\r\n//\tNote!\r\n//\r\n//\t\tIf this DLL is dynamically linked against the MFC\r\n//\t\tDLLs, any functions exported from this DLL which\r\n//\t\tcall into MFC must have the AFX_MANAGE_STATE macro\r\n//\t\tadded at the very beginning of the function.\r\n//\r\n//\t\tFor example:\r\n//\r\n//\t\textern \"C\" BOOL PASCAL EXPORT ExportedFunction()\r\n//\t\t{\r\n//\t\t\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n//\t\t\t// normal function body here\r\n//\t\t}\r\n//\r\n//\t\tIt is very important that this macro appear in each\r\n//\t\tfunction, prior to any calls into MFC. This means that\r\n//\t\tit must appear as the first statement within the \r\n//\t\tfunction, even before any object variable declarations\r\n//\t\tas their constructors may generate calls into the MFC\r\n//\t\tDLL.\r\n//\r\n//\t\tPlease see MFC Technical Notes 33 and 58 for additional\r\n//\t\tdetails.\r\n//\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceEditorApp\r\n\r\nBEGIN_MESSAGE_MAP(vtAgeiaInterfaceEditorApp, CWinApp)\r\n\t//{{AFX_MSG_MAP(vtAgeiaInterfaceEditorApp)\r\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code!\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceEditorApp construction\r\n\r\nvtAgeiaInterfaceEditorApp::vtAgeiaInterfaceEditorApp()\r\n{\r\n\tmContext = NULL;\r\n\tpMan =NULL;\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// The one and only vtAgeiaInterfaceEditorApp object\r\n\r\nvtAgeiaInterfaceEditorApp theApp;\r\n\r\n\r\n\r\n\r\n\r\n\r\nBOOL vtAgeiaInterfaceEditorApp::InitInstance() \r\n{\r\n\tAfxOleInit();\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\tif (GetCKContext(0))\r\n\t{\r\n\t\t/*theApp.mContext = GetCKContext(0);\r\n\t\tPhysicManager *im = (PhysicManager*)getContext()->GetManagerByGuid(PhysicManager_GUID);\r\n\t\tif (im)\r\n\t\t{\r\n\t\t\tpMan = im;\r\n\t\t}*/\r\n\t}\r\n\t\r\n\tstrcpy(g_PluginInfo0.m_Name,\"vtAgeiaInterface\");\r\n\tg_PluginInfo0.m_PluginType\t\t= PluginInfo::PT_EDITOR;\r\n\t//g_PluginInfo0.m_PluginType\t\t= (PluginInfo::PLUGIN_TYPE)(g_PluginInfo0.m_PluginType | PluginInfo::PTF_RECEIVENOTIFICATION);\r\n\t\r\n\t\r\n\t//EDITOR\r\n\t{\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Guid[1]\t\t\t\t\t\t= 0xd07cc06a;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Guid[2]\t\t\t\t\t\t= 0x7ca4fc86;\r\n\t\tstrcpy(g_PluginInfo0.m_EditorInfo.m_EditorName,\"vtAgeiaEditor\");\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_CreateEditorDlgFunc\t\t\t= fCreateEditorDlg;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_CreateToolbarDlgFunc\t\t\t= fCreateToolbarDlg;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bUnique\t\t\t\t\t\t= 1;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bIndestructible\t\t\t\t= 0;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bManageScrollbar\t\t\t\t= 0;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Width\t\t\t\t\t\t\t= 400;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Height\t\t\t\t\t\t\t= 200;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_ToolbarHeight\t\t\t\t\t= 21;\r\n\t\t//InitImageList();\r\n\t\tg_PluginInfo0.m_EditorInfo.m_IconList\t\t\t\t\t\t= &m_ImageList;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_IconIndex\t\t\t\t\t\t= 0;\r\n\t\t\r\n\t\tg_PluginInfo0.m_PluginCallback\t= PluginCallback;\r\n\t}\r\n\t\r\n\r\n\treturn CWinApp::InitInstance();\r\n}\r\n\r\nint vtAgeiaInterfaceEditorApp::ExitInstance() \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\t\r\n\tDeleteImageList();\r\n\r\n\treturn CWinApp::ExitInstance();\r\n}\r\n\r\nvoid vtAgeiaInterfaceEditorApp::InitImageList()\r\n{\r\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n\r\n\tm_ImageList.Create(16, 16, ILC_COLOR8|ILC_MASK, 0, 2);\r\n\r\n//\tm_ImageList.Add(AfxGetApp()->LoadIcon(IDI_EDITORICON));\r\n}\r\n\r\nvoid vtAgeiaInterfaceEditorApp::DeleteImageList()\r\n{\r\n\tm_ImageList.DeleteImageList();\r\n}\r\n\r\n\r\n/*\r\n\r\nCWnd* thisSubParentWindow = CWnd::FromHandle((HWND)ParentWindow);\r\nMultiParamEditDlg\tpedit(GetCKContext(0), thisSubParentWindow);\r\nint s = pedit.GetMode();\r\npedit.SetMode(MultiParamEditDlg::AUTOCLOSE_WHEN_MODELESS|MultiParamEditDlg::MODELESSEDIT);\r\n\r\nCKParameterOut *commonParameter= GetParameterFromStruct(param,PS_COMMON_SETTINGS);\r\npedit.AddParameter(commonParameter);\r\n//for (int i = 0; i < mfx->m_Params.Size(); ++i)\r\n//\tpedit.AddParameter(mfx->m_Params[i]);\r\npedit.SetTitle(\"Material Shader Fx Params\");\r\npedit.DoModal();\r\n\r\nreturn pedit.GetSafeHwnd();\r\n\r\nchar name[256];\r\nif (oriUIFunc && param)\r\n{\r\n\r\n\t//CWnd* thisSubParentWindow = CWnd::FromHandle((HWND)ParentWindow);\r\n\tCWnd* thisSubParentWindow = CWnd::FromHandle((HWND)ParentWindow);\r\n\tCString strMain;\r\n\tthisSubParentWindow->GetWindowText(strMain);\r\n\r\n\r\n\r\n\tif (thisSubParentWindow !=NULL )\r\n\t{\r\n\t\tCWnd* bigParentWindow = thisSubParentWindow;\r\n\t\tfor( CWnd* subParentWindow = bigParentWindow->GetWindow(GW_CHILD); subParentWindow ; subParentWindow = subParentWindow->GetWindow(GW_HWNDNEXT) )\r\n\t\t{\r\n\r\n\r\n\t\t\tCString str;\r\n\t\t\tsubParentWindow->GetWindowText(str);\r\n\r\n\t\t\tGetClassName( subParentWindow->m_hWnd, name, sizeof(name) );\r\n\r\n\t\t\tXString _name(name);\r\n\t\t\t//if( strcmp(name,MFC_NAME_OF_DIALOG) ) continue;\r\n\t\t\tfor( CWnd* child = subParentWindow->GetWindow(GW_CHILD) ; child ; child = child->GetWindow(GW_HWNDNEXT) )\r\n\t\t\t{\r\n\r\n\r\n\t\t\t\tCString str2;\r\n\t\t\t\tchild->GetWindowText(str);\r\n\r\n\r\n\t\t\t\t//GetClassName( child->m_hWnd, name, sizeof(name) );\r\n\t\t\t\t//XString _name2(name);\r\n\r\n\t\t\t\t//if( strcmp(name,MFC_NAME_OF_DIALOG) ) continue;\r\n\r\n\t\t\t\t//CParameterDialog* otherParamDialog = (CParameterDialog*)(child->SendMessage( CKWM_GETPARAMDIALOG, 0, 0 ));\r\n\t\t\t\t//if( !otherParamDialog ) continue;\r\n\r\n\t\t\t\tCKParameterOut *commonParameter= GetParameterFromStruct(param,PS_COMMON_SETTINGS);\r\n\t\t\t\tif (commonParameter)\r\n\t\t\t\t{\r\n\t\t\t\t\tint p2=2;\r\n\t\t\t\t\tp2++;\r\n\t\t\t\t\t//SetParameterStructureValue(commonParameter,PS_HULL_TYPE,HT_Mesh,false);\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\t//--- From this point it should be a CParameterDialog...\r\n\t\t\t\t//CParameterDialog* otherParamDialog = (CParameterDialog*)(child->SendMessage( CKWM_GETPARAMDIALOG, 0, 0 ));\r\n\t\t\t\t//if( !otherParamDialog ) continue;\r\n\r\n\t\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//MultiParamEditDlg test(param->GetCKContext(),ParentWindow);\r\n\r\n\r\n\tCKParameterOut *commonParameter= GetParameterFromStruct(param,PS_COMMON_SETTINGS);\r\n\tif (commonParameter)\r\n\t{\r\n\t//SetParameterStructureValue(commonParameter,PS_HULL_TYPE,HT_Mesh,false);\r\n\r\n\t}\r\n\t//return (*oriUIFunc)(param,ParentWindow,rect);\r\n\treturn ParentWindow;\r\n\tdouble d = 0.0;\r\n}\r\n\r\n*/#ifndef __VT_BB_MACROS_H__\r\n#define __VT_BB_MACROS_H__\r\n\r\n//#ifndef __VT_TOOLS_H__\r\n//\t#include \r\n//#endif\r\n\r\n#ifndef __VT_BB_HELPER_H__\r\n\t#include \r\n#endif\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tThe directive _DOC_ONLY_ is just for forcing in/out- parameters creation in dynamic building blocks. \r\n//\tThis allows imagegen.exe to create the right pictures\r\n//\r\n//#define _DOC_ONLY_ 0\r\n\r\n\r\n#ifdef _DOC_ONLY_\r\n\t#define BB_SPIN(I,G,N,D) BBParameter(I,G,N,D,1)\r\n#else\r\n\t#define BB_SPIN(I,G,N,D) BBParameter(I,G,N,D)\r\n#endif\r\n\r\n#define BB_PIN(I,G,N,D) BBParameter(I,TRUE,G,N,D,1)\r\n\r\n#define BB_SPIN_ON(I,G,N,D) BBParameter(I,G,N,D,1)\r\n\r\n\r\n#define BB_DECLARE_PMAP\tBBParArray *pMap = static_cast(beh->GetAppData())\r\n\r\n\r\n#define BB_CREATE_PMAP BBParArray *pMap = static_cast(beh->GetAppData());\\\r\n\tif(!pMap) pMap = new BBParArray(); \\\r\n\tbeh->SetAppData(pMap)\r\n\r\n\r\n#define BB_DELETE_OLD_MAP if (beh->GetAppData()!=NULL){\\\r\n\tpMap = NULL;\\\r\n\tbeh->SetAppData(NULL);\\\r\n}\\\r\n\r\n#define BB_CKECK_MAP if (pMap==NULL)\\\r\n\t{\\\r\n\tpMap = new BBParArray();\\\r\n\t}\\\r\n\r\n\r\n\r\n\r\n#define BB_CLEANUP BB_DELETE_OLD_MAP;\\\r\n\tBB_CKECK_MAP\r\n\r\n\r\n#define BB_CREATE_PIMAP BBParArray *pIMap = new BBParArray(); \\\r\n\tbeh->SetAppData(pIMap)\r\n\r\n#define BB_DECLARE_PIMAP\tBBParArray *pIMap = static_cast(beh->GetAppData())\r\n\r\n#define BB_PMAP_SIZE(SOURCE_MAP)\t(sizeof(SOURCE_MAP) / sizeof(SOURCE_MAP[0]))\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#define BB_DESTROY_PIMAP BB_DECLARE_PIMAP;\t\\\r\n\tBBHelper::destroyPIMap(beh,pIMap);\t\\\r\n\r\n#define BB_INIT_PIMAP(SOURCE_MAP,SETTING_START_INDEX)\tBB_CREATE_PMAP; \\\r\n\t\tBBHelper::initPIMap(beh,pMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX);\r\n\t\r\n\r\n#define BB_REMAP_PIMAP(SOURCE_MAP,SETTING_START_INDEX) BB_DECLARE_PIMAP;\\\r\n\tBBHelper::remapArray(beh,pIMap,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX)\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n#define BB_EVALUATE_SETTINGS(A) for (int i = 0 ; i < BB_PMAP_SIZE(A) ; i ++)\t{\t\\\r\n\tif(!A[i].fixed)proto->DeclareSetting(A[i].name.Str(),CKPGUID_BOOL, A[i].condition==-1 ? \"FALSE\" : \"TRUE\" ); } \\\r\n\r\n#define BB_EVALUATE_PINS(A) for (int i = 0 ; i < BB_PMAP_SIZE(A) ; i ++)\t{\t\\\r\n\tif(A[i].fixed)proto->DeclareInParameter(A[i].name.Str(),A[i].guid,A[i].defaultValue.Str()); } \\\r\n\r\n#define BB_EVALUATE_OUTPUTS(A) for (int i = 0 ; i < BB_PMAP_SIZE(A) ; i ++)\t{\t\\\r\n\tproto->DeclareOutParameter(A[i].name.Str(),A[i].guid,A[i].defaultValue.Str()); } \\\r\n\r\n#define BB_EVALUATE_INPUTS(A) for (int i = 0 ; i < BB_PMAP_SIZE(A) ; i ++)\t{\t\\\r\n\tproto->DeclareInParameter(A[i].name.Str(),A[i].guid,A[i].defaultValue.Str()); } \\\r\n\r\n//################################################################\r\n//\r\n// \r\n//\r\n#define BB_LOAD_PIMAP(SOURCE_MAP,SETTING_START_INDEX) BB_CLEANUP;\\\r\n\tBBHelper::loadPIMap(beh,pMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX); \\\r\n\tbeh->SetAppData(pMap)\r\n\r\n\r\n#define BB_LOAD_POMAP(SOURCE_MAP,SETTING_START_INDEX) BB_CLEANUP;\\\r\n\tBBPOHelper::loadPOMap(beh,pMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX);\\\r\n\tbeh->SetAppData(pMap)\r\n\r\n\r\n\r\n#define BB_IP_INDEX(A)\tBBHelper::getIndex(beh,pIMap,A)\r\n\r\n#define BBSParameter(A) int s##A;\\\r\n\tbeh->GetLocalParameterValue(A,&s##A)\r\n\r\n#define BBSParameterM(A,B) int s##A;\\\r\n\tbeh->GetLocalParameterValue(A-B,&s##A)\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n#define BB_SPOUT(I,G,N,D) BBParameter(I,G,N,D)\r\n#define BB_SPOUT_ON(I,G,N,D) BBParameter(I,G,N,D,1)\r\n\r\n\r\n#define BB_INIT_PMAP(SOURCE_MAP,SETTING_START_INDEX)\tBB_CREATE_PMAP;\\\r\n\tBBPOHelper::initPMap(beh,pMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX)\r\n\r\n#define BB_REMAP_PMAP(SOURCE_MAP,SETTING_START_INDEX) BB_DECLARE_PMAP;\\\r\n\tBBPOHelper::remapArray(beh,pMap,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX)\r\n\r\n#define BB_DESTROY_PMAP BB_DECLARE_PMAP;\t\\\r\n\tBBPOHelper::destroyPMap(beh,pMap);\t\\\r\n\r\n#define BB_OP_INDEX(A)\tBBPOHelper::getIndex(beh,pMap,A)\r\n\r\n\r\n#define BB_O_SET_VALUE_IF(T,I,V)\t\tif (s##I)\\\r\n\tSetOutputParameterValue(beh,BB_OP_INDEX(I),V)\r\n\r\n\r\n#endif/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 10:41\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\usr\\include\\virtools\\vtBase.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\usr\\include\\virtools \r\n\tfile base:\tvtBase\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tIncludes of Virtools base types. \r\n\t\t\t\tDo not include CKObjects !!!\r\n*********************************************************************/\r\n#ifndef __VT_BASE_H__\r\n#define __VT_BASE_H__\r\n\r\n//################################################################\r\n//\r\n// Base types \r\n//\r\n#include \"XString.h\"\r\n#include \"CKTypes.h\"\r\n#include \"XHashTable.h\"\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJSetBreakForcesDecl();\r\nCKERROR CreatePJSetBreakForcesProto(CKBehaviorPrototype **pproto);\r\nint PJSetBreakForces(const CKBehaviorContext& behcontext);\r\nCKERROR PJSetBreakForcesCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyB,\r\n\tbbI_Type,\r\n\tbbI_MaxForce,\r\n\tbbI_MaxTorque\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJSetBreakForcesDecl\r\n// FullName: FillBehaviorPJSetBreakForcesDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJSetBreakForcesDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJSetBreakForces\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets the maximum forces on a joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x3ace1062,0x265d33c5));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJSetBreakForcesProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJSetBreakForcesProto\r\n// FullName: CreatePJSetBreakForcesProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJSetBreakForcesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJSetBreakForces\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\t/*! \\page PJSetBreakForces \r\n\r\n\t
\r\n\tPJSetBreakForces is categorized in \\ref Joints\r\n\t
\r\n\t\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tSets a joint as breakable or unbreakable.\r\n\t\r\n\t
\r\n\t\r\n\t

Technical Information

\r\n\r\n\r\n\tJoints can be set to be breakable. This means that if a joint is tugged on with a large enough force, it will snap apart. To set a breakable joint, set the maxForce and maxTorque members of NxJointDesc to the desired values - the smaller the value, the more easily the joint will break. The maxForce defines the limit for linear forces that can be applied to a joint before it breaks, while the maxTorque defines the limit for angular forces. The exact behavior depends on the type of joint. It is possible to change these parameters for an existing joint using #pJoint::setBreakForces().\r\n\r\n\tWhen a joint breaks, the \\ref PJIsBroken will be called.\r\n\r\n\t Maximum Force and maximum Torque\r\n\t\r\n\tThe distinction between maxForce and maxTorque is dependent on how the joint is implemented internally, which may not be obvious. For example, what appears to be an angular degree of freedom may be constrained indirectly by a linear constraint.\r\n\r\n\tTherefore, in most practical applications the user should set both maxTorque and maxForce to similar values.\r\n\r\n\tIn the current implementation, the following joints use angular constraints:\r\n\r\n\t-\t\\ref PJD6 - Only in the case where angular DOFs are locked. \r\n\t-\t\\ref PJFixed \r\n\t-\t\\ref PJPrismatic\r\n\t-\t\\ref PJRevolute \r\n\r\n\r\n\t\\image html PJSetBreakForces.png\r\n\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t\r\n\tJoint Type: The joint type. This helps the building block to identify a joint constraint. As usual there can be only one joint of the type x between two bodies.\r\n\t
\r\n\t\r\n\tMaximum Force: Maximum force the joint can withstand without breaking. \r\n\t\t-\tRange: (0,inf]\r\n\t
\r\n\r\n\tMaximum Torque: Maximum torque the joint can withstand without breaking.\r\n\t-\tRange: (0,inf]\r\n\t
\r\n\r\n\r\n\t\\Note If Maximum Force = 0.0 AND Maximum Torque = 0.0 the joint becomes unbreakable.\r\n\r\n\t

VSL : Set break forces


\r\n\t\r\n\t\\include pJSetBreakForces.vsl\r\n\t\r\n\t
\r\n\t\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pJoint::setBreakForces().
\r\n\t*/\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PJSetBreakForcesCB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Joint Type\",VTE_JOINT_TYPE,\"0\");\r\n\tproto->DeclareInParameter(\"Maximum Force\",CKPGUID_FLOAT,\"0\");\r\n\tproto->DeclareInParameter(\"Maximum Torque\",CKPGUID_FLOAT,\"0\");\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PJSetBreakForces);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJSetBreakForces\r\n// FullName: PJSetBreakForces\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJSetBreakForces(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A + B: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bbI_BodyB);\r\n\t\t\r\n\t\tint jointType = GetInputParameterValue(beh,bbI_Type); \r\n\t\tfloat maxForce = GetInputParameterValue(beh,bbI_MaxForce); \r\n\t\tfloat maxTorque = GetInputParameterValue(beh,bbI_MaxTorque); \r\n\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,jointType))\r\n\t\t\treturn CK_OK;\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t// the physic object A && B: \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\t//at least one needs to be there\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\tpJoint *joint = (worldA->getJoint(target,targetB,(JType)jointType));\r\n\t\t\tif (joint)\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\t\t}\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJSetBreakForcesCB\r\n// FullName: PJSetBreakForcesCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJSetBreakForcesCB(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn CKBR_OK;\r\n}#ifndef __VT_BODY_STRUCTS_H__\r\n#define __VT_BODY_STRUCTS_H__\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t@todo : old custom structures, classical registered \r\n//\r\ntypedef enum E_PHYSIC_PARAMETER_STRUCT\r\n{\r\n\tE_PPS_HULLTYPE,\r\n\tE_PPS_BODY_FLAGS,\r\n\tE_PPS_DENSITY,\r\n\tE_PPS_SKIN_WIDTH,\r\n\tE_PPS_MASS_OFFSET,\r\n\tE_PPS_SHAPE_OFFSET,\r\n\tE_PPS_HIRARCHY,\r\n\tE_PPS_WORLD,\r\n\tE_PPS_NEW_DENSITY,\r\n\tE_PPS_TOTAL_MASS,\r\n\tE_PPS_COLL_GROUP\r\n};\r\n\r\ntypedef enum E_MATERIAL_STRUCT\r\n{\r\n\tE_MS_XML_TYPE,\r\n\tE_MS_DFRICTION,\r\n\tE_MS_SFRICTION,\r\n\tE_MS_RESTITUTION,\r\n\tE_MS_DFRICTIONV,\r\n\tE_MS_SFRICTIONV,\r\n\tE_MS_ANIS,\r\n\tE_MS_FCMODE,\r\n\tE_MS_RCMODE,\r\n\tE_MS_FLAGS,\r\n};\r\n\r\ntypedef enum E_RAY_CAST_STRUCT\r\n{\r\n\tE_RC_WORLD,\r\n\tE_RC_ORI,\r\n\tE_RC_ORI_REF,\r\n\tE_RC_DIR,\r\n\tE_RC_DIR_REF,\r\n\tE_RC_LENGTH,\r\n\tE_RC_GROUPS,\r\n\tE_RC_GROUPS_MASK,\r\n\tE_RC_SHAPES_TYPES\r\n};\r\n\r\ntypedef enum E_CLOTH_STRUCT\r\n{\r\n\tE_CS_THICKNESS,\r\n\tE_CS_DENSITY,\r\n\tE_CS_BENDING_STIFFNESS,\r\n\tE_CS_STRETCHING_STIFFNESS,\r\n\tE_CS_DAMPING_COEFFICIENT,\r\n\tE_CS_FRICTION,\r\n\tE_CS_PRESSURE,\r\n\tE_CS_TEAR_FACTOR,\r\n\tE_CS_COLLISIONRESPONSE_COEFFICIENT,\r\n\tE_CS_ATTACHMENTRESPONSE_COEFFICIENT,\r\n\tE_CS_ATTACHMENT_TEAR_FACTOR,\r\n\tE_CS_TO_FLUID_RESPONSE_COEFFICIENT,\r\n\tE_CS_FROM_FLUIDRESPONSE_COEFFICIENT,\r\n\tE_CS_MIN_ADHERE_VELOCITY,\r\n\tE_CS_SOLVER_ITERATIONS,\r\n\tE_CS_EXTERN_ALACCELERATION,\r\n\tE_CS_WIND_ACCELERATION,\r\n\tE_CS_WAKE_UP_COUNTER,\r\n\tE_CS_SLEEP_LINEAR_VELOCITY,\r\n\tE_CS_COLLISIONG_ROUP,\r\n\tE_CS_VALID_BOUNDS,\r\n\tE_CS_RELATIVE_GRID_SPACING,\r\n\tE_CS_FLAGS,\r\n\tE_CS_TEAR_VERTEX_COLOR,\r\n\tE_CS_WORLD_REFERENCE,\r\n\tE_CS_ATTACHMENT_FLAGS,\r\n};\r\n\r\ntypedef enum E_WCD_STRUCT\r\n{\r\n\tE_WCD_CPOINT,\r\n\tE_WCD_CNORMAL,\r\n\tE_WCD_LONG_DIR,\r\n\tE_WCD_LAT_DIR,\r\n\tE_WCD_CONTACT_FORCE,\r\n\tE_WCD_LONG_SLIP,\r\n\tE_WCD_LAT_SLIP,\r\n\tE_WCD_LONG_IMPULSE,\r\n\tE_WCD_LAT_IMPULSE,\r\n\tE_WCD_OTHER_MATERIAL_INDEX,\r\n\tE_WCD_C_POS,\r\n\tE_WCD_CONTACT_ENTITY,\r\n};\r\n\r\ntypedef enum E_VBT_STRUCT\r\n{\r\n\tE_VBT_0,\r\n\tE_VBT_1,\r\n\tE_VBT_2,\r\n\tE_VBT_3,\r\n\tE_VBT_4,\r\n\tE_VBT_5,\r\n\tE_VBT_6,\r\n\tE_VBT_7,\r\n\tE_VBT_8,\r\n\tE_VBT_9\r\n};\r\n\r\ntypedef enum WHEEL_DESCR_STRUCT\r\n{\r\n\tE_WD_XML,\r\n\tE_WD_SUSPENSION,\r\n\tE_WD_SPRING_RES,\r\n\tE_WD_DAMP,\r\n\tE_WD_SPRING_BIAS,\r\n\tE_WD_MAX_BFORCE,\r\n\tE_WD_FSIDE,\r\n\tE_WD_FFRONT,\r\n\tE_WD_INVERSE_WHEEL_MASS,\r\n\tE_WD_FLAGS,\r\n\tE_WD_SFLAGS,\r\n\tE_WD_LAT_FUNC,\r\n\tE_WD_LONG_FUNC,\r\n};\r\n\r\ntypedef enum E_CAPSULE_STRUCT\r\n{\r\n\tE_CS_LENGTH_AXIS,\r\n\tE_CS_RADIUS_AXIS,\r\n\tE_CS_LENGTH,\r\n\tE_CS_RADIUS,\r\n};\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\tNew Structs\r\n//\r\n/**\r\n\\brief\tData mask to determine which parts of a rigid bodies description have to\r\n\t\tbe evolved.\r\n*/\r\nenum pObjectDescrMask\r\n{\r\n\t/**\r\n\t\\brief Description has XML settings\r\n\t*/\r\n\tOD_XML = (1 << 0),\r\n\t/**\r\n\t\\brief Description has pivot override\r\n\t*/\r\n\tOD_Pivot = (1 << 1),\r\n\t/**\r\n\t\\brief Description has mass override\r\n\t*/\r\n\tOD_Mass= (1 << 2),\r\n\t/**\r\n\t\\brief Description has collisions settings\r\n\t*/\r\n\tOD_Collision = (1 << 3),\r\n\t/**\r\n\t\\brief Description has CCD settings\r\n\t*/\r\n\tOD_CCD = (1 << 4),\r\n\t/**\r\n\t\\brief Description has material settings\r\n\t*/\r\n\tOD_Material = (1 << 5),\r\n\t/**\r\n\t\\brief Description has optimization settings\r\n\t*/\r\n\tOD_Optimization = (1 << 6),\r\n\t/**\r\n\t\\brief Description has capsule override\r\n\t*/\r\n\tOD_Capsule = (1 << 7),\r\n\t/**\r\n\t\\brief Description has convex cylinder override\r\n\t*/\r\n\tOD_ConvexCylinder = (1 << 8),\r\n\t/**\r\n\t\\brief Description has wheel settings\r\n\t*/\r\n\tOD_Wheel = (1 << 9)\r\n};\r\n\r\nenum PB_COPY_FLAGS\r\n{\r\n\tPB_CF_PHYSICS=1,\r\n\tPB_CF_SHARE_MESHES=(1<<1),\r\n\tPB_CF_PIVOT_SETTINGS=(1<<2),\r\n\tPB_CF_MASS_SETTINGS=(1<<3),\r\n\tPB_CF_COLLISION=(1<<4),\r\n\tPB_CF_CCD=(1<<5),\r\n\tPB_CF_MATERIAL=(1<<6),\r\n\tPB_CF_OPTIMIZATION=(1<<7),\r\n\tPB_CF_CAPSULE=(1<<8),\r\n\tPB_CF_CONVEX_CYLINDER=(1<<9),\r\n\tPB_CF_FORCE=(1<<10),\r\n\tPB_CF_VELOCITIES=(1<<11),\r\n\tPB_CF_JOINTS=(1<<12),\r\n\tPB_CF_LIMIT_PLANES=(1<<13),\r\n\tPB_CF_SWAP_JOINTS_REFERENCES=(1<<14),\r\n\tPB_CF_OVRRIDE_BODY_FLAGS=(1<<15),\r\n\tPB_CF_COPY_IC=(1<<16),\r\n\tPB_CF_RESTORE_IC=(1<<17),\r\n\r\n};\r\n\r\nenum PS_B_COLLISON\r\n{\r\n\tPS_BC_GROUP,\r\n\tPS_BC_GROUPSMASK,\r\n\tPS_BC_SKINWITDH,\r\n\tPS_BC_CCD_SETUP\r\n};\r\n\r\nenum PS_B_CCD\r\n{\r\n\tPS_B_CCD_MOTION_THRESHOLD,\r\n\tPS_B_CCD_FLAGS,\r\n\tPS_B_CCD_SCALE,\r\n\tPS_B_CCD_MESH_REFERENCE,\r\n};\r\n\r\nenum PS_B_COLLISION_SETUP\r\n{\r\n\tPS_BCS_COLLISION_COMMON,\r\n\tPS_BCS_CCD,\r\n};\r\n\r\n\r\nenum PS_B_DAMPING\r\n{\r\n\tPS_BD_LINEAR,\r\n\tPS_BD_ANGULAR,\r\n};\r\n\r\n\r\nenum PS_B_SLEEPING\r\n{\r\n\tPS_BS_LINEAR_SLEEP,\r\n\tPS_BS_ANGULAR_SLEEP,\r\n\tPS_BS_THRESHOLD,\r\n};\r\n\r\nenum PS_B_OPTIMISATION\r\n{\r\n\tPS_BO_LOCKS,\r\n\tPS_BO_DAMPING,\r\n\tPS_BO_SLEEPING,\r\n\tPS_BO_SOLVER_ITERATIONS,\r\n\tPS_BO_DOMINANCE_GROUP,\r\n\tPS_BO_COMPARTMENT_ID,\r\n\r\n};\r\nenum PS_B_PIVOT\r\n{\r\n\tPS_BP_LINEAR,\r\n\tPS_BP_ANGULAR,\r\n\tPS_BP_REFERENCE,\r\n};\r\n\r\nenum PS_B_MASS\r\n{\r\n\tPS_BM_DENSITY,\r\n\tPS_BM_TOTAL_MASS,\r\n\tPS_BM_PIVOT_POS,\r\n\tPS_BM_PIVOT_ROTATION,\r\n\tPS_BM_PIVOT_REFERENCE,\r\n};\r\n\r\nenum PS_BODY_FULL\r\n{\r\n\tPS_BODY_XML,\r\n\tPS_BODY_HULL_TYPE,\r\n\tPS_BODY_FLAGS,\r\n\r\n};\r\n\r\nenum PS_BODY_XML_SETUP\r\n{\r\n\tPS_INTERN_LINK,\r\n\tPS_EXTERN_LINK,\r\n\tPS_XML_MPORT_FLAGS,\r\n};\r\n\r\nenum PS_BODY_COMMON\r\n{\r\n\tPS_BC_HULL_TYPE,\r\n\tPS_BC_DENSITY,\r\n\tPS_BC_FLAGS,\r\n/*\tPS_BC_TFLAGS,*/\r\n\tPS_BC_WORLD\r\n};\r\n\r\nenum PS_BODY_SETUP\r\n{\r\n\tPS_XML_SETUP,\r\n\tPS_COMMON_SETTINGS,\r\n\t/*PS_PIVOT,\r\n\tPS_MASS,*/\r\n\tPS_COLLISION_SETTINGS,\r\n\r\n};\r\nenum PS_AXIS_REFERENCED_LENGTH\r\n{\r\n\tPS_ARL_VALUE,\r\n\tPS_ARL_REF_OBJECT,\r\n\tPS_ARL_REF_OBJECT_AXIS,\r\n};\r\n\r\nenum PS_CAPSULE\r\n{\r\n\tPS_BCAPSULE_RADIUS_REFERENCED_VALUE,\r\n\tPS_PCAPSULE_HEIGHT_REFERENCED_VALUE,\r\n};\r\nenum PS_CUSTOM_CONVEX_CYLINDER_DESCR\r\n{\r\n\tPS_CC_APPROXIMATION,\r\n\tPS_CC_RADIUS_REFERENCED_VALUE,\r\n\tPS_CC_HEIGHT_REFERENCED_VALUE,\r\n\tPS_CC_FORWARD_AXIS,\r\n\tPS_CC_FORWARD_AXIS_REF,\r\n\tPS_CC_DOWN_AXIS,\r\n\tPS_CC_DOWN_AXIS_REF,\r\n\tPS_CC_RIGHT_AXIS,\r\n\tPS_CC_RIGHT_AXIS_REF,\r\n\tPS_CC_BUILD_LOWER_HALF_ONLY,\r\n\tPS_CC_EXTRA_SHAPE_FLAGS\r\n};\r\n\r\n\r\n\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetCameraTarget for Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetCameraTargetDecl();\r\nCKERROR CreateSetCameraTargetProto(CKBehaviorPrototype **pproto);\r\nint SetCameraTarget(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetCameraTargetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Camera Target\");\t\r\n\tod->SetDescription(\"Makes a 3D Entity be the target of a camera.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tTarget: 3D Entity to target.
\r\n\t
\r\n\tThis building block doesn't need to be looped. (ie: the camera will constantly follow the selected object)
\r\n
\r\n */\r\n\t/* warning:\r\n - if you delete the camera, the target will be deleted.
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x74123741, 0x4563ffff));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00020000);\r\n\tod->SetCreationFunction(CreateSetCameraTargetProto);\r\n\tod->SetCompatibleClassId(CKCID_TARGETCAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetCameraTargetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Camera Target\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Target\", CKPGUID_3DENTITY );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetCameraTarget);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint SetCameraTarget(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKTargetCamera *cam = (CKTargetCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0,TRUE);\r\n\t\r\n\t// Get target\r\n\tCK3dEntity *ent = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\tif( beh->GetVersion()==0x0001000 ){\r\n\t\tVxVector pos(0,0,0);\r\n\t\tent->GetPosition( &pos );\r\n\t\tCK3dEntity *target = cam->GetTarget();\r\n\t\ttarget->SetPosition( &pos );\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\tif (ent && (ent->GetClassID()==CKCID_3DENTITY)){\r\n\t\tcam->SetTarget(ent);\r\n\t} else {\r\n\t\tcam->SetTarget(NULL);\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothDetachFromShapeDecl();\r\nCKERROR CreatePClothDetachFromShapeProto(CKBehaviorPrototype **pproto);\r\nint PClothDetachFromShape(const CKBehaviorContext& behcontext);\r\nCKERROR PClothDetachFromShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_ShapeReference, \r\n\r\n};\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothDetachFromShapeDecl\r\n// FullName: FillBehaviorPClothDetachFromShapeDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothDetachFromShapeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothDetachFromShape\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Detaches the cloth from a shape it has been attached to before. \");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xf4b0609,0x75b453a3));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothDetachFromShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothDetachFromShapeProto\r\n// FullName: CreatePClothDetachFromShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothDetachFromShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothDetachFromShape\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothDetachFromShape \r\n\r\n\tPClothDetachFromShape is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tDetaches the cloth from a shape it has been attached to before
\r\n\r\n\t@see pCloth::detachFromShape()\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothDetachFromShape.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\tShape Reference: Shape to which the cloth should be attached to.\r\n\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tAttachment Flags: One or two way interaction, tearable or non-tearable\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothDetachFromShapeCB );\r\n\tproto->DeclareInParameter(\"Shape Reference\",CKPGUID_3DENTITY);\r\n\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothDetachFromShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDetachFromShape\r\n// FullName: PClothDetachFromShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothDetachFromShape(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tCK3dEntity*shapeReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_ShapeReference);\r\n\t\tif (!shapeReference)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpCloth *cloth = GetPMan()->getCloth(target->GetID());\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\t\r\n\t\tNxShape *shape = cloth->getWorld()->getShapeByEntityID(shapeReference->GetID());\r\n\t\tif(shape)\r\n\t\t{\r\n\t\t\tcloth->detachFromShape((CKBeObject*)shapeReference);\r\n\t\t}\r\n\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothDetachFromShapeCB\r\n// FullName: PClothDetachFromShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothDetachFromShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n#include \"pch.h\"\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorGoFullScreenDecl();\r\nCKERROR CreateGoFullScreenProto(CKBehaviorPrototype **pproto);\r\nint GoFullScreen(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGoFullScreenDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"GoFullScreen\");\t\r\n\t\r\n\tod->SetCategory(\"Narratives/System\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x126046,0x718a4147));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"mw\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGoFullScreenProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGoFullScreenProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"GoFullScreen\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Go\");\r\n\tproto->DeclareOutput(\"Out\");\r\n \t\r\n\tproto->DeclareInParameter(\"driver index\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"width\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"height\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"bpp\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"refreshrate\",CKPGUID_INT);\r\n\t\r\n\tproto->DeclareInParameter(\"SwitchToFS\",CKPGUID_BOOL);\r\n\t\r\n\tproto->DeclareInParameter(\"mode_index\",CKPGUID_INT);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\r\n\tproto->SetFunction(GoFullScreen);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n#include \r\n\r\n BOOL CALLBACK EnumProcessListFunc( HWND, LPARAM );\r\n BOOL CALLBACK\r\n\t EnumProcessListFunc( HWND hWnd, LPARAM lParam )\r\n {\r\n\t static DWORD dwCurrentProcessId;\r\n\t static BOOL fFirstTime = TRUE;\r\n\t static LONG MaxStrLen = 0;\r\n\t static TCHAR TextBuffer[256];\r\n\r\n\t if( fFirstTime ) {\r\n\t\t fFirstTime = FALSE;\r\n\t\t dwCurrentProcessId = GetCurrentProcessId();\r\n\t }\r\n\r\n\t if( hWnd ) {\r\n\t\t GetWindowText( hWnd, (LPTSTR) &TextBuffer, sizeof(TextBuffer)/sizeof(TCHAR) );\r\n\t\t if( *TextBuffer ) {\r\n\t\t\t DWORD dwProcessId;\r\n\r\n\t\t\t /*GetWindowThreadProcessId( hWnd, &dwProcessId );\r\n\t\t\t if( dwProcessId != dwCurrentProcessId ) {\r\n\t\t\t\t LRESULT Index;\r\n\t\t\t\t HWND hWndListBox = (HWND) lParam;\r\n\r\n\t\t\t\t //Index = ListBoxInsert( hWndListBox, &MaxStrLen, TextBuffer );\r\n\t\t\t\t SendMessage( hWndListBox, LB_SETITEMDATA, (WPARAM) Index,\r\n\t\t\t\t\t (LPARAM) dwProcessId );\r\n\t\t\t }*/\r\n\t\t }\r\n\t }\r\n\r\n\t return( TRUE );\r\n }\r\n\r\n BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)\r\n {\r\n\r\n\t if( hwnd ) \r\n\t {\r\n\t\t static TCHAR TextBuffer[256];\r\n\t\t GetWindowText( hwnd, (LPTSTR) &TextBuffer, sizeof(TextBuffer)/sizeof(TCHAR) );\r\n\t\t if( *TextBuffer ) \r\n\t\t {\r\n\t\t\t return true;\r\n\r\n\t\t }\r\n\t }else\r\n\t\t return FALSE;\r\n\r\n }\r\nint GoFullScreen(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tCKRenderManager *rm = (CKRenderManager *)ctx->GetRenderManager();\r\n\r\n\tCKRenderContext *rctx = rm->GetRenderContext(0);\r\n\tint rcount = rm->GetRenderContextCount();\r\n\r\n\tint DriverIndex=0;\r\n\tbeh->GetInputParameterValue(0, &DriverIndex);\r\n\r\n\tint width = 0;\r\n\tbeh->GetInputParameterValue(1, &width);\r\n\tint height= 0;\r\n\tbeh->GetInputParameterValue(2, &height);\r\n\tint bpp = 0;\r\n\tbeh->GetInputParameterValue(3, &bpp);\r\n\tint rr = 0;\r\n\tbeh->GetInputParameterValue(4, &rr);\r\n\tbool gOFS = false;\r\n\tbeh->GetInputParameterValue(5, &gOFS);\r\n\r\n\tint mode = 0;\r\n\tbeh->GetInputParameterValue(6, &mode);\r\n\r\n\r\n\r\n\r\n\r\n\tHWND m_hWndParent = (HWND)ctx->GetMainWindow();\r\n\t//turn off\r\n\r\n\tif(rctx->IsFullScreen() && !gOFS ){\r\n\t\tctx->Pause();\r\n\t\trctx->StopFullScreen();\r\n\t\t//ShowWindow(m_hWndParent ,SW_RESTORE);\r\n\t\t\r\n\t\tRECT m_hWndParent_rect ;\r\n\r\n\t\tGetWindowRect(m_hWndParent,&m_hWndParent_rect);\r\n\r\n\t\t/*\r\n\t\tif (m_hWndParent_rect.bottom!=0 && !rctx->IsFullScreen() ) \r\n\t\t{\r\n\t\t\t//allow the window to be resized\r\n\t\t\tLONG st = GetWindowLong(m_hWndParent,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tSetWindowLong(m_hWndParent,GWL_STYLE,st);\r\n\t\t\t\r\n\t\t\tint Xpos=(GetSystemMetrics(SM_CXSCREEN)-width)/2;\r\n\t\t\tint Ypos=(GetSystemMetrics(SM_CYSCREEN)-height)/2;\r\n\r\n\t\t\t\r\n\t\t\t//reposition the window\r\n\t\t\t::SetWindowPos(m_hWndParent,HWND_NOTOPMOST,Xpos,Ypos,m_hWndParent_rect.right - m_hWndParent_rect.left,m_hWndParent_rect.bottom - m_hWndParent_rect.top,NULL);\r\n\t\t}\r\n*/\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//restore the main window size (only in DirectX rasterizer->m_MainWindowRect.bottom not modified)\r\n\t\tif (m_hWndParent_rect.bottom!=0 && !rctx->IsFullScreen()) {\r\n\t\t\t//allow the window to be resized\r\n\t\t\tLONG st = GetWindowLong(m_hWndParent,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_hWndParent,GWL_STYLE,st);\t\t\t\r\n\t\t}\r\n\r\n\t\t//reposition the window\r\n\t\tm_hWndParent_rect.left = (GetSystemMetrics(SM_CXSCREEN)-width)/2;\r\n\t\tm_hWndParent_rect.right = width+m_hWndParent_rect.left;\r\n\t\tm_hWndParent_rect.top = (GetSystemMetrics(SM_CYSCREEN)-height)/2;\r\n\t\tm_hWndParent_rect.bottom = height+m_hWndParent_rect.top;\r\n\t\tBOOL ret = AdjustWindowRect(&m_hWndParent_rect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t::SetWindowPos(m_hWndParent,HWND_NOTOPMOST,m_hWndParent_rect.left,m_hWndParent_rect.top,m_hWndParent_rect.right - m_hWndParent_rect.left,m_hWndParent_rect.bottom - m_hWndParent_rect.top,NULL);\r\n\r\n\t\t// now we can show the main widnwos\r\n\t\tShowWindow(m_hWndParent,SW_SHOW);\r\n\t\tSetFocus(m_hWndParent);\r\n\r\n\t\trctx->Resize(0,0,width,height);\r\n\r\n\r\n\t\tHWND rWin = GetWindow(m_hWndParent,GW_CHILD);\r\n\t\tif( rWin ) \r\n\t\t{\r\n\t\t\t//static TCHAR TextBuffer[256];\r\n\t\t\t//GetWindowText( rWin, (LPTSTR) &TextBuffer, sizeof(TextBuffer)/sizeof(TCHAR) );\r\n\t\t\t::SetWindowPos(rWin,NULL,0,0,width,height,SWP_NOMOVE|SWP_NOZORDER);\r\n\t\t\t//rctx->Resize(0,0,m_WindowedWidth,m_WindowedHeight);\r\n\t\t\t//MessageBox(NULL,TextBuffer,\"\",NULL);\r\n\r\n\t\t}\r\n\t\t//EnumChildWindows(m_hWndParent, (WNDENUMPROC) EnumProcessListFunc,NULL );\r\n\t\t\r\n\t\t// and set the position of the render window in the main window\r\n\t\t//::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\r\n\t\t// and give the focus to the render window\r\n\t\tSetFocus(m_hWndParent);\r\n\r\n\t\t\r\n\t\tctx->Play();\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\t\treturn CKBR_OK;\r\n\r\n\t}\r\n\tif(!rctx->IsFullScreen() && gOFS ) {\r\n\r\n\t\tctx->Pause();\r\n\t\tint w,h,FSdriver;\t\t\r\n\t\tif (mode<0)\r\n\t\t\trctx->GoFullScreen(w=width,h=height,bpp,FSdriver=DriverIndex,rr);\r\n\t\telse {\r\n\t\t\tVxDriverDesc *MainDesc=rm->GetRenderDriverDescription(DriverIndex);\r\n\t\t\tif (MainDesc)\r\n\t\t\t\trctx->GoFullScreen(w=MainDesc->DisplayModes[mode].Width,\r\n\t\t\t\th=MainDesc->DisplayModes[mode].Height,\r\n\t\t\t\tMainDesc->DisplayModes[mode].Bpp,\r\n\t\t\t\tFSdriver=DriverIndex,rr);\r\n\t\t}\t\r\n\t\tctx->Play();\r\n\r\n\t\tVxDriverDesc* Check_API_Desc=rm->GetRenderDriverDescription(DriverIndex);\r\n\r\n\t\tif (Check_API_Desc->Caps2D.Family==CKRST_DIRECTX && rctx->IsFullScreen()) {\r\n\t\t\t//store current size\r\n\t\t\tRECT g_mainwin_rect;\r\n\r\n\t\t\tGetWindowRect(m_hWndParent,&g_mainwin_rect);\r\n\r\n\t\t\t//Resize the window\r\n\t\t\t::SetWindowPos(m_hWndParent,HWND_TOPMOST,0,0,w,h,NULL);\r\n\r\n\t\t\t//Prevent the window from beeing resized\r\n\t\t\tLONG st = GetWindowLong(m_hWndParent,GWL_STYLE);\r\n\t\t\tst&=(~WS_THICKFRAME);\r\n\t\t\tSetWindowLong(m_hWndParent,GWL_STYLE,st);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\r\n\r\n\r\n\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t//ShowWindow(m_hWndParent,SW_SHOW|SW_MAXIMIZE);\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachToShapeDecl();\r\nCKERROR CreatePClothAttachToShapeProto(CKBehaviorPrototype **pproto);\r\nint PClothAttachToShape(const CKBehaviorContext& behcontext);\r\nCKERROR PClothAttachToShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_ShapeReference, \r\n\tbbI_AttachmentFlags,\r\n\tbbI_AttachToColliding,\r\n};\r\n\r\n\r\nenum bSettings\r\n{\r\n\tbbS_USE_DEFAULT_WORLD,\r\n\tbbS_ADD_ATTRIBUTES\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothAttachToShapeDecl\r\n// FullName: FillBehaviorPClothAttachToShapeDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachToShapeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothAttachToShape\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Attaches a cloth to a shape.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2ca5453a,0x7dc1598f));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothAttachToShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothAttachToShapeProto\r\n// FullName: CreatePClothAttachToShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothAttachToShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothAttachToShape\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothAttachToShape \r\n\r\n\tPClothAttachToShape is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAttaches a cloth to a shape .
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothAttachToShape.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\tShape Reference: Shape to which the cloth should be attached to.\r\n\r\n\t@see pCloth::attachToShape()\r\n\t
\r\n\t
\r\n\r\n\tAttachment Flags: One or two way interaction, tearable or non-tearable\r\n\r\n\tDefault: PCAF_ClothAttachmentTwoway\r\n\r\n\t@see pClothAttachmentFlag\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t
\r\n\tAttach to colliding shapes: Attaches the cloth to all shapes, currently colliding. \r\n\r\n\tThis method only works with primitive and convex shapes. Since the inside of a general \r\n\ttriangle mesh is not clearly defined.\r\n\r\n\t@see pCloth::attachToCollidingShapes()\r\n\r\n\t
\r\n\t
\r\n\r\n\r\n\t\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include pCloth.cpp\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothAttachToShapeCB );\r\n\r\n\tproto->DeclareInParameter(\"Shape Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Attachment Flags\",VTE_CLOTH_ATTACH_FLAGS);\r\n\tproto->DeclareInParameter(\"Attach to colliding shapes\",CKPGUID_BOOL);\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothAttachToShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachToShape\r\n// FullName: PClothAttachToShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothAttachToShape(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tCK3dEntity*shapeReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_ShapeReference);\r\n\t\tif (!shapeReference)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpWorld *world = GetPMan()->getDefaultWorld();\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\r\n\t\tint flags = GetInputParameterValue(beh,bbI_AttachmentFlags);\r\n\t\tint attachToColliders = GetInputParameterValue(beh,bbI_AttachToColliding);\r\n\r\n\t\tNxShape *shape = world->getShapeByEntityID(shapeReference->GetID());\r\n\t\tif(shape)\r\n\t\t{\r\n\t\t\tcloth->attachToShape((CKBeObject*)shapeReference,flags);\r\n\t\t}\r\n\r\n\r\n\t\tif (attachToColliders)\r\n\t\t{\r\n\t\t\tcloth->attachToCollidingShapes(flags);\r\n\t\t}\r\n\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachToShapeCB\r\n// FullName: PClothAttachToShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothAttachToShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}#ifndef __P_SDKP_SDK_PARAMETER_H__\r\n#define __P_SDKP_SDK_PARAMETER_H__\r\n\r\n\r\n\r\n\r\n/** \\addtogroup PhysicSDK\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Parameters enums to be used as the 1st arg to setParameter or getParameter.\r\n\r\n@see PhysicManager.setParameter() PhysicManager.getParameter()\r\n*/\r\ntypedef enum pSDKParameter\r\n{\r\n\t\r\n\t/* RigidBody-related parameters */\r\n\r\n\r\n\t/**\r\n\t\\brief Default value for pShape::skinWidth.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0.025
\r\n\tUnit: distance.\r\n\r\n\t@see pShape.setSkinWidth\r\n\t*/\r\n\tpSDKP_SkinWidth = 1,\r\n\r\n\r\n\t/**\r\n\t\\brief The default linear velocity, squared, below which objects start going to sleep. \r\n\tNote: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: (0.15*0.15)\r\n\r\n\t*/\r\n\tpSDKP_DefaultSleepLinVelSquared = 2,\r\n\r\n\t/**\r\n\t\\brief The default angular velocity, squared, below which objects start going to sleep. \r\n\tNote: Only makes sense when the pSDKP_BF_ENERGY_SLEEP_TEST is not set.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: (0.14*0.14)\r\n\t\r\n\t*/\r\n\tpSDKP_DefaultSleepAngVelSquared = 3,\r\n\t/**\r\n\t\\brief A contact with a relative velocity below this will not bounce.\t\r\n\r\n\tRange: (-inf, 0]
\r\n\tDefault: -2\r\n\r\n\t@see pMaterial\r\n\t*/\r\n\tpSDKP_BounceThreshold = 4,\r\n\r\n\t/**\r\n\t\\brief This lets the user scale the magnitude of the dynamic friction applied to all objects.\t\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 1\r\n\r\n\t@see pMaterial\r\n\t*/\r\n\tpSDKP_DynFrictScaling = 5,\r\n\r\n\t/**\r\n\t\\brief This lets the user scale the magnitude of the static friction applied to all objects.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 1\r\n\t\r\n\r\n\t@see pMaterial\r\n\t*/\r\n\tpSDKP_StaFrictionScaling = 6,\r\n\r\n\t/**\r\n\t\\brief See the comment for pRigidBody::setMaxAngularVelocity() for details.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 7\r\n\r\n\t@see pRigidBody.setMaxAngularVelocity()\r\n\t*/\r\n\tpSDKP_MaxAngularVelocity = 7,\r\n\r\n\t/* Collision-related parameters: */\r\n\r\n\t/**\r\n\t\\brief Enable/disable continuous collision detection (0.0f to disable)\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0.0\r\n\r\n\t@see NxPhysicsSDK.createCCDSkeleton()\r\n\t*/\r\n\tpSDKP_ContinuousCD = 8,\r\n\r\n\t\r\n\r\n\t/* General parameters and new parameters */\r\n\r\n\t/**\r\n\t\\brief Used to enable adaptive forces to accelerate convergence of the solver.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 1.0\r\n\t*/\r\n\tpSDKP_AdaptiveForce = 68,\r\n\r\n\t/**\r\n\t\\brief Controls default filtering for jointed bodies. True means collision is disabled.\r\n\r\n\tRange: {true, false}
\r\n\tDefault: true\r\n\r\n\t@see pSDKP_JF_CollisionEnabled\r\n\t\r\n\t*/\r\n\tpSDKP_CollVetoJointed = 69,\r\n\r\n\t/**\r\n\t\\brief Controls whether two touching triggers generate a callback or not.\r\n\r\n\tRange: {true, false}
\r\n\tDefault: true\r\n\r\n\t@see NxUserTriggerReport\r\n\t*/\r\n\tpSDKP_TriggerTriggerCallback = 70,\r\n\tpSDKP_SelectHW_Algo = 71,\r\n\r\n\t/**\r\n\t\\brief Distance epsilon for the CCD algorithm. \r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0.01\r\n\r\n\t*/\r\n\tpSDKP_CCDEpsilon = 73,\r\n\r\n\t/**\r\n\t\\brief Used to accelerate solver.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0\r\n\t\r\n\t*/\r\n\tpSDKP_SolverConvergenceThreshold = 74,\r\n\r\n\t/**\r\n\t\\brief Used to accelerate HW Broad Phase.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0.001\r\n\r\n\t*/\r\n\tpSDKP_BBoxNoiseLevel = 75,\r\n\r\n\t/**\r\n\t\\brief Used to set the sweep cache size.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 5.0\r\n\r\n\t*/\r\n\tpSDKP_ImplicitSweepCacheSize = 76,\r\n\r\n\t/**\r\n\t\\brief The default sleep energy threshold. Objects with an energy below this threshold are allowed\r\n\tto go to sleep. \r\n\tNote: Only used when the pSDKP_BF_ENERGY_SLEEP_TEST flag is set.\r\n\r\n\tRange: [0, inf)
\r\n\tDefault: 0.005\r\n\r\n\t*/\r\n\tpSDKP_DefaultSleepEnergy = 77,\r\n\r\n\t/**\r\n\t\\brief Constant for the maximum number of packets per fluid. Used to compute the fluid packet buffer size in NxFluidPacketData.\r\n\r\n\tRange: [925, 925]
\r\n\tDefault: 925\r\n\r\n\t@see NxFluidPacketData\r\n\t*/\r\n\tpSDKP_ConstantFluidMaxPackets = 78,\r\n\r\n\t/**\r\n\t\\brief Constant for the maximum number of new fluid particles per frame.\r\n\tRange: [4096, 4096]
\r\n\tDefault: 4096\r\n\r\n\t*/\r\n\tpSDKP_ConstantFluidMaxParticlesPerStep = 79,\r\n\r\n\t/**\r\n\t\\brief [Experimental] Disables scene locks when creating/releasing meshes.\r\n\r\n\tPrevents the SDK from locking all scenes when creating and releasing triangle meshes, convex meshes, height field \r\n\tmeshes, softbody meshes and cloth meshes, which is the default behavior. Can be used to improve parallelism but beware\r\n\tof possible side effects.\r\n\r\n\t\\warning Experimental feature.\r\n\t*/\r\n\tpSDKP_AsynchronousMeshCreation = 96,\r\n\r\n\t/**\r\n\t\\brief Epsilon for custom force field kernels.\r\n\r\n\tThis epsilon is used in custom force field kernels (NxSwTarget). Methods like recip()\r\n\tor recipSqrt() evaluate to zero if their input is smaller than this epsilon.\r\n\r\n\t
\r\n\t*/\r\n\tpSDKP_ForceFieldCustomKernelEpsilon = 97,\r\n\r\n\t/**\r\n\t\\brief Enable/disable improved spring solver for joints and wheelshapes\r\n\r\n\tThis parameter allows to enable/disable an improved version of the spring solver for joints and wheelshapes.\r\n\r\n\t\\warning \r\n\tThe parameter is introduced for legacy purposes only and will be removed in future versions (such that\r\n\tthe improved spring solver will always be used).\r\n\r\n\t\\note \r\n\tChanging the parameter will only affect newly created scenes but not existing ones.\r\n\r\n\tRange: {0: disabled, 1: enabled}
\r\n\tDefault: 1\r\n\r\n\t*/\r\n\tpSDKP_ImprovedSpringSolver = 98,\r\n\r\n\t/**\r\n\t\\brief This is not a parameter, it just records the current number of parameters (as max(NxParameter)+1) for use in loops.\r\n\tWhen a new parameter is added this number should be assigned to it and then incremented.\r\n\t*/\r\n\tpSDKP_PARAMS_NUM_VALUES = 99,\r\n\r\n\tpSDKP_PARAMS_FORCE_DWORD = 0x7fffffff\r\n};\r\n/** @} */\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetDecl();\r\nCKERROR CreatePVSetProto(CKBehaviorPrototype **pproto);\r\nint PVSet(const CKBehaviorContext& behcontext);\r\nCKERROR PVSetCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\n\r\n\r\n\r\nenum bInputs\r\n{\r\n\tI_XML,\r\n\tI_Mass,\r\n\tI_CMass,\r\n\t\r\n\tI_MotorForce,\r\n\tI_DiffRatio,\r\n\tI_TEff,\r\n\tI_MaxVelocity,\r\n\t\r\n\tI_SteerMax,\r\n\tI_SteeringSteerPoint,\r\n\tI_SteerTurnPoint,\r\n\tI_DSDelta,\r\n\t\r\n};\r\n\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap[] = \r\n{\r\n\t\r\n\tBB_SPIN(I_XML,VTE_XML_VEHICLE_SETTINGS,\"Vehicle Settings\",\"None\"),\r\n\tBB_SPIN(I_Mass,CKPGUID_FLOAT,\"Mass\",\"1000\"),\r\n\tBB_SPIN(I_CMass,CKPGUID_VECTOR,\"Center of Mass\",\"0,0,0\"),\r\n\t\r\n\tBB_SPIN(I_MotorForce,CKPGUID_FLOAT,\"Motor Force\",\"2000.0\"),\r\n\tBB_SPIN(I_DiffRatio,CKPGUID_FLOAT,\"Differential Ratio\",\"1.0\"),\r\n\tBB_SPIN(I_TEff,CKPGUID_FLOAT,\"Transmission Efficiency\",\"0.5\"),\r\n\tBB_SPIN(I_MaxVelocity,CKPGUID_FLOAT,\"Max Velocity\",\"1000\"),\r\n\t\r\n\tBB_SPIN(I_SteerMax,CKPGUID_ANGLE,\"Maximum Steer\",\"15\"),\r\n\tBB_SPIN(I_CMass,CKPGUID_VECTOR,\"Steering Steer Point\",\"0,0,0\"),\r\n\tBB_SPIN(I_CMass,CKPGUID_VECTOR,\"Steering Turn Point\",\"0,0,0\"),\r\n\tBB_SPIN(I_DSDelta,CKPGUID_FLOAT,\"Digital Steering Delta\",\"0.5\"),\r\n\t\r\n\t\r\n\r\n};\r\n\r\n#define gVSMap pInMap\r\n//#define BB_LOAD_PIMAP(SOURCE_MAP,SETTING_START_INDEX)\tBBHelper::loadPIMap(beh,pIMap,SOURCE_MAP,BB_PMAP_SIZE(SOURCE_MAP),SETTING_START_INDEX)\r\n\r\n\r\nCKERROR PVSetCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\t\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gVSMap,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPVSetDecl\r\n// FullName: FillBehaviorPVSetDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPVSetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVSet\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Modifies vehicle parameter.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xb7e2395,0x7cfe4597));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVSetProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVSetProto\r\n// FullName: CreatePVSetProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVSetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVSet\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! PVSet \r\n\r\n\tPVSet is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVSet.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::setCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::setKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::enableGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::enableCollision(). \r\n\t
\r\n\tMass Offset: The new mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: The initial shape position in the bodies local space.\r\n\t
\r\n\tNotify Collision: Enables collision notification.This is necessary to use collisions related building blocks. \r\n\t
\r\n\tTransformation Locks: Specifies in which dimension a a transformation lock should occour.\r\n\t
\r\n\tLinear Damping: The new linear damping scale.\r\n\t
\r\n\tAngular Damping: The new linear damping scale.\r\n\t
\r\n\r\n\tFilter Groups: Sets the filter mask of the initial or sub shape.\r\n\t
\r\n\r\n\r\n\tCollisions Group: Enables input for collisions group.\r\n\t
\r\n\tKinematic Object: Enables input for kinematic object.\r\n\t
\r\n\tGravity: Enables input for gravity.\r\n\t
\r\n\tCollision: Enables input for collision. \r\n\t
\r\n\tMas Offset: Enables input for mass offset. \r\n\t
\r\n\tPivot Offset: Enables input for pivot offset.\r\n\t
\r\n\tNotify Collision: Enables input for collision. \r\n\t
\r\n\tLinear Damping: Enables input for linear damping.\r\n\t
\r\n\tAngular Damping: Enables input for angular damping.\r\n\t
\r\n\tFilter Groups: Enables input for filter groups.\r\n\t
\r\n\t\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\t*/\r\n\r\n\t//proto->DeclareSetting(\"Collisions Group\",CKPGUID_BOOL,\"FALSE\");\r\n\t/*proto->DeclareSetting(\"Kinematic\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Mass Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Pivot Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Notify Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Transformation Locks\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Linear Damping\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Angular Damping\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Filter Groups\",CKPGUID_BOOL,\"FALSE\");\r\n*/\r\n\tproto->SetBehaviorCallbackFct( PVSetCB );\r\n\r\n\t\r\n\tBB_EVALUATE_SETTINGS(pInMap);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// We just want create the building block pictures\r\n\t//\r\n\t#ifdef _DOC_ONLY_\r\n\t\tBB_EVALUATE_INPUTS(pInMap);\r\n\t#endif // _DOC_ONLY_\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVSet);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PVSet\r\n// FullName: PVSet\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n#define BBSParameter(A) DWORD s##A;\\\r\n\tbeh->GetLocalParameterValue(A,&s##A)\r\n\r\nint PVSet(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) bbSErrorME(E_PE_REF);\r\n\r\n\t\t\r\n\t\tpRigidBody *body = NULL;\r\n\t\t\r\n\t\t\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\r\n\t\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\r\n\t\tint xmlValue = GetInputParameterValue(beh,BB_IP_INDEX(I_XML));\r\n\t\tfloat mass = GetInputParameterValue(beh,BB_IP_INDEX(I_Mass));\r\n\t\tfloat mForce = GetInputParameterValue(beh,BB_IP_INDEX(I_MotorForce));\r\n\t\tfloat dRatio = GetInputParameterValue(beh,BB_IP_INDEX(I_DiffRatio));\r\n\t\tfloat steerMax = GetInputParameterValue(beh,BB_IP_INDEX(I_SteerMax));\r\n\t\tfloat dsDelta = GetInputParameterValue(beh,BB_IP_INDEX(I_DSDelta));\r\n\t\tfloat tEff = GetInputParameterValue(beh,BB_IP_INDEX(I_TEff));\r\n\t\tfloat maxVel = GetInputParameterValue(beh,BB_IP_INDEX(I_MaxVelocity));\r\n\t\tVxVector cMass = GetInputParameterValue(beh,BB_IP_INDEX(I_CMass));\r\n\r\n\t\tVxVector steeringSteerPoint = GetInputParameterValue(beh,BB_IP_INDEX(I_SteeringSteerPoint));\r\n\t\tVxVector steeringTurnPoint = GetInputParameterValue(beh,BB_IP_INDEX(I_SteerTurnPoint));\r\n\r\n\r\n\t\tBBSParameter(I_XML);\r\n\t\tBBSParameter(I_Mass);\r\n\t\tBBSParameter(I_MotorForce);\r\n\t\tBBSParameter(I_DiffRatio);\r\n\t\tBBSParameter(I_SteerMax);\r\n\t\tBBSParameter(I_DSDelta);\r\n\t\tBBSParameter(I_MaxVelocity);\r\n\t\tBBSParameter(I_CMass);\r\n\t\tBBSParameter(I_TEff);\r\n\t\t\r\n\t\tBBSParameter(I_SteeringSteerPoint);\r\n\t\tBBSParameter(I_SteerTurnPoint);\r\n\r\n\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\r\n\t\t{\r\n\t\t\tpVehicleDesc vdesc;\r\n\t\t\tvdesc.setToDefault();\r\n\r\n\t\t\t//pVehicleGearDesc *gearDesc = vdesc.getGearDescription();\r\n\t\t\t//gearDesc->setToCorvette();\r\n\r\n\t\t\t//pVehicleMotorDesc *motorDesc = vdesc.getMotorDescr();\r\n\t\t\t//motorDesc->setToCorvette();\r\n\t\t\tv = pFactory::Instance()->createVehicle(target,vdesc);\r\n\r\n\t\t}\r\n\r\n\t\tif (!v)\r\n\t\t\tbbErrorME(\"Couldn't create vehicle\");\r\n\r\n\t\tif (sI_Mass) v->setMass(mass);\r\n\t\tif (sI_MotorForce)\tv->setMotorForce(mForce);\r\n\t\tif (sI_DiffRatio)v->setDifferentialRatio(dRatio);\r\n\t\tif (sI_SteerMax)v->setMaxSteering(steerMax) ;\r\n\t\tif (sI_DSDelta)v->setDigitalSteeringDelta(dsDelta);\r\n\t\tif (sI_MaxVelocity)v->setMaxVelocity(maxVel);\r\n\t\tif (sI_CMass)v->setCenterOfMass(cMass);\r\n\t\tif (sI_TEff)v->setTransmissionEfficiency(tEff);\r\n\t\tif(sI_SteeringSteerPoint)v->setSteeringSteerPoint(steeringSteerPoint);\r\n\t\tif(sI_SteerTurnPoint)v->setSteeringTurnPoint(steeringTurnPoint );\r\n\r\n\t\t\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVSetCB\r\n// FullName: PVSetCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n/*\r\n\r\ndx\t-0.99999821\tfloat\r\nangle\t-0.21089047\tfloat\r\nzPos\t0.99999857\tfloat\r\ndz\t4.6712832\tfloat\r\nxPos\t-0.99999821\tfloat\r\natan3\t-0.21089047\tfloat\r\n\r\n\r\ndx\t1.0000019\tfloat\r\nangle\t0.21089132\tfloat\r\nzPos\t1.0000004\tfloat\r\ndz\t4.6712813\tfloat\r\nxPos\t1.0000019\tfloat\r\natan3\t0.21089132\tfloat\r\n\r\n\r\n\r\n\r\n*/\r\n\r\n/*\r\n//\t\t\t\tint indexA = BBHelper::getIndex(beh,pMap,bbI_AxleSpeed);\r\n//\t\t\t\tint indexB = BBHelper::getIndex(beh,pMap,bbI_Steer);\r\n\r\n/*\r\nEnablePInputBySettings(beh,bbI_AxleSpeed);\r\nEnablePInputBySettings(beh,bbI_Steer);\r\nEnablePInputBySettings(beh,bbI_MotorTorque);\r\nEnablePInputBySettings(beh,bbI_BrakeTorque);\r\nEnablePInputBySettings(beh,bbI_SuspensionSpring);\r\nEnablePInputBySettings(beh,bbI_SuspensionTravel);\r\nEnablePInputBySettings(beh,bbI_Radius);\r\n*/\r\n\r\n\r\n\r\n\r\n/*\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\r\n\t\t\t\t/*\t\t\t\tBB_DECLARE_PIMAP;\r\n\t\t\t\twhile (\tpIMap->getArray().size() )\r\n\t\t\t\t{\r\n\r\n\t\t\t\tBBParameter *p=pIMap->getArray().at(0);\r\n\t\t\t\tpIMap->getArray().erase(pIMap->getArray().begin());\r\n\t\t\t\tdelete p;\r\n\t\t\t\tp = NULL;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t\t*/\r\n\t\t\t//\t\t\t\tBB_DECLARE_PIMAP;\r\n\t\t\t//\t\t\t\tBBHelper::destroyPIMap(beh,pIMap,BB_PMAP_SIZE);\r\n\r\n\r\n\r\n#ifndef _NVFILEDIALOG_H_\r\n#define _NVFILEDIALOG_H_\r\n\r\n#pragma warning (disable : 4786)\r\n#include \r\n#pragma warning (disable : 4786)\r\n#include \r\n#pragma warning (disable : 4786)\r\n\r\n#include \r\ntypedef std::basic_string tstring; \r\n\r\n////////////\r\n// Helper class to assist in loading files\r\n//\r\n// Usage :\r\n//\r\n// Just create a NV*FileDialog object on the stack, and call Open\r\n//\r\n// NVXFileDialog aDialog;\r\n//\r\n// std::string theFileName;\r\n// \r\n// if ( aDialog.Open( theFileName ) )\r\n// {\r\n// // open the filename and read it in\r\n// }\r\n//\r\n// // That's it !\r\n//\r\n// Use the NVTextureFileDialog for texture files,\r\n//\r\n// or use the NVFileDialog to do arbitrary filters\r\n//\r\n\r\nclass NVFileDialog\r\n{\r\n\tprivate :\r\n\r\n\t\tOPENFILENAME mOpenFileName;\r\n\r\n\t\tstd::vector< tstring > mFilterNames;\r\n\t\tstd::vector< tstring > mFilterStrings;\r\n\r\n\t\ttstring mString;\r\n\r\n\t\tvoid Init()\r\n\t\t{\r\n\t\t\tmemset( &mOpenFileName, 0x00, sizeof( mOpenFileName ) );\r\n\t\t\tmOpenFileName.lStructSize = sizeof( mOpenFileName );\r\n\r\n\t\t\tOSVERSIONINFO osinfo;\r\n\t\t\tmemset( &osinfo, 0x00, sizeof( osinfo ) );\r\n\t\t\tBOOL bSuccess = ::GetVersionEx( &osinfo );\r\n\r\n\t\t\tif ( osinfo.dwMajorVersion >= 0x0500 )\r\n\t\t\t{\r\n\t\t\t\tmOpenFileName.lStructSize += ( 3 * sizeof( DWORD ) );\r\n\t\t\t}\r\n\r\n\t\t\tmString.erase( mString.begin(), mString.end() );\r\n\r\n\t\t\tmOpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_SHAREAWARE;\r\n\r\n\t\t\tmOpenFileName.nFilterIndex = 1;\r\n\r\n\t\t\tfor (unsigned int i = 0; i < mFilterNames.size(); ++i )\r\n\t\t\t{\r\n\t\t\t\tmString += mFilterNames[ i ];\r\n\t\t\t\tmString += TCHAR(0x00);\r\n\t\t\t\tmString += mFilterStrings[ i ];\r\n\t\t\t\tmString += TCHAR(0x00);\r\n\t\t\t}\r\n\r\n\t\t\t// Last element must be double terminated\r\n\t\t\tmString += TCHAR(0x00);\r\n\r\n\t\t\tmOpenFileName.lpstrFilter = mString.c_str();\r\n\t\t}\r\n\r\n\tpublic :\r\n\r\n\t~NVFileDialog(){;}\r\n\r\n\tNVFileDialog()\r\n\t{\r\n\t\tmFilterNames.push_back(TEXT(\"*.*\"));\r\n\t\tmFilterStrings.push_back(TEXT(\"\"));\r\n\t}\r\n\r\n\tvoid SetFilters( const std::vector< tstring >& theFilterNames,\r\n\t\t\t\t\t const std::vector< tstring >& theFilterStrings )\r\n\t{\r\n\t\tassert( mFilterNames.size() == theFilterStrings.size() );\r\n\r\n\t\tmFilterNames = theFilterNames;\r\n\t\tmFilterStrings = theFilterStrings;\r\n\t}\r\n\r\n\tvoid SetFilter( const tstring& theFilterName )\r\n\t{\r\n\t\tmFilterNames.clear();\r\n\t\tmFilterStrings.clear();\r\n\r\n\t\tmFilterNames.push_back( theFilterName );\r\n\t\tmFilterStrings.push_back( theFilterName );\r\n\t}\r\n\r\n\tvirtual bool Open( tstring& theResult )\r\n\t{\r\n\t\tInit();\r\n\r\n\t\ttheResult.resize(1024);\r\n\t\ttheResult[0] = 0;\r\n\t\tmOpenFileName.lpstrFile = &theResult[ 0 ];\r\n\t\tmOpenFileName.nMaxFile = 1024;\r\n\r\n\t\tBOOL bSuccess = ::GetOpenFileName( &mOpenFileName );\r\n\r\n\t\treturn ( bSuccess == TRUE );\r\n\t}\r\n\r\n};\r\n\r\nclass NVXFileDialog : public NVFileDialog\r\n{\r\n\tpublic :\r\n\r\n\tNVXFileDialog()\r\n\t{\r\n\t\tSetFilter(TEXT(\"*.x\"));\r\n\t}\r\n\r\n};\r\n\r\n\r\nclass NVTextureFileDialog : public NVFileDialog\r\n{\r\n\tpublic :\r\n\r\n\tNVTextureFileDialog()\r\n\t{\r\n\t\tSetFilter(TEXT(\"*.bmp;*.tga;*.dds\"));\r\n\t}\r\n\r\n};\r\n\r\n#endif _NVFILEDIALOG_H_\r\n\r\n#include \"StdAfx.h\"\n\n#include \"vtPhysXAll.h\"\n\n#include \"pEngine.h\"\n#include \"pVehicleAll.h\"\n\n#include \n\n\n// Local trace?\n//#define LTRACE\n\n#define DEF_SIZE .25\n#define DEF_MAXRPM 5000\n#define DEF_MAXPOWER 100\n#define DEF_FRICTION 0\n#define DEF_MAXTORQUE 340 // ~ F1 Jos Verstappen\n\n#define DEF_TORQUE 100 // In case no curve is present\n\n//#define LTRACE\n\n// If USE_HARD_REVLIMIT is used, any rpm above the max. RPM\n// returns a 0 engine torque. Although this works, it gives quite\n// hard rev limits (esp. when in 1st gear). Better is to supply\n// a curve which moves down to 0 torque when rpm gets above maxRPM,\n// so a more natural (smooth) balance is obtained (and turn\n// this define off)\n\n\n\n//#define USE_HARD_REVLIMIT\n\npEngine::pEngine(pVehicle *_car)\n : pDriveLineComp()\n{\n SetName(\"engine\");\n ownerVehicle=_car;\n driveLine=ownerVehicle->getDriveLine();\n initData();\n}\n\npEngine::~pEngine()\n{\n}\n\n\n\nvoid pEngine::initData()\n// initData all member variables\n{\n\n flags=0;\n size=DEF_SIZE;\n \n mass=0;\n torqueReaction=0;\n maxRPM=DEF_MAXRPM;\n idleRPM=900;\n stallRPM=350;\n startRPM=900;\n autoClutchRPM=idleRPM*1.5f;\n //autoClutch=0;\n starterTorque=300;\n idleThrottle=0.1f;\n throttleRange=1000.0-idleThrottle*1000.0;\n friction=0;\n brakingCoeff=0;\n position.Set(0,0,0);\n\n maxTorque=0;\n throttle=0;\n brakes=0;\n size = 0.25f;\n\n \n //QDELETE(crvTorque);\n\n clean();\n}\n\nvoid pEngine::clean()\n// Reset engine before usage (after Shift-R for example)\n{\n torqueReaction=0;\n //torqueCurve.clear();\n pDriveLineComp::Reset();\n\n // No automatic clutch engaged\n //flags&=~AUTOCLUTCH_ACTIVE;\n //flags|=AUTOCLUTCH_ACTIVE;\n\n // Start engine (or not) and make it stable; AFTER RDLC:clean(), since that\n // sets the rotational velocity to 0.\n if(flags&START_STALLED)\n {\n // Start with the engine off\n EnableStall();\n setRPM(0);\n } else\n {\n // Pre-start engine\n DisableStall();\n setRPM(idleRPM);\n }\n}\n\n\nvoid pEngine::setRPM(float rpm)\n{\n // Convert to radians and seconds\n rotV=rpm*2*PI/60.0f;\n}\n\n/*\nfloat pEngine::GetGearRatio(int n)\n{\n\tpLinearInterpolation &ratios = ((pGearBox*)(driveLine->gearbox))->getGearRatios();\n\tif ( n >=0 && n 1)throttle=1;\n else if(throttle<0)throttle=0;\n\n//qdbg(\"pEngine:updateUserControl(); ctlT=%d, throttle=%f\\n\",ctlThrottle,throttle);\n//qdbg(\" idleThrottle=%f, idleRPM=%f\\n\",idleThrottle,idleRPM);\n//qdbg(\"pEngine:updateUserControl(ctlClutch=%d)\\n\",ctlClutch);\n//#define ND_AUTO_CLUTCH\n//#ifdef ND_AUTO_CLUTCH\n // Only update clutch value when the ownerVehicle is not auto-shifting\n\n#ifdef ND_AUTO_CLUTCH\n float ctlClutch = driveLine->GetClutchApplication();\n bool autoShiftStart =true;\n if(!autoShiftStart)\n {\n clutch=((float)ctlClutch)/1000.0f;\n if(clutch>1)clutch=1;\n else if(clutch<0)clutch=0;\n }\n//#else\n // Pass clutch on to driveline\n //driveLine->SetClutchApplication(((float)ctlClutch)/1000.0f);\n // Directly set clutch\n //clutch=((float)ctlClutch)/1000.0f;\n //if(clutch>1)clutch=1;\n //else if(clutch<0)clutch=0;\n#endif\n}\n\nfloat pEngine::GetMaxTorque(float rpm)\n// Returns the maximum torque generated at 'rpm'\n{\n\n\tif ( getVehicle()->getProcessOptions() & pVPO_Engine_UseHardRevlimit)\n\t{\n // Clip hard at max rpm (return 0 torque if rpm gets too high)\n\t if(rpm>maxRPM)\n\t\treturn 0;\n\t}\n if(!torqueCurve.getSize())\n {\n // No curve available, use a less realistic constant torque\n return DEF_TORQUE;\n } else\n {\n float t;\n // Find normalized torque in RPM-to-torque curve\n\tt=(float)torqueCurve.getValue(rpm);\n\tt = 1 / maxTorque *t;\n\t//qdbg(\"pEngine: rpm=%.2f => T=%.2f, (curve)maxTorque=%.2f\\n\",rpm,t,maxTorque);\n return maxTorque*t;\n }\n}\n// Returns the minimum torque generated at 'rpm' (engine braking).\nfloat pEngine::GetMinTorque(float rpm)\n\n{\n // If 0% throttle, this is the minimal torque which is generated\n // by the engine\n return -brakingCoeff*rpm/60.0f;\n}\n\n\nvoid pEngine::CalcForces()\n{\n float minTorque,maxTorque;\n float rpm=getRPM();\n static int starterDelay; // Temp crap to avoid multiple starter smps\n\n\n if(starterDelay>0)\n starterDelay--;\n\n // Check starter; this section assumes CalcForces() is called\n // only once per simulation step. Although this may not be\n // the case in the future, it should not harm that much.\n if(IsStalled())\n {\n // There's only some engine braking\n // Note this skips calculating min/maxTorque\n tEngine=GetMinTorque(rpm);\n\t//qdbg(\"Stalled; check starter=%d\\n\",RMGR->controls->control[RControls::T_STARTER]->value);\n bool starter = true;\n\tif(starter)\n {\n // Use the starter\n tEngine+=starterTorque;\n // Raise the starter sample volume\n if(starterDelay==0)\n {\n starterDelay=1000/ownerVehicle->_lastDT;\n }\n \n\n//#ifdef LTRACE\n//\tqdbg(\" starting; T_starter=%f, tEngine=%f\\n\",starterTorque,tEngine);\n//#endif\n\t \n\n }\n//#ifdef LTRACE\n//\tqdbg(\"Stalled engine torque: %.3f\\n\",tEngine);\n//#endif\n } else\n {\n // Engine is running\n // Calculate minimal torque (if 0% throttle)\n minTorque=GetMinTorque(rpm);\n \n // Calculate maximum torque (100% throttle situation)\n maxTorque=GetMaxTorque(rpm);\n \n // The throttle accounts for how much of the torque is actually\n // produced.\n // NOTE: The output power then is 2*PI*rps*outputTorque\n // (rps=rpm/60; rotations per second). Nothing but a statistic now.\n tEngine=(maxTorque-minTorque)*throttle+minTorque;\n#ifdef LTRACE\n\tqdbg(\"minTorque=%f, maxTorque=%.f, throttle=%f => torque=%f\\n\",minTorque,maxTorque,throttle,tEngine);\n#endif\n\t\n\n }\n}\nvoid pEngine::CalcAccelerations()\n{\n\n\n if(!driveLine->IsPrePostLocked())\n {\n // Engine moves separately from the rest of the driveLine\n rotA=(tEngine-driveLine->GetClutchTorque())/GetInertia();\n } // else rotA is calculated in the driveline (passed up\n // from the wheels on to the root - the engine)\n}\n\nvoid pEngine::Integrate()\n// Step the engine.\n// Also looks at the stall state (you can kickstart the engine when driving).\n{\n float rpm=getRPM();\n\n // This is normally done by RDriveLineComp, but avoid the function call\n float timeStep= lastStepTimeSec;\n \n rotV+=rotA*timeStep;\n // Deduce state of engine (stalling)\n /*if(IsStalled())\n {\n // Turning back on?\n if(rpm>=startRPM)\n {\n DisableStall();\n }\n } else\n {\n // Stalling?\n if(rpmgetDriveLine()->EnableAutoClutch();\n //flags|=AUTOCLUTCH_ACTIVE;\n if(autoClutch<0)autoClutch=0;\n else if(autoClutch>1)autoClutch=1;\n ownerVehicle->getDriveLine()->SetClutchApplication(autoClutch);\n } else\n {\n // Turn off auto-clutch\n ownerVehicle->getDriveLine()->DisableAutoClutch();\n }\n \n }\n \n//qdbg(\" post rotV=%.2f\\n\",rotV);\n}\n\n\nvoid pEngine::setToDefault()\n{\n\ttorqueCurve.clear();\n\t\r\n\t\r\n\ttorqueCurve.insert(500.f, 193.f);\r\n\ttorqueCurve.insert(2000.f, 134.f);\r\n\ttorqueCurve.insert(4000.f, 175.f);\r\n\ttorqueCurve.insert(5000.f, 175.f);\r\n\ttorqueCurve.insert(6000.f, 166.f);\n\ttorqueCurve.insert(7000.f, 166.f);\n\t\n\t/*\n\ttorqueCurve.insert(466.0f, 0.46f);\n\ttorqueCurve.insert(900.0f, 0.75f);\n\ttorqueCurve.insert(1466.0f, 0.89f);\n\ttorqueCurve.insert(2600.0f, 0.985f);\n\ttorqueCurve.insert(3500.0f, 1.0f);\n\ttorqueCurve.insert(4466.0f, 0.987f);\n\ttorqueCurve.insert(5133.333f,0.97f);\n\ttorqueCurve.insert(6933.0f, 0.631f);\n\ttorqueCurve.insert(7500.0f, 0.0f);\n\t*/\n\t\n\n\n\tchar buf[128],fname[128];\n\tposition.Set(0,0,0);\n\tsize = 0.0f;\n\tmaxRPM = 6200;\n\tidleRPM = 700;\n\tmass = 180.0;\n\n\ttorqueReaction=1.0f;\n\tmaxTorque=280.0f;\n\tforceFeedbackScale = 100.0f;\n\n\tSetInertia(0.3f);\n\t\n\ttimeScale = 1.0f;\n\trotationalEndFactor = 1.0f;\n\n\t\n\tfriction=0.01f;\n\tbrakingCoeff=0.1f;\n\tstarterTorque=25;\n\tstallRPM=100.0f;\n\tstartRPM=900;\n\t//autoClutchRPM=1250.0f;\n\tautoClutchRPM=1000.0f;\n\n\t\n\t//flags|=AUTOMATIC;\n\tflags|=AUTOCLUTCH_ACTIVE;\n\t//flags|=HAS_STARTER;\n\n\tpreStep();\n\t\n}\n\nvoid pEngine::setTorqueCurve(pLinearInterpolation val)\n{\n\ttorqueCurve = val;\n\tpreStep();\n}\n\n\nvoid pEngine::setBrakingCoeff(float val)\n{\n\tbrakingCoeff = val;\n\tpreStep();\n}\n\nvoid pEngine::setFriction(float val)\n{\n\tfriction = val;\n\tpreStep();\n}\nvoid pEngine::setStartRPM(float val)\n{\n\tstartRPM = val;\n\tpreStep();\n}\nvoid pEngine::setIdleRPM(float val)\n{\n\tidleRPM = val;\n\tpreStep();\n}\nvoid pEngine::setStarterTorque(float val)\n{\n\tstarterTorque = val;\n\tpreStep();\n}\n\n\nfloat pEngine::getEndTorqueForWheel(CK3dEntity *wheelReference)\n{\n\n\treturn 1;\n}\n\n/*void pEngine::SetInertia(float i)\n{\n\tinertia = i;\n\tpreStep();\n}*/\nvoid pEngine::setFlags(int val)\n{\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n/*\nbool pEngine::Load(QInfo *info,cstring path)\n// 'path' may be 0, in which case the default \"engine\" is used\n{\n\tchar buf[128],fname[128];\n\tQInfo *infoCurve;\n\n\tif(!path)path=\"engine\";\n\n\t// Location\n\tsprintf(buf,\"%s.x\",path);\n\tposition.x=info->GetFloat(buf);\n\tsprintf(buf,\"%s.y\",path);\n\tposition.y=info->GetFloat(buf);\n\tsprintf(buf,\"%s.z\",path);\n\tposition.z=info->GetFloat(buf);\n\tsprintf(buf,\"%s.size\",path);\n\tsize=info->GetFloat(buf,DEF_SIZE);\n\n\t// Physical attribs\n#ifdef OBS\n\tsprintf(buf,\"%s.rolling_friction_coeff\",path);\n\trollingFrictionCoeff=info->GetFloat(buf);\n#endif\n\tsprintf(buf,\"%s.mass\",path);\n\tmass=info->GetFloat(buf);\n\n\t// Power/torque\n\tsprintf(buf,\"%s.max_rpm\",path);\n\tmaxRPM=info->GetFloat(buf,DEF_MAXRPM);\n\tsprintf(buf,\"%s.idle_rpm\",path);\n\tidleRPM=info->GetFloat(buf,1000);\n\n\t// Torque reaction\n\tsprintf(buf,\"%s.torque_reaction\",path);\n\ttorqueReaction=info->GetFloat(buf);\n\n\t// Torque curve or constant (curve is preferred)\n\t//sprintf(buf,\"%s.constant_torque\",path);\n\tsprintf(buf,\"%s.max_torque\",path);\n\tmaxTorque=info->GetFloat(buf,DEF_MAXTORQUE);\n\tcrvTorque=new QCurve();\n\tsprintf(buf,\"%s.curve_torque\",path);\n\tinfo->GetString(buf,fname);\n\n\t//qdbg(\"fname_torque='%s', maxTorque=%.2f\\n\",fname,maxTorque);\n\tif(fname[0])\n\t{\n\t\t\n\t\tinfoCurve=new QInfo(RFindFile(fname,ownerVehicle->GetDir()));\n\t\tcrvTorque->Load(infoCurve,\"curve\");\n\t\tQDELETE(infoCurve);\n\t\t\n\n\t} else\n\t{ // No torque curve\n\t\t//QDELETE(crvTorque);\n\t}\n\n\t// Check torque curve in that it makes sense and is usable\n\tif(!crvTorque)\n\t{\n\t\t//qwarn(\"No torque curve (torque.crv?) present; you really should have one\");\n\t} else\n\t{\n\t\t// Make sure it ends at 0 (assuming no engine will rev above 100,000 rpm)\n\t\tif(fabs(crvTorque->GetValue(100000))>D3_EPSILON)\n\t\t{\n\t\t\t//qwarn(\"The torque curve needs to end at 0 torque (is now %.2f)\", crvTorque->GetValue(100000));\n\t\t}\n\t}\n\n\tsprintf(buf,\"%s.inertia.engine\",path);\n\tSetInertia(info->GetFloat(buf));\n\t//inertiaEngine=info->GetFloat(buf);\n#ifdef OBS\n\tsprintf(buf,\"%s.inertia.final_drive\",path);\n\tinertiaDriveShaft=info->GetFloat(buf);\n#endif\n\tsprintf(buf,\"%s.friction\",path);\n\tfriction=info->GetFloat(buf,DEF_FRICTION);\n\tsprintf(buf,\"%s.braking_coeff\",path);\n\tbrakingCoeff=info->GetFloat(buf);\n\n\t// Starter engine\n\tsprintf(buf,\"%s.starter\",path);\n\tif(info->GetInt(buf,1))\n\t\tflags|=HAS_STARTER;\n\tsprintf(buf,\"%s.start_stalled\",path);\n\tif(info->GetInt(buf,1))\n\t\tflags|=START_STALLED;\n\tsprintf(buf,\"%s.starter_torque\",path);\n\tstarterTorque=info->GetFloat(buf);\n\tsprintf(buf,\"%s.stall_rpm\",path);\n\tstallRPM=info->GetFloat(buf);\n\tsprintf(buf,\"%s.start_rpm\",path);\n\tstartRPM=info->GetFloat(buf);\n\tsprintf(buf,\"%s.autoclutch_rpm\",path);\n\tautoClutchRPM=info->GetFloat(buf);\n\n#ifdef OBS\n\t// Shifting\n\tsprintf(buf,\"%s.shifting.automatic\",path);\n\tif(info->GetInt(buf))\n\t\tflags|=AUTOMATIC;\n\t//qdbg(\"Autoshift: flags=%d, buf='%s'\\n\",flags,buf);\n\tsprintf(buf,\"%s.shifting.shift_up_rpm\",path);\n\tshiftUpRPM=info->GetFloat(buf,3500);\n\tsprintf(buf,\"%s.shifting.shift_down_rpm\",path);\n\tshiftDownRPM=info->GetFloat(buf,2000);\n\tsprintf(buf,\"%s.shifting.time_to_declutch\",path);\n\ttimeToDeclutch=info->GetInt(buf,500);\n\tsprintf(buf,\"%s.shifting.time_to_clutch\",path);\n\ttimeToClutch=info->GetInt(buf,500);\n\n\t// Gearbox\n\tpath=\"gearbox\"; // !\n\tsprintf(buf,\"%s.gears\",path);\n\tgears=info->GetInt(buf,4);\n\tfor(i=0;iGetFloat(buf,1.0);\n\tsprintf(buf,\"%s.gear%d.inertia\",path,i);\n\tgearInertia[i]=info->GetFloat(buf);\n\t}\n\tsprintf(buf,\"%s.end_ratio\",path);\n\tendRatio=info->GetFloat(buf,3.0);\n#endif\n\n\t// Calculate static facts\n\tpreStep();\n\n\treturn TRUE;\n}\n*/\n\n/*\nvoid pEngine::OnGfxFrame()\n{\n}\n\nvoid pEngine::DbgPrint(cstring s)\n{\nqdbg(\"pEngine state (%s):\\n\",s);\nqdbg(\" rpm=%.2f, stalled: %d, idleThrottle: %.2f, Treaction=%.2f\\n\",\ngetRPM(),IsStalled(),idleThrottle,torqueReaction);\n}\n\n\nbool pEngine::LoadState(QFile *f)\n{\nRDriveLineComp::LoadState(f);\nreturn TRUE;\n}\nbool pEngine::SaveState(QFile *f)\n{\nRDriveLineComp::LoadState(f);\nreturn TRUE;\n}\n*/\n/********************************************************************\r\n\tcreated:\t2007/11/28\r\n\tcreated:\t28:11:2007 15:43\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Misc\\CustomPlayerProfileXML.cpp\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_player\\exKamPlayer\\src\\Misc\r\n\tfile base:\tCustomPlayerProfileXML\r\n\tfile ext:\tcpp\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n\r\n#include \"CustomPlayerDefines.h\"\r\n\r\nxEApplicationMode \r\nCCustomPlayer::PGetApplicationMode()\r\n{\r\n\treturn m_AppMode;\r\n}\r\nxSApplicationWindowStyle *\r\nCCustomPlayer::GetPAppStyle()\r\n{\r\n\treturn m_AWStyle;\r\n}\r\n\r\nxSEngineWindowInfo *\r\nCCustomPlayer::GetEWindowInfo()\r\n{\r\n\treturn m_EngineWindowInfo;\r\n}\r\n\r\n/*USHORT \r\nCCustomPlayer::PLoadEnginePathProfile(const char* configFile)\r\n{\r\n return m_EPaths;\r\n}*/\r\nxSEnginePaths* \r\nCCustomPlayer::GetEPathProfile()\r\n{\r\n\treturn m_EPaths;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\r\n//\r\n//\r\n//////////////////////////////////////////////////////////////////////////\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\n\r\nUSHORT\r\nCCustomPlayer::PLoadResourcePaths(const char* configFile,const char*section,int resourceType)\r\n{\r\n\r\n\tif (!this->m_CKContext)return -1;\r\n\t\r\n\tCKPathManager *pm = (CKPathManager*)this->m_CKContext->GetPathManager();\r\n\tif (!pm)return -1;\r\n\r\n\r\n\tUSHORT error = CPE_OK;\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *tsection = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}\r\n\r\n\tif ((tsection = config.GetSubSection((char*)section, FALSE)) != NULL)\r\n\t{\r\n \r\n\t\tConstEntryIt it = tsection->BeginChildEntry();\r\n\t\tVxConfigurationEntry *sEntry = NULL;\r\n\r\n\t\r\n\t\tchar newPath[MAX_PATH];\r\n\t\twhile (sEntry=tsection->GetNextChildEntry(it))\r\n\t\t{\r\n\t\t\tif (sEntry!=NULL)\r\n\t\t\t{\r\n\t\t\t\tconst char * value = sEntry->GetValue();\r\n\t\t\t\tsprintf(newPath,\"%s%s%s\",drive,dir,value);\r\n\t\t\t\tpm->AddPath(resourceType,XString(newPath));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\r\n}\r\n\r\n//************************************\r\n// Method: PLoadAppStyleProfile\r\n// FullName: CCustomPlayerApp::PLoadAppStyleProfile\r\n// Access: protected \r\n// Returns: USHORT\r\n// Qualifier:\r\n// Parameter: const char* configFile\r\n// Parameter: vtPlayer::Structs::xEApplicationWindowStyle& result\r\n//************************************\r\n\r\nUSHORT\r\nCCustomPlayer::PLoadAppStyleProfile(const char* configFile)\r\n{\r\n\tUSHORT error = CPE_OK;\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\t\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *section = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}\r\n\r\n\tif ((section = config.GetSubSection(\"ApplicationConfiguration\", FALSE)) != NULL)\r\n\t{\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// MouseDragsWindow\r\n\t\tentry = section->GetEntry(\"MouseDragsWindow\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\r\n\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_MouseDrag = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// MouseDragsWindow\r\n\t\tentry = section->GetEntry(\"OwnerDrawed\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_OwnerDrawed = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// HasRenderWindow\r\n\t\tentry = section->GetEntry(\"Render\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\r\n\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_Render = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t\tprintf(value);\r\n\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tentry = section->GetEntry(\"AlwayOnTop\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_AOT = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// CaptionBar\r\n\t\tentry = section->GetEntry(\"Title\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tm_AWStyle->g_AppTitle = entry->GetValue();\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// Show Loading Progress : \r\n\t\tentry = section->GetEntry(\"ShowLoadingProcess\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_ShowLoadingProcess= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//splash\r\n\t\tentry = section->GetEntry(\"UseSplash\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_UseSplash = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//ShowDialog\r\n\t\tentry = section->GetEntry(\"ShowDialog\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_ShowDialog = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//ShowAboutTab\r\n\t\tentry = section->GetEntry(\"ShowAboutTab\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_ShowAboutTab = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//ShowConfigTab\r\n\t\tentry = section->GetEntry(\"ShowConfigTab\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_ShowConfigTab= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//MinDirectXVersion\r\n\t\tentry = section->GetEntry(\"MinDirectXVersion\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_MinimumDirectXVersion= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//MinRAM \r\n\t\tentry = section->GetEntry(\"MinRAM\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_AWStyle->g_MiniumumRAM= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\r\n\t}\r\n\r\n\treturn error;\r\n}\r\n\r\n//************************************\r\n// Method: PLoadEngineWindowProperties\r\n// FullName: CCustomPlayerApp::PLoadEngineWindowProperties\r\n// Access: protected \r\n// Returns: USHORT\r\n// Qualifier:\r\n// Parameter: const char *configFile\r\n// Parameter: vtPlayer::Structs::xEEngineWindowInfo& result\r\n//************************************\r\n\r\nUSHORT\r\nCCustomPlayer::PLoadEngineWindowProperties(const char *configFile)\r\n{\r\n\r\n\r\n\r\n\tUSHORT error = CPE_OK;\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *section = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}\r\n\r\n\tif ((section = config.GetSubSection(\"VideoSettings\", FALSE)) != NULL)\r\n\t{\r\n\r\n\t\t// WindowWidth (optional)\r\n\t\tentry = section->GetEntry(\"WindowWidth\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_WidthW = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t// WindowHeight (optional)\r\n\t\tentry = section->GetEntry(\"WindowHeight\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_HeightW = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t// FullscreenWidth (optional)\r\n\t\tentry = section->GetEntry(\"FullscreenWidth\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_Width = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\r\n\t\t// FullscreenHeight\r\n\t\tentry = section->GetEntry(\"FullscreenHeight\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_Height= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t// FullscreenBpp : \r\n\t\tentry = section->GetEntry(\"Bpp\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_Bpp= tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t// FullscreenDriver : \r\n\t\tentry = section->GetEntry(\"FullScreenDriver\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_FullScreenDriver = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\r\n\t\t// FullscreenDriver : \r\n\t\tentry = section->GetEntry(\"WindowedDriver\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_WindowedDriver = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t// RefreshRate : \r\n\t\tentry = section->GetEntry(\"RefreshRate\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_RefreshRate = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//ScreenMode : \r\n\t\tentry = section->GetEntry(\"Mode\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_Mode = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//AntiAlias : \r\n\t\tentry = section->GetEntry(\"AntiAlias\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->FSSA = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//Fullscreen : \r\n\t\tentry = section->GetEntry(\"FullScreen\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_GoFullScreen = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//HasResolutionMask : \r\n\t\tentry = section->GetEntry(\"HasResolutionMask\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\tint tmp = 0;\r\n\t\t\tif(sscanf(value,\"%d\",&tmp)==1) \r\n\t\t\t{\r\n\t\t\t\tm_EngineWindowInfo->g_HasResMask = tmp;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//HasResolutionMaskX : \r\n\t\tentry = section->GetEntry(\"XResolutions\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\t\t\t\r\n\t\t\tif(value) \r\n\t\t\t{\r\n\t\t\t\tXStringTokenizer\ttokizer(value, \",\");\r\n\t\t\t\tconst char*tok = NULL;\r\n\t\t\t\twhile (tokizer.NextToken(tok))\r\n\t\t\t\t{\r\n\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\tXString xtok(tok);\r\n\t\t\t\t\tm_EngineWindowInfo->g_ResMaskArrayX.PushBack(xtok.ToInt());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t\t//HasResolutionMaskY : \r\n\t\tentry = section->GetEntry(\"YResolutions\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\r\n\t\t\tif(value) \r\n\t\t\t{\r\n\t\t\t\tXStringTokenizer\ttokizer(value, \",\");\r\n\t\t\t\tconst char*tok = NULL;\r\n\t\t\t\twhile (tokizer.NextToken(tok))\r\n\t\t\t\t{\r\n\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\tXString xtok(tok);\r\n\t\t\t\t\tm_EngineWindowInfo->g_ResMaskArrayY.PushBack(xtok.ToInt());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\r\n\t\t//Allowed OpenGL versions ; \r\n\t\tentry = section->GetEntry(\"OpenGLVersions\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tconst char * value = entry->GetValue();\r\n\r\n\t\t\tif(value) \r\n\t\t\t{\r\n\t\t\t\tXStringTokenizer\ttokizer(value, \",\");\r\n\t\t\t\tconst char*tok = NULL;\r\n\t\t\t\twhile (tokizer.NextToken(tok))\r\n\t\t\t\t{\r\n\t\t\t\t\ttok = tokizer.NextToken(tok);\r\n\t\t\t\t\tXString xtok(tok);\r\n\t\t\t\t\tm_EngineWindowInfo->g_OpenGLMask.PushBack(xtok);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//todo : \r\n\tm_FullscreenBpp = GetEngineWindowInfo()->g_Bpp;\r\n\tm_FullscreenHeight= GetEngineWindowInfo()->g_Height;\r\n\tm_FullscreenWidth = GetEngineWindowInfo()->g_Width;\r\n\tm_FullscreenRefreshRate = GetEngineWindowInfo()->g_RefreshRate;\r\n\r\n\tm_WindowedWidth = GetEngineWindowInfo()->g_WidthW;\r\n\tm_WindowedHeight = GetEngineWindowInfo()->g_HeightW;\r\n\r\n\treturn error;\r\n}\r\n\r\n//************************************\r\n// Method: PLoadEnginePathProfile\r\n// FullName: vtBaseWindow::PLoadEnginePathProfile\r\n// Access: public \r\n// Returns: USHORT\r\n// Qualifier:\r\n// Parameter: const char* configFile\r\n//************************************\r\n\r\n\r\nUSHORT\r\nCCustomPlayer::PLoadEnginePathProfile(const char* configFile)\r\n{\r\n\r\n\tUSHORT error = CPE_OK;\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *section = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}\r\n\r\n\tif ((section = config.GetSubSection(\"Paths\", FALSE)) != NULL)\r\n\t{\r\n\r\n\t\t// Disable hotkeys (optional)\r\n\t\tentry = section->GetEntry(\"RenderEngines\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->RenderPath = entry->GetValue();\r\n\t\t}\r\n\r\n\t\tentry = section->GetEntry(\"ManagerPath\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->ManagerPath = entry->GetValue() ;\r\n\t\t}\r\n\r\n\t\tentry = section->GetEntry(\"BehaviorPath\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->BehaviorPath = entry->GetValue();\r\n\t\t}\r\n\r\n\t\tentry = section->GetEntry(\"PluginPath\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->PluginPath = entry->GetValue();\r\n\t\t}\r\n\r\n\t\tentry = section->GetEntry(\"LoadFile\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->CompositionFile = entry->GetValue();\r\n\t\t}\r\n\r\n\t\tentry = section->GetEntry(\"DecompressFile\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->DecompressFile = entry->GetValue();\r\n\t\t}\r\n\t\tentry = section->GetEntry(\"Installdirectory\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tGetEPathProfile()->InstallDirectory = entry->GetValue();\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tsection->Clear();\r\n\tconfig.Clear();\r\n\treturn error;\r\n}\r\n\r\nUSHORT\r\nCCustomPlayer::PSaveEngineWindowProperties(const char *configFile,const vtPlayer::Structs::xSEngineWindowInfo& input)\r\n{\r\n\r\n\tUSHORT error = CPE_OK;\r\n\r\n\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,configFile);\r\n\r\n\r\n\tint errorLine;\r\n\tXString errorText;\r\n\tVxConfiguration config;\r\n\tVxConfigurationSection *section = NULL;\r\n\tVxConfigurationEntry *entry = NULL;\r\n\r\n\tif (!config.BuildFromFile(Ini, errorLine, errorText))\r\n\t{\r\n\t\tMessageBox(NULL,\"Cannot open Configfile\",0,MB_OK|MB_ICONERROR);\r\n\t\treturn CPE_PROFILE_ERROR_FILE_INCORRECT;\r\n\t}\r\n\r\n\tif ((section = config.GetSubSection(\"VideoSettings\", FALSE)) != NULL)\r\n\t{\r\n\t\t// WindowWidth (optional)\r\n\t\tentry = section->GetEntry(\"WindowWidth\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_WidthW);\t\t\t\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\r\n\r\n\t\t// WindowHeight (optional)\r\n\t\tentry = section->GetEntry(\"WindowHeight\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_HeightW);\t\t\t\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\r\n\r\n\t\t// FullscreenHeight\r\n\t\tentry = section->GetEntry(\"FullscreenHeight\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_Height);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// FullscreenWidth\r\n\t\tentry = section->GetEntry(\"FullscreenWidth\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_Width);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// FSSA\r\n\t\tentry = section->GetEntry(\"AntiAlias\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.FSSA);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// Bpp\r\n\t\tentry = section->GetEntry(\"Bpp\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_Bpp);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// Driver\r\n\t\tentry = section->GetEntry(\"FullScreenDriver\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_FullScreenDriver);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// Driver\r\n\t\tentry = section->GetEntry(\"WindowedDriver\");\r\n\t\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_WindowedDriver);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\r\n\t\t// RefreshRate\r\n\t\tentry = section->GetEntry(\"RefreshRate\");\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_RefreshRate);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// Mode\r\n\t\tentry = section->GetEntry(\"Mode\");\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_Mode);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\r\n\t\t// FullScreen\r\n\t\tentry = section->GetEntry(\"FullScreen\");\tif (entry != NULL)\r\n\t\t{\r\n\t\t\tentry->SetValue(input.g_GoFullScreen);\r\n\t\t}else\r\n\t\t\terror = CPE_PROFILE_ERROR_ENTRY_INCORRECT;\r\n\t}\r\n\r\n\tconfig.SaveToFile(Ini);\r\n\r\n\treturn error;\r\n}/********************************************************************\r\n\tcreated:\t2009/04/13\r\n\tcreated:\t13:4:2009 21:58\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Include\\Core\\gConfig.h\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Include\\Core \r\n\tfile base:\tgConfig\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tGlobal configuration for this component\r\n*********************************************************************/\r\n#ifndef __G_CONFIG_H__\r\n#define __G_CONFIG_H__\r\n\r\n/*!\r\n\\brief\tEnables access from an external application. All related code needs to enabled \r\n\t\tby this macro\r\n*/\r\n//#define G_EXTERNAL_ACCESS\r\n\r\n\r\n#endif#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\nCKObjectDeclaration\t*FillBehaviorNGetInterfacesDecl();\r\nCKERROR CreateNGetInterfacesProto(CKBehaviorPrototype **);\r\nint NGetInterfaces(const CKBehaviorContext& behcontext);\r\nCKERROR NGetInterfacesCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNGetInterfacesDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NGetInterfaces\");\t\r\n\tod->SetDescription(\"Returns all systems network devices\");\r\n\t\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5a6a0ae6,0x11f86ec3));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNGetInterfacesProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_NEXT,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_INTERFACE,\r\n\tBB_O_ERROR,\r\n\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_INTERFACE_ADDRESS,\r\n\tBB_OP_ERROR\r\n};\r\n\r\n\r\nCKERROR CreateNGetInterfacesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NGetInterfaces\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\t\r\n\tproto->DeclareOutput(\"Exit\");\r\n\tproto->DeclareOutput(\"Interface\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\tproto->DeclareOutParameter(\"Interface\", CKPGUID_STRING, \"FALSE\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\r\n\r\n\tproto->DeclareLocalParameter(\"current result\", CKPGUID_POINTER, \"0\");\r\n\tproto->DeclareLocalParameter(\"currentArrayIndex\", CKPGUID_INT,0 );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(NGetInterfaces);\r\n\tproto->SetBehaviorCallbackFct(NGetInterfacesCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\ntypedef TNL::VectorinterfaceList;\r\n\r\nint NGetInterfaces(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\t\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tbool isTemporary = false;\r\n\t\t\r\n\r\n\t\txNetInterface *cin = GetNM()->GetServerNetInterface();\r\n\t\tif (!cin)\r\n\t\t{\r\n\t\t\tcin = GetNM()->GetClientNetInterface();\r\n\t\t}\r\n\t\t\r\n\t\tif (!cin)\r\n\t\t{\r\n\r\n\t\t\tGetNM()->CreateClient(true,0,NULL);\r\n\t\t\tcin = GetNM()->GetClientNetInterface();\r\n\t\t\tisTemporary = true;\r\n\t\t}\r\n\r\n\t\tinterfaceList *sResults = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\r\n\t\t{\r\n\t\t\tsResults = new interfaceList();\r\n\t\t}else\r\n\t\t\tsResults->clear();\r\n\r\n\r\n\t\tint currentIndex=0;\r\n\t\tbeh->SetLocalParameterValue(1,&currentIndex);\r\n\r\n\t\tif (cin)\r\n\t\t{\r\n\t\t\tTNL::Socket *socket = &cin->getSocket();\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tif (socket->isValid())\r\n\t\t\t\t{\r\n\t\t\t\t\tsocket->getInterfaceAddresses(sResults);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (isTemporary)\r\n\t\t{\r\n\t\t\tGetNM()->SetClientNetInterface(NULL);\r\n\t\t}\r\n\r\n\t\tbeh->SetLocalParameterValue(0,&sResults);\r\n\r\n\t\tif (sResults->size())\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(BB_IT_NEXT);\r\n\t\t}else\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(BB_O_OUT);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif (beh->IsInputActive(1))\r\n\t{\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\r\n\t\tint currentIndex=0;\r\n\t\tbeh->GetLocalParameterValue(1,&currentIndex);\r\n\r\n\r\n\t\tinterfaceList *sResults = NULL;\t\r\n\t\tbeh->GetLocalParameterValue(0,&sResults);\r\n\t\tif (!sResults)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\tif (currentIndex>=sResults->size())\r\n\t\t{\r\n\t\t\tsResults->clear();\r\n\t\t\tbeh->ActivateOutput(BB_O_OUT);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\r\n\t\tTNL::Vector& list = *sResults;\r\n\t\tTNL::Address *addr = &list[currentIndex];\r\n\t\tif (addr)\r\n\t\t{\r\n\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_INTERFACE_ADDRESS);\r\n\t\t\tpout->SetStringValue(const_cast(addr->toString()));\r\n\t\t}\r\n\r\n\t\tcurrentIndex++;\r\n\t\tbeh->SetLocalParameterValue(1,&currentIndex);\r\n\t\tbeh->ActivateOutput(1);\r\n\r\n\t}\r\n\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR NGetInterfacesCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"vtAttributeHelper.h\"\r\n\r\n\r\nusing namespace xUtils;\r\nusing namespace vtAgeia;\r\nusing namespace vtTools::ParameterTools;\r\nusing namespace vtTools::AttributeTools;\r\n\r\n\r\nint registerJD6(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\treturn 0;\r\n}\r\nint registerJD6Drive(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\treturn 0;\r\n}\r\nint registerJLimitPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\t\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// get and check objects\r\n\t//\r\n\tif (!target)\r\n\t\treturn -1;\r\n\r\n\tCKParameterOut *attParameter = target->GetAttributeParameter(attributeType);\r\n\tif (!attParameter)\r\n\t\treturn -1;\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\r\n\tpRigidBody *body = GetPMan()->getBody(target);\r\n\tif (!body)\r\n\t\treturn -1;\r\n\r\n\tCK_ID bodyBId = GetValueFromParameterStruct(attParameter,PS_JLP_BODY_B_REF);\r\n\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\r\n\tif (set)\r\n\t{\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// post pone i ck-start-up or loading\r\n\t\t//\r\n\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t{\r\n\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJLimitPlane,attributeType);\r\n\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tint jointType = GetValueFromParameterStruct(attParameter,PS_JLP_JOINT_TYPE);\r\n\r\n\t\t//try to get the joint \r\n\t\tpJoint *joint = GetPMan()->getJoint(target,bodyBEnt,(JType)jointType);\r\n\t\tif (!joint)\r\n\t\t\treturn -1;\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// we are on ck-play or SetAttribute-BB\t: Retrieve all parameters from the attribute : \r\n\t\t//\r\n\r\n\t\tVxVector limitPoint = GetValueFromParameterStruct(attParameter,PS_JLP_LIMIT_POINT);\r\n\r\n\t\tCK_ID limitPointRefID = GetValueFromParameterStruct(attParameter,PS_JLP_LIMIT_POINT_REF);\r\n\t\tCK3dEntity *limiPointRef = static_cast(GetPMan()->m_Context->GetObject(limitPointRefID));\r\n\t\tif (limiPointRef)\t\t\r\n\t\t\tlimiPointRef->Transform(&limitPoint,&limitPoint);\r\n\r\n\r\n\t\tint isOnBodyB = GetValueFromParameterStruct(attParameter,PS_JLP_IS_ON_BODY_B);\r\n\t\tfloat length = limitPoint.SquareMagnitude();\r\n\t\tif (XAbs(limitPoint.SquareMagnitude()) >=0.01f)\r\n\t\t\tjoint->setLimitPoint(limitPoint,isOnBodyB);\r\n\r\n\t\t\r\n\t\t//\t-\tLimit Point Normal \r\n\t\tVxVector limitPointNormal = GetValueFromParameterStruct(attParameter,PS_JLP_NORMAL);\r\n\r\n\t\tCK_ID limitPointNormalRefID = GetValueFromParameterStruct(attParameter,PS_JLP_NORMAL_REF);\r\n\t\tCK3dEntity *limitPointNormalRef = static_cast(GetPMan()->m_Context->GetObject(limitPointNormalRefID));\r\n\t\t\r\n\t\tif (limitPointNormalRef)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\tlimitPointNormalRef->GetOrientation(&dir,&up,&right);\r\n\t\t\tlimitPointNormalRef->TransformVector(&limitPointNormal,&up);\r\n\t\t}\r\n\r\n\t\t//\t-\tPoint in Plane \r\n\t\tVxVector PointInPlane = GetValueFromParameterStruct(attParameter,PS_JLP_PT_IN_PLANE);\r\n\r\n\t\tCK_ID PointInPlaneRefID = GetValueFromParameterStruct(attParameter,PS_JLP_PT_IN_PLANE_REF);\r\n\t\tCK3dEntity *PointInPlaneRef = static_cast(GetPMan()->m_Context->GetObject(PointInPlaneRefID));\r\n\t\tif (PointInPlaneRef)\t\t\r\n\t\t\tPointInPlaneRef->Transform(&PointInPlane,&PointInPlane);\r\n\r\n\t\t//\t-\tRestitution\r\n\t\tfloat res = GetValueFromParameterStruct(attParameter,PS_JLP_RESTITUTION);\r\n\r\n\t\t//\t-\tExecute \r\n\r\n\t\tint result = joint->addLimitPlane(limitPointNormal,PointInPlane,res);\r\n\t\treturn result;\r\n\t}\r\n\r\n}\r\n\r\n\r\nint registerJPointOnLine(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *pointInPlaneParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (pointInPlaneParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJPointOnLine,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_ANCHOR_REF);\r\n\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//anchor :\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\t\t\tint collision = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_COLLISION);\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//axis\r\n\t\t\tVxVector axis = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_AXIS);\r\n\t\t\tCK_ID axisRefID = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_AXIS_REF);\r\n\t\t\tCK3dEntity *axisRef = static_cast(GetPMan()->m_Context->GetObject(axisRefID));\r\n\t\t\tif (axisRef)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisRef->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisRef->TransformVector(&axis,&up);\r\n\t\t\t}\r\n\r\n\t\t\tpJointPointOnLine*joint = static_cast(pFactory::Instance()->createPointOnLineJoint(target,bodyBEnt,anchor0,axis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPOL_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_PointOnLine);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n}\r\n\r\nint registerJPointInPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *pointInPlaneParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (pointInPlaneParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJPointInPlane,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\t\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_ANCHOR_REF);\r\n\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//anchor :\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\t\t\tint collision = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_COLLISION);\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//axis\r\n\t\t\tVxVector axis = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_AXIS);\r\n\t\t\tCK_ID axisRefID = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_AXIS_REF);\r\n\t\t\tCK3dEntity *axisRef = static_cast(GetPMan()->m_Context->GetObject(axisRefID));\r\n\t\t\tif (axisRef)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisRef->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisRef->TransformVector(&axis,&up);\r\n\t\t\t}\r\n\t\t\t//pJointCylindrical*pFactory::createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n\t\t\tpJointPointInPlane*joint = static_cast(pFactory::Instance()->createPointInPlaneJoint(target,bodyBEnt,anchor0,axis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(pointInPlaneParameter,PS_JPIP_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_PointInPlane);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n}\r\n\r\n\r\nint registerJRevolute(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\t\r\n\tint s = GetPMan()->getAttributePostObjects().Size();\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJRevolute,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_ANCHOR_REF);\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//axis\r\n\t\t\tVxVector axis = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_AXIS);\r\n\t\t\tCK_ID axisRefID = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_AXIS_REF);\r\n\t\t\tCK3dEntity *axisRef = static_cast(GetPMan()->m_Context->GetObject(axisRefID));\r\n\t\t\tif (axisRef)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisRef->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisRef->TransformVector(&axis,&up);\r\n\t\t\t}\r\n\r\n\t\t\tint collision = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_COLLISION);\r\n\r\n\t\t\tint projectionMode = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_PROJ_MODE);\r\n\t\t\tfloat projectionDistance= GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_PROJ_DISTANCE);\r\n\t\t\tfloat projectionAngle = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_PROJ_ANGLE);\r\n\r\n\t\t\t\r\n\r\n\t\t\tpJointLimit limitHigh = pFactory::Instance()->createLimitFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JREVOLUTE_LIMIT_HIGH));\r\n\t\t\tpJointLimit limitLow= pFactory::Instance()->createLimitFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JREVOLUTE_LIMIT_LOW));\r\n\t\t\tpSpring spring = pFactory::Instance()->createSpringFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JREVOLUTE_SPRING));\r\n\t\t\tpMotor motor = pFactory::Instance()->createMotorFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JREVOLUTE_MOTOR));\r\n\r\n\t\t\tpJointRevolute*joint = static_cast(pFactory::Instance()->createRevoluteJoint(target,bodyBEnt,anchor0,axis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\t\t\t\tjoint->setLowLimit(limitLow);\r\n\t\t\t\tjoint->setHighLimit(limitHigh);\r\n\t\t\t\tjoint->setSpring(spring);\r\n\t\t\t\t\r\n\t\t\t\tif (projectionMode!=0)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setProjectionMode((ProjectionMode)projectionMode);\r\n\t\t\t\t\tjoint->setProjectionDistance(projectionDistance);\r\n\t\t\t\t\tjoint->setProjectionAngle(projectionAngle);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JREVOLUTE_MAX_TORQUE);\r\n\t\t\t\tif (maxTorque !=0.0f || maxForce!=0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Revolute);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n\r\n}\r\n\r\n\r\nint registerJCylindrical(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJCylindrical,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_ANCHOR_REF);\r\n\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//anchor :\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\t\t\tint collision = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_COLLISION);\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//axis\r\n\t\t\tVxVector axis = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_AXIS);\r\n\t\t\tCK_ID axisRefID = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_AXIS_REF);\r\n\t\t\tCK3dEntity *axisRef = static_cast(GetPMan()->m_Context->GetObject(axisRefID));\r\n\t\t\tif (axisRef)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisRef->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisRef->TransformVector(&axis,&up);\r\n\t\t\t}\r\n\t\t\t//pJointCylindrical*pFactory::createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n\t\t\tpJointCylindrical*joint = static_cast(pFactory::Instance()->createCylindricalJoint(target,bodyBEnt,anchor0,axis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_MAX_TORQUE);\r\n\t\t\t\t//joint->setBreakForces(maxForce,maxTorque);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Cylindrical);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n}\r\n\r\n\r\nint registerJPrismatic(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJPrismatic,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_ANCHOR_REF);\r\n\r\n\t\t\t\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//anchor :\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\t\t\tint collision = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_COLLISION);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//axis\r\n\t\t\tVxVector axis = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_AXIS);\r\n\t\t\tCK_ID axisRefID = GetValueFromParameterStruct(distanceParameter,PS_JPRISMATIC_AXIS_REF);\r\n\t\t\tCK3dEntity *axisRef = static_cast(GetPMan()->m_Context->GetObject(axisRefID));\r\n\t\t\tif (axisRef)\r\n\t\t\t{\r\n\t\t\t\tVxVector dir,up,right;\r\n\t\t\t\taxisRef->GetOrientation(&dir,&up,&right);\r\n\t\t\t\taxisRef->TransformVector(&axis,&up);\r\n\t\t\t}\r\n\t\t\t//pJointCylindrical*pFactory::createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis)\r\n\t\t\tpJointCylindrical*joint = static_cast(pFactory::Instance()->createCylindricalJoint(target,bodyBEnt,anchor0,axis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JCYLINDRICAL_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Prismatic);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint registerJBall(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JBALL_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJBall,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(distanceParameter,PS_JBALL_ANCHOR);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(distanceParameter,PS_JBALL_ANCHOR_REF);\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->Transform(&anchor0,&anchor0);\r\n\r\n\t\t\tVxVector swingAxis = GetValueFromParameterStruct(distanceParameter,PS_JBALL_LIMIT_SWING_AXIS);\r\n\r\n\t\t\tint collision = GetValueFromParameterStruct(distanceParameter,PS_JBALL_COLLISION);\r\n\t\t\t\r\n\t\t\tint projectionMode = GetValueFromParameterStruct(distanceParameter,PS_JBALL_PROJ_MODE);\r\n\t\t\tfloat minDist = GetValueFromParameterStruct(distanceParameter,PS_JBALL_PROJ_DISTANCE);\r\n\r\n\t\t\tpJointLimit swingLimit = pFactory::Instance()->createLimitFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_SWING_LIMIT));\r\n\t\t\tpJointLimit twistHighLimit = pFactory::Instance()->createLimitFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_TWIST_HIGH));\r\n\t\t\tpJointLimit twistHighLow = pFactory::Instance()->createLimitFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_TWIST_LOW));\r\n\r\n\t\t\tpSpring swingSpring = pFactory::Instance()->createSpringFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_SWING_SPRING));\r\n\t\t\tpSpring twistSpring = pFactory::Instance()->createSpringFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_TWIST_SPRING));\r\n\t\t\tpSpring jointSpring = pFactory::Instance()->createSpringFromParameter(vtTools::ParameterTools::GetParameterFromStruct(distanceParameter,PS_JBALL_JOINT_SPRING));\r\n\r\n\t\t\tpJointBall *joint = static_cast(pFactory::Instance()->createBallJoint(target,bodyBEnt,anchor0,swingAxis));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tjoint->setProjectionMode((ProjectionMode)projectionMode);\r\n\t\t\t\tjoint->setProjectionDistance(minDist);\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JBALL_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JBALL_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\r\n\r\n\r\n\t\t\t\tif (swingLimit.value !=-1.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setSwingLimit(swingLimit);\r\n\t\t\t\t\tjoint->enableFlag(NX_SJF_SWING_LIMIT_ENABLED,true);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tjoint->setSwingLimit(swingLimit);\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\tif (twistHighLimit.value != 0.0f || twistHighLow.value !=0.0f )\r\n\t\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t\tjoint->setTwistHighLimit(twistHighLimit);\r\n\t\t\t\t\tjoint->setTwistLowLimit(twistHighLow);\r\n\t\t\t\t\tjoint->enableFlag(NX_SJF_TWIST_LIMIT_ENABLED,true);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (swingSpring.spring !=0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setSwingSpring(swingSpring);\r\n\t\t\t\t\tjoint->enableFlag(NX_SJF_SWING_SPRING_ENABLED,true);\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\tif (twistSpring.spring =0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setTwistSpring(twistSpring);\r\n\t\t\t\t\tjoint->enableFlag(NX_SJF_TWIST_SPRING_ENABLED,true);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (jointSpring.spring !=0.0f)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setJointSpring(jointSpring);\r\n\t\t\t\t\tjoint->enableFlag(NX_SJF_JOINT_SPRING_ENABLED,true);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Spherical);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint registerJFixed(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JFIXED_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\tif (set)\r\n\t\t{\r\n\r\n\t\t\tif ( isPostJob && GetPMan()->GetContext()->IsPlaying() )\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJFixed,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\r\n\r\n\t\t\tpJointFixed *joint = static_cast(pFactory::Instance()->createFixedJoint(target,bodyBEnt));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JFIXED_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JFIXED_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Fixed);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n\r\n\r\n}\r\n\r\n\r\n\r\nint registerJDistance(CK3dEntity *target,int attributeType,bool set,bool isPostJob)\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\tCKStructHelper sHelper(target->GetAttributeParameter(attributeType));\r\n\tif (sHelper.GetMemberCount() ==0 )//happens when dev is being opened and loads a cmo with physic objects.\r\n\t\treturn -1;\r\n\r\n\tCKParameterOut *distanceParameter = target->GetAttributeParameter(attributeType);\r\n\tif (distanceParameter )\r\n\t{\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)return -1;\r\n\r\n\t\tCK_ID bodyBId = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_BODY_B);\r\n\t\tCK3dEntity *bodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(bodyBId));\r\n\t\tpRigidBody *bodyB = GetPMan()->getBody(bodyBEnt);\r\n\t\tif (bodyB && bodyB->getWorld() != body->getWorld() )\r\n\t\t\treturn -1;\r\n\t\t\r\n\t\tif (set)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (isPostJob && GetPMan()->GetContext()->IsPlaying())\r\n\t\t\t{\r\n\t\t\t\tpAttributePostObject postAttObject(target->GetID(),registerJDistance,attributeType);\r\n\t\t\t\tGetPMan()->getAttributePostObjects().PushBack(postAttObject);\r\n\t\t\t\t\r\n\t\t\t\tint s = GetPMan()->getAttributePostObjects().Size();\r\n\r\n\t\t\t\treturn true;\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (bodyB && body->isConnected(bodyBEnt) )\r\n\t\t\t\treturn -1;\r\n\t\t\t\r\n\t\t\tVxVector anchor0 = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_LOCAL_ANCHOR_A_POS);\r\n\t\t\tCK_ID anchor0RefID = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_LOCAL_ANCHOR_A_REF);\r\n\t\t\tCK3dEntity *a0Ref = static_cast(GetPMan()->m_Context->GetObject(anchor0RefID));\r\n\t\t\tif (a0Ref)\t\ta0Ref->TransformVector(&anchor0,&anchor0,a0Ref);\r\n\r\n\t\t\tVxVector anchor1 = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_LOCAL_ANCHOR_B_POS);\r\n\t\t\tCK_ID anchor1RefID = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_LOCAL_ANCHOR_B_REF);\r\n\t\t\tCK3dEntity *a1Ref = static_cast(GetPMan()->m_Context->GetObject(anchor1RefID));\r\n\t\t\tif (a1Ref)\t\ta1Ref->TransformVector(&anchor1,&anchor1,a1Ref);\r\n\r\n\t\t\tfloat maxDist = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_MAX_DISTANCE);\r\n\t\t\tfloat minDist = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_MIN_DISTANCE);\r\n\r\n\t\t\tpSpring spring = pFactory::Instance()->createSpringFromParameter( GetParameterFromStruct(distanceParameter,PS_JDISTANCE_SPRING) );\r\n\r\n\t\t\tint collision = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_COLL);\r\n\r\n\r\n\t\t\tpJointDistance *joint = static_cast(pFactory::Instance()->createDistanceJoint(target,bodyBEnt,anchor0,anchor1,minDist,maxDist,spring));\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tfloat maxForce = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_MAX_FORCE);\r\n\t\t\t\tfloat maxTorque = GetValueFromParameterStruct(distanceParameter,PS_JDISTANCE_MAX_TORQUE);\r\n\t\t\t\tjoint->setBreakForces(maxForce,maxTorque);\r\n\t\t\t\tjoint->enableCollision(collision);\r\n\r\n\r\n\t\t\t\t#ifdef _DEBUG \r\n\r\n\t\t\t\t\tXString _errorStr;\r\n\r\n\t\t\t\t\tXString attName = GetPMan()->GetContext()->GetAttributeManager()->GetAttributeNameByType(attributeType);\r\n\t\t\t\t\t\r\n\t\t\t\t\t_errorStr << \"Distance joint created on \" << target->GetName() << \" for attribute type : \" << attName.Str();\r\n\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_MANAGER,_errorStr.Str());\r\n\r\n\t\t\t\t#endif\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn 0;\r\n\t\t}else\r\n\t\t{\r\n\r\n\r\n\t\t\tpJoint *joint = body->isConnected(bodyBEnt);\r\n\t\t\tif ( joint)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t\tpJoint *joint2 = body->getWorld()->getJoint(target,bodyBEnt,(JType)JT_Distance);\r\n\t\t\tif (joint2)\r\n\t\t\t{\r\n\t\t\t\tbody->getWorld()->deleteJoint(joint);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n\r\n}\r\n\r\n\r\nvoid PObjectAttributeCallbackFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg)\r\n{\r\n\r\n\tCK3dEntity *ent = static_cast(obj);\r\n\tif (!ent)return;\r\n\r\n\tObjectRegisterFunction myFn = static_cast(arg);\r\n\tif (ent , myFn)\r\n\t{\r\n\t\tbool isPlaying = GetPMan()->GetContext()->IsPlaying();\r\n\t\tint success = (*myFn)(ent,AttribType,Set,true);\r\n\r\n\t\tif (!success)\r\n\t\t{\r\n\t\t\tCKAttributeManager* attman = GetPMan()->GetContext()->GetAttributeManager();\r\n\t\t\tXString error;\r\n\t\t\terror << \"Registration Function failed for attribute\" << attman->GetAttributeNameByType(AttribType) << \" for Object : \" << ent->GetName() ;\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,error.Str());\r\n\t\t}else{\r\n\r\n\t\t\tCKAttributeManager* attman = GetPMan()->GetContext()->GetAttributeManager();\r\n\t\t\tXString error;\r\n\t\t\terror << \"Registration Function succeeded for attribute\" << attman->GetAttributeNameByType(AttribType) << \" for Object : \" << ent->GetName() ;\r\n\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.Str());\r\n\t\t}\r\n\t}\r\n}\r\n#include \"precomp.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"xNetworkFactory.h\"\r\n#include \"tnlRandom.h\"\r\n#include \"tnlSymmetricCipher.h\"\r\n#include \"tnlAsymmetricKey.h\"\r\n\r\n#include \"vtTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendArrayMessageDecl();\r\nCKERROR CreateSendArrayMessageProto(CKBehaviorPrototype **);\r\nint SendArrayMessage(const CKBehaviorContext& behcontext);\r\nCKERROR SendArrayMessageCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendArrayMessageDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Network Send Array Message\");\t\r\n\tod->SetDescription(\"Sends the contents of an array as message to a Network.\");\r\n\t\r\n\tod->SetCategory(\"TNL/Message\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x63db76e8,0x7b6549d3));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSendArrayMessageProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSendArrayMessageProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Send Network Message\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Message\", CKPGUID_MESSAGE, \"OnClick\");\r\n\tproto->DeclareInParameter(\"Dest (User ID)\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->DeclareInParameter(\"Array\", CKPGUID_DATAARRAY, \"0\");\r\n\t\r\n\tproto->DeclareInParameter(\"Starting Row\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Ending Row\", CKPGUID_INT, \"-1\");\r\n\r\n\tproto->DeclareInParameter(\"Starting Column\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Ending Column\", CKPGUID_INT, \"-1\");\r\n\r\n\tproto->DeclareSetting(\"Reliable\", CKPGUID_BOOL, \"true\");\r\n\tproto->DeclareSetting(\"Single\", CKPGUID_BOOL, \"false\");\r\n\tproto->DeclareSetting(\"Exclude Master\", CKPGUID_BOOL, \"false\");\r\n\r\n\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(SendArrayMessage);\r\n\tproto->SetBehaviorCallbackFct(SendArrayMessageCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint msgCounter3 = 0;\r\n\r\nint SendArrayMessage(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\t\r\n\tint msgType = vtTools::BehaviorTools::GetInputParameterValue(beh,1);\r\n\tXString msgTypeStr(mm->GetMessageTypeName(msgType));\r\n\r\n\tint dstID = vtTools::BehaviorTools::GetInputParameterValue(beh,2);\r\n\tCKDataArray *array = static_cast(vtTools::BehaviorTools::GetInputParameterValue(beh,3));\r\n\t\r\n\tint startRow = GetInputParameterValue(beh,4);\r\n\tint endRow = GetInputParameterValue(beh,5);\r\n\r\n\tint startCol = GetInputParameterValue(beh,6);\r\n\tint endCol = GetInputParameterValue(beh,7);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//sanity checks :\r\n\tif (!array)\r\n\t{\r\n\t\tGetNM()->m_Context->OutputToConsoleEx(\"You must specify an array\");\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif (endRow ==-1)\t{\t\tendRow = array->GetRowCount();\t}\r\n\tif (endCol ==-1)\t{\t\tendCol = array->GetColumnCount();\t}\r\n\t\r\n\tif (startRow < 0)\t{\t\tstartRow = 0;\t}\r\n\t//if (startRow > endRow )\t{\t\tstartRow = 0;\t}\r\n\t\r\n\tif (startCol <0 )\t{\t\tstartCol = 0;\t}\r\n\t//if (startCol > endCol )\t{\t\tstartCol = 0;\t}\r\n\r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif(cin->GetConnection())\r\n\t{\r\n\t\tif (!cin->isValid())\r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\tTNL::Vector > dstIDs;\r\n\tdstIDs.push_back(dstID);\r\n\r\n\tCKGUID cGuid = array->GetColumnParameterGuid(0);\r\n\tCKParameterManager *pm = ctx()->GetParameterManager();\r\n\tint cType = pm->ParameterGuidToType(cGuid);\r\n\r\n\r\n\t\r\n\t\r\n\tfor (int j = startCol ; j < endCol ; j++)\r\n\t{\r\n\t\tTNL::Vector >outVec;\r\n\t\tfor (int i = startRow ; i < endRow ; i++)\r\n\t\t{\r\n\t\t\tint val = 0;\r\n\t\t\tarray->GetElementValue(i,0,&val);\r\n\t\t\toutVec.push_back(val);\r\n\t\t}\r\n\t\tcin->GetConnection()->c2sArrayMsgInt( cin->GetConnection()->GetUserID(),dstIDs,cType,startRow,endRow,startCol,endCol,msgTypeStr.CStr(),msgCounter3,j,outVec );\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t/*\r\n\r\n\t//logprintf(\"sending broadcast message :\",\"\" );\r\n\r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::Enums;\r\n\tint bcount = beh->GetInputParameterCount();\r\n\tint srcId = cin->GetConnection()->GetUserID();\r\n\r\n\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t{\r\n\r\n\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\tCKParameterType pType = ciIn->GetType();\r\n\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\r\n\t\t\r\n\r\n\t}*/\r\n\t\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR SendArrayMessageCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n\r\n#include \"pDifferential.h\"\r\n\r\n#include \"pVehicleAll.h\"\r\n\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\n\r\n#define FRICTION_COEFF 100.0f\r\n#define MASS 12\r\n#define TIRE_RATE 50000.0f\r\n#define WHEEL_PENETRATION_DEPTH -0.0258f\r\n#define WHEEL_SUSPENSION_FORCE VxVector(0,-1025.0f,0)\r\n#define RR_EPSILON_VELOCITY\t0.001\t\t// Wheel velocity\r\n#define OPT_SLIPVECTOR_USES_TANSA\r\n\r\n\r\n\r\n// Use full 3D patch for surface detection?\r\n#define USE_3D_PATCH\r\n\r\n#define ENV_INI \"env.ini\"\r\n\r\n// For method #3, slipVector (Gregor Veble), use tan(SA) or SA?\r\n#define OPT_SLIPVECTOR_USES_TANSA\r\n\r\n// Skid methods\r\n//#define SKID_METHOD_SEPARATE_LON_LAT\r\n//#define SKID_METHOD_SLIP_RA_VECTOR\r\n#define SKID_METHOD_Z_GREGOR\r\n\r\n// Point at which skidmarks appear\r\n#define SKIDMARK_SLIPRATIO 0.2\r\n\r\n// Apply damping to slipRatio/slipAngle differential eq's at low speed?\r\n//#define DO_DAMPING_LAT\r\n//#define DO_DAMPING_LONG\r\n\r\n\r\n// Apply low-speed enhancements? (obsolete since 18-5-01)\r\n#define DO_LOW_SPEED\r\n\r\n// Distance (in m) to start with wheel ray-track intersection; this is\r\n// the height at which the ray is started to avoid getting a ray\r\n// that starts BENEATH the track surface and therefore not hitting it.\r\n#define DIST_INTERSECT 1.0\r\n\r\n// Define the next symbol to check for wheel velocity reversal (vertically),\r\n// and if so, the wheel is stopped momentarily. Is used to rule out\r\n// incredibly high damper forces from pushing the wheel to full up or down.\r\n// Should perhaps not be needed anymore combined with the implicit integrator.\r\n// Note that this acts at the outermost positions of the wheel.\r\n#define DAMP_VERTICAL_VELOCITY_REVERSAL\r\n\r\n// Damp the wheel when crossing the equilibrium position?\r\n// As the wheel passes its center position, the spring force reverses. To\r\n// avoid adding energy into the system, when passing this position, damping\r\n// is used to avoid overaccelerating the tire to the other side.\r\n// Note that this acts when the wheel is near its center (rest) position,\r\n// contrast this with DAMP_VERTICAL_VELOCITY_REVERSAL.\r\n//#define DAMP_VERTICAL_EQUILIBRIUM_REVERSAL\r\n\r\n// Use implicit integration? This should be more stable with\r\n// high damper rates.\r\n#define INTEGRATE_IMPLICIT_VERTICAL\r\n\r\n// Gregor Veble combined slip algorithm? (instead of Pacejka)\r\n//#define DO_GREGOR\r\n#ifdef DO_GREGOR\r\n#undef DO_DAMPING_LAT\r\n#undef DO_DAMPING_LONG\r\n#endif\r\n\r\n// Delayed slip angle?\r\n//#define USE_SAE950311_LAT\r\n \r\n// If not using SAE950311, damp SA at low speed? (to avoid jittering)\r\n//#define USE_SA_DAMPING_AT_LOW_SPEED\r\n\r\n// Wheel locking results in force going the direction of -slipVector?\r\n//#define USE_WHEEL_LOCK_ADJUST\r\n\r\n\r\nvoid pWheel2::CalcDamping()\r\n{\r\n\r\n\t// Calculate damping of the tire at low speed, to avoid\r\n\t// oscillations.\r\n\tfloat u,v,b,B;\r\n\r\n\tif ( getVehicle()->getProcessOptions() & pVPO_Lat_Damping || getVehicle()->getProcessOptions() & pVPO_Long_Damping )\r\n\t{\r\n\t\t\r\n\r\n\t\tif(!hadContact)\r\n\t\t\treturn;\r\n\r\n\t\tu=velWheelTC.z;\r\n\t\tv=velWheelTC.x;\r\n\t\r\n\t\tif (getVehicle()->getProcessOptions() & pVPO_Lat_Damping)\r\n\t\t\tb=relaxationLengthLat;\r\n\t\t\r\n\t\t\t\t\r\n\t\tif (getVehicle()->getProcessOptions() & pVPO_Long_Damping)\r\n\t\t\tB=relaxationLengthLong;\r\n\t}\r\n\r\n\t\r\n\t\r\n\r\n\t\t\r\n\tif ( getVehicle()->getProcessOptions() & pVPO_Lat_Damping )\r\n\t{\r\n\r\n\t\r\n\t\r\n\t\t// Calculate damping force, to be added later\r\n\t\t// Assumes CalcLoad() has already been called (for 'load' to be valid)\r\n\t\t//qdbg(\"u=%f, v=%f\\n\",u,v);\r\n\t\t//if(velWheelTC.LengthSquared()0)\r\n\t\tif(fabs(v)GetBody()->GetLinVel()->Length()GetBody()->GetRotVel()->y0)\r\n\t\t\t//if(load>0)\r\n\t\t\t//if(IsLowSpeed()==TRUE&&load>0)\r\n\t\t{\r\n\r\n\t\t\tNxVec3 grav;getBody()->getActor()->getScene().getGravity(grav);\r\n\r\n\t\t\tforceDampingTC.x=2.0f*dampingCoefficientLat*v*\r\n\t\t\t\tsqrt((load*(pacejka.GetCorneringStiffness()) /-grav.y*b));\r\n\t\t\tforceDampingTC.x*=rollingCoeff;\r\n\r\n\t#ifdef OBS\r\n\t\t\tdampingFactorLat=(fabs(car->GetBody()->GetRotVel()->y))*1.0f;\r\n\t#endif\r\n\t\t\t//if(dampingFactorLat<0.1f)dampingFactorLat=0.1f;\r\n\t\t\t//(dampingSpeed-fabs(car->GetBody()->GetRotVel()->y))*1.0f;\r\n\t#ifdef OBS\r\n\t\t\t// Factor damping\r\n\t\t\tdampingCoefficient=1.0f;\r\n\t\t\tdampingFactorLat=dampingCoefficient*(dampingSpeed-fabs(v));\r\n\t\t\tif(dampingFactorLat>1)dampingFactorLat=1;\r\n\r\n\t\t\t//slipAngle*=dampingFactorLat;\r\n\t\t\tdampingFactorLat=0;\r\n\t#endif\r\n\r\n\t\t\t//dampingFactorLat=fabs(v)*3;\r\n\t\t}\r\n\r\n\t\tNxVec3 grav;getBody()->getActor()->getScene().getGravity(grav);\r\n\r\n\t\t// Natural frequency (debug)\r\n\t\tfloat natFreq;\r\n\t\tnatFreq=sqrtf(-grav.y*pacejka.GetCorneringStiffness()/load*b);\r\n\r\n//\t\t#ifdef OBS \t\tqdbg(\"W%d; natFreq=%f ~ %f Hz\\n\",wheelIndex,natFreq,natFreq/6.28f);\t\tcar->GetBody()->GetLinVel()->DbgPrint(\"body linVel\");#endif\r\n\r\n\t\tforceRoadTC.x=pacejka.GetFy();\r\n\t\t//qdbg(\"Flat=%.2f, dampFlat=%.2f, cornStiffness=%.f, load %.f, v=%f\\n\",\r\n\t\t//\tforceRoadTC.x,forceDampingTC.x,pacejka.GetCorneringStiffness(),load,v);\r\n\t}\r\n\r\n\tif (getVehicle()->getProcessOptions() & pVPO_Long_Damping)\r\n\t{\r\n\r\n\t\t// Calculate damping force, to be added later\r\n\t\t// Assumes CalcLoad() has already been called (for 'load' to be valid)\r\n\t\tif(fabs(u)LengthSquared()0)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//----------------------------------------------------------------\r\n\t\t\t//\r\n\t\t\t// get wheel load \r\n\t\t\t//\r\n\t\t\r\n\r\n\t\t\t\t\r\n\t\t\tNxVec3 grav;getBody()->getActor()->getScene().getGravity(grav);\r\n\t\t\tforceDampingTC.z=2.0f*dampingCoefficientLong*u*sqrt((load*pacejka.GetLongitudinalStiffness())/(-grav.y*B));\r\n\t\t\tforceDampingTC.z*=rollingCoeff;\r\n\t\t\t#ifdef OBS\r\n\t\t\t\tqdbg(\"Fz=%f, dampFlon=%f, longStiffness=%.f, load %.f, u=%f, v=%f,\\n\",\r\n\t\t\t\tpacejka.GetFx(),forceDampingTC.z,pacejka.GetLongitudinalStiffness(),load,u,v);\r\n\t\t\t#endif\r\n\t\t\t\r\n\t\t}\r\n\t\t\t//qdbg(\"dampFactorLong=%f\\n\",dampingFactorLong);\r\n\t}\r\n}\r\n\r\n\r\nfloat pWheel2::getMass()\r\n{\r\n\treturn mass;\r\n\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJPrismaticDecl();\r\nCKERROR CreatePJPrismaticProto(CKBehaviorPrototype **pproto);\r\nint PJPrismatic(const CKBehaviorContext& behcontext);\r\nCKERROR PJPrismaticCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Anchor,\r\n\tbI_AnchorRef,\r\n\tbI_Axis,\r\n\tbI_AxisRef,\r\n\tbI_Coll\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorPJPrismaticDecl\r\n// FullName: FillBehaviorPJPrismaticDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPJPrismaticDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJPrismatic\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets/modifies a prismatic joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2c270788,0x2d886425));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJPrismaticProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJPrismaticProto\r\n// FullName: CreatePJPrismaticProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJPrismaticProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJPrismatic\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\tproto->SetBehaviorCallbackFct( PJPrismaticCB );\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Anchor\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Anchor Reference\",CKPGUID_3DENTITY);\r\n\t\r\n\tproto->DeclareInParameter(\"Axis\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Axis Up Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL);\r\n\t/*\r\n\t\r\n\tproto->DeclareInParameter(\"Spring\",VTS_JOINT_SPRING);\r\n\r\n\tproto->DeclareInParameter(\"High Limit\",VTS_JLIMIT);\r\n\tproto->DeclareInParameter(\"Low Limit\",VTS_JLIMIT);\r\n\r\n\r\n\t\r\n\r\n\tproto->DeclareInParameter(\"Motor\",VTS_JOINT_MOTOR);\r\n*/\r\n/*\r\n\tproto->DeclareSetting(\"Spring\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Limit\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Motor\",CKPGUID_BOOL,\"FALSE\");\r\n*/\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PJPrismatic);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PJPrismatic\r\n// FullName: PJPrismatic\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJPrismatic(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\r\n\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Prismatic))\r\n\t\t{\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA && ! worldB )\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor = GetInputParameterValue(beh,bI_Anchor);\r\n\t\tVxVector anchorOut = anchor;\r\n\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);\r\n\t\tif (anchorReference)\r\n\t\t{\r\n\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\t\t//swing axis\r\n\t\tVxVector Axis = GetInputParameterValue(beh,bI_Axis);\r\n\t\tVxVector axisOut = Axis;\r\n\t\tCK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);\r\n\r\n\t\tif (axisReference)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\taxisReference->GetOrientation(&dir,&up,&right);\r\n\t\t\taxisReference->TransformVector(&axisOut,&up);\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint col = GetInputParameterValue(beh,bI_Coll);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\tpJointPrismatic *joint = static_cast(worldA->getJoint(target,targetB,JT_Prismatic));\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joint create ? \r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createPrismaticJoint(target,targetB,anchorOut,axisOut));\r\n\t\t\t}\r\n\t\t\t////////////////////////////////////////////////////////////////////////// Modification : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tjoint->setGlobalAxis(axisOut);\r\n\t\t\t\tjoint->setGlobalAnchor(anchorOut);\r\n\t\t\t\tjoint->enableCollision(col);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: PJPrismaticCB\r\n// FullName: PJPrismaticCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJPrismaticCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\r\n/*\t\t\r\n\t\t\tDWORD twistLimit;\r\n\t\t\tbeh->GetLocalParameterValue(1,&twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_HighLimit,twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_LowLimit,twistLimit);\r\n\r\n\t\t\tDWORD springSwing;\r\n\t\t\tbeh->GetLocalParameterValue(0,&springSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_Spring,springSwing);\r\n\r\n\t\t\tDWORD motor;\r\n\t\t\tbeh->GetLocalParameterValue(2,&motor);\r\n\t\t\tbeh->EnableInputParameter(bbI_Motor,motor);\r\n*/\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#ifndef SOFT_MESH_EZM_H\r\n\r\n#define SOFT_MESH_EZM_H\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nclass SoftMeshInterface;\r\n\r\nbool loadSoftMeshEZM(const char *oname,SoftMeshInterface *smi);\r\n\r\n}; // END OF SOFTBODY NAMESPACE\r\n\r\n\r\n#endif\r\n#if !defined(CUSTOMPLAYERSTATICDLLSEXTA_H)\r\n#define CUSTOMPLAYERSTATICDLLSEXTRA_H\r\n\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\r\n\r\n#ifdef WIN32\r\n#define CDECL_CALL __cdecl\r\n#else\r\n#define CDECL_CALL\r\n#endif\r\n\r\n\r\n\r\n\r\n/***************************************************/\r\n/**** BEHAVIORS ***********************************/\r\n\r\nCKPluginInfo* CDECL_CALL CKGet_TOOLS_PluginInfo(int index);\r\nvoid CDECL_CALL Register_TOOLS_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\nCKPluginInfo* CDECL_CALL CKGet_WIDGETS_PluginInfo(int index);\r\nvoid CDECL_CALL Register_WIDGETS_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\nCKPluginInfo* CDECL_CALL CKGet_VTPHYSX_PluginInfo(int index);\r\nvoid CDECL_CALL Register_VTPHYSX_BehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\n\r\n\r\n//--------------------- Implementation -------------------------------------//\r\n//---------------------\t\t of -------------------------------------//\r\n//--------------------- registration functions -----------------------------//\r\n\r\n\r\n/****************************************************************************\r\nBEHAVIORS\r\n*******************************************************************************/\r\ninline void RegisterToolsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- 3D Tranfo\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_TOOLS_PluginInfo(0),Register_TOOLS_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_TOOLS_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Tools\",2);\r\n}\r\n\r\ninline void RegisterWidgetsBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- 3D Tranfo\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_WIDGETS_PluginInfo(0),Register_WIDGETS_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_WIDGETS_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"Widgets\",1);\r\n}\r\n\r\ninline void RegisterPhysXBehaviors(CKPluginManager& iPluginManager)\r\n{\r\n\t//--- 3D Tranfo\r\n\tiPluginManager.RegisterPluginInfo(0,CKGet_VTPHYSX_PluginInfo(0),Register_VTPHYSX_BehaviorDeclarations,NULL);\r\n\tiPluginManager.RegisterPluginInfo(1,CKGet_VTPHYSX_PluginInfo(1),NULL,NULL);\r\n\tiPluginManager.RegisterNewStaticLibAsDll(\"vtPhysX\",2);\r\n}\r\ninline void CustomPlayerRegisterBehaviorsExtra(CKPluginManager& iPluginManager)\r\n{\r\n\r\n\r\n#ifdef vtToolkit\r\n\tRegisterToolsBehaviors(iPluginManager);\r\n#endif\r\n\r\n#ifdef vtWidgets\r\n\tRegisterWidgetsBehaviors(iPluginManager);\r\n#endif\r\n\r\n#ifdef vtPhysX\r\n\tRegisterPhysXBehaviors(iPluginManager);\r\n#endif\r\n\t\r\n\r\n}\r\n\r\n\r\n\r\n#endif // CUSTOM_PLAYER_STATIC\r\n\r\n\r\n#endif // CUSTOMPLAYERSTATICDLLS_H#ifndef __PBODY_TAB_CONTRL_H__\r\n#define __PBODY_TAB_CONTRL_H__\r\n\r\n#include \"VIControls.h\"\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// PBodyTabContrl window\r\n\r\nclass PBodyTabContrl : public VITabCtrl\r\n{\r\n\tDECLARE_DYNCREATE(PBodyTabContrl)\r\n\r\npublic:\r\n\tPBodyTabContrl();\r\npublic:\r\n\tenum { IDD = IDC_PBODY_TAB_PANE };\r\n\t\r\n\tPBodyTabContrl(CWnd*win);\r\n\tvirtual ~PBodyTabContrl();\r\n\tCDialog *m_tabPages[1];\r\n\tint m_tabCurrent;\r\n\tint m_nNumberOfPages;\r\n\tvoid _construct();\r\n\r\n// Attributes\r\npublic:\r\n\r\n// Operations\r\npublic:\r\n\tvoid Init();\r\n\tvoid SetRectangle();\r\n\r\nprotected:\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n\r\n//{{AFX_INSERT_LOCATION}}\r\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r\n#endif \r\n/*\n * Tcp4u v 3.31\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: port.h\n * Purpose: Portability header file. Allow an uniq code\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n\n/*\n * Fichier d'equivalence Windows/Unix\n * ----------------------------------\n *\n * Cette serie de declarations definit si necessaire\n * SOCKET -> un descripteur de socket\n * HTASK -> un descripteur de process\n * BOOL -> le type VRAI/FAUX\n * HFILE -> un descripteur de fichier\n * API4U -> le type des APIs\n * UINT -> unsigned int\n * DWORD -> entier 4 octets\n * far -> signification uniquement pour Windows 16\n * TRUE\n * FALSE\n * NULL\n * CALLBACK \n * FARPROC\n * les fonctions :\n * GetCurrentTask -> rend un identifiant de tache\n * WSAIsBlocking() -> rend VRAI si une fonction bloquante en cours\n * WSACancelBlockingCall()\n * WSAGetLastError()\n * WSACleanup()\n * WSAIsBadWritePtr()\n * IsCancelled() -> L'ordre a-t-il ete interrompu\n * CloseSocket()\n * IoctlSocket() -> operation \"de bas niveau\"\n * Write -> ecriture dans un fichier HFILE\n * Close -> close et _hclose un fichier HFILE\n * Open -> open et _hopen un fichier HFILE\n * Strlen -> fonction standard C, lstrlen en Windows\n * Strcpy -> fonction standard C, lstrcpy en Windows\n * Strcat -> fonction standard C, lstrcat en Windows\n * Strcpyn -> lstrcpyn en Windows\n * Strcmpn -> lstrcmpn en Windows\n * Sprintf -> fonction standard C, wsprintf en Windows \n * Calloc -> Allocation de N*P octets\n * Free -> liberation des octets\n * OutputDebugString -> fprintf (stderr, ...)\n * et le fichier\n * TCP4U_INCLUDE -> include tcp4ux.h / tcp4w.h\n *\n * \n * Note: Sous Windows certaines definitions sont inutiles pour tcp4w, mais ce\n * fichier est aussi utilise par d'autres projets...\n *\n */\n\n/* ****************************************************************** */\n/* Common Declarations */\n/* ****************************************************************** */\n\n\n/* ****************************************************************** */\n/* Declarations Windows */\n/* ****************************************************************** */\n\n/* #include LIBCO_VERS_H */\n#ifdef _WINDOWS\n\n#define NEED_PROTO\n\n#define WRITE_CR 0\n#define Write(fd,buf,len) _lwrite(fd,buf,len)\n#define Open(fic,mode) _lcreat(fic,mode)\n#define Close(fd) _lclose(fd)\n#define Sprintf wsprintf\n#define Strlen lstrlen\n#define Strcpy lstrcpy\n#define Strcat lstrcat\n#define Strcpy lstrcpy\n#define Strcpyn lstrcpyn\n#define IsCancelled() (WSAGetLastError()==WSAEINTR)\n#define Calloc(n,s) (void far *)GlobalAllocPtr(GMEM_SHARE | GMEM_ZEROINIT,n*s)\n#define Free(p) GlobalFreePtr (p)\n#define IoctlSocket ioctlsocket\n#define CloseSocket(s) closesocket(s)\n#define Strstr(s1,s2) strstr(s1,s2) \n#define Vsprintf wvsprintf\n\n#define SYSTEM_EOL \"\\r\\n\"\n\n/* ----------------------------------- */\n/* 16 bits declarations */\n/* ----------------------------------- */\n#ifndef _WIN32\n# define Unlink(fic) _unlink(fic)\n# define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))\n#endif /* Windows 3.1 */\n\n/* ----------------------------------- */\n/* 32 bits redeclarations */\n/* ----------------------------------- */\n#ifdef _WIN32\n# define Unlink(fic) DeleteFile(fic)\n# define _export\n# define GetCurrentTask() GetCurrentThread() \n# define WRITE OF_WRITE\n# define READ OF_READ\n# define IsTask(x) ( GetThreadPriority(x)!= THREAD_PRIORITY_ERROR_RETURN \\\n || GetLastError() != ERROR_INVALID_HANDLE)\n#endif /* Windows95 / Windows NT */\n\n\n/* ----------------------------------- */\n/* functions defined for compatibility */\n/* ----------------------------------- */\n\nHINSTANCE GetTaskInstance (HWND hParentWindow);\n#endif /* _WINDOWS */\n\n\n/* ****************************************************************** */\n/* Declarations Unix */\n/* ****************************************************************** */\n#ifdef UNIX \n\n#define GetCurrentTask() (int) getpid ()\n#define WSACleanup()\n#define WSAGetLastError() errno\n#define IsBadWritePtr(a,b) FALSE\n#define WSAIsBlocking() FALSE\n#define WSACancelBlockingCall()\n#define IsCancelled() (errno==EINTR)\n#define Write(fd,buf,len) write(fd,buf,len)\n#define Open(fic,mode) open(fic,mode,0666) /* rw-rw-rw - umask */\n#define Close(fd) close(fd)\n#define Sprintf sprintf\n#define Strlen strlen\n#define Strcpy strcpy\n#define Strcat strcat\n#define Strcpyn(a,b,n) strncpy(a,b,n-1), a[n-1]=0\n#ifdef __cplusplus \n# define Calloc(n,s) (char *) calloc(n,s)\n#else /* c++ */\n# define Calloc(n,s) calloc(n,s)\n#endif /* not c++ */\n#define Free(p) free (p)\n#define IoctlSocket ioctl\n#define CloseSocket(s) close (s)\n#define Unlink(fic) unlink(fic)\n#define Strstr(s1,s2) strstr(s1,s2) \n#define Vsprintf vsprintf\n#define OutputDebugString(x) fputs (x, stderr)\n\n#ifndef FALSE\n# define FALSE (0==1)\n#endif /* FALSE */\n#ifndef TRUE\n# define TRUE (1==1)\n#endif /* TRUE */\n#ifndef NULL\n# define NULL ((void *) 0)\n#endif\n#define CALLBACK \n#define FARPROC HTTP4U_CALLBACK\n#ifndef min\n# define min(a,b) ((a)<(b)?(a):(b))\n#endif\n#define WRITE_CR (O_WRONLY | O_CREAT | O_TRUNC)\n#define UINT unsigned int\n#define far\n\n#define SYSTEM_EOL \"\\r\\n\"\n\n#ifndef TYPE_SOCKET_DEF\n typedef unsigned int SOCKET;\n#define TYPE_SOCKET_DEF +\n#endif /* TYPE_SOCKET_DEF */\n#ifndef TYPE_HTASK_DEF\n typedef unsigned int HTASK;\n#define TYPE_HTASK_DEF +\n#endif /* TYPE_HTASK_DEF */\n#ifndef TYPE_BOOL_DEF\n typedef int BOOL;\n#define TYPE_BOOL_DEF +\n#endif /* TYPE_BOOL_DEF */\n#ifndef TYPE_HFILE_DEF\n typedef int HFILE;\n#define TYPE_HFILE_DEF +\n#endif /* TYPE_HFILE_DEF */\n\n#endif /* UNIX */\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointBall::pJointBall(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Spherical)\r\n{\r\n\r\n}\r\n\r\npJointLimit pJointBall::getSwingLimit()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pJointLimit();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pJointLimit (descr.swingLimit.hardness,descr.swingLimit.restitution,descr.swingLimit.value);\r\n}\r\n\r\npJointLimit pJointBall::getTwistHighLimit()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pJointLimit();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pJointLimit (descr.twistLimit.high.hardness,descr.twistLimit.high.restitution,descr.twistLimit.high.value);\r\n}\r\n\r\npJointLimit pJointBall::getTwistLowLimit()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pJointLimit();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pJointLimit (descr.twistLimit.low.hardness,descr.twistLimit.low.restitution,descr.twistLimit.low.value);\r\n}\r\n\r\npSpring pJointBall::getSwingSpring()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pSpring();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pSpring (descr.swingSpring.damper,descr.swingSpring.spring,descr.swingSpring.targetValue);\r\n}\r\npSpring pJointBall::getTwistSpring()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pSpring();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pSpring (descr.twistSpring.damper,descr.twistSpring.spring,descr.twistSpring.targetValue);\r\n}\r\n\r\npSpring pJointBall::getJointSpring()\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return pSpring();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pSpring (descr.jointSpring.damper,descr.jointSpring.spring,descr.jointSpring.targetValue);\r\n}\r\nvoid pJointBall::enableFlag(int flag,bool enable)\r\n{\r\n\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tif (enable)\r\n\t\tdescr.flags |=flag;\r\n\telse\r\n\t\tdescr.flags &=~flag;\r\n\r\n\tjoint->loadFromDesc(descr);\r\n\treturn ;\r\n\r\n}\r\nvoid pJointBall::setSwingLimitAxis( const VxVector& swingLimitAxis )\r\n{\r\n\tNxSphericalJointDesc descr;\t\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.swingAxis = pMath::getFrom(swingLimitAxis);\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}\r\n\r\nvoid pJointBall::enableCollision( bool collision )\r\n{\r\n\r\n\tNxSphericalJointDesc descr;\t\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointBall::setProjectionMode(ProjectionMode mode)\r\n{\r\n\tNxSphericalJointDesc descr;\t\tNxSphericalJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionMode = (NxJointProjectionMode)mode;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointBall::setProjectionDistance(float distance)\r\n{\r\n\tNxSphericalJointDesc descr;\t\tNxSphericalJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.projectionDistance= distance;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nbool pJointBall::setSwingLimit( pJointLimit limit )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tif ( limit.hardness != 0.0f || limit.restitution != 0.0f || limit.value !=0.0f )\r\n\t{\r\n\t\tenableFlag(NX_SJF_SWING_LIMIT_ENABLED,1);\r\n\t\tNxJointLimitDesc sLimit;\tsLimit.value = limit.value;sLimit.restitution = limit.restitution;sLimit.hardness = limit.hardness;\r\n\t\tif (!sLimit.isValid())return false;\r\n\t\tdescr.swingLimit= sLimit;\r\n\t\tjoint->loadFromDesc(descr);\r\n\t\treturn true;\r\n\t}else\r\n\t{\r\n\t\tenableFlag(NX_SJF_SWING_LIMIT_ENABLED,0);\r\n\t}\r\n\treturn false;\r\n}\r\nbool pJointBall::setTwistHighLimit( pJointLimit limit )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\tif ( limit.hardness != 0.0f || limit.restitution != 0.0f || limit.value !=0.0f )\r\n\t{\r\n\r\n\t\tenableFlag(NX_SJF_TWIST_LIMIT_ENABLED,1);\r\n\r\n\t\tNxJointLimitDesc sLimit;\tsLimit.value = limit.value;sLimit.restitution = limit.restitution;sLimit.hardness = limit.hardness;\r\n\t\tif (!sLimit.isValid())return false;\r\n\t\tdescr.twistLimit.high= sLimit;\r\n\t\tjoint->loadFromDesc(descr);\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tenableFlag(NX_SJF_TWIST_LIMIT_ENABLED,0);\r\n\t}\r\n\treturn 1;\r\n}\r\nbool pJointBall::setTwistLowLimit( pJointLimit limit )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tif ( limit.hardness != 0.0f || limit.restitution != 0.0f || limit.value !=0.0f )\r\n\t{\r\n\r\n\t\tenableFlag(NX_SJF_TWIST_LIMIT_ENABLED,1);\r\n\r\n\t\tNxJointLimitDesc sLimit;\tsLimit.value = limit.value;sLimit.restitution = limit.restitution;sLimit.hardness = limit.hardness;\r\n\t\tif (!sLimit.isValid())return false;\r\n\t\tdescr.twistLimit.low= sLimit;\r\n\t\tjoint->loadFromDesc(descr);\r\n\t\treturn true;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tenableFlag(NX_SJF_TWIST_LIMIT_ENABLED,0);\r\n\t}\r\n\treturn 1;\r\n}\r\nvoid pJointBall::setAnchor( const VxVector& anchor )\r\n{\r\n\tNxSphericalJointDesc descr;\t\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tjoint->setGlobalAnchor(pMath::getFrom(anchor));\r\n}\r\n\r\nbool pJointBall::setSwingSpring( pSpring spring )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.swingSpring= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\nbool pJointBall::setTwistSpring( pSpring spring )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.twistSpring= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\nbool pJointBall::setJointSpring( pSpring spring )\r\n{\r\n\tNxSphericalJointDesc descr;\t\r\n\tNxSphericalJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false ;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.jointSpring= sLimit;\r\n\tjoint->loadFromDesc(descr);\r\n\treturn 1;\r\n}\r\nDEV35DIR=\"VTDEV35DIR-NOTFOUND\"\t\r\nDEV40DIR=\"VTDEV40DIR-NOTFOUND\" \r\nDEV41DIR=\"VTDEV41DIR-NOTFOUND\"\t\r\nWEBPLAYERDIR=\"J:/Programme/Virtools/3D Life Player\"\t\r\n#pragma once\r\n\r\n\r\n\r\n// PBRootForm form view\r\n\r\nclass PBRootForm : public CFormView\r\n{\r\n\tDECLARE_DYNCREATE(PBRootForm)\r\n\r\nprotected:\r\n\tPBRootForm(); // protected constructor used by dynamic creation\r\n\tvirtual ~PBRootForm();\r\n\r\npublic:\r\n\tenum { IDD = PBRootMDI };\r\n#ifdef _DEBUG\r\n\tvirtual void AssertValid() const;\r\n#ifndef _WIN32_WCE\r\n\tvirtual void Dump(CDumpContext& dc) const;\r\n#endif\r\n#endif\r\n\r\nprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n\r\n/*\n * Tcp4u v 3.31 Last Revision 08/12/1997 3.31-01\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: tcp4_log.c\n * Purpose: Some logging / debugging\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n\n#include \"build.h\"\n#include \n\n\n/* using a static integer is a bad choice for a DLL, since each app */\n/* shares the same variable. However is will be boring to keep a */\n/* context for each app. */\n\nstatic unsigned uMaskTrace = 0;\n\n\n/* ------------------------------------------------------------------ */\n/* fonctions de log */\n/* ------------------------------------------------------------------ */\n\nvoid API4U Tcp4uEnableLog (unsigned uMask)\n{\n uMaskTrace = uMask;\n} /* Tcp4uEnableLog */\n\n\nvoid Tcp4uLog (unsigned uLevel, LPCSTR fmt, ...)\n{\nva_list marker;\nchar szBuf[512];\n\n if ( (uMaskTrace & uLevel) == 0) return;\n\n\tSprintf (szBuf, \"Proc %d\\t\", GetCurrentTask ());\n switch (uLevel)\n {\n case LOG4U_ERROR :\n \t Sprintf (szBuf + Strlen (szBuf), \"Error %d during \", \n WSAGetLastError());\n break;\n case LOG4U_HIPROC : \n case LOG4U_PROC : \n Sprintf (szBuf + Strlen (szBuf), \"entering \");\n break;\n case LOG4U_DBCALL : \n case LOG4U_CALL : \n Sprintf (szBuf + Strlen (szBuf), \"calling \");\n break;\n case LOG4U_INTERN :\n Sprintf (szBuf + Strlen (szBuf), \"internal \");\n break;\n case LOG4U_HIEXIT : \n case LOG4U_EXIT : \n Sprintf (szBuf + Strlen (szBuf), \"exiting \");\n break;\n } \n va_start (marker, fmt);\n\tVsprintf (szBuf + Strlen (szBuf), fmt, marker);\n va_end (marker);\n\n Strcat (szBuf, SYSTEM_EOL);\n OutputDebugString (szBuf);\n} /* Tcp4uLog */\n\n\n/* -------------------------------------------------------------- */\n/* dump a binary or text frame. The output is the debug window */\n/* for Windows system and stderr for unix */\n/* The code is a port of the xdump function from the cmu snmp lib */\n/* Ajout du cast (unsigned char) */\n/* -------------------------------------------------------------- */\nvoid API4U Tcp4uDump (LPCSTR cp, int nLen, LPCSTR szPrefix)\n{\nint col, count, nPos;\nchar szLine [128];\nstatic const char tCvtHex[] = \"0123456789ABCDEF\";\n\n /* dump enabled ? */ \n if ( (uMaskTrace & LOG4U_DUMP) == 0) return;\n\n if (nLen==0) /* Empty message -> has to be dumped */\n {\n if (szPrefix!=NULL) Strcpyn (szLine, szPrefix, 20);\n else szLine[0]=0;\n Strcat (szLine, \" Empty Message\");\n Strcat (szLine, SYSTEM_EOL);\n OutputDebugString (szLine);\n return; \n }\n\n count = 0;\n while (count < nLen)\n {\n if (szPrefix!=NULL) Strcpyn (szLine, szPrefix, 20);\n else szLine[0]=0;\n nPos = Strlen (szLine);\n szLine[nPos++] = ' ';\n\n for (col = 0 ; count + col < nLen && col < 16 ; col++)\n {\n if (col == 8) szLine[nPos++] = '-', szLine[nPos++] = ' ' ;\n\t szLine [nPos++] = tCvtHex [(unsigned char ) cp[count + col] >> 4];\n\t szLine [nPos++] = tCvtHex [(unsigned char ) cp[count + col] & 0x0F];\n\t szLine [nPos++] = ' ';\n }\n\n while(col++ < 16) /* pad end of buffer with zeros */\n { \n if (col == 8) szLine[nPos++] = ' ', szLine[nPos++] = ' ';\n szLine[nPos++] = ' ';\n szLine[nPos++] = ' ';\n szLine[nPos++] = ' ';\n }\n szLine[nPos++] = ' ';\n szLine[nPos++] = ' ';\n\n for (col = 0; count + col < nLen && col < 16 ; col++) \n {\n\t szLine[nPos++] = isprint(cp[count + col]) ? cp[count + col] : '.';\n }\n\t Strcpy (& szLine[nPos], SYSTEM_EOL);\n OutputDebugString (szLine);\n \n count += col;\n } /* while buffer nor printed */\n\n} /* Tcp4uDump */\n\n#ifndef __xDistributedPoint2F_H\r\n#define __xDistributedPoint2F_H\r\n#include \"xPoint.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xTNLInternAll.h\"\r\n#include \r\n\r\nclass xDistributedPoint2F : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedPoint2F ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tmLastValue = Point2F(0.0f,0.0f);\r\n\t\t\tmCurrentValue= Point2F(0.0f,0.0f);\r\n\t\t\tmDifference = Point2F(0.0f,0.0f);\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\r\n\t\t~xDistributedPoint2F(){}\r\n\r\n\t\tPoint2F mLastValue;\r\n\t\tPoint2F mCurrentValue;\r\n\t\tPoint2F mDifference;\r\n\r\n\t\tPoint2F mLastServerValue;\r\n\t\tPoint2F mLastServerDifference;\r\n \r\n\t\tbool updateValue(Point2F value,xTimeType currentTime);\r\n\t\tPoint2F getDiff(Point2F value);\r\n void pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(TNL::BitStream *stream);\r\n\t\tvoid updateFromServer(TNL::BitStream *stream);\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n \r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pErrorStream.h\"\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\r\n\t\r\nvoid pErrorStream::reportError(NxErrorCode e, const char* message, const char* file, int line)\r\n{\r\n\r\n\txLogger::xLog(ELOGERROR,E_LI_AGEIA,message);\r\n\r\n}\r\nNxAssertResponse pErrorStream::reportAssertViolation(const char* message, const char* file, int line)\r\n{\r\n\treturn NX_AR_CONTINUE;\r\n\r\n}\r\nvoid pErrorStream::print(const char* message)\r\n{\r\n\r\n\txLogger::xLog(ELOGERROR,E_LI_AGEIA,message);\r\n\r\n}\r\n\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBRemoveShapeDecl();\r\nCKERROR CreatePBRemoveShapeProto(CKBehaviorPrototype **pproto);\r\nint PBRemoveShape(const CKBehaviorContext& behcontext);\r\nCKERROR PBRemoveShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBRemoveShapeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBRemoveShape\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Removes a sub shape given by a mesh.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x25637ead,0x3a881190));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBRemoveShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBRemoveShapeProto\r\n// FullName: CreatePBRemoveShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Mesh=0,\r\n\tbbI_Density,\r\n\tbbI_TotalMass,\r\n};\r\n\r\nCKERROR CreatePBRemoveShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBRemoveShape\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PBRemoveShape \r\n\r\n\tPBRemoveShape is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRemoves a sub shape. See also pRigidBody::addSubShape()\t.
\r\n\t\r\n\t

Technical Information

\r\n\r\n\t\\image html PBRemoveShape.png\r\n\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\r\n\r\n\tTarget:The 3D Entity associated to the rigid body.
\r\n\r\n\tMesh Reference:The mesh reference. Must be a Entity3D or a Mesh.
\r\n\r\n\t
\r\n\tNew Density: Density scale factor of the shapes belonging to the body.If you supply a non-zero total mass, \r\n\tthe bodies mass and inertia will first be computed as\tabove and then scaled to fit this total mass. See #pRigidBody::updateMassFromShapes().\r\n\t
\r\n\t
\r\n\tTotal Mass: Total mass if it has sub shapes.If you supply a non-zero density, \r\n\tthe bodies mass and inertia will first be computed as above and then scaled by this factor.See #pRigidBody::updateMassFromShapes().\r\n\t
\r\n\r\n\t
\r\n\t

Note

\r\n\r\n\tThe mesh reference can NOT be the initial shape of the target body.\r\n\r\n\t*/\r\n\t\r\n\tproto->DeclareInParameter(\"Reference\",CKPGUID_BEOBJECT);\r\n\tproto->DeclareInParameter(\"Density\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Total Mass\",CKPGUID_FLOAT);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBRemoveShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBRemoveShape\r\n// FullName: PBRemoveShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBRemoveShape(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\r\n\t\t}\r\n\t\tpRigidBody*result = world->getBody(target);\r\n\t\tif(!result)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\tCKMesh *mesh = (CKMesh*)GetInputParameterValue(beh,bbI_Mesh);\r\n\t\tfloat density = GetInputParameterValue(beh,bbI_Density);\r\n\t\tfloat totalMass = GetInputParameterValue(beh,bbI_TotalMass);\r\n\r\n\t\tresult->removeSubShape(mesh,density,totalMass);\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBRemoveShapeCB\r\n// FullName: PBRemoveShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBRemoveShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#if !defined(EA_45F10106_0809_49c3_8B43_1556D139853F__INCLUDED_)\r\n#define EA_45F10106_0809_49c3_8B43_1556D139853F__INCLUDED_\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\tclass pWorldSettings\r\n\t{\r\n\r\n\t\t\r\n\tpublic:\r\n\r\n\t\t\r\n\t\tpWorldSettings();\r\n\t\t\r\n\t\tVxVector getGravity() const{\r\n\r\n\t\t\treturn m_Gravity;\r\n\t\t}\r\n\t\tvoid setGravity(VxVector val){\r\n\t\t\tm_Gravity = val;\r\n\t\t}\r\n\t\tfloat getSkinWith() const{\r\n\t\t\treturn m_SkinWith;\r\n\t\t}\r\n\t\tvoid setSkinWith(float val)\r\n\t\t{\r\n\t\t\tm_SkinWith = val;\r\n\t\t}\r\n\r\n\t\tbool isFixedTime() const { return fixedTime; }\r\n\t\tvoid setFixedTime(bool val) { fixedTime = val; }\r\n\t\t\r\n\t\tint getNumIterations() const { return numIterations; }\r\n\t\tvoid setNumIterations(int val) { numIterations = val; }\r\n\t\t\r\n\t\tfloat getFixedTimeStep() const { return fixedTimeStep; }\r\n\t\tvoid setFixedTimeStep(float val) { fixedTimeStep = val; }\r\n\t\tint getSceneFlags() const { return sceneFlags; }\r\n\t\tvoid setSceneFlags(int val) { sceneFlags = val; }\r\n\r\n\t\tint getPhysicFlags() const { return physicFlags; }\r\n\t\tvoid setPhysicFlags(int val) { physicFlags = val; }\r\n\r\n\r\n\tprotected:\r\n\r\n\t\tfloat m_SkinWith;\r\n\t\tVxVector m_Gravity;\r\n\r\n\t\tfloat fixedTimeStep;\r\n\t\tint numIterations;\r\n\t\tbool fixedTime;\r\n\t\tint sceneFlags;\r\n\t\tint physicFlags;\r\n\t\t\r\n\t};\r\n\r\n\t\r\n}\r\n#endif // !defined(EA_45F10106_0809_49c3_8B43_1556D139853F__INCLUDED_)\r\n#ifndef InitMAN_H\r\n#define InitMAN_H\r\n\r\n\r\n\r\n#include \"CKBaseManager.h\"\r\n#include \"xNetConstants.h\"\r\n#include \r\n#include \"vtGuids.h\"\r\n\r\n\r\n#define NET_MAN_GUID\t\tCKGUID(0x21aa716b,0x57e37304)\r\n\r\n\r\nclass xNetInterface;\r\nclass vtConnection;\r\nclass xDistributedObject;\r\nclass xDistributedProperty;\r\n\r\n\r\n\r\n\r\nclass vtNetworkManager : public CKBaseManager\r\n{\r\n\r\n\tpublic:\r\n\t\t//Ctor\r\n\t\tvtNetworkManager(CKContext* ctx);\r\n\t\t//Dtor\r\n\t\t~vtNetworkManager();\r\n\t\t\r\n\t\tint Init();\r\n\r\n\t\tvoid initLogger();\r\n\r\n\t\t\r\n\t\t\r\n\t\txNetInterface* GetServerNetInterface();\r\n\t\tvoid SetServerNetInterface(xNetInterface *cinterface);\r\n\t\t\r\n\t\txNetInterface *GetClientNetInterface();\r\n\t\tvoid SetClientNetInterface(xNetInterface *cinterface);\r\n \r\n\r\n\t\tXString m_LastLogEntry;\r\n\t\tXString GetLastLogEntry() const { return m_LastLogEntry; }\r\n\t\tvoid SetLastLogEntry(XString val) { m_LastLogEntry = val; }\r\n\t\t\r\n\t\tint CreateServer(bool deleteExisting,int port,const char *address);\r\n\t\tvoid DeleteServer(int flags);\r\n\t\tint CreateClient(bool deleteExisting,int port,const char *address);\r\n\r\n\r\n\t\tvtConnection *localConnection;\r\n\t\tint CreateLocalConnection();\r\n\r\n\t\tint ConnectToServer(bool deleteExisting,const char *address);\r\n\t\tvoid UpdateDistributedObjects(DWORD flags);\r\n\t\tstatic vtNetworkManager* Instance();\r\n\r\n\t\tstatic vtNetworkManager * Cast(CKBaseManager* iM) { return Instance();}\r\n\r\n\t\t// Initialization\t\r\n\t\tvirtual CKERROR OnCKInit();\r\n\t\tvirtual CKERROR OnCKEnd();\r\n\t\tvirtual CKERROR OnCKReset();\r\n\t\tvirtual CKERROR PreProcess();\r\n\t\tvirtual CKERROR PostProcess();\r\n\t\tvirtual CKERROR PostClearAll();\r\n\t\tvirtual CKERROR OnCKPlay();\r\n\r\n\tvirtual CKDWORD\tGetValidFunctionsMask()\t\r\n\t{ return CKMANAGER_FUNC_OnCKInit|\r\n\t\tCKMANAGER_FUNC_PostProcess|\r\n\t\tCKMANAGER_FUNC_OnCKEnd|\r\n\t\tCKMANAGER_FUNC_OnCKReset|\r\n\t\tCKMANAGER_FUNC_PreProcess|\r\n\t\tCKMANAGER_FUNC_PostClearAll|\r\n\t\tCKMANAGER_FUNC_OnCKPlay; \r\n\t}\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* Parameter Functions\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\r\n\tvoid Test(const char*);\r\n\tvoid RegisterVSL();\r\n\tbool pLoaded;\r\n\r\n\tfloat m_CurrentDeltaTime;\r\n\tfloat getCurrentDeltaTime() const { return m_CurrentDeltaTime; }\r\n\tvoid setCurrentDeltaTime(float val) { m_CurrentDeltaTime = val; }\r\n\r\n\tfloat mCurrentThresholdTicker;\r\n\t\r\n\tfloat& getCurrentThresholdTicker(){ return mCurrentThresholdTicker; }\r\n\tvoid setCurrentThresholdTicker(float val) { mCurrentThresholdTicker = val; }\r\n\r\n\tvoid performGhostUpdates();\r\n\r\n\tvoid updateLocalPosition(xDistributedObject* distObject,CK3dEntity *target,xDistributedProperty*prop);\r\n\tvoid updateLocalRotation(xDistributedObject* distObject,CK3dEntity *target,xDistributedProperty*prop);\r\n\r\n\tfloat m_MinTickTime;\r\n\tfloat getMinTickTime() const { return m_MinTickTime; }\r\n\tvoid setMinTickTime(float val) { m_MinTickTime = val; }\r\n\r\n\r\n\tvoid RegisterParameters();\r\n\r\n\r\n\r\n\tprotected:\r\n\r\n};\r\n\r\n\r\n#define GetNM() vtNetworkManager::Instance()\r\n#define ctx() vtNetworkManager::Instance()->m_Context\r\n\r\n#endif\r\n/*!\r\n * \r\n * \r\n * Copyright (c) 2005 by \r\n */\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachToCoreDecl();\r\nCKERROR CreatePClothAttachToCoreProto(CKBehaviorPrototype **pproto);\r\nint PClothAttachToCore(const CKBehaviorContext& behcontext);\r\nCKERROR PClothAttachToCoreCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_BodyReference, \r\n\tbbI_ImpulseThreshold,\r\n\tbbI_PenetrationDepth,\r\n\tbbI_MaxDeform,\r\n};\r\n\r\n\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPClothAttachToCoreDecl\r\n// FullName: FillBehaviorPClothAttachToCoreDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\n/*!\r\n * \\brief\r\n * Write brief comment for FillBehaviorPClothAttachToCoreDecl here.\r\n * \r\n * \\returns\r\n * Write description of return value here.\r\n * \r\n * \\throws \r\n * Description of criteria for throwing this exception.\r\n * \r\n * Write detailed description for FillBehaviorPClothAttachToCoreDecl here.\r\n * \r\n * \\remarks\r\n * Write remarks for FillBehaviorPClothAttachToCoreDecl here.\r\n * \r\n * \\see\r\n * Separate items with the '|' character.\r\n */\r\nCKObjectDeclaration\t*FillBehaviorPClothAttachToCoreDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PClothAttachToCore\");\t\r\n\tod->SetCategory(\"Physic/Cloth\");\r\n\tod->SetDescription(\"Surrounds a rigid body with a cloth.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x37d75f67,0x7041320f));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePClothAttachToCoreProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePClothAttachToCoreProto\r\n// FullName: CreatePClothAttachToCoreProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePClothAttachToCoreProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PClothAttachToCore\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/*! \\page PClothAttachToCore\r\n\r\n\r\n\tPClothAttachToCore is categorized in \\ref Clothes\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tAttaches a cloth to a body.
\r\n\r\n\tCall this function only once right after the cloth is created.\r\n\tTurning cloth into metal and vice versa during the simulation is not recommended.\r\n\r\n\tThis feature is well suited for volumetric objects like barrels. \r\n\tIt cannot handle two dimensional flat pieces well.\r\n\r\n\tAfter this call, the cloth is infinitely stiff between collisions and simply \r\n\tmoves with the body. At impacts with an impact impulse greater than impulseThreshold, \r\n\tthe cloth is plastically deformed. Thus, a cloth with a core behaves like a piece of metal.\r\n\r\n\tThe core body's geometry is adjusted automatically. Its size also depends on the \r\n\tcloth thickness. Thus, it is recommended to choose small values for the thickness.\r\n\tAt impacts, colliding objects are moved closer to the cloth by the value provided in \r\n\tpenetrationDepth which causes a more dramatic collision result.\r\n\r\n\tThe core body must have at least one shape, and currently supported shapes are \r\n\tspheres, capsules, boxes and compounds of spheres.\r\n\tIt is recommended to specify the density rather than the mass of the core body. \r\n\tThis way the mass and inertia tensor are updated when the core deforms.\r\n\r\n\tThe maximal deviation of cloth particles from their initial positions\r\n\t(modulo the global rigid body transforms translation and rotation) can be\r\n\tspecified via the parameter maxDeformationDistance. Setting this parameter to\r\n\tzero means that the deformation is not limited. \r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PClothAttachToCore.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\tTarget: Target cloth reference.\r\n\t
\r\n\t
\r\n\r\n\tBody Reference: The core body to attach the cloth to.\r\n\r\n\t@see pCloth::attachToCore()\r\n\t
\r\n\tImpulse Threshold: Threshold for when deformation is allowed.\r\n\t
\r\n\r\n\tPenetration Depth: Amount by which colliding objects are brought closer to the cloth.\r\n\t
\r\n\r\n\r\n\tMax Deformation Distance: Maximum deviation of cloth particles from initial position.\r\n\t
\r\n\r\n\r\n\t\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include pCloth.cpp\r\n\t\r\n\t*/\r\n\r\n\r\n\r\n\tproto->SetBehaviorCallbackFct( PClothAttachToCoreCB );\r\n\r\n\tproto->DeclareInParameter(\"Body Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Impulse Threshold\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Penetration Depth\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Max Deformation Distance\",CKPGUID_FLOAT);\r\n\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PClothAttachToCore);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachToCore\r\n// FullName: PClothAttachToCore\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PClothAttachToCore(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tCK3dEntity*bodyReference = (CK3dEntity *) beh->GetInputParameterObject(bbI_BodyReference);\r\n\t\tif (!bodyReference)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(bodyReference);\r\n\t\tif (!body)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\r\n\t\tpWorld *world = body->getWorld();\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\tpCloth *cloth = world->getCloth(target);\r\n\t\tif (!cloth)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn CKBR_PARAMETERERROR;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\r\n\t\tfloat impulseThreshold = GetInputParameterValue(beh,bbI_ImpulseThreshold);\r\n\t\tfloat penetrationDepth = GetInputParameterValue(beh,bbI_PenetrationDepth);\r\n\t\tfloat maxDeform = GetInputParameterValue(beh,bbI_MaxDeform);\r\n\r\n\t\tcloth->attachToCore(bodyReference,impulseThreshold,penetrationDepth,maxDeform);\r\n\r\n\t\tbeh->ActivateOutput(0);\r\n\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PClothAttachToCoreCB\r\n// FullName: PClothAttachToCoreCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PClothAttachToCoreCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\n\r\nbool isSceneObject2(CK3dEntity *object)\r\n{\r\n\tCKLevel *level = GetPMan()->GetContext()->GetCurrentLevel();\r\n\tif(level)\r\n\t{\r\n\t\tfor(int i = 0 ; i < level->GetSceneCount() ; i++ )\r\n\t\t{\r\n\t\t\tCKScene *scene = level->GetScene(i);\r\n\t\t\tif(scene && scene->IsObjectHere(object))\r\n\t\t\t\treturn true;\t\t\t\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\nvoid PhysicManager::_checkObjectsByAttribute(CKScene *newScene)\r\n{\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tint sizeJFuncMap = ATT_FUNC_TABLE_SIZE;//(sizeof(*getRegistrationTable()) / sizeof((getRegistrationTable())[0]));\r\n\tfor (int fIndex = 0 ; fIndex < sizeJFuncMap ; fIndex ++)\r\n\t{\r\n\r\n\t\tstd::vectorattributeIdList;\r\n\t\tpFactory::Instance()->findAttributeIdentifiersByGuid(getRegistrationTable()[fIndex].guid,attributeIdList);\r\n\t\tint attCount = attributeIdList.size();\r\n\r\n\t\tfor (int i = 0 ; i < attCount ; i++ )\r\n\t\t{\r\n\t\t\tint currentAttType = attributeIdList.at(i);\r\n\t\t\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr( attributeIdList.at(i) );\r\n\t\t\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t\t\t{\t\r\n\t\t\t\tCK3dEntity *target = static_cast(*it);\r\n\t\t\t\tif (target)\r\n\t\t\t\t{\r\n\t\t\t\t\tXString error;\r\n\t\t\t\t\terror.Format(\"Registering :%s with %s\",target->GetName(),attman->GetAttributeNameByType(currentAttType));\r\n\t\t\t\t\t//if(!strcmp( target->GetName(),\"smutan3-3\" ) )\t\t\t\t\t{\t\t\t\t\t//\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"problem case\" );\t\t\t\t\t}\r\n\r\n//\t\t\t\t\tCKScene *levelScene = GetContext()->GetCurrentLevel()->GetCurrentScene();\r\n\t\t\t\t\t// we check as no scene is current in use \r\n\t\t\t\t\tif (\t\t(\t\r\n\t\t\t\t\t\t\t\tGetContext()->GetCurrentLevel()->GetLevelScene() == newScene &&\r\n\t\t\t\t\t\t\t\t!isSceneObject2(target) \r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t(\tnewScene && newScene->IsObjectHere(target) && newScene !=GetContext()->GetCurrentLevel()->GetLevelScene() )\r\n\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t(\t\r\n\t\t\t\t\t\t\t\tnewScene &&\r\n\t\t\t\t\t\t\t\tGetContext()->GetCurrentLevel()->GetCurrentScene() && \r\n\t\t\t\t\t\t\t\tGetContext()->GetCurrentLevel()->GetCurrentScene() == newScene &&\r\n\t\t\t\t\t\t\t\tnewScene !=GetContext()->GetCurrentLevel()->GetLevelScene() &&\r\n\t\t\t\t\t\t\t\tnewScene->IsObjectHere(target)\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t(physicFlags & PMF_DONT_DELETE_SCENES) \r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,error.CStr() );\r\n\t\t\t\t\t\t\t(*getRegistrationTable()[fIndex].rFunc)(target,currentAttType,true,false);\r\n\t\t\t\t\t\t\tGetPMan()->getCheckList().PushBack(target->GetID());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::_RegisterAttributeCallbacks()\r\n{\r\n\tif (!getAttributeFunctions().Size())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tAttributeFunctionArrayIteratorType it = getAttributeFunctions().Begin();\r\n\r\n\twhile(it != getAttributeFunctions().End())\r\n\t{\r\n\t\tObjectRegisterFunction myFn = (ObjectRegisterFunction)*it;\r\n\t\tif (myFn)\r\n\t\t{\r\n\t\t\tattman->SetAttributeCallbackFunction(it.GetKey(),PObjectAttributeCallbackFunc,myFn);\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n}\r\n\r\nvoid PhysicManager::cleanAttributePostObjects()\r\n{\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tif (!getAttributePostObjects().Size())\r\n\t\treturn;\r\n\t\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tPostRegistrationArrayIteratorType it = getAttributePostObjects().Begin();\r\n\r\n\tif (getAttributePostObjects().Size())\r\n\t{\r\n\t\tif (!GetPMan()->isValid()){\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Invalid world, performing initiation...\");\r\n\t\t\tGetPMan()->performInitialization();\r\n\t\t}\r\n\t}\r\n\twhile(it != getAttributePostObjects().End())\r\n\t{\r\n\t\tpAttributePostObject& post = *it;\r\n\t\tCK3dEntity *refObject = static_cast(GetPMan()->m_Context->GetObject(post.objectId));\r\n\t\tif (refObject)\r\n\t\t{\r\n\r\n\t\t\tObjectRegisterFunction regFn = (ObjectRegisterFunction)post.func;\r\n\t\t\tif (regFn)\r\n\t\t\t{\r\n\t\t\t\t(*regFn)(refObject,post.attributeID,true,false);\r\n\t\t\t}\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n\tint s = getAttributePostObjects().Size();\r\n\r\n\tgetAttributePostObjects().Clear();\r\n}\r\n\r\nvoid PhysicManager::populateAttributeFunctions()\r\n{\r\n\r\n\tgetAttributeFunctions().Clear();\r\n\r\n\tint sizeJFuncMap = ATT_FUNC_TABLE_SIZE;// (sizeof(*getRegistrationTable()) / sizeof(ObjectRegistration));\r\n\tfor (int fIndex = 0 ; fIndex < sizeJFuncMap ; fIndex ++)\r\n\t{\r\n\t\t#ifdef _DEBUG \r\n\r\n\t\t//XString _errorStr;\r\n\t\t//getRegistrationTable()[fIndex].rFunc.\r\n\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errString.Str());\r\n\r\n\t\t#endif\r\n\r\n\t\tstd::vectorattributeIdList;\r\n\t\tpFactory::Instance()->findAttributeIdentifiersByGuid(getRegistrationTable()[fIndex].guid,attributeIdList);\r\n\t\tint attCount = attributeIdList.size();\r\n\t\tfor (int i = 0 ; i < attCount ; i++ )\r\n\t\t{\r\n\t\t\tint currentAttType = attributeIdList.at(i);\r\n\t\t\tgetAttributeFunctions().Insert(currentAttType,getRegistrationTable()[fIndex].rFunc);\r\n\t\t}\r\n\t}\r\n}\r\nObjectRegistration*PhysicManager::getRegistrationTable()\r\n{\r\n\treturn attributeFunctionMap;\r\n}\r\n#ifndef __XMESSAGE_TYPES_H_\r\n#define __XMESSAGE_TYPES_H_\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n#include \"xPoint.h\"\r\n#include \"xMessage.h\"\r\n\r\nclass xMessageType\r\n{\r\n\r\n\r\n\tpublic :\r\n\t\txMessageType() \r\n\t\t{\r\n\t\t\ttype = -1;\r\n\t\t\tname =\"\";\r\n\t\t\tsessionID =-1;\r\n\t\t\tnumParameters =-1;\r\n\t\t}\r\n\r\n\tint getType() const { return type; }\r\n\tvoid setType(int val) { type = val; }\r\n\txNString getName() const { return name; }\r\n\tvoid setName(xNString val) { name = val; }\r\n\tint getNumParameters() const { return numParameters; }\r\n\tvoid setNumParameters(int val) { numParameters = val; }\r\n\tint getSessionID() const { return sessionID; }\r\n\tvoid setSessionID(int val) { sessionID = val; }\r\n\r\n\tprotected :\r\n\t\tint type;\r\n\t\t\r\n\t\txNString name;\r\n\t\t\r\n\t\tint numParameters;\r\n\t\t\r\n\t\tint sessionID;\r\n\t\t\r\n};\r\n\r\n\r\nclass xNetMessage\r\n{\r\n\r\npublic :\r\n\txNetMessage(){}\r\n\tvirtual ~xNetMessage(){}\r\n\tint type;\r\n\tint getType() const { return type; }\r\n\tvoid setType(int val) { type = val; }\r\n\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\ntemplateclass xMessageData : public xNetMessage\r\n{\r\npublic : \r\n\ttypedef T* ValueRef;\r\n\tT value;\r\n\r\n\r\n\tT getValue(){return value;}\r\n\tvoid setValue(const T& _value )\r\n\t{\r\n\t\tvalue = _value;\r\n\t}\r\n\tvirtual ~xMessageData(){}\r\n\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nclass xMessageFloat : public xMessageData\r\n{\r\npublic :\r\n\txMessageFloat(){}\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nclass xMessageInt : public xMessageData\r\n{\r\npublic :\r\n\txMessageInt(){}\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nclass xMessageString : public xMessageData\r\n{\r\npublic :\r\n\txMessageString(){}\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nclass xMessagePoint3F : public xMessageData\r\n{\r\npublic :\r\n\txMessagePoint3F(){}\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nclass xMessagePoint4F : public xMessageData\r\n{\r\npublic :\r\n\txMessagePoint4F(){}\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#endif#include \r\n#include \"CKAll.h\"\r\n\r\nHINSTANCE GetModulefromResource(HMODULE hModule,int name,char *tempfile);\r\n\r\nHMODULE\tGetParentModule(CK_PLUGIN_TYPE type,CKGUID guid);\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtAttributeHelper.h\"\r\n\r\nNxShape *PhysicManager::getSubShape(CK3dEntity*referenceObject)\r\n{\r\n\tif (!referenceObject)\r\n\t\treturn NULL;\r\n\r\n\tpRigidBody *body = getBody(referenceObject);\r\n\tif (!body)\r\n\t\treturn NULL;\r\n\r\n\t\r\n\treturn body->getSubShape(referenceObject);\r\n\r\n\r\n}\r\nNxCCDSkeleton* PhysicManager::getCCDSkeleton(CKBeObject *shapeReference)\r\n{\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\tint s = getWorlds()->Size();\r\n\r\n\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tNxActor** actors = w->getScene()->getActors();\r\n\t\tint nbActors = w->getScene()->getNbActors();\r\n\t\twhile(nbActors--)\r\n\t\t{\r\n\t\t\tNxActor* actor = *actors++;\r\n\t\t\tif(actor->userData != NULL)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = actor->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)actor->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\tif (sInfo)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\nvoid PhysicManager::createWorlds(int flags)\r\n{\r\n\r\n#ifdef _DEBUG\r\n\t//assert(m_DefaultSleepingSettings());\r\n//\tassert(getWorlds());\r\n#endif\r\n\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_world_object);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\t\tCK3dEntity*target = static_cast(*it);\r\n\t\tpWorld *world = getWorld(target->GetID());\r\n\r\n\t\tconst char*name = target->GetName();\r\n\t\tif (world == getDefaultWorld() )\r\n\t\t{\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//world not registered :\r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//at first we check for an attached sleeping settings attribute, when not, we use this->DefaultDefaultSleepingSettings \r\n//\t\t\tpSleepingSettings *sleepSettings = target->HasAttribute(att_sleep_settings) ? \r\n//\t\t\t\tpFactory::Instance()->GetSleepingSettingsFromEntity(target) : &this->DefaultSleepingSettings(); \r\n\r\n\t\t\t//we also retrieve objects world settings\r\n\t\t\t//pWorldSettings * worldSettings = pFactory::Instance()->GetWorldSettingsFromEntity(target);\r\n\r\n\t\t\t//now we can create the final world,the function initiates the world and also it inserts the world \r\n\t\t\t//in our m_pWorlds array !\r\n\t\t\t//world = pFactory::Instance()->createWorld(target,worldSettings,sleepSettings);\r\n\t\t}\r\n\t}\r\n};\r\nint PhysicManager::getNbWorlds(){\treturn getWorlds()->Size();}\r\nvoid PhysicManager::checkClothes()\r\n{\r\n\r\n\tif (!getNbObjects())\r\n\t\treturn;\r\n\r\n\tif (!isValid())\tperformInitialization();\r\n\tif (!isValid())\r\n\t{\r\n\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't make manager valid\");\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we iterate through all entities tagged with the physic attribute \r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_clothDescr);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\r\n\t\tCK3dEntity *target = static_cast(*it);\r\n\t\tif (target)\r\n\t\t{\r\n\t\t\tconst char *bName = target->GetName();\r\n\t\t\t// is the body registered in any world ? \r\n\t\t\r\n\r\n\t\t\tCK_ID wID = vtTools::AttributeTools::GetValueFromAttribute(target,att_clothDescr,E_CS_WORLD_REFERENCE);\r\n\t\t\tCK3dEntity *worldReference = (CK3dEntity*)m_Context->GetObject(wID);\r\n\t\t\tpWorld *world = getWorld(wID);\r\n\r\n\t\t\tif (!worldReference)\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (getBody(target))\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (world->getShapeByEntityID(target->GetID()))\r\n\t\t\t{\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\t\t\tif (world && worldReference)\r\n\t\t\t{\r\n\t\t\t\tpCloth *cloth = world->getCloth(target);\r\n\t\t\t\tif (!cloth)\r\n\t\t\t\t{\r\n\t\t\t\t\tpClothDesc *descr = pFactory::Instance()->createClothDescrFromParameter(target->GetAttributeParameter(att_clothDescr));\r\n\t\t\t\t\tcloth = pFactory::Instance()->createCloth(target,*descr);\r\n\t\t\t\t\tif(cloth)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\tif (descr->flags & PCF_AttachToParentMainShape )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (target->GetParent())\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *bodyReference = pFactory::Instance()->getMostTopParent(target);\r\n\t\t\t\t\t\t\t\tif (bodyReference)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tpRigidBody *body = GetPMan()->getBody(bodyReference);\r\n\t\t\t\t\t\t\t\t\tif (body)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tcloth->attachToShape((CKBeObject*)bodyReference,descr->attachmentFlags);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\tif (descr->flags & PCF_AttachToCollidingShapes)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcloth->attachToCollidingShapes(descr->attachmentFlags);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\nvoid PhysicManager::checkWorlds()\r\n{\r\n\r\n\tif (!getNbObjects())\r\n\t\treturn;\r\n\r\n\tif (!isValid())\tperformInitialization();\r\n\tif (!isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't make manager valid\");\r\n\t\treturn;\r\n\t}\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we iterate through all entities tagged with the physic attribute \r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(att_physic_object);\r\n\tfor (CKObject** it = Array.Begin(); it != Array.End(); ++it)\r\n\t{\t\r\n\r\n\t\tCK3dEntity *target = static_cast(*it);\r\n\t\tif (target)\r\n\t\t{\r\n\t\t\tconst char *bName = target->GetName();\r\n\t\t\t// is the body registered in any world ? \r\n\t\t\tpRigidBody* body = getBody(target);\r\n\t\t\tif(!body)\r\n\t\t\t{\r\n\t\t\t\t//we retrieve the bodies target world : \r\n\t\t\t\tCK_ID wID = vtTools::AttributeTools::GetValueFromAttribute(target,GetPAttribute(),E_PPS_WORLD);\r\n\t\t\t\tint flags = vtTools::AttributeTools::GetValueFromAttribute(target,GetPAttribute(),E_PPS_BODY_FLAGS);\r\n\t\t\t\tif (flags & BF_SubShape)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tpWorld *world = getWorld(wID) ? getWorld(wID) : getDefaultWorld();\r\n\t\t\t\tif(world)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\t//now create the final rigid body : \r\n\t\t\t\t\tbody = pFactory::Instance()->createRigidBodyFull(target,world->getReference());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\tcheckClothes();\r\n\t_checkObjectsByAttribute();\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tpWorldMapIt itx = getWorlds()->Begin();\r\n\twhile(itx != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *itx;\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->checkList();\r\n\t\t}\r\n\t\titx++;\r\n\t}\r\n}\r\npWorld *PhysicManager::getWorld(CK3dEntity *_o, CK3dEntity *body)\r\n{\r\n\tpWorld *result=NULL;\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t// Priorities : \r\n\t//\t\t1. the given world by _o\r\n\t//\t\t2. DefaultWorld\r\n\t//\t\t3. body physic attribute\r\n\t//\t\t4. created default world\r\n\t//\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we try to get it over _o : \r\n\tif (_o)\r\n\t{\r\n\t\tresult = getWorld(_o->GetID());\r\n\t\tif (result && getWorld(_o->GetID())->getReference() )\r\n\t\t{\r\n\t\t\t_o = result->getReference();\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//still nothing, we try to get the default world :\r\n\tresult = getDefaultWorld();\r\n\tif (result && getDefaultWorld()->getReference() )\r\n\t{\r\n\t\tCK_ID id = getDefaultWorld()->getReference()->GetID();\r\n\t\t_o = result->getReference();\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we try to get it over the bodies attribute : \r\n\tif (body)\r\n\t{\r\n\t\tif (body->HasAttribute(GetPAttribute()))\r\n\t\t{\r\n\t\t\tCK_ID id = vtTools::AttributeTools::GetValueFromAttribute(body,GetPMan()->GetPAttribute(),E_PPS_WORLD);\r\n\t\t\t_o = static_cast(ctx()->GetObject(id));\r\n\t\t\tif (_o)\r\n\t\t\t{\r\n\t\t\t\tresult = getWorld(_o->GetID());\r\n\t\t\t\tif (result && getWorld(_o->GetID())->getReference())\r\n\t\t\t\t{\r\n\t\t\t\t\t_o = result->getReference();\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t}\r\n\t\t\t\t_o = NULL;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//still nothing \r\n\tif (!getDefaultWorld())\r\n\t{\r\n\t\treturn NULL;\r\n\t\t//result = pFactory::Instance()->createDefaultWorld(\"pDefaultWorld\");\r\n\t\t/*\r\n\t\tif (result)\r\n\t\t{\r\n\t\t\t_o = getDefaultWorld()->getReference();\r\n\t\t}else{\r\n\t\t\t\r\n\t\t\tGetPMan()->performInitialization();\r\n\t\t\tresult = GetPMan()->getDefaultWorld();\r\n\t\t\t_o = result->getReference();\r\n\t\t}\r\n\r\n\t\t*/\r\n\t}\r\n\treturn result;\r\n}\r\nvoid PhysicManager::destroyWorlds()\r\n{\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\tint s = getWorlds()->Size();\r\n\r\n\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->destroy();\r\n\r\n\t\t\tif (w->getReference())\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"World destroyed :%s\",w->getReference()->GetName());\r\n\t\t\t}\r\n\r\n\t\t\tgetWorlds()->Remove(w->getReference());\r\n\t\t\tdelete w;\r\n\t\t\tw = NULL;\r\n\t\t\t\r\n\t\t\tif (getWorlds()->Size())\r\n\t\t\t{\r\n\t\t\t\tdestroyWorlds();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tgetWorlds()->Clear();\r\n}\r\npWorld*PhysicManager::getWorld(CK_ID _o)\r\n{\r\n\t\r\n\tpWorld *result = NULL;\r\n\tCK3dEntity *obj = static_cast(GetContext()->GetObject(_o));\r\n\tif (obj)\r\n\t{\r\n\t\tif (getWorlds()->FindPtr(obj))\r\n\t\t{\r\n\t\t\treturn *getWorlds()->FindPtr(obj);\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\nvoid PhysicManager::deleteWorld(CK_ID _o)\r\n{\r\n\t\r\n\tCK3dEntity *obj = static_cast(GetContext()->GetObject(_o));\r\n\tif (obj)\r\n\t{\r\n\t\tpWorld *w = getWorld(_o);\r\n\t\tif (w)\r\n\t\t{\r\n\t\t\tw->destroy();\r\n\t\t\tgetWorlds()->Remove(obj);\r\n\t\t\tdelete w;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n\r\npWorld*PhysicManager::getWorldByShapeReference(CK3dEntity *shapeReference)\r\n{\r\n\r\n\tif (!shapeReference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\t\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\tpRigidBody *body = w->getBody(pFactory::Instance()->getMostTopParent(shapeReference));\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tif (body->isSubShape((CKBeObject*)shapeReference))\r\n\t\t\t\t{\r\n\t\t\t\t\treturn w;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\npWorld*PhysicManager::getWorldByBody(CK3dEntity*ent)\r\n{\r\n\r\n\tif (!ent)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\t//pRigidBody *body = w->getBody(pFactory::Instance()->getMostTopParent(ent));\r\n\t\t\tpRigidBody *body = w->getBody(ent);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\treturn w;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\npCloth *PhysicManager::getCloth(CK_ID entityID)\r\n{\r\n\r\n\tCK3dEntity *entity = (CK3dEntity*)m_Context->GetObject(entityID);\r\n\tif (!entityID)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tfor (pWorldMapIt it = getWorlds()->Begin(); it!=getWorlds()->End(); it++)\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tif(w)\r\n\t\t{\r\n\t\t\tpCloth *cloth = w->getCloth(entity);\r\n\t\t\tif (cloth)\r\n\t\t\t{\r\n\t\t\t\treturn cloth;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n \r\n\treturn NULL;\r\n}\r\nint PhysicManager::getNbObjects(int flags /* =0 */)\r\n{\r\n\r\n\tCKAttributeManager* attman = ctx()->GetAttributeManager();\r\n\r\n\tint testAtt = -1;\r\n\r\n\tif (flags == 0) testAtt = GetPMan()->GetPAttribute();\r\n\r\n\tint newPhysicObjectAttributeType = getAttributeTypeByGuid(VTS_PHYSIC_ACTOR);\r\n\r\n\r\n\t// [3/31/2009 master]\r\n\t\r\n\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(testAtt);\r\n\tint startSize = 0;\r\n\tstartSize +=Array.Size();\r\n\t\r\n\tstartSize+=attman->GetAttributeListPtr(newPhysicObjectAttributeType).Size();\r\n\r\n\r\n\t/*\r\n\t\tpWorldMapIt it = getWorlds()->Begin();\r\n\t\twhile(it != getWorlds()->End())\r\n\t\t{\r\n\t\t\tpWorld *w = *it;\r\n\t\t\tif (w)\r\n\t\t\t{\r\n\t\t\t\tw->checkList();\r\n\t\t\t}\r\n\t\t\tit++;\r\n\t\t}\r\n\t*/\r\n\treturn startSize;\r\n}# TNL Makefile\n# (c) 2003 GarageGames\n#\n# This makefile is for gcc-based projects, at the moment.\n\n\n# \n# Configuration\n#\nCC=g++ -g -DTNL_DEBUG -DTNL_ENABLE_LOGGING -I../libtomcrypt -W -w -fpermissive -DTNL_DEBUG -DTNL_ENABLE_LOGGING # -O2\n\nOBJECTS=\\\n\tassert.o\\\n\tasymmetricKey.o\\\n\tbitStream.o\\\n\tbyteBuffer.o\\\n\tcertificate.o\\\n\tclientPuzzle.o\\\n\tconnectionStringTable.o\\\n\tdataChunker.o\\\n\teventConnection.o\\\n\tghostConnection.o\\\n\thuffmanStringProcessor.o\\\n\tlog.o\\\n\tnetBase.o\\\n\tnetConnection.o\\\n\tnetInterface.o\\\n\tnetObject.o\\\n\tnetStringTable.o\\\n\tplatform.o\\\n\trandom.o\\\n\trpc.o\\\n\tsymmetricCipher.o\\\n\ttnlMethodDispatch.o\\\n\tjournal.o\\\n\tudp.o\\\n\tvector.o\\\n\nCFLAGS=\n\n.cpp.o : \n\t$(CC) -c $(CFLAGS) $<\n\ndefault: $(OBJECTS)\n\t@echo Building libtnl.a ...\n\tar rcv libtnl.a $(OBJECTS)\n\nclean:\n\trm -f $(OBJECTS) libtnl.a\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\n\r\n\r\npFluid *pWorld::getFluid(CK_ID id)\r\n{\r\n\r\n\tint nbFluids= getScene()->getNbFluids();\r\n\tNxFluid** fluids = getScene()->getFluids();\r\n\twhile(nbFluids--)\r\n\t{\r\n\t\tNxFluid* fluid = *fluids++;\r\n\t\tif(fluid->userData != NULL)\r\n\t\t{\r\n\t\t\tpFluid *vFluid = static_cast(fluid->userData);\r\n\t\t\tif (vFluid)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tif (vFluid->getEntityID() == id)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn vFluid;\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\npFluid*pWorld::getFluid(CK3dEntity* entity)\r\n{\r\n\tif (!entity)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\treturn getFluid(entity->GetID());\r\n\r\n}\r\nvoid pWorld::updateFluids()\r\n{\r\n\t\r\n\r\n\tint nbFluids= getScene()->getNbFluids();\r\n\tNxFluid** fluids = getScene()->getFluids();\r\n\twhile(nbFluids--)\r\n\t{\r\n\t\tNxFluid* fluid = *fluids++;\r\n\t\tif(fluid->userData != NULL)\r\n\t\t{\r\n\t\t\tpFluid *vFluid = static_cast(fluid->userData);\r\n\t\t\tif (vFluid)\r\n\t\t\t{\r\n\t\t\t\tvFluid->updateVirtoolsMesh();\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n#endif#ifndef __P_FACTORY_H__\r\n\t#define __P_FACTORY_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n/**\r\n\\brief Singleton class to create physic objects. \r\n*/\r\nclass MODULE_API pFactory\r\n{\r\n\r\n\t\r\npublic:\r\n\t//friend class PhysicManager;\r\n\tvirtual ~pFactory();\r\n\r\n\tvoid findAttributeIdentifiersByGuid(CKGUID guid,std::vector&targetList);\r\n\r\n\tpFactory();\r\n\tpFactory(PhysicManager* prm1,TiXmlDocument*prm2);\r\n\r\n\tint reloadConfig(const char *fName);\r\n\tTiXmlDocument* loadConfig(const char* filename);\r\n\t\r\n\tpWorldSettings *createWorldSettings(const XString nodeName=\"Default\",const TiXmlDocument * doc = NULL);\r\n\tpWorldSettings *createWorldSettings(const char* nodeName,const char *filename);\r\n\tpWorldSettings*getWorldSettings(CK3dEntity*ent);\r\n\tpWorld* createDefaultWorld(XString name);\r\n\tconst TiXmlElement*getFirstDocElement(const TiXmlElement *root);\r\n\tTiXmlDocument* getDefaultDocument() const { return m_DefaultDocument; }\r\n\r\n\tTiXmlDocument* getDocument(XString filename);\r\n\tNxPhysicsSDK* getPhysicSDK() { return mPhysicSDK; }\r\n\tvoid setPhysicSDK(NxPhysicsSDK* val) { mPhysicSDK = val; }\r\n\tPhysicManager * getManager() const { return mManager; }\r\n\tvoid setManager(PhysicManager * val) { mManager = val; }\r\n\tvoid setDefaultDocument(TiXmlDocument* val) { m_DefaultDocument = val; }\r\n\tvoid clean();\r\n\tvoid destroy();\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\tint copyTo(CKParameter *src,pDominanceSetupItem&dst);\r\n\r\n\r\n\r\n\tpSleepingSettings *CreateSleepingSettings(XString nodeName=\"Default\", TiXmlDocument * doc = NULL);\r\n\tpSleepingSettings*CreateSleepingSettings(const char* nodeName,const char *filename);\r\n\tpSleepingSettings*getSleepingSettings(CK3dEntity*ent);\r\n\r\n\tpWorld *createWorld(CK3dEntity *referenceObject,pWorldSettings*worldSettings=NULL,pSleepingSettings*sleepSettings=NULL);\r\n\r\n\tpRemoteDebuggerSettings createDebuggerSettings(const TiXmlDocument * doc);\r\n\r\n\r\n\t/************************************************************************************************/\r\n\t/** @name RigidBody\r\n\t*/\r\n\t//@{\r\n\t\r\n\t\r\n\t\t\r\n\tpRigidBody *cloneRigidBody(CK3dEntity *src,CK3dEntity *dst,CKDependencies *deps,int copyFlags,int bodyFlags=0);\r\n\tNxShape *cloneShape(CK3dEntity *src,CK3dEntity *dst,CK3dEntity*dstBodyReference,int copyFlags,int bodyFlags=0);\r\n\tpJoint* cloneJoint(pJoint *src,CK3dEntity *srcReference,CK3dEntity *dstReference,int copyFlags);\r\n\tint cloneLimitPlanes(pJoint *src,pJoint *dst,CK3dEntity *srcReference,CK3dEntity *dstReference);\r\n\r\n\r\n\r\n\tvoid cloneJoints(CK3dEntity *src,CK3dEntity *dst,int copyFlags);\r\n\r\n\r\n\tpRigidBody *createRigidBodyFull(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject=NULL);\r\n\tpRigidBody *createBody(CK3dEntity *referenceObject,pObjectDescr descriction,CK3dEntity *worldReferenceObject=NULL);\r\n\tpRigidBody *createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject=NULL);\r\n\tpRigidBody *createBody(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,NXU::NxActorDesc *desc,int flags);\r\n\t\r\n\tpRigidBody *createRigidBody(CK3dEntity *referenceObject,pObjectDescr& oDescr);\r\n\tpRigidBody *createBox(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags);\r\n\tpRigidBody *createCapsule(CK3dEntity *referenceObject,CK3dEntity *worldReferenceObject,pObjectDescr*descr,int creationFlags);\r\n\t\r\n\tint createSubShape(CK3dEntity*target,CK3dEntity*child);\r\n\tNxCCDSkeleton *createCCDSkeleton(CKBeObject *meshReference,int flags);\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\t//@}\r\n\t\r\n\t/************************************************************************************************/\r\n\t/** @name Joints\r\n\t*/\r\n\t//@{\r\n\t\r\n\tpJoint *createJoint(CK3dEntity*,CK3dEntity*,int);\r\n\tpJointDistance*createDistanceJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor0=VxVector(0,0,0),VxVector anchor1=VxVector(0,0,0),float minDistance=0.0f,float maxDistance=0.0f,pSpring sSettings=pSpring(),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJDistance\");\r\n\tpJointD6* createD6Joint(CK3dEntity*a,CK3dEntity*b,VxVector globalAnchor=VxVector(0,0,0),VxVector globalAxis=VxVector(0,-1,0),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f);\r\n\tpJointFixed* createFixedJoint(CK3dEntity*a,CK3dEntity*b,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJFixed\");\r\n\tpJointPulley*createPulleyJoint(CK3dEntity*a,CK3dEntity*b,VxVector pulley0,VxVector pulley1, VxVector anchor0, VxVector anchor1,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f);\t\t\r\n\tpJointBall *createBallJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector swingAxis,VxVector globalAxis=VxVector(0,1,0),bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJBall\");\r\n\tpJointPrismatic*createPrismaticJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJPrismatic\");\r\n\tpJointCylindrical*createCylindricalJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJCylindrical\");\r\n\tpJointRevolute *createRevoluteJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJRevolute\");\r\n\tpJointPointInPlane *createPointInPlaneJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJPointInPlane\");\r\n\tpJointPointOnLine *createPointOnLineJoint(CK3dEntity*a,CK3dEntity*b,VxVector anchor,VxVector axis,bool collision=true,float maxForce = 0.0f, float maxTorque=0.0f,const char* attributeName=\"pJPointOnLine\");\r\n\r\n\r\n\r\n\r\n\tpJoint *GetJoint(CK3dEntity*,CK3dEntity*);\r\n\tpJoint *GetJoint(CK3dEntity*,int);\r\n\tpJointSettings *CreateJointSettings(const XString nodeName=\"Default\",const TiXmlDocument * doc = NULL);\r\n\tpJointSettings *CreateJointSettings(const char* nodeName,const char *filename);\r\n\r\n\tint jointCheckPreRequisites(CK3dEntity*,CK3dEntity*,int);\r\n\r\n\t//@}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//nx\r\n\tNxShapeDesc& createShape(int hullType,CK3dEntity*ent,float density = 1.0f);\r\n\tNxMaterialDesc* createMaterialFromXML(const char* nodeName=\"Default\",const TiXmlDocument * doc = NULL);\r\n\tNxMaterialDesc* createMaterialFromEntity(CKBeObject*object);\r\n\r\n\r\n\tCKParameterOut* findSettings(pWheelDescr&dst,CKBeObject*src);\r\n\tbool findSettings(pMaterial&dst,CKBeObject*src);\r\n\tbool copyTo(pMaterial& dst,CKParameter*src);\r\n\tbool copyTo(pMaterial& dst,NxMaterial*src);\r\n\tbool copyTo(NxMaterial&dst,pMaterial*src);\r\n\tbool copyTo(CKParameterOut*dst,const pMaterial&src);\r\n\tbool copyTo(NxMaterialDesc&dst,const pMaterial&src);\r\n\tbool loadFrom(pMaterial& dst,const char* nodeName=\"Default\",const TiXmlDocument * doc = NULL);\r\n\tbool loadMaterial(pMaterial&dst,const char* nodeName);\r\n\tpMaterial loadMaterial(const char* nodeName,int& error);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//nx mesh : \r\n\tvoid createMesh(NxScene *scene,CKMesh *mesh,NxTriangleMeshDesc&descr,bool hardware=false);\r\n\tvoid createConvexMesh(NxScene *scene,CKMesh *mesh,NxConvexMeshDesc&descr,bool hardware=false);\r\n\tNxShape *createShape(CK3dEntity *bodyReference,pObjectDescr descr,CK3dEntity *srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\r\n\r\n\tstatic pFactory* Instance();\r\n\r\n\tpSpring createSpringFromParameter(CKParameter *par);\r\n\tpJointLimit createLimitFromParameter(CKParameter *par);\r\n\tpMotor createMotorFromParameter(CKParameter *par);\r\n\tpTireFunction createTireFuncFromParameter(CKParameter *par);\r\n\tpObjectDescr *createPObjectDescrFromParameter(CKParameter *par);\r\n\t\r\n\t\r\n\t/************************************************************************/\r\n\t/* clothes : */\r\n\t/************************************************************************/\r\n\tpClothDesc *createClothDescrFromParameter(CKParameter *par);\r\n\tpCloth *createCloth(CK3dEntity *srcReference,pClothDesc descr);\r\n\tvoid copyToClothDescr(NxClothDesc* dst,pClothDesc src );\r\n\tvoid copyTo(pDeformableSettings &dst,CKParameter*par);\r\n\t\r\n\t/************************************************************************/\r\n\t/*Special Case Capsule\t: */\r\n\t/************************************************************************/\r\n\tbool copyTo(pCapsuleSettings&dst,CKParameter*src);\r\n\tbool findSettings(pCapsuleSettings&dst,CKBeObject *src);\r\n\t\r\n\tbool findSettings(pCapsuleSettingsEx&dst,CKBeObject *src);\r\n\tbool findSettings(pConvexCylinderSettings&dst,CKBeObject *src);\r\n\tbool findSettings(pCCDSettings&dst,CKBeObject *src);\r\n\tbool findSettings(pMassSettings&dst,CKBeObject *src);\r\n\tbool findSettings(pPivotSettings&dst,CKBeObject *src);\r\n\tbool findSettings(pOptimization&dst,CKBeObject *src);\r\n\tbool findSettings(pCollisionSettings&dst,CKBeObject*src);\r\n\r\n\r\n\tCKParameterOut* findSettingsParameter(CKBeObject *src,CKGUID guid);\r\n\r\n\t/************************************************************************/\r\n\t/* fluids : */\r\n\t/************************************************************************/\r\n\t//pFluid*createFluid(CK3dEntity *srcReference ,pFluidDesc desc);\r\n\t//void copyToFluidDescr(NxFluidDesc &dst , pFluidDesc src );\r\n\t//CK3dEntity *createFluidEntity();\r\n\t//void initParticles(pFluidDesc &desc,NxParticleData&dst,CK3dEntity*srcReference,CK3dEntity*dstEntity);\r\n\t//void copyToEmitterDesc(NxFluidEmitterDesc&dst,pFluidEmitterDesc src);\r\n\t//CK3dPointCloud* createPointCloud(const pFluidDesc&descr);\r\n\r\n\t/************************************************************************/\r\n\t/* Vehicle */\r\n\t/************************************************************************/\r\n\tpVehicle *createVehicle(CK3dEntity *body,pVehicleDesc descr);\r\n\tpVehicleMotor *createVehicleMotor(pVehicleMotorDesc descr);\r\n\tpVehicleGears *createVehicleGears(pVehicleGearDesc descr);\r\n\t\r\n\t\r\n\t\r\n\tpWheel *createWheelSubShape(pRigidBody *body,CK3dEntity* subEntity,CKMesh *mesh,pObjectDescr *descr,VxVector localPos, VxQuaternion localRotation,NxShape*dstShape);\r\n\t\r\n\r\n\tXString _getMaterialsAsEnumeration(const TiXmlDocument * doc);\r\n\tXString _getBodyXMLInternalEnumeration(const TiXmlDocument * doc);\r\n\tXString _getBodyXMLExternalEnumeration(const TiXmlDocument * doc);\r\n\t\r\n\tXString _getVehicleTireFunctionAsEnumeration(const TiXmlDocument * doc);\r\n\tXString _getVehicleWheelAsEnumeration(const TiXmlDocument * doc);\r\n\tXString _getVehicleSettingsAsEnumeration(const TiXmlDocument * doc);\r\n\tXString _getVehicleMotorSettingsAsEnumeration(const TiXmlDocument * doc);\r\n\tXString _getVehicleGearSettingsAsEnumeration(const TiXmlDocument * doc);\r\n\r\n\tXString _getEnumDescription(const TiXmlDocument * doc,XString identifier);\r\n\tint _getEnumIdentifier(const TiXmlDocument * doc,XString type);\r\n\tint _getEnumIndex(XString enumerationFull,XString enumValue);\r\n\r\n\t\r\n\tNxShape *createWheelShape(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\tNxShape *_createWheelShape1(NxActor *actor,pWheel1 *dstWheel,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\tNxShape *_createWheelShape2(NxActor *actor,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation);\r\n\t\r\n\tNxShape *createWheelShape(CK3dEntity*bodyReference,pWheelDescr wheelDescr,CK3dEntity*wheelReference);\r\n\r\n\r\n\tpWheel *createWheel(pRigidBody *body,pWheelDescr descr,CK3dEntity *wheelShapeReference);\r\n\tpWheel* createWheel(CK3dEntity *bodyReference,CK3dEntity*srcReference,pWheelDescr wheelDescr,pConvexCylinderSettings convexCylinder,VxVector localPositionOffset);\r\n\t\tNxShape *createWheelShape2(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr);\r\n\t\tNxShape *createWheelShape1(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr);\r\n\r\n\tNxShape *_createConvexCylinder(NxActor *actor,int approximation,VxVector _forwardAxis,VxVector _downAxis,VxVector _rightAxis,float height,float radius,bool buildLowerHalf,int shapeFlags);\r\n\tbool _createConvexCylinder(NxConvexShapeDesc* shape,CK3dEntity*dstBodyReference,pObjectDescr *oDescr=NULL);\r\n\t\r\n\tbool _createConvexCylinderMesh(NxConvexShapeDesc *dstShapeDescription,pConvexCylinderSettings& srcSettings,CK3dEntity*referenceObject);\r\n\r\n\tNxShape *_createConvexCylinder(const pConvexCylinderSettings& cylinderDescr,CK3dEntity *srcReference);\r\n\r\n\r\n\tint loadVehicleDescrFromXML(pVehicleDesc& dst,const char* nodeName/* =NULL */,const TiXmlDocument * doc /* = NULL */ );\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tGeometry related structures : \r\n\t//\r\n\tvoid copyTo(pAxisReferencedLength&dst,CKParameter*src,bool evaluate=true);\r\n\tbool copyTo(pConvexCylinderSettings&dst,CKParameter*src,bool evaluate=true);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\twheels \r\n\tint copyTo(pWheelDescr *dst,CKParameter *src);\r\n\tint loadFrom(pTireFunction& dst,const char* nodeName/* = */,const TiXmlDocument * doc /* = NULL */);\r\n\tint loadWheelDescrFromXML(pWheelDescr& dst,const char* nodeName/* =NULL */,const TiXmlDocument * doc /* = NULL */ );\r\n\t\r\n\tbool loadFrom(pWheelDescr& dst,const char* nodeName/* =NULL */);\r\n\r\n\tint copyTo(CKParameterOut *dst,pWheelDescr *src);\r\n\tint copyTo(pWheelDescr &dst,CKParameterOut *src);\r\n\r\n\tint copyTo(CKParameterOut *dst,const pTireFunction& src);\r\n\r\n\r\n\t//contact data : \r\n\tint copyTo(CKParameterOut *dst,const pWheelContactData& src);\r\n\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\r\n\t//\t\tcollision structures \r\n\tint copyTo(pGroupsMask &dst,CKParameter*src);\r\n\tint copyTo(CKParameterOut*dst,pGroupsMask src);\r\n\r\n\r\n\tCK3dEntity *getMostTopParent(CK3dEntity*ent);\r\n\r\nprotected:\r\n\tPhysicManager *mManager;\r\n\t\r\n\r\n\tTiXmlDocument* m_DefaultDocument;\r\n\tNxPhysicsSDK* mPhysicSDK;\r\n\r\n\tVxVector _str2Vec(XString _in);\r\n\tint _str2MaterialFlag(XString _in);\r\n\tint _str2WheelFlag(XString _in);\r\n\tint _str2SceneFlags(XString _in);\r\n\tint _str2PhysicFlags(XString _in);\r\n\tint _str2WheelShapeFlag(XString _in);\r\n\tXString ResolveFileName(const char *input);\r\n\tint _str2CombineMode(const char*input);\r\n\t\r\n\tCK3dEntity *createFrame(const char* name);\r\n\t\r\n\t\r\n\t\r\n\r\n};\r\n\r\n\r\n#endif // !defined(EA_10DFC1E8_486F_4770_9451_7898DBDAD59F__INCLUDED_)\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnlBitStream.h\"\n#include \"tnlVector.h\"\n#include \"tnlNetBase.h\"\n#include \"tnlHuffmanStringProcessor.h\"\n#include \"tnlSymmetricCipher.h\"\n#include \n\n#include \n\nnamespace TNL {\n\nvoid BitStream::setMaxSizes(U32 maxReadSize, U32 maxWriteSize)\n{\n maxReadBitNum = maxReadSize << 3;\n maxWriteBitNum = maxWriteSize << 3;\n}\n\nvoid BitStream::setMaxBitSizes(U32 maxReadSize, U32 maxWriteSize)\n{\n maxReadBitNum = maxReadSize;\n maxWriteBitNum = maxWriteSize;\n}\n\nvoid BitStream::reset()\n{\n bitNum = 0;\n error = false;\n mCompressRelative = false;\n mStringBuffer[0] = 0;\n mStringTable = NULL;\n}\n\nU8 *BitStream::getBytePtr()\n{\n return getBuffer() + getBytePosition();\n}\n\nvoid BitStream::writeClassId(U32 classId, U32 classType, U32 classGroup)\n{\n\tTNLAssert(classType < NetClassTypeCount, \"Out of range class type.\");\n\tTNLAssert(classId < NetClassRep::getNetClassCount(classGroup, classType), \"Out of range class id.\");\n\twriteInt(classId, NetClassRep::getNetClassBitSize(classGroup, classType));\n}\n\nU32 BitStream::readClassId(U32 classType, U32 classGroup)\n{\n TNLAssert(classType < NetClassTypeCount, \"Out of range class type.\");\n U32 ret = readInt(NetClassRep::getNetClassBitSize(classGroup, classType));\n if(ret >= NetClassRep::getNetClassCount(classGroup, classType))\n return 0xFFFFFFFF;\n return ret;\n}\n\nbool BitStream::resizeBits(U32 newBits)\n{\n U32 newSize = ((maxWriteBitNum + newBits + 7) >> 3) + ResizePad;\n if(!resize(newSize))\n {\n error = true;\n return false;\n }\n maxReadBitNum = newSize << 3;\n maxWriteBitNum = newSize << 3;\n return true;\n}\n\nbool BitStream::writeBits(U32 bitCount, const void *bitPtr)\n{\n if(!bitCount)\n return true;\n\n if(bitCount + bitNum > maxWriteBitNum)\n if(!resizeBits(bitCount + bitNum - maxWriteBitNum))\n return false;\n\n U32 upShift = bitNum & 0x7;\n U32 downShift= 8 - upShift;\n\n const U8 *sourcePtr = (U8 *) bitPtr;\n U8 *destPtr = getBuffer() + (bitNum >> 3);\n\n // if this write is for <= 1 byte, and it will all fit in the\n // first dest byte, then do some special masking.\n if(downShift >= bitCount)\n {\n U8 mask = ((1 << bitCount) - 1) << upShift;\n *destPtr = (*destPtr & ~mask) | ((*sourcePtr << upShift) & mask);\n bitNum += bitCount;\n return true;\n }\n\n // check for byte aligned writes -- this will be\n // much faster than the shifting writes.\n if(!upShift) \n {\n bitNum += bitCount;\n for(; bitCount >= 8; bitCount -= 8)\n *destPtr++ = *sourcePtr++;\n if(bitCount)\n {\n U8 mask = (1 << bitCount) - 1;\n *destPtr = (*sourcePtr & mask) | (*destPtr & ~mask);\n }\n return true;\n }\n\n // the write destination is not byte aligned.\n U8 sourceByte;\n U8 destByte = *destPtr & (0xFF >> downShift);\n U8 lastMask = 0xFF >> (7 - ((bitNum + bitCount - 1) & 0x7));\n\n bitNum += bitCount;\n\n for(;bitCount >= 8; bitCount -= 8)\n {\n sourceByte = *sourcePtr++;\n *destPtr++ = destByte | (sourceByte << upShift);\n destByte = sourceByte >> downShift;\n }\n if(bitCount == 0)\n {\n *destPtr = (*destPtr & ~lastMask) | (destByte & lastMask);\n return true;\n }\n if(bitCount <= downShift)\n {\n *destPtr = (*destPtr & ~lastMask) | ((destByte | (*sourcePtr << upShift)) & lastMask);\n return true;\n }\n sourceByte = *sourcePtr;\n\n *destPtr++ = destByte | (sourceByte << upShift);\n *destPtr = (*destPtr & ~lastMask) | ((sourceByte >> downShift) & lastMask);\n return true;\n}\n\nbool BitStream::readBits(U32 bitCount, void *bitPtr)\n{\n if(!bitCount)\n return true;\n if(bitCount + bitNum > maxReadBitNum)\n {\n error = true;\n return false;\n }\n\n U8 *sourcePtr = getBuffer() + (bitNum >> 3);\n U32 byteCount = (bitCount + 7) >> 3;\n\n U8 *destPtr = (U8 *) bitPtr;\n\n U32 downShift = bitNum & 0x7;\n U32 upShift = 8 - downShift;\n\n if(!downShift)\n {\n while(byteCount--)\n *destPtr++ = *sourcePtr++;\n bitNum += bitCount;\n return true;\n }\n\n U8 sourceByte = *sourcePtr >> downShift;\n bitNum += bitCount;\n\n for(; bitCount >= 8; bitCount -= 8)\n {\n U8 nextByte = *++sourcePtr;\n *destPtr++ = sourceByte | (nextByte << upShift);\n sourceByte = nextByte >> downShift;\n }\n if(bitCount)\n {\n if(bitCount <= upShift)\n {\n *destPtr = sourceByte;\n return true;\n }\n *destPtr = sourceByte | ( (*++sourcePtr) << upShift);\n }\n return true;\n}\n\nbool BitStream::setBit(U32 bitCount, bool set)\n{\n if(bitCount >= maxWriteBitNum)\n if(!resizeBits(bitCount - maxWriteBitNum + 1))\n return false;\n if(set)\n *(getBuffer() + (bitCount >> 3)) |= (1 << (bitCount & 0x7));\n else\n *(getBuffer() + (bitCount >> 3)) &= ~(1 << (bitCount & 0x7));\n return true;\n}\n\nbool BitStream::testBit(U32 bitCount)\n{\n return (*(getBuffer() + (bitCount >> 3)) & (1 << (bitCount & 0x7))) != 0;\n}\n\nbool BitStream::writeFlag(bool val)\n{\n if(bitNum + 1 > maxWriteBitNum)\n if(!resizeBits(1))\n return false;\n if(val)\n *(getBuffer() + (bitNum >> 3)) |= (1 << (bitNum & 0x7));\n else\n *(getBuffer() + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7));\n bitNum++;\n return (val);\n}\n\nbool BitStream::write(const ByteBuffer *theBuffer)\n{\n U32 size = theBuffer->getBufferSize();\n if(size > 1023)\n return false;\n\n writeInt(size, 10);\n return write(size, theBuffer->getBuffer());\n}\n\nbool BitStream::read(ByteBuffer *theBuffer)\n{\n U32 size = readInt(10);\n theBuffer->takeOwnership();\n theBuffer->resize(size);\n return read(size, theBuffer->getBuffer());\n}\n\nU32 BitStream::readInt(U8 bitCount)\n{\n U32 ret = 0;\n readBits(bitCount, &ret);\n ret = convertLEndianToHost(ret);\n\n // Clear bits that we didn't read.\n if(bitCount == 32)\n return ret;\n else\n ret &= (1 << bitCount) - 1;\n\n return ret;\n}\n\nvoid BitStream::writeInt(U32 val, U8 bitCount)\n{\n val = convertHostToLEndian(val);\n writeBits(bitCount, &val);\n}\n\nvoid BitStream::writeFloat(F32 f, U8 bitCount)\n{\n writeInt(U32(f * ((1 << bitCount) - 1)), bitCount);\n}\n\nF32 BitStream::readFloat(U8 bitCount)\n{\n return readInt(bitCount) / F32((1 << bitCount) - 1);\n}\n\nvoid BitStream::writeSignedFloat(F32 f, U8 bitCount)\n{\n writeSignedInt(S32(f * ((1 << (bitCount - 1)) - 1)), bitCount);\n}\n\nF32 BitStream::readSignedFloat(U8 bitCount)\n{\n return readSignedInt(bitCount) / F32((1 << (bitCount - 1)) - 1);\n}\n\nvoid BitStream::writeSignedInt(S32 value, U8 bitCount)\n{\n if(writeFlag(value < 0))\n writeInt(-value, bitCount - 1);\n else\n writeInt(value, bitCount - 1);\n}\n\nS32 BitStream::readSignedInt(U8 bitCount)\n{\n if(readFlag())\n return -(S32)readInt(bitCount - 1);\n else\n return (S32)readInt(bitCount - 1);\n}\n\nvoid BitStream::writeNormalVector(const Point3f& vec, U8 bitCount)\n{\n F32 phi = F32(atan2(vec.x, vec.y) * FloatInversePi );\n F32 theta = F32(atan2(vec.z, sqrt(vec.x*vec.x + vec.y*vec.y)) * Float2InversePi);\n\n writeSignedFloat(phi, bitCount+1);\n writeSignedFloat(theta, bitCount);\n}\n\nvoid BitStream::readNormalVector(Point3f *vec, U8 bitCount)\n{\n F32 phi = readSignedFloat(bitCount+1) * FloatPi;\n F32 theta = readSignedFloat(bitCount) * FloatHalfPi;\n\n vec->x = sin(phi)*cos(theta);\n vec->y = cos(phi)*cos(theta);\n vec->z = sin(theta);\n}\n\nPoint3f BitStream::dumbDownNormal(const Point3f& vec, U8 bitCount)\n{\n U8 buffer[128];\n BitStream temp(buffer, 128);\n\n temp.writeNormalVector(vec, bitCount);\n temp.setBitPosition(0);\n\n Point3f ret;\n temp.readNormalVector(&ret, bitCount);\n return ret;\n}\n\nvoid BitStream::writeNormalVector(const Point3f& vec, U8 angleBitCount, U8 zBitCount)\n{\n // if this is a z up or down vector, just write out a couple of bits\n // if z is -1 or 1, x and y must both be 0\n\n // FIXME: this should test if the vec.z is within zBitCount precision of 1\n // BJG - fixed, but may be inefficient. Lookup table?\n if(writeFlag(fabs(vec.z) >= (1.0f-(1.0f/zBitCount))))\n writeFlag(vec.z < 0);\n else\n {\n // write out the z value and the angle that x and y make around the z axis\n writeSignedFloat( vec.z, zBitCount );\n writeSignedFloat( atan2(vec.x,vec.y) * FloatInverse2Pi, angleBitCount );\n }\n}\n\nvoid BitStream::readNormalVector(Point3f * vec, U8 angleBitCount, U8 zBitCount)\n{\n if(readFlag())\n {\n vec->z = readFlag() ? -1.0f : 1.0f;\n vec->x = 0;\n vec->y = 0;\n }\n else\n {\n vec->z = readSignedFloat(zBitCount);\n \n F32 angle = Float2Pi * readSignedFloat(angleBitCount);\n\n F32 mult = (F32) sqrt(1.0f - vec->z * vec->z);\n vec->x = mult * cos(angle);\n vec->y = mult * sin(angle);\n }\n}\n\n//----------------------------------------------------------------------------\n\nvoid BitStream::clearPointCompression()\n{\n mCompressRelative = false;\n}\n\nvoid BitStream::setPointCompression(const Point3f& p)\n{\n mCompressRelative = true;\n mCompressPoint = p;\n}\n\nstatic U32 gBitCounts[4] = {\n 16, 18, 20, 32\n};\n\nvoid BitStream::writePointCompressed(const Point3f& p,F32 scale)\n{\n // Same # of bits for all axis\n Point3f vec;\n F32 invScale = 1 / scale;\n U32 type;\n if(mCompressRelative)\n {\n\t vec.x = p.x - mCompressPoint.x;\n\t vec.y = p.y - mCompressPoint.y;\n\t vec.z = p.z - mCompressPoint.z;\n\n F32 dist = (F32) sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) * invScale;\n if(dist < (1 << 15))\n type = 0;\n else if(dist < (1 << 17))\n type = 1;\n else if(dist < (1 << 19))\n type = 2;\n else\n type = 3;\n }\n else\n type = 3;\n\n writeInt(type, 2);\n\n if (type != 3)\n {\n type = gBitCounts[type];\n writeSignedInt(S32(vec.x * invScale),type);\n writeSignedInt(S32(vec.y * invScale),type);\n writeSignedInt(S32(vec.z * invScale),type);\n }\n else\n {\n write(p.x);\n write(p.y);\n write(p.z);\n }\n}\n\nvoid BitStream::readPointCompressed(Point3f* p,F32 scale)\n{\n // Same # of bits for all axis\n U32 type = readInt(2);\n\n if(type == 3)\n {\n read(&p->x);\n read(&p->y);\n read(&p->z);\n }\n else\n {\n type = gBitCounts[type];\n p->x = (F32) readSignedInt(type);\n p->y = (F32) readSignedInt(type);\n p->z = (F32) readSignedInt(type);\n\n p->x = mCompressPoint.x + p->x * scale;\n p->y = mCompressPoint.y + p->y * scale;\n p->z = mCompressPoint.z + p->z * scale;\n }\n}\n\nvoid BitStream::readString(char buf[256])\n{\n if(readFlag())\n {\n S32 offset = readInt(8);\n HuffmanStringProcessor::readHuffBuffer(this, mStringBuffer + offset);\n strcpy(buf, mStringBuffer);\n }\n else\n {\n HuffmanStringProcessor::readHuffBuffer(this, buf);\n strcpy(mStringBuffer, buf);\n }\n}\n\nvoid BitStream::writeString(const char *string, U8 maxLen)\n{\n if(!string)\n string = \"\";\n U8 j;\n for(j = 0; j < maxLen && mStringBuffer[j] == string[j] && string[j];j++)\n ;\n strncpy(mStringBuffer + j, string + j, maxLen - j);\n mStringBuffer[maxLen] = 0;\n\n if(writeFlag(j > 2))\n {\n writeInt(j, 8);\n HuffmanStringProcessor::writeHuffBuffer(this, string + j, maxLen - j);\n }\n else\n HuffmanStringProcessor::writeHuffBuffer(this, string, maxLen);\n}\n\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n\n//----------------------------------------------------------------------------\n\nvoid BitStream::readStringTableEntry(StringTableEntry *ste)\n{\n if(mStringTable)\n *ste = mStringTable->readStringTableEntry(this);\n else\n {\n char buf[256];\n readString(buf);\n ste->set(buf);\n }\n}\n\nvoid BitStream::writeStringTableEntry(const StringTableEntry &ste)\n{\n if(mStringTable)\n mStringTable->writeStringTableEntry(this, ste);\n else\n writeString(ste.getString());\n}\n//------------------------------------------------------------------------------\n\nvoid BitStream::hashAndEncrypt(U32 hashDigestSize, U32 encryptStartOffset, SymmetricCipher *theCipher)\n{\n U32 digestStart = getBytePosition();\n setBytePosition(digestStart);\n hash_state hashState;\n\n U8 hash[32];\n\n // do a sha256 hash of the BitStream:\n sha256_init(&hashState);\n sha256_process(&hashState, getBuffer(), digestStart);\n sha256_done(&hashState, hash);\n\n // write the hash into the BitStream:\n write(hashDigestSize, hash);\n\n theCipher->encrypt(getBuffer() + encryptStartOffset,\n getBuffer() + encryptStartOffset,\n getBytePosition() - encryptStartOffset); \n}\n\nbool BitStream::decryptAndCheckHash(U32 hashDigestSize, U32 decryptStartOffset, SymmetricCipher *theCipher)\n{\n U32 bufferSize = getBufferSize();\n U8 *buffer = getBuffer();\n\n if(bufferSize < decryptStartOffset + hashDigestSize)\n return false;\n\n theCipher->decrypt(buffer + decryptStartOffset,\n buffer + decryptStartOffset,\n bufferSize - decryptStartOffset);\n\n hash_state hashState;\n U8 hash[32];\n\n sha256_init(&hashState);\n sha256_process(&hashState, buffer, bufferSize - hashDigestSize);\n sha256_done(&hashState, hash);\n\n bool ret = !memcmp(buffer + bufferSize - hashDigestSize, hash, hashDigestSize);\n if(ret)\n resize(bufferSize - hashDigestSize);\n return ret;\n}\n\n//------------------------------------------------------------------------------\n\nNetError PacketStream::sendto(Socket &outgoingSocket, const Address &addr)\n{\n return outgoingSocket.sendto(addr, buffer, getBytePosition());\n}\n\nNetError PacketStream::recvfrom(Socket &incomingSocket, Address *recvAddress)\n{\n NetError error;\n S32 dataSize;\n error = incomingSocket.recvfrom(recvAddress, buffer, sizeof(buffer), &dataSize);\n setBuffer(buffer, dataSize);\n setMaxSizes(dataSize, 0);\n reset();\n return error;\n}\n\n};\n#include \r\n\r\n#include \"vtPhysXAll.h\"\r\n#include \"pVehicleAll.h\"\r\n#include \"pWorldSettings.h\"\r\n\r\n\r\n#include \r\n#include \r\n\r\n\r\nusing namespace vtTools::AttributeTools;\r\n\r\nvoid pWorld::_construct()\r\n{\r\n\t//mAllocator = new UserAllocator;\r\n\t//mCManager = NxCreateControllerManager(mAllocator);\r\n\tcompartment = NULL;\r\n\r\n}\r\n\r\nvoid pWorld::destroyCloth(CK_ID id)\r\n{\r\n\r\n\tpCloth*cloth = getCloth(id);\r\n\tif (cloth)\r\n\t{\r\n\t\tdelete cloth;\r\n\t}\r\n}\r\n\r\npCloth *pWorld::getCloth(CK_ID id)\r\n{\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tif (id == vCloth->getEntityID() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn vCloth;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\npCloth *pWorld::getCloth(CK3dEntity*reference)\r\n{\r\n\tif (!reference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tif (reference->GetID() == vCloth->getEntityID() )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn vCloth;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\nvoid pWorld::updateClothes()\r\n{\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\t\t\t\tvCloth->updateVirtoolsMesh();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\nint pWorld::getNbBodies()\r\n{\r\n\tint result = 0;\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tresult+= getScene()->getNbActors();\r\n\treturn result;\r\n}\r\nint pWorld::getNbJoints()\r\n{\r\n\tint result = 0;\r\n\tif (!getScene())\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tresult+= getScene()->getNbJoints();\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\nNxShape *pWorld::getShapeByEntityID(CK_ID id)\r\n{\r\n\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCK3dEntity *entA = static_cast(GetPMan()->GetContext()->GetObject(id));\r\n\tif (!entA)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body =static_cast(actor->userData);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = body->getActor()->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)body->getActor()->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\t\tif (info)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\t\t\t\tif (ent == entA )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn s;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npRigidBody* pWorld::getBodyFromSubEntity(CK3dEntity *sub)\r\n{\r\n\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body =static_cast(actor->userData);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tNxU32 nbShapes = body->getActor()->getNbShapes();\r\n\t\t\t\tif ( nbShapes )\r\n\t\t\t\t{\r\n\t\t\t\t\tNxShape ** slist = (NxShape **)body->getActor()->getShapes();\r\n\t\t\t\t\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\t\t\t\t\tif (info)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCK3dEntity *ent = static_cast(GetPMan()->GetContext()->GetObject(info->entID));\r\n\t\t\t\t\t\t\t\tif (ent)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (sub == ent)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\treturn body;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\nvoid pWorld::checkList()\r\n{\r\n\tif (!getScene() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tint nbActors = getScene()->getNbActors();\r\n\tif (!nbActors)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity * ent = static_cast(GetPMan()->GetContext()->GetObject(body->getEntID()));\r\n\t\t\t\tif (!ent)\r\n\t\t\t\t{\r\n\t\t\t\t\tdeleteBody(body);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tint nbClothes = getScene()->getNbCloths();\r\n\tNxCloth** clothes = getScene()->getCloths();\r\n\twhile(nbClothes--)\r\n\t{\r\n\t\tNxCloth* cloth = *clothes++;\r\n\t\tif(cloth->userData != NULL)\r\n\t\t{\r\n\t\t\tpCloth *vCloth = static_cast(cloth->userData);\r\n\t\t\tif (vCloth)\r\n\t\t\t{\r\n\r\n\t\t\t\tCK3dEntity * ent = static_cast(GetPMan()->GetContext()->GetObject(vCloth->getEntityID()));\r\n\t\t\t\tif (!ent)\r\n\t\t\t\t{\r\n\t\t\t\t\tdestroyCloth(vCloth->getEntityID());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nvoid pWorld::deleteBody(pRigidBody*body)\r\n{\r\n\r\n\tif(!body)\r\n\t\treturn;\r\n\r\n\tCK_ID id = body->getEntID();\r\n\tCK3dEntity *ent = (CK3dEntity*)GetPMan()->GetContext()->GetObject(id);\r\n\r\n\tif(!ent)\r\n\t\treturn;\r\n\t\r\n\tGetPMan()->getRemovalList().PushBack(id);\r\n\treturn;\r\n\r\n\tif (body)\r\n\t{\r\n\t\tbody->destroy();\r\n\t\tif (body->getWorld() && body->getWorld()->getScene() )\r\n\t\t{\r\n\r\n\t\t\tfor (int i = 0 ; i < body->getWorld()->getJointFeedbackList().Size(); i++ )\r\n\t\t\t{\r\n\t\t\t\tpBrokenJointEntry *entry = *body->getWorld()->getJointFeedbackList().At(i);\r\n\t\t\t\tif (entry && entry->joint)\r\n\t\t\t\t{\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tSAFE_DELETE(body);\r\n\t}\r\n\tcheckList();\r\n}\r\n\r\nvoid pWorld::deleteJoint(pJoint*joint)\r\n{\r\n\r\n\tif (!joint)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tpWorld *world = joint->getWorld();\r\n\tif (world && world->getScene() )\r\n\t{\r\n\r\n\t\t\t\r\n\t\tfor (int i = 0 ; i < GetPMan()->getJointFeedbackList().Size(); i++ )\r\n\t\t{\r\n\t\t\tpBrokenJointEntry *entry = *world->getJointFeedbackList().At(i);\r\n\t\t\tif (entry && entry->joint == joint)\r\n\t\t\t{\r\n\t\t\t\tGetPMan()->getJointFeedbackList().EraseAt(i);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tjoint->getJoint()->userData = NULL;\r\n\t\tworld->getScene()->releaseJoint(*joint->getJoint());\r\n\t\tdelete joint;\r\n\r\n\t}\r\n}\r\n\r\npJoint* pWorld::getJoint(CK3dEntity *_a, CK3dEntity *_b, JType type)\r\n{\r\n\t\r\n\t\tif (!getScene())\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tpRigidBody *a = GetPMan()->getBody(_a);\r\n\t\tpRigidBody *b = GetPMan()->getBody(_b);\r\n\r\n\r\n\t\t//bodies have already a joint together ? \r\n\t\tif ( !a && !b)\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif ( a == b)\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (a && !a->isValid() )\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (a && !GetPMan()->getWorldByBody(_a))\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (b && !GetPMan()->getWorldByBody(_b) )\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif (b && !b->isValid())\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\r\n\t\tif ( a && b )\r\n\t\t{\r\n\t\t\tpWorld*worldA = GetPMan()->getWorldByBody(_a);\r\n\t\t\tpWorld*worldB = GetPMan()->getWorldByBody(_b);\r\n\t\t\tif (!worldA || !worldB || (worldA!=worldB) || !worldA->isValid() || !worldB->isValid() )\r\n\t\t\t{\r\n\t\t\t\treturn NULL;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tNxU32\tjointCount = getScene()->getNbJoints();\r\n\t\tif (jointCount)\r\n\t\t{\r\n\t\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\t\tgetScene()->resetJointIterator();\r\n\t\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t\t{\r\n\t\t\t\tNxJoint\t*j = getScene()->getNextJoint();\r\n\r\n\t\t\t\tif (type == JT_Any)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\t\t\tif ( mJoint )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == _a && mJoint->GetVTEntB() == _b )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tCK3dEntity *inA = _b;\r\n\t\t\t\t\t\tCK3dEntity *inB = _a;\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == inA && mJoint->GetVTEntB() == inB )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\r\n\t\t\t\tif ( j->getType() == type)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\t\t\tif ( mJoint )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == _a && mJoint->GetVTEntB() == _b )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tCK3dEntity *inA = _b;\r\n\t\t\t\t\t\tCK3dEntity *inB = _a;\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == inA && mJoint->GetVTEntB() == inB )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn mJoint;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn NULL;\r\n}\r\n\r\nbool pWorld::isValid()\r\n{\r\n\treturn getScene() ? true : false;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\npRigidBody*pWorld::getBody(CK3dEntity*ent)\r\n{\r\n\tpRigidBody *result = NULL;\r\n\t\r\n\tif (!ent || !getScene() )\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tint nbActors = getScene()->getNbActors();\r\n\tNxActor** actors = getScene()->getActors();\r\n\twhile(nbActors--)\r\n\t{\r\n\t\tNxActor* actor = *actors++;\r\n\t\tif(actor->userData != NULL)\r\n\t\t{\r\n\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\tif (body && body->getEntID() == ent->GetID() )\r\n\t\t\t{\r\n\t\t\t\treturn body;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif (body && body->isSubShape(ent) )\r\n\t\t\t{\r\n\t\t\t\treturn body;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn NULL;\r\n}\r\n\r\npWorld::pWorld(CK3dEntity* _o)\r\n{\r\n\r\n\tm_bCompletedLastFrame =true;\r\n\tm_fTimeSinceLastCallToSimulate = 0.0f;\r\n\r\n\tm_SleepingSettings = NULL;\r\n\tm_worldSettings =NULL;\r\n\tm_vtReference = _o;\r\n\tmScene = NULL;\r\n\tcontactReport = NULL;\r\n\ttriggerReport = NULL;\r\n\tcontactModify = NULL;\r\n \r\n\tcallMask = XCM_PreProcess | XCM_PostProcess;\r\n\toverrideMask = 0 ;\r\n\tcompartment = NULL;\r\n}\r\npWorld::~pWorld()\r\n{\r\n\t//m_worldSettings = NULL;\r\n\t//m_SleepingSettings =NULL;\r\n\tmScene = NULL;\r\n\t//m_vtReference =NULL;\r\n}\r\nvoid pWorld::destroy()\r\n{\r\n\tif (getScene())\r\n\t{\r\n\t\tgetScene()->setClothUserNotify(NULL);\r\n\t\tgetScene()->setUserTriggerReport(NULL);\r\n\t\tgetScene()->setUserContactModify(NULL);\r\n\t\tgetScene()->setUserActorPairFiltering(NULL);\r\n\t\tgetScene()->setUserContactReport(NULL);\r\n\t\tgetScene()->setUserNotify(NULL);\r\n\r\n\t\tSAFE_DELETE(contactReport);\r\n\t\tSAFE_DELETE(triggerReport);\r\n\t\tSAFE_DELETE(raycastReport);\r\n\t\tSAFE_DELETE(contactModify);\r\n\r\n\t\tif(mDefaultMaterial)\r\n\t\t\tgetScene()->releaseMaterial(*mDefaultMaterial);\r\n\r\n\r\n\t\tif(compartment)\r\n\t\t{\r\n\t\t\t//getScene()->re\r\n\t\t}\r\n\t\t//SAFE_DELETE()\r\n\r\n\r\n\t\tint nbActors = getScene()->getNbActors();\r\n\t\tif (!nbActors)return;\r\n\r\n\r\n\t\tNxActor** actors = getScene()->getActors();\r\n\t\twhile(nbActors--)\r\n\t\t{\r\n\t\t\tNxActor* actor = *actors++;\r\n\t\t\tif(actor->userData != NULL)\r\n\t\t\t{\r\n\t\t\t\tpRigidBody* body = (pRigidBody*)actor->userData;\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\t\t//body->getActor()->getCompartment()->\r\n\t\t\t\t\tbody->destroy();\r\n\t\t\t\t\tif (body->GetVT3DObject())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Body destroyed :\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tSAFE_DELETE(body);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (GetPMan()->getPhysicsSDK())\r\n\t{\r\n\t\tGetPMan()->getPhysicsSDK()->releaseScene(*mScene);\r\n\t\tmScene = NULL;\r\n\t}\r\n\r\n\tif (m_SleepingSettings)\r\n\t{\r\n\t\tdelete m_SleepingSettings;\r\n\t\tm_SleepingSettings = NULL;\r\n\t}\r\n\r\n\tif (m_worldSettings)\r\n\t{\r\n\t\tdelete m_worldSettings;\r\n\t\tm_worldSettings = NULL;\r\n\t}\r\n\t\r\n}\r\nint pWorld::UpdateProperties(DWORD mode,DWORD flags){\treturn 0;}\r\nVxVector pWorld::getGravity()\r\n{ \r\n\tNxVec3 grav;\r\n\tgetScene()->getGravity(grav);\r\n\treturn getFrom(grav);\r\n\r\n}\r\n\r\nvoid pWorld::setGravity(VxVector gravity)\r\n{ \r\n\tgetScene()->setGravity(getFrom(gravity));\r\n}\r\n#ifndef __P_FLUID_FLAGS_\r\n#define __P_FLUID_FLAGS_\r\n\r\n\r\n\r\n/** \\addtogroup Fluid\r\n@{\r\n*/\r\n\r\n/**\r\n\\brief Fluid flags\r\n*/\r\nenum pFluidFlag\r\n{\r\n\t/**\r\n\t\\brief Enables debug visualization for the NxFluid.\r\n\t*/\r\n\tPFF_VISUALIZATION\t\t\t\t\t\t\t= (1<<0),\r\n\r\n\t/**\r\n\t\\brief Disables scene gravity for the NxFluid.\r\n\t*/\r\n\tPFF_DisableGravity\t\t\t\t\t\t= (1<<1),\r\n\r\n\t/**\r\n\t\\brief Enable/disable two way collision of fluid with the rigid body scene.\r\n\tIn either case, fluid is influenced by colliding rigid bodies.\r\n\tIf PFF_CollisionTwoway is not set, rigid bodies are not influenced by \r\n\tcolliding pieces of fluid. Use pFluidDesc.collisionResponseCoefficient to\r\n\tcontrol the strength of the feedback force on rigid bodies.\r\n\r\n\t@see NxFluidDesc.collisionResponseCoefficient\r\n\t*/\r\n\tPFF_CollisionTwoway\t\t\t\t\t\t= (1<<2),\r\n\r\n\r\n\t/**\r\n\t\\brief Enable/disable execution of fluid simulation.\r\n\t*/\r\n\tPFF_Enabled\t\t\t\t\t\t\t\t= (1<<3),\r\n\r\n\t/**\r\n\t\\brief Defines whether this fluid is simulated on the PPU.\r\n\t*/\r\n\tPFF_Hardware\t\t\t\t\t\t\t\t= (1<<4),\r\n\r\n\t/**\r\n\t\\brief Enable/disable particle priority mode. \r\n\tIf enabled, the oldest particles are deleted to keep a certain budget for \r\n\tnew particles. Note that particles which have equal lifetime can get deleted \r\n\tat the same time. In order to avoid this, the particle lifetimes \r\n\tcan be varied randomly.\r\n\r\n\t@see pFluidDesc.numReserveParticles\r\n\t*/\r\n\tPFF_PriorityMode\t\t\t\t\t\t\t= (1<<5),\r\n\r\n\t/**\r\n\t\\brief Defines whether the particles of this fluid should be projected to a plane.\r\n\tThis can be used to build 2D fluid applications, for instance. The projection\r\n\tplane is defined by the parameter pFluidDesc.projectionPlane.\r\n\r\n\t@see pFluidDesc.projectionPlane\r\n\t*/\r\n\tPFF_ProjectToPlane\t\t\t\t\t\t= (1<<6),\r\n\r\n\t/**\r\n\t\\brief Forces fluid static mesh cooking format to parameters given by the fluid descriptor.\r\n\r\n\tCurrently not implemented!\r\n\t*/\r\n\tPFF_ForceStrictCookingFormat\t\t\t= (1<<7),\r\n\r\n};\r\n\r\n/**\r\n\\brief Describes the particle simulation method\r\n\r\nParticles can be treated in two ways: either they are simulated considering\r\ninterparticular forces (SPH), or they are simulated independently.\r\nIn the latter case (with the simulation method set to PFS_NO_PARTICLE_INTERACTION),\r\nyou still get collision between particles and static/dynamic shapes, damping,\r\nacceleration due to gravity, and the user force.\r\n*/\r\nenum pFluidSimulationMethod\r\n{\r\n\t/**\r\n\t\\brief Enable simulation of inter particle forces.\r\n\t*/\r\n\tPFS_SPH\t\t\t\t\t\t= (1<<0),\t\r\n\r\n\t/**\r\n\t\\brief Do not simulate inter particle forces.\r\n\t*/\r\n\tPFS_NoParticleInteraction\t= (1<<1),\r\n\r\n\t/**\r\n\t\\brief Alternate between SPH and simple particles\r\n\t*/\r\n\tPFS_MixedMode\t\t\t\t\t= (1<<2),\r\n};\r\n\r\n/**\r\n\\brief The fluid collision method\r\n*/\r\nenum pFluidCollisionMethod\r\n{\r\n\t/**\r\n\t\\brief collide with static objects\r\n\t*/\r\n\tPFCM_Static = (1<<0),\r\n\t/**\r\n\t\\brief collide with dynamic objects\r\n\t*/\r\n\tPFCM_Dynamic = (1<<1),\r\n};\r\n\r\n/** @} */\r\n\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetHardDecl();\r\nCKERROR CreatePBSetHardProto(CKBehaviorPrototype **pproto);\r\nint PBSetHard(const CKBehaviorContext& behcontext);\r\nCKERROR PBSetHardCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tbbI_Vel,\r\n\tbbI_AVel,\r\n\tbbI_Momentum,\r\n\tbbI_Torque,\r\n\tbbI_Pos,\r\n\tbbI_Rotation,\r\n\t\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap23[] =\r\n{\r\n\r\n\r\n\tBB_SPIN(bbI_Vel,CKPGUID_VECTOR,\"Linear Velocity\",\"\"),\r\n\tBB_SPIN(bbI_AVel,CKPGUID_VECTOR,\"Angular Velocity\",\"\"),\r\n\tBB_SPIN(bbI_Momentum,CKPGUID_VECTOR,\"Linear Momentum\",\"\"),\r\n\tBB_SPIN(bbI_Torque,CKPGUID_VECTOR,\"Angualar Momentum\",\"\"),\r\n\tBB_SPIN(bbI_Pos,CKPGUID_VECTOR,\"Position\",\"\"),\r\n\tBB_SPIN(bbI_Rotation,CKPGUID_QUATERNION,\"Rotation\",\"\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMap23\r\n\r\n//************************************\r\n// Method: FillBehaviorPBSetHardDecl\r\n// FullName: FillBehaviorPBSetHardDecl\r\n// Access: public\r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBSetHardDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBSetHard\");\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Sets momentum,velocities and transformations.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x528d58e0,0x2fca203a));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBSetHardProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBSetHardProto\r\n// FullName: CreatePBSetHardProto\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBSetHardProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBSetHard\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\t/*! \\page PBSetHard \r\n\r\n\tPBSet is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSetHard.png\r\n\r\n\tIn:triggers the process\r\n\t
\r\n\tOut:is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated with the rigid body or its sub shape. \r\n\t
\r\n\t
\r\n\tLinear Velocity: The linear velocity.See pRigidBody::setLinearVelocity().\r\n\t
\r\n\tAngular Velocity: The angular velocity.See pRigidBody::setAngularVelocity().\r\n\t
\r\n\tAgular Momentum: The angular momentum.See pRigidBody::getAngularMomentum().\r\n\t
\r\n\tLinear Momentum: The linear momentum.See pRigidBody::getLinearMomentum(). \r\n\t
\r\n\tPosition: The position.See pRigidBody::setPosition(). \r\n\t
\r\n\tOrientation: The new rotation.See pRigidBody::setRotation(). \r\n\t
\r\n\r\n\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager .\r\n\t
\r\n\t
\r\n\t\r\n\tThe known building block \"Set Position\" has new settings avaiable.\r\n\tEnable there \"Update Physics\" in order to transfer the new position on the body automatically!\r\n\t\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSet.cpp\r\n\t\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBSetHardCB );\r\n\r\n\tBB_EVALUATE_SETTINGS(gPIMAP)\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(PBSetHard);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetHard\r\n// FullName: PBSetHard\r\n// Access: public\r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBSetHard(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object :\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\tif (!world)\r\n\t\t{\r\n\t\t\tif (!body)\tbbErrorME(\"No valid world object found\");\r\n\t\t}\r\n\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tBB_DECLARE_PIMAP;\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/************************************************************************/\r\n\t\tBBSParameter(bbI_Vel);\r\n\t\tBBSParameter(bbI_AVel);\r\n\t\tBBSParameter(bbI_Torque);\r\n\t\tBBSParameter(bbI_Momentum);\r\n\t\tBBSParameter(bbI_Pos);\r\n\t\tBBSParameter(bbI_Rotation);\r\n\t\t\r\n\t\r\n\t\r\n\t\tif (sbbI_Vel)\r\n\t\t{\r\n\t\t\tVxVector velocity= GetInputParameterValue(beh,BB_IP_INDEX(bbI_Vel));\r\n\t\t\tbody->setLinearVelocity(velocity);\r\n\t\t}\r\n\r\n\t\tif (sbbI_AVel)\r\n\t\t{\r\n\t\t\tVxVector aVelocity= GetInputParameterValue(beh,BB_IP_INDEX(bbI_AVel));\r\n\t\t\tbody->setAngularVelocity(aVelocity);\r\n\t\t}\r\n\r\n\t\tif (sbbI_Torque)\r\n\t\t{\r\n\t\t\tVxVector torque= GetInputParameterValue(beh,BB_IP_INDEX(bbI_Torque));\r\n\t\t\tbody->setAngularMomentum(torque);\r\n\t\t}\r\n\t\tif (sbbI_Momentum)\r\n\t\t{\r\n\t\t\tVxVector momentum= GetInputParameterValue(beh,BB_IP_INDEX(bbI_Momentum));\r\n\t\t\tbody->setLinearMomentum(momentum);\r\n\t\t}\r\n\r\n\t\t\r\n\t\tif (sbbI_Pos)\r\n\t\t{\r\n\t\t\tVxVector pos= GetInputParameterValue(beh,BB_IP_INDEX(bbI_Pos));\r\n\t\t\tbody->setPosition(pos,target);\r\n\t\t}\r\n\t\tif (sbbI_Rotation)\r\n\t\t{\r\n\t\t\tVxQuaternion rot= GetInputParameterValue(beh,BB_IP_INDEX(bbI_Rotation));\r\n\t\t\tbody->setRotation(rot,target);\r\n\t\t}\r\n\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBSetHardCB\r\n// FullName: PBSetHardCB\r\n// Access: public\r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBSetHardCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\t\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#ifndef __xDistributedPoint1F_H\r\n#define __xDistributedPoint1F_H\r\n\r\n#include \"xDistributedProperty.h\"\r\n\r\n\r\nclass xDistributedPoint1F : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedPoint1F ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tmLastValue = 0.0f;\r\n\t\t\tmCurrentValue= 0.0f;\r\n\t\t\tmDifference = 0.0f;\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\r\n\t\t~xDistributedPoint1F(){}\r\n\t\t\r\n\r\n\t\tTNL::F32 mLastValue;\r\n\t\tTNL::F32 mCurrentValue;\r\n\t\tTNL::F32 mDifference;\r\n\r\n\t\tTNL::F32 mLastServerValue;\r\n\t\tTNL::F32 mLastServerDifference;\r\n \r\n\t\tbool updateValue(TNL::F32 value,xTimeType currentTime);\r\n\t\tTNL::F32 getDiff(TNL::F32 value);\r\n void pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(TNL::BitStream *stream);\r\n\t\tvoid updateFromServer(TNL::BitStream *stream);\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n \r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t Generic Camera Orbit\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"GeneralCameraOrbit.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorGenericCameraOrbitDecl();\r\nCKERROR CreateGenericCameraOrbitProto(CKBehaviorPrototype **pproto);\r\nint GenericCameraOrbit(const CKBehaviorContext& behcontext);\r\nvoid ProcessGenericInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping);\r\n\r\nCKObjectDeclaration\t*FillBehaviorGenericCameraOrbitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Generic Camera Orbit\");\r\n\tod->SetDescription(\"Makes a Camera orbit round a 3D Entity using input activation.\");\r\n\tod->SetCategory(\"Cameras/Movement\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x104d0913,0x766563dd));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGenericCameraOrbitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tPrototype creation\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR CreateGenericCameraOrbitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Generic Camera Orbit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t// General Description\r\n\tCKERROR error = FillGeneralCameraOrbitProto(proto);\r\n\tif (error != CK_OK)\r\n\t\treturn (error);\r\n\r\n\t// Additionnal Inputs\r\n\tproto->DeclareInput(\"Move Left\");\r\n\tproto->DeclareInput(\"Move Right\");\r\n\tproto->DeclareInput(\"Move Up\");\r\n\tproto->DeclareInput(\"Move Down\");\r\n\tproto->DeclareInput(\"Zoom In\");\r\n\tproto->DeclareInput(\"Zoom Out\");\r\n\r\n\t// Additionnal Local\r\n\tproto->DeclareLocalParameter(\"Returning\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\t// Set the execution functions\r\n\tproto->SetFunction(GenericCameraOrbit);\r\n\tproto->SetBehaviorCallbackFct(GeneralCameraOrbitCallback,CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORCREATE);\r\n\r\n\t// return OK\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tMain Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nint GenericCameraOrbit(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn ( GeneralCameraOrbit(behcontext,ProcessGenericInputs) );\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFunction that process the inputs\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid ProcessGenericInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping)\r\n{\r\n\t// Is the move limited ?\r\n\tCKBOOL Limited = TRUE;\r\n\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\r\n\t// In the behavioral engine, when the BB return CKBR_ACTIVATENEXTFRAME, and\r\n\t// is also called by another BB, it may happpen that it is called two times.\r\n\t// We could use priorities to avoid this problem, but we implement a more\r\n\t// automatic solution with this parameter.\r\n\t// The return will therefore happen after at least one frame without action.\r\n\tCKBOOL Returning = FALSE;\r\n\tbeh->GetLocalParameterValue(LOCAL_RETURNING,&Returning);\r\n\r\n\t////////////////////\r\n\t// Position Update\r\n\t////////////////////\r\n\t// If the users is moving the camera\r\n\tif ( (beh->IsInputActive(INPUT_LEFT) || beh->IsInputActive(INPUT_RIGHT) || beh->IsInputActive(INPUT_UP) || beh->IsInputActive(INPUT_DOWN)) && !stopping)\r\n\t{\r\n\t\t// Not Returning\r\n\t\tif ( Returning ) {\r\n\t\t\tReturning = FALSE;\r\n\t\t\tbeh->SetLocalParameterValue(LOCAL_RETURNING,&Returning);\r\n\t\t}\r\n\r\n\t\t// Get current time dependent speed angle.\r\n\t\tfloat SpeedAngle = 0.87f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_MOVE,&SpeedAngle);\r\n\t\tSpeedAngle *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinH = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_H, &MinH);\r\n\t\r\n\t\t\tfloat MaxH = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_H, &MaxH);\r\n\r\n\t\t\tfloat MinV = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_V, &MinV);\r\n\r\n\t\t\tfloat MaxV = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_V, &MaxV);\r\n\r\n\t\t\tif ( beh->IsInputActive(INPUT_LEFT)\t)\tRotationAngles->x += XMin(SpeedAngle, MaxH - RotationAngles->x);\r\n\t\t\tif ( beh->IsInputActive(INPUT_RIGHT))\tRotationAngles->x -= XMin(SpeedAngle, RotationAngles->x - MinH);\r\n\t\t\tif ( beh->IsInputActive(INPUT_UP)\t)\tRotationAngles->y += XMin(SpeedAngle, MaxV - RotationAngles->y);\r\n\t\t\tif ( beh->IsInputActive(INPUT_DOWN)\t)\tRotationAngles->y -= XMin(SpeedAngle, RotationAngles->y - MinV);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif( beh->IsInputActive(INPUT_LEFT)\t)\tRotationAngles->x += SpeedAngle;\r\n\t\t\tif( beh->IsInputActive(INPUT_RIGHT)\t)\tRotationAngles->x -= SpeedAngle;\r\n\t\t\tif( beh->IsInputActive(INPUT_UP)\t)\tRotationAngles->y += SpeedAngle;\r\n\t\t\tif( beh->IsInputActive(INPUT_DOWN)\t)\tRotationAngles->y -= SpeedAngle;\r\n\t\t}\r\n\r\n\t\t// Deactivates Inputs\r\n\t\tbeh->ActivateInput(INPUT_LEFT,FALSE);\r\n\t\tbeh->ActivateInput(INPUT_RIGHT,FALSE);\r\n\t\tbeh->ActivateInput(INPUT_UP,FALSE);\r\n\t\tbeh->ActivateInput(INPUT_DOWN,FALSE);\r\n\t}\r\n\telse if (Returns && ((RotationAngles->x != 0) || (RotationAngles->y != 0)))\r\n\t{\r\n\t\tif ( !Returning ) {\r\n\t\t\tReturning = TRUE;\r\n\t\t\tbeh->SetLocalParameterValue(LOCAL_RETURNING,&Returning);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tfloat ReturnSpeedAngle = 1.75f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_RETURN, &ReturnSpeedAngle);\r\n\t\tReturnSpeedAngle *= delta / 1000;\r\n\r\n\t\tif( RotationAngles->x < 0 ) RotationAngles->x += XMin(ReturnSpeedAngle, -RotationAngles->x);\r\n\t\tif( RotationAngles->x > 0 ) RotationAngles->x -= XMin(ReturnSpeedAngle, RotationAngles->x);\r\n\t\tif( RotationAngles->y < 0 ) RotationAngles->y += XMin(ReturnSpeedAngle, -RotationAngles->y);\r\n\t\tif( RotationAngles->y > 0 ) RotationAngles->y -= XMin(ReturnSpeedAngle, RotationAngles->y);\r\n\t}\r\n\t// We are stopping and already stopped !\r\n\telse if (stopping)\r\n\t\tRotationAngles->x = INF;\r\n\r\n\r\n\t////////////////\r\n\t// Zoom Update\r\n\t////////////////\r\n\tif ( (beh->IsInputActive(INPUT_ZOOMIN) || beh->IsInputActive(INPUT_ZOOMOUT)) && !stopping)\r\n\t{\r\n\t\tfloat ZoomSpeed = 40.0f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_ZOOM,&ZoomSpeed);\r\n\t\tZoomSpeed *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinZoom = -40.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_ZOOM, &MinZoom);\r\n\r\n\t\t\tfloat MaxZoom = 10.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_ZOOM, &MaxZoom);\r\n\r\n\r\n\t\t\tif( beh->IsInputActive(INPUT_ZOOMIN) ) RotationAngles->z -= XMin(ZoomSpeed, RotationAngles->z + MaxZoom );\r\n\t\t\tif( beh->IsInputActive(INPUT_ZOOMOUT) ) RotationAngles->z += XMin(ZoomSpeed, - MinZoom - RotationAngles->z);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif( beh->IsInputActive(INPUT_ZOOMIN) ) RotationAngles->z -= ZoomSpeed;\r\n\t\t\tif( beh->IsInputActive(INPUT_ZOOMOUT) ) RotationAngles->z += ZoomSpeed;\r\n\t\t}\r\n\r\n\t\t// Deactivates Inputs\r\n\t\tbeh->ActivateInput(INPUT_ZOOMIN,FALSE);\r\n\t\tbeh->ActivateInput(INPUT_ZOOMOUT,FALSE);\r\n\t}\r\n}\r\n\r\n\r\n/* -----------------------------------------------------------------------------\n * See the LICENSE file for information on copyright, usage and redistribution\n * of SWIG, and the README file for authors - http://www.swig.org/release.html.\n *\n * lua.cxx\n *\n * Lua language module for SWIG.\n * ----------------------------------------------------------------------------- */\n\n/* NEW LANGUAGE NOTE:\n * ver001\n this is simply a copy of tcl8.cxx, which has been renamed\n * ver002\n all non essential code commented out, program now does virtually nothing\n it prints to stderr the list of functions to wrap, but does not create\n the XXX_wrap.c file\n * ver003\n added back top(), still prints the list of fns to stderr\n but now creates a rather empty XXX_wrap.c with some basic boilerplate code\n * ver004\n very basic version of functionWrapper()\n also uncommented usage_string() to keep compiler happy\n this will start producing proper looking code soon (I hope)\n produced the wrapper code, but without any type conversion (in or out)\n generates a few warning because of no wrappering\n does not generate SWIG_init()\n reason for this is that lua.swg is empty\n we will need to add code into this to make it work\n * ver005/6\n massive rework, basing work on the pike module instead of tcl\n (pike module it only 1/3 of the size)(though not as complete)\n * ver007\n added simple type checking\n * ver008\n INPUT, OUTPUT, INOUT typemaps handled (though not all types yet)\n * ver009\n class support: ok for basic types, but methods still TDB\n (code is VERY messed up & needs to be cleaned)\n\n\n*/\n\nchar cvsroot_lua_cxx[] = \"$Id: lua.cxx 10076 2007-10-30 06:10:04Z mgossage $\";\n\n#include \"swigmod.h\"\n\n/**** Diagnostics:\n With the #define REPORT(), you can change the amount of diagnostics given\n This helps me search the parse tree & figure out what is going on inside SWIG\n (because its not clear or documented)\n*/\n#define REPORT(T,D)\t\t// no info:\n//#define REPORT(T,D) {Printf(stdout,T\"\\n\");} // only title\n//#define REPORT(T,D) {Printf(stdout,T\"\\n\");display_mapping(D);} // the works\n//#define REPORT(T,D) {Printf(stdout,T\"\\n\");if(D)Swig_print_node(D);} // the works\n\nvoid display_mapping(DOH *d) {\n if (d == 0 || !DohIsMapping(d))\n return;\n for (DohIterator it = DohFirst(d); it.item; it = DohNext(it)) {\n if (DohIsString(it.item))\n Printf(stdout, \" %s = %s\\n\", it.key, it.item);\n else if (DohIsMapping(it.item))\n Printf(stdout, \" %s = \\n\", it.key);\n else if (DohIsSequence(it.item))\n Printf(stdout, \" %s = \\n\", it.key);\n else\n Printf(stdout, \" %s = \\n\", it.key);\n }\n}\n\n\n\n/* NEW LANGUAGE NOTE:***********************************************\n most of the default options are handled by SWIG\n you can add new ones here\n (though for now I have not bothered)\nNEW LANGUAGE NOTE:END ************************************************/\nstatic const char *usage = (char *) \"\\\nLua Options (available with -lua)\\n\\\n (coming soon.)\\n\\n\";\n\n\n\n/* NEW LANGUAGE NOTE:***********************************************\n To add a new language, you need to derive your class from\n Language and the overload various virtual functions\n (more on this as I figure it out)\nNEW LANGUAGE NOTE:END ************************************************/\n\nclass LUA:public Language {\nprivate:\n\n File *f_runtime;\n File *f_header;\n File *f_wrappers;\n File *f_init;\n File *f_initbeforefunc;\n String *PrefixPlusUnderscore;\n String *s_cmd_tab;\t\t// table of command names\n String *s_var_tab;\t\t// table of global variables\n String *s_const_tab;\t\t// table of global constants\n String *s_methods_tab;\t// table of class methods\n String *s_attr_tab;\t\t// table of class atributes\n\n int have_constructor;\n int have_destructor;\n String *destructor_action;\n String *class_name;\n String *constructor_name;\n\n enum {\n NO_CPP,\n VARIABLE,\t \n MEMBER_FUNC,\n CONSTRUCTOR,\n DESTRUCTOR,\n MEMBER_VAR,\n CLASS_CONST,\n STATIC_FUNC,\n STATIC_VAR\n }current;\n\npublic:\n\n /* ---------------------------------------------------------------------\n * LUA()\n *\n * Initialize member data\n * --------------------------------------------------------------------- */\n\n LUA() {\n f_runtime = 0;\n f_header = 0;\n f_wrappers = 0;\n f_init = 0;\n f_initbeforefunc = 0;\n PrefixPlusUnderscore = 0;\n\n s_cmd_tab = s_var_tab = s_const_tab = 0;\n current=NO_CPP; \n }\n\n /* NEW LANGUAGE NOTE:***********************************************\n This is called to initalise the system & read any command line args\n most of this is boilerplate code, except the command line args\n which depends upon what args your code supports\n NEW LANGUAGE NOTE:END ************************************************/\n\n /* ---------------------------------------------------------------------\n * main()\n *\n * Parse command line options and initializes variables.\n * --------------------------------------------------------------------- */\n \n virtual void main(int argc, char *argv[]) {\n\n /* Set location of SWIG library */\n SWIG_library_directory(\"lua\");\n\n /* Look for certain command line options */\n for (int i = 1; i < argc; i++) {\n if (argv[i]) {\n\tif (strcmp(argv[i], \"-help\") == 0) {\t// usage flags\n\t fputs(usage, stderr);\n\t}\n }\n }\n\n/* NEW LANGUAGE NOTE:***********************************************\n This is the boilerplate code, setting a few #defines\n and which lib directory to use\n the SWIG_library_directory() is also boilerplate code\n but it always seems to be the first line of code\nNEW LANGUAGE NOTE:END ************************************************/\n /* Add a symbol to the parser for conditional compilation */\n Preprocessor_define(\"SWIGLUA 1\", 0);\n\n /* Set language-specific configuration file */\n SWIG_config_file(\"lua.swg\");\n\n /* Set typemap language */\n SWIG_typemap_lang(\"lua\");\n\n /* Enable overloaded methods support */\n allow_overloading();\n }\n\n\n\n\n/* NEW LANGUAGE NOTE:***********************************************\n After calling main, SWIG parses the code to wrap (I believe)\n then calls top()\n in this is more boilerplate code to set everything up\n and a call to Language::top()\n which begins the code generations by calling the member fns\n after all that is more boilerplate code to close all down\n (overall there is virtually nothing here that needs to be edited\n just use as is)\nNEW LANGUAGE NOTE:END ************************************************/\n /* ---------------------------------------------------------------------\n * top()\n * --------------------------------------------------------------------- */\n\n virtual int top(Node *n) {\n /* Get the module name */\n String *module = Getattr(n, \"name\");\n\n /* Get the output file name */\n String *outfile = Getattr(n, \"outfile\");\n\n /* Open the output file */\n f_runtime = NewFile(outfile, \"w\");\n if (!f_runtime) {\n FileErrorDisplay(outfile);\n SWIG_exit(EXIT_FAILURE);\n }\n f_init = NewString(\"\");\n f_header = NewString(\"\");\n f_wrappers = NewString(\"\");\n f_initbeforefunc = NewString(\"\");\n\n /* Register file targets with the SWIG file handler */\n Swig_register_filebyname(\"header\", f_header);\n Swig_register_filebyname(\"wrapper\", f_wrappers);\n Swig_register_filebyname(\"runtime\", f_runtime);\n Swig_register_filebyname(\"init\", f_init);\n Swig_register_filebyname(\"initbeforefunc\", f_initbeforefunc);\n\n/* NEW LANGUAGE NOTE:***********************************************\n s_cmd_tab,s_var_tab & s_const_tab hold the names of the fns for\n registering with SWIG.\n These will be filled in when the functions/variables are wrapped &\n then added to the end of the wrappering code\n just before it is written to file\nNEW LANGUAGE NOTE:END ************************************************/\n // Initialize some variables for the object interface\n s_cmd_tab = NewString(\"\");\n s_var_tab = NewString(\"\");\n// s_methods_tab = NewString(\"\");\n s_const_tab = NewString(\"\");\n current=NO_CPP; \n\n /* Standard stuff for the SWIG runtime section */\n Swig_banner(f_runtime);\n// if (NoInclude) {\n// Printf(f_runtime, \"#define SWIG_NOINCLUDE\\n\");\n// }\n\n //String *init_name = NewStringf(\"%(title)s_Init\", module);\n //Printf(f_header, \"#define SWIG_init %s\\n\", init_name);\n //Printf(f_header, \"#define SWIG_name \\\"%s\\\"\\n\", module);\n /* SWIG_import is a special function name for importing within Lua5.1 */\n //Printf(f_header, \"#define SWIG_import luaopen_%s\\n\\n\", module);\n Printf(f_header, \"#define SWIG_name \\\"%s\\\"\\n\", module);\n Printf(f_header, \"#define SWIG_init luaopen_%s\\n\", module);\n Printf(f_header, \"#define SWIG_init_user luaopen_%s_user\\n\\n\", module);\n\n Printf(s_cmd_tab, \"\\nstatic const struct luaL_reg swig_commands[] = {\\n\");\n Printf(s_var_tab, \"\\nstatic swig_lua_var_info swig_variables[] = {\\n\");\n Printf(s_const_tab, \"\\nstatic swig_lua_const_info swig_constants[] = {\\n\");\n Printf(f_wrappers, \"#ifdef __cplusplus\\nextern \\\"C\\\" {\\n#endif\\n\");\n\n /* %init code inclusion, effectively in the SWIG_init function */\n Printf(f_init, \"void SWIG_init_user(lua_State* L)\\n{\\n\");\n Language::top(n);\n Printf(f_init, \"}\\n\");\n\n Printf(f_wrappers, \"#ifdef __cplusplus\\n}\\n#endif\\n\");\n\n // Done. Close up the module & write to the wrappers\n Printv(s_cmd_tab, tab4, \"{0,0}\\n\", \"};\\n\", NIL);\n Printv(s_var_tab, tab4, \"{0,0,0}\\n\", \"};\\n\", NIL);\n Printv(s_const_tab, tab4, \"{0,0,0,0,0,0}\\n\", \"};\\n\", NIL);\n Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);\n SwigType_emit_type_table(f_runtime, f_wrappers);\n\n/* NEW LANGUAGE NOTE:***********************************************\n this basically combines several of the strings together\n and then writes it all to a file\nNEW LANGUAGE NOTE:END ************************************************/\n /* Close all of the files */\n Delete(s_cmd_tab);\n Delete(s_var_tab);\n Delete(s_const_tab);\n Dump(f_header, f_runtime);\n Dump(f_wrappers, f_runtime);\n Dump(f_initbeforefunc, f_runtime);\n Wrapper_pretty_print(f_init, f_runtime);\n Delete(f_header);\n Delete(f_wrappers);\n Delete(f_init);\n Delete(f_initbeforefunc);\n Close(f_runtime);\n Delete(f_runtime);\n\n /* Done */\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * importDirective()\n * ------------------------------------------------------------ */\n\n virtual int importDirective(Node *n) {\n return Language::importDirective(n);\n }\n\n/* NEW LANGUAGE NOTE:***********************************************\n This is it!\n you get this one right, and most of your work is done\n but its going to take soem file to get it working right\n quite a bit of this is generally boilerplate code\n (or stuff I dont understand)\n that which matters will have extra added comments\nNEW LANGUAGE NOTE:END ************************************************/\n /* ---------------------------------------------------------------------\n * functionWrapper()\n *\n * Create a function declaration and register it with the interpreter.\n * --------------------------------------------------------------------- */\n\n virtual int functionWrapper(Node *n) {\n// REPORT(\"functionWrapper\",n);\n\n String *name = Getattr(n, \"name\");\n String *iname = Getattr(n, \"sym:name\");\n SwigType *d = Getattr(n, \"type\");\n ParmList *l = Getattr(n, \"parms\");\n//Printf(stdout,\"functionWrapper %s %s\\n\",name,iname);\n Parm *p;\n String *tm;\n int i;\n//Printf(stdout,\"functionWrapper %s %s %d\\n\",name,iname,current);\n// int returnval=0; // number of arguments returned\n\n String *overname = 0;\n if (Getattr(n, \"sym:overloaded\")) {\n overname = Getattr(n, \"sym:overname\");\n } else {\n if (!addSymbol(iname, n))\n {\n\tPrintf(stderr,\"addSymbol(%s) failed\\n\",iname);\n\treturn SWIG_ERROR;\n }\n }\n\n/* NEW LANGUAGE NOTE:***********************************************\n the wrapper object holds all the wrappering code\n we need to add a couple of local variables\nNEW LANGUAGE NOTE:END ************************************************/\n Wrapper *f = NewWrapper();\n Wrapper_add_local(f, \"SWIG_arg\", \"int SWIG_arg = -1\");\n\n\n String *wname = Swig_name_wrapper(iname);\n if (overname) {\n Append(wname, overname);\n }\n\n/* NEW LANGUAGE NOTE:***********************************************\n the format of a lua fn is:\n static int wrap_XXX(lua_State* L){...}\n this line adds this into the wrappering code\nNEW LANGUAGE NOTE:END ************************************************/\n Printv(f->def, \"static int \", wname, \"(lua_State* L) {\", NIL);\n\n/* NEW LANGUAGE NOTE:***********************************************\n this prints the list of args, eg for a C fn\n int gcd(int x,int y);\n it will print\n int arg1;\n int arg2;\n int result;\nNEW LANGUAGE NOTE:END ************************************************/\n /* Write code to extract function parameters. */\n emit_args(d, l, f);\n\n /* Attach the standard typemaps */\n emit_attach_parmmaps(l, f);\n Setattr(n, \"wrap:parms\", l);\n\n /* Get number of required and total arguments */\n int num_arguments = emit_num_arguments(l);\n int num_required = emit_num_required(l);\n int varargs = emit_isvarargs(l);\n\n /* Which input argument to start with? */\n// int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0;\n\n /* Offset to skip over the attribute name */\n // int offset = (current == MEMBER_VAR) ? 1 : 0;\n\n/* NEW LANGUAGE NOTE:***********************************************\n from here on in, it gets rather hairy\n this is the code to convert from the scripting language to C/C++\n some of the stuff will refer to the typemaps code written in your swig file\n (lua.swg), and some is done in the code here\n I suppose you could do all the conversion on C, but it would be a nightmare to do\nNEW LANGUAGE NOTE:END ************************************************/\n /* Generate code for argument marshalling */\n// String *description = NewString(\"\");\n/* NEW LANGUAGE NOTE:***********************************************\n argument_check is a new feature I added to check types of arguments:\n eg for int gcd(int,int)\n I want to check that arg1 & arg2 really are integers\nNEW LANGUAGE NOTE:END ************************************************/\n String *argument_check = NewString(\"\");\n String *argument_parse = NewString(\"\");\n String *checkfn = NULL;\n// String *numoutputs=NULL;\n char source[64];\n //Printf(argument_check, \"//args must be %d..%d\\n\",num_required,num_arguments);\n Printf(argument_check, \"SWIG_check_num_args(\\\"%s\\\",%d,%d)\\n\",name,num_required,num_arguments);\n for (i = 0, p = l; i < num_arguments; i++) {\n\n while (checkAttribute(p, \"tmap:in:numinputs\", \"0\")) {\n\tp = Getattr(p, \"tmap:in:next\");\n }\n\n SwigType *pt = Getattr(p, \"type\");\n String *ln = Getattr(p, \"lname\");\n\n /* Look for an input typemap */\n sprintf(source, \"%d\", i + 1);\n if ((tm = Getattr(p, \"tmap:in\"))) {\n\tReplaceall(tm, \"$source\", source);\n\tReplaceall(tm, \"$target\", ln);\n\tReplaceall(tm, \"$input\", source);\n\tSetattr(p, \"emit:input\", source);\n\n/* NEW LANGUAGE NOTE:***********************************************\n look for a 'checkfn' typemap\n this an additional parameter added to the in typemap\n if found the type will be tested for\n this will result in code either in the\n argument_check or argument_parse string\nNEW LANGUAGE NOTE:END ************************************************/\n\tif ((checkfn = Getattr(p, \"tmap:in:checkfn\"))) {\n\t if (i < num_required) {\n\t Printf(argument_check, \"if(!%s(L,%s))\", checkfn, source);\n\t } else {\n\t Printf(argument_check, \"if(lua_gettop(L)>=%s && !%s(L,%s))\", source, checkfn, source);\n\t }\n\t Printf(argument_check, \" SWIG_fail_arg(\\\"%s\\\",%s,\\\"%s\\\");\\n\", name, source, SwigType_str(pt, 0));\n\t}\n/* NEW LANGUAGE NOTE:***********************************************\n lua states the number of arguments passed to a function using the fn\n lua_gettop()\n we can use this to deal with default arguments\nNEW LANGUAGE NOTE:END ************************************************/\n\tif (i < num_required) {\n\t Printf(argument_parse, \"%s\\n\", tm);\n\t} else {\n\t Printf(argument_parse, \"if(lua_gettop(L)>=%s){%s}\\n\", source, tm);\n\t}\n\tp = Getattr(p, \"tmap:in:next\");\n\tcontinue;\n } else {\n/* NEW LANGUAGE NOTE:***********************************************\n\t\t // why is this code not called when I dont have a typemap?\n\t\t // instead of giving a warning, no code is generated\nNEW LANGUAGE NOTE:END ************************************************/\n\tSwig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, \"Unable to use type %s as a function argument.\\n\", SwigType_str(pt, 0));\n\tbreak;\n }\n\n p = nextSibling(p);\n }\n\n // add all argcheck code\n Printv(f->code, argument_check, argument_parse, NIL);\n\n /* Check for trailing varargs */\n if (varargs) {\n if (p && (tm = Getattr(p, \"tmap:in\"))) {\n\tReplaceall(tm, \"$input\", \"varargs\");\n\tPrintv(f->code, tm, \"\\n\", NIL);\n }\n }\n\n /* Insert constraint checking code */\n for (p = l; p;) {\n if ((tm = Getattr(p, \"tmap:check\"))) {\n\tReplaceall(tm, \"$target\", Getattr(p, \"lname\"));\n\tPrintv(f->code, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:check:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* Insert cleanup code */\n String *cleanup = NewString(\"\");\n for (p = l; p;) {\n if ((tm = Getattr(p, \"tmap:freearg\"))) {\n\tReplaceall(tm, \"$source\", Getattr(p, \"lname\"));\n\tPrintv(cleanup, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:freearg:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* Insert argument output code */\n String *outarg = NewString(\"\");\n for (p = l; p;) {\n if ((tm = Getattr(p, \"tmap:argout\"))) {\n// // managing the number of returning variables\n// if (numoutputs=Getattr(p,\"tmap:argout:numoutputs\")){\n// int i=GetInt(p,\"tmap:argout:numoutputs\");\n// printf(\"got argout:numoutputs of %d\\n\",i);\n// returnval+=GetInt(p,\"tmap:argout:numoutputs\");\n// }\n// else returnval++;\n\tReplaceall(tm, \"$source\", Getattr(p, \"lname\"));\n\tReplaceall(tm, \"$target\", \"result\");\n\tReplaceall(tm, \"$arg\", Getattr(p, \"emit:input\"));\n\tReplaceall(tm, \"$input\", Getattr(p, \"emit:input\"));\n\tPrintv(outarg, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:argout:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* Emit the function call */\n emit_action(n, f);\n\n/* NEW LANGUAGE NOTE:***********************************************\nFIXME:\nreturns 1 if there is a void return type\nthis is because there is a typemap for void\nNEW LANGUAGE NOTE:END ************************************************/\n Printv(f->code, \"SWIG_arg=0;\\n\", NIL);\n // Return value if necessary\n if ((tm = Swig_typemap_lookup_new(\"out\", n, \"result\", 0))) {\n // managing the number of returning variables\n// if (numoutputs=Getattr(tm,\"numoutputs\")){\n// int i=GetInt(tm,\"numoutputs\");\n// printf(\"return numoutputs %d\\n\",i);\n// returnval+=GetInt(tm,\"numoutputs\");\n// }\n// else returnval++;\n Replaceall(tm, \"$source\", \"result\");\n if (GetFlag(n, \"feature:new\")) {\n\tReplaceall(tm, \"$owner\", \"1\");\n } else {\n\tReplaceall(tm, \"$owner\", \"0\");\n }\n Printf(f->code, \"%s\\n\", tm);\n// returnval++;\n } else {\n Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, \"Unable to use return type %s in function %s.\\n\", SwigType_str(d, 0), name);\n }\n\n /* Output argument output code */\n Printv(f->code, outarg, NIL);\n\n /* Output cleanup code */\n Printv(f->code, cleanup, NIL);\n\n /* Look to see if there is any newfree cleanup code */\n if (GetFlag(n, \"feature:new\")) {\n if ((tm = Swig_typemap_lookup_new(\"newfree\", n, \"result\", 0))) {\n\tReplaceall(tm, \"$source\", \"result\");\n\tPrintf(f->code, \"%s\\n\", tm);\n }\n }\n\n /* See if there is any return cleanup code */\n if ((tm = Swig_typemap_lookup_new(\"ret\", n, \"result\", 0))) {\n Replaceall(tm, \"$source\", \"result\");\n Printf(f->code, \"%s\\n\", tm);\n }\n\n\n /* Close the function */\n Printv(f->code, \"return SWIG_arg;\\n\", NIL);\n // add the failure cleanup code:\n Printv(f->code, \"\\nif(0) SWIG_fail;\\n\", NIL);\n Printv(f->code, \"\\nfail:\\n\", NIL);\n Printv(f->code, \"$cleanup\", \"lua_error(L);\\n\", NIL);\n Printv(f->code, \"return SWIG_arg;\\n\", NIL);\n Printf(f->code, \"}\\n\");\n\n /* Substitute the cleanup code */\n Replaceall(f->code, \"$cleanup\", cleanup);\n\n /* Substitute the function name */\n Replaceall(f->code, \"$symname\", iname);\n Replaceall(f->code, \"$result\", \"result\");\n\n /* Dump the function out */\n Wrapper_print(f, f_wrappers);\n\n Setattr(n, \"wrap:name\", wname);\t// you need this to make the overloading work\n\n/* NEW LANGUAGE NOTE:***********************************************\nregister the function in SWIG\ndifferent language mappings seem to use different ideas\nNEW LANGUAGE NOTE:END ************************************************/\n /* Now register the function with the interpreter. */\n if (!Getattr(n, \"sym:overloaded\")) {\n// add_method(n, iname, wname, description);\n if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns\n Printv(s_cmd_tab, tab4, \"{ \\\"\", iname, \"\\\", \", Swig_name_wrapper(iname), \"},\\n\", NIL);\n// Printv(s_cmd_tab, tab4, \"{ SWIG_prefix \\\"\", iname, \"\\\", (swig_wrapper_func) \", Swig_name_wrapper(iname), \"},\\n\", NIL);\n } else {\n// Setattr(n,\"wrap:name\", wname);\n if (!Getattr(n, \"sym:nextSibling\")) {\n\tdispatchFunction(n);\n }\n }\n\n Delete(argument_check);\n Delete(argument_parse);\n\n Delete(cleanup);\n Delete(outarg);\n// Delete(description);\n Delete(wname);\n DelWrapper(f);\n\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * dispatchFunction()\n *\n * Emit overloading dispatch function\n * ------------------------------------------------------------ */\n\n/* NEW LANGUAGE NOTE:***********************************************\nThis is an extra function used for overloading of functions\nit checks the args & then calls the relevant fn\nnost of the real work in again typemaps:\nlook for %typecheck(SWIG_TYPECHECK_*) in the .swg file\nNEW LANGUAGE NOTE:END ************************************************/\n void dispatchFunction(Node *n) {\n /* Last node in overloaded chain */\n\n int maxargs;\n String *tmp = NewString(\"\");\n String *dispatch = Swig_overload_dispatch(n, \"return %s(L);\", &maxargs);\n\n /* Generate a dispatch wrapper for all overloaded functions */\n\n Wrapper *f = NewWrapper();\n String *symname = Getattr(n, \"sym:name\");\n String *wname = Swig_name_wrapper(symname);\n\n//Printf(stdout,\"Swig_overload_dispatch %s %s '%s' %d\\n\",symname,wname,dispatch,maxargs);\n\n Printv(f->def, \"static int \", wname, \"(lua_State* L) {\", NIL);\n Wrapper_add_local(f, \"argc\", \"int argc\");\n Printf(tmp, \"int argv[%d]={1\", maxargs + 1);\n for (int i = 1; i <= maxargs; i++) {\n Printf(tmp, \",%d\", i + 1);\n }\n Printf(tmp, \"}\");\n Wrapper_add_local(f, \"argv\", tmp);\n Printf(f->code, \"argc = lua_gettop(L);\\n\");\n\n Replaceall(dispatch, \"$args\", \"self,args\");\n Printv(f->code, dispatch, \"\\n\", NIL);\n Printf(f->code, \"lua_pushstring(L,\\\"No matching function for overloaded '%s'\\\");\\n\", symname);\n Printf(f->code, \"lua_error(L);return 0;\\n\");\n Printv(f->code, \"}\\n\", NIL);\n Wrapper_print(f, f_wrappers);\n //add_method(symname,wname,0);\n if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns\n Printv(s_cmd_tab, tab4, \"{ \\\"\", symname, \"\\\",\", wname, \"},\\n\", NIL);\n\n DelWrapper(f);\n Delete(dispatch);\n Delete(tmp);\n Delete(wname);\n }\n\n\n /* ------------------------------------------------------------\n * variableWrapper()\n * ------------------------------------------------------------ */\n\n virtual int variableWrapper(Node *n) {\n/* NEW LANGUAGE NOTE:***********************************************\nLanguage::variableWrapper(n) will generate two wrapper fns\nFoo_get & Foo_set by calling functionWrapper()\nso we will just add these into the variable lists\nideally we should not have registered these as functions,\nonly WRT this variable will look into this later.\nNEW LANGUAGE NOTE:END ************************************************/\n// REPORT(\"variableWrapper\", n);\n String *iname = Getattr(n, \"sym:name\");\n current=VARIABLE;\n // let SWIG generate the wrappers\n int result = Language::variableWrapper(n);\n current=NO_CPP;\n // normally SWIG will generate 2 wrappers, a get and a set\n // but in certain scenarios (immutable, or if its arrays), it will not\n String *getName = Swig_name_wrapper(Swig_name_get(iname));\n String *setName = 0;\n // checking whether it can be set to or not appears to be a very error prone issue\n // I refered to the Language::variableWrapper() to find this out\n bool assignable=is_assignable(n) ? true : false;\n SwigType *type = Getattr(n, \"type\");\n String *tm = Swig_typemap_lookup_new(\"globalin\", n, iname, 0);\n if (!tm && SwigType_isarray(type))\n assignable=false;\n Delete(tm);\n \n if (assignable) {\n setName = Swig_name_wrapper(Swig_name_set(iname));\n } else {\n // how about calling a 'this is not settable' error message?\n setName = NewString(\"SWIG_Lua_set_immutable\"); // error message\n //setName = NewString(\"0\");\n }\n // register the variable\n Printf(s_var_tab, \"%s{ \\\"%s\\\", %s, %s },\\n\", tab4, iname, getName, setName);\n Delete(getName);\n Delete(setName);\n return result;\n }\n\n /* ------------------------------------------------------------\n * constantWrapper()\n * ------------------------------------------------------------ */\n virtual int constantWrapper(Node *n) {\n// REPORT(\"constantWrapper\", n);\n String *name = Getattr(n, \"name\");\n String *iname = Getattr(n, \"sym:name\");\n //String *nsname = !nspace ? Copy(iname) : NewStringf(\"%s::%s\",ns_name,iname);\n String *nsname = Copy(iname);\n SwigType *type = Getattr(n, \"type\");\n String *rawval = Getattr(n, \"rawval\");\n String *value = rawval ? rawval : Getattr(n, \"value\");\n String *tm;\n\n if (!addSymbol(iname, n))\n return SWIG_ERROR;\n //if (nspace) Setattr(n,\"sym:name\",nsname);\n\n /* Special hook for member pointer */\n if (SwigType_type(type) == T_MPOINTER) {\n String *wname = Swig_name_wrapper(iname);\n Printf(f_wrappers, \"static %s = %s;\\n\", SwigType_str(type, wname), value);\n value = Char(wname);\n }\n\n if ((tm = Swig_typemap_lookup_new(\"consttab\", n, name, 0))) {\n Replaceall(tm, \"$source\", value);\n Replaceall(tm, \"$target\", name);\n Replaceall(tm, \"$value\", value);\n Replaceall(tm, \"$nsname\", nsname);\n Printf(s_const_tab, \"%s,\\n\", tm);\n } else if ((tm = Swig_typemap_lookup_new(\"constcode\", n, name, 0))) {\n Replaceall(tm, \"$source\", value);\n Replaceall(tm, \"$target\", name);\n Replaceall(tm, \"$value\", value);\n Replaceall(tm, \"$nsname\", nsname);\n Printf(f_init, \"%s\\n\", tm);\n } else {\n Delete(nsname);\n Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, \"Unsupported constant value.\\n\");\n return SWIG_NOWRAP;\n }\n Delete(nsname);\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * nativeWrapper()\n * ------------------------------------------------------------ */\n\n virtual int nativeWrapper(Node *n) {\n// REPORT(\"nativeWrapper\", n);\n String *symname = Getattr(n, \"sym:name\");\n String *wrapname = Getattr(n, \"wrap:name\");\n if (!addSymbol(wrapname, n))\n return SWIG_ERROR;\n\n Printv(s_cmd_tab, tab4, \"{ \\\"\", symname, \"\\\",\", wrapname, \"},\\n\", NIL);\n // return Language::nativeWrapper(n); // this does nothing...\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * enumDeclaration()\n * ------------------------------------------------------------ */\n\n virtual int enumDeclaration(Node *n) {\n return Language::enumDeclaration(n);\n }\n\n /* ------------------------------------------------------------\n * enumvalueDeclaration()\n * ------------------------------------------------------------ */\n\n virtual int enumvalueDeclaration(Node *n) {\n return Language::enumvalueDeclaration(n);\n }\n\n /* ------------------------------------------------------------\n * classDeclaration()\n * ------------------------------------------------------------ */\n\n virtual int classDeclaration(Node *n) {\n return Language::classDeclaration(n);\n }\n\n /* ------------------------------------------------------------\n * classHandler()\n * ------------------------------------------------------------ */\n\n virtual int classHandler(Node *n) {\n REPORT(\"classHandler\", n);\n\n String *mangled_classname = 0;\n String *real_classname = 0;\n\n constructor_name = 0;\n have_constructor = 0;\n have_destructor = 0;\n destructor_action = 0;\n\n class_name = Getattr(n, \"sym:name\");\n if (!addSymbol(class_name, n))\n return SWIG_ERROR;\n\n real_classname = Getattr(n, \"name\");\n mangled_classname = Swig_name_mangle(real_classname);\n\n // not sure exactly how this workswhat this works,\n // but tcl has a static hashtable of all classes emitted and then only emits code for them once.\n // this fixes issues in test suites: template_default2 & template_specialization\n static Hash *emitted = NewHash();\n if (Getattr(emitted, mangled_classname))\n return SWIG_NOWRAP;\n Setattr(emitted, mangled_classname, \"1\");\n\n s_attr_tab = NewString(\"\");\n Printf(s_attr_tab, \"static swig_lua_attribute swig_\");\n Printv(s_attr_tab, mangled_classname, \"_attributes[] = {\\n\", NIL);\n\n s_methods_tab = NewString(\"\");\n Printf(s_methods_tab, \"static swig_lua_method swig_\");\n Printv(s_methods_tab, mangled_classname, \"_methods[] = {\\n\", NIL);\n\n // Generate normal wrappers\n Language::classHandler(n);\n\n SwigType *t = Copy(Getattr(n, \"name\"));\n SwigType_add_pointer(t);\n\n // Catch all: eg. a class with only static functions and/or variables will not have 'remembered'\n String *wrap_class = NewStringf(\"&_wrap_class_%s\", mangled_classname);\n SwigType_remember_clientdata(t, wrap_class);\n\n String *rt = Copy(Getattr(n, \"classtype\"));\n SwigType_add_pointer(rt);\n\n // Register the class structure with the type checker\n // Printf(f_init,\"SWIG_TypeClientData(SWIGTYPE%s, (void *) &_wrap_class_%s);\\n\", SwigType_manglestr(t), mangled_classname);\n if (have_destructor) {\n Printv(f_wrappers, \"static void swig_delete_\", class_name, \"(void *obj) {\\n\", NIL);\n if (destructor_action) {\n\tPrintv(f_wrappers, SwigType_str(rt, \"arg1\"), \" = (\", SwigType_str(rt, 0), \") obj;\\n\", NIL);\n\tPrintv(f_wrappers, destructor_action, NIL);\n } else {\n\tif (CPlusPlus) {\n\t Printv(f_wrappers, \" delete (\", SwigType_str(rt, 0), \") obj;\\n\", NIL);\n\t} else {\n\t Printv(f_wrappers, \" free((char *) obj);\\n\", NIL);\n\t}\n }\n Printf(f_wrappers, \"}\\n\");\n }\n\n Printf(s_methods_tab, \" {0,0}\\n};\\n\");\n Printv(f_wrappers, s_methods_tab, NIL);\n\n Printf(s_attr_tab, \" {0,0,0}\\n};\\n\");\n Printv(f_wrappers, s_attr_tab, NIL);\n\n Delete(s_methods_tab);\n Delete(s_attr_tab);\n\n // Handle inheritance\n // note: with the idea of class hireachied spread over multiple modules\n // cf test-suite: imports.i\n // it is not possible to just add the pointers to the base classes to the code\n // (as sometimes these classes are not present)\n // therefore we instead hold the name of the base class and a null pointer\n // at runtime: we can query the swig type manager & see if the class exists\n // if so, we can get the pointer to the base class & replace the null pointer\n // if the type does not exist, then we cannot... \n String *base_class = NewString(\"\");\n String *base_class_names = NewString(\"\");\n\n List *baselist = Getattr(n, \"bases\");\n if (baselist && Len(baselist)) {\n Iterator b;\n int index = 0;\n b = First(baselist);\n while (b.item) {\n\tString *bname = Getattr(b.item, \"name\");\n\tif ((!bname) || GetFlag(b.item, \"feature:ignore\") || (!Getattr(b.item, \"module\"))) {\n\t b = Next(b);\n\t continue;\n\t}\n\t// old code: (used the pointer to the base class)\n\t//String *bmangle = Swig_name_mangle(bname);\n\t//Printf(base_class, \"&_wrap_class_%s\", bmangle);\n\t//Putc(',', base_class);\n\t//Delete(bmangle);\n\t// new code: stores a null pointer & the name\n\tPrintf(base_class, \"0,\");\n\tPrintf(base_class_names, \"\\\"%s *\\\",\", SwigType_namestr(bname));\n\n\tb = Next(b);\n\tindex++;\n }\n }\n\n Printv(f_wrappers, \"static swig_lua_class *swig_\", mangled_classname, \"_bases[] = {\", base_class, \"0};\\n\", NIL);\n Delete(base_class);\n Printv(f_wrappers, \"static char *swig_\", mangled_classname, \"_base_names[] = {\", base_class_names, \"0};\\n\", NIL);\n Delete(base_class_names);\n\n Printv(f_wrappers, \"static swig_lua_class _wrap_class_\", mangled_classname, \" = { \\\"\", class_name, \"\\\", &SWIGTYPE\", SwigType_manglestr(t), \",\", NIL);\n\n if (have_constructor) {\n Printf(f_wrappers, \"%s\", Swig_name_wrapper(Swig_name_construct(constructor_name)));\n Delete(constructor_name);\n constructor_name = 0;\n } else {\n Printf(f_wrappers, \"0\");\n }\n\n if (have_destructor) {\n Printv(f_wrappers, \", swig_delete_\", class_name, NIL);\n } else {\n Printf(f_wrappers, \",0\");\n }\n Printf(f_wrappers, \", swig_%s_methods, swig_%s_attributes, swig_%s_bases, swig_%s_base_names };\\n\\n\", mangled_classname, mangled_classname, mangled_classname, mangled_classname);\n \n// Printv(f_wrappers, \", swig_\", mangled_classname, \"_methods, swig_\", mangled_classname, \"_attributes, swig_\", mangled_classname, \"_bases };\\n\\n\", NIL);\n// Printv(s_cmd_tab, tab4, \"{ SWIG_prefix \\\"\", class_name, \"\\\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_\", mangled_classname, \"},\\n\", NIL);\n Delete(t);\n Delete(mangled_classname);\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * memberfunctionHandler()\n * ------------------------------------------------------------ */\n\n virtual int memberfunctionHandler(Node *n) {\n String *name = Getattr(n, \"name\");\n String *iname = GetChar(n, \"sym:name\");\n//Printf(stdout,\"memberfunctionHandler %s %s\\n\",name,iname);\n\n String *realname, *rname;\n\n current = MEMBER_FUNC;\n Language::memberfunctionHandler(n);\n current = NO_CPP;\n\n realname = iname ? iname : name;\n rname = Swig_name_wrapper(Swig_name_member(class_name, realname));\n if (!Getattr(n, \"sym:nextSibling\")) {\n Printv(s_methods_tab, tab4, \"{\\\"\", realname, \"\\\", \", rname, \"}, \\n\", NIL);\n }\n Delete(rname);\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * membervariableHandler()\n * ------------------------------------------------------------ */\n\n virtual int membervariableHandler(Node *n) {\n// REPORT(\"membervariableHandler\",n);\n String *symname = Getattr(n, \"sym:name\");\n String *gname, *sname;\n\n current = MEMBER_VAR;\n Language::membervariableHandler(n);\n current = NO_CPP;\n gname = Swig_name_wrapper(Swig_name_get(Swig_name_member(class_name, symname)));\n if (!GetFlag(n, \"feature:immutable\")) {\n sname = Swig_name_wrapper(Swig_name_set(Swig_name_member(class_name, symname)));\n } else {\n //sname = NewString(\"0\");\n sname = NewString(\"SWIG_Lua_set_immutable\"); // error message\n }\n Printf(s_attr_tab,\"%s{ \\\"%s\\\", %s, %s},\\n\",tab4,symname,gname,sname);\n Delete(gname);\n Delete(sname);\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * constructorHandler()\n *\n * Method for adding C++ member constructor\n * ------------------------------------------------------------ */\n\n virtual int constructorHandler(Node *n) {\n// REPORT(\"constructorHandler\", n);\n current = CONSTRUCTOR;\n Language::constructorHandler(n);\n current = NO_CPP;\n constructor_name = NewString(Getattr(n, \"sym:name\"));\n have_constructor = 1;\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * destructorHandler()\n * ------------------------------------------------------------ */\n\n virtual int destructorHandler(Node *n) {\n current = DESTRUCTOR;\n Language::destructorHandler(n);\n current = NO_CPP;\n have_destructor = 1;\n destructor_action = Getattr(n, \"wrap:action\");\n return SWIG_OK;\n }\n\n /* -----------------------------------------------------------------------\n * staticmemberfunctionHandler()\n *\n * Wrap a static C++ function\n * ---------------------------------------------------------------------- */\n\n virtual int staticmemberfunctionHandler(Node *n) {\n current = STATIC_FUNC;\n return Language::staticmemberfunctionHandler(n);\n current = NO_CPP;\n }\n\n /* ------------------------------------------------------------\n * memberconstantHandler()\n *\n * Create a C++ constant\n * ------------------------------------------------------------ */\n\n virtual int memberconstantHandler(Node *n) {\n// REPORT(\"memberconstantHandler\",n);\n return Language::memberconstantHandler(n);\n }\n\n /* ---------------------------------------------------------------------\n * staticmembervariableHandler()\n * --------------------------------------------------------------------- */\n\n virtual int staticmembervariableHandler(Node *n) {\n// REPORT(\"staticmembervariableHandler\",n);\n current = STATIC_VAR;\n return Language::staticmembervariableHandler(n);\n current = NO_CPP;\n }\n\n /* ---------------------------------------------------------------------\n * external runtime generation\n * --------------------------------------------------------------------- */\n\n /* This is to support the usage\n SWIG -external-runtime \n The code consists of two functions:\n String *runtimeCode() // returns a large string with all the runtimes in\n String *defaultExternalRuntimeFilename() // returns the default filename\n I am writing a generic solution, even though SWIG-Lua only has one file right now...\n */\n String *runtimeCode() {\n String *s = NewString(\"\");\n const char *filenames[] = { \"luarun.swg\", 0 };\t// must be 0 termiated\n String *sfile;\n for (int i = 0; filenames[i] != 0; i++) {\n sfile = Swig_include_sys(filenames[i]);\n if (!sfile) {\n\tPrintf(stderr, \"*** Unable to open '%s'\\n\", filenames[i]);\n } else {\n\tAppend(s, sfile);\n\tDelete(sfile);\n }\n }\n\n return s;\n }\n\n String *defaultExternalRuntimeFilename() {\n return NewString(\"swigluarun.h\");\n }\n};\n\n/* NEW LANGUAGE NOTE:***********************************************\n in order to add you language into swig, you need to make the following changes:\n - write this file (obviously)\n - add into the makefile (not 100% clear on how to do this)\n - edit swigmain.cxx to add your module\n\nnear the top of swigmain.cxx, look for this code & add you own codes\n======= begin change ==========\nextern \"C\" {\n Language *swig_tcl(void);\n Language *swig_python(void);\n //etc,etc,etc...\n Language *swig_lua(void);\t// this is my code\n}\n\n //etc,etc,etc...\n\nswig_module modules[] = {\n {\"-guile\", swig_guile, \"Guile\"},\n {\"-java\", swig_java, \"Java\"},\n //etc,etc,etc...\n {\"-Lua\", swig_lua, \"Lua\"},\t// this is my code\n {NULL, NULL, NULL}\t// this must come at the end of the list\n};\n======= end change ==========\n\nThis is all that is needed\n\nNEW LANGUAGE NOTE:END ************************************************/\n\n/* -----------------------------------------------------------------------------\n * swig_lua() - Instantiate module\n * ----------------------------------------------------------------------------- */\n\nextern \"C\" Language *swig_lua(void) {\n return new LUA();\n}\n#ifndef SOFT_BODY_MATH_H\r\n\r\n#define SOFT_BODY_MATH_H\r\n\r\n#include \r\n#include \r\n\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nbool SBM_rayIntersectsTriangle(const float *point,const float *direction,const float *v0,const float *v1,const float *v2,float &t);\r\nfloat SBM_computeBoundingSphere(unsigned int vcount,const float *points,float *center);\r\nfloat SBM_computeSphereVolume(float r);\r\nbool SBM_rayIntersectsSphere(const float *point,const float *direction,const float *center,float radius,float &t);\r\n\r\n\r\n}; // END OF SOFTBODY NAMESPACE\r\n\r\n#endif\r\n/******************************************************************************\r\nFile : CustomPlayer.h\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#if !defined(CUSTOMPLAYER_H)\r\n#define CUSTOMPLAYER_H\r\n\r\n\r\n//#include \"resourceplayer.h\"\r\n#include \"CKAll.h\"\r\n\r\n\r\n#include \r\n#include \r\n\r\n#include \"CustomPlayerStructs.h\"\r\n\r\n//#include \"CustomPlayerApp.h\"\r\n\r\n/*************************************************************************\r\nSummary: This class defines the implementation of the Virtools Runtime/Player.\r\n\r\nDescription: This class provides member functions for initializing the\r\nvirtools runtime and for running it.\r\n\r\nRemarks: This class is a singleton. It means there is only one instance of it\r\nand you cannot instanciate it. To get an instance of the class use\r\nCCustomPlayer::Instance.\r\n\r\nSee also: CCustomPlayerApp, Instance.\r\n*************************************************************************/\r\nclass MODULE_API CCustomPlayer\r\n{\r\npublic :\r\n\r\n\t/*************************************************************************\r\n\tSummary: Retrieve the unique instance of the player.\r\n\t*************************************************************************/\r\n\tstatic CCustomPlayer& Instance();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Release all data which has been created during the initializating\r\n\tand the execution of the player.\r\n\t*************************************************************************/\r\n\t~CCustomPlayer();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Initialize the player.\r\n\r\n\tDescription: This function intialize the virtools engine (ck, render engine, ...) and load\r\n\tthe composition\r\n\r\n\tParameters:\r\n\t\tiMainWindow: the main window of the application.\r\n\t\tiRenderWindow: the render window.\r\n\t\tiConfig: the configuration of the player (see EConfigPlayer).\r\n\t\tiData: pointer to a string (if iDataSize==0) containing the name of the filename\r\n\t\tto load or pointer to the memory where the application is located (if iDataSize!=0).\r\n\t\tiDataSize: Size of the memory where the application is located if it is alredy in memory (can be null).\r\n\t*************************************************************************/\r\n\tBOOL InitPlayer(HWND iMainWindow, HWND iRenderWindow, int iConfig, const void* iData, int iDataSize);\r\n\r\n\tvoid Terminate(int flags);\r\n\r\n\r\n\t\r\n\t/*************************************************************************\r\n\tSummary: Initialize the engine.\r\n\r\n\tDescription: This function intialize the virtools engine (ck, render engine, ...) \r\n\r\n\t*************************************************************************/\r\n\tint InitEngine(HWND iMainWindow);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Play the composition.\r\n\t*************************************************************************/\r\n\tvoid Play();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Pause the composition.\r\n\t*************************************************************************/\r\n\tvoid Pause();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Reset the composition and play it.\r\n\t*************************************************************************/\r\n\tvoid Reset();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Process one frame of the compisition\r\n\t*************************************************************************/\r\n\tBOOL Process(int iConfig);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Switch from fullscreen/windowed to windowed/fullscreen.\r\n\r\n\tRemarks: The player try to retrieve the resolution (fullscreen or windowed)\r\n\tfrom level attributes before switching.\r\n\t*************************************************************************/\r\n\tBOOL SwitchFullscreen();\r\n\tBOOL SwitchFullscreen(BOOL value);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Change the current resolution (fullscreen or windowed\r\n\r\n\tRemarks: The player try to retrieve the resolution (fullscreen or windowed)\r\n\tfrom level attributes. If nothing has changed nothing is done.\r\n\t*************************************************************************/\r\n\tBOOL ChangeResolution();\r\n\t\r\n\t/*************************************************************************\r\n\tSummary: Manage the mouse clipping\r\n\r\n\tParameters: TRUE to enable the mouse clipping.\r\n\t*************************************************************************/\r\n\tBOOL ClipMouse(BOOL iEnable);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the WM_PAINT windows event.\r\n\r\n\tDescription: In windowed mode we use the render context to render\r\n\tthe scene.\r\n\t*************************************************************************/\r\n\tvoid OnPaint();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the mouse left button click.\r\n\r\n\tDescription: Send a message (click or double click) to the object \"picked\"\r\n\tby the mouse, if any.\r\n\t*************************************************************************/\r\n\tvoid OnMouseClick(int iMessage);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the focus changement.\r\n\r\n\tDescription:\r\n\t\t- if the application is minimized (no focus) we paused it.\r\n\t\t- if the application is no more minimized (but was minimized) we restart it.\r\n\t\t- if the application focus is changin depending of the \"Focus Lost Behavior\"\r\n\t\t (see CKContext::GetFocusLostBehavior or the \"Focus Lost Behavior\" in the\r\n\t\t variable manager).\r\n\t*************************************************************************/\r\n\tvoid OnFocusChange(BOOL iFocus);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the activty of the application.\r\n\r\n\tDescription: If the application is deactivated while it is in fullscreen\r\n\tmode, we must switch to windowed mode.\r\n\t*************************************************************************/\r\n\tvoid OnActivateApp(BOOL iActivate);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage system keys (ALT + KEY)\r\n\r\n\tDescription: If system keys are not diabled (see eDisableKeys)\r\n\t\t- ALT + ENTER -> SwitchFullscreen\r\n\t\t- ALT + F4 -> Quit the application\r\n\t*************************************************************************/\r\n\tLRESULT\tOnSysKeyDownMainWindow(int iConfig, int iKey);\r\n\t/*************************************************************************\r\n\tSummary: Manage the activty of the application.\r\n\r\n\tDescription: If the application is deactivated while it is in fullscreen\r\n\tmode, we must switch to windowed mode.\r\n\t*************************************************************************/\r\n\tint DoSystemCheck(XString&errorText);\r\n\r\n\tvoid _InitContextAnd();\r\n\tvoid _InitManagers();\r\n\r\n\r\n\tvoid SetMainWindow(HWND _main){ m_MainWindow = _main;}\r\n\r\n\txEApplicationMode m_AppMode;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t// [11/28/2007 mc007]\r\n\t\r\n\t\r\n\txSEngineWindowInfo *m_EngineWindowInfo;\r\n\tUSHORT PLoadEngineWindowProperties(const char *configFile);\r\n\txSEngineWindowInfo *GetEWindowInfo();\r\n\t\r\n\r\n\txSEnginePaths* m_EPaths;\r\n\tUSHORT PLoadEnginePathProfile(const char* configFile);\r\n\txSEnginePaths* GetEPathProfile();\r\n\r\n\txSApplicationWindowStyle *m_AWStyle;\r\n\r\n\tUSHORT PLoadAppStyleProfile(const char* configFile);\t\r\n\tUSHORT PLoadResourcePaths(const char* configFile,const char*section,int resourceType);\t\r\n\r\n\txSApplicationWindowStyle *GetPAppStyle();\r\n\r\n\t\r\n\txEApplicationMode PGetApplicationMode(const char* pstrCommandLine);\r\n\txEApplicationMode PGetApplicationMode();\r\n\t \r\n\txSEnginePointers *GetEnginePointers();\r\n\txSEngineWindowInfo *GetEngineWindowInfo();\r\n\t\r\n\tvoid ShowSplash();\r\n\tvoid SetSplashText(const char* text);\r\n\tvoid HideSplash();\r\n\r\n\tUSHORT PSaveEngineWindowProperties(const char *configFile,const vtPlayer::Structs::xSEngineWindowInfo& input);\r\n\r\n\r\n\t////////////////////////////////////////\r\n\t// accessors\r\n\r\n\tint& RasterizerFamily();\r\n\tint& RasterizerFlags();\r\n\tint& WindowedWidth();\r\n\tint& WindowedHeight();\r\n\tint& MininumWindowedWidth();\r\n\tint& MininumWindowedHeight();\r\n\tint& FullscreenWidth();\r\n\tint& FullscreenHeight();\r\n\tint Driver();\r\n\tint& FullscreenBpp();\r\n\tCKRenderContext* GetRenderContext();\r\n\r\nprotected:\r\n\r\n\tenum DriverFlags \r\n\t{\r\n\t\teFamily\t\t\t= 1,\r\n\t\teDirectXVersion\t= 2,\r\n\t\teSoftware\t\t= 4\r\n\t};\r\n\t\r\n\r\n\tenum PlayerState\r\n\t{\r\n\t\teInitial\t= 0,\r\n\t\tePlaying\t= 1,\r\n\t\tePlaused\t= 2,\r\n\t\teFocusLost\t= 3,\r\n\t\teMinimized\t= 4\r\n\t};\r\n\r\n\r\n\r\n\tBOOL\t_InitPlugins(CKPluginManager& iPluginManager);\r\n\tint\t\t_InitRenderEngines(CKPluginManager& iPluginManager);\r\n\r\n\tpublic :\r\n\r\n\tCKERROR\t_Load(const char* str);\r\n\tCKERROR\t_Load(const void* iMemoryBuffer, int iBufferSize);\r\n\tBOOL\t_FinishLoad();\r\n\r\n\tprotected :\r\n\tvoid\t_MissingGuids(CKFile* iFile, const char* iResolvedFile);\r\n\tBOOL\t_GetWindowedResolution();\r\n\tBOOL\t_GetFullScreenResolution();\r\n\tvoid\t_SetResolutions();\r\n\r\n\tBOOL\t_InitDriver();\r\n\tBOOL\t_CheckDriver(VxDriverDesc* iDesc, int iFlags);\r\n\tBOOL\t_CheckFullscreenDisplayMode(BOOL iDoBest);\r\n\r\n\r\n\t\r\n\r\n\r\n\tint\t\t\t\t\tm_State;\r\n\tpublic:\r\n\tHWND\t\t\t\tm_MainWindow;\r\n\tHWND\t\t\t\tm_RenderWindow;\r\n\tHWND\t\tm_hWndParent;\r\n\t// ck objects (context, managers, ...)\r\n\t\r\n\tCKContext*\t\t\tm_CKContext;\r\n\tCKRenderContext*\tm_RenderContext;\r\n\tCKMessageManager*\tm_MessageManager;\r\n\tCKRenderManager*\tm_RenderManager;\r\n\tCKTimeManager*\t\tm_TimeManager;\r\n\tCKAttributeManager*\tm_AttributeManager;\r\n\tCKInputManager*\t\tm_InputManager;\r\n\r\n\tvtPlayer::Structs::xSEnginePointers m_EnginePointers;\r\n\r\n\r\n\tCKLevel*\t\t\tm_Level;\r\n\t// attributes\r\n\t// from an exemple about using this attributes see sample.cmo which is delivered with this player sample\r\n\tint\t\t\t\t\tm_QuitAttType;\t\t\t\t\t// attribut without type, name is \"Quit\"\r\n\tint\t\t\t\t\tm_SwitchFullscreenAttType;\t\t// attribut without type, name is \"Switch Fullscreen\"\r\n\tint\t\t\t\t\tm_SwitchResolutionAttType;\t\t// attribut without type, name is \"Switch Resolution\"\r\n\tint\t\t\t\t\tm_SwitchMouseClippingAttType;\t// attribut without type, name is \"Switch Mouse Clipping\"\r\n\tint\t\t\t\t\tm_WindowedResolutionAttType;\t// attribut which type is Vector 2D, name is \"Windowed Resolution\"\r\n\tint\t\t\t\t\tm_FullscreenResolutionAttType;\t// attribut which type is Vector 2D, name is \"Fullscreen Resolution\"\r\n\tint\t\t\t\t\tm_FullscreenBppAttType;\t\t\t// attribut which type is Integer, name is \"Fullscreen Bpp\"\r\n\t// messages\r\n\tint\t\t\t\t\tm_MsgClick;\r\n\tint\t\t\t\t\tm_MsgDoubleClick;\r\n\t// display configuration\r\n\tint\t\t\t\t\tm_RasterizerFamily;\t\t// see CKRST_RSTFAMILY\r\n\tint\t\t\t\t\tm_RasterizerFlags;\t\t// see CKRST_SPECIFICCAPS\r\n\tint\t\t\t\t\tm_WindowedWidth;\t\t// windowed mode width\r\n\tint\t\t\t\t\tm_WindowedHeight;\t\t// windowed mode height\r\n\tint\t\t\t\t\tm_MinWindowedWidth;\t\t// windowed mode minimum width\r\n\tint\t\t\t\t\tm_MinWindowedHeight;\t// windowed mode minumum height\r\n\tint\t\t\t\t\tm_FullscreenWidth;\t\t// fullscreen mode width\r\n\tint\t\t\t\t\tm_FullscreenHeight;\t\t// fullscreen mode height\r\n\tint\t\t\t\t\tm_FullscreenBpp;\t\t// fullscreen mode bpp\r\n\tint\t\t\t\t\tm_Driver;\t\t\t\t// index of the current driver\r\n\tBOOL\t\t\t\tm_FullscreenEnabled;\t// is fullscreen enable\r\n\tBOOL\t\t\t\tm_EatDisplayChange;\t\t// used to ensure we are not switching mode will we are already switching\r\n\tBOOL\t\t\t\tm_MouseClipped;\t\t\t// used to know if the mouse is acutally cliped\r\n\tRECT\t\t\t\tm_MainWindowRect;\r\n\r\n\tint\t\t\t\t\tm_FullscreenRefreshRate;\t\t// fullscreen mode bpp\r\n\tint m_LastError;\r\n\tXString m_LastErrorText;\r\n\r\n\r\n\tHINSTANCE m_hInstance;\r\n\tATOM\t_RegisterClass();\r\n\tint\t_CreateWindows();\r\n\r\n\t// main windowproc\r\n\tLRESULT CALLBACK _MainWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r\n\tstatic LRESULT _MainWindowWndProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );\r\n\r\n\tvoid StartMove(LPARAM lParam);\r\n\tvoid DoMMove(LPARAM lParam, WPARAM wParam);\r\n\tint nMMoveX, nMMoveY; //initial mouse position from window origin.\r\n\r\n\r\n\tHRESULT DoFrame();\r\n\tint Tick();\r\n\tint RunInThread();\r\n\tvoid Stop();\r\n\tHANDLE m_hThread;\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,int value);\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,float value);\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,char* value);\r\n\r\n\tvoid RedirectLog();\r\n\tXString m_oldText;\r\n\r\n\r\n\t//HWND\t\tm_Splash;\t\t// the window used to display the splash screen.\r\n\tXString\t\tm_PlayerClass;\t// the name of the windows class used for the main window.\r\n\tXString\t\tm_RenderClass;\t// the name of the windows class used for the render window.\r\n\tXString\t\tm_PlayerTitle;\t// the string display in the title bar of the main window.\r\n\tint\t\t\tm_Config;\t\t// the configuration of the player (see EConfigPlayer).\r\n\tHACCEL\t\tm_hAccelTable;\r\n\r\nprivate:\r\n\r\n\t// {secret}\r\n\tCCustomPlayer();\r\n\t// {secret}\r\n\tCCustomPlayer(const CCustomPlayer&);\r\n\t// {secret}\r\n\tCCustomPlayer& operator=(const CCustomPlayer&);\r\n\r\n};\r\n//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n// [11/28/2007 mc007]\r\n\r\n#define GetPlayer() CCustomPlayer::Instance()\r\n\r\n\r\n#endif // CUSTOMPLAYER_H#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJD6SetMotionModeDecl();\r\nCKERROR CreateJD6SetMotionModeProto(CKBehaviorPrototype **pproto);\r\nint JD6SetMotionMode(const CKBehaviorContext& behcontext);\r\nCKERROR JD6SetMotionModeCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_BodyA=0,\r\n\tbbI_BodyB,\r\n\tbbI_Anchor,\r\n\tbbI_AnchorRef,\r\n\tbbI_Axis,\r\n\tbbI_AxisRef\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJD6SetMotionModeDecl\r\n// FullName: FillBehaviorJD6SetMotionModeDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJD6SetMotionModeDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJD6SetMotionMode\");\t\r\n\tod->SetCategory(\"Physic/D6\");\r\n\tod->SetDescription(\"Sets the motion freedom mode in a D6 joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x62dc4a7e,0x20736a5e));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJD6SetMotionModeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJD6SetMotionModeProto\r\n// FullName: CreateJD6SetMotionModeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJD6SetMotionModeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJD6SetMotionMode\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\r\n\t\r\n\t\r\n\tproto->SetBehaviorCallbackFct( JD6SetMotionModeCB );\r\n\t\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\tproto->DeclareInParameter(\"Motion Axis\",VTE_JOINT_MOTION_MODE_AXIS,0);\r\n\tproto->DeclareInParameter(\"Motion Mode\",VTE_JOINT_MOTION_MODE,0);\r\n\r\n\r\n\r\n\t\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JD6SetMotionMode);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JD6SetMotionMode\r\n// FullName: JD6SetMotionMode\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JD6SetMotionMode(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointD6 *joint =static_cast(worldA->getJoint(target,targetB,JT_D6));\r\n\t\t\tint motionAxis = GetInputParameterValue(beh,1); \r\n\t\t\tD6MotionMode motionMode = GetInputParameterValue(beh,2);\r\n\r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\t\t\t\tswitch(motionAxis)\r\n\t\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t\tcase D6MA_Twist:\r\n\t\t\t\t\t\tjoint->setTwistMotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6MA_Swing1:\r\n\t\t\t\t\t\tjoint->setSwing1MotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6MA_Swing2:\r\n\t\t\t\t\t\tjoint->setSwing2MotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6MA_X:\r\n\t\t\t\t\t\tjoint->setXMotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6MA_Y:\r\n\t\t\t\t\t\tjoint->setYMotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase D6MA_Z:\r\n\t\t\t\t\t\tjoint->setZMotionMode(motionMode);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JD6SetMotionModeCB\r\n// FullName: JD6SetMotionModeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JD6SetMotionModeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tDWORD fmax;\r\n\t\t\tbeh->GetLocalParameterValue(0,&fmax);\r\n\t\t\tif (fmax )\r\n\t\t\t{\r\n\t\t\t\tbeh->EnableInputParameter(6,fmax);\r\n\t\t\t\tbeh->EnableInputParameter(7,fmax);\r\n\t\t\t\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tbeh->EnableInputParameter(6,fmax);\r\n\t\t\t\tbeh->EnableInputParameter(7,fmax);\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//the object A: \r\n\t\t\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\t\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\r\n\t\t\t\tif (target && targetB)\r\n\t\t\t\t{\r\n\t\t\t\t\t// the world : \r\n\t\t\t\t\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\t\t\t\t\tif (!world)\r\n\t\t\t\t\t\treturn CKBR_OK;\r\n\r\n\t\t\t\t\t// the physic object A and B : \r\n\t\t\t\t\tpRigidBody*bodyA= world->getBody(target);\r\n\t\t\t\t\tpRigidBody*bodyB= world->getBody(targetB);\r\n\r\n\t\t\t\t\tif(bodyA && bodyB)\r\n\t\t\t\t\t{\r\n//\t\t\t\t\t\tpJointHinge2 *joint = static_cast(bodyA->isConnected(targetB));\r\n\t\t\t\t\t\t/*\r\n\t\t\t\t\t\tif (joint && joint->GetFeedBack())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tjoint->SetFeedBack(NULL,0,0);\r\n\t\t\t\t\t\t}*/\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xPredictionSetting.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n#include \"xMathFnc2.h\"\r\n\r\nuxString \r\nxDistributedPoint1F::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedPoint1F::updateFromServer(TNL::BitStream *stream)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tTNL::F32 p;\tstream->read(&p);\r\n\t\tTNL::F32 v;\tstream->read(&v);\r\n\t \r\n\t\tmLastServerValue = p;\r\n\t\tmLastServerDifference = v;\r\n\t}\r\n\t\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tTNL::F32 p;\tstream->read(&p);\r\n\t\tmCurrentValue = p;\r\n\t\tmLastServerValue = p;\r\n\t}\r\n\tsetValueState(E_DV_UPDATED);\r\n\r\n}\r\n\r\nvoid\r\nxDistributedPoint1F::updateGhostValue(TNL::BitStream *stream)\r\n{\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tstream->write(mCurrentValue);\r\n\t\tstream->write(mDifference);\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tstream->write(mCurrentValue);\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint1F::unpack(TNL::BitStream *bstream,float sendersOneWayTime)\r\n{\r\n\t\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tsendersOneWayTime *= 0.001f;\r\n\t\t\r\n\r\n\t\tTNL::F32 p;\tbstream->read(&p);\r\n\t\tTNL::F32 v;\tbstream->read(&v);\r\n\r\n\t\tTNL::F32 predictedPos = p + v * sendersOneWayTime;\r\n\t\tsetOwnersOneWayTime(sendersOneWayTime);\r\n\r\n\t\tmLastValue = mCurrentValue;\r\n\t\tmCurrentValue = predictedPos;\r\n\t\tmDifference= mCurrentValue - mLastValue;\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\r\n\t\tTNL::F32 p;\tbstream->read(&p);\r\n\t\tmLastValue = p;\r\n\t\tmLastServerValue = p;\r\n\t\tmCurrentValue = p;\r\n\t}\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint1F::pack(TNL::BitStream *bstream)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tbstream->write(mCurrentValue);\r\n\t\tbstream->write(mDifference);\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tbstream->write(mCurrentValue);\r\n\t}\r\n\r\n\r\n\tint flags = getFlags();\r\n\tflags &= (~E_DP_NEEDS_SEND);\r\n\tsetFlags(flags);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedPoint1F::updateValue(TNL::F32 value,xTimeType currentTime)\r\n{\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue = mCurrentValue;\r\n mCurrentValue = value;\r\n\tmDifference = mCurrentValue - mLastValue;\r\n\t\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\tfloat lengthDiff = fabsf(mDifference);\r\n\tfloat timeDiffMs = ((float)mThresoldTicker) / 1000.f;\r\n\r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\tbool result = false;\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\r\n\t\tif (lengthDiff > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tTNL::F32 serverDiff = mCurrentValue-mLastServerValue ;\r\n\t\t\r\n\t\tif ( fabsf( serverDiff) > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > (getPredictionSettings()->getMinSendTime() * 0.2f) )\r\n\t\t\t{\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t{\r\n\t\t\tmThresoldTicker2 = 0 ;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\t}\r\n\r\n\tif (getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\tresult = true ;\r\n\t}\r\n\r\n\tsetFlags(flags);\r\n\treturn result;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nusing namespace vtAgeia;\r\n\r\nVxVector pJoint::getGlobalAxis(){\r\n\tif (!getJoint())\r\n\t\treturn VxVector(-1,-1,-1);\r\n\r\n\treturn getFrom(getJoint()->getGlobalAxis());\r\n\t\r\n}\r\n\r\nvoid pJoint::setGlobalAxis(VxVector axis)\r\n{\r\n\tif (getJoint())\r\n\t\tgetJoint()->setGlobalAxis(getFrom(axis));\r\n}\r\n\r\n\r\nVxVector pJoint::getGlobalAnchor(){\r\n\tif (!getJoint())\r\n\t\treturn VxVector(-1,-1,-1);\r\n\r\n\treturn getFrom(getJoint()->getGlobalAnchor());\r\n\r\n}\r\n\r\nvoid pJoint::setGlobalAnchor(VxVector anchor)\r\n{\r\n\tif (getJoint())\r\n\t\tgetJoint()->setGlobalAnchor(getFrom(anchor));\r\n}\r\n\r\n\r\nint pJoint::getNbLimitPlanes()\r\n{\r\n\tif (!getJoint())\r\n\t\treturn -1;\r\n\r\n\tNxJoint *j = getJoint();\r\n\tj->resetLimitPlaneIterator();\r\n\tint numLimitPlanes = 0;\r\n\tNxVec3 limitPoint;\r\n\tif ( j->hasMoreLimitPlanes() )\r\n\t{\r\n\t\tNxVec3 planeNormal;\r\n\t\tNxReal planeD;\r\n\t\tNxReal restitution;\r\n\r\n\t\tbool ok = true;\r\n\t\twhile ( ok )\r\n\t\t{\r\n\t\t\tj->getNextLimitPlane( planeNormal, planeD, &restitution );\r\n\t\t\t++numLimitPlanes;\r\n\t\t\tok = j->hasMoreLimitPlanes();\r\n\t\t}\r\n\t}\r\n \r\n\treturn numLimitPlanes;\r\n\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\npJointFixed::pJointFixed(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Fixed)\r\n{\r\n}\r\n\r\npJoint::pJoint(pRigidBody* _a,pRigidBody* _b,int _type ) : m_SolidA(_a) , m_SolidB(_b) ,m_type((JType)_type)\r\n{\r\n\tm_vtObjectA = _a ? _a->GetVT3DObject() : NULL;\r\n\tm_vtObjectB = _b ? _b->GetVT3DObject() : NULL;\r\n\r\n\tmAID = _a ? _a->GetVT3DObject()->GetID() : -1 ;\r\n\tmBID = _b ? _b->GetVT3DObject()->GetID() : -1 ;\r\n\r\n\tmJoint = NULL;\r\n\tm_pWorld = NULL;\r\n}\r\npJointD6*pJoint::castD6Joint()\r\n{\r\n\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isD6Joint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n\r\npJointPulley* pJoint::castPulley()\r\n{\r\n\r\n\t\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isPulleyJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\npJointDistance* pJoint::castDistanceJoint()\r\n{\r\n\r\n\t\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isDistanceJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npJointBall* pJoint::castBall()\r\n{\r\n\r\n\t\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isSphericalJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npJointRevolute* pJoint::castRevolute()\r\n{\r\n\r\n\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isRevoluteJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npJointPrismatic* pJoint::castPrismatic()\r\n{\r\n\r\n\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isPrismaticJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\npJointCylindrical* pJoint::castCylindrical()\r\n{\r\n\r\n\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isCylindricalJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npJointPointInPlane* pJoint::castPointInPlane()\r\n{\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isPointInPlaneJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\npJointPointOnLine* pJoint::castPointOnLine()\r\n{\r\n\tif (getJoint())\r\n\t{\r\n\t\tif (getJoint()->isPointOnLineJoint())\r\n\t\t{\r\n\t\t\treturn static_cast(this);\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\nint pJoint::addLimitPlane(const VxVector normal, VxVector pointInPlane, float restitution/* =0.0f */)\r\n{\t\r\n\tint res = -1;\r\n\tif (getJoint()){\t\t\r\n\t\r\n\t\tres = getJoint()->addLimitPlane(pMath::getFrom(normal),pMath::getFrom(pointInPlane),restitution);\r\n\r\n\t}\r\n\treturn res;\r\n}\r\nvoid pJoint::setLimitPoint( VxVector point,bool pointIsOnActor2/*=true*/ )\r\n{\t\r\n\tif (getJoint()){\t\t\r\n\t\treturn getJoint()->setLimitPoint(getFrom(point),pointIsOnActor2);\r\n\t}\r\n}\r\nvoid pJoint::purgeLimitPlanes(){ \tif (getJoint())\t\tgetJoint()->purgeLimitPlanes();}\r\nvoid pJoint::resetLimitPlaneIterator(){ \tif (getJoint())\t\tgetJoint()->resetLimitPlaneIterator();}\r\nint pJoint::hasMoreLimitPlanes(){ \tif (getJoint())\t\treturn getJoint()->hasMoreLimitPlanes(); return false;}\r\nint pJoint::getNextLimitPlane (VxVector &planeNormal, float &planeD,float *restitution)\r\n{\r\n\tif (getJoint())\r\n\t{\r\n\t\tNxVec3 n;\r\n\t\t\r\n\t\tint k =getJoint()->getNextLimitPlane(n,planeD,restitution);\r\n\t\tplaneNormal = pMath::getFrom(n);\r\n\t\treturn k;\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n\r\n\r\nvoid pJoint::getBreakForces( float& maxForce,float& maxTorque )\r\n{\r\n\tif (getJoint())\r\n\t\tgetJoint()->getBreakable(maxForce,maxTorque); \r\n}\r\n\r\nvoid pJoint::setBreakForces( float maxForce,float maxTorque )\r\n{\r\n\tif (!getJoint())\r\n\treturn;\r\n\r\n\tif ( maxTorque !=0.0f && maxForce != 0.0f)\r\n\t\tgetJoint()->setBreakable(maxForce,maxTorque); \r\n\r\n\t//if ( maxTorque =0.0f && maxForce = 0.0f)\r\n\t//\tgetJoint()->setBreakable(,maxTorque); \r\n\r\n\r\n}\r\n\r\nvoid pJoint::setLocalAnchor0(VxVector anchor0)\r\n{\r\n\tif (getJoint())\r\n\t{\r\n\r\n\t\tif(getJoint()->isRevoluteJoint())\r\n\t\t{\r\n\t\t\tNxRevoluteJointDesc descr;\t\r\n\t\t\tNxRevoluteJoint *joint = static_cast(getJoint());\r\n\t\t\tif (!joint)return;\r\n\t\t\tjoint->saveToDesc(descr);\r\n\t\t\tdescr.localAnchor[0] = getFrom(anchor0);\r\n\t\t\tjoint->loadFromDesc(descr);\r\n\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\n#ifndef __PVEHICLETYPES_H__\r\n#define __PVEHICLETYPES_H__\r\n\r\n#include \"pVTireFunction.h\"\r\n#include \"pLinearInterpolation.h\"\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\n\r\ntypedef enum FrictionCircleMethod\n{\n\tFC_GENTA, // Genta (page 52?)\n\tFC_VECTOR, // Vector reduction to fit circle\n\tFC_VOID, // Don't touch forces (for testing)\n\tFC_SLIPVECTOR // Gregor's method of combined Pacejka\n};\r\n\r\n\r\n#define BREAK_TABLE_ENTRIES 10\r\n\r\nclass pVehicleBrakeTable\r\n{\r\npublic: \r\n\tfloat brakeEntries[BREAK_TABLE_ENTRIES];\r\n};\r\n\r\nclass MODULE_API pVehicleDesc\r\n{\r\n\r\npublic:\r\n\r\n\tVxVector\t\t\t\t\tposition;\r\n\r\n\tpVehicleGearDesc *gearDescription;\r\n\tpVehicleGearDesc * getGearDescription() { return gearDescription; }\r\n\r\n\tpVehicleMotorDesc *motorDescr;\r\n\tpVehicleMotorDesc * getMotorDescr() { return motorDescr; }\r\n\r\n\r\n\r\n\r\n\tfloat\t\t\t\t\tmass;\r\n\tfloat\t\t\t\t\tmotorForce;\r\n\tfloat\t\t\t\t\ttransmissionEfficiency;\r\n\tfloat\t\t\t\t\tdifferentialRatio;\r\n\r\n\tVxVector\t\t\t\t\tsteeringTurnPoint;\r\n\tVxVector\t\t\t\t\tsteeringSteerPoint;\r\n\tfloat\t\t\t\t\tsteeringMaxAngle;\r\n\r\n\tVxVector\t\t\t\t\tcenterOfMass;\r\n\r\n\tfloat\t\t\t\t\tdigitalSteeringDelta;\r\n\r\n\tfloat\t\t\t\t\tmaxVelocity;\r\n\tfloat\t\t\t\t\tdigitalSteeringDeltaVelocityModifier;\r\n\r\n\tint xmlLinkID;\r\n\tXString xmlName;\r\n\t\r\n\tpRigidBody *body;\r\n\r\n\r\n\tvoid*\t\t\t\t\tuserData;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Engine Related Parameters\r\n\t//\r\n\tfloat engineInertia;\r\n\tfloat engineFriction;\r\n\tfloat engineBrakingCoefficient;\r\n\tfloat engineMaximumTorque;\r\n\r\n\t//-RPMs\r\n\tfloat engineRpmMaximum;\r\n\tfloat engineRpmIdle;\r\n\tfloat engineRpmAutoClutch;\r\n\tfloat engineRpmStart;\r\n\tfloat engineRpmStall;\r\n\r\n\tint engineFlags;\r\n\r\n\t//-Engine Torque Curve\r\n\tpLinearInterpolation torqueCurve;\r\n\t\r\n\tint processFlags;\r\n\r\n\r\n\r\n\tpVehicleDesc();\r\n\tvoid setToDefault();\r\n\tbool isValid() const;\r\n};\r\n\r\n\r\n\r\ntypedef std::vectorWheelArrayType;\r\n\r\n/** @} */\r\n\r\n#include \"pLinearInterpolation.h\"\r\n\r\n\r\n\r\n\r\n\r\n#endif // __PVEHICLETYPES_H__#include \"CKAll.h\"\r\n\r\n\r\n/*****************************************************************************\r\n*\r\n* THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF\r\n* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED\r\n* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR\r\n* A PARTICULAR PURPOSE.\r\n*\r\n* Copyright (C) 1993 - 1996 Microsoft Corporation. All Rights Reserved.\r\n*\r\n******************************************************************************\r\n*\r\n* SMF.C\r\n*\r\n* MIDI File access routines.\r\n*\r\n*****************************************************************************/\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \"muldiv32.h\"\r\n#include \"smf.h\"\r\n#include \"smfi.h\"\r\n\r\nstatic SMFRESULT smfInsertParmData(\r\n PSMF pSmf,\r\n TICKS tkDelta, \r\n LPMIDIHDR lpmh);\r\n\r\n/*****************************************************************************\r\n*\r\n* smfOpenFile\r\n*\r\n* This function opens a MIDI file for access. \r\n*\r\n* psofs - Specifies the file to open and associated\r\n* parameters. Contains a valid HSMF handle\r\n* on success.\r\n*\r\n* Returns\r\n* SMF_SUCCESS The specified file was opened.\r\n*\r\n* SMF_OPEN_FAILED The specified file could not be opened because it\r\n* did not exist or could not be created on the disk.\r\n*\r\n* SMF_INVALID_FILE The specified file was corrupt or not a MIDI file.\r\n* \r\n* SMF_NO_MEMORY There was insufficient memory to open the file.\r\n*\r\n* SMF_INVALID_PARM The given flags or time division in the\r\n* SMFOPENFILESTRUCT were invalid.\r\n* \r\n*****************************************************************************/\r\nSMFRESULT smfOpenFile(\r\n PSMFOPENFILESTRUCT psofs)\r\n{\r\n HMMIO hmmio = (HMMIO)NULL;\r\n PSMF pSmf;\r\n SMFRESULT smfrc = SMF_SUCCESS;\r\n MMIOINFO mmioinfo;\r\n MMCKINFO ckRIFF;\r\n MMCKINFO ckDATA;\r\n\r\n //assert(psofs != NULL);\r\n //assert(psofs->pstrName != NULL);\r\n \r\n /* Verify that the file can be opened or created\r\n */\r\n _fmemset(&mmioinfo, 0, sizeof(mmioinfo));\r\n\r\n hmmio = mmioOpen(psofs->pstrName, &mmioinfo, MMIO_READ|MMIO_ALLOCBUF);\r\n if ((HMMIO)NULL == hmmio)\r\n {\r\n //DPF(1, \"smfOpenFile: mmioOpen failed!\");\r\n return SMF_OPEN_FAILED;\r\n }\r\n\r\n /* Now see if we can create the handle structure\r\n */\r\n pSmf = (PSMF)LocalAlloc(LPTR, sizeof(SMF));\r\n if (NULL == pSmf)\r\n {\r\n //DPF(1, \"smfOpenFile: LocalAlloc failed!\");\r\n smfrc = SMF_NO_MEMORY;\r\n goto smf_Open_File_Cleanup;\r\n }\r\n\r\n lstrcpy(pSmf->szName, psofs->pstrName);\r\n pSmf->fdwSMF = 0;\r\n pSmf->pTempoMap = NULL;\r\n\r\n /* Pull the entire file into a block of memory. \r\n */\r\n _fmemset(&ckRIFF, 0, sizeof(ckRIFF));\r\n \r\n if (0 == mmioDescend(hmmio, &ckRIFF, NULL, MMIO_FINDRIFF) &&\r\n ckRIFF.fccType == FOURCC_RMID)\r\n {\r\n ckDATA.ckid = FOURCC_data;\r\n \r\n if (0 == mmioDescend(hmmio, &ckDATA, &ckRIFF, MMIO_FINDCHUNK))\r\n {\r\n pSmf->cbImage = ckDATA.cksize;\r\n }\r\n else\r\n {\r\n //DPF(1, \"smfOpenFile: Could not descend into RIFF DATA chunk!\");\r\n smfrc = SMF_INVALID_FILE;\r\n goto smf_Open_File_Cleanup;\r\n }\r\n }\r\n else\r\n {\r\n long x=mmioSeek(hmmio, 0L, SEEK_SET);\r\n \r\n pSmf->cbImage = mmioSeek(hmmio, 0L, SEEK_END);\r\n mmioSeek(hmmio, 0L, SEEK_SET);\r\n }\r\n \r\n if (NULL == (pSmf->hpbImage = (LPBYTE)GlobalAllocPtr(GMEM_MOVEABLE|GMEM_SHARE, pSmf->cbImage)))\r\n {\r\n //DPF(1, \"smfOpenFile: No memory for image! [%08lX]\", pSmf->cbImage);\r\n smfrc = SMF_NO_MEMORY;\r\n goto smf_Open_File_Cleanup;\r\n }\r\n \r\n if (pSmf->cbImage != (DWORD)mmioRead(hmmio, (char*)pSmf->hpbImage, pSmf->cbImage))\r\n {\r\n //DPF(1, \"smfOpenFile: Read error on image!\");\r\n smfrc = SMF_INVALID_FILE;\r\n goto smf_Open_File_Cleanup;\r\n }\r\n\r\n /* If the file exists, parse it just enough to pull out the header and\r\n ** build a track index.\r\n */\r\n smfrc = smfBuildFileIndex((PSMF *)&pSmf);\r\n if (MMSYSERR_NOERROR != smfrc)\r\n {\r\n //DPF(1, \"smfOpenFile: smfBuildFileIndex failed! [%lu]\", (DWORD)smfrc);\r\n }\r\n\r\nsmf_Open_File_Cleanup:\r\n\r\n mmioClose(hmmio, 0);\r\n\r\n if (SMF_SUCCESS != smfrc)\r\n {\r\n if (NULL != pSmf)\r\n {\r\n if (NULL != pSmf->hpbImage)\r\n {\r\n GlobalFreePtr(pSmf->hpbImage);\r\n }\r\n \r\n LocalFree((HLOCAL)pSmf);\r\n }\r\n }\r\n else\r\n {\r\n psofs->hSmf = (HSMF)pSmf;\r\n }\r\n \r\n return smfrc;\r\n}\r\n\r\n/*****************************************************************************\r\n*\r\n* smfCloseFile\r\n*\r\n* This function closes an open MIDI file.\r\n*\r\n* hSmf - The handle of the open file to close.\r\n*\r\n* Returns\r\n* SMF_SUCCESS The specified file was closed.\r\n* SMF_INVALID_PARM The given handle was not valid.\r\n*\r\n* Any track handles opened from this file handle are invalid after this\r\n* call.\r\n* \r\n*****************************************************************************/\r\nSMFRESULT smfCloseFile(\r\n HSMF hSmf)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n \r\n //assert(pSmf != NULL);\r\n \r\n /*\r\n ** Free up handle memory \r\n */\r\n \r\n if (NULL != pSmf->hpbImage)\r\n GlobalFreePtr(pSmf->hpbImage);\r\n \r\n LocalFree((HLOCAL)pSmf);\r\n \r\n return SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfGetFileInfo This function gets information about the MIDI file.\r\n*\r\n* hSmf - Specifies the open MIDI file to inquire about.\r\n*\r\n* psfi - A structure which will be filled in with\r\n* information about the file.\r\n*\r\n* Returns\r\n* SMF_SUCCESS Information was gotten about the file.\r\n* SMF_INVALID_PARM The given handle was invalid.\r\n*\r\n*****************************************************************************/\r\nSMFRESULT smfGetFileInfo(\r\n HSMF hSmf,\r\n PSMFFILEINFO psfi)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n\r\n //assert(pSmf != NULL);\r\n //assert(psfi != NULL);\r\n\r\n /* \r\n ** Just fill in the structure with useful information.\r\n */\r\n psfi->dwTracks = pSmf->dwTracks;\r\n psfi->dwFormat = pSmf->dwFormat;\r\n psfi->dwTimeDivision= pSmf->dwTimeDivision;\r\n psfi->tkLength = pSmf->tkLength;\r\n \r\n return SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfTicksToMillisecs\r\n*\r\n* This function returns the millisecond offset into the file given the\r\n* tick offset.\r\n*\r\n* hSmf - Specifies the open MIDI file to perform\r\n* the conversion on.\r\n*\r\n* tkOffset - Specifies the tick offset into the stream\r\n* to convert.\r\n*\r\n* Returns the number of milliseconds from the start of the stream.\r\n*\r\n* The conversion is performed taking into account the file's time division and\r\n* tempo map from the first track. Note that the same millisecond value\r\n* might not be valid at a later time if the tempo track is rewritten.\r\n*\r\n*****************************************************************************/\r\nDWORD smfTicksToMillisecs(\r\n HSMF hSmf,\r\n TICKS tkOffset)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n PTEMPOMAPENTRY pTempo;\r\n UINT idx;\r\n UINT uSMPTE;\r\n DWORD dwTicksPerSec;\r\n\r\n //assert(pSmf != NULL);\r\n\r\n if (tkOffset > pSmf->tkLength)\r\n {\r\n //DPF(1, \"sTTM: Clipping ticks to file length!\");\r\n tkOffset = pSmf->tkLength;\r\n }\r\n\r\n /* SMPTE time is easy -- no tempo map, just linear conversion\r\n ** Note that 30-Drop means nothing to us here since we're not\r\n ** converting to a colonized format, which is where dropping\r\n ** happens.\r\n */\r\n if (pSmf->dwTimeDivision & 0x8000)\r\n {\r\n uSMPTE = -(int)(char)((pSmf->dwTimeDivision >> 8)&0xFF);\r\n if (29 == uSMPTE)\r\n uSMPTE = 30;\r\n \r\n dwTicksPerSec = (DWORD)uSMPTE *\r\n (DWORD)(BYTE)(pSmf->dwTimeDivision & 0xFF);\r\n \r\n return (DWORD)muldiv32(tkOffset, 1000L, dwTicksPerSec);\r\n }\r\n \r\n /* Walk the tempo map and find the nearest tick position. Linearly\r\n ** calculate the rest (using MATH.ASM)\r\n */\r\n\r\n pTempo = pSmf->pTempoMap;\r\n //assert(pTempo != NULL);\r\n \r\n for (idx = 0; idx < pSmf->cTempoMap; idx++, pTempo++)\r\n if (tkOffset < pTempo->tkTempo)\r\n break;\r\n pTempo--;\r\n\r\n /* pTempo is the tempo map entry preceding the requested tick offset.\r\n */\r\n\r\n return pTempo->msBase + muldiv32(tkOffset-pTempo->tkTempo,\r\n pTempo->dwTempo,\r\n 1000L*pSmf->dwTimeDivision);\r\n \r\n}\r\n\r\n\r\n/******************************************************************************\r\n*\r\n* smfMillisecsToTicks\r\n*\r\n* This function returns the nearest tick offset into the file given the\r\n* millisecond offset.\r\n*\r\n* hSmf - Specifies the open MIDI file to perform the\r\n* conversion on.\r\n*\r\n* msOffset - Specifies the millisecond offset into the stream\r\n* to convert.\r\n*\r\n* Returns the number of ticks from the start of the stream.\r\n*\r\n* The conversion is performed taking into account the file's time division and\r\n* tempo map from the first track. Note that the same tick value\r\n* might not be valid at a later time if the tempo track is rewritten.\r\n* If the millisecond value does not exactly map to a tick value, then\r\n* the tick value will be rounded down.\r\n*\r\n*****************************************************************************/\r\nTICKS smfMillisecsToTicks(\r\n HSMF hSmf,\r\n DWORD msOffset)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n PTEMPOMAPENTRY pTempo;\r\n UINT idx;\r\n UINT uSMPTE;\r\n DWORD dwTicksPerSec;\r\n TICKS tkOffset;\r\n\r\n //assert(pSmf != NULL);\r\n \r\n /* SMPTE time is easy -- no tempo map, just linear conversion\r\n ** Note that 30-Drop means nothing to us here since we're not\r\n ** converting to a colonized format, which is where dropping\r\n ** happens.\r\n */\r\n if (pSmf->dwTimeDivision & 0x8000)\r\n {\r\n uSMPTE = -(int)(char)((pSmf->dwTimeDivision >> 8)&0xFF);\r\n if (29 == uSMPTE)\r\n uSMPTE = 30;\r\n \r\n dwTicksPerSec = (DWORD)uSMPTE *\r\n (DWORD)(BYTE)(pSmf->dwTimeDivision & 0xFF);\r\n\r\n return (DWORD)muldiv32(msOffset, dwTicksPerSec, 1000L);\r\n }\r\n \r\n /* Walk the tempo map and find the nearest millisecond position. Linearly\r\n ** calculate the rest (using MATH.ASM)\r\n */\r\n pTempo = pSmf->pTempoMap;\r\n //assert(pTempo != NULL);\r\n \r\n for (idx = 0; idx < pSmf->cTempoMap; idx++, pTempo++)\r\n if (msOffset < pTempo->msBase)\r\n break;\r\n pTempo--;\r\n\r\n /* pTempo is the tempo map entry preceding the requested tick offset.\r\n */\r\n\r\n tkOffset = pTempo->tkTempo + muldiv32(msOffset-pTempo->msBase,\r\n 1000L*pSmf->dwTimeDivision,\r\n pTempo->dwTempo);\r\n \r\n if (tkOffset > pSmf->tkLength)\r\n {\r\n //DPF(1, \"sMTT: Clipping ticks to file length!\");\r\n tkOffset = pSmf->tkLength;\r\n }\r\n\r\n return tkOffset;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfReadEvents\r\n*\r\n* This function reads events from a track.\r\n*\r\n* hSmf - Specifies the file to read data from.\r\n*\r\n* lpmh - Contains information about the buffer to fill.\r\n*\r\n* tkMax - Specifies a cutoff point in the stream\r\n* beyond which events will not be read. \r\n*\r\n* Return@rdes\r\n* SMF_SUCCESS The events were successfully read.\r\n* SMF_END_OF_TRACK There are no more events to read in this track.\r\n* SMF_INVALID_FILE A disk error occured on the file.\r\n* \r\n* @xref \r\n*****************************************************************************/\r\nSMFRESULT smfReadEvents(\r\n HSMF hSmf,\r\n LPMIDIHDR lpmh,\r\n TICKS tkMax)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n SMFRESULT smfrc;\r\n EVENT event;\r\n LPDWORD lpdw;\r\n DWORD dwTempo;\r\n\r\n //assert(pSmf != NULL);\r\n //assert(lpmh != NULL);\r\n\r\n /* \r\n ** Read events from the track and pack them into the buffer in polymsg\r\n ** format.\r\n ** \r\n ** If a SysEx or meta would go over a buffer boundry, split it.\r\n */ \r\n lpmh->dwBytesRecorded = 0;\r\n if (pSmf->dwPendingUserEvent)\r\n {\r\n smfrc = smfInsertParmData(pSmf, (TICKS)0, lpmh);\r\n if (SMF_SUCCESS != smfrc)\r\n {\r\n //DPF(1, \"smfInsertParmData() -> %u\", (UINT)smfrc);\r\n return smfrc;\r\n }\r\n }\r\n \r\n lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);\r\n\r\n if (pSmf->fdwSMF & SMF_F_EOF)\r\n {\r\n return SMF_END_OF_FILE;\r\n }\r\n\r\n while(TRUE)\r\n {\r\n //assert(lpmh->dwBytesRecorded <= lpmh->dwBufferLength);\r\n \r\n /* If we know ahead of time we won't have room for the\r\n ** event, just break out now. We need 2 DWORD's for the\r\n ** terminator event and at least 2 DWORD's for any\r\n ** event we might store - this will allow us a full\r\n ** short event or the delta time and stub for a long\r\n ** event to be split.\r\n */\r\n if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 4*sizeof(DWORD))\r\n {\r\n break;\r\n }\r\n\r\n smfrc = smfGetNextEvent(pSmf, (SPEVENT)&event, tkMax);\r\n if (SMF_SUCCESS != smfrc)\r\n {\r\n /* smfGetNextEvent doesn't set this because smfSeek uses it\r\n ** as well and needs to distinguish between reaching the\r\n ** seek point and reaching end-of-file.\r\n **\r\n ** To the user, however, we present the selection between\r\n ** their given tkBase and tkEnd as the entire file, therefore\r\n ** we want to translate this into EOF.\r\n */\r\n if (SMF_REACHED_TKMAX == smfrc)\r\n {\r\n pSmf->fdwSMF |= SMF_F_EOF;\r\n }\r\n \r\n //DPF(1, \"smfReadEvents: smfGetNextEvent() -> %u\", (UINT)smfrc);\r\n break;\r\n }\r\n\r\n \r\n if (MIDI_SYSEX > EVENT_TYPE(event))\r\n {\r\n *lpdw++ = (DWORD)event.tkDelta;\r\n *lpdw++ = 0;\r\n *lpdw++ = (((DWORD)MEVT_SHORTMSG)<<24) |\r\n ((DWORD)EVENT_TYPE(event)) |\r\n (((DWORD)EVENT_CH_B1(event)) << 8) |\r\n (((DWORD)EVENT_CH_B2(event)) << 16);\r\n \r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD);\r\n }\r\n else if (MIDI_META == EVENT_TYPE(event) &&\r\n MIDI_META_EOT == EVENT_META_TYPE(event))\r\n {\r\n /* These are ignoreable since smfReadNextEvent()\r\n ** takes care of track merging\r\n */\r\n }\r\n else if (MIDI_META == EVENT_TYPE(event) &&\r\n MIDI_META_TEMPO == EVENT_META_TYPE(event))\r\n {\r\n if (event.cbParm != 3)\r\n {\r\n //DPF(1, \"smfReadEvents: Corrupt tempo event\");\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n dwTempo = (((DWORD)MEVT_TEMPO)<<24)|\r\n (((DWORD)event.hpbParm[0])<<16)|\r\n (((DWORD)event.hpbParm[1])<<8)|\r\n ((DWORD)event.hpbParm[2]);\r\n\r\n *lpdw++ = (DWORD)event.tkDelta;\r\n *lpdw++ = 0;\r\n *lpdw++ = dwTempo;\r\n\r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD);\r\n }\r\n else if (MIDI_META != EVENT_TYPE(event))\r\n {\r\n /* Must be F0 or F7 system exclusive or FF meta\r\n ** that we didn't recognize\r\n */\r\n pSmf->cbPendingUserEvent = event.cbParm;\r\n pSmf->hpbPendingUserEvent = event.hpbParm;\r\n pSmf->fdwSMF &= ~SMF_F_INSERTSYSEX;\r\n\r\n switch(EVENT_TYPE(event))\r\n {\r\n case MIDI_SYSEX:\r\n pSmf->fdwSMF |= SMF_F_INSERTSYSEX;\r\n \r\n ++pSmf->cbPendingUserEvent;\r\n\r\n /* Falling through...\r\n */\r\n\r\n case MIDI_SYSEXEND:\r\n pSmf->dwPendingUserEvent = ((DWORD)MEVT_LONGMSG) << 24;\r\n break;\r\n }\r\n\r\n smfrc = smfInsertParmData(pSmf, event.tkDelta, lpmh);\r\n if (SMF_SUCCESS != smfrc)\r\n {\r\n //DPF(1, \"smfInsertParmData[2] %u\", (UINT)smfrc);\r\n return smfrc;\r\n }\r\n\r\n lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);\r\n }\r\n }\r\n\r\n return (pSmf->fdwSMF & SMF_F_EOF) ? SMF_END_OF_FILE : SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfInsertParmData\r\n*\r\n* Inserts pending long data from a track into the given buffer.\r\n*\r\n* pSmf - Specifies the file to read data from.\r\n*\r\n* tkDelta - Specfices the tick delta for the data.\r\n*\r\n* lpmh - Contains information about the buffer to fill.\r\n*\r\n* Returns\r\n* SMF_SUCCESS The events were successfully read.\r\n* SMF_INVALID_FILE A disk error occured on the file.\r\n* \r\n* Fills as much data as will fit while leaving room for the buffer\r\n* terminator.\r\n*\r\n* If the long data is depleted, resets pSmf->dwPendingUserEvent so\r\n* that the next event may be read.\r\n*\r\n*****************************************************************************/\r\nstatic SMFRESULT smfInsertParmData(\r\n PSMF pSmf,\r\n TICKS tkDelta, \r\n LPMIDIHDR lpmh)\r\n{\r\n DWORD dwLength;\r\n DWORD dwRounded;\r\n LPDWORD lpdw;\r\n\r\n //assert(pSmf != NULL);\r\n //assert(lpmh != NULL);\r\n \r\n /* Can't fit 4 DWORD's? (tkDelta + stream-id + event + some data)\r\n ** Can't do anything.\r\n */\r\n //assert(lpmh->dwBufferLength >= lpmh->dwBytesRecorded);\r\n \r\n if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 4*sizeof(DWORD))\r\n {\r\n if (0 == tkDelta)\r\n return SMF_SUCCESS;\r\n\r\n /* If we got here with a real delta, that means smfReadEvents screwed\r\n ** up calculating left space and we should flag it somehow.\r\n */\r\n //DPF(1, \"Can't fit initial piece of SysEx into buffer!\");\r\n return SMF_INVALID_FILE;\r\n }\r\n\r\n lpdw = (LPDWORD)(lpmh->lpData + lpmh->dwBytesRecorded);\r\n\r\n dwLength = lpmh->dwBufferLength - lpmh->dwBytesRecorded - 3*sizeof(DWORD);\r\n dwLength = __min(dwLength, pSmf->cbPendingUserEvent);\r\n\r\n *lpdw++ = (DWORD)tkDelta;\r\n *lpdw++ = 0L;\r\n *lpdw++ = (pSmf->dwPendingUserEvent & 0xFF000000L) | (dwLength & 0x00FFFFFFL);\r\n\r\n dwRounded = (dwLength + 3) & (~3L);\r\n \r\n if (pSmf->fdwSMF & SMF_F_INSERTSYSEX)\r\n {\r\n *((LPBYTE)lpdw++) = MIDI_SYSEX;\r\n pSmf->fdwSMF &= ~SMF_F_INSERTSYSEX;\r\n --dwLength;\r\n --pSmf->cbPendingUserEvent;\r\n }\r\n\r\n if (dwLength & 0x80000000L)\r\n {\r\n //DPF(1, \"dwLength %08lX dwBytesRecorded %08lX dwBufferLength %08lX\", dwLength, lpmh->dwBytesRecorded, lpmh->dwBufferLength);\r\n //DPF(1, \"cbPendingUserEvent %08lX dwPendingUserEvent %08lX dwRounded %08lX\", pSmf->cbPendingUserEvent, pSmf->dwPendingUserEvent, dwRounded);\r\n //DPF(1, \"Offset into MIDI image %08lX\", (DWORD)(pSmf->hpbPendingUserEvent - pSmf->hpbImage));\r\n //DPF(1, \"!hmemcpy is about to fault\");\r\n }\r\n\r\n hmemcpy(lpdw, pSmf->hpbPendingUserEvent, dwLength);\r\n if (0 == (pSmf->cbPendingUserEvent -= dwLength))\r\n pSmf->dwPendingUserEvent = 0;\r\n\r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD) + dwRounded;\r\n\r\n return SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfSeek\r\n*\r\n* This function moves the file pointer within a track\r\n* and gets the state of the track at the new position. It returns a buffer of\r\n* state information which can be used to set up to play from the new position.\r\n*\r\n* hSmf - Handle of file to seek within\r\n*\r\n* tkPosition - The position to seek to in the track.\r\n* \r\n* lpmh - A buffer to contain the state information.\r\n*\r\n* Returns\r\n* SMF_SUCCESS | The state was successfully read.\r\n* SMF_END_OF_TRACK | The pointer was moved to end of track and no state\r\n* information was returned.\r\n* SMF_INVALID_PARM | The given handle or buffer was invalid.\r\n* SMF_NO_MEMORY | There was insufficient memory in the given buffer to\r\n* contain all of the state data.\r\n*\r\n* The state information in the buffer includes patch changes, tempo changes,\r\n* time signature, key signature, \r\n* and controller information. Only the most recent of these paramters before\r\n* the current position will be stored. The state buffer will be returned\r\n* in polymsg format so that it may be directly transmitted over the MIDI\r\n* bus to bring the state up to date.\r\n*\r\n* The buffer is mean to be sent as a streaming buffer; i.e. immediately\r\n* followed by the first data buffer. If the requested tick position\r\n* does not exist in the file, the last event in the buffer\r\n* will be a MEVT_NOP with a delta time calculated to make sure that\r\n* the next stream event plays at the proper time.\r\n*\r\n* The meta events (tempo, time signature, key signature) will be the\r\n* first events in the buffer if they exist.\r\n* \r\n* Use smfGetStateMaxSize to determine the maximum size of the state\r\n* information buffer. State information that will not fit into the given\r\n* buffer will be lost.\r\n*\r\n* On return, the dwBytesRecorded field of lpmh will contain the\r\n* actual number of bytes stored in the buffer.\r\n*\r\n*****************************************************************************/\r\n\r\ntypedef struct tag_keyframe\r\n{\r\n /*\r\n ** Meta events. All FF's indicates never seen.\r\n */\r\n BYTE rbTempo[3];\r\n\r\n /*\r\n ** MIDI channel messages. FF indicates never seen.\r\n */\r\n BYTE rbProgram[16];\r\n BYTE rbControl[16*120];\r\n} KEYFRAME,\r\n *PKEYFRAME;\r\n\r\n#define KF_EMPTY ((BYTE)0xFF)\r\n\r\nSMFRESULT smfSeek(\r\n HSMF hSmf,\r\n TICKS tkPosition,\r\n LPMIDIHDR lpmh)\r\n{\r\n PSMF pSmf = (PSMF)hSmf;\r\n PTRACK ptrk;\r\n DWORD idxTrack;\r\n SMFRESULT smfrc;\r\n EVENT event;\r\n LPDWORD lpdw;\r\n BYTE bEvent;\r\n UINT idx;\r\n UINT idxChannel;\r\n UINT idxController;\r\n \r\n static KEYFRAME kf;\r\n\r\n _fmemset(&kf, 0xFF, sizeof(kf));\r\n \r\n pSmf->tkPosition = 0;\r\n pSmf->fdwSMF &= ~SMF_F_EOF;\r\n \r\n for (ptrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; ptrk++)\r\n {\r\n ptrk->pSmf = pSmf;\r\n ptrk->tkPosition = 0;\r\n ptrk->cbLeft = ptrk->smti.cbLength;\r\n ptrk->hpbImage = pSmf->hpbImage + ptrk->idxTrack;\r\n ptrk->bRunningStatus = 0;\r\n ptrk->fdwTrack = 0;\r\n }\r\n\r\n while (SMF_SUCCESS == (smfrc = smfGetNextEvent(pSmf, (SPEVENT)&event, tkPosition)))\r\n {\r\n if (MIDI_META == (bEvent = EVENT_TYPE(event)))\r\n {\r\n if (EVENT_META_TYPE(event) == MIDI_META_TEMPO)\r\n {\r\n if (event.cbParm != sizeof(kf.rbTempo))\r\n return SMF_INVALID_FILE;\r\n\r\n hmemcpy((HPBYTE)kf.rbTempo, event.hpbParm, event.cbParm);\r\n }\r\n }\r\n else switch(bEvent & 0xF0)\r\n {\r\n case MIDI_PROGRAMCHANGE:\r\n kf.rbProgram[bEvent & 0x0F] = EVENT_CH_B1(event);\r\n break;\r\n\r\n case MIDI_CONTROLCHANGE:\r\n kf.rbControl[(((WORD)bEvent & 0x0F)*120) + EVENT_CH_B1(event)] =\r\n EVENT_CH_B2(event);\r\n break;\r\n }\r\n }\r\n\r\n if (SMF_REACHED_TKMAX != smfrc)\r\n {\r\n return smfrc;\r\n }\r\n\r\n /* Build lpmh from keyframe\r\n */\r\n lpmh->dwBytesRecorded = 0;\r\n lpdw = (LPDWORD)lpmh->lpData;\r\n\r\n /* Tempo change event?\r\n */\r\n if (KF_EMPTY != kf.rbTempo[0] ||\r\n KF_EMPTY != kf.rbTempo[1] ||\r\n KF_EMPTY != kf.rbTempo[2])\r\n {\r\n if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))\r\n return SMF_NO_MEMORY;\r\n\r\n *lpdw++ = 0;\r\n *lpdw++ = 0;\r\n *lpdw++ = (((DWORD)kf.rbTempo[0])<<16)|\r\n (((DWORD)kf.rbTempo[1])<<8)|\r\n ((DWORD)kf.rbTempo[2])|\r\n (((DWORD)MEVT_TEMPO) << 24);\r\n\r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD);\r\n }\r\n\r\n /* Program change events?\r\n */\r\n for (idx = 0; idx < 16; idx++)\r\n {\r\n if (KF_EMPTY != kf.rbProgram[idx])\r\n {\r\n if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))\r\n return SMF_NO_MEMORY;\r\n\r\n *lpdw++ = 0;\r\n *lpdw++ = 0;\r\n *lpdw++ = (((DWORD)MEVT_SHORTMSG) << 24) |\r\n ((DWORD)MIDI_PROGRAMCHANGE) |\r\n ((DWORD)idx) |\r\n (((DWORD)kf.rbProgram[idx]) << 8);\r\n\r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD);\r\n }\r\n }\r\n\r\n /* Controller events?\r\n */\r\n idx = 0;\r\n for (idxChannel = 0; idxChannel < 16; idxChannel++)\r\n {\r\n for (idxController = 0; idxController < 120; idxController++)\r\n {\r\n if (KF_EMPTY != kf.rbControl[idx])\r\n {\r\n if (lpmh->dwBufferLength - lpmh->dwBytesRecorded < 3*sizeof(DWORD))\r\n return SMF_NO_MEMORY;\r\n\r\n *lpdw++ = 0;\r\n *lpdw++ = 0;\r\n *lpdw++ = (((DWORD)MEVT_SHORTMSG << 24) |\r\n ((DWORD)MIDI_CONTROLCHANGE) |\r\n ((DWORD)idxChannel) |\r\n (((DWORD)idxController) << 8) |\r\n (((DWORD)kf.rbControl[idx]) << 16));\r\n\r\n\r\n lpmh->dwBytesRecorded += 3*sizeof(DWORD);\r\n }\r\n\r\n idx++;\r\n }\r\n }\r\n\r\n /* Force all tracks to be at tkPosition. We are guaranteed that\r\n ** all tracks will be past the event immediately preceding tkPosition;\r\n ** this will force correct delta-ticks to be generated so that events\r\n ** on all tracks will line up properly on a seek into the middle of the\r\n ** file.\r\n */\r\n for (ptrk = pSmf->rTracks, idxTrack = pSmf->dwTracks; idxTrack--; ptrk++)\r\n {\r\n ptrk->tkPosition = tkPosition;\r\n }\r\n \r\n return SMF_SUCCESS;\r\n}\r\n\r\n/******************************************************************************\r\n*\r\n* smfGetStateMaxSize\r\n*\r\n* This function returns the maximum sizeof buffer that is needed to\r\n* hold the state information returned by f smfSeek.\r\n*\r\n* pdwSize - Gets the size in bytes that should be allocated\r\n* for the state buffer.\r\n*\r\n* Returns the state size in bytes.\r\n*\r\n*****************************************************************************/\r\nDWORD smfGetStateMaxSize(\r\n VOID)\r\n{\r\n return 3*sizeof(DWORD) + /* Tempo */\r\n 3*16*sizeof(DWORD) + /* Patch changes */ \r\n 3*16*120*sizeof(DWORD) + /* Controller changes */\r\n 3*sizeof(DWORD); /* Time alignment NOP */\r\n}\r\n\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARTPlus\r\n// -------\r\n//\r\n// Description:\r\n// The ARTPlus building block initialize the ARToolKitPlus for Single marker\r\n// detection. It should called once in your virtools project. Due to the fact,\r\n// that the number of pattern which can be detected, is set on compile time,\r\n// you can only detect 20 Pattern inside a video frame. If you want to detect\r\n// more, than you have to change the number and recompile (See line 183).\r\n//\r\n// Input Parameter:\r\n// IN_VIDEO_TEXTURE\t\t: The image, in with ARToolKitPlus\r\n//\t\t\t\t\t\t perform the detection\r\n// IN_CAMERA_PARAM_FILE : The filename of the camera parameter file\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_NEAR_CLIP_PLANE\t: Near clip plane used by the camera\r\n// IN_FAR_CLIP_PLANE\t: Far clip plane used by the camera\r\n//\t\t\t\t\t\t (look into ARToolKitPlus for description)\r\n// IN_ENABLE_CAMERA_CORRECTION :\r\n//\t\t\t\t\t\t Flag which indicates that the ARToolKitPlusManager\r\n//\t\t\t\t\t\t should use the camera transformation matrix as\r\n//\t\t\t\t\t\t projection matrix\r\n//\r\n// Output Parameter:\r\n// OUT_CAMERA_TRANSFORM_MATRIX :\r\n//\t\t\t\t\t\t The camera transformation matrix.\r\n// OUT_ERROR_STRING\t\t: String which describe the error, if one occurs. If\r\n//\t\t\t\t\t\t there was no error the string will contain the word\r\n//\t\t\t\t\t\t \"Success\" (without the marks)\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n// Input Parameter\r\n#define IN_VIDEO_TEXTURE 0\r\n#define IN_CAMERA_PARAM_FILE 1\r\n#define IN_NEAR_CLIP_PLANE 2\r\n#define IN_FAR_CLIP_PLANE 3\r\n#define IN_ENABLE_CAMERA_CORRECTION 4\r\n\r\n// Output Parameter\r\n#define OUT_CAMERA_TRANSFORM_MATRIX 0\r\n#define OUT_ERROR_STRING 1\r\n\r\n// Local Parameters\r\n#define LOCAL_TRACKER 0\r\n\r\n// Output Signals\r\n#define OUTPUT_OK 0\r\n#define OUTPUT_ERROR 1\r\n\r\n#include \"CKAll.h\"\r\n\r\n#include \"ARToolKitLogger.h\"\r\n#include \r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusDecl();\r\nCKERROR CreateARTPlusProto(CKBehaviorPrototype **);\r\n\r\nvoid cleanUp();\r\nint ARTPlus(const CKBehaviorContext& BehContext);\r\nint ARTPlusCallBack(const CKBehaviorContext& BehContext);\r\n\r\nbool ARTPlusInitialized = false;\r\nbool ARTPlusCorrectCamera = true;\r\n\r\nvoid argConvGlpara( float para[4][4], float gl_para[16] );\r\nvoid argConvGlparaTrans( float para[4][4], float gl_para[16] );\r\n\r\nARToolKitPlus::TrackerSingleMarker *tracker = NULL;\r\nARToolKitLogger logger;\r\n\r\nCKObjectDeclaration\t*FillBehaviorARTPlusDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Single Marker Tracker\");\t\r\n\t\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateARTPlusProto);\r\n\tod->SetDescription(\"Single Marker Tracker\");\r\n\tod->SetCategory(\"ARToolKitPlus\");\r\n\tod->SetGuid(CKGUID(0x6d8452a7, 0x94937df2));\r\n\tod->SetAuthorGuid(CKGUID(0x56495254,0x4f4f4c53));\r\n\tod->SetAuthorName(\"\");\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\r\n\treturn od;\r\n}\r\n\r\nCKERROR CreateARTPlusProto(CKBehaviorPrototype** pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Single Marker Tracker\");\r\n\tif (!proto) {\r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\t}\r\n\r\n//--- Inputs declaration\n\tproto->DeclareInput(\"In\");\n\r\n//--- Outputs declaration\n\tproto->DeclareOutput(\"Out\");\n\tproto->DeclareOutput(\"Error\");\n\r\n//--- Input Parameters declaration\n\tproto->DeclareInParameter(\"Video Image\", CKPGUID_TEXTURE);\n\tproto->DeclareInParameter(\"Camera-Param File\", CKPGUID_STRING, \"c:\\\\LogitechPro4000.dat\");\n\tproto->DeclareInParameter(\"Near Clip Plane\", CKPGUID_FLOAT, \"1.0\");\n\tproto->DeclareInParameter(\"Far Clip Plane\", CKPGUID_FLOAT, \"1000.0\");\n\tproto->DeclareInParameter(\"Enable Camera Correction\", CKPGUID_BOOL, \"TRUE\");\r\n\n//--- Output Parameters declaration\n\tproto->DeclareOutParameter(\"CameraMatrix\", CKPGUID_MATRIX);\n\tproto->DeclareOutParameter(\"Error\", CKPGUID_STRING, \"Success\");\n\r\n\r\n//----\tLocal Parameters Declaration\r\n\t//proto->DeclareLocalParameter(\"ARTracker\", CKPGUID_POINTER, NULL, 4);\r\n\r\n//----\tSettings Declaration\r\n\r\n\tproto->SetBehaviorCallbackFct(ARTPlusCallBack, CKCB_BEHAVIORATTACH|CKCB_BEHAVIORDETACH|CKCB_BEHAVIORDELETE|CKCB_BEHAVIOREDITED|CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORPRESAVE|CKCB_BEHAVIORPOSTSAVE|CKCB_BEHAVIORRESUME|CKCB_BEHAVIORPAUSE|CKCB_BEHAVIORRESET|CKCB_BEHAVIORRESET|CKCB_BEHAVIORDEACTIVATESCRIPT|CKCB_BEHAVIORACTIVATESCRIPT|CKCB_BEHAVIORREADSTATE, NULL);\r\n\tproto->SetFunction(ARTPlus);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint ARTPlus(const CKBehaviorContext& BehContext)\r\n{\r\n\tCKBehavior* beh = BehContext.Behavior;\r\n\tfloat nearclip = 1.0f;\r\n\tfloat farclip = 1000.0f;\r\n\tfloat* buffer = NULL;\r\n\tfloat gl_matirx[4][4];\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tif(ARTPlusInitialized == false)\r\n\t{\r\n\t\tCKTexture* texture = NULL;\r\n\t\tCKSTRING camparam = NULL;\r\n\t\tfloat nearclip = 1.0f;\r\n\t\tfloat farclip = 1000.0f;\r\n\t\tCKBOOL enableCamCorr = TRUE;\r\n\r\n\t\t// Texture (Important, request the Object not the Value or the Ptr!!!)\r\n\t\ttexture = CKTexture::Cast(beh->GetInputParameterObject(IN_VIDEO_TEXTURE));\r\n\r\n\t\tif(texture == NULL)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: No Texture Present\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\tint width = texture->GetWidth();\r\n\t\tint height = texture->GetHeight();\r\n\t\tint windowwidth = BehContext.CurrentRenderContext->GetWidth();\r\n\t\tint windowheight = BehContext.CurrentRenderContext->GetHeight();\r\n\r\n\t\t// Patternname\r\n\t\tcamparam = (CKSTRING)(beh->GetInputParameterReadDataPtr(IN_CAMERA_PARAM_FILE));\r\n\r\n\t\t// Fetch value for NearClip \r\n\t\tbeh->GetInputParameterValue(IN_NEAR_CLIP_PLANE, &nearclip);\r\n\r\n\t\t// Fetch value for FarClip\r\n\t\tbeh->GetInputParameterValue(IN_FAR_CLIP_PLANE, &farclip);\r\n\r\n\t\t// create a tracker that does:\r\n\t\t// - 12x12 sized marker images\r\n\t\t// - samples at a maximum of 12x12\r\n\t\t// - works with luminance (gray) images\r\n\t\t// - can load a maximum of 10 pattern\r\n\t\t// - can detect a maximum of 12 patterns in one image\r\n\t\ttracker = new ARToolKitPlus::TrackerSingleMarkerImpl<12,12,12,20,20>(width, height);\r\n\n\t\t// set a logger so we can output error messages\r\n\t\t//\r\n\t\ttracker->setLogger(&logger);\r\n\t\ttracker->setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_ABGR);\r\n\t\ttracker->setLoadUndistLUT(true);\r\n\r\n\t\ttracker->setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES);\r\n\r\n\t\t// load a camera file. two types of camera files are supported:\r\n\t\t// - Std. ARToolKit\r\n\t\t// - MATLAB Camera Calibration Toolbox\r\n\t\tif(!tracker->init(camparam, nearclip, farclip)) // load std. ARToolKit camera file\r\n\t\t//if(!tracker->init(\"data/PGR_M12x0.5_2.5mm.cal\", 1.0f, 1000.0f)) // load MATLAB file\r\n\t\t{\r\n\t\t\tprintf(\"ERROR: init() failed\\n\");\r\n\t\t\tdelete tracker;\r\n\t\t\ttracker = NULL;\r\n\r\n\t\t\tbeh->ActivateOutput(OUTPUT_ERROR);\r\n\t\t\tchar string[] = \"ERROR: init() failed\";\n\t\t\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\r\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\t// Fetch value for Camera Correction\r\n\t\tbeh->GetInputParameterValue(IN_ENABLE_CAMERA_CORRECTION, &enableCamCorr);\r\n\t\tARTPlusCorrectCamera = enableCamCorr==TRUE?true:false;\r\n\r\n\t\t// let's use lookup-table undistortion for high-speed\r\n\t\t// note: LUT only works with images up to 1024x1024\r\n\t\ttracker->setUndistortionMode(ARToolKitPlus::UNDIST_LUT);\r\n\r\n\t\t// RPP is more robust than ARToolKit's standard pose estimator\r\n\t\ttracker->setPoseEstimator(ARToolKitPlus::POSE_ESTIMATOR_RPP);\r\n\r\n//\t\tbeh->SetLocalParameterValue(LOCAL_TRACKER, (void *)tracker, 4);\r\n\r\n\t\tARTPlusInitialized = true;\r\n\t}\r\n\tbeh->ActivateOutput(OUTPUT_OK);\r\n\r\n//\tIn development\r\n//\tARToolKitPlus::TrackerSingleMarker *localTracker = (ARToolKitPlus::TrackerSingleMarker *)beh->GetLocalParameter(LOCAL_TRACKER);\r\n\r\n\tbuffer = (float *)tracker->getProjectionMatrix();\r\n\targConvGlpara(gl_matirx, buffer);\r\n\tVxMatrix mat = VxMatrix(gl_matirx);\r\n\r\n\t// Set matrix\r\n\tbeh->SetOutputParameterValue(OUT_CAMERA_TRANSFORM_MATRIX, &mat, 0);\r\n\r\n\t// Set error string\n\tchar string[] = \"Success\";\n\tbeh->SetOutputParameterValue(OUT_ERROR_STRING, string, strlen(string)+1);\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nint ARTPlusCallBack(const CKBehaviorContext& BehContext)\n{\n\tswitch (BehContext.CallbackMessage)\n\t{\n\t\tcase CKM_BEHAVIORATTACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDETACH:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDELETE:\n\t\t{\n\t\t\tcleanUp();\n\t\t\tbreak;\n\t\t}\n\t\tcase CKM_BEHAVIOREDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORLOAD:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPRESAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPOSTSAVE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESUME:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORPAUSE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORRESET:\n\t\t{\n\t\t\tcleanUp();\n\t\t\tbreak;\n\t\t}\n\t\tcase CKM_BEHAVIORNEWSCENE:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORDEACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORACTIVATESCRIPT:\n\t\t\tbreak;\n\t\tcase CKM_BEHAVIORREADSTATE:\n\t\t\tbreak;\n\t}\n\treturn CKBR_OK;\n}\r\n\r\nvoid cleanUp()\r\n{\r\n\tif(ARTPlusInitialized)\n\t{\n\t\ttracker->cleanup();\n\t\tdelete tracker;\n\t\tARTPlusInitialized = false;\r\n\t}\r\n\ttracker = NULL;\n}\r\n\r\nvoid argConvGlpara( float para[4][4], float gl_para[16] )\n{\n int i, j;\n\n for( j = 0; j < 4; j++ )\n\t{\n for( i = 0; i < 4; i++ )\n\t\t{\n para[j][i] = (gl_para[i*4+j]);\n }\n }\n}\n\nvoid argConvGlparaTrans( float para[4][4], float gl_para[16] )\n{\n int i, j;\n\n for( j = 0; j < 4; j++ )\n\t{\n for( i = 0; i < 4; i++ )\n\t\t{\n para[i][j] = (gl_para[i*4+j]);\n }\n }\n}\n\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n/* */\r\n/* */\r\n/* D L L F T P */\r\n/* */\r\n/* W I N D O W S */\r\n/* */\r\n/* P o u r A r t h i c */\r\n/* */\r\n/* V e r s i o n 3 . 0 */\r\n/* */\r\n/* */\r\n/* */\r\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\r\n\r\n\r\n\r\n\r\n#define FTP4W_INCLUDES_AND_GENERAL +\r\n\r\n#include \r\n#include \r\n\r\n\r\n#include /* external header file */ \r\n\r\n#include \"port32.h\" /* 16/32 bits */\r\n#include \"ftp4w.h\" /* external header file */ \r\n#include \"ftp4w_in.h\" /* internal header file */\r\n#include \"rfc959.h\" /* only for error codes */ \r\n\r\nextern LPProcData pFirstProcData;\r\n\r\n\r\n/* ******************************************************************* */\r\n/* */\r\n/* Partie V : Utilitaires Applicatifs */\r\n/* */\r\n/* ******************************************************************* */\r\n\r\n\r\n/* ----------------------------------------------------------- */\r\n/* ToolsLocateProcData : Retrouve la structure de données de */\r\n/* la session */\r\n/* ----------------------------------------------------------- */\r\nLPProcData ToolsLocateProcData (void)\r\n{\r\nLPProcData pProcData;\r\n for ( pProcData = pFirstProcData ;\r\n pProcData != NULL \r\n && (*pProcData->fIdentifyThread)()!= pProcData->nThreadIdent ;\r\n pProcData = pProcData->Next );\r\nreturn pProcData;\r\n} /* ToolsLocateProcData */\r\n\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpDataPtr */\r\n/* Renvoie un pointeur sur la structure */\r\n/* ------------------------------------------------------------ */\r\nLPProcData _export PASCAL FAR FtpDataPtr (void)\r\n{\r\nreturn ToolsLocateProcData ();\r\n} /* FtpDataPtr */\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpBufferPtr */\r\n/* Renvoie un pointeur sur le buffer de donnees*/\r\n/* ------------------------------------------------------------ */\r\nLPSTR _export PASCAL FAR FtpBufferPtr (void)\r\n{\r\nreturn ToolsLocateProcData()->ftp.szInBuf;\r\n} /* FtpDataPtr */\r\n\r\n\r\n\r\n/* -------------------------------------------------------------- */\r\n/* Fonctions DLL de parametrage */\r\n/* -------------------------------------------------------------- */\r\n/* Remplace les defines suivants */\r\n/* - FtpBytesTransferred() FtpDataPtr()->File.lPos */\r\n/* - FtpBytesToBeTransferred() FtpDataPtr()->File.lTotal */\r\n/* - FtpSetDefaultTimeOut(x) FtpDataPtr()->ftp.nTimeOut=x */\r\n/* - FtpSetDefaultPort(x) FtpDataPtr()->ftp.nPort=x */\r\n/* - FtpSetAsynchronousMode() FtpDataPtr()->File.bAsyncMode=TRUE */\r\n/* - FtpSetSynchronousMode() FtpDataPtr()->File.bAsyncMode=FALSE*/\r\n/* - FtpIsAsynchronousMode() FtpDataPtr()->File.bAsyncMode */\r\n/* - FtpSetNewDelay(x) FtpDataPtr()->File.nDelay=x */\r\n/* - FtpSetNewSlices(x,y) FtpDataPtr()->File.nAsyncAlone=x,\\ */\r\n/* FtpDataPtr()->File.nAsyncAlone=y */\r\n/* -------------------------------------------------------------- */\r\n\r\n/* redefinition of bad spelled functions */\r\nlong _export PASCAL FAR FtpBytesTransfered (void)\r\n{ return FtpBytesTransferred(); }\r\nlong _export PASCAL FAR FtpBytesToBeTransfered(void) \r\n{ return FtpBytesToBeTransferred(); }\r\n\r\n\r\n/* the new functions */\r\nlong _export PASCAL FAR FtpBytesTransferred (void) \r\n{LPProcData p = ToolsLocateProcData();\r\n return p==NULL ? 0 :p->File.lPos; }\r\n\r\nlong _export PASCAL FAR FtpBytesToBeTransferred(void) \r\n{LPProcData p = ToolsLocateProcData();\r\n return p==NULL ? 0 :p->File.lTotal; }\r\n\r\nvoid _export PASCAL FAR FtpSetDefaultTimeOut(int x) \r\n{ ToolsLocateProcData()->ftp.nTimeOut=x; /* x seconds */ }\r\n\r\nvoid _export PASCAL FAR FtpSetDefaultPort(int x) \r\n{ ToolsLocateProcData()->ftp.nPort=(short) x; }\r\n\r\nvoid _export PASCAL FAR FtpSetAsynchronousMode(void) \r\n{ ToolsLocateProcData()->File.bAsyncMode=TRUE; }\r\n\r\nvoid _export PASCAL FAR FtpSetSynchronousMode(void) \r\n{ ToolsLocateProcData()->File.bAsyncMode=FALSE; }\r\n\r\nBOOL _export PASCAL FAR FtpIsAsynchronousMode(void) \r\n{ return ToolsLocateProcData()->File.bAsyncMode; }\r\n\r\nvoid _export PASCAL FAR FtpSetNewDelay(int x) \r\n{ ToolsLocateProcData()->File.nDelay=x; /* x millisec */ }\r\n\r\nvoid _export PASCAL FAR FtpSetNewSlices(int x,int y) \r\n{ \r\nLPProcData p = ToolsLocateProcData();\r\n p->File.nAsyncAlone=x, p->File.nAsyncAlone=y;\r\n}\r\n\r\nvoid _export PASCAL FAR FtpSetPassiveMode (BOOL bPassif) \r\n{ ToolsLocateProcData()->ftp.bPassif = bPassif; }\r\n\r\nvoid _export PASCAL FAR FtpLogTo (HFILE hLogFile)\r\n{ ToolsLocateProcData()->ftp.hLogFile = hLogFile; }\r\n\r\nvoid _export PASCAL FAR FtpEnableDebugging (void)\r\n{ Tcp4uEnableLog (0xFFFF); }\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpSetVerboseMode */\r\n/* ------------------------------------------------------------ */\r\nint _export PASCAL FAR FtpSetVerboseMode (BOOL bMode, HWND hWnd, UINT wMsg)\r\n{\r\nLPProcData pProcData;\r\n\r\n pProcData = ToolsLocateProcData ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n pProcData->ftp.bVerbose = bMode;\r\n pProcData->VMsg.hVerboseWnd = hWnd;\r\n pProcData->VMsg.nVerboseMsg = wMsg;\r\nreturn FTPERR_OK; \r\n} /* SetVerboseMode */\r\n\r\n\r\n\r\n\r\n----------> DEV 35 Users \r\n - no cmo available ! \r\n \r\n1.0 General Notes \r\n 1.1 Installation \r\n - copy from BuildingBlocks\\vtTNL.dll to your dev\\BuildingBlocks directory\r\n - for testing of your application I recommend :\r\n - copy the entire Dev-YOUR-VERSION directory into your dev directory !\r\n - call vtNetServer.bat(a custom player in console mode) to start a cmo driven server or \r\n start \"xConsoleServer.exe\" (virtools independent server module !)\r\n\r\n2.0 Usage \r\n\t- start the server : xConsoleServer.exe or the embedded one !\r\n\t- create a session ( with password )\r\n\t- join to this session\r\n - now you can send messages and attach parameters of the type :\r\n - Vector 2/3/4 - D \r\n - String (256 chars per message !) \r\n - int /float\r\n\r\n Documentation in progress ! ;-)\r\n\r\n\r\n3.0 License issues : \r\n\r\n This distribution is for free and provided as it is !\r\n\r\n\r\nUpdates : \r\n\r\n Check vtmod svn details ! \r\n\r\nBugs : please post it preferably on vtmod or theswapmeet.\r\n\r\n\r\n\r\n\r\n \r\n\r\n#ifndef __VTWINDOW_H_\r\n#define __VTWINDOW_H_\r\n#include \r\n#include \"BaseMacros.h\"\r\n#include \r\n\r\n\r\nclass CCustomPlayer;\r\n\r\nclass vtWindow\r\n{\r\npublic:\r\n\r\n\tvtWindow();\r\n\tint CreateAsChild(long *parent);\r\n\tint Run();\r\n\tint Init();\r\n\tvoid ParseCommandLine(const char*cmdLine);\r\n\tvoid Destroy();\r\n\tint Tick();\r\n\tint DoFrame();\r\n\t\r\n\tint Show(int ShowFlags);\r\n\tint GetWidth();\r\n\tint GetHeight();\r\n\tint UpdateRenderSize(int w,int h);\r\n\r\n\r\n\t//send a message to a certain object given by name or when not specified as broadcast\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,int value);\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,float value);\r\n\tint SendMessage(char *targetObject,char *message,int id0,int id1,int id2,char* value);\r\n\r\n\t//pseudo message sending to csharp : \r\n\tint HasMessages();\r\n\tint GetNumMessages();\r\n\tchar *GetMessageName(int messageID);\r\n\tint GetNumParameters(int messageID);\r\n\tint GetMessageParameterType(int messageID,int parameterSubID);\r\n\t\r\n\tint GetMessageValueInt(int messageID,int parameterSubID);\r\n\tfloat GetMessageValueFloat(int messageID,int parameterSubID);\r\n\tchar* GetMessageValueStr(int messageID,int parameterSubID);\r\n\r\n\tvoid CleanMessages();\r\n\tvoid DeleteMessage(int messageID);\r\n\r\n\tvoid Pause();\r\n\tvoid Play();\r\n\tvoid LoadCompostion(char *file);\r\n\tvoid Terminate(int flags);\r\n\tint WndProc( long *hWnd, int uMsg, long * wParam, long* lParam );\r\n \r\nprotected:\r\n\r\n\tCCustomPlayer *m_Player;\r\n\tCONSOLE_SCREEN_BUFFER_INFO m_SavedConsoleInfo;\r\n\r\n\r\nprivate:\r\n};\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\r\n#endif##########################################################################################################\r\n# VIRTOOLS 2001\r\n# OpenGL List of Video cards with problems\r\n#\r\n# + To identify a video card you can either give the vendor,renderer and version of that card as found in\r\n# the caps file generated by engineTest.exe but it is specific to OpenGL or otherwise a card can be identified\r\n# by the description string given in the same file or in the preferences box in the interface...\r\n# + Each video card section must have a different name\r\n#\r\n#\r\n# Syntax: \r\n#\r\n# \r\n#\r\n#####################################################################################################################\r\n\r\n\r\n#################################################################################\r\n# Ati Radeon : Texture format bug on less than 16 bit textures \r\n# with alpha information in OpenGL\r\n\r\n\tCompany = ATI Technologies Inc.\r\n\tRenderer = Radeon\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# Matrox G400 : Texture format bug on less than 16 bit textures \r\n#\t\tFALSE MaxtextureWidth (2048 does not work)\r\n\r\n\tCompany = Matrox Graphics Inc.\r\n\tRenderer = Matrox G400\r\n\t\r\n\t\t_16_RGB555 = 1\r\n\t\t_16_RGB565 = 1\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_RGB332 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\r\n\tMaxTextureWidth = 1024\r\n\tMaxTextureHeight = 1024\r\n\r\n\r\n#################################################################################\r\n# Matrox G200 : Texture format bug on less than 16 bit textures\r\n#\t\tUnsuppoted ClampEdge extension \r\n#\t\tFALSE MaxtextureWidth (2048 does not work)\r\n\r\n\tCompany = Matrox Graphics Inc.\r\n\tRenderer = Matrox G200\r\n\t\r\n\t\t_16_RGB555 = 1\r\n\t\t_16_RGB565 = 1\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_RGB332 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\t_DXT5 = 1\r\n\t\r\n\tBug_ClampEdge = 1\r\n\tMaxTextureWidth = 1024\r\n\tMaxTextureHeight = 1024\r\n\r\n\r\n\r\n#################################################################################\r\n# 3DFX VOODOO5 : \r\n#\t\tFALSE MaxtextureWidth (2048 does not work)\r\n\r\n\r\n\tCompany = 3Dfx Interactive Inc.\r\n\tRenderer = 3Dfx/Voodoo5 (tm)/2 TMUs/32 MB SDRAM/KNI/ICD (Oct 24 2000)\r\n\tMaxTextureWidth = 1024\r\n\tMaxTextureHeight = 1024\r\n\r\n\r\n\r\n#################################################################################\r\n# Ati Rage Pro : Texture format bug on less than 16 bit textures \r\n# with alpha information in OpenGL\r\n\r\n\tCompany = ATI\r\n\tRenderer = RagePRO\r\n\t\r\n\t\tVXOS_WIN2K = 1\r\n\t\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# Ati Rage Pro on W98 (different renderer name): Texture format bug on less than 16 bit textures \r\n# with alpha information in OpenGL\r\n\r\n\tCompany = ATI\r\n\tRenderer = RAGE PRO\r\n\t\r\n\t\tVXOS_WIN98 = 1\r\n\t\r\n\t\r\n\t\t_32_ARGB8888 = 1\r\n\t\t_32_RGB888 = 1\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\t_DXT5 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# Ati Rage Pro on WIN NT4 (different renderer name): Texture format bug on less than 16 bit textures \r\n# with alpha information in OpenGL\r\n\r\n\tCompany = ATI\r\n\tRenderer = RagePRO\r\n\t\r\n\t\tVXOS_WINNT4 = 1\r\n\t\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# Power VR test : Texture format bug with DXT1 format Red Blue swapping\r\n\r\n\tCompany = Imagination Technologies\r\n\tRenderer = PowerVR KYRO\r\n\t\r\n\t\t_DXT1 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# ATI Radeon test : Texture format bug with 1555 format Red Blue swapping\r\n\r\n\tCompany = ATI Technologies Inc.\r\n\tRenderer = Radeon DDR x86/SSE\r\n\t\r\n\t\tVXOS_WINNT4 = 1\r\n\t\tVXOS_WIN2K = 1\r\n\t\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# I740 feedback : Texture Red Blue swapping\r\n\r\n\tCompany = Intel\r\n\tRenderer = Intel740\r\n\t\r\n\t\tVXOS_WIN98 = 1\r\n\t\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\t_32_ARGB8888 = 1\r\n\t\t_32_RGB888 = 1\r\n\t\t_16_ARGB4444 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\t_DXT1 = 1\r\n\t\t_DXT3 = 1\r\n\t\t_DXT5 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# ATI Radeon test : Texture format bug with 1555 format Red Blue swapping\r\n\r\n\tCompany = ATI Technologies Inc.\r\n# No renderer specified : all the ATI cards\r\n#\tRenderer = Radeon 7200 DDR x86/SSE\r\n\t\r\n\t\tVXOS_WINXP = 1\r\n\t\r\n\t\r\n\t\t_16_ARGB1555 = 1\r\n\t\r\n\r\n\r\n#################################################################################\r\n# 3D Labs Wildcat test : \r\n#\tTexture format bug with 565 format Red Blue swapping\r\n#\tFALSE MaxtextureWidth (2048 does not work)\r\n#################################################################################\r\n<3Dlabs WILDCAT VP>\r\n\tCompany = 3Dlabs\r\n\tRenderer = Wildcat VP970 - GL2\r\n\t\r\n\t\t_16_RGB565 = 1\r\n\t\t_8_ARGB2222 = 1\r\n\t\r\n\tMaxTextureWidth = 1024\r\n\tMaxTextureHeight = 1024\r\n\r\n\r\n#include \"StdAfx.h\"\r\n#include \"vtcxglobal.h\"\r\n#include \"InitMan.h\"\r\n#include \"vt_python_funcs.h\"\r\n\r\n\r\n#ifdef CK_LIB\r\n#define RegisterBehaviorDeclarations Register_TOOLS_BehaviorDeclarations\t\t\r\n#define InitInstance\t\t\t\t\t_TOOLS_InitInstance\r\n#define ExitInstance\t\t\t\t\t_TOOLS_ExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGet_TOOLS_PluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGet_TOOLS_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_TOOLS_PluginInfo\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n#define InitInstance\t\t\t\t\tInitInstance\r\n#define ExitInstance\t\t\t\t\tExitInstance\r\n#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\nCKPluginInfo g_PluginInfo;\r\nvt_python_man *pym = NULL;\r\n\r\nPLUGIN_EXPORT int CKGetPluginInfoCount(){return 2;}\r\n\r\n\r\nCKERROR InitInstanc1e(CKContext* context);\r\n\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n\r\n\tCKParameterManager* pm = context->GetParameterManager();\r\n\tvt_python_man* initman =new vt_python_man(context);\r\n\tpym = initman;\r\n\tpym->py = NULL;\r\n\tinitman->pLoaded = false;\r\n\tinitman->RegisterVSL();\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\tvt_python_man* initman =(vt_python_man*)context->GetManagerByGuid(INIT_MAN_GUID);\r\n\r\n\tDestroyPython();\r\n\tdelete initman;\r\n\treturn CK_OK;\r\n}\r\n#define INIT_BEH_GUID\t\tCKGUID(0x587c6467,0x4b970a1)\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tswitch (Index) \r\n\t{\r\n\tcase 0:\r\n\t\tg_PluginInfo.m_Author\t\t\t= VTCX_AUTHOR;\r\n\t\tg_PluginInfo.m_Description\t\t= \"Python Building Blocks\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= NULL;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_BEH_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"Python Building Blocks\";\r\n\t\tbreak;\r\n\r\n\tcase 1:\r\n\t\tg_PluginInfo.m_Author\t\t\t= VTCX_AUTHOR;\r\n\t\tg_PluginInfo.m_Description\t\t= \"Python Manager\";\r\n\t\tg_PluginInfo.m_Extension\t\t= \"\";\r\n\t\tg_PluginInfo.m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\t\tg_PluginInfo.m_Version\t\t\t= 0x000001;\r\n\t\tg_PluginInfo.m_InitInstanceFct\t= InitInstance;\r\n\t\tg_PluginInfo.m_ExitInstanceFct\t= ExitInstance;\r\n\t\tg_PluginInfo.m_GUID\t\t\t\t= INIT_MAN_GUID;\r\n\t\tg_PluginInfo.m_Summary\t\t\t= \"Python Manager\";\r\n\t\tbreak;\r\n\r\n\r\n\t}\r\n\treturn &g_PluginInfo;\r\n}\r\n\r\n\r\nPLUGIN_EXPORT void RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\tRegisterBehavior(reg,FillBehaviorCallPythonFuncDecl);\r\n\tRegisterBehavior(reg,FillBehaviorCallPythonFuncDecl2);\r\n\tRegisterBehavior(reg,FillBehaviorLoadPythonDecl);\r\n\tRegisterBehavior(reg,FillBehaviorDestroyPythonDecl);\r\n\tRegisterBehavior(reg,FillBehaviorGetNextBBIdDecl);\r\n\r\n\r\n}\r\n#ifndef _XDISTRIBUTED_RECT_H_\r\n#define _XDISTRIBUTED_RECT_H_\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xNetMath.h\"\r\n\r\n\r\nclass xDistributedRect : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\t\tPoint3F mData;\r\n\tprotected:\r\n\tprivate:\r\n};\r\n\r\n#endif#ifndef __P_VEHICLE_ALL_H__\r\n\t#define __P_VEHICLE_ALL_H__\r\n\r\n#include \r\n#include \r\n\r\n//using namespace std::numeric_limits;\r\n\r\n#define XFLT_EPSILON_MIN 0.00001f\r\n#define XFLT_EPSILON_MAX FLT_MAX\r\n\r\n#define xCheckFloat(n) ((fabs(n) > XFLT_EPSILON_MIN && n < XFLT_EPSILON_MAX ) ? n : 0.0f)\r\n\r\n\r\ntypedef enum pVehicleProcessoptions\r\n{\r\n\tpVPO_Lat_Damping=(1<<0),\r\n\tpVPO_Long_Damping=(1<<1),\r\n\tpVPO_SA_Damping=(1<<2),\r\n\tpVPO_SA_Delay=(1<<3),\r\n\tpVPO_SV_Tansa=(1<<4),\r\n\tpVPO_SA_DownSettle=(1<<5),\r\n\tpVPO_CheckLowSpeed=(1<<6),\r\n\tpVPO_Wheel_LockAdjust=(1<<7),\r\n\tpVPO_Wheel_UsePHYSX_Load=(1<<8),\r\n\tpVPO_Wheel_UsePHYSX_CONTACT_DATA=(1<<9),\r\n\tpVPO_Wheel_DoGregor=(1<<10),\r\n\tpVPO_Wheel_DampVerticalVelocityReversal=(1<<11),\r\n\tpVPO_Wheel_IntegrateImplicitVertical=(1<12),\r\n\tpVPO_Wheel_DiffDirect=(1<<13),\r\n\tpVPO_Engine_UseHardRevlimit=(1<<14),\r\n\tpVPO_Forces_No_Lateral=(1<<15),\r\n\r\n};\r\n\r\n#include \"pEngine.h\"\r\n#include \"pVehicleTypes.h\"\r\n#include \"pGearbox.h\"\r\n#include \"pDifferential.h\"\r\n#include \"pSteer.h\"\r\n\r\n\r\n\r\n\r\n#endif\r\n/*********************************************************************NVMH4****\r\nPath: SDK\\LIBS\\inc\\shared\r\nFile: NV_StringFuncs.h\r\n\r\nCopyright NVIDIA Corporation 2002\r\nTO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED\r\n*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS\r\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS\r\nBE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES\r\nWHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,\r\nBUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)\r\nARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS\r\nBEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r\n\r\n\r\n\r\nComments:\r\nA collection of useful string functions, built upon std::string\r\n\r\nThey are not all meant to be fast. Many return vectors of strings, which will\r\nrequire string copies and lots of work by the STL functions. For processing\r\nlarge strings or a lot of string data you will probably want to devise your\r\nown routines.\r\n\r\nA demo of using the functions is provided in:\r\nSDK\\DEMOS\\common\\src\\NV_StringFuncs\r\n\r\n\r\n******************************************************************************/\r\n\r\n\r\n#ifndef _NV_STRINGFUNCS_GJ_H\r\n#define _NV_STRINGFUNCS_GJ_H\r\n\r\n\r\n#pragma warning(disable : 4786)\t\t\t// STL warning\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n// sfsizet is size type for the string class used\r\ntypedef std::string::size_type sfsizet;\r\ntypedef std::basic_string tstring; \r\n\r\nnamespace NVStringConv\r\n{\r\n\t// use as an alternative to wcstombs()\r\n\tstd::string WStringToString( const std::wstring * in_pwstring );\r\n\tstd::string WStringToString( std::wstring & in_wstring );\r\n\tstd::string lpcwstrToString( LPCWSTR in_lpcwstr );\r\n\r\n\tstd::wstring StringToWString( const std::string * in_pString );\r\n\tstd::wstring StringToWString( std::string & in_String );\r\n\tstd::wstring lpcstrToWString( LPCSTR str );\r\n};\t\t\t\t// namespace NVStringConv\r\n\r\n/////////////////////////////////////////////////////////////////////\r\n// macro to expand vector of anything into single string\r\n// example c is \"%u \" and the % must match type held in vector\r\n// Example:\r\n// string dest;\r\n// vector< int > vint;\r\n// VEC_TO_STR( dest, vint, \"%d \" );\r\n//\r\n#ifndef VEC_TO_STR\r\n#define VEC_TO_STR( a, b, c )\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tfor( int vectocnt = 0; vectocnt < b.size(); vectocnt++ )\t\t\t\t\t\t\t\t\t\\\r\n\t{ a += StrPrintf( c, b.at(vectocnt) );\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n}\r\n#endif\r\n\r\n//////////////////////////\r\n// Convert list of some type to vector of same type\r\n// L is list, V is vector, T is type\r\n// Example:\r\n// list< string > lStr;\r\n// vector< string > vStr;\r\n// lStr.push_back( \"a\" );\r\n// lStr.push_back( \"b\" );\r\n// LIST_TO_VEC( lStr, vStr, std::string );\r\n\r\n#ifndef LIST_TO_VEC\r\n#define LIST_TO_VEC( L, V, T )\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tstd::list< T >::const_iterator ltovecmacroiter;\t\t\t\t\t\t\t\t\t\t\\\r\n\tfor( ltovecmacroiter = L.begin(); ltovecmacroiter != L.end(); ltovecmacroiter++ )\t\\\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t\tV.push_back( *ltovecmacroiter );\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n}\r\n#endif\r\n\r\n//////////////////////////\r\n// Convert vector of some type to list of same type\r\n// L is list, V is vector, T is type\r\n//\r\n#ifndef VEC_TO_LIST\r\n#define VEC_TO_LIST( V, L, T )\t\t\t\t\t\t\t\t\t\\\r\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n\tfor( int vtolistc=0; vtolistc < V.size(); vtolistc++ )\t\t\\\r\n\t{\tL.push_back( V.at(vtolistc) );\t\t\t\t\t\t\t\\\r\n\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\r\n}\r\n#endif\r\n\r\n/////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\t// Create a string using va_args, just like printf, sprintf, etc.\r\nstd::string StrPrintf( const char * szFormat, ... );\r\n\r\n\r\nstd::string StrToUpper( const std::string & strIn );\r\nstd::string StrToLower( const std::string & strIn );\r\n\r\n\t// Writes each string in the vector to a single output\r\n\t// string, separating each by a space.\r\nstd::string StrsToString( const std::vector< std::string > & vstrIn );\r\n\t// same, but lets you specify the separator between strings\r\nstd::string StrsToString( const std::vector< std::string > & vstrIn,\r\n\t\t\t\t\t\t const std::string & separator );\r\nstd::string StrsToString( const std::list< std::string > & lstrIn,\r\n\t\t\t\t\t\t const std::string & separator );\r\n\r\n\r\n\t// Like CString::Replace()\r\n\t// Sequence and it's replacement can be different lengths or empty\r\nstd::string StrReplace( const std::string & sequence_to_replace, \r\n\t\t\t\t\t\tconst std::string & replacement_string,\r\n\t\t\t\t\t\tconst std::string & strIn );\r\n\t// same as above, only it modifies pOut and also returns pOut\r\nstd::string * StrReplace( const std::string & sequence_to_replace, \r\n\t\t\t\t\t\t\tconst std::string & replacement_string,\r\n\t\t\t\t\t\t\tconst std::string & strIn,\r\n\t\t\t\t\t\t\tstd::string * pOut,\r\n\t\t\t\t\t\t\tbool bVerbose = false );\r\n\r\n\r\n\t// applies strtok repeatedly & acumulates ouput tokens \r\n\t// in output string separated by spaces\r\nstd::string StrTokenize( const std::string & strIn, const std::string & delimiters );\r\n\r\n\t// Same as above, but allows you to specify the separator between \r\n\t// tokens in the output\r\nstd::string StrTokenize( const std::string & strIn,\r\n\t\t\t\t\t\t const std::string & delimiters,\r\n\t\t\t\t\t\t const std::string & output_separator );\r\n\r\nsfsizet StrFindCaseless( const std::string & strSearchIn, sfsizet start_pos, const std::string & strSearchFor );\r\n\r\nstd::vector< sfsizet > StrFindAllCaseless( const std::string & strSearchIn,\r\n\t\t\t\t\t\t\t\t\t\t\tsfsizet start_pos,\r\n\t\t\t\t\t\t\t\t\t\t\tconst std::string & strSearchFor );\r\n\r\nstd::vector< sfsizet > StrFindAll( const std::string & strSearchIn,\r\n\t\t\t\t\t\t\t\t\t\t\tsfsizet start_pos,\r\n\t\t\t\t\t\t\t\t\t\t\tconst std::string & strSearchFor );\r\n\r\nstd::vector< std::string > StrSort( const std::vector< std::string > & vStrIn );\r\n\r\ntstring GetFilenameFromFullPath( const tstring & full_path );\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////\r\n/*\r\nMore ideas for functions to implement\r\nSortCaseless\r\nSort\t\t// case sensitive\r\n\r\n_stricmp - compare two strings without regard to case\r\n_strrev = reverse string\r\n*/\r\n\r\n#endif \r\n#include \"stdafx.h\"\r\n#include \"DistributedNetworkClassDialogCallback.h\"\r\n\r\n\r\n#include \"DistributedNetworkClassDialogMenu.h\"\r\n\r\n//static plugin interface that allow direct communication with Virtools Dev\r\nPluginInterface*\t\ts_Plugininterface\t= NULL;\r\n\r\n\r\n//main plugin callback for Virtools Dev\r\nvoid PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface)\r\n{\r\n\tswitch(reason)\r\n\t{\r\n\tcase PluginInfo::CR_LOAD:\r\n\t\t{\r\n\t\t\ts_Plugininterface\t= plugininterface;\r\n\t\t\tInitMenu();\r\n\t\t\tUpdateMenu();\r\n\t\t}break;\r\n\tcase PluginInfo::CR_UNLOAD:\r\n\t\t{\r\n\t\t\tRemoveMenu();\r\n\t\t\ts_Plugininterface\t= NULL;\r\n\t\t}break;\r\n\tcase PluginInfo::CR_NEWCOMPOSITIONNAME:\r\n\t\t{\r\n\t\t}break;\r\n\tcase PluginInfo::CR_NOTIFICATION:\r\n\t\t{\r\n\t\t}break;\r\n\t}\r\n}\r\n#include \r\n#include \"vtBaseManager.h\"\r\n\r\n/*\r\nvtBaseManager::vtBaseManager(CKContext *context,CKGUID guid,char* name):\tCKBaseManager(context,guid,name)\r\n{\r\n}\r\n*/\r\n\r\n/*\r\nvtBaseManager::~vtBaseManager()\r\n{\r\n\r\n}\r\n*//////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetProjection Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\n#define CKPGUID_PROJECTIONTYPE\t\tCKDEFINEGUID(0x1ee22148, 0x602c1ca1)\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetProjectionDecl();\r\nCKERROR CreateSetProjectionProto(CKBehaviorPrototype **pproto);\r\nint SetProjection(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetProjectionDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set Projection\");\t\r\n\tod->SetDescription(\"Sets the Projection Type of the Camera.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tProjection Type: the type of projection you want to use - orthographic or perspective.
\r\n\t
\r\n\tNote : The orthographic mode is useful to render simple object when depth is not important since the vertices transformation is much simpler.
\r\n
\r\n See Also: 'Orthographic Zoom'.
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xe444e666, 0x4eee6eee));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetProjectionProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetProjectionProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set Projection\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Projection Type\", CKPGUID_PROJECTIONTYPE, \"Orthographic\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetProjection);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint SetProjection(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\t// Get projection type\r\n\tint type=1;\r\n\tbeh->GetInputParameterValue(0,&type);\r\n\r\n\tcam->SetProjectionType( type );\r\n\r\n\treturn CKBR_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARPlusBehavior \r\n// --------------\r\n//\r\n// Description:\r\n// Defines the initialization routines for the plugin DLL. Done by the Virtools\r\n// wizzard\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n#include \"CKAll.h\"\r\n#include \"ARToolKitPlusManager.h\"\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief Switches between static library or dll \r\n//\r\n#ifdef CK_LIB\r\n#define RegisterBehaviorDeclarations\tRegister_VTAR_BehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\t_VTAR_InitInstance\r\n\t#define ExitInstance\t\t\t\t\t_VTAR_ExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGet_VTAR_PluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGet_VTAR_PluginInfo\r\n#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#else\r\n#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\tInitInstance\r\n\t#define ExitInstance\t\t\t\t\tExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\n\r\n\r\nCKERROR InitInstance(CKContext* context)\r\n{\r\n#ifdef Webpack\r\n\tInitInstanceCamera(context);\r\n#endif\r\n\r\n\tnew ARToolKitPlusManager(context);\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ExitInstance(CKContext* context)\r\n{\r\n\t// This function will only be called if the dll is unloaded explicitely \r\n\t// by a user in Virtools Dev interface\r\n\t// Otherwise the manager destructor will be called by Virtools runtime directly\r\n\r\n\tdelete context->GetManagerByGuid(ARToolKitPlusManagerGUID);\r\n\r\n#ifdef Webpack\r\n\tExitInstanceCamera(context);\r\n#endif\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\n#ifdef WebPack\r\n\textern CKERROR InitInstanceCamera(CKContext* context);\r\n\textern CKERROR ExitInstanceCamera(CKContext* context);\r\n\textern int RegisterCameraBeh(XObjectDeclarationArray *reg);\r\n#endif\r\n\r\n#ifdef WebPack\r\n\t#define GUID_MODULE_BUILDING_BLOCKS\tCKGUID(0x12d94eba,0x47057415)\r\n#else\r\n\t#define GUID_MODULE_BUILDING_BLOCKS\tCKGUID(0x6d8452a7, 0x94937df2)\r\n#endif\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\n#define PLUGIN_COUNT 2\r\n\r\nCKPluginInfo g_PluginInfo[PLUGIN_COUNT];\r\n\r\nint CKGetPluginInfoCount() {\treturn PLUGIN_COUNT; }\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CKPluginInfo* CKGetPluginInfo( int index )\r\n*\r\n* Description : This function takes an index and returns a corresponding plugin desciptor\r\n*\t\t\r\n* Parameters :\r\n* index, index of the plugin information to get\r\n*\r\n* Returns : pointer to the requested plugin information\r\n*\r\n*******************************************************************\r\n*/\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index);\r\n\r\nPLUGIN_EXPORT CKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tint Plugin = 0;\r\n\t// Register ARTPlus\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"The ARTPlus building block initialize the ARToolKitPlus for Single marker detection\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL;\r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= GUID_MODULE_BUILDING_BLOCKS;\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Tracker for Single Marker\";\r\n\tPlugin++;\r\n\t\r\n\t/*\r\n\t// Register ARTPlusPatternTransformation\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Buildingblock that transforms a given object by the detected transformation matrix of the corrosponding pattern (single marker)\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL; \r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0x6b733302,0x12d23c1f);\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Pattern Transformation\";\r\n\tPlugin++;\r\n\t// Register ARToolKitPlusDetect\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Buildingblock that detects pattern (single marker) in the given video image\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL; \r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0x1ff46552,0x6c31e58);\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Single Marker Detection\";\r\n\tPlugin++;\r\n\t//Register ARTPlusDetectionAndTransformation\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Buildingblock that detects a pattern (single marker) and transforms the related Object\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL; \r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0x2f9e2472,0x639e208c);\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Single Marker Detection and Transformation\";\r\n\tPlugin++;\r\n\t// Register ARTPlusMulti\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"The ARTPlus building block initialize the ARToolKitPlus for multi marker detection\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL; \r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0xa59f1,0x3d486f81);\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Tracker for Multi Marker\";\r\n\tPlugin++;\r\n\t//Register ARTPlusMultiDetectionAndTransformation\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"Buildingblock that detects a pattern (multi marker) and transforms the related Object\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= NULL; \r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= CKGUID(0x61232b96,0x598d625a);\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Multi Marker Detection and Transformation\";\r\n\tPlugin++;\r\n\t*/\r\n\r\n\t// Register ARToolKitPlusManager\r\n\tg_PluginInfo[Plugin].m_Author\t\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Description\t\t= \"This manager is used for setting the right camera projection matrix if an ARToolKitPlus building block is used and the flag ARTPlus(Multi)CorrectCamera is set\";\r\n\tg_PluginInfo[Plugin].m_Extension\t\t= \"\";\r\n\tg_PluginInfo[Plugin].m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\tg_PluginInfo[Plugin].m_Version\t\t\t= 0x00000001;\r\n\tg_PluginInfo[Plugin].m_InitInstanceFct\t= InitInstance;\r\n\tg_PluginInfo[Plugin].m_ExitInstanceFct\t= ExitInstance;\r\n\tg_PluginInfo[Plugin].m_GUID\t\t\t\t= ARToolKitPlusManagerGUID;\r\n\tg_PluginInfo[Plugin].m_Summary\t\t\t= \"ARToolKitPlus Manager\";\r\n\treturn &g_PluginInfo[Index];\r\n}\r\n\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n\r\n\tRegisterBehavior(reg, FillBehaviorARTPlusDecl);\r\n\tRegisterBehavior(reg, FillBehaviorARTPlusMultiDecl);\r\n\tRegisterBehavior(reg, FillBehaviorARToolKitPlusDetectDecl);\r\n\tRegisterBehavior(reg, FillBehaviorARTPlusPatternTransformationDecl);\r\n\tRegisterBehavior(reg, FillBehaviorARTPlusDetectionAndTransformationDecl);\r\n\tRegisterBehavior(reg, FillBehaviorARTPlusMultiDetectionAndTransformationDecl);\r\n\r\n\t#ifdef WebPack\r\n\t\tRegisterCameraBeh(reg);\r\n\t#endif\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointPulley::pJointPulley(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Pulley)\r\n{\r\n\r\n}\r\n\r\nvoid pJointPulley::setLocalAnchorA(VxVector anchor)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.localAnchor[0] = pMath::getFrom(anchor);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nVxVector pJointPulley::getLocalAnchorA()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pMath::getFrom(descr.localAnchor[0]);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setLocalAnchorB(VxVector anchor)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.localAnchor[1] = pMath::getFrom(anchor);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\n\r\nVxVector pJointPulley::getLocalAnchorB()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pMath::getFrom(descr.localAnchor[1]);\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setPulleyA(VxVector pulley)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.pulley[0] = pMath::getFrom(pulley);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nVxVector pJointPulley::getPulleyA()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pMath::getFrom(descr.pulley[0]);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setPulleyB(VxVector pulley)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.pulley[1] = pMath::getFrom(pulley);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nVxVector pJointPulley::getPulleyB()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn pMath::getFrom(descr.pulley[1]);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setStiffness(float stiffness)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.stiffness= stiffness;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nfloat pJointPulley::getStiffness()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return -1.0f;\r\n\tjoint->saveToDesc(descr);\r\n\treturn descr.stiffness;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setRatio(float ratio)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.ratio= ratio;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nfloat pJointPulley::getRatio()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return -1.0f;\r\n\tjoint->saveToDesc(descr);\r\n\treturn descr.ratio;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nvoid pJointPulley::setDistance(float distance)\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.distance= distance;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nfloat pJointPulley::getDistance()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return -1.0f;\r\n\tjoint->saveToDesc(descr);\r\n\treturn descr.distance;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::setRigid( bool rigid )\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (rigid)\r\n\t{\r\n\t\tdescr.flags|=NX_PJF_IS_RIGID;\r\n\t}else{\r\n\t\tdescr.flags&=~NX_PJF_IS_RIGID;\r\n\r\n\t}\r\n\tjoint->loadFromDesc(descr);\r\n}\r\nbool pJointPulley::isRigid()\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return -1.0f;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\treturn ( descr.flags & NX_PJF_IS_RIGID );\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\npMotor pJointPulley::getMotor()\r\n{\r\n\tNxPulleyJointDesc descr;\r\n\tNxPulleyJoint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\tNxMotorDesc mDescr = descr.motor;\r\n\tpMotor result;\r\n\tresult.freeSpin = mDescr.freeSpin;\r\n\tresult.targetVelocity= mDescr.velTarget;\r\n\tresult.maximumForce = mDescr.maxForce;\r\n\treturn result;\r\n}\r\nvoid pJointPulley::setMotor(pMotor motor)\r\n{\r\n\tNxPulleyJointDesc descr;\r\n\tNxPulleyJoint *joint = static_cast(getJoint());joint->saveToDesc(descr);\r\n\r\n\tNxMotorDesc mDescr = descr.motor;\r\n\r\n\tif (motor.maximumForce!=0.0f && motor.targetVelocity !=0.0f )\r\n\t{\r\n\t\tmDescr.freeSpin = motor.freeSpin;\r\n\t\tmDescr.velTarget= motor.targetVelocity;\r\n\t\tmDescr.maxForce= motor.maximumForce;\r\n\t\tdescr.flags |= NX_PJF_MOTOR_ENABLED;\r\n\t\tjoint->setMotor(mDescr);\r\n\t\tdescr.motor = mDescr;\r\n\t}else{\r\n\t\tdescr.flags &=~NX_PJF_MOTOR_ENABLED;\r\n\t}\r\n\r\n\tint flagsNow = descr.flags;\r\n\tint isValid = descr.isValid();\r\n\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid pJointPulley::enableCollision( bool collision )\r\n{\r\n\tNxPulleyJointDesc descr;\t\t\r\n\tNxPulleyJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n//{{NO_DEPENDENCIES}}\r\n// Microsoft Visual C++ generated include file.\r\n// Used by CPResource.rc\r\n//\r\n#define IDD_ABOUTBOX 100\r\n#define IDR_MAINFRAME 128\r\n#define IDD_DIALOGSETUP 129\r\n#define IDI_VIRTOOLS 135\r\n#define IDR_LICENSE 137\r\n#define IDR_ABOUT 138\r\n#define IDD_DIALOGINIT 146\r\n#define IDD_SPLASH 147\r\n#define IDS_ABOUT_ABOUTTEXTss 200\r\n#define IDS_ABOUT_THANKSTOTEXT 201\r\n#define IDS_ABOUT_ABOUT 202\r\n#define IDS_ABOUT_THANKSTO 203\r\n#define IDS_ABOUT_LICENSEAGREEMENT 204\r\n#define IDC_STATIC_LOADING 1000\r\n#define IDC_FULLSCREENDRIVERLIST 1001\r\n#define IDC_WINDOWEDDRIVERLIST 1002\r\n#define IDC_FULLSCREENMODELIST 1003\r\n#define IDC_FULLSCREEN32BITS 1004\r\n#define IDC_STATIC_SPLASHLOADING 1005\r\n#define IDC_COMBO1 1006\r\n#define IDC_CB_WMODES 1006\r\n#define IDC_WINSIZE 1007\r\n#define IDCB_RRATE 1008\r\n#define IDC_ERROR_RICHEDIT 1009\r\n#define IDC_RICHEDIT21 1009\r\n#define IDCB_BPP 1009\r\n#define IDC_ERROR_RICHT_TEXT 1009\r\n#define IDC_DRIVER_LIST 1011\r\n#define IDC_TAB 1013\r\n#define IDC_CB_BPPS 1013\r\n#define IDC_CAPTION 1014\r\n#define IDC_CB_RRATES 1014\r\n#define IDC_CHECKB_FULLSCREEN 1015\r\n#define IDC_RADIO1 1016\r\n#define IDC_LIST1 1017\r\n#define IDC_COMBO2 1018\r\n#define IDC_CB_FSSA 1018\r\n#define IDC_TEXT 1112\r\n#define IDC_CB_FMODE 1112\r\n#define IDD_STYLE 1310\r\n#define IDC_RECTANGLE 1311\r\n#define IDC_ROUND_RECTANGLE 1312\r\n#define IDC_ELLIPSE 1313\r\n#define IDC_FSSA_RADIO_0 1317\r\n#define IDC_FSSA_RADIO_1 1318\r\n#define IDR_MENU1 2101\r\n#define IDD_ERROR 2110\r\n#define IDD_ABOUTP 2700\r\n#define IDD_DIALOG1 22770\r\n#define IDD_DIALOG2 22771\r\n#define TB_IDC_D3DC_WINDOWED_MODE 22773\r\n#define IDC_SCREENSETTINGS 22774\r\n#define TB_IDC_D3DC_FULLSCREEN_MODE 22775\r\n#define IDC_LISTMODE 22776\r\n#define IDC_LISTDRIVER 22777\r\n#define IDC_CHECK1 22778\r\n#define IDC_CHB_FULLSCREEN 22778\r\n#define IDC_LISTMODE2 22779\r\n#define IDC_FSSA_0 22779\r\n#define IDC_CANCEL2 22780\r\n#define IDC_FSS_SELCTION 22781\r\n#define IDC_FSSA_1 22781\r\n#define IDC_FSS_SELCTION2 22782\r\n#define IDC_FSSA_2 22782\r\n#define IDB_SPLASH 22783\r\n#define ID_PLAYER_RESET 32770\r\n#define ID_PLAYER_FULLSCREEN 32771\r\n#define ID_PLAYER_QUIT 32772\r\n#define ID_PLAYER_SETUP 32774\r\n#define ID_PLAYER_WEBSITE 32775\r\n\r\n// Next default values for new objects\r\n// \r\n#ifdef APSTUDIO_INVOKED\r\n#ifndef APSTUDIO_READONLY_SYMBOLS\r\n#define _APS_NEXT_RESOURCE_VALUE 105\r\n#define _APS_NEXT_COMMAND_VALUE 40001\r\n#define _APS_NEXT_CONTROL_VALUE 1019\r\n#define _APS_NEXT_SYMED_VALUE 101\r\n#endif\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBSetMaterialDecl();\r\nCKERROR CreatePBSetMaterialProto(CKBehaviorPrototype **pproto);\r\nint PBSetMaterial(const CKBehaviorContext& behcontext);\r\nCKERROR PBSetMaterialCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\nenum bInputs\r\n{\r\n\tI_XML,\r\n\tI_DFRICTION,\r\n\tI_SFRICTION,\r\n\tI_RES,\r\n\tI_DFRICTIONV,\r\n\tI_SFRICTIONV,\r\n\tI_ANIS,\r\n\tI_FCMODE,\r\n\tI_RCMODE,\r\n\tI_FLAGS,\r\n};\r\n\r\nCKERROR PBSetMaterialCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\tCKContext *ctx = beh->GetCKContext();\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\r\n\t\t\tDWORD outputResult = 0;\r\n\t\t\tbeh->GetLocalParameterValue(1,&outputResult);\r\n\t\t\tbeh->EnableOutputParameter(0,outputResult);\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\r\n\t\t\tDWORD outputResult = 0;\r\n\t\t\tbeh->GetLocalParameterValue(1,&outputResult);\r\n\t\t\tbeh->EnableOutputParameter(0,outputResult);\r\n\r\n\t\t\tint fromParameter=0;\r\n\t\t\tbeh->GetLocalParameterValue(0,&fromParameter);\r\n\r\n\t\t\tif (fromParameter)\r\n\t\t\t{\r\n\t\t\t\tif (beh->GetInputParameterCount() > 1 )\r\n\t\t\t\t{\r\n\t\t\t\t\twhile ( beh->GetInputParameterCount())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCKDestroyObject(beh->RemoveInputParameter(0));\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Material Settings\",VTS_MATERIAL);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (!fromParameter)\r\n\t\t\t{\r\n\t\t\t\tif (beh->GetInputParameterCount() < 2 )\r\n\t\t\t\t{\r\n\t\t\t\t\tCKDestroyObject(beh->RemoveInputParameter(0));\r\n\t\t\t\t\tbeh->CreateInputParameter(\"XML Link\",VTE_XML_MATERIAL_TYPE);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Dynamic Friction\",CKPGUID_FLOAT);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Static Friction\",CKPGUID_FLOAT);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Restitution\",CKPGUID_FLOAT);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Dynamic Friction V\",CKPGUID_FLOAT);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Static Friction V\",CKPGUID_FLOAT);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Direction of Anisotropy \",CKPGUID_VECTOR);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Friction Combine Mode\",VTE_MATERIAL_COMBINE_MODE);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Restitution Combine Mode\",VTE_MATERIAL_COMBINE_MODE);\r\n\t\t\t\t\tbeh->CreateInputParameter(\"Flags\",VTF_MATERIAL_FLAGS);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPBSetMaterialDecl\r\n// FullName: FillBehaviorPBSetMaterialDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration*FillBehaviorPBSetMaterialDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBSetMaterial\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Attaches and/or modifies the physic material of a rigid body or its sub shape\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x52523d82,0x5cb74a78));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBSetMaterialProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBSetMaterialProto\r\n// FullName: CreatePBSetMaterialProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBSetMaterialProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBSetMaterial\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Material Settings\",VTS_MATERIAL,\"NONE\");\r\n\tproto->DeclareSetting(\"From Material Parameter\",CKPGUID_BOOL,\"TRUE\");\r\n\tproto->DeclareSetting(\"Output Result\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Add Attribute\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\tproto->DeclareOutParameter(\"Result\",VTS_MATERIAL);\r\n\r\n\r\n\t/*! \\page PBSetMaterial \r\n\r\n\tPBSetMaterial is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies a rigid bodies physic material .
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PBSetMaterial.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\t\r\n\tTarget: The 3D Entity associated to the rigid body or its sub shape.\r\n\t
\r\n\t\r\n\r\n\tXML Link: The name of the material stored in the chosen xml file. If set to \"None\" the values from the parameter struct will be used. The list of avaiable materials will be updated from PhysicDefaults.xml on Dev reset.\r\n\t
\r\n\r\n\tDynamic Friction: Coefficient of dynamic friction -- should be in [0, +inf]. If set to greater than staticFriction, the effective value of staticFriction will be increased to match.\r\n\tIf in the flags \"Anisotropic\" is set, then this value is used for the primary direction of anisotropy (U axis).
\r\n\r\n\t\tRange: [0,inf]
\r\n\t\tDefault: 0.0\r\n\r\n\r\n\tStatic Friction: Coefficient of static friction -- should be in [0, +inf]\r\n\tIf in the flags \"Anisotropic\" is set, then this value is used for the primary direction of anisotropy (U axis)\r\n\r\n\t\tRange: [0,inf]
\r\n\t\tDefault: 0.0\r\n\r\n\tRestitution: Coefficient of restitution -- 0 makes the object bounce as little as possible, higher values up to 1.0 result in more bounce.\r\n\tNote that values close to or above 1 may cause stability problems and/or increasing energy.\r\n\r\n\t\tRange: [0,1]
\r\n\t\tDefault: 0.0\r\n\r\n\tDynamic Friction V: Anisotropic dynamic friction coefficient for along the secondary (V) axis of anisotropy. \r\n\tThis is only used if the flag Anisotropic is set.\r\n\t\r\n\t\tRange: [0,inf]
\r\n\t\tDefault: 0.0\r\n\r\n\tStatic Friction V : Anisotropic static friction coefficient for along the secondary (V) axis of anisotropy. \r\n\tThis is only used if the flag Anisotropic is set.\r\n\r\n\t\tRange: [0,inf]
\r\n\t\tDefault: 0.0\r\n\r\n\r\n\tDir Of Anisotropy: Shape space direction (unit vector) of anisotropy.\r\n\tThis is only used if flags Anisotropic is set.\r\n\r\n\t\tRange: direction vector
\r\n\t\tDefault: 1.0f,0.0f,0.0f\r\n\r\n\tFlags: Flags, a combination of the bits defined by the enum ::MaterialFlags. \r\n\r\n\tFrom Material Parameter: Switches the input method between the custom parameter struct \"pMaterial\" and its enacpsulated input. The parameter \"pMaterial\" can be modified through parameter operations!\r\n\t
\r\n\r\n\tOutput Result: Outputs a pMaterial parameter. This can be useful if a xml setup has be been chosen.\r\n\t
\r\n\r\n\tAdd Attribute: Adds the resulting material as a parameter to the selected object.\r\n\t
\r\n\r\n\t\r\n\t

Warning

\r\n\t-\tBy default, each body or sub shape retrieves the worlds default material(PhysicDefaults.xml - Default). This building block creates or modifies a new material.\r\n\t-\tIf the settings are invalid, the building block aborts and outputs a message in the console. \r\n\t-\tYou can assign a material to a deformable or a cloth object.\r\n\r\n\r\n\t
\r\n\t
\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PBSetMaterialCB );\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PBSetMaterial);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PBSetMaterial\r\n// FullName: PBSetMaterial\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n\r\n\r\n\r\n\r\nint PBSetMaterial(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\t\r\n\r\n\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target )\tbbSErrorME(E_PE_REF);\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)\r\n\t\t\tbody = GetPMan()->getBody(target);\r\n\r\n\t\tif( !body )\tbbSErrorME(E_PE_REF);\r\n\r\n\t\tint fromStruct=0;\r\n\t\tbeh->GetLocalParameterValue(0,&fromStruct);\r\n\r\n\t\tint output=0;\r\n\t\tbeh->GetLocalParameterValue(1,&output);\r\n\t\t\r\n\t\tint AddAsAttribute=0;\r\n\t\tbeh->GetLocalParameterValue(2,&AddAsAttribute);\r\n\r\n\r\n\r\n\t\tpMaterial mat;\r\n\t\tmat.setToDefault();\r\n\r\n\r\n\t\tif (fromStruct)\r\n\t\t{\r\n\t\t\tCKParameter *mParameter = beh->GetInputParameter(0)->GetRealSource();\r\n\t\t\tif (mParameter)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(mat,mParameter);\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tmat.xmlLinkID = GetInputParameterValue(beh,I_XML);\r\n\t\t\tmat.dynamicFriction = GetInputParameterValue(beh,I_DFRICTION);\r\n\t\t\tmat.dynamicFrictionV = GetInputParameterValue(beh,I_DFRICTIONV);\r\n\t\t\tmat.staticFriction = GetInputParameterValue(beh,I_SFRICTION);\r\n\t\t\tmat.staticFrictionV = GetInputParameterValue(beh,I_SFRICTIONV);\r\n\t\t\tmat.restitution = GetInputParameterValue(beh,I_RES);\r\n\t\t\tmat.dirOfAnisotropy = GetInputParameterValue(beh,I_ANIS);\r\n\t\t\tmat.restitutionCombineMode = (CombineMode)GetInputParameterValue(beh,I_RCMODE);\r\n\t\t\tmat.frictionCombineMode = (CombineMode)GetInputParameterValue(beh,I_FCMODE);\r\n\t\t\tmat.flags = GetInputParameterValue(beh,I_FLAGS);\r\n\t\t}\r\n\r\n\t\tXString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,mat.xmlLinkID);\r\n\t\tif ( mat.xmlLinkID !=0 )\r\n\t\t{\r\n\t\t\t\r\n\t\t\tbool err = pFactory::Instance()->loadFrom(mat,nodeName.Str(),pFactory::Instance()->getDefaultDocument());\r\n\t\t\tif (!err)\r\n\t\t\t{\r\n\t\t\t\tXString error; \r\n\t\t\t\terror << \"Couldn't load \" << nodeName << \" from XML!\";\r\n\t\t\t\tbbErrorME(error.Str());\r\n\t\t\t}\r\n\t\t\tif (output)\r\n\t\t\t{\r\n\t\t\t\tpFactory::Instance()->copyTo(beh->GetOutputParameter(0),mat);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!mat.isValid())\r\n\t\t{\r\n\t\t\tXString error; \r\n\t\t\terror << \"Material Settings \" << nodeName << \" are invalid!\";\r\n\t\t\tbbErrorME(error.Str());\r\n\t\t}\r\n\r\n\t\tif (mat.isValid())\r\n\t\t{\r\n\t\t\tbody->setShapeMaterial(mat,target);\r\n\r\n\t\t\tif (AddAsAttribute)\r\n\t\t\t{\r\n\t\t\t\tif (!target->HasAttribute(GetPMan()->att_surface_props))\r\n\t\t\t\t\ttarget->SetAttribute(GetPMan()->att_surface_props);\r\n\t\t\t\tpFactory::Instance()->copyTo(target->GetAttributeParameter(GetPMan()->att_surface_props),mat);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedPropertyInfo* xDistributedClass::exists(int nativeType)\r\n{\r\n\txDistributedPropertyInfo *result = NULL;\r\n\tif (getDistributedProperties() ==NULL ) return NULL;\r\n\tint size = getDistributedProperties()->size();\r\n\tfor (unsigned int i = 0 ; i < getDistributedProperties()->size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo * current = m_DistributedProperties->at(i);\r\n\t\tint nType = current->mNativeType ;\r\n\t\tif ( current->mNativeType == nativeType)\r\n\t\t{\r\n\t\t\treturn current;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedPropertyInfo*\txDistributedClass::exists(const char*name)\r\n{\r\n\txDistributedPropertyInfo *result = NULL;\r\n\r\n\tif (!strlen(name))return result;\r\n\t\r\n\tfor (unsigned int i = 0 ; i < getDistributedProperties()->size() ; i ++ )\r\n\t{\r\n\t\txDistributedPropertyInfo * current = m_DistributedProperties->at(i);\r\n\t\tif (!strcmp(current->mName.getString(),name))\r\n\t\t{\r\n\t\t\treturn current;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributed3DObjectClass*xDistributedClass::cast(xDistributedClass *_in){\treturn static_cast(_in);\t}\r\n\r\n\r\nxNString \r\nxDistributedClass::getClassName()\r\n{\r\n\r\n\treturn m_ClassName;\r\n}\r\nxDistributedClass::~xDistributedClass()\r\n{\r\n\r\n\tm_DistributedProperties->clear();\r\n\t//delete m_DistributedProperties;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid xDistributedClass::setClassName(xNString name)\r\n{\r\n\tm_ClassName = name;\r\n}\r\n\r\nxDistributedClass::xDistributedClass()\r\n{\r\n\r\n\tm_DistributedProperties = new xDistributedPropertiesListType();\r\n\tm_EnitityType = 0;\r\n\tm_NativeFlags = 0;\r\n\r\n}\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJIteratorDecl();\r\nCKERROR CreatePJIteratorProto(CKBehaviorPrototype **pproto);\r\nint PJIterator(const CKBehaviorContext& behcontext);\r\nCKERROR PJIteratorCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJIteratorDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJIterator\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Iterates through bodies joints\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x115941e7,0x15861d73));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJIteratorProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJIteratorProto\r\n// FullName: CreatePJIteratorProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nenum bInput\r\n{\r\n};\r\nenum bbO\r\n{\r\n\r\n\tbbO_BodyB,\r\n\tbbO_Type,\r\n\r\n};\r\nenum bbOT\r\n{\r\n\tbbOT_Finish,\r\n\tbbOT_Next,\r\n};\r\nCKERROR CreatePJIteratorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJIterators\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJIterator\r\n\r\n\r\n\tPJIterators is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tPerforms a ray cast test. Outputs hit informations.
\r\n\tSee PWRayCasts.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJIterators.png\r\n\r\n\tIn: Triggers the process.\r\n\t
\r\n\tNext: Next Hit.\r\n\t
\r\n\t\r\n\t\r\n\tYes: Hit occured.\r\n\t
\r\n\tNo: No hits.\r\n\t
\r\n\tFinish: Last hit.\r\n\t
\r\n\tNext: Loop out.\r\n\t
\r\n\r\n\r\n\r\n\r\n\r\n\tTarget: World Reference. pDefaultWorld!\r\n\t
\r\n\tRay Origin: Start of the ray.\r\n\t
\r\n\tRay Origin Reference: Reference object to determine the start of the ray. Ray Origin becomes transformed if an object is given.\r\n\t
\r\n\tRay Direction: Direction of the ray.\r\n\t
\r\n\tRay Direction Reference: Reference object to determine the direction of the ray. Ray Direction becomes transformed if an object is given. Up axis will be used then.\r\n\t
\r\n\tLength: Lenght of the ray.\r\n\t
\r\n\tShapes Types: Adds static and/or dynamic shapes to the test.\r\n\t
\r\n\r\n\tGroups: Includes specific groups to the test. \r\n\t
\r\n\tGroups Mask: Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t
\r\n\r\n\tTouched Body: The touched body.\r\n\t
\r\n\tImpact Position: Hit point in world space.\r\n\t
\r\n\tFace Normal: Normal of the hit.\r\n\t
\r\n\tFace Index: \r\n\t
\r\n\tDistance: Distance between ray start and hit.\r\n\t
\r\n\tUV: not used yet !\r\n\t
\r\n\tMaterial Index: Index of the internal physic material.\r\n\t
\r\n\t\r\n\t\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pWorld::raycastAllShapes()
\r\n\t\r\n\t*/\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"LoopOut\");\r\n\r\n\tproto->DeclareLocalParameter(\"result\", CKPGUID_POINTER);\r\n\tproto->DeclareLocalParameter(\"index\", CKPGUID_INT);\r\n\r\n\tproto->DeclareOutParameter(\"Body B\",CKPGUID_3DENTITY);\r\n\tproto->DeclareOutParameter(\"Joint Type\",VTE_JOINT_TYPE);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PJIteratorCB );\r\n\tproto->SetFunction(PJIterator);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nstruct _pJoint\r\n{\r\n\tpJoint *_j;\r\n\tCK3dEntity *_b;\r\n\r\n};\r\ntypedef std::vector<_pJoint*>_pJointList;\r\n\r\n\r\n//************************************\r\n// Method: PJIterator\r\n// FullName: PJIterator\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJIterator(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// the world : \r\n\t\r\n\tpWorld *world=GetPMan()->getWorldByBody(target); \r\n\tif (!world)\r\n\t\tbbErrorME(\"No valid world object found\");\r\n\r\n\r\n\tpRigidBody *body = NULL;\r\n\r\n\tbody = GetPMan()->getBody(target);\r\n\tif (!body)\tbbErrorME(\"Object not physicalized\");\r\n\r\n\t/************************************************************************/\r\n\t/* we come in by reset */\r\n\t/************************************************************************/\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\t_pJointList *jarray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&jarray);\r\n\t\tif (jarray)\r\n\t\t{\r\n\t\t\tjarray->clear();\r\n\t\t}else\r\n\t\t{\r\n\t\t\tjarray = new _pJointList();\r\n\t\t}\r\n\t\t\r\n\t\tbeh->SetLocalParameterValue(0,&jarray);\r\n\r\n\t\tint hitIndex = 0;\r\n\t\tbeh->SetLocalParameterValue(1,&hitIndex);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// get joint list\r\n\t\tint nbJoints = body->getNbJoints();\r\n\t\tif (nbJoints)\r\n\t\t{\r\n\t\t\tNxU32\tjointCount = world->getScene()->getNbJoints();\r\n\t\t\tif (jointCount)\r\n\t\t\t{\r\n\t\t\t\tNxArray< NxJoint * > joints;\r\n\r\n\t\t\t\tworld->getScene()->resetJointIterator();\r\n\r\n\t\t\t\tfor\t(NxU32 i = 0;\ti\t<\tjointCount;\t++i)\r\n\t\t\t\t{\r\n\t\t\t\t\tNxJoint\t*j = world->getScene()->getNextJoint();\r\n\t\t\t\t\tpJoint *mJoint = static_cast( j->userData );\r\n\r\n\t\t\t\t\tif ( mJoint )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (mJoint->GetVTEntA() == target || mJoint->GetVTEntB() == target )\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t_pJoint *j = new _pJoint();\r\n\t\t\t\t\t\t\tj->_j = mJoint;\r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\tif (mJoint->GetVTEntA() == target )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tj->_b = mJoint->GetVTEntB();\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tif (mJoint->GetVTEntB() == target )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tj->_b = mJoint->GetVTEntA();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tjarray->push_back(j);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (nbJoints)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbOT_Next);\r\n\t\t\tbeh->ActivateInput(1,TRUE);\r\n\r\n\t\t}else{\r\n\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t}\r\n\t}\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\t_pJointList *carray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&carray);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\tif (carray->size())\r\n\t\t\t{\r\n\t\t\t\t_pJoint *hit = carray->at(carray->size()-1);\r\n\t\t\t\tif (hit)\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->SetOutputParameterObject(bbO_BodyB,hit->_b);\r\n\t\t\t\t\tSetOutputParameterValue(beh,bbO_Type,hit->_j->getType());\r\n\t\t\t\t\tcarray->pop_back();\r\n\t\t\t\t\tif (carray->size())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Next);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PJIteratorCB\r\n// FullName: PJIteratorCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJIteratorCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n/********************************************************************\r\n\tcreated:\t2009/02/16\r\n\tcreated:\t16:2:2009 20:25\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common\\vtInterfaceEnumeration.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\Include\\Core\\Common \r\n\tfile base:\tvtInterfaceEnumeration\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tDeclaration of enumerations with bindings in the interface :\r\n\t\t\t\t+ VSL \r\n\t\t\t\t+ Custom Enumeration\r\n\r\n\tRemarks\t\tThe identifiers described here need to be consistent with types\r\n\t\t\t\tregistered for the interface. All types are used by this SDK\r\n\r\n*********************************************************************/\r\n#ifndef __VT_INTERFACE_ENUMERATION_H__\r\n#define __VT_INTERFACE_ENUMERATION_H__\r\n\r\n\r\n\r\n\r\n\t/** \\addtogroup Callbacks\r\n\t@{\r\n\t*/\r\n\ttypedef enum pCallback\r\n\t{\r\n\t\tCB_OnDelete\t\t\t\t=\t(1<<0),\r\n\t\tCB_OnCopy\t\t\t\t=\t(1<<1),\r\n\t\tCB_OnPreProcess\t\t\t=\t(1<<2),\r\n\t\tCB_OnPostProcess\t\t=\t(1<<3),\r\n\t\tCB_OnContactNotify\t\t=\t(1<<4),\r\n\t\tCB_OnContactModify\t\t=\t(1<<5),\r\n\t\tCB_OnRayCastHit\t\t\t=\t(1<<6),\r\n\t\tCB_OnWheelContactModify\t=\t(1<<7),\r\n\t\tCB_OnTrigger\t\t\t=\t(1<<8),\r\n\t\tCB_OnJointBreak\t\t\t=\t(1<<9),\r\n\t\tCB_Max,\r\n\t};\r\n\ttypedef enum pWheelContactModifyFlags\r\n\t{\r\n\t\tCWCM_ContactPoint\t\t=\t(1<<0),\r\n\t\tCWCM_ContactNormal\t\t=\t(1<<1),\r\n\t\tCWCM_ContactPosition\t=\t(1<<2),\r\n\t\tCWCM_NormalForce\t\t=\t(1<<3),\r\n\t\tCWCM_OtherMaterialIndex\t=\t(1<<4),\r\n\t};\r\n\t/** @} */\r\n\t\r\n\r\n\t/** \\addtogroup Collision\r\n\t@{\r\n\t*/\r\n\r\n\t/**\r\n\t\\brief Contact pair flags.\r\n\r\n\t@see NxUserContactReport.onContactNotify() NxActor::setContactReportThreshold\r\n\t*/\r\n\ttypedef enum pContactPairFlags\r\n\t{\r\n\t\tCPF_IgnorePair\t\t\t\t\t\t\t\t= (1<<0),\t//!< disable contact generation for this pair\r\n\r\n\t\tCPF_OnStartTouch\t\t\t\t\t= (1<<1),\t//!< pair callback will be called when the pair starts to be in contact\r\n\t\tCPF_OnEndTouch\t\t\t\t\t\t= (1<<2),\t//!< pair callback will be called when the pair stops to be in contact\r\n\t\tCPF_OnTouch\t\t\t\t\t\t\t= (1<<3),\t//!< pair callback will keep getting called while the pair is in contact\r\n\t\tCPF_OnImpact\t\t\t\t\t\t\t= (1<<4),\t//!< [not yet implemented] pair callback will be called when it may be appropriate for the pair to play an impact sound\r\n\t\tCPF_OnRoll\t\t\t\t\t\t\t= (1<<5),\t//!< [not yet implemented] pair callback will be called when the pair is in contact and rolling.\r\n\t\tCPF_OnSlide\t\t\t\t\t\t\t= (1<<6),\t//!< [not yet implemented] pair callback will be called when the pair is in contact and sliding (and not rolling).\r\n\t\tCPF_Forces\t\t\t\t\t\t\t= (1<<7),\t//!< the (summed total) friction force and normal force will be given in the nxcontactpair variable in the contact report.\r\n\t\tCPF_OnStartTouchForceThreshold\t= (1<<8),\t//!< pair callback will be called when the contact force between two actors exceeds one of the actor-defined force thresholds\r\n\t\tCPF_OnEndTouchForceThreshold\t\t= (1<<9),\t//!< pair callback will be called when the contact force between two actors falls below the actor-defined force thresholds\r\n\t\tCPF_OnTouchForceThreshold\t\t\t= (1<<10),\t//!< pair callback will keep getting called while the contact force between two actors exceeds one of the actor-defined force thresholds\r\n\r\n\t\tCPF_ContactModification\t\t\t\t= (1<<16),\t//!< generate a callback for all associated contact constraints, making it possible to edit the constraint. this flag is not included in CPFall for performance reasons. \\see nxusercontactmodify\r\n\t};\r\n\r\n\ttypedef enum pContactModifyMask\r\n\t{\r\n\r\n\t\tCMM_None\t\t\t\t\t= 0,\t\t//!< No changes made\r\n\r\n\t\tCMM_MinImpulse\t\t\t= (1<<0),\t//!< Min impulse value changed\r\n\t\tCMM_MaxImpulse\t\t\t= (1<<1),\t//!< Max impulse value changed\r\n\t\tCMM_Error\t\t\t\t= (1<<2),\t//!< Error vector changed\r\n\t\tCMM_Target\t\t\t\t= (1<<3),\t//!< Target vector changed\r\n\r\n\t\tCMM_LocalPosition0\t\t= (1<<4),\t//!< Local attachment position in shape 0 changed\r\n\t\tCMM_LocalPosition1\t\t= (1<<5),\t//!< Local attachment position in shape 1 changed\r\n\t\tCMM_LocalOrientation0\t= (1<<6),\t//!< Local orientation (normal, friction direction) in shape 0 changed\r\n\t\tCMM_LocalOrientation1\t= (1<<7),\t//!< Local orientation (normal, friction direction) in shape 1 changed\r\n\r\n\t\tCMM_StaticFriction0\t\t= (1<<8),\t//!< Static friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1)\r\n\t\tCMM_StaticFriction1\t\t= (1<<9),\t//!< Static friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1)\r\n\t\tCMM_DynamicFriction0\t\t= (1<<10),\t//!< Dynamic friction parameter 0 changed. (Note: 0 does not have anything to do with shape 0/1)\r\n\t\tCMM_DynamicFriction1\t\t= (1<<11),\t//!< Dynamic friction parameter 1 changed. (Note: 1 does not have anything to do with shape 0/1)\r\n\t\tCMM_Restitution\t\t\t= (1<<12),\t//!< Restitution value changed.\r\n\r\n\t\tCMM_Force32\t\t\t\t= (1<<31)\t//!< Not a valid flag value, used by the enum to force the size to 32 bits.\r\n\r\n\t};\r\n\t\r\n\t/**\r\n\tSpecifies which informations should be generated(when used as hint flags for ray casting methods).\r\n\t*/\r\n\tenum pRaycastBit\r\n\t{\r\n\t\tRCH_Shape\t\t= (1<<0),\t\t\t\t\t\t\t\t//!< \"shape\" member of #NxRaycastHit is valid\r\n\t\tRCH_Impact\t\t= (1<<1),\t\t\t\t\t\t\t\t//!< \"worldImpact\" member of #NxRaycastHit is valid\r\n\t\tRCH_Normal\t\t= (1<<2),\t\t\t\t\t\t\t\t//!< \"worldNormal\" member of #NxRaycastHit is valid\r\n\t\tRCH_FaceIndex\t= (1<<3),\t\t\t\t\t\t\t\t//!< \"faceID\" member of #NxRaycastHit is valid\r\n\t\tRCH_Distance\t\t= (1<<4),\t\t\t\t\t\t\t\t//!< \"distance\" member of #NxRaycastHit is valid\r\n\t\tRCH_UV\t= (1<<5),\t\t\t\t\t\t\t\t//!< \"u\" and \"v\" members of #NxRaycastHit are valid\r\n\t\tRCH_FaceNormal\t= (1<<6),\t\t\t\t\t\t\t\t//!< Same as RCH_NORMAL but computes a non-smoothed normal\r\n\t\tRCH_Material= (1<<7),\t\t\t\t\t\t\t\t//!< \"material\" member of #NxRaycastHit is valid\r\n\t};\r\n\r\n\t/**\r\n\t\\brief Collision filtering operations.\r\n\r\n\t@see pGroupsMask\r\n\t*/\r\n\tenum pFilterOp\r\n\t{\r\n\t\tFO_And,\r\n\t\tFO_Or,\r\n\t\tFO_Xor,\r\n\t\tFO_Nand,\r\n\t\tFO_Nor,\r\n\t\tFO_NXor,\r\n\t\tFO_SwapAnd\r\n\t};\r\n\t/**\r\n\t\\brief Used to specify which types(static or dynamic) of shape to test against when used with raycasting and overlap test methods in pWorld.\r\n\r\n\t*/\r\n\ttypedef enum pShapesType\r\n\t{\r\n\t\t/**\r\n\t\t\\brief Hits static shapes. \r\n\t\t*/\r\n\t\tST_Static= 1,\r\n\r\n\t\t/**\r\n\t\t\\brief Hits dynamic shapes. \r\n\t\t*/\r\n\t\tST_Dynamic= 2, \r\n\t\t\r\n\t\t/**\r\n\t\t\\brief Hits dynamic and static shapes. \r\n\t\t*/\r\n\t\tST_All\t\t\t\t\t= ST_Dynamic|ST_Static, \r\n\t};\r\n\r\n\r\n\t/**\r\n\t\\brief Flags which affect the behavior of NxShapes.\r\n\r\n\t@see pRigidBody.setTriggerFlags()\r\n\t*/\r\n\ttypedef enum pTriggerFlags\r\n\t{\r\n\t\t/**\r\n\t\t\\brief Disables trigger callback.\r\n\t\t*/\r\n\t\tTF_Disable\t\t\t\t= (1<<3),\r\n\t\t/**\r\n\t\t\\brief Trigger callback will be called when a shape enters the trigger volume.\r\n\t\t*/\r\n\t\tTF_OnEnter\t\t\t\t= (1<<0),\r\n\r\n\t\t/**\r\n\t\t\\brief Trigger callback will be called after a shape leaves the trigger volume.\r\n\t\t*/\r\n\t\tTF_OnLeave\t\t\t\t= (1<<1),\r\n\r\n\t\t/**\r\n\t\t\\brief Trigger callback will be called while a shape is intersecting the trigger volume.\r\n\t\t*/\r\n\t\tTF_OnStay\t\t\t\t= (1<<2)\r\n\r\n\t};\r\n\t/** @} */\r\n\t\r\n\ttypedef enum E_ENTITY_DATA_FLAGS\r\n\t{\r\n\t\tEDF_MATERIAL_PARAMETER,\r\n\t\tEDF_SLEEPING_PARAMETER,\r\n\t\tEDF_DAMPING_PARAMETER,\r\n\t\tEDF_DEFORMABLE_PARAMETER,\r\n\t\tEDF_OPTIMIZATION_PARAMETER,\r\n\t};\r\n\r\n\ttypedef enum WORLD_DATA_FLAGS\r\n\t{\r\n\t\tWDF_HAS_SURFACE_PARAMETER = 0x0001,\r\n\t\tWDF_HAS_SLEEPING_PARAMETER = 0x0002,\r\n\t\tWDF_HAS_DAMPING_PARAMETER = 0x0004\r\n\t};\r\n\r\n\ttypedef enum WORLD_UPDATE_MODE\r\n\t{\r\n\t\tWUM_UPDATE_FROM_ATTRIBUTE = 0x0001\r\n\t};\r\n\r\n\ttypedef enum WORLD_UPDATE_FLAGS\r\n\t{\r\n\t\tWUF_WORLD_SETTINGS = 0x0001,\r\n\t\tWUF_DAMPING_PARAMETER = 0x0002,\r\n\t\tWUF_SLEEPING_PARAMETER = 0x0004,\r\n\t\tWUF_SURFACE_SETTINGS = 0x0008,\r\n\t\tWUF_ALL_PARAMETERS = 0x0010,\r\n\t};\r\n\r\n\ttypedef enum BODY_UPDATE_FLAGS\r\n\t{\r\n\t\tBUF_PHY_PARAMETER = 0x0001,\r\n\t\tBUF_DAMPING_PARAMETER = 0x0002,\r\n\t\tBUF_SLEEPING_PARAMETER = 0x0004,\r\n\t\tBUF_JOINT_PARAMETERS = 0x0008,\r\n\t\tBUF_SURFACE_PARAMETERS = 0x0010,\r\n\t\tBUF_ALL_PARAMETERS = 0x0020,\r\n\t\tBUF_GEOMETRY = 0x0040,\r\n\t\tBUF_PIVOT = 0x0080,\r\n\t\tBUF_MASS = 0x0100,\r\n\t\tBUF_ALL = 0x0200\r\n\t};\r\n\r\n\t/** \\addtogroup Joints\r\n\t@{\r\n\t*/\r\n\t//! Identifies each type of joint. \r\n\t//! This enum is registered as a custom enumeration for the schematic interface as #pJointType.
\r\n\ttypedef enum JType\r\n\t{\r\n\t\tJT_Any =-1,/*!\r\n\t//! -during body registration.
\r\n\t//! -through invoking of #pRigidBody::addSubShape().This needs to have BF_SubShape enabled then!.
\r\n\t//! -as member of #pObjectDescr.

\r\n\t//! This enum is registered as a custom flags for the schematic : #pBFlags.
\r\n\ttypedef enum BodyFlags{\r\n\t\tBF_Moving=1,/*!< Makes the body movable. this can not be altered after creation */\r\n\t\tBF_Gravity=2,/*!< Enables gravity. See #pRigidBody::enableGravity() or \\ref PBSetPar */\r\n\t\tBF_Collision=4,/*!< Enables collisions response. See #pRigidBody::enableCollision() or \\ref PBSetPar */\r\n\t\tBF_Kinematic=8,/*!< Act as kinematic object. See #pRigidBody::setKinematic() or \\ref PBSetPar */\r\n\t\tBF_SubShape=16,/*!\r\n\t//! -during body registration.
\r\n\t//! -as member of #pObjectDescr.

\r\n\t//! This enum is registered as a custom flags for the schematic : #pBHullType.
\r\n\ttypedef enum HullType {\r\n\t\tHT_Sphere = 0,\r\n\t\t/*!\r\n\t\t*/\r\n\t\tHT_Box = 1, \r\n\t\t/*!\r\n\t\t*/\r\n\t\tHT_Capsule = 2,\r\n\t\t/*!\r\n\t\t\t\tAssuming bodies pivot is aligned to the world frame, the entities rotation is set to 0,0,0 (degree) temporary in order to determine the capsule parameters whereas :
\r\n\t\t\t\tcapsule length = boxMeshSize.y - boxMeshSize.x and
\r\n\t\t\t\tcapsule radius = boxMeshSize.x / 2
\r\n\t\t
\r\n\t\t*/\r\n\t\tHT_Plane = 3,\r\n\t\t/*!
\r\n\t\t*/\r\n\t\tHT_Mesh =4,\r\n\t\t/*!\r\n\t\t\\note This mesh type will not create contact points with another trieangle meshs. Avoid this at any cost, otherwise Virtools will crash!
\r\n\t\t
\r\n\t\t*/\r\n\t\tHT_ConvexMesh =5,\r\n\t\t/*!
\r\n\t\t\\note This type will create contact points with all other types!\r\n\t\t
\r\n\t\t*/\r\n\t\tHT_Heightfield=6,\r\n\t\t/*!
\r\n\t\t*/\r\n\t\tHT_Wheel=7,\r\n\t\t/*!\r\n\t\t*/\r\n\t\tHT_Cloth=8,\r\n\t\t/*!\r\n\t\t*/\r\n\t\tHT_ConvexCylinder=9,\r\n\t\t/*!\r\n\t\t*/\r\n\t\tHT_Unknown,\r\n\t\t/*!\r\n\t\t*/\r\n\t};\r\n\t/** @} */\r\n\r\n\ttypedef enum E_LOG_ITEMS\r\n\t{\r\n\t\tE_LI_AGEIA,\r\n\t\tE_LI_MANAGER,\r\n\t\tE_VSL,\r\n\t\tE_BB,\r\n\t};\r\n\r\n\ttypedef enum E_PHYSIC_ERROR\r\n\t{\r\n\t\tE_PE_OK,\r\n\t\tE_PE_AGEIA_ERROR,\r\n\t\tE_PE_INVALID_PARAMETER,\r\n\t\tE_PE_INVALID_OPERATION,\r\n\t};\r\n\r\n\ttypedef enum E_MANAGER_FLAGS\r\n\t{\r\n\t\tE_MF_OK,\r\n\t\tE_MF_PSDK_LOADED,\r\n\t\tE_MF_PSDK_FAILED,\r\n\t\tE_MF_DEFAULT_WORLD_CREATED,\r\n\t\tE_MF_DEFAULT_CONFIG_LOADED,\r\n\t\tE_MF_LOADING_DEFAULT_CONFIG_FAILED,\r\n\t\tE_MF_FACTORY_CREATED,\r\n\t};\r\n\ttypedef enum E_MANAGER_INIT_FLAGS\r\n\t{\r\n\t\tE_MFI_LOAD_CONFIG,\r\n\t\tE_MFI_CREATE_FACTORY,\r\n\t\tE_MFI_CREATE_DEFAULT_WORLD,\r\n\t\tE_MFI_USE_XML_WORLD_SETTINGS\r\n\t};\r\n\r\n\r\n\t/** \\addtogroup RigidBody\r\n\t@{\r\n\t*/\r\n\t//! This enum is registered as a custom flags for the schematic : #pBForceMode.
\r\n\t//! Enumeration to force related calls.\r\n\t//*!\tIs used for force related calls. Registered as custom enumeration #pBForceMode. */\r\n\tenum ForceMode\r\n\t{\r\n\t\tFM_Force, /*!< parameter has unit of mass * distance/ time^2, i.e. a force*/\r\n\t\tFM_Impulse, /*!< parameter has unit of mass * distance /time */\r\n\t\tFM_VelocityChange,\t\t\t/*!< parameter has unit of distance / time, i.e. the effect is mass independent: a velocity change.*/\r\n\t\tFM_SmoothImpulse, /*!< same as FM_Impulse but the effect is applied over all sub steps. Use this for motion controllers that repeatedly apply an impulse.*/\r\n\t\tFM_SmoothVelocityChange,\t/*!< same as FM_VelocityChange but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse.*/\r\n\t\tFM_Acceleration\t\t\t\t/*!< parameter has unit of distance/ time^2, i.e. an acceleration. It gets treated just like a force except the mass is not divided out before integration.*/\r\n\t};\r\n\r\n\t//! This enum is registered as custom hidden enumeration for pCCDSettings-\r\n\tenum CCDFlags\r\n\t{\r\n\t\tCCD_Shared, /*!< Is reusing a ccd skeleton*/\r\n\t};\r\n\r\n\t/** @} */\r\n\r\n\t/** \\addtogroup RigidBody\r\n\t@{\r\n\t*/\r\n\t//! Flag that determines the combine mode. When two bodies come in contact with each other, \r\n\t//!\t they each have materials with various coefficients, but we only need a single set of coefficients for the pair. \r\n\t//! Physics doesn't have any inherent combinations because the coefficients are determined empirically on a case by case basis. However, simulating this with a pairwise lookup table is often impractical. For this reason the following combine \r\n\t//! behaviors are available: CM_Average CM_Min CM_Multiply CM_Max \r\n\t//! The effective combine mode for the pair is max(material0.combineMode, material1.combineMode).\r\n\tenum CombineMode\r\n\t{\r\n\t\tCM_Average,/*!\t\r\n\t\t\\note The appropriate target positions/orientations should be set.\r\n\t\t*/\r\n\t\tD6DT_Velocity = 1 << 1,\r\n\t\t/*!\r\n\t\t\\note The appropriate target velocities should beset.*/\r\n\t};\r\n\t/** @} */\r\n\r\n\r\n\t/** \\addtogroup D6\r\n\t@{\r\n\t*/\r\n\t//! Enumeration is used to specify a particular degree of freedom.Registered as custom enumeration #pJD6Axis.\r\n\ttypedef enum D6MotionAxis\r\n\t{\r\n\r\n\t\tD6MA_Twist,/*!\r\n\t\t\t- building block \\ref PVWSet\r\n\t\t\t- #pWheel::setShapeFlags\r\n\r\n\t*/\r\n\t/**\r\n\tFlags to describe the wheels control facility. This can be done at any time with :
\r\n\t- building block \\ref PVWSet\r\n\t- #pWheel::setWheelFlags\r\n\t*/\r\n\ttypedef enum VehicleFlags\r\n\t{\r\n\t\tVF_UseAdvance\t\t\t= (1 << 0),\r\n\t};\r\n\ttypedef enum WheelShapeFlags\r\n\t{\r\n\t\t/**\r\n\t\t\\brief Determines whether the suspension axis or the ground contact normal is used for the suspension constraint.\r\n\t\t*/\r\n\t\tWSF_WheelAxisContactNormal = 1 << 0,\r\n\r\n\t\t/**\r\n\t\t\\brief If set, the lateral slip velocity is used as the input to the tire function, rather than the slip angle.\r\n\r\n\t\t*/\r\n\t\tWSF_InputLatSlipVelocity = 1 << 1,\r\n\r\n\t\t/**\r\n\t\t\\brief If set, the longitudinal slip velocity is used as the input to the tire function, rather than the slip ratio. \r\n\t\t*/\r\n\t\tWSF_InputLongSlipVelocity = 1 << 2,\r\n\r\n\t\t/**\r\n\t\t\\brief If set, does not factor out the suspension travel and wheel radius from the spring force computation. This is the legacy behavior from the raycast capsule approach.\r\n\t\t*/\r\n\t\tWSF_UnscaledSpringBehavior = 1 << 3, \r\n\r\n\t\t/**\r\n\t\t\\brief If set, the axle speed is not computed by the simulation but is rather expected to be provided by the user every simulation step via NxWheelShape::setAxleSpeed().\r\n\t\t*/\r\n\t\tWSF_AxleSpeedOverride = 1 << 4,\r\n\t\t/**\r\n\t\t\\brief If set, the wheels shape will emulate the legacy raycast capsule based wheel.\r\n\t\tSee #pVWheelFunction\r\n\t\t*/\r\n\t\tWSF_EmulateLegacyWheel = 1 << 5,\r\n\r\n\t\t/**\r\n\t\t\\brief If set, the shape will clamp the force in the friction constraints.\r\n\t\tSee #pVWheelFunction\r\n\t\t*/\r\n\t\tWSF_ClampedFriction = 1 << 6,\r\n\t};\r\n\r\n\t/**\r\n\tFlags to describe the wheels control facility. This can be done at any time with :
\r\n\t- building block \\ref PVWSet\r\n\t- #pWheel::setWheelFlags\r\n\t*/\r\n\ttypedef enum WheelFlags\r\n\t{\r\n\r\n\t\t\t/**\r\n\t\t\t\\brief If set, the wheels shape will emulate the legacy raycast capsule based wheel.\r\n\t\t\tSee #pVWheelFunction\r\n\t\t\t*/\r\n\t\t\tWF_SteerableInput\t\t\t= (1 << 0),\r\n\t\t\tWF_SteerableAuto\t\t\t= (1 << 1),\r\n\t\t\tWF_AffectedByHandbrake\t\t= (1 << 2),\r\n\t\t\tWF_Accelerated\t\t\t\t= (1 << 3),\r\n\t\t\tWF_VehicleControlled\t\t= (1 << 4),\r\n\t\t\tWF_AffectedByDifferential\t= (1 << 5),\r\n\t\t\tWF_IgnoreTireFunction\t\t= (1 << 6),\r\n\r\n\t\t\tWF_AllWheelFlags\t\t= WF_SteerableInput\r\n\t\t\t| WF_SteerableAuto\r\n\t\t\t| WF_AffectedByHandbrake\r\n\t\t\t| WF_Accelerated\r\n\t\t\t| WF_VehicleControlled\r\n\t\t\t| WF_AffectedByDifferential,\r\n\r\n\t};\r\n\r\n\ttypedef enum E_VEHICLE_STATE_FLAGS\r\n\t{\r\n\t\tE_VSF_HAS_GEARS=(1<<0),\r\n\t\tE_VSF_HAS_MOTOR=(1<<1),\r\n\t\tE_VSF_HAS_GROUND=(1<<2),\r\n\t\tE_VSF_IS_BRAKING=(1<<3),\r\n\t\tE_VSF_IS_BREAKPEDAL=(1<<4),\r\n\t\tE_VSF_BREAKPEDAL_CHANGED=(1<<5),\r\n\t\tE_VSF_ACC_PEDAL=(1<<6),\r\n\t\tE_VSF_RELEASING_BRAKE_PEDAL=(1<<7),\r\n\t};\r\n\r\n\t\t\r\n\t/** @} */\r\n\r\n\ttypedef enum pParticleRenderType\r\n\t{\r\n\r\n\t\tPRT_Point,\r\n\t\tPRT_Sprite,\r\n\r\n\t};\r\n\r\n\ttypedef enum E_OBJECT_CREATION_FLAGS\r\n\t{\r\n\r\n\t\tE_OCF_ROTATION,\r\n\t\tE_OFC_POSITION,\r\n\t\tE_OFC_DIMENSION,\r\n\t\tE_OFC_PERISITENT,\r\n\r\n\t};\r\n\r\n\ttypedef enum xManagerCallMask\r\n\t{\r\n\t\tXCM_PreProcess = 1 << 0 ,\r\n\t\tXCM_PostProcess = 1 << 0\r\n\t};\r\n\r\n\r\n\r\n#endif // __VTINTERFACEENUMERATION_H__#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"cooking.h\"\r\n#include \"Stream.h\"\r\n\r\n#include \"pConfig.h\"\r\n\r\n\r\nvoid pFactory::copyTo(pDeformableSettings &dst,CKParameter*par)\r\n{\r\n\r\n\tif (!par)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tdst.ImpulsThresold = GetValueFromParameterStruct(par,0);\r\n\tdst.PenetrationDepth = GetValueFromParameterStruct(par,1);\r\n\tdst.MaxDeform = GetValueFromParameterStruct(par,2);\r\n\r\n}\r\n\r\npCloth* pFactory::createCloth(CK3dEntity *srcReference,pClothDesc descr)\r\n{\r\n\r\n\r\n#ifdef DONLGE\r\n\tif(!GetPMan()->DongleHasAdvancedVersion)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Cannot create cloth : no license !\");\r\n\t\treturn NULL;\r\n\t}\r\n#endif\r\n\r\n\tif (!srcReference)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tif (!srcReference->GetCurrentMesh())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tif (!descr.isValid())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCK3dEntity*worldReference = (CK3dEntity*)GetPMan()->m_Context->GetObject(descr.worldReference);\r\n\t\r\n\tif (!worldReference)\r\n\t{\r\n\t\tif (GetPMan()->getDefaultWorld())\r\n\t\t{\r\n\t\t\tworldReference = GetPMan()->getDefaultWorld()->getReference();\r\n\t\t}else\r\n\t\t\treturn NULL;\r\n\t}\r\n\r\n\tpWorld*world = GetPMan()->getWorld(worldReference->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\treturn NULL;\r\n\r\n\t}\r\n\r\n\r\n\tpRigidBody *body = GetPMan()->getBody(srcReference);\r\n/*\tif (!body)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n*/\r\n\r\n\tNxClothMeshDesc meshDesc;\r\n\t\r\n\t// if we want tearing we must tell the cooker\r\n\t// this way it will generate some space for particles that will be generated during tearing\r\n\tif (descr.flags & PCF_Tearable)\r\n\t\tmeshDesc.flags |= NX_CLOTH_MESH_TEARABLE;\r\n\r\n\tpCloth *result = new pCloth();\r\n\r\n\tresult->generateMeshDesc(descr,&meshDesc,srcReference->GetCurrentMesh());\r\n\tint mValid = meshDesc.isValid();\r\n\r\n\tif (!result->cookMesh(&meshDesc))\r\n\t{\r\n\t\tdelete result;\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tresult->releaseMeshDescBuffers(&meshDesc);\r\n\tresult->allocateClothReceiveBuffers(meshDesc.numVertices, meshDesc.numTriangles);\r\n\r\n\tNxClothDesc cDescr;\r\n\tcopyToClothDescr(&cDescr,descr);\r\n\tcDescr.clothMesh = result->getClothMesh();\r\n\tcDescr.meshData = *result->getReceiveBuffers();\r\n\r\n\tVxMatrix v_matrix ;\r\n\tVxVector position,scale;\t\t\r\n\tVxQuaternion quat;\t\r\n\r\n\r\n\r\n\tv_matrix = srcReference->GetWorldMatrix();\r\n\tVx3DDecomposeMatrix(v_matrix,quat,position,scale);\r\n\r\n\tcDescr.globalPose.t = getFrom(position);\r\n\tcDescr.globalPose.M = getFrom(quat);\r\n\t\r\n\t\r\n\r\n\t\r\n\tNxCloth *cloth = world->getScene()->createCloth(cDescr);\r\n\tif (cloth)\r\n\t{\r\n\t\tresult->setCloth(cloth);\r\n\t\tresult->setEntityID(srcReference->GetID());\r\n\t\tresult->setWorld(GetPMan()->getDefaultWorld());\r\n\t\tcloth->userData = result;\r\n\r\n\t\tif (meshDesc.points)\r\n\t\t{\r\n//\t\t\tdelete []meshDesc.points;\r\n//\t\t\tdelete []meshDesc.triangles;\r\n\t\t}\r\n\r\n\r\n\r\n\t\tif (descr.flags & PCF_AttachToParentMainShape )\r\n\t\t{\r\n\t\t\tif (srcReference->GetParent())\r\n\t\t\t{\r\n\t\t\t\tCK3dEntity *bodyReference = getMostTopParent(srcReference);\r\n\t\t\t\tif (bodyReference)\r\n\t\t\t\t{\r\n\t\t\t\t\tpRigidBody *body = GetPMan()->getBody(bodyReference);\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult->attachToShape((CKBeObject*)bodyReference,descr.attachmentFlags);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (descr.flags & PCF_AttachToCollidingShapes)\r\n\t\t{\r\n\t\t\tresult->attachToCollidingShapes(descr.attachmentFlags);\r\n\t\t}\r\n\r\n\t\tif (descr.flags & PCF_AttachToCore)\r\n\t\t{\r\n/*\r\n\r\n\t\t\tNxBodyDesc coreBodyDesc;\r\n\t\t\tcoreBodyDesc.linearDamping = 0.2f;\r\n\t\t\tcoreBodyDesc.angularDamping = 0.2f;\r\n\r\n\t\t\tNxActorDesc coreActorDesc;\r\n\t\t\tcoreActorDesc.density = 0.1f;\r\n\t\t\tcoreActorDesc.body = &coreBodyDesc;\r\n\r\n\t\t\tcoreActorDesc.shapes.pushBack(new NxBoxShapeDesc());\r\n\r\n\t\t\tNxActor *coreActor = world->getScene()->createActor(coreActorDesc);\r\n\t\t\tcoreActor->userData =NULL;\r\n\t\t\t\r\n\r\n\t\t\tNxReal impulseThreshold = 50.0f;\r\n\t\t\tNxReal penetrationDepth = 0.5f;\r\n\t\t\tNxReal maxDeformationDistance = 0.5f;\r\n\r\n\t\t\tcloth->attachToCore(coreActor, impulseThreshold, penetrationDepth, maxDeformationDistance); \r\n*/\r\n//\t\t\tresult->attachToCollidingShapes(descr.attachmentFlags);\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif (meshDesc.points)\r\n\t{\r\n//\t\tdelete []meshDesc.points;\r\n//\t\tdelete []meshDesc.triangles;\r\n\t}\r\n\t\r\n\treturn result;\r\n\r\n}\r\npClothDesc* pFactory::createClothDescrFromParameter(CKParameter *par)\r\n{\r\n\r\n\tif (!par)\r\n\t\treturn NULL;\r\n\r\n\tpClothDesc *descr = new pClothDesc();\r\n\t\r\n\tusing namespace vtTools::ParameterTools;\r\n\t\r\n\tdescr->density = GetValueFromParameterStruct(par,E_CS_DENSITY,false);\r\n\tdescr->thickness = GetValueFromParameterStruct(par,E_CS_THICKNESS,false);\r\n\tdescr->bendingStiffness = GetValueFromParameterStruct(par,E_CS_BENDING_STIFFNESS,false);\r\n\tdescr->stretchingStiffness = GetValueFromParameterStruct(par,E_CS_STRETCHING_STIFFNESS,false);\r\n\tdescr->dampingCoefficient = GetValueFromParameterStruct(par,E_CS_DAMPING_COEFFICIENT,false);\r\n\tdescr->friction = GetValueFromParameterStruct(par,E_CS_FRICTION,false);\r\n\t\r\n\tdescr->pressure = GetValueFromParameterStruct(par,E_CS_PRESSURE,false);\r\n\tdescr->tearFactor = GetValueFromParameterStruct(par,E_CS_TEAR_FACTOR,false);\r\n\tdescr->collisionResponseCoefficient = GetValueFromParameterStruct(par,E_CS_COLLISIONRESPONSE_COEFFICIENT,false);\r\n\t\r\n\tdescr->attachmentResponseCoefficient = GetValueFromParameterStruct(par,E_CS_ATTACHMENTRESPONSE_COEFFICIENT,false);\r\n\tdescr->attachmentTearFactor = GetValueFromParameterStruct(par,E_CS_ATTACHMENT_TEAR_FACTOR,false);\r\n\tdescr->toFluidResponseCoefficient = GetValueFromParameterStruct(par,E_CS_TO_FLUID_RESPONSE_COEFFICIENT,false);\r\n\r\n\tdescr->fromFluidResponseCoefficient = GetValueFromParameterStruct(par,E_CS_FROM_FLUIDRESPONSE_COEFFICIENT,false);\r\n\tdescr->minAdhereVelocity = GetValueFromParameterStruct(par,E_CS_MIN_ADHERE_VELOCITY,false);\r\n\tdescr->solverIterations = GetValueFromParameterStruct(par,E_CS_SOLVER_ITERATIONS,false);\r\n\t\r\n\tdescr->externalAcceleration = GetValueFromParameterStruct(par,E_CS_EXTERN_ALACCELERATION,false);\r\n\tdescr->windAcceleration = GetValueFromParameterStruct(par,E_CS_WIND_ACCELERATION,false);\r\n\tdescr->wakeUpCounter = GetValueFromParameterStruct(par,E_CS_WAKE_UP_COUNTER,false);\r\n\t\r\n\tdescr->sleepLinearVelocity = GetValueFromParameterStruct(par,E_CS_SLEEP_LINEAR_VELOCITY,false);\r\n\tdescr->collisionGroup = GetValueFromParameterStruct(par,E_CS_COLLISIONG_ROUP,false);\r\n\t\r\n\tdescr->validBounds = GetValueFromParameterStruct(par,E_CS_VALID_BOUNDS,false);\r\n\tdescr->relativeGridSpacing = GetValueFromParameterStruct(par,E_CS_RELATIVE_GRID_SPACING,false);\r\n\tdescr->flags = GetValueFromParameterStruct(par,E_CS_FLAGS,false);\r\n\tdescr->tearVertexColor = GetValueFromParameterStruct(par,E_CS_TEAR_VERTEX_COLOR,false);\r\n\t\r\n\tdescr->worldReference = GetValueFromParameterStruct(par,E_CS_WORLD_REFERENCE,false);\r\n\r\n\treturn descr;\r\n\t\r\n}\r\n\r\nvoid pFactory::copyToClothDescr(NxClothDesc* dst,pClothDesc src )\r\n{\r\n\r\n\tdst->density = src.density ;\r\n\tdst->thickness = src.thickness ;\r\n\tdst->bendingStiffness = src.bendingStiffness;\r\n\tdst->stretchingStiffness = src.stretchingStiffness;\r\n\tdst->dampingCoefficient = src.dampingCoefficient;\r\n\r\n\tdst->friction = src.friction;\r\n\tdst->pressure = src.pressure;\r\n\tdst->tearFactor = src.tearFactor ;\r\n\tdst->collisionResponseCoefficient = src.collisionResponseCoefficient ;\r\n\tdst->attachmentResponseCoefficient = src.attachmentResponseCoefficient ;\r\n\tdst->attachmentTearFactor = src.attachmentTearFactor ;\r\n\tdst->toFluidResponseCoefficient = src.toFluidResponseCoefficient ;\r\n\tdst->fromFluidResponseCoefficient= src.fromFluidResponseCoefficient ;\r\n\tdst->minAdhereVelocity = src.minAdhereVelocity ;\r\n\tdst->solverIterations = src.solverIterations ;\r\n\tdst->externalAcceleration = getFrom(src.externalAcceleration) ;\r\n\tdst->windAcceleration = getFrom(src.windAcceleration);\r\n\tdst->wakeUpCounter = src.wakeUpCounter ;\r\n\tdst->sleepLinearVelocity = src.sleepLinearVelocity ;\r\n\tdst->collisionGroup = src.collisionGroup;\r\n\tdst->validBounds.set(getFrom(src.validBounds.Min) , getFrom(src.validBounds.Max));\r\n\tdst->relativeGridSpacing = src.relativeGridSpacing;\r\n\tdst->flags =src.flags;\r\n\t\r\n}#ifndef __xPredictionSetting_h_\r\n#define __xPredictionSetting_h_\r\n\r\nclass xPredictionSetting\r\n{\r\n\tpublic:\r\n\t\txPredictionSetting()\r\n\t\t{\r\n\t\t\tm_MinSendTime =0.0f;\r\n\t\t\tm_MinDifference =0.0f;\r\n\t\t\tm_PredictionFactor = 0.0f;\r\n\r\n\t\t}\r\n\t\t\r\n\t\tfloat getMinSendTime() const { return m_MinSendTime; }\r\n\t\tvoid setMinSendTime(float val) { m_MinSendTime = val; }\r\n\r\n\t\tfloat getMinDifference() const { return m_MinDifference; }\r\n\t\tvoid setMinDifference(float val) { m_MinDifference = val; }\r\n\t\tfloat getPredictionFactor() const { return m_PredictionFactor; }\r\n\t\tvoid setPredictionFactor(float val) { m_PredictionFactor = val; }\r\n\r\n\tprivate:\r\n\r\n\t\tfloat m_MinSendTime;\r\n\t\tfloat m_MinDifference;\r\n\t\tfloat m_PredictionFactor;\r\n\t\t\r\n\t\t\r\n};\r\n#endif\r\n/********************************************************************\r\n\tcreated:\t2009/01/05\r\n\tcreated:\t5:1:2009 18:18\r\n\tfilename: \tX:\\ProjectRoot\\svn\\local\\usr\\include\\virtools\\vtCXGlobal.h\r\n\tfile path:\tX:\\ProjectRoot\\svn\\local\\usr\\include\\virtools\r\n\tfile base:\tvtCXGlobal\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __VTCXGLOBAL_H__\r\n\t#define __VTCXGLOBAL_H__\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tPlatform Headers\r\n//\r\n\r\n//#include \r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tPlatform specific header switchs : \r\n//\r\n#ifdef _WIN32\r\n\t#include \r\n#endif\r\n\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tBuild switchs : \r\n//\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// \r\n//\tDebugBuild is used to hide private building blocks, types, attributes,...\r\n#ifdef NDEBUG\r\n\tstatic const bool vtCXDebugBuild = true;\r\n#else\r\n\tstatic const bool vtCXDebugBuild = false;\r\n#endif\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n// dll directives :\r\n#ifndef VTCX_API_EXPORT\r\n\t#define VTCX_API_EXPORT __declspec(dllexport)\r\n#endif\r\n\r\n#ifndef VTCX_API_INLINE\r\n\t#define VTCX_API_INLINE __inline\r\n#endif\r\n\r\n#ifndef VTCX_API_sCALL\r\n\t#define VTCX_API_sCALL __stdcall\r\n#endif\r\n\r\n#ifndef VTCX_API_cDECL\r\n\t#define VTCX_API_cDECL __cdecl\r\n#endif\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tAPI Specific Constants :\r\n//\r\n\r\n//\t#define MY_BB_CAT VTCX_API_CUSTOM_BB_CATEGORY(/MyPlug) leads to : \"vtCX/MyPlug\"\r\n\r\n\r\n#ifndef VTCX_AUTHOR\r\n\t#define\tVTCX_AUTHOR\t\t\t\t\"Gu\"\r\n#endif\r\n\r\n#ifndef VTCX_AUTHOR_GUID\r\n\t#define\tVTCX_AUTHOR_GUID\t\t\tCKGUID(0x79ba75dd,0x41d77c63)\r\n#endif\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tError Identifiers : \r\n//\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFile System Specific : \t\t\t\t\t\t\r\n//\r\n\r\n#if defined (_LINUX)\r\n\t#define VTCX_FS_PATH_SEPERATOR '/'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR ':'\r\n\t#define VTCX_FS_EOL \"\\n\"\t\t\t//(0x0D)\r\n#endif\r\n\r\n#ifdef _WIN32\r\n\t#define VTCX_FS_PATH_SEPERATOR '\\\\'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR \r\n\t#define VTCX_FS_EOL \"\\r\\n\"\t\t//(0x0A 0x0D)\r\n#endif\r\n\r\n#if defined (macintosh)\r\n\t#define VTCX_FS_PATH_SEPERATOR '/'\r\n\t#define VTCX_FS_PATH_DRIVE_SEPARATOR \r\n\t#define VTCX_FS_EOL \"\\r\"\t\t//(0x0A)\r\n#endif\r\n\r\n#define VTCX_FS_PATH_EXT_SEPARATOR '.'\r\n\r\n////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n//\r\n\r\n \t\t\r\n\r\n\r\n#endif#include \"precomp.h\"\r\n#include \"Manager/Manager.h\"\r\n\r\n#include \"virtools/vt_tools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendCSMessageDecl();\r\nCKERROR CreateSendCSMessageProto(CKBehaviorPrototype **);\r\nint SendMessage(const CKBehaviorContext& behcontext);\r\nCKERROR SendMessageCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 1\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nint msgCounter = 0;\r\n\r\nCKObjectDeclaration\t*FillBehaviorSendCSMessageDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Send CSMessage\");\t\r\n\tod->SetDescription(\"Stores a message in the CSManager \");\r\n\t\r\n\tod->SetCategory(\"CSharp/Message\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2f0b513c,0xa4b1eb9));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSendCSMessageProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSendCSMessageProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Send CSMessage\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Message\", CKPGUID_STRING, \"msg\");\r\n\t//proto->DeclareInParameter(\"Target User ID\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(SendMessage);\r\n\tproto->SetBehaviorCallbackFct(SendMessageCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint SendMessage(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\tCSManager* cman =(CSManager*)ctx->GetManagerByGuid(INIT_MAN_GUID);\r\n\r\n\t\r\n\tXString msg((CKSTRING) beh->GetInputParameterReadDataPtr(0));\r\n\t\r\n\tcsMessage *msgout = new csMessage();\r\n\tmsgout->SetName(msg.CStr());\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::Enums;\r\n\tint bcount = beh->GetInputParameterCount();\r\n\r\n\r\n\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t{\r\n\r\n\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\tCKParameterType pType = ciIn->GetType();\r\n\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\r\n\t\tswitch (sType)\r\n\t\t{\r\n\t\t\tcase vtSTRING:\r\n\t\t\tcase vtFLOAT:\r\n\t\t\tcase vtINTEGER:\r\n\t\t\t{\r\n\t\t\t\tmsgout->AddParameter(ciIn->GetRealSource());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tdefault :\r\n\t\t\t\tXString err(\"wrong input parameter type: \");\r\n\t\t\t\terr << ciIn->GetName() << \"Only Types derivated from Interger,Float or String are acceptable\";\r\n\t\t\t\tctx->OutputToConsole(err.Str(),FALSE );\r\n\t\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t\t}\r\n\t}\r\n\tcman->AddMessage(msgout);\r\n\tbeh->ActivateOutput(0);\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR SendMessageCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}/* A Bison parser, made by GNU Bison 2.3. */\n\n/* Skeleton implementation for Bison's Yacc-like parsers in C\n\n Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006\n Free Software Foundation, Inc.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2, or (at your option)\n any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin Street, Fifth Floor,\n Boston, MA 02110-1301, USA. */\n\n/* As a special exception, you may create a larger work that contains\n part or all of the Bison parser skeleton and distribute that work\n under terms of your choice, so long as that work isn't itself a\n parser generator using the skeleton or a modified version thereof\n as a parser skeleton. Alternatively, if you modify or redistribute\n the parser skeleton itself, you may (at your option) remove this\n special exception, which will cause the skeleton and the resulting\n Bison output files to be licensed under the GNU General Public\n License without this special exception.\n\n This special exception was added by the Free Software Foundation in\n version 2.2 of Bison. */\n\n/* C LALR(1) parser skeleton written by , by\n simplifying the original so-called \"semantic\" parser. */\n\n/* All symbols defined below should begin with yy or YY, to avoid\n infringing on user name space. This should be done even for local\n variables, as they might otherwise be expanded by user macros.\n There are some unavoidable exceptions within include files to\n define necessary library symbols; they are noted \"INFRINGES ON\n USER NAME SPACE\" below. */\n\n/* Identify Bison output. */\n#define YYBISON 1\n\n/* Bison version. */\n#define YYBISON_VERSION \"2.3\"\n\n/* Skeleton name. */\n#define YYSKELETON_NAME \"yacc.c\"\n\n/* Pure parsers. */\n#define YYPURE 0\n\n/* Using locations. */\n#define YYLSP_NEEDED 0\n\n\n\n/* Tokens. */\n#ifndef YYTOKENTYPE\n# define YYTOKENTYPE\n /* Put the tokens into the symbol table, so that GDB and other debuggers\n know about them. */\n enum yytokentype {\n ID = 258,\n HBLOCK = 259,\n POUND = 260,\n STRING = 261,\n INCLUDE = 262,\n IMPORT = 263,\n INSERT = 264,\n CHARCONST = 265,\n NUM_INT = 266,\n NUM_FLOAT = 267,\n NUM_UNSIGNED = 268,\n NUM_LONG = 269,\n NUM_ULONG = 270,\n NUM_LONGLONG = 271,\n NUM_ULONGLONG = 272,\n TYPEDEF = 273,\n TYPE_INT = 274,\n TYPE_UNSIGNED = 275,\n TYPE_SHORT = 276,\n TYPE_LONG = 277,\n TYPE_FLOAT = 278,\n TYPE_DOUBLE = 279,\n TYPE_CHAR = 280,\n TYPE_WCHAR = 281,\n TYPE_VOID = 282,\n TYPE_SIGNED = 283,\n TYPE_BOOL = 284,\n TYPE_COMPLEX = 285,\n TYPE_TYPEDEF = 286,\n TYPE_RAW = 287,\n TYPE_NON_ISO_INT8 = 288,\n TYPE_NON_ISO_INT16 = 289,\n TYPE_NON_ISO_INT32 = 290,\n TYPE_NON_ISO_INT64 = 291,\n LPAREN = 292,\n RPAREN = 293,\n COMMA = 294,\n SEMI = 295,\n EXTERN = 296,\n INIT = 297,\n LBRACE = 298,\n RBRACE = 299,\n PERIOD = 300,\n CONST_QUAL = 301,\n VOLATILE = 302,\n REGISTER = 303,\n STRUCT = 304,\n UNION = 305,\n EQUAL = 306,\n SIZEOF = 307,\n MODULE = 308,\n LBRACKET = 309,\n RBRACKET = 310,\n ILLEGAL = 311,\n CONSTANT = 312,\n NAME = 313,\n RENAME = 314,\n NAMEWARN = 315,\n EXTEND = 316,\n PRAGMA = 317,\n FEATURE = 318,\n VARARGS = 319,\n ENUM = 320,\n CLASS = 321,\n TYPENAME = 322,\n PRIVATE = 323,\n PUBLIC = 324,\n PROTECTED = 325,\n COLON = 326,\n STATIC = 327,\n VIRTUAL = 328,\n FRIEND = 329,\n THROW = 330,\n CATCH = 331,\n EXPLICIT = 332,\n USING = 333,\n NAMESPACE = 334,\n NATIVE = 335,\n INLINE = 336,\n TYPEMAP = 337,\n EXCEPT = 338,\n ECHO = 339,\n APPLY = 340,\n CLEAR = 341,\n SWIGTEMPLATE = 342,\n FRAGMENT = 343,\n WARN = 344,\n LESSTHAN = 345,\n GREATERTHAN = 346,\n MODULO = 347,\n DELETE_KW = 348,\n LESSTHANOREQUALTO = 349,\n GREATERTHANOREQUALTO = 350,\n EQUALTO = 351,\n NOTEQUALTO = 352,\n QUESTIONMARK = 353,\n TYPES = 354,\n PARMS = 355,\n NONID = 356,\n DSTAR = 357,\n DCNOT = 358,\n TEMPLATE = 359,\n OPERATOR = 360,\n COPERATOR = 361,\n PARSETYPE = 362,\n PARSEPARM = 363,\n PARSEPARMS = 364,\n CAST = 365,\n LOR = 366,\n LAND = 367,\n OR = 368,\n XOR = 369,\n AND = 370,\n RSHIFT = 371,\n LSHIFT = 372,\n MINUS = 373,\n PLUS = 374,\n MODULUS = 375,\n SLASH = 376,\n STAR = 377,\n LNOT = 378,\n NOT = 379,\n UMINUS = 380,\n DCOLON = 381\n };\n#endif\n/* Tokens. */\n#define ID 258\n#define HBLOCK 259\n#define POUND 260\n#define STRING 261\n#define INCLUDE 262\n#define IMPORT 263\n#define INSERT 264\n#define CHARCONST 265\n#define NUM_INT 266\n#define NUM_FLOAT 267\n#define NUM_UNSIGNED 268\n#define NUM_LONG 269\n#define NUM_ULONG 270\n#define NUM_LONGLONG 271\n#define NUM_ULONGLONG 272\n#define TYPEDEF 273\n#define TYPE_INT 274\n#define TYPE_UNSIGNED 275\n#define TYPE_SHORT 276\n#define TYPE_LONG 277\n#define TYPE_FLOAT 278\n#define TYPE_DOUBLE 279\n#define TYPE_CHAR 280\n#define TYPE_WCHAR 281\n#define TYPE_VOID 282\n#define TYPE_SIGNED 283\n#define TYPE_BOOL 284\n#define TYPE_COMPLEX 285\n#define TYPE_TYPEDEF 286\n#define TYPE_RAW 287\n#define TYPE_NON_ISO_INT8 288\n#define TYPE_NON_ISO_INT16 289\n#define TYPE_NON_ISO_INT32 290\n#define TYPE_NON_ISO_INT64 291\n#define LPAREN 292\n#define RPAREN 293\n#define COMMA 294\n#define SEMI 295\n#define EXTERN 296\n#define INIT 297\n#define LBRACE 298\n#define RBRACE 299\n#define PERIOD 300\n#define CONST_QUAL 301\n#define VOLATILE 302\n#define REGISTER 303\n#define STRUCT 304\n#define UNION 305\n#define EQUAL 306\n#define SIZEOF 307\n#define MODULE 308\n#define LBRACKET 309\n#define RBRACKET 310\n#define ILLEGAL 311\n#define CONSTANT 312\n#define NAME 313\n#define RENAME 314\n#define NAMEWARN 315\n#define EXTEND 316\n#define PRAGMA 317\n#define FEATURE 318\n#define VARARGS 319\n#define ENUM 320\n#define CLASS 321\n#define TYPENAME 322\n#define PRIVATE 323\n#define PUBLIC 324\n#define PROTECTED 325\n#define COLON 326\n#define STATIC 327\n#define VIRTUAL 328\n#define FRIEND 329\n#define THROW 330\n#define CATCH 331\n#define EXPLICIT 332\n#define USING 333\n#define NAMESPACE 334\n#define NATIVE 335\n#define INLINE 336\n#define TYPEMAP 337\n#define EXCEPT 338\n#define ECHO 339\n#define APPLY 340\n#define CLEAR 341\n#define SWIGTEMPLATE 342\n#define FRAGMENT 343\n#define WARN 344\n#define LESSTHAN 345\n#define GREATERTHAN 346\n#define MODULO 347\n#define DELETE_KW 348\n#define LESSTHANOREQUALTO 349\n#define GREATERTHANOREQUALTO 350\n#define EQUALTO 351\n#define NOTEQUALTO 352\n#define QUESTIONMARK 353\n#define TYPES 354\n#define PARMS 355\n#define NONID 356\n#define DSTAR 357\n#define DCNOT 358\n#define TEMPLATE 359\n#define OPERATOR 360\n#define COPERATOR 361\n#define PARSETYPE 362\n#define PARSEPARM 363\n#define PARSEPARMS 364\n#define CAST 365\n#define LOR 366\n#define LAND 367\n#define OR 368\n#define XOR 369\n#define AND 370\n#define RSHIFT 371\n#define LSHIFT 372\n#define MINUS 373\n#define PLUS 374\n#define MODULUS 375\n#define SLASH 376\n#define STAR 377\n#define LNOT 378\n#define NOT 379\n#define UMINUS 380\n#define DCOLON 381\n\n\n\n\n/* Copy the first part of user declarations. */\n#line 12 \"parser.y\"\n\n\n#define yylex yylex\n\nchar cvsroot_parser_y[] = \"$Id: parser.y 9847 2007-06-05 17:48:16Z olly $\";\n\n#include \"swig.h\"\n#include \"cparse.h\"\n#include \"preprocessor.h\"\n#include \n\n/* We do this for portability */\n#undef alloca\n#define alloca malloc\n\n/* -----------------------------------------------------------------------------\n * Externals\n * ----------------------------------------------------------------------------- */\n\nint yyparse();\n\n/* NEW Variables */\n\nstatic Node *top = 0; /* Top of the generated parse tree */\nstatic int unnamed = 0; /* Unnamed datatype counter */\nstatic Hash *extendhash = 0; /* Hash table of added methods */\nstatic Hash *classes = 0; /* Hash table of classes */\nstatic Symtab *prev_symtab = 0;\nstatic Node *current_class = 0;\nString *ModuleName = 0;\nstatic Node *module_node = 0;\nstatic String *Classprefix = 0; \nstatic String *Namespaceprefix = 0;\nstatic int inclass = 0;\nstatic char *last_cpptype = 0;\nstatic int inherit_list = 0;\nstatic Parm *template_parameters = 0;\nstatic int extendmode = 0;\nstatic int compact_default_args = 0;\nstatic int template_reduce = 0;\nstatic int cparse_externc = 0;\n\nstatic int max_class_levels = 0;\nstatic int class_level = 0;\nstatic Node **class_decl = NULL;\n\n/* -----------------------------------------------------------------------------\n * Assist Functions\n * ----------------------------------------------------------------------------- */\n\n\n \n/* Called by the parser (yyparse) when an error is found.*/\nstatic void yyerror (const char *e) {\n (void)e;\n}\n\nstatic Node *new_node(const String_or_char *tag) {\n Node *n = NewHash();\n set_nodeType(n,tag);\n Setfile(n,cparse_file);\n Setline(n,cparse_line);\n return n;\n}\n\n/* Copies a node. Does not copy tree links or symbol table data (except for\n sym:name) */\n\nstatic Node *copy_node(Node *n) {\n Node *nn;\n Iterator k;\n nn = NewHash();\n Setfile(nn,Getfile(n));\n Setline(nn,Getline(n));\n for (k = First(n); k.key; k = Next(k)) {\n String *ci;\n String *key = k.key;\n char *ckey = Char(key);\n if ((strcmp(ckey,\"nextSibling\") == 0) ||\n\t(strcmp(ckey,\"previousSibling\") == 0) ||\n\t(strcmp(ckey,\"parentNode\") == 0) ||\n\t(strcmp(ckey,\"lastChild\") == 0)) {\n continue;\n }\n if (Strncmp(key,\"csym:\",5) == 0) continue;\n /* We do copy sym:name. For templates */\n if ((strcmp(ckey,\"sym:name\") == 0) || \n\t(strcmp(ckey,\"sym:weak\") == 0) ||\n\t(strcmp(ckey,\"sym:typename\") == 0)) {\n String *ci = Copy(k.item);\n Setattr(nn,key, ci);\n Delete(ci);\n continue;\n }\n if (strcmp(ckey,\"sym:symtab\") == 0) {\n Setattr(nn,\"sym:needs_symtab\", \"1\");\n }\n /* We don't copy any other symbol table attributes */\n if (strncmp(ckey,\"sym:\",4) == 0) {\n continue;\n }\n /* If children. We copy them recursively using this function */\n if (strcmp(ckey,\"firstChild\") == 0) {\n /* Copy children */\n Node *cn = k.item;\n while (cn) {\n\tNode *copy = copy_node(cn);\n\tappendChild(nn,copy);\n\tDelete(copy);\n\tcn = nextSibling(cn);\n }\n continue;\n }\n /* We don't copy the symbol table. But we drop an attribute \n requires_symtab so that functions know it needs to be built */\n\n if (strcmp(ckey,\"symtab\") == 0) {\n /* Node defined a symbol table. */\n Setattr(nn,\"requires_symtab\",\"1\");\n continue;\n }\n /* Can't copy nodes */\n if (strcmp(ckey,\"node\") == 0) {\n continue;\n }\n if ((strcmp(ckey,\"parms\") == 0) || (strcmp(ckey,\"pattern\") == 0) || (strcmp(ckey,\"throws\") == 0)\n\t|| (strcmp(ckey,\"kwargs\") == 0)) {\n ParmList *pl = CopyParmList(k.item);\n Setattr(nn,key,pl);\n Delete(pl);\n continue;\n }\n /* Looks okay. Just copy the data using Copy */\n ci = Copy(k.item);\n Setattr(nn, key, ci);\n Delete(ci);\n }\n return nn;\n}\n\n/* -----------------------------------------------------------------------------\n * Variables\n * ----------------------------------------------------------------------------- */\n\nstatic char *typemap_lang = 0; /* Current language setting */\n\nstatic int cplus_mode = 0;\nstatic String *class_rename = 0;\n\n/* C++ modes */\n\n#define CPLUS_PUBLIC 1\n#define CPLUS_PRIVATE 2\n#define CPLUS_PROTECTED 3\n\n/* include types */\nstatic int import_mode = 0;\n\nvoid SWIG_typemap_lang(const char *tm_lang) {\n typemap_lang = Swig_copy_string(tm_lang);\n}\n\nvoid SWIG_cparse_set_compact_default_args(int defargs) {\n compact_default_args = defargs;\n}\n\nint SWIG_cparse_template_reduce(int treduce) {\n template_reduce = treduce;\n return treduce; \n}\n\n/* -----------------------------------------------------------------------------\n * Assist functions\n * ----------------------------------------------------------------------------- */\n\nstatic int promote_type(int t) {\n if (t <= T_UCHAR || t == T_CHAR) return T_INT;\n return t;\n}\n\n/* Perform type-promotion for binary operators */\nstatic int promote(int t1, int t2) {\n t1 = promote_type(t1);\n t2 = promote_type(t2);\n return t1 > t2 ? t1 : t2;\n}\n\nstatic String *yyrename = 0;\n\n/* Forward renaming operator */\n\nstatic String *resolve_node_scope(String *cname);\n\n\nHash *Swig_cparse_features() {\n static Hash *features_hash = 0;\n if (!features_hash) features_hash = NewHash();\n return features_hash;\n}\n\nstatic String *feature_identifier_fix(String *s) {\n if (SwigType_istemplate(s)) {\n String *tp, *ts, *ta, *tq;\n tp = SwigType_templateprefix(s);\n ts = SwigType_templatesuffix(s);\n ta = SwigType_templateargs(s);\n tq = Swig_symbol_type_qualify(ta,0);\n Append(tp,tq);\n Append(tp,ts);\n Delete(ts);\n Delete(ta);\n Delete(tq);\n return tp;\n } else {\n return NewString(s);\n }\n}\n\n/* Generate the symbol table name for an object */\n/* This is a bit of a mess. Need to clean up */\nstatic String *add_oldname = 0;\n\n\n\nstatic String *make_name(Node *n, String *name,SwigType *decl) {\n int destructor = name && (*(Char(name)) == '~');\n\n if (yyrename) {\n String *s = NewString(yyrename);\n Delete(yyrename);\n yyrename = 0;\n if (destructor && (*(Char(s)) != '~')) {\n Insert(s,0,\"~\");\n }\n return s;\n }\n\n if (!name) return 0;\n return Swig_name_make(n,Namespaceprefix,name,decl,add_oldname);\n}\n\n/* Generate an unnamed identifier */\nstatic String *make_unnamed() {\n unnamed++;\n return NewStringf(\"$unnamed%d$\",unnamed);\n}\n\n/* Return if the node is a friend declaration */\nstatic int is_friend(Node *n) {\n return Cmp(Getattr(n,\"storage\"),\"friend\") == 0;\n}\n\nstatic int is_operator(String *name) {\n return Strncmp(name,\"operator \", 9) == 0;\n}\n\n\n/* Add declaration list to symbol table */\nstatic int add_only_one = 0;\n\nstatic void add_symbols(Node *n) {\n String *decl;\n String *wrn = 0;\n if (inclass && n) {\n cparse_normalize_void(n);\n }\n while (n) {\n String *symname = 0;\n /* for friends, we need to pop the scope once */\n String *old_prefix = 0;\n Symtab *old_scope = 0;\n int isfriend = inclass && is_friend(n);\n int iscdecl = Cmp(nodeType(n),\"cdecl\") == 0;\n if (extendmode) {\n Setattr(n,\"isextension\",\"1\");\n }\n \n if (inclass) {\n String *name = Getattr(n, \"name\");\n if (isfriend) {\n\t/* for friends, we need to add the scopename if needed */\n\tString *prefix = name ? Swig_scopename_prefix(name) : 0;\n\told_prefix = Namespaceprefix;\n\told_scope = Swig_symbol_popscope();\n\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n\tif (!prefix) {\n\t if (name && !is_operator(name) && Namespaceprefix) {\n\t String *nname = NewStringf(\"%s::%s\", Namespaceprefix, name);\n\t Setattr(n,\"name\",nname);\n\t Delete(nname);\n\t }\n\t} else {\n\t Symtab *st = Swig_symbol_getscope(prefix);\n\t String *ns = st ? Getattr(st,\"name\") : prefix;\n\t String *base = Swig_scopename_last(name);\n\t String *nname = NewStringf(\"%s::%s\", ns, base);\n\t Setattr(n,\"name\",nname);\n\t Delete(nname);\n\t Delete(base);\n\t Delete(prefix);\n\t}\n\tNamespaceprefix = 0;\n } else {\n\t/* for member functions, we need to remove the redundant\n\t class scope if provided, as in\n\t \n\t struct Foo {\n\t int Foo::method(int a);\n\t };\n\t \n\t*/\n\tString *prefix = name ? Swig_scopename_prefix(name) : 0;\n\tif (prefix) {\n\t if (Classprefix && (Equal(prefix,Classprefix))) {\n\t String *base = Swig_scopename_last(name);\n\t Setattr(n,\"name\",base);\n\t Delete(base);\n\t }\n\t Delete(prefix);\n\t}\n\n\tif (0 && !Getattr(n,\"parentNode\") && class_level) set_parentNode(n,class_decl[class_level - 1]);\n\tSetattr(n,\"ismember\",\"1\");\n }\n }\n if (!isfriend && inclass) {\n if ((cplus_mode != CPLUS_PUBLIC)) {\n\tint only_csymbol = 1;\n\tif (cplus_mode == CPLUS_PROTECTED) {\n\t Setattr(n,\"access\", \"protected\");\n\t only_csymbol = !Swig_need_protected(n);\n\t} else {\n\t /* private are needed only when they are pure virtuals */\n\t Setattr(n,\"access\", \"private\");\n\t if ((Cmp(Getattr(n,\"storage\"),\"virtual\") == 0)\n\t && (Cmp(Getattr(n,\"value\"),\"0\") == 0)) {\n\t only_csymbol = !Swig_need_protected(n);\n\t }\n\t}\n\tif (only_csymbol) {\n\t /* Only add to C symbol table and continue */\n\t Swig_symbol_add(0, n); \n\t if (add_only_one) break;\n\t n = nextSibling(n);\n\t continue;\n\t}\n } else {\n\t Setattr(n,\"access\", \"public\");\n }\n }\n if (Getattr(n,\"sym:name\")) {\n n = nextSibling(n);\n continue;\n }\n decl = Getattr(n,\"decl\");\n if (!SwigType_isfunction(decl)) {\n String *name = Getattr(n,\"name\");\n String *makename = Getattr(n,\"parser:makename\");\n if (iscdecl) {\t\n\tString *storage = Getattr(n, \"storage\");\n\tif (Cmp(storage,\"typedef\") == 0) {\n\t Setattr(n,\"kind\",\"typedef\");\n\t} else {\n\t SwigType *type = Getattr(n,\"type\");\n\t String *value = Getattr(n,\"value\");\n\t Setattr(n,\"kind\",\"variable\");\n\t if (value && Len(value)) {\n\t Setattr(n,\"hasvalue\",\"1\");\n\t }\n\t if (type) {\n\t SwigType *ty;\n\t SwigType *tmp = 0;\n\t if (decl) {\n\t ty = tmp = Copy(type);\n\t SwigType_push(ty,decl);\n\t } else {\n\t ty = type;\n\t }\n\t if (!SwigType_ismutable(ty)) {\n\t SetFlag(n,\"hasconsttype\");\n\t SetFlag(n,\"feature:immutable\");\n\t }\n\t if (tmp) Delete(tmp);\n\t }\n\t if (!type) {\n\t Printf(stderr,\"notype name %s\\n\", name);\n\t }\n\t}\n }\n Swig_features_get(Swig_cparse_features(), Namespaceprefix, name, 0, n);\n if (makename) {\n\tsymname = make_name(n, makename,0);\n Delattr(n,\"parser:makename\"); /* temporary information, don't leave it hanging around */\n } else {\n makename = name;\n\tsymname = make_name(n, makename,0);\n }\n \n if (!symname) {\n\tsymname = Copy(Getattr(n,\"unnamed\"));\n }\n if (symname) {\n\twrn = Swig_name_warning(n, Namespaceprefix, symname,0);\n }\n } else {\n String *name = Getattr(n,\"name\");\n SwigType *fdecl = Copy(decl);\n SwigType *fun = SwigType_pop_function(fdecl);\n if (iscdecl) {\t\n\tSetattr(n,\"kind\",\"function\");\n }\n \n Swig_features_get(Swig_cparse_features(),Namespaceprefix,name,fun,n);\n\n symname = make_name(n, name,fun);\n wrn = Swig_name_warning(n, Namespaceprefix,symname,fun);\n \n Delete(fdecl);\n Delete(fun);\n \n }\n if (!symname) {\n n = nextSibling(n);\n continue;\n }\n if (GetFlag(n,\"feature:ignore\")) {\n Swig_symbol_add(0, n);\n } else if (strncmp(Char(symname),\"$ignore\",7) == 0) {\n char *c = Char(symname)+7;\n SetFlag(n,\"feature:ignore\");\n if (strlen(c)) {\n\tSWIG_WARN_NODE_BEGIN(n);\n\tSwig_warning(0,Getfile(n), Getline(n), \"%s\\n\",c+1);\n\tSWIG_WARN_NODE_END(n);\n }\n Swig_symbol_add(0, n);\n } else {\n Node *c;\n if ((wrn) && (Len(wrn))) {\n\tString *metaname = symname;\n\tif (!Getmeta(metaname,\"already_warned\")) {\n\t SWIG_WARN_NODE_BEGIN(n);\n\t Swig_warning(0,Getfile(n),Getline(n), \"%s\\n\", wrn);\n\t SWIG_WARN_NODE_END(n);\n\t Setmeta(metaname,\"already_warned\",\"1\");\n\t}\n }\n c = Swig_symbol_add(symname,n);\n\n if (c != n) {\n /* symbol conflict attempting to add in the new symbol */\n if (Getattr(n,\"sym:weak\")) {\n Setattr(n,\"sym:name\",symname);\n } else {\n String *e = NewStringEmpty();\n String *en = NewStringEmpty();\n String *ec = NewStringEmpty();\n int redefined = Swig_need_redefined_warn(n,c,inclass);\n if (redefined) {\n Printf(en,\"Identifier '%s' redefined (ignored)\",symname);\n Printf(ec,\"previous definition of '%s'\",symname);\n } else {\n Printf(en,\"Redundant redeclaration of '%s'\",symname);\n Printf(ec,\"previous declaration of '%s'\",symname);\n }\n if (Cmp(symname,Getattr(n,\"name\"))) {\n Printf(en,\" (Renamed from '%s')\", SwigType_namestr(Getattr(n,\"name\")));\n }\n Printf(en,\",\");\n if (Cmp(symname,Getattr(c,\"name\"))) {\n Printf(ec,\" (Renamed from '%s')\", SwigType_namestr(Getattr(c,\"name\")));\n }\n Printf(ec,\".\");\n\t SWIG_WARN_NODE_BEGIN(n);\n if (redefined) {\n Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),\"%s\\n\",en);\n Swig_warning(WARN_PARSE_REDEFINED,Getfile(c),Getline(c),\"%s\\n\",ec);\n } else if (!is_friend(n) && !is_friend(c)) {\n Swig_warning(WARN_PARSE_REDUNDANT,Getfile(n),Getline(n),\"%s\\n\",en);\n Swig_warning(WARN_PARSE_REDUNDANT,Getfile(c),Getline(c),\"%s\\n\",ec);\n }\n\t SWIG_WARN_NODE_END(n);\n Printf(e,\"%s:%d:%s\\n%s:%d:%s\\n\",Getfile(n),Getline(n),en,\n Getfile(c),Getline(c),ec);\n Setattr(n,\"error\",e);\n\t Delete(e);\n Delete(en);\n Delete(ec);\n }\n }\n }\n /* restore the class scope if needed */\n if (isfriend) {\n Swig_symbol_setscope(old_scope);\n if (old_prefix) {\n\tDelete(Namespaceprefix);\n\tNamespaceprefix = old_prefix;\n }\n }\n Delete(symname);\n\n if (add_only_one) return;\n n = nextSibling(n);\n }\n}\n\n\n/* add symbols a parse tree node copy */\n\nstatic void add_symbols_copy(Node *n) {\n String *name;\n int emode = 0;\n while (n) {\n char *cnodeType = Char(nodeType(n));\n\n if (strcmp(cnodeType,\"access\") == 0) {\n String *kind = Getattr(n,\"kind\");\n if (Strcmp(kind,\"public\") == 0) {\n\tcplus_mode = CPLUS_PUBLIC;\n } else if (Strcmp(kind,\"private\") == 0) {\n\tcplus_mode = CPLUS_PRIVATE;\n } else if (Strcmp(kind,\"protected\") == 0) {\n\tcplus_mode = CPLUS_PROTECTED;\n }\n n = nextSibling(n);\n continue;\n }\n\n add_oldname = Getattr(n,\"sym:name\");\n if ((add_oldname) || (Getattr(n,\"sym:needs_symtab\"))) {\n if (add_oldname) {\n\tDohIncref(add_oldname);\n\t/* Disable this, it prevents %rename to work with templates */\n\t/* If already renamed, we used that name */\n\t/*\n\tif (Strcmp(add_oldname, Getattr(n,\"name\")) != 0) {\n\t Delete(yyrename);\n\t yyrename = Copy(add_oldname);\n\t}\n\t*/\n }\n Delattr(n,\"sym:needs_symtab\");\n Delattr(n,\"sym:name\");\n\n add_only_one = 1;\n add_symbols(n);\n\n if (Getattr(n,\"partialargs\")) {\n\tSwig_symbol_cadd(Getattr(n,\"partialargs\"),n);\n }\n add_only_one = 0;\n name = Getattr(n,\"name\");\n if (Getattr(n,\"requires_symtab\")) {\n\tSwig_symbol_newscope();\n\tSwig_symbol_setscopename(name);\n\tDelete(Namespaceprefix);\n\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n }\n if (strcmp(cnodeType,\"class\") == 0) {\n\tinclass = 1;\n\tcurrent_class = n;\n\tif (Strcmp(Getattr(n,\"kind\"),\"class\") == 0) {\n\t cplus_mode = CPLUS_PRIVATE;\n\t} else {\n\t cplus_mode = CPLUS_PUBLIC;\n\t}\n }\n if (strcmp(cnodeType,\"extend\") == 0) {\n\temode = cplus_mode;\n\tcplus_mode = CPLUS_PUBLIC;\n }\n add_symbols_copy(firstChild(n));\n if (strcmp(cnodeType,\"extend\") == 0) {\n\tcplus_mode = emode;\n }\n if (Getattr(n,\"requires_symtab\")) {\n\tSetattr(n,\"symtab\", Swig_symbol_popscope());\n\tDelattr(n,\"requires_symtab\");\n\tDelete(Namespaceprefix);\n\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n }\n if (add_oldname) {\n\tDelete(add_oldname);\n\tadd_oldname = 0;\n }\n if (strcmp(cnodeType,\"class\") == 0) {\n\tinclass = 0;\n\tcurrent_class = 0;\n }\n } else {\n if (strcmp(cnodeType,\"extend\") == 0) {\n\temode = cplus_mode;\n\tcplus_mode = CPLUS_PUBLIC;\n }\n add_symbols_copy(firstChild(n));\n if (strcmp(cnodeType,\"extend\") == 0) {\n\tcplus_mode = emode;\n }\n }\n n = nextSibling(n);\n }\n}\n\n/* Extension merge. This function is used to handle the %extend directive\n when it appears before a class definition. To handle this, the %extend\n actually needs to take precedence. Therefore, we will selectively nuke symbols\n from the current symbol table, replacing them with the added methods */\n\nstatic void merge_extensions(Node *cls, Node *am) {\n Node *n;\n Node *csym;\n\n n = firstChild(am);\n while (n) {\n String *symname;\n if (Strcmp(nodeType(n),\"constructor\") == 0) {\n symname = Getattr(n,\"sym:name\");\n if (symname) {\n\tif (Strcmp(symname,Getattr(n,\"name\")) == 0) {\n\t /* If the name and the sym:name of a constructor are the same,\n then it hasn't been renamed. However---the name of the class\n itself might have been renamed so we need to do a consistency\n check here */\n\t if (Getattr(cls,\"sym:name\")) {\n\t Setattr(n,\"sym:name\", Getattr(cls,\"sym:name\"));\n\t }\n\t}\n } \n }\n\n symname = Getattr(n,\"sym:name\");\n DohIncref(symname);\n if ((symname) && (!Getattr(n,\"error\"))) {\n /* Remove node from its symbol table */\n Swig_symbol_remove(n);\n csym = Swig_symbol_add(symname,n);\n if (csym != n) {\n\t/* Conflict with previous definition. Nuke previous definition */\n\tString *e = NewStringEmpty();\n\tString *en = NewStringEmpty();\n\tString *ec = NewStringEmpty();\n\tPrintf(ec,\"Identifier '%s' redefined by %%extend (ignored),\",symname);\n\tPrintf(en,\"%%extend definition of '%s'.\",symname);\n\tSWIG_WARN_NODE_BEGIN(n);\n\tSwig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),\"%s\\n\",ec);\n\tSwig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),\"%s\\n\",en);\n\tSWIG_WARN_NODE_END(n);\n\tPrintf(e,\"%s:%d:%s\\n%s:%d:%s\\n\",Getfile(csym),Getline(csym),ec, \n\t Getfile(n),Getline(n),en);\n\tSetattr(csym,\"error\",e);\n\tDelete(e);\n\tDelete(en);\n\tDelete(ec);\n\tSwig_symbol_remove(csym); /* Remove class definition */\n\tSwig_symbol_add(symname,n); /* Insert extend definition */\n }\n }\n n = nextSibling(n);\n }\n}\n\nstatic void append_previous_extension(Node *cls, Node *am) {\n Node *n, *ne;\n Node *pe = 0;\n Node *ae = 0;\n\n if (!am) return;\n \n n = firstChild(am);\n while (n) {\n ne = nextSibling(n);\n set_nextSibling(n,0);\n /* typemaps and fragments need to be prepended */\n if (((Cmp(nodeType(n),\"typemap\") == 0) || (Cmp(nodeType(n),\"fragment\") == 0))) {\n if (!pe) pe = new_node(\"extend\");\n appendChild(pe, n);\n } else {\n if (!ae) ae = new_node(\"extend\");\n appendChild(ae, n);\n } \n n = ne;\n }\n if (pe) prependChild(cls,pe);\n if (ae) appendChild(cls,ae);\n}\n \n\n/* Check for unused %extend. Special case, don't report unused\n extensions for templates */\n \nstatic void check_extensions() {\n Iterator ki;\n\n if (!extendhash) return;\n for (ki = First(extendhash); ki.key; ki = Next(ki)) {\n if (!Strchr(ki.key,'<')) {\n SWIG_WARN_NODE_BEGIN(ki.item);\n Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), \"%%extend defined for an undeclared class %s.\\n\", ki.key);\n SWIG_WARN_NODE_END(ki.item);\n }\n }\n}\n\n/* Check a set of declarations to see if any are pure-abstract */\n\nstatic List *pure_abstract(Node *n) {\n List *abs = 0;\n while (n) {\n if (Cmp(nodeType(n),\"cdecl\") == 0) {\n String *decl = Getattr(n,\"decl\");\n if (SwigType_isfunction(decl)) {\n\tString *init = Getattr(n,\"value\");\n\tif (Cmp(init,\"0\") == 0) {\n\t if (!abs) {\n\t abs = NewList();\n\t }\n\t Append(abs,n);\n\t Setattr(n,\"abstract\",\"1\");\n\t}\n }\n } else if (Cmp(nodeType(n),\"destructor\") == 0) {\n if (Cmp(Getattr(n,\"value\"),\"0\") == 0) {\n\tif (!abs) {\n\t abs = NewList();\n\t}\n\tAppend(abs,n);\n\tSetattr(n,\"abstract\",\"1\");\n }\n }\n n = nextSibling(n);\n }\n return abs;\n}\n\n/* Make a classname */\n\nstatic String *make_class_name(String *name) {\n String *nname = 0;\n if (Namespaceprefix) {\n nname= NewStringf(\"%s::%s\", Namespaceprefix, name);\n } else {\n nname = NewString(name);\n }\n if (SwigType_istemplate(nname)) {\n String *prefix, *args, *qargs;\n prefix = SwigType_templateprefix(nname);\n args = SwigType_templateargs(nname);\n qargs = Swig_symbol_type_qualify(args,0);\n Append(prefix,qargs);\n Delete(nname);\n Delete(args);\n Delete(qargs);\n nname = prefix;\n }\n return nname;\n}\n\nstatic List *make_inherit_list(String *clsname, List *names) {\n int i, ilen;\n String *derived;\n List *bases = NewList();\n\n if (Namespaceprefix) derived = NewStringf(\"%s::%s\", Namespaceprefix,clsname);\n else derived = NewString(clsname);\n\n ilen = Len(names);\n for (i = 0; i < ilen; i++) {\n Node *s;\n String *base;\n String *n = Getitem(names,i);\n /* Try to figure out where this symbol is */\n s = Swig_symbol_clookup(n,0);\n if (s) {\n while (s && (Strcmp(nodeType(s),\"class\") != 0)) {\n\t/* Not a class. Could be a typedef though. */\n\tString *storage = Getattr(s,\"storage\");\n\tif (storage && (Strcmp(storage,\"typedef\") == 0)) {\n\t String *nn = Getattr(s,\"type\");\n\t s = Swig_symbol_clookup(nn,Getattr(s,\"sym:symtab\"));\n\t} else {\n\t break;\n\t}\n }\n if (s && ((Strcmp(nodeType(s),\"class\") == 0) || (Strcmp(nodeType(s),\"template\") == 0))) {\n\tString *q = Swig_symbol_qualified(s);\n\tAppend(bases,s);\n\tif (q) {\n\t base = NewStringf(\"%s::%s\", q, Getattr(s,\"name\"));\n\t Delete(q);\n\t} else {\n\t base = NewString(Getattr(s,\"name\"));\n\t}\n } else {\n\tbase = NewString(n);\n }\n } else {\n base = NewString(n);\n }\n if (base) {\n Swig_name_inherit(base,derived);\n Delete(base);\n }\n }\n return bases;\n}\n\n/* If the class name is qualified. We need to create or lookup namespace entries */\n\nstatic Symtab *get_global_scope() {\n Symtab *symtab = Swig_symbol_current();\n Node *pn = parentNode(symtab);\n while (pn) {\n symtab = pn;\n pn = parentNode(symtab);\n if (!pn) break;\n }\n Swig_symbol_setscope(symtab);\n return symtab;\n}\n \n\nstatic Node *nscope = 0;\nstatic Node *nscope_inner = 0;\nstatic String *resolve_node_scope(String *cname) {\n Symtab *gscope = 0;\n nscope = 0;\n nscope_inner = 0; \n if (Swig_scopename_check(cname)) {\n Node *ns;\n String *prefix = Swig_scopename_prefix(cname);\n String *base = Swig_scopename_last(cname);\n if (prefix && (Strncmp(prefix,\"::\",2) == 0)) {\n /* Use the global scope */\n String *nprefix = NewString(Char(prefix)+2);\n Delete(prefix);\n prefix= nprefix;\n gscope = get_global_scope();\n } \n if (!prefix || (Len(prefix) == 0)) {\n /* Use the global scope, but we need to add a 'global' namespace. */\n if (!gscope) gscope = get_global_scope();\n /* note that this namespace is not the \"unnamed\" one,\n\t and we don't use Setattr(nscope,\"name\", \"\"),\n\t because the unnamed namespace is private */\n nscope = new_node(\"namespace\");\n Setattr(nscope,\"symtab\", gscope);;\n nscope_inner = nscope;\n return base;\n }\n /* Try to locate the scope */\n ns = Swig_symbol_clookup(prefix,0);\n if (!ns) {\n Swig_error(cparse_file,cparse_line,\"Undefined scope '%s'\\n\", prefix);\n } else {\n Symtab *nstab = Getattr(ns,\"symtab\");\n if (!nstab) {\n\tSwig_error(cparse_file,cparse_line,\n\t\t \"'%s' is not defined as a valid scope.\\n\", prefix);\n\tns = 0;\n } else {\n\t/* Check if the node scope is the current scope */\n\tString *tname = Swig_symbol_qualifiedscopename(0);\n\tString *nname = Swig_symbol_qualifiedscopename(nstab);\n\tif (tname && (Strcmp(tname,nname) == 0)) {\n\t ns = 0;\n\t cname = base;\n\t}\n\tDelete(tname);\n\tDelete(nname);\n }\n if (ns) {\n\t/* we will try to create a new node using the namespaces we\n\t can find in the scope name */\n\tList *scopes;\n\tString *sname;\n\tIterator si;\n\tString *name = NewString(prefix);\n\tscopes = NewList();\n\twhile (name) {\n\t String *base = Swig_scopename_last(name);\n\t String *tprefix = Swig_scopename_prefix(name);\n\t Insert(scopes,0,base);\n\t Delete(base);\n\t Delete(name);\n\t name = tprefix;\n\t}\n\tfor (si = First(scopes); si.item; si = Next(si)) {\n\t Node *ns1,*ns2;\n\t sname = si.item;\n\t ns1 = Swig_symbol_clookup(sname,0);\n\t assert(ns1);\n\t if (Strcmp(nodeType(ns1),\"namespace\") == 0) {\n\t if (Getattr(ns1,\"alias\")) {\n\t ns1 = Getattr(ns1,\"namespace\");\n\t }\n\t } else {\n\t /* now this last part is a class */\n\t si = Next(si);\n\t ns1 = Swig_symbol_clookup(sname,0);\n\t /* or a nested class tree, which is unrolled here */\n\t for (; si.item; si = Next(si)) {\n\t if (si.item) {\n\t\tPrintf(sname,\"::%s\",si.item);\n\t }\n\t }\n\t /* we get the 'inner' class */\n\t nscope_inner = Swig_symbol_clookup(sname,0);\n\t /* set the scope to the inner class */\n\t Swig_symbol_setscope(Getattr(nscope_inner,\"symtab\"));\n\t /* save the last namespace prefix */\n\t Delete(Namespaceprefix);\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t /* and return the node name, including the inner class prefix */\n\t break;\n\t }\n\t /* here we just populate the namespace tree as usual */\n\t ns2 = new_node(\"namespace\");\n\t Setattr(ns2,\"name\",sname);\n\t Setattr(ns2,\"symtab\", Getattr(ns1,\"symtab\"));\n\t add_symbols(ns2);\n\t Swig_symbol_setscope(Getattr(ns1,\"symtab\"));\n\t Delete(Namespaceprefix);\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t if (nscope_inner) {\n\t if (Getattr(nscope_inner,\"symtab\") != Getattr(ns2,\"symtab\")) {\n\t appendChild(nscope_inner,ns2);\n\t Delete(ns2);\n\t }\n\t }\n\t nscope_inner = ns2;\n\t if (!nscope) nscope = ns2;\n\t}\n\tcname = base;\n\tDelete(scopes);\n }\n }\n Delete(prefix);\n }\n return cname;\n}\n \n\n\n\n\n/* Structures for handling code fragments built for nested classes */\n\ntypedef struct Nested {\n String *code; /* Associated code fragment */\n int line; /* line number where it starts */\n char *name; /* Name associated with this nested class */\n char *kind; /* Kind of class */\n int unnamed; /* unnamed class */\n SwigType *type; /* Datatype associated with the name */\n struct Nested *next; /* Next code fragment in list */\n} Nested;\n\n/* Some internal variables for saving nested class information */\n\nstatic Nested *nested_list = 0;\n\n/* Add a function to the nested list */\n\nstatic void add_nested(Nested *n) {\n Nested *n1;\n if (!nested_list) nested_list = n;\n else {\n n1 = nested_list;\n while (n1->next) n1 = n1->next;\n n1->next = n;\n }\n}\n\n/* Dump all of the nested class declarations to the inline processor\n * However. We need to do a few name replacements and other munging\n * first. This function must be called before closing a class! */\n\nstatic Node *dump_nested(const char *parent) {\n Nested *n,*n1;\n Node *ret = 0;\n n = nested_list;\n if (!parent) {\n nested_list = 0;\n return 0;\n }\n while (n) {\n Node *retx;\n SwigType *nt;\n /* Token replace the name of the parent class */\n Replace(n->code, \"$classname\", parent, DOH_REPLACE_ANY);\n\n /* Fix up the name of the datatype (for building typedefs and other stuff) */\n Append(n->type,parent);\n Append(n->type,\"_\");\n Append(n->type,n->name);\n\n /* Add the appropriate declaration to the C++ processor */\n retx = new_node(\"cdecl\");\n Setattr(retx,\"name\",n->name);\n nt = Copy(n->type);\n Setattr(retx,\"type\",nt);\n Delete(nt);\n Setattr(retx,\"nested\",parent);\n if (n->unnamed) {\n Setattr(retx,\"unnamed\",\"1\");\n }\n \n add_symbols(retx);\n if (ret) {\n set_nextSibling(retx,ret);\n Delete(ret);\n }\n ret = retx;\n\n /* Insert a forward class declaration */\n /* Disabled: [ 597599 ] union in class: incorrect scope \n retx = new_node(\"classforward\");\n Setattr(retx,\"kind\",n->kind);\n Setattr(retx,\"name\",Copy(n->type));\n Setattr(retx,\"sym:name\", make_name(n->type,0));\n set_nextSibling(retx,ret);\n ret = retx; \n */\n\n /* Make all SWIG created typedef structs/unions/classes unnamed else \n redefinition errors occur - nasty hack alert.*/\n\n {\n const char* types_array[3] = {\"struct\", \"union\", \"class\"};\n int i;\n for (i=0; i<3; i++) {\n\tchar* code_ptr = Char(n->code);\n\twhile (code_ptr) {\n\t /* Replace struct name (as in 'struct name {...}' ) with whitespace\n\t name will be between struct and opening brace */\n\t\n\t code_ptr = strstr(code_ptr, types_array[i]);\n\t if (code_ptr) {\n\t char *open_bracket_pos;\n\t code_ptr += strlen(types_array[i]);\n\t open_bracket_pos = strchr(code_ptr, '{');\n\t if (open_bracket_pos) { \n\t /* Make sure we don't have something like struct A a; */\n\t char* semi_colon_pos = strchr(code_ptr, ';');\n\t if (!(semi_colon_pos && (semi_colon_pos < open_bracket_pos)))\n\t\twhile (code_ptr < open_bracket_pos)\n\t\t *code_ptr++ = ' ';\n\t }\n\t }\n\t}\n }\n }\n \n {\n /* Remove SWIG directive %constant which may be left in the SWIG created typedefs */\n char* code_ptr = Char(n->code);\n while (code_ptr) {\n\tcode_ptr = strstr(code_ptr, \"%constant\");\n\tif (code_ptr) {\n\t char* directive_end_pos = strchr(code_ptr, ';');\n\t if (directive_end_pos) { \n while (code_ptr <= directive_end_pos)\n *code_ptr++ = ' ';\n\t }\n\t}\n }\n }\n {\n Node *head = new_node(\"insert\");\n String *code = NewStringf(\"\\n%s\\n\",n->code);\n Setattr(head,\"code\", code);\n Delete(code);\n set_nextSibling(head,ret);\n Delete(ret); \n ret = head;\n }\n \n /* Dump the code to the scanner */\n start_inline(Char(n->code),n->line);\n\n n1 = n->next;\n Delete(n->code);\n free(n);\n n = n1;\n }\n nested_list = 0;\n return ret;\n}\n\nNode *Swig_cparse(File *f) {\n scanner_file(f);\n top = 0;\n yyparse();\n return top;\n}\n\nstatic void single_new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {\n String *fname;\n String *name;\n String *fixname;\n SwigType *t = Copy(type);\n\n /* Printf(stdout, \"single_new_feature: [%s] [%s] [%s] [%s] [%s] [%s]\\n\", featurename, val, declaratorid, t, ParmList_str_defaultargs(declaratorparms), qualifier); */\n\n fname = NewStringf(\"feature:%s\",featurename);\n if (declaratorid) {\n fixname = feature_identifier_fix(declaratorid);\n } else {\n fixname = NewStringEmpty();\n }\n if (Namespaceprefix) {\n name = NewStringf(\"%s::%s\",Namespaceprefix, fixname);\n } else {\n name = fixname;\n }\n\n if (declaratorparms) Setmeta(val,\"parms\",declaratorparms);\n if (!Len(t)) t = 0;\n if (t) {\n if (qualifier) SwigType_push(t,qualifier);\n if (SwigType_isfunction(t)) {\n SwigType *decl = SwigType_pop_function(t);\n if (SwigType_ispointer(t)) {\n\tString *nname = NewStringf(\"*%s\",name);\n\tSwig_feature_set(Swig_cparse_features(), nname, decl, fname, val, featureattribs);\n\tDelete(nname);\n } else {\n\tSwig_feature_set(Swig_cparse_features(), name, decl, fname, val, featureattribs);\n }\n Delete(decl);\n } else if (SwigType_ispointer(t)) {\n String *nname = NewStringf(\"*%s\",name);\n Swig_feature_set(Swig_cparse_features(),nname,0,fname,val, featureattribs);\n Delete(nname);\n }\n } else {\n /* Global feature, that is, feature not associated with any particular symbol */\n Swig_feature_set(Swig_cparse_features(),name,0,fname,val, featureattribs);\n }\n Delete(fname);\n Delete(name);\n}\n\n/* Add a new feature to the Hash. Additional features are added if the feature has a parameter list (declaratorparms)\n * and one or more of the parameters have a default argument. An extra feature is added for each defaulted parameter,\n * simulating the equivalent overloaded method. */\nstatic void new_feature(const char *featurename, String *val, Hash *featureattribs, char *declaratorid, SwigType *type, ParmList *declaratorparms, String *qualifier) {\n\n ParmList *declparms = declaratorparms;\n\n /* Add the feature */\n single_new_feature(featurename, val, featureattribs, declaratorid, type, declaratorparms, qualifier);\n\n /* Add extra features if there are default parameters in the parameter list */\n if (type) {\n while (declparms) {\n if (ParmList_has_defaultargs(declparms)) {\n\n /* Create a parameter list for the new feature by copying all\n but the last (defaulted) parameter */\n ParmList* newparms = CopyParmListMax(declparms, ParmList_len(declparms)-1);\n\n /* Create new declaration - with the last parameter removed */\n SwigType *newtype = Copy(type);\n Delete(SwigType_pop_function(newtype)); /* remove the old parameter list from newtype */\n SwigType_add_function(newtype,newparms);\n\n single_new_feature(featurename, Copy(val), featureattribs, declaratorid, newtype, newparms, qualifier);\n declparms = newparms;\n } else {\n declparms = 0;\n }\n }\n }\n}\n\n/* check if a function declaration is a plain C object */\nstatic int is_cfunction(Node *n) {\n if (!cparse_cplusplus || cparse_externc) return 1;\n if (Cmp(Getattr(n,\"storage\"),\"externc\") == 0) {\n return 1;\n }\n return 0;\n}\n\n/* If the Node is a function with parameters, check to see if any of the parameters\n * have default arguments. If so create a new function for each defaulted argument. \n * The additional functions form a linked list of nodes with the head being the original Node n. */\nstatic void default_arguments(Node *n) {\n Node *function = n;\n\n if (function) {\n ParmList *varargs = Getattr(function,\"feature:varargs\");\n if (varargs) {\n /* Handles the %varargs directive by looking for \"feature:varargs\" and \n * substituting ... with an alternative set of arguments. */\n Parm *p = Getattr(function,\"parms\");\n Parm *pp = 0;\n while (p) {\n\tSwigType *t = Getattr(p,\"type\");\n\tif (Strcmp(t,\"v(...)\") == 0) {\n\t if (pp) {\n\t ParmList *cv = Copy(varargs);\n\t set_nextSibling(pp,cv);\n\t Delete(cv);\n\t } else {\n\t ParmList *cv = Copy(varargs);\n\t Setattr(function,\"parms\", cv);\n\t Delete(cv);\n\t }\n\t break;\n\t}\n\tpp = p;\n\tp = nextSibling(p);\n }\n }\n\n /* Do not add in functions if kwargs is being used or if user wants old default argument wrapping\n (one wrapped method per function irrespective of number of default arguments) */\n if (compact_default_args \n\t|| is_cfunction(function) \n\t|| GetFlag(function,\"feature:compactdefaultargs\") \n\t|| GetFlag(function,\"feature:kwargs\")) {\n ParmList *p = Getattr(function,\"parms\");\n if (p) \n Setattr(p,\"compactdefargs\", \"1\"); /* mark parameters for special handling */\n function = 0; /* don't add in extra methods */\n }\n }\n\n while (function) {\n ParmList *parms = Getattr(function,\"parms\");\n if (ParmList_has_defaultargs(parms)) {\n\n /* Create a parameter list for the new function by copying all\n but the last (defaulted) parameter */\n ParmList* newparms = CopyParmListMax(parms,ParmList_len(parms)-1);\n\n /* Create new function and add to symbol table */\n {\n\tSwigType *ntype = Copy(nodeType(function));\n\tchar *cntype = Char(ntype);\n Node *new_function = new_node(ntype);\n SwigType *decl = Copy(Getattr(function,\"decl\"));\n int constqualifier = SwigType_isconst(decl);\n\tString *ccode = Copy(Getattr(function,\"code\"));\n\tString *cstorage = Copy(Getattr(function,\"storage\"));\n\tString *cvalue = Copy(Getattr(function,\"value\"));\n\tSwigType *ctype = Copy(Getattr(function,\"type\"));\n\tString *cthrow = Copy(Getattr(function,\"throw\"));\n\n Delete(SwigType_pop_function(decl)); /* remove the old parameter list from decl */\n SwigType_add_function(decl,newparms);\n if (constqualifier)\n SwigType_add_qualifier(decl,\"const\");\n\n Setattr(new_function,\"name\", Getattr(function,\"name\"));\n Setattr(new_function,\"code\", ccode);\n Setattr(new_function,\"decl\", decl);\n Setattr(new_function,\"parms\", newparms);\n Setattr(new_function,\"storage\", cstorage);\n Setattr(new_function,\"value\", cvalue);\n Setattr(new_function,\"type\", ctype);\n Setattr(new_function,\"throw\", cthrow);\n\n\tDelete(ccode);\n\tDelete(cstorage);\n\tDelete(cvalue);\n\tDelete(ctype);\n\tDelete(cthrow);\n\tDelete(decl);\n\n {\n Node *throws = Getattr(function,\"throws\");\n\t ParmList *pl = CopyParmList(throws);\n if (throws) Setattr(new_function,\"throws\",pl);\n\t Delete(pl);\n }\n\n /* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */\n if (strcmp(cntype,\"template\") == 0) {\n Node *templatetype = Getattr(function,\"templatetype\");\n Node *symtypename = Getattr(function,\"sym:typename\");\n Parm *templateparms = Getattr(function,\"templateparms\");\n if (templatetype) {\n\t Node *tmp = Copy(templatetype);\n\t Setattr(new_function,\"templatetype\",tmp);\n\t Delete(tmp);\n\t }\n if (symtypename) {\n\t Node *tmp = Copy(symtypename);\n\t Setattr(new_function,\"sym:typename\",tmp);\n\t Delete(tmp);\n\t }\n if (templateparms) {\n\t Parm *tmp = CopyParmList(templateparms);\n\t Setattr(new_function,\"templateparms\",tmp);\n\t Delete(tmp);\n\t }\n } else if (strcmp(cntype,\"constructor\") == 0) {\n /* only copied for constructors as this is not a user defined feature - it is hard coded in the parser */\n if (GetFlag(function,\"feature:new\")) SetFlag(new_function,\"feature:new\");\n }\n\n add_symbols(new_function);\n /* mark added functions as ones with overloaded parameters and point to the parsed method */\n Setattr(new_function,\"defaultargs\", n);\n\n /* Point to the new function, extending the linked list */\n set_nextSibling(function, new_function);\n\tDelete(new_function);\n function = new_function;\n\t\n\tDelete(ntype);\n }\n } else {\n function = 0;\n }\n }\n}\n\n/* -----------------------------------------------------------------------------\n * tag_nodes()\n *\n * Used by the parser to mark subtypes with extra information.\n * ----------------------------------------------------------------------------- */\n\nstatic void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {\n while (n) {\n Setattr(n, attrname, value);\n tag_nodes(firstChild(n), attrname, value);\n n = nextSibling(n);\n }\n}\n\n\n\n/* Enabling traces. */\n#ifndef YYDEBUG\n# define YYDEBUG 0\n#endif\n\n/* Enabling verbose error messages. */\n#ifdef YYERROR_VERBOSE\n# undef YYERROR_VERBOSE\n# define YYERROR_VERBOSE 1\n#else\n# define YYERROR_VERBOSE 0\n#endif\n\n/* Enabling the token table. */\n#ifndef YYTOKEN_TABLE\n# define YYTOKEN_TABLE 0\n#endif\n\n#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED\ntypedef union YYSTYPE\n#line 1349 \"parser.y\"\n{\n char *id;\n List *bases;\n struct Define {\n String *val;\n String *rawval;\n int type;\n String *qualifier;\n String *bitfield;\n Parm *throws;\n String *throwf;\n } dtype;\n struct {\n char *type;\n String *filename;\n int line;\n } loc;\n struct {\n char *id;\n SwigType *type;\n String *defarg;\n ParmList *parms;\n short have_parms;\n ParmList *throws;\n String *throwf;\n } decl;\n Parm *tparms;\n struct {\n String *op;\n Hash *kwargs;\n } tmap;\n struct {\n String *type;\n String *us;\n } ptype;\n SwigType *type;\n String *str;\n Parm *p;\n ParmList *pl;\n int ivalue;\n Node *node;\n}\n/* Line 187 of yacc.c. */\n#line 1728 \"y.tab.c\"\n\tYYSTYPE;\n# define yystype YYSTYPE /* obsolescent; will be withdrawn */\n# define YYSTYPE_IS_DECLARED 1\n# define YYSTYPE_IS_TRIVIAL 1\n#endif\n\n\n\n/* Copy the second part of user declarations. */\n\n\n/* Line 216 of yacc.c. */\n#line 1741 \"y.tab.c\"\n\n#ifdef short\n# undef short\n#endif\n\n#ifdef YYTYPE_UINT8\ntypedef YYTYPE_UINT8 yytype_uint8;\n#else\ntypedef unsigned char yytype_uint8;\n#endif\n\n#ifdef YYTYPE_INT8\ntypedef YYTYPE_INT8 yytype_int8;\n#elif (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\ntypedef signed char yytype_int8;\n#else\ntypedef short int yytype_int8;\n#endif\n\n#ifdef YYTYPE_UINT16\ntypedef YYTYPE_UINT16 yytype_uint16;\n#else\ntypedef unsigned short int yytype_uint16;\n#endif\n\n#ifdef YYTYPE_INT16\ntypedef YYTYPE_INT16 yytype_int16;\n#else\ntypedef short int yytype_int16;\n#endif\n\n#ifndef YYSIZE_T\n# ifdef __SIZE_TYPE__\n# define YYSIZE_T __SIZE_TYPE__\n# elif defined size_t\n# define YYSIZE_T size_t\n# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\n# include /* INFRINGES ON USER NAME SPACE */\n# define YYSIZE_T size_t\n# else\n# define YYSIZE_T unsigned int\n# endif\n#endif\n\n#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)\n\n#ifndef YY_\n# if YYENABLE_NLS\n# if ENABLE_NLS\n# include /* INFRINGES ON USER NAME SPACE */\n# define YY_(msgid) dgettext (\"bison-runtime\", msgid)\n# endif\n# endif\n# ifndef YY_\n# define YY_(msgid) msgid\n# endif\n#endif\n\n/* Suppress unused-variable warnings by \"using\" E. */\n#if ! defined lint || defined __GNUC__\n# define YYUSE(e) ((void) (e))\n#else\n# define YYUSE(e) /* empty */\n#endif\n\n/* Identity function, used to suppress warnings about constant conditions. */\n#ifndef lint\n# define YYID(n) (n)\n#else\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic int\nYYID (int i)\n#else\nstatic int\nYYID (i)\n int i;\n#endif\n{\n return i;\n}\n#endif\n\n#if ! defined yyoverflow || YYERROR_VERBOSE\n\n/* The parser invokes alloca or malloc; define the necessary symbols. */\n\n# ifdef YYSTACK_USE_ALLOCA\n# if YYSTACK_USE_ALLOCA\n# ifdef __GNUC__\n# define YYSTACK_ALLOC __builtin_alloca\n# elif defined __BUILTIN_VA_ARG_INCR\n# include /* INFRINGES ON USER NAME SPACE */\n# elif defined _AIX\n# define YYSTACK_ALLOC __alloca\n# elif defined _MSC_VER\n# include /* INFRINGES ON USER NAME SPACE */\n# define alloca _alloca\n# else\n# define YYSTACK_ALLOC alloca\n# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\n# include /* INFRINGES ON USER NAME SPACE */\n# ifndef _STDLIB_H\n# define _STDLIB_H 1\n# endif\n# endif\n# endif\n# endif\n# endif\n\n# ifdef YYSTACK_ALLOC\n /* Pacify GCC's `empty if-body' warning. */\n# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))\n# ifndef YYSTACK_ALLOC_MAXIMUM\n /* The OS might guarantee only one guard page at the bottom of the stack,\n and a page size can be as small as 4096 bytes. So we cannot safely\n invoke alloca (N) if N exceeds 4096. Use a slightly smaller number\n to allow for a few compiler-allocated temporary stack slots. */\n# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */\n# endif\n# else\n# define YYSTACK_ALLOC YYMALLOC\n# define YYSTACK_FREE YYFREE\n# ifndef YYSTACK_ALLOC_MAXIMUM\n# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM\n# endif\n# if (defined __cplusplus && ! defined _STDLIB_H \\\n && ! ((defined YYMALLOC || defined malloc) \\\n\t && (defined YYFREE || defined free)))\n# include /* INFRINGES ON USER NAME SPACE */\n# ifndef _STDLIB_H\n# define _STDLIB_H 1\n# endif\n# endif\n# ifndef YYMALLOC\n# define YYMALLOC malloc\n# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nvoid *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */\n# endif\n# endif\n# ifndef YYFREE\n# define YYFREE free\n# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nvoid free (void *); /* INFRINGES ON USER NAME SPACE */\n# endif\n# endif\n# endif\n#endif /* ! defined yyoverflow || YYERROR_VERBOSE */\n\n\n#if (! defined yyoverflow \\\n && (! defined __cplusplus \\\n\t || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))\n\n/* A type that is properly aligned for any stack member. */\nunion yyalloc\n{\n yytype_int16 yyss;\n YYSTYPE yyvs;\n };\n\n/* The size of the maximum gap between one aligned stack and the next. */\n# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)\n\n/* The size of an array large to enough to hold all stacks, each with\n N elements. */\n# define YYSTACK_BYTES(N) \\\n ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \\\n + YYSTACK_GAP_MAXIMUM)\n\n/* Copy COUNT objects from FROM to TO. The source and destination do\n not overlap. */\n# ifndef YYCOPY\n# if defined __GNUC__ && 1 < __GNUC__\n# define YYCOPY(To, From, Count) \\\n __builtin_memcpy (To, From, (Count) * sizeof (*(From)))\n# else\n# define YYCOPY(To, From, Count)\t\t\\\n do\t\t\t\t\t\\\n\t{\t\t\t\t\t\\\n\t YYSIZE_T yyi;\t\t\t\t\\\n\t for (yyi = 0; yyi < (Count); yyi++)\t\\\n\t (To)[yyi] = (From)[yyi];\t\t\\\n\t}\t\t\t\t\t\\\n while (YYID (0))\n# endif\n# endif\n\n/* Relocate STACK from its old location to the new one. The\n local variables YYSIZE and YYSTACKSIZE give the old and new number of\n elements in the stack, and YYPTR gives the new location of the\n stack. Advance YYPTR to a properly aligned location for the next\n stack. */\n# define YYSTACK_RELOCATE(Stack)\t\t\t\t\t\\\n do\t\t\t\t\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n\tYYSIZE_T yynewbytes;\t\t\t\t\t\t\\\n\tYYCOPY (&yyptr->Stack, Stack, yysize);\t\t\t\t\\\n\tStack = &yyptr->Stack;\t\t\t\t\t\t\\\n\tyynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \\\n\tyyptr += yynewbytes / sizeof (*yyptr);\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\t\\\n while (YYID (0))\n\n#endif\n\n/* YYFINAL -- State number of the termination state. */\n#define YYFINAL 55\n/* YYLAST -- Last index in YYTABLE. */\n#define YYLAST 3822\n\n/* YYNTOKENS -- Number of terminals. */\n#define YYNTOKENS 127\n/* YYNNTS -- Number of nonterminals. */\n#define YYNNTS 148\n/* YYNRULES -- Number of rules. */\n#define YYNRULES 467\n/* YYNRULES -- Number of states. */\n#define YYNSTATES 903\n\n/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */\n#define YYUNDEFTOK 2\n#define YYMAXUTOK 381\n\n#define YYTRANSLATE(YYX)\t\t\t\t\t\t\\\n ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)\n\n/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */\nstatic const yytype_uint8 yytranslate[] =\n{\n 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,\n 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,\n 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,\n 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,\n 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,\n 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,\n 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,\n 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,\n 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,\n 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,\n 125, 126\n};\n\n#if YYDEBUG\n/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in\n YYRHS. */\nstatic const yytype_uint16 yyprhs[] =\n{\n 0, 0, 3, 5, 9, 12, 16, 19, 25, 29,\n 32, 34, 36, 38, 40, 42, 44, 46, 49, 51,\n 53, 55, 57, 59, 61, 63, 65, 67, 69, 71,\n 73, 75, 77, 79, 81, 83, 85, 87, 89, 91,\n 92, 100, 106, 110, 116, 122, 126, 129, 132, 138,\n 141, 147, 150, 155, 157, 159, 167, 175, 181, 182,\n 190, 192, 194, 197, 200, 202, 208, 214, 220, 224,\n 229, 233, 241, 250, 256, 260, 262, 264, 268, 270,\n 275, 283, 290, 292, 294, 302, 312, 321, 332, 338,\n 346, 353, 362, 364, 366, 372, 377, 383, 391, 393,\n 397, 404, 411, 420, 422, 425, 429, 431, 434, 438,\n 445, 451, 461, 464, 466, 468, 470, 471, 478, 484,\n 486, 491, 493, 495, 498, 504, 511, 516, 524, 533,\n 540, 542, 544, 546, 548, 550, 552, 553, 563, 564,\n 573, 575, 578, 583, 584, 591, 595, 597, 599, 601,\n 603, 605, 607, 609, 612, 614, 616, 618, 622, 624,\n 628, 633, 634, 641, 642, 648, 654, 657, 658, 665,\n 667, 669, 670, 674, 676, 678, 680, 682, 684, 686,\n 688, 690, 694, 696, 698, 700, 702, 704, 706, 708,\n 710, 712, 719, 726, 734, 743, 752, 760, 766, 769,\n 772, 775, 776, 784, 785, 792, 793, 802, 804, 806,\n 808, 810, 812, 814, 816, 818, 820, 822, 824, 826,\n 828, 831, 834, 837, 842, 845, 851, 853, 856, 858,\n 860, 862, 864, 866, 868, 870, 873, 875, 879, 881,\n 884, 891, 895, 897, 900, 902, 906, 908, 910, 912,\n 915, 921, 924, 927, 929, 932, 935, 937, 939, 941,\n 943, 946, 950, 952, 955, 959, 964, 970, 975, 977,\n 980, 984, 989, 995, 999, 1004, 1009, 1011, 1014, 1019,\n 1024, 1030, 1034, 1039, 1044, 1046, 1049, 1052, 1056, 1058,\n 1061, 1063, 1066, 1070, 1075, 1079, 1084, 1087, 1091, 1095,\n 1100, 1104, 1108, 1111, 1114, 1116, 1118, 1121, 1123, 1125,\n 1127, 1129, 1132, 1134, 1137, 1141, 1143, 1145, 1147, 1150,\n 1153, 1155, 1157, 1160, 1162, 1164, 1167, 1169, 1171, 1173,\n 1175, 1177, 1179, 1181, 1183, 1185, 1187, 1189, 1191, 1193,\n 1195, 1196, 1199, 1201, 1203, 1207, 1209, 1211, 1215, 1217,\n 1219, 1221, 1223, 1225, 1227, 1233, 1235, 1237, 1241, 1246,\n 1252, 1258, 1265, 1268, 1271, 1273, 1275, 1277, 1279, 1281,\n 1283, 1285, 1289, 1293, 1297, 1301, 1305, 1309, 1313, 1317,\n 1321, 1325, 1329, 1333, 1337, 1341, 1345, 1349, 1355, 1358,\n 1361, 1364, 1367, 1370, 1372, 1373, 1377, 1379, 1381, 1385,\n 1388, 1393, 1395, 1397, 1399, 1401, 1403, 1405, 1407, 1409,\n 1411, 1413, 1415, 1420, 1426, 1428, 1432, 1436, 1441, 1446,\n 1450, 1453, 1455, 1457, 1461, 1464, 1468, 1470, 1472, 1474,\n 1476, 1478, 1481, 1486, 1488, 1492, 1494, 1498, 1502, 1505,\n 1508, 1511, 1514, 1517, 1522, 1524, 1528, 1530, 1534, 1538,\n 1541, 1544, 1547, 1550, 1552, 1554, 1556, 1558, 1562, 1564,\n 1568, 1574, 1576, 1580, 1584, 1590, 1592, 1594\n};\n\n/* YYRHS -- A `-1'-separated list of the rules' RHS. */\nstatic const yytype_int16 yyrhs[] =\n{\n 128, 0, -1, 129, -1, 107, 215, 40, -1, 107,\n 1, -1, 108, 215, 40, -1, 108, 1, -1, 109,\n 37, 212, 38, 40, -1, 109, 1, 40, -1, 129,\n 130, -1, 274, -1, 131, -1, 168, -1, 176, -1,\n 40, -1, 1, -1, 175, -1, 1, 106, -1, 132,\n -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,\n -1, 141, -1, 142, -1, 145, -1, 146, -1, 147,\n -1, 148, -1, 149, -1, 150, -1, 153, -1, 155,\n -1, 158, -1, 160, -1, 165, -1, 166, -1, 167,\n -1, -1, 61, 271, 264, 43, 133, 193, 44, -1,\n 85, 164, 43, 162, 44, -1, 86, 162, 40, -1,\n 57, 3, 51, 237, 40, -1, 57, 231, 223, 220,\n 40, -1, 57, 1, 40, -1, 84, 4, -1, 84,\n 269, -1, 83, 37, 3, 38, 43, -1, 83, 43,\n -1, 83, 37, 3, 38, 40, -1, 83, 40, -1,\n 269, 43, 215, 44, -1, 269, -1, 139, -1, 88,\n 37, 140, 39, 272, 38, 4, -1, 88, 37, 140,\n 39, 272, 38, 43, -1, 88, 37, 140, 38, 40,\n -1, -1, 144, 271, 269, 54, 143, 129, 55, -1,\n 7, -1, 8, -1, 81, 4, -1, 81, 43, -1,\n 4, -1, 9, 37, 262, 38, 269, -1, 9, 37,\n 262, 38, 4, -1, 9, 37, 262, 38, 43, -1,\n 53, 271, 262, -1, 58, 37, 262, 38, -1, 58,\n 37, 38, -1, 80, 37, 3, 38, 211, 3, 40,\n -1, 80, 37, 3, 38, 211, 231, 223, 40, -1,\n 62, 152, 3, 51, 151, -1, 62, 152, 3, -1,\n 269, -1, 4, -1, 37, 3, 38, -1, 274, -1,\n 154, 223, 262, 40, -1, 154, 37, 272, 38, 223,\n 256, 40, -1, 154, 37, 272, 38, 269, 40, -1,\n 59, -1, 60, -1, 63, 37, 262, 38, 223, 256,\n 156, -1, 63, 37, 262, 39, 273, 38, 223, 256,\n 40, -1, 63, 37, 262, 157, 38, 223, 256, 156,\n -1, 63, 37, 262, 39, 273, 157, 38, 223, 256,\n 40, -1, 63, 37, 262, 38, 156, -1, 63, 37,\n 262, 39, 273, 38, 40, -1, 63, 37, 262, 157,\n 38, 156, -1, 63, 37, 262, 39, 273, 157, 38,\n 40, -1, 270, -1, 40, -1, 100, 37, 212, 38,\n 40, -1, 39, 262, 51, 273, -1, 39, 262, 51,\n 273, 157, -1, 64, 37, 159, 38, 223, 256, 40,\n -1, 212, -1, 11, 39, 215, -1, 82, 37, 161,\n 38, 162, 270, -1, 82, 37, 161, 38, 162, 40,\n -1, 82, 37, 161, 38, 162, 51, 164, 40, -1,\n 272, -1, 164, 163, -1, 39, 164, 163, -1, 274,\n -1, 231, 222, -1, 37, 212, 38, -1, 37, 212,\n 38, 37, 212, 38, -1, 99, 37, 212, 38, 40,\n -1, 87, 37, 263, 38, 267, 90, 216, 91, 40,\n -1, 89, 269, -1, 170, -1, 174, -1, 173, -1,\n -1, 41, 269, 43, 169, 129, 44, -1, 211, 231,\n 223, 172, 171, -1, 40, -1, 39, 223, 172, 171,\n -1, 43, -1, 220, -1, 229, 220, -1, 75, 37,\n 212, 38, 220, -1, 229, 75, 37, 212, 38, 220,\n -1, 211, 65, 3, 40, -1, 211, 65, 239, 43,\n 240, 44, 40, -1, 211, 65, 239, 43, 240, 44,\n 223, 171, -1, 211, 231, 37, 212, 38, 257, -1,\n 177, -1, 181, -1, 182, -1, 189, -1, 190, -1,\n 200, -1, -1, 211, 254, 264, 247, 43, 178, 193,\n 44, 180, -1, -1, 211, 254, 43, 179, 193, 44,\n 223, 171, -1, 40, -1, 223, 171, -1, 211, 254,\n 264, 40, -1, -1, 104, 90, 185, 91, 183, 184,\n -1, 104, 254, 264, -1, 170, -1, 177, -1, 197,\n -1, 182, -1, 181, -1, 199, -1, 186, -1, 187,\n 188, -1, 274, -1, 253, -1, 215, -1, 39, 187,\n 188, -1, 274, -1, 78, 264, 40, -1, 78, 79,\n 264, 40, -1, -1, 79, 264, 43, 191, 129, 44,\n -1, -1, 79, 43, 192, 129, 44, -1, 79, 3,\n 51, 264, 40, -1, 196, 193, -1, -1, 61, 43,\n 194, 193, 44, 193, -1, 142, -1, 274, -1, -1,\n 1, 195, 193, -1, 168, -1, 197, -1, 198, -1,\n 201, -1, 207, -1, 199, -1, 181, -1, 202, -1,\n 211, 264, 40, -1, 189, -1, 182, -1, 200, -1,\n 166, -1, 167, -1, 210, -1, 141, -1, 165, -1,\n 40, -1, 211, 231, 37, 212, 38, 257, -1, 124,\n 266, 37, 212, 38, 208, -1, 73, 124, 266, 37,\n 212, 38, 209, -1, 211, 106, 231, 228, 37, 212,\n 38, 209, -1, 211, 106, 231, 115, 37, 212, 38,\n 209, -1, 211, 106, 231, 37, 212, 38, 209, -1,\n 76, 37, 212, 38, 43, -1, 69, 71, -1, 68,\n 71, -1, 70, 71, -1, -1, 211, 254, 3, 43,\n 203, 206, 40, -1, -1, 211, 254, 43, 204, 206,\n 40, -1, -1, 211, 254, 264, 71, 250, 43, 205,\n 40, -1, 223, -1, 274, -1, 150, -1, 136, -1,\n 148, -1, 153, -1, 155, -1, 158, -1, 146, -1,\n 160, -1, 134, -1, 135, -1, 137, -1, 256, 40,\n -1, 256, 43, -1, 256, 40, -1, 256, 51, 237,\n 40, -1, 256, 43, -1, 211, 231, 71, 243, 40,\n -1, 41, -1, 41, 269, -1, 72, -1, 18, -1,\n 73, -1, 74, -1, 77, -1, 274, -1, 213, -1,\n 215, 214, -1, 274, -1, 39, 215, 214, -1, 274,\n -1, 232, 221, -1, 104, 90, 254, 91, 254, 264,\n -1, 45, 45, 45, -1, 217, -1, 219, 218, -1,\n 274, -1, 39, 219, 218, -1, 274, -1, 215, -1,\n 244, -1, 51, 237, -1, 51, 237, 54, 243, 55,\n -1, 51, 43, -1, 71, 243, -1, 274, -1, 223,\n 220, -1, 226, 220, -1, 220, -1, 223, -1, 226,\n -1, 274, -1, 228, 224, -1, 228, 115, 224, -1,\n 225, -1, 115, 224, -1, 264, 102, 224, -1, 228,\n 264, 102, 224, -1, 228, 264, 102, 115, 224, -1,\n 264, 102, 115, 224, -1, 264, -1, 124, 264, -1,\n 37, 264, 38, -1, 37, 228, 224, 38, -1, 37,\n 264, 102, 224, 38, -1, 224, 54, 55, -1, 224,\n 54, 243, 55, -1, 224, 37, 212, 38, -1, 264,\n -1, 124, 264, -1, 37, 228, 225, 38, -1, 37,\n 115, 225, 38, -1, 37, 264, 102, 225, 38, -1,\n 225, 54, 55, -1, 225, 54, 243, 55, -1, 225,\n 37, 212, 38, -1, 228, -1, 228, 227, -1, 228,\n 115, -1, 228, 115, 227, -1, 227, -1, 115, 227,\n -1, 115, -1, 264, 102, -1, 228, 264, 102, -1,\n 228, 264, 102, 227, -1, 227, 54, 55, -1, 227,\n 54, 243, 55, -1, 54, 55, -1, 54, 243, 55,\n -1, 37, 226, 38, -1, 227, 37, 212, 38, -1,\n 37, 212, 38, -1, 122, 229, 228, -1, 122, 228,\n -1, 122, 229, -1, 122, -1, 230, -1, 230, 229,\n -1, 46, -1, 47, -1, 48, -1, 232, -1, 229,\n 233, -1, 233, -1, 233, 229, -1, 229, 233, 229,\n -1, 234, -1, 29, -1, 27, -1, 31, 261, -1,\n 65, 264, -1, 32, -1, 264, -1, 254, 264, -1,\n 235, -1, 236, -1, 236, 235, -1, 19, -1, 21,\n -1, 22, -1, 25, -1, 26, -1, 23, -1, 24,\n -1, 28, -1, 20, -1, 30, -1, 33, -1, 34,\n -1, 35, -1, 36, -1, -1, 238, 243, -1, 3,\n -1, 274, -1, 240, 39, 241, -1, 241, -1, 3,\n -1, 3, 51, 242, -1, 274, -1, 243, -1, 244,\n -1, 231, -1, 245, -1, 269, -1, 52, 37, 231,\n 221, 38, -1, 246, -1, 10, -1, 37, 243, 38,\n -1, 37, 243, 38, 243, -1, 37, 243, 228, 38,\n 243, -1, 37, 243, 115, 38, 243, -1, 37, 243,\n 228, 115, 38, 243, -1, 115, 243, -1, 122, 243,\n -1, 11, -1, 12, -1, 13, -1, 14, -1, 15,\n -1, 16, -1, 17, -1, 243, 119, 243, -1, 243,\n 118, 243, -1, 243, 122, 243, -1, 243, 121, 243,\n -1, 243, 120, 243, -1, 243, 115, 243, -1, 243,\n 113, 243, -1, 243, 114, 243, -1, 243, 117, 243,\n -1, 243, 116, 243, -1, 243, 112, 243, -1, 243,\n 111, 243, -1, 243, 96, 243, -1, 243, 97, 243,\n -1, 243, 95, 243, -1, 243, 94, 243, -1, 243,\n 98, 243, 71, 243, -1, 118, 243, -1, 119, 243,\n -1, 124, 243, -1, 123, 243, -1, 231, 37, -1,\n 248, -1, -1, 71, 249, 250, -1, 274, -1, 251,\n -1, 250, 39, 251, -1, 255, 264, -1, 255, 252,\n 255, 264, -1, 69, -1, 68, -1, 70, -1, 66,\n -1, 67, -1, 253, -1, 49, -1, 50, -1, 73,\n -1, 274, -1, 229, -1, 75, 37, 212, 38, -1,\n 229, 75, 37, 212, 38, -1, 274, -1, 256, 258,\n 40, -1, 256, 258, 43, -1, 37, 212, 38, 40,\n -1, 37, 212, 38, 43, -1, 51, 237, 40, -1,\n 71, 259, -1, 274, -1, 260, -1, 259, 39, 260,\n -1, 264, 37, -1, 90, 216, 91, -1, 274, -1,\n 3, -1, 269, -1, 262, -1, 274, -1, 266, 265,\n -1, 101, 126, 266, 265, -1, 266, -1, 101, 126,\n 266, -1, 105, -1, 101, 126, 105, -1, 126, 266,\n 265, -1, 126, 266, -1, 126, 105, -1, 103, 266,\n -1, 3, 261, -1, 3, 268, -1, 101, 126, 3,\n 268, -1, 3, -1, 101, 126, 3, -1, 105, -1,\n 101, 126, 105, -1, 126, 3, 268, -1, 126, 3,\n -1, 126, 105, -1, 103, 3, -1, 269, 6, -1,\n 6, -1, 269, -1, 43, -1, 4, -1, 37, 272,\n 38, -1, 274, -1, 262, 51, 273, -1, 262, 51,\n 273, 39, 272, -1, 262, -1, 262, 39, 272, -1,\n 262, 51, 139, -1, 262, 51, 139, 39, 272, -1,\n 269, -1, 245, -1, -1\n};\n\n/* YYRLINE[YYN] -- source line where rule number YYN was defined. */\nstatic const yytype_uint16 yyrline[] =\n{\n 0, 1502, 1502, 1515, 1519, 1522, 1525, 1528, 1531, 1536,\n 1541, 1546, 1547, 1548, 1549, 1550, 1556, 1572, 1582, 1583,\n 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593,\n 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1609,\n 1609, 1681, 1691, 1702, 1723, 1745, 1756, 1765, 1784, 1790,\n 1796, 1801, 1812, 1819, 1823, 1828, 1837, 1852, 1865, 1865,\n 1915, 1916, 1923, 1943, 1974, 1978, 1988, 1993, 2011, 2045,\n 2051, 2064, 2070, 2096, 2102, 2109, 2110, 2113, 2114, 2122,\n 2168, 2214, 2225, 2228, 2255, 2260, 2265, 2270, 2277, 2282,\n 2287, 2292, 2299, 2300, 2301, 2304, 2309, 2319, 2355, 2356,\n 2386, 2420, 2428, 2441, 2466, 2472, 2476, 2479, 2490, 2495,\n 2507, 2517, 2784, 2794, 2801, 2802, 2806, 2806, 2837, 2898,\n 2902, 2924, 2930, 2936, 2942, 2948, 2961, 2976, 2986, 3064,\n 3115, 3116, 3117, 3118, 3119, 3120, 3126, 3126, 3358, 3358,\n 3480, 3481, 3493, 3513, 3513, 3748, 3754, 3757, 3760, 3763,\n 3766, 3769, 3774, 3804, 3808, 3811, 3814, 3819, 3823, 3828,\n 3838, 3869, 3869, 3898, 3898, 3920, 3947, 3962, 3962, 3972,\n 3973, 3974, 3974, 3990, 3991, 4008, 4009, 4010, 4011, 4012,\n 4013, 4014, 4015, 4016, 4017, 4018, 4019, 4020, 4021, 4022,\n 4023, 4032, 4057, 4081, 4121, 4136, 4154, 4173, 4180, 4187,\n 4195, 4218, 4218, 4253, 4253, 4284, 4284, 4302, 4303, 4309,\n 4312, 4316, 4319, 4320, 4321, 4322, 4323, 4324, 4325, 4326,\n 4329, 4334, 4341, 4349, 4357, 4368, 4374, 4375, 4383, 4384,\n 4385, 4386, 4387, 4388, 4395, 4406, 4414, 4417, 4421, 4425,\n 4435, 4440, 4448, 4461, 4469, 4472, 4476, 4480, 4508, 4516,\n 4527, 4541, 4550, 4558, 4568, 4572, 4576, 4583, 4600, 4617,\n 4625, 4633, 4642, 4646, 4655, 4666, 4678, 4688, 4701, 4708,\n 4716, 4732, 4740, 4751, 4762, 4773, 4792, 4800, 4817, 4825,\n 4832, 4843, 4854, 4865, 4884, 4890, 4896, 4903, 4912, 4915,\n 4924, 4931, 4938, 4948, 4959, 4970, 4981, 4988, 4995, 4998,\n 5015, 5025, 5032, 5038, 5043, 5049, 5053, 5059, 5060, 5061,\n 5067, 5073, 5077, 5078, 5082, 5089, 5092, 5093, 5094, 5095,\n 5096, 5098, 5101, 5106, 5131, 5134, 5188, 5192, 5196, 5200,\n 5204, 5208, 5212, 5216, 5220, 5224, 5228, 5232, 5236, 5240,\n 5246, 5246, 5272, 5273, 5276, 5289, 5297, 5305, 5322, 5325,\n 5340, 5341, 5360, 5361, 5365, 5370, 5371, 5385, 5392, 5398,\n 5405, 5412, 5420, 5424, 5430, 5431, 5432, 5433, 5434, 5435,\n 5436, 5439, 5443, 5447, 5451, 5455, 5459, 5463, 5467, 5471,\n 5475, 5479, 5483, 5487, 5491, 5505, 5512, 5516, 5522, 5526,\n 5530, 5534, 5538, 5554, 5559, 5559, 5560, 5563, 5580, 5589,\n 5602, 5615, 5616, 5617, 5621, 5625, 5631, 5634, 5638, 5644,\n 5645, 5648, 5653, 5658, 5663, 5670, 5677, 5684, 5692, 5700,\n 5708, 5709, 5712, 5713, 5716, 5722, 5728, 5731, 5732, 5735,\n 5736, 5739, 5744, 5748, 5751, 5754, 5757, 5762, 5766, 5769,\n 5776, 5782, 5791, 5796, 5800, 5803, 5806, 5809, 5814, 5818,\n 5821, 5824, 5830, 5835, 5838, 5841, 5845, 5850, 5863, 5867,\n 5872, 5878, 5882, 5887, 5891, 5898, 5901, 5906\n};\n#endif\n\n#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE\n/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.\n First, the terminals, then, starting at YYNTOKENS, nonterminals. */\nstatic const char *const yytname[] =\n{\n \"$end\", \"error\", \"$undefined\", \"ID\", \"HBLOCK\", \"POUND\", \"STRING\",\n \"INCLUDE\", \"IMPORT\", \"INSERT\", \"CHARCONST\", \"NUM_INT\", \"NUM_FLOAT\",\n \"NUM_UNSIGNED\", \"NUM_LONG\", \"NUM_ULONG\", \"NUM_LONGLONG\", \"NUM_ULONGLONG\",\n \"TYPEDEF\", \"TYPE_INT\", \"TYPE_UNSIGNED\", \"TYPE_SHORT\", \"TYPE_LONG\",\n \"TYPE_FLOAT\", \"TYPE_DOUBLE\", \"TYPE_CHAR\", \"TYPE_WCHAR\", \"TYPE_VOID\",\n \"TYPE_SIGNED\", \"TYPE_BOOL\", \"TYPE_COMPLEX\", \"TYPE_TYPEDEF\", \"TYPE_RAW\",\n \"TYPE_NON_ISO_INT8\", \"TYPE_NON_ISO_INT16\", \"TYPE_NON_ISO_INT32\",\n \"TYPE_NON_ISO_INT64\", \"LPAREN\", \"RPAREN\", \"COMMA\", \"SEMI\", \"EXTERN\",\n \"INIT\", \"LBRACE\", \"RBRACE\", \"PERIOD\", \"CONST_QUAL\", \"VOLATILE\",\n \"REGISTER\", \"STRUCT\", \"UNION\", \"EQUAL\", \"SIZEOF\", \"MODULE\", \"LBRACKET\",\n \"RBRACKET\", \"ILLEGAL\", \"CONSTANT\", \"NAME\", \"RENAME\", \"NAMEWARN\",\n \"EXTEND\", \"PRAGMA\", \"FEATURE\", \"VARARGS\", \"ENUM\", \"CLASS\", \"TYPENAME\",\n \"PRIVATE\", \"PUBLIC\", \"PROTECTED\", \"COLON\", \"STATIC\", \"VIRTUAL\", \"FRIEND\",\n \"THROW\", \"CATCH\", \"EXPLICIT\", \"USING\", \"NAMESPACE\", \"NATIVE\", \"INLINE\",\n \"TYPEMAP\", \"EXCEPT\", \"ECHO\", \"APPLY\", \"CLEAR\", \"SWIGTEMPLATE\",\n \"FRAGMENT\", \"WARN\", \"LESSTHAN\", \"GREATERTHAN\", \"MODULO\", \"DELETE_KW\",\n \"LESSTHANOREQUALTO\", \"GREATERTHANOREQUALTO\", \"EQUALTO\", \"NOTEQUALTO\",\n \"QUESTIONMARK\", \"TYPES\", \"PARMS\", \"NONID\", \"DSTAR\", \"DCNOT\", \"TEMPLATE\",\n \"OPERATOR\", \"COPERATOR\", \"PARSETYPE\", \"PARSEPARM\", \"PARSEPARMS\", \"CAST\",\n \"LOR\", \"LAND\", \"OR\", \"XOR\", \"AND\", \"RSHIFT\", \"LSHIFT\", \"MINUS\", \"PLUS\",\n \"MODULUS\", \"SLASH\", \"STAR\", \"LNOT\", \"NOT\", \"UMINUS\", \"DCOLON\", \"$accept\",\n \"program\", \"interface\", \"declaration\", \"swig_directive\",\n \"extend_directive\", \"@1\", \"apply_directive\", \"clear_directive\",\n \"constant_directive\", \"echo_directive\", \"except_directive\", \"stringtype\",\n \"fname\", \"fragment_directive\", \"include_directive\", \"@2\", \"includetype\",\n \"inline_directive\", \"insert_directive\", \"module_directive\",\n \"name_directive\", \"native_directive\", \"pragma_directive\", \"pragma_arg\",\n \"pragma_lang\", \"rename_directive\", \"rename_namewarn\",\n \"feature_directive\", \"stringbracesemi\", \"featattr\", \"varargs_directive\",\n \"varargs_parms\", \"typemap_directive\", \"typemap_type\", \"tm_list\",\n \"tm_tail\", \"typemap_parm\", \"types_directive\", \"template_directive\",\n \"warn_directive\", \"c_declaration\", \"@3\", \"c_decl\", \"c_decl_tail\",\n \"initializer\", \"c_enum_forward_decl\", \"c_enum_decl\",\n \"c_constructor_decl\", \"cpp_declaration\", \"cpp_class_decl\", \"@4\", \"@5\",\n \"cpp_opt_declarators\", \"cpp_forward_class_decl\", \"cpp_template_decl\",\n \"@6\", \"cpp_temp_possible\", \"template_parms\", \"templateparameters\",\n \"templateparameter\", \"templateparameterstail\", \"cpp_using_decl\",\n \"cpp_namespace_decl\", \"@7\", \"@8\", \"cpp_members\", \"@9\", \"@10\",\n \"cpp_member\", \"cpp_constructor_decl\", \"cpp_destructor_decl\",\n \"cpp_conversion_operator\", \"cpp_catch_decl\", \"cpp_protection_decl\",\n \"cpp_nested\", \"@11\", \"@12\", \"@13\", \"nested_decl\", \"cpp_swig_directive\",\n \"cpp_end\", \"cpp_vend\", \"anonymous_bitfield\", \"storage_class\", \"parms\",\n \"rawparms\", \"ptail\", \"parm\", \"valparms\", \"rawvalparms\", \"valptail\",\n \"valparm\", \"def_args\", \"parameter_declarator\",\n \"typemap_parameter_declarator\", \"declarator\", \"notso_direct_declarator\",\n \"direct_declarator\", \"abstract_declarator\", \"direct_abstract_declarator\",\n \"pointer\", \"type_qualifier\", \"type_qualifier_raw\", \"type\", \"rawtype\",\n \"type_right\", \"primitive_type\", \"primitive_type_list\", \"type_specifier\",\n \"definetype\", \"@14\", \"ename\", \"enumlist\", \"edecl\", \"etype\", \"expr\",\n \"valexpr\", \"exprnum\", \"exprcompound\", \"inherit\", \"raw_inherit\", \"@15\",\n \"base_list\", \"base_specifier\", \"access_specifier\", \"templcpptype\",\n \"cpptype\", \"opt_virtual\", \"cpp_const\", \"ctor_end\", \"ctor_initializer\",\n \"mem_initializer_list\", \"mem_initializer\", \"template_decl\", \"idstring\",\n \"idstringopt\", \"idcolon\", \"idcolontail\", \"idtemplate\", \"idcolonnt\",\n \"idcolontailnt\", \"string\", \"stringbrace\", \"options\", \"kwargs\",\n \"stringnum\", \"empty\", 0\n};\n#endif\n\n# ifdef YYPRINT\n/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to\n token YYLEX-NUM. */\nstatic const yytype_uint16 yytoknum[] =\n{\n 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,\n 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,\n 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,\n 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,\n 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,\n 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,\n 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,\n 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,\n 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,\n 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,\n 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,\n 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,\n 375, 376, 377, 378, 379, 380, 381\n};\n# endif\n\n/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */\nstatic const yytype_uint16 yyr1[] =\n{\n 0, 127, 128, 128, 128, 128, 128, 128, 128, 129,\n 129, 130, 130, 130, 130, 130, 130, 130, 131, 131,\n 131, 131, 131, 131, 131, 131, 131, 131, 131, 131,\n 131, 131, 131, 131, 131, 131, 131, 131, 131, 133,\n 132, 134, 135, 136, 136, 136, 137, 137, 138, 138,\n 138, 138, 139, 140, 140, 141, 141, 141, 143, 142,\n 144, 144, 145, 145, 146, 146, 146, 146, 147, 148,\n 148, 149, 149, 150, 150, 151, 151, 152, 152, 153,\n 153, 153, 154, 154, 155, 155, 155, 155, 155, 155,\n 155, 155, 156, 156, 156, 157, 157, 158, 159, 159,\n 160, 160, 160, 161, 162, 163, 163, 164, 164, 164,\n 165, 166, 167, 168, 168, 168, 169, 168, 170, 171,\n 171, 171, 172, 172, 172, 172, 173, 174, 174, 175,\n 176, 176, 176, 176, 176, 176, 178, 177, 179, 177,\n 180, 180, 181, 183, 182, 182, 184, 184, 184, 184,\n 184, 184, 185, 186, 186, 187, 187, 188, 188, 189,\n 189, 191, 190, 192, 190, 190, 193, 194, 193, 193,\n 193, 195, 193, 196, 196, 196, 196, 196, 196, 196,\n 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,\n 196, 197, 198, 198, 199, 199, 199, 200, 201, 201,\n 201, 203, 202, 204, 202, 205, 202, 206, 206, 207,\n 207, 207, 207, 207, 207, 207, 207, 207, 207, 207,\n 208, 208, 209, 209, 209, 210, 211, 211, 211, 211,\n 211, 211, 211, 211, 212, 213, 213, 214, 214, 215,\n 215, 215, 216, 217, 217, 218, 218, 219, 219, 220,\n 220, 220, 220, 220, 221, 221, 221, 222, 222, 222,\n 223, 223, 223, 223, 223, 223, 223, 223, 224, 224,\n 224, 224, 224, 224, 224, 224, 225, 225, 225, 225,\n 225, 225, 225, 225, 226, 226, 226, 226, 226, 226,\n 226, 226, 226, 226, 227, 227, 227, 227, 227, 227,\n 227, 228, 228, 228, 228, 229, 229, 230, 230, 230,\n 231, 232, 232, 232, 232, 233, 233, 233, 233, 233,\n 233, 233, 233, 234, 235, 235, 236, 236, 236, 236,\n 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,\n 238, 237, 239, 239, 240, 240, 241, 241, 241, 242,\n 243, 243, 244, 244, 244, 244, 244, 244, 244, 244,\n 244, 244, 244, 244, 245, 245, 245, 245, 245, 245,\n 245, 246, 246, 246, 246, 246, 246, 246, 246, 246,\n 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,\n 246, 246, 246, 247, 249, 248, 248, 250, 250, 251,\n 251, 252, 252, 252, 253, 253, 254, 254, 254, 255,\n 255, 256, 256, 256, 256, 257, 257, 257, 257, 257,\n 258, 258, 259, 259, 260, 261, 261, 262, 262, 263,\n 263, 264, 264, 264, 264, 264, 264, 265, 265, 265,\n 265, 266, 267, 267, 267, 267, 267, 267, 268, 268,\n 268, 268, 269, 269, 270, 270, 270, 271, 271, 272,\n 272, 272, 272, 272, 272, 273, 273, 274\n};\n\n/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */\nstatic const yytype_uint8 yyr2[] =\n{\n 0, 2, 1, 3, 2, 3, 2, 5, 3, 2,\n 1, 1, 1, 1, 1, 1, 1, 2, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n 7, 5, 3, 5, 5, 3, 2, 2, 5, 2,\n 5, 2, 4, 1, 1, 7, 7, 5, 0, 7,\n 1, 1, 2, 2, 1, 5, 5, 5, 3, 4,\n 3, 7, 8, 5, 3, 1, 1, 3, 1, 4,\n 7, 6, 1, 1, 7, 9, 8, 10, 5, 7,\n 6, 8, 1, 1, 5, 4, 5, 7, 1, 3,\n 6, 6, 8, 1, 2, 3, 1, 2, 3, 6,\n 5, 9, 2, 1, 1, 1, 0, 6, 5, 1,\n 4, 1, 1, 2, 5, 6, 4, 7, 8, 6,\n 1, 1, 1, 1, 1, 1, 0, 9, 0, 8,\n 1, 2, 4, 0, 6, 3, 1, 1, 1, 1,\n 1, 1, 1, 2, 1, 1, 1, 3, 1, 3,\n 4, 0, 6, 0, 5, 5, 2, 0, 6, 1,\n 1, 0, 3, 1, 1, 1, 1, 1, 1, 1,\n 1, 3, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 6, 6, 7, 8, 8, 7, 5, 2, 2,\n 2, 0, 7, 0, 6, 0, 8, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 2, 2, 2, 4, 2, 5, 1, 2, 1, 1,\n 1, 1, 1, 1, 1, 2, 1, 3, 1, 2,\n 6, 3, 1, 2, 1, 3, 1, 1, 1, 2,\n 5, 2, 2, 1, 2, 2, 1, 1, 1, 1,\n 2, 3, 1, 2, 3, 4, 5, 4, 1, 2,\n 3, 4, 5, 3, 4, 4, 1, 2, 4, 4,\n 5, 3, 4, 4, 1, 2, 2, 3, 1, 2,\n 1, 2, 3, 4, 3, 4, 2, 3, 3, 4,\n 3, 3, 2, 2, 1, 1, 2, 1, 1, 1,\n 1, 2, 1, 2, 3, 1, 1, 1, 2, 2,\n 1, 1, 2, 1, 1, 2, 1, 1, 1, 1,\n 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 0, 2, 1, 1, 3, 1, 1, 3, 1, 1,\n 1, 1, 1, 1, 5, 1, 1, 3, 4, 5,\n 5, 6, 2, 2, 1, 1, 1, 1, 1, 1,\n 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,\n 3, 3, 3, 3, 3, 3, 3, 5, 2, 2,\n 2, 2, 2, 1, 0, 3, 1, 1, 3, 2,\n 4, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n 1, 1, 4, 5, 1, 3, 3, 4, 4, 3,\n 2, 1, 1, 3, 2, 3, 1, 1, 1, 1,\n 1, 2, 4, 1, 3, 1, 3, 3, 2, 2,\n 2, 2, 2, 4, 1, 3, 1, 3, 3, 2,\n 2, 2, 2, 1, 1, 1, 1, 3, 1, 3,\n 5, 1, 3, 3, 5, 1, 1, 0\n};\n\n/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state\n STATE-NUM when YYTABLE doesn't specify something else to do. Zero\n means the default is an error. */\nstatic const yytype_uint16 yydefact[] =\n{\n 467, 0, 0, 0, 0, 0, 10, 4, 467, 326,\n 334, 327, 328, 331, 332, 329, 330, 317, 333, 316,\n 335, 467, 320, 336, 337, 338, 339, 0, 307, 308,\n 309, 407, 408, 0, 404, 405, 0, 0, 435, 0,\n 0, 305, 467, 312, 315, 323, 324, 406, 0, 321,\n 433, 6, 0, 0, 467, 1, 15, 64, 60, 61,\n 0, 229, 14, 226, 467, 0, 0, 82, 83, 467,\n 467, 0, 0, 228, 230, 231, 0, 232, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 9, 11, 18, 19, 20, 21, 22, 23,\n 24, 25, 467, 26, 27, 28, 29, 30, 31, 32,\n 0, 33, 34, 35, 36, 37, 38, 12, 113, 115,\n 114, 16, 13, 130, 131, 132, 133, 134, 135, 0,\n 233, 467, 441, 426, 318, 0, 319, 0, 0, 3,\n 311, 306, 467, 340, 0, 0, 290, 304, 0, 256,\n 239, 467, 262, 467, 288, 284, 276, 253, 313, 325,\n 322, 0, 0, 431, 5, 8, 0, 234, 467, 236,\n 17, 0, 453, 227, 0, 0, 458, 0, 467, 0,\n 310, 0, 0, 0, 0, 78, 0, 467, 467, 0,\n 0, 467, 163, 0, 0, 62, 63, 0, 0, 51,\n 49, 46, 47, 467, 0, 467, 0, 467, 467, 0,\n 112, 467, 467, 0, 0, 0, 0, 0, 0, 276,\n 467, 0, 0, 356, 364, 365, 366, 367, 368, 369,\n 370, 0, 0, 0, 0, 0, 0, 0, 0, 247,\n 0, 242, 467, 351, 310, 0, 350, 352, 355, 353,\n 244, 241, 436, 434, 0, 314, 467, 290, 0, 0,\n 284, 321, 251, 249, 0, 296, 0, 350, 252, 467,\n 0, 263, 289, 268, 302, 303, 277, 254, 467, 0,\n 255, 467, 0, 286, 260, 285, 268, 291, 440, 439,\n 438, 0, 0, 235, 238, 427, 0, 428, 452, 116,\n 461, 0, 68, 45, 340, 0, 467, 70, 0, 0,\n 0, 74, 0, 0, 0, 98, 0, 0, 159, 0,\n 467, 161, 0, 0, 103, 0, 0, 0, 107, 257,\n 258, 259, 42, 0, 104, 106, 429, 0, 430, 54,\n 0, 53, 0, 0, 152, 467, 156, 406, 154, 145,\n 0, 427, 0, 0, 0, 0, 0, 0, 0, 268,\n 0, 467, 0, 343, 467, 467, 138, 322, 0, 0,\n 362, 388, 389, 363, 391, 390, 425, 0, 243, 246,\n 392, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 432, 0,\n 290, 284, 321, 0, 276, 300, 298, 286, 0, 276,\n 291, 0, 341, 297, 284, 321, 269, 467, 0, 301,\n 0, 281, 0, 0, 294, 0, 261, 287, 292, 0,\n 264, 437, 7, 467, 0, 467, 0, 0, 457, 0,\n 0, 69, 39, 77, 0, 0, 0, 0, 0, 0,\n 0, 160, 0, 0, 467, 467, 0, 0, 108, 0,\n 467, 0, 0, 0, 0, 0, 143, 0, 153, 158,\n 58, 0, 0, 0, 0, 79, 0, 126, 467, 0,\n 321, 0, 0, 122, 467, 0, 142, 394, 0, 393,\n 396, 357, 0, 304, 0, 467, 467, 386, 385, 383,\n 384, 0, 382, 381, 377, 378, 376, 380, 379, 372,\n 371, 375, 374, 373, 0, 0, 291, 279, 278, 292,\n 0, 0, 0, 268, 270, 291, 0, 273, 0, 283,\n 282, 299, 295, 0, 265, 293, 267, 237, 66, 67,\n 65, 0, 462, 463, 466, 465, 459, 43, 44, 0,\n 76, 73, 75, 456, 93, 455, 0, 88, 467, 454,\n 92, 0, 465, 0, 0, 99, 467, 197, 165, 164,\n 0, 226, 0, 0, 50, 48, 467, 41, 105, 444,\n 0, 446, 0, 57, 0, 0, 110, 467, 467, 467,\n 467, 0, 0, 346, 0, 345, 348, 467, 467, 0,\n 119, 121, 118, 0, 123, 171, 190, 0, 0, 0,\n 0, 230, 0, 217, 218, 210, 219, 188, 169, 215,\n 211, 209, 212, 213, 214, 216, 189, 185, 186, 173,\n 179, 183, 182, 0, 0, 174, 175, 178, 184, 176,\n 180, 177, 187, 0, 233, 467, 136, 358, 0, 304,\n 303, 0, 0, 0, 245, 0, 240, 280, 250, 271,\n 0, 275, 274, 266, 117, 0, 0, 0, 467, 0,\n 411, 0, 414, 0, 0, 0, 0, 90, 467, 0,\n 162, 227, 467, 0, 101, 0, 100, 0, 0, 0,\n 442, 0, 467, 0, 52, 146, 147, 150, 149, 144,\n 148, 151, 0, 157, 0, 0, 81, 0, 467, 0,\n 467, 340, 467, 129, 0, 467, 467, 0, 167, 199,\n 198, 200, 0, 0, 0, 166, 0, 0, 0, 321,\n 409, 395, 397, 0, 410, 0, 360, 359, 0, 354,\n 387, 272, 464, 460, 40, 0, 467, 0, 84, 465,\n 95, 89, 467, 0, 0, 97, 71, 0, 0, 109,\n 451, 449, 450, 445, 447, 0, 55, 56, 0, 59,\n 80, 347, 349, 344, 127, 0, 0, 0, 0, 0,\n 421, 467, 0, 0, 172, 0, 0, 467, 0, 0,\n 467, 0, 467, 203, 322, 181, 467, 402, 401, 403,\n 467, 399, 0, 361, 0, 0, 467, 96, 0, 91,\n 467, 86, 72, 102, 448, 443, 0, 128, 0, 419,\n 420, 422, 0, 415, 416, 124, 120, 467, 0, 467,\n 0, 139, 467, 0, 0, 0, 0, 201, 467, 467,\n 398, 0, 0, 94, 412, 0, 85, 0, 111, 417,\n 418, 0, 424, 125, 0, 0, 467, 0, 467, 467,\n 467, 225, 467, 0, 207, 208, 0, 400, 140, 137,\n 0, 413, 87, 423, 168, 467, 192, 0, 467, 0,\n 0, 191, 0, 204, 205, 141, 193, 0, 220, 221,\n 196, 467, 467, 202, 0, 222, 224, 340, 195, 194,\n 206, 0, 223\n};\n\n/* YYDEFGOTO[NTERM-NUM]. */\nstatic const yytype_int16 yydefgoto[] =\n{\n -1, 4, 5, 92, 93, 94, 549, 613, 614, 615,\n 616, 99, 339, 340, 617, 618, 589, 102, 103, 619,\n 105, 620, 107, 621, 551, 184, 622, 110, 623, 557,\n 447, 624, 314, 625, 323, 206, 334, 207, 626, 627,\n 628, 629, 435, 118, 602, 482, 119, 120, 121, 122,\n 123, 735, 485, 869, 630, 631, 587, 699, 343, 344,\n 345, 468, 632, 127, 454, 320, 633, 785, 717, 634,\n 635, 636, 637, 638, 639, 640, 862, 838, 894, 863,\n 641, 876, 886, 642, 643, 258, 167, 293, 168, 240,\n 241, 378, 242, 149, 150, 328, 151, 271, 152, 153,\n 154, 218, 40, 41, 243, 180, 43, 44, 45, 46,\n 263, 264, 362, 594, 595, 771, 245, 267, 247, 248,\n 488, 489, 645, 731, 732, 800, 47, 48, 733, 887,\n 713, 779, 820, 821, 132, 300, 337, 49, 163, 50,\n 582, 690, 249, 560, 175, 301, 546, 169\n};\n\n/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing\n STATE-NUM. */\n#define YYPACT_NINF -713\nstatic const yytype_int16 yypact[] =\n{\n 621, 3162, 3212, 209, 89, 2717, -713, -713, -54, -713,\n -713, -713, -713, -713, -713, -713, -713, -713, -713, -713,\n -713, -54, -713, -713, -713, -713, -713, 87, -713, -713,\n -713, -713, -713, 85, -713, -713, 7, 80, -713, 117,\n 3717, 353, 302, 353, -713, -713, 1331, -713, 85, -713,\n 127, -713, 171, 189, 3470, -713, 156, -713, -713, -713,\n 204, -713, -713, 259, 237, 3272, 250, -713, -713, 237,\n 263, 297, 312, -713, -713, -713, 323, -713, 36, 338,\n 332, 184, 348, 340, 465, 3519, 3519, 356, 371, 259,\n 376, 613, -713, -713, -713, -713, -713, -713, -713, -713,\n -713, -713, 237, -713, -713, -713, -713, -713, -713, -713,\n 987, -713, -713, -713, -713, -713, -713, -713, -713, -713,\n -713, -713, -713, -713, -713, -713, -713, -713, -713, 3569,\n -713, 1649, -713, -713, -713, 334, -713, 38, 656, -713,\n 353, -713, 1282, 378, 1771, 2381, 135, 244, 85, -713,\n -713, 192, 200, 192, 292, 281, 339, -713, -713, -713,\n -713, 446, 49, -713, -713, -713, 435, -713, 447, -713,\n -713, 178, -713, 105, 178, 178, -713, 464, 219, 1031,\n -713, 222, 85, 525, 537, -713, 178, 3420, 3470, 85,\n 470, 221, -713, 511, 547, -713, -713, 178, 554, -713,\n -713, -713, 558, 3470, 530, 305, 534, 539, 178, 259,\n 558, 3470, 3470, 85, 259, 412, 97, 178, 333, 481,\n 177, 1032, 341, -713, -713, -713, -713, -713, -713, -713,\n -713, 2381, 565, 2381, 2381, 2381, 2381, 2381, 2381, -713,\n 519, -713, 574, 583, 180, 1747, -1, -713, -713, 558,\n -713, -713, -713, 127, 535, -713, 1409, 273, 597, 600,\n 639, 552, -713, 585, 2381, -713, 1856, -713, 1747, 1409,\n 85, 301, 292, -713, -713, 527, -713, -713, 3470, 1893,\n -713, 3470, 2015, 135, 301, 292, 553, 822, -713, -713,\n 127, 601, 3470, -713, -713, -713, 623, 558, -713, -713,\n 134, 626, -713, -713, -713, 41, 192, -713, 630, 627,\n 637, 638, 483, 633, 653, -713, 661, 654, -713, 85,\n -713, -713, 669, 672, -713, 673, 681, 3519, -713, -713,\n -713, -713, -713, 3519, -713, -713, -713, 682, -713, -713,\n 509, 123, 688, 640, -713, 699, -713, 84, -713, -713,\n 31, 342, 198, 198, 641, 713, 94, 720, 97, 651,\n 822, 104, 721, -713, 2553, 1129, -713, 64, 1608, 3618,\n 1421, -713, -713, -713, -713, -713, -713, 1649, -713, -713,\n -713, 2381, 2381, 2381, 2381, 2381, 2381, 2381, 2381, 2381,\n 2381, 2381, 2381, 2381, 2381, 2381, 2381, 2381, -713, 656,\n 303, 91, 666, 357, -713, -713, -713, 303, 393, 676,\n 198, 2381, 1747, -713, 766, -9, -713, 3470, 2137, -713,\n 745, -713, 1978, 746, -713, 2100, 301, 292, 1091, 97,\n 301, -713, -713, 447, 218, -713, 178, 1867, -713, 749,\n 753, -713, -713, -713, 529, 916, 1728, 757, 3470, 1031,\n 758, -713, 762, 2806, -713, 611, 3519, 385, 771, 765,\n 539, 223, 772, 178, 3470, 773, -713, 3470, -713, -713,\n -713, 198, 365, 97, 23, -713, 1000, -713, 811, 777,\n 641, 781, 634, -713, 279, 1543, -713, -713, 778, -713,\n -713, 2381, 2259, 2503, -6, 302, 574, 1104, 1104, 1154,\n 1154, 2585, 1373, 1989, 1641, 2111, 1421, 628, 628, 685,\n 685, -713, -713, -713, 85, 676, -713, -713, -713, 303,\n 438, 2222, 488, 676, -713, 97, 786, -713, 2344, -713,\n -713, -713, -713, 97, 301, 292, 301, -713, -713, -713,\n 558, 2895, -713, 789, -713, 123, 790, -713, -713, 1543,\n -713, -713, 558, -713, -713, -713, 793, -713, 344, 558,\n -713, 780, 59, 521, 916, -713, 344, -713, -713, -713,\n 2984, 259, 3668, 647, -713, -713, 3470, -713, -713, 195,\n 707, -713, 744, -713, 799, 801, -713, 937, 699, -713,\n 344, 16, 97, 792, 319, -713, -713, 649, 3470, 1031,\n -713, -713, -713, 810, -713, -713, -713, 805, 782, 784,\n 794, 728, 446, -713, -713, -713, -713, -713, -713, -713,\n -713, -713, -713, -713, -713, -713, -713, -713, -713, -713,\n -713, -713, -713, 817, 1543, -713, -713, -713, -713, -713,\n -713, -713, -713, 3321, 820, 795, -713, 1747, 2381, 2503,\n 2611, 2381, 828, 832, -713, 2381, -713, -713, -713, -713,\n 507, -713, -713, 301, -713, 178, 178, 835, 3470, 845,\n 797, 74, -713, 1867, 847, 178, 851, -713, 344, 846,\n -713, 558, 124, 1031, -713, 3519, -713, 855, 882, 88,\n -713, 95, 1649, 269, -713, -713, -713, -713, -713, -713,\n -713, -713, 3371, -713, 3073, 856, -713, 2381, 811, 860,\n 3470, -713, 824, -713, 880, 1129, 3470, 1543, -713, -713,\n -713, -713, 446, 884, 1031, -713, 3618, 903, 413, 885,\n -713, 887, -713, 718, -713, 1543, 1747, 1747, 2381, -713,\n 1868, -713, -713, -713, -713, 890, 3470, 893, -713, 558,\n 892, -713, 344, 965, 74, -713, -713, 894, 899, -713,\n -713, 195, -713, 195, -713, 841, -713, -713, 1145, -713,\n -713, -713, 1747, -713, -713, 634, 895, 917, 85, 397,\n -713, 192, 634, 905, -713, 1543, 921, 3470, 634, 37,\n 2553, 2381, 128, -713, 254, -713, 795, -713, -713, -713,\n 795, -713, 922, 1747, 920, 929, 3470, -713, 930, -713,\n 344, -713, -713, -713, -713, -713, 932, -713, 457, -713,\n 934, -713, 939, -713, -713, -713, -713, 192, 935, 3470,\n 942, -713, 3470, 946, 948, 949, 1735, -713, 1031, 795,\n -713, 85, 992, -713, -713, 951, -713, 954, -713, -713,\n -713, 85, -713, -713, 1543, 958, 344, 959, 3470, 3470,\n 649, -713, 1031, 960, -713, -713, 276, -713, -713, -713,\n 634, -713, -713, -713, -713, 344, -713, 512, 344, 963,\n 968, -713, 972, -713, -713, -713, -713, 421, -713, -713,\n -713, 344, 344, -713, 975, -713, -713, -713, -713, -713,\n -713, 979, -713\n};\n\n/* YYPGOTO[NTERM-NUM]. */\nstatic const yytype_int16 yypgoto[] =\n{\n -713, -713, -314, -713, -713, -713, -713, 10, 12, 21,\n 28, -713, 549, -713, 30, 35, -713, -713, -713, 52,\n -713, 53, -713, 54, -713, -713, 55, -713, 58, -545,\n -535, 62, -713, 63, -713, -296, 538, -84, 66, 67,\n 70, 76, -713, 436, -709, 311, -713, -713, -713, -713,\n 441, -713, -713, -713, -2, 5, -713, -713, -713, -713,\n 569, 451, 78, -713, -713, -713, -538, -713, -713, -713,\n 455, -713, 456, 90, -713, -713, -713, -713, -713, 182,\n -713, -713, -401, -713, -3, 201, -713, 612, 202, 359,\n -713, 557, 671, -48, 560, -713, -97, 662, -233, -87,\n -121, 8, -34, -713, 203, 45, -36, -713, 1003, -713,\n -288, -713, -713, -713, 349, -713, 848, -111, -423, -713,\n -713, -713, -713, 217, 265, -713, -200, -37, 262, -513,\n 205, -713, -713, 212, 1043, -59, -713, 694, -123, -75,\n -713, -712, 727, 494, -26, -167, -428, 0\n};\n\n/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If\n positive, shift that token. If negative, reduce the rule which\n number is the opposite. If zero, do what YYDEFACT says.\n If YYTABLE_NINF, syntax error. */\n#define YYTABLE_NINF -468\nstatic const yytype_int16 yytable[] =\n{\n 6, 204, 129, 124, 140, 130, 453, 141, 133, 158,\n 125, 667, 347, 217, 544, 95, 439, 96, 563, 677,\n 246, 133, 298, 544, 403, 272, 97, 408, 676, 524,\n 324, 459, 651, 98, 285, 100, 131, 298, -248, 8,\n 101, 8, 157, 182, 8, 671, 42, 42, 355, 814,\n 155, 815, 8, 679, 213, 259, 706, 104, 106, 108,\n 109, 524, 253, 111, 176, 298, 817, 112, 113, 176,\n 185, 114, 115, 826, 832, 116, 214, 705, 553, 831,\n 172, 117, 306, 126, 712, 470, 288, 290, 8, 55,\n -248, 761, 222, 525, 8, 128, 725, 8, 763, 42,\n 8, 254, 176, 277, 486, 280, 255, -467, 329, 652,\n -428, 298, 296, 275, 554, 189, 302, 555, 330, 403,\n 408, 541, 308, -155, 365, 592, 748, 312, 256, 298,\n 398, 250, 135, 137, 356, 487, 272, 36, 8, 285,\n 570, 38, 36, 252, 477, 144, 38, -342, 299, 336,\n 260, 157, 833, 157, 289, 274, 352, 139, 357, 147,\n 573, 885, 427, 147, 756, 754, 464, 431, 294, 259,\n 138, 837, 269, 436, 556, -155, 244, 520, 133, 784,\n 361, 295, 259, 8, 172, 437, 36, 42, 195, 144,\n 38, 133, 36, 762, 131, 36, 38, 802, 36, 38,\n 764, 8, 38, 39, 52, 331, 407, 335, 338, 811,\n 53, 164, 348, 155, 131, 807, 147, 142, 131, -467,\n 363, 270, 538, 353, 172, 295, 579, 196, 172, 165,\n 161, 143, 42, 42, 144, 305, 36, 278, 520, 808,\n 38, 171, 379, 143, 157, 750, 54, 828, 42, 460,\n 544, 145, 155, 162, 279, 166, 42, 42, 440, 270,\n 307, 539, 170, 145, 401, 172, 246, 347, 179, 542,\n 304, -467, 319, 766, 174, 704, 8, 414, 36, 272,\n 285, 36, 38, 419, 8, 38, 427, 181, 205, 205,\n 28, 29, 30, 285, 486, 146, 584, 847, 688, 36,\n 183, 42, 147, 38, 148, 8, 157, 535, 8, 131,\n 142, 131, 767, 353, 42, 796, 874, 483, 269, 884,\n 6, 689, 148, 42, 580, 839, 42, 144, 581, 281,\n 143, 484, 221, 239, 186, 144, 8, 42, 417, 142,\n 256, 191, 142, 877, 8, 469, 282, 712, 558, 187,\n 145, 133, 566, 143, 603, 418, 144, 144, 708, 144,\n 188, 133, 514, 709, 473, 157, 147, 490, 8, 194,\n 356, 172, 353, 145, 36, 590, 494, 198, 38, 251,\n 199, 192, 36, 200, 366, 197, 38, 561, 315, 316,\n 28, 29, 30, 208, 278, 517, 283, 148, 535, 28,\n 29, 30, 305, 36, 326, 270, 36, 38, 209, 42,\n 38, 279, 342, 211, 346, 351, 792, 146, 172, 669,\n 146, 262, 244, 777, 147, 574, 148, 147, 575, 148,\n 278, 518, 131, 294, 36, 6, 604, 823, 38, 36,\n 824, 287, 36, 38, -467, -467, 38, 279, 358, 8,\n 129, 124, 572, 130, 6, 130, 793, 270, 125, 650,\n 335, 895, 42, 95, 896, 96, 36, 678, -467, 201,\n 38, 172, 897, 291, 97, 278, 657, 890, 596, 420,\n 216, 98, 423, 100, 157, 644, 292, 147, 101, 148,\n 898, 899, 279, 42, 433, 157, 379, 849, 742, 743,\n 850, 274, 715, 155, 303, 104, 106, 108, 109, 42,\n 318, 111, 42, 36, 36, 112, 113, 38, 38, 114,\n 115, 445, 446, 116, 670, 417, 659, 352, 310, 117,\n 205, 126, 670, 550, 147, 172, 205, 723, 129, 124,\n 311, 130, 418, 128, 417, 741, 125, 462, 463, 644,\n 322, 95, 888, 96, 321, 889, 670, 325, 672, 674,\n 675, 418, 97, 670, 298, 479, 672, 129, 124, 98,\n 130, 100, 495, 327, 332, 125, 101, 752, 333, 239,\n 95, 246, 96, 360, 702, 697, 757, 130, 469, 6,\n 672, 97, 698, 104, 106, 108, 109, 672, 98, 111,\n 100, 758, 369, 112, 113, 101, 728, 114, 115, 901,\n 376, 116, 775, 377, 140, 650, 561, 117, 526, 126,\n 380, 42, 104, 106, 108, 109, 399, 788, 111, 61,\n 365, 128, 112, 113, 644, 405, 114, 115, 406, 411,\n 116, 432, 8, 42, 670, 734, 117, 786, 126, 147,\n 565, 553, 571, 172, 410, 428, 810, 274, 419, 205,\n 128, 434, 31, 32, 438, 222, 585, 483, 441, 346,\n 442, 365, 448, 599, 600, 443, 142, 601, 672, 34,\n 35, 484, 133, 73, 74, 75, 710, 684, 77, 444,\n 555, 449, 250, 144, 451, 28, 29, 30, 685, 450,\n 711, 129, 124, 212, 130, 31, 32, 455, 596, 125,\n 456, 457, 780, 42, 95, 157, 96, 644, 670, 458,\n 461, 8, 34, 35, 669, 97, 465, 136, 1, 2,\n 3, 466, 98, 825, 100, 644, 156, 244, 467, 101,\n 36, 864, 160, 471, 38, 870, 393, 394, 395, 396,\n 397, 472, 672, 476, 407, 42, 104, 106, 108, 109,\n 475, 42, 111, 148, 478, 864, 112, 113, 516, 8,\n 114, 115, 190, 193, 116, 683, 670, 687, 519, 853,\n 117, 157, 126, 529, 531, 644, 797, 798, 799, 547,\n 173, 42, 133, 548, 128, 564, 734, 834, 353, 714,\n 734, 567, 568, 269, 219, 395, 396, 397, 576, 577,\n 672, 202, 583, 586, 593, 597, 210, 284, 598, 36,\n 144, 646, 670, 38, 661, 8, 670, 157, 665, 666,\n 668, 673, 42, 691, 692, 42, 261, 693, 865, 734,\n 273, 670, 276, 707, 670, 694, 727, 716, 718, 286,\n 8, 42, 722, 719, 644, 720, 672, 670, 670, 356,\n 672, 724, 865, 8, -170, 721, 738, 36, 730, 745,\n 739, 38, 747, 219, 42, 672, 309, 42, 672, 744,\n 284, 407, 746, 317, 305, 760, 755, 751, 205, 753,\n 270, 672, 672, 759, 239, 778, 770, 305, 297, 156,\n 774, 297, 297, 42, 42, 768, 8, 349, 297, 354,\n 273, 776, 359, 297, 136, 219, 367, 783, 781, 8,\n 553, 787, 172, 36, 297, 795, 796, 38, 804, 789,\n 806, 675, 816, 818, 812, 297, 341, 429, 156, 813,\n 790, 350, 297, 827, 297, 426, 270, 805, 36, 430,\n 402, 404, 38, 305, 409, 61, 554, 819, 829, 555,\n 843, 36, 216, 415, 416, 38, 842, 844, 8, 147,\n 846, 148, 848, 851, 791, 216, 852, 273, 571, 854,\n 856, 273, 147, 858, 148, 859, 543, 860, 830, 871,\n 8, 835, 266, 268, 872, 8, 875, 878, 578, 354,\n 883, 891, 305, 8, 36, 809, 892, 845, 38, 73,\n 74, 75, 893, 452, 77, 900, 556, 36, 216, 902,\n 426, 38, 430, 695, 215, 147, 782, 148, 696, 305,\n 855, 216, 868, 857, 8, 8, 588, 356, 147, 703,\n 148, 91, 700, 701, 882, 537, 404, 404, 496, 159,\n 474, 765, 273, 654, 273, 653, 866, 773, 480, 879,\n 880, 840, 841, 873, 134, 881, 36, 686, 305, 364,\n 38, 0, 0, 0, 0, 0, 522, 0, 0, 368,\n 216, 370, 371, 372, 373, 374, 375, 147, 36, 148,\n 534, 536, 38, 36, 8, 515, 0, 38, 0, 0,\n 0, 36, 216, 0, 404, 38, 0, 216, 523, 147,\n 0, 148, 412, 0, 147, 533, 148, 0, 0, 0,\n 0, 0, 273, 273, 270, 0, 0, 422, 269, 0,\n 425, 0, 36, 36, 0, 522, 38, 38, 534, 219,\n 0, 0, 0, 219, 0, 144, 216, 216, 8, 0,\n 0, 0, 0, 147, 147, 148, 148, 0, 0, 0,\n 0, 540, 0, 297, 545, 404, 219, 273, 0, 0,\n 273, 552, 559, 562, 0, 28, 29, 30, 0, 0,\n 143, 0, 790, 0, 0, 0, 0, 660, 0, 156,\n 297, 0, 36, 0, 0, 663, 38, 0, 0, 591,\n 145, 0, 0, 0, 481, 0, 533, 0, 656, 0,\n 0, 0, 0, 0, 0, 270, 0, 0, 0, 273,\n 391, 392, 393, 394, 395, 396, 397, 273, 0, 497,\n 498, 499, 500, 501, 502, 503, 504, 505, 506, 507,\n 508, 509, 510, 511, 512, 513, 36, 0, 381, 382,\n 38, 0, 0, 0, 660, 0, 0, 0, 219, 521,\n 216, 0, 0, 0, 0, 0, 528, 147, 0, 148,\n 391, 392, 393, 394, 395, 396, 397, 0, 0, 0,\n 0, 0, 0, 0, 0, 8, 273, 0, 0, 0,\n 0, 559, 0, 219, 0, 0, 0, 0, 681, 0,\n 559, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n 18, 19, 20, 21, 22, 23, 24, 25, 26, 256,\n 0, 0, 0, 0, 0, 0, 0, 27, 28, 29,\n 30, 31, 32, 0, 0, 0, 144, 729, 0, 647,\n 506, 513, 0, 0, 0, 0, 0, 33, 34, 35,\n 9, 10, 11, 12, 13, 14, 15, 16, 0, 18,\n 0, 20, 0, 0, 23, 24, 25, 26, 219, 0,\n 0, 0, 0, 0, 0, 0, 0, 219, 0, 0,\n 0, 0, 0, 36, 0, 0, 37, 38, 0, 0,\n 0, 0, 297, 297, 0, 0, 0, 257, 559, 0,\n 749, 0, 297, 219, 147, 0, 0, 0, 0, 0,\n 0, 0, 8, 0, 0, 0, 0, 0, 219, 0,\n 0, 219, 794, 0, 0, 0, 0, 801, 9, 10,\n 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 26, 256, 219, 0, 0,\n 0, 0, 0, 0, 27, 28, 29, 30, 31, 32,\n 0, 0, 219, 144, 0, 0, 0, 381, 382, 383,\n 384, 0, 822, 0, 33, 34, 35, 0, 0, 0,\n 0, 559, 0, 0, 480, 387, 388, 389, 390, 391,\n 392, 393, 394, 395, 396, 397, 736, 373, 0, 737,\n 0, 0, 0, 740, 0, 0, 0, 0, 0, 0,\n 36, 0, 0, 37, 38, 381, 382, 383, 384, 0,\n 0, 0, 0, 0, 400, 0, 0, 0, 0, 0,\n 0, 147, 219, 0, 0, 867, 219, 391, 392, 393,\n 394, 395, 396, 397, 605, 822, -467, 57, 0, 0,\n 58, 59, 60, 0, 0, 772, 219, 0, 0, 0,\n 0, 61, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n 0, 0, 0, 606, 63, 0, 803, -467, 0, -467,\n -467, -467, -467, -467, 0, 0, 0, 0, 0, 0,\n 65, 66, 67, 68, 607, 70, 71, 72, -467, -467,\n -467, 608, 609, 610, 0, 73, 611, 75, 0, 76,\n 77, 78, 0, 0, 0, 82, 0, 84, 85, 86,\n 87, 88, 89, 0, 0, 0, 0, 0, 0, 836,\n 0, 0, 90, 0, -467, 0, 491, 91, -467, -467,\n 0, 0, 8, 0, 0, 172, 0, 0, 0, 223,\n 224, 225, 226, 227, 228, 229, 230, 612, 9, 10,\n 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 26, 231, 0, 0, 0,\n 0, 0, 0, 0, 27, 28, 29, 30, 31, 32,\n 0, 232, 381, 382, 383, 384, 385, 0, 0, 0,\n 0, 0, 0, 0, 33, 34, 35, 0, 0, 386,\n 387, 388, 389, 492, 391, 392, 393, 394, 395, 396,\n 493, 295, 0, 0, 172, 381, 382, 383, 384, 224,\n 225, 226, 227, 228, 229, 230, 0, 0, 0, 0,\n 36, 0, 0, 37, 38, 389, 390, 391, 392, 393,\n 394, 395, 396, 397, 233, 0, 0, 234, 235, 0,\n 0, 236, 237, 238, 8, 861, 0, 172, 0, 0,\n 0, 223, 224, 225, 226, 227, 228, 229, 230, 0,\n 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n 19, 20, 21, 22, 23, 24, 25, 26, 231, 0,\n 0, 0, 0, 0, 0, 0, 0, 28, 29, 30,\n 31, 32, 0, 232, 0, 0, 265, 0, 0, 381,\n 382, 383, 384, 385, 0, 0, 33, 34, 35, 0,\n 0, 381, 382, 383, 384, 385, 386, 387, 388, 389,\n 390, 391, 392, 393, 394, 395, 396, 397, 386, 387,\n 388, 389, 390, 391, 392, 393, 394, 395, 396, 397,\n 0, 0, 36, 172, 0, 0, 38, 0, 224, 225,\n 226, 227, 228, 229, 230, 0, 233, 0, 0, 234,\n 235, 0, 0, 236, 237, 238, 8, 0, 0, 172,\n 0, 0, 0, 223, 224, 225, 226, 227, 228, 229,\n 230, 413, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n 231, 0, 0, 0, 0, 0, 0, 0, 0, 28,\n 29, 30, 31, 32, 0, 232, 0, 0, 421, 0,\n 381, 382, 383, 384, 385, 0, 0, 0, 33, 34,\n 35, 0, 381, 382, 383, 384, 0, 386, 387, 388,\n 389, 390, 391, 392, 393, 394, 395, 396, 397, 386,\n 387, 388, 389, 390, 391, 392, 393, 394, 395, 396,\n 397, 0, 0, 0, 36, 0, 0, 0, 38, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 233, 0,\n 0, 234, 235, 0, 0, 236, 237, 238, 8, 0,\n 0, 172, 0, 0, 0, 223, 224, 225, 226, 227,\n 228, 229, 230, 530, 9, 10, 11, 12, 13, 14,\n 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\n 25, 26, 231, 0, 0, 0, 0, 0, 0, 0,\n 0, 28, 29, 30, 31, 32, 0, 232, 0, 0,\n 424, 0, 381, 382, 383, 384, 385, 0, 0, 0,\n 33, 34, 35, 381, 382, 383, 384, 0, 0, 386,\n 387, 388, 389, 390, 391, 392, 393, 394, 395, 396,\n 397, 0, 388, 389, 390, 391, 392, 393, 394, 395,\n 396, 397, 0, 0, 0, 0, 36, 0, 0, 0,\n 38, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 233, 0, 0, 234, 235, 0, 0, 236, 237, 238,\n 8, 0, 0, 172, 0, 0, 0, 223, 224, 225,\n 226, 227, 228, 229, 230, 532, 9, 10, 11, 12,\n 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n 23, 24, 25, 26, 231, 0, 0, 0, 0, 0,\n 0, 0, 0, 28, 29, 30, 31, 32, 0, 232,\n 0, 0, 527, 0, 381, 382, 383, 384, 385, 0,\n 0, 0, 33, 34, 35, 381, 382, 383, 384, 0,\n 0, 386, 387, 388, 389, 390, 391, 392, 393, 394,\n 395, 396, 397, 0, 0, 0, 390, 391, 392, 393,\n 394, 395, 396, 397, 0, 0, 0, 0, 36, 0,\n 0, 0, 38, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 233, 0, 0, 234, 235, 0, 0, 236,\n 237, 238, 8, 0, 0, 172, 0, 0, 0, 223,\n 224, 225, 226, 227, 228, 229, 230, 658, 9, 10,\n 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 26, 231, 648, 0, 0,\n 0, 0, 0, 0, 0, 28, 29, 30, 31, 32,\n 0, 232, 0, 0, 0, 0, 381, 382, 383, 384,\n 385, 0, 0, 0, 33, 34, 35, 0, 0, 0,\n 0, 0, 0, 386, 387, 388, 389, 390, 391, 392,\n 393, 394, 395, 396, 397, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 36, 0, 0, 0, 38, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 233, 0, 0, 234, 235, 0,\n 0, 236, 237, 238, 8, 0, 0, 172, 0, 0,\n 0, 223, 224, 225, 226, 227, 228, 229, 230, 662,\n 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n 19, 20, 21, 22, 23, 24, 25, 26, 231, 0,\n 0, 0, 0, 0, 0, 0, 0, 28, 29, 30,\n 31, 32, 0, 232, 0, 0, 0, 0, 381, 382,\n 383, 384, 385, 0, 0, 0, 33, 34, 35, 0,\n 0, 0, 0, 0, 0, 386, 387, 388, 389, 390,\n 391, 392, 393, 394, 395, 396, 397, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 36, 0, 0, 0, 38, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 233, 0, 0, 234,\n 235, 0, 0, 236, 237, 238, 8, 0, 0, 172,\n 0, 0, 0, 223, 224, 225, 226, 227, 228, 229,\n 230, 0, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n 231, 0, 0, 0, 0, 0, 0, 0, 0, 28,\n 29, 30, 31, 32, 0, 232, 8, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 33, 34,\n 35, 0, 9, 10, 11, 12, 13, 14, 15, 16,\n 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n 0, 0, 0, 0, 0, 0, 0, 0, 27, 28,\n 29, 30, 31, 32, 36, 0, 0, 0, 38, 0,\n 0, 0, 0, 0, 8, 0, 0, 0, 33, 34,\n 35, 234, 235, 0, 0, 649, 237, 238, 0, 0,\n 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n 19, 20, 21, 22, 23, 24, 25, 26, 0, 0,\n 0, 0, 0, 0, 36, 0, 655, 37, 38, 0,\n 31, 32, 0, 0, 0, 0, 0, 0, 352, 0,\n 0, 0, 0, 0, 0, 147, 33, 34, 35, 381,\n 382, 383, 384, 385, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 386, 387, 388, 389,\n 390, 391, 392, 393, 394, 395, 396, 397, 0, 0,\n 0, 0, 36, 0, 0, 0, 38, -2, 56, 0,\n -467, 57, 0, 0, 58, 59, 60, 0, 0, 0,\n 0, 0, 0, 147, 0, 61, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, 0, 0, 0, 62, 63, 0,\n 0, 0, 0, -467, -467, -467, -467, -467, 0, 0,\n 64, 0, 0, 0, 65, 66, 67, 68, 69, 70,\n 71, 72, -467, -467, -467, 0, 0, 0, 0, 73,\n 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,\n 83, 84, 85, 86, 87, 88, 89, 56, 0, -467,\n 57, 0, 0, 58, 59, 60, 90, 0, -467, 0,\n 0, 91, -467, 0, 61, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, 0, 0, 0, 62, 63, 0, 0,\n 569, 0, -467, -467, -467, -467, -467, 0, 0, 64,\n 0, 0, 0, 65, 66, 67, 68, 69, 70, 71,\n 72, -467, -467, -467, 0, 0, 0, 0, 73, 74,\n 75, 0, 76, 77, 78, 79, 80, 81, 82, 83,\n 84, 85, 86, 87, 88, 89, 56, 0, -467, 57,\n 0, 0, 58, 59, 60, 90, 0, -467, 0, 0,\n 91, -467, 0, 61, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, 0, 0, 0, 62, 63, 0, 0, 664,\n 0, -467, -467, -467, -467, -467, 0, 0, 64, 0,\n 0, 0, 65, 66, 67, 68, 69, 70, 71, 72,\n -467, -467, -467, 0, 0, 0, 0, 73, 74, 75,\n 0, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n 85, 86, 87, 88, 89, 56, 0, -467, 57, 0,\n 0, 58, 59, 60, 90, 0, -467, 0, 0, 91,\n -467, 0, 61, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, 0, 0, 0, 62, 63, 0, 0, 680, 0,\n -467, -467, -467, -467, -467, 0, 0, 64, 0, 0,\n 0, 65, 66, 67, 68, 69, 70, 71, 72, -467,\n -467, -467, 0, 0, 0, 0, 73, 74, 75, 0,\n 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,\n 86, 87, 88, 89, 56, 0, -467, 57, 0, 0,\n 58, 59, 60, 90, 0, -467, 0, 0, 91, -467,\n 0, 61, -467, -467, -467, -467, -467, -467, -467, -467,\n -467, -467, -467, -467, -467, -467, -467, -467, -467, -467,\n 0, 0, 0, 62, 63, 0, 0, 0, 0, -467,\n -467, -467, -467, -467, 0, 0, 64, 0, 769, 0,\n 65, 66, 67, 68, 69, 70, 71, 72, -467, -467,\n -467, 0, 0, 0, 0, 73, 74, 75, 0, 76,\n 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,\n 87, 88, 89, 7, 0, 8, 0, 0, 0, 0,\n 0, 0, 90, 0, -467, 0, 0, 91, -467, 0,\n 0, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n 18, 19, 20, 21, 22, 23, 24, 25, 26, 0,\n 0, 0, 0, 0, 0, 0, 0, 27, 28, 29,\n 30, 31, 32, 51, 0, 8, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 33, 34, 35,\n 0, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n 18, 19, 20, 21, 22, 23, 24, 25, 26, 0,\n 0, 0, 0, 0, 0, 0, 0, 27, 28, 29,\n 30, 31, 32, 36, 0, 0, 37, 38, 0, 0,\n 0, 0, 0, 177, 0, 178, 0, 33, 34, 35,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n 18, 19, 20, 21, 22, 23, 24, 25, 26, 0,\n 0, 0, 0, 36, 0, 0, 37, 38, 28, 29,\n 30, 31, 32, 0, 8, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 33, 34, 35,\n 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n 19, 20, 21, 22, 23, 24, 25, 26, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 28, 29, 30,\n 31, 32, 0, 36, 8, 0, 0, 38, 0, 0,\n 0, 0, 0, 0, 0, 0, 220, 34, 35, 0,\n 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n 19, 20, 21, 22, 23, 24, 25, 26, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 28, 29, 30,\n 31, 32, 36, 8, 0, 0, 38, 726, 0, 0,\n 0, 313, 0, 0, 0, 0, 33, 34, 35, 9,\n 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n 20, 21, 22, 23, 24, 25, 26, 0, 0, 0,\n 0, 0, 0, 0, 0, 27, 28, 29, 30, 31,\n 32, 0, 36, 8, 0, 0, 38, 726, 0, 0,\n 0, 0, 0, 0, 0, 33, 34, 35, 0, 9,\n 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n 20, 21, 22, 23, 24, 25, 26, 0, 0, 0,\n 0, 0, 0, 0, 0, 27, 28, 29, 30, 31,\n 32, 36, 8, 0, 37, 38, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 33, 34, 35, 9, 10,\n 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 26, 203, 0, 0, 0,\n 0, 0, 0, 0, 0, 28, 29, 30, 31, 32,\n 0, 36, 8, 0, 37, 38, 0, 0, 0, 0,\n 0, 0, 0, 0, 33, 34, 35, 0, 9, 10,\n 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 26, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 28, 29, 30, 31, 32,\n 36, 8, 0, 0, 38, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 220, 34, 35, 9, 10, 11,\n 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n 22, 23, 24, 25, 26, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 28, 29, 30, 31, 32, 0,\n 36, 682, 0, 0, 38, 0, 0, 0, 0, 0,\n 0, 0, 0, 33, 34, 35, 0, 9, 10, 11,\n 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,\n 22, 23, 24, 25, 26, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 28, 29, 30, 31, 32, 36,\n 8, 0, 0, 38, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 33, 34, 35, 9, 10, 11, 12,\n 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n 23, 24, 25, 26, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 31, 32, 0, 36,\n 0, 0, 0, 38, 0, 0, 0, 0, 0, 0,\n 0, 0, 33, 34, 35, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0, 0, 0, 0, 0, 36, 0,\n 0, 0, 38\n};\n\nstatic const yytype_int16 yycheck[] =\n{\n 0, 85, 5, 5, 40, 5, 320, 41, 8, 43,\n 5, 549, 212, 110, 437, 5, 304, 5, 446, 564,\n 131, 21, 6, 446, 257, 146, 5, 260, 563, 38,\n 197, 327, 38, 5, 155, 5, 90, 6, 39, 3,\n 5, 3, 42, 69, 3, 558, 1, 2, 215, 761,\n 42, 763, 3, 566, 91, 142, 40, 5, 5, 5,\n 5, 38, 137, 5, 64, 6, 775, 5, 5, 69,\n 70, 5, 5, 782, 37, 5, 102, 590, 4, 788,\n 6, 5, 179, 5, 597, 54, 161, 162, 3, 0,\n 91, 3, 129, 102, 3, 5, 634, 3, 3, 54,\n 3, 138, 102, 151, 40, 153, 140, 43, 205, 115,\n 51, 6, 171, 147, 40, 79, 175, 43, 205, 352,\n 353, 435, 181, 39, 221, 102, 671, 186, 37, 6,\n 253, 131, 45, 126, 37, 71, 257, 101, 3, 260,\n 454, 105, 101, 105, 40, 54, 105, 43, 43, 208,\n 142, 151, 115, 153, 105, 147, 115, 40, 217, 122,\n 456, 870, 283, 122, 40, 678, 43, 290, 168, 256,\n 90, 43, 37, 39, 100, 91, 131, 410, 178, 717,\n 3, 3, 269, 3, 6, 51, 101, 142, 4, 54,\n 105, 191, 101, 105, 90, 101, 105, 735, 101, 105,\n 105, 3, 105, 1, 2, 205, 115, 207, 208, 754,\n 1, 40, 212, 205, 90, 750, 122, 37, 90, 39,\n 220, 124, 4, 215, 6, 3, 3, 43, 6, 40,\n 103, 51, 187, 188, 54, 37, 101, 37, 471, 752,\n 105, 37, 242, 51, 244, 673, 37, 785, 203, 333,\n 673, 71, 244, 126, 54, 54, 211, 212, 306, 124,\n 38, 43, 106, 71, 256, 6, 377, 467, 65, 436,\n 51, 91, 51, 4, 37, 589, 3, 269, 101, 400,\n 401, 101, 105, 275, 3, 105, 407, 37, 85, 86,\n 46, 47, 48, 414, 40, 115, 463, 810, 103, 101,\n 37, 256, 122, 105, 124, 3, 306, 428, 3, 90,\n 37, 90, 43, 305, 269, 39, 854, 365, 37, 43,\n 320, 126, 124, 278, 101, 71, 281, 54, 105, 37,\n 51, 365, 129, 131, 37, 54, 3, 292, 37, 37,\n 37, 3, 37, 856, 3, 345, 54, 860, 445, 37,\n 71, 351, 449, 51, 75, 54, 54, 54, 39, 54,\n 37, 361, 399, 44, 356, 365, 122, 367, 3, 37,\n 37, 6, 364, 71, 101, 472, 368, 37, 105, 45,\n 40, 43, 101, 43, 43, 37, 105, 446, 187, 188,\n 46, 47, 48, 37, 37, 38, 115, 124, 519, 46,\n 47, 48, 37, 101, 203, 124, 101, 105, 37, 364,\n 105, 54, 211, 37, 212, 3, 3, 115, 6, 75,\n 115, 43, 377, 711, 122, 40, 124, 122, 43, 124,\n 37, 38, 90, 433, 101, 435, 484, 40, 105, 101,\n 43, 102, 101, 105, 102, 103, 105, 54, 115, 3,\n 453, 453, 455, 453, 454, 455, 43, 124, 453, 493,\n 460, 40, 417, 453, 43, 453, 101, 564, 126, 4,\n 105, 6, 51, 38, 453, 37, 38, 878, 478, 278,\n 115, 453, 281, 453, 484, 485, 39, 122, 453, 124,\n 891, 892, 54, 448, 292, 495, 496, 40, 665, 666,\n 43, 493, 599, 495, 40, 453, 453, 453, 453, 464,\n 40, 453, 467, 101, 101, 453, 453, 105, 105, 453,\n 453, 38, 39, 453, 558, 37, 38, 115, 3, 453,\n 327, 453, 566, 4, 122, 6, 333, 612, 541, 541,\n 3, 541, 54, 453, 37, 38, 541, 38, 39, 549,\n 3, 541, 40, 541, 43, 43, 590, 3, 558, 38,\n 39, 54, 541, 597, 6, 364, 566, 570, 570, 541,\n 570, 541, 369, 43, 40, 570, 541, 674, 39, 377,\n 570, 692, 570, 102, 587, 587, 683, 587, 588, 589,\n 590, 570, 587, 541, 541, 541, 541, 597, 570, 541,\n 570, 685, 37, 541, 541, 570, 643, 541, 541, 897,\n 91, 541, 709, 39, 650, 649, 675, 541, 417, 541,\n 37, 576, 570, 570, 570, 570, 91, 724, 570, 18,\n 727, 541, 570, 570, 634, 38, 570, 570, 38, 54,\n 570, 40, 3, 598, 678, 645, 570, 722, 570, 122,\n 448, 4, 41, 6, 102, 102, 753, 649, 650, 456,\n 570, 38, 49, 50, 38, 702, 464, 715, 38, 467,\n 43, 768, 39, 39, 40, 38, 37, 43, 678, 66,\n 67, 715, 682, 72, 73, 74, 37, 40, 77, 51,\n 43, 38, 692, 54, 40, 46, 47, 48, 51, 38,\n 51, 704, 704, 90, 704, 49, 50, 38, 708, 704,\n 38, 38, 712, 668, 704, 715, 704, 717, 752, 38,\n 38, 3, 66, 67, 75, 704, 38, 33, 107, 108,\n 109, 91, 704, 781, 704, 735, 42, 692, 39, 704,\n 101, 838, 48, 102, 105, 842, 118, 119, 120, 121,\n 122, 38, 752, 102, 115, 710, 704, 704, 704, 704,\n 40, 716, 704, 124, 43, 862, 704, 704, 102, 3,\n 704, 704, 78, 79, 704, 572, 810, 576, 102, 827,\n 704, 781, 704, 38, 38, 785, 68, 69, 70, 40,\n 63, 746, 792, 40, 704, 38, 796, 789, 790, 598,\n 800, 43, 40, 37, 110, 120, 121, 122, 37, 44,\n 810, 84, 40, 40, 3, 38, 89, 155, 37, 101,\n 54, 43, 856, 105, 38, 3, 860, 827, 39, 39,\n 37, 51, 787, 126, 90, 790, 142, 38, 838, 839,\n 146, 875, 148, 51, 878, 44, 643, 37, 43, 155,\n 3, 806, 124, 71, 854, 71, 856, 891, 892, 37,\n 860, 44, 862, 3, 44, 71, 38, 101, 73, 668,\n 38, 105, 75, 179, 829, 875, 182, 832, 878, 44,\n 218, 115, 37, 189, 37, 3, 40, 40, 685, 38,\n 124, 891, 892, 38, 692, 71, 40, 37, 171, 205,\n 40, 174, 175, 858, 859, 702, 3, 213, 181, 215,\n 216, 710, 218, 186, 220, 221, 222, 716, 38, 3,\n 4, 37, 6, 101, 197, 40, 39, 105, 38, 726,\n 37, 39, 91, 38, 40, 208, 209, 115, 244, 40,\n 37, 214, 215, 38, 217, 283, 124, 746, 101, 287,\n 256, 257, 105, 37, 260, 18, 40, 40, 37, 43,\n 40, 101, 115, 269, 270, 105, 44, 38, 3, 122,\n 40, 124, 40, 39, 71, 115, 37, 283, 41, 44,\n 38, 287, 122, 37, 124, 37, 437, 38, 787, 38,\n 3, 790, 144, 145, 40, 3, 38, 38, 460, 305,\n 40, 38, 37, 3, 101, 40, 38, 806, 105, 72,\n 73, 74, 40, 319, 77, 40, 100, 101, 115, 40,\n 358, 105, 360, 587, 37, 122, 715, 124, 587, 37,\n 829, 115, 40, 832, 3, 3, 467, 37, 122, 588,\n 124, 104, 587, 587, 862, 433, 352, 353, 377, 46,\n 356, 692, 358, 496, 360, 495, 839, 708, 364, 858,\n 859, 796, 800, 851, 21, 860, 101, 573, 37, 37,\n 105, -1, -1, -1, -1, -1, 414, -1, -1, 231,\n 115, 233, 234, 235, 236, 237, 238, 122, 101, 124,\n 428, 429, 105, 101, 3, 401, -1, 105, -1, -1,\n -1, 101, 115, -1, 410, 105, -1, 115, 414, 122,\n -1, 124, 264, -1, 122, 115, 124, -1, -1, -1,\n -1, -1, 428, 429, 124, -1, -1, 279, 37, -1,\n 282, -1, 101, 101, -1, 473, 105, 105, 476, 445,\n -1, -1, -1, 449, -1, 54, 115, 115, 3, -1,\n -1, -1, -1, 122, 122, 124, 124, -1, -1, -1,\n -1, 434, -1, 436, 437, 471, 472, 473, -1, -1,\n 476, 444, 445, 446, -1, 46, 47, 48, -1, -1,\n 51, -1, 37, -1, -1, -1, -1, 525, -1, 495,\n 463, -1, 101, -1, -1, 533, 105, -1, -1, 472,\n 71, -1, -1, -1, 75, -1, 115, -1, 514, -1,\n -1, -1, -1, -1, -1, 124, -1, -1, -1, 525,\n 116, 117, 118, 119, 120, 121, 122, 533, -1, 381,\n 382, 383, 384, 385, 386, 387, 388, 389, 390, 391,\n 392, 393, 394, 395, 396, 397, 101, -1, 94, 95,\n 105, -1, -1, -1, 592, -1, -1, -1, 564, 411,\n 115, -1, -1, -1, -1, -1, 418, 122, -1, 124,\n 116, 117, 118, 119, 120, 121, 122, -1, -1, -1,\n -1, -1, -1, -1, -1, 3, 592, -1, -1, -1,\n -1, 564, -1, 599, -1, -1, -1, -1, 571, -1,\n 573, 19, 20, 21, 22, 23, 24, 25, 26, 27,\n 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,\n -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,\n 48, 49, 50, -1, -1, -1, 54, 643, -1, 491,\n 492, 493, -1, -1, -1, -1, -1, 65, 66, 67,\n 19, 20, 21, 22, 23, 24, 25, 26, -1, 28,\n -1, 30, -1, -1, 33, 34, 35, 36, 674, -1,\n -1, -1, -1, -1, -1, -1, -1, 683, -1, -1,\n -1, -1, -1, 101, -1, -1, 104, 105, -1, -1,\n -1, -1, 665, 666, -1, -1, -1, 115, 671, -1,\n 673, -1, 675, 709, 122, -1, -1, -1, -1, -1,\n -1, -1, 3, -1, -1, -1, -1, -1, 724, -1,\n -1, 727, 728, -1, -1, -1, -1, 733, 19, 20,\n 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n 31, 32, 33, 34, 35, 36, 37, 753, -1, -1,\n -1, -1, -1, -1, 45, 46, 47, 48, 49, 50,\n -1, -1, 768, 54, -1, -1, -1, 94, 95, 96,\n 97, -1, 778, -1, 65, 66, 67, -1, -1, -1,\n -1, 754, -1, -1, 790, 112, 113, 114, 115, 116,\n 117, 118, 119, 120, 121, 122, 648, 649, -1, 651,\n -1, -1, -1, 655, -1, -1, -1, -1, -1, -1,\n 101, -1, -1, 104, 105, 94, 95, 96, 97, -1,\n -1, -1, -1, -1, 115, -1, -1, -1, -1, -1,\n -1, 122, 838, -1, -1, 841, 842, 116, 117, 118,\n 119, 120, 121, 122, 1, 851, 3, 4, -1, -1,\n 7, 8, 9, -1, -1, 707, 862, -1, -1, -1,\n -1, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\n -1, -1, -1, 40, 41, -1, 738, 44, -1, 46,\n 47, 48, 49, 50, -1, -1, -1, -1, -1, -1,\n 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,\n 67, 68, 69, 70, -1, 72, 73, 74, -1, 76,\n 77, 78, -1, -1, -1, 82, -1, 84, 85, 86,\n 87, 88, 89, -1, -1, -1, -1, -1, -1, 791,\n -1, -1, 99, -1, 101, -1, 38, 104, 105, 106,\n -1, -1, 3, -1, -1, 6, -1, -1, -1, 10,\n 11, 12, 13, 14, 15, 16, 17, 124, 19, 20,\n 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n 31, 32, 33, 34, 35, 36, 37, -1, -1, -1,\n -1, -1, -1, -1, 45, 46, 47, 48, 49, 50,\n -1, 52, 94, 95, 96, 97, 98, -1, -1, -1,\n -1, -1, -1, -1, 65, 66, 67, -1, -1, 111,\n 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n 122, 3, -1, -1, 6, 94, 95, 96, 97, 11,\n 12, 13, 14, 15, 16, 17, -1, -1, -1, -1,\n 101, -1, -1, 104, 105, 114, 115, 116, 117, 118,\n 119, 120, 121, 122, 115, -1, -1, 118, 119, -1,\n -1, 122, 123, 124, 3, 40, -1, 6, -1, -1,\n -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,\n 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,\n 29, 30, 31, 32, 33, 34, 35, 36, 37, -1,\n -1, -1, -1, -1, -1, -1, -1, 46, 47, 48,\n 49, 50, -1, 52, -1, -1, 55, -1, -1, 94,\n 95, 96, 97, 98, -1, -1, 65, 66, 67, -1,\n -1, 94, 95, 96, 97, 98, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, 111, 112,\n 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,\n -1, -1, 101, 6, -1, -1, 105, -1, 11, 12,\n 13, 14, 15, 16, 17, -1, 115, -1, -1, 118,\n 119, -1, -1, 122, 123, 124, 3, -1, -1, 6,\n -1, -1, -1, 10, 11, 12, 13, 14, 15, 16,\n 17, 55, 19, 20, 21, 22, 23, 24, 25, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\n 37, -1, -1, -1, -1, -1, -1, -1, -1, 46,\n 47, 48, 49, 50, -1, 52, -1, -1, 55, -1,\n 94, 95, 96, 97, 98, -1, -1, -1, 65, 66,\n 67, -1, 94, 95, 96, 97, -1, 111, 112, 113,\n 114, 115, 116, 117, 118, 119, 120, 121, 122, 111,\n 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n 122, -1, -1, -1, 101, -1, -1, -1, 105, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, 115, -1,\n -1, 118, 119, -1, -1, 122, 123, 124, 3, -1,\n -1, 6, -1, -1, -1, 10, 11, 12, 13, 14,\n 15, 16, 17, 55, 19, 20, 21, 22, 23, 24,\n 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,\n 35, 36, 37, -1, -1, -1, -1, -1, -1, -1,\n -1, 46, 47, 48, 49, 50, -1, 52, -1, -1,\n 55, -1, 94, 95, 96, 97, 98, -1, -1, -1,\n 65, 66, 67, 94, 95, 96, 97, -1, -1, 111,\n 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n 122, -1, 113, 114, 115, 116, 117, 118, 119, 120,\n 121, 122, -1, -1, -1, -1, 101, -1, -1, -1,\n 105, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 115, -1, -1, 118, 119, -1, -1, 122, 123, 124,\n 3, -1, -1, 6, -1, -1, -1, 10, 11, 12,\n 13, 14, 15, 16, 17, 55, 19, 20, 21, 22,\n 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,\n 33, 34, 35, 36, 37, -1, -1, -1, -1, -1,\n -1, -1, -1, 46, 47, 48, 49, 50, -1, 52,\n -1, -1, 55, -1, 94, 95, 96, 97, 98, -1,\n -1, -1, 65, 66, 67, 94, 95, 96, 97, -1,\n -1, 111, 112, 113, 114, 115, 116, 117, 118, 119,\n 120, 121, 122, -1, -1, -1, 115, 116, 117, 118,\n 119, 120, 121, 122, -1, -1, -1, -1, 101, -1,\n -1, -1, 105, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, 115, -1, -1, 118, 119, -1, -1, 122,\n 123, 124, 3, -1, -1, 6, -1, -1, -1, 10,\n 11, 12, 13, 14, 15, 16, 17, 55, 19, 20,\n 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n 31, 32, 33, 34, 35, 36, 37, 38, -1, -1,\n -1, -1, -1, -1, -1, 46, 47, 48, 49, 50,\n -1, 52, -1, -1, -1, -1, 94, 95, 96, 97,\n 98, -1, -1, -1, 65, 66, 67, -1, -1, -1,\n -1, -1, -1, 111, 112, 113, 114, 115, 116, 117,\n 118, 119, 120, 121, 122, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 101, -1, -1, -1, 105, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, 115, -1, -1, 118, 119, -1,\n -1, 122, 123, 124, 3, -1, -1, 6, -1, -1,\n -1, 10, 11, 12, 13, 14, 15, 16, 17, 55,\n 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,\n 29, 30, 31, 32, 33, 34, 35, 36, 37, -1,\n -1, -1, -1, -1, -1, -1, -1, 46, 47, 48,\n 49, 50, -1, 52, -1, -1, -1, -1, 94, 95,\n 96, 97, 98, -1, -1, -1, 65, 66, 67, -1,\n -1, -1, -1, -1, -1, 111, 112, 113, 114, 115,\n 116, 117, 118, 119, 120, 121, 122, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, 101, -1, -1, -1, 105, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, 115, -1, -1, 118,\n 119, -1, -1, 122, 123, 124, 3, -1, -1, 6,\n -1, -1, -1, 10, 11, 12, 13, 14, 15, 16,\n 17, -1, 19, 20, 21, 22, 23, 24, 25, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\n 37, -1, -1, -1, -1, -1, -1, -1, -1, 46,\n 47, 48, 49, 50, -1, 52, 3, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, 65, 66,\n 67, -1, 19, 20, 21, 22, 23, 24, 25, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\n -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,\n 47, 48, 49, 50, 101, -1, -1, -1, 105, -1,\n -1, -1, -1, -1, 3, -1, -1, -1, 65, 66,\n 67, 118, 119, -1, -1, 122, 123, 124, -1, -1,\n 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,\n 29, 30, 31, 32, 33, 34, 35, 36, -1, -1,\n -1, -1, -1, -1, 101, -1, 71, 104, 105, -1,\n 49, 50, -1, -1, -1, -1, -1, -1, 115, -1,\n -1, -1, -1, -1, -1, 122, 65, 66, 67, 94,\n 95, 96, 97, 98, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, -1, -1,\n -1, -1, 101, -1, -1, -1, 105, 0, 1, -1,\n 3, 4, -1, -1, 7, 8, 9, -1, -1, -1,\n -1, -1, -1, 122, -1, 18, 19, 20, 21, 22,\n 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,\n 33, 34, 35, 36, -1, -1, -1, 40, 41, -1,\n -1, -1, -1, 46, 47, 48, 49, 50, -1, -1,\n 53, -1, -1, -1, 57, 58, 59, 60, 61, 62,\n 63, 64, 65, 66, 67, -1, -1, -1, -1, 72,\n 73, 74, -1, 76, 77, 78, 79, 80, 81, 82,\n 83, 84, 85, 86, 87, 88, 89, 1, -1, 3,\n 4, -1, -1, 7, 8, 9, 99, -1, 101, -1,\n -1, 104, 105, -1, 18, 19, 20, 21, 22, 23,\n 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n 34, 35, 36, -1, -1, -1, 40, 41, -1, -1,\n 44, -1, 46, 47, 48, 49, 50, -1, -1, 53,\n -1, -1, -1, 57, 58, 59, 60, 61, 62, 63,\n 64, 65, 66, 67, -1, -1, -1, -1, 72, 73,\n 74, -1, 76, 77, 78, 79, 80, 81, 82, 83,\n 84, 85, 86, 87, 88, 89, 1, -1, 3, 4,\n -1, -1, 7, 8, 9, 99, -1, 101, -1, -1,\n 104, 105, -1, 18, 19, 20, 21, 22, 23, 24,\n 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,\n 35, 36, -1, -1, -1, 40, 41, -1, -1, 44,\n -1, 46, 47, 48, 49, 50, -1, -1, 53, -1,\n -1, -1, 57, 58, 59, 60, 61, 62, 63, 64,\n 65, 66, 67, -1, -1, -1, -1, 72, 73, 74,\n -1, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n 85, 86, 87, 88, 89, 1, -1, 3, 4, -1,\n -1, 7, 8, 9, 99, -1, 101, -1, -1, 104,\n 105, -1, 18, 19, 20, 21, 22, 23, 24, 25,\n 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n 36, -1, -1, -1, 40, 41, -1, -1, 44, -1,\n 46, 47, 48, 49, 50, -1, -1, 53, -1, -1,\n -1, 57, 58, 59, 60, 61, 62, 63, 64, 65,\n 66, 67, -1, -1, -1, -1, 72, 73, 74, -1,\n 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,\n 86, 87, 88, 89, 1, -1, 3, 4, -1, -1,\n 7, 8, 9, 99, -1, 101, -1, -1, 104, 105,\n -1, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\n -1, -1, -1, 40, 41, -1, -1, -1, -1, 46,\n 47, 48, 49, 50, -1, -1, 53, -1, 55, -1,\n 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,\n 67, -1, -1, -1, -1, 72, 73, 74, -1, 76,\n 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,\n 87, 88, 89, 1, -1, 3, -1, -1, -1, -1,\n -1, -1, 99, -1, 101, -1, -1, 104, 105, -1,\n -1, 19, 20, 21, 22, 23, 24, 25, 26, 27,\n 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,\n -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,\n 48, 49, 50, 1, -1, 3, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,\n -1, 19, 20, 21, 22, 23, 24, 25, 26, 27,\n 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,\n -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,\n 48, 49, 50, 101, -1, -1, 104, 105, -1, -1,\n -1, -1, -1, 1, -1, 3, -1, 65, 66, 67,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, 19, 20, 21, 22, 23, 24, 25, 26, 27,\n 28, 29, 30, 31, 32, 33, 34, 35, 36, -1,\n -1, -1, -1, 101, -1, -1, 104, 105, 46, 47,\n 48, 49, 50, -1, 3, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, 65, 66, 67,\n 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,\n 29, 30, 31, 32, 33, 34, 35, 36, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, 46, 47, 48,\n 49, 50, -1, 101, 3, -1, -1, 105, -1, -1,\n -1, -1, -1, -1, -1, -1, 65, 66, 67, -1,\n 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,\n 29, 30, 31, 32, 33, 34, 35, 36, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, 46, 47, 48,\n 49, 50, 101, 3, -1, -1, 105, 106, -1, -1,\n -1, 11, -1, -1, -1, -1, 65, 66, 67, 19,\n 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n 30, 31, 32, 33, 34, 35, 36, -1, -1, -1,\n -1, -1, -1, -1, -1, 45, 46, 47, 48, 49,\n 50, -1, 101, 3, -1, -1, 105, 106, -1, -1,\n -1, -1, -1, -1, -1, 65, 66, 67, -1, 19,\n 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n 30, 31, 32, 33, 34, 35, 36, -1, -1, -1,\n -1, -1, -1, -1, -1, 45, 46, 47, 48, 49,\n 50, 101, 3, -1, 104, 105, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, 65, 66, 67, 19, 20,\n 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n 31, 32, 33, 34, 35, 36, 37, -1, -1, -1,\n -1, -1, -1, -1, -1, 46, 47, 48, 49, 50,\n -1, 101, 3, -1, 104, 105, -1, -1, -1, -1,\n -1, -1, -1, -1, 65, 66, 67, -1, 19, 20,\n 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n 31, 32, 33, 34, 35, 36, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, 46, 47, 48, 49, 50,\n 101, 3, -1, -1, 105, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, 65, 66, 67, 19, 20, 21,\n 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n 32, 33, 34, 35, 36, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, 46, 47, 48, 49, 50, -1,\n 101, 3, -1, -1, 105, -1, -1, -1, -1, -1,\n -1, -1, -1, 65, 66, 67, -1, 19, 20, 21,\n 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n 32, 33, 34, 35, 36, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, 46, 47, 48, 49, 50, 101,\n 3, -1, -1, 105, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, 65, 66, 67, 19, 20, 21, 22,\n 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,\n 33, 34, 35, 36, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, 49, 50, -1, 101,\n -1, -1, -1, 105, -1, -1, -1, -1, -1, -1,\n -1, -1, 65, 66, 67, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, 101, -1,\n -1, -1, 105\n};\n\n/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing\n symbol of state STATE-NUM. */\nstatic const yytype_uint16 yystos[] =\n{\n 0, 107, 108, 109, 128, 129, 274, 1, 3, 19,\n 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n 30, 31, 32, 33, 34, 35, 36, 45, 46, 47,\n 48, 49, 50, 65, 66, 67, 101, 104, 105, 215,\n 229, 230, 232, 233, 234, 235, 236, 253, 254, 264,\n 266, 1, 215, 1, 37, 0, 1, 4, 7, 8,\n 9, 18, 40, 41, 53, 57, 58, 59, 60, 61,\n 62, 63, 64, 72, 73, 74, 76, 77, 78, 79,\n 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,\n 99, 104, 130, 131, 132, 134, 135, 136, 137, 138,\n 141, 142, 144, 145, 146, 147, 148, 149, 150, 153,\n 154, 155, 158, 160, 165, 166, 167, 168, 170, 173,\n 174, 175, 176, 177, 181, 182, 189, 190, 200, 211,\n 274, 90, 261, 274, 261, 45, 264, 126, 90, 40,\n 233, 229, 37, 51, 54, 71, 115, 122, 124, 220,\n 221, 223, 225, 226, 227, 228, 264, 274, 229, 235,\n 264, 103, 126, 265, 40, 40, 212, 213, 215, 274,\n 106, 37, 6, 269, 37, 271, 274, 1, 3, 231,\n 232, 37, 271, 37, 152, 274, 37, 37, 37, 79,\n 264, 3, 43, 264, 37, 4, 43, 37, 37, 40,\n 43, 4, 269, 37, 164, 231, 162, 164, 37, 37,\n 269, 37, 90, 254, 271, 37, 115, 223, 228, 264,\n 65, 231, 254, 10, 11, 12, 13, 14, 15, 16,\n 17, 37, 52, 115, 118, 119, 122, 123, 124, 215,\n 216, 217, 219, 231, 232, 243, 244, 245, 246, 269,\n 274, 45, 105, 266, 254, 229, 37, 115, 212, 226,\n 228, 264, 43, 237, 238, 55, 243, 244, 243, 37,\n 124, 224, 227, 264, 228, 229, 264, 220, 37, 54,\n 220, 37, 54, 115, 224, 227, 264, 102, 266, 105,\n 266, 38, 39, 214, 274, 3, 262, 269, 6, 43,\n 262, 272, 262, 40, 51, 37, 223, 38, 262, 264,\n 3, 3, 262, 11, 159, 212, 212, 264, 40, 51,\n 192, 43, 3, 161, 272, 3, 212, 43, 222, 223,\n 226, 274, 40, 39, 163, 274, 262, 263, 274, 139,\n 140, 269, 212, 185, 186, 187, 215, 253, 274, 264,\n 269, 3, 115, 228, 264, 272, 37, 262, 115, 264,\n 102, 3, 239, 274, 37, 223, 43, 264, 243, 37,\n 243, 243, 243, 243, 243, 243, 91, 39, 218, 274,\n 37, 94, 95, 96, 97, 98, 111, 112, 113, 114,\n 115, 116, 117, 118, 119, 120, 121, 122, 265, 91,\n 115, 228, 264, 225, 264, 38, 38, 115, 225, 264,\n 102, 54, 243, 55, 228, 264, 264, 37, 54, 228,\n 212, 55, 243, 212, 55, 243, 224, 227, 102, 115,\n 224, 265, 40, 215, 38, 169, 39, 51, 38, 237,\n 220, 38, 43, 38, 51, 38, 39, 157, 39, 38,\n 38, 40, 264, 129, 191, 38, 38, 38, 38, 162,\n 164, 38, 38, 39, 43, 38, 91, 39, 188, 274,\n 54, 102, 38, 228, 264, 40, 102, 40, 43, 212,\n 264, 75, 172, 220, 229, 179, 40, 71, 247, 248,\n 274, 38, 115, 122, 228, 231, 219, 243, 243, 243,\n 243, 243, 243, 243, 243, 243, 243, 243, 243, 243,\n 243, 243, 243, 243, 254, 264, 102, 38, 38, 102,\n 225, 243, 224, 264, 38, 102, 212, 55, 243, 38,\n 55, 38, 55, 115, 224, 227, 224, 214, 4, 43,\n 269, 129, 272, 139, 245, 269, 273, 40, 40, 133,\n 4, 151, 269, 4, 40, 43, 100, 156, 223, 269,\n 270, 262, 269, 273, 38, 215, 223, 43, 40, 44,\n 129, 41, 211, 162, 40, 43, 37, 44, 163, 3,\n 101, 105, 267, 40, 272, 215, 40, 183, 187, 143,\n 223, 269, 102, 3, 240, 241, 274, 38, 37, 39,\n 40, 43, 171, 75, 220, 1, 40, 61, 68, 69,\n 70, 73, 124, 134, 135, 136, 137, 141, 142, 146,\n 148, 150, 153, 155, 158, 160, 165, 166, 167, 168,\n 181, 182, 189, 193, 196, 197, 198, 199, 200, 201,\n 202, 207, 210, 211, 274, 249, 43, 243, 38, 122,\n 229, 38, 115, 221, 218, 71, 264, 38, 55, 38,\n 224, 38, 55, 224, 44, 39, 39, 193, 37, 75,\n 229, 256, 274, 51, 38, 39, 157, 156, 223, 256,\n 44, 269, 3, 231, 40, 51, 270, 212, 103, 126,\n 268, 126, 90, 38, 44, 170, 177, 181, 182, 184,\n 197, 199, 211, 188, 129, 256, 40, 51, 39, 44,\n 37, 51, 256, 257, 212, 223, 37, 195, 43, 71,\n 71, 71, 124, 266, 44, 193, 106, 231, 254, 264,\n 73, 250, 251, 255, 274, 178, 243, 243, 38, 38,\n 243, 38, 272, 272, 44, 212, 37, 75, 156, 269,\n 273, 40, 223, 38, 256, 40, 40, 223, 164, 38,\n 3, 3, 105, 3, 105, 216, 4, 43, 231, 55,\n 40, 242, 243, 241, 40, 223, 212, 237, 71, 258,\n 274, 38, 172, 212, 193, 194, 266, 37, 223, 231,\n 37, 71, 3, 43, 264, 40, 39, 68, 69, 70,\n 252, 264, 193, 243, 38, 212, 37, 157, 256, 40,\n 223, 156, 40, 40, 268, 268, 91, 171, 38, 40,\n 259, 260, 264, 40, 43, 220, 171, 38, 193, 37,\n 212, 171, 37, 115, 228, 212, 243, 43, 204, 71,\n 251, 255, 44, 40, 38, 212, 40, 256, 40, 40,\n 43, 39, 37, 220, 44, 212, 38, 212, 37, 37,\n 38, 40, 203, 206, 223, 274, 250, 264, 40, 180,\n 223, 38, 40, 260, 193, 38, 208, 256, 38, 212,\n 212, 257, 206, 40, 43, 171, 209, 256, 40, 43,\n 209, 38, 38, 40, 205, 40, 43, 51, 209, 209,\n 40, 237, 40\n};\n\n#define yyerrok\t\t(yyerrstatus = 0)\n#define yyclearin\t(yychar = YYEMPTY)\n#define YYEMPTY\t\t(-2)\n#define YYEOF\t\t0\n\n#define YYACCEPT\tgoto yyacceptlab\n#define YYABORT\t\tgoto yyabortlab\n#define YYERROR\t\tgoto yyerrorlab\n\n\n/* Like YYERROR except do call yyerror. This remains here temporarily\n to ease the transition to the new meaning of YYERROR, for GCC.\n Once GCC version 2 has supplanted version 1, this can go. */\n\n#define YYFAIL\t\tgoto yyerrlab\n\n#define YYRECOVERING() (!!yyerrstatus)\n\n#define YYBACKUP(Token, Value)\t\t\t\t\t\\\ndo\t\t\t\t\t\t\t\t\\\n if (yychar == YYEMPTY && yylen == 1)\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\\\n yychar = (Token);\t\t\t\t\t\t\\\n yylval = (Value);\t\t\t\t\t\t\\\n yytoken = YYTRANSLATE (yychar);\t\t\t\t\\\n YYPOPSTACK (1);\t\t\t\t\t\t\\\n goto yybackup;\t\t\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\\\n else\t\t\t\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\\\n yyerror (YY_(\"syntax error: cannot back up\")); \\\n YYERROR;\t\t\t\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\\\nwhile (YYID (0))\n\n\n#define YYTERROR\t1\n#define YYERRCODE\t256\n\n\n/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].\n If N is 0, then set CURRENT to the empty location which ends\n the previous symbol: RHS[0] (always defined). */\n\n#define YYRHSLOC(Rhs, K) ((Rhs)[K])\n#ifndef YYLLOC_DEFAULT\n# define YYLLOC_DEFAULT(Current, Rhs, N)\t\t\t\t\\\n do\t\t\t\t\t\t\t\t\t\\\n if (YYID (N)) \\\n\t{\t\t\t\t\t\t\t\t\\\n\t (Current).first_line = YYRHSLOC (Rhs, 1).first_line;\t\\\n\t (Current).first_column = YYRHSLOC (Rhs, 1).first_column;\t\\\n\t (Current).last_line = YYRHSLOC (Rhs, N).last_line;\t\t\\\n\t (Current).last_column = YYRHSLOC (Rhs, N).last_column;\t\\\n\t}\t\t\t\t\t\t\t\t\\\n else\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t (Current).first_line = (Current).last_line =\t\t\\\n\t YYRHSLOC (Rhs, 0).last_line;\t\t\t\t\\\n\t (Current).first_column = (Current).last_column =\t\t\\\n\t YYRHSLOC (Rhs, 0).last_column;\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n while (YYID (0))\n#endif\n\n\n/* YY_LOCATION_PRINT -- Print the location on the stream.\n This macro was not mandated originally: define only if we know\n we won't break user code: when these are the locations we know. */\n\n#ifndef YY_LOCATION_PRINT\n# if YYLTYPE_IS_TRIVIAL\n# define YY_LOCATION_PRINT(File, Loc)\t\t\t\\\n fprintf (File, \"%d.%d-%d.%d\",\t\t\t\\\n\t (Loc).first_line, (Loc).first_column,\t\\\n\t (Loc).last_line, (Loc).last_column)\n# else\n# define YY_LOCATION_PRINT(File, Loc) ((void) 0)\n# endif\n#endif\n\n\n/* YYLEX -- calling `yylex' with the right arguments. */\n\n#ifdef YYLEX_PARAM\n# define YYLEX yylex (YYLEX_PARAM)\n#else\n# define YYLEX yylex ()\n#endif\n\n/* Enable debugging if requested. */\n#if YYDEBUG\n\n# ifndef YYFPRINTF\n# include /* INFRINGES ON USER NAME SPACE */\n# define YYFPRINTF fprintf\n# endif\n\n# define YYDPRINTF(Args)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n if (yydebug)\t\t\t\t\t\\\n YYFPRINTF Args;\t\t\t\t\\\n} while (YYID (0))\n\n# define YY_SYMBOL_PRINT(Title, Type, Value, Location)\t\t\t \\\ndo {\t\t\t\t\t\t\t\t\t \\\n if (yydebug)\t\t\t\t\t\t\t\t \\\n {\t\t\t\t\t\t\t\t\t \\\n YYFPRINTF (stderr, \"%s \", Title);\t\t\t\t\t \\\n yy_symbol_print (stderr,\t\t\t\t\t\t \\\n\t\t Type, Value); \\\n YYFPRINTF (stderr, \"\\n\");\t\t\t\t\t\t \\\n }\t\t\t\t\t\t\t\t\t \\\n} while (YYID (0))\n\n\n/*--------------------------------.\n| Print this symbol on YYOUTPUT. |\n`--------------------------------*/\n\n/*ARGSUSED*/\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic void\nyy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)\n#else\nstatic void\nyy_symbol_value_print (yyoutput, yytype, yyvaluep)\n FILE *yyoutput;\n int yytype;\n YYSTYPE const * const yyvaluep;\n#endif\n{\n if (!yyvaluep)\n return;\n# ifdef YYPRINT\n if (yytype < YYNTOKENS)\n YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);\n# else\n YYUSE (yyoutput);\n# endif\n switch (yytype)\n {\n default:\n\tbreak;\n }\n}\n\n\n/*--------------------------------.\n| Print this symbol on YYOUTPUT. |\n`--------------------------------*/\n\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic void\nyy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)\n#else\nstatic void\nyy_symbol_print (yyoutput, yytype, yyvaluep)\n FILE *yyoutput;\n int yytype;\n YYSTYPE const * const yyvaluep;\n#endif\n{\n if (yytype < YYNTOKENS)\n YYFPRINTF (yyoutput, \"token %s (\", yytname[yytype]);\n else\n YYFPRINTF (yyoutput, \"nterm %s (\", yytname[yytype]);\n\n yy_symbol_value_print (yyoutput, yytype, yyvaluep);\n YYFPRINTF (yyoutput, \")\");\n}\n\n/*------------------------------------------------------------------.\n| yy_stack_print -- Print the state stack from its BOTTOM up to its |\n| TOP (included). |\n`------------------------------------------------------------------*/\n\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic void\nyy_stack_print (yytype_int16 *bottom, yytype_int16 *top)\n#else\nstatic void\nyy_stack_print (bottom, top)\n yytype_int16 *bottom;\n yytype_int16 *top;\n#endif\n{\n YYFPRINTF (stderr, \"Stack now\");\n for (; bottom <= top; ++bottom)\n YYFPRINTF (stderr, \" %d\", *bottom);\n YYFPRINTF (stderr, \"\\n\");\n}\n\n# define YY_STACK_PRINT(Bottom, Top)\t\t\t\t\\\ndo {\t\t\t\t\t\t\t\t\\\n if (yydebug)\t\t\t\t\t\t\t\\\n yy_stack_print ((Bottom), (Top));\t\t\t\t\\\n} while (YYID (0))\n\n\n/*------------------------------------------------.\n| Report that the YYRULE is going to be reduced. |\n`------------------------------------------------*/\n\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic void\nyy_reduce_print (YYSTYPE *yyvsp, int yyrule)\n#else\nstatic void\nyy_reduce_print (yyvsp, yyrule)\n YYSTYPE *yyvsp;\n int yyrule;\n#endif\n{\n int yynrhs = yyr2[yyrule];\n int yyi;\n unsigned long int yylno = yyrline[yyrule];\n YYFPRINTF (stderr, \"Reducing stack by rule %d (line %lu):\\n\",\n\t yyrule - 1, yylno);\n /* The symbols being reduced. */\n for (yyi = 0; yyi < yynrhs; yyi++)\n {\n fprintf (stderr, \" $%d = \", yyi + 1);\n yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],\n\t\t &(yyvsp[(yyi + 1) - (yynrhs)])\n\t\t \t\t );\n fprintf (stderr, \"\\n\");\n }\n}\n\n# define YY_REDUCE_PRINT(Rule)\t\t\\\ndo {\t\t\t\t\t\\\n if (yydebug)\t\t\t\t\\\n yy_reduce_print (yyvsp, Rule); \\\n} while (YYID (0))\n\n/* Nonzero means print parse trace. It is left uninitialized so that\n multiple parsers can coexist. */\nint yydebug;\n#else /* !YYDEBUG */\n# define YYDPRINTF(Args)\n# define YY_SYMBOL_PRINT(Title, Type, Value, Location)\n# define YY_STACK_PRINT(Bottom, Top)\n# define YY_REDUCE_PRINT(Rule)\n#endif /* !YYDEBUG */\n\n\n/* YYINITDEPTH -- initial size of the parser's stacks. */\n#ifndef\tYYINITDEPTH\n# define YYINITDEPTH 200\n#endif\n\n/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only\n if the built-in stack extension method is used).\n\n Do not make this value too large; the results are undefined if\n YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)\n evaluated with infinite-precision integer arithmetic. */\n\n#ifndef YYMAXDEPTH\n# define YYMAXDEPTH 10000\n#endif\n\n\f\n\n#if YYERROR_VERBOSE\n\n# ifndef yystrlen\n# if defined __GLIBC__ && defined _STRING_H\n# define yystrlen strlen\n# else\n/* Return the length of YYSTR. */\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic YYSIZE_T\nyystrlen (const char *yystr)\n#else\nstatic YYSIZE_T\nyystrlen (yystr)\n const char *yystr;\n#endif\n{\n YYSIZE_T yylen;\n for (yylen = 0; yystr[yylen]; yylen++)\n continue;\n return yylen;\n}\n# endif\n# endif\n\n# ifndef yystpcpy\n# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE\n# define yystpcpy stpcpy\n# else\n/* Copy YYSRC to YYDEST, returning the address of the terminating '\\0' in\n YYDEST. */\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic char *\nyystpcpy (char *yydest, const char *yysrc)\n#else\nstatic char *\nyystpcpy (yydest, yysrc)\n char *yydest;\n const char *yysrc;\n#endif\n{\n char *yyd = yydest;\n const char *yys = yysrc;\n\n while ((*yyd++ = *yys++) != '\\0')\n continue;\n\n return yyd - 1;\n}\n# endif\n# endif\n\n# ifndef yytnamerr\n/* Copy to YYRES the contents of YYSTR after stripping away unnecessary\n quotes and backslashes, so that it's suitable for yyerror. The\n heuristic is that double-quoting is unnecessary unless the string\n contains an apostrophe, a comma, or backslash (other than\n backslash-backslash). YYSTR is taken from yytname. If YYRES is\n null, do not copy; instead, return the length of what the result\n would have been. */\nstatic YYSIZE_T\nyytnamerr (char *yyres, const char *yystr)\n{\n if (*yystr == '\"')\n {\n YYSIZE_T yyn = 0;\n char const *yyp = yystr;\n\n for (;;)\n\tswitch (*++yyp)\n\t {\n\t case '\\'':\n\t case ',':\n\t goto do_not_strip_quotes;\n\n\t case '\\\\':\n\t if (*++yyp != '\\\\')\n\t goto do_not_strip_quotes;\n\t /* Fall through. */\n\t default:\n\t if (yyres)\n\t yyres[yyn] = *yyp;\n\t yyn++;\n\t break;\n\n\t case '\"':\n\t if (yyres)\n\t yyres[yyn] = '\\0';\n\t return yyn;\n\t }\n do_not_strip_quotes: ;\n }\n\n if (! yyres)\n return yystrlen (yystr);\n\n return yystpcpy (yyres, yystr) - yyres;\n}\n# endif\n\n/* Copy into YYRESULT an error message about the unexpected token\n YYCHAR while in state YYSTATE. Return the number of bytes copied,\n including the terminating null byte. If YYRESULT is null, do not\n copy anything; just return the number of bytes that would be\n copied. As a special case, return 0 if an ordinary \"syntax error\"\n message will do. Return YYSIZE_MAXIMUM if overflow occurs during\n size calculation. */\nstatic YYSIZE_T\nyysyntax_error (char *yyresult, int yystate, int yychar)\n{\n int yyn = yypact[yystate];\n\n if (! (YYPACT_NINF < yyn && yyn <= YYLAST))\n return 0;\n else\n {\n int yytype = YYTRANSLATE (yychar);\n YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);\n YYSIZE_T yysize = yysize0;\n YYSIZE_T yysize1;\n int yysize_overflow = 0;\n enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };\n char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];\n int yyx;\n\n# if 0\n /* This is so xgettext sees the translatable formats that are\n\t constructed on the fly. */\n YY_(\"syntax error, unexpected %s\");\n YY_(\"syntax error, unexpected %s, expecting %s\");\n YY_(\"syntax error, unexpected %s, expecting %s or %s\");\n YY_(\"syntax error, unexpected %s, expecting %s or %s or %s\");\n YY_(\"syntax error, unexpected %s, expecting %s or %s or %s or %s\");\n# endif\n char *yyfmt;\n char const *yyf;\n static char const yyunexpected[] = \"syntax error, unexpected %s\";\n static char const yyexpecting[] = \", expecting %s\";\n static char const yyor[] = \" or %s\";\n char yyformat[sizeof yyunexpected\n\t\t + sizeof yyexpecting - 1\n\t\t + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)\n\t\t * (sizeof yyor - 1))];\n char const *yyprefix = yyexpecting;\n\n /* Start YYX at -YYN if negative to avoid negative indexes in\n\t YYCHECK. */\n int yyxbegin = yyn < 0 ? -yyn : 0;\n\n /* Stay within bounds of both yycheck and yytname. */\n int yychecklim = YYLAST - yyn + 1;\n int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;\n int yycount = 1;\n\n yyarg[0] = yytname[yytype];\n yyfmt = yystpcpy (yyformat, yyunexpected);\n\n for (yyx = yyxbegin; yyx < yyxend; ++yyx)\n\tif (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)\n\t {\n\t if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)\n\t {\n\t\tyycount = 1;\n\t\tyysize = yysize0;\n\t\tyyformat[sizeof yyunexpected - 1] = '\\0';\n\t\tbreak;\n\t }\n\t yyarg[yycount++] = yytname[yyx];\n\t yysize1 = yysize + yytnamerr (0, yytname[yyx]);\n\t yysize_overflow |= (yysize1 < yysize);\n\t yysize = yysize1;\n\t yyfmt = yystpcpy (yyfmt, yyprefix);\n\t yyprefix = yyor;\n\t }\n\n yyf = YY_(yyformat);\n yysize1 = yysize + yystrlen (yyf);\n yysize_overflow |= (yysize1 < yysize);\n yysize = yysize1;\n\n if (yysize_overflow)\n\treturn YYSIZE_MAXIMUM;\n\n if (yyresult)\n\t{\n\t /* Avoid sprintf, as that infringes on the user's name space.\n\t Don't have undefined behavior even if the translation\n\t produced a string with the wrong number of \"%s\"s. */\n\t char *yyp = yyresult;\n\t int yyi = 0;\n\t while ((*yyp = *yyf) != '\\0')\n\t {\n\t if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)\n\t\t{\n\t\t yyp += yytnamerr (yyp, yyarg[yyi++]);\n\t\t yyf += 2;\n\t\t}\n\t else\n\t\t{\n\t\t yyp++;\n\t\t yyf++;\n\t\t}\n\t }\n\t}\n return yysize;\n }\n}\n#endif /* YYERROR_VERBOSE */\n\f\n\n/*-----------------------------------------------.\n| Release the memory associated to this symbol. |\n`-----------------------------------------------*/\n\n/*ARGSUSED*/\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nstatic void\nyydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)\n#else\nstatic void\nyydestruct (yymsg, yytype, yyvaluep)\n const char *yymsg;\n int yytype;\n YYSTYPE *yyvaluep;\n#endif\n{\n YYUSE (yyvaluep);\n\n if (!yymsg)\n yymsg = \"Deleting\";\n YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);\n\n switch (yytype)\n {\n\n default:\n\tbreak;\n }\n}\n\f\n\n/* Prevent warnings from -Wmissing-prototypes. */\n\n#ifdef YYPARSE_PARAM\n#if defined __STDC__ || defined __cplusplus\nint yyparse (void *YYPARSE_PARAM);\n#else\nint yyparse ();\n#endif\n#else /* ! YYPARSE_PARAM */\n#if defined __STDC__ || defined __cplusplus\nint yyparse (void);\n#else\nint yyparse ();\n#endif\n#endif /* ! YYPARSE_PARAM */\n\n\n\n/* The look-ahead symbol. */\nint yychar;\n\n/* The semantic value of the look-ahead symbol. */\nYYSTYPE yylval;\n\n/* Number of syntax errors so far. */\nint yynerrs;\n\n\n\n/*----------.\n| yyparse. |\n`----------*/\n\n#ifdef YYPARSE_PARAM\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nint\nyyparse (void *YYPARSE_PARAM)\n#else\nint\nyyparse (YYPARSE_PARAM)\n void *YYPARSE_PARAM;\n#endif\n#else /* ! YYPARSE_PARAM */\n#if (defined __STDC__ || defined __C99__FUNC__ \\\n || defined __cplusplus || defined _MSC_VER)\nint\nyyparse (void)\n#else\nint\nyyparse ()\n\n#endif\n#endif\n{\n \n int yystate;\n int yyn;\n int yyresult;\n /* Number of tokens to shift before error messages enabled. */\n int yyerrstatus;\n /* Look-ahead token as an internal (translated) token number. */\n int yytoken = 0;\n#if YYERROR_VERBOSE\n /* Buffer for error messages, and its allocated size. */\n char yymsgbuf[128];\n char *yymsg = yymsgbuf;\n YYSIZE_T yymsg_alloc = sizeof yymsgbuf;\n#endif\n\n /* Three stacks and their tools:\n `yyss': related to states,\n `yyvs': related to semantic values,\n `yyls': related to locations.\n\n Refer to the stacks thru separate pointers, to allow yyoverflow\n to reallocate them elsewhere. */\n\n /* The state stack. */\n yytype_int16 yyssa[YYINITDEPTH];\n yytype_int16 *yyss = yyssa;\n yytype_int16 *yyssp;\n\n /* The semantic value stack. */\n YYSTYPE yyvsa[YYINITDEPTH];\n YYSTYPE *yyvs = yyvsa;\n YYSTYPE *yyvsp;\n\n\n\n#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))\n\n YYSIZE_T yystacksize = YYINITDEPTH;\n\n /* The variables used to return semantic value and location from the\n action routines. */\n YYSTYPE yyval;\n\n\n /* The number of symbols on the RHS of the reduced rule.\n Keep to zero when no symbol should be popped. */\n int yylen = 0;\n\n YYDPRINTF ((stderr, \"Starting parse\\n\"));\n\n yystate = 0;\n yyerrstatus = 0;\n yynerrs = 0;\n yychar = YYEMPTY;\t\t/* Cause a token to be read. */\n\n /* Initialize stack pointers.\n Waste one element of value and location stack\n so that they stay on the same level as the state stack.\n The wasted elements are never initialized. */\n\n yyssp = yyss;\n yyvsp = yyvs;\n\n goto yysetstate;\n\n/*------------------------------------------------------------.\n| yynewstate -- Push a new state, which is found in yystate. |\n`------------------------------------------------------------*/\n yynewstate:\n /* In all cases, when you get here, the value and location stacks\n have just been pushed. So pushing a state here evens the stacks. */\n yyssp++;\n\n yysetstate:\n *yyssp = yystate;\n\n if (yyss + yystacksize - 1 <= yyssp)\n {\n /* Get the current used size of the three stacks, in elements. */\n YYSIZE_T yysize = yyssp - yyss + 1;\n\n#ifdef yyoverflow\n {\n\t/* Give user a chance to reallocate the stack. Use copies of\n\t these so that the &'s don't force the real ones into\n\t memory. */\n\tYYSTYPE *yyvs1 = yyvs;\n\tyytype_int16 *yyss1 = yyss;\n\n\n\t/* Each stack pointer address is followed by the size of the\n\t data in use in that stack, in bytes. This used to be a\n\t conditional around just the two extra args, but that might\n\t be undefined if yyoverflow is a macro. */\n\tyyoverflow (YY_(\"memory exhausted\"),\n\t\t &yyss1, yysize * sizeof (*yyssp),\n\t\t &yyvs1, yysize * sizeof (*yyvsp),\n\n\t\t &yystacksize);\n\n\tyyss = yyss1;\n\tyyvs = yyvs1;\n }\n#else /* no yyoverflow */\n# ifndef YYSTACK_RELOCATE\n goto yyexhaustedlab;\n# else\n /* Extend the stack our own way. */\n if (YYMAXDEPTH <= yystacksize)\n\tgoto yyexhaustedlab;\n yystacksize *= 2;\n if (YYMAXDEPTH < yystacksize)\n\tyystacksize = YYMAXDEPTH;\n\n {\n\tyytype_int16 *yyss1 = yyss;\n\tunion yyalloc *yyptr =\n\t (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));\n\tif (! yyptr)\n\t goto yyexhaustedlab;\n\tYYSTACK_RELOCATE (yyss);\n\tYYSTACK_RELOCATE (yyvs);\n\n# undef YYSTACK_RELOCATE\n\tif (yyss1 != yyssa)\n\t YYSTACK_FREE (yyss1);\n }\n# endif\n#endif /* no yyoverflow */\n\n yyssp = yyss + yysize - 1;\n yyvsp = yyvs + yysize - 1;\n\n\n YYDPRINTF ((stderr, \"Stack size increased to %lu\\n\",\n\t\t (unsigned long int) yystacksize));\n\n if (yyss + yystacksize - 1 <= yyssp)\n\tYYABORT;\n }\n\n YYDPRINTF ((stderr, \"Entering state %d\\n\", yystate));\n\n goto yybackup;\n\n/*-----------.\n| yybackup. |\n`-----------*/\nyybackup:\n\n /* Do appropriate processing given the current state. Read a\n look-ahead token if we need one and don't already have one. */\n\n /* First try to decide what to do without reference to look-ahead token. */\n yyn = yypact[yystate];\n if (yyn == YYPACT_NINF)\n goto yydefault;\n\n /* Not known => get a look-ahead token if don't already have one. */\n\n /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */\n if (yychar == YYEMPTY)\n {\n YYDPRINTF ((stderr, \"Reading a token: \"));\n yychar = YYLEX;\n }\n\n if (yychar <= YYEOF)\n {\n yychar = yytoken = YYEOF;\n YYDPRINTF ((stderr, \"Now at end of input.\\n\"));\n }\n else\n {\n yytoken = YYTRANSLATE (yychar);\n YY_SYMBOL_PRINT (\"Next token is\", yytoken, &yylval, &yylloc);\n }\n\n /* If the proper action on seeing token YYTOKEN is to reduce or to\n detect an error, take that action. */\n yyn += yytoken;\n if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)\n goto yydefault;\n yyn = yytable[yyn];\n if (yyn <= 0)\n {\n if (yyn == 0 || yyn == YYTABLE_NINF)\n\tgoto yyerrlab;\n yyn = -yyn;\n goto yyreduce;\n }\n\n if (yyn == YYFINAL)\n YYACCEPT;\n\n /* Count tokens shifted since error; after three, turn off error\n status. */\n if (yyerrstatus)\n yyerrstatus--;\n\n /* Shift the look-ahead token. */\n YY_SYMBOL_PRINT (\"Shifting\", yytoken, &yylval, &yylloc);\n\n /* Discard the shifted token unless it is eof. */\n if (yychar != YYEOF)\n yychar = YYEMPTY;\n\n yystate = yyn;\n *++yyvsp = yylval;\n\n goto yynewstate;\n\n\n/*-----------------------------------------------------------.\n| yydefault -- do the default action for the current state. |\n`-----------------------------------------------------------*/\nyydefault:\n yyn = yydefact[yystate];\n if (yyn == 0)\n goto yyerrlab;\n goto yyreduce;\n\n\n/*-----------------------------.\n| yyreduce -- Do a reduction. |\n`-----------------------------*/\nyyreduce:\n /* yyn is the number of a rule to reduce with. */\n yylen = yyr2[yyn];\n\n /* If YYLEN is nonzero, implement the default value of the action:\n `$$ = $1'.\n\n Otherwise, the following line sets YYVAL to garbage.\n This behavior is undocumented and Bison\n users should not rely upon it. Assigning to YYVAL\n unconditionally makes the parser a bit smaller, and it avoids a\n GCC warning that YYVAL may be used uninitialized. */\n yyval = yyvsp[1-yylen];\n\n\n YY_REDUCE_PRINT (yyn);\n switch (yyn)\n {\n case 2:\n#line 1502 \"parser.y\"\n {\n if (!classes) classes = NewHash();\n\t\t Setattr((yyvsp[(1) - (1)].node),\"classes\",classes); \n\t\t Setattr((yyvsp[(1) - (1)].node),\"name\",ModuleName);\n\t\t \n\t\t if ((!module_node) && ModuleName) {\n\t\t module_node = new_node(\"module\");\n\t\t Setattr(module_node,\"name\",ModuleName);\n\t\t }\n\t\t Setattr((yyvsp[(1) - (1)].node),\"module\",module_node);\n\t\t check_extensions();\n\t top = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 3:\n#line 1515 \"parser.y\"\n {\n top = Copy(Getattr((yyvsp[(2) - (3)].p),\"type\"));\n\t\t Delete((yyvsp[(2) - (3)].p));\n }\n break;\n\n case 4:\n#line 1519 \"parser.y\"\n {\n top = 0;\n }\n break;\n\n case 5:\n#line 1522 \"parser.y\"\n {\n top = (yyvsp[(2) - (3)].p);\n }\n break;\n\n case 6:\n#line 1525 \"parser.y\"\n {\n top = 0;\n }\n break;\n\n case 7:\n#line 1528 \"parser.y\"\n {\n top = (yyvsp[(3) - (5)].pl);\n }\n break;\n\n case 8:\n#line 1531 \"parser.y\"\n {\n top = 0;\n }\n break;\n\n case 9:\n#line 1536 \"parser.y\"\n { \n /* add declaration to end of linked list (the declaration isn't always a single declaration, sometimes it is a linked list itself) */\n appendChild((yyvsp[(1) - (2)].node),(yyvsp[(2) - (2)].node));\n (yyval.node) = (yyvsp[(1) - (2)].node);\n }\n break;\n\n case 10:\n#line 1541 \"parser.y\"\n {\n (yyval.node) = new_node(\"top\");\n }\n break;\n\n case 11:\n#line 1546 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 12:\n#line 1547 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 13:\n#line 1548 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 14:\n#line 1549 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 15:\n#line 1550 \"parser.y\"\n {\n (yyval.node) = 0;\n\t\t Swig_error(cparse_file, cparse_line,\"Syntax error in input(1).\\n\");\n\t\t exit(1);\n }\n break;\n\n case 16:\n#line 1556 \"parser.y\"\n { \n if ((yyval.node)) {\n \t\t add_symbols((yyval.node));\n }\n (yyval.node) = (yyvsp[(1) - (1)].node); \n\t }\n break;\n\n case 17:\n#line 1572 \"parser.y\"\n {\n (yyval.node) = 0;\n skip_decl();\n }\n break;\n\n case 18:\n#line 1582 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 19:\n#line 1583 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 20:\n#line 1584 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 21:\n#line 1585 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 22:\n#line 1586 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 23:\n#line 1587 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 24:\n#line 1588 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 25:\n#line 1589 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 26:\n#line 1590 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 27:\n#line 1591 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 28:\n#line 1592 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 29:\n#line 1593 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 30:\n#line 1594 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 31:\n#line 1595 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 32:\n#line 1596 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 33:\n#line 1597 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 34:\n#line 1598 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 35:\n#line 1599 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 36:\n#line 1600 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 37:\n#line 1601 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 38:\n#line 1602 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 39:\n#line 1609 \"parser.y\"\n {\n Node *cls;\n\t String *clsname;\n\t cplus_mode = CPLUS_PUBLIC;\n\t if (!classes) classes = NewHash();\n\t if (!extendhash) extendhash = NewHash();\n\t clsname = make_class_name((yyvsp[(3) - (4)].str));\n\t cls = Getattr(classes,clsname);\n\t if (!cls) {\n\t\t /* No previous definition. Create a new scope */\n\t\t Node *am = Getattr(extendhash,clsname);\n\t\t if (!am) {\n\t\t Swig_symbol_newscope();\n\t\t Swig_symbol_setscopename((yyvsp[(3) - (4)].str));\n\t\t prev_symtab = 0;\n\t\t } else {\n\t\t prev_symtab = Swig_symbol_setscope(Getattr(am,\"symtab\"));\n\t\t }\n\t\t current_class = 0;\n\t } else {\n\t\t /* Previous class definition. Use its symbol table */\n\t\t prev_symtab = Swig_symbol_setscope(Getattr(cls,\"symtab\"));\n\t\t current_class = cls;\n\t\t extendmode = 1;\n\t }\n\t Classprefix = NewString((yyvsp[(3) - (4)].str));\n\t Namespaceprefix= Swig_symbol_qualifiedscopename(0);\n\t Delete(clsname);\n\t }\n break;\n\n case 40:\n#line 1637 \"parser.y\"\n {\n String *clsname;\n\t extendmode = 0;\n (yyval.node) = new_node(\"extend\");\n\t Setattr((yyval.node),\"symtab\",Swig_symbol_popscope());\n\t if (prev_symtab) {\n\t\t Swig_symbol_setscope(prev_symtab);\n\t }\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n clsname = make_class_name((yyvsp[(3) - (7)].str));\n\t Setattr((yyval.node),\"name\",clsname);\n\n\t /* Mark members as extend */\n\n\t tag_nodes((yyvsp[(6) - (7)].node),\"feature:extend\",(char*) \"1\");\n\t if (current_class) {\n\t\t /* We add the extension to the previously defined class */\n\t\t appendChild((yyval.node),(yyvsp[(6) - (7)].node));\n\t\t appendChild(current_class,(yyval.node));\n\t } else {\n\t\t /* We store the extensions in the extensions hash */\n\t\t Node *am = Getattr(extendhash,clsname);\n\t\t if (am) {\n\t\t /* Append the members to the previous extend methods */\n\t\t appendChild(am,(yyvsp[(6) - (7)].node));\n\t\t } else {\n\t\t appendChild((yyval.node),(yyvsp[(6) - (7)].node));\n\t\t Setattr(extendhash,clsname,(yyval.node));\n\t\t }\n\t }\n\t current_class = 0;\n\t Delete(Classprefix);\n\t Delete(clsname);\n\t Classprefix = 0;\n\t prev_symtab = 0;\n\t (yyval.node) = 0;\n\n\t }\n break;\n\n case 41:\n#line 1681 \"parser.y\"\n {\n (yyval.node) = new_node(\"apply\");\n Setattr((yyval.node),\"pattern\",Getattr((yyvsp[(2) - (5)].p),\"pattern\"));\n\t\t appendChild((yyval.node),(yyvsp[(4) - (5)].p));\n }\n break;\n\n case 42:\n#line 1691 \"parser.y\"\n {\n\t\t (yyval.node) = new_node(\"clear\");\n\t\t appendChild((yyval.node),(yyvsp[(2) - (3)].p));\n }\n break;\n\n case 43:\n#line 1702 \"parser.y\"\n {\n\t\t if (((yyvsp[(4) - (5)].dtype).type != T_ERROR) && ((yyvsp[(4) - (5)].dtype).type != T_SYMBOL)) {\n\t\t SwigType *type = NewSwigType((yyvsp[(4) - (5)].dtype).type);\n\t\t (yyval.node) = new_node(\"constant\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (5)].id));\n\t\t Setattr((yyval.node),\"type\",type);\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(4) - (5)].dtype).val);\n\t\t if ((yyvsp[(4) - (5)].dtype).rawval) Setattr((yyval.node),\"rawval\", (yyvsp[(4) - (5)].dtype).rawval);\n\t\t Setattr((yyval.node),\"storage\",\"%constant\");\n\t\t SetFlag((yyval.node),\"feature:immutable\");\n\t\t add_symbols((yyval.node));\n\t\t Delete(type);\n\t\t } else {\n\t\t if ((yyvsp[(4) - (5)].dtype).type == T_ERROR) {\n\t\t Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,\"Unsupported constant value (ignored)\\n\");\n\t\t }\n\t\t (yyval.node) = 0;\n\t\t }\n\n\t }\n break;\n\n case 44:\n#line 1723 \"parser.y\"\n {\n\t\t if (((yyvsp[(4) - (5)].dtype).type != T_ERROR) && ((yyvsp[(4) - (5)].dtype).type != T_SYMBOL)) {\n\t\t SwigType_push((yyvsp[(2) - (5)].type),(yyvsp[(3) - (5)].decl).type);\n\t\t /* Sneaky callback function trick */\n\t\t if (SwigType_isfunction((yyvsp[(2) - (5)].type))) {\n\t\t SwigType_add_pointer((yyvsp[(2) - (5)].type));\n\t\t }\n\t\t (yyval.node) = new_node(\"constant\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (5)].decl).id);\n\t\t Setattr((yyval.node),\"type\",(yyvsp[(2) - (5)].type));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(4) - (5)].dtype).val);\n\t\t if ((yyvsp[(4) - (5)].dtype).rawval) Setattr((yyval.node),\"rawval\", (yyvsp[(4) - (5)].dtype).rawval);\n\t\t Setattr((yyval.node),\"storage\",\"%constant\");\n\t\t SetFlag((yyval.node),\"feature:immutable\");\n\t\t add_symbols((yyval.node));\n\t\t } else {\n\t\t if ((yyvsp[(4) - (5)].dtype).type == T_ERROR) {\n\t\t Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE,cparse_file,cparse_line,\"Unsupported constant value\\n\");\n\t\t }\n\t\t (yyval.node) = 0;\n\t\t }\n }\n break;\n\n case 45:\n#line 1745 \"parser.y\"\n {\n\t\t Swig_warning(WARN_PARSE_BAD_VALUE,cparse_file,cparse_line,\"Bad constant value (ignored).\\n\");\n\t\t (yyval.node) = 0;\n\t }\n break;\n\n case 46:\n#line 1756 \"parser.y\"\n {\n\t\t char temp[64];\n\t\t Replace((yyvsp[(2) - (2)].str),\"$file\",cparse_file, DOH_REPLACE_ANY);\n\t\t sprintf(temp,\"%d\", cparse_line);\n\t\t Replace((yyvsp[(2) - (2)].str),\"$line\",temp,DOH_REPLACE_ANY);\n\t\t Printf(stderr,\"%s\\n\", (yyvsp[(2) - (2)].str));\n\t\t Delete((yyvsp[(2) - (2)].str));\n (yyval.node) = 0;\n\t }\n break;\n\n case 47:\n#line 1765 \"parser.y\"\n {\n\t\t char temp[64];\n\t\t String *s = NewString((yyvsp[(2) - (2)].id));\n\t\t Replace(s,\"$file\",cparse_file, DOH_REPLACE_ANY);\n\t\t sprintf(temp,\"%d\", cparse_line);\n\t\t Replace(s,\"$line\",temp,DOH_REPLACE_ANY);\n\t\t Printf(stderr,\"%s\\n\", s);\n\t\t Delete(s);\n (yyval.node) = 0;\n }\n break;\n\n case 48:\n#line 1784 \"parser.y\"\n {\n skip_balanced('{','}');\n\t\t (yyval.node) = 0;\n\t\t Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, \"%%except is deprecated. Use %%exception instead.\\n\");\n\t }\n break;\n\n case 49:\n#line 1790 \"parser.y\"\n {\n skip_balanced('{','}');\n\t\t (yyval.node) = 0;\n\t\t Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, \"%%except is deprecated. Use %%exception instead.\\n\");\n }\n break;\n\n case 50:\n#line 1796 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n\t\t Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, \"%%except is deprecated. Use %%exception instead.\\n\");\n }\n break;\n\n case 51:\n#line 1801 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n\t\t Swig_warning(WARN_DEPRECATED_EXCEPT,cparse_file, cparse_line, \"%%except is deprecated. Use %%exception instead.\\n\");\n\t }\n break;\n\n case 52:\n#line 1812 \"parser.y\"\n {\t\t \n (yyval.node) = NewHash();\n Setattr((yyval.node),\"value\",(yyvsp[(1) - (4)].id));\n\t\t Setattr((yyval.node),\"type\",Getattr((yyvsp[(3) - (4)].p),\"type\"));\n }\n break;\n\n case 53:\n#line 1819 \"parser.y\"\n {\n (yyval.node) = NewHash();\n Setattr((yyval.node),\"value\",(yyvsp[(1) - (1)].id));\n }\n break;\n\n case 54:\n#line 1823 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 55:\n#line 1828 \"parser.y\"\n {\n Hash *p = (yyvsp[(5) - (7)].node);\n\t\t (yyval.node) = new_node(\"fragment\");\n\t\t Setattr((yyval.node),\"value\",Getattr((yyvsp[(3) - (7)].node),\"value\"));\n\t\t Setattr((yyval.node),\"type\",Getattr((yyvsp[(3) - (7)].node),\"type\"));\n\t\t Setattr((yyval.node),\"section\",Getattr(p,\"name\"));\n\t\t Setattr((yyval.node),\"kwargs\",nextSibling(p));\n\t\t Setattr((yyval.node),\"code\",(yyvsp[(7) - (7)].str));\n }\n break;\n\n case 56:\n#line 1837 \"parser.y\"\n {\n\t\t Hash *p = (yyvsp[(5) - (7)].node);\n\t\t String *code;\n skip_balanced('{','}');\n\t\t (yyval.node) = new_node(\"fragment\");\n\t\t Setattr((yyval.node),\"value\",Getattr((yyvsp[(3) - (7)].node),\"value\"));\n\t\t Setattr((yyval.node),\"type\",Getattr((yyvsp[(3) - (7)].node),\"type\"));\n\t\t Setattr((yyval.node),\"section\",Getattr(p,\"name\"));\n\t\t Setattr((yyval.node),\"kwargs\",nextSibling(p));\n\t\t Delitem(scanner_ccode,0);\n\t\t Delitem(scanner_ccode,DOH_END);\n\t\t code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n }\n break;\n\n case 57:\n#line 1852 \"parser.y\"\n {\n\t\t (yyval.node) = new_node(\"fragment\");\n\t\t Setattr((yyval.node),\"value\",Getattr((yyvsp[(3) - (5)].node),\"value\"));\n\t\t Setattr((yyval.node),\"type\",Getattr((yyvsp[(3) - (5)].node),\"type\"));\n\t\t Setattr((yyval.node),\"emitonly\",\"1\");\n\t\t }\n break;\n\n case 58:\n#line 1865 \"parser.y\"\n {\n (yyvsp[(1) - (4)].loc).filename = Copy(cparse_file);\n\t\t (yyvsp[(1) - (4)].loc).line = cparse_line;\n\t\t scanner_set_location(NewString((yyvsp[(3) - (4)].id)),1);\n }\n break;\n\n case 59:\n#line 1869 \"parser.y\"\n {\n String *mname = 0;\n (yyval.node) = (yyvsp[(6) - (7)].node);\n\t\t scanner_set_location((yyvsp[(1) - (7)].loc).filename,(yyvsp[(1) - (7)].loc).line);\n\t\t if (strcmp((yyvsp[(1) - (7)].loc).type,\"include\") == 0) set_nodeType((yyval.node),\"include\");\n\t\t if (strcmp((yyvsp[(1) - (7)].loc).type,\"import\") == 0) {\n\t\t mname = (yyvsp[(2) - (7)].node) ? Getattr((yyvsp[(2) - (7)].node),\"module\") : 0;\n\t\t set_nodeType((yyval.node),\"import\");\n\t\t if (import_mode) --import_mode;\n\t\t }\n\t\t \n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (7)].id));\n\t\t /* Search for the module (if any) */\n\t\t {\n\t\t\t Node *n = firstChild((yyval.node));\n\t\t\t while (n) {\n\t\t\t if (Strcmp(nodeType(n),\"module\") == 0) {\n\t\t\t if (mname) {\n\t\t\t\t Setattr(n,\"name\", mname);\n\t\t\t\t mname = 0;\n\t\t\t\t }\n\t\t\t\t Setattr((yyval.node),\"module\",Getattr(n,\"name\"));\n\t\t\t\t break;\n\t\t\t }\n\t\t\t n = nextSibling(n);\n\t\t\t }\n\t\t\t if (mname) {\n\t\t\t /* There is no module node in the import\n\t\t\t node, ie, you imported a .h file\n\t\t\t directly. We are forced then to create\n\t\t\t a new import node with a module node.\n\t\t\t */\t\t\t \n\t\t\t Node *nint = new_node(\"import\");\n\t\t\t Node *mnode = new_node(\"module\");\n\t\t\t Setattr(mnode,\"name\", mname);\n\t\t\t appendChild(nint,mnode);\n\t\t\t Delete(mnode);\n\t\t\t appendChild(nint,firstChild((yyval.node)));\n\t\t\t (yyval.node) = nint;\n\t\t\t Setattr((yyval.node),\"module\",mname);\n\t\t\t }\n\t\t }\n\t\t Setattr((yyval.node),\"options\",(yyvsp[(2) - (7)].node));\n }\n break;\n\n case 60:\n#line 1915 \"parser.y\"\n { (yyval.loc).type = (char *) \"include\"; }\n break;\n\n case 61:\n#line 1916 \"parser.y\"\n { (yyval.loc).type = (char *) \"import\"; ++import_mode;}\n break;\n\n case 62:\n#line 1923 \"parser.y\"\n {\n String *cpps;\n\t\t if (Namespaceprefix) {\n\t\t Swig_error(cparse_file, cparse_start_line, \"%%inline directive inside a namespace is disallowed.\\n\");\n\n\t\t (yyval.node) = 0;\n\t\t } else {\n\t\t (yyval.node) = new_node(\"insert\");\n\t\t Setattr((yyval.node),\"code\",(yyvsp[(2) - (2)].str));\n\t\t /* Need to run through the preprocessor */\n\t\t Setline((yyvsp[(2) - (2)].str),cparse_start_line);\n\t\t Setfile((yyvsp[(2) - (2)].str),cparse_file);\n\t\t Seek((yyvsp[(2) - (2)].str),0,SEEK_SET);\n\t\t cpps = Preprocessor_parse((yyvsp[(2) - (2)].str));\n\t\t start_inline(Char(cpps), cparse_start_line);\n\t\t Delete((yyvsp[(2) - (2)].str));\n\t\t Delete(cpps);\n\t\t }\n\t\t \n\t }\n break;\n\n case 63:\n#line 1943 \"parser.y\"\n {\n String *cpps;\n\t\t int start_line = cparse_line;\n\t\t skip_balanced('{','}');\n\t\t if (Namespaceprefix) {\n\t\t Swig_error(cparse_file, cparse_start_line, \"%%inline directive inside a namespace is disallowed.\\n\");\n\t\t \n\t\t (yyval.node) = 0;\n\t\t } else {\n\t\t String *code;\n (yyval.node) = new_node(\"insert\");\n\t\t Delitem(scanner_ccode,0);\n\t\t Delitem(scanner_ccode,DOH_END);\n\t\t code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\", code);\n\t\t Delete(code);\t\t \n\t\t cpps=Copy(scanner_ccode);\n\t\t start_inline(Char(cpps), start_line);\n\t\t Delete(cpps);\n\t\t }\n }\n break;\n\n case 64:\n#line 1974 \"parser.y\"\n {\n (yyval.node) = new_node(\"insert\");\n\t\t Setattr((yyval.node),\"code\",(yyvsp[(1) - (1)].str));\n\t }\n break;\n\n case 65:\n#line 1978 \"parser.y\"\n {\n\t\t String *code = NewStringEmpty();\n\t\t (yyval.node) = new_node(\"insert\");\n\t\t Setattr((yyval.node),\"section\",(yyvsp[(3) - (5)].id));\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t if (Swig_insert_file((yyvsp[(5) - (5)].id),code) < 0) {\n\t\t Swig_error(cparse_file, cparse_line, \"Couldn't find '%s'.\\n\", (yyvsp[(5) - (5)].id));\n\t\t (yyval.node) = 0;\n\t\t } \n }\n break;\n\n case 66:\n#line 1988 \"parser.y\"\n {\n\t\t (yyval.node) = new_node(\"insert\");\n\t\t Setattr((yyval.node),\"section\",(yyvsp[(3) - (5)].id));\n\t\t Setattr((yyval.node),\"code\",(yyvsp[(5) - (5)].str));\n }\n break;\n\n case 67:\n#line 1993 \"parser.y\"\n {\n\t\t String *code;\n skip_balanced('{','}');\n\t\t (yyval.node) = new_node(\"insert\");\n\t\t Setattr((yyval.node),\"section\",(yyvsp[(3) - (5)].id));\n\t\t Delitem(scanner_ccode,0);\n\t\t Delitem(scanner_ccode,DOH_END);\n\t\t code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\", code);\n\t\t Delete(code);\n\t }\n break;\n\n case 68:\n#line 2011 \"parser.y\"\n {\n (yyval.node) = new_node(\"module\");\n\t\t if ((yyvsp[(2) - (3)].node)) {\n\t\t Setattr((yyval.node),\"options\",(yyvsp[(2) - (3)].node));\n\t\t if (Getattr((yyvsp[(2) - (3)].node),\"directors\")) {\n\t\t Wrapper_director_mode_set(1);\n\t\t } \n\t\t if (Getattr((yyvsp[(2) - (3)].node),\"templatereduce\")) {\n\t\t template_reduce = 1;\n\t\t }\n\t\t if (Getattr((yyvsp[(2) - (3)].node),\"notemplatereduce\")) {\n\t\t template_reduce = 0;\n\t\t }\n\t\t }\n\t\t if (!ModuleName) ModuleName = NewString((yyvsp[(3) - (3)].id));\n\t\t if (!import_mode) {\n\t\t /* first module included, we apply global\n\t\t ModuleName, which can be modify by -module */\n\t\t String *mname = Copy(ModuleName);\n\t\t Setattr((yyval.node),\"name\",mname);\n\t\t Delete(mname);\n\t\t } else { \n\t\t /* import mode, we just pass the idstring */\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (3)].id)); \n\t\t }\t\t \n\t\t if (!module_node) module_node = (yyval.node);\n\t }\n break;\n\n case 69:\n#line 2045 \"parser.y\"\n {\n Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, \"%%name is deprecated. Use %%rename instead.\\n\");\n\t\t Delete(yyrename);\n yyrename = NewString((yyvsp[(3) - (4)].id));\n\t\t (yyval.node) = 0;\n }\n break;\n\n case 70:\n#line 2051 \"parser.y\"\n {\n\t\t Swig_warning(WARN_DEPRECATED_NAME,cparse_file,cparse_line, \"%%name is deprecated. Use %%rename instead.\\n\");\n\t\t (yyval.node) = 0;\n\t\t Swig_error(cparse_file,cparse_line,\"Missing argument to %%name directive.\\n\");\n\t }\n break;\n\n case 71:\n#line 2064 \"parser.y\"\n {\n (yyval.node) = new_node(\"native\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (7)].id));\n\t\t Setattr((yyval.node),\"wrap:name\",(yyvsp[(6) - (7)].id));\n\t add_symbols((yyval.node));\n\t }\n break;\n\n case 72:\n#line 2070 \"parser.y\"\n {\n\t\t if (!SwigType_isfunction((yyvsp[(7) - (8)].decl).type)) {\n\t\t Swig_error(cparse_file,cparse_line,\"%%native declaration '%s' is not a function.\\n\", (yyvsp[(7) - (8)].decl).id);\n\t\t (yyval.node) = 0;\n\t\t } else {\n\t\t Delete(SwigType_pop_function((yyvsp[(7) - (8)].decl).type));\n\t\t /* Need check for function here */\n\t\t SwigType_push((yyvsp[(6) - (8)].type),(yyvsp[(7) - (8)].decl).type);\n\t\t (yyval.node) = new_node(\"native\");\n\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (8)].id));\n\t\t Setattr((yyval.node),\"wrap:name\",(yyvsp[(7) - (8)].decl).id);\n\t\t Setattr((yyval.node),\"type\",(yyvsp[(6) - (8)].type));\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(7) - (8)].decl).parms);\n\t\t Setattr((yyval.node),\"decl\",(yyvsp[(7) - (8)].decl).type);\n\t\t }\n\t add_symbols((yyval.node));\n\t }\n break;\n\n case 73:\n#line 2096 \"parser.y\"\n {\n (yyval.node) = new_node(\"pragma\");\n\t\t Setattr((yyval.node),\"lang\",(yyvsp[(2) - (5)].id));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (5)].id));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(5) - (5)].str));\n\t }\n break;\n\n case 74:\n#line 2102 \"parser.y\"\n {\n\t\t(yyval.node) = new_node(\"pragma\");\n\t\tSetattr((yyval.node),\"lang\",(yyvsp[(2) - (3)].id));\n\t\tSetattr((yyval.node),\"name\",(yyvsp[(3) - (3)].id));\n\t }\n break;\n\n case 75:\n#line 2109 \"parser.y\"\n { (yyval.str) = NewString((yyvsp[(1) - (1)].id)); }\n break;\n\n case 76:\n#line 2110 \"parser.y\"\n { (yyval.str) = (yyvsp[(1) - (1)].str); }\n break;\n\n case 77:\n#line 2113 \"parser.y\"\n { (yyval.id) = (yyvsp[(2) - (3)].id); }\n break;\n\n case 78:\n#line 2114 \"parser.y\"\n { (yyval.id) = (char *) \"swig\"; }\n break;\n\n case 79:\n#line 2122 \"parser.y\"\n {\n SwigType *t = (yyvsp[(2) - (4)].decl).type;\n\t\tHash *kws = NewHash();\n\t\tString *fixname;\n\t\tfixname = feature_identifier_fix((yyvsp[(2) - (4)].decl).id);\n\t\tSetattr(kws,\"name\",(yyvsp[(3) - (4)].id));\n\t\tif (!Len(t)) t = 0;\n\t\t/* Special declarator check */\n\t\tif (t) {\n\t\t if (SwigType_isfunction(t)) {\n\t\t SwigType *decl = SwigType_pop_function(t);\n\t\t if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",fixname);\n\t\t if ((yyvsp[(1) - (4)].ivalue)) {\n\t\t\tSwig_name_rename_add(Namespaceprefix, nname,decl,kws,(yyvsp[(2) - (4)].decl).parms);\n\t\t } else {\n\t\t\tSwig_name_namewarn_add(Namespaceprefix,nname,decl,kws);\n\t\t }\n\t\t Delete(nname);\n\t\t } else {\n\t\t if ((yyvsp[(1) - (4)].ivalue)) {\n\t\t\tSwig_name_rename_add(Namespaceprefix,(fixname),decl,kws,(yyvsp[(2) - (4)].decl).parms);\n\t\t } else {\n\t\t\tSwig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws);\n\t\t }\n\t\t }\n\t\t Delete(decl);\n\t\t } else if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",fixname);\n\t\t if ((yyvsp[(1) - (4)].ivalue)) {\n\t\t Swig_name_rename_add(Namespaceprefix,(nname),0,kws,(yyvsp[(2) - (4)].decl).parms);\n\t\t } else {\n\t\t Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws);\n\t\t }\n\t\t Delete(nname);\n\t\t }\n\t\t} else {\n\t\t if ((yyvsp[(1) - (4)].ivalue)) {\n\t\t Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,(yyvsp[(2) - (4)].decl).parms);\n\t\t } else {\n\t\t Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws);\n\t\t }\n\t\t}\n (yyval.node) = 0;\n\t\tscanner_clear_rename();\n }\n break;\n\n case 80:\n#line 2168 \"parser.y\"\n {\n\t\tString *fixname;\n\t\tHash *kws = (yyvsp[(3) - (7)].node);\n\t\tSwigType *t = (yyvsp[(5) - (7)].decl).type;\n\t\tfixname = feature_identifier_fix((yyvsp[(5) - (7)].decl).id);\n\t\tif (!Len(t)) t = 0;\n\t\t/* Special declarator check */\n\t\tif (t) {\n\t\t if ((yyvsp[(6) - (7)].dtype).qualifier) SwigType_push(t,(yyvsp[(6) - (7)].dtype).qualifier);\n\t\t if (SwigType_isfunction(t)) {\n\t\t SwigType *decl = SwigType_pop_function(t);\n\t\t if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",fixname);\n\t\t if ((yyvsp[(1) - (7)].ivalue)) {\n\t\t\tSwig_name_rename_add(Namespaceprefix, nname,decl,kws,(yyvsp[(5) - (7)].decl).parms);\n\t\t } else {\n\t\t\tSwig_name_namewarn_add(Namespaceprefix,nname,decl,kws);\n\t\t }\n\t\t Delete(nname);\n\t\t } else {\n\t\t if ((yyvsp[(1) - (7)].ivalue)) {\n\t\t\tSwig_name_rename_add(Namespaceprefix,(fixname),decl,kws,(yyvsp[(5) - (7)].decl).parms);\n\t\t } else {\n\t\t\tSwig_name_namewarn_add(Namespaceprefix,(fixname),decl,kws);\n\t\t }\n\t\t }\n\t\t Delete(decl);\n\t\t } else if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",fixname);\n\t\t if ((yyvsp[(1) - (7)].ivalue)) {\n\t\t Swig_name_rename_add(Namespaceprefix,(nname),0,kws,(yyvsp[(5) - (7)].decl).parms);\n\t\t } else {\n\t\t Swig_name_namewarn_add(Namespaceprefix,(nname),0,kws);\n\t\t }\n\t\t Delete(nname);\n\t\t }\n\t\t} else {\n\t\t if ((yyvsp[(1) - (7)].ivalue)) {\n\t\t Swig_name_rename_add(Namespaceprefix,(fixname),0,kws,(yyvsp[(5) - (7)].decl).parms);\n\t\t } else {\n\t\t Swig_name_namewarn_add(Namespaceprefix,(fixname),0,kws);\n\t\t }\n\t\t}\n (yyval.node) = 0;\n\t\tscanner_clear_rename();\n }\n break;\n\n case 81:\n#line 2214 \"parser.y\"\n {\n\t\tif ((yyvsp[(1) - (6)].ivalue)) {\n\t\t Swig_name_rename_add(Namespaceprefix,(yyvsp[(5) - (6)].id),0,(yyvsp[(3) - (6)].node),0);\n\t\t} else {\n\t\t Swig_name_namewarn_add(Namespaceprefix,(yyvsp[(5) - (6)].id),0,(yyvsp[(3) - (6)].node));\n\t\t}\n\t\t(yyval.node) = 0;\n\t\tscanner_clear_rename();\n }\n break;\n\n case 82:\n#line 2225 \"parser.y\"\n {\n\t\t (yyval.ivalue) = 1;\n }\n break;\n\n case 83:\n#line 2228 \"parser.y\"\n {\n (yyval.ivalue) = 0;\n }\n break;\n\n case 84:\n#line 2255 \"parser.y\"\n {\n String *val = (yyvsp[(7) - (7)].str) ? NewString((yyvsp[(7) - (7)].str)) : NewString(\"1\");\n new_feature((yyvsp[(3) - (7)].id), val, 0, (yyvsp[(5) - (7)].decl).id, (yyvsp[(5) - (7)].decl).type, (yyvsp[(5) - (7)].decl).parms, (yyvsp[(6) - (7)].dtype).qualifier);\n (yyval.node) = 0;\n }\n break;\n\n case 85:\n#line 2260 \"parser.y\"\n {\n String *val = Len((yyvsp[(5) - (9)].id)) ? NewString((yyvsp[(5) - (9)].id)) : 0;\n new_feature((yyvsp[(3) - (9)].id), val, 0, (yyvsp[(7) - (9)].decl).id, (yyvsp[(7) - (9)].decl).type, (yyvsp[(7) - (9)].decl).parms, (yyvsp[(8) - (9)].dtype).qualifier);\n (yyval.node) = 0;\n }\n break;\n\n case 86:\n#line 2265 \"parser.y\"\n {\n String *val = (yyvsp[(8) - (8)].str) ? NewString((yyvsp[(8) - (8)].str)) : NewString(\"1\");\n new_feature((yyvsp[(3) - (8)].id), val, (yyvsp[(4) - (8)].node), (yyvsp[(6) - (8)].decl).id, (yyvsp[(6) - (8)].decl).type, (yyvsp[(6) - (8)].decl).parms, (yyvsp[(7) - (8)].dtype).qualifier);\n (yyval.node) = 0;\n }\n break;\n\n case 87:\n#line 2270 \"parser.y\"\n {\n String *val = Len((yyvsp[(5) - (10)].id)) ? NewString((yyvsp[(5) - (10)].id)) : 0;\n new_feature((yyvsp[(3) - (10)].id), val, (yyvsp[(6) - (10)].node), (yyvsp[(8) - (10)].decl).id, (yyvsp[(8) - (10)].decl).type, (yyvsp[(8) - (10)].decl).parms, (yyvsp[(9) - (10)].dtype).qualifier);\n (yyval.node) = 0;\n }\n break;\n\n case 88:\n#line 2277 \"parser.y\"\n {\n String *val = (yyvsp[(5) - (5)].str) ? NewString((yyvsp[(5) - (5)].str)) : NewString(\"1\");\n new_feature((yyvsp[(3) - (5)].id), val, 0, 0, 0, 0, 0);\n (yyval.node) = 0;\n }\n break;\n\n case 89:\n#line 2282 \"parser.y\"\n {\n String *val = Len((yyvsp[(5) - (7)].id)) ? NewString((yyvsp[(5) - (7)].id)) : 0;\n new_feature((yyvsp[(3) - (7)].id), val, 0, 0, 0, 0, 0);\n (yyval.node) = 0;\n }\n break;\n\n case 90:\n#line 2287 \"parser.y\"\n {\n String *val = (yyvsp[(6) - (6)].str) ? NewString((yyvsp[(6) - (6)].str)) : NewString(\"1\");\n new_feature((yyvsp[(3) - (6)].id), val, (yyvsp[(4) - (6)].node), 0, 0, 0, 0);\n (yyval.node) = 0;\n }\n break;\n\n case 91:\n#line 2292 \"parser.y\"\n {\n String *val = Len((yyvsp[(5) - (8)].id)) ? NewString((yyvsp[(5) - (8)].id)) : 0;\n new_feature((yyvsp[(3) - (8)].id), val, (yyvsp[(6) - (8)].node), 0, 0, 0, 0);\n (yyval.node) = 0;\n }\n break;\n\n case 92:\n#line 2299 \"parser.y\"\n { (yyval.str) = (yyvsp[(1) - (1)].str); }\n break;\n\n case 93:\n#line 2300 \"parser.y\"\n { (yyval.str) = 0; }\n break;\n\n case 94:\n#line 2301 \"parser.y\"\n { (yyval.str) = (yyvsp[(3) - (5)].pl); }\n break;\n\n case 95:\n#line 2304 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (4)].id));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(4) - (4)].id));\n }\n break;\n\n case 96:\n#line 2309 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (5)].id));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(4) - (5)].id));\n set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node));\n }\n break;\n\n case 97:\n#line 2319 \"parser.y\"\n {\n Parm *val;\n\t\t String *name;\n\t\t SwigType *t;\n\t\t if (Namespaceprefix) name = NewStringf(\"%s::%s\", Namespaceprefix, (yyvsp[(5) - (7)].decl).id);\n\t\t else name = NewString((yyvsp[(5) - (7)].decl).id);\n\t\t val = (yyvsp[(3) - (7)].pl);\n\t\t if ((yyvsp[(5) - (7)].decl).parms) {\n\t\t Setmeta(val,\"parms\",(yyvsp[(5) - (7)].decl).parms);\n\t\t }\n\t\t t = (yyvsp[(5) - (7)].decl).type;\n\t\t if (!Len(t)) t = 0;\n\t\t if (t) {\n\t\t if ((yyvsp[(6) - (7)].dtype).qualifier) SwigType_push(t,(yyvsp[(6) - (7)].dtype).qualifier);\n\t\t if (SwigType_isfunction(t)) {\n\t\t SwigType *decl = SwigType_pop_function(t);\n\t\t if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",name);\n\t\t Swig_feature_set(Swig_cparse_features(), nname, decl, \"feature:varargs\", val, 0);\n\t\t Delete(nname);\n\t\t } else {\n\t\t Swig_feature_set(Swig_cparse_features(), name, decl, \"feature:varargs\", val, 0);\n\t\t }\n\t\t Delete(decl);\n\t\t } else if (SwigType_ispointer(t)) {\n\t\t String *nname = NewStringf(\"*%s\",name);\n\t\t Swig_feature_set(Swig_cparse_features(),nname,0,\"feature:varargs\",val, 0);\n\t\t Delete(nname);\n\t\t }\n\t\t } else {\n\t\t Swig_feature_set(Swig_cparse_features(),name,0,\"feature:varargs\",val, 0);\n\t\t }\n\t\t Delete(name);\n\t\t (yyval.node) = 0;\n }\n break;\n\n case 98:\n#line 2355 \"parser.y\"\n { (yyval.pl) = (yyvsp[(1) - (1)].pl); }\n break;\n\n case 99:\n#line 2356 \"parser.y\"\n { \n\t\t int i;\n\t\t int n;\n\t\t Parm *p;\n\t\t n = atoi(Char((yyvsp[(1) - (3)].dtype).val));\n\t\t if (n <= 0) {\n\t\t Swig_error(cparse_file, cparse_line,\"Argument count in %%varargs must be positive.\\n\");\n\t\t (yyval.pl) = 0;\n\t\t } else {\n\t\t (yyval.pl) = Copy((yyvsp[(3) - (3)].p));\n\t\t Setattr((yyval.pl),\"name\",\"VARARGS_SENTINEL\");\n\t\t for (i = 0; i < n; i++) {\n\t\t p = Copy((yyvsp[(3) - (3)].p));\n\t\t set_nextSibling(p,(yyval.pl));\n\t\t Delete((yyval.pl));\n\t\t (yyval.pl) = p;\n\t\t }\n\t\t }\n }\n break;\n\n case 100:\n#line 2386 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n\t\t if ((yyvsp[(3) - (6)].tmap).op) {\n\t\t String *code = 0;\n\t\t (yyval.node) = new_node(\"typemap\");\n\t\t Setattr((yyval.node),\"method\",(yyvsp[(3) - (6)].tmap).op);\n\t\t if ((yyvsp[(3) - (6)].tmap).kwargs) {\n\t\t Parm *kw = (yyvsp[(3) - (6)].tmap).kwargs;\n\t\t /* check for 'noblock' option, which remove the block braces */\n\t\t while (kw) {\n\t\t\t String *name = Getattr(kw,\"name\");\n\t\t\t if (name && (Cmp(name,\"noblock\") == 0)) {\n\t\t\t char *cstr = Char((yyvsp[(6) - (6)].str));\n\t\t\t size_t len = Len((yyvsp[(6) - (6)].str));\n\t\t\t if (len && cstr[0] == '{') {\n\t\t\t --len; ++cstr; \n\t\t\t if (len && cstr[len - 1] == '}') { --len; }\n\t\t\t /* we now remove the extra spaces */\n\t\t\t while (len && isspace((int)cstr[0])) { --len; ++cstr; }\n\t\t\t while (len && isspace((int)cstr[len - 1])) { --len; }\n\t\t\t code = NewStringWithSize(cstr, len);\n\t\t\t break;\n\t\t\t }\n\t\t\t }\n\t\t\t kw = nextSibling(kw);\n\t\t }\n\t\t Setattr((yyval.node),\"kwargs\", (yyvsp[(3) - (6)].tmap).kwargs);\n\t\t }\n\t\t code = code ? code : NewString((yyvsp[(6) - (6)].str));\n\t\t Setattr((yyval.node),\"code\", code);\n\t\t Delete(code);\n\t\t appendChild((yyval.node),(yyvsp[(5) - (6)].p));\n\t\t }\n\t }\n break;\n\n case 101:\n#line 2420 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n\t\t if ((yyvsp[(3) - (6)].tmap).op) {\n\t\t (yyval.node) = new_node(\"typemap\");\n\t\t Setattr((yyval.node),\"method\",(yyvsp[(3) - (6)].tmap).op);\n\t\t appendChild((yyval.node),(yyvsp[(5) - (6)].p));\n\t\t }\n\t }\n break;\n\n case 102:\n#line 2428 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n\t\t if ((yyvsp[(3) - (8)].tmap).op) {\n\t\t (yyval.node) = new_node(\"typemapcopy\");\n\t\t Setattr((yyval.node),\"method\",(yyvsp[(3) - (8)].tmap).op);\n\t\t Setattr((yyval.node),\"pattern\", Getattr((yyvsp[(7) - (8)].p),\"pattern\"));\n\t\t appendChild((yyval.node),(yyvsp[(5) - (8)].p));\n\t\t }\n\t }\n break;\n\n case 103:\n#line 2441 \"parser.y\"\n {\n\t\t Hash *p;\n\t\t String *name;\n\t\t p = nextSibling((yyvsp[(1) - (1)].node));\n\t\t if (p && (!Getattr(p,\"value\"))) {\n \t\t /* this is the deprecated two argument typemap form */\n \t\t Swig_warning(WARN_DEPRECATED_TYPEMAP_LANG,cparse_file, cparse_line,\n\t\t\t\t\"Specifying the language name in %%typemap is deprecated - use #ifdef SWIG instead.\\n\");\n\t\t /* two argument typemap form */\n\t\t name = Getattr((yyvsp[(1) - (1)].node),\"name\");\n\t\t if (!name || (Strcmp(name,typemap_lang))) {\n\t\t (yyval.tmap).op = 0;\n\t\t (yyval.tmap).kwargs = 0;\n\t\t } else {\n\t\t (yyval.tmap).op = Getattr(p,\"name\");\n\t\t (yyval.tmap).kwargs = nextSibling(p);\n\t\t }\n\t\t } else {\n\t\t /* one-argument typemap-form */\n\t\t (yyval.tmap).op = Getattr((yyvsp[(1) - (1)].node),\"name\");\n\t\t (yyval.tmap).kwargs = p;\n\t\t }\n }\n break;\n\n case 104:\n#line 2466 \"parser.y\"\n {\n (yyval.p) = (yyvsp[(1) - (2)].p);\n\t\t set_nextSibling((yyval.p),(yyvsp[(2) - (2)].p));\n\t\t}\n break;\n\n case 105:\n#line 2472 \"parser.y\"\n {\n (yyval.p) = (yyvsp[(2) - (3)].p);\n\t\t set_nextSibling((yyval.p),(yyvsp[(3) - (3)].p));\n }\n break;\n\n case 106:\n#line 2476 \"parser.y\"\n { (yyval.p) = 0;}\n break;\n\n case 107:\n#line 2479 \"parser.y\"\n {\n Parm *parm;\n\t\t SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type);\n\t\t (yyval.p) = new_node(\"typemapitem\");\n\t\t parm = NewParm((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).id);\n\t\t Setattr((yyval.p),\"pattern\",parm);\n\t\t Setattr((yyval.p),\"parms\", (yyvsp[(2) - (2)].decl).parms);\n\t\t Delete(parm);\n\t\t /*\t\t $$ = NewParm($1,$2.id);\n\t\t\t\t Setattr($$,\"parms\",$2.parms); */\n }\n break;\n\n case 108:\n#line 2490 \"parser.y\"\n {\n (yyval.p) = new_node(\"typemapitem\");\n\t\t Setattr((yyval.p),\"pattern\",(yyvsp[(2) - (3)].pl));\n\t\t /*\t\t Setattr($$,\"multitype\",$2); */\n }\n break;\n\n case 109:\n#line 2495 \"parser.y\"\n {\n\t\t (yyval.p) = new_node(\"typemapitem\");\n\t\t Setattr((yyval.p),\"pattern\", (yyvsp[(2) - (6)].pl));\n\t\t /* Setattr($$,\"multitype\",$2); */\n\t\t Setattr((yyval.p),\"parms\",(yyvsp[(5) - (6)].pl));\n }\n break;\n\n case 110:\n#line 2507 \"parser.y\"\n {\n (yyval.node) = new_node(\"types\");\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(3) - (5)].pl));\n }\n break;\n\n case 111:\n#line 2517 \"parser.y\"\n {\n Parm *p, *tp;\n\t\t Node *n;\n\t\t Node *tnode = 0;\n\t\t Symtab *tscope = 0;\n\t\t int specialized = 0;\n\n\t\t (yyval.node) = 0;\n\n\t\t tscope = Swig_symbol_current(); /* Get the current scope */\n\n\t\t /* If the class name is qualified, we need to create or lookup namespace entries */\n\t\t if (!inclass) {\n\t\t (yyvsp[(5) - (9)].str) = resolve_node_scope((yyvsp[(5) - (9)].str));\n\t\t }\n\n\t\t /*\n\t\t We use the new namespace entry 'nscope' only to\n\t\t emit the template node. The template parameters are\n\t\t resolved in the current 'tscope'.\n\n\t\t This is closer to the C++ (typedef) behavior.\n\t\t */\n\t\t n = Swig_cparse_template_locate((yyvsp[(5) - (9)].str),(yyvsp[(7) - (9)].p),tscope);\n\n\t\t /* Patch the argument types to respect namespaces */\n\t\t p = (yyvsp[(7) - (9)].p);\n\t\t while (p) {\n\t\t SwigType *value = Getattr(p,\"value\");\n\t\t if (!value) {\n\t\t SwigType *ty = Getattr(p,\"type\");\n\t\t if (ty) {\n\t\t\tSwigType *rty = 0;\n\t\t\tint reduce = template_reduce;\n\t\t\tif (reduce || !SwigType_ispointer(ty)) {\n\t\t\t rty = Swig_symbol_typedef_reduce(ty,tscope);\n\t\t\t if (!reduce) reduce = SwigType_ispointer(rty);\n\t\t\t}\n\t\t\tty = reduce ? Swig_symbol_type_qualify(rty,tscope) : Swig_symbol_type_qualify(ty,tscope);\n\t\t\tSetattr(p,\"type\",ty);\n\t\t\tDelete(ty);\n\t\t\tDelete(rty);\n\t\t }\n\t\t } else {\n\t\t value = Swig_symbol_type_qualify(value,tscope);\n\t\t Setattr(p,\"value\",value);\n\t\t Delete(value);\n\t\t }\n\n\t\t p = nextSibling(p);\n\t\t }\n\n\t\t /* Look for the template */\n\t\t {\n Node *nn = n;\n Node *linklistend = 0;\n while (nn) {\n Node *templnode = 0;\n if (Strcmp(nodeType(nn),\"template\") == 0) {\n int nnisclass = (Strcmp(Getattr(nn,\"templatetype\"),\"class\") == 0); /* if not a templated class it is a templated function */\n Parm *tparms = Getattr(nn,\"templateparms\");\n if (!tparms) {\n specialized = 1;\n }\n if (nnisclass && !specialized && ((ParmList_len((yyvsp[(7) - (9)].p)) > ParmList_len(tparms)))) {\n Swig_error(cparse_file, cparse_line, \"Too many template parameters. Maximum of %d.\\n\", ParmList_len(tparms));\n } else if (nnisclass && !specialized && ((ParmList_len((yyvsp[(7) - (9)].p)) < ParmList_numrequired(tparms)))) {\n Swig_error(cparse_file, cparse_line, \"Not enough template parameters specified. %d required.\\n\", ParmList_numrequired(tparms));\n } else if (!nnisclass && ((ParmList_len((yyvsp[(7) - (9)].p)) != ParmList_len(tparms)))) {\n /* must be an overloaded templated method - ignore it as it is overloaded with a different number of template parameters */\n nn = Getattr(nn,\"sym:nextSibling\"); /* repeat for overloaded templated functions */\n continue;\n } else {\n\t\t\t String *tname = Copy((yyvsp[(5) - (9)].str));\n int def_supplied = 0;\n /* Expand the template */\n\t\t\t Node *templ = Swig_symbol_clookup((yyvsp[(5) - (9)].str),0);\n\t\t\t Parm *targs = templ ? Getattr(templ,\"templateparms\") : 0;\n\n ParmList *temparms;\n if (specialized) temparms = CopyParmList((yyvsp[(7) - (9)].p));\n else temparms = CopyParmList(tparms);\n\n /* Create typedef's and arguments */\n p = (yyvsp[(7) - (9)].p);\n tp = temparms;\n while (p) {\n String *value = Getattr(p,\"value\");\n if (def_supplied) {\n Setattr(p,\"default\",\"1\");\n }\n if (value) {\n Setattr(tp,\"value\",value);\n } else {\n SwigType *ty = Getattr(p,\"type\");\n if (ty) {\n Setattr(tp,\"type\",ty);\n }\n Delattr(tp,\"value\");\n }\n\t\t\t /* fix default arg values */\n\t\t\t if (targs) {\n\t\t\t Parm *pi = temparms;\n\t\t\t Parm *ti = targs;\n\t\t\t String *tv = Getattr(tp,\"value\");\n\t\t\t if (!tv) tv = Getattr(tp,\"type\");\n\t\t\t while(pi != tp) {\n\t\t\t\tString *name = Getattr(ti,\"name\");\n\t\t\t\tString *value = Getattr(pi,\"value\");\n\t\t\t\tif (!value) value = Getattr(pi,\"type\");\n\t\t\t\tReplaceid(tv, name, value);\n\t\t\t\tpi = nextSibling(pi);\n\t\t\t\tti = nextSibling(ti);\n\t\t\t }\n\t\t\t }\n p = nextSibling(p);\n tp = nextSibling(tp);\n if (!p && tp) {\n p = tp;\n def_supplied = 1;\n }\n }\n\n templnode = copy_node(nn);\n /* We need to set the node name based on name used to instantiate */\n Setattr(templnode,\"name\",tname);\n\t\t\t Delete(tname);\n if (!specialized) {\n Delattr(templnode,\"sym:typename\");\n } else {\n Setattr(templnode,\"sym:typename\",\"1\");\n }\n if ((yyvsp[(3) - (9)].id)) {\n\t\t\t /*\n\t\t\t Comment this out for 1.3.28. We need to\n\t\t\t re-enable it later but first we need to\n\t\t\t move %ignore from using %rename to use\n\t\t\t %feature(ignore).\n\n\t\t\t String *symname = Swig_name_make(templnode,0,$3,0,0);\n\t\t\t */\n\t\t\t String *symname = (yyvsp[(3) - (9)].id);\n Swig_cparse_template_expand(templnode,symname,temparms,tscope);\n Setattr(templnode,\"sym:name\",symname);\n } else {\n static int cnt = 0;\n String *nname = NewStringf(\"__dummy_%d__\", cnt++);\n Swig_cparse_template_expand(templnode,nname,temparms,tscope);\n Setattr(templnode,\"sym:name\",nname);\n\t\t\t Delete(nname);\n Setattr(templnode,\"feature:onlychildren\",\n \"typemap,typemapitem,typemapcopy,typedef,types,fragment\");\n }\n Delattr(templnode,\"templatetype\");\n Setattr(templnode,\"template\",nn);\n tnode = templnode;\n Setfile(templnode,cparse_file);\n Setline(templnode,cparse_line);\n Delete(temparms);\n\n add_symbols_copy(templnode);\n\n if (Strcmp(nodeType(templnode),\"class\") == 0) {\n\n /* Identify pure abstract methods */\n Setattr(templnode,\"abstract\", pure_abstract(firstChild(templnode)));\n\n /* Set up inheritance in symbol table */\n {\n Symtab *csyms;\n List *baselist = Getattr(templnode,\"baselist\");\n csyms = Swig_symbol_current();\n Swig_symbol_setscope(Getattr(templnode,\"symtab\"));\n if (baselist) {\n List *bases = make_inherit_list(Getattr(templnode,\"name\"),baselist);\n if (bases) {\n Iterator s;\n for (s = First(bases); s.item; s = Next(s)) {\n Symtab *st = Getattr(s.item,\"symtab\");\n if (st) {\n\t\t\t\t Setfile(st,Getfile(s.item));\n\t\t\t\t Setline(st,Getline(s.item));\n Swig_symbol_inherit(st);\n }\n }\n\t\t\t\t Delete(bases);\n }\n }\n Swig_symbol_setscope(csyms);\n }\n\n /* Merge in addmethods for this class */\n\n\t\t\t /* !!! This may be broken. We may have to add the\n\t\t\t addmethods at the beginning of the class */\n\n if (extendhash) {\n String *stmp = 0;\n String *clsname;\n Node *am;\n if (Namespaceprefix) {\n clsname = stmp = NewStringf(\"%s::%s\", Namespaceprefix, Getattr(templnode,\"name\"));\n } else {\n clsname = Getattr(templnode,\"name\");\n }\n am = Getattr(extendhash,clsname);\n if (am) {\n Symtab *st = Swig_symbol_current();\n Swig_symbol_setscope(Getattr(templnode,\"symtab\"));\n /*\t\t\t Printf(stdout,\"%s: %s %x %x\\n\", Getattr(templnode,\"name\"), clsname, Swig_symbol_current(), Getattr(templnode,\"symtab\")); */\n merge_extensions(templnode,am);\n Swig_symbol_setscope(st);\n\t\t\t\tappend_previous_extension(templnode,am);\n Delattr(extendhash,clsname);\n }\n\t\t\t if (stmp) Delete(stmp);\n }\n /* Add to classes hash */\n if (!classes) classes = NewHash();\n\n {\n if (Namespaceprefix) {\n String *temp = NewStringf(\"%s::%s\", Namespaceprefix, Getattr(templnode,\"name\"));\n Setattr(classes,temp,templnode);\n\t\t\t\tDelete(temp);\n } else {\n\t\t\t\tString *qs = Swig_symbol_qualifiedscopename(templnode);\n Setattr(classes, qs,templnode);\n\t\t\t\tDelete(qs);\n }\n }\n }\n }\n\n /* all the overloaded templated functions are added into a linked list */\n if (nscope_inner) {\n /* non-global namespace */\n if (templnode) {\n appendChild(nscope_inner,templnode);\n\t\t\t Delete(templnode);\n if (nscope) (yyval.node) = nscope;\n }\n } else {\n /* global namespace */\n if (!linklistend) {\n (yyval.node) = templnode;\n } else {\n set_nextSibling(linklistend,templnode);\n\t\t\t Delete(templnode);\n }\n linklistend = templnode;\n }\n }\n nn = Getattr(nn,\"sym:nextSibling\"); /* repeat for overloaded templated functions. If a templated class there will never be a sibling. */\n }\n\t\t }\n\t Swig_symbol_setscope(tscope);\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n }\n break;\n\n case 112:\n#line 2784 \"parser.y\"\n {\n\t\t Swig_warning(0,cparse_file, cparse_line,\"%s\\n\", (yyvsp[(2) - (2)].id));\n\t\t (yyval.node) = 0;\n }\n break;\n\n case 113:\n#line 2794 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node); \n if ((yyval.node)) {\n \t\t add_symbols((yyval.node));\n default_arguments((yyval.node));\n \t }\n }\n break;\n\n case 114:\n#line 2801 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 115:\n#line 2802 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 116:\n#line 2806 \"parser.y\"\n {\n\t\t if (Strcmp((yyvsp[(2) - (3)].id),\"C\") == 0) {\n\t\t cparse_externc = 1;\n\t\t }\n\t\t}\n break;\n\n case 117:\n#line 2810 \"parser.y\"\n {\n\t\t cparse_externc = 0;\n\t\t if (Strcmp((yyvsp[(2) - (6)].id),\"C\") == 0) {\n\t\t Node *n = firstChild((yyvsp[(5) - (6)].node));\n\t\t (yyval.node) = new_node(\"extern\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (6)].id));\n\t\t appendChild((yyval.node),n);\n\t\t while (n) {\n\t\t SwigType *decl = Getattr(n,\"decl\");\n\t\t if (SwigType_isfunction(decl)) {\n\t\t\tSetattr(n,\"storage\",\"externc\");\n\t\t }\n\t\t n = nextSibling(n);\n\t\t }\n\t\t } else {\n\t\t Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,\"Unrecognized extern type \\\"%s\\\".\\n\", (yyvsp[(2) - (6)].id));\n\t\t (yyval.node) = new_node(\"extern\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (6)].id));\n\t\t appendChild((yyval.node),firstChild((yyvsp[(5) - (6)].node)));\n\t\t }\n }\n break;\n\n case 118:\n#line 2837 \"parser.y\"\n {\n (yyval.node) = new_node(\"cdecl\");\n\t if ((yyvsp[(4) - (5)].dtype).qualifier) SwigType_push((yyvsp[(3) - (5)].decl).type,(yyvsp[(4) - (5)].dtype).qualifier);\n\t Setattr((yyval.node),\"type\",(yyvsp[(2) - (5)].type));\n\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (5)].id));\n\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (5)].decl).id);\n\t Setattr((yyval.node),\"decl\",(yyvsp[(3) - (5)].decl).type);\n\t Setattr((yyval.node),\"parms\",(yyvsp[(3) - (5)].decl).parms);\n\t Setattr((yyval.node),\"value\",(yyvsp[(4) - (5)].dtype).val);\n\t Setattr((yyval.node),\"throws\",(yyvsp[(4) - (5)].dtype).throws);\n\t Setattr((yyval.node),\"throw\",(yyvsp[(4) - (5)].dtype).throwf);\n\t if (!(yyvsp[(5) - (5)].node)) {\n\t\tif (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n\t\t}\n\t } else {\n\t\tNode *n = (yyvsp[(5) - (5)].node);\n\t\t/* Inherit attributes */\n\t\twhile (n) {\n\t\t String *type = Copy((yyvsp[(2) - (5)].type));\n\t\t Setattr(n,\"type\",type);\n\t\t Setattr(n,\"storage\",(yyvsp[(1) - (5)].id));\n\t\t n = nextSibling(n);\n\t\t Delete(type);\n\t\t}\n\t }\n\t if ((yyvsp[(4) - (5)].dtype).bitfield) {\n\t\tSetattr((yyval.node),\"bitfield\", (yyvsp[(4) - (5)].dtype).bitfield);\n\t }\n\n\t /* Look for \"::\" declarations (ignored) */\n\t if (Strstr((yyvsp[(3) - (5)].decl).id,\"::\")) {\n /* This is a special case. If the scope name of the declaration exactly\n matches that of the declaration, then we will allow it. Otherwise, delete. */\n String *p = Swig_scopename_prefix((yyvsp[(3) - (5)].decl).id);\n\t\tif (p) {\n\t\t if ((Namespaceprefix && Strcmp(p,Namespaceprefix) == 0) ||\n\t\t (inclass && Strcmp(p,Classprefix) == 0)) {\n\t\t String *lstr = Swig_scopename_last((yyvsp[(3) - (5)].decl).id);\n\t\t Setattr((yyval.node),\"name\",lstr);\n\t\t Delete(lstr);\n\t\t set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node));\n\t\t } else {\n\t\t Delete((yyval.node));\n\t\t (yyval.node) = (yyvsp[(5) - (5)].node);\n\t\t }\n\t\t Delete(p);\n\t\t} else {\n\t\t Delete((yyval.node));\n\t\t (yyval.node) = (yyvsp[(5) - (5)].node);\n\t\t}\n\t } else {\n\t\tset_nextSibling((yyval.node),(yyvsp[(5) - (5)].node));\n\t }\n }\n break;\n\n case 119:\n#line 2898 \"parser.y\"\n { \n (yyval.node) = 0;\n Clear(scanner_ccode); \n }\n break;\n\n case 120:\n#line 2902 \"parser.y\"\n {\n\t\t (yyval.node) = new_node(\"cdecl\");\n\t\t if ((yyvsp[(3) - (4)].dtype).qualifier) SwigType_push((yyvsp[(2) - (4)].decl).type,(yyvsp[(3) - (4)].dtype).qualifier);\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (4)].decl).id);\n\t\t Setattr((yyval.node),\"decl\",(yyvsp[(2) - (4)].decl).type);\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(2) - (4)].decl).parms);\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(3) - (4)].dtype).val);\n\t\t Setattr((yyval.node),\"throws\",(yyvsp[(3) - (4)].dtype).throws);\n\t\t Setattr((yyval.node),\"throw\",(yyvsp[(3) - (4)].dtype).throwf);\n\t\t if ((yyvsp[(3) - (4)].dtype).bitfield) {\n\t\t Setattr((yyval.node),\"bitfield\", (yyvsp[(3) - (4)].dtype).bitfield);\n\t\t }\n\t\t if (!(yyvsp[(4) - (4)].node)) {\n\t\t if (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n\t\t }\n\t\t } else {\n\t\t set_nextSibling((yyval.node),(yyvsp[(4) - (4)].node));\n\t\t }\n\t }\n break;\n\n case 121:\n#line 2924 \"parser.y\"\n { \n skip_balanced('{','}');\n (yyval.node) = 0;\n }\n break;\n\n case 122:\n#line 2930 \"parser.y\"\n { \n (yyval.dtype) = (yyvsp[(1) - (1)].dtype); \n (yyval.dtype).qualifier = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n }\n break;\n\n case 123:\n#line 2936 \"parser.y\"\n { \n (yyval.dtype) = (yyvsp[(2) - (2)].dtype); \n\t\t (yyval.dtype).qualifier = (yyvsp[(1) - (2)].str);\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t }\n break;\n\n case 124:\n#line 2942 \"parser.y\"\n { \n\t\t (yyval.dtype) = (yyvsp[(5) - (5)].dtype); \n (yyval.dtype).qualifier = 0;\n\t\t (yyval.dtype).throws = (yyvsp[(3) - (5)].pl);\n\t\t (yyval.dtype).throwf = NewString(\"1\");\n }\n break;\n\n case 125:\n#line 2948 \"parser.y\"\n { \n (yyval.dtype) = (yyvsp[(6) - (6)].dtype); \n (yyval.dtype).qualifier = (yyvsp[(1) - (6)].str);\n\t\t (yyval.dtype).throws = (yyvsp[(4) - (6)].pl);\n\t\t (yyval.dtype).throwf = NewString(\"1\");\n }\n break;\n\n case 126:\n#line 2961 \"parser.y\"\n {\n\t\t SwigType *ty = 0;\n\t\t (yyval.node) = new_node(\"enumforward\");\n\t\t ty = NewStringf(\"enum %s\", (yyvsp[(3) - (4)].id));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (4)].id));\n\t\t Setattr((yyval.node),\"type\",ty);\n\t\t Setattr((yyval.node),\"sym:weak\", \"1\");\n\t\t add_symbols((yyval.node));\n\t }\n break;\n\n case 127:\n#line 2976 \"parser.y\"\n {\n\t\t SwigType *ty = 0;\n (yyval.node) = new_node(\"enum\");\n\t\t ty = NewStringf(\"enum %s\", (yyvsp[(3) - (7)].id));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (7)].id));\n\t\t Setattr((yyval.node),\"type\",ty);\n\t\t appendChild((yyval.node),(yyvsp[(5) - (7)].node));\n\t\t add_symbols((yyval.node)); /* Add to tag space */\n\t\t add_symbols((yyvsp[(5) - (7)].node)); /* Add enum values to id space */\n }\n break;\n\n case 128:\n#line 2986 \"parser.y\"\n {\n\t\t Node *n;\n\t\t SwigType *ty = 0;\n\t\t String *unnamed = 0;\n\t\t int unnamedinstance = 0;\n\n\t\t (yyval.node) = new_node(\"enum\");\n\t\t if ((yyvsp[(3) - (8)].id)) {\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (8)].id));\n\t\t ty = NewStringf(\"enum %s\", (yyvsp[(3) - (8)].id));\n\t\t } else if ((yyvsp[(7) - (8)].decl).id) {\n\t\t unnamed = make_unnamed();\n\t\t ty = NewStringf(\"enum %s\", unnamed);\n\t\t Setattr((yyval.node),\"unnamed\",unnamed);\n /* name is not set for unnamed enum instances, e.g. enum { foo } Instance; */\n\t\t if ((yyvsp[(1) - (8)].id) && Cmp((yyvsp[(1) - (8)].id),\"typedef\") == 0) {\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(7) - (8)].decl).id);\n } else {\n unnamedinstance = 1;\n }\n\t\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (8)].id));\n\t\t }\n\t\t if ((yyvsp[(7) - (8)].decl).id && Cmp((yyvsp[(1) - (8)].id),\"typedef\") == 0) {\n\t\t Setattr((yyval.node),\"tdname\",(yyvsp[(7) - (8)].decl).id);\n Setattr((yyval.node),\"allows_typedef\",\"1\");\n }\n\t\t appendChild((yyval.node),(yyvsp[(5) - (8)].node));\n\t\t n = new_node(\"cdecl\");\n\t\t Setattr(n,\"type\",ty);\n\t\t Setattr(n,\"name\",(yyvsp[(7) - (8)].decl).id);\n\t\t Setattr(n,\"storage\",(yyvsp[(1) - (8)].id));\n\t\t Setattr(n,\"decl\",(yyvsp[(7) - (8)].decl).type);\n\t\t Setattr(n,\"parms\",(yyvsp[(7) - (8)].decl).parms);\n\t\t Setattr(n,\"unnamed\",unnamed);\n\n if (unnamedinstance) {\n\t\t SwigType *cty = NewString(\"enum \");\n\t\t Setattr((yyval.node),\"type\",cty);\n\t\t Setattr((yyval.node),\"unnamedinstance\",\"1\");\n\t\t Setattr(n,\"unnamedinstance\",\"1\");\n\t\t Delete(cty);\n }\n\t\t if ((yyvsp[(8) - (8)].node)) {\n\t\t Node *p = (yyvsp[(8) - (8)].node);\n\t\t set_nextSibling(n,p);\n\t\t while (p) {\n\t\t SwigType *cty = Copy(ty);\n\t\t Setattr(p,\"type\",cty);\n\t\t Setattr(p,\"unnamed\",unnamed);\n\t\t Setattr(p,\"storage\",(yyvsp[(1) - (8)].id));\n\t\t Delete(cty);\n\t\t p = nextSibling(p);\n\t\t }\n\t\t } else {\n\t\t if (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr(n,\"code\",code);\n\t\t Delete(code);\n\t\t }\n\t\t }\n\n /* Ensure that typedef enum ABC {foo} XYZ; uses XYZ for sym:name, like structs.\n * Note that class_rename/yyrename are bit of a mess so used this simple approach to change the name. */\n if ((yyvsp[(7) - (8)].decl).id && (yyvsp[(3) - (8)].id) && Cmp((yyvsp[(1) - (8)].id),\"typedef\") == 0) {\n\t\t String *name = NewString((yyvsp[(7) - (8)].decl).id);\n Setattr((yyval.node), \"parser:makename\", name);\n\t\t Delete(name);\n }\n\n\t\t add_symbols((yyval.node)); /* Add enum to tag space */\n\t\t set_nextSibling((yyval.node),n);\n\t\t Delete(n);\n\t\t add_symbols((yyvsp[(5) - (8)].node)); /* Add enum values to id space */\n\t add_symbols(n);\n\t\t Delete(unnamed);\n\t }\n break;\n\n case 129:\n#line 3064 \"parser.y\"\n {\n /* This is a sick hack. If the ctor_end has parameters,\n and the parms parameter only has 1 parameter, this\n could be a declaration of the form:\n\n type (id)(parms)\n\n\t\t\t Otherwise it's an error. */\n int err = 0;\n (yyval.node) = 0;\n\n\t\t if ((ParmList_len((yyvsp[(4) - (6)].pl)) == 1) && (!Swig_scopename_check((yyvsp[(2) - (6)].type)))) {\n\t\t SwigType *ty = Getattr((yyvsp[(4) - (6)].pl),\"type\");\n\t\t String *name = Getattr((yyvsp[(4) - (6)].pl),\"name\");\n\t\t err = 1;\n\t\t if (!name) {\n\t\t\t(yyval.node) = new_node(\"cdecl\");\n\t\t\tSetattr((yyval.node),\"type\",(yyvsp[(2) - (6)].type));\n\t\t\tSetattr((yyval.node),\"storage\",(yyvsp[(1) - (6)].id));\n\t\t\tSetattr((yyval.node),\"name\",ty);\n\n\t\t\tif ((yyvsp[(6) - (6)].decl).have_parms) {\n\t\t\t SwigType *decl = NewStringEmpty();\n\t\t\t SwigType_add_function(decl,(yyvsp[(6) - (6)].decl).parms);\n\t\t\t Setattr((yyval.node),\"decl\",decl);\n\t\t\t Setattr((yyval.node),\"parms\",(yyvsp[(6) - (6)].decl).parms);\n\t\t\t if (Len(scanner_ccode)) {\n\t\t\t String *code = Copy(scanner_ccode);\n\t\t\t Setattr((yyval.node),\"code\",code);\n\t\t\t Delete(code);\n\t\t\t }\n\t\t\t}\n\t\t\tif ((yyvsp[(6) - (6)].decl).defarg) {\n\t\t\t Setattr((yyval.node),\"value\",(yyvsp[(6) - (6)].decl).defarg);\n\t\t\t}\n\t\t\tSetattr((yyval.node),\"throws\",(yyvsp[(6) - (6)].decl).throws);\n\t\t\tSetattr((yyval.node),\"throw\",(yyvsp[(6) - (6)].decl).throwf);\n\t\t\terr = 0;\n\t\t }\n\t\t }\n\t\t if (err) {\n\t\t Swig_error(cparse_file,cparse_line,\"Syntax error in input(2).\\n\");\n\t\t exit(1);\n\t\t }\n }\n break;\n\n case 130:\n#line 3115 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 131:\n#line 3116 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 132:\n#line 3117 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 133:\n#line 3118 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 134:\n#line 3119 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 135:\n#line 3120 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 136:\n#line 3126 \"parser.y\"\n {\n List *bases = 0;\n\t\t Node *scope = 0;\n\t\t (yyval.node) = new_node(\"class\");\n\t\t Setline((yyval.node),cparse_start_line);\n\t\t Setattr((yyval.node),\"kind\",(yyvsp[(2) - (5)].id));\n\t\t if ((yyvsp[(4) - (5)].bases)) {\n\t\t Setattr((yyval.node),\"baselist\", Getattr((yyvsp[(4) - (5)].bases),\"public\"));\n\t\t Setattr((yyval.node),\"protectedbaselist\", Getattr((yyvsp[(4) - (5)].bases),\"protected\"));\n\t\t Setattr((yyval.node),\"privatebaselist\", Getattr((yyvsp[(4) - (5)].bases),\"private\"));\n\t\t }\n\t\t Setattr((yyval.node),\"allows_typedef\",\"1\");\n\n\t\t /* preserve the current scope */\n\t\t prev_symtab = Swig_symbol_current();\n\t\t \n\t\t /* If the class name is qualified. We need to create or lookup namespace/scope entries */\n\t\t scope = resolve_node_scope((yyvsp[(3) - (5)].str));\n\t\t Setfile(scope,cparse_file);\n\t\t Setline(scope,cparse_line);\n\t\t (yyvsp[(3) - (5)].str) = scope;\n\t\t \n\t\t /* support for old nested classes \"pseudo\" support, such as:\n\n\t\t %rename(Ala__Ola) Ala::Ola;\n\t\t\tclass Ala::Ola {\n\t\t\tpublic:\n\t\t\t Ola() {}\n\t\t };\n\n\t\t this should disappear when a proper implementation is added.\n\t\t */\n\t\t if (nscope_inner && Strcmp(nodeType(nscope_inner),\"namespace\") != 0) {\n\t\t if (Namespaceprefix) {\n\t\t String *name = NewStringf(\"%s::%s\", Namespaceprefix, (yyvsp[(3) - (5)].str));\t\t \n\t\t (yyvsp[(3) - (5)].str) = name;\n\t\t Namespaceprefix = 0;\n\t\t nscope_inner = 0;\n\t\t }\n\t\t }\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (5)].str));\n\n\t\t Delete(class_rename);\n class_rename = make_name((yyval.node),(yyvsp[(3) - (5)].str),0);\n\t\t Classprefix = NewString((yyvsp[(3) - (5)].str));\n\t\t /* Deal with inheritance */\n\t\t if ((yyvsp[(4) - (5)].bases)) {\n\t\t bases = make_inherit_list((yyvsp[(3) - (5)].str),Getattr((yyvsp[(4) - (5)].bases),\"public\"));\n\t\t }\n\t\t if (SwigType_istemplate((yyvsp[(3) - (5)].str))) {\n\t\t String *fbase, *tbase, *prefix;\n\t\t prefix = SwigType_templateprefix((yyvsp[(3) - (5)].str));\n\t\t if (Namespaceprefix) {\n\t\t fbase = NewStringf(\"%s::%s\", Namespaceprefix,(yyvsp[(3) - (5)].str));\n\t\t tbase = NewStringf(\"%s::%s\", Namespaceprefix, prefix);\n\t\t } else {\n\t\t fbase = Copy((yyvsp[(3) - (5)].str));\n\t\t tbase = Copy(prefix);\n\t\t }\n\t\t Swig_name_inherit(tbase,fbase);\n\t\t Delete(fbase);\n\t\t Delete(tbase);\n\t\t Delete(prefix);\n\t\t }\n if (strcmp((yyvsp[(2) - (5)].id),\"class\") == 0) {\n\t\t cplus_mode = CPLUS_PRIVATE;\n\t\t } else {\n\t\t cplus_mode = CPLUS_PUBLIC;\n\t\t }\n\t\t Swig_symbol_newscope();\n\t\t Swig_symbol_setscopename((yyvsp[(3) - (5)].str));\n\t\t if (bases) {\n\t\t Iterator s;\n\t\t for (s = First(bases); s.item; s = Next(s)) {\n\t\t Symtab *st = Getattr(s.item,\"symtab\");\n\t\t if (st) {\n\t\t\t Setfile(st,Getfile(s.item));\n\t\t\t Setline(st,Getline(s.item));\n\t\t\t Swig_symbol_inherit(st); \n\t\t }\n\t\t }\n\t\t Delete(bases);\n\t\t }\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\t cparse_start_line = cparse_line;\n\n\t\t /* If there are active template parameters, we need to make sure they are\n placed in the class symbol table so we can catch shadows */\n\n\t\t if (template_parameters) {\n\t\t Parm *tp = template_parameters;\n\t\t while(tp) {\n\t\t String *tpname = Copy(Getattr(tp,\"name\"));\n\t\t Node *tn = new_node(\"templateparm\");\n\t\t Setattr(tn,\"name\",tpname);\n\t\t Swig_symbol_cadd(tpname,tn);\n\t\t tp = nextSibling(tp);\n\t\t Delete(tpname);\n\t\t }\n\t\t }\n\t\t if (class_level >= max_class_levels) {\n\t\t if (!max_class_levels) {\n\t\t\t max_class_levels = 16;\n\t\t } else {\n\t\t\t max_class_levels *= 2;\n\t\t }\n\t\t class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);\n\t\t if (!class_decl) {\n\t\t\t Swig_error(cparse_file, cparse_line, \"realloc() failed\\n\");\n\t\t }\n\t\t }\n\t\t class_decl[class_level++] = (yyval.node);\n\t\t inclass = 1;\n }\n break;\n\n case 137:\n#line 3240 \"parser.y\"\n {\n\t\t Node *p;\n\t\t SwigType *ty;\n\t\t Symtab *cscope = prev_symtab;\n\t\t Node *am = 0;\n\t\t String *scpname = 0;\n\t\t (yyval.node) = class_decl[--class_level];\n\t\t inclass = 0;\n\t\t \n\t\t /* Check for pure-abstract class */\n\t\t Setattr((yyval.node),\"abstract\", pure_abstract((yyvsp[(7) - (9)].node)));\n\t\t \n\t\t /* This bit of code merges in a previously defined %extend directive (if any) */\n\t\t \n\t\t if (extendhash) {\n\t\t String *clsname = Swig_symbol_qualifiedscopename(0);\n\t\t am = Getattr(extendhash,clsname);\n\t\t if (am) {\n\t\t merge_extensions((yyval.node),am);\n\t\t Delattr(extendhash,clsname);\n\t\t }\n\t\t Delete(clsname);\n\t\t }\n\t\t if (!classes) classes = NewHash();\n\t\t scpname = Swig_symbol_qualifiedscopename(0);\n\t\t Setattr(classes,scpname,(yyval.node));\n\t\t Delete(scpname);\n\n\t\t appendChild((yyval.node),(yyvsp[(7) - (9)].node));\n\t\t \n\t\t if (am) append_previous_extension((yyval.node),am);\n\n\t\t p = (yyvsp[(9) - (9)].node);\n\t\t if (p) {\n\t\t set_nextSibling((yyval.node),p);\n\t\t }\n\t\t \n\t\t if (cparse_cplusplus && !cparse_externc) {\n\t\t ty = NewString((yyvsp[(3) - (9)].str));\n\t\t } else {\n\t\t ty = NewStringf(\"%s %s\", (yyvsp[(2) - (9)].id),(yyvsp[(3) - (9)].str));\n\t\t }\n\t\t while (p) {\n\t\t Setattr(p,\"storage\",(yyvsp[(1) - (9)].id));\n\t\t Setattr(p,\"type\",ty);\n\t\t p = nextSibling(p);\n\t\t }\n\t\t /* Dump nested classes */\n\t\t {\n\t\t String *name = (yyvsp[(3) - (9)].str);\n\t\t if ((yyvsp[(9) - (9)].node)) {\n\t\t SwigType *decltype = Getattr((yyvsp[(9) - (9)].node),\"decl\");\n\t\t if (Cmp((yyvsp[(1) - (9)].id),\"typedef\") == 0) {\n\t\t if (!decltype || !Len(decltype)) {\n\t\t\t String *cname;\n\t\t\t name = Getattr((yyvsp[(9) - (9)].node),\"name\");\n\t\t\t cname = Copy(name);\n\t\t\t Setattr((yyval.node),\"tdname\",cname);\n\t\t\t Delete(cname);\n\n\t\t\t /* Use typedef name as class name */\n\t\t\t if (class_rename && (Strcmp(class_rename,(yyvsp[(3) - (9)].str)) == 0)) {\n\t\t\t Delete(class_rename);\n\t\t\t class_rename = NewString(name);\n\t\t\t }\n\t\t\t if (!Getattr(classes,name)) {\n\t\t\t Setattr(classes,name,(yyval.node));\n\t\t\t }\n\t\t\t Setattr((yyval.node),\"decl\",decltype);\n\t\t }\n\t\t }\n\t\t }\n\t\t appendChild((yyval.node),dump_nested(Char(name)));\n\t\t }\n\n\t\t if (cplus_mode != CPLUS_PUBLIC) {\n\t\t /* we 'open' the class at the end, to allow %template\n\t\t to add new members */\n\t\t Node *pa = new_node(\"access\");\n\t\t Setattr(pa,\"kind\",\"public\");\n\t\t cplus_mode = CPLUS_PUBLIC;\n\t\t appendChild((yyval.node),pa);\n\t\t Delete(pa);\n\t\t }\n\n\t\t Setattr((yyval.node),\"symtab\",Swig_symbol_popscope());\n\n\t\t Classprefix = 0;\n\t\t if (nscope_inner) {\n\t\t /* this is tricky */\n\t\t /* we add the declaration in the original namespace */\n\t\t appendChild(nscope_inner,(yyval.node));\n\t\t Swig_symbol_setscope(Getattr(nscope_inner,\"symtab\"));\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\t add_symbols((yyval.node));\n\t\t if (nscope) (yyval.node) = nscope;\n\t\t /* but the variable definition in the current scope */\n\t\t Swig_symbol_setscope(cscope);\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\t add_symbols((yyvsp[(9) - (9)].node));\n\t\t } else {\n\t\t Delete(yyrename);\n\t\t yyrename = Copy(class_rename);\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\n\t\t add_symbols((yyval.node));\n\t\t add_symbols((yyvsp[(9) - (9)].node));\n\t\t }\n\t\t Swig_symbol_setscope(cscope);\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t }\n break;\n\n case 138:\n#line 3358 \"parser.y\"\n {\n\t String *unnamed;\n\t unnamed = make_unnamed();\n\t (yyval.node) = new_node(\"class\");\n\t Setline((yyval.node),cparse_start_line);\n\t Setattr((yyval.node),\"kind\",(yyvsp[(2) - (3)].id));\n\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (3)].id));\n\t Setattr((yyval.node),\"unnamed\",unnamed);\n\t Setattr((yyval.node),\"allows_typedef\",\"1\");\n\t Delete(class_rename);\n\t class_rename = make_name((yyval.node),0,0);\n\t if (strcmp((yyvsp[(2) - (3)].id),\"class\") == 0) {\n\t\t cplus_mode = CPLUS_PRIVATE;\n\t } else {\n\t\t cplus_mode = CPLUS_PUBLIC;\n\t }\n\t Swig_symbol_newscope();\n\t cparse_start_line = cparse_line;\n\t if (class_level >= max_class_levels) {\n\t\t if (!max_class_levels) {\n\t\t max_class_levels = 16;\n\t\t } else {\n\t\t max_class_levels *= 2;\n\t\t }\n\t\t class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);\n\t\t if (!class_decl) {\n\t\t Swig_error(cparse_file, cparse_line, \"realloc() failed\\n\");\n\t\t }\n\t }\n\t class_decl[class_level++] = (yyval.node);\n\t inclass = 1;\n\t Classprefix = NewStringEmpty();\n\t Delete(Namespaceprefix);\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n }\n break;\n\n case 139:\n#line 3392 \"parser.y\"\n {\n\t String *unnamed;\n\t Node *n;\n\t Classprefix = 0;\n\t (yyval.node) = class_decl[--class_level];\n\t inclass = 0;\n\t unnamed = Getattr((yyval.node),\"unnamed\");\n\n\t /* Check for pure-abstract class */\n\t Setattr((yyval.node),\"abstract\", pure_abstract((yyvsp[(5) - (8)].node)));\n\n\t n = new_node(\"cdecl\");\n\t Setattr(n,\"name\",(yyvsp[(7) - (8)].decl).id);\n\t Setattr(n,\"unnamed\",unnamed);\n\t Setattr(n,\"type\",unnamed);\n\t Setattr(n,\"decl\",(yyvsp[(7) - (8)].decl).type);\n\t Setattr(n,\"parms\",(yyvsp[(7) - (8)].decl).parms);\n\t Setattr(n,\"storage\",(yyvsp[(1) - (8)].id));\n\t if ((yyvsp[(8) - (8)].node)) {\n\t\t Node *p = (yyvsp[(8) - (8)].node);\n\t\t set_nextSibling(n,p);\n\t\t while (p) {\n\t\t String *type = Copy(unnamed);\n\t\t Setattr(p,\"name\",(yyvsp[(7) - (8)].decl).id);\n\t\t Setattr(p,\"unnamed\",unnamed);\n\t\t Setattr(p,\"type\",type);\n\t\t Delete(type);\n\t\t Setattr(p,\"storage\",(yyvsp[(1) - (8)].id));\n\t\t p = nextSibling(p);\n\t\t }\n\t }\n\t set_nextSibling((yyval.node),n);\n\t Delete(n);\n\t {\n\t\t /* If a proper typedef name was given, we'll use it to set the scope name */\n\t\t String *name = 0;\n\t\t if ((yyvsp[(1) - (8)].id) && (strcmp((yyvsp[(1) - (8)].id),\"typedef\") == 0)) {\n\t\t if (!Len((yyvsp[(7) - (8)].decl).type)) {\t\n\t\t String *scpname = 0;\n\t\t name = (yyvsp[(7) - (8)].decl).id;\n\t\t Setattr((yyval.node),\"tdname\",name);\n\t\t Setattr((yyval.node),\"name\",name);\n\t\t Swig_symbol_setscopename(name);\n\n\t\t /* If a proper name was given, we use that as the typedef, not unnamed */\n\t\t Clear(unnamed);\n\t\t Append(unnamed, name);\n\t\t \n\t\t n = nextSibling(n);\n\t\t set_nextSibling((yyval.node),n);\n\n\t\t /* Check for previous extensions */\n\t\t if (extendhash) {\n\t\t String *clsname = Swig_symbol_qualifiedscopename(0);\n\t\t Node *am = Getattr(extendhash,clsname);\n\t\t if (am) {\n\t\t\t /* Merge the extension into the symbol table */\n\t\t\t merge_extensions((yyval.node),am);\n\t\t\t append_previous_extension((yyval.node),am);\n\t\t\t Delattr(extendhash,clsname);\n\t\t }\n\t\t Delete(clsname);\n\t\t }\n\t\t if (!classes) classes = NewHash();\n\t\t scpname = Swig_symbol_qualifiedscopename(0);\n\t\t Setattr(classes,scpname,(yyval.node));\n\t\t Delete(scpname);\n\t\t } else {\n\t\t Swig_symbol_setscopename((char*)\"\");\n\t\t }\n\t\t }\n\t\t appendChild((yyval.node),(yyvsp[(5) - (8)].node));\n\t\t appendChild((yyval.node),dump_nested(Char(name)));\n\t }\n\t /* Pop the scope */\n\t Setattr((yyval.node),\"symtab\",Swig_symbol_popscope());\n\t if (class_rename) {\n\t\t Delete(yyrename);\n\t\t yyrename = NewString(class_rename);\n\t }\n\t Delete(Namespaceprefix);\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t add_symbols((yyval.node));\n\t add_symbols(n);\n\t Delete(unnamed);\n }\n break;\n\n case 140:\n#line 3480 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 141:\n#line 3481 \"parser.y\"\n {\n (yyval.node) = new_node(\"cdecl\");\n Setattr((yyval.node),\"name\",(yyvsp[(1) - (2)].decl).id);\n Setattr((yyval.node),\"decl\",(yyvsp[(1) - (2)].decl).type);\n Setattr((yyval.node),\"parms\",(yyvsp[(1) - (2)].decl).parms);\n\t\t\tset_nextSibling((yyval.node),(yyvsp[(2) - (2)].node));\n }\n break;\n\n case 142:\n#line 3493 \"parser.y\"\n {\n if ((yyvsp[(1) - (4)].id) && (Strcmp((yyvsp[(1) - (4)].id),\"friend\") == 0)) {\n\t\t/* Ignore */\n (yyval.node) = 0; \n\t } else {\n\t\t(yyval.node) = new_node(\"classforward\");\n\t\tSetfile((yyval.node),cparse_file);\n\t\tSetline((yyval.node),cparse_line);\n\t\tSetattr((yyval.node),\"kind\",(yyvsp[(2) - (4)].id));\n\t\tSetattr((yyval.node),\"name\",(yyvsp[(3) - (4)].str));\n\t\tSetattr((yyval.node),\"sym:weak\", \"1\");\n\t\tadd_symbols((yyval.node));\n\t }\n }\n break;\n\n case 143:\n#line 3513 \"parser.y\"\n { template_parameters = (yyvsp[(3) - (4)].tparms); }\n break;\n\n case 144:\n#line 3513 \"parser.y\"\n {\n\t\t String *tname = 0;\n\t\t int error = 0;\n\n\t\t /* check if we get a namespace node with a class declaration, and retrieve the class */\n\t\t Symtab *cscope = Swig_symbol_current();\n\t\t Symtab *sti = 0;\n\t\t Node *ntop = (yyvsp[(6) - (6)].node);\n\t\t Node *ni = ntop;\n\t\t SwigType *ntype = ni ? nodeType(ni) : 0;\n\t\t while (ni && Strcmp(ntype,\"namespace\") == 0) {\n\t\t\tsti = Getattr(ni,\"symtab\");\n\t\t\tni = firstChild(ni);\n\t\t\tntype = nodeType(ni);\n\t\t }\n\t\t if (sti) {\n\t\t\tSwig_symbol_setscope(sti);\n\t\t\tDelete(Namespaceprefix);\n\t\t\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\t\t(yyvsp[(6) - (6)].node) = ni;\n\t\t }\n\n template_parameters = 0;\n (yyval.node) = (yyvsp[(6) - (6)].node);\n\t\t if ((yyval.node)) tname = Getattr((yyval.node),\"name\");\n\t\t \n\t\t /* Check if the class is a template specialization */\n\t\t if (((yyval.node)) && (Strchr(tname,'<')) && (!is_operator(tname))) {\n\t\t\t/* If a specialization. Check if defined. */\n\t\t\tNode *tempn = 0;\n\t\t\t{\n\t\t\t String *tbase = SwigType_templateprefix(tname);\n\t\t\t tempn = Swig_symbol_clookup_local(tbase,0);\n\t\t\t if (!tempn || (Strcmp(nodeType(tempn),\"template\") != 0)) {\n\t\t\t SWIG_WARN_NODE_BEGIN(tempn);\n\t\t\t Swig_warning(WARN_PARSE_TEMPLATE_SP_UNDEF, Getfile((yyval.node)),Getline((yyval.node)),\"Specialization of non-template '%s'.\\n\", tbase);\n\t\t\t SWIG_WARN_NODE_END(tempn);\n\t\t\t tempn = 0;\n\t\t\t error = 1;\n\t\t\t }\n\t\t\t Delete(tbase);\n\t\t\t}\n\t\t\tSetattr((yyval.node),\"specialization\",\"1\");\n\t\t\tSetattr((yyval.node),\"templatetype\",nodeType((yyval.node)));\n\t\t\tset_nodeType((yyval.node),\"template\");\n\t\t\t/* Template partial specialization */\n\t\t\tif (tempn && ((yyvsp[(3) - (6)].tparms)) && ((yyvsp[(6) - (6)].node))) {\n\t\t\t List *tlist;\n\t\t\t String *targs = SwigType_templateargs(tname);\n\t\t\t tlist = SwigType_parmlist(targs);\n\t\t\t /*\t\t\t Printf(stdout,\"targs = '%s' %s\\n\", targs, tlist); */\n\t\t\t if (!Getattr((yyval.node),\"sym:weak\")) {\n\t\t\t Setattr((yyval.node),\"sym:typename\",\"1\");\n\t\t\t }\n\t\t\t \n\t\t\t if (Len(tlist) != ParmList_len(Getattr(tempn,\"templateparms\"))) {\n\t\t\t Swig_error(Getfile((yyval.node)),Getline((yyval.node)),\"Inconsistent argument count in template partial specialization. %d %d\\n\", Len(tlist), ParmList_len(Getattr(tempn,\"templateparms\")));\n\t\t\t \n\t\t\t } else {\n\n\t\t\t /* This code builds the argument list for the partial template\n specialization. This is a little hairy, but the idea is as\n follows:\n\n $3 contains a list of arguments supplied for the template.\n For example template.\n\n tlist is a list of the specialization arguments--which may be\n different. For example class.\n\n tp is a copy of the arguments in the original template definition.\n \n The patching algorithm walks through the list of supplied\n arguments ($3), finds the position in the specialization arguments\n (tlist), and then patches the name in the argument list of the\n original template.\n\t\t\t */\n\n\t\t\t {\n\t\t\t String *pn;\n\t\t\t Parm *p, *p1;\n\t\t\t int i, nargs;\n\t\t\t Parm *tp = CopyParmList(Getattr(tempn,\"templateparms\"));\n\t\t\t nargs = Len(tlist);\n\t\t\t p = (yyvsp[(3) - (6)].tparms);\n\t\t\t while (p) {\n\t\t\t for (i = 0; i < nargs; i++){\n\t\t\t\tpn = Getattr(p,\"name\");\n\t\t\t\tif (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) {\n\t\t\t\t int j;\n\t\t\t\t Parm *p1 = tp;\n\t\t\t\t for (j = 0; j < i; j++) {\n\t\t\t\t p1 = nextSibling(p1);\n\t\t\t\t }\n\t\t\t\t Setattr(p1,\"name\",pn);\n\t\t\t\t Setattr(p1,\"partialarg\",\"1\");\n\t\t\t\t}\n\t\t\t }\n\t\t\t p = nextSibling(p);\n\t\t\t }\n\t\t\t p1 = tp;\n\t\t\t i = 0;\n\t\t\t while (p1) {\n\t\t\t if (!Getattr(p1,\"partialarg\")) {\n\t\t\t\tDelattr(p1,\"name\");\n\t\t\t\tSetattr(p1,\"type\", Getitem(tlist,i));\n\t\t\t } \n\t\t\t i++;\n\t\t\t p1 = nextSibling(p1);\n\t\t\t }\n\t\t\t Setattr((yyval.node),\"templateparms\",tp);\n\t\t\t Delete(tp);\n\t\t\t }\n#if 0\n\t\t\t /* Patch the parameter list */\n\t\t\t if (tempn) {\n\t\t\t Parm *p,*p1;\n\t\t\t ParmList *tp = CopyParmList(Getattr(tempn,\"templateparms\"));\n\t\t\t p = (yyvsp[(3) - (6)].tparms);\n\t\t\t p1 = tp;\n\t\t\t while (p && p1) {\n\t\t\t String *pn = Getattr(p,\"name\");\n\t\t\t Printf(stdout,\"pn = '%s'\\n\", pn);\n\t\t\t if (pn) Setattr(p1,\"name\",pn);\n\t\t\t else Delattr(p1,\"name\");\n\t\t\t pn = Getattr(p,\"type\");\n\t\t\t if (pn) Setattr(p1,\"type\",pn);\n\t\t\t p = nextSibling(p);\n\t\t\t p1 = nextSibling(p1);\n\t\t\t }\n\t\t\t Setattr((yyval.node),\"templateparms\",tp);\n\t\t\t Delete(tp);\n\t\t\t } else {\n\t\t\t Setattr((yyval.node),\"templateparms\",(yyvsp[(3) - (6)].tparms));\n\t\t\t }\n#endif\n\t\t\t Delattr((yyval.node),\"specialization\");\n\t\t\t Setattr((yyval.node),\"partialspecialization\",\"1\");\n\t\t\t /* Create a specialized name for matching */\n\t\t\t {\n\t\t\t Parm *p = (yyvsp[(3) - (6)].tparms);\n\t\t\t String *fname = NewString(Getattr((yyval.node),\"name\"));\n\t\t\t String *ffname = 0;\n\n\t\t\t char tmp[32];\n\t\t\t int i, ilen;\n\t\t\t while (p) {\n\t\t\t String *n = Getattr(p,\"name\");\n\t\t\t if (!n) {\n\t\t\t\tp = nextSibling(p);\n\t\t\t\tcontinue;\n\t\t\t }\n\t\t\t ilen = Len(tlist);\n\t\t\t for (i = 0; i < ilen; i++) {\n\t\t\t\tif (Strstr(Getitem(tlist,i),n)) {\n\t\t\t\t sprintf(tmp,\"$%d\",i+1);\n\t\t\t\t Replaceid(fname,n,tmp);\n\t\t\t\t}\n\t\t\t }\n\t\t\t p = nextSibling(p);\n\t\t\t }\n\t\t\t /* Patch argument names with typedef */\n\t\t\t {\n\t\t\t Iterator tt;\n\t\t\t List *tparms = SwigType_parmlist(fname);\n\t\t\t ffname = SwigType_templateprefix(fname);\n\t\t\t Append(ffname,\"<(\");\n\t\t\t for (tt = First(tparms); tt.item; ) {\n\t\t\t\tSwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0);\n\t\t\t\tSwigType *ttr = Swig_symbol_type_qualify(rtt,0);\n\t\t\t\tAppend(ffname,ttr);\n\t\t\t\ttt = Next(tt);\n\t\t\t\tif (tt.item) Putc(',',ffname);\n\t\t\t\tDelete(rtt);\n\t\t\t\tDelete(ttr);\n\t\t\t }\n\t\t\t Delete(tparms);\n\t\t\t Append(ffname,\")>\");\n\t\t\t }\n\t\t\t {\n\t\t\t String *partials = Getattr(tempn,\"partials\");\n\t\t\t if (!partials) {\n\t\t\t\tpartials = NewList();\n\t\t\t\tSetattr(tempn,\"partials\",partials);\n\t\t\t\tDelete(partials);\n\t\t\t }\n\t\t\t /*\t\t\t Printf(stdout,\"partial: fname = '%s', '%s'\\n\", fname, Swig_symbol_typedef_reduce(fname,0)); */\n\t\t\t Append(partials,ffname);\n\t\t\t }\n\t\t\t Setattr((yyval.node),\"partialargs\",ffname);\n\t\t\t Swig_symbol_cadd(ffname,(yyval.node));\n\t\t\t }\n\t\t\t }\n\t\t\t Delete(tlist);\n\t\t\t Delete(targs);\n\t\t\t} else {\n\t\t\t /* Need to resolve exact specialization name */\n\t\t\t /* add default args from generic template */\n\t\t\t String *ty = Swig_symbol_template_deftype(tname,0);\n\t\t\t String *fname = Swig_symbol_type_qualify(ty,0);\n\t\t\t Swig_symbol_cadd(fname,(yyval.node));\n\t\t\t Delete(ty);\n\t\t\t Delete(fname);\n\t\t\t}\n\t\t } else if ((yyval.node)) {\n\t\t\tSetattr((yyval.node),\"templatetype\",nodeType((yyvsp[(6) - (6)].node)));\n\t\t\tset_nodeType((yyval.node),\"template\");\n\t\t\tSetattr((yyval.node),\"templateparms\", (yyvsp[(3) - (6)].tparms));\n\t\t\tif (!Getattr((yyval.node),\"sym:weak\")) {\n\t\t\t Setattr((yyval.node),\"sym:typename\",\"1\");\n\t\t\t}\n\t\t\tadd_symbols((yyval.node));\n default_arguments((yyval.node));\n\t\t\t/* We also place a fully parameterized version in the symbol table */\n\t\t\t{\n\t\t\t Parm *p;\n\t\t\t String *fname = NewStringf(\"%s<(\", Getattr((yyval.node),\"name\"));\n\t\t\t p = (yyvsp[(3) - (6)].tparms);\n\t\t\t while (p) {\n\t\t\t String *n = Getattr(p,\"name\");\n\t\t\t if (!n) n = Getattr(p,\"type\");\n\t\t\t Append(fname,n);\n\t\t\t p = nextSibling(p);\n\t\t\t if (p) Putc(',',fname);\n\t\t\t }\n\t\t\t Append(fname,\")>\");\n\t\t\t Swig_symbol_cadd(fname,(yyval.node));\n\t\t\t}\n\t\t }\n\t\t (yyval.node) = ntop;\n\t\t Swig_symbol_setscope(cscope);\n\t\t Delete(Namespaceprefix);\n\t\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\t if (error) (yyval.node) = 0;\n }\n break;\n\n case 145:\n#line 3748 \"parser.y\"\n {\n\t\t Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, \"Explicit template instantiation ignored.\\n\");\n (yyval.node) = 0; \n }\n break;\n\n case 146:\n#line 3754 \"parser.y\"\n {\n\t\t (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 147:\n#line 3757 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 148:\n#line 3760 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 149:\n#line 3763 \"parser.y\"\n {\n\t\t (yyval.node) = 0;\n }\n break;\n\n case 150:\n#line 3766 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 151:\n#line 3769 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (1)].node);\n }\n break;\n\n case 152:\n#line 3774 \"parser.y\"\n {\n\t\t /* Rip out the parameter names */\n\t\t Parm *p = (yyvsp[(1) - (1)].pl);\n\t\t (yyval.tparms) = (yyvsp[(1) - (1)].pl);\n\n\t\t while (p) {\n\t\t String *name = Getattr(p,\"name\");\n\t\t if (!name) {\n\t\t /* Hmmm. Maybe it's a 'class T' parameter */\n\t\t char *type = Char(Getattr(p,\"type\"));\n\t\t /* Template template parameter */\n\t\t if (strncmp(type,\"template \",16) == 0) {\n\t\t\ttype += 16;\n\t\t }\n\t\t if ((strncmp(type,\"class \",6) == 0) || (strncmp(type,\"typename \", 9) == 0)) {\n\t\t\tchar *t = strchr(type,' ');\n\t\t\tSetattr(p,\"name\", t+1);\n\t\t } else {\n\t\t\t/*\n\t\t\t Swig_error(cparse_file, cparse_line, \"Missing template parameter name\\n\");\n\t\t\t $$.rparms = 0;\n\t\t\t $$.parms = 0;\n\t\t\t break; */\n\t\t }\n\t\t }\n\t\t p = nextSibling(p);\n\t\t }\n }\n break;\n\n case 153:\n#line 3804 \"parser.y\"\n {\n set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl));\n (yyval.pl) = (yyvsp[(1) - (2)].p);\n }\n break;\n\n case 154:\n#line 3808 \"parser.y\"\n { (yyval.pl) = 0; }\n break;\n\n case 155:\n#line 3811 \"parser.y\"\n {\n\t\t (yyval.p) = NewParm(NewString((yyvsp[(1) - (1)].id)), 0);\n }\n break;\n\n case 156:\n#line 3814 \"parser.y\"\n {\n (yyval.p) = (yyvsp[(1) - (1)].p);\n }\n break;\n\n case 157:\n#line 3819 \"parser.y\"\n {\n set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl));\n (yyval.pl) = (yyvsp[(2) - (3)].p);\n }\n break;\n\n case 158:\n#line 3823 \"parser.y\"\n { (yyval.pl) = 0; }\n break;\n\n case 159:\n#line 3828 \"parser.y\"\n {\n String *uname = Swig_symbol_type_qualify((yyvsp[(2) - (3)].str),0);\n\t\t String *name = Swig_scopename_last((yyvsp[(2) - (3)].str));\n (yyval.node) = new_node(\"using\");\n\t\t Setattr((yyval.node),\"uname\",uname);\n\t\t Setattr((yyval.node),\"name\", name);\n\t\t Delete(uname);\n\t\t Delete(name);\n\t\t add_symbols((yyval.node));\n }\n break;\n\n case 160:\n#line 3838 \"parser.y\"\n {\n\t Node *n = Swig_symbol_clookup((yyvsp[(3) - (4)].str),0);\n\t if (!n) {\n\t\t Swig_error(cparse_file, cparse_line, \"Nothing known about namespace '%s'\\n\", (yyvsp[(3) - (4)].str));\n\t\t (yyval.node) = 0;\n\t } else {\n\n\t\t while (Strcmp(nodeType(n),\"using\") == 0) {\n\t\t n = Getattr(n,\"node\");\n\t\t }\n\t\t if (n) {\n\t\t if (Strcmp(nodeType(n),\"namespace\") == 0) {\n\t\t Symtab *current = Swig_symbol_current();\n\t\t Symtab *symtab = Getattr(n,\"symtab\");\n\t\t (yyval.node) = new_node(\"using\");\n\t\t Setattr((yyval.node),\"node\",n);\n\t\t Setattr((yyval.node),\"namespace\", (yyvsp[(3) - (4)].str));\n\t\t if (current != symtab) {\n\t\t Swig_symbol_inherit(symtab);\n\t\t }\n\t\t } else {\n\t\t Swig_error(cparse_file, cparse_line, \"'%s' is not a namespace.\\n\", (yyvsp[(3) - (4)].str));\n\t\t (yyval.node) = 0;\n\t\t }\n\t\t } else {\n\t\t (yyval.node) = 0;\n\t\t }\n\t }\n }\n break;\n\n case 161:\n#line 3869 \"parser.y\"\n { \n Hash *h;\n (yyvsp[(1) - (3)].node) = Swig_symbol_current();\n\t\th = Swig_symbol_clookup((yyvsp[(2) - (3)].str),0);\n\t\tif (h && ((yyvsp[(1) - (3)].node) == Getattr(h,\"sym:symtab\")) && (Strcmp(nodeType(h),\"namespace\") == 0)) {\n\t\t if (Getattr(h,\"alias\")) {\n\t\t h = Getattr(h,\"namespace\");\n\t\t Swig_warning(WARN_PARSE_NAMESPACE_ALIAS, cparse_file, cparse_line, \"Namespace alias '%s' not allowed here. Assuming '%s'\\n\",\n\t\t\t\t (yyvsp[(2) - (3)].str), Getattr(h,\"name\"));\n\t\t (yyvsp[(2) - (3)].str) = Getattr(h,\"name\");\n\t\t }\n\t\t Swig_symbol_setscope(Getattr(h,\"symtab\"));\n\t\t} else {\n\t\t Swig_symbol_newscope();\n\t\t Swig_symbol_setscopename((yyvsp[(2) - (3)].str));\n\t\t}\n\t\tDelete(Namespaceprefix);\n\t\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n }\n break;\n\n case 162:\n#line 3887 \"parser.y\"\n {\n Node *n = (yyvsp[(5) - (6)].node);\n\t\tset_nodeType(n,\"namespace\");\n\t\tSetattr(n,\"name\",(yyvsp[(2) - (6)].str));\n Setattr(n,\"symtab\", Swig_symbol_popscope());\n\t\tSwig_symbol_setscope((yyvsp[(1) - (6)].node));\n\t\t(yyval.node) = n;\n\t\tDelete(Namespaceprefix);\n\t\tNamespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t\tadd_symbols((yyval.node));\n }\n break;\n\n case 163:\n#line 3898 \"parser.y\"\n {\n\t Hash *h;\n\t (yyvsp[(1) - (2)].node) = Swig_symbol_current();\n\t h = Swig_symbol_clookup((char *)\" \",0);\n\t if (h && (Strcmp(nodeType(h),\"namespace\") == 0)) {\n\t\t Swig_symbol_setscope(Getattr(h,\"symtab\"));\n\t } else {\n\t\t Swig_symbol_newscope();\n\t\t /* we don't use \"__unnamed__\", but a long 'empty' name */\n\t\t Swig_symbol_setscopename(\" \");\n\t }\n\t Namespaceprefix = 0;\n }\n break;\n\n case 164:\n#line 3910 \"parser.y\"\n {\n\t (yyval.node) = (yyvsp[(4) - (5)].node);\n\t set_nodeType((yyval.node),\"namespace\");\n\t Setattr((yyval.node),\"unnamed\",\"1\");\n\t Setattr((yyval.node),\"symtab\", Swig_symbol_popscope());\n\t Swig_symbol_setscope((yyvsp[(1) - (5)].node));\n\t Delete(Namespaceprefix);\n\t Namespaceprefix = Swig_symbol_qualifiedscopename(0);\n\t add_symbols((yyval.node));\n }\n break;\n\n case 165:\n#line 3920 \"parser.y\"\n {\n\t /* Namespace alias */\n\t Node *n;\n\t (yyval.node) = new_node(\"namespace\");\n\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (5)].id));\n\t Setattr((yyval.node),\"alias\",(yyvsp[(4) - (5)].str));\n\t n = Swig_symbol_clookup((yyvsp[(4) - (5)].str),0);\n\t if (!n) {\n\t\t Swig_error(cparse_file, cparse_line, \"Unknown namespace '%s'\\n\", (yyvsp[(4) - (5)].str));\n\t\t (yyval.node) = 0;\n\t } else {\n\t\t if (Strcmp(nodeType(n),\"namespace\") != 0) {\n\t\t Swig_error(cparse_file, cparse_line, \"'%s' is not a namespace\\n\",(yyvsp[(4) - (5)].str));\n\t\t (yyval.node) = 0;\n\t\t } else {\n\t\t while (Getattr(n,\"alias\")) {\n\t\t n = Getattr(n,\"namespace\");\n\t\t }\n\t\t Setattr((yyval.node),\"namespace\",n);\n\t\t add_symbols((yyval.node));\n\t\t /* Set up a scope alias */\n\t\t Swig_symbol_alias((yyvsp[(2) - (5)].id),Getattr(n,\"symtab\"));\n\t\t }\n\t }\n }\n break;\n\n case 166:\n#line 3947 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(1) - (2)].node);\n /* Insert cpp_member (including any siblings) to the front of the cpp_members linked list */\n\t\t if ((yyval.node)) {\n\t\t Node *p = (yyval.node);\n\t\t Node *pp =0;\n\t\t while (p) {\n\t\t pp = p;\n\t\t p = nextSibling(p);\n\t\t }\n\t\t set_nextSibling(pp,(yyvsp[(2) - (2)].node));\n\t\t } else {\n\t\t (yyval.node) = (yyvsp[(2) - (2)].node);\n\t\t }\n }\n break;\n\n case 167:\n#line 3962 \"parser.y\"\n { \n if (cplus_mode != CPLUS_PUBLIC) {\n\t\t Swig_error(cparse_file,cparse_line,\"%%extend can only be used in a public section\\n\");\n\t\t }\n }\n break;\n\n case 168:\n#line 3966 \"parser.y\"\n {\n\t (yyval.node) = new_node(\"extend\");\n\t tag_nodes((yyvsp[(4) - (6)].node),\"feature:extend\",(char*) \"1\");\n\t appendChild((yyval.node),(yyvsp[(4) - (6)].node));\n\t set_nextSibling((yyval.node),(yyvsp[(6) - (6)].node));\n\t }\n break;\n\n case 169:\n#line 3972 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 170:\n#line 3973 \"parser.y\"\n { (yyval.node) = 0;}\n break;\n\n case 171:\n#line 3974 \"parser.y\"\n {\n\t int start_line = cparse_line;\n\t skip_decl();\n\t Swig_error(cparse_file,start_line,\"Syntax error in input(3).\\n\");\n\t exit(1);\n\t }\n break;\n\n case 172:\n#line 3979 \"parser.y\"\n { \n\t\t (yyval.node) = (yyvsp[(3) - (3)].node);\n \t }\n break;\n\n case 173:\n#line 3990 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 174:\n#line 3991 \"parser.y\"\n { \n (yyval.node) = (yyvsp[(1) - (1)].node); \n\t\t if (extendmode) {\n\t\t String *symname;\n\t\t symname= make_name((yyval.node),Getattr((yyval.node),\"name\"), Getattr((yyval.node),\"decl\"));\n\t\t if (Strcmp(symname,Getattr((yyval.node),\"name\")) == 0) {\n\t\t /* No renaming operation. Set name to class name */\n\t\t Delete(yyrename);\n\t\t yyrename = NewString(Getattr(current_class,\"sym:name\"));\n\t\t } else {\n\t\t Delete(yyrename);\n\t\t yyrename = symname;\n\t\t }\n\t\t }\n\t\t add_symbols((yyval.node));\n default_arguments((yyval.node));\n }\n break;\n\n case 175:\n#line 4008 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 176:\n#line 4009 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 177:\n#line 4010 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 178:\n#line 4011 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 179:\n#line 4012 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 180:\n#line 4013 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 181:\n#line 4014 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 182:\n#line 4015 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 183:\n#line 4016 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 184:\n#line 4017 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 185:\n#line 4018 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 186:\n#line 4019 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 187:\n#line 4020 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 188:\n#line 4021 \"parser.y\"\n {(yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 189:\n#line 4022 \"parser.y\"\n {(yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 190:\n#line 4023 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 191:\n#line 4032 \"parser.y\"\n {\n if (Classprefix) {\n\t\t SwigType *decl = NewStringEmpty();\n\t\t (yyval.node) = new_node(\"constructor\");\n\t\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (6)].id));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (6)].type));\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(4) - (6)].pl));\n\t\t SwigType_add_function(decl,(yyvsp[(4) - (6)].pl));\n\t\t Setattr((yyval.node),\"decl\",decl);\n\t\t Setattr((yyval.node),\"throws\",(yyvsp[(6) - (6)].decl).throws);\n\t\t Setattr((yyval.node),\"throw\",(yyvsp[(6) - (6)].decl).throwf);\n\t\t if (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n\t\t }\n\t\t SetFlag((yyval.node),\"feature:new\");\n\t } else {\n\t\t(yyval.node) = 0;\n }\n }\n break;\n\n case 192:\n#line 4057 \"parser.y\"\n {\n String *name = NewStringf(\"%s\",(yyvsp[(2) - (6)].str));\n\t if (*(Char(name)) != '~') Insert(name,0,\"~\");\n (yyval.node) = new_node(\"destructor\");\n\t Setattr((yyval.node),\"name\",name);\n\t Delete(name);\n\t if (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n\t }\n\t {\n\t\t String *decl = NewStringEmpty();\n\t\t SwigType_add_function(decl,(yyvsp[(4) - (6)].pl));\n\t\t Setattr((yyval.node),\"decl\",decl);\n\t\t Delete(decl);\n\t }\n\t Setattr((yyval.node),\"throws\",(yyvsp[(6) - (6)].dtype).throws);\n\t Setattr((yyval.node),\"throw\",(yyvsp[(6) - (6)].dtype).throwf);\n\t add_symbols((yyval.node));\n\t }\n break;\n\n case 193:\n#line 4081 \"parser.y\"\n {\n\t\tString *name;\n\t\tchar *c = 0;\n\t\t(yyval.node) = new_node(\"destructor\");\n\t /* Check for template names. If the class is a template\n\t\t and the constructor is missing the template part, we\n\t\t add it */\n\t if (Classprefix && (c = strchr(Char(Classprefix),'<'))) {\n\t\t if (!Strchr((yyvsp[(3) - (7)].str),'<')) {\n\t\t (yyvsp[(3) - (7)].str) = NewStringf(\"%s%s\",(yyvsp[(3) - (7)].str),c);\n\t\t }\n\t\t}\n\t\tSetattr((yyval.node),\"storage\",\"virtual\");\n\t name = NewStringf(\"%s\",(yyvsp[(3) - (7)].str));\n\t\tif (*(Char(name)) != '~') Insert(name,0,\"~\");\n\t\tSetattr((yyval.node),\"name\",name);\n\t\tDelete(name);\n\t\tSetattr((yyval.node),\"throws\",(yyvsp[(7) - (7)].dtype).throws);\n\t\tSetattr((yyval.node),\"throw\",(yyvsp[(7) - (7)].dtype).throwf);\n\t\tif ((yyvsp[(7) - (7)].dtype).val) {\n\t\t Setattr((yyval.node),\"value\",\"0\");\n\t\t}\n\t\tif (Len(scanner_ccode)) {\n\t\t String *code = Copy(scanner_ccode);\n\t\t Setattr((yyval.node),\"code\",code);\n\t\t Delete(code);\n\t\t}\n\t\t{\n\t\t String *decl = NewStringEmpty();\n\t\t SwigType_add_function(decl,(yyvsp[(5) - (7)].pl));\n\t\t Setattr((yyval.node),\"decl\",decl);\n\t\t Delete(decl);\n\t\t}\n\n\t\tadd_symbols((yyval.node));\n\t }\n break;\n\n case 194:\n#line 4121 \"parser.y\"\n {\n (yyval.node) = new_node(\"cdecl\");\n Setattr((yyval.node),\"type\",(yyvsp[(3) - (8)].type));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (8)].str));\n\t\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (8)].id));\n\n\t\t SwigType_add_function((yyvsp[(4) - (8)].type),(yyvsp[(6) - (8)].pl));\n\t\t if ((yyvsp[(8) - (8)].dtype).qualifier) {\n\t\t SwigType_push((yyvsp[(4) - (8)].type),(yyvsp[(8) - (8)].dtype).qualifier);\n\t\t }\n\t\t Setattr((yyval.node),\"decl\",(yyvsp[(4) - (8)].type));\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(6) - (8)].pl));\n\t\t Setattr((yyval.node),\"conversion_operator\",\"1\");\n\t\t add_symbols((yyval.node));\n }\n break;\n\n case 195:\n#line 4136 \"parser.y\"\n {\n\t\t SwigType *decl;\n (yyval.node) = new_node(\"cdecl\");\n Setattr((yyval.node),\"type\",(yyvsp[(3) - (8)].type));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (8)].str));\n\t\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (8)].id));\n\t\t decl = NewStringEmpty();\n\t\t SwigType_add_reference(decl);\n\t\t SwigType_add_function(decl,(yyvsp[(6) - (8)].pl));\n\t\t if ((yyvsp[(8) - (8)].dtype).qualifier) {\n\t\t SwigType_push(decl,(yyvsp[(8) - (8)].dtype).qualifier);\n\t\t }\n\t\t Setattr((yyval.node),\"decl\",decl);\n\t\t Setattr((yyval.node),\"parms\",(yyvsp[(6) - (8)].pl));\n\t\t Setattr((yyval.node),\"conversion_operator\",\"1\");\n\t\t add_symbols((yyval.node));\n\t }\n break;\n\n case 196:\n#line 4154 \"parser.y\"\n {\n\t\tString *t = NewStringEmpty();\n\t\t(yyval.node) = new_node(\"cdecl\");\n\t\tSetattr((yyval.node),\"type\",(yyvsp[(3) - (7)].type));\n\t\tSetattr((yyval.node),\"name\",(yyvsp[(2) - (7)].str));\n\t\t Setattr((yyval.node),\"storage\",(yyvsp[(1) - (7)].id));\n\t\tSwigType_add_function(t,(yyvsp[(5) - (7)].pl));\n\t\tif ((yyvsp[(7) - (7)].dtype).qualifier) {\n\t\t SwigType_push(t,(yyvsp[(7) - (7)].dtype).qualifier);\n\t\t}\n\t\tSetattr((yyval.node),\"decl\",t);\n\t\tSetattr((yyval.node),\"parms\",(yyvsp[(5) - (7)].pl));\n\t\tSetattr((yyval.node),\"conversion_operator\",\"1\");\n\t\tadd_symbols((yyval.node));\n }\n break;\n\n case 197:\n#line 4173 \"parser.y\"\n {\n skip_balanced('{','}');\n (yyval.node) = 0;\n }\n break;\n\n case 198:\n#line 4180 \"parser.y\"\n { \n (yyval.node) = new_node(\"access\");\n\t\tSetattr((yyval.node),\"kind\",\"public\");\n cplus_mode = CPLUS_PUBLIC;\n }\n break;\n\n case 199:\n#line 4187 \"parser.y\"\n { \n (yyval.node) = new_node(\"access\");\n Setattr((yyval.node),\"kind\",\"private\");\n\t\tcplus_mode = CPLUS_PRIVATE;\n\t }\n break;\n\n case 200:\n#line 4195 \"parser.y\"\n { \n\t\t(yyval.node) = new_node(\"access\");\n\t\tSetattr((yyval.node),\"kind\",\"protected\");\n\t\tcplus_mode = CPLUS_PROTECTED;\n\t }\n break;\n\n case 201:\n#line 4218 \"parser.y\"\n { cparse_start_line = cparse_line; skip_balanced('{','}');\n\t }\n break;\n\n case 202:\n#line 4219 \"parser.y\"\n {\n\t (yyval.node) = 0;\n\t\tif (cplus_mode == CPLUS_PUBLIC) {\n\t\t if ((yyvsp[(6) - (7)].decl).id && strcmp((yyvsp[(2) - (7)].id), \"class\") != 0) {\n\t\t Nested *n = (Nested *) malloc(sizeof(Nested));\n\t\t n->code = NewStringEmpty();\n\t\t Printv(n->code, \"typedef \", (yyvsp[(2) - (7)].id), \" \",\n\t\t\t Char(scanner_ccode), \" $classname_\", (yyvsp[(6) - (7)].decl).id, \";\\n\", NIL);\n\n\t\t n->name = Swig_copy_string((yyvsp[(6) - (7)].decl).id);\n\t\t n->line = cparse_start_line;\n\t\t n->type = NewStringEmpty();\n\t\t n->kind = (yyvsp[(2) - (7)].id);\n\t\t n->unnamed = 0;\n\t\t SwigType_push(n->type, (yyvsp[(6) - (7)].decl).type);\n\t\t n->next = 0;\n\t\t add_nested(n);\n\t\t } else {\n\t\t Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, \"Nested %s not currently supported (ignored).\\n\", (yyvsp[(2) - (7)].id));\n\t\t if (strcmp((yyvsp[(2) - (7)].id), \"class\") == 0) {\n\t\t /* For now, just treat the nested class as a forward\n\t\t * declaration (SF bug #909387). */\n\t\t (yyval.node) = new_node(\"classforward\");\n\t\t Setfile((yyval.node),cparse_file);\n\t\t Setline((yyval.node),cparse_line);\n\t\t Setattr((yyval.node),\"kind\",(yyvsp[(2) - (7)].id));\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(3) - (7)].id));\n\t\t Setattr((yyval.node),\"sym:weak\", \"1\");\n\t\t add_symbols((yyval.node));\n\t\t }\n\t\t }\n\t\t}\n\t }\n break;\n\n case 203:\n#line 4253 \"parser.y\"\n { cparse_start_line = cparse_line; skip_balanced('{','}');\n }\n break;\n\n case 204:\n#line 4254 \"parser.y\"\n {\n\t (yyval.node) = 0;\n\t\tif (cplus_mode == CPLUS_PUBLIC) {\n\t\t if (strcmp((yyvsp[(2) - (6)].id),\"class\") == 0) {\n\t\t Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,\"Nested class not currently supported (ignored)\\n\");\n\t\t /* Generate some code for a new class */\n\t\t } else if ((yyvsp[(5) - (6)].decl).id) {\n\t\t /* Generate some code for a new class */\n\t\t Nested *n = (Nested *) malloc(sizeof(Nested));\n\t\t n->code = NewStringEmpty();\n\t\t Printv(n->code, \"typedef \", (yyvsp[(2) - (6)].id), \" \" ,\n\t\t\t Char(scanner_ccode), \" $classname_\", (yyvsp[(5) - (6)].decl).id, \";\\n\",NIL);\n\t\t n->name = Swig_copy_string((yyvsp[(5) - (6)].decl).id);\n\t\t n->line = cparse_start_line;\n\t\t n->type = NewStringEmpty();\n\t\t n->kind = (yyvsp[(2) - (6)].id);\n\t\t n->unnamed = 1;\n\t\t SwigType_push(n->type,(yyvsp[(5) - (6)].decl).type);\n\t\t n->next = 0;\n\t\t add_nested(n);\n\t\t } else {\n\t\t Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, \"Nested %s not currently supported (ignored).\\n\", (yyvsp[(2) - (6)].id));\n\t\t }\n\t\t}\n\t }\n break;\n\n case 205:\n#line 4284 \"parser.y\"\n { cparse_start_line = cparse_line; skip_balanced('{','}');\n }\n break;\n\n case 206:\n#line 4285 \"parser.y\"\n {\n\t (yyval.node) = 0;\n\t\tif (cplus_mode == CPLUS_PUBLIC) {\n\t\t Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,\"Nested class not currently supported (ignored)\\n\");\n\t\t}\n\t }\n break;\n\n case 207:\n#line 4302 \"parser.y\"\n { (yyval.decl) = (yyvsp[(1) - (1)].decl);}\n break;\n\n case 208:\n#line 4303 \"parser.y\"\n { (yyval.decl).id = 0; }\n break;\n\n case 209:\n#line 4309 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 210:\n#line 4312 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 211:\n#line 4316 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 212:\n#line 4319 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 213:\n#line 4320 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 214:\n#line 4321 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 215:\n#line 4322 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 216:\n#line 4323 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 217:\n#line 4324 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 218:\n#line 4325 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 219:\n#line 4326 \"parser.y\"\n { (yyval.node) = (yyvsp[(1) - (1)].node); }\n break;\n\n case 220:\n#line 4329 \"parser.y\"\n {\n\t Clear(scanner_ccode);\n\t\t (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws;\n\t\t (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf;\n }\n break;\n\n case 221:\n#line 4334 \"parser.y\"\n { \n\t\t skip_balanced('{','}'); \n\t\t (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws;\n\t\t (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf;\n\t }\n break;\n\n case 222:\n#line 4341 \"parser.y\"\n { \n Clear(scanner_ccode);\n (yyval.dtype).val = 0;\n (yyval.dtype).qualifier = (yyvsp[(1) - (2)].dtype).qualifier;\n (yyval.dtype).bitfield = 0;\n (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws;\n (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf;\n }\n break;\n\n case 223:\n#line 4349 \"parser.y\"\n { \n Clear(scanner_ccode);\n (yyval.dtype).val = (yyvsp[(3) - (4)].dtype).val;\n (yyval.dtype).qualifier = (yyvsp[(1) - (4)].dtype).qualifier;\n (yyval.dtype).bitfield = 0;\n (yyval.dtype).throws = (yyvsp[(1) - (4)].dtype).throws; \n (yyval.dtype).throwf = (yyvsp[(1) - (4)].dtype).throwf; \n }\n break;\n\n case 224:\n#line 4357 \"parser.y\"\n { \n skip_balanced('{','}');\n (yyval.dtype).val = 0;\n (yyval.dtype).qualifier = (yyvsp[(1) - (2)].dtype).qualifier;\n (yyval.dtype).bitfield = 0;\n (yyval.dtype).throws = (yyvsp[(1) - (2)].dtype).throws; \n (yyval.dtype).throwf = (yyvsp[(1) - (2)].dtype).throwf; \n }\n break;\n\n case 225:\n#line 4368 \"parser.y\"\n { }\n break;\n\n case 226:\n#line 4374 \"parser.y\"\n { (yyval.id) = \"extern\"; }\n break;\n\n case 227:\n#line 4375 \"parser.y\"\n { \n if (strcmp((yyvsp[(2) - (2)].id),\"C\") == 0) {\n\t\t (yyval.id) = \"externc\";\n\t\t } else {\n\t\t Swig_warning(WARN_PARSE_UNDEFINED_EXTERN,cparse_file, cparse_line,\"Unrecognized extern type \\\"%s\\\".\\n\", (yyvsp[(2) - (2)].id));\n\t\t (yyval.id) = 0;\n\t\t }\n }\n break;\n\n case 228:\n#line 4383 \"parser.y\"\n { (yyval.id) = \"static\"; }\n break;\n\n case 229:\n#line 4384 \"parser.y\"\n { (yyval.id) = \"typedef\"; }\n break;\n\n case 230:\n#line 4385 \"parser.y\"\n { (yyval.id) = \"virtual\"; }\n break;\n\n case 231:\n#line 4386 \"parser.y\"\n { (yyval.id) = \"friend\"; }\n break;\n\n case 232:\n#line 4387 \"parser.y\"\n { (yyval.id) = \"explicit\"; }\n break;\n\n case 233:\n#line 4388 \"parser.y\"\n { (yyval.id) = 0; }\n break;\n\n case 234:\n#line 4395 \"parser.y\"\n {\n Parm *p;\n\t\t (yyval.pl) = (yyvsp[(1) - (1)].pl);\n\t\t p = (yyvsp[(1) - (1)].pl);\n while (p) {\n\t\t Replace(Getattr(p,\"type\"),\"typename \", \"\", DOH_REPLACE_ANY);\n\t\t p = nextSibling(p);\n }\n }\n break;\n\n case 235:\n#line 4406 \"parser.y\"\n {\n\t\t if (1) { \n\t\t set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].pl));\n\t\t (yyval.pl) = (yyvsp[(1) - (2)].p);\n\t\t } else {\n\t\t (yyval.pl) = (yyvsp[(2) - (2)].pl);\n\t\t }\n\t\t}\n break;\n\n case 236:\n#line 4414 \"parser.y\"\n { (yyval.pl) = 0; }\n break;\n\n case 237:\n#line 4417 \"parser.y\"\n {\n set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].pl));\n\t\t (yyval.pl) = (yyvsp[(2) - (3)].p);\n }\n break;\n\n case 238:\n#line 4421 \"parser.y\"\n { (yyval.pl) = 0; }\n break;\n\n case 239:\n#line 4425 \"parser.y\"\n {\n SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type);\n\t\t (yyval.p) = NewParm((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).id);\n\t\t Setfile((yyval.p),cparse_file);\n\t\t Setline((yyval.p),cparse_line);\n\t\t if ((yyvsp[(2) - (2)].decl).defarg) {\n\t\t Setattr((yyval.p),\"value\",(yyvsp[(2) - (2)].decl).defarg);\n\t\t }\n\t\t}\n break;\n\n case 240:\n#line 4435 \"parser.y\"\n {\n (yyval.p) = NewParm(NewStringf(\"template %s %s\", (yyvsp[(5) - (6)].id),(yyvsp[(6) - (6)].str)), 0);\n\t\t Setfile((yyval.p),cparse_file);\n\t\t Setline((yyval.p),cparse_line);\n }\n break;\n\n case 241:\n#line 4440 \"parser.y\"\n {\n\t\t SwigType *t = NewString(\"v(...)\");\n\t\t (yyval.p) = NewParm(t, 0);\n\t\t Setfile((yyval.p),cparse_file);\n\t\t Setline((yyval.p),cparse_line);\n\t\t}\n break;\n\n case 242:\n#line 4448 \"parser.y\"\n {\n Parm *p;\n\t\t (yyval.p) = (yyvsp[(1) - (1)].p);\n\t\t p = (yyvsp[(1) - (1)].p);\n while (p) {\n\t\t if (Getattr(p,\"type\")) {\n\t\t Replace(Getattr(p,\"type\"),\"typename \", \"\", DOH_REPLACE_ANY);\n\t\t }\n\t\t p = nextSibling(p);\n }\n }\n break;\n\n case 243:\n#line 4461 \"parser.y\"\n {\n\t\t if (1) { \n\t\t set_nextSibling((yyvsp[(1) - (2)].p),(yyvsp[(2) - (2)].p));\n\t\t (yyval.p) = (yyvsp[(1) - (2)].p);\n\t\t } else {\n\t\t (yyval.p) = (yyvsp[(2) - (2)].p);\n\t\t }\n\t\t}\n break;\n\n case 244:\n#line 4469 \"parser.y\"\n { (yyval.p) = 0; }\n break;\n\n case 245:\n#line 4472 \"parser.y\"\n {\n set_nextSibling((yyvsp[(2) - (3)].p),(yyvsp[(3) - (3)].p));\n\t\t (yyval.p) = (yyvsp[(2) - (3)].p);\n }\n break;\n\n case 246:\n#line 4476 \"parser.y\"\n { (yyval.p) = 0; }\n break;\n\n case 247:\n#line 4480 \"parser.y\"\n {\n\t\t (yyval.p) = (yyvsp[(1) - (1)].p);\n\t\t {\n\t\t /* We need to make a possible adjustment for integer parameters. */\n\t\t SwigType *type;\n\t\t Node *n = 0;\n\n\t\t while (!n) {\n\t\t type = Getattr((yyvsp[(1) - (1)].p),\"type\");\n\t\t n = Swig_symbol_clookup(type,0); /* See if we can find a node that matches the typename */\n\t\t if ((n) && (Strcmp(nodeType(n),\"cdecl\") == 0)) {\n\t\t\tSwigType *decl = Getattr(n,\"decl\");\n\t\t\tif (!SwigType_isfunction(decl)) {\n\t\t\t String *value = Getattr(n,\"value\");\n\t\t\t if (value) {\n\t\t\t String *v = Copy(value);\n\t\t\t Setattr((yyvsp[(1) - (1)].p),\"type\",v);\n\t\t\t Delete(v);\n\t\t\t n = 0;\n\t\t\t }\n\t\t\t}\n\t\t } else {\n\t\t\tbreak;\n\t\t }\n\t\t }\n\t\t }\n\n }\n break;\n\n case 248:\n#line 4508 \"parser.y\"\n {\n (yyval.p) = NewParm(0,0);\n Setfile((yyval.p),cparse_file);\n\t\t Setline((yyval.p),cparse_line);\n\t\t Setattr((yyval.p),\"value\",(yyvsp[(1) - (1)].dtype).val);\n }\n break;\n\n case 249:\n#line 4516 \"parser.y\"\n { \n (yyval.dtype) = (yyvsp[(2) - (2)].dtype); \n\t\t if ((yyvsp[(2) - (2)].dtype).type == T_ERROR) {\n\t\t Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, \"Can't set default argument (ignored)\\n\");\n\t\t (yyval.dtype).val = 0;\n\t\t (yyval.dtype).rawval = 0;\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t\t }\n }\n break;\n\n case 250:\n#line 4527 \"parser.y\"\n { \n\t\t (yyval.dtype) = (yyvsp[(2) - (5)].dtype);\n\t\t if ((yyvsp[(2) - (5)].dtype).type == T_ERROR) {\n\t\t Swig_warning(WARN_PARSE_BAD_DEFAULT,cparse_file, cparse_line, \"Can't set default argument (ignored)\\n\");\n\t\t (yyval.dtype) = (yyvsp[(2) - (5)].dtype);\n\t\t (yyval.dtype).val = 0;\n\t\t (yyval.dtype).rawval = 0;\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t\t } else {\n\t\t (yyval.dtype).val = NewStringf(\"%s[%s]\",(yyvsp[(2) - (5)].dtype).val,(yyvsp[(4) - (5)].dtype).val); \n\t\t }\t\t \n }\n break;\n\n case 251:\n#line 4541 \"parser.y\"\n {\n\t\t skip_balanced('{','}');\n\t\t (yyval.dtype).val = 0;\n\t\t (yyval.dtype).rawval = 0;\n (yyval.dtype).type = T_INT;\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t }\n break;\n\n case 252:\n#line 4550 \"parser.y\"\n { \n\t\t (yyval.dtype).val = 0;\n\t\t (yyval.dtype).rawval = 0;\n\t\t (yyval.dtype).type = 0;\n\t\t (yyval.dtype).bitfield = (yyvsp[(2) - (2)].dtype).val;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t }\n break;\n\n case 253:\n#line 4558 \"parser.y\"\n {\n (yyval.dtype).val = 0;\n (yyval.dtype).rawval = 0;\n (yyval.dtype).type = T_INT;\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n }\n break;\n\n case 254:\n#line 4568 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(1) - (2)].decl);\n\t\t (yyval.decl).defarg = (yyvsp[(2) - (2)].dtype).rawval ? (yyvsp[(2) - (2)].dtype).rawval : (yyvsp[(2) - (2)].dtype).val;\n }\n break;\n\n case 255:\n#line 4572 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(1) - (2)].decl);\n\t (yyval.decl).defarg = (yyvsp[(2) - (2)].dtype).rawval ? (yyvsp[(2) - (2)].dtype).rawval : (yyvsp[(2) - (2)].dtype).val;\n }\n break;\n\n case 256:\n#line 4576 \"parser.y\"\n {\n \t (yyval.decl).type = 0;\n (yyval.decl).id = 0;\n\t (yyval.decl).defarg = (yyvsp[(1) - (1)].dtype).rawval ? (yyvsp[(1) - (1)].dtype).rawval : (yyvsp[(1) - (1)].dtype).val;\n }\n break;\n\n case 257:\n#line 4583 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(1) - (1)].decl);\n\t\t if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) {\n\t\t Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type));\n\t\t } else if (SwigType_isarray((yyvsp[(1) - (1)].decl).type)) {\n\t\t SwigType *ta = SwigType_pop_arrays((yyvsp[(1) - (1)].decl).type);\n\t\t if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) {\n\t\t Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type));\n\t\t } else {\n\t\t (yyval.decl).parms = 0;\n\t\t }\n\t\t SwigType_push((yyvsp[(1) - (1)].decl).type,ta);\n\t\t Delete(ta);\n\t\t } else {\n\t\t (yyval.decl).parms = 0;\n\t\t }\n }\n break;\n\n case 258:\n#line 4600 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(1) - (1)].decl);\n\t if (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) {\n\t\tDelete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type));\n\t } else if (SwigType_isarray((yyvsp[(1) - (1)].decl).type)) {\n\t\tSwigType *ta = SwigType_pop_arrays((yyvsp[(1) - (1)].decl).type);\n\t\tif (SwigType_isfunction((yyvsp[(1) - (1)].decl).type)) {\n\t\t Delete(SwigType_pop_function((yyvsp[(1) - (1)].decl).type));\n\t\t} else {\n\t\t (yyval.decl).parms = 0;\n\t\t}\n\t\tSwigType_push((yyvsp[(1) - (1)].decl).type,ta);\n\t\tDelete(ta);\n\t } else {\n\t\t(yyval.decl).parms = 0;\n\t }\n }\n break;\n\n case 259:\n#line 4617 \"parser.y\"\n {\n \t (yyval.decl).type = 0;\n (yyval.decl).id = 0;\n\t (yyval.decl).parms = 0;\n\t }\n break;\n\n case 260:\n#line 4625 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(2) - (2)].decl);\n\t if ((yyval.decl).type) {\n\t\tSwigType_push((yyvsp[(1) - (2)].type),(yyval.decl).type);\n\t\tDelete((yyval.decl).type);\n\t }\n\t (yyval.decl).type = (yyvsp[(1) - (2)].type);\n }\n break;\n\n case 261:\n#line 4633 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(3) - (3)].decl);\n\t SwigType_add_reference((yyvsp[(1) - (3)].type));\n if ((yyval.decl).type) {\n\t\tSwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type);\n\t\tDelete((yyval.decl).type);\n\t }\n\t (yyval.decl).type = (yyvsp[(1) - (3)].type);\n }\n break;\n\n case 262:\n#line 4642 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(1) - (1)].decl);\n\t if (!(yyval.decl).type) (yyval.decl).type = NewStringEmpty();\n }\n break;\n\n case 263:\n#line 4646 \"parser.y\"\n { \n\t (yyval.decl) = (yyvsp[(2) - (2)].decl);\n\t (yyval.decl).type = NewStringEmpty();\n\t SwigType_add_reference((yyval.decl).type);\n\t if ((yyvsp[(2) - (2)].decl).type) {\n\t SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type);\n\t Delete((yyvsp[(2) - (2)].decl).type);\n\t }\n }\n break;\n\n case 264:\n#line 4655 \"parser.y\"\n { \n\t SwigType *t = NewStringEmpty();\n\n\t (yyval.decl) = (yyvsp[(3) - (3)].decl);\n\t SwigType_add_memberpointer(t,(yyvsp[(1) - (3)].str));\n\t if ((yyval.decl).type) {\n\t SwigType_push(t,(yyval.decl).type);\n\t Delete((yyval.decl).type);\n\t }\n\t (yyval.decl).type = t;\n\t }\n break;\n\n case 265:\n#line 4666 \"parser.y\"\n { \n\t SwigType *t = NewStringEmpty();\n\t (yyval.decl) = (yyvsp[(4) - (4)].decl);\n\t SwigType_add_memberpointer(t,(yyvsp[(2) - (4)].str));\n\t SwigType_push((yyvsp[(1) - (4)].type),t);\n\t if ((yyval.decl).type) {\n\t SwigType_push((yyvsp[(1) - (4)].type),(yyval.decl).type);\n\t Delete((yyval.decl).type);\n\t }\n\t (yyval.decl).type = (yyvsp[(1) - (4)].type);\n\t Delete(t);\n\t }\n break;\n\n case 266:\n#line 4678 \"parser.y\"\n { \n\t (yyval.decl) = (yyvsp[(5) - (5)].decl);\n\t SwigType_add_memberpointer((yyvsp[(1) - (5)].type),(yyvsp[(2) - (5)].str));\n\t SwigType_add_reference((yyvsp[(1) - (5)].type));\n\t if ((yyval.decl).type) {\n\t SwigType_push((yyvsp[(1) - (5)].type),(yyval.decl).type);\n\t Delete((yyval.decl).type);\n\t }\n\t (yyval.decl).type = (yyvsp[(1) - (5)].type);\n\t }\n break;\n\n case 267:\n#line 4688 \"parser.y\"\n { \n\t SwigType *t = NewStringEmpty();\n\t (yyval.decl) = (yyvsp[(4) - (4)].decl);\n\t SwigType_add_memberpointer(t,(yyvsp[(1) - (4)].str));\n\t SwigType_add_reference(t);\n\t if ((yyval.decl).type) {\n\t SwigType_push(t,(yyval.decl).type);\n\t Delete((yyval.decl).type);\n\t } \n\t (yyval.decl).type = t;\n\t }\n break;\n\n case 268:\n#line 4701 \"parser.y\"\n {\n /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */\n (yyval.decl).id = Char((yyvsp[(1) - (1)].str));\n\t\t (yyval.decl).type = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n }\n break;\n\n case 269:\n#line 4708 \"parser.y\"\n {\n (yyval.decl).id = Char(NewStringf(\"~%s\",(yyvsp[(2) - (2)].str)));\n (yyval.decl).type = 0;\n (yyval.decl).parms = 0;\n (yyval.decl).have_parms = 0;\n }\n break;\n\n case 270:\n#line 4716 \"parser.y\"\n {\n (yyval.decl).id = Char((yyvsp[(2) - (3)].str));\n (yyval.decl).type = 0;\n (yyval.decl).parms = 0;\n (yyval.decl).have_parms = 0;\n }\n break;\n\n case 271:\n#line 4732 \"parser.y\"\n {\n\t\t (yyval.decl) = (yyvsp[(3) - (4)].decl);\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push((yyvsp[(2) - (4)].type),(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = (yyvsp[(2) - (4)].type);\n }\n break;\n\n case 272:\n#line 4740 \"parser.y\"\n {\n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(4) - (5)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_memberpointer(t,(yyvsp[(2) - (5)].str));\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n\t\t }\n break;\n\n case 273:\n#line 4751 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (3)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(char*)\"\");\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 274:\n#line 4762 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val);\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 275:\n#line 4773 \"parser.y\"\n {\n\t\t SwigType *t;\n (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_function(t,(yyvsp[(3) - (4)].pl));\n\t\t if (!(yyval.decl).have_parms) {\n\t\t (yyval.decl).parms = (yyvsp[(3) - (4)].pl);\n\t\t (yyval.decl).have_parms = 1;\n\t\t }\n\t\t if (!(yyval.decl).type) {\n\t\t (yyval.decl).type = t;\n\t\t } else {\n\t\t SwigType_push(t, (yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t (yyval.decl).type = t;\n\t\t }\n\t\t }\n break;\n\n case 276:\n#line 4792 \"parser.y\"\n {\n /* Note: This is non-standard C. Template declarator is allowed to follow an identifier */\n (yyval.decl).id = Char((yyvsp[(1) - (1)].str));\n\t\t (yyval.decl).type = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n }\n break;\n\n case 277:\n#line 4800 \"parser.y\"\n {\n (yyval.decl).id = Char(NewStringf(\"~%s\",(yyvsp[(2) - (2)].str)));\n (yyval.decl).type = 0;\n (yyval.decl).parms = 0;\n (yyval.decl).have_parms = 0;\n }\n break;\n\n case 278:\n#line 4817 \"parser.y\"\n {\n\t\t (yyval.decl) = (yyvsp[(3) - (4)].decl);\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push((yyvsp[(2) - (4)].type),(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = (yyvsp[(2) - (4)].type);\n }\n break;\n\n case 279:\n#line 4825 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(3) - (4)].decl);\n\t\t if (!(yyval.decl).type) {\n\t\t (yyval.decl).type = NewStringEmpty();\n\t\t }\n\t\t SwigType_add_reference((yyval.decl).type);\n }\n break;\n\n case 280:\n#line 4832 \"parser.y\"\n {\n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(4) - (5)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_memberpointer(t,(yyvsp[(2) - (5)].str));\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n\t\t }\n break;\n\n case 281:\n#line 4843 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (3)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(char*)\"\");\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 282:\n#line 4854 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val);\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 283:\n#line 4865 \"parser.y\"\n {\n\t\t SwigType *t;\n (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_function(t,(yyvsp[(3) - (4)].pl));\n\t\t if (!(yyval.decl).have_parms) {\n\t\t (yyval.decl).parms = (yyvsp[(3) - (4)].pl);\n\t\t (yyval.decl).have_parms = 1;\n\t\t }\n\t\t if (!(yyval.decl).type) {\n\t\t (yyval.decl).type = t;\n\t\t } else {\n\t\t SwigType_push(t, (yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t (yyval.decl).type = t;\n\t\t }\n\t\t }\n break;\n\n case 284:\n#line 4884 \"parser.y\"\n {\n\t\t (yyval.decl).type = (yyvsp[(1) - (1)].type);\n (yyval.decl).id = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n }\n break;\n\n case 285:\n#line 4890 \"parser.y\"\n { \n (yyval.decl) = (yyvsp[(2) - (2)].decl);\n SwigType_push((yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].decl).type);\n\t\t (yyval.decl).type = (yyvsp[(1) - (2)].type);\n\t\t Delete((yyvsp[(2) - (2)].decl).type);\n }\n break;\n\n case 286:\n#line 4896 \"parser.y\"\n {\n\t\t (yyval.decl).type = (yyvsp[(1) - (2)].type);\n\t\t SwigType_add_reference((yyval.decl).type);\n\t\t (yyval.decl).id = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n\t\t }\n break;\n\n case 287:\n#line 4903 \"parser.y\"\n {\n\t\t (yyval.decl) = (yyvsp[(3) - (3)].decl);\n\t\t SwigType_add_reference((yyvsp[(1) - (3)].type));\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push((yyvsp[(1) - (3)].type),(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = (yyvsp[(1) - (3)].type);\n }\n break;\n\n case 288:\n#line 4912 \"parser.y\"\n {\n\t\t (yyval.decl) = (yyvsp[(1) - (1)].decl);\n }\n break;\n\n case 289:\n#line 4915 \"parser.y\"\n {\n\t\t (yyval.decl) = (yyvsp[(2) - (2)].decl);\n\t\t (yyval.decl).type = NewStringEmpty();\n\t\t SwigType_add_reference((yyval.decl).type);\n\t\t if ((yyvsp[(2) - (2)].decl).type) {\n\t\t SwigType_push((yyval.decl).type,(yyvsp[(2) - (2)].decl).type);\n\t\t Delete((yyvsp[(2) - (2)].decl).type);\n\t\t }\n }\n break;\n\n case 290:\n#line 4924 \"parser.y\"\n { \n (yyval.decl).id = 0;\n (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n (yyval.decl).type = NewStringEmpty();\n\t\t SwigType_add_reference((yyval.decl).type);\n }\n break;\n\n case 291:\n#line 4931 \"parser.y\"\n { \n\t\t (yyval.decl).type = NewStringEmpty();\n SwigType_add_memberpointer((yyval.decl).type,(yyvsp[(1) - (2)].str));\n (yyval.decl).id = 0;\n (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n \t }\n break;\n\n case 292:\n#line 4938 \"parser.y\"\n { \n\t\t SwigType *t = NewStringEmpty();\n (yyval.decl).type = (yyvsp[(1) - (3)].type);\n\t\t (yyval.decl).id = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n\t\t SwigType_add_memberpointer(t,(yyvsp[(2) - (3)].str));\n\t\t SwigType_push((yyval.decl).type,t);\n\t\t Delete(t);\n }\n break;\n\n case 293:\n#line 4948 \"parser.y\"\n { \n\t\t (yyval.decl) = (yyvsp[(4) - (4)].decl);\n\t\t SwigType_add_memberpointer((yyvsp[(1) - (4)].type),(yyvsp[(2) - (4)].str));\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push((yyvsp[(1) - (4)].type),(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = (yyvsp[(1) - (4)].type);\n }\n break;\n\n case 294:\n#line 4959 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (3)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(char*)\"\");\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 295:\n#line 4970 \"parser.y\"\n { \n\t\t SwigType *t;\n\t\t (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n\t\t SwigType_add_array(t,(yyvsp[(3) - (4)].dtype).val);\n\t\t if ((yyval.decl).type) {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t }\n\t\t (yyval.decl).type = t;\n }\n break;\n\n case 296:\n#line 4981 \"parser.y\"\n { \n\t\t (yyval.decl).type = NewStringEmpty();\n\t\t (yyval.decl).id = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n\t\t SwigType_add_array((yyval.decl).type,(char*)\"\");\n }\n break;\n\n case 297:\n#line 4988 \"parser.y\"\n { \n\t\t (yyval.decl).type = NewStringEmpty();\n\t\t (yyval.decl).id = 0;\n\t\t (yyval.decl).parms = 0;\n\t\t (yyval.decl).have_parms = 0;\n\t\t SwigType_add_array((yyval.decl).type,(yyvsp[(2) - (3)].dtype).val);\n\t\t }\n break;\n\n case 298:\n#line 4995 \"parser.y\"\n {\n (yyval.decl) = (yyvsp[(2) - (3)].decl);\n\t\t }\n break;\n\n case 299:\n#line 4998 \"parser.y\"\n {\n\t\t SwigType *t;\n (yyval.decl) = (yyvsp[(1) - (4)].decl);\n\t\t t = NewStringEmpty();\n SwigType_add_function(t,(yyvsp[(3) - (4)].pl));\n\t\t if (!(yyval.decl).type) {\n\t\t (yyval.decl).type = t;\n\t\t } else {\n\t\t SwigType_push(t,(yyval.decl).type);\n\t\t Delete((yyval.decl).type);\n\t\t (yyval.decl).type = t;\n\t\t }\n\t\t if (!(yyval.decl).have_parms) {\n\t\t (yyval.decl).parms = (yyvsp[(3) - (4)].pl);\n\t\t (yyval.decl).have_parms = 1;\n\t\t }\n\t\t }\n break;\n\n case 300:\n#line 5015 \"parser.y\"\n {\n (yyval.decl).type = NewStringEmpty();\n SwigType_add_function((yyval.decl).type,(yyvsp[(2) - (3)].pl));\n\t\t (yyval.decl).parms = (yyvsp[(2) - (3)].pl);\n\t\t (yyval.decl).have_parms = 1;\n\t\t (yyval.decl).id = 0;\n }\n break;\n\n case 301:\n#line 5025 \"parser.y\"\n { \n (yyval.type) = NewStringEmpty();\n SwigType_add_pointer((yyval.type));\n\t SwigType_push((yyval.type),(yyvsp[(2) - (3)].str));\n\t SwigType_push((yyval.type),(yyvsp[(3) - (3)].type));\n\t Delete((yyvsp[(3) - (3)].type));\n }\n break;\n\n case 302:\n#line 5032 \"parser.y\"\n {\n\t (yyval.type) = NewStringEmpty();\n\t SwigType_add_pointer((yyval.type));\n\t SwigType_push((yyval.type),(yyvsp[(2) - (2)].type));\n\t Delete((yyvsp[(2) - (2)].type));\n\t }\n break;\n\n case 303:\n#line 5038 \"parser.y\"\n { \n\t \t(yyval.type) = NewStringEmpty();\t\n\t\tSwigType_add_pointer((yyval.type));\n\t SwigType_push((yyval.type),(yyvsp[(2) - (2)].str));\n }\n break;\n\n case 304:\n#line 5043 \"parser.y\"\n {\n\t (yyval.type) = NewStringEmpty();\n\t SwigType_add_pointer((yyval.type));\n }\n break;\n\n case 305:\n#line 5049 \"parser.y\"\n {\n\t (yyval.str) = NewStringEmpty();\n\t if ((yyvsp[(1) - (1)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (1)].id));\n }\n break;\n\n case 306:\n#line 5053 \"parser.y\"\n {\n\t\t (yyval.str) = (yyvsp[(2) - (2)].str);\n\t if ((yyvsp[(1) - (2)].id)) SwigType_add_qualifier((yyval.str),(yyvsp[(1) - (2)].id));\n }\n break;\n\n case 307:\n#line 5059 \"parser.y\"\n { (yyval.id) = \"const\"; }\n break;\n\n case 308:\n#line 5060 \"parser.y\"\n { (yyval.id) = \"volatile\"; }\n break;\n\n case 309:\n#line 5061 \"parser.y\"\n { (yyval.id) = 0; }\n break;\n\n case 310:\n#line 5067 \"parser.y\"\n {\n (yyval.type) = (yyvsp[(1) - (1)].type);\n Replace((yyval.type),\"typename \",\"\", DOH_REPLACE_ANY);\n }\n break;\n\n case 311:\n#line 5073 \"parser.y\"\n {\n (yyval.type) = (yyvsp[(2) - (2)].type);\n\t SwigType_push((yyval.type),(yyvsp[(1) - (2)].str));\n }\n break;\n\n case 312:\n#line 5077 \"parser.y\"\n { (yyval.type) = (yyvsp[(1) - (1)].type); }\n break;\n\n case 313:\n#line 5078 \"parser.y\"\n {\n\t\t (yyval.type) = (yyvsp[(1) - (2)].type);\n\t SwigType_push((yyval.type),(yyvsp[(2) - (2)].str));\n\t }\n break;\n\n case 314:\n#line 5082 \"parser.y\"\n {\n\t\t (yyval.type) = (yyvsp[(2) - (3)].type);\n\t SwigType_push((yyval.type),(yyvsp[(3) - (3)].str));\n\t SwigType_push((yyval.type),(yyvsp[(1) - (3)].str));\n\t }\n break;\n\n case 315:\n#line 5089 \"parser.y\"\n { (yyval.type) = (yyvsp[(1) - (1)].type);\n /* Printf(stdout,\"primitive = '%s'\\n\", $$);*/\n }\n break;\n\n case 316:\n#line 5092 \"parser.y\"\n { (yyval.type) = (yyvsp[(1) - (1)].type); }\n break;\n\n case 317:\n#line 5093 \"parser.y\"\n { (yyval.type) = (yyvsp[(1) - (1)].type); }\n break;\n\n case 318:\n#line 5094 \"parser.y\"\n { (yyval.type) = NewStringf(\"%s%s\",(yyvsp[(1) - (2)].type),(yyvsp[(2) - (2)].id)); }\n break;\n\n case 319:\n#line 5095 \"parser.y\"\n { (yyval.type) = NewStringf(\"enum %s\", (yyvsp[(2) - (2)].str)); }\n break;\n\n case 320:\n#line 5096 \"parser.y\"\n { (yyval.type) = (yyvsp[(1) - (1)].type); }\n break;\n\n case 321:\n#line 5098 \"parser.y\"\n {\n\t\t (yyval.type) = (yyvsp[(1) - (1)].str);\n }\n break;\n\n case 322:\n#line 5101 \"parser.y\"\n { \n\t\t (yyval.type) = NewStringf(\"%s %s\", (yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].str));\n }\n break;\n\n case 323:\n#line 5106 \"parser.y\"\n {\n\t\t if (!(yyvsp[(1) - (1)].ptype).type) (yyvsp[(1) - (1)].ptype).type = NewString(\"int\");\n\t\t if ((yyvsp[(1) - (1)].ptype).us) {\n\t\t (yyval.type) = NewStringf(\"%s %s\", (yyvsp[(1) - (1)].ptype).us, (yyvsp[(1) - (1)].ptype).type);\n\t\t Delete((yyvsp[(1) - (1)].ptype).us);\n Delete((yyvsp[(1) - (1)].ptype).type);\n\t\t } else {\n (yyval.type) = (yyvsp[(1) - (1)].ptype).type;\n\t\t }\n\t\t if (Cmp((yyval.type),\"signed int\") == 0) {\n\t\t Delete((yyval.type));\n\t\t (yyval.type) = NewString(\"int\");\n } else if (Cmp((yyval.type),\"signed long\") == 0) {\n\t\t Delete((yyval.type));\n (yyval.type) = NewString(\"long\");\n } else if (Cmp((yyval.type),\"signed short\") == 0) {\n\t\t Delete((yyval.type));\n\t\t (yyval.type) = NewString(\"short\");\n\t\t } else if (Cmp((yyval.type),\"signed long long\") == 0) {\n\t\t Delete((yyval.type));\n\t\t (yyval.type) = NewString(\"long long\");\n\t\t }\n }\n break;\n\n case 324:\n#line 5131 \"parser.y\"\n { \n (yyval.ptype) = (yyvsp[(1) - (1)].ptype);\n }\n break;\n\n case 325:\n#line 5134 \"parser.y\"\n {\n if ((yyvsp[(1) - (2)].ptype).us && (yyvsp[(2) - (2)].ptype).us) {\n\t\t Swig_error(cparse_file, cparse_line, \"Extra %s specifier.\\n\", (yyvsp[(2) - (2)].ptype).us);\n\t\t }\n (yyval.ptype) = (yyvsp[(2) - (2)].ptype);\n if ((yyvsp[(1) - (2)].ptype).us) (yyval.ptype).us = (yyvsp[(1) - (2)].ptype).us;\n\t\t if ((yyvsp[(1) - (2)].ptype).type) {\n\t\t if (!(yyvsp[(2) - (2)].ptype).type) (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type;\n\t\t else {\n\t\t\tint err = 0;\n\t\t\tif ((Cmp((yyvsp[(1) - (2)].ptype).type,\"long\") == 0)) {\n\t\t\t if ((Cmp((yyvsp[(2) - (2)].ptype).type,\"long\") == 0) || (Strncmp((yyvsp[(2) - (2)].ptype).type,\"double\",6) == 0)) {\n\t\t\t (yyval.ptype).type = NewStringf(\"long %s\", (yyvsp[(2) - (2)].ptype).type);\n\t\t\t } else if (Cmp((yyvsp[(2) - (2)].ptype).type,\"int\") == 0) {\n\t\t\t (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type;\n\t\t\t } else {\n\t\t\t err = 1;\n\t\t\t }\n\t\t\t} else if ((Cmp((yyvsp[(1) - (2)].ptype).type,\"short\")) == 0) {\n\t\t\t if (Cmp((yyvsp[(2) - (2)].ptype).type,\"int\") == 0) {\n\t\t\t (yyval.ptype).type = (yyvsp[(1) - (2)].ptype).type;\n\t\t\t } else {\n\t\t\t err = 1;\n\t\t\t }\n\t\t\t} else if (Cmp((yyvsp[(1) - (2)].ptype).type,\"int\") == 0) {\n\t\t\t (yyval.ptype).type = (yyvsp[(2) - (2)].ptype).type;\n\t\t\t} else if (Cmp((yyvsp[(1) - (2)].ptype).type,\"double\") == 0) {\n\t\t\t if (Cmp((yyvsp[(2) - (2)].ptype).type,\"long\") == 0) {\n\t\t\t (yyval.ptype).type = NewString(\"long double\");\n\t\t\t } else if (Cmp((yyvsp[(2) - (2)].ptype).type,\"complex\") == 0) {\n\t\t\t (yyval.ptype).type = NewString(\"double complex\");\n\t\t\t } else {\n\t\t\t err = 1;\n\t\t\t }\n\t\t\t} else if (Cmp((yyvsp[(1) - (2)].ptype).type,\"float\") == 0) {\n\t\t\t if (Cmp((yyvsp[(2) - (2)].ptype).type,\"complex\") == 0) {\n\t\t\t (yyval.ptype).type = NewString(\"float complex\");\n\t\t\t } else {\n\t\t\t err = 1;\n\t\t\t }\n\t\t\t} else if (Cmp((yyvsp[(1) - (2)].ptype).type,\"complex\") == 0) {\n\t\t\t (yyval.ptype).type = NewStringf(\"%s complex\", (yyvsp[(2) - (2)].ptype).type);\n\t\t\t} else {\n\t\t\t err = 1;\n\t\t\t}\n\t\t\tif (err) {\n\t\t\t Swig_error(cparse_file, cparse_line, \"Extra %s specifier.\\n\", (yyvsp[(1) - (2)].ptype).type);\n\t\t\t}\n\t\t }\n\t\t }\n }\n break;\n\n case 326:\n#line 5188 \"parser.y\"\n { \n\t\t (yyval.ptype).type = NewString(\"int\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 327:\n#line 5192 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"short\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 328:\n#line 5196 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"long\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 329:\n#line 5200 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"char\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 330:\n#line 5204 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"wchar_t\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 331:\n#line 5208 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"float\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 332:\n#line 5212 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"double\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 333:\n#line 5216 \"parser.y\"\n { \n (yyval.ptype).us = NewString(\"signed\");\n (yyval.ptype).type = 0;\n }\n break;\n\n case 334:\n#line 5220 \"parser.y\"\n { \n (yyval.ptype).us = NewString(\"unsigned\");\n (yyval.ptype).type = 0;\n }\n break;\n\n case 335:\n#line 5224 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"complex\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 336:\n#line 5228 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"__int8\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 337:\n#line 5232 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"__int16\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 338:\n#line 5236 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"__int32\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 339:\n#line 5240 \"parser.y\"\n { \n (yyval.ptype).type = NewString(\"__int64\");\n (yyval.ptype).us = 0;\n }\n break;\n\n case 340:\n#line 5246 \"parser.y\"\n { /* scanner_check_typedef(); */ }\n break;\n\n case 341:\n#line 5246 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(2) - (2)].dtype);\n\t\t if ((yyval.dtype).type == T_STRING) {\n\t\t (yyval.dtype).rawval = NewStringf(\"\\\"%(escape)s\\\"\",(yyval.dtype).val);\n\t\t } else if ((yyval.dtype).type != T_CHAR) {\n\t\t (yyval.dtype).rawval = 0;\n\t\t }\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t\t scanner_ignore_typedef();\n }\n break;\n\n case 342:\n#line 5272 \"parser.y\"\n { (yyval.id) = (yyvsp[(1) - (1)].id); }\n break;\n\n case 343:\n#line 5273 \"parser.y\"\n { (yyval.id) = (char *) 0;}\n break;\n\n case 344:\n#line 5276 \"parser.y\"\n { \n\n /* Ignore if there is a trailing comma in the enum list */\n if ((yyvsp[(3) - (3)].node)) {\n Node *leftSibling = Getattr((yyvsp[(1) - (3)].node),\"_last\");\n if (!leftSibling) {\n leftSibling=(yyvsp[(1) - (3)].node);\n }\n set_nextSibling(leftSibling,(yyvsp[(3) - (3)].node));\n Setattr((yyvsp[(1) - (3)].node),\"_last\",(yyvsp[(3) - (3)].node));\n }\n\t\t (yyval.node) = (yyvsp[(1) - (3)].node);\n }\n break;\n\n case 345:\n#line 5289 \"parser.y\"\n { \n (yyval.node) = (yyvsp[(1) - (1)].node); \n if ((yyvsp[(1) - (1)].node)) {\n Setattr((yyvsp[(1) - (1)].node),\"_last\",(yyvsp[(1) - (1)].node));\n }\n }\n break;\n\n case 346:\n#line 5297 \"parser.y\"\n {\n\t\t SwigType *type = NewSwigType(T_INT);\n\t\t (yyval.node) = new_node(\"enumitem\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (1)].id));\n\t\t Setattr((yyval.node),\"type\",type);\n\t\t SetFlag((yyval.node),\"feature:immutable\");\n\t\t Delete(type);\n\t\t }\n break;\n\n case 347:\n#line 5305 \"parser.y\"\n {\n\t\t (yyval.node) = new_node(\"enumitem\");\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (3)].id));\n\t\t Setattr((yyval.node),\"enumvalue\", (yyvsp[(3) - (3)].dtype).val);\n\t if ((yyvsp[(3) - (3)].dtype).type == T_CHAR) {\n\t\t SwigType *type = NewSwigType(T_CHAR);\n\t\t Setattr((yyval.node),\"value\",NewStringf(\"\\'%(escape)s\\'\", (yyvsp[(3) - (3)].dtype).val));\n\t\t Setattr((yyval.node),\"type\",type);\n\t\t Delete(type);\n\t\t } else {\n\t\t SwigType *type = NewSwigType(T_INT);\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(1) - (3)].id));\n\t\t Setattr((yyval.node),\"type\",type);\n\t\t Delete(type);\n\t\t }\n\t\t SetFlag((yyval.node),\"feature:immutable\");\n }\n break;\n\n case 348:\n#line 5322 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 349:\n#line 5325 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(1) - (1)].dtype);\n\t\t if (((yyval.dtype).type != T_INT) && ((yyval.dtype).type != T_UINT) &&\n\t\t ((yyval.dtype).type != T_LONG) && ((yyval.dtype).type != T_ULONG) &&\n\t\t ((yyval.dtype).type != T_SHORT) && ((yyval.dtype).type != T_USHORT) &&\n\t\t ((yyval.dtype).type != T_SCHAR) && ((yyval.dtype).type != T_UCHAR) &&\n\t\t ((yyval.dtype).type != T_CHAR)) {\n\t\t Swig_error(cparse_file,cparse_line,\"Type error. Expecting an int\\n\");\n\t\t }\n\t\t if ((yyval.dtype).type == T_CHAR) (yyval.dtype).type = T_INT;\n }\n break;\n\n case 350:\n#line 5340 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 351:\n#line 5341 \"parser.y\"\n {\n\t\t Node *n;\n\t\t (yyval.dtype).val = (yyvsp[(1) - (1)].type);\n\t\t (yyval.dtype).type = T_INT;\n\t\t /* Check if value is in scope */\n\t\t n = Swig_symbol_clookup((yyvsp[(1) - (1)].type),0);\n\t\t if (n) {\n /* A band-aid for enum values used in expressions. */\n if (Strcmp(nodeType(n),\"enumitem\") == 0) {\n String *q = Swig_symbol_qualified(n);\n if (q) {\n (yyval.dtype).val = NewStringf(\"%s::%s\", q, Getattr(n,\"name\"));\n Delete(q);\n }\n }\n\t\t }\n }\n break;\n\n case 352:\n#line 5360 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 353:\n#line 5361 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewString((yyvsp[(1) - (1)].id));\n (yyval.dtype).type = T_STRING;\n }\n break;\n\n case 354:\n#line 5365 \"parser.y\"\n {\n\t\t SwigType_push((yyvsp[(3) - (5)].type),(yyvsp[(4) - (5)].decl).type);\n\t\t (yyval.dtype).val = NewStringf(\"sizeof(%s)\",SwigType_str((yyvsp[(3) - (5)].type),0));\n\t\t (yyval.dtype).type = T_ULONG;\n }\n break;\n\n case 355:\n#line 5370 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 356:\n#line 5371 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewString((yyvsp[(1) - (1)].str));\n\t\t if (Len((yyval.dtype).val)) {\n\t\t (yyval.dtype).rawval = NewStringf(\"'%(escape)s'\", (yyval.dtype).val);\n\t\t } else {\n\t\t (yyval.dtype).rawval = NewString(\"'\\\\0'\");\n\t\t }\n\t\t (yyval.dtype).type = T_CHAR;\n\t\t (yyval.dtype).bitfield = 0;\n\t\t (yyval.dtype).throws = 0;\n\t\t (yyval.dtype).throwf = 0;\n\t }\n break;\n\n case 357:\n#line 5385 \"parser.y\"\n {\n \t (yyval.dtype).val = NewStringf(\"(%s)\",(yyvsp[(2) - (3)].dtype).val);\n\t\t (yyval.dtype).type = (yyvsp[(2) - (3)].dtype).type;\n \t }\n break;\n\n case 358:\n#line 5392 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(4) - (4)].dtype);\n\t\t if ((yyvsp[(4) - (4)].dtype).type != T_STRING) {\n\t\t (yyval.dtype).val = NewStringf(\"(%s) %s\", SwigType_str((yyvsp[(2) - (4)].dtype).val,0), (yyvsp[(4) - (4)].dtype).val);\n\t\t }\n \t }\n break;\n\n case 359:\n#line 5398 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(5) - (5)].dtype);\n\t\t if ((yyvsp[(5) - (5)].dtype).type != T_STRING) {\n\t\t SwigType_push((yyvsp[(2) - (5)].dtype).val,(yyvsp[(3) - (5)].type));\n\t\t (yyval.dtype).val = NewStringf(\"(%s) %s\", SwigType_str((yyvsp[(2) - (5)].dtype).val,0), (yyvsp[(5) - (5)].dtype).val);\n\t\t }\n \t }\n break;\n\n case 360:\n#line 5405 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(5) - (5)].dtype);\n\t\t if ((yyvsp[(5) - (5)].dtype).type != T_STRING) {\n\t\t SwigType_add_reference((yyvsp[(2) - (5)].dtype).val);\n\t\t (yyval.dtype).val = NewStringf(\"(%s) %s\", SwigType_str((yyvsp[(2) - (5)].dtype).val,0), (yyvsp[(5) - (5)].dtype).val);\n\t\t }\n \t }\n break;\n\n case 361:\n#line 5412 \"parser.y\"\n {\n (yyval.dtype) = (yyvsp[(6) - (6)].dtype);\n\t\t if ((yyvsp[(6) - (6)].dtype).type != T_STRING) {\n\t\t SwigType_push((yyvsp[(2) - (6)].dtype).val,(yyvsp[(3) - (6)].type));\n\t\t SwigType_add_reference((yyvsp[(2) - (6)].dtype).val);\n\t\t (yyval.dtype).val = NewStringf(\"(%s) %s\", SwigType_str((yyvsp[(2) - (6)].dtype).val,0), (yyvsp[(6) - (6)].dtype).val);\n\t\t }\n \t }\n break;\n\n case 362:\n#line 5420 \"parser.y\"\n {\n\t\t (yyval.dtype) = (yyvsp[(2) - (2)].dtype);\n (yyval.dtype).val = NewStringf(\"&%s\",(yyvsp[(2) - (2)].dtype).val);\n\t }\n break;\n\n case 363:\n#line 5424 \"parser.y\"\n {\n\t\t (yyval.dtype) = (yyvsp[(2) - (2)].dtype);\n (yyval.dtype).val = NewStringf(\"*%s\",(yyvsp[(2) - (2)].dtype).val);\n\t }\n break;\n\n case 364:\n#line 5430 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 365:\n#line 5431 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 366:\n#line 5432 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 367:\n#line 5433 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 368:\n#line 5434 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 369:\n#line 5435 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 370:\n#line 5436 \"parser.y\"\n { (yyval.dtype) = (yyvsp[(1) - (1)].dtype); }\n break;\n\n case 371:\n#line 5439 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s+%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 372:\n#line 5443 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s-%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 373:\n#line 5447 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s*%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 374:\n#line 5451 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s/%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 375:\n#line 5455 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s%%%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 376:\n#line 5459 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s&%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 377:\n#line 5463 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s|%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 378:\n#line 5467 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s^%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote((yyvsp[(1) - (3)].dtype).type,(yyvsp[(3) - (3)].dtype).type);\n\t }\n break;\n\n case 379:\n#line 5471 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s << %s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote_type((yyvsp[(1) - (3)].dtype).type);\n\t }\n break;\n\n case 380:\n#line 5475 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s >> %s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = promote_type((yyvsp[(1) - (3)].dtype).type);\n\t }\n break;\n\n case 381:\n#line 5479 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s&&%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 382:\n#line 5483 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s||%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 383:\n#line 5487 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s==%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 384:\n#line 5491 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s!=%s\",(yyvsp[(1) - (3)].dtype).val,(yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 385:\n#line 5505 \"parser.y\"\n {\n\t\t /* Putting >= in the expression literally causes an infinite\n\t\t * loop somewhere in the type system. Just workaround for now\n\t\t * - SWIG_GE is defined in swiglabels.swg. */\n\t\t (yyval.dtype).val = NewStringf(\"%s SWIG_GE %s\", (yyvsp[(1) - (3)].dtype).val, (yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 386:\n#line 5512 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s SWIG_LE %s\", (yyvsp[(1) - (3)].dtype).val, (yyvsp[(3) - (3)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 387:\n#line 5516 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"%s?%s:%s\", (yyvsp[(1) - (5)].dtype).val, (yyvsp[(3) - (5)].dtype).val, (yyvsp[(5) - (5)].dtype).val);\n\t\t /* This may not be exactly right, but is probably good enough\n\t\t * for the purposes of parsing constant expressions. */\n\t\t (yyval.dtype).type = promote((yyvsp[(3) - (5)].dtype).type, (yyvsp[(5) - (5)].dtype).type);\n\t }\n break;\n\n case 388:\n#line 5522 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"-%s\",(yyvsp[(2) - (2)].dtype).val);\n\t\t (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type;\n\t }\n break;\n\n case 389:\n#line 5526 \"parser.y\"\n {\n (yyval.dtype).val = NewStringf(\"+%s\",(yyvsp[(2) - (2)].dtype).val);\n\t\t (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type;\n\t }\n break;\n\n case 390:\n#line 5530 \"parser.y\"\n {\n\t\t (yyval.dtype).val = NewStringf(\"~%s\",(yyvsp[(2) - (2)].dtype).val);\n\t\t (yyval.dtype).type = (yyvsp[(2) - (2)].dtype).type;\n\t }\n break;\n\n case 391:\n#line 5534 \"parser.y\"\n {\n (yyval.dtype).val = NewStringf(\"!%s\",(yyvsp[(2) - (2)].dtype).val);\n\t\t (yyval.dtype).type = T_INT;\n\t }\n break;\n\n case 392:\n#line 5538 \"parser.y\"\n {\n\t\t String *qty;\n skip_balanced('(',')');\n\t\t qty = Swig_symbol_type_qualify((yyvsp[(1) - (2)].type),0);\n\t\t if (SwigType_istemplate(qty)) {\n\t\t String *nstr = SwigType_namestr(qty);\n\t\t Delete(qty);\n\t\t qty = nstr;\n\t\t }\n\t\t (yyval.dtype).val = NewStringf(\"%s%s\",qty,scanner_ccode);\n\t\t Clear(scanner_ccode);\n\t\t (yyval.dtype).type = T_INT;\n\t\t Delete(qty);\n }\n break;\n\n case 393:\n#line 5554 \"parser.y\"\n {\n\t\t (yyval.bases) = (yyvsp[(1) - (1)].bases);\n }\n break;\n\n case 394:\n#line 5559 \"parser.y\"\n { inherit_list = 1; }\n break;\n\n case 395:\n#line 5559 \"parser.y\"\n { (yyval.bases) = (yyvsp[(3) - (3)].bases); inherit_list = 0; }\n break;\n\n case 396:\n#line 5560 \"parser.y\"\n { (yyval.bases) = 0; }\n break;\n\n case 397:\n#line 5563 \"parser.y\"\n {\n\t\t Hash *list = NewHash();\n\t\t Node *base = (yyvsp[(1) - (1)].node);\n\t\t Node *name = Getattr(base,\"name\");\n\t\t List *lpublic = NewList();\n\t\t List *lprotected = NewList();\n\t\t List *lprivate = NewList();\n\t\t Setattr(list,\"public\",lpublic);\n\t\t Setattr(list,\"protected\",lprotected);\n\t\t Setattr(list,\"private\",lprivate);\n\t\t Delete(lpublic);\n\t\t Delete(lprotected);\n\t\t Delete(lprivate);\n\t\t Append(Getattr(list,Getattr(base,\"access\")),name);\n\t (yyval.bases) = list;\n }\n break;\n\n case 398:\n#line 5580 \"parser.y\"\n {\n\t\t Hash *list = (yyvsp[(1) - (3)].bases);\n\t\t Node *base = (yyvsp[(3) - (3)].node);\n\t\t Node *name = Getattr(base,\"name\");\n\t\t Append(Getattr(list,Getattr(base,\"access\")),name);\n (yyval.bases) = list;\n }\n break;\n\n case 399:\n#line 5589 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setfile((yyval.node),cparse_file);\n\t\t Setline((yyval.node),cparse_line);\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(2) - (2)].str));\n if (last_cpptype && (Strcmp(last_cpptype,\"struct\") != 0)) {\n\t\t Setattr((yyval.node),\"access\",\"private\");\n\t\t Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,\n\t\t\t\t\"No access specifier given for base class %s (ignored).\\n\",(yyvsp[(2) - (2)].str));\n } else {\n\t\t Setattr((yyval.node),\"access\",\"public\");\n\t\t }\n }\n break;\n\n case 400:\n#line 5602 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setfile((yyval.node),cparse_file);\n\t\t Setline((yyval.node),cparse_line);\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(4) - (4)].str));\n\t\t Setattr((yyval.node),\"access\",(yyvsp[(2) - (4)].id));\n\t if (Strcmp((yyvsp[(2) - (4)].id),\"public\") != 0) {\n\t\t Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file, \n\t\t\t\tcparse_line,\"%s inheritance ignored.\\n\", (yyvsp[(2) - (4)].id));\n\t\t }\n }\n break;\n\n case 401:\n#line 5615 \"parser.y\"\n { (yyval.id) = (char*)\"public\"; }\n break;\n\n case 402:\n#line 5616 \"parser.y\"\n { (yyval.id) = (char*)\"private\"; }\n break;\n\n case 403:\n#line 5617 \"parser.y\"\n { (yyval.id) = (char*)\"protected\"; }\n break;\n\n case 404:\n#line 5621 \"parser.y\"\n { \n (yyval.id) = (char*)\"class\"; \n\t\t if (!inherit_list) last_cpptype = (yyval.id);\n }\n break;\n\n case 405:\n#line 5625 \"parser.y\"\n { \n (yyval.id) = (char *)\"typename\"; \n\t\t if (!inherit_list) last_cpptype = (yyval.id);\n }\n break;\n\n case 406:\n#line 5631 \"parser.y\"\n {\n (yyval.id) = (yyvsp[(1) - (1)].id);\n }\n break;\n\n case 407:\n#line 5634 \"parser.y\"\n { \n (yyval.id) = (char*)\"struct\"; \n\t\t if (!inherit_list) last_cpptype = (yyval.id);\n }\n break;\n\n case 408:\n#line 5638 \"parser.y\"\n {\n (yyval.id) = (char*)\"union\"; \n\t\t if (!inherit_list) last_cpptype = (yyval.id);\n }\n break;\n\n case 411:\n#line 5648 \"parser.y\"\n {\n (yyval.dtype).qualifier = (yyvsp[(1) - (1)].str);\n (yyval.dtype).throws = 0;\n (yyval.dtype).throwf = 0;\n }\n break;\n\n case 412:\n#line 5653 \"parser.y\"\n {\n (yyval.dtype).qualifier = 0;\n (yyval.dtype).throws = (yyvsp[(3) - (4)].pl);\n (yyval.dtype).throwf = NewString(\"1\");\n }\n break;\n\n case 413:\n#line 5658 \"parser.y\"\n {\n (yyval.dtype).qualifier = (yyvsp[(1) - (5)].str);\n (yyval.dtype).throws = (yyvsp[(4) - (5)].pl);\n (yyval.dtype).throwf = NewString(\"1\");\n }\n break;\n\n case 414:\n#line 5663 \"parser.y\"\n { \n (yyval.dtype).qualifier = 0; \n (yyval.dtype).throws = 0;\n (yyval.dtype).throwf = 0;\n }\n break;\n\n case 415:\n#line 5670 \"parser.y\"\n { \n Clear(scanner_ccode); \n (yyval.decl).have_parms = 0; \n (yyval.decl).defarg = 0; \n\t\t (yyval.decl).throws = (yyvsp[(1) - (3)].dtype).throws;\n\t\t (yyval.decl).throwf = (yyvsp[(1) - (3)].dtype).throwf;\n }\n break;\n\n case 416:\n#line 5677 \"parser.y\"\n { \n skip_balanced('{','}'); \n (yyval.decl).have_parms = 0; \n (yyval.decl).defarg = 0; \n (yyval.decl).throws = (yyvsp[(1) - (3)].dtype).throws;\n (yyval.decl).throwf = (yyvsp[(1) - (3)].dtype).throwf;\n }\n break;\n\n case 417:\n#line 5684 \"parser.y\"\n { \n Clear(scanner_ccode); \n (yyval.decl).parms = (yyvsp[(2) - (4)].pl); \n (yyval.decl).have_parms = 1; \n (yyval.decl).defarg = 0; \n\t\t (yyval.decl).throws = 0;\n\t\t (yyval.decl).throwf = 0;\n }\n break;\n\n case 418:\n#line 5692 \"parser.y\"\n {\n skip_balanced('{','}'); \n (yyval.decl).parms = (yyvsp[(2) - (4)].pl); \n (yyval.decl).have_parms = 1; \n (yyval.decl).defarg = 0; \n (yyval.decl).throws = 0;\n (yyval.decl).throwf = 0;\n }\n break;\n\n case 419:\n#line 5700 \"parser.y\"\n { \n (yyval.decl).have_parms = 0; \n (yyval.decl).defarg = (yyvsp[(2) - (3)].dtype).val; \n (yyval.decl).throws = 0;\n (yyval.decl).throwf = 0;\n }\n break;\n\n case 424:\n#line 5716 \"parser.y\"\n {\n\t skip_balanced('(',')');\n Clear(scanner_ccode);\n \t}\n break;\n\n case 425:\n#line 5722 \"parser.y\"\n { \n String *s = NewStringEmpty();\n SwigType_add_template(s,(yyvsp[(2) - (3)].p));\n (yyval.id) = Char(s);\n\t\t scanner_last_id(1);\n }\n break;\n\n case 426:\n#line 5728 \"parser.y\"\n { (yyval.id) = (char*)\"\"; }\n break;\n\n case 427:\n#line 5731 \"parser.y\"\n { (yyval.id) = (yyvsp[(1) - (1)].id); }\n break;\n\n case 428:\n#line 5732 \"parser.y\"\n { (yyval.id) = (yyvsp[(1) - (1)].id); }\n break;\n\n case 429:\n#line 5735 \"parser.y\"\n { (yyval.id) = (yyvsp[(1) - (1)].id); }\n break;\n\n case 430:\n#line 5736 \"parser.y\"\n { (yyval.id) = 0; }\n break;\n\n case 431:\n#line 5739 \"parser.y\"\n { \n (yyval.str) = 0;\n\t\t if (!(yyval.str)) (yyval.str) = NewStringf(\"%s%s\", (yyvsp[(1) - (2)].str),(yyvsp[(2) - (2)].str));\n \t Delete((yyvsp[(2) - (2)].str));\n }\n break;\n\n case 432:\n#line 5744 \"parser.y\"\n { \n\t\t (yyval.str) = NewStringf(\"::%s%s\",(yyvsp[(3) - (4)].str),(yyvsp[(4) - (4)].str));\n Delete((yyvsp[(4) - (4)].str));\n }\n break;\n\n case 433:\n#line 5748 \"parser.y\"\n {\n\t\t (yyval.str) = NewString((yyvsp[(1) - (1)].str));\n \t }\n break;\n\n case 434:\n#line 5751 \"parser.y\"\n {\n\t\t (yyval.str) = NewStringf(\"::%s\",(yyvsp[(3) - (3)].str));\n }\n break;\n\n case 435:\n#line 5754 \"parser.y\"\n {\n (yyval.str) = NewString((yyvsp[(1) - (1)].str));\n\t }\n break;\n\n case 436:\n#line 5757 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(3) - (3)].str));\n }\n break;\n\n case 437:\n#line 5762 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s%s\",(yyvsp[(2) - (3)].str),(yyvsp[(3) - (3)].str));\n\t\t Delete((yyvsp[(3) - (3)].str));\n }\n break;\n\n case 438:\n#line 5766 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(2) - (2)].str));\n }\n break;\n\n case 439:\n#line 5769 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(2) - (2)].str));\n }\n break;\n\n case 440:\n#line 5776 \"parser.y\"\n {\n\t\t (yyval.str) = NewStringf(\"::~%s\",(yyvsp[(2) - (2)].str));\n }\n break;\n\n case 441:\n#line 5782 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"%s%s\",(yyvsp[(1) - (2)].id),(yyvsp[(2) - (2)].id));\n\t\t /*\t\t if (Len($2)) {\n\t\t scanner_last_id(1);\n\t\t } */\n }\n break;\n\n case 442:\n#line 5791 \"parser.y\"\n { \n (yyval.str) = 0;\n\t\t if (!(yyval.str)) (yyval.str) = NewStringf(\"%s%s\", (yyvsp[(1) - (2)].id),(yyvsp[(2) - (2)].str));\n \t Delete((yyvsp[(2) - (2)].str));\n }\n break;\n\n case 443:\n#line 5796 \"parser.y\"\n { \n\t\t (yyval.str) = NewStringf(\"::%s%s\",(yyvsp[(3) - (4)].id),(yyvsp[(4) - (4)].str));\n Delete((yyvsp[(4) - (4)].str));\n }\n break;\n\n case 444:\n#line 5800 \"parser.y\"\n {\n\t\t (yyval.str) = NewString((yyvsp[(1) - (1)].id));\n \t }\n break;\n\n case 445:\n#line 5803 \"parser.y\"\n {\n\t\t (yyval.str) = NewStringf(\"::%s\",(yyvsp[(3) - (3)].id));\n }\n break;\n\n case 446:\n#line 5806 \"parser.y\"\n {\n (yyval.str) = NewString((yyvsp[(1) - (1)].str));\n\t }\n break;\n\n case 447:\n#line 5809 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(3) - (3)].str));\n }\n break;\n\n case 448:\n#line 5814 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s%s\",(yyvsp[(2) - (3)].id),(yyvsp[(3) - (3)].str));\n\t\t Delete((yyvsp[(3) - (3)].str));\n }\n break;\n\n case 449:\n#line 5818 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(2) - (2)].id));\n }\n break;\n\n case 450:\n#line 5821 \"parser.y\"\n {\n (yyval.str) = NewStringf(\"::%s\",(yyvsp[(2) - (2)].str));\n }\n break;\n\n case 451:\n#line 5824 \"parser.y\"\n {\n\t\t (yyval.str) = NewStringf(\"::~%s\",(yyvsp[(2) - (2)].id));\n }\n break;\n\n case 452:\n#line 5830 \"parser.y\"\n { \n (yyval.id) = (char *) malloc(strlen((yyvsp[(1) - (2)].id))+strlen((yyvsp[(2) - (2)].id))+1);\n strcpy((yyval.id),(yyvsp[(1) - (2)].id));\n strcat((yyval.id),(yyvsp[(2) - (2)].id));\n }\n break;\n\n case 453:\n#line 5835 \"parser.y\"\n { (yyval.id) = (yyvsp[(1) - (1)].id);}\n break;\n\n case 454:\n#line 5838 \"parser.y\"\n {\n\t\t (yyval.str) = NewString((yyvsp[(1) - (1)].id));\n }\n break;\n\n case 455:\n#line 5841 \"parser.y\"\n {\n skip_balanced('{','}');\n\t\t (yyval.str) = NewString(scanner_ccode);\n }\n break;\n\n case 456:\n#line 5845 \"parser.y\"\n {\n\t\t (yyval.str) = (yyvsp[(1) - (1)].str);\n }\n break;\n\n case 457:\n#line 5850 \"parser.y\"\n {\n Hash *n;\n (yyval.node) = NewHash();\n n = (yyvsp[(2) - (3)].node);\n while(n) {\n String *name, *value;\n name = Getattr(n,\"name\");\n value = Getattr(n,\"value\");\n\t\t if (!value) value = (String *) \"1\";\n Setattr((yyval.node),name, value);\n\t\t n = nextSibling(n);\n\t\t }\n }\n break;\n\n case 458:\n#line 5863 \"parser.y\"\n { (yyval.node) = 0; }\n break;\n\n case 459:\n#line 5867 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (3)].id));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(3) - (3)].id));\n }\n break;\n\n case 460:\n#line 5872 \"parser.y\"\n {\n\t\t (yyval.node) = NewHash();\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (5)].id));\n\t\t Setattr((yyval.node),\"value\",(yyvsp[(3) - (5)].id));\n\t\t set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node));\n }\n break;\n\n case 461:\n#line 5878 \"parser.y\"\n {\n (yyval.node) = NewHash();\n Setattr((yyval.node),\"name\",(yyvsp[(1) - (1)].id));\n\t }\n break;\n\n case 462:\n#line 5882 \"parser.y\"\n {\n (yyval.node) = NewHash();\n Setattr((yyval.node),\"name\",(yyvsp[(1) - (3)].id));\n set_nextSibling((yyval.node),(yyvsp[(3) - (3)].node));\n }\n break;\n\n case 463:\n#line 5887 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(3) - (3)].node);\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (3)].id));\n }\n break;\n\n case 464:\n#line 5891 \"parser.y\"\n {\n (yyval.node) = (yyvsp[(3) - (5)].node);\n\t\t Setattr((yyval.node),\"name\",(yyvsp[(1) - (5)].id));\n\t\t set_nextSibling((yyval.node),(yyvsp[(5) - (5)].node));\n }\n break;\n\n case 465:\n#line 5898 \"parser.y\"\n {\n\t\t (yyval.id) = (yyvsp[(1) - (1)].id);\n }\n break;\n\n case 466:\n#line 5901 \"parser.y\"\n {\n (yyval.id) = Char((yyvsp[(1) - (1)].dtype).val);\n }\n break;\n\n\n/* Line 1267 of yacc.c. */\n#line 10054 \"y.tab.c\"\n default: break;\n }\n YY_SYMBOL_PRINT (\"-> $$ =\", yyr1[yyn], &yyval, &yyloc);\n\n YYPOPSTACK (yylen);\n yylen = 0;\n YY_STACK_PRINT (yyss, yyssp);\n\n *++yyvsp = yyval;\n\n\n /* Now `shift' the result of the reduction. Determine what state\n that goes to, based on the state we popped back to and the rule\n number reduced by. */\n\n yyn = yyr1[yyn];\n\n yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;\n if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)\n yystate = yytable[yystate];\n else\n yystate = yydefgoto[yyn - YYNTOKENS];\n\n goto yynewstate;\n\n\n/*------------------------------------.\n| yyerrlab -- here on detecting error |\n`------------------------------------*/\nyyerrlab:\n /* If not already recovering from an error, report this error. */\n if (!yyerrstatus)\n {\n ++yynerrs;\n#if ! YYERROR_VERBOSE\n yyerror (YY_(\"syntax error\"));\n#else\n {\n\tYYSIZE_T yysize = yysyntax_error (0, yystate, yychar);\n\tif (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)\n\t {\n\t YYSIZE_T yyalloc = 2 * yysize;\n\t if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))\n\t yyalloc = YYSTACK_ALLOC_MAXIMUM;\n\t if (yymsg != yymsgbuf)\n\t YYSTACK_FREE (yymsg);\n\t yymsg = (char *) YYSTACK_ALLOC (yyalloc);\n\t if (yymsg)\n\t yymsg_alloc = yyalloc;\n\t else\n\t {\n\t\tyymsg = yymsgbuf;\n\t\tyymsg_alloc = sizeof yymsgbuf;\n\t }\n\t }\n\n\tif (0 < yysize && yysize <= yymsg_alloc)\n\t {\n\t (void) yysyntax_error (yymsg, yystate, yychar);\n\t yyerror (yymsg);\n\t }\n\telse\n\t {\n\t yyerror (YY_(\"syntax error\"));\n\t if (yysize != 0)\n\t goto yyexhaustedlab;\n\t }\n }\n#endif\n }\n\n\n\n if (yyerrstatus == 3)\n {\n /* If just tried and failed to reuse look-ahead token after an\n\t error, discard it. */\n\n if (yychar <= YYEOF)\n\t{\n\t /* Return failure if at end of input. */\n\t if (yychar == YYEOF)\n\t YYABORT;\n\t}\n else\n\t{\n\t yydestruct (\"Error: discarding\",\n\t\t yytoken, &yylval);\n\t yychar = YYEMPTY;\n\t}\n }\n\n /* Else will try to reuse look-ahead token after shifting the error\n token. */\n goto yyerrlab1;\n\n\n/*---------------------------------------------------.\n| yyerrorlab -- error raised explicitly by YYERROR. |\n`---------------------------------------------------*/\nyyerrorlab:\n\n /* Pacify compilers like GCC when the user code never invokes\n YYERROR and the label yyerrorlab therefore never appears in user\n code. */\n if (/*CONSTCOND*/ 0)\n goto yyerrorlab;\n\n /* Do not reclaim the symbols of the rule which action triggered\n this YYERROR. */\n YYPOPSTACK (yylen);\n yylen = 0;\n YY_STACK_PRINT (yyss, yyssp);\n yystate = *yyssp;\n goto yyerrlab1;\n\n\n/*-------------------------------------------------------------.\n| yyerrlab1 -- common code for both syntax error and YYERROR. |\n`-------------------------------------------------------------*/\nyyerrlab1:\n yyerrstatus = 3;\t/* Each real token shifted decrements this. */\n\n for (;;)\n {\n yyn = yypact[yystate];\n if (yyn != YYPACT_NINF)\n\t{\n\t yyn += YYTERROR;\n\t if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)\n\t {\n\t yyn = yytable[yyn];\n\t if (0 < yyn)\n\t\tbreak;\n\t }\n\t}\n\n /* Pop the current state because it cannot handle the error token. */\n if (yyssp == yyss)\n\tYYABORT;\n\n\n yydestruct (\"Error: popping\",\n\t\t yystos[yystate], yyvsp);\n YYPOPSTACK (1);\n yystate = *yyssp;\n YY_STACK_PRINT (yyss, yyssp);\n }\n\n if (yyn == YYFINAL)\n YYACCEPT;\n\n *++yyvsp = yylval;\n\n\n /* Shift the error token. */\n YY_SYMBOL_PRINT (\"Shifting\", yystos[yyn], yyvsp, yylsp);\n\n yystate = yyn;\n goto yynewstate;\n\n\n/*-------------------------------------.\n| yyacceptlab -- YYACCEPT comes here. |\n`-------------------------------------*/\nyyacceptlab:\n yyresult = 0;\n goto yyreturn;\n\n/*-----------------------------------.\n| yyabortlab -- YYABORT comes here. |\n`-----------------------------------*/\nyyabortlab:\n yyresult = 1;\n goto yyreturn;\n\n#ifndef yyoverflow\n/*-------------------------------------------------.\n| yyexhaustedlab -- memory exhaustion comes here. |\n`-------------------------------------------------*/\nyyexhaustedlab:\n yyerror (YY_(\"memory exhausted\"));\n yyresult = 2;\n /* Fall through. */\n#endif\n\nyyreturn:\n if (yychar != YYEOF && yychar != YYEMPTY)\n yydestruct (\"Cleanup: discarding lookahead\",\n\t\t yytoken, &yylval);\n /* Do not reclaim the symbols of the rule which action triggered\n this YYABORT or YYACCEPT. */\n YYPOPSTACK (yylen);\n YY_STACK_PRINT (yyss, yyssp);\n while (yyssp != yyss)\n {\n yydestruct (\"Cleanup: popping\",\n\t\t yystos[*yyssp], yyvsp);\n YYPOPSTACK (1);\n }\n#ifndef yyoverflow\n if (yyss != yyssa)\n YYSTACK_FREE (yyss);\n#endif\n#if YYERROR_VERBOSE\n if (yymsg != yymsgbuf)\n YYSTACK_FREE (yymsg);\n#endif\n /* Make sure YYID is used. */\n return YYID (yyresult);\n}\n\n\n#line 5908 \"parser.y\"\n\n\nSwigType *Swig_cparse_type(String *s) {\n String *ns;\n ns = NewStringf(\"%s;\",s);\n Seek(ns,0,SEEK_SET);\n scanner_file(ns);\n top = 0;\n scanner_next_token(PARSETYPE);\n yyparse();\n /* Printf(stdout,\"typeparse: '%s' ---> '%s'\\n\", s, top); */\n return top;\n}\n\n\nParm *Swig_cparse_parm(String *s) {\n String *ns;\n ns = NewStringf(\"%s;\",s);\n Seek(ns,0,SEEK_SET);\n scanner_file(ns);\n top = 0;\n scanner_next_token(PARSEPARM);\n yyparse();\n /* Printf(stdout,\"typeparse: '%s' ---> '%s'\\n\", s, top); */\n Delete(ns);\n return top;\n}\n\n\nParmList *Swig_cparse_parms(String *s) {\n String *ns;\n char *cs = Char(s);\n if (cs && cs[0] != '(') {\n ns = NewStringf(\"(%s);\",s);\n } else {\n ns = NewStringf(\"%s;\",s);\n } \n Seek(ns,0,SEEK_SET);\n scanner_file(ns);\n top = 0;\n scanner_next_token(PARSEPARMS);\n yyparse();\n /* Printf(stdout,\"typeparse: '%s' ---> '%s'\\n\", s, top); */\n return top;\n}\n\n\n#include \r\n\r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \r\n#include \r\n\r\n\r\n\r\n#include \"IParameter.h\"\r\n\r\n\r\nPhysicManager *manager = NULL;\r\nusing namespace xUtils;\r\nusing namespace vtAgeia;\r\n\r\nvoid\r\nPhysicManager::_destruct(xBitSet flags /* = 0 */)\r\n{\r\n\r\n\t//################################################################\r\n\t//\r\n\t// some sanity checks\r\n\t//\r\n\tassert(mIParameter);\r\n\tassert(m_Worlds);\r\n\tassert(manager);\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Clean instances :\r\n\t//\r\n\tSAFE_DELETE(mIParameter);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nPhysicManager::PhysicManager(CKContext* context):CKPhysicManager(context,GUID_MODULE_MANAGER,VTCX_API_ENTRY(\"PhysicManager\")) //Name as used in profiler\r\n{\r\n\r\n\r\n\tm_Context->RegisterNewManager(this);\r\n\tm_Worlds = new pWorldMap();\r\n\tmanager = this;\r\n\r\n\t\r\n\t_Hook3DBBs();\r\n\t_HookGenericBBs();\r\n\r\n\t_construct();\r\n\r\n\tint ss = xLogger::GetInstance()->getItemDescriptions().size();\r\n\tint ss2= xLogger::GetInstance()->getLogItems().size();\r\n\txLogger::xLog(ELOGERROR,E_BB,\"No Reference Object specified\");\r\n\r\n\ttimer = 0.0f;\r\n\tmPhysicsSDK = NULL;\r\n\tDongleHasBasicVersion=0;\r\n\tDongleHasAdvancedVersion=0;\r\n\r\n\t_LogErrors = _LogInfo = _LogTrace = _LogWarnings = _LogToConsole = 0;\r\n\r\n\r\n\tmIParameter = new IParameter(this);\r\n\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid PhysicManager::cleanAll()\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//destroy all worlds : \r\n\tif (getWorlds()->Size())\r\n\t{\r\n\t\tdestroyWorlds();\r\n\t\tm_DefaultWorld = NULL;\r\n\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//destroy default objects :\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//world settings : \r\n\tif (getDefaultWorldSettings())\r\n\t{\r\n\t\tSAFE_DELETE(mDefaultWorldSettings);\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Deleted default world settings\");\r\n\t}\r\n\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//default configuration : \r\n\tif (m_DefaultDocument)\r\n\t{\r\n\t\tSAFE_DELETE(m_DefaultDocument);\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Deleted default configuration\");\r\n\t}\r\n\r\n\tif (pFactory::Instance())\r\n\t{\r\n\t\tpFactory::Instance()->reloadConfig(\"PhysicDefaults.xml\");\r\n\t}\r\n\r\n\tif (getPhysicsSDK())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Physic SDK released \");\r\n\t\tNxReleasePhysicsSDK(getPhysicsSDK());\r\n\t\tmPhysicsSDK = NULL;\r\n\t}\r\n\r\n\r\n\r\n\t_getManagerFlags() = 0 ;\r\n\r\n}\r\n\r\nvoid PhysicManager::doInit()\r\n{\r\n\t//CreateWorlds(0);\r\n}\r\nCKERROR PhysicManager::OnCKPause()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR PhysicManager::OnCKPlay()\r\n{\r\n\tint a = _LogErrors;\r\n\tint b = 0;\r\n\r\n\t\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_AGEIA,ELOGERROR,_LogErrors);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGERROR,_LogErrors);\r\n\r\n\t\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGTRACE,_LogTrace);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGWARNING,_LogWarnings);\r\n\txLogger::GetInstance()->enableLoggingLevel(E_LI_MANAGER,ELOGINFO,_LogInfo);\r\n\r\n\r\n\ttry {\r\n\t\tpopulateAttributeFunctions();\r\n\t\t_RegisterAttributeCallbacks();\r\n\t} catch(std::exception ex) {\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Error during Attribute List Populations\");\r\n\t} catch(...) {\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Error during Attribute List Populations\");\r\n\t\t//systemMessage(\"System Error\");\r\n\t}\r\n\tif (getNbObjects())\r\n\t{\r\n\t\t_migrateOldCustomStructures(GetContext()->GetCurrentScene());\r\n\r\n\t\tif (\r\n\t\t\tisFlagOff(_getManagerFlags(),E_MF_PSDK_LOADED) && \r\n\t\t\tisFlagOff(_getManagerFlags(),E_MF_DEFAULT_WORLD_CREATED) &&\r\n\t\t\tisFlagOff(_getManagerFlags(),E_MF_FACTORY_CREATED)\r\n\t\t\t)\r\n\t\t{\r\n\t\t\tperformInitialization();\r\n\t\t\tcheckWorlds();\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\nCKERROR PhysicManager::PostClearAll()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKERROR PhysicManager::OnCKInit()\r\n{\r\n\tbindVariables();\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nCKERROR PhysicManager::PreSave()\r\n{\r\n\treturn CK_OK;\r\n}\r\nCKContext* PhysicManager::GetContext()\r\n{\r\n\treturn manager->m_Context;\r\n}\r\nPhysicManager* PhysicManager::GetInstance()\r\n{\r\n\tif (manager)\r\n\t{\r\n\t\treturn manager;\r\n\t}\r\n\treturn NULL;\r\n}\r\nPhysicManager::~PhysicManager(){}\r\n\r\nCKERROR PhysicManager::OnPostCopy(CKDependenciesContext& context)\r\n{\r\n\tCKDependenciesContext dependencies_ctx(m_Context);\n//\tdependencies_ctx.SetOperationMode(CK_DEPENDENCIES_SAVE);\n/*\n\tdependencies_ctx.StartDependencies(iDep);\n\n\t//We scan the group and fill the dependencies context\n\tfor (int i=0;iGetObjectCount();i++)\n\t{\n\t\tCKBeObject* object = iGrp->GetObject(i);\n\t\tobject->PrepareDependencies(dependencies_ctx);\n\t}\n*/\n\t// Build a list of id to save\n\treturn CK_OK;\n\tXObjectArray dependencies_list = context.FillDependencies();\n\tint s = dependencies_list.Size();\n\t\n\n\t\n\t//dependencies_list.PushBack(iGrp->GetID());//add group at the end\n\n\t//copy list of objects in ckobjectarray\n\tCKObjectArray* listToSave = CreateCKObjectArray();\n\tXObjectArray::Iterator it1 = dependencies_list.Begin();\n\tXObjectArray::Iterator it2 = dependencies_list.End();\r\n\twhile (it1!=it2)\n\t{\n\t\tCKObject* object = m_Context->GetObject(*it1);\n\t\t/*CK_ID cID = object->GetID();\n\t\tlistToSave->InsertRear(*it1++);\n\t\tCKSTRING name = object->GetName();\n\t\t\n\t\tCK_ID id2 = context.RemapID(cID);\n\t\tCK_ID id3 = context.RemapID(cID);*/\n\n\t\t\n\t\t\n\t}\r\n\r\n\treturn CK_OK;\r\n\r\n\r\n}\r\nCKERROR PhysicManager::SequenceDeleted(CK_ID *objids,int count)\r\n{\r\n\r\n\r\n\t\r\n\tif (getNbObjects())\r\n\t{\r\n\t\tif(GetContext()->IsPlaying())\r\n\t\t\tcheckWorlds();\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR PhysicManager::SequenceAddedToScene(CKScene *scn,CK_ID *objids,int count)\r\n{\r\n\tint isInLoad=GetContext()->IsInLoad();\r\n\tint nbOfObjects = 0 ;\r\n\tif (!GetContext()->IsPlaying())\r\n\t{\r\n\t\t\r\n\t\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\t\tconst XObjectPointerArray& Array = attman->GetAttributeListPtr(GetPAttribute());\r\n\t\tnbOfObjects = Array.Size();\r\n\t\tif (nbOfObjects)\r\n\t\t{\r\n\t\t\t_migrateOldCustomStructures(scn);\r\n\t\t}\r\n\r\n\r\n\t}\r\n\r\n\tif (getNbObjects())\r\n\t{\r\n\t\tif(GetContext()->IsPlaying()){\r\n\r\n\t\t\t\r\n\t\t\t/*\r\n\t\t\tfor (int i = 0 ; i < count ; i++ )\r\n\t\t\t{\r\n\t\t\t\tCK_ID dstId = objids[i];\r\n\t\t\t\tCKBeObject * obj = GetContext()->GetObject()\r\n\t\t\t}\r\n\t\t\t*/\r\n\t\t\tcheckWorlds();\r\n\t\t}\r\n\t}\r\n\treturn CK_OK;\r\n}\r\nCKERROR PhysicManager::SequenceToBeDeleted(CK_ID *objids,int count)\r\n{\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR PhysicManager::SequenceRemovedFromScene(CKScene *scn,CK_ID *objids,int count)\r\n{\r\n\r\n\tif (getNbObjects())\r\n\t{\r\n\t\tif(GetContext()->IsPlaying())\r\n\t\t\tcheckWorlds();\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nCKERROR PhysicManager::PreClearAll()\r\n{\r\n\t\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR PhysicManager::OnCKReset()\r\n{\r\n\r\n\r\n\tcleanAll();\r\n\t_RegisterDynamicParameters();\r\n\r\n\treturn CK_OK;\r\n}\r\nCKERROR PhysicManager::OnCKEnd()\r\n{\r\n\t\r\n\tunBindVariables();\r\n\r\n\treturn 0;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n#include \"tinyxml.h\"\r\n\r\n#include \r\n\r\nNxShape*pFactory::createWheelShape1(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr)\r\n{\r\n\r\n\tNxWheelShape *result = NULL;\r\n\tpRigidBody *body=GetPMan()->getBody(bodyReference);\r\n\t\r\n\r\n\tbool assertResult = true;\r\n\tiAssertWR(bodyReference && wheelReference && wheelDescr.isValid() && body && body->getActor(),\"\",assertResult);\r\n\tif (!assertResult)\r\n\t\treturn NULL;\r\n\r\n\tNxActor *actor = body->getActor();\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// prepare data : \r\n\t//\r\n\tCKMesh *mesh = wheelReference->GetCurrentMesh();\r\n\tVxVector box_s = mesh->GetLocalBox().GetSize();\r\n\t\r\n\tfloat radius = wheelDescr.radius.value > 0.0f ? wheelDescr.radius.value : box_s.v[wheelDescr.radius.referenceAxis] * 0.5f;\r\n\r\n\tVxQuaternion quatOffset;\r\n\tVxVector posOffset;\r\n\tvtAgeia::calculateOffsets(bodyReference,wheelReference,quatOffset,posOffset);\r\n\tCK_ID srcID = mesh->GetID();\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// create convex cylinder : \r\n\t//\r\n\tNxConvexShapeDesc shape;\r\n\tbool resultAssert = true;\r\n\tiAssertW(wheelDescr.convexCylinder.isValid(),wheelDescr.convexCylinder.setToDefault(),\"\");\r\n\tiAssertW( pFactory::Instance()->_createConvexCylinderMesh(&shape,wheelDescr.convexCylinder,wheelReference),\"\");\r\n\r\n\tshape.localPose.M = pMath::getFrom(quatOffset);\r\n\tshape.localPose.t = pMath::getFrom(posOffset);\r\n\t\r\n\tactor->createShape(shape)->isConvexMesh();\r\n\r\n/*\tNxConvexShapeDesc shape;\r\n\tif (!_createConvexCylinder(&shape,wheelReference))\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create convex cylinder mesh\");\r\n\r\n*/\r\n\r\n\r\n\r\n\treturn NULL;\r\n}/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t TextureSinus\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//#include \"precomp.h\"\r\n\r\n#include \"CKAll.h\"\r\nCKObjectDeclaration\t*FillBehaviorTextureSinusDecl();\r\nCKERROR CreateTextureSinusProto(CKBehaviorPrototype **);\r\nint TextureSinus(const CKBehaviorContext& behcontext);\r\nCKERROR TextureSinusCallBackObject(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorTextureSinusDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Texture Sine2\");\t\r\n\tod->SetDescription(\"Produces a sinusoidal displacement on the UV coords of a mesh's material (or one of its channel).\");\r\n\t\r\n /* rem:\r\n\tIn: triggers the process
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tX Amplitude: amplitude of sine displacement along the X axis of the texture
\r\n\tY Amplitude: amplitude of sine displacement along the Y axis of the texture.
\r\n\tVelocity: radial speed expressed in radian/seconds.
\r\n\tChannel: if set to -1, the mapping is calculated only for the default material. \r\n Otherwise it is processed on the specified channel.
\r\n\t
\r\n\t*/\r\n\t/* warning:\r\n\t- The initial UV (mapping coordinates) on the mesh for this texture are saved when the building block is attached\r\n\tto the mesh (that's why we can't target this building block to another mesh than the one\r\n\tthe building block is applied to), therefore you needn't to put Initials Conditions to the mesh if\r\n\tyou wish to recover the initial mapping of the texture.
\r\n\t- Beware, not all the building blocks work with this specification (eg: Texture Scroller need IC to recover the initials mapping).
\r\n\t- The \"Texture Sine\" BB is a time based building block (i.e. it will execute at the same speed what ever the frame rate is \r\n\t[this means you needn't to add a per second building block in front of it]).
\r\n\t*/\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x47e96252,0x632216fe));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateTextureSinusProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"Materials-Textures/Animation\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateTextureSinusProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Texture Sine2\");\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"X Amplitude\", CKPGUID_FLOAT,\"0.1\" );\r\n\tproto->DeclareInParameter(\"Y Amplitude\", CKPGUID_FLOAT ,\"0.1\");\r\n\tproto->DeclareInParameter(\"Velocity\", CKPGUID_FLOAT ,\"1\");\r\n\tproto->DeclareInParameter(\"Channel\", CKPGUID_INT, \"-1\");\r\n\r\n\tproto->DeclareInParameter(\"target\", CKPGUID_MESH, \"-1\");\r\n\r\n\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_VOIDBUF );\t\t// Data\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_FLOAT, \"0.0\" );\t// Time\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(TextureSinus);\r\n\r\n\tproto->SetBehaviorCallbackFct(TextureSinusCallBackObject);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\nint TextureSinus(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\t// we get the amount value\r\n\tfloat xamp=0.1f;\r\n\tbeh->GetInputParameterValue(0, &xamp);\r\n\t\r\n\t// we get the amount value\r\n\tfloat yamp=0.1f;\r\n\tbeh->GetInputParameterValue(1, &yamp);\r\n\t\r\n\tfloat l= 1.0f;\r\n\tbeh->GetInputParameterValue(2, &l);\r\n\t\r\n\t// we get the saved uv's\r\n\tVxUV* savedUV = (VxUV*) beh->GetLocalParameterReadDataPtr(0);\r\n\t\r\n\t// we get the interpolated mesh\r\n\tCKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);\r\n\t\r\n\tint channel = -1;\r\n\tbeh->GetInputParameterValue(3, &channel);\r\n\tint channelcount = mesh->GetChannelCount();\r\n\tif (channel < -1 || channel >= channelcount) {\r\n\t\tbeh->ActivateInput(0, FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_PARAMETERERROR;\r\n\t}\r\n\r\n\tCKDWORD Stride;\r\n\tVxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride,channel);\r\n\tint pointsNumber = mesh->GetModifierUVCount(channel);\r\n\t\r\n\tfloat time;\r\n\tbeh->GetLocalParameterValue(1, &time);\r\n\t\r\n\tfloat t;\r\n\tfor( int i=0 ; iu = savedUV[i].u + ( 0.5f - savedUV[i].u ) * xamp * cosf(t);\r\n\t\tuvarray->v = savedUV[i].v + ( 0.5f - savedUV[i].v ) * yamp * sinf(t);\r\n\t}\r\n\tmesh->ModifierUVMove(channel);\r\n\r\n\tfloat pi = 3.1415926535f;\r\n\ttime += behcontext.DeltaTime * 0.001f;\r\n\t\r\n\tif(l*time > 2*pi)\r\n\t\ttime -= (2*pi / l);\r\n\t\r\n\tbeh->SetLocalParameterValue(1, &time);\r\n\t\r\n\tbeh->ActivateInput(0, FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR TextureSinusCallBackObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\t#ifdef macintosh\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\r\n\t\t\t\r\n\t\t\tCKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);\r\n\t\t\tif(!mesh) \r\n\t\t\t\treturn 0;\r\n\t\t\tint nbvert = mesh->GetModifierUVCount();\r\n\t\t\t// we get the saved uv's\r\n\t\t\tDWORD *savedUV = (DWORD *) beh->GetLocalParameterWriteDataPtr(0);\r\n\t\t\t\r\n\t\t\tfor(int i=0;iGetInputParameterObject(4);\r\n\t\t\tif(!mesh) return 0;\r\n\r\n\t\t\tCKDWORD Stride;\r\n\t\t\tVxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride);\r\n\t\t\tint nbvert = mesh->GetModifierUVCount();\r\n\t\t\t\r\n\t\t\tVxUV *savedUV;\r\n\t\t\tsavedUV = new VxUV[nbvert];\r\n\t\t\t\r\n\t\t\tfor(int i=0 ; iSetLocalParameterValue(0, savedUV, nbvert * sizeof(VxUV) );\r\n\t\t\t\r\n\t\t\tdelete[] savedUV;\r\n\t\t}\r\n\t\tbreak;\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\t// we get the mesh vertices\r\n\t\t\tif(!beh) return 0;\r\n\t\t\tCKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);\r\n\t\t\tif(!mesh) return 0;\r\n\r\n\t\t\tCKDWORD Stride;\r\n\t\t\tVxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride);\r\n\t\t\tint nbvert = mesh->GetModifierUVCount();\r\n\t\t\t\r\n\t\t\tVxUV *savePos = (VxUV*) beh->GetLocalParameterWriteDataPtr(0);\r\n\t\t\tif(!savePos) return 0;\r\n\r\n\t\t\tfor(int i=0 ; iModifierUVMove();\r\n\t\t}\r\n\t\t\r\n\t}\r\n\treturn CKBR_OK; \r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n#include \"pWorldCallbacks.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWRayCastAllShapeDecl();\r\nCKERROR CreatePWRayCastAllShapeProto(CKBehaviorPrototype **pproto);\r\nint PWRayCastAllShape(const CKBehaviorContext& behcontext);\r\nCKERROR PWRayCastAllShapeCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWRayCastAllShapeDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PWRayCastAllShapes\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Performs a ray cast test\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7a2308ad,0x7a777c6e));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePWRayCastAllShapeProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePWRayCastAllShapeProto\r\n// FullName: CreatePWRayCastAllShapeProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nenum bInput\r\n{\r\n\r\n\t//bbI_WorldRef,\r\n\tbbI_RayOri,\r\n\tbbI_RayOriRef,\r\n\tbbI_RayDir,\r\n\tbbI_RayDirRef,\r\n\tbbI_Length,\r\n\tbbI_ShapesType,\r\n\tbbI_Groups,\r\n\tbbI_Mask,\r\n\r\n\r\n};\r\n\r\nenum bbS\r\n{\r\n\tbbS_Hints=2,\r\n\tbbS_Groups=3,\r\n\tbbS_Mask=4\r\n};\r\n\r\nenum bbO\r\n{\r\n\r\n\tbbO_Shape,\r\n\tbbO_Impact,\r\n\tbbO_Normal,\r\n\tbbO_FaceIndex,\r\n\tbbO_Distance,\r\n\tbbO_UV,\r\n\tbbO_Material\r\n\r\n};\r\nenum bbOT\r\n{\r\n\tbbOT_Yes,\r\n\tbbOT_No,\r\n\tbbOT_Finish,\r\n\tbbOT_Next,\r\n\r\n};\r\nCKERROR CreatePWRayCastAllShapeProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PWRayCastAllShapes\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PWRayCastAllShapes \r\n\r\n\r\n\tPWRayCastAllShapes is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a
3DEntity
\r\n\tPerforms a ray cast test. Outputs hit informations.
\r\n\tSee PWRayCasts.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PWRayCastAllShapes.png\r\n\r\n\tIn: Triggers the process.\r\n\t
\r\n\tNext: Next Hit.\r\n\t
\r\n\t\r\n\t\r\n\tYes: Hit occured.\r\n\t
\r\n\tNo: No hits.\r\n\t
\r\n\tFinish: Last hit.\r\n\t
\r\n\tNext: Loop out.\r\n\t
\r\n\r\n\r\n\r\n\r\n\r\n\tTarget: World Reference. pDefaultWorld!\r\n\t
\r\n\tRay Origin: Start of the ray.\r\n\t
\r\n\tRay Origin Reference: Reference object to determine the start of the ray. Ray Origin becomes transformed if an object is given.\r\n\t
\r\n\tRay Direction: Direction of the ray.\r\n\t
\r\n\tRay Direction Reference: Reference object to determine the direction of the ray. Ray Direction becomes transformed if an object is given. Up axis will be used then.\r\n\t
\r\n\tLength: Lenght of the ray.\r\n\t
\r\n\tShapes Types: Adds static and/or dynamic shapes to the test.\r\n\t
\r\n\r\n\tGroups: Includes specific groups to the test. \r\n\t
\r\n\tGroups Mask: Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t
\r\n\r\n\tTouched Body: The touched body.\r\n\t
\r\n\tImpact Position: Hit point in world space.\r\n\t
\r\n\tFace Normal: Normal of the hit.\r\n\t
\r\n\tFace Index: \r\n\t
\r\n\tDistance: Distance between ray start and hit.\r\n\t
\r\n\tUV: not used yet !\r\n\t
\r\n\tMaterial Index: Index of the internal physic material.\r\n\t
\r\n\t\r\n\t\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pWorld::raycastAllShapes()
\r\n\t\r\n\t*/\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\r\n\r\n\t\r\n\tproto->DeclareOutput(\"Yes\");\r\n\tproto->DeclareOutput(\"No\");\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"Next\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Ray Origin\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Ray Origin Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Ray Direction\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Ray Direction Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Length\",CKPGUID_FLOAT);\r\n\tproto->DeclareInParameter(\"Shapes Type\",VTF_SHAPES_TYPE);\r\n\r\n\tproto->DeclareInParameter(\"Groups\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Filter Mask\",VTS_FILTER_GROUPS);\r\n\r\n\r\n\tproto->DeclareLocalParameter(\"result\", CKPGUID_POINTER);\r\n\tproto->DeclareLocalParameter(\"index\", CKPGUID_INT);\r\n\r\n\tproto->DeclareSetting(\"RayCast Hints\",VTF_RAY_HINTS,\"0\");\r\n\tproto->DeclareSetting(\"Groups\",CKPGUID_BOOL,\"false\");\r\n\tproto->DeclareSetting(\"Groups Mask\",CKPGUID_BOOL,\"false\");\r\n\r\n\r\n\tproto->DeclareOutParameter(\"Touched Body\",CKPGUID_3DENTITY);\r\n\tproto->DeclareOutParameter(\"Impact Position\",CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Face Normal\",CKPGUID_VECTOR);\r\n\tproto->DeclareOutParameter(\"Face Index\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Distance\",CKPGUID_FLOAT);\r\n\tproto->DeclareOutParameter(\"UV\",CKPGUID_2DVECTOR);\r\n\tproto->DeclareOutParameter(\"Material Index\",CKPGUID_INT);\r\n\r\n\t//proto->DeclareSetting(\"Trigger on Enter\",CKPGUID_BOOL,\"FALSE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PWRayCastAllShapeCB );\r\n\tproto->SetFunction(PWRayCastAllShape);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Enter,\r\n\tbbO_Stay,\r\n\tbbO_Leave,\r\n};\r\n\r\n//************************************\r\n// Method: PWRayCastAllShape\r\n// FullName: PWRayCastAllShape\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PWRayCastAllShape(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// the world : \r\n\tpWorld *world=GetPMan()->getWorld(target->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tNxScene *scene = world->getScene();\r\n\tif (!scene)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\tpRayCastHits *carray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&carray);\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\tcarray->clear();\r\n\t\t}else\r\n\t\t{\r\n\t\t\tcarray = new pRayCastHits();\r\n\t\t}\r\n\t\t\r\n\t\tbeh->SetLocalParameterValue(0,&carray);\r\n\r\n\t\tint hitIndex = 0;\r\n\t\tbeh->SetLocalParameterValue(1,&hitIndex);\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tCK3dEntity *rayOriRef= (CK3dEntity *) beh->GetInputParameterObject(bbI_RayOriRef);\r\n\t\tCK3dEntity *rayDirRef= (CK3dEntity *) beh->GetInputParameterObject(bbI_RayDirRef);\r\n\r\n\t\t//ori : \r\n\t\tVxVector ori = GetInputParameterValue(beh,bbI_RayOri);\r\n\t\tVxVector oriOut = ori;\r\n\t\tif (rayOriRef)\r\n\t\t{\r\n\t\t\trayOriRef->Transform(&oriOut,&ori);\r\n\t\t}\r\n\t\t//dir : \r\n\t\tVxVector dir = GetInputParameterValue(beh,bbI_RayDir);\r\n\t\tVxVector dirOut = dir;\r\n\t\tif (rayDirRef)\r\n\t\t{\r\n\t\t\tVxVector dir,up,right;\r\n\t\t\trayDirRef->GetOrientation(&dir,&up,&right);\r\n\t\t\trayDirRef->TransformVector(&dirOut,&up);\r\n\t\t}\r\n\r\n\t\tfloat lenght = GetInputParameterValue(beh,bbI_Length);\r\n\t\tint types = GetInputParameterValue(beh,bbI_ShapesType);\r\n\r\n\t\tVxRay ray;\r\n\t\tray.m_Direction = dirOut;\r\n\t\tray.m_Origin = oriOut;\r\n\r\n\t\tpRayCastReport &report = *world->getRaycastReport();\r\n\t\treport.setCurrentBehavior(beh->GetID());\r\n\r\n\t\t\r\n\r\n\t\tpRaycastBit hints;\r\n\t\tbeh->GetLocalParameterValue(bbS_Hints,&hints);\r\n\r\n\r\n\t\tDWORD groupsEnabled;\r\n\t\tDWORD groups = 0xffffffff;\r\n\t\tbeh->GetLocalParameterValue(bbS_Groups,&groupsEnabled);\r\n\t\tif (groupsEnabled)\r\n\t\t{\r\n\t\t\tgroups = GetInputParameterValue(beh,bbI_Groups);\r\n\t\t}\r\n\r\n\t\tpGroupsMask *gmask = NULL;\r\n\t\tDWORD mask;\r\n\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\tif (mask)\r\n\t\t{\r\n\t\t\tCKParameter *maskP = beh->GetInputParameter(bbI_Mask)->GetRealSource();\r\n\t\t\tgmask->bits0 = GetValueFromParameterStruct(maskP,0);\r\n\t\t\tgmask->bits1 = GetValueFromParameterStruct(maskP,1);\r\n\t\t\tgmask->bits2 = GetValueFromParameterStruct(maskP,2);\r\n\t\t\tgmask->bits3 = GetValueFromParameterStruct(maskP,3);\r\n\r\n\t\t}\r\n\r\n\t\tint nbShapes = world->raycastAllShapes(ray,(pShapesType)types,groups,lenght,hints,gmask);\r\n\r\n\t\tif (nbShapes)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbOT_Yes);\r\n\t\t\tbeh->ActivateInput(1,TRUE);\r\n\r\n\t\t}else{\r\n\t\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\t}\r\n\t}\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tpRayCastHits *carray = NULL;\r\n\t\tbeh->GetLocalParameterValue(0,&carray);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\tif (carray->size())\r\n\t\t\t{\r\n\t\t\t\tNxRaycastHit *hit = carray->at(carray->size()-1);\r\n\t\t\t\tif (hit)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tpRaycastBit hints;\r\n\t\t\t\t\tbeh->GetLocalParameterValue(bbS_Hints,&hints);\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (hints & RCH_Shape)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tNxShape *shape = hit->shape;\r\n\t\t\t\t\t\tif (shape)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tpSubMeshInfo *sInfo = static_cast(shape->userData);\r\n\t\t\t\t\t\t\tif (sInfo->entID)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tCKObject *obj = (CKObject*)GetPMan()->m_Context->GetObject(sInfo->entID);\r\n\t\t\t\t\t\t\t\tif (obj)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tbeh->SetOutputParameterObject(bbO_Shape,obj);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t//\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (hints & RCH_Distance)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_Distance,&hit->distance);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (hints & RCH_FaceIndex)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_FaceIndex,&hit->internalFaceID);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (hints & RCH_Impact)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tVxVector vec = getFrom(hit->worldImpact);\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_Impact,&vec);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (hints & RCH_FaceNormal)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tVxVector vec = getFrom(hit->worldNormal);\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_Normal,&vec);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (hints & RCH_Material)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint vec = hit->materialIndex;\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_Material,&vec);\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (hints & RCH_FaceIndex)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tint vec = hit->faceID;\r\n\t\t\t\t\t\tbeh->SetOutputParameterValue(bbO_FaceIndex,&vec);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t\tcarray->pop_back();\r\n\r\n\t\t\t\t\tif (carray->size())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Next);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t\t\t\t}\r\n\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PWRayCastAllShapeCB\r\n// FullName: PWRayCastAllShapeCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PWRayCastAllShapeCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t\t\r\n\t\t\tDWORD flags;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Hints,&flags);\r\n\r\n\t\t\tbeh->EnableOutputParameter(bbO_Shape,flags & RCH_Shape);\r\n\t\t\tbeh->EnableOutputParameter(bbO_Impact,flags & RCH_Impact);\r\n\t\t\tbeh->EnableOutputParameter(bbO_Normal,flags & RCH_Normal);\r\n\t\t\tbeh->EnableOutputParameter(bbO_FaceIndex,flags & RCH_FaceIndex);\r\n\t\t\tbeh->EnableOutputParameter(bbO_Distance,flags & RCH_Distance);\r\n\t\t\tbeh->EnableOutputParameter(bbO_UV,flags & RCH_UV);\r\n\t\t\tbeh->EnableOutputParameter(bbO_Material,flags & RCH_Material);\r\n\r\n\r\n\t\t\tDWORD groups;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Groups,&groups);\r\n\t\t\tbeh->EnableInputParameter(bbI_Groups,groups);\r\n\r\n\t\t\tDWORD mask;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\t\tbeh->EnableInputParameter(bbI_Mask,mask);\r\n\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \"TetraGraphics.h\"\r\n\r\nnamespace SOFTBODY\r\n{\r\nTetraGraphicsInterface *gGraphicsInterface = 0;\r\nSoftFileInterface *gFileInterface=0;\r\n}\r\n\r\n\r\n#include \"stdafx.h\"\r\n#include \"xSplash.h\"\r\n#include \"splashscreenex.h\"\r\n//#include \"../../CustomPlayerDefines.h\"\r\n\r\n\r\n\t\r\nCSplashScreenEx *splash = NULL;\r\n\r\nLRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\nnamespace xSplash\r\n{\r\n\r\n\tCSplashScreenEx *GetSplash()\r\n\t{\r\n\t\treturn splash;\r\n\t}\r\n\t//************************************\r\n\t// Method: HideSplash\r\n\t// FullName: xSplash::HideSplash\r\n\t// Access: public \r\n\t// Returns: void\r\n\t// Qualifier:\r\n\t//************************************\r\n\tvoid HideSplash()\r\n\t{ \r\n\t\tif (splash)\r\n\t\t{\r\n\t\t\tsplash->Hide() ;\r\n\t\t\tdelete splash;\r\n\t\t\tsplash = NULL;\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\n\t//************************************\r\n\t// Method: ShowSplash\r\n\t// FullName: xSplash::ShowSplash\r\n\t// Access: public \r\n\t// Returns: void\r\n\t// Qualifier:\r\n\t//************************************\r\n\tvoid ShowSplash()\r\n\t{ \r\n\t\tif (splash)\r\n\t\t{\r\n\t\t\tsplash->Show() ;\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\n\t//************************************\r\n\t// Method: SetText\r\n\t// FullName: xSplash::SetText\r\n\t// Access: public \r\n\t// Returns: void\r\n\t// Qualifier:\r\n\t// Parameter: const char* text\r\n\t//************************************\r\n\tvoid SetText(const char* text)\r\n\t{\r\n\t\tif(splash)\r\n\t\t{\r\n\t\t\tsplash->SetText(text);\r\n\t\t}\r\n\t}\r\n\r\n\t//************************************\r\n\t// Method: CreateSplashEx\r\n\t// FullName: xSplash::CreateSplashEx\r\n\t// Access: public \r\n\t// Returns: void\r\n\t// Qualifier:\r\n\t// Parameter: CWnd *parent\r\n\t// Parameter: int w\r\n\t// Parameter: int h\r\n\t//************************************\r\n\tvoid CreateSplashEx(CWnd *parent,int w,int h)\r\n\t{\r\n\r\n\t\tsplash=new CSplashScreenEx();\r\n\t\tsplash->Create(parent,NULL,0,CSS_FADEIN | CSS_CENTERSCREEN | CSS_SHADOW|CSS_FADEOUT|CSS_HIDEONCLICK\t);\r\n\t\tsplash->SetBitmap(CPF_SPLASH_FILE,255,0,255);\r\n\t\tsplash->SetTextFont(CPF_SPLASH_TEXT_TYPE,100,CSS_TEXT_NORMAL);\r\n\t\tint Xpos,Ypos;\r\n\t\tXpos=(GetSystemMetrics(SM_CXSCREEN)-w)/2;\r\n\t\tYpos=(GetSystemMetrics(SM_CYSCREEN)-h)/2;\r\n\r\n\t\t//splash->SetTextRect(CRect(125,60,291,104));\r\n\t\tsplash->SetTextColor(RGB(255,251,185));\r\n\t\tsplash->SetTextFormat(CPF_SPLASH_TEXT_FORMAT);\r\n\t\tsplash->SetFadeInTime(2000);\r\n\t\tsplash->SetFadeOutTime(3000);\r\n\r\n\t}\r\n\r\n\t//************************************\r\n\t// Method: CreateSplash\r\n\t// FullName: xSplash::CreateSplash\r\n\t// Access: public \r\n\t// Returns: void\r\n\t// Qualifier:\r\n\t// Parameter: HINSTANCE hinst\r\n\t// Parameter: int w\r\n\t// Parameter: int h\r\n\t//************************************\r\n\tvoid CreateSplash(HINSTANCE hinst,int w,int h)\r\n\t{\r\n\r\n\t\tsplash=new CSplashScreenEx();\r\n\t\tsplash->Create(NULL,NULL,0,CSS_FADEIN | CSS_CENTERSCREEN | CSS_SHADOW|CSS_FADEOUT|CSS_HIDEONCLICK\t);\r\n\t\tsplash->SetBitmap(\"splash.bmp\",255,0,255);\r\n\r\n\t\tsplash->SetTextFont(\"MicrogrammaDBolExt\",100,CSS_TEXT_NORMAL);\r\n\t\tint Xpos,Ypos;\r\n\t\tXpos=(GetSystemMetrics(SM_CXSCREEN)-w)/2;\r\n\t\tYpos=(GetSystemMetrics(SM_CYSCREEN)-h)/2;\r\n\r\n\t\t//splash->SetTextRect(CRect(125,60,291,104));\r\n\t\tsplash->SetTextColor(RGB(255,251,185));\r\n\t\tsplash->SetTextFormat(DT_SINGLELINE | DT_LEFT | DT_BOTTOM);\r\n\t\tsplash->Show();\r\n\r\n\t\t//splash=CreateDialog(hinst,(LPCTSTR)IDD_DIALOG2, NULL, (DLGPROC)About); \r\n\t\t/*::GetWindowRect(splash->getw,&rc);\r\n\t\tSetWindowPos(splash,NULL,(GetSystemMetrics(SM_CXSCREEN)-(rc.right-rc.left))/2,\r\n\t\t(GetSystemMetrics(SM_CYSCREEN)-(rc.bottom-rc.top))/2,\t0,0,SWP_NOZORDER|SWP_NOSIZE);\r\n\t\tShowWindow(splash, SW_SHOW);\r\n\t\tUpdateWindow(splash);\r\n\t\t*/\r\n\t}\r\n\r\n\r\n\t//************************************\r\n\t// Method: About\r\n\t// FullName: xSplash::About\r\n\t// Access: public \r\n\t// Returns: LRESULT CALLBACK\r\n\t// Qualifier:\r\n\t// Parameter: HWND hDlg\r\n\t// Parameter: UINT message\r\n\t// Parameter: WPARAM wParam\r\n\t// Parameter: LPARAM lParam\r\n\t//************************************\r\n\tLRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r\n\t{\r\n\t\tswitch (message)\r\n\t\t{\r\n\t\tcase WM_INITDIALOG:\r\n\t\t\treturn TRUE;\r\n\r\n\t\tcase WM_COMMAND:\r\n\r\n\t\t\tif (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) \r\n\t\t\t{\r\n\t\t\t\tEndDialog(hDlg, LOWORD(wParam));\r\n\t\t\t\treturn TRUE;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\treturn FALSE;\r\n\t}\r\n}//end of namespace xSplash\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pFluid.h\"\r\n#include \"pFluidEmitter.h\"\r\n#include \"CK3dPointCloud.h\"\r\n\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\npFluidEmitter*pFluid::createEmitter(const pFluidEmitterDesc& desc)\r\n{\r\n\r\n\tNxFluidEmitterDesc eDesc ;\r\n\teDesc.setToDefault();\r\n\r\n\tpFactory::Instance()->copyToEmitterDesc(eDesc,desc);\r\n\r\n\tint valid = eDesc.isValid();\r\n\tif (!valid)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Emitter Description not Valid !\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tCK3dEntity*entityReference = (CK3dEntity*)ctx()->GetObject(desc.entityReference);\r\n\tif (!entityReference)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"You must set a reference object ID in .referenceEntity\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\teDesc.relPose.M.id();\r\n\teDesc.relPose.M.rotX(-NxHalfPiF32);\r\n\teDesc.relPose.t = NxVec3(0,1.1f,0);\r\n\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\r\n\tNxFluidEmitter *emitter = getFluid()->createEmitter(eDesc);\r\n\r\n\tif (!emitter)\r\n\t\treturn NULL;\r\n\t\r\n\tpFluidEmitter * result = new pFluidEmitter();\r\n\tresult->setEmitter(emitter);\r\n\tresult->setFluid(this);\r\n\tresult->setEntityReference(entityReference->GetID());\r\n\tVxVector pos;\r\n\tif (desc.frameShape)\r\n\t{\r\n\t\tdesc.frameShape->GetPosition(&pos);\r\n\t}\r\n\temitter->setGlobalPosition(getFrom(pos));\r\n\temitter->userData = result;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tRender Settings : \r\n\t//\r\n\r\n\tpFluidRenderSettings *rSettings = new pFluidRenderSettings(ctx(),desc.entityReference,\"pFluidEmitter\");\r\n\trSettings->setToDefault();\r\n\trSettings->setEmitter(result);\r\n\r\n\treturn result;\r\n\t\r\n}\r\n\r\n\r\nCK3dEntity*pFluid::getParticleObject()\r\n{\r\n\r\n\tCK3dEntity* result = (CK3dEntity*)ctx()->GetObject(entityID);\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\nvoid pFluid::updateVirtoolsMesh()\r\n{\r\n\r\n/*\r\n\tupdateCloud();\r\n\treturn;*/\r\n\t//todo, move this into a small billboard rendering lib.\r\n\tif (!mRenderBuffer)\r\n\t{\r\n\t\tunsigned sizeFloat = mMaxParticles * 3 * 4;\r\n\t\tmRenderBuffer = new float[sizeFloat];\r\n\r\n\t\tif (mTrackUserData)\r\n\t\t{\r\n\t\t\tmRenderBufferUserData = new float[mMaxParticles * 4 * 4];\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn ;\r\n\r\n\tCK3dEntity *dstEnt = getParticleObject();\r\n\tCKMesh *mesh = getParticleObject()->GetCurrentMesh();\r\n\r\n\tif (!dstEnt || !mesh )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tif (mParticleBuffer)\r\n\t{\r\n\r\n\t\tfor (int i = 0 ; i < mesh->GetVertexCount() ; i++)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tpParticle *p = &mParticleBuffer[i];\r\n\t\t\tif (p)\r\n\t\t\t{\r\n\t\t\t\tVxVector v = getFrom(p->position);\r\n\t\t\t\tVxVector outIV;\r\n\t\t\t\tgetParticleObject()->InverseTransform(&outIV,&v);\r\n\t\t\t\tmesh->SetVertexPosition(i,&outIV);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tmesh->VertexMove();\r\n}\r\n\r\npFluid::pFluid(NxFluidDesc &desc, bool trackUserData, bool provideCollisionNormals, const VxVector& color, float particleSize) :\r\n\r\n\tmParticleBufferNum(0),\r\n\tmParticleBuffer(NULL),\r\n\tmFluid(NULL),\r\n\tmTrackUserData(trackUserData),\r\n\tmMyParticleBuffer(NULL),\r\n\tmCreatedParticleIdsNum(0),\r\n\tmCreatedParticleIds(NULL),\r\n\tmDeletedParticleIdsNum(0),\r\n\tmDeletedParticleIds(NULL),\r\n\tmParticleColor(color),\r\n\tmParticleSize(particleSize),\r\n\tmRenderBuffer(NULL),\r\n\tmRenderBufferUserData(NULL)\r\n{\r\n\r\n\tmMaxParticles = desc.maxParticles;\r\n\tmParticleBuffer = new pParticle[mMaxParticles];\r\n\tdesc.userData = this;\r\n\r\n\tentityID = 0;\r\n\r\n\r\n\t//Setup particle write data.\r\n\tNxParticleData particleData;\r\n\tparticleData.numParticlesPtr = &mParticleBufferNum;\r\n\tparticleData.bufferPos = &mParticleBuffer[0].position.x;\r\n\tparticleData.bufferPosByteStride = sizeof(pParticle);\r\n\tparticleData.bufferVel = &mParticleBuffer[0].velocity.x;\r\n\tparticleData.bufferVelByteStride = sizeof(pParticle);\r\n\tparticleData.bufferDensity = &mParticleBuffer[0].density;\r\n\tparticleData.bufferDensityByteStride = sizeof(pParticle);\r\n\tparticleData.bufferLife = &mParticleBuffer[0].lifetime;\r\n\tparticleData.bufferLifeByteStride = sizeof(pParticle);\r\n\tparticleData.bufferId = &mParticleBuffer[0].id;\r\n\tparticleData.bufferIdByteStride = sizeof(pParticle);\r\n\r\n\tif (provideCollisionNormals)\r\n\t{\r\n\t\tparticleData.bufferCollisionNormal = &mParticleBuffer[0].collisionNormal.x;\r\n\t\tparticleData.bufferCollisionNormalByteStride = sizeof(pParticle);\r\n\t}\r\n\r\n\tdesc.particlesWriteData = particleData;\r\n\r\n\t//User data buffers\r\n\tif (mTrackUserData)\r\n\t{\r\n\t\t//mMyParticleBuffer = new MyParticle[mMaxParticles];\r\n\t\tmCreatedParticleIds = new NxU32[mMaxParticles];\r\n\t\tmDeletedParticleIds = new NxU32[mMaxParticles];\r\n\r\n\t\t//Setup id write data.\r\n\t\tNxParticleIdData idData;\r\n\r\n\t\t//Creation\r\n\t\tidData.numIdsPtr = &mCreatedParticleIdsNum;\r\n\t\tidData.bufferId = mCreatedParticleIds;\r\n\t\tidData.bufferIdByteStride = sizeof(NxU32);\r\n\t\tdesc.particleCreationIdWriteData = idData;\r\n\r\n\t\t//Deletion\r\n\t\tidData.numIdsPtr = &mDeletedParticleIdsNum;\r\n\t\tidData.bufferId = mDeletedParticleIds;\r\n\t\tidData.bufferIdByteStride = sizeof(NxU32);\r\n\t\tdesc.particleDeletionIdWriteData = idData;\r\n\t}\r\n\r\n\t\r\n}\r\n\r\n\r\n\r\npFluidDesc::pFluidDesc()\r\n{\r\n\r\n\tsetToDefault();\r\n}\r\n\r\nvoid pFluidDesc::setToDefault()\r\n{\r\n\r\n\tmaxParticles\t\t\t\t= 500;\r\n\tnumReserveParticles\t\t\t= 0;\r\n\trestParticlesPerMeter\t\t= 50.0f;\r\n\trestDensity\t\t\t\t\t= 1000.0f;\r\n\tkernelRadiusMultiplier\t\t= 1.2f;\r\n\tmotionLimitMultiplier\t\t= 3.0f * kernelRadiusMultiplier;\r\n\tcollisionDistanceMultiplier = 0.1f * kernelRadiusMultiplier;\r\n\tpacketSizeMultiplier\t\t= 16;\r\n\tstiffness\t\t\t\t\t= 20.0f;\r\n\tviscosity\t\t\t\t\t= 6.0f;\r\n\tsurfaceTension\t\t\t\t= 0.0f;\r\n\tdamping\t\t\t\t\t\t= 0.0f;\r\n\tfadeInTime\t\t\t\t\t= 0.0f;\r\n\texternalAcceleration.Set(0.0f,0.0f,0.0f);\r\n\tprojectionPlane.set(NxVec3(0.0f, 0.0f, 1.0f), 0.0f);\r\n\trestitutionForStaticShapes\t= 0.5f;\r\n\tdynamicFrictionForStaticShapes = 0.05f;\r\n\tstaticFrictionForStaticShapes = 0.05f;\r\n\tattractionForStaticShapes\t= 0.0f;\r\n\trestitutionForDynamicShapes\t= 0.5f;\r\n\tdynamicFrictionForDynamicShapes = 0.5f;\r\n\tstaticFrictionForDynamicShapes = 0.5f;\r\n\tattractionForDynamicShapes\t= 0.0f;\r\n\tcollisionResponseCoefficient = 0.2f;\r\n\r\n\tsimulationMethod\t\t\t= (pFluidSimulationMethod)(NX_F_SPH);\r\n\tcollisionMethod\t\t\t\t=(pFluidCollisionMethod)(NX_F_STATIC|NX_F_DYNAMIC);\r\n\tcollisionGroup\t\t\t\t= 0;\t\r\n\tgroupsMask.bits0 = 0;\r\n\tgroupsMask.bits1 = 0;\r\n\tgroupsMask.bits2 = 0;\r\n\tgroupsMask.bits3 = 0;\r\n\r\n\r\n\tflags\t\t\t\t\t\t= (pFluidFlag)(NX_FF_ENABLED);\r\n\tflags &= ~NX_FF_HARDWARE;\r\n\r\n\tuserData\t\t\t\t\t= NULL;\r\n\tname\t\t\t\t\t\t= NULL;\r\n\tworldReference = 0 ;\r\n\r\n}\r\n\r\nbool pFluidDesc::isValid()const\r\n{\r\n\r\n\tif (kernelRadiusMultiplier < 1.0f) return false;\r\n\tif (restDensity <= 0.0f) return false;\r\n\tif (restParticlesPerMeter <= 0.0f) return false;\r\n\r\n\tif (packetSizeMultiplier < 4) return false;\r\n\tif (packetSizeMultiplier & ( packetSizeMultiplier - 1 ) ) return false; \r\n\r\n\tif (motionLimitMultiplier <= 0.0f) return false;\r\n\tif (motionLimitMultiplier > packetSizeMultiplier*kernelRadiusMultiplier) return false;\r\n\r\n\tif (collisionDistanceMultiplier <= 0.0f) return false;\r\n\tif (collisionDistanceMultiplier > packetSizeMultiplier*kernelRadiusMultiplier) return false;\r\n\r\n\tif (stiffness <= 0.0f) return false;\r\n\tif (viscosity <= 0.0f) return false;\r\n\tif (surfaceTension < 0.0f) return false;\r\n\r\n\tbool isNoInteraction = (simulationMethod & NX_F_NO_PARTICLE_INTERACTION) > 0;\r\n\tbool isSPH = (simulationMethod & NX_F_SPH) > 0;\r\n\tbool isMixed = (simulationMethod & NX_F_MIXED_MODE) > 0;\r\n\tif (!(isNoInteraction || isSPH || isMixed)) return false;\r\n\tif (isNoInteraction && (isSPH || isMixed)) return false;\r\n\tif (isSPH && (isNoInteraction || isMixed)) return false;\r\n\tif (isMixed && (isNoInteraction || isSPH)) return false;\r\n\r\n\tif (damping < 0.0f) return false;\r\n\tif (fadeInTime < 0.0f) return false;\r\n\r\n\tif (projectionPlane.normal.isZero()) return false;\r\n\r\n\tif (dynamicFrictionForDynamicShapes < 0.0f || dynamicFrictionForDynamicShapes > 1.0f) return false;\r\n\tif (staticFrictionForDynamicShapes < 0.0f || staticFrictionForDynamicShapes > 1.0f) return false;\r\n\tif (restitutionForDynamicShapes < 0.0f || restitutionForDynamicShapes > 1.0f) return false;\r\n\tif (attractionForDynamicShapes < 0.0f) return false;\r\n\tif (dynamicFrictionForStaticShapes < 0.0f || dynamicFrictionForStaticShapes > 1.0f) return false;\r\n\tif (staticFrictionForStaticShapes < 0.0f || staticFrictionForStaticShapes > 1.0f) return false;\r\n\tif (restitutionForStaticShapes < 0.0f || restitutionForStaticShapes > 1.0f) return false;\r\n\tif (attractionForStaticShapes < 0.0f) return false;\r\n\tif (collisionResponseCoefficient < 0.0f) return false;\r\n\r\n\t\r\n\tif (maxParticles > 32767) return false;\r\n\tif (maxParticles < 1) return false;\r\n\r\n\tif (numReserveParticles >= maxParticles) return false;\r\n\r\n\tif(collisionGroup >= 32) return false; // We only support 32 different collision groups\r\n\r\n\treturn true;\r\n}\r\n\r\nvoid pFluid::updateCloud()\r\n{\r\n\r\n\tCK3dPointCloud *cloud = getPointCloud();\r\n\tif (!cloud)\r\n\t\treturn;\r\n\r\n\tCKMesh *mesh = getParticleObject()->GetCurrentMesh();\r\n\tint count = mesh->GetVertexCount();\r\n\r\n\tVxVector *points = new VxVector[count];\r\n\tif (mParticleBuffer)\r\n\t{\r\n\t\tfor (int i = 0 ; i < mesh->GetVertexCount() ; i++)\r\n\t\t{\r\n\r\n\t\t\tpParticle *p = &mParticleBuffer[i];\r\n\t\t\tif (p)\r\n\t\t\t{\r\n\t\t\t\tpoints[i]= getFrom(p->position);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tVxVector prec(0.5,0.5,0.5);\r\n\tVxVector a[10];\r\n\r\n\r\n\tint b = cloud->CreateFromPointList(2,a,NULL,NULL,NULL,prec);\r\n\tif (b)\r\n\t{\r\n\t\tint op2=2;\r\n\t\top2++;\r\n\t}\r\n\r\n}\r\n\r\n#endif // HAS_FLUIDS#ifndef __PJOINTTYPES_H__\r\n#define __PJOINTTYPES_H__\r\n\r\n\r\n/** \\addtogroup Joints\r\n@{\r\n*/\r\n\r\n\r\n/**\r\n\\brief Describes a joint motor. Some joints can be motorized, this allows them to apply a force to cause attached actors to move. Joints which can be motorized: #pJointPulley #pJointRevolute is used for a similar purpose with pJointD6.\r\n\r\n*/\r\nclass pMotor\r\n{\r\n\r\npublic :\r\n\r\n\t/**\r\n\tThe relative velocity the motor is trying to achieve.Default = 0.0f.\r\n\t*/\r\n\tfloat targetVelocity;\r\n\t/**\r\n\tThe maximum force (or torque) the motor can exert.Default = 0.0f.\r\n\t*/\r\n\tfloat maximumForce;\r\n\t/**\r\n\tIf true, motor will not brake when it spins faster than velTarget.Default = false.\r\n\t*/\r\n\tbool freeSpin;\r\n\r\n\tpMotor()\r\n\t{\r\n\t\ttargetVelocity = 0.0f;\r\n\t\tmaximumForce =0.0f;\r\n\t\tfreeSpin = false;\r\n\t}\r\n\r\n};\r\n/**\r\n\\brief Describes a joint limit. pJointLimit is registered as custom structure #pJLimit and can be accessed or modified through parameter operations.
\r\n\r\nThis is used for ball joints. \r\n\\sa \\ref PJBall.\r\n\r\n*/\r\nclass pJointLimit\r\n{\r\n\r\npublic:\r\n\r\n\t/**\r\n\t[not yet implemented!] Limit can be made softer by setting this to less than 1. Default = 0.0f;\r\n\t*/\r\n\tfloat hardness;\r\n\t/**\r\n\tThe angle / position beyond which the limit is active. Default = 0.0f;\r\n\t*/\r\n\tfloat value;\r\n\t/**\r\n\tThe limit bounce. Default = 0.0f;\r\n\t*/\r\n\tfloat restitution;\r\n\tpJointLimit()\r\n\t{\r\n\t\thardness = 0.0f;\r\n\t\tvalue = 0.0f;\r\n\t\trestitution = 0.0f;\r\n\t}\r\n\r\n\tpJointLimit(float _h,float _r, float _v)\r\n\t{\r\n\t\thardness = _h;\r\n\t\trestitution = _r;\r\n\t\tvalue = _v;\r\n\t}\r\n\r\n};\r\n\r\n\r\n\r\n/**\r\n\\brief Describes a joint soft limit for D6 usage. pJD6SoftLimit is registered as custom structure #pJD6SLimit and can be accessed or modified through parameter operations.
\r\n\\sa #PJD6.\r\n*/\r\nclass pJD6SoftLimit\r\n{\r\n\r\n\r\n\r\npublic:\r\n\t/**\\brief If spring is greater than zero, this is the damping of the spring. \r\n\t*/\r\n\tfloat damping;\r\n\t/**\\brief If greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit.\r\n\r\n\tRange: [0,inf)
\r\n\tDefault: 0.0\r\n\t*/\r\n\tfloat spring;\r\n\t/**\\brief The angle or position beyond which the limit is active. \r\n\r\n\tWhich side the limit restricts depends on whether this is a high or low limit.\r\n\r\n\tUnit: Angular: Radians\r\n\tRange: Angular: (-PI,PI)
\r\n\tRange: Positional: [0.0,inf)
\r\n\tDefault: 0.0\r\n\t*/\r\n\tfloat value;\r\n\t/**\\brief Controls the amount of bounce when the joint hits a limit. \r\n\t
\r\n\t
\r\n\tA restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit. A value of zero causes the joint to stop dead.\r\n\r\n\tIn situations where the joint has many locked DOFs (e.g. 5) the restitution may not be applied correctly. This is due to a limitation in the solver which causes the restitution velocity to become zero as the solver enforces constraints on the other DOFs.\r\n\r\n\tThis limitation applies to both angular and linear limits, however it is generally most apparent with limited angular DOFs.\r\n\r\n\tDisabling joint projection and increasing the solver iteration count may improve this behavior to some extent.\r\n\r\n\tAlso, combining soft joint limits with joint motors driving against those limits may affect stability.\r\n\r\n\tRange: [0,1]
\r\n\tDefault: 0.0\r\n\r\n\t*/\r\n\tfloat restitution;\r\n\tpJD6SoftLimit()\r\n\t{\r\n\t\tdamping = 0.0f;\r\n\t\tspring = 0.0f;\r\n\t\tvalue = 0.0f;\r\n\t\trestitution = 0.0f;\r\n\t}\r\n\tpJD6SoftLimit(float _damping,float _spring,float _value,float _restitution)\r\n\t{\r\n\r\n\t\tdamping = _damping;\r\n\t\tspring = _spring;\r\n\t\tvalue = _value;\r\n\t\trestitution = _restitution;\r\n\t}\r\n\r\n};\r\n/**\r\n\\brief Class used to describe drive properties for a #pJointD6.\r\n*/\r\nclass pJD6Drive\r\n{\r\n\r\npublic:\r\n\r\n\t/**\r\n\tDamper coefficient\r\n\tDefault: 0\r\n\tRange: [0,inf)\r\n\t*/\r\n\tfloat damping;\r\n\t/**\r\n\tSpring coefficient\r\n\r\n\tDefault: 0\r\n\tRange: (-inf,inf)\r\n\t*/\r\n\tfloat spring;\r\n\t/**\r\n\tThe maximum force (or torque) the drive can exert.\r\n\r\n\tDefault: FloatMax\r\n\tRange: [0,inf)\r\n\t*/\r\n\tfloat forceLimit;\r\n\t/**\r\n\tType of drive to apply.See #D6DriveType.\r\n\tDefault: FloatMax\r\n\tRange: [0,inf)\r\n\t*/\r\n\tint driveType;\r\n\r\n\tpJD6Drive()\r\n\t{\r\n\t\tdamping = 0.0f;\r\n\t\tspring = 0.0f;\r\n\t\tforceLimit = 3.402823466e+38F;\r\n\t\tdriveType = 0;\r\n\r\n\t}\r\n\tpJD6Drive(float _damping,float _spring,float _forceLimit,int _driveType)\r\n\t{\r\n\t\tdamping = _damping;\r\n\t\tspring = _spring;\r\n\t\tforceLimit = _forceLimit;\r\n\t\tdriveType = _driveType;\r\n\t}\r\n\r\n};\r\n/** @} */\r\n\r\n#endif // __PJOINTTYPES_H__#ifndef PATH_H\r\n#define PATH_H\r\n\r\n\r\n#include \"CKALL.H\"\r\n#include \"windows.h\"\r\n\r\n#include \r\n#include \r\n\r\n\r\n\r\n\r\n#include \"Shlwapi.h\"\r\n#pragma comment (lib,\"SHLWAPI.LIB\")\r\n\r\n\r\n\r\nclass XPath {\r\n\r\nprivate:\r\n\r\n\r\n\tchar path_separator_;\r\n\tchar drive_separator_;\r\n\tchar extension_separator_;\r\n\t\t\r\npublic:\r\n\t\t\r\n\tXString data_;\r\n\t\r\n\t//ctors\r\n\t\r\n\tinline XPath();\r\n\tXPath( const XPath& path );\r\n\tXPath( const XString& filepath );\r\n\t\r\n XPath( const XString& dirpath, const XString& filename );\r\n XPath\r\n (\r\n const XString& dirpath,\r\n const XString& base,\r\n const XString& extension\r\n );\r\n\tXPath\r\n (\r\n char drive,\r\n const XString& dirpath,\r\n const XString& filename\r\n );\r\n XPath\r\n (\r\n char drive,\r\n const XString& dirpath,\r\n const XString& base,\r\n const XString& extension\r\n );\r\n\t\r\n\t\r\n\r\n\t//components\r\n\tXString operator[]( int index ) const;\r\n\r\n // Testing.\r\n bool absolute() const;\r\n bool relative() const;\r\n\r\n bool directory_path() const;\r\n bool has_directory() const;\r\n bool has_extension() const;\r\n bool has_drive() const;\r\n\tbool is_valid();\r\n\r\n\t\t\r\n\t// Conversion.\r\n operator const char*() const;\r\n operator const XString&() const;\r\n\t\r\n // Comparison\r\n int operator==( const XPath& path ) const;\r\n int operator==( const XString& string ) const;\r\n int operator!=( const XPath& path ) const;\r\n int operator!=( const XString& string ) const;\r\n int operator<( const XPath& path ) const;\r\n int operator<( const XString& string ) const;\r\n\r\n\tXPath& operator=( const XString& filepath );\r\n XPath& operator=( const XPath& path );\r\n\r\n\t//used for the objectmode\r\n\tXPath& operator+=(CKBeObject *beo){\r\n\t\t\r\n\t\tif(data_.Length() == 0)data_ = VxGetTempPath().CStr();\r\n\t\tdata_ << beo->GetName() << \".nmo\";\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t\r\n\t// Accessors.\r\n char* GetFileName();\r\n\tchar* GetPath();\r\n\r\n\t\r\n\t\r\n\tchar path_separator() const;\r\n char drive_separator() const;\r\n char extension_separator() const;\r\n\t\r\n\tint absolute_levels() const;\r\n\t\r\nprotected:\r\n\r\n\tvoid init_separators();\r\n\t// Common finds.\r\n size_t last_extension_separator() const;\r\n\r\n};\r\n\r\n\r\n/************************************************************************/\r\n/* protected funtions\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\ninline void\r\nXPath::init_separators(){\r\n\r\n\tpath_separator_ = '\\\\';\r\n\tdrive_separator_ = ':';\r\n\textension_separator_ = '.';\r\n}\r\n\r\n/************************************************************************/\r\n/* ctors //ops // converts\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\ninline\r\nXPath::XPath(const XString& dirpath, const XString& filename ){\r\n\tinit_separators();\r\n\tdata_ << dirpath <#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n\r\n\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"IDistributedObjectsInterface.h\"\r\n#include \"IMessages.h\"\r\n\r\n\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xLogger.h\"\r\n#include \"xNetConstants.h\"\r\n\r\nvoid\r\nxNetInterface::setFixedRateParameters(TNL::U32 minPacketSendPeriod, TNL::U32 minPacketRecvPeriod, TNL::U32 maxSendBandwidth, TNL::U32 maxRecvBandwidth,bool global/* =false */)\r\n{\r\n\r\n\tif (minPacketRecvPeriod < 10)\r\n\t{\r\n\t\tminPacketRecvPeriod =10;\r\n\t}\r\n\tif (minPacketSendPeriod < 10)\r\n\t{\r\n\t\tminPacketSendPeriod = 10;\r\n\t}\r\n\r\n\tif (maxRecvBandwidth < 100 )\t{\t\tmaxRecvBandwidth = 100;\t}\r\n\tif (maxRecvBandwidth > 5000 )\t{\t\tmaxRecvBandwidth = 5000;\t}\r\n\r\n\tif (maxSendBandwidth< 100 )\t{\t\tmaxSendBandwidth = 100;\t}\r\n\tif (maxSendBandwidth > 5000 )\t{\t\tmaxSendBandwidth = 5000;\t}\r\n \r\n\tif (!IsServer())\r\n\t{\r\n\t\tif (getConnection())\r\n\t\t{\r\n\t\t\tgetConnection()->setFixedRateParameters(minPacketSendPeriod,minPacketRecvPeriod,maxSendBandwidth,maxRecvBandwidth);\r\n\t\t}\r\n\t}\r\n\r\n\tif (global && IsServer())\r\n\t{\r\n\r\n\t\tTNL::Vector con_list = getConnectionList();\r\n\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t{\r\n\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\tcon->setFixedRateParameters(minPacketSendPeriod,minPacketRecvPeriod,maxSendBandwidth,maxRecvBandwidth);\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxNetInterface::enableLogLevel(int type,int verbosity,int value)\r\n{\r\n\txLogger::GetInstance()->enableLoggingLevel(type,verbosity,value);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\n\r\n\r\n\r\nvoid\r\nxNetInterface::initBaseClasses(int flags)\r\n{\r\n\r\n\tIDistributedClasses *cInterface = getDistributedClassInterface();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class \r\n\r\n\txDistributedSessionClass*classTemplate = (xDistributedSessionClass*)cInterface->get(\"Session Class\");\r\n\t//if (!classTemplate)\r\n\t//\tclassTemplate = (xDistributedSessionClass*)cInterface ->createClass(\"Session Class\",E_DC_BTYPE_SESSION);\r\n\r\n\t/*\r\n\tclassTemplate->addProperty(E_DC_S_NP_MAX_USERS,E_PTYPE_RELIABLE);\r\n\tclassTemplate->addProperty(E_DC_S_NP_PASSWORD,E_PTYPE_RELIABLE);\r\n\tclassTemplate->addProperty(E_DC_S_NP_TYPE,E_PTYPE_RELIABLE);\r\n\t*/\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::updateDistributedObjects( int flags,float deltaTime )\r\n{\r\n\r\n\r\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\r\n\t\t\tif (_class)\r\n\t\t\t{\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributed3DObject *dobj3D = static_cast(dobj);\r\n\t\t\t\t\tif (dobj3D)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdobj3D->update(deltaTime);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::createScopeObject()\r\n{\r\n return;\r\n\tif (!IsServer())\r\n\t{\r\n/*\t\tvtConnection *con = getConnection();\r\n\t\tif (con)\r\n\t\t{\r\n\t\t\tcon->scopeObject = new xDistributedObject();\n\t\t\tcon->scopeObject->SetObjectFlags(E_DO_CREATION_COMPLETE);\r\n\t\t\tcon->scopeObject->SetEntityID(-1);\r\n\t\t\tcon->scopeObject->SetServerID(-1);\r\n\t\t\tcon->scopeObject->SetCreationTime(0.0f);\r\n\t\t\tcon->scopeObject->SetName(\"Client\");\r\n\r\n\t\t\tvtDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\t\t\tdistObjects->PushBack(con->scopeObject);\n\t\t\tcon->setScopeObject(con->scopeObject);\r\n\t\t\tlogprintf(\"scope object created\");\r\n\t\t}\r\n\t*/\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::setConnection(vtConnection* val)\r\n{\r\n\t\r\n\tif (!IsServer() && getConnection())\r\n\t{\r\n\t\tgetConnection()->disconnect(\"asdasd\");\r\n\t}\r\n\tif (!IsServer())\r\n\t{\r\n\t\tconnectionToServer = val;\r\n\t}\r\n\t\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nbool xNetInterface::isValid()\r\n{\r\n\r\n\tif (getConnection())\r\n\t{\r\n\t\tif (getConnection()->getConnectionState() == TNL::NetConnection::Connected )\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxNetInterface::xNetInterface(bool server, const TNL::Address &bindAddress, const TNL::Address &pingAddr) : TNL::NetInterface(bindAddress)\r\n{\r\n\t\n\tm_IsServer = server;\n\tpingingServers = !server;\n\tlastPingTime = 0;\n\tpingAddress = pingAddr;\r\n\telapsedConnectionTime = 0.0f;\r\n\tconnectionTimeOut = 2000.0f;\r\n\tconnectionInProgress = false;\r\n\tm_isConnected = false;\r\n\tm_DistributedClassInterface = new IDistributedClasses(this);\r\n\t\tgetDistributedClassInterface()->createClass(\"CLIENT CLASS\",E_DC_BTYPE_CLIENT);\r\n\r\n\r\n\tm_DOCounter =0;\r\n\r\n\tm_DistObjectInterface = new IDistributedObjects(this);\r\n\tm_DistributedObjects = new xDistributedObjectsArrayType();\r\n\r\n\tm_ObjectUpdateCounter = 0 ;\r\n\tm_NetworkMessages = new xNetworkMessageArrayType();\r\n\tm_IMessages = new IMessages(this);\r\n\tmCheckObjects = false;\r\n\tconnectionToServer = NULL;\r\n\t\r\n\t\r\n\tmISession = new ISession(this);\r\n\tmSessions = new xSessionArrayType();\r\n\tmCurrentSession = NULL;\r\n\tmMyUserID = -1;\r\n\tmMyClient = NULL;\r\n\r\n\tmMessages = new xMessageArrayType();\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::destroy()\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//disconnect : \r\n\tif (IsServer())\r\n\t{\r\n\t\tTNL::Vector con_list = getConnectionList();\r\n\t\tfor(int i = 0; i < con_list.size(); i++)\r\n\t\t{\r\n\t\t\tvtConnection *con = (vtConnection *)con_list[i];\r\n\t\t\tcon->disconnect(\"destroyed\");\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\tif (connectionToServer)\r\n\t\t{\r\n\t\t\tconnectionToServer->disconnect(\"destroyed\");\r\n\t\t\tdelete connectionToServer;\r\n\t\t\tconnectionToServer = NULL;\r\n\t\t}\r\n\t}\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//cleanup dist objects : \r\n\tif (m_DistObjectInterface!=NULL)\r\n\t{\r\n\t\tm_DistObjectInterface->Destroy();\r\n\t\tdelete m_DistObjectInterface;\r\n\t\tm_DistObjectInterface = NULL;\r\n\t}\r\n\tif (m_DistributedObjects!=NULL)\r\n\t{\r\n\t\tm_DistributedObjects->clear();\r\n\t\tdelete m_DistributedObjects;\r\n\t\tm_DistributedObjects = NULL;\r\n\t}\r\n\tif (m_DistributedClassInterface)\r\n\t{\r\n\t\tm_DistributedClassInterface->getDistrutedClassesPtr()->clear();\r\n\t\tm_DistributedClassInterface->destroy();\r\n\t\tdelete m_DistributedClassInterface;\r\n\t\tm_DistributedClassInterface = NULL;\r\n\t}\r\n\tif (getMessagesInterface())\r\n\t{\r\n\t\tgetMessagesInterface()->deleteAllOldMessages();\r\n\r\n\t\tif (mMessages)\r\n\t\t{\r\n\t\t\tdelete mMessages;\r\n\t\t\tmMessages = NULL;\r\n\t\t}\r\n\t}\r\n\r\n\tmMyClient = NULL;\r\n\tmMyUserID = -1;\r\n\tmInterfaceFlags = 0 ;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::sendPing(TNL::Address addr,int type)\r\n{\r\n\tTNL::PacketStream writeStream;\n\n\twriteStream.write(TNL::U8(type));\n\twriteStream.sendto(mSocket, addr);\r\n\txLogger::xLog(ELOGINFO,XL_START,\"%s - sending ping \", addr.toString());\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::sendPing()\n{\n\tTNL::PacketStream writeStream;\n\twriteStream.write(TNL::U8(GamePingRequest));\n\twriteStream.sendto(mSocket, pingAddress);\n\txLogger::xLog(ELOGINFO,XL_START,\"%s - sending ping \", pingAddress.toString());\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid xNetInterface::tick()\n{\n\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\n\n\tif(pingingServers && (lastPingTime + PingDelayTime < currentTime))\n\t{\n\t\tlastPingTime = currentTime;\n\t}\n\n\n\tfloat timeDelta = (currentTime - mLastTime) / 1000.f;\r\n\tmLastTime = (float)currentTime;\r\n\tmDeltaTime = mDeltaTime + timeDelta;\r\n\r\n\tif (!IsServer())\r\n\t{\r\n\t\tif (getConnection() && isValid())\r\n\t\t{\r\n\t\t\tif (getCurrentThresholdTicker() < 50)\r\n\t\t\t{\r\n\t\t\t\tcalculateUpdateCounter();\n\t\t\t}\r\n\t\t\tmLastSendTime = getConnection()->getOneWayTime();\r\n\t\t\tmLastRoundTripTime = getConnection()->getRoundTripTime();\r\n\t\t}\r\n\t}\r\n\t\n\n\tcheckIncomingPackets();\n\tprocessConnections();\n\n\tif (getCheckObjects())\r\n\t{\r\n\t\tcheckObjects();\r\n\t\tsetCheckObjects(false);\r\n\t}\r\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid xNetInterface::advanceTime(xTimeType timeNow,float deltaTime)\n{\n\n\t//return;\n\tmLastTime2 = timeNow;\n\tmLastDeltaTime2 = deltaTime;\n\n\tmCurrentThresholdTicker +=getCurrentThresholdTicker() +deltaTime;\r\n\tif (getCurrentThresholdTicker() > 50)\r\n\t{\r\n\t\tmCurrentThresholdTicker = 0.0f;\r\n\t}\n\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\tif (_class && dobj )\r\n\t\t{\r\n\t\t\tif (_class->getEnitityType() != E_DC_BTYPE_CLIENT )\r\n\t\t\t{\r\n\t\t\t\txDistributedPropertyArrayType &props = *dobj->getDistributedPorperties();\r\n\t\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedProperty *prop = props[i];\n\t\t\t\t\tprop->advanceTime(mLastTime2,mLastDeltaTime2);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tbegin++;\n\t}\n\n\t\t\r\n\tgetMessagesInterface()->advanceTime(deltaTime);\r\n\n\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid xNetInterface::handleInfoPacket(const TNL::Address &address, TNL::U8 packetType, TNL::BitStream *stream)\n{\n\t\t\n\t\r\n\tif (IsServer())\r\n\t{\r\n\t\tTNL::PacketStream writeStream;\n\t\tif(packetType == GamePingRequest && IsServer())\n\t\t{\n\t\t\twriteStream.write(TNL::U8(GamePingResponse));\n\t\t\twriteStream.sendto(mSocket, address);\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server : %s - sending ping response.\", address.toString());\n\t\t}\n\t\tif(packetType == ScanPingRequest && IsServer())\n\t\t{\n\t\t\twriteStream.write(TNL::U8(ScanPingResponse));\n\t\t\twriteStream.sendto(mSocket, address);\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server : %s - sending scan ping response.\", address.toString());\n\t\t}\n\t\telse if(packetType == GamePingResponse && pingingServers )\n\t\t{\n\t\t\t\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Client : %s - received ping response.\", address.toString());\n\t\t\n\t\t\tvtConnection *conn = new vtConnection();\n\t\t\tconn->connect(this, address,true,false); // connect to the server through the game's network interface\n\t\t\tsetConnection(conn);\n\t\t\tconn->m_NetInterface = this;\n\t\t\tconn->setInterface(this);\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Connecting to server: %s\", address.toString());\n\r\n\t\t\tpingingServers = false;\n\t\t}\n\t\telse if(packetType == ScanPingResponse )\n\t\t{\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Client : %s - received scan ping response.\", address.toString());\n\t\t}\n\t}\n}\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\nvoid \nxNetInterface::processPacket(const TNL::Address &sourceAddress, TNL::BitStream *pStream)\n{\n\tParent::processPacket(sourceAddress,pStream);\n\n}\n\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxNetInterface::removeClient(int clientID)\r\n{\r\n\r\n\tif(IsServer())\r\n\t{\r\n\t\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\t\tif (!doInterface)return;\r\n\t\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\t\txDistObjectIt begin = distObjects->begin();\r\n\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\tif (distObject)\r\n\t\t\t{\r\n\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\tif (_class)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\tif (distClient)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (distClient->getUserID() == clientID )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tdelete distClient;\r\n\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbegin++;\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\txClientInfo *clientInfo = new xClientInfo();\r\n\t\tclientInfo->userFlag = USER_DELETED;\r\n\t\tclientInfo->userID= clientID;\r\n\t\tgetClientInfoTable().push_back(clientInfo);\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxNetInterface::addDeleteObject(xDistributedObject* object)\r\n{\r\n\r\n\tif(!IsServer() && object)\r\n\t{\r\n\r\n\t\txDistDeleteInfo* dinfo = new xDistDeleteInfo();\r\n\t\tdinfo->entityID = object->getEntityID();\r\n\t\tdinfo->serverID = object->getServerID();\r\n\t\tdinfo->deleteState = E_DO_DS_DELETED ;\r\n\t\tgetDistDeleteTable().push_back(dinfo);\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxNetInterface::writeDistributedProperties(TNL::BitStream *bstream)\r\n{\r\n\r\n\tif(IsServer()) return;\r\n\r\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\tif (!doInterface)return;\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\tif (getObjectUpdateCounter())\r\n\t{\r\n\t\tbstream->writeFlag(E_C_CLIENT_OBJECT_UPDATE);\r\n\t\tbstream->writeRangedU32(getObjectUpdateCounter(), 0, 63 );\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIDistributedClasses*xNetInterface::getDistributedClassInterface(){return m_DistributedClassInterface;}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxNetInterface::calculateUpdateCounter()\r\n{\r\n\tif (IsServer())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\t\r\n\tsetObjectUpdateCounter(0);\r\n\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\tif (_class && dobj )\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (_class->getEnitityType() != E_DC_BTYPE_CLIENT )\r\n\t\t\t{\r\n\t\t\t\txDistributedPropertyArrayType &props = *dobj->getDistributedPorperties();\r\n\t\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\t\t\tdobj->getUpdateBits().set(BIT(blockIndex),prop->getFlags() & E_DP_NEEDS_SEND );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t{\r\n\t\t\t\txDistributedClient *client = (xDistributedClient*)dobj;\r\n\t\t\t\tclient->calculateUpdateBits();\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (dobj->getUpdateBits().getMask())\r\n\t\t\t{\r\n\t\t\t\tgetObjectUpdateCounter()++;\r\n\t\t\t\tdobj->setUpdateState(E_DO_US_PENDING);\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tdobj->setUpdateState(E_DO_US_OK);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint xNetInterface::getNumConnections()\r\n{\r\n\tint i = 0 ; \r\n\tTNL::Vector con_list = getConnectionList();\r\n\tfor(i = 0; i < con_list.size(); i++)\r\n\t{\r\n\t}\r\n\treturn i;\r\n}\r\n\r\nvoid\r\nxNetInterface::checkConnections()\r\n{\r\n\t/*if (getNumConnections()==0)\r\n\t{\r\n\t\tgetDistObjectInterface()->removeAll(getDistributedObjects());\r\n\t\t//xLogger::xLog(ELOGINFO,XL_START,\"no clients anymore: remove all objects!\");\r\n\t}*/\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xNetInterface::disconnect(int connectionID)\r\n{\r\n\tif (IsServer())return;\r\n\r\n\tif (getConnection())\r\n\t{\r\n\t\tgetConnection()->disconnect(\"no reason\");\r\n\t\tsetConnected(false);\r\n\t\tif (connectionToServer)\r\n\t\t{\r\n\t\t\tdelete connectionToServer;\r\n\t\t\tconnectionToServer = NULL;\r\n\t\t}\r\n\r\n\t}\r\n\tgetDistObjectInterface()->removeAll(getDistributedObjects());\r\n\tgetClientInfoTable().clear();\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint xNetInterface::getNumDistributedObjects(int templateType)\r\n{\r\n\r\n\tint counter = 0 ; \r\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\tif (_class && dobj )\r\n\t\t{\r\n\t\t\tif (_class->getEnitityType() == templateType )\r\n\t\t\t{\r\n\t\t\t\tcounter ++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn counter;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nxNetInterface::checkObjects()\r\n{\r\n\t\r\n\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server makes an object validation\");\r\n\tif (getConnectionList().size() ==0)\r\n\t{\r\n\t\tgetDistObjectInterface()->removeAll(getDistributedObjects());\r\n\t\tgetDistributedClassInterface()->getDistrutedClassesPtr()->clear();\r\n\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"Server : No clients anymore, ..delete all\");\r\n\t\r\n\t}\r\n\tcheckSessions();\r\n\t\r\n\tsetCheckObjects(false);\r\n}\r\n\r\n\r\nvoid xNetInterface::checkSessions()\r\n{\r\n\r\n\txLogger::xLog(ELOGINFO,E_LI_SESSION,\"Server : Looking for invalid sessions \");\r\n\tIDistributedObjects *doInterface = getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\tif (_class && dobj )\r\n\t\t{\r\n\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t{\r\n\r\n\t\t\t\txDistributedSession *session = (xDistributedSession*)dobj;\r\n\t\t\t\txDistributedClient *client = (xDistributedClient*)doInterface->getByUserID(dobj->getUserID(),E_DC_BTYPE_CLIENT);\r\n\t\t\t\tif (!client && session )\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_SESSION,\"Server : Found invalid session object %s : deleting\",session->GetName().getString());\r\n\t\t\t\t\tISession *sInterface = getSessionInterface();\r\n\t\t\t\t\tsInterface->deleteSession(session->getSessionID());\r\n\t\t\t\t\tbegin =distObjects->begin();\r\n\t\t\t\t\treturn;\r\n\r\n\t\t\t\t\t//continue;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\tsetCheckObjects(false);\r\n}\r\n\r\nvoid\r\nxNetInterface::printObjects(int type, int flags)\r\n{\r\n\tswitch(type)\r\n\t{\r\n\tcase E_OT_DIST_OBJECT:\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Print all Objects : Num : %d\",getDistributedObjects()->size());\r\n\t\t\txDistributedObjectsArrayType *distObjects = getDistributedObjects();\r\n\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\txDistObjectIt end = distObjects->end();\r\n\t\t\twhile (begin!=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedObject* dobj = *begin;\r\n\t\t\t\tif (dobj)\r\n\t\t\t\t{\r\n\t\t\t\t\tchar out[4096];\r\n\t\t\t\t\t//xDistributedClass *_class = dobj->getDistributedClass();\r\n\t\t\t\t\tTNL::BitSet32 opflags = xBIT(E_OPF_NAME);\r\n\r\n\t\t\t\t\txBitSet stylePrintFlags = 0;\r\n\t\t\t\t\tstylePrintFlags.set(E_PSF_PRINT_LOG_TYPE,true);\r\n\t\t\t\t\tstylePrintFlags.set(E_PSF_PRINT_COMPONENT,true);\r\n\t\t\t\t\t//enableFlag(stylePrintFlags,E_PSF_PRINT_LOG_TYPE); \r\n\t\t\t\t\t//enableFlag(stylePrintFlags,E_PSF_PRINT_COMPONENT);\r\n\r\n\t\t\t\t\tenableFlag(opflags,E_OPF_NAME);\r\n\t\t\t\t\tenableFlag(opflags,E_OPF_GHOST_ID);\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tenableFlag(opflags,E_OPF_USER_ID);\r\n\t\t\t\t\tenableFlag(opflags,E_OPF_SESSION_ID);\r\n\t\t\t\t\tenableFlag(opflags,E_OPF_CLASS);*/\r\n\r\n\t\t\t\t\tuxString objString = dobj->print(opflags);\r\n\t\t\t\t\t//sprintf(out,\"%s | usrID:%d | serverID:%d | sessionID:%d | class:%s | props :%d\",dobj->GetName().getString(),dobj->getUserID(),dobj->getServerID(),dobj->getSessionID,_class ? _class->getClassName().getString() : \"NOCLASS!\",dobj->getDistributedPorperties()->size() );\r\n\t\t\t\t\t//TNL::logprintf(\"\\nsessionID:%d\",dobj->getSessionID());\r\n\t\t\t\t\t//xLogger::xLogExtro(0,\"%s\",objString.CStr());\r\n\t\t\t\t\txLogger::xLog(stylePrintFlags,ELOGINFO,E_LI_CPP,\"%s\",objString.CStr());\r\n\t\t\t\t\t/*switch(_class->getEnitityType())\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tcase E_DC_BTYPE_CLIENT : \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedClient *sobj = (xDistributedClient*)dobj;\r\n\t\t\t\t\t\t\tif (sobj)\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\tint gIndex = dobj->getOwnerConnection() ? dobj->getOwnerConnection()->getGhostIndex(dobj) : getConnection()->getGhostIndex(dobj);\r\n\t\t\t\t\t\t\t\txLogger::xLogExtro(0,\"\\n\\t -->UserName : %s \\n\\tSessionID:%d \\n\\tIsJoined:%d \\n\\tGhostIndex:%d\",sobj->getUserName().getString(),sobj->getSessionID(),isFlagOn(sobj->getClientFlags(),E_CF_SESSION_JOINED) ? 1 : 0,gIndex );\r\n\t\t\t\t\t\t\t\t//xLogger::xLogExtro(0,\"\\n\\t -->HasAddingFlag:%d\",sobj->getUserName().getString(),sobj->getLocalAddress().getString(),sobj->getSessionID(),isFlagOn(sobj->getClientFlags(),E_CF_ADDING) ? 1 : 0);\r\n\t\t\t\t\t\t\t\t//xLogger::xLogExtro(0,\"\\n\\t -->HasAddedFlag:%d\",sobj->getUserName().getString(),sobj->getLocalAddress().getString(),sobj->getSessionID(),isFlagOn(sobj->getClientFlags(),E_CF_ADDED) ? 1 : 0);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}break;\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\tcase E_DC_BTYPE_SESSION: \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedSession*sobj = (xDistributedSession*)dobj;\r\n\t\t\t\t\t\t\tif (sobj)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\txLogger::xLogExtro(0,\"\\n\\t -->Session ID : %d \\tLocked:%d \\tNumUsers %d \\tPrivate : %d \\tMaster :%d \\n\\tFull:%d \\n\\tMaxPlayers:%d\",sobj->getSessionID(),sobj->isLocked(),sobj->getNumUsers(),sobj->isPrivate(),sobj->getUserID(),sobj->isFull(),sobj->getMaxUsers() );\r\n\t\t\t\t\t\t\t\tsobj->\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}break;\r\n\t\t\t\t\t}*/\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\tcase E_OT_CLASS:\r\n\t\t{\r\n\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Print all Classes : Num : %d \",getDistributedClassInterface()->getNumClasses());\r\n\r\n\t\t\txDistributedClassesArrayType *_classes = getDistributedClassInterface()->getDistrutedClassesPtr();\r\n\t\t\txDistClassIt begin = _classes->begin();\r\n\t\t\txDistClassIt end = _classes->end();\r\n\t\t\twhile (begin!=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedClass *_class = begin->second;\r\n\t\t\t\tif (_class)\r\n\t\t\t\t{\r\n\t\t\t\t\tchar out[4096];\r\n\t\t\t\t\tsprintf(out,\"\\t %s | type :%d | props : %d\",_class->getClassName().getString(),_class->getEnitityType(),_class->getDistributedProperties()->size() );\r\n\t\t\t\t\txLogger::xLogExtro(0,\"CLASS : %s\",out);\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\tIMessages *mInterface = getMessagesInterface();\r\n\txLogger::xLog(ELOGINFO,E_LI_CPP,\"Print Messages : Num : %d\",mInterface->getMessages()->size());\r\n\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid \r\nxNetInterface::deploySessionClasses(TNL::GhostConnection *connection)\r\n{\r\n\r\n\tIDistributedClasses *cInterface = getDistributedClassInterface();\r\n\txDistributedClassesArrayType *_classes = cInterface->getDistrutedClassesPtr();\r\n\txDistClassIt begin = _classes->begin();\r\n\txDistClassIt end = _classes->end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedClass *_class = begin->second;\r\n\t\tif (_class && _class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t{\r\n\r\n\t\t\tTNL::StringPtr className(_class->getClassName().getString());\r\n\t\t\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_DISTRIBUTED_CLASS_DESCRIPTORS,\"\\n deploying session class %s \",_class->getClassName().getString());\r\n\t\t\tTNL::Int<16>entityType = _class->getEnitityType();\r\n\r\n\t\t\tTNL::VectorpropertyNames;\r\n\t\t\tTNL::Vector >nativeTypes;\r\n\t\t\tTNL::Vector >valueTypes;\r\n\t\t\tTNL::Vector >predictionTypes;\r\n\r\n\t\t\txDistributedPropertiesListType &props = *_class->getDistributedProperties();\r\n\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i ++ )\r\n\t\t\t{\r\n\t\t\t\txDistributedPropertyInfo *dInfo = props[i];\r\n\t\t\t\tpropertyNames.push_back( TNL::StringPtr(dInfo->mName) );\r\n\t\t\t\tnativeTypes.push_back(dInfo->mNativeType);\r\n\t\t\t\tvalueTypes.push_back(dInfo->mValueType);\r\n\t\t\t\tpredictionTypes.push_back(dInfo->mPredictionType);\r\n\t\t\t}\r\n\t\t\t((vtConnection*)connection)->s2cDeployDistributedClass(className,entityType,propertyNames,nativeTypes,valueTypes,predictionTypes);\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}#pragma once\r\n#include \"StdAfx2.h\"\r\n#include \"VIControls.h\"\r\n#include \"ParameterDialog.h\"\r\n#include \"CKShader.h\"\r\n//#include \"CUIKNotificationReceiver.h\"\r\n\r\n//--- Include \"GenericObjectParameterDialog.h\" from CK2UI define IDDs to mak it compile\r\n#define IDD_GENOBJECTDIALOG 2011\r\n#define IDD_BASEPARAMDIALOG 2000\r\n#include \"Parameters\\GenericObjectParameterDialog.h\"\r\n\r\n#include \"resource.h\"\r\n#include \"PCommonDialog.h\"\r\n\r\n\r\n//--- Some constants\r\n#define MFC_NAME_OF_DIALOG \"#32770\"\r\n#define CHECK_MATERIAL_TIMER 57\r\nclass CPBXMLSetup : public CParameterDialog ,public CPSharedBase\r\n{\r\n\r\npublic:\r\n\r\n\t//\tvirtual void PreSubclassWindow();\r\n\r\n\tint\t\t\t\t\tm_paramType;\r\n\r\n\tCPBXMLSetup(CKParameter* Parameter,CWnd* parent = NULL);\r\n\tCPBXMLSetup(CKParameter* Parameter,CWnd *parent,CK_CLASSID Cid=CKCID_OBJECT);\r\n\tCPBXMLSetup(CKParameter* Parameter,CK_CLASSID Cid=CKCID_OBJECT);\r\n\tvirtual ~CPBXMLSetup();\r\n\tvoid _destroy();\r\n\r\n\t//BOOL Create(CKParameter* Parameter,UINT nIDTemplate, CWnd* pParentWnd);\r\n\t//BOOL Init(CKParameter* Parameter,UINT nIDTemplate,CParameterDialog *parent);\r\n\t\r\n\t//BOOL OnInitDialog();\r\n\r\n\r\n\tCPBXMLSetup* refresh(CKParameter*src);\r\n\t/************************************************************************/\r\n\t/* Overrides \r\n\t*/\r\n\t/************************************************************************/\r\n\tvoid OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);\r\n\tLRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Accessors */\r\n\t/************************************************************************/\r\n\tCKParameter * getEditedParameter() const { return mParameter; }\r\n\tvoid setEditedParameter(CKParameter * val) { mParameter= val; }\r\n\r\n\t/************************************************************************/\r\n\t/* Virtools mParameter transfer callbacks : */\r\n\t/************************************************************************/\r\n\tvirtual BOOL On_UpdateFromParameter(CKParameter* p){\r\n\r\n\t\t//\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\t//\t\tif(!p) return FALSE;\r\n\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\tvirtual BOOL On_UpdateToParameter(CKParameter* p)\r\n\t{\r\n\r\n\t\t/*\r\n\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\tif(!p) return FALSE;\r\n\t\tCString cstr;*/\r\n\t\treturn TRUE;\r\n\r\n\t}\r\n\t\r\n\r\n\r\npublic:\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* Low Level passes */\r\n\t/************************************************************************/\r\n\tLRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Logical Actions */\r\n\t/************************************************************************/\r\n\tvirtual int OnSelect(int before=-1);\r\n\r\n\tvoid fillXMLLinks();\r\n\r\n\tHWND getDlgWindowHandle(UINT templateID);\r\n\r\n\t/************************************************************************/\r\n\t/* Members */\r\n\t/************************************************************************/\r\n\r\n\t//\t\tHull Type \r\n\r\n\tVIComboBox XMLInternLink;\t\r\n\tVIStaticText XMLInternLinkLbl;\r\n\tVIComboBox XMLExternLink;\t\r\n\tVIStaticText XMLExternLinkLbl;\r\n\tCKParameter *mParameter;\r\n\tVIEdit editValue;\r\n\tVIStaticText textValue;\r\n\tVIComboBox\t\t\ttype;\r\n\r\n\t\r\n\tenum { IDD = IDD_PB_XML_PARENT };\r\n\t\r\n\t//{{AFX_VIRTUAL(CPBXMLSetup)\r\nprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n\t//{{AFX_MSG(CPBXMLSetup)\r\n\tBOOL OnInitDialog();\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n\r\n\t\r\npublic:\r\n\tafx_msg void OnStnClickedXmlMainView();\r\n};\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t GetCurrentCamera \r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetCurrentCameraDecl();\r\nCKERROR CreateGetCurrentCameraProto(CKBehaviorPrototype **pproto);\r\nint GetCurrentCamera(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetCurrentCameraDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Get Current Camera\");\t\r\n\tod->SetDescription(\"States the current camera in the active scene.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tCurrent Camera: the camera currently used in the main viewport.
\r\n\t
\r\n See Also: 'Set As Active Camera'.
\r\n */\r\n\tod->SetCategory(\"Cameras/Montage\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x368f22b1,0x222957e4));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetCurrentCameraProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateGetCurrentCameraProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Get Current Camera\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Current Camera\",CKPGUID_CAMERA);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(GetCurrentCamera);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint GetCurrentCamera(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n // Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tCKCamera* cam = behcontext.CurrentRenderContext->GetAttachedCamera();\r\n\r\n\tbeh->SetOutputParameterObject(0,cam);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#ifndef __CSMANAGER_H_\r\n#define __CSMANAGER_H_\r\n\r\n#include \"../virtools/vt_tools.h\"\r\n#include \"CKBaseManager.h\"\r\n#include \r\n#include \r\n#include \r\n\r\n#define INIT_MAN_GUID\t\tCKGUID(0x35824c8a,0x4e320ac4)\r\n\r\n\r\nclass csMessage \r\n{\r\npublic :\r\n\r\n\tcsMessage(){}\r\n\t\r\n\tvirtual ~csMessage()\t{\t}\r\n\t\r\n\tXString name;\r\n\tchar*GetName(){ return name.Str() ; }\r\n\tvoid SetName(const char* _name)\t{\t\tname = _name;\t}\r\n\r\n\r\n\ttypedef XArray MessageParameterArrayType;\r\n\tMessageParameterArrayType m_Parameters;\r\n\tint GetNumParameters(){ return m_Parameters.Size() ; }\r\n\tvoid AddParameter(CKParameter *pin){ m_Parameters.PushBack(pin); }\r\n\r\n};\r\n\r\ntypedef std::vectorcsMessagesArrayType;\r\n\r\nclass CSManager : public CKBaseManager\r\n{\r\n\r\n\tpublic:\r\n\t\t//Ctor\r\n\t\tCSManager(CKContext* ctx);\r\n\t\t//Dtor\r\n\t\t~CSManager();\r\n\r\n\t\t// Initialization\t\r\n\t\tvirtual CKERROR OnCKInit();\r\n\t\tvirtual CKERROR OnCKReset();\r\n\t\tvirtual CKERROR PreProcess();\r\n\t\t\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\tint HasMessages() const { return m_HasMessages; }\r\n\tvoid SetHasMessages(int val) { m_HasMessages = val; }\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tcsMessagesArrayType m_CSMessages;\r\n\tcsMessagesArrayType& GetCSMessages() { return m_CSMessages; }\r\n\tvoid AddMessage(csMessage*msg);\r\n\r\n\t__inline int GetNumMessages();\r\n __inline char *GetMessageName(int messageID);\r\n\t__inline int GetNumParameters(int messageID);\r\n\t__inline int GetMessageParameterType(int messageID,int parameterSubID);\r\n\r\n\t__inline int GetMessageValueInt(int messageID,int parameterSubID);\r\n\t__inline float GetMessageValueFloat(int messageID,int parameterSubID);\r\n\t__inline char* GetMessageValueStr(int messageID,int parameterSubID);\r\n\t__inline void CleanMessages();\r\n\t__inline void DeleteMessage(int messageID);\r\n \r\n\tvirtual CKDWORD\tGetValidFunctionsMask()\t\t{ return CKMANAGER_FUNC_OnCKInit|\t\tCKMANAGER_FUNC_OnCKReset; \t}\r\n\r\n\tprivate:\r\n\r\n\tprotected:\r\n\tint m_HasMessages;\r\n\t\r\n\t\r\n};\r\n//////////////////////////////////////////////////////////////////////////\r\nchar*\r\nCSManager::GetMessageName(int messageID)\r\n{\r\n\tXString result;\r\n\tif (GetNumMessages() && messageID < GetNumMessages() )\r\n\t{\r\n\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\treturn msg->GetName();\r\n\t}\r\n\treturn result.Str();\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint CSManager::GetNumMessages()\r\n{ \t\r\n\r\n\t//MessageBox(NULL,\"\",\"\",1);\r\n\treturn GetCSMessages().size(); \r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint CSManager::GetNumParameters(int messageID)\r\n{\r\n\tint result = -1;\r\n\tif (messageID < GetNumMessages())\r\n\t{\r\n\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\treturn msg->GetNumParameters();\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint CSManager::GetMessageParameterType(int messageID,int parameterSubID)\r\n{\r\n\tint result = -1;\r\n\tif (GetNumParameters(messageID))\r\n\t{\r\n\r\n\t\tif (parameterSubID < GetNumParameters(messageID))\r\n\t\t{\r\n\t\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\t\tCKParameter *par = *msg->m_Parameters.At(parameterSubID);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameterManager *pam = static_cast(m_Context->GetParameterManager());\r\n\t\t\t\tCKParameterType pType = par->GetType();\r\n\t\t\t\tusing namespace vtTools;\r\n\t\t\t\tusing namespace vtTools::Enums;\r\n\t\t\t\tSuperType sType = ParameterTools::GetVirtoolsSuperType(m_Context,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\tswitch (sType)\r\n\t\t\t\t{\r\n\t\t\t\tcase vtSTRING:\r\n\t\t\t\t\tresult=1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase vtFLOAT:\r\n\t\t\t\t\tresult=2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase vtINTEGER:\r\n\t\t\t\t\tresult=3;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault :\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nint CSManager::GetMessageValueInt(int messageID,int parameterSubID)\r\n{\r\n\tassert(GetMessageParameterType(messageID,parameterSubID)==3 );\r\n\r\n\tint result = -1;\r\n\tif (GetNumParameters(messageID))\r\n\t{\r\n\t\tif (parameterSubID < GetNumParameters(messageID))\r\n\t\t{\r\n\t\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\t\tCKParameter *par = *msg->m_Parameters.At(parameterSubID);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tpar->GetValue(&result);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nfloat CSManager::GetMessageValueFloat(int messageID,int parameterSubID)\r\n{\r\n\tassert(GetMessageParameterType(messageID,parameterSubID)==2 );\r\n\r\n\tfloat result = -1.0f;\r\n\tif (GetNumParameters(messageID))\r\n\t{\r\n\t\tif (parameterSubID < GetNumParameters(messageID))\r\n\t\t{\r\n\t\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\t\tCKParameter *par = *msg->m_Parameters.At(parameterSubID);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tpar->GetValue(&result);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nchar*CSManager::GetMessageValueStr(int messageID,int parameterSubID)\r\n{\r\n\tassert(GetMessageParameterType(messageID,parameterSubID)==1 );\r\n\r\n\tchar* result = NULL;\r\n\tif (GetNumParameters(messageID))\r\n\t{\r\n\t\tif (parameterSubID < GetNumParameters(messageID))\r\n\t\t{\r\n\t\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\t\tCKParameter *par = *msg->m_Parameters.At(parameterSubID);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tVxScratch sbuffer(par->GetDataSize() +1 );\r\n\t\t\t\tCKSTRING buffer = (CKSTRING)sbuffer.Mem();\r\n\t\t\t\tpar->GetStringValue(buffer);\r\n\t\t\t\treturn buffer;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid CSManager::CleanMessages()\r\n{\r\n\tfor (int i = 0 ; i < GetNumMessages() ; i++ )\r\n\t{\r\n\t\tcsMessage* msg = GetCSMessages().at(i);\r\n\t\tfor (int j = 0 ; j < GetNumParameters(i) ; j++ )\r\n\t\t{\r\n\t\t\tmsg->m_Parameters[j]=NULL;\r\n\t\t}\r\n\t\tmsg->m_Parameters.Clear();\r\n\t}\r\n\tGetCSMessages().erase(GetCSMessages().begin(),GetCSMessages().end());\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid CSManager::DeleteMessage(int messageID)\r\n{\r\n\tif (messageID < GetNumMessages() )\r\n\t{\r\n\t\tcsMessage* msg = GetCSMessages().at(messageID);\r\n\t\tfor (int j = 0 ; j < GetNumParameters(messageID) ; j++ )\r\n\t\t{\r\n\t\t\tmsg->m_Parameters[j]=NULL;\r\n\t\t}\r\n\t\tmsg->m_Parameters.Clear();\r\n\t\tGetCSMessages().erase(GetCSMessages().begin() + messageID);\r\n\t}\r\n}\r\n\r\n\r\n#endif\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pSleepingSettings.h\"\r\n#include \"pWorldSettings.h\"\r\n\r\n#include \"tinyxml.h\"\r\n\r\nTiXmlDocument*pFactory::loadConfig(const char* filename)\r\n{\r\n\r\n\t// load and check file\r\n\tchar Ini[MAX_PATH];\r\n\tchar drive[MAX_PATH];\r\n\tchar dir[MAX_PATH];\r\n\tchar szPath[MAX_PATH];\r\n\r\n\tGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\t_splitpath(szPath, drive, dir, NULL, NULL );\r\n\tsprintf(Ini,\"%s%s%s\",drive,dir,filename);\t\r\n\tXString name(Ini);\r\n\tname << '\\0';\r\n\r\n\tm_DefaultDocument = new TiXmlDocument(filename);\r\n\tm_DefaultDocument ->LoadFile(Ini);\r\n\tm_DefaultDocument ->Parse(Ini);\r\n\r\n\tif (m_DefaultDocument->Error())\r\n\t{\r\n\r\n\t\tdelete m_DefaultDocument;\r\n\t\tm_DefaultDocument = NULL;\r\n\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\t// get the ogreode element.\r\n\tTiXmlNode* node = m_DefaultDocument->FirstChild( \"vtPhysics\" );\r\n\tif (!node)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\treturn m_DefaultDocument;\r\n\r\n}\r\n\r\nint pFactory::reloadConfig(const char *fName)\r\n{\r\n\r\n\r\n\tif (! fName || !strlen(fName))return -1;\r\n\t////////////////////////////////////////Load our physic default xml document : \r\n\tif (getDefaultDocument())\r\n\t{\r\n\t\tdelete m_DefaultDocument;\r\n\t\tm_DefaultDocument = NULL;\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Deleted old default config\");\r\n\t} \r\n\r\n\tTiXmlDocument * defaultDoc = loadConfig(fName);\r\n\tif (!defaultDoc)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Loading default config : PhysicDefaults.xml: failed\");\r\n\t\tsetDefaultDocument(NULL);\r\n\t}else\r\n\t{\r\n\t\tsetDefaultDocument(defaultDoc);\r\n\t}\r\n\treturn 1;\r\n}\r\n\r\n\r\npRemoteDebuggerSettings pFactory::createDebuggerSettings(const TiXmlDocument * doc)\r\n{\r\n\r\n\tpRemoteDebuggerSettings result;\r\n\tresult.enabled = -1;\r\n\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif (doc)\r\n\t{\r\n\t\t\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"Debugger\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),\"Default\" ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\t\tdouble v;\r\n\t\t\t\t\t\t\t\t\tint i=0;\r\n\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tint res = sube->QueryIntAttribute(\"enabled\",&i);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tresult.enabled = i ;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tres = sube->QueryIntAttribute(\"port\",&i);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tresult.port = i ;\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* host = sube->Attribute(\"host\");\r\n\t\t\t\t\t\t\t\t\tif (strlen(host))\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t//strcpy(result.mHost,host);\r\n\t\t\t\t\t\t\t\t\t\tresult.mHost = host;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n//************************************\r\n// Method: GetFirstDocElement\r\n// FullName: vtODE::pFactory::GetFirstDocElement\r\n// Access: public \r\n// Returns: const TiXmlElement*\r\n// Qualifier:\r\n// Parameter: const TiXmlElement *root\r\n//************************************\r\nconst TiXmlElement*pFactory::getFirstDocElement(const TiXmlElement *root)\r\n{\r\n\r\n\tif (!strcmp(root->Value(), \"vtPhysics\"))\r\n\t{\r\n\t\treturn root;\r\n\t}\r\n\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling())\r\n\t{\r\n\t\tif (child->Type() == TiXmlNode::ELEMENT)\r\n\t\t{\r\n\t\t\tconst TiXmlElement *res = getFirstDocElement(child->ToElement ());\r\n\t\t\tif (res)\r\n\t\t\t\treturn res;\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: GetDocument\r\n// FullName: vtPhysics::pFactory::GetDocument\r\n// Access: public \r\n// Returns: TiXmlDocument*\r\n// Qualifier:\r\n// Parameter: XString filename\r\n//************************************\r\nTiXmlDocument* pFactory::getDocument(XString filename)\r\n{\r\n\t\r\n\r\n\tXString fname(filename.Str());\r\n\tif ( fname.Length() )\r\n\t{\r\n\t\tXString fnameTest = ResolveFileName(fname.CStr());\r\n\t\tif ( fnameTest.Length())\r\n\t\t{\r\n\t\t\tTiXmlDocument* result = new TiXmlDocument(fnameTest.Str());\r\n\t\t\tresult->LoadFile(fnameTest.Str());\r\n\t\t\tresult->Parse(fnameTest.Str());\r\n\r\n\t\t\tTiXmlNode* node = result->FirstChild( \"vtPhysics\" );\r\n\t\t\tif (!node)\r\n\t\t\t{\r\n\t\t\t\tGetPMan()->m_Context->OutputToConsoleEx(\"PFactory : Couldn't load Document : %s\",filename.Str());\r\n\t\t\t\treturn NULL;\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n//************************************\r\n// Method: CreateWorldSettings\r\n// FullName: vtPhysics::pFactory::CreateWorldSettings\r\n// Access: public \r\n// Returns: pWorldSettings*\r\n// Qualifier:\r\n// Parameter: const char* nodeName\r\n// Parameter: const char* filename\r\n//************************************\r\n/*!\r\n * \\brief\r\n * Write brief comment for createWorldSettings here.\r\n * \r\n * \\param nodeName\r\n * Description of parameter nodeName.\r\n * \r\n * \\param filename\r\n * Description of parameter filename.\r\n * \r\n * \\returns\r\n * Write description of return value here.\r\n * \r\n * \\throws \r\n * Description of criteria for throwing this exception.\r\n * \r\n * Write detailed description for createWorldSettings here.\r\n * \r\n * \\remarks\r\n * Write remarks for createWorldSettings here.\r\n * \r\n * \\see\r\n * Separate items with the '|' character.\r\n */\r\npWorldSettings*pFactory::createWorldSettings(const char* nodeName, const char* filename)\r\n{\r\n\r\n\tXString fname(filename);\r\n\tXString nName(nodeName);\r\n\tif ( nName.Length() && fname.Length() )\r\n\t{\r\n\t\tpWorldSettings *result = NULL;\r\n\t\tTiXmlDocument * document = getDocument(fname);\r\n\t\tif (document)\r\n\t\t{\r\n\t\t\tresult =createWorldSettings(nodeName,document);\r\n\t\t\tif ( result)\r\n\t\t\t{\r\n\t\t\t\tdelete document;\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (document)\r\n\t\t{\r\n\t\t\tresult = new pWorldSettings();\r\n\t\t\tresult->setGravity(VxVector(0,-9.81,0));\r\n\t\t\tresult->setSkinWith(0.02f);\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n//************************************\r\n// Method: CreateWorldSettings\r\n// FullName: vtPhysics::pFactory::CreateWorldSettings\r\n// Access: public \r\n// Returns: pWorldSettings*\r\n// Qualifier:\r\n// Parameter: XString nodeName\r\n// Parameter: TiXmlDocument * doc \r\n//************************************\r\n\r\npWorldSettings*\r\npFactory::createWorldSettings(const XString nodeName/* = */, const TiXmlDocument * doc /* = NULL */)\r\n{\r\n\r\n\tpWorldSettings *result = new pWorldSettings();\r\n\t\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif (doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"world\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName.CStr() ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (const TiXmlNode *node = element->FirstChild(); node; node = node->NextSibling() )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif ((node->Type() == TiXmlNode::ELEMENT) && (!stricmp(node->Value(),\"settings\")))\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)node;\r\n\t\t\t\t\t\t\t\t\tdouble v;\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tint res = sube->QueryDoubleAttribute(\"SkinWith\",&v);\r\n\t\t\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tresult->setSkinWith((float)v);\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tconst char* grav = sube->Attribute(\"Gravity\");\r\n\t\t\t\t\t\t\t\t\tVxVector vec = _str2Vec(grav);\r\n\t\t\t\t\t\t\t\t\tresult->setGravity(vec);\r\n\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//result->setGravity(VxVector(0,-9.81,0));\r\n\t//result->setSkinWith(0.02f);\r\n\r\n\treturn result;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: CreateSleepingSettings\r\n// FullName: vtPhysics::pFactory::CreateSleepingSettings\r\n// Access: public \r\n// Returns: pSleepingSettings*\r\n// Qualifier:\r\n// Parameter: const char* nodeName\r\n// Parameter: const char *filename\r\n//************************************\r\npSleepingSettings*pFactory::CreateSleepingSettings(const char* nodeName,const char *filename)\r\n{\r\n\t\r\n\tXString fname(filename);\r\n\tXString nName(nodeName);\r\n\tif ( nName.Length() && fname.Length() )\r\n\t{\r\n\t\tTiXmlDocument * document = getDocument(fname);\r\n\t\tif (document)\r\n\t\t{\r\n\t\t\tpSleepingSettings *result = CreateSleepingSettings(nodeName,document);\r\n\t\t\tif ( result)\r\n\t\t\t{\r\n\t\t\t\tdelete document;\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: CreateSleepingSettings\r\n// FullName: vtPhysics::pFactory::CreateSleepingSettings\r\n// Access: public \r\n// Returns: pSleepingSettings*\r\n// Qualifier:\r\n// Parameter: XString nodeName\r\n// Parameter: TiXmlDocument * doc \r\n//************************************\r\npSleepingSettings*pFactory::CreateSleepingSettings(XString nodeName/* = */, TiXmlDocument * doc /* = NULL */)\r\n{\r\n\tpSleepingSettings *result = new pSleepingSettings();\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif (nodeName.Length() && doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"sleepsettings\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tconst TiXmlElement *element = (const TiXmlElement*)child;\r\n\t\t\t\t\tif (element->Type() == TiXmlNode::ELEMENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(!strcmp( element->Attribute(\"name\"),nodeName.CStr() ) )\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tint v;\r\n\t\t\t\t\t\t\tint res = element->QueryIntAttribute(\"SleepSteps\",&v);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->SleepSteps(v);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryIntAttribute(\"AutoSleepFlag\",&v);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->AutoSleepFlag(v);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tfloat vF;\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"AngularThresold\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->AngularThresold(vF);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\tres = element->QueryFloatAttribute(\"LinearThresold\",&vF);\r\n\t\t\t\t\t\t\tif (res == TIXML_SUCCESS)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult->LinearThresold(vF);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\nXString pFactory::_getEnumDescription(const TiXmlDocument *doc, XString identifier)\r\n{\r\n\r\n\tif (!doc)\r\n\t{\r\n\t\treturn XString(\"\");\r\n\t}\r\n\r\n\tXString result(\"None=0\");\r\n\tint counter = 1;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif ( doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), identifier.Str() ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)child;\r\n\r\n\t\t\t\t\tconst char* matName = NULL;\r\n\t\t\t\t\tmatName = sube->Attribute(\"name\");\r\n\t\t\t\t\tif (matName && strlen(matName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (result.Length())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresult << matName;\r\n\t\t\t\t\t\tresult << \"=\" << counter;\r\n\t\t\t\t\t\tcounter ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nXString pFactory::_getBodyXMLInternalEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\treturn _getEnumDescription(doc,\"Body\");\r\n\r\n}\r\nXString pFactory::_getBodyXMLExternalEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\treturn _getEnumDescription(doc,\"Body\");\r\n\r\n}\r\n\r\nXString pFactory::_getMaterialsAsEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\tif (!doc)\r\n\t{\r\n\t\treturn XString(\"\");\r\n\t}\r\n\r\n\tXString result(\"None=0\");\r\n\tint counter = 1;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* try to load settings from xml : */\r\n\t/************************************************************************/\r\n\tif ( doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\r\n\t\t\t\tif (!strcmp(child->Value(), \"material\" ) )\r\n\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)child;\r\n\t\t\t\t\t\r\n\t\t\t\t\tconst char* matName = NULL;\r\n\t\t\t\t\tmatName = sube->Attribute(\"name\");\r\n\t\t\t\t\tif (matName && strlen(matName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (result.Length())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresult << matName;\r\n\t\t\t\t\t\tresult << \"=\" << counter;\r\n\t\t\t\t\t\tcounter ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\n//************************************\r\n// Method: _str2CombineMode\r\n// FullName: vtAgeia::pFactory::_str2CombineMode\r\n// Access: protected \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const char*input\r\n//************************************\r\nint pFactory::_str2CombineMode(const char*input)\r\n{\r\n\r\n\tint result = -1;\r\n\tif (!strlen(input))\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tif (!strcmp(input,\"AVERAGE\"))\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tif (!strcmp(input,\"MIN\"))\r\n\t{\r\n\t\treturn 1;\r\n\t}\r\n\tif (!strcmp(input,\"MAX\"))\r\n\t{\r\n\t\treturn 3;\r\n\t}\r\n\r\n\tif (!strcmp(input,\"MULTIPLY\"))\r\n\t{\r\n\t\treturn 2;\r\n\t}\r\n\treturn result;\r\n\r\n}#ifndef _VTLOG_TOOLS_H_\r\n#define _VTLOG_TOOLS_H_\r\n\r\n#include \"xLogger.h\"\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n//\r\n//\r\n//\tWe different output channels for logging,debugging or assertions : \r\n//\t\t+\tconsole\r\n//\t\t+\tlog file\r\n//\t\t+\tstd::err\r\n\r\nclass CKContext;\r\nclass CKGUID;\r\n\r\nnamespace vtTools\r\n{\r\n\r\n\tclass BehaviorInfoTools\r\n\t{\r\n\t\tpublic :\r\n\t\t\tstatic const char*getBuildingBlockName(CKContext *ctx,CKGUID* guid);\r\n\t};\r\n\r\n}\r\n\r\n \r\n#define XL_BB_NAME beh->GetPrototype()->GetName()\r\n#define XL_BB_OWNER_SCRIPT beh->GetOwnerScript()->GetName()\r\n#define XL_BB_OWNER_OBJECT beh->GetOwner() ? beh->GetOwner()->GetName() : \"none\"\r\n#define XL_BB_SIGNATURE (\"\\n\\tScript : %s\\n\\tBuildingBlock : %s \\n\\tObject :%s Error :\") \r\n\r\n\r\n#define XLOG_FMT(msg,extro) msg##extro\r\n#define XLOG_MERGE(var, fmt) (#var##fmt )\r\n#define XLOG_MERGE2(var,fmt) (var##fmt)\r\n\r\n#define XLOG_BB_INFO xLogger::xLogExtro(0,XL_BB_SIGNATURE,XL_BB_OWNER_SCRIPT,XL_BB_NAME,XL_BB_OWNER_OBJECT)\r\n\r\n#define VTERROR_STRING(F) sErrorStrings[F]\r\n#define bbError(F) \tXLOG_BB_INFO; \\\r\n\tError(beh,F,BB_OP_ERROR,VTERROR_STRING(F),TRUE,BB_O_ERROR,TRUE)\r\n#define bbNoError(F) Error(beh,F,BB_OP_ERROR,VTERROR_STRING(F),FALSE,BB_O_ERROR,FALSE)\r\n\r\n#define bbErrorMesg(F) \txLogger::xLog(ELOGERROR,E_BB,F); \\\r\n\tXLOG_BB_INFO;\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJGroupBreakIteratorDecl();\r\nCKERROR CreatePJGroupBreakIteratorProto(CKBehaviorPrototype **pproto);\r\nint PJGroupBreakIterator(const CKBehaviorContext& behcontext);\r\nCKERROR PJGroupBreakIteratorCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPJGroupBreakIteratorDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJGroupBreakIterator\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Enables trigger output for multiple objects when a joint got broken\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7a64881,0x3aca7f0c));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePJGroupBreakIteratorProto);\r\n\tod->SetCompatibleClassId(CKCID_GROUP);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePJGroupBreakIteratorProto\r\n// FullName: CreatePJGroupBreakIteratorProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePJGroupBreakIteratorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJGroupBreakIterator\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJGroupBreakIterator \r\n\r\n\tPJGroupBreakIterator is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tTriggers outputs if the body enters,stays or leaves another body .
\r\n\tSee pBTriggerEvent.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJGroupBreakIterator.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\t\r\n\tNo Event: Nothing touched.\r\n\t
\r\n\tEntering: Body entered.\r\n\t
\r\n\tLeaving: Body leaved.\r\n\t
\r\n\tStay: Inside body .\r\n\t
\r\n\r\n\tTarget Group: The group which the bb outputs triggers for.\r\n\t
\r\n\tTouched Object: The touched body.\r\n\t
\r\n\t\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note


\r\n\t\r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pRigidBody::addForce().
\r\n\t\r\n\t*/\r\n\r\n\t//proto->DeclareInParameter(\"Extra Filter\",VTF_TRIGGER,\"0\");\r\n\t//proto->DeclareInParameter(\"Remove Event\",CKPGUID_BOOL,\"0\");\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\t\r\n\tproto->DeclareOutput(\"None\");\r\n\tproto->DeclareOutput(\"Break\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Body A\",CKPGUID_3DENTITY,0);\r\n\tproto->DeclareOutParameter(\"Body B\",CKPGUID_3DENTITY,0);\r\n\tproto->DeclareOutParameter(\"Impulse\",CKPGUID_FLOAT,0);\r\n\r\n\tproto->DeclareLocalParameter(\"currentIndex\", CKPGUID_INT);\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PJGroupBreakIterator);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Break,\r\n};\r\n\r\nenum bInputs\r\n{\r\n\tbbI_Init,\r\n\tbbI_Next,\r\n};\r\n\r\nbool isInGroup2(CKGroup *src, CK3dEntity* testObject)\r\n{\r\n\r\n\tif (src && testObject)\r\n\t{\r\n\t\tfor (int i = 0 ; i < src->GetObjectCount() ; i++ )\r\n\t\t{\r\n\t\t\tCK3dEntity *ent = (CK3dEntity*)src->GetObject(i);\r\n\t\t\tif(ent)\r\n\t\t\t{\r\n\t\t\t\tif (ent==testObject)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n\r\n//************************************\r\n// Method: PJGroupBreakIterator\r\n// FullName: PJGroupBreakIterator\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PJGroupBreakIterator(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCKGroup *target = (CKGroup *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\tint nbOfEvents = GetPMan()->getJointFeedbackList().Size();\r\n\t/************************************************************************/\r\n\t/* handle init */\r\n\t/************************************************************************/\r\n\tif( beh->IsInputActive(bbI_Init) )\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_Init,FALSE);\r\n\t\tif (nbOfEvents)\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(bbI_Next,TRUE);\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* handle trigger 'next' */\r\n\t/************************************************************************/\r\n\tif( beh->IsInputActive(bbI_Next) && nbOfEvents )\r\n\t{\r\n\t\tbeh->ActivateInput(bbI_Next,FALSE);\r\n\t\tbeh->ActivateOutput(bbO_Break,FALSE);\r\n\t\tCK3dEntity *bodyAEnt =NULL; //static_cast(GetPMan()->GetContext()->GetObject(entry->mAEnt));\r\n\t\tCK3dEntity *bodyBEnt = NULL;//static_cast(GetPMan()->GetContext()->GetObject(entry->mBEnt));\r\n\r\n\t\tpBrokenJointEntry *entry = *GetPMan()->getJointFeedbackList().At(0);\r\n\r\n\t\tbodyAEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mAEnt));\r\n\t\tbodyBEnt = static_cast(GetPMan()->GetContext()->GetObject(entry->mBEnt));\r\n\r\n\t\tif (isInGroup2(target,bodyAEnt) || isInGroup2(target,bodyBEnt))\r\n\t\t{\r\n\r\n\t\t\tbeh->SetOutputParameterObject(0,bodyAEnt);\r\n\t\t\tbeh->SetOutputParameterObject(1,bodyBEnt);\r\n\t\t\tSetOutputParameterValue(beh,2,entry->impulse);\r\n\t\t\tGetPMan()->getJointFeedbackList().EraseAt(0);\r\n\t\t\tbeh->ActivateOutput(bbO_Break);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* terminate */\r\n\t/************************************************************************/\r\n\tbeh->ActivateOutput(bbO_None);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PJGroupBreakIteratorCB\r\n// FullName: PJGroupBreakIteratorCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PJGroupBreakIteratorCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\nFIND_PATH(VTDEV40DIR\r\n NAMES dev.exe devr.exe\r\n PATHS\r\n [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Virtools\\\\Dev\\\\4.0;InstallPath]\r\n )\r\nMARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)\r\nSET(VTDEV40 1)\r\n\r\n################################################################################ \r\n# activate_licenses.ini: Virtools Addons License Management \r\n# This file contains the list of the Virtools Addon Components. \r\n# When using the FlexLM Server Installation,if you \r\n# do not want an Virtools addon to be loaded into Virtools\r\n# (i.e. its flexlm license to be checked-out), \r\n# simply comment it with a '#' before the component's name. \r\n################################################################################ \r\n# Virtools Physics Pack Components \r\n#VirtoolsPhysicPackFeature \r\n# Virtools VR Pack Components \r\n#VRK\r\n#VRD\r\n#VRV\r\n#VRC\r\n#VRPackBetaFeatures\r\n# Virtools Server Components \r\n#VirtoolsVBS_C_DevFeature \r\n#VirtoolsVBS_C_MultiuserFeature \r\n#VirtoolsVBS_C_PeerFeature \r\n#VirtoolsVBS_C_DownloadFeature \r\n#VirtoolsVBS_C_DatabaseFeature \r\n# Virtools XBOX Kit Components \r\n#VirtoolsXboxPackUIFeature \r\n#VirtoolsXboxPackBBFeature\r\n# Virtools AI Pack Components \r\n#VirtoolsAIPackFeature\r\n# Office/XE/PCS Components\r\n#VirtoolsPCSBB\r\n#VirtoolsXMLManager\r\n#VirtoolsFilesMgt\r\n#VirtoolsEncryption\r\n#VirtoolsCapture\r\n#VirtoolsDynamicInterface\r\n# Virtools Vector Graphics\r\n#VirtoolsVectorGraphics/********************************************************************\r\n\tcreated:\t2008/01/14\r\n\tcreated:\t14:1:2008 11:57\r\n\tfilename: \tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\\CustomPlayerDialog.h\r\n\tfile path:\tx:\\junctions\\ProjectRoot\\vdev\\Sdk\\Samples\\Runtime\\kamplayer\r\n\tfile base:\tCustomPlayerDialog\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t Dialog for the Custom Player : \r\n\t\t-\tsets the values in the player.ini\r\n\t\t-\tcontains an about tab\r\n\t\t-\tcontains an error tab when necessary \r\n\r\n*********************************************************************/\r\n#pragma once\r\n\r\n#include \"CustomPlayerDialogGraphicPage.h\"\r\n#include \"CustomPlayerDialogErrorPage.h\"\r\n#include \"CustomPlayerDialogAboutPage.h\"\r\n\r\nclass CustomPlayerDialog : public CPropertySheet\r\n{\r\npublic:\r\n\tDECLARE_DYNAMIC(CustomPlayerDialog)\r\n\t//standard constructor, not used !\r\n\t//CustomPlayerDialog(CWnd* pWndParent = NULL);\r\n\r\n\r\n\t// explicit constructor, the only one we use !, an error string is passed here, when strlen(errorText) >0 then we have an error tab !\r\n\tCustomPlayerDialog(CWnd* pWndParent = NULL,CString errorText=\"\");\r\n\r\n\tCustomPlayerDialogGraphicPage m_GraphicPage;\r\n\tCustomPlayerDialogErrorPage m_errorPage;\r\n\tCustomPlayerDialogAboutPage m_aboutPage;\r\n\tCString m_ErrorText;\r\n\t\r\n\t// Overrides : \r\n\r\n\t//\r\n\t//************************************\r\n\t// Method: OnInitDialog\r\n\t// FullName: CustomPlayerDialog::OnInitDialog\r\n\t// Access: public \r\n\t// Returns: BOOL\r\n\t// Qualifier:\r\n\t// Summary : \r\n\t//\t\t\t- fills the configuration tab \r\n\r\n\t//************************************\r\n\tvirtual BOOL OnInitDialog();\r\n\r\n\t// Message Handlers\r\nprotected:\r\n\t//{{AFX_MSG(CModalShapePropSheet)\r\n\tafx_msg void OnApplyNow();\r\n\t\r\n\t//}}AFX_MSG\r\n\t\r\n\tDECLARE_MESSAGE_MAP()\r\npublic:\r\n\t\r\n};\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pVehicleMotor.h\"\r\n#include \"pVehicleGears.h\"\r\n\r\n#include \r\n#include \"NxArray.h\"\r\n\r\n#include \"pEngine.h\"\r\n#include \"pGearbox.h\"\r\n#include \"pDifferential.h\"\r\n\r\nvoid pVehicle::AddDifferential(pDifferential *diff)\n{\n\tif(differentials==MAX_DIFFERENTIAL)\n\t{\n\t\txWarning(\"RCar::AddDifferential(); maximum (%d) exceeded\");\n\t\treturn;\n\t}\n\tdifferential[differentials]=diff;\n\tdifferentials++;\n}\r\n\r\n\r\nint pVehicle::doEngine(int flags,float dt)\r\n{\r\n\r\n\tif (engine && gearbox && driveLine )\r\n\t{\r\n\t\tengine->SetInput(_cAcceleration);\r\n\t\tengine->CalcForces();\r\n\r\n\t\tdriveLine->CalcForces();\r\n\t\tdriveLine->CalcAccelerations();\r\n\r\n\t\tdriveLine->Integrate();\r\n\r\n\t\tfor(int i=0;iIntegrate();\n\t\t}\r\n\r\n\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint pVehicle::initEngine(int flags)\r\n{\r\n\n\tdriveLine=new pDriveLine(this);\n\n\tengine=new pEngine(this);\n\tengine->setToDefault();\n\r\n\tgearbox=new pGearBox(this);\r\n\tgearbox->setToDefault();\r\n\r\n\tdriveLine->SetRoot(engine);\r\n\tengine->AddChild(gearbox);\r\n\r\n\tdriveLine->SetGearBox(gearbox);\r\n\r\n\tdifferentials = 0 ; \r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// setup differential , a single one for the first\r\n\t//\r\n\r\n\tpDifferential *d = new pDifferential(this);\r\n\td->setToDefault();\r\n\r\n\tpWheel *w1 = NULL;int w1Index = -1;\r\n\tpWheel *w2 = NULL;int w2Index = -1;\r\n\t\r\n\r\n\tfindDifferentialWheels(w1Index,w2Index);\r\n\tw1 = (w1Index !=-1) ? _wheels[w1Index] : NULL;\r\n\tw2 = (w2Index !=-1) ? _wheels[w2Index] : NULL;\r\n\r\n\tif ( !w1||!w2 || ( !w1&&!w2 ) )\r\n\t{\r\n\t\txError(\"Couldn't find differential wheels\");\r\n\t\treturn -1;\r\n\t}\r\n\r\n\td->wheel[0]=w1; w1->setDifferential(d,0);\r\n\td->wheel[1]=w2; w2->setDifferential(d,1);\r\n\r\n\td->engine = engine;\r\n\tAddDifferential(d);\r\n\r\n\t// Add differentials and wheels to the driveline\n\t// Note this code does NOT work for 3 diffs, need more work for that.\n\tdriveLine->SetDifferentials(differentials);\n\tif(differentials>0)\n\t{\n\t\t// Hook first diff to the gearbox\n\t\tgearbox->AddChild(differential[0]);\n\t}\n\t// Make the wheels children of the differentials\n\t// A diff with 2 diffs as children is not yet supported.\n\tfor(int i=0;iAddChild(differential[i]->wheel[0]);\n\t\tdifferential[i]->AddChild(differential[i]->wheel[1]);\n\t}\r\n\r\n\r\n\r\n\tdriveLine->CalcPreClutchInertia();\r\n\tgearbox->SetGear(0);\r\n\r\n\treturn 0;\r\n}\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// \r\n//\r\n\r\nfloat pVehicle::getTorque(int component)\r\n{\r\n\tif (isValidEngine())\r\n\t{\r\n\t\treturn GetEngine()->GetTorque();\r\n\t}\r\n\treturn -1.0f;\r\n}\r\n\r\nbool pVehicle::isStalled()\r\n{\r\n\tif (isValidEngine())\r\n\t{\r\n\t\treturn GetEngine()->IsStalled();\r\n\t}\r\n\treturn false;\r\n}\r\nfloat pVehicle::getRPM()\r\n{\r\n\tif (isValidEngine())\r\n\t{\r\n\t\treturn GetEngine()->GetRPM();\r\n\t}\r\n\treturn -1.0f;\r\n}\r\nint pVehicle::getGear()\r\n{\r\n\tif (isValidEngine())\r\n\t{\r\n\t\treturn GetGearBox()->GetGear();\r\n\t}\r\n}\r\n\r\nbool pVehicle::hasDifferential()\r\n{\r\n\treturn differentials;\r\n}\r\n\r\nbool pVehicle::isValidEngine()\r\n{\r\n\treturn engine && gearbox && driveLine && differentials;\r\n}\r\n#ifndef __PREREQUISITES_3TH_PARTY_H__\r\n#define __PREREQUISITES_3TH_PARTY_H__\r\n\r\n\r\n\r\n//################################################################\r\n//\r\n// External : TINY XML\r\n//\r\nclass TiXmlNode;\r\nclass TiXmlDocument;\r\nclass TiXmlElement;\r\n\r\n//################################################################\r\n//\r\n// External NxuStream\r\n//\r\n\r\n\r\n\r\n\r\n#endif /********************************************************************\r\n\tcreated:\t2007/10/29\r\n\tcreated:\t29:10:2007 15:16\r\n\tfilename: \tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\\xSystem3D.h\r\n\tfile path:\tf:\\ProjectRoot\\current\\vt_plugins\\vt_toolkit\\src\r\n\tfile base:\txSystem3D\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#include \"base_macros.h\"\r\n\r\nnamespace xSystem3DHelper\r\n{\r\n\r\n#ifdef __cplusplus\r\n\textern \"C\" {\r\n#endif\r\n\r\n\t\tAPI_EXPORT int xSGetAvailableTextureMem();\r\n\t\tAPI_EXPORT float xSGetPhysicalMemoryInMB();\r\n\t\tAPI_EXPORT int xSGetPhysicalGPUMemoryInMB(int device);\r\n\t\tAPI_EXPORT void xSSaveAllDxPropsToFile(char*file);\r\n\t\tAPI_EXPORT void xSGetDXVersion(char*& versionstring,int& minor);\r\n\r\n\r\n#ifdef __cplusplus\r\n\t}\r\n#endif\r\n\r\n}#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOSetUserValueDecl();\r\nCKERROR CreateDOSetUserValueProto(CKBehaviorPrototype **);\r\nint DOSetUserValue(const CKBehaviorContext& behcontext);\r\nCKERROR DOSetUserValueCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorDOSetUserValueDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"DOSetUserValue\");\t\r\n\tod->SetDescription(\"Sets a user value on distributed object\");\r\n\r\n\tod->SetCategory(\"TNL/Distributed Objects\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x3b345be9,0x2851018b));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateDOSetUserValueProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateDOSetUserValueProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"DOSetUserValue\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\r\n\r\n\tproto->DeclareOutput(\"Exit In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_BEOBJECT, \"test\");\r\n\t\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\tproto->DeclareSetting(\"Class\", CKPGUID_STRING, \"My3DClass\");\r\n\t\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(DOSetUserValue);\r\n\tproto->SetBehaviorCallbackFct(DOSetUserValueCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint DOSetUserValue(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id : \r\n\tint connectionID = vtTools::BehaviorTools::GetInputParameterValue(beh,0);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object :\r\n\tCK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tif (!obj)\r\n\t{\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\tXString errorMesg(\"distributed object creation failed,no network connection !\");\r\n\t\tpout->SetStringValue(errorMesg.Str());\r\n\t\tbeh->ActivateOutput(1);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\t//use objects name, if not specified : \r\n\tCKSTRING name= obj->GetName();\r\n\t\r\n\tIDistributedObjects*doInterface = cin->getDistObjectInterface();\r\n\tIDistributedClasses*cInterface = cin->getDistributedClassInterface();\r\n \r\n\tXString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));\r\n\txDistributedClass *_class = cInterface->get(className.CStr());\r\n\t\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//dist class ok ? \r\n\tif (_class==NULL)\r\n\t{\r\n\t\tbeh->ActivateOutput(1);\r\n\t\tctx->OutputToConsoleEx(\"Distributed Class doesn't exists : %s\",className.CStr());\r\n\t\treturn 0;\r\n\t}\r\n\tconst char * cNAme = _class->getClassName().getString();\r\n\r\n\tint classType = _class->getEnitityType();\r\n\r\n\t/*using namespace vtTools;\r\n\tusing namespace vtTools::Enums;*/\r\n\tint bcount = beh->GetInputParameterCount();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by input 0 : \r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\r\n\r\n\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t{\r\n\t\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t\txDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());\r\n\t\t\t\r\n\t\t\tif (!dobj )\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\r\n\t\t\tint dOID = dobj->getUserID(); \r\n\t\t\tint clientID = cin->getConnection()->getUserID();\r\n\t\t\tif (dOID !=clientID)\r\n\t\t\t{\r\n\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\t}\r\n\t\t\t\r\n\r\n\r\n\t\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\txDistributedPropertyArrayType &props = *dobj->getDistributedPorperties();\r\n\t\t\t\r\n\t\t\tint propID = _class->getInternalUserFieldIndex(i - BEH_IN_INDEX_MIN_COUNT);\r\n\t\t\tif (propID==-1 || propID > props.size() )\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\txDistributedProperty *prop = props[propID];\r\n\t\t\tif (prop)\r\n\t\t\t{\r\n\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\tif (propInfo)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\r\n\t\t\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVxVector vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n break;\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tfloat vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(vvalue,currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedPoint2F * dpoint3F = (xDistributedPoint2F*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVx2DVector vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tVxQuaternion vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedString * dpoint3F = (xDistributedString*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tCKParameter *pin = beh->GetInputParameter(i)->GetRealSource();\r\n\t\t\t\t\t\t\t\t\tif (pin)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxScratch sbuffer(256);\r\n\t\t\t\t\t\t\t\t\t\tCKSTRING buffer = (CKSTRING)sbuffer.Mem();\r\n\t\t\t\t\t\t\t\t\t\tpin->GetStringValue(buffer);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(TNL::StringPtr(buffer),currentTime);\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\txDistributedInteger * dpoint3F = (xDistributedInteger*)prop;\r\n\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tint vvalue;\r\n\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(vvalue,currentTime);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t}\r\n\t\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we come in by loop : \r\n\treturn 0;\r\n}\r\n\r\nCKERROR DOSetUserValueCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}// Editor.cpp : Defines the initialization routines for the DLL.\r\n//\r\n\r\n#include \"stdafx.h\"\r\n#include \"DistributedNetworkClassDialogEditor.h\"\r\n#include \"DistributedNetworkClassDialogEditorDlg.h\"\r\n#include \"DistributedNetworkClassDialogToolbarDlg.h\"\r\n#include \"DistributedNetworkClassDialogCallback.h\"\r\n\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nDistributedNetworkClassDialogEditorDlg*\t\tg_Editor\t\t\t= NULL;\r\nDistributedNetworkClassDialogToolbarDlg*\t\tg_Toolbar\t\t\t= NULL;\r\n\r\n//----------------------------------------\r\n//The Plugin Info structure that must be filled for Virtools Dev to load effectively the plugin\r\nPluginInfo g_PluginInfo0;\r\n\r\n//Returns the number of plugin contained in this dll\r\n//this function must be exported (have a .def file with its name or use __declspec( dllexport )\r\nint GetVirtoolsPluginInfoCount()\r\n{\r\n\treturn 1;\r\n}\r\n\r\n//returns the ptr of the (index)th plugininfo structure of this dll\r\n//this function must be exported (have a .def file with its name or use __declspec( dllexport )\r\nPluginInfo* GetVirtoolsPluginInfo(int index)\r\n{\r\n\tswitch(index)\r\n\t{\r\n\tcase 0:\r\n\t\treturn &g_PluginInfo0;\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n//\r\n//\tNote!\r\n//\r\n//\t\tIf this DLL is dynamically linked against the MFC\r\n//\t\tDLLs, any functions exported from this DLL which\r\n//\t\tcall into MFC must have the AFX_MANAGE_STATE macro\r\n//\t\tadded at the very beginning of the function.\r\n//\r\n//\t\tFor example:\r\n//\r\n//\t\textern \"C\" BOOL PASCAL EXPORT ExportedFunction()\r\n//\t\t{\r\n//\t\t\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n//\t\t\t// normal function body here\r\n//\t\t}\r\n//\r\n//\t\tIt is very important that this macro appear in each\r\n//\t\tfunction, prior to any calls into MFC. This means that\r\n//\t\tit must appear as the first statement within the \r\n//\t\tfunction, even before any object variable declarations\r\n//\t\tas their constructors may generate calls into the MFC\r\n//\t\tDLL.\r\n//\r\n//\t\tPlease see MFC Technical Notes 33 and 58 for additional\r\n//\t\tdetails.\r\n//\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogEditorApp\r\n\r\nBEGIN_MESSAGE_MAP(DistributedNetworkClassDialogEditorApp, CWinApp)\r\n\t//{{AFX_MSG_MAP(DistributedNetworkClassDialogEditorApp)\r\n\t\t// NOTE - the ClassWizard will add and remove mapping macros here.\r\n\t\t// DO NOT EDIT what you see in these blocks of generated code!\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// DistributedNetworkClassDialogEditorApp construction\r\n\r\nDistributedNetworkClassDialogEditorApp::DistributedNetworkClassDialogEditorApp()\r\n{\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// The one and only DistributedNetworkClassDialogEditorApp object\r\n\r\nDistributedNetworkClassDialogEditorApp theApp;\r\n\r\nBOOL DistributedNetworkClassDialogEditorApp::InitInstance() \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\t\r\n\tstrcpy(g_PluginInfo0.m_Name,\"DistributedObjects\");\r\n\tg_PluginInfo0.m_PluginType\t\t= PluginInfo::PT_EDITOR;\r\n\tg_PluginInfo0.m_PluginType\t\t= (PluginInfo::PLUGIN_TYPE)(g_PluginInfo0.m_PluginType | PluginInfo::PTF_RECEIVENOTIFICATION);\r\n\tg_PluginInfo0.m_PluginCallback\t= PluginCallback;\r\n\t//EDITOR\r\n\t{\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Guid[1]\t\t\t\t\t\t= 0x5f116b1f;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Guid[2]\t\t\t\t\t\t= 0x7771a950;\r\n\t\tstrcpy(g_PluginInfo0.m_EditorInfo.m_EditorName,\"DistributedNetworkClassDialog\");\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_CreateEditorDlgFunc\t\t\t= fCreateEditorDlg;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_CreateToolbarDlgFunc\t\t\t= fCreateToolbarDlg;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bUnique\t\t\t\t\t\t= 1;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bIndestructible\t\t\t\t= false;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_bManageScrollbar\t\t\t\t= 0;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Width\t\t\t\t\t\t\t= 800;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_Height\t\t\t\t\t\t\t= 800;\r\n\r\n\t\tg_PluginInfo0.m_EditorInfo.m_ToolbarHeight\t\t\t\t\t= 21;\r\n\t\tInitImageList();\r\n\t\tg_PluginInfo0.m_EditorInfo.m_IconList\t\t\t\t\t\t= &m_ImageList;\r\n\t\tg_PluginInfo0.m_EditorInfo.m_IconIndex\t\t\t\t\t\t= 0;\r\n\t}\r\n\r\n\treturn CWinApp::InitInstance();\r\n}\r\n\r\nint DistributedNetworkClassDialogEditorApp::ExitInstance() \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\t\r\n\tDeleteImageList();\r\n\r\n\treturn CWinApp::ExitInstance();\r\n}\r\n\r\nvoid DistributedNetworkClassDialogEditorApp::InitImageList()\r\n{\r\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n\r\n\tm_ImageList.Create(16, 16, ILC_COLOR8|ILC_MASK, 0, 2);\r\n\r\n\tm_ImageList.Add(AfxGetApp()->LoadIcon(IDI_EDITORICON));\r\n}\r\n\r\nvoid DistributedNetworkClassDialogEditorApp::DeleteImageList()\r\n{\r\n\tm_ImageList.DeleteImageList();\r\n}\r\n// racer/differential.h\n\n#ifndef __RACER_DIFFERENTIAL_H\n#define __RACER_DIFFERENTIAL_H\n\n#include \"vtPhysXBase.h\"\n#include \"pDriveline.h\"\n\nclass pVehicle;\nclass pWheel;\nclass pEngine;\n\nclass MODULE_API pDifferential : public pDriveLineComp\n// A differential that has 3 parts; 1 'input', and 2 'outputs'.\n// Actually, all parts work together in deciding what happens.\n{\n public:\n enum Type\n {\n FREE=0, // Free/open differential\n VISCOUS=1, // Viscous locking differential\n SALISBURY=2 // Grand Prix Legends type clutch locking\n };\n enum Flags\n {\n //LINEAR_LOCKING=1 // Viscous diff is of linear (expensive) type\n };\n\n void setToDefault();\n\n protected:\n\n // Definition (static input)\n int type;\n int flags; // Behavior flags\n float lockingCoeff; // Coefficient for viscous diff\n // Salisbury diff\n float powerAngle,coastAngle; // Ramp angles\n int clutches; // Number of clutches in use\n float clutchFactor; // Scaling the effect of the clutches\n float maxBiasRatioPower; // Resulting max. bias ratio\n float maxBiasRatioCoast; // Resulting max. bias ratio\n\n // Input\n\n // Torque on the 3 parts\n float torqueIn;\n float torqueOut[2];\n float torqueBrakingOut[2]; // Potential braking torque\n // Inertia of objects\n float inertiaIn;\n float inertiaOut[2];\n // Limited slip differentials add a locking torque\n float torqueLock;\n\n // State\n float velASymmetric; // Difference in wheel rotation speed\n float torqueBiasRatio; // Relative difference in reaction T's\n float torqueBiasRatioAbs; // Always >=1\n int locked; // Mask of locked ends\n\n // Output\n\n // Resulting accelerations\n float accIn,\n accASymmetric;\n float accOut[2];\n float rotVdriveShaft; // Speed of driveshaft (in)\n\n pVehicle *car;\n\n public:\n // Input\n pEngine *engine;\n // Output members\n pWheel2 *wheel[2];\n\n public:\n pDifferential(pVehicle *car);\n ~pDifferential();\n\n void Reset();\n //----------------------------------------------------------------\n //\n // experimental\n //\n \n void SetTorqueIn(float torque);\n \n float GetTorqueOut(int n);\n float GetBreakTorqueOut(int n);\n\n void SetInertiaIn(float inertia);\n void SetInertiaOut(int n,float inertia);\n\n\n //----------------------------------------------------------------\n //\n // standard\n //\n \n\n float GetAccIn() const { return accIn; }\n float GetAccASymmetric() const { return accASymmetric; }\n float GetAccOut(int n) const { return accOut[n]; }\n // Salisbury info\n float GetTorqueBiasRatio(){ return torqueBiasRatio; }\n float GetMaxBiasRatioPower(){ return maxBiasRatioPower; }\n float GetMaxBiasRatioCoast(){ return maxBiasRatioCoast; }\n float GetPowerAngle(){ return powerAngle; }\n float GetCoastAngle(){ return powerAngle; }\n int GetClutches(){ return clutches; }\n float GetClutchFactor(){ return clutchFactor; }\n // Other info\n float GetRotationalVelocityIn() const { return rotVdriveShaft; }\n\n void Lock(int wheel);\n bool IsLocked(int wheel)\n { if(locked&(1</////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Mimic\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorMimicDecl();\r\nCKERROR CreateMimicProto(CKBehaviorPrototype **pproto);\r\nint Mimic(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorMimicDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Mimic\");\t\r\n\tod->SetDescription(\"Makes a 3D Entity copy the motion of another one.\");\r\n\t/* rem:\r\n\tIn: triggers the process
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tObject: object to copy.
\r\n\tCopy Position: TRUE means the object's position will be copied.
\r\n\tPosition Speed: how fast the 3D Entity is to copy the object's position. \r\n\tThe higher the percentage, the faster the 3D Entity will do this.
\r\n\tCopy Orientation: TRUE means that 3D Entity will copy the object's orientation.
\r\n\tOrientation Speed: how fast the 3D Entity is to copy the object's orientation. \r\n\tThe higher the percentage, the faster the 3D Entity will do this.
\r\n\tCopy Scale: TRUE means that the 3D Entity will copy the object's scale.
\r\n\tScale Speed: how fast the 3D Entity is to copy the object's orientation. \r\n\tThe higher the percentage, the faster the 3D Entity will do this.
\r\n\tHierarchy: if TRUE, then this behavior will also apply to the 3D Entity's children.
\r\n\t
\r\n\tTime Based: If checked, this building block will be Time and not Frame Rate \r\n\tdependant. Making this building block Time dependant has the advantage that compositions will run \r\n\tat the same rate on all computer configurations.
\r\n\t
\r\n\tThis behavior needs to be looped, if you want the object to constantly mimic the target.
\r\n\t*/\r\n /* warning:\r\n - If you want no attenuation during motion, you shouldn't use the 'Time Based' setting.
\r\n - As a time dependant looping process this building block has to be looped with a 1 frame link delay. \r\n The reason of this is because the internally laps of time used is always equal to the duration of one global process of the building blocks.
\r\n This means, if you use 2 or 3 frame link delay, the process will become frame dependant.
\r\n Note: if you don't use any '... Speed' value (ie 100), the above remark is useless (because movement is instantaneous).
\r\n */\r\n\tod->SetCategory(\"3D Transformations/Constraint\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x1df50d81,0x53cc788f));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateMimicProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateMimicProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Mimic2\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Object\", CKPGUID_3DENTITY );\r\n\tproto->DeclareInParameter(\"Copy Position\", CKPGUID_BOOL , \"TRUE\");\r\n\tproto->DeclareInParameter(\"Position Speed\", CKPGUID_PERCENTAGE, \"100\");\r\n\tproto->DeclareInParameter(\"add vec\", CKPGUID_VECTOR);\r\n\r\n\tproto->DeclareInParameter(\"Copy Orientation\", CKPGUID_BOOL , \"TRUE\");\r\n\tproto->DeclareInParameter(\"Orientation Speed\", CKPGUID_PERCENTAGE, \"100\");\r\n\tproto->DeclareInParameter(\"add quat\", CKPGUID_QUATERNION);\r\n\r\n\tproto->DeclareInParameter(\"Copy Scale\", CKPGUID_BOOL , \"TRUE\");\r\n\tproto->DeclareInParameter(\"Scale Speed\", CKPGUID_PERCENTAGE, \"100\");\r\n\tproto->DeclareInParameter(\"Hierarchy\", CKPGUID_BOOL , \"TRUE\");\r\n\r\n proto->DeclareSetting(\"Time Based\", CKPGUID_BOOL, \"TRUE\");\r\n \r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Mimic);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint Mimic(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior* beh = behcontext.Behavior;\r\n\r\n\t// Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\t// Get the Owner Object\r\n\tCK3dEntity *Ent1 = (CK3dEntity *) beh->GetTarget();\r\n if( !Ent1 ) return CKBR_OWNERERROR;\r\n\r\n // Get the Object\r\n CK3dEntity *Ent2 = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n if(!Ent2) return CKBR_OK;\r\n \r\n // hierarchy\r\n CKBOOL k = TRUE;\r\n beh->GetInputParameterValue(7, &k);\r\n k=!k;\r\n \r\n CKBOOL b;\r\n float f = 0.0;\r\n \r\n /////////////////////////////////////////////////////////////////////////////////////\r\n // Time Based Setting Version ?\r\n CKBOOL time_based=FALSE;\r\n beh->GetLocalParameterValue(0, &time_based);\r\n \r\n // Mimic Position\r\n beh->GetInputParameterValue(1,&b);\r\n if(b) { \r\n beh->GetInputParameterValue(2,&f);\r\n if( time_based ) {\r\n f *= behcontext.DeltaTime * 0.07f;\r\n if (f > 1.0f) f = 1.0f;\r\n }\r\n \r\n VxVector p1,p2;\r\n Ent1->GetPosition(&p1);\r\n Ent2->GetPosition(&p2);\r\n\tVxVector addV; \r\n\tbeh->GetInputParameterValue(3,&addV);\r\n\r\n\tp1 +=addV;\r\n\tp1 += (p2-p1) * f;\r\n \r\n Ent1->SetPosition(&p1,NULL,k);\r\n\t\t\t\t\r\n }\r\n \r\n // Mimic orientation\r\n beh->GetInputParameterValue(4,&b);\r\n if(b) { \r\n beh->GetInputParameterValue(5,&f);\r\n if( time_based ) {\r\n f *= behcontext.DeltaTime * 0.07f;\r\n if (f > 1.0f) f = 1.0f;\r\n }\r\n \r\n\r\n VxQuaternion quatA, quatB, quatC,quatD;\r\n\tbeh->GetInputParameterValue(6,&quatD);\r\n\t\r\n\r\n VxVector scale1, scale2, scaleUnit(1,1,1);\r\n Ent1->GetScale(&scale1);\r\n\r\n Ent1->GetQuaternion(&quatA);\r\n Ent2->GetQuaternion(&quatB);\r\n\r\n quatC=Slerp(f, quatA, quatB); \r\n \r\n Ent1->SetQuaternion(&quatC,NULL,k);\r\n Ent1->SetScale(&scale1);\r\n }\r\n \r\n // Mimic Scale\r\n beh->GetInputParameterValue(7,&b);\r\n if(b) { \r\n beh->GetInputParameterValue(8,&f);\r\n if( time_based ) {\r\n f *= behcontext.DeltaTime * 0.07f;\r\n if (f > 1.0f) f = 1.0f;\r\n }\r\n \r\n VxVector p1,p2;\r\n\t\tEnt1->GetScale(&p1);\r\n\t\tEnt2->GetScale(&p2);\r\n\r\n p1 += (p2-p1) * f;\r\n\t\t\r\n Ent1->SetScale(&p1,k);\r\n\t}\r\n\t\r\n\treturn CKBR_OK;\r\n}\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedClient.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSCreateObjectDecl();\r\nCKERROR CreateNSCreateObjectProto(CKBehaviorPrototype **);\r\nint NSCreateObject(const CKBehaviorContext& behcontext);\r\nCKERROR NSCreateObjectCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 5\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_SESSION_TYPE,\r\n\tBB_IP_SESSION_NAME,\r\n\tBB_IP_MAX_PLAYERS,\r\n\tBB_IP_PASSWORD\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\r\n\tBB_O_CREATED,\r\n\tBB_O_WAITING,\r\n\tBB_O_ERROR\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\r\n\tBB_OP_SESSION_ID,\r\n\tBB_OP_MAX_PLAYERS,\r\n\tBB_OP_ERROR\r\n};\r\n\r\nCKObjectDeclaration\t*FillBehaviorNSCreateObjectDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NSCreate\");\t\r\n\tod->SetDescription(\"Creates a session\");\r\n\r\n\tod->SetCategory(\"TNL/Sessions\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5efe2bbd,0x20525241));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNSCreateObjectProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNSCreateObjectProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NSCreate\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\r\n\r\n\tproto->DeclareInput(\"Create\");\r\n\r\n\tproto->DeclareOutput(\"Created\");\r\n\tproto->DeclareOutput(\"Waiting For Answer\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\r\n\r\n\tproto->DeclareInParameter(\"Connection ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Session Type\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareInParameter(\"Session Name\", CKPGUID_STRING, \"test\");\r\n\tproto->DeclareInParameter(\"Maximum Players\", CKPGUID_INT, \"3\");\r\n\tproto->DeclareInParameter(\"Password\", CKPGUID_STRING, \"\");\r\n\r\n\r\n\r\n\tproto->DeclareOutParameter(\"Session ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Maximum Players\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"Ok\");\r\n\t\r\n\r\n\tproto->DeclareSetting(\"Long Session\", CKPGUID_BOOL, \"TRUE\");\r\n\tproto->DeclareLocalParameter(\"Creation Status\", CKPGUID_INT, \"0\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\tproto->SetFunction(NSCreateObject);\r\n\tproto->SetBehaviorCallbackFct(NSCreateObjectCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NSCreateObject(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//connection id + session name : \r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tint connectionID = GetInputParameterValue(beh,0);\r\n\tCKSTRING sessionName = GetInputParameterValue(beh,BB_IP_SESSION_NAME);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we create one session class per session object : \r\n\tISession *sInterface = cin->getSessionInterface();\r\n\txDistributedSession *session = sInterface->get(sessionName);\r\n\tIDistributedClasses *cInterface = cin->getDistributedClassInterface();\r\n\t\r\n\tint creationStatus = E_DO_CREATION_INCOMPLETE;\r\n\tbeh->SetLocalParameterValue(1,&creationStatus);\r\n\r\n \r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tbbNoError(E_NWE_OK);\r\n\t\txDistributedClient *myClient = cin->getMyClient();\r\n\t\tif (!myClient)\r\n\t\t{\r\n\t\t\tbbError(E_NWE_INTERN);\r\n\t\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (isFlagOn(myClient->getClientFlags(),E_CF_SESSION_JOINED ))\r\n\t\t{\r\n\t\t\tbbError(E_NWE_SESSION_ALREADY_JOINED);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\r\n\t\t//we attach the building blocks parameter \r\n\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\t\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t{\r\n\r\n\t\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(ciIn->GetType()));\r\n\t\t\tif (xDistTools::SuperTypeToValueType(sType) == E_DC_PTYPE_UNKNOWN)\r\n\t\t\t{\r\n\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\t/************************************************************************/\r\n\t\t/*\t\t\tSESSION CLASS CREATION !\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\r\n\t\t//pickup data\r\n\r\n\t\tint sessionType = GetInputParameterValue(beh,BB_IP_SESSION_TYPE);\r\n\t\tint MaxPlayers = GetInputParameterValue(beh,BB_IP_MAX_PLAYERS);\r\n\t\tCKSTRING password = GetInputParameterValue(beh,BB_IP_PASSWORD);\r\n\r\n\t\t//we create a session class, according sessions name and attached user parameters\r\n\t\txDistributedSessionClass*sessionClass = (xDistributedSessionClass*)cInterface->get(sessionName);\r\n\t\tif (!sessionClass)\r\n\t\t{\r\n\t\t\tsessionClass = (xDistributedSessionClass*)cInterface ->createClass(sessionName,E_DC_BTYPE_SESSION);\r\n\t\t\t\r\n\t\t\t//we enable all native properties : \r\n\t\t\tsessionClass->addProperty(E_DC_S_NP_MAX_USERS,E_PTYPE_RELIABLE);\r\n\t\t\tif (strlen(password))\r\n\t\t\t\tsessionClass->addProperty(E_DC_S_NP_PASSWORD,E_PTYPE_RELIABLE);\r\n\t\t\tsessionClass->addProperty(E_DC_S_NP_TYPE,E_PTYPE_RELIABLE);\r\n\t\t\tsessionClass->addProperty(E_DC_S_NP_LOCKED,E_PTYPE_RELIABLE);\r\n\t\t\tsessionClass->addProperty(E_DC_S_NP_NUM_USERS,E_PTYPE_RELIABLE);\r\n\r\n \r\n\t\t\t\r\n\t\t\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(ciIn->GetType()));\r\n\t\t\t\tsessionClass->addProperty(ciIn->GetName(),xDistTools::SuperTypeToValueType(sType),E_PTYPE_RELIABLE);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//now we deploy it on the server : \r\n\t\tcInterface->deployClass(sessionClass);\r\n\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/*\t\t\tSESSION OBJECT CREATION\t\t\t\t\t */\r\n\t\t/************************************************************************/\r\n\t\r\n\t\t//create a session via rpc : \r\n\r\n\t\tsInterface->create(sessionName,MaxPlayers,password,sessionType);\r\n\r\n\t\treturn CKBR_ACTIVATENEXTFRAME;\r\n\t}\r\n\r\n\r\n\t/************************************************************************/\r\n\t/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\tif ( session \r\n\t\t&& session->getSessionFlags().test(1<< E_SF_INCOMPLETE) \r\n\t\t&& session->getUserID() == cin->getConnection()->getUserID()\r\n\t\t&& !session->getSessionFlags().test( 1 << E_SF_POPULATE_PARAMETERS )\r\n\t\t)\r\n\t{\r\n\t\t\r\n\r\n\t\tsession->getSessionFlags().set( 1 << E_SF_POPULATE_PARAMETERS );\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint MaxPlayers = GetInputParameterValue(beh,BB_IP_MAX_PLAYERS);\r\n\t\txDistributedInteger *pMaxUsers = (xDistributedInteger *)session->getProperty(E_DC_S_NP_MAX_USERS);\r\n\t\tpMaxUsers->updateValue(MaxPlayers,0);\r\n\t\tpMaxUsers->setFlags(E_DP_NEEDS_SEND);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tCKSTRING password = GetInputParameterValue(beh,BB_IP_PASSWORD);\r\n\t\txDistributedString *pPass= (xDistributedString*)session->getProperty(E_DC_S_NP_PASSWORD);\r\n\t\tif (pPass)\r\n\t\t{\r\n\t\t\tpPass->updateValue(xNString(password),0);\r\n\t\t\tpPass->setFlags(E_DP_NEEDS_SEND);\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint sessionType = GetInputParameterValue(beh,BB_IP_SESSION_TYPE);\r\n\t\txDistributedInteger *pType= (xDistributedInteger *)session->getProperty(E_DC_S_NP_TYPE);\r\n\t\tpType->updateValue(sessionType,0);\r\n\t\tpType->setFlags(E_DP_NEEDS_SEND);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tint sessionLocked = 0;\r\n\t\txDistributedInteger *pLocked= (xDistributedInteger *)session->getProperty(E_DC_S_NP_LOCKED);\r\n\t\tpLocked->updateValue(sessionLocked,0);\r\n\t\tpLocked->setFlags(E_DP_NEEDS_SEND);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\tif ( beh->GetInputParameterCount() > BEH_IN_INDEX_MIN_COUNT )\r\n\t\t{\r\n \t\txDistributedSessionClass *_class = (xDistributedSessionClass*)session->getDistributedClass();\r\n\r\n\t\t\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\t\t\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t\t\t{\r\n\t\t\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\t\t\tCKParameterType pType = ciIn->GetType();\r\n\t\t\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\t\t\txDistributedPropertyArrayType &props = *session->getDistributedPorperties();\r\n\r\n\t\t\t\tint propID = _class->getInternalUserFieldIndex(i - BEH_IN_INDEX_MIN_COUNT);\r\n\t\t\t\tint startIndex = _class->getFirstUserField();\r\n\t\t\t\tint pSize = props.size();\r\n\t\t\t\tif (propID==-1 || propID > props.size() )\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\txDistributedProperty *prop = props[propID];\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\r\n\r\n\r\n\t\t\t\t\t//we set the update flag in the prop by hand : \r\n\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\tif (propInfo)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\tint dType = xDistTools::ValueTypeToSuperType(propInfo->mValueType);\r\n\t\t\t\t\t\tif (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\r\n\t\t\t\t\t\t\tswitch(propInfo->mValueType)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_3DVECTOR:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxVector vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedPoint1F * dpoint3F = (xDistributedPoint1F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tfloat vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(vvalue,currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedPoint2F * dpoint3F = (xDistributedPoint2F*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVx2DVector vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tVxQuaternion vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_STRING:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedString * dpoint3F = (xDistributedString*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tCKParameter *pin = beh->GetInputParameter(i)->GetRealSource();\r\n\t\t\t\t\t\t\t\t\t\tif (pin)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tVxScratch sbuffer(256);\r\n\t\t\t\t\t\t\t\t\t\t\tCKSTRING buffer = (CKSTRING)sbuffer.Mem();\r\n\t\t\t\t\t\t\t\t\t\t\tpin->GetStringValue(buffer);\r\n\t\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(TNL::StringPtr(buffer),currentTime);\r\n\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\txDistributedInteger * dpoint3F = (xDistributedInteger*)prop;\r\n\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tint vvalue;\r\n\t\t\t\t\t\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(vvalue,currentTime);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t\r\n\t\r\n\t/************************************************************************/\r\n\t/* SESSION COMPLETE\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\tif ( \r\n\t\tsession \r\n\t\t&& session->getSessionFlags().test(1<< E_SF_COMPLETE ) \r\n\t\t&& session->getUserID() == cin->getConnection()->getUserID()\t\t\r\n\t\t)\r\n\t{\r\n\r\n\t\tsession->getSessionFlags().set( 1 << E_SF_INCOMPLETE,false );\r\n\t\tsession->getSessionFlags().set( 1 << E_SF_POPULATE_PARAMETERS,false );\r\n\r\n\t\tint sessionID = session->getSessionID();\r\n\t\tbeh->SetOutputParameterValue(BB_OP_SESSION_ID,&sessionID);\r\n\r\n\t\tbeh->ActivateOutput(BB_O_CREATED);\r\n\t\treturn 0;\r\n\r\n\r\n\t}\r\n\r\n\tbeh->ActivateOutput(BB_O_WAITING);\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n\r\n}\r\n\r\nCKERROR NSCreateObjectCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// ARToolKitPlusManager\r\n// --------------------\r\n//\r\n// Description:\r\n// This manager is used for setting the right camera projection matrix if\r\n// an ARToolKitPlus building block is used and the flag\r\n// ARTPlus(Multi)CorrectCamera is set.\r\n//\r\n//\r\n// Version 1.0\t: First Release\r\n//\r\n// Known Bugs\t: None\r\n//\r\n// Copyright <>, University of Paderborn\r\n////////////////////////////////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"ARToolKitPlusManager.h\"\r\n#include \r\n#include \r\n\r\nextern bool ARTPlusInitialized;\r\nextern bool ARTPlusCorrectCamera;\r\n\r\nextern bool ARTPlusMultiInitialized;\r\nextern bool ARTPlusMultiCorrectCamera;\r\n\r\nextern ARToolKitPlus::TrackerSingleMarker *tracker;\r\nextern ARToolKitPlus::TrackerMultiMarker *multiTracker;\r\n\nextern void argConvGlpara( float para[4][4], float gl_para[16] );\nextern void argConvGlparaTrans( float para[4][4], float gl_para[16] );\n\r\nVxMatrix projectMat;\r\n\r\nARToolKitPlusManager::ARToolKitPlusManager(CKContext *Context) : \r\nCKBaseManager(Context, ARToolKitPlusManagerGUID, \"ARToolKitPlusManager\")\r\n{\r\n\tContext->RegisterNewManager(this);\r\n}\r\n\r\nARToolKitPlusManager::~ARToolKitPlusManager()\r\n{\r\n}\r\n\r\n//--- Called before the composition is reset.\nCKERROR ARToolKitPlusManager::OnCKReset()\n{\n\treturn CKERR_NOTIMPLEMENTED;\n}\n\n//--- Called when the process loop is started.\nCKERROR ARToolKitPlusManager::OnCKPlay()\n{\n\treturn CKERR_NOTIMPLEMENTED;\n}\n\n//--- Called when the process loop is paused.\nCKERROR ARToolKitPlusManager::OnCKPause()\n{\n\treturn CKERR_NOTIMPLEMENTED;\n}\n\n//--- Called before the rendering of the 3D objects.\nCKERROR ARToolKitPlusManager::OnPreRender(CKRenderContext* dev)\n{\n\tif( (ARTPlusInitialized && ARTPlusCorrectCamera) ||\r\n\t\t(ARTPlusMultiInitialized && ARTPlusMultiCorrectCamera) )\r\n\t{\n\t\tfloat* buffer = NULL;\r\n\t\tfloat gl_matirx[4][4];\r\n\r\n\t\tif(tracker!=NULL && ARTPlusInitialized)\r\n\t\t{\r\n\t\t\tbuffer = (float *)tracker->getProjectionMatrix();\r\n\t\t}\r\n\t\telse if (multiTracker!=NULL && ARTPlusMultiInitialized)\r\n\t\t{\r\n\t\t\tbuffer = (float *)multiTracker->getProjectionMatrix();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn CKERR_NOTINITIALIZED;\r\n\t\t}\r\n\r\n\t\targConvGlparaTrans(gl_matirx, buffer);\r\n\r\n\t\tgl_matirx[1][1] = -gl_matirx[1][1];\r\n\r\n\t\tVxMatrix mat = VxMatrix(gl_matirx);\r\n\t\tprojectMat = dev->GetProjectionTransformationMatrix();\r\n\r\n\t\tdev->SetProjectionTransformationMatrix(mat);\r\n\t}\n\n\treturn CK_OK;\n}\n\n//--- Called after the rendering of the 3D objects.\nCKERROR ARToolKitPlusManager::OnPostRender(CKRenderContext* dev)\n{\n\tif(ARTPlusInitialized && ARTPlusCorrectCamera)\n\t{\n\t\tdev->SetProjectionTransformationMatrix(projectMat);\r\n\t}\n\n\treturn CK_OK;\n}\n\n\r\n\r\n\r\nSET DEV40DIR=\"x:/sdk/dev4\"\r\nSET DEV41DIR=\"x:/sdk/dev41R\"\r\nSET DEV5DIR=\"x:/sdk/dev5GA\"\r\n\r\nxcopy /c /r /y %DEV40DIR%\\BuildingBlocks\\vtPhysX.dll ..\\Release\\Author\\Dev40\\BuildingBlocks\\\r\nxcopy /c /r /y %DEV40DIR%\\vtPhysXLib.dll ..\\Release\\Author\\Dev40\\\r\n\r\nxcopy /c /r /y %DEV41DIR%\\BuildingBlocks\\vtPhysX.dll ..\\Release\\Author\\Dev41\\BuildingBlocks\\\r\nxcopy /c /r /y %DEV41DIR%\\vtPhysXLib.dll ..\\Release\\Author\\Dev41\\\r\n\r\nxcopy /c /r /y %DEV5DIR%\\BuildingBlocks\\vtPhysX.dll ..\\Release\\Author\\Dev5\\BuildingBlocks\\\r\nxcopy /c /r /y %DEV5DIR%\\vtPhysXLib.dll ..\\Release\\Author\\Dev5\\\r\n\r\n\r\nsvn ci -m \"batch upload: release demo\" ..\\Release\\Author\\\r\n\r\ncd ..\\Tools\r\nCreateAuthorZip.bat\r\n\r\n\r\n\r\n#include \"SoftMeshPSK.h\"\r\n\r\nnamespace SOFTBODY\r\n{\r\n\tCallback_LoadSoftMeshPSK gUserLoadSoftMeshPSK = 0;\r\n};#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCIgnorePairDecl();\r\nCKERROR CreatePCIgnorePairProto(CKBehaviorPrototype **pproto);\r\nint PCIgnorePair(const CKBehaviorContext& behcontext);\r\nCKERROR PCIgnorePairCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPCIgnorePairDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PCIgnorePair\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Enables/Disables collision between two bodies.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x63f648f7,0x13c7097f));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePCIgnorePairProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePCIgnorePairProto\r\n// FullName: CreatePCIgnorePairProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePCIgnorePairProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PCIgnorePair\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PCIgnorePairCB );\r\n\t\r\n\tproto->DeclareInParameter(\"Object A\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Object B\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Ignore\",CKPGUID_BOOL,\"0\");\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PCIgnorePair);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PCIgnorePair\r\n// FullName: PCIgnorePair\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PCIgnorePair(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t\tCK3dEntity *targetA = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(1);\r\n\t\tint ignore = GetInputParameterValue(beh,2);\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t// the world : \r\n\t\tpWorld *world=GetPMan()->getWorld(target); \r\n\t\t\r\n\t\tif(world){\r\n\t\t\tworld->cIgnorePair(targetA,targetB,ignore);\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PCIgnorePairCB\r\n// FullName: PCIgnorePairCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PCIgnorePairCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_NETINTERFACE_H_\n#define _TNL_NETINTERFACE_H_\n\n#ifndef _TNL_VECTOR_H_\n#include \"tnlVector.h\"\n#endif\n\n#ifndef _TNL_NETBASE_H_\n#include \"tnlNetBase.h\"\n#endif\n\n#include \"tnlClientPuzzle.h\"\n\n#ifndef _TNL_NETOBJECT_H_\n#include \"tnlNetObject.h\"\n#endif\n\n#ifndef _TNL_NETCONNECTION_H_\n#include \"tnlNetConnection.h\"\n#endif\n\nnamespace TNL {\n\nclass AsymmetricKey;\nclass Certificate;\nstruct ConnectionParameters;\n\n/// NetInterface class.\n///\n/// Manages all valid and pending notify protocol connections for a port/IP. If you are\n/// providing multiple services or servicing multiple networks, you may have more than\n/// one NetInterface.\n///\n/// Connection handshaking basic overview:\n///\n/// TNL does a two phase connect handshake to prevent a several types of\n/// Denial-of-Service (DoS) attacks.\n///\n/// The initiator of the connection (client) starts the connection by sending\n/// a unique random nonce (number, used once) value to the server as part of\n/// the ConnectChallengeRequest packet.\n/// C->S: ConnectChallengeRequest, Nc\n///\n/// The server responds to the ConnectChallengeRequest with a \"Client Puzzle\"\n/// that has the property that verifying a solution to the puzzle is computationally\n/// simple, but can be of a specified computational, brute-force difficulty to\n/// compute the solution itself. The client puzzle is of the form:\n/// secureHash(Ic, Nc, Ns, X) = Y >> k, where Ic is the identity of the client,\n/// and X is a value computed by the client such that the high k bits of the value\n/// y are all zero. The client identity is computed by the server as a partial hash\n/// of the client's IP address and port and some random data on the server.\n/// its current nonce (Ns), Nc, k, and the server's authentication certificate.\n/// S->C: ConnectChallengeResponse, Nc, Ns, Ic, Cs\n///\n/// The client, upon receipt of the ConnectChallengeResponse, validates the packet\n/// sent by the server and computes a solution to the puzzle the server sent. If\n/// the connection is to be authenticated, the client can also validate the server's\n/// certificate (if it's been signed by a Certificate Authority), and then generates\n/// a shared secret from the client's key pair and the server's public key. The client\n/// response to the server consists of:\n/// C->S: ConnectRequest, Nc, Ns, X, Cc, sharedSecret(key1, sequence1, NetConnectionClass, class-specific sendData)\n///\n/// The server then can validation the solution to the puzzle the client submitted, along\n/// with the client identity (Ic).\n/// Until this point the server has allocated no memory for the client and has\n/// verified that the client is sending from a valid IP address, and that the client\n/// has done some amount of work to prove its willingness to start a connection.\n/// As the server load increases, the server may choose to increase the difficulty (k) of\n/// the client puzzle, thereby making a resource depletion DoS attack successively more\n/// difficult to launch.\n///\n/// If the server accepts the connection, it sends a connect accept packet that is\n/// encrypted and hashed using the shared secret. The contents of the packet are\n/// another sequence number (sequence2) and another key (key2). The sequence numbers \n/// are the initial send and receive sequence numbers for the connection, and the\n/// key2 value becomes the IV of the symmetric cipher. The connection subclass is\n/// also allowed to write any connection specific data into this packet.\n///\n/// This system can operate in one of 3 ways: unencrypted, encrypted key exchange (ECDH),\n/// or encrypted key exchange with server and/or client signed certificates (ECDSA).\n/// \n/// The unencrypted communication mode is NOT secure. Packets en route between hosts\n/// can be modified without detection by the hosts at either end. Connections using\n/// the secure key exchange are still vulnerable to Man-in-the-middle attacks, but still\n/// much more secure than the unencrypted channels. Using certificate(s) signed by a\n/// trusted certificate authority (CA), makes the communications channel as securely\n/// trusted as the trust in the CA.\n///\n/// Arranged Connection handshaking:\n///\n/// NetInterface can also facilitate \"arranged\" connections. Arranged connections are\n/// necessary when both parties to the connection are behind firewalls or NAT routers.\n/// Suppose there are two clients, A and B that want to esablish a direct connection with\n/// one another. If A and B are both logged into some common server S, then S can send\n/// A and B the public (NAT'd) address, as well as the IP addresses each client detects\n/// for itself.\n///\n/// A and B then both send \"Punch\" packets to the known possible addresses of each other.\n/// The punch packet client A sends enables the punch packets client B sends to be \n/// delivered through the router or firewall since it will appear as though it is a service\n/// response to A's initial packet.\n///\n/// Upon receipt of the Punch packet by the \"initiator\"\n/// of the connection, an ArrangedConnectRequest packet is sent.\n/// if the non-initiator of the connection gets an ArrangedPunch\n/// packet, it simply sends another Punch packet to the\n/// remote host, but narrows down its Address range to the address\n/// it received the packet from.\n/// The ArrangedPunch packet from the intiator contains the nonce \n/// for the non-initiator, and the nonce for the initiator encrypted\n/// with the shared secret.\n/// The ArrangedPunch packet for the receiver of the connection\n/// contains all that, plus the public key/keysize or the certificate\n/// of the receiver.\n\n\nclass NetInterface : public Object\n{\n friend class NetConnection;\npublic:\n /// PacketType is encoded as the first byte of each packet.\n ///\n /// Subclasses of NetInterface can add custom, non-connected data\n /// packet types starting at FirstValidInfoPacketId, and overriding \n /// handleInfoPacket to process them.\n ///\n /// Packets that arrive with the high bit of the first byte set\n /// (i.e. the first unsigned byte is greater than 127), are\n /// assumed to be connected protocol packets, and are dispatched to\n /// the appropriate connection for further processing.\n\n enum PacketType\n {\n ConnectChallengeRequest = 0, ///< Initial packet of the two-phase connect process\n ConnectChallengeResponse = 1, ///< Response packet to the ChallengeRequest containing client identity, a client puzzle, and possibly the server's public key.\n ConnectRequest = 2, ///< A connect request packet, including all puzzle solution data and connection initiation data.\n ConnectReject = 3, ///< A packet sent to notify a host that a ConnectRequest was rejected.\n ConnectAccept = 4, ///< A packet sent to notify a host that a connection was accepted.\n Disconnect = 5, ///< A packet sent to notify a host that the specified connection has terminated.\n Punch = 6, ///< A packet sent in order to create a hole in a firewall or NAT so packets from the remote host can be received.\n ArrangedConnectRequest = 7, ///< A connection request for an \"arranged\" connection.\n FirstValidInfoPacketId = 8, ///< The first valid ID for a NetInterface subclass's info packets.\n\t BroadcastMessage = 9, ///< A connection request for an \"arranged\" connection.\n };\n\nprotected:\n Vector mConnectionList; ///< List of all the connections that are in a connected state on this NetInterface.\n Vector mConnectionHashTable; ///< A resizable hash table for all connected connections. This is a flat hash table (no buckets).\n\n Vector mPendingConnections; ///< List of connections that are in the startup state, where the remote host has not fully\n /// validated the connection.\n\n RefPtr mPrivateKey; ///< The private key used by this NetInterface for secure key exchange.\n RefPtr mCertificate; ///< A certificate, signed by some Certificate Authority, to authenticate this host.\n ClientPuzzleManager mPuzzleManager; ///< The object that tracks the current client puzzle difficulty, current puzzle and solutions for this NetInterface.\n\n /// @name NetInterfaceSocket Socket\n ///\n /// State regarding the socket this NetInterface controls.\n ///\n /// @{\n\n ///\n Socket mSocket; ///< Network socket this NetInterface communicates over.\n\n /// @}\n\n U32 mCurrentTime; ///< Current time tracked by this NetInterface.\n bool mRequiresKeyExchange; ///< True if all connections outgoing and incoming require key exchange.\n U32 mLastTimeoutCheckTime; ///< Last time all the active connections were checked for timeouts.\n U8 mRandomHashData[12]; ///< Data that gets hashed with connect challenge requests to prevent connection spoofing.\n bool mAllowConnections; ///< Set if this NetInterface allows connections from remote instances.\n\n /// Structure used to track packets that are delayed in sending for simulating a high-latency connection.\n ///\n /// The DelaySendPacket is allocated as sizeof(DelaySendPacket) + packetSize;\n struct DelaySendPacket\n {\n DelaySendPacket *nextPacket; ///< The next packet in the list of delayed packets.\n Address remoteAddress; ///< The address to send this packet to.\n U32 sendTime; ///< Time when we should send the packet.\n U32 packetSize; ///< Size, in bytes, of the packet data.\n U8 packetData[1]; ///< Packet data.\n };\n DelaySendPacket *mSendPacketList; ///< List of delayed packets pending to send.\n\n enum NetInterfaceConstants {\n ChallengeRetryCount = 4, ///< Number of times to send connect challenge requests before giving up.\n ChallengeRetryTime = 2500, ///< Timeout interval in milliseconds before retrying connect challenge.\n\n ConnectRetryCount = 4, ///< Number of times to send connect requests before giving up.\n ConnectRetryTime = 2500, ///< Timeout interval in milliseconds before retrying connect request.\n\n PunchRetryCount = 6, ///< Number of times to send groups of firewall punch packets before giving up.\n PunchRetryTime = 2500, ///< Timeout interval in milliseconds before retrying punch sends.\n\n TimeoutCheckInterval = 1500, ///< Interval in milliseconds between checking for connection timeouts.\n PuzzleSolutionTimeout = 30000, ///< If the server gives us a puzzle that takes more than 30 seconds, time out.\n };\n\n /// Computes an identity token for the connecting client based on the address of the client and the\n /// client's unique nonce value.\n U32 computeClientIdentityToken(const Address &theAddress, const Nonce &theNonce);\n\n /// Finds a connection instance that this NetInterface has initiated.\n NetConnection *findPendingConnection(const Address &address);\n\n /// Adds a connection the list of pending connections.\n void addPendingConnection(NetConnection *conn);\n\n /// Removes a connection from the list of pending connections.\n void removePendingConnection(NetConnection *conn);\n\n /// Finds a connection by address from the pending list and removes it.\n void findAndRemovePendingConnection(const Address &address);\n\n /// Adds a connection to the internal connection list.\n void addConnection(NetConnection *connection);\n\n /// Remove a connection from the list.\n void removeConnection(NetConnection *connection);\n\n /// Begins the connection handshaking process for a connection. Called from NetConnection::connect()\n void startConnection(NetConnection *conn);\n\n /// Sends a connect challenge request on behalf of the connection to the remote host.\n void sendConnectChallengeRequest(NetConnection *conn);\n\n /// Handles a connect challenge request by replying to the requestor of a connection with a\n /// unique token for that connection, as well as (possibly) a client puzzle (for DoS prevention),\n /// or this NetInterface's public key.\n void handleConnectChallengeRequest(const Address &addr, BitStream *stream);\n\n /// Sends a connect challenge request to the specified address. This can happen as a result\n /// of receiving a connect challenge request, or during an \"arranged\" connection for the non-initiator\n /// of the connection.\n void sendConnectChallengeResponse(const Address &addr, Nonce &clientNonce, bool wantsKeyExchange, bool wantsCertificate);\n\n /// Processes a ConnectChallengeResponse, by issueing a connect request if it was for\n /// a connection this NetInterface has pending.\n void handleConnectChallengeResponse(const Address &address, BitStream *stream);\n\n /// Continues computation of the solution of a client puzzle, and issues a connect request\n /// when the solution is found.\n void continuePuzzleSolution(NetConnection *conn);\n\n /// Sends a connect request on behalf of a pending connection.\n void sendConnectRequest(NetConnection *conn);\n\n /// Handles a connection request from a remote host.\n ///\n /// This will verify the validity of the connection token, as well as any solution\n /// to a client puzzle this NetInterface sent to the remote host. If those tests\n /// pass, it will construct a local connection instance to handle the rest of the\n /// connection negotiation.\n void handleConnectRequest(const Address &address, BitStream *stream);\n\n /// Sends a connect accept packet to acknowledge the successful acceptance of a connect request.\n void sendConnectAccept(NetConnection *conn);\n\n /// Handles a connect accept packet, putting the connection associated with the\n /// remote host (if there is one) into an active state.\n void handleConnectAccept(const Address &address, BitStream *stream);\n\n /// Sends a connect rejection to a valid connect request in response to possible error\n /// conditions (server full, wrong password, etc).\n void sendConnectReject(ConnectionParameters *theParams, const Address &theAddress, const char *reason);\n\n /// Handles a connect rejection packet by notifying the connection object\n /// that the connection was rejected.\n void handleConnectReject(const Address &address, BitStream *stream);\n\n /// Begins the connection handshaking process for an arranged connection.\n void startArrangedConnection(NetConnection *conn);\n\n /// Sends Punch packets to each address in the possible connection address list.\n void sendPunchPackets(NetConnection *conn);\n\n /// Handles an incoming Punch packet from a remote host.\n void handlePunch(const Address &theAddress, BitStream *stream);\n\n /// Sends an arranged connect request.\n void sendArrangedConnectRequest(NetConnection *conn);\n\n /// Handles an incoming connect request from an arranged connection.\n void handleArrangedConnectRequest(const Address &theAddress, BitStream *stream);\n\n /// Handles an incoming connect request from an arranged connection.\n void handleBroadcastMessage(const Address &theAddress, BitStream *stream);\n \n /// Dispatches a disconnect packet for a specified connection.\n void handleDisconnect(const Address &address, BitStream *stream);\n\n /// Handles an error reported while reading a packet from this remote connection.\n void handleConnectionError(NetConnection *theConnection, const char *errorString);\n\n /// Disconnects the given connection and removes it from the NetInterface\n void disconnect(NetConnection *conn, NetConnection::TerminationReason reason, const char *reasonString);\n /// @}\npublic:\n /// @param bindAddress Local network address to bind this interface to.\n NetInterface(const Address &bindAddress);\n ~NetInterface();\n\n /// Returns the address of the first network interface in the list that the socket on this NetInterface is bound to.\n Address getFirstBoundInterfaceAddress();\n\n /// Sets the private key this NetInterface will use for authentication and key exchange\n void setPrivateKey(AsymmetricKey *theKey);\n\n /// Requires that all connections use encryption and key exchange\n void setRequiresKeyExchange(bool requires) { mRequiresKeyExchange = requires; }\n\n /// Sets the public certificate that validates the private key and stores\n /// information about this host. If no certificate is set, this interface can\n /// still initiate and accept encrypted connections, but they will be vulnerable to\n /// man in the middle attacks, unless the remote host can validate the public key\n /// in another way.\n void setCertificate(Certificate *theCertificate);\n\n /// Returns whether or not this NetInterface allows connections from remote hosts.\n bool doesAllowConnections() { return mAllowConnections; }\n\n /// Sets whether or not this NetInterface allows connections from remote hosts.\n void setAllowsConnections(bool conn) { mAllowConnections = conn; }\n\n /// Returns the Socket associated with this NetInterface\n Socket &getSocket() { return mSocket; }\n\n /// Sends a packet to the remote address over this interface's socket.\n NetError sendto(const Address &address, BitStream *stream);\n\n /// Sends a packet to the remote address after millisecondDelay time has elapsed.\n ///\n /// This is used to simulate network latency on a LAN or single computer.\n void sendtoDelayed(const Address &address, BitStream *stream, U32 millisecondDelay);\n\n /// Dispatch function for processing all network packets through this NetInterface.\n void checkIncomingPackets();\n\n /// Processes a single packet, and dispatches either to handleInfoPacket or to\n /// the NetConnection associated with the remote address.\n virtual void processPacket(const Address &address, BitStream *packetStream);\n\n /// Handles all packets that don't fall into the category of connection handshake or game data.\n virtual void handleInfoPacket(const Address &address, U8 packetType, BitStream *stream);\n\n /// Checks all connections on this interface for packet sends, and for timeouts and all valid\n /// and pending connections.\n void processConnections();\n\n /// Returns the list of connections on this NetInterface.\n Vector &getConnectionList() { return mConnectionList; }\n\n /// looks up a connected connection on this NetInterface\n NetConnection *findConnection(const Address &remoteAddress);\n\n /// returns the current process time for this NetInterface\n U32 getCurrentTime() { return mCurrentTime; }\n};\n\n};\n\n#endif\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetTime2Decl();\r\nCKERROR CreateGetTime2Proto(CKBehaviorPrototype **pproto);\r\nint GetTime2(const CKBehaviorContext& behcontext);\r\n\r\n/************************************************************************/\r\n/* */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetTime2Decl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"GetTime\");\t\r\n\tod->SetDescription(\"Logics/Tools\");\r\n\tod->SetCategory(\"a\");\r\n\t\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x33ce78ad,0x6e4a5d37));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetTime2Proto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGetTime2Proto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"GetTime\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Create Zip File\");\r\n\r\n\tproto->DeclareOutput(\"Zip File created\");\r\n\t\r\n\t\r\n\tproto->DeclareOutParameter(\"Hour\", CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Minutes\", CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"Seconds\", CKPGUID_INT);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(GetTime2);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint GetTime2(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\t\r\n\t\r\n\t//int hour,minute,second;\r\n\t//SYSTEMTIME lpSystemTime;\r\n\t/*\r\n\tGetSystemTime( &lpSystemTime );\r\n\t\r\n\thour = lpSystemTime.wHour;\r\n\tminute = lpSystemTime.wMinute;\r\n\tsecond = lpSystemTime.wSecond;\r\n\tbeh->SetOutputParameterValue(0,&hour);\r\n\tbeh->SetOutputParameterValue(1,&minute);\r\n\tbeh->SetOutputParameterValue(2,&second);\r\n\tbeh->ActivateOutput(0);\r\n*/\r\n\treturn 0;\r\n\t\r\n}\r\n\r\n\r\npFactory pf = getPFactory();\r\n\r\npObjectDescr descr;\r\n\r\ndescr.flags = BF_Moving + BF_Gravity + BF_Collision;\r\ndescr.density = 1.0f;\r\ndescr.hullType = HT_Box;\r\ndescr.shapeOffset = pivotOffset;\r\n\r\n pRigidBody body = pf.createBody(entity,descr);\r\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\n#include \"ISession.h\"\r\n#include \"IMessages.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xMessageTypes.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNMSendDecl();\r\nCKERROR CreateNMSendProto(CKBehaviorPrototype **);\r\nint NMSend(const CKBehaviorContext& behcontext);\r\nCKERROR NMSendCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 0\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_CONNECTION_ID,\r\n\tBB_IP_MESSAGE,\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_ERROR,\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_ERROR,\r\n};\r\n\r\nCKObjectDeclaration\t*FillBehaviorNMSendDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NMSend\");\t\r\n\tod->SetDescription(\"Sends a message over network\");\r\n\t\r\n\tod->SetCategory(\"TNL/Message\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x51a072f,0x6aec1386));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNMSendProto);\r\n\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateNMSendProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NMSend\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\t\r\n\tproto->DeclareInParameter(\"Message\", CKPGUID_MESSAGE, \"OnClick\");\r\n\tproto->DeclareInParameter(\"Target User ID\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR);\r\n\tproto->DeclareSetting(\"Ignore Session Master\", CKPGUID_BOOL, \"FALSE\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)( CKBEHAVIOR_VARIABLEPARAMETERINPUTS ));\r\n\tproto->SetFunction(NMSend);\r\n\tproto->SetBehaviorCallbackFct(NMSendCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NMSend(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tbbNoError(E_NWE_OK);\r\n\tbeh->ActivateInput(0,FALSE);\r\n\r\n\tint Msg=-1;\r\n\tbeh->GetInputParameterValue(0,&Msg);\r\n\tXString msgType(mm->GetMessageTypeName(Msg));\r\n\txNString mName = msgType.CStr();\r\n\t\r\n\tint targetID=0;\r\n\tbeh->GetInputParameterValue(1,&targetID);\r\n\r\n\t\r\n\tint ignoreSessionMaster = 0;\r\n\tbeh->GetLocalParameterValue(0,&ignoreSessionMaster);\r\n\t\r\n\tbbNoError(E_NWE_OK);\r\n\r\n\t//network ok ? \r\n\txNetInterface *cin = GetNM()->GetClientNetInterface();\r\n\tif (!cin)\r\n\t{\r\n\t\tbbError(E_NWE_NO_CONNECTION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!cin->getMyClient())\r\n\t{\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tISession *sInterface = cin->getSessionInterface();\r\n\tIMessages *mInterface = cin->getMessagesInterface();\r\n\r\n\r\n\txDistributedClient *myClient = cin->getMyClient();\r\n\tif (!myClient)\r\n\t{\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\txDistributedSession *session = sInterface->get(myClient->getSessionID());\r\n\tif (!session)\r\n\t{\r\n\t\tbbError(E_NWE_NO_SUCH_SESSION);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif (!isFlagOn(myClient->getClientFlags(),E_CF_SESSION_JOINED))\r\n\t{\t\r\n\t\tbbError(E_NWE_NO_SESSION);\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tif (session->getUserID() == myClient->getUserID() && session->getNumUsers()==1 )\r\n\t{\r\n\t\tbbError(E_NWE_INTERN);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tint bcount = beh->GetInputParameterCount();\r\n\tint srcId = cin->getConnection()->getUserID();\r\n\r\n\txMessage *msg = new xMessage();\r\n\tmsg->setName(mName);\r\n\tmsg->setSrcUser( myClient->getServerID() );\r\n\tmsg->setIgnoreSessionMaster(ignoreSessionMaster);\r\n\tmsg->setDstUser(targetID);\r\n\r\n\tif (targetID !=-1)\r\n\t{\r\n\t\tIDistributedObjects *doInterface = cin->getDistObjectInterface();\r\n\t\txDistributedClient *dstClient = static_cast(doInterface->getByUserID(targetID,E_DC_BTYPE_CLIENT));\r\n\t\tif (dstClient)\r\n\t\t{\r\n\t\t\tif (dstClient->getUserID() == myClient->getUserID())\r\n\t\t\t{\r\n\t\t\t\tbbError(E_NWE_INTERN);\r\n\t\t\t\tdelete msg;\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\r\n\t\t\tmsg->setDstUser(dstClient->getUserID());\r\n\r\n\r\n\t\t}else{\r\n\t\t\tbbError(E_NWE_NO_SUCH_USER);\r\n\t\t\tdelete msg;\r\n\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\t\r\n\tfor (int i = BEH_IN_INDEX_MIN_COUNT ; i < beh->GetInputParameterCount() ; i++ )\r\n\t{\r\n\r\n\t\tCKParameterIn *ciIn = beh->GetInputParameter(i);\r\n\t\tCKParameterType pType = ciIn->GetType();\r\n\t\tint sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));\t\r\n\t\tconst char *pname = pam->ParameterTypeToName(pType);\r\n\t\t\r\n\t\txDistributedPropertyInfo *dInfo = new xDistributedPropertyInfo( ciIn->GetName() , xDistTools::SuperTypeToValueType(sType) , -1 ,E_PTYPE_RELIABLE);\r\n\r\n\r\n\t\tswitch (sType)\r\n\t\t{\r\n\t\tcase vtSTRING:\r\n\t\t\t{\r\n\t\t\t\tCKParameter *pin = beh->GetInputParameter(i)->GetRealSource();\r\n\t\t\t\tif (pin)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedString *prop = new xDistributedString(dInfo,30,3000);\r\n\t\t\t\t\tVxScratch sbuffer(256);\r\n\t\t\t\t\tCKSTRING buffer = (CKSTRING)sbuffer.Mem();\r\n\t\t\t\t\tpin->GetStringValue(buffer);\r\n\t\t\t\t\tprop->updateValue(TNL::StringPtr(buffer),0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtFLOAT:\r\n\t\t\t{\r\n\t\t\t\txDistributedPoint1F * prop = new xDistributedPoint1F(dInfo,30,3000);\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\t\t\t\t\tfloat vvalue;\r\n\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\tbool update = prop->updateValue(vvalue,0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtINTEGER:\r\n\t\t\t{\r\n\r\n\t\t\t\txDistributedInteger * prop = new xDistributedInteger(dInfo,30,3000);\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\t\t\t\t\tint vvalue;\r\n\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\tbool update = prop->updateValue(vvalue,0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtVECTOR:\r\n\t\t\t{\r\n\r\n\t\t\t\txDistributedPoint3F * prop = new xDistributedPoint3F(dInfo,30,3000);\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\t\t\t\t\tVxVector vvalue;\r\n\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\tbool update = prop->updateValue(xMath::getFrom(vvalue),0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtVECTOR2D:\r\n\t\t\t{\r\n\r\n\t\t\t\txDistributedPoint2F * prop = new xDistributedPoint2F(dInfo,30,3000);\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\t\t\t\t\tVx2DVector vvalue;\r\n\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\tbool update = prop->updateValue(xMath::getFrom(vvalue),0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtQUATERNION:\r\n\t\t\t{\r\n\t\t\t\txDistributedQuatF * prop = new xDistributedQuatF(dInfo,30,3000);\r\n\t\t\t\tif (prop)\r\n\t\t\t\t{\r\n\t\t\t\t\tVxQuaternion vvalue;\r\n\t\t\t\t\tbeh->GetInputParameterValue(i,&vvalue);\r\n\t\t\t\t\tbool update = prop->updateValue(xMath::getFrom(vvalue),0);\r\n\t\t\t\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\t\tprop->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tcase vtUNKNOWN:\r\n\t\t\t{\r\n\t\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tdefault :\r\n\t\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\t\treturn CKBR_BEHAVIORERROR;\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\r\n\tenableFlag(msg->getFlags(),E_MF_OUTGOING);\r\n\r\n\tmInterface->addMessage(msg);\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR NMSendCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_TYPES_H_\n#define _TNL_TYPES_H_\n\n\n//--------------------------------------\n// Enable Asserts in all debug builds\n#if defined(TNL_DEBUG)\n#ifndef TNL_ENABLE_ASSERTS\n#define TNL_ENABLE_ASSERTS\n#endif\n#endif\n#include \n//inline void* operator new(size_t size, void* ptr) { return ptr; }\n#include \nnamespace TNL {\n\n#ifndef NULL\n# define NULL 0\n#endif\n\n\n//------------------------------------------------------------------------------\n//-------------------------------------- Basic Types...\n\n/// @defgroup BasicTypes Basic Compiler Independent Types\n/// These types are defined so that we know exactly what we have, sign and bit wise.\n///\n/// The number represents number of bits, the letters represent Signed,\n/// Unsigned, or Floating point (implicitly signed).\n/// @{\n\ntypedef signed char S8; ///< Compiler independent signed char (8bit integer).\ntypedef unsigned char U8; ///< Compiler independent unsigned char (8bit integer).\n\ntypedef signed short S16; ///< Compiler independent signed 16-bit short integer.\ntypedef unsigned short U16; ///< Compiler independent unsigned 16-bit short integer.\n\ntypedef signed int S32; ///< Compiler independent signed 32-bit integer.\ntypedef unsigned int U32; ///< Compiler independent unsigned 32-bit integer.\n\ntypedef float F32; ///< Compiler independent 32-bit float.\ntypedef double F64; ///< Compiler independent 64-bit float.\n\n/// @}\n\n/// NetType serves as a base class for all bit-compressed versions of\n/// the base types that can be transmitted using TNL's RPC mechanism.\n/// In general, the type names are self-explanatory, providing simple\n/// wrappers on the original base types. The template argument for bit\n/// counts or numeric ranges is necessary because TNL parses the actual\n/// function prototype as a string in order to determine how many bits\n/// to use for each RPC parameter.\n///\n/// Template parameters to the NetType templates can be either integer\n/// constants or enumeration values. If enumeration values are used,\n/// the TNL_DECLARE_RPC_ENUM or TNL_DECLARE_RPC_MEM enum macros must\n/// be used to register the enumerations with the RPC system.\nstruct NetType {\n\n};\n\n/// Unsigned integer bit-level RPC template wrapper.\n///\n/// When an Int is in the parameter list for an RPC method, that parameter will\n/// be transmitted using X bits.\ntemplate struct Int : NetType\n{\n U32 value;\n Int(U32 val=0) { value = val; }\n operator U32() const { return value; }\n U32 getPrecisionBits() { return bitCount; }\n};\n\n/// Signed integer bit-level RPC template wrapper.\n///\n/// When a SignedInt is in the parameter list for an RPC method, that parameter will\n/// be transmitted using X bits.\ntemplate struct SignedInt : NetType\n{\n S32 value;\n SignedInt(S32 val=0) { value = val; }\n operator S32() const { return value; }\n U32 getPrecisionBits() { return bitCount; }\n};\n\n/// Floating point 0...1 value bit-level RPC template wrapper.\n///\n/// When a Float is in the parameter list for an RPC method, that parameter will\n/// be transmitted using X bits.\ntemplate struct Float : NetType\n{\n F32 value;\n Float(F32 val=0) { value = val; }\n operator F32() const { return value; }\n U32 getPrecisionBits() { return bitCount; }\n};\n\n/// Floating point -1...1 value bit-level RPC template wrapper.\n///\n/// When a SignedFloat is in the parameter list for an RPC method, that parameter will\n/// be transmitted using X bits.\ntemplate struct SignedFloat : NetType\n{\n F32 value;\n SignedFloat(F32 val=0) { value = val; }\n operator F32() const { return value; }\n U32 getPrecisionBits() { return bitCount; }\n};\n\n/// Unsigned ranged integer bit-level RPC template wrapper.\n///\n/// The RangedU32 is used to specify a range of valid values for the parameter\n/// in the parameter list for an RPC method.\ntemplate struct RangedU32 : NetType\n{\n U32 value;\n RangedU32(U32 val=rangeStart) { value = val; }\n operator U32() const { return value; }\n};\n\n//------------------------------------------------------------------------------\n//-------------------------------------- Type constants...\n\n/// @defgroup BasicConstants Global Constants\n///\n/// Handy constants!\n/// @{\n\n#define __EQUAL_CONST_F F32(0.000001) ///< Constant float epsilon used for F32 comparisons\n\nstatic const F32 FloatOne = F32(1.0); ///< Constant float 1.0\nstatic const F32 FloatHalf = F32(0.5); ///< Constant float 0.5\nstatic const F32 FloatZero = F32(0.0); ///< Constant float 0.0\n\nstatic const F32 FloatPi = F32(3.14159265358979323846); ///< Constant float PI\nstatic const F32 Float2Pi = F32(2.0 * 3.14159265358979323846); ///< Constant float 2*PI\nstatic const F32 FloatInversePi = F32(1.0 / 3.14159265358979323846); ///< Constant float 1 / PI\nstatic const F32 FloatHalfPi = F32(0.5 * 3.14159265358979323846); ///< Constant float 1/2 * PI\nstatic const F32 Float2InversePi = F32(2.0 / 3.14159265358979323846);///< Constant float 2 / PI\nstatic const F32 FloatInverse2Pi = F32(0.5 / 3.14159265358979323846);///< Constant float 2 / PI\n\nstatic const F32 FloatSqrt2 = F32(1.41421356237309504880f); ///< Constant float sqrt(2)\nstatic const F32 FloatSqrtHalf = F32(0.7071067811865475244008443f); ///< Constant float sqrt(0.5)\n\nstatic const S8 S8_MIN = S8(-128); ///< Constant Min Limit S8\nstatic const S8 S8_MAX = S8(127); ///< Constant Max Limit S8\nstatic const U8 U8_MAX = U8(255); ///< Constant Max Limit U8\n\nstatic const S16 S16_MIN = S16(-32768); ///< Constant Min Limit S16\nstatic const S16 S16_MAX = S16(32767); ///< Constant Max Limit S16\nstatic const U16 U16_MAX = U16(65535); ///< Constant Max Limit U16\n\nstatic const S32 S32_MIN = S32(-2147483647 - 1); ///< Constant Min Limit S32\nstatic const S32 S32_MAX = S32(2147483647); ///< Constant Max Limit S32\nstatic const U32 U32_MAX = U32(0xffffffff); ///< Constant Max Limit U32\n\nstatic const F32 F32_MIN = F32(1.175494351e-38F); ///< Constant Min Limit F32\nstatic const F32 F32_MAX = F32(3.402823466e+38F); ///< Constant Max Limit F32\n\n//----------------------------------------------------------------------------------\n// Identify the compiler and OS specific stuff we need:\n//----------------------------------------------------------------------------------\n\n#if defined (_MSC_VER)\n\ntypedef signed _int64 S64;\ntypedef unsigned _int64 U64;\n\n#ifndef TNL_COMPILER_VISUALC\r\n\t#define TNL_COMPILER_VISUALC _MSC_VER\r\n#endif\n\n\n#if _MSC_VER < 1200\n // No support for old compilers\n# error \"VC: Minimum Visual C++ 6.0 or newer required\"\n#else //_MSC_VER >= 1200\n# define TNL_COMPILER_STRING \"VisualC++\"\n#endif\n\n#define for if(false) {} else for ///< Hack to work around Microsoft VC's non-C++ compliance on variable scoping\n\n// disable warning caused by memory layer\n// see msdn.microsoft.com \"Compiler Warning (level 1) C4291\" for more details\n#pragma warning(disable: 4291)\n// disable performance warning of integer to bool conversions\n#pragma warning(disable: 4800)\n\n#elif defined(__MWERKS__) && defined(_WIN32)\n\ntypedef signed long long S64; ///< Compiler independent signed 64-bit integer\ntypedef unsigned long long U64; ///< Compiler independent unsigned 64-bit integer\n\n#define TNL_COMPILER_STRING \"Metrowerks CW Win32\"\n\n#elif defined(__GNUC__)\n\ntypedef signed long long S64; ///< Compiler independent signed 64-bit integer\ntypedef unsigned long long U64; ///< Compiler independent unsigned 64-bit integer\n\n#if defined(__MINGW32__)\n# define TNL_COMPILER_STRING \"GCC (MinGW)\"\n# define TNL_COMPILER_MINGW\n#elif defined(__CYGWIN__)\n# define TNL_COMPILER_STRING \"GCC (Cygwin)\"\n# define TNL_COMPILER_MINGW\n#else\n# define TNL_COMPILER_STRING \"GCC \"\n#endif\n\n#else\n# error \"TNL: Unknown Compiler\"\n#endif\n\n//----------------------------------------------------------------------------------\n// Identify the target Operating System\n//----------------------------------------------------------------------------------\n\n#if defined (_XBOX) || defined(__XBOX__)\n# define TNL_OS_STRING \"XBox\"\n# define TNL_OS_XBOX\n# define FN_CDECL __cdecl\n\n#elif defined(__WIN32__) || defined(_WIN32) || defined(__CYGWIN__)\n# define TNL_OS_STRING \"Win32\"\n# define TNL_OS_WIN32\n\n#ifdef TNL_COMPILER_MINGW\n# define FN_CDECL\n#else\n# define FN_CDECL __cdecl\n#endif\n\n#elif defined(linux)\n# define TNL_OS_STRING \"Linux\"\n# define TNL_OS_LINUX\n# define FN_CDECL\n\n#elif defined(__OpenBSD__)\n# define TNL_OS_STRING \"OpenBSD\"\n# define TNL_OS_OPENBSD\n# define FN_CDECL\n\n#elif defined(__FreeBSD__)\n# define TNL_OS_STRING \"FreeBSD\"\n# define TNL_OS_FREEBSD\n# define FN_CDECL\n\n#elif defined(__APPLE__)\n# define TNL_OS_MAC\n# define TNL_OS_MAC_OSX\n# define FN_CDECL\n\n#else\n# error \"TNL: Unsupported Operating System\"\n#endif\n\n\n\n//----------------------------------------------------------------------------------\n// Identify the target CPU and assembly language options\n//----------------------------------------------------------------------------------\n\n#if defined(_M_IX86) || defined(i386)\n# define TNL_CPU_STRING \"Intel x86\"\n# define TNL_CPU_X86\n# define TNL_LITTLE_ENDIAN\n# define TNL_SUPPORTS_NASM\n\n# if defined (__GNUC__)\n# if __GNUC__ == 2\n# define TNL_GCC_2\n# elif __GNUC__ == 3\n# define TNL_GCC_3\n# else\n# error \"TNL: Unsupported version of GCC (see tnlMethodDispatch.cpp)\"\n# endif\n# define TNL_SUPPORTS_GCC_INLINE_X86_ASM\n# elif defined (__MWERKS__)\n# define TNL_SUPPORTS_MWERKS_INLINE_X86_ASM\n# else\n# define TNL_SUPPORTS_VC_INLINE_X86_ASM\n# endif\n\n#elif defined(__ppc__)\n# define TNL_CPU_STRING \"PowerPC\"\n# define TNL_CPU_PPC\n# define TNL_BIG_ENDIAN\n# ifdef __GNUC__\n# define TNL_SUPPORTS_GCC_INLINE_PPC_ASM\n# endif\n#else\n# error \"TNL: Unsupported Target CPU\"\n#endif\n\n\n/// @}\n\n///@defgroup ObjTrickery Object Management Trickery\n///\n/// These functions are to construct and destruct objects in memory\n/// without causing a free or malloc call to occur. This is so that\n/// we don't have to worry about allocating, say, space for a hundred\n/// NetAddresses with a single malloc call, calling delete on a single\n/// NetAdress, and having it try to free memory out from under us.\n///\n/// @{\n\n/// Constructs an object that already has memory allocated for it.\ntemplate \ninline T* constructInPlace(T* p)\n{\n return new(p) T;\n}\n\n/// Copy constructs an object that already has memory allocated for it.\ntemplate \ninline T* constructInPlace(T* p, const T* copy)\n{\n return new(p) T(*copy);\n}\n\n/// Destructs an object without freeing the memory associated with it.\ntemplate \ninline void destructInPlace(T* p)\n{\n p->~T();\n}\n\n/// @}\n\n/// @name GeneralMath Math Helpers\n///\n/// Some general numeric utility functions.\n///\n/// @{\n\n/// Determines if number is a power of two.\ninline bool isPow2(const U32 number)\n{\n return (number & (number - 1)) == 0;\n}\n\n/// Determines the binary logarithm of the input value rounded down to the nearest power of 2.\ninline U32 getBinLog2(U32 value)\n{\n F32 floatValue = F32(value);\n return (*((U32 *) &floatValue) >> 23) - 127;\n}\n\n/// Determines the binary logarithm of the next greater power of two of the input number.\ninline U32 getNextBinLog2(U32 number)\n{\n return getBinLog2(number) + (isPow2(number) ? 0 : 1);\n}\n\n/// Determines the next greater power of two from the value. If the value is a power of two, it is returned.\ninline U32 getNextPow2(U32 value)\n{\n return isPow2(value) ? value : (1 << (getBinLog2(value) + 1));\n}\n\n\n/// @defgroup MinMaxFuncs Many version of min and max\n///\n/// We can't use template functions because MSVC6 chokes.\n///\n/// So we have these...\n/// @{\n\n#define DeclareTemplatizedMinMax(type) \\\n inline type getMin(type a, type b) { return a > b ? b : a; } \\\n inline type getMax(type a, type b) { return a > b ? a : b; }\n\nDeclareTemplatizedMinMax(U32)\nDeclareTemplatizedMinMax(S32)\nDeclareTemplatizedMinMax(U16)\nDeclareTemplatizedMinMax(S16)\nDeclareTemplatizedMinMax(U8)\nDeclareTemplatizedMinMax(S8)\nDeclareTemplatizedMinMax(F32)\nDeclareTemplatizedMinMax(F64)\n\n/// @}\n\ninline void writeU32ToBuffer(U32 value, U8 *buffer)\n{\n buffer[0] = value >> 24;\n buffer[1] = value >> 16;\n buffer[2] = value >> 8;\n buffer[3] = value;\n}\n\ninline U32 readU32FromBuffer(const U8 *buf)\n{\n return (U32(buf[0]) << 24) |\n (U32(buf[1]) << 16) |\n (U32(buf[2]) << 8 ) |\n U32(buf[3]);\n}\n\ninline void writeU16ToBuffer(U16 value, U8 *buffer)\n{\n buffer[0] = value >> 8;\n buffer[1] = (U8) value;\n}\n\ninline U16 readU16FromBuffer(const U8 *buffer)\n{\n return (U16(buffer[0]) << 8) |\n U16(buffer[1]);\n}\n\ninline U32 fourByteAlign(U32 value)\n{\n return (value + 3) & ~3;\n}\n\n#define BIT(x) (1 << (x)) ///< Returns value with bit x set (2^x)\n\n};\n\n#endif //_TNL_TYPES_H_\n#ifndef __XNETWORKSETTINGS_H\r\n#define __XNETWORKSETTINGS_H\r\n\r\n#include \"precomp.h\"\r\n\r\nstruct xNetworkSettings\r\n{\r\n\r\n\tXString name;\r\n\tint port;\r\n\tbool isServer;\r\n\tTNL::Address bindAddress;\r\n\tTNL::Address pingAddr;\r\n\r\n};\r\n\r\n#endif\r\n#ifndef __VT_X_ALL_H__\r\n#define __VT_X_ALL_H__\r\n\r\n/********************************************************************\r\n\tcreated:\t2008/12/05\r\n\tcreated:\t5:12:2008 0:34\r\n\tfilename: \tx:\\ProjectRoot\\localSVN\\usr\\include\\vtXAll.h\r\n\tfile path:\tx:\\ProjectRoot\\localSVN\\usr\\include\r\n\tfile base:\tvtXAll\r\n\tfile ext:\th\r\n\tauthor:\t\tmc007\r\n\t\r\n\tpurpose:\tcollective header file, includes all generic vt helper classes \r\n*********************************************************************/\r\n\r\n\r\n#include \r\n\r\n//#include \r\n//#include \r\n\r\nusing namespace vtTools;\r\nusing namespace BehaviorTools;\r\n\r\n//#include \r\n\r\n#include \"vtLogTools.h\"\r\n#include \"vtStructHelper.h\"\r\n\r\n/*\r\n#define VTD_PREFIX #include \r\n#include \"vtPhysXAll.h\"\r\n\r\nvoid pVehicleGearDesc::setToCorvette() {\r\n\r\n\tforwardGearRatios[0] = 1.66f;\r\n\tforwardGearRatios[1] = 1.78f;\r\n\tforwardGearRatios[2] = 1.30f;\r\n\tforwardGearRatios[3] = 1;\r\n\tforwardGearRatios[4] = 0.74f;\r\n\tforwardGearRatios[5] = 0.50f;\r\n\tnbForwardGears = 6;\r\n\r\n\tbackwardGearRatio = -2.90f;\r\n\r\n}\r\n\r\n\r\nvoid pVehicleGearDesc::setToDefault() \r\n{\r\n\t//forwardGears.clear();\r\n}\r\n\r\nbool pVehicleGearDesc::isValid() const \r\n{\r\n\tif (nbForwardGears > getMaxNumOfGears()) {\r\n\t\tfprintf(stderr, \"NxVehicleGearDesc::isValid(): nbForwardGears(%d) is bigger than max (%d)\\n\",\r\n\t\t\tnbForwardGears, getMaxNumOfGears());\r\n\t\treturn false;\r\n\t}\r\n\tif (nbForwardGears <= 0) {\r\n\t\tfprintf(stderr, \"NxVehicleGearDesc::isValid(): nbForwardGears(%d) smaller or equal 0\\n\", nbForwardGears);\r\n\t\treturn false;\r\n\t}\r\n\tif (backwardGearRatio > 0) {\r\n\t\tfprintf(stderr, \"NxVehilceGearDesc::isValid(): backwardGearRatio(%2.3f) is bigger than 0, make it negative\\n\", backwardGearRatio);\r\n\t\treturn false;\r\n\t}\r\n\tfor (int i = 0; i < nbForwardGears; i++) \r\n\t{\r\n\t\tif (forwardGearRatios[i] < 0) \r\n\t\t{\r\n\t\t\tfprintf(stderr, \"NxVehilceGearDesc::isValid(): forwardGearRatios[%d] (%2.3f) has value smaller 0\\n\", i, forwardGearRatios[i]);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n}\r\n\r\n\r\nfloat pVehicleGears::getCurrentRatio() const {\r\n\treturn getRatio(_curGear);\r\n}\r\n\r\nfloat pVehicleGears::getRatio(NxI32 gear) const {\r\n\tif (gear > 0)\r\n\t\treturn _forwardGearRatios[gear-1];\r\n\t\t//return _forwardGears[gear-1];\r\n\tif (gear == -1)\r\n\t\treturn _backwardGearRatio;\r\n\treturn 0;\r\n}\r\n\r\n#ifndef __VC_WARNINGS_H__\r\n#define __VC_WARNINGS_H__\r\n\r\n#pragma warning( disable : 4311 )\r\n#pragma warning( disable : 4244 )\r\n#pragma warning( disable : 4267 )\r\n#pragma warning( disable : 4275 )\r\n#pragma warning( disable : 4311)\r\n#pragma warning( disable : 4099)\r\n#pragma warning( disable : 4996)\r\n\r\n\r\n#endif\r\n#include \"IMessages.h\"\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n#include \"xMessageTypes.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n\r\nint msgIDCounter=0;\r\n/*\r\n{\r\n\tif (getThresoldTicker() < getMinSendTime())\r\n\t{\r\n\t\tTNL::logprintf(\"flood detected : %f\",getThresoldTicker());\r\n\t\treturn;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\txMessage*currentMessage = myClient->getCurrentMessage();\r\n\tif (currentMessage)\r\n\t{\r\n\t\tif (isFlagOn(currentMessage->getFlags(),E_MF_SENT))\r\n\t\t{\r\n\t\t\t//xLogger::xLog(XL_START,ELOGINFO,E_LI_MESSAGES,\"message was sent by client,removing\");\r\n\t\t\tenableFlag(currentMessage->getFlags(),E_MF_DELETED);\r\n\t\t\tcurrentMessage =NULL;\r\n\t\t\tmyClient->setCurrentOutMessage(NULL);\r\n\t\t\t// \t\t\tenableFlag(myClient->getClientFlags(),E_CF_NM_SENT);\r\n\t\t\t// \t\t\tdisableFlag(myClient->getClientFlags(),E_CF_NM_SENDING);\r\n\t\t\t// \t\t\tsetThresoldTicker(getMinSendTime() + 10.0f);\r\n\t\t}\r\n\t}\r\n\r\n\txMessage *mOut = getNextOutMessage();\r\n\tif (mOut ==NULL)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tTNL::logprintf(\"msg :ticker time : %f\",getThresoldTicker());\r\n\r\n\tif (isFlagOn(myClient->getClientFlags(),E_CF_NM_SENDING))\r\n\t{\r\n\t\t//xLogger::xLog(XL_START,ELOGWARNING,E_LI_MESSAGES,\"busy!\");\r\n\t\treturn;\r\n\t}else\r\n\t{\r\n\t\tsetThresoldTicker(0.0f);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\tenableFlag(mOut->getFlags(),E_MF_SENDING);\r\n\tenableFlag(myClient->getClientFlags(),E_CF_NM_SENDING);\r\n\tif (mOut->getDstUser()==-1)\r\n\t{\r\n\t\tenableFlag(mOut->getFlags(),E_MF_SEND_TO_ALL);\r\n\t}\r\n\r\n\tmyClient->setCurrentOutMessage(mOut);\r\n\r\n}*/\r\nvoid\r\nIMessages::writeToStream(xMessage *msg,TNL::BitStream *bstream,TNL::BitSet32 flags)\r\n{\r\n\r\n\tbstream->writeRangedU32(msg->getParameters().size(),0,16);\r\n\tbstream->writeString(msg->getName().getString(),strlen(msg->getName().getString()));\r\n\t\r\n\tif (isFlagOn(flags,E_MWF_SEND_SRC_USER_ID))\r\n\t{\r\n\t\tbstream->writeInt(msg->getSrcUser(), GhostConnection::GhostIdBitSize);\r\n\t}\r\n\r\n\r\n\tbstream->writeFlag(isFlagOn(msg->getFlags(),E_MF_SEND_TO_ALL));\r\n\tbstream->writeFlag(msg->getIgnoreSessionMaster());\r\n\r\n\tif (!isFlagOn(msg->getFlags(),E_MF_SEND_TO_ALL) \r\n\t\t&& isFlagOn(flags,E_MWF_SEND_TARGET_USER_ID))\r\n\t\tbstream->writeInt(msg->getDstUser(),GhostConnection::GhostIdBitSize);\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\txDistributedPropertyArrayType *props = &msg->getParameters();\r\n\tfor (unsigned int i = 0 ; i < props->size() ; i++ )\r\n\t{\r\n\t\txDistributedProperty *prop = props->at(i);\r\n\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\r\n\t\tbstream->writeRangedU32(propInfo->mValueType,0,10);\r\n\t\r\n\t\tif (isFlagOn(flags,E_MWF_UPDATE_SERVER))\r\n\t\t{\r\n\t\t\tprop->pack(bstream);\r\n\t\t\t\r\n\t\t}\r\n\r\n\t\tif (isFlagOn(flags,E_MWF_UPDATE_GHOST))\r\n\t\t{\r\n\t\t\tprop->updateGhostValue(bstream);\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\t\r\n\t/*xDistributedClient *myClient = getNetInterface()->getMyClient();\r\n\tif (myClient )\r\n\t{\r\n\t\r\n\t\tenableFlag(myClient->getClientFlags(),E_CF_NM_SENT);\r\n\t\tdisableFlag(myClient->getClientFlags(),E_CF_NM_SENDING);\r\n\t}*/\r\n\r\n\tsetThresoldTicker(getMinSendTime() + 10.0f);\r\n\tmsg->setSendCount(msg->getSendCount() +1 );\r\n\r\n\t//TNL::logprintf(\"msg written :%d tTime: %f | dst : %d\",msg->getMessageID(),getThresoldTicker(),msg->getDstUser());\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxMessage* IMessages::readFromStream(TNL::BitStream *bstream,TNL::BitSet32 flags)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\txMessage *msg = new xMessage();\r\n\r\n\tint parSize = bstream->readRangedU32(0,16);\r\n\tchar mName[256];bstream->readString(mName);\r\n\tmsg->setName(mName);\r\n\r\n\tU32 ghostSrcIndex = 0 ; \r\n\tS32 ghostDstIndex =0;\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tif (isFlagOn(flags,E_MRF_READ_SRC_USER_ID))\r\n\t{\r\n\t\tghostSrcIndex = bstream->readInt(GhostConnection::GhostIdBitSize);\r\n\t\t//TNL::logprintf(\"reading msg: \\t reading src id :%d\",ghostSrcIndex);\r\n\t\tmsg->setSrcUser(ghostSrcIndex);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tbool sendToAll = bstream->readFlag();\r\n\tbool ignoreSessionMaster= bstream->readFlag();\r\n\tmsg->setIgnoreSessionMaster(ignoreSessionMaster);\r\n\tif (sendToAll)\r\n\t{\r\n\t\tenableFlag(msg->getFlags(),E_MF_SEND_TO_ALL);\r\n\t\tmsg->setDstUser(-1);\r\n\t}\r\n\r\n\tif (\t!isFlagOn(msg->getFlags(),E_MF_SEND_TO_ALL) && \r\n\t\t\t\tisFlagOn(flags,E_MRF_READ_TARGET_USER_ID) )\r\n\t{\r\n\t\tghostDstIndex = \t bstream->readInt(GhostConnection::GhostIdBitSize);\r\n\t\tmsg->setDstUser(ghostDstIndex);\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tfor (int i = 0 ; i < parSize ; i ++ )\r\n\t{\r\n\r\n\t\tint valType = bstream->readRangedU32(0,10);\r\n\r\n\t\txDistributedPropertyInfo *dInfo = new xDistributedPropertyInfo( \"NoName\" , valType , -1 ,E_PTYPE_RELIABLE);\r\n\r\n\t\txDistributedProperty *prop = NULL;\r\n\t\t\r\n\t\tswitch(valType)\r\n\t\t{\r\n\t\t\tcase E_DC_PTYPE_STRING :\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedString(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tcase E_DC_PTYPE_FLOAT:\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedPoint1F(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_INT:\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedInteger(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_2DVECTOR:\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedPoint2F(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_3DVECTOR :\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedPoint3F(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase E_DC_PTYPE_QUATERNION:\r\n\t\t\t{\r\n\t\t\t\tprop = new xDistributedQuatF(dInfo,30,3000);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\tif (isFlagOn(flags,E_MRF_UPDATE_BY_GHOST))\r\n\t\t{\r\n\t\t\tprop->unpack(bstream,0.0f);\r\n\r\n\t\t}\r\n\r\n\t\tif (isFlagOn(flags,E_MRF_SERVER_UPDATE))\r\n\t\t{\r\n\t\t\tprop->updateFromServer(bstream);\r\n\r\n\t\t}\r\n\t\tmsg->getParameters().push_back(prop);\r\n\t\t\t\r\n\t}\r\n\r\n\t//TNL::logprintf(\"msg recieved :%d\",msg->getMessageID());\r\n\treturn msg;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIMessages::addMessage(xMessage*msg)\r\n{\r\n\r\n\r\n\txDistributedClient *myClient = getNetInterface()->getMyClient();\r\n\tif (!myClient )\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MESSAGES,\"no client object\");\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!msg)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MESSAGES,\"invalid input message\");\r\n\t\treturn;\r\n\t}\r\n\r\n\tenableFlag(msg->getFlags(),E_MF_NEW);\r\n\tenableFlag(msg->getFlags(),E_MF_OUTGOING);\r\n\r\n\tgetMessages()->push_back(msg);\r\n\tmsg->setMessageID(msgIDCounter);\r\n\tmsgIDCounter ++;\r\n\r\n\r\n\tif (msg->getDstUser()==-1)\r\n\t{\r\n\t\tenableFlag(msg->getFlags(),E_MF_SEND_TO_ALL);\r\n\t}\r\n\r\n\treturn;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IMessages::advanceTime(float deltaTime)\r\n{\r\n\r\n\txMessageArrayType *messages = getMessages();\r\n\t\r\n\tfloat time = getThresoldTicker() +deltaTime ;\r\n\tsetThresoldTicker( time );\r\n\r\n\txMessageArrayIterator begin = messages->begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg && !isFlagOn(_cmsg->getFlags(),E_MF_DELETED) )\r\n\t\t{\r\n\t\t\t_cmsg->setLifeTime( _cmsg->getLifeTime() + deltaTime );\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\nint IMessages::getNumOutMessages()\r\n{\r\n\r\n\txMessageArrayType *messages = getMessages();\r\n\r\n\r\n\txMessageArrayIterator begin = messages->begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\tint result = 0;\r\n\t\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg )\r\n\t\t{\r\n\t\t\tif (!isFlagOn(_cmsg->getFlags(),E_MF_DELETED) &&\r\n\t\t\t\tisFlagOn(_cmsg->getFlags(),E_MF_NEW) && \r\n\t\t\t\tisFlagOn(_cmsg->getFlags(),E_MF_OUTGOING) && \r\n\t\t\t\t!isFlagOn(_cmsg->getFlags(),E_MF_SENT) )\r\n\t\t\t{\r\n\t\t\t\tresult ++;\r\n\t\t\t}\r\n\t\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IMessages::checkMessages()\r\n{\r\n\txMessageArrayType *messages = getMessages();\r\n\r\n\r\n\txMessageArrayIterator begin = messages->begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg )\r\n\t\t{\r\n\t\t\tif ( _cmsg->getLifeTime() > getMessageTimeout() )\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"msg expired %f | timout : %f\",_cmsg->getLifeTime(),getMessageTimeout() );\r\n\t\t\t\tenableFlag(_cmsg->getFlags(),E_MF_DELETED); \r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n\tif (!getNetInterface()->IsServer() && !getNumOutMessages())\r\n\t{\r\n\t\tif (getNetInterface()->getMyClient())\r\n\t\t{\r\n\t\t\txDistributedClient *client = getNetInterface()->getMyClient();\r\n\t\t\t\r\n\t\t\tdisableFlag(client->getClientFlags(),E_CF_NM_SENDING);\r\n\t\t\tclient->setCurrentOutMessage(NULL);\r\n\t\t\tsetThresoldTicker(getMinSendTime() + 10.0f);\r\n\t\t}\r\n\t}\r\n\t\r\n\tif (!getNetInterface()->IsServer() &&getNumOutMessages())\r\n\t{\r\n\t\tif (getNetInterface()->getMyClient())\r\n\t\t{\r\n\t\t\txDistributedClient *client = getNetInterface()->getMyClient();\r\n\t\t\txMessage *mOut = getNextOutMessage();\r\n\t\t\tif (mOut && getThresoldTicker() > getMinSendTime() ) \r\n\t\t\t{\r\n\t\t\t\t//TNL::logprintf(\"push next message %d\",mOut->getMessageID());\r\n\t\t\t\t//client->setUpdateState(E_DO_US_PENDING);\r\n\t\t\t\tclient->setCurrentOutMessage(mOut);\r\n\t\t\t\tsetThresoldTicker(0.0f);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tif (getNetInterface()->IsServer())\r\n\t{\r\n\t\r\n\t\tif (getNumOutMessages())\r\n\t\t{\r\n\t\t\txMessage *mOut = getNextOutMessage();\r\n\t\t\txDistributedClient *client = mOut->getClientSource();\r\n\t\t\tif (mOut && client && client->getCurrentMessage()==NULL && getThresoldTicker() > getMinSendTime() ) \r\n\t\t\t{\r\n\t\t\t\t//TNL::logprintf(\"push next message %d\",mOut->getMessageID());\r\n\t\t\t\tif (mOut->getClientSource())\r\n\t\t\t\t{\r\n\t\t\t\t\tmOut->getClientSource()->setCurrentOutMessage(mOut);\r\n\t\t\t\t\tmOut->getClientSource()->setMaskBits(1<begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg )\r\n\t\t{\r\n\t\t\tif ( isFlagOn(_cmsg->getFlags(),type) )\r\n\t\t\t{\r\n\r\n\t\t\t\tcounter++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn counter;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid IMessages::deleteAllOldMessages()\r\n{\r\n\r\n\tint numMessages = getNumMessagesOfType(E_MF_DELETED);\r\n\tif (!numMessages)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\r\n\txMessageArrayType *messages = getMessages();\r\n\txMessageArrayIterator begin = messages->begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg )\r\n\t\t{\r\n\t\t\tif ( isFlagOn(_cmsg->getFlags(),E_MF_DELETED) )\r\n\t\t\t{\r\n\r\n\t\t\t\t\r\n\t\t\t\tif (isFlagOn(_cmsg->getFlags(),E_MF_OUTGOING) && !isFlagOn(_cmsg->getFlags(),E_MF_SENT))\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"message never sent %d %f\",_cmsg->getMessageID(),_cmsg->getLifeTime());\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (getNetInterface()->IsServer())\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClient *client = _cmsg->getClientSource();\r\n\t\t\t\t\tif (client)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tclient->setCurrentOutMessage(NULL);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tgetMessages()->erase(begin);\r\n\t\t\t\tdelete _cmsg;\r\n\t\t\t\t_cmsg = NULL;\r\n\t\t\t\t\r\n\t\t\t\tif (getNumMessagesOfType(E_MF_DELETED))\r\n\t\t\t\t{\r\n\t\t\t\t//\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MESSAGES,\"check again\");\r\n\t\t\t\t\tdeleteAllOldMessages();\r\n\t\t\t\t}\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\r\n}\r\n/*\r\n\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIMessages::deleteMessage(xMessage*msg)\r\n{\r\n\tif (!msg )return;\r\n\r\n\t\r\n\tenableFlag(msg->getFlags(),E_MF_DELETED); \r\n\treturn;\r\n\r\n\t/*\r\n\txDistributedPropertyArrayIterator begin = msg.getParameters().begin();\r\n\txDistributedPropertyArrayIterator end = msg.getParameters().end();\r\n\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedProperty *prop = *begin;\r\n\t\tif (prop)\r\n\t\t{\r\n\r\n\t\t\txDistributedPropertyInfo *info = prop->m_PropertyInfo;\r\n\t\t\tif (info)\r\n\t\t\t{\r\n\t\t\t\tdelete info;\r\n\t\t\t\tprop->m_PropertyInfo=NULL;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tmsg.getParameters().erase(begin);\r\n\t\t\tdelete prop;\r\n\t\t\tbegin = msg.getParameters().begin();\r\n\t\t\tint size = msg.getParameters().size();\r\n\t\t\tif (size)\r\n\t\t\t\tcontinue;\r\n\t\t\telse\r\n\t\t\t\tbreak;\r\n\r\n\t\t}\r\n\t\tbegin++;\r\n\t}*/\r\n\t/*msg.getParameters().clear();\r\n\tdelete msg.getParameters();*/\r\n\tdelete msg;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid\r\nIMessages::removeMessage(xMessage*msg)\r\n{\r\n\tif (!msg) return;\r\n\r\n\txMessageArrayType *messages = getMessages();\r\n\r\n\txMessageArrayIterator begin = messages->begin();\r\n\txMessageArrayIterator end = messages->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txMessage* _cmsg = *begin;\r\n\t\tif (_cmsg && _cmsg ==msg)\r\n\t\t{\r\n\t\t\tenableFlag(_cmsg->getFlags(),E_MF_DELETED); \r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxMessage*IMessages::getNextInMessage(xNString mName)\r\n{\r\n\r\n\tfor(int i = 0 ; i < getMessages()->size() ; i++)\r\n\t{\r\n\t\txMessage *msg = getMessages()->at(i);\r\n\t\tif (isFlagOn(msg->getFlags(),E_MF_NEW) && \r\n\t\t\tisFlagOn(msg->getFlags(),E_MF_INCOMING) &&\r\n\t\t\tisFlagOn(msg->getFlags(),E_MF_FINISH) &&\r\n\t\t\t!strcmp(msg->getName().getString(),mName.getString() ) )\r\n\t\t{\r\n\t\t\treturn msg;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxMessage*IMessages::getNextInMessage()\r\n{\r\n\r\n\tfor(int i = 0 ; i < getMessages()->size() ; i++)\r\n\t{\r\n\t\txMessage *msg = getMessages()->at(i);\r\n\t\tif (isFlagOn(msg->getFlags(),E_MF_NEW) && \r\n\t\t\tisFlagOn(msg->getFlags(),E_MF_INCOMING) &&\r\n\t\t\tisFlagOn(msg->getFlags(),E_MF_FINISH) )\r\n\t\t{\r\n\t\t\treturn msg;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxMessage*IMessages::getNextOutMessage()\r\n{\r\n\r\n\tfor(int i = 0 ; i < getMessages()->size() ; i++)\r\n\t{\r\n\t\txMessage *msg = getMessages()->at(i);\r\n\t\tif (isFlagOn(msg->getFlags(),E_MF_NEW) && \r\n\t\t\tisFlagOn(msg->getFlags(),E_MF_OUTGOING) &&\r\n\t\t\t!isFlagOn(msg->getFlags(),E_MF_SENT) &&\r\n\t\t\t!isFlagOn(msg->getFlags(),E_MF_DELETED) )\r\n\t\t{\r\n\t\t\treturn msg;\r\n\t\t}\r\n\t}\r\n\treturn NULL;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxMessageArrayType*\r\nIMessages::getMessages()\r\n{\r\n\tif (getNetInterface())\r\n\t{\r\n\t\treturn getNetInterface()->getMessages();\r\n\t}\r\n\treturn NULL;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nIMessages::IMessages(xNetInterface *ninterface) : mNetInterface(ninterface)\r\n{\r\n\r\n\tsetMessageTimeout(5000);\r\n\tmMinSendTime = 30;\r\n\tmThresoldTicker = getMinSendTime() + 10.0f;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\n// rsteer.h\n\n#ifndef __PVEHICLE_STEER_H__\n#define __PVEHICLE_STEER_H__\n\n#include \"vtPhysXBase.h\"\n#include \"pVehicleTypes.h\"\n\n\nclass pVehicleSteer\n{\n pVehicle *car;\n\n // Physical\n float lock; // Maximum angle (radians)\n \n VxVector position;\n float radius;\n float xa; // Rotation towards the driver's face\n \n // State (output)\n float angle; // -lock .. +lock\n \n \n // Input\n int axisInput; // Controller position (axis)\n \n public:\n pVehicleSteer(pVehicle *car);\n ~pVehicleSteer();\n \n \n float GetAngle(){ return angle; }\n float GetLock(){ return lock; }\n void SetAngle(float _angle){ angle=_angle; } // For replays\n\n void setToDefault();\n\n void SetInput(int axisPos);\n float getLock() const { return lock; }\n void setLock(float val) { lock = val; }\n\n \n void Integrate();\n};\n\n#endif\n\n#include \r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n#include \r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetBreakSettingsDecl();\r\nCKERROR CreatePVSetBreakSettingsProto(CKBehaviorPrototype **pproto);\r\nint PVSetBreakSettings(const CKBehaviorContext& behcontext);\r\nCKERROR PVSetBreakSettingsCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bInputs\r\n{\r\n\tbbI_XML_Link,\r\n\tbbI_BreakFlags,\r\n\tbbI_BSmallPressure,\r\n\tbbI_BMediumPressure,\r\n\tbbI_BHighPressure,\r\n\tbbI_BMediumTime,\r\n\tbbI_BHighTime,\r\n\tbbI_BTableSmall,\r\n\tbbI_BTableMedium,\r\n\tbbI_BTableHigh,\r\n\r\n};\r\n\r\n#define BB_SSTART bbI_BTableSmall\r\n\r\nBBParameter pInMap233[] =\r\n{\r\n\r\n\tBB_PIN(bbI_XML_Link,VTE_BRAKE_XML_LINK,\"XML Link\",\"Stub\"),\r\n\tBB_PIN(bbI_BreakFlags,VTF_BRAKE_FLAGS,\"Use Break Table\",\"Use Table\"),\r\n\tBB_PIN(bbI_BSmallPressure,CKPGUID_FLOAT,\"Break Pressure : Small \",\"0.1f\"),\r\n\tBB_PIN(bbI_BMediumPressure,CKPGUID_FLOAT,\"Break Pressure : Medium \",\"0.3f\"),\r\n\tBB_PIN(bbI_BHighPressure,CKPGUID_FLOAT,\"Break Pressure : High\",\"1.0f\"),\r\n\tBB_PIN(bbI_BMediumTime,CKPGUID_TIME,\"Medium Apply Time\",\"1.5\"),\r\n\tBB_PIN(bbI_BHighTime,CKPGUID_TIME,\"High Apply Time\",\"3.5\"),\r\n\tBB_SPIN(bbI_BTableSmall,VTS_BRAKE_TABLE,\"Break Table : Small\",\"\"),\r\n\tBB_SPIN(bbI_BTableMedium,VTS_BRAKE_TABLE,\"Break Table : Medium\",\"\"),\r\n\tBB_SPIN(bbI_BTableHigh,VTS_BRAKE_TABLE,\"Break Table : High\",\"\"),\r\n};\r\n#define gPIMAP pInMap233\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetBreakSettingsDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVSetBreakSettings\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Sets custom break behavior.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x719d41c2,0x46b76965));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVSetBreakSettingsProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVSetBreakSettingsProto\r\n// FullName: CreatePVSetBreakSettingsProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVSetBreakSettingsProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVSetBreakSettings\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t/* PVSetBreakSettings \r\n\r\n\tPVSetBreakSettings is categorized in \\ref Body\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRegisters an object in the physic engine.
\r\n\tSee PVSetBreakSettings.cmo for example.\r\n\t\r\n\t

Technical Information

\r\n\r\n\t\\image html PVSetBreakSettings.png\r\n\r\n\tIn: triggers the process
\r\n\t\r\n\tOut: is activated when the process is completed
\r\n\t\r\n\t
\r\n\t\r\n\tTarget:The 3D Entity associated to the rigid body
\r\n\t\r\n*/\r\n\r\n\r\n\tBB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(gPIMAP)\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct( PVSetBreakSettingsCB );\r\n\tproto->SetFunction(PVSetBreakSettings);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PVSetBreakSettings\r\n// FullName: PVSetBreakSettings\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PVSetBreakSettings(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tobjects\t\t\r\n\t//\r\n\t\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\t//the object :\r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) bbSErrorME(E_PE_REF);\r\n\r\n\t//the world reference, optional used\r\n\tCK3dEntity*worldRef = NULL;\r\n\r\n\t//the world object, only used when reference has been specified\r\n\tpWorld *world = NULL;\r\n\r\n\t//final object description \r\n\tpObjectDescr *oDesc = new pObjectDescr();\r\n\r\n\tpRigidBody *body = NULL;\r\n\tpVehicle *v = NULL;\r\n\r\n\tXString errMesg;\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// sanity checks \r\n\t//\r\n\tbody = GetPMan()->getBody(target);\r\n\tif (!body)\r\n\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\tv = body->getVehicle();\r\n\tif (!v)\t\r\n\t\tbbSErrorME(E_PE_NoVeh);\r\n\r\n \r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tCollecting data. Stores all settings in a pObjectDescr.\r\n\t//\r\n\r\n\t//get the parameter array\r\n\tBB_DECLARE_PIMAP;\r\n\r\n\tv->setBreakFlags(GetInputParameterValue(beh,BB_IP_INDEX(bbI_BreakFlags)));\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// brake pressures\r\n\t//\r\n\tfloat pressureSmall = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BSmallPressure));\r\n\tiAssertW( pressureSmall >=0.0f && pressureSmall <=1.0f , _FLT_ASSIGMENT(pressureSmall,0.1f) ,\"\");\r\n\r\n\tfloat pressureMedium = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BMediumPressure));\r\n\tiAssertW( pressureMedium>=0.0f && pressureMedium<=1.0f , _FLT_ASSIGMENT(pressureMedium,0.3f) ,\"\");\r\n\r\n\tfloat pressureHigh = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BHighPressure));\r\n\tiAssertW( pressureHigh >=0.0f && pressureHigh<=1.0f , _FLT_ASSIGMENT(pressureHigh,1.0f) ,\"\");\r\n\r\n\tv->setBreakPressure(BL_Small,pressureSmall);\r\n\tv->setBreakPressure(BL_Medium,pressureMedium);\r\n\tv->setBreakPressure(BL_High,pressureHigh);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// brake table \r\n\t//\r\n\tBBSParameterM(bbI_BTableSmall,BB_SSTART);\r\n\tif(sbbI_BTableSmall)\r\n\t\tIParameter::Instance()->copyTo(v->mSmallBrakeTable,beh->GetInputParameter(BB_IP_INDEX(bbI_BTableSmall))->GetRealSource());\r\n\r\n\tBBSParameterM(bbI_BTableMedium,BB_SSTART);\r\n\tif(sbbI_BTableMedium)\r\n\t\tIParameter::Instance()->copyTo(v->mMediumBrakeTable,beh->GetInputParameter(BB_IP_INDEX(bbI_BTableMedium))->GetRealSource());\r\n\r\n\tBBSParameterM(bbI_BTableHigh,BB_SSTART);\r\n\tif(sbbI_BTableHigh)\r\n\t\tIParameter::Instance()->copyTo(v->mHighBrakeTable,beh->GetInputParameter(BB_IP_INDEX(bbI_BTableHigh))->GetRealSource());\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// brake wait time \r\n\t//\r\n\tv->mBrakeMediumThresold = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BMediumTime));\r\n\tv->mBrakeHighThresold = GetInputParameterValue(beh,BB_IP_INDEX(bbI_BHighTime));\r\n\r\n\t\t//----------------------------------------------------------------\r\n\t//\r\n\t// error out\r\n\t//\r\n\terrorFound:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_GENERICERROR;\r\n\t}\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// All ok\r\n\t//\r\n\tallOk:\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVSetBreakSettingsCB\r\n// FullName: PVSetBreakSettingsCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PVSetBreakSettingsCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\tcase CKM_BEHAVIORCREATE:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#include \"StdAfx.h\"\r\n#include \"InitMan.h\"\r\n#include \"vt_python_funcs.h\"\r\n//#include \"VSLManagerSDK.h\"\r\n/*#include \r\n#include \"pyembed.h\"\r\n*/\r\n\r\nextern vt_python_man *pym;\r\n//////////////////////////////////////////////////////////////////////////\r\nvt_python_man::~vt_python_man(){}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nvt_python_man*\r\nvt_python_man::GetPyMan()\r\n{\r\n\r\n\treturn pym;\r\n}\r\n\r\n\r\n//************************************\r\n// Method: PostProcess\r\n// FullName: vt_python_man::PostProcess\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n//************************************\r\nCKERROR\r\nvt_python_man::PostProcess()\r\n{\r\n\tif (m_stdErr.Length())\r\n\t{\r\n\t\t\r\n\t\tm_Context->OutputToConsoleEx(\"\\nPyErr:%s\",m_stdErr.Str(),FALSE);\r\n\t\tm_stdErr =\"\";\r\n\t}\r\n\t\r\n\tif (m_stdOut.Length())\r\n\t{\r\n\t\tm_Context->OutputToConsoleEx(\"\\nPyOut:%s\",m_stdOut.Str(),FALSE);\r\n\t\tm_stdOut=\"\";\r\n\t\t\r\n\t}\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PreProcess\r\n// FullName: vt_python_man::PreProcess\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n//************************************\r\nCKERROR\r\nvt_python_man::PreProcess()\r\n{\r\n\t//m_Context->OutputToConsoleEx(\"Py std::error : %s\",m_stdErr);\r\n\t//m_Context->OutputToConsoleEx(\"Py std::out : %s\",m_stdOut);\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR\r\nvt_python_man::PostClearAll(){\r\n\treturn CK_OK;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR vt_python_man::OnCKEnd(){\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nCKERROR vt_python_man::OnCKReset(){\r\n\r\n\t/*if(py)\r\n\t{\r\n\t\tdelete py;\r\n\t\r\n\t\tpy = NULL;\r\n\t}*/\r\n\tClearModules();\r\n\tDestroyPython();\r\n\treturn CK_OK;\r\n\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR vt_python_man::OnCKPlay()\r\n{\r\n\t\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nCKERROR vt_python_man::OnCKInit(){\r\n\t\r\n\tm_Context->ActivateManager((CKBaseManager*) this,true);\t\r\n/*\r\n\tint argc = 1;\r\n\tchar *cmd =GetCommandLineA();\r\n\tchar *c1[1];\r\n\tc1[0]=new char[5];\r\n\tstrcpy(c1[0],cmd);*/\r\n\t//py = new Python(argc,c1);\r\n\r\n\t/*if(py)\r\n\t{\r\n\t\tdelete py;\r\n\t\tpy = NULL;\r\n\t}*/\r\n\t//RegisterVSL();\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n#ifndef __X_ASSERT_CUSTOMIZATION_H__\r\n\t#define __X_ASSERT_CUSTOMIZATION_H__\r\n\r\n#include \"xPlatform.h\"\r\n\r\n\tstruct xAssertInfo\r\n\t{\r\n\tpublic:\r\n\t\tE_ASSERTION_FAILURE_SEVERITY failureSeverity;\r\n\t\tchar *assertionExpression;\r\n\t\tchar *assertionFileName;\r\n\t\tint assertionSourceLine;\r\n\t\tchar *assertionPostMessage;\r\n\t\tvoid *postAction;\r\n\t\tbool result;\r\n\r\n\t\txAssertInfo() : failureSeverity(AFS__MAX) ,\r\n assertionExpression(NULL),\r\n\t\t\tassertionFileName(NULL),\r\n\t\t\tassertionSourceLine(0),\r\n\t\t\tassertionPostMessage(NULL),\r\n\t\t\tpostAction(NULL),\r\n\t\t\tresult(false)\r\n\t\t{\r\n\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\txAssertInfo() : \r\n\t\t{\r\n\t\t\tfailureSeverity\t\t\t= AFS__MAX;\r\n\t\t\tassertionExpression\t\t= NULL;\r\n\t\t\tassertionFileName\t\t= NULL;\r\n\t\t\tassertionSourceLine\t\t= 0;\r\n\t\t\tassertionSourceObject\t= NULL;\r\n\t\t\tassertionPostMessage\t= NULL;\r\n\t\t\tpostAction\t\t\t\t= NULL;\r\n\t\t\tresult\t\t\t\t\t= false;\r\n\t\t}\r\n\t\t*/\r\n\r\n\t\txAssertInfo(\r\n\t\t\tE_ASSERTION_FAILURE_SEVERITY _failureSeverity,\r\n\t\t\tchar *_assertionExpression,\r\n\t\t\tchar *_assertionFileName,\r\n\t\t\tint _assertionSourceLine,\r\n\t\t\tchar *_assertionPostMessage,\r\n\t\t\tvoid* _postAction,\r\n\t\t\tbool _result)\r\n\t\t{\r\n assertionExpression = _assertionExpression;\r\n\t\t\tassertionFileName = _assertionFileName;\r\n\t\t\tassertionSourceLine = _assertionSourceLine;\r\n\t\t\tassertionPostMessage = _assertionPostMessage;\r\n\t\t\tpostAction = _postAction;\r\n\t\t\tfailureSeverity = _failureSeverity;\r\n\t\t\tresult = _result;\r\n\t\t}\r\n\t};\r\n\r\n#endif/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#include \"vtTools.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n// include file used for the static configuration\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\n#include \"xSplash.h\"\r\n\r\n\r\nextern CCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\nBOOL CCustomPlayerApp::InitInstance()\r\n{\r\n\r\n\t// register the windows class the main and the render window\r\n\t_RegisterClass();\r\n\r\n\r\n\t// read the configuration\r\n\r\n\tconst char* fileBuffer = 0;\r\n\tXDWORD fileSize = 0;\r\n\r\n\t// read the configuration\r\n\t//XString filename;\r\n\r\n\t// retrieve the unique instance of the player (CCustomPlayer class)\r\n\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\r\n\r\n\r\n\r\n\tplayer.PLoadEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE);\r\n\tplayer.PLoadEnginePathProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\r\n\tplayer.PLoadAppStyleProfile(CUSTOM_PLAYER_CONFIG_FILE);\r\n\r\n\r\n\tplayer.m_AppMode = player.PGetApplicationMode(GetCommandLine()); // sets player.m_AppMode = full;\r\n\r\n\r\n\t//m_Config |= eAutoFullscreen;\r\n\t// create the main and the render window\r\n\r\n\t//we only create windows when we want to render something !\r\n\t\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif(!_CreateWindows()) \r\n\t\t{\r\n\t\t\tMessageBox(NULL,FAILED_TO_CREATE_WINDOWS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\tXString filename(GetPlayer().GetEPathProfile()->CompositionFile);\r\n\r\n\r\n\r\n\tif(!_ReadConfig(filename,fileBuffer,fileSize)) {\r\n\t\t/*MessageBox(NULL,CANNOT_READ_CONFIG,INIT_ERROR,MB_OK|MB_ICONERROR);*/\r\n\t\t//return FALSE;\r\n\t}\r\n\r\n\r\n\t//XString filename(\"tetris1.cmo\");\r\n\r\n\t// initialize the player\r\n\tif(!player.InitPlayer(m_MainWindow,m_RenderWindow,m_Config,filename.Length()==0?fileBuffer:filename.CStr(),filename.Length()==0?fileSize:0)) \r\n\t{\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\r\n\t// [12/17/2007 mc007] \r\n\t// as the player is ready we destroy the splash screen window\r\n\t//DestroyWindow(m_Splash);\r\n\r\n\r\n\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t{\r\n\t\tif (GetPlayer().GetEWindowInfo()->g_GoFullScreen) \r\n\t\t{\r\n\t\t\t// we are a auto fullscreen mode\r\n\t\t\t// so we hide the main window\r\n\t\t\tShowWindow(m_MainWindow,SW_HIDE);\r\n\t\t\tUpdateWindow(m_MainWindow);\r\n\t\t\t// we show the render window\r\n\t\t\tShowWindow(m_RenderWindow,theApp.m_nCmdShow);\r\n\t\t\tUpdateWindow(m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_RenderWindow);\r\n\t\t\tGetPlayer().m_EatDisplayChange = TRUE;\r\n\t\t} else {\r\n\t\t\t// we are in windowed mode\r\n\t\t\t// so we show the main window\r\n\t\t\tShowWindow(m_MainWindow,theApp.m_nCmdShow);\r\n\t\t\tUpdateWindow(m_MainWindow);\r\n\t\t\t// the render window too\r\n\t\t\tShowWindow(m_RenderWindow,theApp.m_nCmdShow);\r\n\t\t\tUpdateWindow(m_RenderWindow);\r\n\t\t\t// and set the focus to it\r\n\t\t\tSetFocus(m_RenderWindow);\r\n\t\t}\r\n\t}\r\n\t// we reset the player to start it\r\n\tplayer.Reset();\r\n\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\t// NOTE: other important things to read after initialization\r\n\t// - the main loop of the player is executed by CCustomPlayerApp::Run\r\n\t// - the windowproc of the main and render window is\r\n\t// CCustomPlayerApp::_MainWindowWndProc\r\n\t// - but the main part of the application is implemented by the\r\n\t// CCustomPlayer class.\r\n\t///////////////////////////////////////////////////////////////////////////\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nint CCustomPlayerApp::Run() \r\n{\r\n\tMSG msg; \r\n\r\n\twhile(1) {\r\n\t\tif(PeekMessage(&msg, NULL,0,0,PM_REMOVE)) {\r\n\t\t\tif(msg.message==WM_QUIT) {\r\n\t\t\t\treturn CWinApp::Run();\r\n\t\t\t}\r\n\t\t\telse if(!TranslateAccelerator(msg.hwnd,m_hAccelTable,&msg)) {\r\n\t\t\t\tTranslateMessage(&msg);\r\n\t\t\t\tDispatchMessage(&msg);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\t// process the player\r\n\t\t\tif(!CCustomPlayer::Instance().Process(m_Config)) {\r\n\t\t\t\tPostQuitMessage(0);\r\n\t\t\t\treturn CWinApp::Run();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn msg.wParam;\r\n}#ifndef __P_FLUID_EMITTER_DESC_H__\r\n#define __P_FLUID_EMITTER_DESC_H__\r\n\r\n/** \\addtogroup fluids\r\n @{\r\n*/\r\n\r\n/**\r\n\\brief Flags which control the behavior of fluid emitters.\r\n\r\n@see pFluidEmitter\r\n*/\r\nenum pFluidEmitterFlag\r\n\t{\r\n\t/**\r\n\t\\brief Flags whether the emitter should be visualized for debugging or not.\r\n\t*/\r\n\tPFEF_Visualization\t\t= (1<<0),\r\n\r\n\t/**\r\n\t\\brief This flag specifies whether the emission should cause a force on \r\n\tthe shapes body that the emitter is attached to.\r\n\t*/\r\n\tPFEF_ForceOnBody\t\t= (1<<2),\r\n\t\r\n\t/**\r\n\t\\brief If set, the velocity of the shapes body is added to the emitted particle velocity.\r\n\t\r\n\tThis is the default behavior .\r\n\t*/\r\n\tPFEF_AddBodyVelocity\t= (1<<3),\r\n\t\r\n\t/**\r\n\t\\brief Flag to start and stop the emission. On default the emission is enabled.\r\n\t*/\r\n\tPFEF_Enabled\t\t\t\t= (1<<4),\r\n};\r\n\r\n/**\r\n\\brief Flags to specify the shape of the area of emission.\r\n\r\nExactly one flag should be set at any time.\r\n\r\n*/\r\nenum pEmitterShape\r\n{\r\n\tPFES_Rectangular\t\t= (1<<0),\r\n\tPFES_Ellipse\t\t\t= (1<<1)\r\n};\r\n\r\n/**\r\n\\brief Flags to specify the emitter's type of operation.\r\nExactly one flag should be set at any time.\r\n\r\n@see pFluidEmitter\r\n*/\r\nenum pEmitterType\r\n{\r\n\tPFET_ConstantPressure\t\t= (1<<0),\r\n\tPFET_ConstantFlowRate\t= (1<<1)\r\n};\r\n\r\n\r\n/**\r\n\\brief Descriptor for pFluidEmitter class. Used for saving and loading the emitter state.\r\n*/\r\nclass MODULE_API pFluidEmitterDesc\r\n\t{\r\n\tpublic:\r\n\r\n\r\n\r\n\tCK_ID entityReference;\r\n\t/**\r\n\t\\brief A pointer to the shape to which the emitter is attached to.\r\n\t\r\n\tIf this pointer is set to NULL, the emitter is attached to the world frame. The shape \r\n\tmust be in the same scene as the emitter. \r\n\t*/\r\n\tCK3dEntity*\t\t\t\tframeShape;\r\n\r\n\t/**\r\n\t\\brief The emitter's mode of operation.\r\n\r\n\tEither the simulation enforces constant pressure or constant flow rate at the emission site, \r\n\tgiven the velocity of emitted particles.\r\n\r\n\t@see NxEmitterType\r\n\t*/\r\n\tpEmitterType\t\t\t\t\ttype;\r\n\r\n\t/**\r\n\t\\brief The maximum number of particles which are emitted from this emitter.\r\n\t\r\n\tIf the total number of particles in the fluid already hit the maxParticles parameter of the fluid, \r\n\tthis maximal values can't be reached.\r\n\t\r\n\tIf set to 0, the number of emitted particles is unrestricted.\r\n\t*/\r\n\tint\t\t\t\t\tmaxParticles;\r\n\r\n\t/**\r\n\t\\brief The emitter's shape can either be rectangular or elliptical.\r\n\r\n\t@see pEmitterShape\r\n\t*/\r\n\tpEmitterShape\t\t\t\t\tshape;\r\n\r\n\t/**\r\n\t\\brief The sizes of the emitter in the directions of the first and the second axis of its orientation \r\n\tframe (relPose).\r\n\r\n\tThe dimensions are actually the radii of the size.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\tdimensionX;\r\n\tfloat\t\t\t\t\tdimensionY;\r\n\r\n\t/**\r\n\t\\brief Random vector with values for each axis direction of the emitter orientation.\r\n\t\r\n\tThe values have to be positive and describe the maximal random particle displacement in each dimension.\r\n\t\r\n\tThe z value describes the randomization in emission direction. The emission direction \r\n\tis specified by the third orientation axis of relPose.\r\n\r\n\t*/\r\n VxVector\t\t\t\t\trandomPos;\r\n\r\n\t/**\r\n\t\\brief Random angle deviation from emission direction.\r\n\t\r\n\tThe emission direction is specified by the third orientation axis of relPose.\r\n\t\r\n\tUnit: Radians\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\trandomAngle;\r\n\r\n\t/**\r\n\t\\brief The velocity magnitude of the emitted fluid particles.\r\n\r\n\t*/\r\n\tfloat\t\t\t\t\tfluidVelocityMagnitude;\r\n\r\n\t/**\r\n\t\\brief The rate specifies how many particles are emitted per second.\r\n\t\r\n\tThe rate is only considered in the simulation if the type is set to PFET_ConstantFlowRate.\r\n\r\n\t@see NxEmitterType\r\n\t*/\r\n\tfloat\t\t\t\t\trate;\r\n\t\r\n\t/**\r\n\t\\brief This specifies the time in seconds an emitted particle lives.\r\n\r\n\tIf set to 0, each particle will live until it collides with a drain.\r\n\t*/\r\n\tfloat\t\t\t\t\tparticleLifetime;\r\n\r\n\t/**\r\n\t\\brief Defines a factor for the impulse transfer from attached emitter to body.\r\n\r\n\tOnly has an effect if PFEF_ForceOnBody is set.\r\n\r\n\tDefault: 1.0
\r\n\tRange: [0,inf)\r\n\r\n\t@see PFEF_ForceOnBody NxFluidEmitter.setRepulsionCoefficient()\r\n\t*/\r\n\tfloat\t\t\t\t\trepulsionCoefficient;\r\n\r\n\t/**\r\n\t\\brief A combination of pFluidEmitterFlags.\r\n\r\n\t@see pFluidEmitterFlag\r\n\t*/\r\n\tpFluidEmitterFlag\t\t\t\t\tflags;\r\n\r\n\t~pFluidEmitterDesc();\r\n\t/**\r\n\t\\brief (Re)sets the structure to the default.\t\r\n\t*/\r\n\tvoid setToDefault();\r\n\t/**\r\n\t\\brief Returns true if the current settings are valid\r\n\t*/\r\n\tbool isValid() const;\r\n\r\n\t/**\r\n\t\\brief Constructor sets to default.\r\n\t*/\r\n\tpFluidEmitterDesc();\r\n\t};\r\n\r\n\r\n\r\n/** @} */\r\n\r\n#endif\r\n#ifndef ZCALLBCK_H\r\n#define ZCALLBCK_H\r\n\r\n//#include \"StdAfx.h\"\r\n#include \r\n\r\n#define MAX_FILES 4096\r\n\r\n#pragma pack (push)\r\n\r\nstruct CZipCallbackData\r\n{\r\n\tDWORD m_hwndHandle;\r\n\tHWND m_pCaller;\r\n\tlong int m_liVersion;\r\n\tBOOL m_bIsOperationZip;\r\n\tlong int m_liActionCode;\r\n\tlong int m_liErrorCode;\r\n\tlong int m_liFileSize;\r\n\tchar m_pszFileNameOrMsg[512];\r\n};\r\n\r\n#pragma pack (pop)\r\n\r\ntypedef BOOL (__stdcall *ZFunctionPtrType) (CZipCallbackData*);\r\n\r\n#endif ZCALLBCK_H // ZCALLBCK_H\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n\r\n\r\nPhysicManager *ourMan = NULL;\r\n\r\ntypedef ForceMode PForceMode;\r\ntypedef D6MotionMode PJMotion;\r\ntypedef D6DriveType PDriveType;\r\n\r\n\r\npRigidBody *getBody(CK3dEntity*ent){\r\n\tpRigidBody *body = GetPMan()->getBody(ent);\r\n\tif (body)\r\n\t{\r\n\t\treturn body;\r\n\t}else{\r\n\t\treturn NULL;\r\n\t}\r\n}\r\n\r\nvoid __newpSpring(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pSpring();\r\n}\r\nvoid __newpSoftLimit(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJD6SoftLimit();\r\n}\r\n\r\nvoid __newpDrive(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJD6Drive();\r\n}\r\nvoid __newpJointLimit(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pJointLimit();\r\n}\r\n\r\nvoid __newpMotor(BYTE *iAdd) \r\n{\r\n\tnew (iAdd) pMotor();\r\n}\r\n\r\n\r\npSerializer *GetSerializer()\r\n{\r\n\treturn pSerializer::Instance();\r\n}\r\n\r\n\r\n\r\nvoid __newpClothDescr(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pClothDesc();\r\n}\r\n\r\n#define TESTGUID CKGUID(0x2c5c47f6,0x1d0755d9)\r\n\r\n\r\nvoid PhysicManager::_RegisterVSL()\r\n{\r\n\t\r\n\t_RegisterVSLCommon();\r\n\r\n\r\n\tourMan = GetPMan();\r\n\r\n\t\r\n\t_RegisterVSLCommon();\r\n\t_RegisterVSLVehicle();\r\n\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\r\n\t\tDECLAREENUM(\"pClothAttachmentFlag\")\r\n\t\tDECLAREENUMVALUE(\"pClothAttachmentFlag\", \"PCAF_ClothAttachmentTwoway\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"pClothAttachmentFlag\", \"PCAF_ClothAttachmentTearable\" ,2 )\r\n\r\n\t\tDECLAREENUM(\"pClothFlag\")\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Pressure\" ,1 )\r\n\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Static\",2)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_DisableCollision\",4)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_SelfCollision\",8)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Gravity\",32)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Bending\",64)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_BendingOrtho\",128)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Damping\",256)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_CollisionTwoway\",512)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_TriangleCollision\",2048)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Tearable\",4096)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_Hardware\",8192)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_ComDamping\",16384)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_ValidBounds\",32768)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_FluidCollision\",65536)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_DisableDynamicCCD\",131072)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AddHere\",262144)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToParentMainShape\",524288)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToCollidingShapes\",1048576)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachToCore\",2097152)\r\n\t\tDECLAREENUMVALUE(\"pClothFlag\", \"PCF_AttachAttributes\",4194304)\r\n\r\n\r\n\t\r\n\t\t\t\t\r\n\r\n\r\n\t\tDECLAREOBJECTTYPE(pClothDesc)\r\n\t\t\r\n\t\tDECLAREMEMBER(pClothDesc,float,thickness)\r\n\t\tDECLAREMEMBER(pClothDesc,float,density)\r\n\t\tDECLAREMEMBER(pClothDesc,float,bendingStiffness)\r\n\r\n\t\tDECLAREMEMBER(pClothDesc,float,stretchingStiffness)\r\n\t\tDECLAREMEMBER(pClothDesc,float,dampingCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,friction)\r\n\t\tDECLAREMEMBER(pClothDesc,float,pressure)\r\n\t\tDECLAREMEMBER(pClothDesc,float,tearFactor)\r\n\t\tDECLAREMEMBER(pClothDesc,float,collisionResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,attachmentResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,attachmentTearFactor)\r\n\t\tDECLAREMEMBER(pClothDesc,float,toFluidResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,fromFluidResponseCoefficient)\r\n\t\tDECLAREMEMBER(pClothDesc,float,minAdhereVelocity)\r\n\t\tDECLAREMEMBER(pClothDesc,int,solverIterations)\r\n\t\tDECLAREMEMBER(pClothDesc,VxVector,externalAcceleration)\r\n\t\tDECLAREMEMBER(pClothDesc,VxVector,windAcceleration)\r\n\t\tDECLAREMEMBER(pClothDesc,float,wakeUpCounter)\r\n\t\tDECLAREMEMBER(pClothDesc,float,sleepLinearVelocity)\r\n\t\tDECLAREMEMBER(pClothDesc,int,collisionGroup)\r\n\t\tDECLAREMEMBER(pClothDesc,VxBbox,validBounds)\r\n\t\tDECLAREMEMBER(pClothDesc,float,relativeGridSpacing)\r\n\t\tDECLAREMEMBER(pClothDesc,pClothFlag,flags)\r\n\t\tDECLAREMEMBER(pClothDesc,pClothAttachmentFlag,attachmentFlags)\r\n\t\tDECLAREMEMBER(pClothDesc,VxColor,tearVertexColor)\r\n\t\tDECLAREMEMBER(pClothDesc,CK_ID,worldReference)\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pClothDesc,void,setToDefault)\r\n\t\tDECLARECTOR_0(__newpClothDescr)\r\n\r\n\r\n\r\n\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\t\t\t\tVehicle : \r\n\t//\r\n\tDECLAREMETHOD_1(pVehicle,void,updateVehicle,float)\r\n\tDECLAREMETHOD_5(pVehicle,void,setControlState,float,bool,float,bool,bool)\r\n\r\n\r\n\tDECLAREMETHOD_1(pVehicle,pWheel*,getWheel,CK3dEntity*)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleMotor*,getMotor)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleGears*,getGears)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,void,gearUp)\r\n\tDECLAREMETHOD_0(pVehicle,void,gearDown)\r\n\t\r\n\t\r\n\tDECLAREMETHOD_0(pVehicleGears,int,getGear)\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//motor : \r\n\tDECLAREMETHOD_0(pVehicleMotor,float,getRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotor,float,getTorque)\r\n\r\n\r\n\tDECLAREMETHOD_0(pWheel,pWheel1*,castWheel1)\r\n\tDECLAREMETHOD_0(pWheel,pWheel2*,castWheel2)\r\n\r\n\tDECLAREMETHOD_0(pWheel,float,getWheelRollAngle)\r\n\tDECLAREMETHOD_0(pWheel2,float,getRpm)\r\n\tDECLAREMETHOD_0(pWheel2,float,getAxleSpeed)\r\n\tDECLAREMETHOD_0(pWheel2,float,getSuspensionTravel)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,getGroundContactPos)\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tBindings for pVehicle related classes : \r\n\t//\r\n\t//\r\n\r\n\r\n\t\r\n\t\r\n\t\r\n\r\n\r\n\t\t\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREOBJECTTYPE(pJointLimit)\r\n\t\tDECLARECTOR_0(__newpJointLimit)\r\n\t\tDECLAREMEMBER(pJointLimit,float,hardness)\r\n\t\tDECLAREMEMBER(pJointLimit,float,restitution)\r\n\t\tDECLAREMEMBER(pJointLimit,float,value)\r\n\r\n\t\tDECLAREOBJECTTYPE(pJD6Drive)\r\n\t\tDECLARECTOR_0(__newpDrive)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,damping)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,spring)\r\n\t\tDECLAREMEMBER(pJD6Drive,float,forceLimit)\r\n\t\tDECLAREMEMBER(pJD6Drive,int,driveType)\r\n\r\n\t\tDECLAREOBJECTTYPE(pJD6SoftLimit)\r\n\t\tDECLARECTOR_0(__newpSoftLimit)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,damping)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,spring)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,value)\r\n\t\tDECLAREMEMBER(pJD6SoftLimit,float,restitution)\r\n\r\n\r\n\t\tDECLAREOBJECTTYPE(pSpring)\r\n\t\tDECLARECTOR_0(__newpSpring)\r\n\t\t//DECLARECTOR_3(__newpSpringSettings3,float,float,float)\r\n\t\tDECLAREMEMBER(pSpring,float,damper)\r\n\t\tDECLAREMEMBER(pSpring,float,spring)\r\n\t\tDECLAREMEMBER(pSpring,float,targetValue)\r\n\r\n\t\tDECLAREOBJECTTYPE(pMotor)\r\n\t\tDECLARECTOR_0(__newpMotor)\r\n\t\tDECLAREMEMBER(pMotor,float,maximumForce)\r\n\t\tDECLAREMEMBER(pMotor,float,targetVelocity)\r\n\t\tDECLAREMEMBER(pMotor,float,freeSpin)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tSerializer : \r\n\t\t//\r\n\t\tDECLAREPOINTERTYPE(pSerializer)\r\n\t\tDECLAREFUN_C_0(pSerializer*, GetSerializer)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,overrideBody,pRigidBody*,int)\r\n\t\tDECLAREMETHOD_2(pSerializer,int,loadCollection,const char*,int)\r\n\t\tDECLAREMETHOD_1(pSerializer,int,saveCollection,const char*)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,parseFile,const char*,int)\r\n\r\n\r\n\t\t\r\n\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tFactory\r\n\t\t//\r\n\r\n\t\t\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tENUMERATION \r\n\t\t//\r\n\r\n\t\tDECLAREENUM(\"D6DriveType\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Position\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Velocity\" ,2 )\r\n\r\n\r\n\t\tDECLAREENUM(\"PForceMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Force\" , 0)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Impulse\" , 1)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_VelocityChange\" , 2)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothImpulse\" , 3)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothVelocityChange\" , 4)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Acceleration\" , 5)\r\n\t\t\r\n\t\tDECLAREENUM(\"D6MotionMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Locked\" , 0)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Limited\" , 1)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Free\" , 2)\r\n\r\n\t\tDECLAREENUM(\"JType\")\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Any\" , -1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Prismatic\" , 0)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Revolute\" , 1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Cylindrical\" , 2)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Spherical\" , 3)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointOnLine\" , 4)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointInPlane\" , 5)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Distance\" , 6)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Pulley\" , 7)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Fixed\" ,8 )\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_D6\" ,9 )\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_2(pFactory,pVehicle*,createVehicle,CK3dEntity*,pVehicleDesc)\r\n\t\t\r\n\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getWheelRollAngle)\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getRpm)\r\n\r\n\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT CREATION\r\n\t\t//\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointDistance*,createDistanceJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,VxVector(),VxVector,VxVector(),float,0.0f,float,0.0f,pSpring,pSpring())\r\n\t\tDECLAREMETHOD_5(pFactory,pJointD6*,createD6Joint,CK3dEntity*,CK3dEntity*,VxVector,VxVector,bool)\r\n\t\tDECLAREMETHOD_2(pFactory,pJointFixed*,createFixedJoint,CK3dEntity*,CK3dEntity*)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pFactory,pRigidBody*,createBody,CK3dEntity*,NODEFAULT,pObjectDescr,NODEFAULT,CK3dEntity*,NULL)\r\n\t\t\r\n\t\tDECLAREMETHOD_2(pFactory,pRigidBody*,createRigidBody,CK3dEntity*,pObjectDescr&)\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,bool,loadMaterial,pMaterial&,const char*)\r\n\t\tDECLAREMETHOD_2(pFactory,pMaterial,loadMaterial,const char*,int&)\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,bool,loadFrom,pWheelDescr&,const char*)\r\n\t\tDECLAREMETHOD_5(pFactory,pWheel*,createWheel,CK3dEntity *,CK3dEntity*,pWheelDescr,pConvexCylinderSettings,VxVector)\r\n\r\n\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_6(pFactory,pJointPulley*,createPulleyJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointBall*,createBallJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointRevolute*,createRevoluteJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPrismatic*,createPrismaticJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointCylindrical*,createCylindricalJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPointInPlane*,createPointInPlaneJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPointOnLine*,createPointOnLineJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\r\n\t\t\r\n\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,pCloth*,createCloth,CK3dEntity*,pClothDesc)\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tCloth\r\n\t\t//\r\n\t\tDECLAREMETHOD_4(pCloth,void,attachToCore,CK3dEntity*,float,float,float)\r\n\t\tDECLAREMETHOD_2(pCloth,void,attachToShape,CK3dEntity*,pClothAttachmentFlag)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tMANAGER\r\n\t\t//\r\n\t\t\r\n\t\t\r\n\t\tDECLAREMETHOD_0(PhysicManager,pWorld*,getDefaultWorld)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pRigidBody*,getBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorldByBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorld,CK_ID)\r\n\t\tDECLAREMETHOD_1(PhysicManager,int,getAttributeTypeByGuid,CKGUID)\r\n\t\t\r\n\r\n\t\tDECLAREMETHOD_1(CK3dEntity,CKBOOL,HasAttribute,int)\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(PhysicManager,pJoint*,getJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NULL,JType,JT_Any)\r\n\r\n//\t\tDECLAREMETHOD_0(PhysicManager,void,makeDongleTest)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tWorld\r\n\t\t//\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pWorld,pRigidBody*,getBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(pWorld,pVehicle*,getVehicle,CK3dEntity*)\r\n\t\tDECLAREMETHOD_3(pWorld,pJoint*,getJoint,CK3dEntity*,CK3dEntity*,JType)\r\n\r\n\t\tDECLAREMETHOD_3(pWorld,void,setFilterOps,pFilterOp,pFilterOp,pFilterOp)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterBool,bool)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant0,const pGroupsMask&)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant1,const pGroupsMask&)\r\n\r\n\r\n\r\n\r\n\t\t//\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pWorld,bool,raycastAnyBounds,const VxRay&,NODEFAULT,pShapesType,NODEFAULT,pGroupsMask,NODEFAULT,int,0xffffffff,float,NX_MAX_F32)\r\n\t\tDECLAREMETHOD_8(pWorld,bool,overlapSphereShapes,CK3dEntity*,const VxSphere&,CK3dEntity*,pShapesType,CKGroup*,int,const pGroupsMask*,BOOL)\r\n\r\n\t\t//(const VxRay& worldRay, pShapesType shapesType, pGroupsMask groupsMask,unsigned int groups=0xffffffff, float maxDist=NX_MAX_F32);\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT :: Revolute\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointRevolute*,castRevolute)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAnchor,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAxis,const VxVector&)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setLowLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setMotor,pMotor)\r\n\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getLowLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pMotor,getMotor)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,enableCollision,bool)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: Ball\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointBall*,castBall)\r\n\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setAnchor,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setSwingLimitAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistLowLimit,pJointLimit)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getSwingLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistLowLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setJointSpring,pSpring)\r\n\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getSwingSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getTwistSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getJointSpring)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Prismatic\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPrismatic*,castPrismatic)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Cylindrical\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointCylindrical*,castCylindrical)\r\n\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,enableCollision,int)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointInPlane*,castPointInPlane)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointOnLine*,castPointOnLine)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT BASE \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_1(pJoint,void,setLocalAnchor0,VxVector)\r\n\r\n\t\tDECLAREMETHOD_2(pJoint,void,setBreakForces,float,float)\r\n\t\tDECLAREMETHOD_2(pJoint,void,getBreakForces,float&,float&)\r\n\t\tDECLAREMETHOD_3(pJoint,int,addLimitPlane,VxVector,VxVector,float)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pJoint,void,setLimitPoint,VxVector,NODEFAULT,bool,true)\r\n\t\tDECLAREMETHOD_0(pJoint,void,purgeLimitPlanes)\r\n\t\tDECLAREMETHOD_0(pJoint,void,resetLimitPlaneIterator)\r\n\t\tDECLAREMETHOD_0(pJoint,int,hasMoreLimitPlanes)\r\n\t\tDECLAREMETHOD_3(pJoint,int,getNextLimitPlane,VxVector&,float&,float&)\r\n\t\tDECLAREMETHOD_0(pJoint,int,getType)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: DISTANCE\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointDistance*,castDistanceJoint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMinDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMaxDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor0,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor1,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMinDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMaxDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor0)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor1)\r\n\t\tDECLAREMETHOD_0(pJointDistance,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\t\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPulley*,castPulley)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setStiffness,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRatio,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRigid,int)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setMotor,pMotor)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getStiffness)\r\n\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getRatio)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getDistance)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,enableCollision,bool)\r\n\t\tDECLAREMETHOD_0(pJointPulley,pMotor,getMotor)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\tJOINT D6\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointD6*,castD6Joint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setTwistMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing1MotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing2MotionMode,D6MotionMode)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setXMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setYMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setZMotionMode,D6MotionMode)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//softwLimits\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getLinearLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setLinearLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing1Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing1Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing2Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing2Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistHighLimit,pJD6SoftLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistLowLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistLowLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getXDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setXDrive,pJD6Drive)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getYDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setYDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getZDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setZDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSwingDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwingDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getTwistDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSlerpDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSlerpDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDrivePosition,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveRotation,VxQuaternion)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveLinearVelocity,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveAngularVelocity,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,enableCollision,bool)\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tRigid Body Exports \r\n\t\t//\r\n\t\t//\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Forces */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addForce,const VxVector&,NODEFAULT, PForceMode, 0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addTorque,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalForce,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalTorque,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtPos, const VxVector&,NODEFAULT,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtLocalPos,const VxVector,NODEFAULT, const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtPos, const VxVector&, NODEFAULT,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtLocalPos, const VxVector&, NODEFAULT,const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Momentum */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularMomentum)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearMomentum)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Pose : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setPosition,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setRotation,const VxQuaternion&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,translateLocalShapePosition,VxVector)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Velocity : */\r\n\t\t/************************************************************************/\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,getMaxAngularSpeed)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearVelocity)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularVelocity)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Mass */\r\n\t\t/************************************************************************/\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMassOffset,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMaxAngularSpeed,float)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Hull */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,pWorld*,getWorld)\r\n\t\tDECLAREMETHOD_1(pRigidBody,pJoint*,isConnected,CK3dEntity*)\r\n\t\t//DECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\t\tDECLAREMETHOD_1_WITH_DEF_VALS(pRigidBody,float,getMass,CK3dEntity*,NULL)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getHullType)\r\n\r\n\t\tDECLAREMETHOD_2(pRigidBody,void,setGroupsMask,CK3dEntity*,const pGroupsMask&)\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getPointVelocity,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getLocalPointVelocity,VxVector)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isCollisionEnabled)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setKinematic,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isKinematic)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,enableGravity,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isAffectedByGravity)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSleeping,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isSleeping)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,lockTransformation,BodyLockFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,int,isBodyFlagOn,int)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSolverIterationCount,int)\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setCollisionsGroup,int,NODEFAULT,CK3dEntity*,)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,enableCollision,bool,NODEFAULT,CK3dEntity*,NULL)\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getCollisionsGroup)\r\n\t\tDECLAREMETHOD_2(pRigidBody,int,updateMassFromShapes,float,float)\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pRigidBody,int,addSubShape,CKMesh*,NULL,pObjectDescr,NODEFAULT,CK3dEntity*,NULL,VxVector,VxVector(),VxQuaternion,VxQuaternion())\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,int,removeSubShape,CKMesh*,NODEFAULT,float,0.0,float,0.0)\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\nswig.exe -c++ -csharp vtCSWindow.i\r\n#ifndef __PREREQS_H_\r\n#define __PREREQS_H_\r\n\r\n\r\nstruct xNetworkSettings;\r\nclass xNetInterface;\r\nclass vtConnection;\r\nclass xNetworkFactory;\r\nclass xNetObject;\r\nclass IMessages;\r\n\r\n\r\n\r\nclass xDistributedClass;\r\nclass xDistributed3DObjectClass;\r\nclass IDistributedClasses;\r\n\r\nclass xDistributedProperty;\r\nclass xDistributedPropertyInfo;\r\n\r\nclass xDistributedObject;\r\nclass xDistributedClient;\r\nclass xDistributed3DObject;\r\n\r\nstruct x3DObjectData;\r\n\r\nclass vtNetworkManager;\r\nclass IDistributedObjects;\r\nclass xPredictionSetting;\r\n//class Extrapolator;\r\n\r\n\r\n//class vtDistributedObjectsArrayType;\r\n\r\n\r\nnamespace TNL\r\n{\r\n\tclass NetInterface;\r\n\tclass GhostConnection;\r\n\tclass BitStream;\r\n\r\n}\r\n#include \"tnlNetBase.h\"\r\n#include \r\n//using namespace TNL;\r\n\r\ntypedef TNL::StringPtr xNString;\r\n\r\n#include \"stdlib.h\"\r\n#include \"map\"\r\n#include \r\n#include \r\n\r\n#endif\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t MidiEvent\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n#include \"../MidiManager.h\"\r\n\r\n\r\nCKERROR CreateMidiEventBehaviorProto(CKBehaviorPrototype **);\r\nint MidiEvent(const CKBehaviorContext& behcontext);\r\n\r\nCKERROR MidiEventCallBack(const CKBehaviorContext& behcontext); // CallBack Functioon\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO DECALRATION */\r\n/*******************************************************/\r\nCKObjectDeclaration\t*FillBehaviorMidiEventDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Midi Event\");\r\n\tod->SetDescription(\"Gets a Midi event ON/OFF.\");\r\n\tod->SetCategory(\"Controllers/Midi\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7c652f90,0x64404377));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateMidiEventBehaviorProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* PROTO CREATION */\r\n/*******************************************************/\r\nCKERROR CreateMidiEventBehaviorProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Midi Event\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"On\");\r\n\tproto->DeclareInput(\"Off\");\r\n\t\r\n\tproto->DeclareOutput(\"Activated\");\r\n\tproto->DeclareOutput(\"Deactivated\");\r\n\r\n\tproto->DeclareInParameter(\"Channel\", CKPGUID_INT, \"0\");\r\n\tproto->DeclareInParameter(\"Note 1\", CKPGUID_INT, \"0\");\r\n\t\r\n\tproto->DeclareLocalParameter(NULL, CKPGUID_BOOL, \"FALSE\"); // Combination was ok\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(MidiEvent);\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_VARIABLEPARAMETERINPUTS));\r\n\t\r\n proto->SetBehaviorCallbackFct( MidiEventCallBack );\r\n \r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* MAIN FUNCTION */\r\n/*******************************************************/\r\nint MidiEvent(const CKBehaviorContext& behcontext)\r\n{\r\n CKBehavior *beh = behcontext.Behavior;\r\n\r\n if( beh->IsInputActive(1) ){ // OFF\r\n beh->ActivateInput(1, FALSE);\r\n\r\n return CKBR_OK;\r\n }\r\n \r\n CKBOOL combiWasOK = FALSE;\r\n if( beh->IsInputActive(0) ){ // ON\r\n beh->ActivateInput(0, FALSE);\r\n beh->SetLocalParameterValue(0, &combiWasOK);\r\n } else {\r\n beh->GetLocalParameterValue(0, &combiWasOK);\r\n }\r\n\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n // Channel\r\n int channel=0;\r\n beh->GetInputParameterValue(0, &channel);\r\n\r\n int note, count = beh->GetInputParameterCount();\r\n //--- test if all input notes are activated or not\r\n for( int a=1 ; aGetInputParameterValue(a, &note);\r\n if( !mm->IsNoteActive(note, channel) ) break;\r\n }\r\n\r\n if( a==count ){ // All notes are pressed\r\n if( !combiWasOK ){\r\n beh->ActivateOutput(0);\r\n \r\n combiWasOK = TRUE;\r\n beh->SetLocalParameterValue(0, &combiWasOK);\r\n \r\n return CKBR_ACTIVATENEXTFRAME;\r\n }\r\n } else { // Not all notes are pressed\r\n if( combiWasOK ){\r\n beh->ActivateOutput(1);\r\n \r\n combiWasOK = FALSE;\r\n beh->SetLocalParameterValue(0, &combiWasOK);\r\n \r\n return CKBR_ACTIVATENEXTFRAME;\r\n }\r\n }\r\n\r\n return CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\n\r\n/*******************************************************/\r\n/* CALLBACK */\r\n/*******************************************************/\r\nCKERROR MidiEventCallBack(const CKBehaviorContext& behcontext){\r\n CKBehavior *beh = behcontext.Behavior;\r\n MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n\r\n switch( behcontext.CallbackMessage ){\r\n \r\n case CKM_BEHAVIOREDITED:\r\n {\r\n int c_pin = beh->GetInputParameterCount();\r\n \r\n char name[20];\r\n\r\n CKParameterIn *pin;\r\n for( int a=2 ; aGetInputParameter(a);\r\n sprintf( name, \"Note %d\", a);\r\n pin->SetName( name );\r\n pin->SetGUID( CKPGUID_INT );\r\n }\r\n } break;\r\n \r\n case CKM_BEHAVIORATTACH:\r\n case CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tmm->AddMidiBBref();\r\n\t\t} break;\r\n case CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tmm->RemoveMidiBBref();\r\n\t\t} break;\r\n }\r\n \r\n return CKBR_OK; \r\n}\r\n\n\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\t\n\t\t\n\t\n\n/******************************************************************************\r\nFile : CustomPlayer.cpp\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n/*\r\nint le = GetLastError();\r\nXString buf;\r\nbuf.Format(\"le:%d\",le);\r\nMessageBox(NULL,buf.Str(),\"\",1);\r\n*/\r\n\r\n#include \"CPStdAfx.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"CustomPlayerDialog.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n// include file used for the static configuration\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#include \"CustomPlayerRegisterDllsExtra.h\"\r\n#endif\r\n\r\n\r\n\r\nextern CCustomPlayerApp theApp;\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\n\r\nextern CKERROR LoadCallBack(CKUICallbackStruct& loaddata,void*);\r\nint\r\nCCustomPlayer::InitEngine(HWND iMainWindow)\r\n{\r\n\r\n\tm_MainWindow = iMainWindow;\r\n\t// start the Virtools Engine\r\n\tCKStartUp();\r\n\r\n\t// retrieve the plugin manager ...\r\n\tCKPluginManager* pluginManager = CKGetPluginManager();\r\n\r\n\t// ... to intialize plugins ...\r\n\tif (!_InitPlugins(*pluginManager)) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_PLUGINS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// ... and the render engine.\r\n\tint renderEngine = _InitRenderEngines(*pluginManager);\r\n\tif (renderEngine==-1) {\r\n\t\tMessageBox(NULL,UNABLE_TO_LOAD_RENDERENGINE,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tXString inifile = CKGetStartPath();\r\n\tinifile << \"CompositionPrefs_R_Hi.ini\";\r\n\tCKERROR res = CKCreateContext(&m_CKContext,m_MainWindow,inifile.Str());\r\n\tif (res!=CK_OK) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_CK,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// retrieve the main managers which will be used by the player\r\n\tm_MessageManager\t= m_CKContext->GetMessageManager();\r\n\tm_RenderManager\t\t= m_CKContext->GetRenderManager();\r\n\tm_TimeManager\t\t= m_CKContext->GetTimeManager();\r\n\tm_AttributeManager\t= m_CKContext->GetAttributeManager();\r\n\r\n\tm_InputManager\t\t= (CKInputManager*)m_CKContext->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n\tif (!m_MessageManager || !m_RenderManager || !m_TimeManager || !m_AttributeManager || !m_InputManager) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_MANAGERS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// initialize the display driver using the player configuration (resolution, rasterizer, ...)\r\n\tif (!_InitDriver()) {\t\t\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_DRIVER,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n\r\n\r\nBOOL CCustomPlayer::InitPlayer(HWND iMainWindow, HWND iRenderWindow, int iConfig, const void* iData,int iDataSize)\r\n{\r\n\r\n\t// keep a reference on the main/render window\r\n\tm_MainWindow = iMainWindow;\r\n\tm_RenderWindow = iRenderWindow;\r\n\r\n\r\n\r\n\t// start the Virtools Engine\r\n\t//CKInitCustomPlayer(false);\r\n\tCKStartUp();\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// we have unmet requirements ? \r\n\tXString errorText;\r\n\tint hasError = DoSystemCheck(errorText);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// show splash when we have no error and we are not in the explicit configuration mode ( invoked by : \"CustomPlayer.exe -c \") : \r\n\tif( GetPAppStyle()->UseSplash() && !hasError && PGetApplicationMode() != config )\r\n\t{\r\n\t\tShowSplash();\r\n\t}\r\n\r\n\r\n\t// retrieve the plugin manager ...\r\n\tCKPluginManager* pluginManager = CKGetPluginManager();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// ... to intialize plugins ...\r\n\tif (!_InitPlugins(*pluginManager)) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_PLUGINS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// ... and the render engine.\r\n\tint renderEngine = _InitRenderEngines(*pluginManager);\r\n\tif (renderEngine==-1) \r\n\t{\r\n\t\tMessageBox(NULL,UNABLE_TO_LOAD_RENDERENGINE,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// now create the CK context\r\n\tXString inifile = CKGetStartPath();\r\n\tinifile << \"CompositionPrefs_R_Hi.ini\";\r\n\tCKERROR res = CKCreateContext(&m_CKContext,m_MainWindow,inifile.Str());\r\n\tif (res!=CK_OK) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_CK,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\t// if the player is not static\r\n\r\n\tchar BehaviorPath[_MAX_PATH];\r\n\tchar szPath[_MAX_PATH];\r\n\tVxGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\tCKPathSplitter ps(szPath);\r\n\tsprintf(BehaviorPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->BehaviorPath.Str());\r\n\tpluginManager->ParsePlugins(BehaviorPath);\r\n\r\n#endif\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// adding load callback\r\n\tif(GetPAppStyle()->UseSplash() && !m_LastError && PGetApplicationMode() != config )\r\n\t{\r\n\t\tif (GetPAppStyle()->ShowLoadingProcess())\r\n\t\t{\r\n\t\t\t\r\n\t\t\tm_CKContext->SetInterfaceMode(FALSE,LoadCallBack,NULL);\r\n\t\t}\r\n\t}\r\n\r\n\t// retrieve the main managers which will be used by the player\r\n\tm_MessageManager\t= m_CKContext->GetMessageManager();\r\n\tm_RenderManager\t\t= m_CKContext->GetRenderManager();\r\n\tm_TimeManager\t\t= m_CKContext->GetTimeManager();\r\n\tm_AttributeManager\t= m_CKContext->GetAttributeManager();\r\n\t\r\n\tm_EnginePointers.TheMessageManager = m_MessageManager;\r\n\tm_EnginePointers.TheRenderManager = m_RenderManager;\r\n\tm_EnginePointers.TheTimeManager = m_TimeManager;\r\n\tm_EnginePointers.TheCKContext = m_CKContext;\r\n\t\r\n\r\n\t//We have an error, show our dialog : \r\n\tif (hasError)\r\n\t{\r\n\t\tAfxInitRichEdit2();\r\n\t\tCustomPlayerDialog k(NULL,CString(errorText.Str()));\r\n\t\tk.DoModal();\r\n\t\tif (CPA_ABORT_ON_ERROR)\r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\t\r\n\r\n\r\n\r\n\tm_InputManager\t\t= (CKInputManager*)m_CKContext->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n\tif (!m_MessageManager || !m_RenderManager || !m_TimeManager || !m_AttributeManager || !m_InputManager) {\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_MANAGERS,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\t// initialize the display driver using the player configuration (resolution, rasterizer, ...)\r\n\tif (!_InitDriver()) {\t\t\r\n\t\tMessageBox(NULL,UNABLE_TO_INIT_DRIVER,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\tPLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,\"Textures\",0);\r\n\tPLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,\"Data\",1);\r\n\tPLoadResourcePaths(CUSTOM_PLAYER_CONFIG_FILE,\"Music\",2);\r\n\r\n\r\n\r\n\t// now load the composition\r\n\tif (iDataSize) { // if iDataSize is not null it means the composition is already in memory\r\n\t\tif (_Load(iData,iDataSize)!=CK_OK) {\r\n\t\t\tMessageBox(NULL,\"Unable to load composition from memory.\",\"Initialization Error\",MB_OK|MB_ICONERROR);\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t} else if (_Load((const char*)iData)!=CK_OK) { // else we load it from a file (iData contains the filename)\r\n\t\tMessageBox(NULL,\"Unable to load composition from file.\",\"Initialization Error\",MB_OK|MB_ICONERROR);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t//GetPlayer().HideSplash();\r\n\r\n\t//show our dialog ? \r\n\tif (GetPAppStyle()->g_ShowDialog)\r\n\t{\r\n\t\tAfxInitRichEdit2();\r\n\t\tCustomPlayerDialog k(NULL,CString(errorText.Str()));\r\n\t\tk.DoModal();\r\n\t}\r\n\r\n\t\r\n\r\n\r\n\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\t// update of our member variables\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tm_WindowedHeight = ewinfo->g_HeightW;\r\n\tm_WindowedWidth = ewinfo->g_WidthW;\r\n\t\r\n\tm_FullscreenWidth = ewinfo->g_Width;\r\n\tm_FullscreenHeight = ewinfo->g_Height;\r\n\r\n\tif(ewinfo->g_GoFullScreen)\r\n\t\tm_Driver = ewinfo->g_FullScreenDriver;\r\n\telse\r\n\t\tm_Driver = ewinfo->g_WindowedDriver;\r\n\r\n\tm_FullscreenBpp = ewinfo->g_Bpp;\r\n\t\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tCKVariableManager *vm = (CKVariableManager *)m_EnginePointers.TheCKContext->GetVariableManager();\r\n\tvm->SetValue(\"CK2_3D/Antialias\", GetEWindowInfo()->FSSA * 2 );\r\n \r\n\r\n\tif(PGetApplicationMode() != config)\r\n\t{\r\n\t\t \r\n\t\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t\t{\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// create the render context\r\n\t\t\tif (GetEWindowInfo()->g_GoFullScreen) \r\n\t\t\t{\r\n\t\t\t\t// in fullscreen we specify the rendering size using a rectangle (CKRECT)\r\n\t\t\t\tCKRECT rect;\r\n\t\t\t\trect.left = 0;\r\n\t\t\t\trect.top = 0;\r\n\t\t\t\trect.right = m_FullscreenWidth;\r\n\t\t\t\trect.bottom = m_FullscreenHeight;\r\n\t\t\t\t// create the render context\r\n\t\t\t\r\n\t\t\t\tm_RenderContext = m_RenderManager->CreateRenderContext(m_RenderWindow,GetEWindowInfo()->g_FullScreenDriver,&rect,TRUE,m_FullscreenBpp);\r\n\r\n\t\t\t\t// set the position of the render window\r\n\r\n\t\t\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_FullscreenWidth,m_FullscreenHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\r\n\t\t\t\t// resize the render context\r\n\t\t\t\tif (m_RenderContext) {\r\n\t\t\t\t\tm_RenderContext->Resize(0,0,m_FullscreenWidth,m_FullscreenHeight);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t// [2/18/2008 mc007]\r\n // we only repositioning the window when we are not displayed by a hosting application like\r\n\t\t\t\t// a charp panel !\r\n\t\t\t\tif (!GetPAppStyle()->g_OwnerDrawed)\r\n\t\t\t\t{\r\n\t\t\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\t\t\tst|=WS_THICKFRAME;\r\n\t\t\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\r\n\t\t\t\t\t//reposition the window\r\n\t\t\t\t\tm_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;\r\n\t\t\t\t\tm_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;\r\n\t\t\t\t\tm_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;\r\n\t\t\t\t\tm_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;\r\n\t\t\t\t\tBOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t\t\t\t::SetWindowPos(m_MainWindow,0,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);\r\n\r\n\t\t\t\t\t// set the position of the render window\r\n\t\t\t\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\t\t\t\t}\r\n\t\t\t\t// create the render context\r\n\t\t\t\tm_RenderContext = m_RenderManager->CreateRenderContext(m_RenderWindow,m_Driver,0,FALSE);\r\n\r\n\t\t\t\t// resize the render context\r\n\t\t\t\tif (m_RenderContext) {\r\n\t\t\t\t\tm_RenderContext->Resize(0,0,m_WindowedWidth,m_WindowedHeight);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// when somebody changed any resolution in the configuration tab , we should update our windows : \r\n\t\t\t//store current size\r\n\t\t\t/*\r\n\t\t\tGetWindowRect(m_MainWindow,&m_MainWindowRect);\r\n\r\n\t\t\tLONG st = GetWindowLong(m_MainWindow,GWL_STYLE);\r\n\t\t\tst|=WS_THICKFRAME;\r\n\t\t\tst&=~WS_SIZEBOX;\r\n\t\t\tSetWindowLong(m_MainWindow,GWL_STYLE,st);\r\n\r\n\t\t\t//reposition the window\r\n\t\t\tm_MainWindowRect.left = (GetSystemMetrics(SM_CXSCREEN)-m_WindowedWidth)/2;\r\n\t\t\tm_MainWindowRect.right = m_WindowedWidth+m_MainWindowRect.left;\r\n\t\t\tm_MainWindowRect.top = (GetSystemMetrics(SM_CYSCREEN)-m_WindowedHeight)/2;\r\n\t\t\tm_MainWindowRect.bottom = m_WindowedHeight+m_MainWindowRect.top;\r\n\t\t\tBOOL ret = AdjustWindowRect(&m_MainWindowRect,WS_OVERLAPPEDWINDOW & ~(WS_SYSMENU|WS_SIZEBOX|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX),FALSE);\r\n\t\t\t::SetWindowPos(m_MainWindow,0,m_MainWindowRect.left,m_MainWindowRect.top,m_MainWindowRect.right - m_MainWindowRect.left,m_MainWindowRect.bottom - m_MainWindowRect.top,NULL);\r\n\r\n\t\t\t// and set the position of the render window in the main window\r\n\t\t\t::SetWindowPos(m_RenderWindow,NULL,0,0,m_WindowedWidth,m_WindowedHeight,SWP_NOMOVE|SWP_NOZORDER);\r\n\t\t\tm_RenderContext->Resize(0,0,GetEWindowInfo()->g_GoFullScreen ? m_FullscreenWidth : m_WindowedWidth, GetEWindowInfo()->g_GoFullScreen ? m_FullscreenHeight : m_WindowedHeight);*/\r\n\r\n\r\n\t\t\tif (!m_RenderContext) {\r\n\t\t\t\tMessageBox(NULL,UNABLE_TO_CREATE_RENDERCONTEXT,INIT_ERROR,MB_OK|MB_ICONERROR);\r\n\t\t\t\treturn FALSE;\r\n\t\t\t}\r\n\r\n\r\n\t\t\t\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// clear the render view\r\n\t\t\tm_RenderContext->Clear();\r\n\t\t\tm_RenderContext->BackToFront();\r\n\t\t\tm_RenderContext->Clear();\r\n\t\t}\r\n\r\n\r\n\t\t// finalize the loading\r\n\t\tif (!_FinishLoad()) \r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL CCustomPlayer::_InitDriver()\r\n{\r\n\tint count = m_RenderManager->GetRenderDriverCount();\r\n\tint i = 0;\r\n\r\n\t// first, we try to get exactly what is required\r\n\tint checkFlags = eFamily | eDirectXVersion | eSoftware;\r\n\tfor (i=0;iGetRenderDriverDescription(i);\r\n\t\tif (!desc) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (_CheckDriver(desc,checkFlags)) {\r\n\t\t\tm_Driver = i;\r\n\t\t\t_CheckFullscreenDisplayMode(TRUE);\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\tif (m_RasterizerFamily == CKRST_OPENGL) {\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// if we did not find a driver,\r\n\t// we only check family and software flags\r\n\tcheckFlags &= ~eDirectXVersion;\r\n\tfor (i=0;iGetRenderDriverDescription(i);\r\n\t\tif (!desc) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif (_CheckDriver(desc,checkFlags)) {\r\n\t\t\tm_Driver = i;\r\n\t\t\t_CheckFullscreenDisplayMode(TRUE);\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\t}\r\n\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL CCustomPlayer::_InitPlugins(CKPluginManager& iPluginManager)\r\n{\r\n\r\n\tchar szPath[_MAX_PATH];\r\n\tchar BehaviorPath[_MAX_PATH];\r\n\t\r\n\r\n#if !defined(CUSTOM_PLAYER_STATIC)\r\n\t// if the player is not static\r\n\r\n\t\r\n\tchar PluginPath[_MAX_PATH];\r\n\tchar RenderPath[_MAX_PATH];\r\n\tchar ManagerPath[_MAX_PATH];\r\n\r\n\tVxGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\tCKPathSplitter ps(szPath);\r\n\tsprintf(PluginPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->PluginPath.Str());\r\n\tsprintf(RenderPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->RenderPath.Str());\r\n\tsprintf(ManagerPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->ManagerPath.Str());\r\n\tsprintf(BehaviorPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->BehaviorPath.Str());\r\n\r\n\t// we initialize plugins by parsing directories\r\n\tiPluginManager.ParsePlugins(RenderPath);\r\n\tiPluginManager.ParsePlugins(ManagerPath);\r\n\tiPluginManager.ParsePlugins(BehaviorPath);\r\n\tiPluginManager.ParsePlugins(PluginPath);\r\n\r\n#else\r\n\t// else if the player is static\r\n\t// we initialize plugins by manually register them\r\n\t// for an exemple look at CustomPlayerRegisterDlls.h\r\n\tCustomPlayerRegisterRenderEngine(iPluginManager);\r\n\tCustomPlayerRegisterReaders(iPluginManager);\r\n\tCustomPlayerRegisterManagers(iPluginManager);\r\n\tCustomPlayerRegisterBehaviors(iPluginManager);\r\n\tCustomPlayerRegisterBehaviorsExtra(iPluginManager);\r\n\r\n\r\n\tVxGetModuleFileName(NULL,szPath,_MAX_PATH);\r\n\tCKPathSplitter ps(szPath);\r\n\tsprintf(BehaviorPath,\"%s%s%s\",ps.GetDrive(),ps.GetDir(),GetEPathProfile()->BehaviorPath.Str());\r\n\t//iPluginManager.ParsePlugins(BehaviorPath);\r\n\r\n#endif\r\n\r\n\treturn TRUE;\r\n}\r\n\r\nint CCustomPlayer::_InitRenderEngines(CKPluginManager& iPluginManager)\r\n{\r\n\t// here we look for the render engine (ck2_3d)\r\n\tint count = iPluginManager.GetPluginCount(CKPLUGIN_RENDERENGINE_DLL);\r\n\tfor (int i=0;im_PluginDllIndex); \r\n#if !defined(CUSTOM_PLAYER_STATIC)\r\n\t\tXWORD pos = dll->m_DllFileName.RFind(DIRECTORY_SEP_CHAR);\r\n\t\tif (pos==XString::NOTFOUND)\r\n\t\t\tcontinue;\r\n\t\tXString str = dll->m_DllFileName.Substring(pos+1);\r\n\t\tif (strnicmp(str.CStr(),\"ck2_3d\",strlen(\"ck2_3d\"))==0)\r\n\t\t\treturn i;\r\n#else\r\n\t\tif (dll->m_DllFileName.ICompare(\"ck2_3d\")==0)\r\n\t\t\treturn i;\r\n#endif\r\n\t}\r\n\r\n\treturn -1;\r\n}\r\n\r\n\r\n#include \"ISession.h\"\r\n#include \"xDistributedSessionClass.h\"\r\n#include \"xDistributedSession.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\n\r\nvoid ISession::deleteSession(int sessionID)\r\n{\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif ( netInterface && netInterface->IsServer())\r\n\t{\r\n\t\txDistributedSession *session = get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\r\n\t\t\tIDistributedObjects *doInterface = netInterface->getDistObjectInterface();\r\n\t\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\t\txDistObjectIt begin = distObjects->begin();\r\n\t\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\t\twhile (begin!=end)\r\n\t\t\t{\r\n\t\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\t\tif (distObject)\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\t\tif (_class)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\t\tif (distClient && distClient->getSessionID() == sessionID )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tdistClient->setSessionID(-1);\r\n\t\t\t\t\t\t\t\tdisableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED);\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbegin++;\r\n\t\t\t}\r\n\t\t\r\n\t\t\tdoInterface->deleteObject((xDistributedObject*)session);\r\n\r\n\t\t}else\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,\"couldn't find session %d\",sessionID);\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid ISession::unlockSession(int userID,int sessionID)\r\n{\r\n\r\n\txNetInterface *netInterface = getNetInterface();\r\n\r\n\tif ( netInterface && !netInterface->IsServer() && netInterface->isValid())\r\n\t{\r\n\t\txDistributedSession *session = get(sessionID);\r\n\t\tif ( session)\r\n\t\t{\r\n\r\n\t\t\tif (session->getUserID() != userID)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,\"User %d must be session master !\",userID);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tint sessionLocked = 0;\r\n\t\t\txDistributedInteger *pLocked= (xDistributedInteger *)session->getProperty(E_DC_S_NP_LOCKED);\r\n\t\t\tpLocked->updateValue(sessionLocked,0);\r\n\t\t\tpLocked->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid ISession::lockSession(int userID,int sessionID)\r\n{\r\n\r\n\txNetInterface *netInterface = getNetInterface();\r\n\r\n\tif ( netInterface && !netInterface->IsServer() && netInterface->isValid())\r\n\t{\r\n\t\txDistributedSession *session = get(sessionID);\r\n\t\tif ( session)\r\n\t\t{\r\n\r\n\t\t\tif (session->getUserID() != userID)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,\"User %d must be session master !\",userID);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tint sessionLocked = 1;\r\n\t\t\txDistributedInteger *pLocked= (xDistributedInteger *)session->getProperty(E_DC_S_NP_LOCKED);\r\n\t\t\tpLocked->updateValue(sessionLocked,0);\r\n\t\t\tpLocked->setFlags(E_DP_NEEDS_SEND);\r\n\t\t\treturn ;\r\n\t\t}\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint ISession::removeClient(xDistributedClient*client,int sessionID,bool destroy/* =false */)\r\n{\r\n\r\n\txNetInterface *netInterface = getNetInterface();\r\n\tif (client && netInterface && !netInterface->IsServer() && netInterface->isValid())\r\n\t{\r\n\t\tvtConnection *con = netInterface->getConnection();\r\n\t\txDistributedSession *session = get(sessionID);\r\n\t\txDistributedClient *myClient = netInterface->getMyClient();\r\n\t\tif ( con && session && myClient )\r\n\t\t{\r\n\r\n\t\t\tif (session->getUserID() !=myClient->getUserID() && myClient->getUserID()!=client->getUserID() )\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,\"You must be session master to remove a client !\");\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\r\n\t\t\txLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,\"Removing user :%d from session %d\",client->getUserID(),sessionID);\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\tcon->c2sLeaveSession_RPC(client->getUserID(),sessionID,destroy);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_DELETING,true);\r\n\t\t\tclient->getClientFlags().set(1 << E_CF_DELETED,false);\r\n\t\t}\r\n\t}else \r\n\t{\r\n\t\treturn -1;\r\n\t}\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//its our self who leaves the session\r\n\t//we must remove all other clients from the dist array : \r\n\txDistributedClient *myClient = netInterface->getMyClient();\r\n\tif (myClient && myClient->getUserID() == client->getUserID() && netInterface->getCurrentSession() )\r\n\t{\r\n\r\n\t\r\n\t\tIDistributedObjects *doInterface = netInterface->getDistObjectInterface();\r\n\t\txDistributedObjectsArrayType *distObjects = netInterface->getDistributedObjects();\r\n\t\txDistObjectIt begin = distObjects->begin();\r\n\t\txDistObjectIt end = distObjects->end();\r\n\r\n\t\twhile (begin!=end)\r\n\t\t{\r\n\t\t\txDistributedObject *distObject = *begin;\r\n\t\t\tif (distObject)\r\n\t\t\t{\r\n\t\t\t\txDistributedClass *_class = distObject->getDistributedClass();\r\n\t\t\t\tif (_class)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_CLIENT )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\txDistributedClient *distClient = static_cast(distObject);\r\n\t\t\t\t\t\tif (distClient)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (distClient->getUserID() != myClient->getUserID() &&\r\n\t\t\t\t\t\t\t\tdistClient->getSessionID()==sessionID )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tdistClient->getClientFlags().set(1 << E_CF_DELETING,true);\r\n\t\t\t\t\t\t\t\tdistClient->getClientFlags().set(1 << E_CF_DELETED,false);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbegin++;\r\n\t\t}\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint ISession::joinClient(xDistributedClient*client, int sessionID,xNString password)\r\n{\r\n\r\n\txNetInterface *netInterface = getNetInterface();\r\n\t\r\n\tif (netInterface && !netInterface->IsServer() && netInterface->isValid())\r\n\t{\r\n\t\txDistributedSession *session = get(sessionID);\r\n\t\tif (session)\r\n\t\t{\r\n\t\t\tvtConnection *con = netInterface->getConnection();\r\n\t\t\tif ( con)\r\n\t\t\t{\r\n\t\t\t\tcon->c2sJoinSession_RPC(client->getUserID(),sessionID,password);\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn -1;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedSession*ISession::get(int sessionID)\r\n{\r\n\r\n\tif (!getNetInterface())\t{\t\treturn NULL;\t}\r\n\tif (!getNetInterface()->getDistributedObjects())return NULL;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj && dobj->getDistributedClass() && dobj->getDistributedClass()->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t{\r\n\t\t\txDistributedSession *session = static_cast(dobj);\r\n\t\t\tif (session && session->getSessionID() == sessionID)\r\n\t\t\t\treturn session;\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\treturn NULL;\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedSession*ISession::getByUserID(int userID)\r\n{\r\n\r\n\tif (!getNetInterface())\t{\t\treturn NULL;\t}\r\n\tif (!getNetInterface()->getDistributedObjects())return NULL;\r\n\treturn static_cast(getNetInterface()->getDistObjectInterface()->getByUserID(userID,E_DC_BTYPE_SESSION));\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nxDistributedSession* ISession::get(xNString name)\r\n{\r\n\r\n\tif (!getNetInterface())\t{\t\treturn NULL;\t}\r\n\tif (!getNetInterface()->getDistributedObjects())return NULL;\r\n\r\n\txDistributedObjectsArrayType *distObjects = getNetInterface()->getDistributedObjects();\r\n\treturn static_cast(getNetInterface()->getDistObjectInterface()->get(name,E_DC_BTYPE_SESSION));\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nint\r\nISession::create(xNString name,int maxUsers,xNString password,int type)\r\n{\r\n\r\n\tint result = -1 ;\r\n\r\n\tif (getNetInterface() && getNetInterface()->isValid() && !getNetInterface()->IsServer() )\r\n\t{\r\n\t\tvtConnection *con = getNetInterface()->getConnection();\r\n\t\tcon->c2sCreateSession_RPC(name,type,maxUsers,password);\r\n\t}\r\n\r\n\treturn result ;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pWorldSettings.h\"\r\n\r\n#include \r\n\r\nstd::vector&_getValidDominanceGroups(std::vector&_inputGroups,pDominanceSetupItem *testItem)\r\n{\r\n\tstd::vector result;\r\n\r\n\tif (!_inputGroups.size())\r\n\t\treturn result;\r\n\r\n\r\n\t/*\r\n\r\n\tg1A + g1A \r\n\tg1A != g1B !\r\n\r\n\tg2A + g2B\r\n\r\n\t1 2 3\r\n\r\n\r\n\t1 : 1 - 2\r\n\t2 : 1 - 3\r\n\r\n\t*/\r\n\r\n\tfor (int i = 0 ; i < _inputGroups.size() ; i++)\r\n\t{\r\n\t\tpDominanceSetupItem* cItem =_inputGroups[i];\r\n\r\n\t\tif ( cItem == testItem )\r\n\t\t{\r\n\t\t\tresult.push_back(cItem);\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tif ( cItem->dominanceGroup0 != testItem->dominanceGroup0 )\r\n\t\t{\r\n\r\n\t\t}\r\n\r\n\t\t\r\n\t}\r\n\r\n}\r\n\r\n\r\nvoid pWorld::_checkForDominanceConstraints()\r\n{\r\n\r\n#ifndef _DEBUG\r\n\tassert(getReference());\r\n\tassert(getScene());\r\n#endif\r\n\r\n\tint att = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_DOMINANCE_SCENE_SETTINGS);\r\n\t\r\n\tif (!getReference()->HasAttribute(att)) \r\n\t\treturn;\r\n\r\n\tCKParameterOut *domPar = getReference()->GetAttributeParameter(att);\r\n\tif(!domPar)\r\n\t\treturn;\r\n\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tusing namespace vtTools::AttributeTools;\r\n\r\n\r\n\tCKParameterOut *d1 = GetParameterFromStruct(domPar,PS_WDS_ITEM1);\r\n\tCKParameterOut *d2 = GetParameterFromStruct(domPar,PS_WDS_ITEM2);\r\n\tCKParameterOut *d3 = GetParameterFromStruct(domPar,PS_WDS_ITEM3);\r\n\tCKParameterOut *d4 = GetParameterFromStruct(domPar,PS_WDS_ITEM4);\r\n\tCKParameterOut *d5 = GetParameterFromStruct(domPar,PS_WDS_ITEM5);\r\n\r\n\tpDominanceSetupItem item1;\r\n\tpDominanceSetupItem item2;\r\n\tpDominanceSetupItem item3;\r\n\tpDominanceSetupItem item4;\r\n\tpDominanceSetupItem item5;\r\n\r\n\r\n\r\n\tint error = pFactory::Instance()->copyTo(d1,item1);\r\n\r\n\terror = pFactory::Instance()->copyTo(d2,item2);\r\n\terror = pFactory::Instance()->copyTo(d3,item3);\r\n\terror = pFactory::Instance()->copyTo(d4,item4);\r\n\terror = pFactory::Instance()->copyTo(d5,item5);\r\n\r\n\tstd::vector allDominanceItems;\r\n\t\r\n\t//################################################################\r\n\t//\r\n\t// gather all in an array\r\n\t//\r\n\r\n\r\n\r\n\tint a = item1.dominanceGroup0;\r\n\tint a1 = item1.dominanceGroup1;\r\n\t\r\n\tif (item1.dominanceGroup0 !=0 && item1.dominanceGroup1 !=0 && (item1.dominanceGroup0 != item1.dominanceGroup1 ) )\r\n\t\tallDominanceItems.push_back(&item1);\r\n\t\r\n\tif (item2.dominanceGroup0 !=0 && item2.dominanceGroup1 !=0 && (item2.dominanceGroup0 != item1.dominanceGroup1 ) )\r\n\t\tallDominanceItems.push_back(&item2);\r\n\t\r\n\tif (item3.dominanceGroup0 !=0 && item3.dominanceGroup1 !=0 && (item3.dominanceGroup0 != item3.dominanceGroup1 ) )\r\n\t\tallDominanceItems.push_back(&item3);\r\n\r\n\tif (item4.dominanceGroup0 !=0 && item4.dominanceGroup1 !=0 && (item4.dominanceGroup0 != item4.dominanceGroup1 ) )\r\n\t\tallDominanceItems.push_back(&item4);\r\n\r\n\tif (item5.dominanceGroup0 !=0 && item5.dominanceGroup1 !=0 && (item5.dominanceGroup0 != item5.dominanceGroup1 ) )\r\n\t\tallDominanceItems.push_back(&item5);\r\n\r\n\r\n\t//std::vector_validDominanceItems1 = _getValidDominanceGroups(allDominanceItems,&item1);\r\n\t//int s = _validDominanceItems1.size();\r\n\r\n\t\r\n\r\n\tfor (int i = 0 ; i < allDominanceItems.size() ; i++)\r\n\t{\r\n\t\tpDominanceSetupItem* cItem = allDominanceItems[i];\r\n\t\tNxConstraintDominance cD1( cItem->constraint.dominanceA , cItem->constraint.dominanceB );\r\n\t\t\r\n\t\tgetScene()->setDominanceGroupPair(cItem->dominanceGroup0, cItem->dominanceGroup1,cD1);\t\r\n\r\n\r\n\r\n\r\n\t}\r\n\r\n\t\r\n\r\n\r\n}\r\n\r\n\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\r\npWorldSettings::pWorldSettings() : \r\n\t\tm_Gravity(VxVector(0.0f,-9.81f,0.0f)) , \r\n\t\tm_SkinWith(0.1)\r\n{\r\n\r\n}\r\n\r\n\r\n}#include \"StdAfx.h\"\n#include \"pVehicleAll.h\"\n\n// Paint the stub wheel?\n//#define DO_PAINT_STUB\n\n#define DEF_LOCK 2\n#define DEF_RADIUS .20\n#define DEF_XA 20\n\n// Input scaling\n//#define MAX_INPUT 1000\n\nvoid pVehicleSteer::setToDefault()\n{\n\n\tradius = 10.0;\n\txa = 0.0f;\n\tlock = 80.0f;\n}\n\npVehicleSteer::pVehicleSteer(pVehicle *_car)\n{\n car=_car;\n angle=0;\n lock=5;\n xa=0;\n position.Set(0,0,0);\n radius=DEF_RADIUS;\n axisInput=0;\n}\npVehicleSteer::~pVehicleSteer()\n{\n \n}\n\n/*\nbool pVehicleSteer::Load(QInfo *info,cstring path)\n// 'path' may be 0, in which case the default \"steer\" is used\n{\n char buf[128];\n \n if(!path)path=\"steer\";\n\n // Location\n sprintf(buf,\"%s.x\",path);\n position.x=info->GetFloat(buf);\n sprintf(buf,\"%s.y\",path);\n position.y=info->GetFloat(buf);\n sprintf(buf,\"%s.z\",path);\n position.z=info->GetFloat(buf);\n sprintf(buf,\"%s.radius\",path);\n radius=info->GetFloat(buf,DEF_RADIUS);\n sprintf(buf,\"%s.xa\",path);\n xa=info->GetFloat(buf,DEF_XA);\n \n // Physical attribs\n sprintf(buf,\"%s.lock\",path);\n lock=info->GetFloat(buf,DEF_LOCK)/RR_RAD_DEG_FACTOR;\n\n // Model (was new'ed in the ctor)\n model->Load(info,path);\n if(!model->IsLoaded())\n {\n // Stub gfx\n quad=gluNewQuadric();\n }\n//qdbg(\"RSteer: r=%f, xa=%f\\n\",radius,xa);\n return TRUE;\n}\n*/\n/*******\n* Dump *\n*******/\n/*\nbool RSteer::LoadState(QFile *f)\n{\n f->Read(&angle,sizeof(angle));\n // 'axisInput'?\n return TRUE;\n}\nbool RSteer::SaveState(QFile *f)\n{\n f->Write(&angle,sizeof(angle));\n return TRUE;\n}\n*/\n/**********\n* Attribs *\n**********/\n\n/********\n* Paint *\n********/\n\n/**********\n* Animate *\n**********/\nvoid pVehicleSteer::Integrate()\n{\n//qdbg(\"RSteer: steerPos=%d => angle=%f deg\\n\",axisInput,angle*RR_RAD_DEG_FACTOR);\n}\n\n/********\n* Input *\n********/\nvoid pVehicleSteer::SetInput(int steerPos)\n// 'steerPos' is the angle of the input steering wheel\n// ranging from -1000..+1000\n{\n float a;\n\n // Clip\n if(steerPos<-1000)\n\t steerPos=-1000;\n else if(steerPos>1000)\n\t steerPos=1000;\n \n axisInput=steerPos;\n \n // Take controller position\n a=((float)axisInput)*lock/1000.0;\n//qdbg(\"RSteer: axisInput=%d, a=%f,lock=%f\\n\",axisInput,a,lock);\n // Set this directly as the steering wheel's angles\n // But notice that because of counterclockwise angles being >0,\n // the sign is reversed\n angle=a;\n}\nstatic char* sErrorStrings[]=\r\n{\r\n\t\"OK\",\r\n\t\"\\t Intern :\",\r\n\t\"\\t No connection :\",\r\n\t\"\\t Not joined to a session:\",\r\n\t\"\\t Session needs right password:\",\r\n\t\"\\t Session is locked:\",\r\n\t\"\\t Session already exists:\",\r\n\t\"\\t Session is full:\",\r\n\t\"\\t You must be session master:\",\r\n\t\"\\t Invalid parameter :\",\r\n\t\"\\t There is not such user :\",\r\n\t\"\\t Distributed class already exists :\",\r\n\t\"\\t Couldn't connect to any server :\",\r\n\t\"\\t You already joined to a session :\",\r\n\t\"\\t No such session :\"\r\n};#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"NXU_helper.h\" // NxuStream helper functions.\r\n#include \"NXU_PhysicsInstantiator.h\"\r\n\r\n\r\nvoid pRigidBody::updateWheels(float step)\r\n{\r\n\r\n\t\r\n\r\n\tNxVec3 _localVelocity;\r\n\r\n\tbool _breaking=false;\r\n\r\n\r\n\t/*\r\n\t_computeMostTouchedActor();\r\n\tNxVec3 relativeVelocity;\r\n\tif (_mostTouchedActor == NULL || !_mostTouchedActor->isDynamic())\r\n\t{\r\n\t\trelativeVelocity = getActor()->getLinearVelocity();\r\n\t} else {\r\n\t\trelativeVelocity = getActor()->getLinearVelocity() - _mostTouchedActor->getLinearVelocity();\r\n\t}\r\n\tNxQuat rotation = getActor()->getGlobalOrientationQuat();\r\n\tNxQuat global2Local;\r\n\t_localVelocity = relativeVelocity;\r\n\trotation.inverseRotate(_localVelocity);\r\n\tchar master[512];\r\n\t*/\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t{\r\n\t\t\t\tpWheel *wheel = sinfo->wheel;\r\n\t\t\t\tpWheel2* wheel2 = dynamic_cast(wheel);\r\n\t\t\t\t\r\n\t\t\t\tif (wheel->getWheelFlag(WF_VehicleControlled))\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\twheel->_tick(step / GetPMan()->GetContext()->GetTimeManager()->GetTimeScaleFactor());\r\n\r\n\t\t\t\t/*\r\n\r\n\t\t\t\tNxWheelShape *wShape = wheel2->getWheelShape();\r\n\t\t\t\tif (!wShape) continue;\r\n\r\n\r\n\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//\r\n\t\t\t\t//\r\n\t\t\t\t//\r\n\t\t\t\tNxWheelContactData wcd; \r\n\t\t\t\tNxShape* contactShape = wShape->getContact(wcd);\r\n\t\t\t\t\r\n\t\t\t\tif (contactShape)\r\n\t\t\t\t{\r\n\t\t\t\t\t\r\n\t\t\t\t\tNxVec3 relativeVelocity;\r\n\t\t\t\t\tif ( !contactShape->getActor().isDynamic())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trelativeVelocity = getActor()->getLinearVelocity();\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\trelativeVelocity = getActor()->getLinearVelocity() - contactShape->getActor().getLinearVelocity();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tNxQuat rotation = getActor()->getGlobalOrientationQuat();\r\n\r\n\t\t\t\t\t_localVelocity = relativeVelocity;\r\n\t\t\t\t\trotation.inverseRotate(_localVelocity);\r\n\t\t\t\t\t_breaking = NxMath::abs(_localVelocity.z) < ( 0.1 );\r\n//\t\t\t\t\twShape->setAxleSpeed()\r\n\t\t\t\t}\r\n\r\n\t\t\r\n\t\t\t\tfloat rollAngle = wheel2->getWheelRollAngle();\r\n\t\t\t\trollAngle+=wShape->getAxleSpeed() * (step* 0.01f);\r\n\t\t\t\twhile (rollAngle > NxTwoPi)\t//normally just 1x\r\n\t\t\t\t\trollAngle-= NxTwoPi;\r\n\t\t\t\twhile (rollAngle< -NxTwoPi)\t//normally just 1x\r\n\t\t\t\t\trollAngle+= NxTwoPi;\r\n\t\t\t\t\r\n\t\t\t\twheel2->setWheelRollAngle(rollAngle);\r\n\r\n\t\t\t\tNxMat34& wheelPose = wShape->getGlobalPose();\r\n\r\n\t\t\t\t\r\n\t\t\t\tNxReal stravel = wShape->getSuspensionTravel();\r\n\t\t\t\tNxReal radius = wShape->getRadius();\r\n\r\n\r\n\t\t\t\t//have ground contact?\r\n\t\t\t\tif( contactShape && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\t\t\t\twheelPose.t = NxVec3( wheelPose.t.x, wcd.contactPoint.y + wheel2->getRadius(), wheelPose.t.z );\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\twheelPose.t = NxVec3( wheelPose.t.x, wheelPose.t.y - wheel2->getSuspensionTravel(), wheelPose.t.z );\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfloat rAngle = wheel2->getWheelRollAngle();\r\n\t\t\t\tfloat steer = wShape->getSteerAngle();\r\n\r\n\t\t\t\tNxMat33 rot, axisRot, rollRot;\r\n\t\t\t\trot.rotY( wShape->getSteerAngle() );\r\n\t\t\t\taxisRot.rotY(0);\r\n\t\t\t\trollRot.rotX(rAngle);\r\n\t\t\t\twheelPose.M = rot * wheelPose.M * axisRot * rollRot;\r\n\t\t\t\twheel2->setWheelPose(wheelPose);\r\n\r\n\t\t\t\t*/\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n/*\t//motorTorque *= 0.1f;\r\n\tbrakeTorque *= 500.0f;\r\n\tif(handBrake && getWheelFlag(E_WF_AFFECTED_BY_HANDBRAKE))\r\n\t\tbrakeTorque = 1000.0f;\r\n\tif(getWheelFlag(E_WF_ACCELERATED)) \r\n\t\tmWheelShape->setMotorTorque(motorTorque);\r\n\tmWheelShape->setBrakeTorque(brakeTorque);\r\n\r\n\r\n\t\r\n\r\n\r\n\tmWheelPose = mWheelShape->getGlobalPose();\r\n\r\n\tNxWheelContactData wcd;\r\n\tNxShape* s = mWheelShape->getContact(wcd);\t\r\n\tNxReal stravel = mWheelShape->getSuspensionTravel();\r\n\tNxReal radius = mWheelShape->getRadius();\r\n\r\n\r\n\t//have ground contact?\r\n\tif( s && wcd.contactPosition <= (stravel + radius) ) {\r\n\t\tmWheelPose.t = NxVec3( mWheelPose.t.x, wcd.contactPoint.y + radius, mWheelPose.t.z );\r\n\t}\r\n\telse {\r\n\t\tmWheelPose.t = NxVec3( mWheelPose.t.x, mWheelPose.t.y - stravel, mWheelPose.t.z );\r\n\t}\r\n\r\n\r\n\tNxMat33 rot, axisRot, rollRot;\r\n\trot.rotY( mWheelShape->getSteerAngle() );\r\n\t//rot.rotX(0);\r\n\taxisRot.rotY(0);\r\n\trollRot.rotX(_wheelRollAngle);\r\n\tmWheelPose.M = rot * mWheelPose.M * axisRot * rollRot;\r\n\r\n\t*/\r\n\r\n}\r\nbool pRigidBody::hasWheels()\r\n{\r\n\r\n\tbool result = false;\r\n\r\n\tif (!getActor())\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pRigidBody::getNbWheels()\r\n{\r\n\r\n\tint result = 0;\r\n\r\n\tif (!getActor())\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\tint nbShapes = getActor()->getNbShapes();\r\n\tNxShape ** slist = (NxShape **)getActor()->getShapes();\r\n\tfor (NxU32 j=0; j(s->userData);\r\n\t\t\tif (sinfo && sinfo->wheel !=NULL)\r\n\t\t\t{\r\n\t\t\t\tresult ++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\npWheel2 *pRigidBody::getWheel2(CK3dEntity* subShapeReference)\r\n{\r\n\treturn static_cast(getWheel(subShapeReference));\r\n}\r\npWheel *pRigidBody::getWheel(CK3dEntity* subShapeReference)\r\n{\r\n\r\n\tpWheel *result = NULL;\r\n\tif (!subShapeReference)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tNxShape *subShape = _getSubShapeByEntityID(subShapeReference->GetID());\r\n\tif (!subShape) \r\n\t\treturn result;\r\n\r\n\tpSubMeshInfo *sInfo = static_cast(subShape->userData);\r\n\r\n\tif (sInfo && sInfo->wheel)\r\n\t{\r\n\t\treturn sInfo->wheel;\r\n\t}\r\n\t/*\r\n\r\n\tNxWheelShape *wheel = static_cast(subShape->isWheel());\r\n\tif (wheel)\r\n\t{\r\n\tpSubMeshInfo *sInfo = static_cast(subShape->userData);\r\n\r\n\tif (sInfo && sInfo->wheel)\r\n\t{\r\n\treturn sInfo->wheel;\r\n\t}\r\n\t}\r\n\t*/\r\n\treturn result;\r\n\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"vtStructHelper.h\"\r\n#include \"vtAttributeHelper.h\"\r\n\r\nusing namespace vtTools::AttributeTools;\r\n\r\nint PhysicManager::getAttributeTypeByGuid(CKGUID guid)\r\n{\r\n\r\n\r\n\tCKContext *ctx = GetPMan()->GetContext();\r\n\r\n\tCKAttributeManager *attMan = ctx->GetAttributeManager();\r\n\tCKParameterManager *parMan = ctx->GetParameterManager();\r\n\r\n\tint cCount = attMan->GetAttributeCount();\r\n\tfor(int i = 0 ; i < cCount ; i++)\r\n\t{\r\n\t\tCKSTRING name = attMan->GetAttributeNameByType(i);\r\n\t\tif ( parMan->ParameterTypeToGuid(attMan->GetAttributeParameterType(i)) == guid )\r\n\t\t{\r\n\t\t\treturn i;\r\n\t\t}\r\n\t}\r\n\r\n\treturn -1;\r\n}\r\n\r\nvoid PhysicManager::_RegisterDynamicEnumeration(XString file,XString enumerationName,CKGUID enumerationGuid,PFEnumStringFunction enumFunc,BOOL hidden)\r\n{\r\n\r\n\r\n\tTiXmlDocument * defaultDoc = loadDefaults(file.Str());\r\n\tif (!defaultDoc)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Loading default config :PhysicDefaults.xml: failed\");\r\n\t}\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\tif (!getCurrentFactory())\r\n\t{\r\n\t\tpFactory *factory = new pFactory(this,getDefaultConfig());\r\n\t\tsetCurrentFactory(factory);\r\n\t}\r\n\r\n\tpFactory *factory = pFactory::Instance();\r\n\r\n\tXString outList;\r\n\tif (defaultDoc)\r\n\t\toutList = (factory->*enumFunc)(getDefaultConfig());\r\n\r\n\tif (!outList.Length())\r\n\t\toutList<< \"None=0\";\r\n\r\n\tCKParameterType pType = pm->ParameterGuidToType(enumerationGuid);\r\n\tif (pType==-1)\r\n\t\tpm->RegisterNewEnum(enumerationGuid,enumerationName.Str(),outList.Str());\r\n\telse{\r\n\t\tpm->ChangeEnumDeclaration(enumerationGuid,outList.Str());\r\n\t}\r\n\r\n\tCKParameterTypeDesc* param_type = pm->GetParameterTypeDescription(enumerationGuid);\n\tif (param_type && hidden)\r\n\t\tparam_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"%s settings from xml detected : %s\",enumerationName.Str(),outList.Str());\r\n\r\n\r\n\r\n}\r\n\r\nvoid PhysicManager::_RegisterDynamicParameters()\r\n{\r\n\r\n\t\r\n\tTiXmlDocument * defaultDoc = loadDefaults(\"PhysicDefaults.xml\");\r\n\tif (!defaultDoc)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Loading default config :PhysicDefaults.xml: failed\");\r\n\t}\r\n\t\r\n\t//xLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Default xml configuration loaded\");\r\n\t\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\tif (!getCurrentFactory())\r\n\t{\r\n\t\tpFactory *factory = new pFactory(this,getDefaultConfig());\r\n\t\tsetCurrentFactory(factory);\r\n\t}\r\n\t\r\n\r\n\tint pType = 0;\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\tMaterial !\r\n\t//\r\n/*\r\n\tXString materialList;\r\n\tif (defaultDoc)\r\n\t{\r\n\t\tmaterialList = pFactory::Instance()->_getMaterialsAsEnumeration(getDefaultConfig());\r\n\t}else{\r\n\r\n\t\tmaterialList << \"None=0\";\r\n\t}\r\n\r\n\tint pType = pm->ParameterGuidToType(VTE_XML_MATERIAL_TYPE);\r\n\r\n\tif (pType==-1)\r\n\t\tpm->RegisterNewEnum(VTE_XML_MATERIAL_TYPE,\"pMaterialType\",materialList.Str());\r\n\telse{\r\n\t\tpm->ChangeEnumDeclaration(VTE_XML_MATERIAL_TYPE,materialList.Str());\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"materials : %s\",materialList.Str());\r\n*/\r\n\r\n\t_RegisterDynamicEnumeration(\"PhysicDefaults.xml\",\"pMaterialType\",VTE_XML_MATERIAL_TYPE,&pFactory::_getMaterialsAsEnumeration,true);\r\n\t_RegisterDynamicEnumeration(\"PhysicDefaults.xml\",\"pBodyXMLInternalLink\",VTS_PHYSIC_ACTOR_XML_SETTINGS_INTERN,&pFactory::_getBodyXMLInternalEnumeration,false);\r\n\t_RegisterDynamicEnumeration(\"PhysicDefaults.xml\",\"pBodyXMLExternalLink\",VTS_PHYSIC_ACTOR_XML_SETTINGS_EXTERN,&pFactory::_getBodyXMLExternalEnumeration,false);\r\n\r\n\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tVehicle Settings\r\n\t//\r\n\tXString vSListStr;\r\n\tif (defaultDoc)\r\n\t\tvSListStr= pFactory::Instance()->_getVehicleSettingsAsEnumeration(getDefaultConfig());\r\n\r\n\tif (!vSListStr.Length())\r\n\t\tvSListStr << \"None=0\";\r\n\r\n\tpType = pm->ParameterGuidToType(VTE_XML_VEHICLE_SETTINGS);\r\n\tif (pType==-1)\r\n\t\tpm->RegisterNewEnum(VTE_XML_VEHICLE_SETTINGS,\"pVehicleSettingsLink\",vSListStr.Str());\r\n\telse{\r\n\t\tpm->ChangeEnumDeclaration(VTE_XML_VEHICLE_SETTINGS,vSListStr.Str());\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"vehicle settings : %s\",vSListStr.Str());\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\tWheel Settings\r\n\t//\r\n\tXString wSListStr;\r\n\tif (defaultDoc)\r\n\t\twSListStr = pFactory::Instance()->_getVehicleWheelAsEnumeration(getDefaultConfig());\r\n\r\n\tif (!wSListStr.Length())\r\n\t\twSListStr << \"None=0\";\r\n\r\n\r\n\tpType = pm->ParameterGuidToType(VTE_XML_WHEEL_SETTINGS);\r\n\tif (pType==-1)\r\n\t\tpm->RegisterNewEnum(VTE_XML_WHEEL_SETTINGS,\"pWheelSettingsLink\",wSListStr.Str());\r\n\telse{\r\n\t\tpm->ChangeEnumDeclaration(VTE_XML_WHEEL_SETTINGS,wSListStr.Str());\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"wheel vehicle settings : %s\",wSListStr.Str());\r\n\r\n\r\n\tCKParameterTypeDesc* param_type;\n\tparam_type=pm->GetParameterTypeDescription(VTE_XML_WHEEL_SETTINGS);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\n\t\n\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\n\t//\t\tWheel Tire Function\n\t//\n\tXString wTListStr;\r\n\tif (defaultDoc)\r\n\t\twTListStr = pFactory::Instance()->_getVehicleTireFunctionAsEnumeration(getDefaultConfig());\r\n\r\n\tif (!wTListStr.Length())\r\n\t\twTListStr << \"None=0\";\r\n\r\n\tpType = pm->ParameterGuidToType(VTE_XML_TIRE_SETTINGS);\r\n\tif (pType==-1)\r\n\t\tpm->RegisterNewEnum(VTE_XML_TIRE_SETTINGS,\"pWheelSettingsLink\",wTListStr.Str());\r\n\telse{\r\n\t\tpm->ChangeEnumDeclaration(VTE_XML_TIRE_SETTINGS,wTListStr.Str());\r\n\t}\r\n\r\n\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"wheel tire force settings : %s\",wTListStr.Str());\r\n\r\n\tparam_type=pm->GetParameterTypeDescription(VTE_XML_TIRE_SETTINGS);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\n\n\n\n\n\t//_getVehicleTireFunctionAsEnumeration\n\t/*param_type=pm->GetParameterTypeDescription(CKPGUID_EVOLUTIONS);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n*/\r\n\r\n\r\n\t_RegisterDynamicEnumeration(\"PhysicDefaults.xml\",\"pMaterialType\",VTE_XML_MATERIAL_TYPE,&pFactory::_getMaterialsAsEnumeration,true);\r\n\r\n\r\n}\r\n\r\n\r\nvoid\trecheckWorldsFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg)\r\n{\r\n\r\n\tint s = GetPMan()->getNbObjects();\r\n\tif (AttribType == GetPMan()->GetPAttribute())\r\n\t{\r\n\t\tpRigidBody *body = body = GetPMan()->getBody(pFactory::Instance()->getMostTopParent((CK3dEntity*)obj));\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tif (Set)\r\n\t\t\t\tif (!body->isSubShape(obj))\r\n\t\t\t\t\tbody->_checkForNewSubShapes();\r\n\t\t\telse\r\n\t\t\t\tbody->_checkForRemovedSubShapes();\r\n\t\t}\r\n\t}\r\n\t//CKParameterOut *pout = obj->GetAttributeParameter(GetPMan()->att_physic_object);\r\n\r\n}\r\n\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\nvtTools::ParameterTools::StructurMember PBRigidBodyMemberMap[] =\r\n{\r\n\r\n\tSTRUCT_ATTRIBUTE(VTE_COLLIDER_TYPE,\"Geometry\",\"Sphere\"),\r\n\tSTRUCT_ATTRIBUTE(VTF_BODY_FLAGS,\"Physic Flags\",\"Moving Object,World Gravity,Enabled,Collision\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Density\",\"1.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Skin Width\",\"-1.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Mass Offset\",\"0.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Pivot Offset\",\"0.0,0.0,0.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_BOOL,\"Hierarchy\",\"FALSE\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"World\",\"pDefaultWorld\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Total Mass\",\"-1.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"New Density\",\"-1.0\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_INT,\"Collision Group\",\"0\"),\r\n};\r\n\r\n//pm->RegisterNewStructure(VTS_PHYSIC_PARAMETER,\"pObject\", \",Mass Offset,Pivot Offset,Hierarchy,World,New Density,Total Mass,Collision Group\",\r\n//VTE_COLLIDER_TYPE,VTF_BODY_FLAGS,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_VECTOR,CKPGUID_VECTOR,CKPGUID_BOOL,CKPGUID_3DENTITY,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_INT);\r\n\r\n\r\nvoid PhysicManager::_RegisterParameters()\r\n{\r\n\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\t\r\n\r\n\tattman->AddCategory(\"Physic\");\r\n\r\n\t_RegisterWorldParameters();\r\n\t_RegisterBodyParameters();\r\n\t_RegisterBodyParameterFunctions();\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* clothes : */\r\n\t/************************************************************************/\r\n\tpm->RegisterNewFlags(VTE_CLOTH_FLAGS,\"pClothFlags\",\"Pressure=1,Static=2,DisableCollision=4,SelfCollision=8,Gravity=32,Bending=64,BendingOrtho=128,Damping=256,CollisionTwoway=512,TriangleCollision=2048,Tearable=4096,Hardware=8192,ComDamping=16384,ValidBounds=32768,FluidCollision=65536,DisableCCD=131072,AddHere=262144,AttachToParentMainShape=524288,AttachToCollidingShapes=1048576,AttachToCore=2097152,AttachAttributes=4194304\");\r\n\tpm->RegisterNewFlags(VTE_CLOTH_ATTACH_FLAGS,\"pClothAttachFlags\",\"Twoway=1,Tearable=2\");\r\n\r\n\tpm->RegisterNewStructure(VTS_CLOTH_DESCR,\"pClothDesc\",\"Thickness,Density,Bending Stiffness,Stretching Stiffness,Damping Coefficient,Friction,Pressure,Tear Factor,Collision Response Coefficient,Attachment Response Coefficient,Attachment Tear Factor,To Fluid Response Coefficient,From Fluid Response Coefficient,Min Adhere Velocity,Solver Iterations,External Acceleration,Wind Acceleration,Wake Up Counter,Sleep Linear Velocity,Collision Group,Valid Bounds,Relative Grid Spacing,Flags,Tear Vertex Color,World Reference,Attachment Flags\",CKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_INT,\tCKPGUID_VECTOR,\tCKPGUID_VECTOR,\tCKPGUID_FLOAT,\tCKPGUID_FLOAT,\tCKPGUID_INT,\tCKPGUID_BOX,\tCKPGUID_FLOAT,\tVTE_CLOTH_FLAGS,\tCKPGUID_COLOR,\tCKPGUID_3DENTITY,\tVTE_CLOTH_ATTACH_FLAGS);\r\n\tatt_clothDescr= attman->RegisterNewAttributeType(\"Cloth\",VTS_CLOTH_DESCR,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_clothDescr,\"Physic\");\r\n\tattman->SetAttributeDefaultValue(att_clothDescr,\"0.01f;1.0f;1.0f;1.0f;0.5f;0.5f;1.0f;1.5f;0.2f;\t0.2f;1.5f;1.0f;1.0f;1.0f;5;0.0f,0.0f,0.0f;0.0f,0.0f,0.0f;0.4f;-1.0f;0;0.0f,0.0f,0.0f,0.0f,0.0f,0.0f;0.25;Gravity;255,255,255,255;pDefaultWorld;Twoway\");\r\n\r\n\tpm->RegisterNewStructure(VTS_CLOTH_METAL_DESCR,\"pDeformableSettings\",\"Impulse Threshold,Penetration Depth,Maximal Deformation Distance\",CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT);\r\n\r\n\tCKParameterTypeDesc* param_type=pm->GetParameterTypeDescription(VTS_CLOTH_METAL_DESCR);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\tatt_deformable = attman->RegisterNewAttributeType(\"Deformable Settings\",VTS_CLOTH_METAL_DESCR,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_deformable,\"Physic\");\r\n\t\r\n\t//attman->SetAttributeCallbackFunction(att_clothDescr,recheckWorldsFunc,NULL);\r\n\r\n\t\r\n\t/************************************************************************/\r\n\t/* material */\r\n\t/************************************************************************/\r\n\tpm->RegisterNewFlags(VTF_MATERIAL_FLAGS,\"pMaterialFlags\",\"Anisotropic=1,Disable Friction=16,Disable Strong Friction=32\");\r\n\tpm->RegisterNewEnum(VTE_MATERIAL_COMBINE_MODE,\"pFrictionCombineMode\",\"Average=0,Min=1,Multiply=2,Max=3\");\r\n\tpm->RegisterNewStructure(VTS_MATERIAL,\"pMaterial\",\"XML Link,DynamicFriction,Static Friction,Restitution,Dynamic Friction V,Static Friction V,Direction of Anisotropy,Friction Combine Mode,Restitution Combine Mode,Flags\",VTE_XML_MATERIAL_TYPE,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_VECTOR,VTE_MATERIAL_COMBINE_MODE,VTE_MATERIAL_COMBINE_MODE,VTF_MATERIAL_FLAGS);\r\n\r\n\tatt_surface_props= attman->RegisterNewAttributeType(\"Material\",VTS_MATERIAL,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_surface_props,\"Physic\");\r\n\r\n\tattman->SetAttributeCallbackFunction(att_surface_props,recheckWorldsFunc,NULL);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Collision */\r\n\t/************************************************************************/\r\n\r\n\r\n\tatt_trigger= attman->RegisterNewAttributeType(\"Trigger\",VTF_TRIGGER,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_trigger,\"Physic\");\r\n\r\n\tpm->RegisterNewFlags(VTF_RAY_HINTS,\"pRayCastHints\",\"Shape=1,Impact=2,Normal=4,Face Index=8,Distance=16,UV=32,Face Normal=64,Material=128\");\r\n\tpm->RegisterNewStructure(VTS_RAYCAST,\"pRayCast\",\"World Reference,Ray Origin,Ray Origin Reference,Ray Direction,Ray Direction Reference,Length,Groups,Groups Mask,Shape Types\",CKPGUID_3DENTITY,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_VECTOR,CKPGUID_3DENTITY,CKPGUID_FLOAT,CKPGUID_INT,VTS_FILTER_GROUPS,VTF_SHAPES_TYPE);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Vehicle : */\r\n\t/************************************************************************/\r\n\t//\r\n\t\r\n\t//pm->RegisterNewStructure(VTS_WHEEL_CONTACT,\"pWheelContactData\",\"Contact Point,Contact Normal,Longitudes Direction,Lateral Direction,Contact Force,Longitudes Slip,Lateral Slip,\tLongitudes Impulse,Lateral Impulse,Other Material,Contact Position,\tContact Entity\",CKPGUID_VECTOR,CKPGUID_VECTOR,CKPGUID_VECTOR,CKPGUID_VECTOR,\tCKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,VTS_MATERIAL,CKPGUID_FLOAT,CKPGUID_3DENTITY);\r\n\t//REGISTER_CUSTOM_STRUCT(\"pJDistance\",PS_JDISTANCE_MEMBERS,VTS_JOINT_DISTANCE,gSMapJDistance,FALSE);\r\n\t\r\n\t_RegisterVehicleParameters();\r\n\t_RegisterJointParameters();\r\n\r\n\r\n\t//registerWatchers();\r\n}\r\n\r\nXString getEnumDescription(CKParameterManager* pm,CKBeObject *object,int index)\r\n{\r\n\r\n\tXString result=\"None\";\r\n\tint pType = pm->ParameterGuidToType(VTE_XML_MATERIAL_TYPE);\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\t\t\tif(i == index)\r\n\t\t\t{\r\n\t\t\t\tresult = enumStruct->GetEnumDescription(i);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint getEnumIndexByDescription(CKParameterManager* pm,XString descr)\r\n{\r\n\r\n\tint result =0;\r\n\tint pType = pm->ParameterGuidToType(VTE_XML_MATERIAL_TYPE);\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\r\n\t\t\tif (!strcmp(enumStruct->GetEnumDescription(i),descr.CStr()))\r\n\t\t\t{\r\n\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWSetFilteringDecl();\r\nCKERROR CreatePWSetFilteringProto(CKBehaviorPrototype **pproto);\r\nint PWSetFiltering(const CKBehaviorContext& behcontext);\r\nCKERROR PWSetFilteringCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWSetFilteringDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PWSetFiltering\");\t\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Sets the worlds filter settings for contact generation.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7ae099f,0x1f8e6949));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePWSetFilteringProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePWSetFilteringProto\r\n// FullName: CreatePWSetFilteringProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nenum bInput\r\n{\r\n\r\n\tbbI_FBool,\r\n\tbbI_FOp0,\r\n\tbbI_FOp1,\r\n\tbbI_FOp2,\r\n\tbbI_FConst0,\r\n\tbbI_FConst1,\r\n\r\n\r\n};\r\nCKERROR CreatePWSetFilteringProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PWSetFiltering\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PWSetFiltering \r\n\r\n\tPWSetFiltering is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tSets the worlds filter settings for contact generation.
\r\n\tSee pWFiltering.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PWSetFiltering.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\t\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\r\n\tTarget: The world reference. Choose pDefaultWord if there are no multiple worlds in use.\r\n\t
\r\n\t\r\n\tFilter Bool: Setups filtering's boolean value.\r\n\t
\r\n\r\n\tFilter Op 0: Setups filtering operation.\r\n\t
\r\n\tFilter Op 1: Setups filtering operation.\r\n\t
\r\n\tFilter Op 2: Setups filtering operation.\r\n\t
\r\n\tFilter Constant 0: Setups filtering's K0 value. \r\n\t
\r\n\tFilter Constant 1: Setups filtering's K1 value. \r\n\t
\r\n\r\n\t

Note


\r\n\r\n\tSee \\ref CollisionFiltering for more details. \r\n\t\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pWorld .
\r\n\t\r\n\t*/\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Filter Bool\",CKPGUID_BOOL,\"true\");\r\n\tproto->DeclareInParameter(\"Filter Op 0\",VTE_FILTER_OPS,\"Or\");\r\n\tproto->DeclareInParameter(\"Filter Op 1\",VTE_FILTER_OPS,\"Or\");\r\n\tproto->DeclareInParameter(\"Filter Op 2\",VTE_FILTER_OPS,\"And\");\r\n\tproto->DeclareInParameter(\"Filter Constant 0\",VTS_FILTER_GROUPS,\"0\");\r\n\tproto->DeclareInParameter(\"Filter Constant 1\",VTS_FILTER_GROUPS,\"0\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PWSetFiltering);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\nenum bOutputs\r\n{\r\n\tbbO_None,\r\n\tbbO_Enter,\r\n\tbbO_Stay,\r\n\tbbO_Leave,\r\n};\r\n\r\n//************************************\r\n// Method: PWSetFiltering\r\n// FullName: PWSetFiltering\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PWSetFiltering(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// the world : \r\n\tpWorld *world=GetPMan()->getWorld(target->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tNxScene *scene = world->getScene();\r\n\tif (!scene)\r\n\t{\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tint filterBool = GetInputParameterValue(beh,bbI_FBool);\r\n\tint fOP0 = GetInputParameterValue(beh,bbI_FOp0);\r\n\tint fOP1 = GetInputParameterValue(beh,bbI_FOp1);\r\n\tint fOP2 = GetInputParameterValue(beh,bbI_FOp2);\r\n\r\n\tCKParameter *fConst0 = beh->GetInputParameter(bbI_FConst0)->GetRealSource();\r\n\r\n\tNxGroupsMask mask0;\r\n\tmask0.bits0 = GetValueFromParameterStruct(fConst0,0);\r\n\tmask0.bits1 = GetValueFromParameterStruct(fConst0,1);\r\n\tmask0.bits2 = GetValueFromParameterStruct(fConst0,2);\r\n\tmask0.bits3 = GetValueFromParameterStruct(fConst0,3);\r\n\r\n\tCKParameter *fConst1 = beh->GetInputParameter(bbI_FConst1)->GetRealSource();\r\n\r\n\tNxGroupsMask mask1;\r\n\tmask1.bits0 = GetValueFromParameterStruct(fConst1,0);\r\n\tmask1.bits1 = GetValueFromParameterStruct(fConst1,1);\r\n\tmask1.bits2 = GetValueFromParameterStruct(fConst1,2);\r\n\tmask1.bits3 = GetValueFromParameterStruct(fConst1,3);\r\n\r\n\r\n\tscene->setFilterBool(filterBool);\r\n\tscene->setFilterOps((NxFilterOp)fOP0,(NxFilterOp)fOP1,(NxFilterOp)fOP2);\r\n\t\r\n\tscene->setFilterConstant0(mask0);\r\n\tscene->setFilterConstant1(mask1);\r\n\r\n\t//scene->raycastAnyShape()\r\n\r\n\tbeh->ActivateOutput(0);\r\n\r\n\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PWSetFilteringCB\r\n// FullName: PWSetFilteringCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PWSetFilteringCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"pConfig.h\"\r\n\r\n#include \r\n\r\nint demoTimerExpired=0;\r\n\r\nfloat absTime = 0.0f;\r\nfloat lastAbsTime = 0.0f;\r\n#include \"Timing.h\"\r\n\r\nstatic float\t\t\tgTimestepMultiplier\t= 1.0f;\r\n\r\nfloat getCurrentTime()\r\n{\r\n\tunsigned int currentTime = timeGetTime();\r\n\treturn (float)(currentTime)*0.001f;\r\n}\r\n\r\n\r\nfloat getElapsedTime()\r\n{\r\n\tstatic LARGE_INTEGER previousTime;\r\n\tstatic LARGE_INTEGER freq;\r\n\tstatic bool init = false;\r\n\tif(!init){\r\n\t\tQueryPerformanceFrequency(&freq);\r\n\t\tQueryPerformanceCounter(&previousTime);\r\n\t\tinit=true;\r\n\t}\r\n\tLARGE_INTEGER currentTime;\r\n\tQueryPerformanceCounter(&currentTime);\r\n\tunsigned long long elapsedTime = currentTime.QuadPart - previousTime.QuadPart;\r\n\tpreviousTime = currentTime;\r\n\treturn (float)(elapsedTime)/(freq.QuadPart);\r\n}\r\n\r\n\r\nint PhysicManager::_checkResetList()\r\n{\r\n\r\n\tint result = 0 ;\r\n\tpRestoreMapIt it = _getRestoreMap()->Begin();\r\n\twhile(it != _getRestoreMap()->End())\r\n\t{\r\n\t\tCK_ID id = it.GetKey();\r\n\t\tCK3dEntity * ent = (CK3dEntity*)GetPMan()->GetContext()->GetObject(id);\r\n\t\tif(ent)\r\n\t\t{\r\n\t\t\tpRigidBody* body = GetPMan()->getBody(ent);\r\n\t\t\tif (body)\r\n\t\t\t{\r\n\t\t\t\tbody->onICRestore(ent,*it);\r\n\t\t\t\t_getRestoreMap()->Remove(it.GetKey());\r\n\t\t\t\t//_getRestoreMap()->Remove(it.GetKey());\r\n\t\t\t\tit =_getRestoreMap()->Begin();\r\n\t\t\t\tresult++;\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\t_getRestoreMap()->Remove(it.GetKey());\r\n\t\t\tit =_getRestoreMap()->Begin();\r\n\t\t\tresult++;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tit++;\r\n\t}\r\n\t//_getRestoreMap()->Clear();\r\n\r\n\t/*\r\n\tfor (CK3dEntity** it = resetList.Begin(); it != resetList.End(); ++it)\r\n\t{\t\r\n\t\tpRigidBody* body = GetPMan()->getBody(*it);\r\n\t\tif (body)\r\n\t\t{\r\n\t\t\tbody->onICRestore(*it,true);\r\n\t\t}\r\n\t}\r\n\t*/\r\n//\tresetList.Clear();\r\n\r\n\treturn result;\r\n}\r\n\r\nfloat PhysicManager::getLastTimeStep(int flags)\r\n{\r\n\r\n\tNxF32 elapsedTime = getElapsedTime();\r\n\telapsedTime*= GetContext()->GetTimeManager()->GetTimeScaleFactor();\r\n\t\r\n\telapsedTime*=10.0f;\r\n\tif(elapsedTime <= 0)\r\n\t\telapsedTime = 0;\r\n\r\n\treturn elapsedTime;\r\n\r\n}\r\nvoid PhysicManager::advanceTime(float time)\r\n{\r\n\t\r\n\ttimer +=time;\r\n\tfloat timeNow = timer;\r\n\r\n\tmLastStepTime = time;\r\n\r\n\tint op= 30 ;\r\n\top++;\r\n\t/*\r\n\tfloat TimeStep = 1.0f / 60.0f;\r\n\tif(gFixedStep) gScene->setTiming(TimeStep, 1, NX_TIMESTEP_FIXED);\r\n\telse gScene->setTiming(TimeStep, 1, NX_TIMESTEP_VARIABLE);\r\n\r\n\t*/\r\n\r\n}\r\n\r\nvoid PhysicManager::update(float stepsize)\r\n{\r\n\tadvanceTime(stepsize);\r\n/*\tfloat a= time->GetSpanMS();\r\n\tfloat b= time->GetRealTime();\r\n\ttime->Update();\r\n*/\r\n\tint lastTime;\r\n\tint curTime,diffTime,maxTime;\r\n\r\n\t// Calculate time from last to current situation\r\n//\ttime->Update();\r\n\tcurTime=time->GetRealTime();\r\n\tlastTime=time->GetLastSimTime();\r\n\tdiffTime=curTime-lastTime;\r\n\t//maxTime=lastTime+maxSimTimePerFrame;\r\n\r\n#ifdef SESSION_LIMIT\r\n\t#ifndef REDIST\r\n\t\t\r\n\t\tif (timer >(SESSION_MAX))\r\n\t\t{\r\n\t\t\tif (demoTimerExpired==0)\r\n\t\t\t{\r\n\t\t\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"Demo expires after 15 mins\");\r\n\t\t\t\tdemoTimerExpired = 1;\r\n\t\t\t}\r\n\t\t\treturn ;\r\n\t\t}\r\n\t#endif\r\n#endif\r\n\r\n#ifdef REDIST\r\n\r\n\tif (m_Context->IsInInterfaceMode())\r\n\t{\r\n\t\txLogger::xLog(ELOGERROR,E_LI_MANAGER,\"This is a redist Dll\");\r\n\t\treturn;\r\n\t}\r\n\t#pragma message(\"-------------------------------PManager ::Update REDIST\" )\r\n#endif\r\n\r\n\r\n\t//CKTimeProfiler(const char* iTitle, CKContext* iContext, int iStartingCount = 4):\r\n\t//CKTimeProfiler MyProfiler(\"PhysX Step\",GetContext(),8);\r\n\r\n\r\n\r\n\tfloat elapsedTime = getLastTimeStep(0);//(0.5)\r\n\tfloat msTimeNow = lastStepTimeMS;//(50.0)\r\n\r\n\t//_checkResetList();\r\n\t\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\t\r\n\t\tw->step(elapsedTime);\r\n\t\t//w->step(lastStepTimeMS);\r\n\t\tit++;\r\n\t}\r\n\r\n\t/*\r\n\tif (checkPhysics)\r\n\t{\r\n\t\tcheckWorlds();\r\n\t\tcheckPhysics = false;\r\n\t}\r\n\t*/\r\n\r\n\t\r\n\r\n\t/*if (checkPhysics)\r\n\t{\r\n\t\t_checkObjectsByAttribute(GetContext()->GetCurrentLevel()->GetCurrentScene());\r\n\t\tcheckPhysics = false;\r\n\t}*/\r\n\t//float pTime = MyProfiler\r\n\t//float a = pTime;\r\n}\r\n\r\nCKERROR PhysicManager::PostProcess()\r\n{\r\n\tadvanceTime(lastStepTimeSec);\r\n\r\n\tif(sceneWasChanged)\r\n\t{\r\n\r\n\r\n\t\t//xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"sceneWasChanged\");\r\n\t\tsceneWasChanged = 0;\r\n\r\n\t}\r\n\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tw->onPostProcess();\r\n\t\tit++;\r\n\t}\r\n\t\r\n\tcleanAttributePostObjects();\r\n\t_cleanTriggers();\r\n\tgetJointFeedbackList().Clear();\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nCKERROR PhysicManager::PreProcess()\r\n{\r\n\t\r\n\r\n\tfloat timeCtx = GetContext()->GetTimeManager()->GetLastDeltaTimeFree();\r\n\tupdate(timeCtx);\r\n\r\n\tpWorldMapIt it = getWorlds()->Begin();\r\n\twhile(it != getWorlds()->End())\r\n\t{\r\n\t\tpWorld *w = *it;\r\n\t\tw->onPreProcess();\r\n\t\tit++;\r\n\t}\r\n\t\r\n\treturn CK_OK;\r\n}\r\n\r\nvoid PhysicManager::_cleanTriggers()\r\n{\r\n\t/*\r\n\tint nbEntries = getTriggers().Size() ; \r\n\tfor (int i = 0 ; i < getTriggers().Size(); i++ )\r\n\t{\r\n\t\r\n\t\tpTriggerEntry &entry = *getTriggers().At(i);\r\n\t\t{\r\n\t\t\tif (entry.triggered)\r\n\t\t\t{\r\n\t\t\t\tgetTriggers().RemoveAt(i);\r\n\t\t\t\ti = 0;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t*/\r\n\tgetTriggers().Clear();\r\n}\r\n\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n\r\nCKPhysicManager::CKPhysicManager(CKContext *Context,CKGUID guid,char* name):CKBaseManager(Context,GUID_MODULE_MANAGER,\"PhysicManager\")\r\n{\r\n\r\n}STRING resultPath; \r\nSTRING vDev35Path,vDev40Path,vDev41Path,WebPlayerPath; \r\nSTRING vDev35RPath,vDev40RPath,vDev41RPath,WebPlayerRPath;\r\nNUMBER gSetupType;\r\nSTRING gSetupTypeStr; \r\nNUMBER gPXVER;\r\nSTRING gPXVER_STR; \r\n\r\nNUMBER vtA35,vtA40,vtA41;\r\n\r\n\r\n//export prototype GetVPath( NUMBER, STRING );\r\n\r\nexport prototype SdAskDestPath22( STRING, STRING, STRING);\r\n\r\n\t\r\n\r\n\r\n #ifndef __VTPRECOMP_H_\r\n#define __VTPRECOMP_H_\r\n\r\n\t#include \"VxMath.h\"\r\n\t#include \"CKAll.h\"\r\n\t#include \"vtNetworkManager.h\"\r\n\t#include \"tnl.h\"\r\n\r\n\t#undef min\r\n\t#undef max\r\n\r\n#endif\r\n//{{NO_DEPENDENCIES}}\r\n// Microsoft Visual C++ generated include file.\r\n// Used by vtAgeiaInterface.rc\r\n//\r\n#define IDD_DIALOG1 2000\r\n#define IDC_EDIT 2001\r\n#define IDC_PARAM_NAME 2006\r\n#define IDC_LBL_HTYPE 10000\r\n#define IDC_BFLAGS_MOVING 10001\r\n#define IDC_LBL_FLAGS 10002\r\n#define IDC_BFLAGS_DEFORMABLE 10003\r\n#define IDC_BFLAGS_GRAV 10004\r\n#define IDC_BFLAGS_KINEMATIC 10005\r\n#define IDC_BFLAGS_COLL 10006\r\n#define IDC_BFLAGS_COLL_NOTIFY 10007\r\n#define IDC_BFLAGS_TRIGGER 10008\r\n#define IDC_BFLAGS_SSHAPE 10009\r\n#define IDC_BFLAGS_HIERARCHY 10010\r\n#define IDD_EDITOR 10011\r\n#define IDC_FLAGS_BG 10012\r\n#define IDI_EDITORICON 10013\r\n#define IDC_FLEX_FRAME 10014\r\n#define IDC_HULLTYPE 10015\r\n#define IDC_BFLAGS_TRIGGEREX 10018\r\n#define IDC_TRACKTEST 10019\r\n#define IDC_TRACKTEST_TREE 10019\r\n#define IDC_BFLAGS_TEST 10020\r\n#define IDC_BFLAGS_SLEEP 10021\r\n#define IDC_TREE1 10021\r\n#define IDD_PBCOMMON 10022\r\n#define IDC_TAB1 10022\r\n#define IDD_TOOLBAR 10023\r\n#define IDD_PBCOMMON_DEFORMABLE 10024\r\n#define IDC_MAINTAB 10025\r\n\r\n// Next default values for new objects\r\n//\r\n#ifdef APSTUDIO_INVOKED\r\n#ifndef APSTUDIO_READONLY_SYMBOLS\r\n#define _APS_NEXT_RESOURCE_VALUE 10006\r\n#define _APS_NEXT_COMMAND_VALUE 32771\r\n#define _APS_NEXT_CONTROL_VALUE 10023\r\n#define _APS_NEXT_SYMED_VALUE 10000\r\n#endif\r\n#endif\r\n#if !defined( _CONSTREAM_H )\r\n#define _CONSTREAM_H\r\n\r\n//\r\n// Note that ConStream uses the standard C++ libraries that ship with\r\n// Visual C++ 5.0 and later, not the older libraries with the .h suffix.\r\n// The library would require some modifications to work with the older\r\n// libraries.\r\n//\r\n#include \r\n#include \r\n\r\n#include \r\n#include \r\n#include \r\n\r\n//using namespace std;\r\n\r\n//\r\n// The ConStream class is derived from what we normally think of as ostream,\r\n// which means you can use standard insertion operators to write to it. Of\r\n// course, this includes insertion operators for user defined classes. At\r\n// all times, a ConStream object is either writing out to to a FILE\r\n// object attached to the NUL device, or a FILE object attached to a console\r\n// created using the Win32 API. Which of the two is in use depends on whether\r\n// or not the ConStream object has had its Open() or Close() method called.\r\n//\r\n#define MAX_BUFFER 4096\r\n\r\nclass ConStream : public std::basic_ostream\r\n{\r\npublic :\r\n ConStream();\r\n virtual ~ConStream();\r\n void Open();\r\n void Close();\r\nprotected :\r\n HANDLE m_hConsole;\r\n\r\n\tstd::basic_filebuf *m_FileBuf;\r\n\tstd::basic_filebuf m_Nul;\r\n\r\n\tFILE *m_fNul;\r\n FILE *m_fConsole;\r\n\r\npublic:\r\n\tint lastLine;\r\n\tchar* buf;\r\n\tint hConHandle;\r\n\tlong lStdHandle;\r\n\tFILE *fp;\r\n\r\n};\r\n\r\n#endif // !defined( _CONSTREAM_H )\r\n/* -----------------------------------------------------------------------------\n * See the LICENSE file for information on copyright, usage and redistribution\n * of SWIG, and the README file for authors - http://www.swig.org/release.html.\n *\n * php4.cxx\n *\n * Php language module for SWIG.\n * -----------------------------------------------------------------------------\n */\n\n/* FIXME: PHP5 OO wrapping TODO list:\n *\n * Short term:\n *\n * Sort out auto-renaming of method and class names which are reserved\n * words (e.g. empty, clone, exception, etc.) vs -php4/-php5 in some\n * sane way.\n *\n * Sort out wrapping of static member variables in OO PHP5 (which first may\n * mean we need to sort them out for PHP4!)\n *\n * Medium term:\n *\n * Handle default parameters on overloaded methods in PHP where possible.\n * (Mostly done - just need to handle cases of overloaded methods with\n * default parameters...)\n * This is an optimisation - we could handle this case using a PHP\n * default value, but currently we treat it as we would for a default\n * value which is a compound C++ expression (i.e. as if we had a\n * method with two overloaded forms instead of a single method with\n * a default parameter value).\n *\n * Long term:\n *\n * Option to generate code to work with PHP4 instead (\"public $_cPtr;\" ->\n * \"var $_cPtr;\", \"abstract\" -> \"\", no static class functions - but making\n * these changes gives a segfault with make check...)\n * Sort out locale-dependent behaviour of strtod() - it's harmless unless\n * SWIG ever sets the locale and DOH/base.c calls atof, so we're probably\n * OK currently at least.\n */\n\n/*\n * TODO: Replace remaining stderr messages with Swig_error or Swig_warning\n * (may need to add more WARN_PHP4_xxx codes...)\n */\n\nchar cvsroot_php4_cxx[] = \"$Id: php4.cxx 10099 2007-11-10 21:10:17Z wsfulton $\";\n\n#include \"swigmod.h\"\n\n#include \n#include \n\nstatic const char *usage = (char *) \"\\\nPHP Options (available with -php4 or -php5)\\n\\\n -cppext - cpp file extension (default to .cpp)\\n\\\n -noproxy - Don't generate proxy classes.\\n\\\n -prefix - Prepend to all class names in PHP5 wrappers\\n\\\n -make - Create simple makefile\\n\\\n -phpfull - Create full make files\\n\\\n -withincs - With -phpfull writes needed incs in config.m4\\n\\\n -withlibs - With -phpfull writes needed libs in config.m4\\n\\\n -withc - With -phpfull makes extra C files in Makefile.in\\n\\\n -withcxx - With -phpfull makes extra C++ files in Makefile.in\\n\\\n\\n\";\n\n/* The original class wrappers for PHP4 store the pointer to the C++ class in\n * the object property _cPtr. If we use the same name for the member variable\n * which we put the pointer to the C++ class in, then the flat function\n * wrappers will automatically pull it out without any changes being required.\n * FIXME: Isn't using a leading underscore a bit suspect here?\n */\n#define SWIG_PTR \"_cPtr\"\n\nstatic int constructors = 0;\nstatic String *NOTCLASS = NewString(\"Not a class\");\nstatic Node *classnode = 0;\nstatic String *module = 0;\nstatic String *cap_module = 0;\nstatic String *prefix = 0;\nstatic String *withlibs = 0;\nstatic String *withincs = 0;\nstatic String *withc = 0;\nstatic String *withcxx = 0;\n\nstatic String *shadow_classname = 0;\n\nstatic int gen_extra = 0;\nstatic int gen_make = 0;\n\nstatic File *f_runtime = 0;\nstatic File *f_h = 0;\nstatic File *f_phpcode = 0;\nstatic String *phpfilename = 0;\n\nstatic String *s_header;\nstatic String *s_wrappers;\nstatic String *s_init;\nstatic String *r_init;\t\t// RINIT user code\nstatic String *s_shutdown;\t// MSHUTDOWN user code\nstatic String *r_shutdown;\t// RSHUTDOWN user code\nstatic String *s_vinit;\t\t// varinit initialization code.\nstatic String *s_vdecl;\nstatic String *s_cinit;\t\t// consttab initialization code.\nstatic String *s_oinit;\nstatic String *s_entry;\nstatic String *cs_entry;\nstatic String *all_cs_entry;\nstatic String *pragma_incl;\nstatic String *pragma_code;\nstatic String *pragma_phpinfo;\nstatic String *s_oowrappers;\nstatic String *s_fakeoowrappers;\nstatic String *s_phpclasses;\n\n/* Variables for using PHP classes */\nstatic Node *current_class = 0;\n\nstatic Hash *shadow_get_vars;\nstatic Hash *shadow_set_vars;\n#define NATIVE_CONSTRUCTOR 1\n#define ALTERNATIVE_CONSTRUCTOR 2\nstatic int native_constructor = 0;\nstatic Hash *zend_types = 0;\n\nstatic int shadow = 1;\n\nstatic bool class_has_ctor = false;\nstatic String *wrapping_member_constant = NULL;\n\n// These static variables are used to pass some state from Handlers into functionWrapper\nstatic enum {\n standard = 0,\n memberfn,\n staticmemberfn,\n membervar,\n staticmembervar,\n constructor,\n destructor\n} wrapperType = standard;\n\nextern \"C\" {\n static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;\n}\n\nvoid SwigPHP_emit_resource_registrations() {\n Iterator ki;\n\n if (!zend_types)\n return;\n\n ki = First(zend_types);\n if (ki.key)\n Printf(s_oinit, \"\\n/* Register resource destructors for pointer types */\\n\");\n while (ki.key)\n if (1 /* is pointer type */ ) {\n DOH *key = ki.key;\n Node *class_node = ki.item;\n String *human_name = key;\n\n // Write out destructor function header\n Printf(s_wrappers, \"/* NEW Destructor style */\\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\\n\", key);\n\n // write out body\n if ((class_node != NOTCLASS)) {\n\tString *destructor = Getattr(class_node, \"destructor\");\n\thuman_name = Getattr(class_node, \"sym:name\");\n\tif (!human_name)\n\t human_name = Getattr(class_node, \"name\");\n\t// Do we have a known destructor for this type?\n\tif (destructor) {\n\t Printf(s_wrappers, \" %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\\n\", destructor, key);\n\t} else {\n\t Printf(s_wrappers, \" /* No destructor for class %s */\\n\", human_name);\n\t}\n } else {\n\tPrintf(s_wrappers, \" /* No destructor for simple type %s */\\n\", key);\n }\n\n // close function\n Printf(s_wrappers, \"}\\n\");\n\n // declare le_swig_ to store php registration\n Printf(s_vdecl, \"static int le_swig_%s=0; /* handle for %s */\\n\", key, human_name);\n\n // register with php\n Printf(s_oinit, \"le_swig_%s=zend_register_list_destructors_ex\" \"(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\\n\", key, key, key);\n\n // store php type in class struct\n Printf(s_oinit, \"SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\\n\", key, key);\n\n ki = Next(ki);\n }\n}\n\nclass PHP:public Language {\n int php_version;\n\npublic:\n PHP(int php_version_):php_version(php_version_) {\n }\n\n /* Test to see if a type corresponds to something wrapped with a shadow class. */\n \n String *is_shadow(SwigType *t) {\n String *r = 0;\n Node *n = classLookup(t);\n if (n) {\n r = Getattr(n, \"php:proxy\");\t// Set by classDeclaration()\n if (!r) {\n\tr = Getattr(n, \"sym:name\");\t// Not seen by classDeclaration yet, but this is the name\n }\n }\n return r;\n }\n\n /* ------------------------------------------------------------\n * main()\n * ------------------------------------------------------------ */\n\n virtual void main(int argc, char *argv[]) {\n int i;\n SWIG_library_directory(\"php4\");\n SWIG_config_cppext(\"cpp\");\n\n for (i = 1; i < argc; i++) {\n if (argv[i]) {\n\tif (strcmp(argv[i], \"-phpfull\") == 0) {\n\t gen_extra = 1;\n\t Swig_mark_arg(i);\n\t} else if (strcmp(argv[i], \"-dlname\") == 0) {\n\t Printf(stderr, \"*** -dlname is no longer supported\\n*** if you want to change the module name, use -module instead.\\n\");\n\t SWIG_exit(EXIT_FAILURE);\n\t} else if (strcmp(argv[i], \"-prefix\") == 0) {\n\t if (argv[i + 1]) {\n\t prefix = NewString(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if (strcmp(argv[i], \"-withlibs\") == 0) {\n\t if (argv[i + 1]) {\n\t withlibs = NewString(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if (strcmp(argv[i], \"-withincs\") == 0) {\n\t if (argv[i + 1]) {\n\t withincs = NewString(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if (strcmp(argv[i], \"-withc\") == 0) {\n\t if (argv[i + 1]) {\n\t withc = NewString(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if (strcmp(argv[i], \"-withcxx\") == 0) {\n\t if (argv[i + 1]) {\n\t withcxx = NewString(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if (strcmp(argv[i], \"-cppext\") == 0) {\n\t if (argv[i + 1]) {\n\t SWIG_config_cppext(argv[i + 1]);\n\t Swig_mark_arg(i);\n\t Swig_mark_arg(i + 1);\n\t i++;\n\t } else {\n\t Swig_arg_error();\n\t }\n\t} else if ((strcmp(argv[i], \"-noshadow\") == 0) || (strcmp(argv[i], \"-noproxy\") == 0)) {\n\t shadow = 0;\n\t Swig_mark_arg(i);\n\t} else if (strcmp(argv[i], \"-make\") == 0) {\n\t gen_make = 1;\n\t Swig_mark_arg(i);\n\t} else if (strcmp(argv[i], \"-help\") == 0) {\n\t fputs(usage, stdout);\n\t}\n }\n }\n\n Preprocessor_define((void *) \"SWIGPHP 1\", 0);\n if (php_version == 4) {\n Preprocessor_define((void *) \"SWIGPHP4 1\", 0);\n } else if (php_version == 5) {\n Preprocessor_define((void *) \"SWIGPHP5 1\", 0);\n }\n SWIG_typemap_lang(\"php4\");\n /* DB: Suggest using a language configuration file */\n SWIG_config_file(\"php4.swg\");\n allow_overloading();\n }\n\n void create_simple_make(void) {\n File *f_make;\n\n f_make = NewFile((void *) \"makefile\", \"w\");\n Printf(f_make, \"CC=gcc\\n\");\n Printf(f_make, \"CXX=g++\\n\");\n Printf(f_make, \"CXX_SOURCES=%s\\n\", withcxx);\n Printf(f_make, \"C_SOURCES=%s\\n\", withc);\n Printf(f_make, \"OBJS=%s_wrap.o $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cxx=.o)\\n\", module);\n Printf(f_make, \"MODULE=%s.so\\n\", module);\n Printf(f_make, \"CFLAGS=-fpic\\n\");\n Printf(f_make, \"LDFLAGS=-shared\\n\");\n Printf(f_make, \"PHP_INC=`php-config --includes`\\n\");\n Printf(f_make, \"EXTRA_INC=\\n\");\n Printf(f_make, \"EXTRA_LIB=\\n\\n\");\n Printf(f_make, \"$(MODULE): $(OBJS)\\n\");\n if (CPlusPlus || (withcxx != NULL)) {\n Printf(f_make, \"\\t$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\\n\\n\");\n } else {\n Printf(f_make, \"\\t$(CC) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\\n\\n\");\n }\n Printf(f_make, \"%%.o: %%.cpp\\n\");\n Printf(f_make, \"\\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\\n\");\n Printf(f_make, \"%%.o: %%.cxx\\n\");\n Printf(f_make, \"\\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\\n\");\n Printf(f_make, \"%%.o: %%.c\\n\");\n Printf(f_make, \"\\t$(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\\n\");\n\n Close(f_make);\n }\n\n void create_extra_files(String *outfile) {\n File *f_extra;\n\n static String *configm4 = 0;\n static String *makefilein = 0;\n static String *credits = 0;\n\n configm4 = NewStringEmpty();\n Printv(configm4, SWIG_output_directory(), \"config.m4\", NIL);\n\n makefilein = NewStringEmpty();\n Printv(makefilein, SWIG_output_directory(), \"Makefile.in\", NIL);\n\n credits = NewStringEmpty();\n Printv(credits, SWIG_output_directory(), \"CREDITS\", NIL);\n\n // are we a --with- or --enable-\n int with = (withincs || withlibs) ? 1 : 0;\n\n // Note Makefile.in only copes with one source file\n // also withincs and withlibs only take one name each now\n // the code they generate should be adapted to take multiple lines\n\n /* Write out Makefile.in */\n f_extra = NewFile(makefilein, \"w\");\n if (!f_extra) {\n FileErrorDisplay(makefilein);\n SWIG_exit(EXIT_FAILURE);\n }\n\n Printf(f_extra, \"# $Id: php4.cxx 10099 2007-11-10 21:10:17Z wsfulton $\\n\\n\" \"LTLIBRARY_NAME = %s.la\\n\", module);\n\n // C++ has more and different entries to C in Makefile.in\n if (!CPlusPlus) {\n Printf(f_extra, \"LTLIBRARY_SOURCES = %s %s\\n\", Swig_file_filename(outfile), withc);\n Printf(f_extra, \"LTLIBRARY_SOURCES_CPP = %s\\n\", withcxx);\n } else {\n Printf(f_extra, \"LTLIBRARY_SOURCES = %s\\n\", withc);\n Printf(f_extra, \"LTLIBRARY_SOURCES_CPP = %s %s\\n\", Swig_file_filename(outfile), withcxx);\n Printf(f_extra, \"LTLIBRARY_OBJECTS_X = $(LTLIBRARY_SOURCES_CPP:.cpp=.lo) $(LTLIBRARY_SOURCES_CPP:.cxx=.lo)\\n\");\n }\n Printf(f_extra, \"LTLIBRARY_SHARED_NAME = %s.la\\n\", module);\n Printf(f_extra, \"LTLIBRARY_SHARED_LIBADD = $(%s_SHARED_LIBADD)\\n\\n\", cap_module);\n Printf(f_extra, \"include $(top_srcdir)/build/dynlib.mk\\n\");\n\n Printf(f_extra, \"\\n# patch in .cxx support to php build system to work like .cpp\\n\");\n Printf(f_extra, \".SUFFIXES: .cxx\\n\\n\");\n\n Printf(f_extra, \".cxx.o:\\n\");\n Printf(f_extra, \"\\t$(CXX_COMPILE) -c $<\\n\\n\");\n\n Printf(f_extra, \".cxx.lo:\\n\");\n Printf(f_extra, \"\\t$(CXX_PHP_COMPILE)\\n\\n\");\n Printf(f_extra, \".cxx.slo:\\n\");\n\n Printf(f_extra, \"\\t$(CXX_SHARED_COMPILE)\\n\\n\");\n\n Printf(f_extra, \"\\n# make it easy to test module\\n\");\n Printf(f_extra, \"testmodule:\\n\");\n Printf(f_extra, \"\\tphp -q -d extension_dir=modules %s\\n\\n\", Swig_file_filename(phpfilename));\n\n Close(f_extra);\n\n /* Now config.m4 */\n // Note: # comments are OK in config.m4 if you don't mind them\n // appearing in the final ./configure file\n // (which can help with ./configure debugging)\n\n // NOTE2: phpize really ought to be able to write out a sample\n // config.m4 based on some simple data, I'll take this up with\n // the php folk!\n f_extra = NewFile(configm4, \"w\");\n if (!f_extra) {\n FileErrorDisplay(configm4);\n SWIG_exit(EXIT_FAILURE);\n }\n\n Printf(f_extra, \"dnl $Id: php4.cxx 10099 2007-11-10 21:10:17Z wsfulton $\\n\");\n Printf(f_extra, \"dnl ***********************************************************************\\n\");\n Printf(f_extra, \"dnl ** THIS config.m4 is provided for PHPIZE and PHP's consumption NOT\\n\");\n Printf(f_extra, \"dnl ** for any part of the rest of the %s build system\\n\", module);\n Printf(f_extra, \"dnl ***********************************************************************\\n\\n\");\n\n\n if (!with) {\t\t// must be enable then\n Printf(f_extra, \"PHP_ARG_ENABLE(%s, whether to enable %s support,\\n\", module, module);\n Printf(f_extra, \"[ --enable-%s Enable %s support])\\n\\n\", module, module);\n } else {\n Printf(f_extra, \"PHP_ARG_WITH(%s, for %s support,\\n\", module, module);\n Printf(f_extra, \"[ --with-%s[=DIR] Include %s support.])\\n\\n\", module, module);\n // These tests try and file the library we need\n Printf(f_extra, \"dnl THESE TESTS try and find the library and header files\\n\");\n Printf(f_extra, \"dnl your new php module needs. YOU MAY NEED TO EDIT THEM\\n\");\n Printf(f_extra, \"dnl as written they assume your header files are all in the same place\\n\\n\");\n\n Printf(f_extra, \"dnl ** are we looking for %s_lib.h or something else?\\n\", module);\n if (withincs)\n\tPrintf(f_extra, \"HNAMES=\\\"%s\\\"\\n\\n\", withincs);\n else\n\tPrintf(f_extra, \"HNAMES=\\\"\\\"; # %s_lib.h ?\\n\\n\", module);\n\n Printf(f_extra, \"dnl ** Are we looking for lib%s.a or lib%s.so or something else?\\n\", module, module);\n\n if (withlibs)\n\tPrintf(f_extra, \"LIBNAMES=\\\"%s\\\"\\n\\n\", withlibs);\n else\n\tPrintf(f_extra, \"LIBNAMES=\\\"\\\"; # lib%s.so ?\\n\\n\", module);\n\n Printf(f_extra, \"dnl IF YOU KNOW one of the symbols in the library and you\\n\");\n Printf(f_extra, \"dnl specify it below then we can have a link test to see if it works\\n\");\n Printf(f_extra, \"LIBSYMBOL=\\\"\\\"\\n\\n\");\n }\n\n // Now write out tests to find thing.. they may need to extend tests\n Printf(f_extra, \"if test \\\"$PHP_%s\\\" != \\\"no\\\"; then\\n\\n\", cap_module);\n\n // Ready for when we add libraries as we find them\n Printf(f_extra, \" PHP_SUBST(%s_SHARED_LIBADD)\\n\\n\", cap_module);\n\n if (withlibs) {\t\t// find more than one library\n Printf(f_extra, \" for LIBNAME in $LIBNAMES ; do\\n\");\n Printf(f_extra, \" LIBDIR=\\\"\\\"\\n\");\n // For each path element to try...\n Printf(f_extra, \" for i in $PHP_%s $PHP_%s/lib /usr/lib /usr/local/lib ; do\\n\", cap_module, cap_module);\n Printf(f_extra, \" if test -r $i/lib$LIBNAME.a -o -r $i/lib$LIBNAME.so ; then\\n\");\n Printf(f_extra, \" LIBDIR=\\\"$i\\\"\\n\");\n Printf(f_extra, \" break\\n\");\n Printf(f_extra, \" fi\\n\");\n Printf(f_extra, \" done\\n\\n\");\n Printf(f_extra, \" dnl ** and $LIBDIR should be the library path\\n\");\n Printf(f_extra, \" if test \\\"$LIBNAME\\\" != \\\"\\\" -a -z \\\"$LIBDIR\\\" ; then\\n\");\n Printf(f_extra, \" AC_MSG_RESULT(Library files $LIBNAME not found)\\n\");\n Printf(f_extra, \" AC_MSG_ERROR(Is the %s distribution installed properly?)\\n\", module);\n Printf(f_extra, \" else\\n\");\n Printf(f_extra, \" AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)\\n\");\n Printf(f_extra, \" PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, %s_SHARED_LIBADD)\\n\", cap_module);\n Printf(f_extra, \" fi\\n\");\n Printf(f_extra, \" done\\n\\n\");\n }\n\n if (withincs) {\t\t// Find more than once include\n Printf(f_extra, \" for HNAME in $HNAMES ; do\\n\");\n Printf(f_extra, \" INCDIR=\\\"\\\"\\n\");\n // For each path element to try...\n Printf(f_extra, \" for i in $PHP_%s $PHP_%s/include $PHP_%s/includes $PHP_%s/inc $PHP_%s/incs /usr/local/include /usr/include; do\\n\", cap_module,\n\t cap_module, cap_module, cap_module, cap_module);\n // Try and find header files\n Printf(f_extra, \" if test \\\"$HNAME\\\" != \\\"\\\" -a -r $i/$HNAME ; then\\n\");\n Printf(f_extra, \" INCDIR=\\\"$i\\\"\\n\");\n Printf(f_extra, \" break\\n\");\n Printf(f_extra, \" fi\\n\");\n Printf(f_extra, \" done\\n\\n\");\n\n Printf(f_extra, \" dnl ** Now $INCDIR should be the include file path\\n\");\n Printf(f_extra, \" if test \\\"$HNAME\\\" != \\\"\\\" -a -z \\\"$INCDIR\\\" ; then\\n\");\n Printf(f_extra, \" AC_MSG_RESULT(Include files $HNAME not found)\\n\");\n Printf(f_extra, \" AC_MSG_ERROR(Is the %s distribution installed properly?)\\n\", module);\n Printf(f_extra, \" else\\n\");\n Printf(f_extra, \" AC_MSG_RESULT(Include files $HNAME found in $INCDIR)\\n\");\n Printf(f_extra, \" PHP_ADD_INCLUDE($INCDIR)\\n\");\n Printf(f_extra, \" fi\\n\\n\");\n Printf(f_extra, \" done\\n\\n\");\n }\n\n if (CPlusPlus) {\n Printf(f_extra, \" # As this is a C++ module..\\n\");\n }\n\n Printf(f_extra, \" PHP_REQUIRE_CXX\\n\");\n Printf(f_extra, \" AC_CHECK_LIB(stdc++, cin)\\n\");\n\n if (with) {\n Printf(f_extra, \" if test \\\"$LIBSYMBOL\\\" != \\\"\\\" ; then\\n\");\n Printf(f_extra, \" old_LIBS=\\\"$LIBS\\\"\\n\");\n Printf(f_extra, \" LIBS=\\\"$LIBS -L$TEST_DIR/lib -lm -ldl\\\"\\n\");\n Printf(f_extra, \" AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_TESTLIB,1, [ ])],\\n\");\n Printf(f_extra, \" [AC_MSG_ERROR(wrong test lib version or lib not found)])\\n\");\n Printf(f_extra, \" LIBS=\\\"$old_LIBS\\\"\\n\");\n Printf(f_extra, \" fi\\n\\n\");\n }\n\n Printf(f_extra, \" AC_DEFINE(HAVE_%s, 1, [ ])\\n\", cap_module);\n Printf(f_extra, \"dnl AC_DEFINE_UNQUOTED(PHP_%s_DIR, \\\"$%s_DIR\\\", [ ])\\n\", cap_module, cap_module);\n Printf(f_extra, \" PHP_EXTENSION(%s, $ext_shared)\\n\", module);\n\n // and thats all!\n Printf(f_extra, \"fi\\n\");\n\n Close(f_extra);\n\n /* CREDITS */\n f_extra = NewFile(credits, \"w\");\n if (!f_extra) {\n FileErrorDisplay(credits);\n SWIG_exit(EXIT_FAILURE);\n }\n Printf(f_extra, \"%s\\n\", module);\n Close(f_extra);\n }\n\n /* ------------------------------------------------------------\n * top()\n * ------------------------------------------------------------ */\n\n virtual int top(Node *n) {\n\n String *filen;\n String *s_type;\n\n /* Initialize all of the output files */\n String *outfile = Getattr(n, \"outfile\");\n\n /* main output file */\n f_runtime = NewFile(outfile, \"w\");\n if (!f_runtime) {\n FileErrorDisplay(outfile);\n SWIG_exit(EXIT_FAILURE);\n }\n\n Swig_banner(f_runtime);\n\n /* sections of the output file */\n s_init = NewString(\"/* init section */\\n\");\n r_init = NewString(\"/* rinit section */\\n\");\n s_shutdown = NewString(\"/* shutdown section */\\n\");\n r_shutdown = NewString(\"/* rshutdown section */\\n\");\n s_header = NewString(\"/* header section */\\n\");\n s_wrappers = NewString(\"/* wrapper section */\\n\");\n s_type = NewStringEmpty();\n /* subsections of the init section */\n s_vinit = NewString(\"/* vinit subsection */\\n\");\n s_vdecl = NewString(\"/* vdecl subsection */\\n\");\n s_cinit = NewString(\"/* cinit subsection */\\n\");\n s_oinit = NewString(\"/* oinit subsection */\\n\");\n pragma_phpinfo = NewStringEmpty();\n s_phpclasses = NewString(\"/* PHP Proxy Classes */\\n\");\n\n /* Register file targets with the SWIG file handler */\n Swig_register_filebyname(\"runtime\", f_runtime);\n Swig_register_filebyname(\"init\", s_init);\n Swig_register_filebyname(\"rinit\", r_init);\n Swig_register_filebyname(\"shutdown\", s_shutdown);\n Swig_register_filebyname(\"rshutdown\", r_shutdown);\n Swig_register_filebyname(\"header\", s_header);\n Swig_register_filebyname(\"wrapper\", s_wrappers);\n\n /* Set the module name */\n module = Copy(Getattr(n, \"name\"));\n cap_module = NewStringf(\"%(upper)s\", module);\n if (!prefix)\n prefix = NewStringEmpty();\n\n /* PHP module file */\n filen = NewStringEmpty();\n Printv(filen, SWIG_output_directory(), module, \".php\", NIL);\n phpfilename = NewString(filen);\n\n f_phpcode = NewFile(filen, \"w\");\n if (!f_phpcode) {\n FileErrorDisplay(filen);\n SWIG_exit(EXIT_FAILURE);\n }\n\n Printf(f_phpcode, \"error_msg = default_error_msg;\\n\");\n Printf(s_header, \" globals->error_code = default_error_code;\\n\");\n Printf(s_header, \"}\\n\");\n\n Printf(s_header, \"static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\\n\", module, module);\n\n Printf(s_header, \"\\n\");\n Printf(s_header, \"static void SWIG_ResetError() {\\n\");\n Printf(s_header, \" TSRMLS_FETCH();\\n\");\n Printf(s_header, \" SWIG_ErrorMsg() = default_error_msg;\\n\");\n Printf(s_header, \" SWIG_ErrorCode() = default_error_code;\\n\");\n Printf(s_header, \"}\\n\");\n\n Printf(s_header, \"#define SWIG_name \\\"%s\\\"\\n\", module);\n /* Printf(s_header,\"#ifdef HAVE_CONFIG_H\\n\");\n Printf(s_header,\"#include \\\"config.h\\\"\\n\");\n Printf(s_header,\"#endif\\n\\n\");\n */\n Printf(s_header, \"#ifdef __cplusplus\\n\");\n Printf(s_header, \"extern \\\"C\\\" {\\n\");\n Printf(s_header, \"#endif\\n\");\n Printf(s_header, \"#include \\\"php.h\\\"\\n\");\n Printf(s_header, \"#include \\\"php_ini.h\\\"\\n\");\n Printf(s_header, \"#include \\\"ext/standard/info.h\\\"\\n\");\n Printf(s_header, \"#include \\\"php_%s.h\\\"\\n\", module);\n Printf(s_header, \"#ifdef __cplusplus\\n\");\n Printf(s_header, \"}\\n\");\n Printf(s_header, \"#endif\\n\\n\");\n\n /* Create the .h file too */\n filen = NewStringEmpty();\n Printv(filen, SWIG_output_directory(), \"php_\", module, \".h\", NIL);\n f_h = NewFile(filen, \"w\");\n if (!f_h) {\n FileErrorDisplay(filen);\n SWIG_exit(EXIT_FAILURE);\n }\n\n Swig_banner(f_h);\n\n Printf(f_h, \"\\n\\n\");\n Printf(f_h, \"#ifndef PHP_%s_H\\n\", cap_module);\n Printf(f_h, \"#define PHP_%s_H\\n\\n\", cap_module);\n Printf(f_h, \"extern zend_module_entry %s_module_entry;\\n\", module);\n Printf(f_h, \"#define phpext_%s_ptr &%s_module_entry\\n\\n\", module, module);\n Printf(f_h, \"#ifdef PHP_WIN32\\n\");\n Printf(f_h, \"# define PHP_%s_API __declspec(dllexport)\\n\", cap_module);\n Printf(f_h, \"#else\\n\");\n Printf(f_h, \"# define PHP_%s_API\\n\", cap_module);\n Printf(f_h, \"#endif\\n\\n\");\n Printf(f_h, \"#ifdef ZTS\\n\");\n Printf(f_h, \"#include \\\"TSRM.h\\\"\\n\");\n Printf(f_h, \"#endif\\n\\n\");\n Printf(f_h, \"PHP_MINIT_FUNCTION(%s);\\n\", module);\n Printf(f_h, \"PHP_MSHUTDOWN_FUNCTION(%s);\\n\", module);\n Printf(f_h, \"PHP_RINIT_FUNCTION(%s);\\n\", module);\n Printf(f_h, \"PHP_RSHUTDOWN_FUNCTION(%s);\\n\", module);\n Printf(f_h, \"PHP_MINFO_FUNCTION(%s);\\n\\n\", module);\n\n /* start the function entry section */\n s_entry = NewString(\"/* entry subsection */\\n\");\n\n /* holds all the per-class function entry sections */\n all_cs_entry = NewString(\"/* class entry subsection */\\n\");\n cs_entry = NULL;\n\n Printf(s_entry, \"/* Every non-class user visible function must have an entry here */\\n\");\n Printf(s_entry, \"static zend_function_entry %s_functions[] = {\\n\", module);\n\n /* start the init section */\n Printv(s_init, \"zend_module_entry \", module, \"_module_entry = {\\n\" \"#if ZEND_MODULE_API_NO > 20010900\\n\" \" STANDARD_MODULE_HEADER,\\n\" \"#endif\\n\", NIL);\n Printf(s_init, \" (char*)\\\"%s\\\",\\n\", module);\n Printf(s_init, \" %s_functions,\\n\", module);\n Printf(s_init, \" PHP_MINIT(%s),\\n\", module);\n Printf(s_init, \" PHP_MSHUTDOWN(%s),\\n\", module);\n Printf(s_init, \" PHP_RINIT(%s),\\n\", module);\n Printf(s_init, \" PHP_RSHUTDOWN(%s),\\n\", module);\n Printf(s_init, \" PHP_MINFO(%s),\\n\", module);\n Printf(s_init, \"#if ZEND_MODULE_API_NO > 20010900\\n\");\n Printf(s_init, \" NO_VERSION_YET,\\n\");\n Printf(s_init, \"#endif\\n\");\n Printf(s_init, \" STANDARD_MODULE_PROPERTIES\\n\");\n Printf(s_init, \"};\\n\");\n Printf(s_init, \"zend_module_entry* SWIG_module_entry = &%s_module_entry;\\n\\n\", module);\n\n if (gen_extra) {\n Printf(s_init, \"#ifdef COMPILE_DL_%s\\n\", cap_module);\n }\n Printf(s_init, \"#ifdef __cplusplus\\n\");\n Printf(s_init, \"extern \\\"C\\\" {\\n\");\n Printf(s_init, \"#endif\\n\");\n // We want to write \"SWIGEXPORT ZEND_GET_MODULE(%s)\" but ZEND_GET_MODULE\n // in PHP5 has \"extern \"C\" { ... }\" around it so we can't do that.\n Printf(s_init, \"SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\\n\", module);\n Printf(s_init, \"#ifdef __cplusplus\\n\");\n Printf(s_init, \"}\\n\");\n Printf(s_init, \"#endif\\n\\n\");\n\n if (gen_extra) {\n Printf(s_init, \"#endif\\n\\n\");\n }\n\n /* We have to register the constants before they are (possibly) used\n * by the pointer typemaps. This all needs re-arranging really as\n * things are being called in the wrong order\n */\n Printf(s_init, \"#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\\n\", module);\n\n /* Emit all of the code */\n Language::top(n);\n\n SwigPHP_emit_resource_registrations();\n // Printv(s_init,s_resourcetypes,NIL);\n /* We need this after all classes written out by ::top */\n Printf(s_oinit, \"CG(active_class_entry) = NULL;\\n\");\n Printf(s_oinit, \"/* end oinit subsection */\\n\");\n Printf(s_init, \"%s\\n\", s_oinit);\n\n /* Constants generated during top call */\n Printf(s_cinit, \"/* end cinit subsection */\\n\");\n Printf(s_init, \"%s\\n\", s_cinit);\n Clear(s_cinit);\n Delete(s_cinit);\n\n Printf(s_init, \" return SUCCESS;\\n\");\n Printf(s_init, \"}\\n\\n\");\n\n // Now do REQUEST init which holds any user specified %rinit, and also vinit\n Printf(s_init, \"PHP_RINIT_FUNCTION(%s)\\n{\\n\", module);\n Printf(s_init, \"%s\\n\", r_init);\n\n /* finish our init section which will have been used by class wrappers */\n Printf(s_vinit, \"/* end vinit subsection */\\n\");\n Printf(s_init, \"%s\\n\", s_vinit);\n Clear(s_vinit);\n Delete(s_vinit);\n\n Printf(s_init, \" return SUCCESS;\\n\");\n Printf(s_init, \"}\\n\\n\");\n\n Printv(s_init, \"PHP_MSHUTDOWN_FUNCTION(\", module, \")\\n\"\n\t\t \"{\\n\",\n\t\t s_shutdown,\n\t\t \"#ifdef ZTS\\n\"\n\t\t \" ts_free_id(\", module, \"_globals_id);\\n\"\n\t\t \"#endif\\n\"\n\t\t \" return SUCCESS;\\n\"\n\t\t \"}\\n\\n\", NIL);\n\n Printf(s_init, \"PHP_RSHUTDOWN_FUNCTION(%s)\\n{\\n\", module);\n Printf(s_init, \"%s\\n\", r_shutdown);\n Printf(s_init, \" return SUCCESS;\\n\");\n Printf(s_init, \"}\\n\\n\");\n\n Printf(s_init, \"PHP_MINFO_FUNCTION(%s)\\n{\\n\", module);\n Printf(s_init, \"%s\", pragma_phpinfo);\n Printf(s_init, \"}\\n\");\n Printf(s_init, \"/* end init section */\\n\");\n\n Printf(f_h, \"#endif /* PHP_%s_H */\\n\", cap_module);\n\n Close(f_h);\n\n String *type_table = NewStringEmpty();\n SwigType_emit_type_table(f_runtime, type_table);\n Printf(s_header, \"%s\", type_table);\n Delete(type_table);\n\n /* Oh dear, more things being called in the wrong order. This whole\n * function really needs totally redoing.\n */\n\n Printf(s_header, \"/* end header section */\\n\");\n Printf(s_wrappers, \"/* end wrapper section */\\n\");\n Printf(s_vdecl, \"/* end vdecl subsection */\\n\");\n\n Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL);\n Printv(f_runtime, all_cs_entry, \"\\n\\n\", s_entry, \"{NULL, NULL, NULL}\\n};\\n\\n\", NIL);\n Printv(f_runtime, s_init, NIL);\n Delete(s_header);\n Delete(s_wrappers);\n Delete(s_init);\n Delete(s_vdecl);\n Delete(all_cs_entry);\n Delete(s_entry);\n Close(f_runtime);\n\n Printf(f_phpcode, \"%s\\n%s\\n\", pragma_incl, pragma_code);\n if (s_fakeoowrappers) {\n Printf(f_phpcode, \"abstract class %s {\", Len(prefix) ? prefix : module);\n Printf(f_phpcode, \"%s\", s_fakeoowrappers);\n Printf(f_phpcode, \"}\\n\\n\");\n Delete(s_fakeoowrappers);\n s_fakeoowrappers = NULL;\n }\n Printf(f_phpcode, \"%s\\n?>\\n\", s_phpclasses);\n Close(f_phpcode);\n\n if (gen_extra) {\n create_extra_files(outfile);\n } else if (gen_make) {\n create_simple_make();\n }\n\n return SWIG_OK;\n }\n\n /* Just need to append function names to function table to register with PHP. */\n void create_command(String *cname, String *iname) {\n // This is for the single main zend_function_entry record\n if (shadow && php_version == 4) {\n if (wrapperType != standard)\n\treturn;\n }\n Printf(f_h, \"ZEND_NAMED_FUNCTION(%s);\\n\", iname);\n String * s = cs_entry;\n if (!s) s = s_entry;\n Printf(s, \" SWIG_ZEND_NAMED_FE(%(lower)s,%s,NULL)\\n\", cname, iname);\n }\n\n /* ------------------------------------------------------------\n * dispatchFunction()\n * ------------------------------------------------------------ */\n void dispatchFunction(Node *n) {\n /* Last node in overloaded chain */\n\n int maxargs;\n String *tmp = NewStringEmpty();\n String *dispatch = Swig_overload_dispatch(n, \"return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);\", &maxargs);\n\n int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4);\n\n /* Generate a dispatch wrapper for all overloaded functions */\n\n Wrapper *f = NewWrapper();\n String *symname = Getattr(n, \"sym:name\");\n String *wname = Swig_name_wrapper(symname);\n\n create_command(symname, wname);\n Printv(f->def, \"ZEND_NAMED_FUNCTION(\", wname, \") {\\n\", NIL);\n\n Wrapper_add_local(f, \"argc\", \"int argc\");\n\n Printf(tmp, \"zval **argv[%d]\", maxargs);\n Wrapper_add_local(f, \"argv\", tmp);\n\n Printf(f->code, \"argc = ZEND_NUM_ARGS();\\n\");\n\n if (has_this_ptr) {\n Printf(f->code, \"argv[0] = &this_ptr;\\n\");\n Printf(f->code, \"zend_get_parameters_array_ex(argc,argv+1);\\n\");\n Printf(f->code, \"argc++;\\n\");\n } else {\n Printf(f->code, \"zend_get_parameters_array_ex(argc,argv);\\n\");\n }\n\n Replaceall(dispatch, \"$args\", \"self,args\");\n\n Printv(f->code, dispatch, \"\\n\", NIL);\n\n Printf(f->code, \"SWIG_ErrorCode() = E_ERROR;\\n\");\n Printf(f->code, \"SWIG_ErrorMsg() = \\\"No matching function for overloaded '%s'\\\";\\n\", symname);\n Printv(f->code, \"zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\\n\", NIL);\n\n Printv(f->code, \"}\\n\", NIL);\n Wrapper_print(f, s_wrappers);\n\n DelWrapper(f);\n Delete(dispatch);\n Delete(tmp);\n Delete(wname);\n }\n\n /* ------------------------------------------------------------\n * functionWrapper()\n * ------------------------------------------------------------ */\n\n /* Helper method for PHP::functionWrapper */\n bool is_class(SwigType *t) {\n Node *n = classLookup(t);\n if (n) {\n String *r = Getattr(n, \"php:proxy\");\t// Set by classDeclaration()\n if (!r)\n\tr = Getattr(n, \"sym:name\");\t// Not seen by classDeclaration yet, but this is the name\n if (r)\n\treturn true;\n }\n return false;\n }\n\n virtual int functionWrapper(Node *n) {\n String *name = GetChar(n, \"name\");\n String *iname = GetChar(n, \"sym:name\");\n SwigType *d = Getattr(n, \"type\");\n ParmList *l = Getattr(n, \"parms\");\n String *nodeType = Getattr(n, \"nodeType\");\n int newobject = GetFlag(n, \"feature:new\");\n\n Parm *p;\n int i;\n int numopt;\n String *tm;\n Wrapper *f;\n bool mvr = (shadow && php_version == 4 && wrapperType == membervar);\n bool mvrset = (mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0));\n\n String *wname;\n int overloaded = 0;\n String *overname = 0;\n\n if (Cmp(nodeType, \"destructor\") == 0) {\n // We just generate the Zend List Destructor and let Zend manage the\n // reference counting. There's no explicit destructor, but the user can\n // just do `$obj = null;' to remove a reference to an object.\n return CreateZendListDestructor(n);\n }\n // Test for overloading;\n if (Getattr(n, \"sym:overloaded\")) {\n overloaded = 1;\n overname = Getattr(n, \"sym:overname\");\n } else {\n if (!addSymbol(iname, n))\n\treturn SWIG_ERROR;\n }\n\n wname = Swig_name_wrapper(iname);\n if (overname) {\n Printf(wname, \"%s\", overname);\n }\n // if PHP4, shadow and variable wrapper we want to snag the main contents\n // of this function to stick in to the property handler...\n if (mvr) {\n String *php_function_name = NewString(iname);\n if (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0) {\n\tSetattr(shadow_set_vars, php_function_name, name);\n }\n if (Strcmp(iname, Swig_name_get(Swig_name_member(shadow_classname, name))) == 0) {\n\tSetattr(shadow_get_vars, php_function_name, name);\n }\n\n Delete(php_function_name);\n }\n\n f = NewWrapper();\n numopt = 0;\n\n String *outarg = NewStringEmpty();\n String *cleanup = NewStringEmpty();\n\n if (mvr) {\t\t\t// do prop[gs]et header\n if (mvrset) {\n\tPrintf(f->def, \"static int _wrap_%s(zend_property_reference *property_reference, pval *value) {\\n\", iname);\n } else {\n\tPrintf(f->def, \"static pval _wrap_%s(zend_property_reference *property_reference) {\\n\", iname);\n }\n } else {\n // regular header\n // Not issued for overloaded functions or static member variables.\n if (!overloaded && wrapperType != staticmembervar) {\n\tcreate_command(iname, wname);\n }\n Printv(f->def, \"ZEND_NAMED_FUNCTION(\", wname, \") {\\n\", NIL);\n }\n\n emit_args(d, l, f);\n /* Attach standard typemaps */\n\n emit_attach_parmmaps(l, f);\n\n // wrap:parms is used by overload resolution.\n Setattr(n, \"wrap:parms\", l);\n\n int num_arguments = emit_num_arguments(l);\n int num_required = emit_num_required(l);\n numopt = num_arguments - num_required;\n\n int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4);\n\n if (num_arguments - has_this_ptr > 0) {\n String *args = NewStringf(\"zval **args[%d]\", num_arguments - has_this_ptr);\n Wrapper_add_local(f, \"args\", args);\n Delete(args);\n args = NULL;\n }\n // This generated code may be called:\n // 1) as an object method, or\n // 2) as a class-method/function (without a \"this_ptr\")\n // Option (1) has \"this_ptr\" for \"this\", option (2) needs it as\n // first parameter\n\n // NOTE: possible we ignore this_ptr as a param for native constructor\n\n Printf(f->code, \"SWIG_ResetError();\\n\");\n\n if (has_this_ptr)\n Printf(f->code, \"/* This function uses a this_ptr*/\\n\");\n\n if (native_constructor) {\n if (native_constructor == NATIVE_CONSTRUCTOR) {\n\tPrintf(f->code, \"/* NATIVE Constructor */\\n\");\n } else {\n\tPrintf(f->code, \"/* ALTERNATIVE Constructor */\\n\");\n }\n }\n\n if (mvr && !mvrset) {\n Wrapper_add_local(f, \"_return_value\", \"zval _return_value\");\n Wrapper_add_local(f, \"return_value\", \"zval *return_value=&_return_value\");\n }\n\n if (numopt > 0) {\t\t// membervariable wrappers do not have optional args\n Wrapper_add_local(f, \"arg_count\", \"int arg_count\");\n Printf(f->code, \"arg_count = ZEND_NUM_ARGS();\\n\");\n Printf(f->code, \"if(arg_count<%d || arg_count>%d ||\\n\", num_required, num_arguments);\n Printf(f->code, \" zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\\n\");\n Printf(f->code, \"\\tWRONG_PARAM_COUNT;\\n\\n\");\n } else if (!mvr) {\n int num = num_arguments - has_this_ptr;\n if (num == 0) {\n\tPrintf(f->code, \"if(ZEND_NUM_ARGS() != 0) {\\n\");\n } else {\n\tPrintf(f->code, \"if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\\n\", num, num);\n }\n Printf(f->code, \"WRONG_PARAM_COUNT;\\n}\\n\\n\");\n }\n\n /* Now convert from php to C variables */\n // At this point, argcount if used is the number of deliberately passed args\n // not including this_ptr even if it is used.\n // It means error messages may be out by argbase with error\n // reports. We can either take argbase into account when raising\n // errors, or find a better way of dealing with _thisptr.\n // I would like, if objects are wrapped, to assume _thisptr is always\n // _this and not the first argument.\n // This may mean looking at Language::memberfunctionHandler\n\n for (i = 0, p = l; i < num_arguments; i++) {\n String *source;\n\n /* Skip ignored arguments */\n //while (Getattr(p,\"tmap:ignore\")) { p = Getattr(p,\"tmap:ignore:next\");}\n while (checkAttribute(p, \"tmap:in:numinputs\", \"0\")) {\n\tp = Getattr(p, \"tmap:in:next\");\n }\n\n SwigType *pt = Getattr(p, \"type\");\n\n if (mvr) {\t\t// do we assert that numargs=2, that i<2\n\tif (i == 0) {\n\t source = NewString(\"&(property_reference->object)\");\n\t} else {\n\t source = NewString(\"&value\");\n\t}\n } else {\n\tif (i == 0 && has_this_ptr) {\n\t source = NewString(\"&this_ptr\");\n\t} else {\n\t source = NewStringf(\"args[%d]\", i - has_this_ptr);\n\t}\n }\n\n String *ln = Getattr(p, \"lname\");\n\n /* Check if optional */\n if (i >= num_required) {\n\tPrintf(f->code, \"\\tif(arg_count > %d) {\\n\", i);\n }\n\n if ((tm = Getattr(p, \"tmap:in\"))) {\n\tReplaceall(tm, \"$source\", source);\n\tReplaceall(tm, \"$target\", ln);\n\tReplaceall(tm, \"$input\", source);\n\tSetattr(p, \"emit:input\", source);\n\tPrintf(f->code, \"%s\\n\", tm);\n\tif (i == 0 && Getattr(p, \"self\")) {\n\t Printf(f->code, \"\\tif(!arg1) SWIG_PHP_Error(E_ERROR, \\\"this pointer is NULL\\\");\\n\");\n\t}\n\tp = Getattr(p, \"tmap:in:next\");\n\tif (i >= num_required) {\n\t Printf(f->code, \"}\\n\");\n\t}\n\tcontinue;\n } else {\n\tSwig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, \"Unable to use type %s as a function argument.\\n\", SwigType_str(pt, 0));\n }\n if (i >= num_required) {\n\tPrintf(f->code, \"\\t}\\n\");\n }\n Delete(source);\n }\n\n /* Insert constraint checking code */\n for (p = l; p;) {\n if ((tm = Getattr(p, \"tmap:check\"))) {\n\tReplaceall(tm, \"$target\", Getattr(p, \"lname\"));\n\tPrintv(f->code, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:check:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* Insert cleanup code */\n for (i = 0, p = l; p; i++) {\n if ((tm = Getattr(p, \"tmap:freearg\"))) {\n\tReplaceall(tm, \"$source\", Getattr(p, \"lname\"));\n\tPrintv(cleanup, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:freearg:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* Insert argument output code */\n for (i = 0, p = l; p; i++) {\n if ((tm = Getattr(p, \"tmap:argout\"))) {\n\tReplaceall(tm, \"$source\", Getattr(p, \"lname\"));\n\t// Replaceall(tm,\"$input\",Getattr(p,\"lname\"));\n\tReplaceall(tm, \"$target\", \"return_value\");\n\tReplaceall(tm, \"$result\", \"return_value\");\n\tReplaceall(tm, \"$arg\", Getattr(p, \"emit:input\"));\n\tReplaceall(tm, \"$input\", Getattr(p, \"emit:input\"));\n\tPrintv(outarg, tm, \"\\n\", NIL);\n\tp = Getattr(p, \"tmap:argout:next\");\n } else {\n\tp = nextSibling(p);\n }\n }\n\n /* emit function call */\n emit_action(n, f);\n\n if ((tm = Swig_typemap_lookup_new(\"out\", n, \"result\", 0))) {\n Replaceall(tm, \"$input\", \"result\");\n Replaceall(tm, \"$source\", \"result\");\n Replaceall(tm, \"$target\", \"return_value\");\n Replaceall(tm, \"$result\", \"return_value\");\n Replaceall(tm, \"$owner\", newobject ? \"1\" : \"0\");\n Printf(f->code, \"%s\\n\", tm);\n // Are we returning a wrapable object?\n if (shadow && php_version == 4 && is_shadow(d) && (SwigType_type(d) != T_ARRAY)) {\n\t// Make object.\n\tPrintf(f->code, \"{\\n/* Wrap this return value */\\n\");\n\tPrintf(f->code, \"zval *_cPtr;\\n\");\n\tPrintf(f->code, \"ALLOC_ZVAL(_cPtr);\\n\");\n\tPrintf(f->code, \"*_cPtr = *return_value;\\n\");\n\tPrintf(f->code, \"INIT_ZVAL(*return_value);\\n\");\n\tif (native_constructor == NATIVE_CONSTRUCTOR) {\n\t Printf(f->code, \"add_property_zval(this_ptr,\\\"\" SWIG_PTR \"\\\",_cPtr);\\n\");\n\t} else {\n\t String *shadowrettype = SwigToPhpType(d, iname, true);\n\t Printf(f->code, \"object_init_ex(return_value,ptr_ce_swig_%s);\\n\", shadowrettype);\n\t Delete(shadowrettype);\n\t Printf(f->code, \"add_property_zval(return_value,\\\"\" SWIG_PTR \"\\\",_cPtr);\\n\");\n\t}\n\tPrintf(f->code, \"}\\n\");\n }\n } else {\n Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, \"Unable to use return type %s in function %s.\\n\", SwigType_str(d, 0), name);\n }\n\n if (outarg) {\n Printv(f->code, outarg, NIL);\n }\n\n if (cleanup) {\n Printv(f->code, cleanup, NIL);\n }\n\n /* Look to see if there is any newfree cleanup code */\n if (GetFlag(n, \"feature:new\")) {\n if ((tm = Swig_typemap_lookup_new(\"newfree\", n, \"result\", 0))) {\n\tPrintf(f->code, \"%s\\n\", tm);\n\tDelete(tm);\n }\n }\n\n /* See if there is any return cleanup code */\n if ((tm = Swig_typemap_lookup_new(\"ret\", n, \"result\", 0))) {\n Printf(f->code, \"%s\\n\", tm);\n Delete(tm);\n }\n\n\n if (mvr) {\n if (!mvrset) {\n\tPrintf(f->code, \"return _return_value;\\n\");\n } else {\n\tPrintf(f->code, \"return SUCCESS;\\n\");\n }\n } else {\n Printf(f->code, \"return;\\n\");\n }\n\n /* Error handling code */\n Printf(f->code, \"fail:\\n\");\n Printv(f->code, cleanup, NIL);\n Printv(f->code, \"zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\", NIL);\n\n Printf(f->code, \"}\\n\");\n\n Replaceall(f->code, \"$cleanup\", cleanup);\n Replaceall(f->code, \"$symname\", iname);\n\n Wrapper_print(f, s_wrappers);\n\n // wrap:name is used by overload resolution\n Setattr(n, \"wrap:name\", wname);\n if (overloaded && !Getattr(n, \"sym:nextSibling\")) {\n dispatchFunction(n);\n }\n\n Delete(wname);\n wname = NULL;\n\n if (!(shadow && php_version == 5)) {\n DelWrapper(f);\n return SWIG_OK;\n }\n\n // Handle getters and setters.\n if (wrapperType == membervar) {\n const char *p = Char(iname);\n if (strlen(p) > 4) {\n\tp += strlen(p) - 4;\n\tString *varname = Getattr(n, \"membervariableHandler:sym:name\");\n\tif (strcmp(p, \"_get\") == 0) {\n\t Setattr(shadow_get_vars, varname, iname);\n\t} else if (strcmp(p, \"_set\") == 0) {\n\t Setattr(shadow_set_vars, varname, iname);\n\t}\n }\n }\n // Only look at non-overloaded methods and the last entry in each overload\n // chain (we check the last so that wrap:parms and wrap:name have been set\n // for them all).\n if (overloaded && Getattr(n, \"sym:nextSibling\") != 0)\n return SWIG_OK;\n\n if (!s_oowrappers)\n s_oowrappers = NewStringEmpty();\n if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard) {\n bool handle_as_overload = false;\n String **arg_names;\n String **arg_values;\n // Method or static method or plain function.\n const char *methodname = 0;\n String *output = s_oowrappers;\n if (newobject) {\n\tclass_has_ctor = true;\n\tmethodname = \"__construct\";\n } else if (wrapperType == memberfn) {\n\tmethodname = Char(Getattr(n, \"memberfunctionHandler:sym:name\"));\n } else if (wrapperType == staticmemberfn) {\n\tmethodname = Char(Getattr(n, \"staticmemberfunctionHandler:sym:name\"));\n } else {\t\t\t// wrapperType == standard\n\tmethodname = Char(iname);\n\tif (!s_fakeoowrappers)\n\t s_fakeoowrappers = NewStringEmpty();\n\toutput = s_fakeoowrappers;\n }\n\n bool really_overloaded = overloaded ? true : false;\n int min_num_of_arguments = emit_num_required(l);\n int max_num_of_arguments = emit_num_arguments(l);\n // For a function with default arguments, we end up with the fullest\n // parmlist in full_parmlist.\n ParmList *full_parmlist = l;\n Hash *ret_types = NewHash();\n Setattr(ret_types, d, d);\n\n if (overloaded) {\n\t// Look at all the overloaded versions of this method in turn to\n\t// decide if it's really an overloaded method, or just one where some\n\t// parameters have default values.\n\tNode *o = Getattr(n, \"sym:overloaded\");\n\twhile (o) {\n\t if (o == n) {\n\t o = Getattr(o, \"sym:nextSibling\");\n\t continue;\n\t }\n\n\t SwigType *d2 = Getattr(o, \"type\");\n\t if (!d2) {\n\t assert(constructor);\n\t } else if (!Getattr(ret_types, d2)) {\n\t Setattr(ret_types, d2, d2);\n\t }\n\n\t ParmList *l2 = Getattr(o, \"wrap:parms\");\n\t int num_arguments = emit_num_arguments(l2);\n\t int num_required = emit_num_required(l2);\n\t if (num_required < min_num_of_arguments)\n\t min_num_of_arguments = num_required;\n\n\t if (num_arguments > max_num_of_arguments) {\n\t max_num_of_arguments = num_arguments;\n\t full_parmlist = l2;\n\t }\n\t o = Getattr(o, \"sym:nextSibling\");\n\t}\n\n\to = Getattr(n, \"sym:overloaded\");\n\twhile (o) {\n\t if (o == n) {\n\t o = Getattr(o, \"sym:nextSibling\");\n\t continue;\n\t }\n\n\t ParmList *l2 = Getattr(o, \"wrap:parms\");\n\t Parm *p = l, *p2 = l2;\n\t if (wrapperType == memberfn) {\n\t p = nextSibling(p);\n\t p2 = nextSibling(p2);\n\t }\n\t while (p && p2) {\n\t if (Cmp(Getattr(p, \"type\"), Getattr(p2, \"type\")) != 0)\n\t break;\n\t if (Cmp(Getattr(p, \"name\"), Getattr(p2, \"name\")) != 0)\n\t break;\n\t String *value = Getattr(p, \"value\");\n\t String *value2 = Getattr(p2, \"value\");\n\t if (value && !value2)\n\t break;\n\t if (!value && value2)\n\t break;\n\t if (value) {\n\t if (Cmp(value, value2) != 0)\n\t\tbreak;\n\t }\n\t p = nextSibling(p);\n\t p2 = nextSibling(p2);\n\t }\n\t if (p && p2)\n\t break;\n\t // One parameter list is a prefix of the other, so check that all\n\t // remaining parameters of the longer list are optional.\n\t if (p2)\n\t p = p2;\n\t while (p && Getattr(p, \"value\"))\n\t p = nextSibling(p);\n\t if (p)\n\t break;\n\t o = Getattr(o, \"sym:nextSibling\");\n\t}\n\tif (!o) {\n\t // This \"overloaded method\" is really just one with default args.\n\t really_overloaded = false;\n\t if (l != full_parmlist) {\n\t l = full_parmlist;\n\t if (wrapperType == memberfn)\n\t l = nextSibling(l);\n\t }\n\t}\n }\n\n if (wrapperType == memberfn) {\n\t// Allow for the \"this\" pointer.\n\t--min_num_of_arguments;\n\t--max_num_of_arguments;\n }\n\n arg_names = (String **) malloc(max_num_of_arguments * sizeof(String *));\n if (!arg_names) {\n\t/* FIXME: How should this be handled? The rest of SWIG just seems\n\t * to not bother checking for malloc failing! */\n\tfprintf(stderr, \"Malloc failed!\\n\");\n\texit(1);\n }\n for (i = 0; i < max_num_of_arguments; ++i) {\n\targ_names[i] = NULL;\n }\n\n arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *));\n if (!arg_values) {\n\t/* FIXME: How should this be handled? The rest of SWIG just seems\n\t * to not bother checking for malloc failing! */\n\tfprintf(stderr, \"Malloc failed!\\n\");\n\texit(1);\n }\n for (i = 0; i < max_num_of_arguments; ++i) {\n\targ_values[i] = NULL;\n }\n\n Node *o;\n if (overloaded) {\n\to = Getattr(n, \"sym:overloaded\");\n } else {\n\to = n;\n }\n while (o) {\n\tint argno = 0;\n\tParm *p = Getattr(o, \"wrap:parms\");\n\tif (wrapperType == memberfn)\n\t p = nextSibling(p);\n\twhile (p) {\n\t assert(0 <= argno && argno < max_num_of_arguments);\n\t String *&pname = arg_names[argno];\n\t const char *pname_cstr = GetChar(p, \"name\");\n\t if (!pname_cstr) {\n\t // Unnamed parameter, e.g. int foo(int);\n\t } else if (pname == NULL) {\n\t pname = NewString(pname_cstr);\n\t } else {\n\t size_t len = strlen(pname_cstr);\n\t size_t spc = 0;\n\t size_t len_pname = strlen(Char(pname));\n\t while (spc + len <= len_pname) {\n\t if (strncmp(pname_cstr, Char(pname) + spc, len) == 0) {\n\t\tchar ch = ((char *) Char(pname))[spc + len];\n\t\tif (ch == '\\0' || ch == ' ') {\n\t\t // Already have this pname_cstr.\n\t\t pname_cstr = NULL;\n\t\t break;\n\t\t}\n\t }\n\t char *p = strchr(Char(pname) + spc, ' ');\n\t if (!p)\n\t\tbreak;\n\t spc = (p + 4) - Char(pname);\n\t }\n\t if (pname_cstr) {\n\t Printf(pname, \" or_%s\", pname_cstr);\n\t }\n\t }\n\t String *value = NewString(Getattr(p, \"value\"));\n\t if (Len(value)) {\n\t /* Check that value is a valid constant in PHP (and adjust it if\n\t * necessary, or replace it with \"?\" if it's just not valid). */\n\t SwigType *type = Getattr(p, \"type\");\n\t switch (SwigType_type(type)) {\n\t case T_BOOL: {\n\t\tif (Strcmp(value, \"true\") == 0 || Strcmp(value, \"false\") == 0)\n\t\t break;\n\t\tchar *p;\n\t\terrno = 0;\n\t\tint n = strtol(Char(value), &p, 0);\n\t Clear(value);\n\t\tif (errno || *p) {\n\t\t Append(value, \"?\");\n\t\t} else if (n) {\n\t\t Append(value, \"true\");\n\t\t} else {\n\t\t Append(value, \"false\");\n\t\t}\n\t\tbreak;\n\t }\n\t case T_CHAR:\n\t case T_SCHAR:\n\t case T_SHORT:\n\t case T_INT:\n\t case T_LONG: {\n\t\tchar *p;\n\t\terrno = 0;\n\t\t(void) strtol(Char(value), &p, 0);\n\t\tif (errno || *p) {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t}\n\t\tbreak;\n\t }\n\t case T_UCHAR:\n\t case T_USHORT:\n\t case T_UINT:\n\t case T_ULONG: {\n\t\tchar *p;\n\t\terrno = 0;\n\t\t(void) strtoul(Char(value), &p, 0);\n\t\tif (errno || *p) {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t}\n\t\tbreak;\n\t }\n\t case T_FLOAT:\n\t case T_DOUBLE:{\n\t\tchar *p;\n\t\terrno = 0;\n\t\t/* FIXME: strtod is locale dependent... */\n\t\tdouble val = strtod(Char(value), &p);\n\t\tif (errno || *p) {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t} else if (strchr(Char(value), '.') == NULL) {\n\t\t // Ensure value is a double constant, not an integer one.\n\t\t Append(value, \".0\");\n\t\t double val2 = strtod(Char(value), &p);\n\t\t if (errno || *p || val != val2) {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t }\n\t\t}\n\t\tbreak;\n\t }\n\t case T_REFERENCE:\n\t case T_USER:\n\t case T_ARRAY:\n\t\tClear(value);\n\t\tAppend(value, \"?\");\n\t\tbreak;\n\t case T_STRING:\n\t\tif (Len(value) < 2) {\n\t\t // How can a string (including \"\" be less than 2 characters?)\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t} else {\n\t\t const char *v = Char(value);\n\t\t if (v[0] != '\"' || v[Len(value) - 1] != '\"') {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t }\n\t\t // Strings containing \"$\" require special handling, but we do\n\t\t // that later.\n\t\t}\n\t\tbreak;\n\t case T_VOID:\n\t\tassert(false);\n\t\tbreak;\n\t case T_POINTER: {\n\t\tconst char *v = Char(value);\n\t\tif (v[0] == '(') {\n\t\t // Handle \"(void*)0\", \"(TYPE*)0\", \"(char*)NULL\", etc.\n\t\t v += strcspn(v + 1, \"*()\") + 1;\n\t\t if (*v == '*') {\n\t\t do {\n\t\t v++;\n\t\t v += strspn(v, \" \\t\");\n\t\t } while (*v == '*');\n\t\t if (*v++ == ')') {\n\t\t v += strspn(v, \" \\t\");\n\t\t String * old = value;\n\t\t value = NewString(v);\n\t\t Delete(old);\n\t\t }\n\t\t }\n\t\t}\n\t\tif (Strcmp(value, \"NULL\") == 0 ||\n\t\t Strcmp(value, \"0\") == 0 ||\n\t\t Strcmp(value, \"0L\") == 0) {\n\t\t Clear(value);\n\t\t Append(value, \"null\");\n\t\t} else {\n\t\t Clear(value);\n\t\t Append(value, \"?\");\n\t\t}\n\t\tbreak;\n\t }\n\t }\n\n\t if (!arg_values[argno]) {\n\t arg_values[argno] = value;\n\t value = NULL;\n\t } else if (Cmp(arg_values[argno], value) != 0) {\n\t // If a parameter has two different default values in\n\t // different overloaded forms of the function, we can't\n\t // set its default in PHP. Flag this by setting its\n\t // default to `?'.\n\t Delete(arg_values[argno]);\n\t arg_values[argno] = NewString(\"?\");\n\t }\n\t } else if (arg_values[argno]) {\n\t // This argument already has a default value in another overloaded\n\t // form, but doesn't in this form. So don't try to do anything\n\t // clever, just let the C wrappers resolve the overload and set the\n\t // default values.\n\t //\n\t // This handling is safe, but I'm wondering if it may be overly\n\t // conservative (FIXME) in some cases. It seems it's only bad when\n\t // there's an overloaded form with the appropriate number of\n\t // parameters which doesn't want the default value, but I need to\n\t // think about this more.\n\t Delete(arg_values[argno]);\n\t arg_values[argno] = NewString(\"?\");\n\t }\n\t Delete(value);\n\t p = nextSibling(p);\n\t ++argno;\n\t}\n\tif (!really_overloaded)\n\t break;\n\to = Getattr(o, \"sym:nextSibling\");\n }\n\n /* Clean up any parameters which haven't yet got names, or whose\n * names clash. */\n Hash *seen = NewHash();\n /* We need $this to refer to the current class, so can't allow it\n * to be used as a parameter. */\n Setattr(seen, \"this\", seen);\n /* We use $r to store the return value, so disallow that as a parameter\n * name in case the user uses the \"call-time pass-by-reference\" feature\n * (it's deprecated and off by default in PHP5 and even later PHP4\n * versions apparently, but we want to be maximally portable).\n */\n Setattr(seen, \"r\", seen);\n\n for (int argno = 0; argno < max_num_of_arguments; ++argno) {\n\tString *&pname = arg_names[argno];\n\tif (pname) {\n\t Replaceall(pname, \" \", \"_\");\n\t} else {\n\t /* We get here if the SWIG .i file has \"int foo(int);\" */\n\t pname = NewStringEmpty();\n\t Printf(pname, \"arg%d\", argno + 1);\n\t}\n\t// Check if we've already used this parameter name.\n\twhile (Getattr(seen, pname)) {\n\t // Append \"_\" to clashing names until they stop clashing...\n\t Printf(pname, \"_\");\n\t}\n\tSetattr(seen, Char(pname), seen);\n\n\tif (arg_values[argno] && Cmp(arg_values[argno], \"?\") == 0) {\n\t handle_as_overload = true;\n\t}\n }\n Delete(seen);\n seen = NULL;\n\n String *invoke = NewStringEmpty();\n String *prepare = NewStringEmpty();\n String *args = NewStringEmpty();\n\n if (!handle_as_overload && !(really_overloaded && max_num_of_arguments > min_num_of_arguments)) {\n\tPrintf(invoke, \"%s(\", iname);\n\tif (wrapperType == memberfn) {\n\t Printf(invoke, \"$this->%s\", SWIG_PTR);\n\t}\n\tfor (int i = 0; i < max_num_of_arguments; ++i) {\n\t if (i)\n\t Printf(args, \",\");\n\t if (i || wrapperType == memberfn)\n\t Printf(invoke, \",\");\n\t String *value = arg_values[i];\n\t if (value) {\n\t const char *v = Char(value);\n\t if (v[0] == '\"') {\n\t /* In a PHP double quoted string, $ needs to be escaped as \\$. */\n\t Replaceall(value, \"$\", \"\\\\$\");\n\t }\n\t Printf(args, \"$%s=%s\", arg_names[i], value);\n\t } else {\n\t Printf(args, \"$%s\", arg_names[i]);\n\t }\n\t Printf(invoke, \"$%s\", arg_names[i]);\n\t}\n\tPrintf(invoke, \")\");\n } else {\n\tint i;\n\tfor (i = 0; i < min_num_of_arguments; ++i) {\n\t if (i)\n\t Printf(args, \",\");\n\t Printf(args, \"$%s\", arg_names[i]);\n\t}\n\tString *invoke_args = NewStringEmpty();\n\tif (wrapperType == memberfn) {\n\t Printf(invoke_args, \"$this->%s\", SWIG_PTR);\n\t if (min_num_of_arguments > 0)\n\t Printf(invoke_args, \",\");\n\t}\n\tPrintf(invoke_args, \"%s\", args);\n\tbool had_a_case = false;\n\tint last_handled_i = i - 1;\n\tfor (; i < max_num_of_arguments; ++i) {\n\t if (i)\n\t Printf(args, \",\");\n\t const char *value = Char(arg_values[i]);\n\t // FIXME: (really_overloaded && handle_as_overload) is perhaps a\n\t // little conservative, but it doesn't hit any cases that it\n\t // shouldn't for Xapian at least (and we need it to handle\n\t // \"Enquire::get_mset()\" correctly).\n\t bool non_php_default = ((really_overloaded && handle_as_overload) ||\n\t\t\t\t !value || strcmp(value, \"?\") == 0);\n\t if (non_php_default)\n\t value = \"null\";\n\t Printf(args, \"$%s=%s\", arg_names[i], value);\n\t if (non_php_default) {\n\t if (!had_a_case) {\n\t Printf(prepare, \"\\t\\tswitch (func_num_args()) {\\n\");\n\t had_a_case = true;\n\t }\n\t Printf(prepare, \"\\t\\t\");\n\t while (last_handled_i < i) {\n\t Printf(prepare, \"case %d: \", ++last_handled_i);\n\t }\n\t if (Cmp(d, \"void\") != 0)\n\t Printf(prepare, \"$r=\");\n\t Printf(prepare, \"%s(%s); break;\\n\", iname, invoke_args);\n\t }\n\t if (i || wrapperType == memberfn)\n\t Printf(invoke_args, \",\");\n\t Printf(invoke_args, \"$%s\", arg_names[i]);\n\t}\n\tPrintf(prepare, \"\\t\\t\");\n\tif (had_a_case)\n\t Printf(prepare, \"default: \");\n\tif (Cmp(d, \"void\") != 0)\n\t Printf(prepare, \"$r=\");\n\tPrintf(prepare, \"%s(%s);\\n\", iname, invoke_args);\n\tif (had_a_case)\n\t Printf(prepare, \"\\t\\t}\\n\");\n\tDelete(invoke_args);\n\tPrintf(invoke, \"$r\");\n }\n\n Printf(output, \"\\n\");\n if (wrapperType == memberfn || newobject) {\n\tPrintf(output, \"\\tfunction %s(%s) {\\n\", methodname, args);\n\t// We don't need this code if the wrapped class has a copy ctor\n\t// since the flat function new_CLASSNAME will handle it for us.\n\tif (newobject && !Getattr(current_class, \"allocate:copy_constructor\")) {\n\t SwigType *t = Getattr(current_class, \"classtype\");\n\t String *mangled_type = SwigType_manglestr(SwigType_ltype(t));\n\t Printf(s_oowrappers, \"\\t\\tif (is_resource($%s) && get_resource_type($%s) == \\\"_p%s\\\") {\\n\", arg_names[0], arg_names[0], mangled_type);\n\t Printf(s_oowrappers, \"\\t\\t\\t$this->%s=$%s;\\n\", SWIG_PTR, arg_names[0]);\n\t Printf(s_oowrappers, \"\\t\\t\\treturn;\\n\");\n\t Printf(s_oowrappers, \"\\t\\t}\\n\");\n\t}\n } else {\n\tPrintf(output, \"\\tstatic function %s(%s) {\\n\", methodname, args);\n }\n Delete(args);\n args = NULL;\n\n for (int i = 0; i < max_num_of_arguments; ++i) {\n\tDelete(arg_names[i]);\n }\n free(arg_names);\n arg_names = NULL;\n\n Printf(output, \"%s\", prepare);\n if (newobject) {\n\tPrintf(output, \"\\t\\t$this->%s=%s;\\n\", SWIG_PTR, invoke);\n } else if (Cmp(d, \"void\") == 0) {\n\tif (Cmp(invoke, \"$r\") != 0)\n\t Printf(output, \"\\t\\t%s;\\n\", invoke);\n } else if (is_class(d)) {\n\tif (Cmp(invoke, \"$r\") != 0)\n\t Printf(output, \"\\t\\t$r=%s;\\n\", invoke);\n\tif (Len(ret_types) == 1) {\n\t Printf(output, \"\\t\\treturn is_resource($r) ? new %s%s($r) : $r;\\n\", prefix, Getattr(classLookup(d), \"sym:name\"));\n\t} else {\n\t Printf(output, \"\\t\\tif (!is_resource($r)) return $r;\\n\");\n\t Printf(output, \"\\t\\tswitch (get_resource_type($r)) {\\n\");\n\t Iterator i = First(ret_types);\n\t while (i.item) {\n\t SwigType *ret_type = i.item;\n\t i = Next(i);\n\t Printf(output, \"\\t\\t\");\n\t String *mangled = NewString(\"_p\");\n\t Printf(mangled, \"%s\", SwigType_manglestr(ret_type));\n\t Node *class_node = Getattr(zend_types, mangled);\n\t if (!class_node) {\n\t /* This is needed when we're returning a pointer to a type\n\t * rather than returning the type by value or reference. */\n\t class_node = current_class;\n\t Delete(mangled);\n\t mangled = NewString(SwigType_manglestr(ret_type));\n\t class_node = Getattr(zend_types, mangled);\n\t }\n\t if (i.item) {\n\t Printf(output, \"case \\\"%s\\\": \", mangled);\n\t } else {\n\t Printf(output, \"default: \");\n\t }\n\t const char *classname = GetChar(class_node, \"sym:name\");\n\t if (!classname)\n\t classname = GetChar(class_node, \"name\");\n\t if (classname)\n\t Printf(output, \"return new %s%s($r);\\n\", prefix, classname);\n else\n\t Printf(output, \"return $r;\\n\");\n\t Delete(mangled);\n\t }\n\t Printf(output, \"\\t\\t}\\n\");\n\t}\n } else {\n\tPrintf(output, \"\\t\\treturn %s;\\n\", invoke);\n }\n Printf(output, \"\\t}\\n\");\n Delete(prepare);\n Delete(invoke);\n free(arg_values);\n }\n\n DelWrapper(f);\n\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * globalvariableHandler()\n * ------------------------------------------------------------ */\n\n virtual int globalvariableHandler(Node *n) {\n char *name = GetChar(n, \"name\");\n char *iname = GetChar(n, \"sym:name\");\n SwigType *t = Getattr(n, \"type\");\n String *tm;\n\n /* First do the wrappers such as name_set(), name_get()\n * as provided by the baseclass's implementation of variableWrapper\n */\n if (Language::globalvariableHandler(n) == SWIG_NOWRAP) {\n return SWIG_NOWRAP;\n }\n\n if (!addSymbol(iname, n))\n return SWIG_ERROR;\n\n SwigType_remember(t);\n\n /* First link C variables to PHP */\n\n tm = Swig_typemap_lookup_new(\"varinit\", n, name, 0);\n if (tm) {\n Replaceall(tm, \"$target\", name);\n Printf(s_vinit, \"%s\\n\", tm);\n } else {\n Printf(stderr, \"%s: Line %d, Unable to link with type %s\\n\", input_file, line_number, SwigType_str(t, 0));\n }\n\n /* Now generate PHP -> C sync blocks */\n /*\n tm = Swig_typemap_lookup_new(\"varin\", n, name, 0);\n if(tm) {\n Replaceall(tm, \"$symname\", iname);\n Printf(f_c->code, \"%s\\n\", tm);\n } else {\n Printf(stderr,\"%s: Line %d, Unable to link with type %s\\n\",\n input_file, line_number, SwigType_str(t, 0));\n }\n */\n /* Now generate C -> PHP sync blocks */\n /*\n if(!GetFlag(n,\"feature:immutable\")) {\n\n tm = Swig_typemap_lookup_new(\"varout\", n, name, 0);\n if(tm) {\n Replaceall(tm, \"$symname\", iname);\n Printf(f_php->code, \"%s\\n\", tm);\n } else {\n Printf(stderr,\"%s: Line %d, Unable to link with type %s\\n\",\n input_file, line_number, SwigType_str(t, 0));\n }\n }\n */\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * constantWrapper()\n * ------------------------------------------------------------ */\n\n virtual int constantWrapper(Node *n) {\n String *name = GetChar(n, \"name\");\n String *iname = GetChar(n, \"sym:name\");\n SwigType *type = Getattr(n, \"type\");\n String *rawval = Getattr(n, \"rawval\");\n String *value = rawval ? rawval : Getattr(n, \"value\");\n String *tm;\n\n if (!addSymbol(iname, n))\n return SWIG_ERROR;\n\n SwigType_remember(type);\n\n if ((tm = Swig_typemap_lookup_new(\"consttab\", n, name, 0))) {\n Replaceall(tm, \"$source\", value);\n Replaceall(tm, \"$target\", name);\n Replaceall(tm, \"$value\", value);\n Printf(s_cinit, \"%s\\n\", tm);\n }\n\n if (shadow && php_version == 5) {\n String *enumvalue = GetChar(n, \"enumvalue\");\n String *set_to = iname;\n\n if (!enumvalue) {\n\tenumvalue = GetChar(n, \"enumvalueex\");\n }\n\n if (enumvalue) {\n\t// Check for a simple constant expression which is valid in PHP.\n\t// If we find one, initialise the const member with it; otherwise\n\t// we initialise it using the C/C++ wrapped constant.\n\tconst char *p;\n\tfor (p = Char(enumvalue); *p; ++p) {\n\t if (!isdigit((unsigned char)*p) && !strchr(\" +-\", *p)) {\n\t // FIXME: enhance to handle ` + 1' which is what\n\t // we get for enums that don't have an explicit value set.\n\t break;\n\t }\n\t}\n\tif (!*p) set_to = enumvalue;\n }\n\n if (wrapping_member_constant) {\n\tif (!s_oowrappers)\n\t s_oowrappers = NewStringEmpty();\n\tPrintf(s_oowrappers, \"\\n\\tconst %s = %s;\\n\", wrapping_member_constant, set_to);\n } else {\n\tif (!s_fakeoowrappers)\n\t s_fakeoowrappers = NewStringEmpty();\n\tPrintf(s_fakeoowrappers, \"\\n\\tconst %s = %s;\\n\", name, set_to);\n }\n }\n\n return SWIG_OK;\n }\n\n /*\n * PHP::pragma()\n *\n * Pragma directive.\n *\n * %pragma(php4) code=\"String\" # Includes a string in the .php file\n * %pragma(php4) include=\"file.pl\" # Includes a file in the .php file\n */\n\n virtual int pragmaDirective(Node *n) {\n if (!ImportMode) {\n String *lang = Getattr(n, \"lang\");\n String *type = Getattr(n, \"name\");\n String *value = Getattr(n, \"value\");\n\n if (Strcmp(lang, \"php4\") == 0) {\n\tif (Strcmp(type, \"code\") == 0) {\n\t if (value) {\n\t Printf(pragma_code, \"%s\\n\", value);\n\t }\n\t} else if (Strcmp(type, \"include\") == 0) {\n\t if (value) {\n\t Printf(pragma_incl, \"include \\\"%s\\\";\\n\", value);\n\t }\n\t} else if (Strcmp(type, \"phpinfo\") == 0) {\n\t if (value) {\n\t Printf(pragma_phpinfo, \"%s\\n\", value);\n\t }\n\t} else {\n\t Swig_warning(WARN_PHP4_UNKNOWN_PRAGMA, input_file, line_number, \"Unrecognized pragma <%s>.\\n\", type);\n\t}\n }\n }\n return Language::pragmaDirective(n);\n }\n\n /* ------------------------------------------------------------\n * classDeclaration()\n * ------------------------------------------------------------ */\n\n virtual int classDeclaration(Node *n) {\n if (!Getattr(n, \"feature:onlychildren\")) {\n String *symname = Getattr(n, \"sym:name\");\n Setattr(n, \"php:proxy\", symname);\n }\n\n return Language::classDeclaration(n);\n }\n\n /* ------------------------------------------------------------\n * classHandler()\n * ------------------------------------------------------------ */\n\n virtual int classHandler(Node *n) {\n constructors = 0;\n //SwigType *t = Getattr(n, \"classtype\");\n current_class = n;\n // String *use_class_name=SwigType_manglestr(SwigType_ltype(t));\n\n if (shadow && php_version == 4) {\n char *rename = GetChar(n, \"sym:name\");\n\n if (!addSymbol(rename, n))\n\treturn SWIG_ERROR;\n shadow_classname = NewString(rename);\n cs_entry = NewStringEmpty();\n Printf(cs_entry, \"/* Function entries for %s */\\n\", shadow_classname);\n Printf(cs_entry, \"static zend_function_entry %s_functions[] = {\\n\", shadow_classname);\n\n if (Strcmp(shadow_classname, module) == 0) {\n\tPrintf(stderr, \"class name cannot be equal to module name: %s\\n\", module);\n\tSWIG_exit(1);\n }\n\n shadow_get_vars = NewHash();\n shadow_set_vars = NewHash();\n\n /* Deal with inheritance */\n List *baselist = Getattr(n, \"bases\");\n if (baselist) {\n\tIterator base = First(baselist);\n\twhile (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t}\n\tbase = Next(base);\n\tif (base.item) {\n\t /* Warn about multiple inheritance for additional base class(es) */\n\t while (base.item) {\n\t if (GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t continue;\n\t }\n\t String *proxyclassname = SwigType_str(Getattr(n, \"classtypeobj\"), 0);\n\t String *baseclassname = SwigType_str(Getattr(base.item, \"name\"), 0);\n\t Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number,\n\t\t\t \"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Php4.\\n\", proxyclassname, baseclassname);\n\t base = Next(base);\n\t }\n\t}\n }\n\n /* Write out class init code */\n Printf(s_vdecl, \"static zend_class_entry ce_swig_%s;\\n\", shadow_classname);\n Printf(s_vdecl, \"static zend_class_entry* ptr_ce_swig_%s=NULL;\\n\", shadow_classname);\n } else if (shadow && php_version == 5) {\n char *rename = GetChar(n, \"sym:name\");\n\n if (!addSymbol(rename, n))\n\treturn SWIG_ERROR;\n shadow_classname = NewString(rename);\n\n shadow_get_vars = NewHash();\n shadow_set_vars = NewHash();\n\n /* Deal with inheritance */\n List *baselist = Getattr(n, \"bases\");\n if (baselist) {\n\tIterator base = First(baselist);\n\twhile (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t}\n\tbase = Next(base);\n\tif (base.item) {\n\t /* Warn about multiple inheritance for additional base class(es) */\n\t while (base.item) {\n\t if (GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t continue;\n\t }\n\t String *proxyclassname = SwigType_str(Getattr(n, \"classtypeobj\"), 0);\n\t String *baseclassname = SwigType_str(Getattr(base.item, \"name\"), 0);\n\t Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number,\n\t\t\t \"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Php4.\\n\", proxyclassname, baseclassname);\n\t base = Next(base);\n\t }\n\t}\n }\n }\n\n classnode = n;\n Language::classHandler(n);\n classnode = 0;\n\n if (shadow && php_version == 4) {\n DOH *key;\n String *s_propget = NewStringEmpty();\n String *s_propset = NewStringEmpty();\n List *baselist = Getattr(n, \"bases\");\n Iterator ki, base;\n\n // If no constructor was generated (abstract class) we had better\n // generate a constructor that raises an error about instantiating\n // abstract classes\n if (Getattr(n, \"abstract\") && constructors == 0) {\n\t// have to write out fake constructor which raises an error when called\n\tabstractConstructorHandler(n);\n }\n\n Printf(s_oinit, \"/* Define class %s */\\n\", shadow_classname);\n Printf(s_oinit, \"INIT_OVERLOADED_CLASS_ENTRY(ce_swig_%s,\\\"%(lower)s\\\",%s_functions,\", shadow_classname, shadow_classname, shadow_classname);\n Printf(s_oinit, \"NULL,_wrap_propget_%s,_wrap_propset_%s);\\n\", shadow_classname, shadow_classname);\n\n // ******** Write property SET handlers\n Printf(s_header, \"static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value);\\n\", shadow_classname);\n Printf(s_header, \"static int _propset_%s(zend_property_reference *property_reference, pval *value);\\n\", shadow_classname);\n\n Printf(s_propset, \"static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value) { \\n\", shadow_classname);\n Printf(s_propset, \" zval * _value;\\n\");\n Printf(s_propset, \" zend_llist_element *element = property_reference->elements_list->head;\\n\");\n Printf(s_propset, \" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\\n\");\n Printf(s_propset, \" if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\\n\", shadow_classname);\n Printf(s_propset, \" /* set it ourselves as it is %s */\\n\", shadow_classname);\n Printf(s_propset, \" MAKE_STD_ZVAL(_value);\\n\");\n Printf(s_propset, \" *_value=*value;\\n\");\n Printf(s_propset, \" INIT_PZVAL(_value);\\n\");\n Printf(s_propset, \" zval_copy_ctor(_value);\\n\");\n Printf(s_propset,\n\t \" return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value);\\n\");\n Printf(s_propset, \"}\\n\");\n Printf(s_propset, \"static int _propset_%s(zend_property_reference *property_reference, pval *value) {\\n\", shadow_classname);\n\n\n if (baselist) {\n\tbase = First(baselist);\n } else {\n\tbase.item = NULL;\n }\n\n while (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\tbase = Next(base);\n }\n\n ki = First(shadow_set_vars);\n key = ki.key;\n\n // Print function header; we only need to find property name if there\n // are properties for this class to look up...\n if (key || !base.item) {\t// or if we are base class and set it ourselves\n\tPrintf(s_propset, \" /* get the property name */\\n\");\n\tPrintf(s_propset, \" zend_llist_element *element = property_reference->elements_list->head;\\n\");\n\tPrintf(s_propset, \" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\\n\");\n\tPrintf(s_propset, \" char *propname=Z_STRVAL_P(&(property->element));\\n\");\n } else {\n\tif (base.item) {\n\t Printf(s_propset, \" /* No extra properties for subclass %s */\\n\", shadow_classname);\n\t} else {\n\t Printf(s_propset, \" /* No properties for base class %s */\\n\", shadow_classname);\n\t}\n }\n\n while (ki.key) {\n\tkey = ki.key;\n\tPrintf(s_propset, \" if (strcmp(propname,\\\"%s\\\")==0) return _wrap_%s(property_reference, value);\\n\", ki.item, key);\n\n\tki = Next(ki);\n }\n\n // If the property wasn't in this class, try the handlers of each base\n // class (if any) in turn until we succeed in setting the property or\n // have tried all base classes.\n if (base.item) {\n\tPrintf(s_propset, \" /* Try base class(es) */\\n\");\n\twhile (base.item) {\n\t Printf(s_propset, \" if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\\n\", GetChar(base.item, \"sym:name\"));\n\n\t base = Next(base);\n\t while (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t }\n\t}\n }\n Printf(s_propset, \" return FAILURE;\\n}\\n\\n\");\n\n // ******** Write property GET handlers\n Printf(s_header, \"static pval _wrap_propget_%s(zend_property_reference *property_reference);\\n\", shadow_classname);\n Printf(s_header, \"static int _propget_%s(zend_property_reference *property_reference, pval *value);\\n\", shadow_classname);\n\n Printf(s_propget, \"static pval _wrap_propget_%s(zend_property_reference *property_reference) {\\n\", shadow_classname);\n Printf(s_propget, \" pval result;\\n\");\n Printf(s_propget, \" pval **_result;\\n\");\n Printf(s_propget, \" zend_llist_element *element = property_reference->elements_list->head;\\n\");\n Printf(s_propget, \" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\\n\");\n Printf(s_propget, \" result.type = IS_NULL;\\n\");\n Printf(s_propget, \" if (_propget_%s(property_reference, &result)==SUCCESS) return result;\\n\", shadow_classname);\n Printf(s_propget, \" /* return it ourselves */\\n\");\n Printf(s_propget,\n\t \" if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) {\\n\");\n Printf(s_propget, \" zval *_value;\\n\");\n Printf(s_propget, \" MAKE_STD_ZVAL(_value);\");\n Printf(s_propget, \" *_value=**_result;\\n\");\n Printf(s_propget, \" INIT_PZVAL(_value);\\n\");\n Printf(s_propget, \" zval_copy_ctor(_value);\\n\");\n Printf(s_propget, \" return *_value;\\n\");\n Printf(s_propget, \" }\\n\");\n Printf(s_propget, \" result.type = IS_NULL;\\n\");\n Printf(s_propget, \" return result;\\n\");\n Printf(s_propget, \"}\\n\");\n Printf(s_propget, \"static int _propget_%s(zend_property_reference *property_reference, pval *value) {\\n\", shadow_classname);\n\n if (baselist) {\n\tbase = First(baselist);\n } else {\n\tbase.item = NULL;\n }\n while (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\tbase = Next(base);\n }\n ki = First(shadow_get_vars);\n\n key = ki.key;\n\n // Print function header; we only need to find property name if there\n // are properties for this class to look up...\n if (key || !base.item) {\t// or if we are base class...\n\tPrintf(s_propget, \" /* get the property name */\\n\");\n\tPrintf(s_propget, \" zend_llist_element *element = property_reference->elements_list->head;\\n\");\n\tPrintf(s_propget, \" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\\n\");\n\tPrintf(s_propget, \" char *propname=Z_STRVAL_P(&(property->element));\\n\");\n } else {\n\tif (base.item) {\n\t Printf(s_propget, \" /* No extra properties for subclass %s */\\n\", shadow_classname);\n\t} else {\n\t Printf(s_propget, \" /* No properties for base class %s */\\n\", shadow_classname);\n\t}\n }\n\n while (ki.key) {\n\tkey = ki.key;\n\tPrintf(s_propget, \" if (strcmp(propname,\\\"%s\\\")==0) {\\n\", ki.item);\n\tPrintf(s_propget, \" *value=_wrap_%s(property_reference);\\n\", key);\n\tPrintf(s_propget, \" return SUCCESS;\\n\");\n\tPrintf(s_propget, \" }\\n\");\n\n\tki = Next(ki);\n }\n\n // If the property wasn't in this class, try the handlers of each base\n // class (if any) in turn until we succeed in setting the property or\n // have tried all base classes.\n if (base.item) {\n\tPrintf(s_propget, \" /* Try base class(es). */\\n\");\n\twhile (base.item) {\n\t Printf(s_propget, \" if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\\n\", GetChar(base.item, \"sym:name\"));\n\n\t base = Next(base);\n\t while (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t }\n\t}\n }\n Printf(s_propget, \" return FAILURE;\\n}\\n\\n\");\n\n // wrappers generated now...\n\n // add wrappers to output code\n Printf(s_wrappers, \"/* property handler for class %s */\\n\", shadow_classname);\n Printv(s_wrappers, s_propget, s_propset, NIL);\n\n // Save class in class table\n if (baselist) {\n\tbase = First(baselist);\n } else {\n\tbase.item = NULL;\n }\n while (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\tbase = Next(base);\n }\n\n if (base.item) {\n\tPrintf(s_oinit,\n\t \"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL TSRMLS_CC))) zend_error(E_ERROR,\\\"Error registering wrapper for class %s\\\");\\n\",\n\t shadow_classname, shadow_classname, GetChar(base.item, \"sym:name\"), shadow_classname);\n } else {\n\tPrintf(s_oinit,\n\t \"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL TSRMLS_CC))) zend_error(E_ERROR,\\\"Error registering wrapper for class %s\\\");\\n\",\n\t shadow_classname, shadow_classname, shadow_classname);\n }\n Printf(s_oinit, \"\\n\");\n\n // Write the enum initialisation code in a static block\n // These are all the enums defined within the C++ class.\n\n Delete(shadow_classname);\n shadow_classname = NULL;\n\n Delete(shadow_set_vars);\n shadow_set_vars = NULL;\n Delete(shadow_get_vars);\n shadow_get_vars = NULL;\n\n Printv(all_cs_entry, cs_entry, \" { NULL, NULL, NULL}\\n};\\n\", NIL);\n Delete(cs_entry);\n cs_entry = NULL;\n } else if (shadow && php_version == 5) {\n DOH *key;\n List *baselist = Getattr(n, \"bases\");\n Iterator ki, base;\n\n if (baselist) {\n\tbase = First(baselist);\n\twhile (base.item && GetFlag(base.item, \"feature:ignore\")) {\n\t base = Next(base);\n\t}\n } else {\n\tbase.item = NULL;\n }\n\n if (Getattr(n, \"abstract\")) {\n\tPrintf(s_phpclasses, \"abstract \");\n }\n\n Printf(s_phpclasses, \"class %s%s \", prefix, shadow_classname);\n if (base.item) {\n\tString *baseclass = Getattr(base.item, \"sym:name\");\n\tif (!baseclass)\n\t baseclass = Getattr(base.item, \"name\");\n\tPrintf(s_phpclasses, \"extends %s%s \", prefix, baseclass);\n }\n Printf(s_phpclasses, \"{\\n\\tpublic $%s=null;\\n\", SWIG_PTR);\n\n // Write property SET handlers\n ki = First(shadow_set_vars);\n\n if (ki.key) {\n\t// This class has setters.\n\t// FIXME: just ignore setting an unknown property name for now.\n\tPrintf(s_phpclasses, \"\\n\\tfunction __set($var,$value) {\\n\");\n\t// FIXME: tune this threshold...\n\tif (Len(shadow_set_vars) <= 2) {\n\t // Not many setters, so avoid call_user_func.\n\t while (ki.key) {\n\t key = ki.key;\n\t Printf(s_phpclasses, \"\\t\\tif ($var == '%s') return %s($this->%s,$value);\\n\", key, ki.item, SWIG_PTR);\n\t ki = Next(ki);\n\t }\n\t} else {\n\t Printf(s_phpclasses, \"\\t\\t$func = '%s_'.$var.'_set';\\n\", shadow_classname);\n\t Printf(s_phpclasses, \"\\t\\tif (function_exists($func)) call_user_func($func,$this->%s,$value);\\n\", SWIG_PTR);\n\t}\n\tPrintf(s_phpclasses, \"\\t}\\n\");\n\n\t/* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */\n\tPrintf(s_phpclasses, \"\\n\\tfunction __isset($var) {\\n\");\n\t// FIXME: tune this threshold, but it should probably be different to\n\t// that for __set() and __get() as we don't need to call_user_func()\n\t// here...\n\tif (Len(shadow_set_vars) == 1) {\n\t // Only one setter, so just check the name.\n\t Printf(s_phpclasses, \"\\t\\treturn \");\n\t while (ki.key) {\n\t key = ki.key;\n\t Printf(s_phpclasses, \"$var == '%s'\", ki.key);\n\t ki = Next(ki);\n\t if (ki.key) Printf(s_phpclasses, \" || \");\n\t }\n\t Printf(s_phpclasses, \";\\n\");\n\t} else {\n\t Printf(s_phpclasses, \"\\t\\treturn function_exists('%s_'.$var.'_set');\\n\", shadow_classname);\n\t}\n\tPrintf(s_phpclasses, \"\\t}\\n\");\n }\n // Write property GET handlers\n ki = First(shadow_get_vars);\n\n if (ki.key) {\n\t// This class has getters.\n\tPrintf(s_phpclasses, \"\\n\\tfunction __get($var) {\\n\");\n\t// FIXME: tune this threshold...\n\tif (Len(shadow_get_vars) <= 2) {\n\t // Not many getters, so avoid call_user_func.\n\t while (ki.key) {\n\t key = ki.key;\n\t Printf(s_phpclasses, \"\\t\\tif ($var == '%s') return %s($this->%s);\\n\", key, ki.item, SWIG_PTR);\n\t ki = Next(ki);\n\t }\n\t} else {\n\t Printf(s_phpclasses, \"\\t\\t$func = '%s_'.$var.'_get';\\n\", shadow_classname);\n\t Printf(s_phpclasses, \"\\t\\tif (function_exists($func)) return call_user_func($func,$this->%s);\\n\", SWIG_PTR);\n\t}\n\t// Reading an unknown property name gives null in PHP.\n\tPrintf(s_phpclasses, \"\\t\\treturn null;\\n\");\n\tPrintf(s_phpclasses, \"\\t}\\n\");\n }\n\n if (!class_has_ctor) {\n\tPrintf(s_phpclasses, \"\\tfunction __construct($h) {\\n\");\n\tPrintf(s_phpclasses, \"\\t\\t$this->%s=$h;\\n\", SWIG_PTR);\n\tPrintf(s_phpclasses, \"\\t}\\n\");\n }\n\n if (s_oowrappers) {\n\tPrintf(s_phpclasses, \"%s\", s_oowrappers);\n\tDelete(s_oowrappers);\n\ts_oowrappers = NULL;\n }\n class_has_ctor = false;\n\n Printf(s_phpclasses, \"}\\n\\n\");\n\n Delete(shadow_classname);\n shadow_classname = NULL;\n\n Delete(shadow_set_vars);\n shadow_set_vars = NULL;\n Delete(shadow_get_vars);\n shadow_get_vars = NULL;\n }\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * memberfunctionHandler()\n * ------------------------------------------------------------ */\n\n virtual int memberfunctionHandler(Node *n) {\n char *name = GetChar(n, \"name\");\n char *iname = GetChar(n, \"sym:name\");\n\n wrapperType = memberfn;\n this->Language::memberfunctionHandler(n);\n wrapperType = standard;\n\n // Only declare the member function if\n // we are doing shadow classes, and the function\n // is not overloaded, or if it is overloaded, it is the dispatch function.\n if (shadow && php_version == 4 && (!Getattr(n, \"sym:overloaded\") || !Getattr(n, \"sym:nextSibling\"))) {\n char *realname = iname ? iname : name;\n String *php_function_name = Swig_name_member(shadow_classname, realname);\n create_command(realname, Swig_name_wrapper(php_function_name));\n }\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * membervariableHandler()\n * ------------------------------------------------------------ */\n\n virtual int membervariableHandler(Node *n) {\n\n wrapperType = membervar;\n Language::membervariableHandler(n);\n wrapperType = standard;\n\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * staticmembervariableHandler()\n * ------------------------------------------------------------ */\n\n virtual int staticmembervariableHandler(Node *n) {\n\n wrapperType = staticmembervar;\n Language::staticmembervariableHandler(n);\n wrapperType = standard;\n\n SwigType *type = Getattr(n, \"type\");\n String *name = Getattr(n, \"name\");\n String *iname = Getattr(n, \"sym:name\");\n\n /* A temporary(!) hack for static member variables.\n * Php currently supports class functions, but not class variables.\n * Until it does, we convert a class variable to a class function\n * that returns the current value of the variable. E.g.\n *\n * class Example {\n * public:\n * static int ncount;\n * };\n *\n * would be available in php as Example::ncount() \n */\n\n // If the variable is const, then it's wrapped as a constant with set/get functions.\n if (SwigType_isconst(type))\n return SWIG_OK;\n\n // This duplicates the logic from Language::variableWrapper() to test if the set wrapper\n // is made.\n int assignable = is_assignable(n);\n if (assignable) {\n String *tm = Swig_typemap_lookup_new(\"globalin\", n, name, 0);\n if (!tm && SwigType_isarray(type)) {\n\tassignable = 0;\n }\n }\n\n String *class_iname = Swig_name_member(Getattr(current_class, \"sym:name\"), iname);\n create_command(iname, Swig_name_wrapper(class_iname));\n\n Wrapper *f = NewWrapper();\n\n Printv(f->def, \"ZEND_NAMED_FUNCTION(\", Swig_name_wrapper(class_iname), \") {\\n\", NIL);\n String *mget = Swig_name_wrapper(Swig_name_get(class_iname));\n String *mset = Swig_name_wrapper(Swig_name_set(class_iname));\n\n if (assignable) {\n Printf(f->code, \"if (ZEND_NUM_ARGS() > 0 ) {\\n\");\n Printf(f->code, \" %s( INTERNAL_FUNCTION_PARAM_PASSTHRU );\\n\", mset);\n Printf(f->code, \" // need some error checking here?\\n\");\n Printf(f->code, \" // Set the argument count to 0 for the get call\\n\");\n Printf(f->code, \" ht = 0;\\n\");\n Printf(f->code, \"}\\n\");\n }\n\n Printf(f->code, \"%s( INTERNAL_FUNCTION_PARAM_PASSTHRU );\\n\", mget);\n Printf(f->code, \"}\\n\");\n\n Wrapper_print(f, s_wrappers);\n\n Delete(class_iname);\n Delete(mget);\n Delete(mset);\n DelWrapper(f);\n\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * staticmemberfunctionHandler()\n * ------------------------------------------------------------ */\n\n virtual int staticmemberfunctionHandler(Node *n) {\n char *name = GetChar(n, \"name\");\n char *iname = GetChar(n, \"sym:name\");\n\n wrapperType = staticmemberfn;\n Language::staticmemberfunctionHandler(n);\n wrapperType = standard;\n\n if (shadow && php_version == 4) {\n String *symname = Getattr(n, \"sym:name\");\n char *realname = iname ? iname : name;\n String *php_function_name = Swig_name_member(shadow_classname, realname);\n create_command(symname, Swig_name_wrapper(php_function_name));\n }\n\n return SWIG_OK;\n }\n\n\n String * SwigToPhpType(SwigType *t, String_or_char *pname, int shadow_flag) {\n String *ptype = 0;\n\n if (shadow_flag) {\n ptype = PhpTypeFromTypemap((char *) \"pstype\", t, pname, (char *) \"\");\n }\n if (!ptype) {\n ptype = PhpTypeFromTypemap((char *) \"ptype\", t, pname, (char *) \"\");\n }\n\n if (ptype) return ptype;\n\n /* Map type here */\n switch (SwigType_type(t)) {\n case T_CHAR:\n case T_SCHAR:\n case T_UCHAR:\n case T_SHORT:\n case T_USHORT:\n case T_INT:\n case T_UINT:\n case T_LONG:\n case T_ULONG:\n case T_FLOAT:\n case T_DOUBLE:\n case T_BOOL:\n case T_STRING:\n case T_VOID:\n\tbreak;\n case T_POINTER:\n case T_REFERENCE:\n case T_USER:\n\tif (shadow_flag && is_shadow(t)) {\n\t return NewString(Char(is_shadow(t)));\n\t}\n\tbreak;\n case T_ARRAY:\n\t/* TODO */\n\tbreak;\n default:\n\tPrintf(stderr, \"SwigToPhpType: unhandled data type: %s\\n\", SwigType_str(t, 0));\n\tbreak;\n }\n\n return NewStringEmpty();\n }\n\n String *PhpTypeFromTypemap(char *op, SwigType *t, String_or_char *pname, String_or_char *lname) {\n String *tms;\n tms = Swig_typemap_lookup(op, t, pname, lname, (char *) \"\", (char *) \"\", NULL);\n if (!tms) {\n return NULL;\n }\n\n char *start = Char(tms);\n while (isspace(*start) || *start == '{') {\n start++;\n }\n char *end = start;\n while (*end && *end != '}') {\n end++;\n }\n return NewStringWithSize(start, end - start);\n }\n\n int abstractConstructorHandler(Node *n) {\n String *iname = GetChar(n, \"sym:name\");\n if (shadow && php_version == 4) {\n Wrapper *f = NewWrapper();\n\n String *wname = NewStringf(\"_wrap_new_%s\", iname);\n create_command(iname, wname);\n\n Printf(f->def, \"ZEND_NAMED_FUNCTION(_wrap_new_%s) {\\n\", iname);\n Printf(f->def, \" zend_error(E_ERROR,\\\"Cannot create swig object type: %s as the underlying class is abstract\\\");\\n\", iname);\n Printf(f->def, \"}\\n\\n\");\n Wrapper_print(f, s_wrappers);\n DelWrapper(f);\n Delete(wname);\n }\n return SWIG_OK;\n }\n /* ------------------------------------------------------------\n * constructorHandler()\n * ------------------------------------------------------------ */\n\n virtual int constructorHandler(Node *n) {\n char *name = GetChar(n, \"name\");\n char *iname = GetChar(n, \"sym:name\");\n\n if (shadow && php_version == 4) {\n if (iname && strcmp(iname, Char(shadow_classname)) == 0) {\n\tnative_constructor = NATIVE_CONSTRUCTOR;\n } else {\n\tnative_constructor = ALTERNATIVE_CONSTRUCTOR;\n }\n } else {\n native_constructor = 0;\n }\n constructors++;\n wrapperType = constructor;\n Language::constructorHandler(n);\n wrapperType = standard;\n\n if (shadow && php_version == 4) {\n if (!Getattr(n, \"sym:overloaded\") || !Getattr(n, \"sym:nextSibling\")) {\n\tchar *realname = iname ? iname : name;\n\tString *php_function_name = Swig_name_construct(realname);\n\tcreate_command(realname, Swig_name_wrapper(php_function_name));\n }\n }\n\n native_constructor = 0;\n return SWIG_OK;\n }\n\n /* ------------------------------------------------------------\n * CreateZendListDestructor()\n * ------------------------------------------------------------ */\n //virtual int destructorHandler(Node *n) {\n //}\n int CreateZendListDestructor(Node *n) {\n String *name = GetChar(Swig_methodclass(n), \"name\");\n String *iname = GetChar(n, \"sym:name\");\n SwigType *d = Getattr(n, \"type\");\n ParmList *l = Getattr(n, \"parms\");\n\n String *destructorname = NewStringEmpty();\n Printf(destructorname, \"_%s\", Swig_name_wrapper(iname));\n Setattr(classnode, \"destructor\", destructorname);\n\n Wrapper *df = NewWrapper();\n Printf(df->def, \"/* This function is designed to be called by the zend list destructors */\\n\");\n Printf(df->def, \"/* to typecast and do the actual destruction */\\n\");\n Printf(df->def, \"static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\\n\", destructorname);\n\n Wrapper_add_localv(df, \"value\", \"swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr\", NIL);\n Wrapper_add_localv(df, \"ptr\", \"void *ptr=value->ptr\", NIL);\n Wrapper_add_localv(df, \"newobject\", \"int newobject=value->newobject\", NIL);\n\n emit_args(d, l, df);\n emit_attach_parmmaps(l, df);\n\n // Get type of first arg, thing to be destructed\n // Skip ignored arguments\n Parm *p = l;\n //while (Getattr(p,\"tmap:ignore\")) {p = Getattr(p,\"tmap:ignore:next\");}\n while (checkAttribute(p, \"tmap:in:numinputs\", \"0\")) {\n p = Getattr(p, \"tmap:in:next\");\n }\n SwigType *pt = Getattr(p, \"type\");\n\n Printf(df->code, \" efree(value);\\n\");\n Printf(df->code, \" if (! newobject) return; /* can't delete it! */\\n\");\n Printf(df->code, \" arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\\n\", SwigType_lstr(pt, 0), SwigType_manglestr(pt));\n Printf(df->code, \" if (! arg1) zend_error(E_ERROR, \\\"%s resource already free'd\\\");\\n\", Char(name));\n\n emit_action(n, df);\n\n Printf(df->code, \"}\\n\");\n\n Wrapper_print(df, s_wrappers);\n\n return SWIG_OK;\n\n }\n\n /* ------------------------------------------------------------\n * memberconstantHandler()\n * ------------------------------------------------------------ */\n\n virtual int memberconstantHandler(Node *n) {\n wrapping_member_constant = Getattr(n, \"name\");\n Language::memberconstantHandler(n);\n wrapping_member_constant = NULL;\n return SWIG_OK;\n }\n\n};\t\t\t\t/* class PHP */\n\n/* -----------------------------------------------------------------------------\n * swig_php() - Instantiate module\n * ----------------------------------------------------------------------------- */\n\nstatic PHP *maininstance = 0;\n\n// We use this function to be able to write out zend_register_list_destructor_ex\n// lines for most things in the type table\n// NOTE: it's a function NOT A PHP::METHOD\nextern \"C\" void typetrace(SwigType *ty, String *mangled, String *clientdata) {\n Node *class_node;\n if (!zend_types) {\n zend_types = NewHash();\n }\n // we want to know if the type which reduced to this has a constructor\n if ((class_node = maininstance->classLookup(ty))) {\n if (!Getattr(zend_types, mangled)) {\n // OK it may have been set before by a different SwigType but it would\n // have had the same underlying class node I think\n // - it is certainly required not to have different originating class\n // nodes for the same SwigType\n Setattr(zend_types, mangled, class_node);\n }\n } else {\t\t\t// a non-class pointer\n Setattr(zend_types, mangled, NOTCLASS);\n }\n if (r_prevtracefunc)\n (*r_prevtracefunc) (ty, mangled, (String *) clientdata);\n}\n\nstatic Language *new_swig_php(int php_version) {\n maininstance = new PHP(php_version);\n if (!r_prevtracefunc) {\n r_prevtracefunc = SwigType_remember_trace(typetrace);\n } else {\n Printf(stderr, \"php Typetrace vector already saved!\\n\");\n assert(0);\n }\n return maininstance;\n}\nextern \"C\" Language *swig_php4(void) {\n return new_swig_php(4);\n}\nextern \"C\" Language *swig_php5(void) {\n return new_swig_php(5);\n}\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointPointInPlane::pJointPointInPlane(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_PointInPlane)\r\n{\r\n\r\n}\r\n\r\nvoid pJointPointInPlane::setGlobalAnchor(VxVector anchor)\r\n{\r\n\r\n\r\n\tNxPointInPlaneJointDesc descr;\t\t\r\n\tNxPointInPlaneJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAnchor(getFrom(anchor));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointPointInPlane::setGlobalAxis(VxVector axis)\r\n{\r\n\r\n\r\n\tNxPointInPlaneJointDesc descr;\t\t\r\n\tNxPointInPlaneJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.setGlobalAxis(getFrom(axis));\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\n\r\n\r\nvoid pJointPointInPlane::enableCollision(int collision)\r\n{\r\n\tNxPointInPlaneJointDesc descr;\t\t\r\n\tNxPointInPlaneJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n\r\n\r\nPhysicManager *ourMan = NULL;\r\nvoid __newpClothDescr(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pClothDesc();\r\n}\r\n\r\n\r\nvoid PhysicManager::_RegisterVSLCloth()\r\n{\r\n\t\r\n\tourMan = GetPMan();\r\n\t\t\r\n\t\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\tDECLAREOBJECTTYPE(pClothDesc)\r\n\t\r\n\tDECLAREMEMBER(pClothDesc,float,thickness)\r\n\tDECLAREMEMBER(pClothDesc,float,density)\r\n\tDECLAREMEMBER(pClothDesc,float,bendingStiffness)\r\n\r\n\tDECLAREMEMBER(pClothDesc,float,stretchingStiffness)\r\n\tDECLAREMEMBER(pClothDesc,float,dampingCoefficient)\r\n\tDECLAREMEMBER(pClothDesc,float,friction)\r\n\tDECLAREMEMBER(pClothDesc,float,pressure)\r\n\tDECLAREMEMBER(pClothDesc,float,tearFactor)\r\n\tDECLAREMEMBER(pClothDesc,float,collisionResponseCoefficient)\r\n\tDECLAREMEMBER(pClothDesc,float,attachmentResponseCoefficient)\r\n\tDECLAREMEMBER(pClothDesc,float,attachmentTearFactor)\r\n\tDECLAREMEMBER(pClothDesc,float,toFluidResponseCoefficient)\r\n\tDECLAREMEMBER(pClothDesc,float,fromFluidResponseCoefficient)\r\n\tDECLAREMEMBER(pClothDesc,float,minAdhereVelocity)\r\n\tDECLAREMEMBER(pClothDesc,int,solverIterations)\r\n\tDECLAREMEMBER(pClothDesc,VxVector,externalAcceleration)\r\n\tDECLAREMEMBER(pClothDesc,VxVector,windAcceleration)\r\n\tDECLAREMEMBER(pClothDesc,float,wakeUpCounter)\r\n\tDECLAREMEMBER(pClothDesc,float,sleepLinearVelocity)\r\n\tDECLAREMEMBER(pClothDesc,int,collisionGroup)\r\n\tDECLAREMEMBER(pClothDesc,VxBbox,validBounds)\r\n\tDECLAREMEMBER(pClothDesc,float,relativeGridSpacing)\r\n\tDECLAREMEMBER(pClothDesc,pClothFlag,flags)\r\n\tDECLAREMEMBER(pClothDesc,pClothAttachmentFlag,attachmentFlags)\r\n\tDECLAREMEMBER(pClothDesc,VxColor,tearVertexColor)\r\n\tDECLAREMEMBER(pClothDesc,CK_ID,worldReference)\r\n\r\n\r\n\tDECLAREMETHOD_0(pClothDesc,void,setToDefault)\r\n\tDECLARECTOR_0(__newpClothDescr)\r\n\tDECLAREPOINTERTYPE(pWorld)\r\n\r\n\tDECLAREPOINTERTYPE(pRigidBody)\r\n\tDECLAREPOINTERTYPEALIAS(pRigidBody,\"pBody\")\r\n\r\n\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tSerializer : \r\n\t\t//\r\n\t\tDECLAREPOINTERTYPE(pSerializer)\r\n\t\tDECLAREFUN_C_0(pSerializer*, GetSerializer)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,overrideBody,pRigidBody*,int)\r\n\t\tDECLAREMETHOD_2(pSerializer,int,loadCollection,const char*,int)\r\n\t\tDECLAREMETHOD_1(pSerializer,int,saveCollection,const char*)\r\n\t\tDECLAREMETHOD_2(pSerializer,void,parseFile,const char*,int)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJoints :\r\n\t\t//\r\n\r\n\t\t\r\n\t\tDECLAREPOINTERTYPE(pJoint)\r\n\t\tDECLAREPOINTERTYPE(pJointFixed)\r\n\t\tDECLAREPOINTERTYPE(pJointDistance)\r\n\t\tDECLAREPOINTERTYPE(pJointD6)\r\n\t\tDECLAREPOINTERTYPE(pJointPulley)\r\n\t\tDECLAREPOINTERTYPE(pJointBall)\r\n\t\tDECLAREPOINTERTYPE(pJointRevolute)\r\n\t\tDECLAREPOINTERTYPE(pJointPrismatic)\r\n\t\tDECLAREPOINTERTYPE(pJointCylindrical)\r\n\t\tDECLAREPOINTERTYPE(pJointPointInPlane)\r\n\t\tDECLAREPOINTERTYPE(pJointPointOnLine)\r\n\r\n\t\t\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointDistance\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointD6\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointFixed\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPulley\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointBall\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointRevolute\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPrismatic\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointCylindrical\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPointOnLine\")\r\n\t\tDECLAREINHERITANCESIMPLE(\"pJoint\",\"pJointPointInPlane\")\r\n\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tFactory\r\n\t\t//\r\n\r\n\t\tDECLAREPOINTERTYPE(pFactory)\r\n\t\tDECLAREFUN_C_0(pFactory,getPFactory)\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tENUMERATION \r\n\t\t//\r\n\r\n\t\tDECLAREENUM(\"D6DriveType\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Position\" ,1 )\r\n\t\tDECLAREENUMVALUE(\"D6DriveType\", \"D6DT_Velocity\" ,2 )\r\n\r\n\r\n\t\tDECLAREENUM(\"PForceMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Force\" , 0)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Impulse\" , 1)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_VelocityChange\" , 2)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothImpulse\" , 3)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_SmoothVelocityChange\" , 4)\r\n\t\tDECLAREENUMVALUE(\"PForceMode\", \"PFM_Acceleration\" , 5)\r\n\t\t\r\n\t\tDECLAREENUM(\"D6MotionMode\")\r\n\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Locked\" , 0)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Limited\" , 1)\r\n\t\tDECLAREENUMVALUE(\"D6MotionMode\", \"D6MM_Free\" , 2)\r\n\r\n\t\tDECLAREENUM(\"JType\")\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Any\" , -1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Prismatic\" , 0)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Revolute\" , 1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Cylindrical\" , 2)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Spherical\" , 3)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointOnLine\" , 4)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_PointInPlane\" , 5)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Distance\" , 6)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Pulley\" , 7)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_Fixed\" ,8 )\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_D6\" ,9 )\r\n\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\tBindings for pVehicle related classes : \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_2(pFactory,pVehicle*,createVehicle,CK3dEntity*,pVehicleDesc)\r\n\t\t\r\n\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getWheelRollAngle)\r\n\t\t//DECLAREMETHOD_0(pVehicle,float,getRpm)\r\n\r\n\r\n\r\n\t\t\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT CREATION\r\n\t\t//\r\n\t\tDECLAREMETHOD_7_WITH_DEF_VALS(pFactory,pJointDistance*,createDistanceJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NODEFAULT,VxVector,VxVector(),VxVector,VxVector(),float,0.0f,float,0.0f,pSpring,pSpring())\r\n\t\tDECLAREMETHOD_5(pFactory,pJointD6*,createD6Joint,CK3dEntity*,CK3dEntity*,VxVector,VxVector,bool)\r\n\t\tDECLAREMETHOD_2(pFactory,pJointFixed*,createFixedJoint,CK3dEntity*,CK3dEntity*)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pFactory,pRigidBody*,createBody,CK3dEntity*,NODEFAULT,pObjectDescr,NODEFAULT,CK3dEntity*,NULL)\r\n\t\tDECLAREMETHOD_6(pFactory,pJointPulley*,createPulleyJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointBall*,createBallJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointRevolute*,createRevoluteJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPrismatic*,createPrismaticJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointCylindrical*,createCylindricalJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPointInPlane*,createPointInPlaneJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\tDECLAREMETHOD_4(pFactory,pJointPointOnLine*,createPointOnLineJoint,CK3dEntity*,CK3dEntity*,VxVector,VxVector)\r\n\t\t\r\n\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,pCloth*,createCloth,CK3dEntity*,pClothDesc)\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tCloth\r\n\t\t//\r\n\t\tDECLAREMETHOD_4(pCloth,void,attachToCore,CK3dEntity*,float,float,float)\r\n\t\tDECLAREMETHOD_2(pCloth,void,attachToShape,CK3dEntity*,pClothAttachmentFlag)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tMANAGER\r\n\t\t//\r\n\t\tDECLAREFUN_C_0(CKGUID, GetPhysicManagerGUID)\r\n\t\tDECLAREOBJECTTYPE(PhysicManager)\r\n\t\tDECLARESTATIC_1(PhysicManager,PhysicManager*,Cast,CKBaseManager* iM)\r\n\t\tDECLAREFUN_C_0(PhysicManager*, GetPhysicManager)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(PhysicManager,pWorld*,getDefaultWorld)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pRigidBody*,getBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorldByBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorld,CK_ID)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(PhysicManager,pJoint*,getJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NULL,JType,JT_Any)\r\n\r\n//\t\tDECLAREMETHOD_0(PhysicManager,void,makeDongleTest)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tWorld\r\n\t\t//\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pWorld,pRigidBody*,getBody,CK3dEntity*)\r\n\t\tDECLAREMETHOD_1(pWorld,pVehicle*,getVehicle,CK3dEntity*)\r\n\t\tDECLAREMETHOD_3(pWorld,pJoint*,getJoint,CK3dEntity*,CK3dEntity*,JType)\r\n\r\n\t\tDECLAREMETHOD_3(pWorld,void,setFilterOps,pFilterOp,pFilterOp,pFilterOp)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterBool,bool)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant0,const pGroupsMask&)\r\n\t\tDECLAREMETHOD_1(pWorld,void,setFilterConstant1,const pGroupsMask&)\r\n\r\n\r\n\r\n\r\n\t\t//\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pWorld,bool,raycastAnyBounds,const VxRay&,NODEFAULT,pShapesType,NODEFAULT,pGroupsMask,NODEFAULT,int,0xffffffff,float,NX_MAX_F32)\r\n\t\tDECLAREMETHOD_8(pWorld,bool,overlapSphereShapes,CK3dEntity*,const VxSphere&,CK3dEntity*,pShapesType,CKGroup*,int,const pGroupsMask*,BOOL)\r\n\r\n\t\t//(const VxRay& worldRay, pShapesType shapesType, pGroupsMask groupsMask,unsigned int groups=0xffffffff, float maxDist=NX_MAX_F32);\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT :: Revolute\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointRevolute*,castRevolute)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAnchor,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setGlobalAxis,const VxVector&)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setLowLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,setMotor,pMotor)\r\n\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getLowLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pJointLimit,getHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointRevolute,pMotor,getMotor)\r\n\t\tDECLAREMETHOD_1(pJointRevolute,void,enableCollision,bool)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: Ball\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointBall*,castBall)\r\n\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setAnchor,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setSwingLimitAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistHighLimit,pJointLimit)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistLowLimit,pJointLimit)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getSwingLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_0(pJointBall,pJointLimit,getTwistLowLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setSwingSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,bool,setTwistSpring,pSpring)\r\n\t\tDECLAREMETHOD_1(pJointBall,void,setJointSpring,pSpring)\r\n\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getSwingSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getTwistSpring)\r\n\t\tDECLAREMETHOD_0(pJointBall,pSpring,getJointSpring)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointBall,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Prismatic\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPrismatic*,castPrismatic)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPrismatic,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Cylindrical\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointCylindrical*,castCylindrical)\r\n\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointCylindrical,void,enableCollision,int)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointInPlane*,castPointInPlane)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointInPlane,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT Point In Plane\r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPointOnLine*,castPointOnLine)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAnchor,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,setGlobalAxis,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPointOnLine,void,enableCollision,bool)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tJOINT BASE \r\n\t\t//\r\n\t\t//\r\n\t\tDECLAREMETHOD_1(pJoint,void,setLocalAnchor0,VxVector)\r\n\r\n\t\tDECLAREMETHOD_2(pJoint,void,setBreakForces,float,float)\r\n\t\tDECLAREMETHOD_2(pJoint,void,getBreakForces,float&,float&)\r\n\t\tDECLAREMETHOD_3(pJoint,int,addLimitPlane,VxVector,VxVector,float)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pJoint,void,setLimitPoint,VxVector,NODEFAULT,bool,true)\r\n\t\tDECLAREMETHOD_0(pJoint,void,purgeLimitPlanes)\r\n\t\tDECLAREMETHOD_0(pJoint,void,resetLimitPlaneIterator)\r\n\t\tDECLAREMETHOD_0(pJoint,int,hasMoreLimitPlanes)\r\n\t\tDECLAREMETHOD_3(pJoint,int,getNextLimitPlane,VxVector&,float&,float&)\r\n\t\tDECLAREMETHOD_0(pJoint,int,getType)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT :: DISTANCE\r\n\t\t//\r\n\t\tDECLAREMETHOD_0(pJoint,pJointDistance*,castDistanceJoint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMinDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setMaxDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor0,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setLocalAnchor1,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,setSpring,pSpring)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMinDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getMaxDistance)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor0)\r\n\t\tDECLAREMETHOD_0(pJointDistance,float,getLocalAnchor1)\r\n\t\tDECLAREMETHOD_0(pJointDistance,pSpring,getSpring)\r\n\t\tDECLAREMETHOD_1(pJointDistance,void,enableCollision,bool)\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\t\tJOINT PULLEY\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointPulley*,castPulley)\r\n\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setLocalAnchorB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyA,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setPulleyB,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setStiffness,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRatio,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setRigid,int)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setDistance,float)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,setMotor,pMotor)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getLocalAnchorB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyA)\r\n\t\tDECLAREMETHOD_0(pJointPulley,VxVector,getPulleyB)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getStiffness)\r\n\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getRatio)\r\n\t\tDECLAREMETHOD_0(pJointPulley,float,getDistance)\r\n\t\tDECLAREMETHOD_1(pJointPulley,void,enableCollision,bool)\r\n\t\tDECLAREMETHOD_0(pJointPulley,pMotor,getMotor)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\tJOINT D6\r\n\t\t//\r\n\r\n\t\tDECLAREMETHOD_0(pJoint,pJointD6*,castD6Joint)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setTwistMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing1MotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setSwing2MotionMode,D6MotionMode)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setXMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setYMotionMode,D6MotionMode)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setZMotionMode,D6MotionMode)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getXMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getYMotion)\r\n\t\tDECLAREMETHOD_0(pJointD6,D6MotionMode,getZMotion)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//softwLimits\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getLinearLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setLinearLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing1Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing1Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getSwing2Limit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwing2Limit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistHighLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistHighLimit,pJD6SoftLimit)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6SoftLimit,getTwistLowLimit)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistLowLimit,pJD6SoftLimit)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getXDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setXDrive,pJD6Drive)\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getYDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setYDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getZDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setZDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSwingDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSwingDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getTwistDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setTwistDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_0(pJointD6,pJD6Drive,getSlerpDrive)\r\n\t\tDECLAREMETHOD_1(pJointD6,int,setSlerpDrive,pJD6Drive)\r\n\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDrivePosition,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveRotation,VxQuaternion)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveLinearVelocity,VxVector)\r\n\t\tDECLAREMETHOD_1(pJointD6,void,setDriveAngularVelocity,VxVector)\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pJointD6,void,enableCollision,bool)\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\t\tRigid Body Exports \r\n\t\t//\r\n\t\t//\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Forces */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addForce,const VxVector&,NODEFAULT, PForceMode, 0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addTorque,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalForce,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,void,addLocalTorque,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtPos, const VxVector&,NODEFAULT,const VxVector&,NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addForceAtLocalPos,const VxVector,NODEFAULT, const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtPos, const VxVector&, NODEFAULT,const VxVector&,NODEFAULT, PForceMode,0,bool,true)\r\n\t\tDECLAREMETHOD_4_WITH_DEF_VALS(pRigidBody,void,addLocalForceAtLocalPos, const VxVector&, NODEFAULT,const VxVector&, NODEFAULT,PForceMode,0,bool,true)\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Momentum */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearMomentum,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularMomentum)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearMomentum)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Pose : */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setPosition,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setRotation,const VxQuaternion&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,translateLocalShapePosition,VxVector)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Velocity : */\r\n\t\t/************************************************************************/\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularVelocity,const VxVector&)\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,getMaxAngularSpeed)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getLinearVelocity)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxVector,getAngularVelocity)\r\n\t\t\r\n\t\t/************************************************************************/\r\n\t\t/* Mass */\r\n\t\t/************************************************************************/\r\n\t\t\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMassOffset,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setMaxAngularSpeed,float)\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* Hull */\r\n\t\t/************************************************************************/\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,pWorld*,getWorld)\r\n\t\tDECLAREMETHOD_1(pRigidBody,pJoint*,isConnected,CK3dEntity*)\r\n\t\t//DECLAREMETHOD_2_WITH_DEF_VALS(pRigidBody,void,setBoxDimensions,const VxVector&,NODEFAULT,CKBeObject*,NULL)\r\n\t\tDECLAREMETHOD_1_WITH_DEF_VALS(pRigidBody,float,getMass,CK3dEntity*,NULL)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getHullType)\r\n\r\n\t\tDECLAREMETHOD_2(pRigidBody,void,setGroupsMask,CK3dEntity*,const pGroupsMask&)\r\n\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getPointVelocity,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,VxVector,getLocalPointVelocity,VxVector)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,enableCollision,bool)\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isCollisionEnabled)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setKinematic,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isKinematic)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,enableGravity,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,bool,isAffectedByGravity)\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSleeping,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,isSleeping)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setLinearDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setAngularDamping,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,lockTransformation,BodyLockFlags)\r\n\t\tDECLAREMETHOD_1(pRigidBody,int,isBodyFlagOn,int)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setSolverIterationCount,int)\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,setCollisionsGroup,int)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,getCollisionsGroup)\r\n\t\tDECLAREMETHOD_2(pRigidBody,int,updateMassFromShapes,float,float)\r\n\t\tDECLAREMETHOD_5_WITH_DEF_VALS(pRigidBody,int,addSubShape,CKMesh*,NULL,pObjectDescr,NODEFAULT,CK3dEntity*,NULL,VxVector,VxVector(),VxQuaternion,VxQuaternion())\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pRigidBody,int,removeSubShape,CKMesh*,NODEFAULT,float,0.0,float,0.0)\r\n\r\n\r\n\r\n\r\n\t\t/*\r\n\t\tDECLAREENUM(\"WORLD_UPDATE_MODE\")\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_MODE\", \"WUM_UPDATE_FROM_ATTRIBUTE\" , 0x0001)\r\n\r\n\t\tDECLAREENUM(\"WORLD_UPDATE_FLAGS\")\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_FLAGS\", \"WUF_WORLD_SETTINGS\" , 0x0001)\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_FLAGS\", \"WUF_DAMPING_PARAMETER\" , 0x0002)\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_FLAGS\", \"WUF_SLEEPING_PARAMETER\" , 0x0004)\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_FLAGS\", \"WUF_SURFACE_SETTINGS\" , 0x0008)\r\n\t\tDECLAREENUMVALUE(\"WORLD_UPDATE_FLAGS\", \"WUF_ALL_PARAMETERS\" , 0x0010)\r\n\r\n\t\tDECLAREENUM(\"BODY_UPDATE_FLAGS\")\r\n\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_PHY_PARAMETER\" , 0x0001)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_DAMPING_PARAMETER\" , 0x0002)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_SLEEPING_PARAMETER\" , 0x0004)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_JOINT_PARAMETERS\" , 0x0008)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_ALL_PARAMETERS\" , 0x0010)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_GEOMETRY\" , 0x0020)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_PIVOT\" , 0x0040)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_MASS\" , 0x0080)\r\n\t\tDECLAREENUMVALUE(\"BODY_UPDATE_FLAGS\", \"BUF_ALL\" , 0x0100)\r\n\r\n\r\n\t\t\r\n\r\n\r\n\t\tDECLAREENUM(\"JType\")\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_NONE\" , 0)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_BALL\" , 1)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_HINGE\" , 2)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_SLIDER\" , 3)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_CONTACT\" , 4)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_UNIVERSAL\" , 5)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_HINGE2\" , 6)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_FIXED\" , 7)\r\n\t\tDECLAREENUMVALUE(\"JType\", \"JT_MOTOR\" ,8 )\r\n\r\n\r\n\r\n\t\t\r\n \t\t\r\n\r\n\t\tDECLAREENUM(\"J_LIMITPARAMETER\");\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JLoStop\" , 0);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JHiStop\", 1);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JVel\" , 2);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JFMax\" , 3);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JFudgeFactor\" , 4);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JBounce\" , 5);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JCFM\" , 6);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JStopERP\" , 7);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JStopCFM\" , 8);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JSuspensionERP\" , 9);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JSuspensionCFM\" , 10);\r\n\t\tDECLAREENUMVALUE(\"J_LIMITPARAMETER\", \"JERP\" , 11);\r\n\r\n\t\tDECLAREENUM(\"J_MOTOR_AXIS_TYPE\")\r\n\t\tDECLAREENUMVALUE(\"J_MOTOR_AXIS_TYPE\", \"AXIS_GLOBAL_FRAME\" , 0)\r\n\t\tDECLAREENUMVALUE(\"J_MOTOR_AXIS_TYPE\", \"AXIS_FIRST_BODY\" , 1)\r\n\t\tDECLAREENUMVALUE(\"J_MOTOR_AXIS_TYPE\", \"AXIS_SECOND_BODY\" , 2)\r\n*/\r\n\r\n/*\r\n\t\tDECLAREOBJECTTYPE(pSleepingSettings)\r\n\t\tDECLARECTOR_0(__newvtSleepingSettings)\r\n\t\r\n\t\tDECLAREMETHODC_0(pSleepingSettings,int,SleepSteps)\r\n\t\tDECLAREMETHOD_1(pSleepingSettings,void,SleepSteps,int)\r\n\t\tDECLAREMETHODC_0(pSleepingSettings,float,AngularThresold)\r\n\t\tDECLAREMETHOD_1(pSleepingSettings,void,AngularThresold,float)\r\n\t\tDECLAREMETHODC_0(pSleepingSettings,float,LinearThresold)\r\n\t\tDECLAREMETHOD_1(pSleepingSettings,void,LinearThresold,float)\r\n\t\tDECLAREMETHODC_0(pSleepingSettings,int,AutoSleepFlag)\r\n\t\tDECLAREMETHOD_1(pSleepingSettings,void,AutoSleepFlag,int)\r\n\r\n\t\r\n\t\tDECLAREOBJECTTYPE(pWorldSettings)\r\n\t\tDECLARECTOR_0(__newvtWorldSettings)\r\n\t\tDECLAREMETHODC_0(pWorldSettings,VxVector,Gravity)\r\n\t\tDECLAREMETHOD_1(pWorldSettings,void,Gravity,VxVector)\r\n\t\tDECLAREMETHODC_0(pWorldSettings,float,ContactSurfaceLayer)\r\n\t\tDECLAREMETHOD_1(pWorldSettings,void,ContactSurfaceLayer,float)\r\n\t\tDECLAREMETHODC_0(pWorldSettings,float,ERP)\r\n\t\tDECLAREMETHOD_1(pWorldSettings,void,ERP,float)\r\n\t\tDECLAREMETHODC_0(pWorldSettings,float,CFM)\r\n\t\tDECLAREMETHOD_1(pWorldSettings,void,CFM,float)\r\n\t\tDECLAREMETHODC_0(pWorldSettings,float,MaximumContactCorrectVelocity)\r\n\t\tDECLAREMETHOD_1(pWorldSettings,void,MaximumContactCorrectVelocity,float)\r\n\r\n\t\tDECLAREOBJECTTYPE(pJointSettings)\r\n\t\tDECLARECTOR_0(__newvtJointSettings)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\tDECLAREFUN_C_1(int,TestWS,pWorldSettings)\r\n\t\t\t\r\n\t\t\r\n\t\tDECLAREMETHODC_0(pWorld,pSleepingSettings*,SleepingSettings)\r\n\t\tDECLAREMETHOD_1(pWorld,void,SleepingSettings,pSleepingSettings*)\r\n\t\t\r\n\t\tDECLAREMETHODC_0(pWorld,pWorldSettings*,WorldSettings)\r\n\t\tDECLAREMETHOD_1(pWorld,void,WorldSettings,pWorldSettings*)\r\n\t\tDECLAREMETHOD_0(pWorld,int,NumJoints)\r\n*/\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//collision\r\n\r\n/*\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,GetFriction)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,SetFriction,float)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,SetPosition,VxVector)\r\n\t\tDECLAREMETHOD_1(pRigidBody,void,SetQuaternion, VxQuaternion)\r\n\t\tDECLAREMETHOD_0(pRigidBody,VxBbox,GetAABB)\r\n\r\n\t\t\r\n\t\tDECLAREMETHOD_0(pRigidBody,float,GetLastHFHeight)\r\n\t\tDECLAREMETHOD_0(pRigidBody,int,GetLastHFColor)\r\n\t\tDECLAREMETHOD_0(pRigidBody,Vx2DVector,GetLastHCoord)\r\n*/\r\n\r\n\t\t// Velocity :\r\n\t\t//DECLAREMETHOD_1(pRigidBody,void,setLinearVel,VxVector)\r\n\t\t//DECLAREMETHOD_1(pRigidBody,void,setAngularVel, VxVector)\r\n\r\n\t\t/*\r\n\t\t//DECLAREMETHOD_0(pRigidBody,VxVector,GetLinearVel)\r\n\t\t//DECLAREMETHOD_0(pRigidBody,VxVector,GetAngularVel)\r\n\t\t// Forces :\t\r\n\t\t*/\r\n\t\t\r\n\t\t//DECLAREMETHOD_2(pRigidBody,void,addForce, VxVector , PForceMode )\r\n\t\t\r\n\r\n\r\n\r\n\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//rotation axis : \r\n\r\n\t\t/*\r\n\r\n\r\n\r\n\r\n\t\tDECLAREMETHOD_2(pFactory,pWorldSettings*,CreateWorldSettings,const char *,const char*)\r\n\t\tDECLAREMETHOD_2_WITH_DEF_VALS(pFactory,pWorldSettings*,CreateWorldSettings,const char *,\"Default\",const char*,\"PhysicDefaults.xml\")\r\n\t\t\r\n\t\tDECLAREMETHOD_2(pFactory,pSleepingSettings*,CreateSleepingSettings,const char *,const char*)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//world : \r\n\t\tDECLAREMETHOD_3(pFactory,pWorld*,CreateWorld,CK3dEntity*,pWorldSettings*,pSleepingSettings*)\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//bodies :\r\n\t\tDECLAREMETHOD_3(pFactory,pRigidBody*,CreateRigidBody,CK3dEntity*,pWorld*,pSleepingSettings*)\r\n\t\tDECLAREMETHOD_3(pFactory,pRigidBody*,CreateRigidBody,CK3dEntity*,CK3dEntity*,pSleepingSettings*)\r\n\r\n\t\tDECLAREMETHOD_3_WITH_DEF_VALS(pFactory,pRigidBody*,CreateBall,CK3dEntity*,NULL,CK3dEntity*,NULL,pSleepingSettings*,NULL)\r\n\t\tDECLAREMETHOD_3(pFactory,pRigidBody*,CreateRigidBodyFull,CK3dEntity*,pWorld*,pSleepingSettings*)\r\n\t\tDECLAREMETHOD_8_WITH_DEF_VALS(pFactory,pRigidBody*,CreateBody,CK3dEntity*,NULL,CK3dEntity*,NULL,pSleepingSettings*,NULL,int,(BodyFlags)(BF_MOVING|BF_P2V|BF_WORLD_GRAVITY|BF_ENABLED|BF_COLLISION),int,HT_BOX,float,1.0f,float,0.0f,float,1.0f)\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//joint\r\n\r\n\t\tDECLAREMETHOD_2(pRigidBody,pJoint*,IsConnected, CK3dEntity*,int)\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//collision : \r\n\r\n\t\tDECLAREMETHOD_4(pWorld,CK3dEntity*,CIsInCollision,CK3dEntity*,VxVector&,VxVector&,float&)\r\n\t\tDECLAREMETHOD_5(pWorld,CK3dEntity*,CIsInCollision,CK3dEntity*,CKGroup*,VxVector&,VxVector&,float&)\r\n\t\tDECLAREMETHOD_5(pWorld,bool,CIsInCollision,CK3dEntity*,CK3dEntity*,VxVector&,VxVector&,float&)\r\n\t\tDECLAREMETHOD_8(pWorld,CK3dEntity*,CRayCollision,VxVector ,CK3dEntity*,VxVector,CK3dEntity*,float,bool,VxVector&, VxVector&)\r\n\t\tDECLAREMETHOD_2(pWorld,int,CIsInCollision,CK3dEntity*,CK3dEntity*)\r\n\r\n\t\t//\tDECLAREMETHOD_7(PhysicManager,int,CTestRayCollision,CKGroup*,VxVector,VxVector,float,VxVector*,VxVector*,CK3dEntity**)\r\n\r\n\t\t\r\n\r\n\t\r\n\r\n*/\r\n\r\n\t\t\r\n\r\n\t\t/*\r\n\r\n\t\tDECLAREMETHODC_0(PhysicManager,pWorldSettings,DefaultWorldSettings)\r\n\t\tDECLAREMETHOD_1(PhysicManager,void,DefaultWorldSettings,pWorldSettings)\r\n\r\n\t\tDECLAREMETHODC_0(PhysicManager,pSleepingSettings,DefaultSleepingSettings)\r\n\t\tDECLAREMETHOD_1(PhysicManager,void,DefaultSleepingSettings,pSleepingSettings)\r\n\r\n\t\tDECLAREMETHOD_0(PhysicManager,void,CheckWorlds)\r\n\t\tDECLARESTATIC_0(pWorld,pWorld*,GetDefault)\r\n\t\t*/\r\n\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\n\r\n\r\nPhysicManager*GetPhysicManager()\r\n{\r\n\treturn GetPMan();\r\n}\r\n\r\n/*\r\nvoid __newvtWorldSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pWorldSettings();\r\n}\r\nvoid __newvtSleepingSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pSleepingSettings();\r\n}\r\nvoid __newvtJointSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pJointSettings();\r\n}\r\n\r\n\r\nint TestWS(pWorldSettings pWS)\r\n{\r\nVxVector grav = pWS.Gravity();\r\nreturn 2;\r\n}\r\n\r\npFactory* GetPFactory();\r\n\r\n\r\npFactory* GetPFactory()\r\n{\r\nreturn pFactory::Instance();\r\n}\r\n\r\n\r\nextern pRigidBody*getBody(CK3dEntity*ent);\r\n*/#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceCallback.h\"\r\n\r\n\r\n#include \"vtAgeiaInterfaceKeyboardShortcuts.h\"\r\n#include \"vtAgeiaInterfaceMenu.h\"\r\n\r\n#include \"PCommonDialog.h\"\r\n#include \"vtBodyStructs.h\"\r\n#include \"PBodySetup.h\"\r\n\r\n\r\n\r\n\r\n//static plugin interface that allow direct communication with Virtools Dev\r\nPluginInterface*\t\ts_Plugininterface\t= NULL;\r\n\r\nWIN_HANDLE CKActorUIFunc(CKParameter* param,WIN_HANDLE parent,CKRECT *rect);\r\nWIN_HANDLE CKDoubleUIFunc (CKParameter *param,WIN_HANDLE ParentWindow,CKRECT *rect);\r\n\r\n/*\r\nAFX_STATIC UINT _afxMsgMouseWheel = \r\n(((::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 4)) ||\r\n (!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 3)))\r\n ? ::RegisterWindowMessage(MSH_MOUSEWHEEL) : 0;\r\n*/\r\n\r\n//ON_REGISTERED_MESSAGE(_afxMsgMouseWheel, OnRegisteredMouseWheel)*/\r\n//ON_BN_CLICKED(IDC_BFLAGS_DEFORMABLE, OnBnClickedBflagsDeformable)\r\n\r\n\r\n\r\nWIN_HANDLE CKActorUIFunc (CKParameter *param,WIN_HANDLE ParentWindow,CKRECT *rect) \r\n{\r\n\r\n\r\n\tAFX_MANAGE_STATE(AfxGetStaticModuleState());\r\n/*\t\r\n\t// Initialize OLE libraries\r\n\tif (!AfxOleInit())\r\n\t{\r\n\t\t//AfxMessageBox(IDP_OLE_INIT_FAILED);\r\n\t\treturn FALSE;\r\n\t}\r\n*/\r\n//\tCMultiDocTemplate* pDocTemplate;\r\n\r\n/*\tpDocTemplate = new CMultiDocTemplate(IDR_DRAWCLTYPE, RUNTIME_CLASS(CDrawDoc), RUNTIME_CLASS(CSplitFrame), RUNTIME_CLASS(CDrawView));\r\n\tpDocTemplate->SetContainerInfo(IDR_DRAWCLTYPE_CNTR_IP);\r\n\tAddDocTemplate(pDocTemplate);\r\n*/\r\n\t\r\n\t\r\n\tCPBCommonDialog *Dlg = new CPBCommonDialog(param);\r\n\tDlg->m_Context = param->GetCKContext();\r\n\tHWND win = (HWND)ParentWindow;\r\n\t//Dlg->HType.SetCurSel(0);\r\n\tCKRECT &rect2= *rect;\r\n\tHWND result = NULL;\r\n\r\n\t//CPBParentDialog *Dlg = new CPBParentDialog(param,CWnd::FromHandle(win));\r\n\t//CPBodyCfg *Dlg = new CPBodyCfg(param);\r\n\r\n\tif (param && win && Dlg )\r\n\t{\r\n\t\tDlg->Create( IDD_PBCOMMON, CWnd::FromHandle(win));\r\n\t\tresult = CreateParameterDialog( win, Dlg, 0, PARAMETER_PICKALL, 0, PARAMETER_NORESIZE);\r\n\t}\r\n\r\n\tif (result)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\t\r\n\treturn NULL;\r\n\r\n}\r\n\r\n//main plugin callback for Virtools Dev\r\nvoid PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface)\r\n{\r\n\tCKContext* ctx = GetCKContext(0);\r\n\r\n\tCKParameterManager *pm = ctx->GetParameterManager();\r\n\r\n\r\n\t{\t//--- Set UI Function of Shader Param\r\n\t\tCKParameterTypeDesc *param_desc = pm->GetParameterTypeDescription(VTF_PHYSIC_BODY_COMMON_SETTINGS);\r\n\t\tif( !param_desc ) return;\r\n\r\n\t\tparam_desc->UICreatorFunction = CKActorUIFunc;\r\n\t\t//param_desc->UICreatorFunction = CKDoubleUIFunc;\r\n\t}\r\n\r\n\tswitch(reason)\r\n\t{\r\n\tcase PluginInfo::CR_LOAD:\r\n\t\t{\r\n\t\t\ts_Plugininterface\t= plugininterface;\r\n\t\t\t//InitParameters(reason,plugininterface);\r\n\t\t\t/*InitMenu();\r\n\t\t\tUpdateMenu();\r\n\t\t\tRegisterKeyboardShortcutCategory();\r\n\t\t\tRegisterKeyboardShortcuts();*/\r\n\r\n\t\t}break;\r\n\tcase PluginInfo::CR_UNLOAD:\r\n\t\t{\r\n\t\t\t//RemoveMenu();\r\n\t\t\t//UnregisterKeyboardShortcutCategory();\r\n\t\t\ts_Plugininterface\t= NULL;\r\n\t\t}break;\r\n\tcase PluginInfo::CR_NEWCOMPOSITIONNAME:\r\n\t\t{\r\n\t\t\t//\t\t\tInitMenu();\r\n\r\n\t\t}break;\r\n\tcase PluginInfo::CR_NOTIFICATION:\r\n\t\t{\r\n\t\t}break;\r\n\t}\r\n}\r\n/********************************************************************\r\n\tcreated:\t2009/05/01\r\n\tcreated:\t1:5:2009 19:35\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\usr\\include\\xAssertion.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\usr\\include \r\n\tfile base:\txAssertion\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\t\r\n*********************************************************************/\r\n#ifndef __X_ASSERTION_H__\r\n#define __X_ASSERTION_H__\r\n\r\n\r\n\r\n#include \"xPlatform.h\"\r\n#include \"xLogger.h\"\r\n#include \"xAssertCustomization.h\"\r\n\r\nextern void assert_notify_failure(const char* str); // may also take\r\nextern xAssertInfo* getLastAssertInfo();\r\nextern xAssertInfo* assertFailed();\r\n\r\n\r\nbool TestCustomizations_Asserts();\r\nbool customizeAsserts();\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n\r\n\r\n\r\n#ifdef _DEBUG\r\n\t#include \r\n#endif\r\n\r\n\r\n\r\n\r\nvoid xCONVENTION_CALLBACK updateAssertHandlerData(\r\n\tE_ASSERTION_FAILURE_SEVERITY _failureSeverity,\r\n\tchar *_assertionExpression,\r\n\tchar *_assertionFileName,\r\n\tint _assertionSourceLine,\r\n\tchar *_assertionPostMessage,\r\n\tvoid* _postAction,\r\n\tbool _result);\r\n\r\nvoid xCONVENTION_CALLBACK tickAssertHandlerData();\r\n\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//\tAssertion checks customization\r\n//\r\ntypedef void (xCONVENTION_CALLBACK *CAssertionFailedProcedure)(\r\n\tE_ASSERTION_FAILURE_SEVERITY fsFailureSeverity, \r\n\tconst char *szAssertionExpression, \r\n\tconst char *szAssertionFileName, \r\n\tunsigned int uiAssertionSourceLine\r\n\t);\r\n\r\n//typedef void (xCONVENTION_CALLBACK *CPostCallback)(); \r\n\r\ntypedef void (xCONVENTION_CALLBACK *xErrorHandlerFn)\r\n\t(\r\n\tE_ASSERTION_FAILURE_SEVERITY m_fsFailureSeverity,\r\n\tchar *m_szAssertionExpression,\r\n\tchar *m_szAssertionFileName,\r\n\tint m_uiAssertionSourceLine,\r\n\tchar *szAssertionPostMessage,\r\n\tvoid* postAction,\r\n\tbool result\r\n\t);\r\n\r\n\r\n\r\n\r\nclass xAssertionEx\r\n{\r\npublic:\r\n\r\n\tstatic CAssertionFailedProcedure getAssertFailureCustomHandler()\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"invoked\");\r\n//\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Null\");\r\n\treturn g_fnAssertFailureHandler;\r\n\t}\r\n\tstatic void CustomizeAssertionChecks(CAssertionFailedProcedure fnAssertionFailureProcedure)\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"invoked\");\r\n//\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Null\");\r\n\t\tg_fnAssertFailureHandler = fnAssertionFailureProcedure;\r\n\t}\r\n\r\n\r\n\t\r\n\t//xErrorHandlerFn xCONVENTION_API getErrorHandler();\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// \r\n\t//\r\n\tstatic xErrorHandlerFn getErrorHandler()\r\n\t{\r\n\t\t///xAssertInfo *testData = getLastAssertInfo();\r\n\t\t//xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"invoked\");\r\n\t\treturn g_fnAssertHandler;\r\n\t}\r\n\r\n\tstatic void updateErrorHandler(xErrorHandlerFn fnFailureProcedure)\r\n\t{\r\n\t\tg_fnAssertHandler = fnFailureProcedure;\r\n\t\t//xLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"invoked\");\r\n\r\n\t}\r\n\t\r\n\t//void xCONVENTION_API setErrorHandler(xErrorHandlerFn fnFailureProcedure);\r\n\r\n\r\n\tstatic void swapBuffer(xAssertInfo&newData);\r\n\tstatic xAssertionEx *Instance();\r\n\txAssertionEx();\r\n\r\nprivate:\r\n\t\r\n\tstatic CAssertionFailedProcedure g_fnAssertFailureHandler;\r\n\tstatic xErrorHandlerFn g_fnAssertHandler;\r\n\r\n\r\n};\t\r\n\r\n#define xAssertRouted(Assertion) if(Assertion){}else assert_notify_failure(#Assertion)\r\n\r\n#define XASSERT_HANDLER(Assertion) (false || (Assertion) \\\r\n\t|| (xAssertionEx::getAssertFailureCustomHandler() \\\r\n\t&& (xAssertionEx::getAssertFailureCustomHandler()( \\\r\n\tAFS_ASSERT, #Assertion, __FILE__, __LINE__), true)))\r\n\r\n#define xCHECK_HANDLER(Assertion) ((bConditionValue = false || (Assertion)\\\r\n\t|| (xAssertionEx::getAssertFailureCustomHandler() \\\r\n\t&& (xAssertionEx::getAssertFailureCustomHandler()( \\\r\n\tAFS_CHECK, #Assertion, __FILE__, __LINE__), true)))\r\n\r\n\r\n\r\n#define _xAssertHandler(Assertion) (false || (Assertion) || \\\r\n\t(xAssertionEx::getErrorHandler() &&\\\r\n\t(xAssertionEx::getErrorHandler()( AFS_ASSERT, #Assertion, __FILE__, __LINE__,\"asdasd\",NULL,TRUE), true)))\r\n\r\n\r\n/*#define _xAssert(Assertion) (false || (Assertion) \r\n\t|| (xAssertionEx::getErrorHandler() \\\r\n\t&& (xAssertionEx::getErrorHandler()( \\\r\n\tAFS_ASSERT, #Assertion, __FILE__, __LINE__,\"\",\"\",FALSE), true)))\r\n*/\r\n\r\n\r\n#define xAssert(Assertion) xAssertRouted(XASSERT_HANDLER(Assertion))\r\n\r\n#define xVerify(Assertion) xAssert(Assertion)\r\n\r\n#define xCheck(Assertion) { \\\r\n\tbool bConditionValue; \\\r\n\tassert(xCHECK_HANDLER(Assertion)); \\\r\n\t(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n\r\n\r\n#define xVerify(Assertion) _xAssertHandler(Assertion)\r\n\r\n\r\n/*\r\n#define xVerify(Assertion) { \\\r\n\tbool bConditionValue=False; \\\r\n\txAssert(xVerifyHandlerEx(Assertion)); \\\r\n\t(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n}\r\n\r\n*/\r\n\r\n\r\n/*\r\n\r\n#define xVerify(Assertion) { \\\r\n\tbool bConditionValue; \\\r\n\tassert(xVerifyHandlerEx(Assertion)); \\\r\n\t(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n}\r\n\r\n\r\n\r\n\r\n//#define xAssert(Assertion) assert(XASSERT_HANDLER(Assertion))\r\n\r\n//#define xVerify(Assertion) assert(xVerifyHandlerEx(Assertion))\r\n\r\n/*\r\n\r\n\r\n\r\n\r\n/*\t\r\n\r\n//extern xErrorHandlerFn xAssertionEx::g_fnAssertHandler;\r\n\r\n*/\r\n\r\n/*\r\n\r\n\r\n\r\n#define xASSERT_HANDLER(Condition) (false || (Condition) \\\r\n|| (xAssertionEx::GetAssertFailureCustomHandler() \\\r\n&& (xAssertionEx::GetAssertFailureCustomHandler()( \\\r\nAFS_ASSERT, #Condition, __FILE__, __LINE__), true)))\r\n\r\n#define xAssert(Condition) XASSERT(xASSERT_HANDLER(Condition))\r\n*/\r\n//#define xVerify(Condition) xAssert(Condition)\r\n\r\n//#define XASSERT(Condition) assert(xASSERT_HANDLER(Condition))\r\n\r\n\r\n/*\r\n#define xVerifyHandlerEx(Condition,Message,Object,PostAction,Result) (false || (Condition,Message,Object,PostAction,Result) \\\r\n|| (xAssertionEx::CVerifyChecks2() \\\r\n&& (xAssertionEx::CVerifyChecks2()( \\\r\nAFS_ASSERT, #Condition, __FILE__, __LINE__,Message,Object,PostAction,Result), true)))\r\n*/\r\n/*\r\n#define xVerifyAndCorrect(Condition,Message,Object,PostAction,Result) { \\\r\nbool bConditionValue; \\\r\nxAssert(xVerifyHandlerEx(Condition,Message,Object,PostAction,Result)); \\\r\n(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n}\r\n*/\r\n\r\n/*\r\n#define xCheck(Condition) { \\\r\nbool bConditionValue; \\\r\nXASSERT(xCHECK_HANDLER(Condition)); \\\r\n(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n}\r\n*/\r\n\r\n/*\r\n#define xVerifyHandlerEx(Conditio1n,Message,Object,PostAction,Result) (false || (Condition,Message,Object,PostAction,Result) \\\r\n|| (xAssertionEx::CVerifyChecks2() \\\r\n&& (xAssertionEx::CVerifyChecks2()( \\\r\nAFS_ASSERT, #Condition, __FILE__, __LINE__,Message,Object,PostAction,Result), true)))\r\n*/\r\n\r\n\r\n/*\r\n#define xVerifyHandler(Condition) (false || (Condition) \\\r\n|| (xAssertionEx::GetAssertFailureCustomHandler() \\\r\n&& (xAssertionEx::GetAssertFailureCustomHandler()( \\\r\nAFS_ASSERT, #Condition, __FILE__, __LINE__), true)))\r\n*/\r\n/*\r\n#define xVerifyHandler(Condition,Message,Object,PostAction,Result) (false || (Condition,Message,Object,PostAction,Result) \\\r\n|| (xAssertionEx::CVerifyChecks() \\\r\n&& (xAssertionEx::CVerifyChecks()(\\\r\nAFS_ASSERT, #Condition ,__FILE__, __LINE__,Message,Object,PostAction,Result), true)))\r\n*/\r\n\r\n/*\r\n#define xVerifyHandler(Condition,Message,Object,PostAction,Result) (false || (Condition\r\n|| (xAssertionEx::CVerifyChecks() \\\r\n&& (xAssertionEx::CVerifyChecks()( AFS_ASSERT, #Condition ,\\\r\n__FILE__, __LINE__,Message,Object,PostAction,Result), true)))\r\n*/\r\n\r\n/*\r\n#define xCHECK_HANDLER(Condition) ((bConditionValue = false || (Condition)) \\\r\n|| (xAssertionEx::GetAssertFailureCustomHandler() \\\r\n&& (xAssertionEx::GetAssertFailureCustomHandler()( \\\r\nAFS_CHECK, #Condition, __FILE__, __LINE__), true)))\r\n*/\r\n\r\n/*\t\r\n#define xCHECK_HANDLER_MO(Condition) ((bConditionValue = false || (Condition)) \\\r\n|| (xAssertionEx::GetAssertFailureCustomHandler() \\\r\n&& (xAssertionEx::GetAssertFailureCustomHandler()( \\\r\nAFS_CHECK, #Condition, __FILE__, __LINE__), true)))\r\n*/\r\n\r\n\r\n\r\n\r\n\r\n/*\r\n\r\n\r\n\r\n/*\r\n\r\n\r\n#define xCheckMO(Condition) { \\\r\nbool bConditionValue; \\\r\nXASSERT(xCHECK_HANDLER(Condition)); \\\r\n(void)(bConditionValue || (*(int *)0 = 0)); \\\r\n}\r\n*/\r\n\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// Release Code :\r\n//\r\n//#define xAssert(Condition) ((void)0)\r\n\r\n//#define xVerify(Condition) ((void)(Condition))\r\n\r\n\r\n\r\n\r\n/*\r\n#define xVerifyAndCorrect(Condition) { \\\r\n\tbool bConditionValue = true; \\\r\n\txAssert(xVerifyHandlerEx(Condition)); \\\r\n\t(void)(bConditionValue || (*(int *)0 = 0)); }\r\n\r\n*/\r\n/*\r\n#define xVerifyHandlerEx(Condition) (false||(Condition) \\\r\n\t|| (xAssertionEx::GetVerifyCustomHandler() \\\r\n\t&& (xAssertionEx::GetVerifyCustomHandler()( \\\r\n\tAFS_ASSERT, #Condition, __FILE__, __LINE__), true)))\r\n*/\r\n\r\n\r\n\r\n\r\n\r\n\r\n/*\r\n#define xVerifyHandlerEx(Condition) (false || (Condition)) \\\r\n\t|| (xAssertionEx::CVerifyChecks2() \\\r\n\t&& (xAssertionEx::CVerifyChecks2()( \\\r\n\tAFS_ASSERT, #Condition, __FILE__, __LINE__), true)))\r\n*/\r\n\r\n\r\n\r\n\r\n\r\n//#define xVerifyAndCorrect(Condition,Message,Object,PostAction,Result) xAssert(XASSERT_HANDLER(Condition,Message,Object,PostAction,Result))\r\n//#define xVerify(Condition) xAssert(Condition)\r\n\r\n/*#define xVerifyAndCorrect(Condition,Message,Object,PostAction,Result)xAssert(Condition)*/\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\n#include \"pFluidRenderSettings.h\"\r\n\r\n\r\npFluidRenderSettings::pFluidRenderSettings(CKContext* ctx,CK_ID entity,char* name)\r\n{\r\n\r\n\tm_Context = ctx;\r\n\tm_InteractorsFlags = 0;\r\n\r\n\tm_StartSize = 0;\r\n\tm_StartSizeVar = 0;\r\n\tm_EndSize = 0;\r\n\tm_EndSizeVar = 0;\r\n\r\n\tm_StartColor.r = 0.6f;\r\n\tm_StartColor.g = 0.6f;\r\n\tm_StartColor.b = 0.8f;\r\n\tm_StartColor.b = 1.0f;\r\n\tm_StartColorVar.r = 0.0f;\r\n\tm_StartColorVar.g = 0.0f;\r\n\tm_StartColorVar.b = 0.0f;\r\n\tm_StartColorVar.a = 0.0f;\r\n\tm_EndColor.r = 0.0f;\r\n\tm_EndColor.g = 0.0f;\r\n\tm_EndColor.b = 0.0f;\r\n\tm_EndColor.a = 0.0f;\r\n\tm_EndColorVar.r = 0.0f;\r\n\tm_EndColorVar.g = 0.0f;\r\n\tm_EndColorVar.b = 0.0f;\r\n\tm_EndColorVar.a = 0.0f;\r\n\tm_InitialTextureFrame = 0;\r\n\tm_InitialTextureFrameVariance = 0;\r\n\tm_SpeedTextureFrame = 0;\r\n\tm_SpeedTextureFrameVariance = 0;\r\n\tm_TextureFrameCount = 0;\r\n\tm_TextureFrameloop = FALSE;\r\n\tm_EvolutionsFlags = 0;\r\n\tm_VariancesFlags = 0;\r\n\tm_InteractorsFlags = 0;\r\n\tm_DeflectorsFlags = 0;\r\n\tm_RenderMode = 3;\r\n\tm_Behavior = NULL;\r\n\r\n\tmRenderType = PRT_Point;\r\n\r\n\r\n\tm_Mesh = 0;\r\n\tm_Entity = entity;\r\n\tCK3dEntity* ent = (CK3dEntity*)m_Context->GetObject(m_Entity);\r\n\tif (ent)\r\n\t\tm_EntityBbox = ent->GetBoundingBox(TRUE);\r\n\r\n\tm_Texture = 0;\r\n\tm_Group = 0;\r\n\tm_MessageType = -1;\r\n\r\n}\r\n\r\n\r\n\r\nvoid pFluidRenderSettings::setToDefault()\r\n{\r\n\r\n}\r\n#endif // HAS_FLUIDS#include \r\n#include \"pMisc.h\"\r\n#include \"pCommon.h\"\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\nint getHullTypeFromShape(NxShape *shape)\r\n{\r\n\r\n\tint result = - 1; \r\n\tif (!shape)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tint nxType = shape->getType();\r\n\tswitch (nxType)\r\n\t{\r\n\t\tcase NX_SHAPE_PLANE:\r\n\t\t\treturn HT_Plane;\r\n\t\t\r\n\t\tcase NX_SHAPE_BOX:\r\n\t\t\treturn HT_Box;\r\n\t\t\r\n\t\tcase NX_SHAPE_SPHERE:\r\n\t\t\treturn HT_Sphere;\r\n\t\t\r\n\t\tcase NX_SHAPE_CONVEX: \r\n\t\t\treturn HT_ConvexMesh;\r\n\t\t\r\n\t\tcase NX_SHAPE_CAPSULE:\r\n\t\t\treturn HT_Capsule;\r\n\t\t\r\n\t\tcase NX_SHAPE_MESH:\r\n\t\t\treturn HT_Mesh;\r\n\t}\r\n\r\n\treturn -1;\r\n\r\n}\r\n\r\n\r\nXString getEnumDescription(CKParameterManager* pm,CKGUID parGuide,int parameterSubIndex)\r\n{\r\n\r\n\tXString result=\"None\";\r\n\tint pType = pm->ParameterGuidToType(parGuide);\r\n\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(pType);\r\n\tif ( enumStruct )\r\n\t{\r\n\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t{\r\n\t\t\tif(i == parameterSubIndex)\r\n\t\t\t{\r\n\t\t\t\tresult = enumStruct->GetEnumDescription(i);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n//************************************\r\n// Method: BoxGetZero\r\n// FullName: vtAgeia::BoxGetZero\r\n// Access: public \r\n// Returns: VxVector\r\n// Qualifier:\r\n// Parameter: vt3DObject ent\r\n//************************************\r\nVxVector BoxGetZero(CK3dEntity* ent)\r\n{\r\n\r\n\tVxVector box_s= VxVector(1,1,1);\r\n\tif (ent)\r\n\t{\r\n\r\n\t\tVxMatrix mat = ent->GetWorldMatrix();\r\n\t\tVxVector g;\r\n\t\tVx3DMatrixToEulerAngles(mat,&g.x,&g.y,&g.z);\r\n\t\tSetEulerDirection(ent,VxVector(0,0,0));\r\n\t\tCKMesh *mesh = ent->GetCurrentMesh();\r\n\r\n\r\n\t\tif (mesh!=NULL)\r\n\t\t{\r\n\t\t\tbox_s = mesh->GetLocalBox().GetSize();\r\n\t\t}\r\n\t\tSetEulerDirection(ent,g); \r\n\t}\r\n\treturn box_s;\r\n}\r\n\r\n//************************************\r\n// Method: SetEulerDirection\r\n// FullName: vtAgeia::SetEulerDirection\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK3dEntity* ent\r\n// Parameter: VxVector direction\r\n//************************************\r\nvoid SetEulerDirection(CK3dEntity* ent,VxVector direction)\r\n{\r\n\r\n\tVxVector dir,up,right;\r\n\tVxMatrix mat;\r\n\tVx3DMatrixFromEulerAngles(mat,direction.x,direction.y,direction.z);\r\n\tdir=(VxVector)mat[2];\r\n\tup=(VxVector)mat[1];\r\n\tright=(VxVector)mat[0];\r\n\tent->SetOrientation(&dir,&up,&right,NULL,FALSE);\r\n\r\n}\r\n\r\n\r\n}\r\nvtPlayerConsole.exe -d=1#include \r\n#include \"pCommon.h\"\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPBDestroyDecl();\r\nCKERROR CreatePBDestroyProto(CKBehaviorPrototype **pproto);\r\nint PBDestroy(const CKBehaviorContext& behcontext);\r\nCKERROR PBDestroyCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorPBDestroyDecl\r\n// FullName: FillBehaviorPBDestroyDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorPBDestroyDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PBDestroy\");\t\r\n\tod->SetCategory(\"Physic/Body\");\r\n\tod->SetDescription(\"Removes an entity from the physic engine.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x72519cc,0x1f2d16da));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePBDestroyProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePBDestroyProto\r\n// FullName: CreatePBDestroyProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePBDestroyProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PBDestroy\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In0\");\r\n\tproto->DeclareOutput(\"Out0\");\r\n\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\tproto->SetBehaviorCallbackFct( PBDestroyCB );\r\n\tproto->SetFunction(PBDestroy);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PBDestroy\r\n// FullName: PBDestroy\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PBDestroy(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object : \r\n\t\tCK3dEntity *referenceObject = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !referenceObject ) return CKBR_OWNERERROR;\r\n\r\n\t\tpWorld *world=GetPMan()->getWorldByBody(referenceObject); \r\n\t\tif (world)\r\n\t\t{\r\n\r\n\t\t\tpRigidBody*bodyA= world->getBody(referenceObject);\r\n\t\t\tif (bodyA)\r\n\t\t\t{\r\n\t\t\t\tworld->deleteBody(bodyA);\r\n\t\t\t}\r\n\t\t}\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PBDestroyCB\r\n// FullName: PBDestroyCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PBDestroyCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t\r\n\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n #include \"CKAll.h\"\r\n#include \"InitMan.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n\r\nInitMan::~InitMan(){}\r\n\r\n\r\n\r\nCKERROR \r\nInitMan::PreProcess(){\t\r\n\tPerformMessages();\treturn CK_OK; \r\n}\r\n\r\n\r\nCKERROR\r\nInitMan::PostClearAll(){\r\n\treturn CK_OK;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR InitMan::OnCKEnd(){\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nCKERROR InitMan::OnCKReset(){\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR InitMan::OnCKPlay()\r\n{\r\n\t\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nCKERROR InitMan::OnCKInit(){\r\n\t\r\n\tm_Context->ActivateManager((CKBaseManager*) this,true);\t\r\n\treturn CK_OK;\r\n}\r\n\r\n#include \"InitMan.h\"\r\n#include \"ResourceTools.h\"\r\n\r\n\r\n\r\nbool\r\nInitMan::AddFileEntry(XString ArchiveName,XString FileEntry){\r\n\r\n\tif (strlen(FileEntry.Str()) == 0)return FALSE;\r\n\tZiJoIt it = zili.find(ArchiveName);\r\n\tif ( it == zili.end())\r\n\t\tit = zili.insert(zili.end(),std::make_pair(ArchiveName,new XFileList()));\r\n\tit->second->push_back(FileEntry);\r\n\treturn TRUE;\r\n}\r\n\r\n\r\nint \r\nInitMan::GetUnzipDllVersion(){\r\n\treturn m_GetUnzipDllVersion();\r\n}\r\n\r\nint \r\nInitMan::GetZipDllVersion(){\r\n\treturn m_GetZipDllVersion();\r\n}\r\n\r\n\r\n\r\nBOOL __stdcall DefaultZipCallback(CZipCallbackData *pData){\r\n\treturn FALSE;\r\n\r\n}\r\n\r\nvoid \r\nInitMan::SetDefaultZipValues(CZipParams * pParams){\r\n\t\r\n\tpParams->m_hwndHandle\t\t\t= NULL;\r\n\tpParams->m_pCaller\t\t\t\t= NULL;\r\n\tpParams->m_liVersion\t\t\t= GetZipDllVersion();\r\n\tpParams->m_pfCallbackFunction\t= DefaultZipCallback;\r\n\tpParams->m_bTraceEnabled\t\t= FALSE;\r\n\r\n\tpParams->m_pszZipPassword\t\t= NULL;\r\n\tpParams->m_bSuffix\t\t\t\t= FALSE;\r\n\tpParams->m_bEncrypt\t\t\t\t= FALSE;\r\n\tpParams->m_bSystem\t\t\t\t= FALSE;\r\n\tpParams->m_bVolume\t\t\t\t= FALSE;\r\n\tpParams->m_bExtra\t\t\t\t= FALSE;\r\n\tpParams->m_bNoDirEntries\t\t= FALSE;\r\n\tpParams->m_bDate\t\t\t\t= FALSE;\r\n\tpParams->m_bVerboseEnabled\t\t= FALSE;\r\n\tpParams->m_bQuiet\t\t\t\t= FALSE;\r\n\tpParams->m_bLevel\t\t\t\t= 9;\r\n\tpParams->m_bComprSpecial\t\t= FALSE;\r\n\tpParams->m_bCRLF_LF\t\t\t\t= FALSE;\r\n\tpParams->m_bJunkDir\t\t\t\t= FALSE;\r\n\tpParams->m_bRecurse\t\t\t\t= FALSE;\r\n\tpParams->m_bGrow\t\t\t\t= TRUE;\r\n\tpParams->m_bForce\t\t\t\t= FALSE;\r\n\tpParams->m_bMove\t\t\t\t= FALSE;\r\n\tpParams->m_bDeleteEntries\t\t= FALSE;\r\n\tpParams->m_bUpdate\t\t\t\t= FALSE;\r\n\tpParams->m_bFreshen\t\t\t\t= FALSE;\r\n\tpParams->m_bJunkSFX\t\t\t\t= FALSE;\r\n\tpParams->m_bLatestTime\t\t\t= FALSE;\r\n\r\n\tfor (int j=0; j<8; j++)\r\n\t\tpParams->m_cDate[j] = 0;\r\n\tpParams->m_liFileCount\t\t\t= 0;\r\n\tpParams->m_pszArchiveFileName\t= NULL;\r\n\tpParams->m_liSeven\t\t\t\t= 7;\r\n\r\n\t\r\n}\r\nvoid \r\nInitMan::SetDefaultUnZipValues(CUnzipParams * pParams)\r\n{\r\n\t\r\n\tpParams->m_wndHandle = NULL;\r\n\tpParams->m_pCaller = NULL;\r\n\tpParams->m_liVersion = GetUnzipDllVersion();\r\n\tpParams->m_pfCallbackFunction = DefaultZipCallback;\r\n\tpParams->m_bTraceEnabled = FALSE;\r\n\r\n\tpParams->m_bPromptToOverwrite = FALSE;\r\n\tpParams->m_pszZipPassword = NULL;\r\n\tpParams->m_bTest = FALSE;\r\n\tpParams->m_bComments = FALSE;\r\n\tpParams->m_bConvert = FALSE;\r\n\r\n\tpParams->m_bQuiet = FALSE;\r\n\tpParams->m_bVerboseEnabled = FALSE;\r\n\tpParams->m_bUpdate = FALSE;\r\n\tpParams->m_bFreshen = FALSE;\r\n\tpParams->m_bDirectories = TRUE;\r\n\tpParams->m_bOverwrite = TRUE;\r\n\r\n\tpParams->m_liFileCount = 0;\r\n\tpParams->m_pszArchiveFileName = NULL;\r\n\tpParams->m_liSeven = 7;\r\n\r\n}\r\n\r\n\r\nBOOL\r\nInitMan::UnLoadZipDll(){\r\n\t\r\n\tFreeLibrary(m_ZipDllHandle);\r\n\tm_ZipDllHandle = 0;\r\n\tm_ZipDllExec = 0;\r\n\tm_GetZipDllVersion = 0;\r\n\tif(DeleteFile(ZipDllTempFile))return TRUE;\r\n\treturn FALSE;\r\n}\r\nBOOL\r\nInitMan::UnLoadUnZipDll(){\r\n\tFreeLibrary(m_UnzipDllHandle);\r\n\tm_ZipDllHandle = 0;\r\n\tm_ZipDllExec = 0;\r\n\tm_GetZipDllVersion = 0;\r\n\tif(DeleteFile(UnZipDllTempFile))return TRUE;\r\n\treturn FALSE;\r\n}\r\n\r\nBOOL \r\nInitMan::LoadZipDll(){\r\n\t\r\n\t\r\n\t \r\n/*\t\r\n\tHMODULE mod =GetParentModule(CKPLUGIN_MANAGER_DLL,INIT_MAN_GUID);\r\n\tif (mod)\r\n\t\tm_ZipDllHandle = GetModulefromResource(mod,ZIP_DLL,ZipDllTempFile);\r\n\t\t\r\n*/\r\n\tm_ZipDllHandle = LoadLibrary(\"ZIP.DLL\");\r\n\r\n\tif (!m_ZipDllHandle)return FALSE;\r\n\t\r\n\tm_GetZipDllVersion = (CGetZipDllVersion)GetProcAddress(m_ZipDllHandle, \"GetZipDllVersion\");\r\n\tif (!m_GetZipDllVersion)return FALSE;\r\n\t\r\n\tm_ZipDllExec = (CZipDllExec)GetProcAddress(m_ZipDllHandle, \"ZipDllExec\");\r\n\tif (!m_ZipDllExec)return FALSE;\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL \r\nInitMan::LoadUnzipDll(){\r\n\r\n\t/*\r\n\tHMODULE mod =GetParentModule(CKPLUGIN_MANAGER_DLL,INIT_MAN_GUID);\r\n\tif (mod)m_UnzipDllHandle = GetModulefromResource(mod,UNZIP_DLL,UnZipDllTempFile);*/\r\n\t\r\n\r\n\tm_UnzipDllHandle = LoadLibrary(\"UNZIP.DLL\");\r\n\t\r\n\tif (!m_UnzipDllHandle)return FALSE;\r\n\t\r\n\r\n\tm_GetUnzipDllVersion = (CGetUnzipDllVersion)GetProcAddress(m_UnzipDllHandle, \"GetUnzDllVersion\");\r\n\tif (!m_GetUnzipDllVersion)return FALSE;\r\n\r\n\tm_UnzipDllExec = (CUnzipDllExec)GetProcAddress(m_UnzipDllHandle, \"UnzDllExec\");\r\n\tif (!m_UnzipDllExec)return FALSE;\r\n\treturn TRUE;\r\n}\r\n\r\n\r\n\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n/********************************************************************\r\n\tcreated:\t2009/04/13\r\n\tcreated:\t13:4:2009 22:08\r\n\tfilename: \tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Include\\Core\\Common\\MemoryFileMappingPrerequisites.h\r\n\tfile path:\tx:\\ProjectRoot\\vtmodsvn\\tools\\VTCPPProjectPremakerSimple\\Sdk\\Include\\Core\\Common \r\n\tfile base:\tMemoryFileMappingPrerequisites\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tForward decalarations for memory file mappings\r\n*********************************************************************/\r\n#ifndef __MEMORY_FILE_MAPPING_PREREQUISITES_H__\r\n#define __MEMORY_FILE_MAPPING_PREREQUISITES_H__\r\n\r\n\r\nstruct vtExternalEvent;\r\nstruct TSharedMemory;\r\nstruct haptekMsg;\r\n\r\n#endif#pragma once\r\n#ifndef __GLOBAL_ARTP__\r\n#define __GLOBAL_ARTP__\r\n#endif///////////////////////////////////////////////////////////\r\n// dSleepingSettings.h\r\n// Implementation of the Class dSleepingSettings\r\n// Created on: 18-Jan-2008 17:15:31\r\n///////////////////////////////////////////////////////////\r\n\r\n#if !defined(EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_)\r\n#define EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_\r\n\r\nnamespace vtAgeia\r\n{\r\n\r\n\r\nclass pSleepingSettings\r\n{\r\n\r\npublic:\r\n\tpSleepingSettings()\r\n\t{\r\n\t\tm_AngularThresold = 0.1f;\r\n\t\tm_LinearThresold = 0.1f;\r\n\t\tm_SleepSteps = 0 ; \r\n\t\tm_AutoSleepFlag = 1;\r\n\t\tm_SleepTime = 0.0f;\r\n\t}\r\n\tvirtual ~pSleepingSettings(){}\r\n\t\r\n\tint SleepSteps() const { return m_SleepSteps; }\r\n\tvoid SleepSteps(int val) { m_SleepSteps = val; }\r\n\t\r\n\tfloat AngularThresold() const { return m_AngularThresold; }\r\n\tvoid AngularThresold(float val) { m_AngularThresold = val; }\r\n\tint AutoSleepFlag() const { return m_AutoSleepFlag; }\r\n\tvoid AutoSleepFlag(int val) { m_AutoSleepFlag = val; }\r\n\r\n\tfloat LinearThresold() const { return m_LinearThresold; }\r\n\tvoid LinearThresold(float val) { m_LinearThresold = val; }\r\n\r\n\r\n\r\n\tfloat m_AngularThresold;\r\n\tint m_AutoSleepFlag;\r\n\tfloat m_LinearThresold;\r\n\tint m_SleepSteps;\r\n\tfloat m_SleepTime;\r\n\r\n};\r\n\r\n}\r\n#endif // !defined(EA_7D481C15_2B93_4925_B66E_6FAF4DED2A2A__INCLUDED_)\r\n#pragma once\r\n\r\n\r\n// PBDodyTab\r\n\r\nclass PBDodyTab : public CTabCtrl\r\n{\r\n\tDECLARE_DYNAMIC(PBDodyTab)\r\n\r\npublic:\r\n\tPBDodyTab();\r\n\tvirtual ~PBDodyTab();\r\n\r\n\tvirtual void OnFinalRelease();\r\n\r\nprotected:\r\n\tDECLARE_MESSAGE_MAP()\r\n\tDECLARE_DISPATCH_MAP()\r\n\tDECLARE_INTERFACE_MAP()\r\n};\r\n\r\n\r\n#define NOMINMAX \r\n\r\n#if defined(WIN32)\r\n#include \r\n#include \r\n#include \r\n#elif defined(__APPLE__)\r\n#include \r\n#include \r\n#endif\r\n#include \r\n\r\n#include \"OrthographicDrawing.h\"\r\n\r\n// Physics code\r\n#undef random\r\n#include \"NxPhysics.h\"\r\n#include \"NxVehicle.h\"\r\n\r\nenum CreationModes { MODE_NONE, MODE_CAR, MODE_TRUCK };\r\n\r\nextern NxPhysicsSDK*\tgPhysicsSDK;\r\nextern NxScene*\t\t\tgScene;\r\nextern NxSpringDesc wheelSpring;\r\nextern bool keyDown[256];\r\n\r\nextern NxUserContactReport * carContactReport;\r\n//void initCar();\r\n//void createCar(const NxVec3& pos);\r\nvoid createCarWithDesc(const NxVec3& pos, bool frontWheelDrive, bool backWheelDrive, bool corvetteMotor, bool monsterTruck, bool oldStyle, NxPhysicsSDK* physicsSDK);\r\nvoid createCart(const NxVec3& pos, bool frontWheelDrive, bool backWheelDrive, bool oldStyle);\r\nNxVehicleDesc* createTruckPullerDesc(const NxVec3& pos, NxU32 nbGears, bool oldStyle);\r\nNxVehicleDesc* createTruckTrailer1(const NxVec3& pos, NxReal length, bool oldStyle);\r\nNxVehicleDesc* createFullTruckDesc(const NxVec3& pos, NxReal length, NxU32 nbGears, bool has4Axes, bool oldStyle);\r\nNxVehicleDesc* createTwoAxisTrailer(const NxVec3& pos, NxReal length, bool oldStyle);\r\n\r\nNxVehicle* createTruckPuller(const NxVec3& pos, NxU32 nbGears, bool oldStyle);\r\nNxVehicle* createFullTruck(const NxVec3& pos, NxU32 nbGears, bool has4Axes, bool oldStyle);\r\nNxVehicle* createTruckWithTrailer1(const NxVec3& pos, NxU32 nbGears, bool oldStyle);\r\nNxVehicle* createFullTruckWithTrailer2(const NxVec3& pos, NxU32 nbGears, bool oldStyle);\r\n//void tickCar();\r\n\r\nvoid InitTerrain();\r\nvoid RenderTerrain();\r\nvoid RenderAllActors();\r\nvoid renderHUD(OrthographicDrawing& orthoDraw);\r\n# MAKEFILE for linux GCC\n#\n# \n# Modified by \n#\n# NOTE: This should later be replaced by autoconf/automake scripts, but for\n# the time being this is actually pretty clean. The only ugly part is\n# handling CFLAGS so that the x86 specific optimizations don't break\n# a build. This is easy to remedy though, for those that have problems.\n\n# The version\nVERSION=0.92\n\n#ch1-01-1\n# Compiler and Linker Names\n#CC=gcc\n#LD=ld\n\n# Archiver [makes .a files]\n#AR=ar\n#ARFLAGS=r\n#ch1-01-1\n\n# optimize for SIZE\n#CFLAGS += -Os\n#ch1-01-3\n# Compilation flags. Note the += does not write over the user's CFLAGS!\nCFLAGS += -c -I./ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter -DLTC_SOURCE\n\n# optimize for SPEED\nCFLAGS += -O3 -funroll-loops\n\n#add -fomit-frame-pointer. v3.2 is buggy for certain platforms!\nCFLAGS += -fomit-frame-pointer\n\n# optimize for SIZE\nCFLAGS += -Os\n\n# compile for DEBUGING\n#CFLAGS += -g3\n#ch1-01-3\n\n#These flags control how the library gets built.\n\n#Output filenames for various targets.\nLIBNAME=libtomcrypt.a\nTEST=test\nHASH=hashsum\nCRYPT=encrypt\nSMALL=small\nPROF=x86_prof\nTV=tv_gen\n\n#LIBPATH-The directory for libtomcrypt to be installed to.\n#INCPATH-The directory to install the header files for libtomcrypt.\n#DATAPATH-The directory to install the pdf docs.\nDESTDIR=\nLIBPATH=/usr/lib\nINCPATH=/usr/include\nDATAPATH=/usr/share/doc/libtomcrypt/pdf\n\n#List of objects to compile.\n\n#Leave MPI built-in or force developer to link against libtommath?\nMPIOBJECT=mpi.o\n\nOBJECTS=keyring.o gf.o mem.o sprng.o ecc.o base64.o dh.o rsa.o \\\nbits.o yarrow.o cfb.o ofb.o ecb.o ctr.o cbc.o hash.o tiger.o sha1.o \\\nmd5.o md4.o md2.o sha256.o sha512.o xtea.o aes.o des.o \\\nsafer_tab.o safer.o safer+.o rc4.o rc2.o rc6.o rc5.o cast5.o noekeon.o blowfish.o crypt.o \\\nprime.o twofish.o packet.o hmac.o strings.o rmd128.o rmd160.o skipjack.o omac.o dsa.o $(MPIOBJECT)\n\nTESTOBJECTS=demos/test.o\nHASHOBJECTS=demos/hashsum.o\nCRYPTOBJECTS=demos/encrypt.o\nSMALLOBJECTS=demos/small.o\nPROFS=demos/x86_prof.o\nTVS=demos/tv_gen.o\n\n#Files left over from making the crypt.pdf.\nLEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind\n\n#Compressed filenames\nCOMPRESSED=crypt.tar.bz2 crypt.zip crypt.tar.gz\n\n#Header files used by libtomcrypt.\nHEADERS=tommath.h mycrypt_cfg.h mycrypt_gf.h mycrypt_kr.h \\\nmycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \\\nmycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h mycrypt_custom.h\n\n#The default rule for make builds the libtomcrypt library.\ndefault:library mycrypt.h mycrypt_cfg.h\n\n#These are the rules to make certain object files.\nrsa.o: rsa.c rsa_sys.c\necc.o: ecc.c ecc_sys.c\ndh.o: dh.c dh_sys.c\naes.o: aes.c aes_tab.c\ntwofish.o: twofish.c twofish_tab.c\nsha512.o: sha512.c sha384.c\nsha256.o: sha256.c sha224.c\n\n#This rule makes the libtomcrypt library.\nlibrary: $(LIBNAME)\n\n$(LIBNAME): $(OBJECTS)\n\t$(AR) $(ARFLAGS) $@ $(OBJECTS) \n\n#This rule makes the test program included with libtomcrypt\ntest: library $(TESTOBJECTS)\n\t$(CC) $(TESTOBJECTS) $(LIBNAME) -o $(TEST) $(WARN)\n\n#This rule makes the hash program included with libtomcrypt\nhashsum: library $(HASHOBJECTS)\n\t$(CC) $(HASHOBJECTS) $(LIBNAME) -o $(HASH) $(WARN)\n\n#makes the crypt program\ncrypt: library $(CRYPTOBJECTS)\n\t$(CC) $(CRYPTOBJECTS) $(LIBNAME) -o $(CRYPT) $(WARN)\n\n#makes the small program\nsmall: library $(SMALLOBJECTS)\n\t$(CC) $(SMALLOBJECTS) $(LIBNAME) -o $(SMALL) $(WARN)\n\t\nx86_prof: library $(PROFS)\n\t$(CC) $(PROFS) $(LIBNAME) -o $(PROF)\n\ntv_gen: library $(TVS)\n\t$(CC) $(TVS) $(LIBNAME) -o $(TV)\n\n#This rule installs the library and the header files. This must be run\n#as root in order to have a high enough permission to write to the correct\n#directories and to set the owner and group to root.\ninstall: library docs\n\tinstall -d -g root -o root $(DESTDIR)$(LIBPATH)\n\tinstall -d -g root -o root $(DESTDIR)$(INCPATH)\n\tinstall -d -g root -o root $(DESTDIR)$(DATAPATH)\n\tinstall -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)\n\tinstall -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)\n\tinstall -g root -o root crypt.pdf $(DESTDIR)$(DATAPATH)\n\n#This rule cleans the source tree of all compiled code, not including the pdf\n#documentation.\nclean:\n\trm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME)\n\trm -f $(TEST) $(HASH) $(COMPRESSED) $(PROFS) $(PROF) $(TVS) $(TV)\n\trm -f *.a *.dll *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat *.txt\n\n#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed\n#from the clean command! This is because most people would like to keep the\n#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to\n#delete it if we are rebuilding it.\ndocs: crypt.tex\n\trm -f crypt.pdf $(LEFTOVERS)\n\tlatex crypt > /dev/null\n\tmakeindex crypt > /dev/null\n\tpdflatex crypt > /dev/null\n\trm -f $(LEFTOVERS)\n \n#beta\nbeta: clean\n\tcd .. ; rm -rf crypt* libtomcrypt-$(VERSION)-beta ; mkdir libtomcrypt-$(VERSION)-beta ; \\\n\tcp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)-beta/ ; tar -c libtomcrypt-$(VERSION)-beta/* > crypt-$(VERSION)-beta.tar ; \\\n\tbzip2 -9vv crypt-$(VERSION)-beta.tar ; zip -9 -r crypt-$(VERSION)-beta.zip libtomcrypt-$(VERSION)-beta/*\n\n#zipup the project (take that!)\nzipup: clean docs\n\tcd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \\\n\tcp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \\\n\tbzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/*\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t Orbit\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorOrbitDecl();\r\nCKERROR CreateOrbitProto(CKBehaviorPrototype **pproto);\r\nint Orbit(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorOrbitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Camera Orbit\");\t\r\n\tod->SetDescription(\"Makes a Camera orbit round a 3D Entity.\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tTarget: 3D Entity to target.
\r\n\tDistance: current distance between the Camera and its target.
\r\n\t
\r\n\tThe following keys are used by default to move the Camera around its target:
\r\n\t
\r\n\tPage Up: Zoom in.
\r\n\tPage Down: Zoom out.
\r\n\tUp and Down Arrows: Rotate around the view X axis.
\r\n\tLeft and Right Arrows: Rotate around the view Y axis.
\r\n\tRIGHT SHIFT: Velocity x 2.
\r\n\tThe arrow keys are the inverted T arrow keys and not the ones of the numeric keypad.
\r\n
\r\n\tKey Zoom in: Key used to zoom in.
\r\n\tKey Zoom out: Key used to zoom in.
\r\n\tKey Rotate Up: Key used to rotate up.
\r\n\tKey Rotate Down: Key used to rotate down.
\r\n\tKey Rotate Left: Key used to rotate left.
\r\n\tKey Rotate Right: Key used to rotate right.
\r\n\tKey Speed x2: Key used to speed up motion by 2.
\r\n
\r\n */\r\n\tod->SetCategory(\"Cameras/Movement\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x777d999e, 0xdef777d8));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateOrbitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateOrbitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Camera Orbit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Target\", CKPGUID_3DENTITY );\r\n\r\n\tproto->DeclareOutParameter(\"Distance\", CKPGUID_FLOAT );\r\n\r\n\tproto->DeclareSetting(\"Key Zoom In\", CKPGUID_KEY,\"Numpad -\");\r\n\tproto->DeclareSetting(\"Key Zoom Out\", CKPGUID_KEY,\"Numpad +\");\r\n\tproto->DeclareSetting(\"Key Rotate Up\", CKPGUID_KEY,\"Up Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Down\", CKPGUID_KEY,\"Down Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Left\", CKPGUID_KEY,\"Left Arrow\");\r\n\tproto->DeclareSetting(\"Key Rotate Right\", CKPGUID_KEY,\"Right Arrow\");\r\n\tproto->DeclareSetting(\"Key Speed x2\", CKPGUID_KEY,\"Right Shift\");\r\n \r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(Orbit);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint Orbit(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n // Set IO states\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\r\n // Get Key Codes\r\n int key_zoomin=0; beh->GetLocalParameterValue(0, &key_zoomin); if(!key_zoomin) key_zoomin=CKKEY_PRIOR;\r\n int key_zoomout=0; beh->GetLocalParameterValue(1, &key_zoomout); if(!key_zoomout) key_zoomout=CKKEY_NEXT;\r\n int key_rotateup=0; beh->GetLocalParameterValue(2, &key_rotateup); if(!key_rotateup) key_rotateup=CKKEY_UP;\r\n int key_rotatedown=0; beh->GetLocalParameterValue(3, &key_rotatedown); if(!key_rotatedown) key_rotatedown=CKKEY_DOWN;\r\n int key_rotateleft=0; beh->GetLocalParameterValue(4, &key_rotateleft); if(!key_rotateleft) key_rotateleft=CKKEY_LEFT;\r\n int key_rotateright=0; beh->GetLocalParameterValue(5, &key_rotateright); if(!key_rotateright) key_rotateright=CKKEY_RIGHT;\r\n int key_speedx2=0; beh->GetLocalParameterValue(6, &key_speedx2); if(!key_speedx2) key_speedx2=CKKEY_RSHIFT;\r\n \r\n // Object to follow\r\n\tCK3dEntity *ent = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\r\n\tVxVector pos_tar;\r\n\tfloat radius;\r\n\r\n if( ent ){\r\n ent->GetPosition( &pos_tar );\r\n\tradius = ent->GetRadius();\r\n } else {\r\n radius = 10.0f;\r\n pos_tar = VxVector::axis0();\r\n }\r\n \r\n if( radius <= 0.01f ) radius = 0.01f;\r\n\r\n\tVxVector pos;\r\n\r\n // Get the Target of camera\r\n CK3dEntity *tar;\r\n CKBOOL CameraHasTarget = CKIsChildClassOf( cam, CKCID_TARGETCAMERA ) && (tar=((CKTargetCamera*)cam)->GetTarget());\r\n if( CameraHasTarget ){\r\n tar->SetPosition( &pos_tar );\r\n } else {\r\n tar = ent;\r\n }\r\n\r\n //________________// Left / Right / Up / Down\r\n cam->GetPosition( &pos, NULL);\r\n pos -= pos_tar;\r\n\r\n CKInputManager *input = (CKInputManager*)behcontext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);\r\n if( !input ) return CKBR_GENERICERROR;\r\n\r\n float d = Magnitude( pos );\r\n float ratio = (input->IsKeyDown(key_speedx2))? .003f:.001f;\r\n //\tfloat s = d * radius * ratio;\r\n\tfloat s = d * behcontext.DeltaTime * ratio;\r\n \r\n\tVxVector dep(0.0f);\r\n if( input->IsKeyDown(key_rotateup) ) dep.y = s;\r\n if( input->IsKeyDown(key_rotatedown) ) dep.y += -s;\r\n if( input->IsKeyDown(key_rotateleft) ) dep.x = -s;\r\n if( input->IsKeyDown(key_rotateright) ) dep.x += s;\r\n \r\n \r\n cam->Translate( &dep, cam, FALSE);\r\n\r\n //________________// Forward / Backward\r\n cam->GetPosition( &pos, NULL);\r\n pos -= pos_tar;\r\n \r\n float tmp = Magnitude( pos );\r\n dep.x = 0.0f;\r\n\tdep.y = 0.0f;\r\n\tdep.z = tmp - d;\r\n \r\n if( input->IsKeyDown(key_zoomin) ) dep.z += s;\r\n\tif( input->IsKeyDown(key_zoomout) ) dep.z += -s;\r\n\r\n\tcam->Translate( &dep, cam, FALSE);\r\n \r\n //________________// Output Distance\r\n d = tmp - dep.z;\r\n\tbeh->SetOutputParameterValue(0, &d );\r\n\r\n //________________// Look At target\r\n if( !CameraHasTarget ){\r\n cam->LookAt( &pos_tar );\r\n }\r\n \r\n\treturn CKBR_OK;\r\n}\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xMathStream.h\"\r\n#include \"xPredictionSetting.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\nuxString \r\nxDistributedPoint3F::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedPoint3F::updateFromServer(xNStream *stream)\r\n{\r\n\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tTNL::Point3f p;\r\n\t\tstream->readPointCompressed(&p,1.0f);\r\n\t\tPoint3F realPos(p.x,p.y,p.z);\r\n\r\n\t\tTNL::Point3f v;\r\n\t\tstream->readPointCompressed(&v,1.0f);\r\n\t\tPoint3F velocity(v.x,v.y,v.z);\r\n\r\n\t\tmLastServerValue = realPos;\r\n\t\tmLastServerDifference = velocity;\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tTNL::Point3f p;\r\n\t\tstream->readPointCompressed(&p,1.0f);\r\n\t\tPoint3F realPos(p.x,p.y,p.z);\r\n\t\tmLastServerValue = realPos;\r\n\t}\r\n\r\n\tsetValueState(E_DV_UPDATED);\r\n\r\n\r\n\t//xLogger::xLog(ELOGINFO,XL_START,\"\\n vel: %f,%f,%f\",velocity.x,velocity.y,velocity.z );\r\n}\r\n\r\nvoid\r\nxDistributedPoint3F::updateGhostValue(xNStream *stream)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tTNL::Point3f p;\r\n\r\n\t\tp.x = mCurrentValue.x;\r\n\t\tp.y = mCurrentValue.y;\r\n\t\tp.z = mCurrentValue.z;\r\n\t\tstream->writePointCompressed(p,1.0f);\r\n\r\n\t\tTNL::Point3f v;\r\n\t\tv.x = mDifference.x;\r\n\t\tv.y = mDifference.y;\r\n\t\tv.z = mDifference.z;\r\n\t\tstream->writePointCompressed(v,1.0f);\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tTNL::Point3f p;\r\n\r\n\t\tp.x = mCurrentValue.x;\r\n\t\tp.y = mCurrentValue.y;\r\n\t\tp.z = mCurrentValue.z;\r\n\t\tstream->writePointCompressed(p,1.0f);\r\n\t}\r\n\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint3F::unpack(xNStream *bstream,float sendersOneWayTime)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tsendersOneWayTime *= 0.001f;\r\n\r\n\t\tTNL::Point3f p;\r\n\t\tbstream->readPointCompressed(&p,1.0f);\r\n\t\tPoint3F realPos(p.x,p.y,p.z);\r\n\r\n\r\n\t\tTNL::Point3f v;\r\n\t\tbstream->readPointCompressed(&v,1.0f);\r\n\t\tPoint3F velocity(v.x,v.y,v.z);\r\n\r\n\t\tPoint3F predictedPos = realPos + velocity * sendersOneWayTime;\r\n\t\t\r\n\t\t\r\n\t\tsetOwnersOneWayTime(sendersOneWayTime);\r\n\r\n\t\tmLastValue = mCurrentValue;\r\n\t\tmCurrentValue = predictedPos;\r\n\t\tmDifference= mCurrentValue - mLastValue;\r\n\t}\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\r\n\t\tTNL::Point3f p;\r\n\t\tbstream->readPointCompressed(&p,1.0f);\r\n\t\tPoint3F realPos(p.x,p.y,p.z);\r\n\r\n\t\tmLastValue = realPos;\r\n\t\tmLastServerValue = realPos;\r\n\t\tmCurrentValue = realPos;\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint3F::pack(xNStream *bstream)\r\n{\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\r\n\t\tTNL::Point3f p;\r\n\r\n\t\tp.x = mCurrentValue.x;\r\n\t\tp.y = mCurrentValue.y;\r\n\t\tp.z = mCurrentValue.z;\r\n\t\tbstream->writePointCompressed(p,1.0f);\r\n\r\n\t\tTNL::Point3f v;\r\n\t\tv.x = mDifference.x;\r\n\t\tv.y = mDifference.y;\r\n\t\tv.z = mDifference.z;\r\n\t\tbstream->writePointCompressed(v,1.0f);\r\n\t}\r\n\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tTNL::Point3f p;\r\n\r\n\t\tp.x = mCurrentValue.x;\r\n\t\tp.y = mCurrentValue.y;\r\n\t\tp.z = mCurrentValue.z;\r\n\t\tbstream->writePointCompressed(p,1.0f);\r\n\r\n\t}\r\n\t\tint flags = getFlags();\r\n\t\tflags &= (~E_DP_NEEDS_SEND);\r\n\t\tsetFlags(flags);\r\n\r\n\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedPoint3F::updateValue(Point3F value,xTimeType currentTime)\r\n{\r\n\r\n\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue = mCurrentValue;\r\n mCurrentValue = value;\r\n\tmDifference = mCurrentValue - mLastValue;\r\n\t\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\tfloat lengthDiff = fabsf(mDifference.len());\r\n\tfloat timeDiffMs = ((float)mThresoldTicker) / 1000.f;\r\n\t\r\n\r\n\t\r\n\r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\tbool result = false;\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tif (lengthDiff > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t\t\r\n\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"mThresoldTicker2: %f\",mThresoldTicker2);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tPoint3F serverDiff = mCurrentValue-mLastServerValue ;\r\n\t\t\r\n\t\tif ( fabsf( serverDiff.len()) > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > (getPredictionSettings()->getMinSendTime() * 0.2f) )\r\n\t\t\t{\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t\t//xLogger::xLog(ELOGINFO,XL_START,\"mThresoldTicker2: %f\",mThresoldTicker2);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t{\r\n\t\t\tmThresoldTicker2 = 0 ;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\t}\r\n\r\n\tif (getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\tresult = true ;\r\n\t\tmLastValue = value;\r\n\t\tmCurrentValue = value;\r\n\t}\r\n\r\n\tsetFlags(flags);\r\n\treturn result;\r\n}//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#include \"tnl.h\"\n#include \"tnlEventConnection.h\"\n#include \"tnlBitStream.h\"\n#include \"tnlLog.h\"\n#include \"tnlNetInterface.h\"\n\nnamespace TNL {\n\nClassChunker EventConnection::mEventNoteChunker;\n\nEventConnection::EventConnection()\n{\n // event management data:\n\n mNotifyEventList = NULL;\n mSendEventQueueHead = NULL;\n mSendEventQueueTail = NULL;\n mUnorderedSendEventQueueHead = NULL;\n mUnorderedSendEventQueueTail = NULL;\n mWaitSeqEvents = NULL;\n\n mNextSendEventSeq = FirstValidSendEventSeq;\n mNextRecvEventSeq = FirstValidSendEventSeq;\n mLastAckedEventSeq = -1;\n mEventClassCount = 0;\n mEventClassBitSize = 0;\n}\n\nEventConnection::~EventConnection()\n{\n \n while(mNotifyEventList)\n {\n EventNote *temp = mNotifyEventList;\n mNotifyEventList = temp->mNextEvent;\n \n temp->mEvent->notifyDelivered(this, true);\n mEventNoteChunker.free(temp);\n }\n while(mUnorderedSendEventQueueHead)\n {\n EventNote *temp = mUnorderedSendEventQueueHead;\n mUnorderedSendEventQueueHead = temp->mNextEvent;\n \n temp->mEvent->notifyDelivered(this, true);\n mEventNoteChunker.free(temp);\n }\n while(mSendEventQueueHead)\n {\n EventNote *temp = mSendEventQueueHead;\n mSendEventQueueHead = temp->mNextEvent;\n \n temp->mEvent->notifyDelivered(this, true);\n mEventNoteChunker.free(temp);\n }\n}\n\nvoid EventConnection::writeConnectRequest(BitStream *stream)\n{\n Parent::writeConnectRequest(stream);\n stream->write(NetClassRep::getNetClassCount(getNetClassGroup(), NetClassTypeEvent));\n}\n\nbool EventConnection::readConnectRequest(BitStream *stream, const char **errorString)\n{\n if(!Parent::readConnectRequest(stream, errorString))\n return false;\n\n U32 classCount;\n stream->read(&classCount);\n\n U32 myCount = NetClassRep::getNetClassCount(getNetClassGroup(), NetClassTypeEvent);\n if(myCount <= classCount)\n mEventClassCount = myCount;\n else\n {\n mEventClassCount = classCount;\n if(!NetClassRep::isVersionBorderCount(getNetClassGroup(), NetClassTypeEvent, mEventClassCount))\n return false;\n }\n mEventClassVersion = NetClassRep::getClass(getNetClassGroup(), NetClassTypeEvent, mEventClassCount-1)->getClassVersion();\n mEventClassBitSize = getNextBinLog2(mEventClassCount);\n return true;\n}\n\nvoid EventConnection::writeConnectAccept(BitStream *stream)\n{\n Parent::writeConnectAccept(stream);\n stream->write(mEventClassCount);\n}\n\nbool EventConnection::readConnectAccept(BitStream *stream, const char **errorString)\n{\n if(!Parent::readConnectAccept(stream, errorString))\n return false;\n\n stream->read(&mEventClassCount);\n U32 myCount = NetClassRep::getNetClassCount(getNetClassGroup(), NetClassTypeEvent);\n\n if(mEventClassCount > myCount)\n return false;\n\n if(!NetClassRep::isVersionBorderCount(getNetClassGroup(), NetClassTypeEvent, mEventClassCount))\n return false;\n\n mEventClassBitSize = getNextBinLog2(mEventClassCount);\n return true;\n}\n\nvoid EventConnection::processEvent(NetEvent *theEvent)\n{\n if(getConnectionState() == NetConnection::Connected)\n theEvent->process(this);\n}\n\nvoid EventConnection::packetDropped(PacketNotify *pnotify)\n{\n Parent::packetDropped(pnotify);\n EventPacketNotify *notify = static_cast(pnotify);\n\n EventNote *walk = notify->eventList;\n EventNote **insertList = &mSendEventQueueHead;\n EventNote *temp;\n \n while(walk)\n {\n switch(walk->mEvent->mGuaranteeType)\n {\n case NetEvent::GuaranteedOrdered:\n // It was a guaranteed ordered packet, reinsert it back into\n // mSendEventQueueHead in the right place (based on seq numbers)\n\n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: DroppedGuaranteed - %d\", getNetAddressString(), walk->mSeqCount));\n while(*insertList && (*insertList)->mSeqCount < walk->mSeqCount)\n insertList = &((*insertList)->mNextEvent);\n \n temp = walk->mNextEvent;\n walk->mNextEvent = *insertList;\n if(!walk->mNextEvent)\n mSendEventQueueTail = walk;\n *insertList = walk;\n insertList = &(walk->mNextEvent);\n walk = temp;\n break;\n case NetEvent::Guaranteed:\n // It was a guaranteed packet, put it at the top of\n // mUnorderedSendEventQueueHead.\n temp = walk->mNextEvent;\n walk->mNextEvent = mUnorderedSendEventQueueHead;\n mUnorderedSendEventQueueHead = walk;\n if(!walk->mNextEvent)\n mUnorderedSendEventQueueTail = walk;\n walk = temp;\n break;\n case NetEvent::Unguaranteed:\n // Or else it was an unguaranteed packet, notify that\n // it was _not_ delivered and blast it.\n walk->mEvent->notifyDelivered(this, false);\n temp = walk->mNextEvent;\n mEventNoteChunker.free(walk);\n walk = temp;\n }\n }\n}\n\nvoid EventConnection::packetReceived(PacketNotify *pnotify)\n{\n Parent::packetReceived(pnotify);\n\n EventPacketNotify *notify = static_cast(pnotify);\n\n EventNote *walk = notify->eventList;\n EventNote **noteList = &mNotifyEventList;\n\n while(walk)\n {\n EventNote *next = walk->mNextEvent;\n if(walk->mEvent->mGuaranteeType != NetEvent::GuaranteedOrdered)\n {\n walk->mEvent->notifyDelivered(this, true);\n mEventNoteChunker.free(walk);\n walk = next;\n }\n else\n {\n while(*noteList && (*noteList)->mSeqCount < walk->mSeqCount)\n noteList = &((*noteList)->mNextEvent);\n \n walk->mNextEvent = *noteList;\n *noteList = walk;\n noteList = &walk->mNextEvent;\n walk = next;\n }\n }\n while(mNotifyEventList && mNotifyEventList->mSeqCount == mLastAckedEventSeq + 1)\n {\n mLastAckedEventSeq++;\n EventNote *next = mNotifyEventList->mNextEvent;\n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: NotifyDelivered - %d\", getNetAddressString(), mNotifyEventList->mSeqCount));\n mNotifyEventList->mEvent->notifyDelivered(this, true);\n mEventNoteChunker.free(mNotifyEventList);\n mNotifyEventList = next;\n }\n}\n\nvoid EventConnection::writePacket(BitStream *bstream, PacketNotify *pnotify)\n{\n Parent::writePacket(bstream, pnotify);\n EventPacketNotify *notify = static_cast(pnotify);\n \n if(mConnectionParameters.mDebugObjectSizes)\n bstream->writeInt(DebugChecksum, 32);\n\n EventNote *packQueueHead = NULL, *packQueueTail = NULL;\n\n while(mUnorderedSendEventQueueHead)\n {\n if(bstream->isFull())\n break;\n // get the first event\n EventNote *ev = mUnorderedSendEventQueueHead;\n\n bstream->writeFlag(true);\n S32 start = bstream->getBitPosition();\n\n if(mConnectionParameters.mDebugObjectSizes)\n bstream->advanceBitPosition(BitStreamPosBitSize);\n \n S32 classId = ev->mEvent->getClassId(getNetClassGroup());\n bstream->writeInt(classId, mEventClassBitSize);\n\n ev->mEvent->pack(this, bstream);\n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: WroteEvent %s - %d bits\", getNetAddressString(), ev->mEvent->getDebugName(), bstream->getBitPosition() - start));\n\n if(mConnectionParameters.mDebugObjectSizes)\n bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, start);\n\n if(bstream->getBitSpaceAvailable() < MinimumPaddingBits)\n {\n // rewind to before the event, and break out of the loop:\n bstream->setBitPosition(start - 1);\n bstream->clearError();\n break;\n }\n\n // dequeue the event and add this event onto the packet queue\n mUnorderedSendEventQueueHead = ev->mNextEvent;\n ev->mNextEvent = NULL;\n\n if(!packQueueHead)\n packQueueHead = ev;\n else\n packQueueTail->mNextEvent = ev;\n packQueueTail = ev;\n }\n \n bstream->writeFlag(false); \n S32 prevSeq = -2;\n \n while(mSendEventQueueHead)\n {\n if(bstream->isFull())\n break;\n \n // if the event window is full, stop processing\n if(mSendEventQueueHead->mSeqCount > mLastAckedEventSeq + 126)\n break;\n\n // get the first event\n EventNote *ev = mSendEventQueueHead;\n S32 eventStart = bstream->getBitPosition();\n\n bstream->writeFlag(true);\n\n if(!bstream->writeFlag(ev->mSeqCount == prevSeq + 1))\n bstream->writeInt(ev->mSeqCount, 7);\n prevSeq = ev->mSeqCount;\n\n if(mConnectionParameters.mDebugObjectSizes)\n bstream->advanceBitPosition(BitStreamPosBitSize);\n\n S32 start = bstream->getBitPosition();\n\n S32 classId = ev->mEvent->getClassId(getNetClassGroup());\n bstream->writeInt(classId, mEventClassBitSize);\n ev->mEvent->pack(this, bstream);\n\n ev->mEvent->getClassRep()->addInitialUpdate(bstream->getBitPosition() - start);\n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: WroteEvent %s - %d bits\", getNetAddressString(), ev->mEvent->getDebugName(), bstream->getBitPosition() - start));\n\n if(mConnectionParameters.mDebugObjectSizes)\n bstream->writeIntAt(bstream->getBitPosition(), BitStreamPosBitSize, start - BitStreamPosBitSize);\n\n if(bstream->getBitSpaceAvailable() < MinimumPaddingBits)\n {\n // rewind to before the event, and break out of the loop:\n bstream->setBitPosition(eventStart);\n bstream->clearError();\n break;\n }\n\n // dequeue the event:\n mSendEventQueueHead = ev->mNextEvent; \n ev->mNextEvent = NULL;\n if(!packQueueHead)\n packQueueHead = ev;\n else\n packQueueTail->mNextEvent = ev;\n packQueueTail = ev;\n }\n for(EventNote *ev = packQueueHead; ev; ev = ev->mNextEvent)\n ev->mEvent->notifySent(this);\n \n notify->eventList = packQueueHead;\n bstream->writeFlag(0);\n}\n\nvoid EventConnection::readPacket(BitStream *bstream)\n{\n Parent::readPacket(bstream);\n\n if(mConnectionParameters.mDebugObjectSizes)\n {\n U32 sum = bstream->readInt(32);\n TNLAssert(sum == DebugChecksum, \"Invalid checksum.\");\n }\n \n S32 prevSeq = -2;\n EventNote **waitInsert = &mWaitSeqEvents;\n bool unguaranteedPhase = true;\n \n while(true)\n {\n bool bit = bstream->readFlag();\n if(unguaranteedPhase && !bit)\n {\n unguaranteedPhase = false;\n bit = bstream->readFlag();\n }\n if(!unguaranteedPhase && !bit)\n break;\n \n S32 seq = -1;\n \n if(!unguaranteedPhase) // get the sequence\n {\n if(bstream->readFlag())\n seq = (prevSeq + 1) & 0x7f;\n else\n seq = bstream->readInt(7);\n prevSeq = seq;\n }\n\n U32 endingPosition;\n if(mConnectionParameters.mDebugObjectSizes)\n endingPosition = bstream->readInt(BitStreamPosBitSize);\n\n U32 classId = bstream->readInt(mEventClassBitSize);\n if(classId >= mEventClassCount)\n {\n setLastError(\"Invalid packet.\");\n return;\n }\n NetEvent *evt = (NetEvent *) Object::create(getNetClassGroup(), NetClassTypeEvent, classId);\n if(!evt)\n {\n setLastError(\"Invalid packet.\");\n return;\n }\n\n // check if the direction this event moves is a valid direction.\n if( (evt->getEventDirection() == NetEvent::DirUnset)\n || (evt->getEventDirection() == NetEvent::DirServerToClient && isConnectionToClient())\n || (evt->getEventDirection() == NetEvent::DirClientToServer && isConnectionToServer()) )\n {\n setLastError(\"Invalid Packet.\");\n return;\n }\n\n\n evt->unpack(this, bstream);\n if(mErrorBuffer[0])\n return;\n\n if(mConnectionParameters.mDebugObjectSizes)\n {\n TNLAssert(endingPosition == bstream->getBitPosition(),\n avar(\"unpack did not match pack for event of class %s.\",\n evt->getClassName()) );\n }\n\n if(unguaranteedPhase)\n {\n processEvent(evt);\n delete evt;\n if(mErrorBuffer[0])\n return;\n continue;\n }\n seq |= (mNextRecvEventSeq & ~0x7F);\n if(seq < mNextRecvEventSeq)\n seq += 128;\n \n EventNote *note = mEventNoteChunker.alloc();\n note->mEvent = evt;\n note->mSeqCount = seq;\n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: RecvdGuaranteed %d\", getNetAddressString(), seq));\n\n while(*waitInsert && (*waitInsert)->mSeqCount < seq)\n waitInsert = &((*waitInsert)->mNextEvent);\n \n note->mNextEvent = *waitInsert;\n *waitInsert = note;\n waitInsert = &(note->mNextEvent);\n }\n while(mWaitSeqEvents && mWaitSeqEvents->mSeqCount == mNextRecvEventSeq)\n {\n mNextRecvEventSeq++;\n EventNote *temp = mWaitSeqEvents;\n mWaitSeqEvents = temp->mNextEvent;\n \n TNLLogMessageV(LogEventConnection, (\"EventConnection %s: ProcessGuaranteed %d\", getNetAddressString(), temp->mSeqCount));\n processEvent(temp->mEvent);\n mEventNoteChunker.free(temp);\n if(mErrorBuffer[0])\n return;\n }\n}\n\nbool EventConnection::postNetEvent(NetEvent *theEvent)\n{ \n S32 classId = theEvent->getClassId(getNetClassGroup());\n if(U32(classId) >= mEventClassCount && getConnectionState() == Connected)\n return false;\n\n theEvent->notifyPosted(this);\n\n EventNote *event = mEventNoteChunker.alloc();\n event->mEvent = theEvent;\n event->mNextEvent = NULL;\n\n if(event->mEvent->mGuaranteeType == NetEvent::GuaranteedOrdered)\n {\n event->mSeqCount = mNextSendEventSeq++;\n if(!mSendEventQueueHead)\n mSendEventQueueHead = event;\n else\n mSendEventQueueTail->mNextEvent = event;\n mSendEventQueueTail = event;\n }\n else\n {\n event->mSeqCount = InvalidSendEventSeq;\n if(!mUnorderedSendEventQueueHead)\n mUnorderedSendEventQueueHead = event;\n else\n mUnorderedSendEventQueueTail->mNextEvent = event;\n mUnorderedSendEventQueueTail = event;\n }\n return true;\n}\n\nbool EventConnection::isDataToTransmit()\n{\n return mUnorderedSendEventQueueHead || mSendEventQueueHead || Parent::isDataToTransmit();\n}\n\n};\n#ifndef VT_BASE_MANAGER_H__\r\n#define VT_BASE_MANAGER_H__ \"$Id:$\"\r\n\r\n\r\n#include \"BaseMacros.h\"\r\n#include \"CKBaseManager.h\"\r\n\r\n\r\nclass MODULE_API vtBaseManager : public CKBaseManager \r\n{\r\n\r\npublic:\r\n\r\n\tvirtual CKERROR OnCKInit()=0;\r\n\tvirtual CKERROR PostClearAll()=0;\r\n\tvirtual CKERROR PreSave()=0;\r\n\tvirtual CKERROR OnCKReset()=0;\r\n\tvirtual CKERROR PreProcess()=0;\r\n\r\n\tvirtual CKDWORD GetValidFunctionsMask()\t{ return CKMANAGER_FUNC_PostClearAll|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_OnCKInit|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PreSave|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PostLoad|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_OnCKReset|\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t CKMANAGER_FUNC_PreProcess;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t }\r\n\tvirtual void RegisterParameters()=0;\r\n\tvirtual void RegisterVSL()=0;\r\n\r\n\t\r\n\tvtBaseManager(CKContext *context,CKGUID guid,char* name) : CKBaseManager(context,guid,name) {};\r\n\r\n\t~vtBaseManager(){};\r\n\r\n};\r\n\r\n// CK2 VERSION ...\r\n#endif\r\n#include \n\n\n#include \"xTime.h\"\n#include \nxTime::xTime()\n{\n // Default time span\n span=0.01;\n spanMS=10;\n tmr=new QTimer();\n Reset();\n}\nxTime::~xTime()\n{\n SAFE_DELETE(tmr);\n}\n\n/**********\n* Attribs *\n**********/\nvoid xTime::AddSimTime(int msecs)\n// Another 'msecs' of time was simulated\n{\n curSimTime+=msecs;\n}\n#ifdef OBS_INLINED\nvoid xTime::SetLastSimTime(int t)\n// 't' is the time to which the sim has been simulated\n// This is set after a number of integrations to remember the last\n// time for the next graphics frame (calculating the distance in time to 'now')\n{\n lastSimTime=t;\n}\n#endif\nvoid xTime::SetSpan(int ms)\n// Set integration step time in milliseconds\n{\n spanMS=ms;\n span=((float)ms)/1000.0f;\n}\n\n\n\n/*************\n* Start/stop *\n*************/\nvoid xTime::Start()\n// Start the real timer\n{\n tmr->Start();\n}\nvoid xTime::Stop()\n// Stop the real timer\n{\n tmr->Stop();\n}\nvoid xTime::Reset()\n// Reset the real timer (to 0)\n{\n tmr->Reset();\n curRealTime=0;\n curSimTime=0;\n lastSimTime=0;\n}\n\n/*********\n* Update *\n*********/\nvoid xTime::Update()\n// Update the real timing\n{\n curRealTime=tmr->GetMilliSeconds();\n}\n#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\nCKObjectDeclaration\t*FillBehaviorNServerStopDecl();\r\nCKERROR CreateNServerStopProto(CKBehaviorPrototype **);\r\nint NServerStop(const CKBehaviorContext& behcontext);\r\nCKERROR NServerStopCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNServerStopDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NServerStop\");\t\r\n\tod->SetDescription(\"Stops an embedded server\");\r\n\t\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x5c357547,0x34836669));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNServerStopProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_OFF,\r\n\tBB_IT_NEXT,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_ADDRESS,\r\n\tBB_IP_MAXCLIENTS,\r\n\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_ERROR,\r\n\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_SERVER_ADDRESS,\r\n\tBB_OP_ERROR\r\n};\r\n\r\n\r\nCKERROR CreateNServerStopProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NServerStop\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(NServerStop);\r\n\tproto->SetBehaviorCallbackFct(NServerStopCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NServerStop(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\t\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\tbool result = true;\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\t\r\n\t\txNetInterface *cin = GetNM()->GetServerNetInterface();\r\n\t\tif (cin)\r\n\t\t{\r\n\t\t\tGetNM()->SetServerNetInterface(NULL);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\nCKERROR NServerStopCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"vtPhysXAll.h\"\r\n\r\npJointDistance::pJointDistance(pRigidBody* _a,pRigidBody* _b) : pJoint(_a,_b,JT_Distance)\r\n{\r\n}\r\n\r\nvoid pJointDistance::setMinDistance(float distance)\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.minDistance=distance;\r\n\r\n\tif (distance !=0.0f)\r\n\t{\r\n\t\tdescr.flags |=NX_DJF_MIN_DISTANCE_ENABLED; \r\n\t}else\r\n\t\tdescr.flags &=~NX_DJF_MIN_DISTANCE_ENABLED;\r\n\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointDistance::setMaxDistance(float distance)\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.maxDistance=distance;\r\n\tif (distance !=0.0f)\r\n\t{\r\n\t\tdescr.flags |=NX_DJF_MAX_DISTANCE_ENABLED; \r\n\t}else\r\n\t\tdescr.flags &=~NX_DJF_MAX_DISTANCE_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointDistance::setLocalAnchor1(VxVector anchor)\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.localAnchor[1] =getFrom(anchor);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointDistance::setLocalAnchor0(VxVector anchor)\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tdescr.localAnchor[0] =getFrom(anchor);\r\n\tjoint->loadFromDesc(descr);\r\n}\r\n\r\nvoid pJointDistance::enableCollision(int collision)\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return ;\tjoint->saveToDesc(descr);\r\n\tif (collision)\r\n\t{\r\n\t\tdescr.jointFlags |= NX_JF_COLLISION_ENABLED;\r\n\t}else\r\n\t\tdescr.jointFlags &= ~NX_JF_COLLISION_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n}\r\nbool pJointDistance::setSpring( pSpring spring )\r\n{\r\n\tNxDistanceJointDesc descr;\r\n\tNxDistanceJoint *joint = static_cast(getJoint());\r\n\tif (!joint)return false;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tNxSpringDesc sLimit;\tsLimit.damper = spring.damper;sLimit.spring=spring.spring;sLimit.targetValue=spring.targetValue;\r\n\tif (!sLimit.isValid())return false;\r\n\tdescr.spring= sLimit;\r\n\r\n\tif(spring.spring!=0.0f || spring.damper!=0.0f )\r\n\t\tdescr.flags|=NX_DJF_SPRING_ENABLED;\r\n\telse\r\n\t\tdescr.flags &=~NX_DJF_SPRING_ENABLED;\r\n\tjoint->loadFromDesc(descr);\r\n\r\n\treturn true;\r\n}\r\n\r\nVxVector pJointDistance::getLocalAnchor0()\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn getFrom(descr.localAnchor[0]);\r\n}\r\nVxVector pJointDistance::getLocalAnchor1()\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tif (!joint)return VxVector();\r\n\tjoint->saveToDesc(descr);\r\n\treturn getFrom(descr.localAnchor[1]);\r\n}\r\n\r\nfloat pJointDistance::getMinDistance()\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\r\n\tif (!joint)return -1.0f;\r\n\r\n\tjoint->saveToDesc(descr);\r\n\treturn descr.minDistance;\r\n}\r\n\r\nfloat pJointDistance::getMaxDistance()\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\r\n\tif (!joint)return -1.0f;\r\n\r\n\tjoint->saveToDesc(descr);\r\n\treturn descr.maxDistance;\r\n}\r\n\r\npSpring pJointDistance::getSpring()\r\n{\r\n\tNxDistanceJointDesc descr;\t\t\r\n\tNxDistanceJoint*joint = static_cast(getJoint());\t\r\n\tpSpring result;\r\n\tif (!joint)result;\r\n\tjoint->saveToDesc(descr);\r\n\r\n\tresult.spring = descr.spring.spring;\r\n\tresult.damper = descr.spring.damper;\r\n\tresult.targetValue = descr.spring.targetValue;\r\n\treturn result;\r\n}#include \"CPStdAfx.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#include \"vtTools.h\"\r\n\r\n#if defined(CUSTOM_PLAYER_STATIC)\r\n\r\n#include \"CustomPlayerStaticLibs.h\"\r\n#include \"CustomPlayerRegisterDlls.h\"\r\n#endif\r\n\r\n#include \"xSplash.h\"\r\n\r\nextern CCustomPlayer*\tthePlayer;\r\n\r\n\r\n#include \r\n\r\nvoid\r\nCCustomPlayer::Terminate(int flags) \r\n{\r\n\r\n\t\r\n\ttry \r\n\t{\r\n\t\tif (!m_CKContext) \r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tm_CKContext->Pause();\r\n\t\tm_CKContext->Reset();\r\n\t\tm_CKContext->ClearAll();\r\n\t\tif (m_EnginePointers.TheRenderManager && m_RenderContext )\r\n\t\t{\r\n\t\t\tm_EnginePointers.TheRenderManager->DestroyRenderContext(m_RenderContext);\r\n\t\t}\r\n\t\tm_RenderContext = NULL;\r\n\t\tCKCloseContext(m_CKContext);\r\n\t\tCKShutdown();\r\n\t\tm_CKContext = NULL;\r\n\r\n\t\tDestroyWindow(m_RenderWindow);\r\n\t\tDestroyWindow(m_MainWindow);\r\n\t\t\r\n\t\tStop();\r\n\t\tPostQuitMessage(0);\r\n\t\texit(0);\r\n\t} \r\n\tcatch(...) \r\n\t{\r\n\t}\r\n\t//VxGetCurrentDirectory(cDir);\r\n\t//bool res = RunAndForgetProcess2(\"playerS.exe\",cDir ,&ret);\r\n\t//MSGBOX(\"post quit : now \");\r\n\t//PostQuitMessage(0);\r\n\t//MSGBOX(\"post quit\");\r\n\r\n}\r\n\r\nvoid CCustomPlayer::StartMove(LPARAM lParam)\r\n{\r\n\tnMMoveX = LOWORD(lParam);\r\n\tnMMoveY = HIWORD(lParam);\r\n}\r\n//////////////////////////////////////////////////////////////////////////\r\nvoid CCustomPlayer::DoMMove(LPARAM lParam, WPARAM wParam) {\r\n\r\n\tif(wParam & MK_LBUTTON) { //if mouse is down; window is being dragged.\r\n\t\tRECT wnrect;\r\n\t\tGetWindowRect(this->m_MainWindow,&wnrect); //get window restraints\r\n\t\tMoveWindow(this->m_MainWindow,wnrect.left+(LOWORD(lParam)-nMMoveX),wnrect.top+(HIWORD(lParam)-nMMoveY),wnrect.right - wnrect.left,wnrect.bottom - wnrect.top,true);\r\n\t}\r\n}\r\n\r\nLRESULT CCustomPlayer::_MainWindowWndProcStub(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){\treturn thePlayer->_MainWindowWndProc(hWnd,uMsg,wParam,lParam);}\r\nLRESULT CALLBACK CCustomPlayer::_MainWindowWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)\r\n{\r\n\tswitch(message) \r\n\t{\r\n\r\n\t\tcase WM_DROPFILES:\t\t// Load any dropped file\r\n\t\t{\r\n\r\n\t\t\tchar FileName[_MAX_PATH];\r\n\t\t\tHDROP hdrop=(HDROP)wParam;\r\n\t\t\tDragQueryFile(hdrop,0,FileName,_MAX_PATH);\r\n\t\t\tReset();\r\n\t\t\t_Load(FileName);\r\n\t\t\t_FinishLoad();\r\n\t\t\tbreak;\r\n\t\t}\t\r\n\r\n\tcase WM_MOUSEMOVE:\r\n\t\t{\r\n\t\t\t// we allow window dragging enabled in the player.ini file !\r\n\t\t\tif (GetPAppStyle()->g_MouseDrag==1)\r\n\t\t\t{\r\n\t\t\t\tDoMMove(lParam,wParam);\r\n\t\t\t}\r\n\t\t}\r\n\tcase WM_ACTIVATEAPP:\r\n\t\t{\r\n\t\t\tOnActivateApp(wParam);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// Minimum size of the player window\r\n\tcase WM_GETMINMAXINFO:\r\n\t\t// this message is not very useful because\r\n\t\t// the main window of the player is not resizable ...\r\n\t\t// but perhaps it will change so we manage this message.\r\n\t\t{\r\n\t\t\tCCustomPlayer& player = CCustomPlayer::Instance();\r\n\t\t\tif((LPMINMAXINFO)lParam) {\r\n\t\t\t\t((LPMINMAXINFO)lParam)->ptMinTrackSize.x=MininumWindowedWidth();\r\n\t\t\t\t((LPMINMAXINFO)lParam)->ptMinTrackSize.y=MininumWindowedHeight();\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// Sends a Message \"OnClick\" or \"OnDblClick\" if any object is under mouse cursor\r\n\tcase WM_LBUTTONDBLCLK:\r\n\tcase WM_LBUTTONDOWN:\r\n\t\t{\r\n\t\t\t\r\n\t\t\tOnMouseClick(message);\r\n\r\n\t\t\t// [2/18/2008 mc007]\r\n\t\t\t// we allow window dragging enabled in the player.ini file !\r\n\t\t\tif (GetPAppStyle()->g_MouseDrag)\r\n\t\t\t{\r\n\t\t\t\tStartMove(lParam);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// Size and focus management\r\n\tcase WM_SIZE:\r\n\t\t// if the window is maximized or minimized\r\n\t\t// we get/lost focus.\r\n\t\t{\r\n\t\t\tif (wParam==SIZE_MINIMIZED) {\r\n\t\t\t\tOnFocusChange(FALSE);\r\n\t\t\t} else if (wParam==SIZE_MAXIMIZED) {\r\n\t\t\t\tOnFocusChange(TRUE);\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// Manage system key (ALT + KEY)\r\n\tcase WM_SYSKEYDOWN:\t\r\n\t\t{\r\n//\t\t\treturn OnSysKeyDownMainWindow(theApp.m_Config,(int)wParam);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// Repaint main frame\r\n\tcase WM_PAINT:\r\n\t\t{\r\n\t\t\tOnPaint();\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\t// The main windows has been closed by the user\r\n\tcase WM_CLOSE:\r\n\t\tPostQuitMessage(0);\r\n\t\tbreak;\r\n\r\n\t\t// Focus management\r\n\tcase WM_KILLFOCUS:\r\n\tcase WM_SETFOCUS:\r\n\t\t{\r\n\t\t\tOnFocusChange(message==WM_SETFOCUS);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\tdefault:\r\n\t\treturn DefWindowProc(hWnd, message, wParam, lParam);\r\n\t}\r\n\r\n\treturn DefWindowProc(hWnd, message, wParam, lParam);\r\n}\r\n\r\nstatic DWORD WINAPI runner(LPVOID lpParam){\tGetPlayer().DoFrame();\treturn TRUE;}\r\nvoid CCustomPlayer::Stop()\r\n{\r\n\tif (m_hThread)\r\n\t{\r\n\t\tTerminateThread(m_hThread,0);\r\n\t\tSleep(50);\r\n\t\tm_hThread = NULL;\r\n\t}\r\n}\r\n\r\nint CCustomPlayer::RunInThread()\r\n{\r\n\tDWORD threadId, thirdParam = 0;\r\n\t\r\n\tm_hThread = CreateThread(\r\n\t\tNULL,\t\t\t // no security attributes\r\n\t\t0,\t\t\t // use default stack size\r\n\t\trunner,\t // thread function\r\n\t\t&thirdParam,\t\t // argument to thread function\r\n\t\t0,\t\t\t // use default creation flags\r\n\t\t&threadId);\t\t // returns the thread identifier\r\n\r\n\treturn 123;\r\n}\r\nint CCustomPlayer::Tick()\r\n{\r\n\r\n\tMSG msg;\r\n\tGetMessage(&msg, NULL, 0, 0);\r\n\tTranslateMessage(&msg);\r\n\tDispatchMessage(&msg);\r\n\r\n\treturn Process(m_Config);\r\n}\r\n#include \r\n#include \r\n\r\nHRESULT CCustomPlayer::DoFrame() \r\n{\r\n\r\n\tBOOL bGotMsg;\r\n\tMSG msg;\r\n\tmsg.message = WM_NULL;\r\n\r\n\twhile ( msg.message != WM_QUIT )\r\n\t{\t\t\r\n\t\tif (kbhit())\r\n\t\t{\r\n\t\t\tchar message[400];\r\n\t\t\tgets(message);\r\n\t\t\tif (!strcmp(message,\"exit\"))\r\n\t\t\t{\r\n Terminate(0);\r\n\t\t\t}\r\n\t\t\tSendMessage(\"Level\",\"ConsoleMessage\",1,1,1,message);\r\n \r\n\t\t\twhile (kbhit()){\r\n\t\t\t\tgetch();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tbGotMsg = PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );\r\n\t\tif( bGotMsg )\r\n\t\t{\r\n\t\t\tTranslateMessage( &msg );\r\n\t\t\tDispatchMessage( &msg );\r\n\r\n\t\t} else Process(m_Config);\r\n\t}\r\n\treturn S_OK;\r\n}\r\n\r\n\r\n\r\nCKERROR LogRedirect(CKUICallbackStruct& loaddata,void*) \r\n{\r\n\tif(loaddata.Reason == CKUIM_OUTTOCONSOLE || \r\n\t\tloaddata.Reason \t== CKUIM_OUTTOINFOBAR ||\r\n\t\tloaddata.Reason \t== CKUIM_DEBUGMESSAGESEND\t ) \r\n\t{ \r\n\r\n\t\t\r\n\t\t//printf (\"oldString : %s\\n\",GetPlayer().m_oldText.CStr());\r\n\t\t//printf (\"newString : %s\\n\",loaddata.ConsoleString);\r\n\t\tif (GetPlayer().m_oldText.Compare(loaddata.ConsoleString))\r\n\t\t{\r\n\t\t\tprintf (\"%s\\n\",loaddata.ConsoleString);\r\n\t\t\tGetPlayer().m_oldText = loaddata.ConsoleString;\r\n\r\n\t\t\t//GetPlayer().m_CKContext->OutputToConsoleEx(\"log:%s\",GetPlayer().m_oldText);\r\n\r\n\t\t}\r\n\t\t//char buffer[MAX_PATH];\r\n\t\t/*if (GetPlayer().m_oldText.Compare(loaddata.ConsoleString))\r\n\t\t{\r\n\t\t\t//printf (loaddata.ConsoleString);\r\n\t\t\tGetPlayer().m_oldText = loaddata.ConsoleString;\r\n\t\t}*/\r\n\t} \r\n\r\n\treturn CK_OK; \r\n}\r\nvoid CCustomPlayer::RedirectLog()\r\n{\r\n\r\n\r\n\tm_oldText =\"\";\r\n\tm_CKContext->SetInterfaceMode(FALSE,LogRedirect,NULL);\r\n}\r\nCKERROR LoadCallBack(CKUICallbackStruct& loaddata,void*) { \r\n\r\n\tif (GetPlayer().GetPAppStyle()->UseSplash() && GetPlayer().GetPAppStyle()->ShowLoadingProcess())\r\n\t{\r\n\t\tif(loaddata.Reason == CKUIM_LOADSAVEPROGRESS ){ \r\n\t\t\tif (loaddata.NbObjetsLoaded % 10 == 0)\r\n\t\t\t{\r\n\t\t\t\tfloat progress = (static_cast(loaddata.NbObjetsLoaded) / static_cast(loaddata.NbObjetsToLoad)) ; \r\n\t\t\t\tprogress *=100;\r\n\t\t\t\tint out = static_cast(progress);\r\n\t\t\t\tXString percStr;\r\n\t\t\t\tpercStr.Format(\"Load... %d %s\",out,\"%\");\r\n\t\t\t\tif (xSplash::GetSplash())\r\n\t\t\t\t{\r\n\t\t\t\t\tGetPlayer().SetSplashText(percStr.Str());\r\n\t\t\t\t\tif (progress > 99.9F)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tGetPlayer().HideSplash();\r\n\t\t\t\t\t\t//Sleep(3000);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CK_OK; \r\n}\r\nvoid CCustomPlayer::Reset()\r\n{\r\n\t// mark the player as playing\r\n\tm_State = ePlaying;\r\n\t// reset\r\n\tm_CKContext->Reset();\r\n\t// and play\r\n\tm_CKContext->Play();\r\n}\r\nvoid CCustomPlayer::Pause()\r\n{\r\n\t// mark the play as paused\r\n\tm_State = ePlaused;\r\n\t// pause\r\n\tm_CKContext->Pause();\r\n}\r\n\r\nvoid CCustomPlayer::Play()\r\n{\r\n\t// mark the player as playing\r\n\tm_State = ePlaying;\r\n\t// play\r\n\tm_CKContext->Play();\r\n}\r\n\r\nBOOL CCustomPlayer::Process(int iConfig)\r\n{\r\n\t// just to be sure we check the player is ready and playing\r\n\tif (!m_CKContext || !m_CKContext->IsPlaying()) {\r\n\t\tSleep(10);\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\tfloat beforeRender\t= 0;\r\n\tfloat beforeProcess\t= 0;\r\n\t// retrieve the time to wait in milliseconds to perfom a rendering or a process loop\r\n\t// so that the time manager limits are respected.\r\n\tm_TimeManager->GetTimeToWaitForLimits(beforeRender,beforeProcess);\r\n\r\n\tif (beforeProcess<=0) {\r\n\t\t// ok to process\r\n\t\tm_TimeManager->ResetChronos(FALSE,TRUE);\r\n\t\tm_CKContext->Process();\r\n\t}\r\n\r\n\tif (beforeRender<=0) {\r\n\t\t// ok to render\r\n\t\tm_TimeManager->ResetChronos(TRUE,FALSE);\r\n\t\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t\t\tm_RenderContext->Render();\r\n\t}\r\n\r\n\t// now we check if the composition has not change the state of a \"control\" attribute\r\n\r\n\t// quit has been set\r\n\tif (m_Level->HasAttribute(m_QuitAttType)) {\r\n\t\t// we remove it (so it is not \"here\" the next frame)\r\n\t\tm_Level->RemoveAttribute(m_QuitAttType);\r\n//\t\tMessageBox(NULL,\"\",\"a\",1);\r\n\t\t// and return FALSE to quit\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\t// switch fullscreen has been set\r\n\tif (m_Level->HasAttribute(m_SwitchFullscreenAttType)) \r\n\t{\r\n\t\t//bool goFS;// = vtTools::AttributeTools::GetValueFromAttribute(m_Level,m_SwitchFullscreenAttType);\r\n\t\t/*CKParameterOut* pout = m_Level->GetAttributeParameter(m_SwitchFullscreenAttType);\r\n\t\tif (!pout) {\r\n\t\t\treturn FALSE;\r\n\t\t}*/\r\n\t\t// we remove it (so it is not \"here\" the next frame)\r\n\t\tm_Level->RemoveAttribute(m_SwitchFullscreenAttType);\r\n\t\t// and switch fullscreen (ie goes from fullscreen to windowed\r\n\t\t// or to windowed from fullscreen)\r\n//\t\tif(goFS)\r\n\t\tif (GetPlayer().GetPAppStyle()->IsRenderering())\r\n\t\t\tSwitchFullscreen();\r\n\r\n\t}\r\n\r\n\t// switch resolution has been set\r\n\tif (m_Level->HasAttribute(m_SwitchResolutionAttType)) {\r\n\t\t// we remove it (so it is not \"here\" the next frame)\r\n\t\tm_Level->RemoveAttribute(m_SwitchResolutionAttType);\r\n\t\t// and we change the resolution\r\n\t\tChangeResolution();\r\n\t}\r\n\r\n\t// switch resolution has been set\r\n\tif (m_Level->HasAttribute(m_SwitchMouseClippingAttType)) {\r\n\t\t// we remove it (so it is not \"here\" the next frame)\r\n\t\tm_Level->RemoveAttribute(m_SwitchMouseClippingAttType);\r\n\t\tm_MouseClipped = !m_MouseClipped;\r\n\t\tClipMouse(m_MouseClipped);\r\n\t}\r\n\r\n\treturn TRUE;\r\n}\r\n\r\n#pragma once\r\n\r\n#include \"StdAfx2.h\"\r\n#include \"VIControls.h\"\r\n#include \"ParameterDialog.h\"\r\n//#include \"CUIKNotificationReceiver.h\"\r\n\r\n//--- Include \"GenericObjectParameterDialog.h\" from CK2UI define IDDs to mak it compile\r\n\r\n\r\n#include \"resource.h\"\r\n#include \"PCommonDialog.h\"\r\n#include \"afxwin.h\"\r\n\r\n\r\n//--- Some constants\r\n#define MFC_NAME_OF_DIALOG \"#32770\"\r\n#define CHECK_MATERIAL_TIMER 57\r\n\r\nclass CPBodyCfg : public CParameterDialog\r\n{\r\n\r\npublic:\r\n\r\n\t//\tvirtual void PreSubclassWindow();\r\n\r\n\tint\t\t\t\t\tm_paramType;\r\n\r\n\tCPBodyCfg(CKParameter* Parameter,CK_CLASSID Cid=CKCID_OBJECT);\r\n\tvirtual ~CPBodyCfg();\r\n\tvoid _destroy();\r\n\r\n\t//virtual BOOL Create(UINT nIDTemplate, CWnd* pParentWnd);\r\n\tvirtual void Init(CParameterDialog *parent);\r\n\t\r\n\tCParameterDialog* refresh(CKParameter*src);\r\n\tvoid initSplitter();\r\n\r\n\t/************************************************************************/\r\n\t/* Overrides \r\n\t*/\r\n\t/************************************************************************/\r\n\tvoid OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);\r\n\tLRESULT OnRegisteredMouseWheel(WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Accessors */\r\n\t/************************************************************************/\r\n\tCKParameter * getEditedParameter() const { return mParameter; }\r\n\tvoid setEditedParameter(CKParameter * val) { mParameter= val; }\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Virtools mParameter transfer callbacks : */\r\n\t/************************************************************************/\r\n\tvirtual BOOL On_UpdateFromParameter(CKParameter* p){\r\n\r\n\t\t\t//\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\t\t//\t\tif(!p) return FALSE;\r\n\r\n\t\t\treturn TRUE;\r\n\t\t}\r\n\r\n\t\tvirtual BOOL On_UpdateToParameter(CKParameter* p)\r\n\t\t{\r\n\r\n\t\t\t/*\r\n\t\t\tif(!p) p = (CKParameterOut *)CKGetObject(m_EditedParameter);\r\n\t\t\tif(!p) return FALSE;\r\n\t\t\tCString cstr;*/\r\n\t\t\treturn TRUE;\r\n\r\n\t\t}\r\n\t\r\n\t\t\r\n\r\n\t// associated resource id :\r\n\tenum { IDD = IDD_PBCOMMON };\r\n\r\n\r\n\tvirtual int OnSelect(int before=-1);\r\n\t\r\n\t\r\n\t\r\n\t//{{AFX_VIRTUAL(CPBodyCfg)\r\nprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n\r\n\t//{{AFX_MSG(CPBodyCfg)\r\n\t\r\n\t//}}AFX_MSG\r\n\r\npublic:\r\n\r\n\tCParameterDialog *dlgDeformableSettings;\r\n\t//VITrackCtrl mTestViControl;\r\n\t//VITreeCtrl mTestViControl;\r\n\tVITabCtrl mTestViControl;\r\n\tCParameterDialog *mParent;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Low Level passes */\r\n\t/************************************************************************/\r\n\tLRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* Members */\r\n\t/************************************************************************/\r\n\r\n\r\n\t//\t\tHull Type \r\n\r\n\tVIComboBox HType;\t\tVIStaticText LBL_HType;\r\n\t\r\n\tvoid fillHullType();\r\n\t\r\n\t\r\n\r\n\t//\t\tBody main Flags \r\n\r\n\tVIStaticText LBL_Flags;\t\r\n\r\n\tVICheckButton\t\t\tBF_Move;\r\n\tVICheckButton\t\t\tBF_Grav;\r\n\tVICheckButton\t\t\tBF_Collision;\r\n\tVICheckButton\t\t\tBF_CollisionNotify;\r\n\r\n\tVICheckButton\t\t\tBF_Kinematic;\r\n\tVICheckButton\t\t\tBF_TriggerShape;\r\n\tVICheckButton\t\t\tBF_SubShape;\r\n\tVICheckButton\t\t\tBF_Sleep;\r\n\tVICheckButton\t\t\tBF_Hierarchy;\r\n\r\n\tVICheckButton\t\t\tBF_Deformable;\r\n\r\n\tVIStaticRectangle\t\tBF_BG_Rect;\r\n\tVIStaticRectangle\t\tBF_FLEX_Rect;\r\n\r\n\tvoid fillFlags();\r\n\r\n\t//\t\t\tTransformation Lock Flags\r\n\r\n\tVIStaticText LBL_TransformationLockFlags;\r\n\tVICheckButton\t\t\tTF_POS;\r\n\tVICheckButton\t\t\tTF_ROT;\r\n\tVICheckButton\t\t\tTF_PX;\t\tVICheckButton\t\t\tTF_RX;\r\n\tVICheckButton\t\t\tTF_PY;\t\tVICheckButton\t\t\tTF_RY;\r\n\tVICheckButton\t\t\tTF_PZ;\t\tVICheckButton\t\t\tTF_RZ;\r\n\r\n\r\n\tvoid fillTransformationFlags();\r\n\r\n\r\npublic:\r\n\r\n\r\n\tCKParameter *mParameter;\r\n\tVIEdit editValue;\r\n\tVIStaticText textValue;\r\n\tVIComboBox\t\t\ttype;\r\n\r\n\tDECLARE_MESSAGE_MAP()\r\n\r\n\tafx_msg void OnTcnSelchangeMaintab(NMHDR *pNMHDR, LRESULT *pResult);\r\n\tCComboBox UserLevel;\r\n\tafx_msg void OnCbnSelchangeHulltype2();\r\n\tafx_msg void OnStnClickedLblFlags();\r\n\tafx_msg void OnStnClickedDynaFlagsRect();\r\n};\r\n\r\ncopy /y .\\examples\\*.cmo .\\doxyOutput\\html\r\n\r\ndoxygen .\\doxyConfigPagesOnly.dox\r\ncd .\\doxyOutput\\\r\nvtPhysX.CHM\r\n\r\n\r\n\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmod_vtAgeia\\Doc /y\r\nREM copy X:\\ProjectRoot\\vdev\\Documentation\\vtAgeia.CHM X:\\ProjectRoot\\vtmodsvn\\Plugins\\vtAgeia\\Documentation /y\r\nREM exit\r\nimport vt\r\n\r\n\r\ndef init():\r\n print(\"initiated\")\r\n vt.ActivateOut(bid,0,1)\r\n\r\ndef loop():\r\n print(\"loop in activated\")\r\n vt.ActivateOut(bid,1,1)\r\n\r\n#--------------------------- PyFuncEx enters here : -------------------------------#\r\n\r\ndef vTest():\r\n #-------call init when the first bb input is triggered :\r\n if vt.IsInputActive(bid,0) : \r\n init()\r\n \r\n #-------call loop when the second bb input is triggered :\r\n if vt.IsInputActive(bid,1) : \r\n loop()#ifndef __vtDistributedProperty_h_\r\n#define __vtDistributedProperty_h_\r\n\r\nclass vtDistributedProperty\r\n{\r\n\tpublic:\r\n\r\n\t\tvtDistributedProperty();\r\n\t\tvtDistributedProperty(int type);\r\n\t\tvirtual ~vtDistributedProperty();\r\n\r\n\t\tXString GetName() const { return m_Name; }\r\n\t\tvoid SetName(XString val) { m_Name = val; }\r\n\r\n\t\tDWORD GetType() const { return m_Type; }\r\n\t\tvoid SetType(DWORD val) { m_Type = val; }\r\n\r\n\tprotected:\r\n\t\tXString m_Name;\r\n\t\tDWORD m_Type;\r\n\t\t\r\n\tprivate:\r\n};\r\n#endif/*\n * Tcp4u v 3.31 Last Revision 27/02/1998 3.30.02\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: util.c\n * Purpose: A few utilities functions\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n/* this definition will be enough for our use */\n#undef toupper\n#define toupper(x) ( (x) & 0xDF )\n\n\n\n/* ------------------------------------------------------------------------- */\n/* Conversion d'un nom de machine en adresse IP */\n/* Le nom est soit une \"dotted address\" soit un alias */ \n/* return : INADDR_NONE or IP address\t\t\t\t\t\t\t\t\t\t */ \n/* ------------------------------------------------------------------------- */\nstruct in_addr Tcp4uGetIPAddr (LPCSTR szHost)\n{\nstruct hostent far * lpHostEnt;\nstruct in_addr sin_addr;\n\n Tcp4uLog (LOG4U_INTERN, \"Tcp4uGetIPAddr host %s\", szHost);\n\n sin_addr.s_addr = inet_addr (szHost); /* doted address */\n if (sin_addr.s_addr==INADDR_NONE) /* si pas une doted address */\n { /* regarder le fichier hosts */\n Tcp4uLog (LOG4U_CALL, \"gethostbyname host %s\", szHost);\n lpHostEnt = gethostbyname (szHost);\n if (lpHostEnt!=NULL)\n memcpy (& sin_addr.s_addr, lpHostEnt->h_addr, lpHostEnt->h_length);\n else \n {\n Tcp4uLog (LOG4U_ERROR, \"gethostbyname host %s\", szHost);\n }\n\n }\nreturn sin_addr;\n} /* Tcp4uGetIPAddr */\n\n\n\n/* -------------------------------------- */\n/* a self-made atoi */\n/* -------------------------------------- */\n\n/* Note: ne pas utiliser la fonction isdigit: qui donne des */\n/* resultats errones en Windows */\n#define IsDigit(x) ( (x)>='0' && (x)<='9')\n\n\nint Tcp4uAtoi (LPCSTR p)\n{\nint n;\n Tcp4uLog (LOG4U_INTERN, \"Tcp4uAtoi\");\n\n for (n=0 ; IsDigit (*p) ; p++)\n {\n n *= 10;\n n += (*p - '0');\n }\nreturn n; \n} /* tcp4u_atoi */\n\n\nlong Tcp4uAtol (LPCSTR p)\n{\nlong n;\n Tcp4uLog (LOG4U_INTERN, \"Tcp4uAtol\");\n\n for (n=0 ; IsDigit (*p) ; p++)\n {\n n *= 10;\n n += (*p - '0');\n }\nreturn n; \n} /* Tcp4uAtol */\n\n\n/* a unix function which is not available under Windows */\n/* should have same proto than strncmp */\n/* adapted from the GNU strncasecmp */\nint Tcp4uStrncasecmp (LPCSTR s1, LPCSTR s2, size_t n)\n{\nchar c1, c2;\n for ( ; n!=0 ; --n)\n {\n c1 = *s1++;\n c2 = *s2++;\n if (toupper (c1)!=toupper(c2)) return toupper (c1) - toupper(c2);\n if (c1==0) return 0;\n }\nreturn 0;\n} /* Strncasecmp */\n\n/* ------------------------------------------------------------------------- */\n/* a case-insentive strstr */\n/* ------------------------------------------------------------------------- */\nLPSTR Tcp4uStrIStr (LPCSTR s1, LPCSTR s2)\n{\nsize_t nLength = Strlen(s2);\n for (;;)\n {\n while (*s1!=0 && toupper(*s1)!=toupper(*s2) ) s1++;\n if (*s1==0) return NULL;\n if (Tcp4uStrncasecmp (s1, s2, nLength)==0) return (LPSTR) s1;\n s1++;\n }\n} /* Tcp4uStrIStr */\n#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n#include \"resourceplayer.h\"\r\n\r\n#include \"CustomPlayerDialogGraphicPage.h\"\r\n#include \"CustomPlayerDialog.h\"\r\n\r\n#ifdef _DEBUG\r\n#undef THIS_FILE\r\nstatic char BASED_CODE THIS_FILE[] = __FILE__;\r\n#endif\r\n\r\nextern void _UpdateResolutionLists(HWND hwndDlg,int DriverId);\r\n\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CStylePage dialog\r\n\r\n\r\n\r\nCustomPlayerDialogGraphicPage::CustomPlayerDialogGraphicPage() : CPropertyPage(CustomPlayerDialogGraphicPage::IDD)\r\n, m_FullScreen(FALSE)\r\n, m_FSSA(0)\r\n{\r\n\t//{{AFX_DATA_INIT(CStylePage)\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tCPropertyPage::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(CStylePage)\r\n\t//}}AFX_DATA_MAP\r\n\tDDX_Control(pDX, IDC_CB_WMODES, m_windowMode);\r\n\tDDX_Control(pDX, IDC_DRIVER_LIST, m_Driver);\r\n\tDDX_Control(pDX, IDC_CB_FMODE, m_FModes);\r\n\tDDX_Control(pDX, IDC_CB_BPPS, m_Bpps);\r\n\tDDX_Control(pDX, IDC_CB_RRATES, m_RRates);\r\n\t\r\n\tDDX_Control(pDX, IDC_CHECKB_FULLSCREEN, m_FullScreenBtn);\r\n\tDDX_Control(pDX, IDC_CB_FSSA, m_CB_FSSA);\r\n\r\n}\r\n\r\n\r\n\r\nBEGIN_MESSAGE_MAP(CustomPlayerDialogGraphicPage, CPropertyPage)\r\n\t//{{AFX_MSG_MAP(CStylePage)\r\n\t\t// NOTE: the ClassWizard will add message map macros here\r\n\t//}}AFX_MSG_MAP\r\n\tON_LBN_SELCHANGE(IDC_DRIVER_LIST, OnLbnSelchangeDriverList)\r\n\tON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)\r\n\tON_CBN_SELCHANGE(IDC_CB_FMODE, OnCbnSelchangeCbFmode)\r\n\tON_CBN_SELCHANGE(IDC_CB_BPPS, OnCbnSelchangeCbBpps)\r\n\tON_CBN_SELCHANGE(IDC_CB_RRATES, OnCbnSelchangeCbRrates)\r\n\tON_BN_CLICKED(IDC_CHECKB_FULLSCREEN, OnBnClickedCheckbFullscreen)\r\n\tON_CBN_SELCHANGE(IDC_CB_FSSA, OnCbnSelchangeCbFssa)\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// CStylePage message handlers\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnLbnSelchangeDriverList()\r\n{\r\n m_Bpps.ResetContent();\r\n\tm_RRates.ResetContent();\r\n\tm_windowMode.ResetContent();\r\n\tm_FModes.ResetContent();\r\n\t\r\n\t_UpdateResolutionLists(NULL, m_Driver.GetCurSel());\r\n\t\r\n\r\n\tSetModified();\r\n\t\r\n\t// TODO: Add your control notification handler code here\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnCbnSelchangeCombo1()\r\n{\r\n\r\n\tSetModified();\r\n\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnCbnSelchangeCbFmode()\r\n{\r\n\tSetModified();\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnCbnSelchangeCbBpps()\r\n{\r\n\r\n\tSetModified();\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnCbnSelchangeCbRrates()\r\n{\r\n\r\n\tSetModified();\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnBnClickedCheckbFullscreen()\r\n{\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tewinfo->g_GoFullScreen = m_FullScreenBtn.GetCheck();\r\n\r\n\tif (ewinfo->g_GoFullScreen)\r\n\t{\r\n\t\tif (ewinfo->g_FullScreenDriver < m_Driver.GetCount() )\r\n\t\t{\r\n\t\t\tm_Driver.SetCurSel( ewinfo->g_FullScreenDriver );\r\n\t\t}\r\n\t}else\r\n\t{\r\n\t\tif (ewinfo->g_WindowedDriver < m_Driver.GetCount() )\r\n\t\t{\r\n\t\t\tm_Driver.SetCurSel( ewinfo->g_WindowedDriver );\r\n\t\t}\r\n\t}\r\n\tSetModified();\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnCbnSelchangeCbFssa()\r\n{\r\n\tSetModified();\r\n}\r\n\r\nvoid CustomPlayerDialogGraphicPage::OnOK()\r\n{\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString bpp;\r\n\tm_Bpps.GetLBText(m_Bpps.GetCurSel(),bpp);\r\n\tXString oBpp(bpp);\r\n\tewinfo->g_Bpp = oBpp.ToInt();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString rr;\r\n\tm_RRates.GetLBText(m_RRates.GetCurSel(),rr);\r\n\tXString oRR(rr);\r\n\tewinfo->g_RefreshRate= oRR.ToInt();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString fssa;\r\n\tm_CB_FSSA.GetLBText(m_CB_FSSA.GetCurSel(),fssa);\r\n\tXString oFSSA(fssa);\r\n\tewinfo->FSSA= oFSSA.ToInt();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tewinfo->g_GoFullScreen = m_FullScreenBtn.GetCheck();\r\n\tif (ewinfo->g_GoFullScreen)\r\n\t{\r\n\t\tewinfo->g_FullScreenDriver = m_Driver.GetCurSel();\r\n\t}else\r\n\t\tewinfo->g_WindowedDriver = m_Driver.GetCurSel();\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString fmode;\r\n\tm_FModes.GetLBText(m_FModes.GetCurSel(),fmode);\r\n\r\n\r\n\r\n\tXStringTokenizer\ttokizer(fmode, \"x\");\r\n\tconst char*tok = NULL;\r\n\ttok = tokizer.NextToken(tok);\r\n\tXString width(tok);\r\n\ttok = tokizer.NextToken(tok);\r\n\tXString height(tok);\r\n\tewinfo->g_Width = width.ToInt();\r\n\tewinfo->g_Height = height.ToInt();\r\n\r\n\t{\r\n\r\n\t\tCString wmode;\r\n\t\tm_windowMode.GetLBText(m_windowMode.GetCurSel(),wmode);\r\n\t\tXStringTokenizer\ttokizer(wmode, \"x\");\r\n\t\tconst char*tok = NULL;\r\n\t\ttok = tokizer.NextToken(tok);\r\n\t\tXString width(tok);\r\n\t\ttok = tokizer.NextToken(tok);\r\n\t\tXString height(tok);\r\n\t\tewinfo->g_WidthW = width.ToInt();\r\n\t\tewinfo->g_HeightW = height.ToInt();\r\n\t}\r\n\r\n\t//GetApp()->PSaveEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE,*GetPlayer().GetEngineWindowInfo());\r\n\t\r\n}#ifndef __P_CONFIG_H__\n#define __P_CONFIG_H__\n\n\n#define SESSION_MAX 9000000\n\n#define START_MONTH 7\n#define END_MONTH 12\n/*\n//////////////////////////////////////////////////////////////////////////\n#if defined (ReleaseDemo)\n\t#define SESSION_LIMIT\n\t#define MONTH_LIMIT\n\t#ifndef AUTHOR\n\t\t#define AUTHOR\n\t#endif\n\t#define DEMO_ONLY \n\n#endif\n\n\n#if defined (ReleaseFree)\n\t#define MONTH_LIMIT\n\t#define AUTHOR\n#endif\n\n\n#if defined (ReleaseRedist)\n\t#define REDIST\n\t#undef DEMO_ONLY\n#endif\n\n\n#if defined (ReleaseDongle)\n\t#define DONGLE_VERSION\n\t#undef DEMO_ONLY\n#endif\n\n*/\n\n#endif//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_GHOSTCONNECTION_H_\n#define _TNL_GHOSTCONNECTION_H_\n\n#ifndef _TNL_EVENTCONNECTION_H_\n#include \"tnlEventConnection.h\"\n#endif\n\n#ifndef _TNL_RPC_H_\n#include \"tnlRPC.h\"\n#endif\n\nnamespace TNL {\n\nstruct GhostInfo;\n\n/// GhostConnection is a subclass of EventConnection that manages the transmission\n/// (ghosting) and updating of NetObjects over a connection.\n///\n/// The GhostConnection is responsible for doing scoping calculations (on the server side)\n/// and transmitting most-recent ghost information to the client.\n///\n/// Ghosting is the most complex, and most powerful, part of TNL's capabilities. It\n/// allows the information sent to clients to be very precisely matched to what they need, so that\n/// no excess bandwidth is wasted. Each GhostConnection has a scope object that is responsible\n/// for determining what other NetObject instances are relevant to that connection's client. Each time\n/// GhostConnection sends a packet, NetObject::performScopeQuery() is called on the scope object, which\n/// calls GhostConnection::objectInScope() for each relevant object.\n///\n/// Each object that is in scope, and in need of update (based on its maskbits) is given a priority\n/// ranking by calling that object's getUpdatePriority() method. The packet is then filled with\n/// updates, ordered by priority. This way the most important updates get through first, with less\n/// important updates being sent as space is available.\n///\n/// There is a cap on the maximum number of ghosts that can be active through a GhostConnection at once.\n/// The enum GhostIdBitSize (defaults to 10) determines how many bits will be used to transmit the ID for\n/// each ghost, so the maximum number is 2^GhostIdBitSize or 1024. This can be easily raised; see the\n/// GhostConstants enum.\n///\n/// Each object ghosted is assigned a ghost ID; the client is only aware of the ghost ID. This acts\n/// to enhance simulation security, as it becomes difficult to map objects from one connection to another,\n/// or to reliably identify objects from ID alone. IDs are also reassigned based on need, making it hard\n/// to track objects that have fallen out of scope (as any object which the player shouldn't see would).\n///\n/// resolveGhost() is used on the client side, and resolveObjectFromGhostIndex() on the server side, to\n/// convert ghost IDs to object references.\n///\n/// @see NetObject for more information on network object functionality.\nclass GhostConnection : public EventConnection\n{\n typedef EventConnection Parent;\n friend class ConnectionMessageEvent;\npublic:\n /// GhostRef tracks an update sent in one packet for the ghost of one NetObject.\n ///\n /// When we are notified that a pack is sent/lost, this is used to determine what\n /// updates need to be resent and so forth.\n struct GhostRef\n {\n U32 mask; ///< The mask of bits that were updated in this packet\n U32 ghostInfoFlags; ///< GhostInfo::Flags bitset, determes if the ghost is in a\n /// special processing mode (created/deleted)\n GhostInfo *ghost; ///< The ghost information for the object on the connection that sent\n /// the packet this GhostRef is attached to\n GhostRef *nextRef; ///< The next ghost updated in this packet\n GhostRef *updateChain; ///< A pointer to the GhostRef on the least previous packet that\n /// updated this ghost, or NULL, if no prior packet updated this ghost\n };\n\n /// Notify structure attached to each packet with information about the ghost updates in the packet\n struct GhostPacketNotify : public EventConnection::EventPacketNotify\n {\n GhostRef *ghostList; ///< list of ghosts updated in this packet\n GhostPacketNotify() { ghostList = NULL; }\n };\n\nprotected:\n\n /// Override of EventConnection's allocNotify, to use the GhostPacketNotify structure.\n PacketNotify *allocNotify() { return new GhostPacketNotify; }\n\n /// Override to properly update the GhostInfo's for all ghosts that had upates in the dropped packet.\n void packetDropped(PacketNotify *notify);\n\n /// Override to update flags associated with the ghosts updated in this packet.\n void packetReceived(PacketNotify *notify);\n\n /// Performs the scoping query in order to determine if there is data to send from this GhostConnection.\n void prepareWritePacket();\n\n /// Override to write ghost updates into each packet.\n void writePacket(BitStream *bstream, PacketNotify *notify);\n\n /// Override to read updated ghost information from the packet stream.\n void readPacket(BitStream *bstream);\n\n /// Override to check if there is data pending on this GhostConnection.\n bool isDataToTransmit();\n\n//----------------------------------------------------------------\n// ghost manager functions/code:\n//----------------------------------------------------------------\n\npublic:\n GhostInfo **mGhostArray; ///< Array of GhostInfo structures used to track all the objects ghosted by this side of the connection.\n ///\n /// For efficiency, ghosts are stored in three segments - the first segment contains GhostInfos\n /// that have pending updates, the second ghostrefs that need no updating, and last, free\n /// GhostInfos that may be reused.\n\n S32 mGhostZeroUpdateIndex; ///< Index in mGhostArray of first ghost with 0 update mask (ie, with no updates).\n S32 mGhostFreeIndex; ///< index in mGhostArray of first free ghost.\n\n bool mGhosting; ///< Am I currently ghosting objects over?\n bool mScoping; ///< Am I currently allowing objects to be scoped?\n U32 mGhostingSequence; ///< Sequence number describing this ghosting session.\n\n NetObject **mLocalGhosts; ///< Local ghost array for remote objects, or NULL if mGhostTo is false.\n\n GhostInfo *mGhostRefs; ///< Allocated array of ghostInfos, or NULL if mGhostFrom is false.\n GhostInfo **mGhostLookupTable; ///< Table indexed by object id->GhostInfo, or NULL if mGhostFrom is false.\n\n SafePtr mScopeObject; ///< The local NetObject that performs scoping queries to determine what\n /// objects to ghost to the client.\n\n void clearGhostInfo();\n void deleteLocalGhosts();\n bool validateGhostArray();\n\n void freeGhostInfo(GhostInfo *);\n\n /// Notifies subclasses that the remote host is about to start ghosting objects.\n virtual void onStartGhosting(); \n\n /// Notifies subclasses that the server has stopped ghosting objects on this connection.\n virtual void onEndGhosting();\n\npublic:\n GhostConnection();\n ~GhostConnection();\n\n void setGhostFrom(bool ghostFrom); ///< Sets whether ghosts transmit from this side of the connection.\n void setGhostTo(bool ghostTo); ///< Sets whether ghosts are allowed from the other side of the connection.\n\n bool doesGhostFrom() { return mGhostArray != NULL; } ///< Does this GhostConnection ghost NetObjects to the remote host?\n bool doesGhostTo() { return mLocalGhosts != NULL; } ///< Does this GhostConnection receive ghosts from the remote host?\n\n /// Returns the sequence number of this ghosting session.\n U32 getGhostingSequence() { return mGhostingSequence; }\n\n enum GhostConstants {\n GhostIdBitSize = 10, ///< Size, in bits, of the integer used to transmit ghost IDs\n GhostLookupTableSizeShift = 10, ///< The size of the hash table used to lookup source NetObjects by remote ghost ID is 1 << GhostLookupTableSizeShift.\n\n MaxGhostCount = (1 << GhostIdBitSize), ///< Maximum number of ghosts that can be active at any one time.\n GhostCountBitSize = GhostIdBitSize + 1, ///< Size of the field needed to transmit the total number of ghosts.\n\n GhostLookupTableSize = (1 << GhostLookupTableSizeShift), ///< Size of the hash table used to lookup source NetObjects by remote ghost ID.\n GhostLookupTableMask = (GhostLookupTableSize - 1), ///< Hashing mask for table lookups.\n\n };\n\n void setScopeObject(NetObject *object); ///< Sets the object that is queried at each packet to determine\n /// what NetObjects should be ghosted on this connection.\n NetObject *getScopeObject() { return (NetObject*)mScopeObject; }; ///< Returns the current scope object.\n\n void objectInScope(NetObject *object); ///< Indicate that the specified object is currently in scope.\n ///\n /// Method called by the scope object to indicate that the specified object is in scope.\n void objectLocalScopeAlways(NetObject *object); ///< The specified object should be always in scope for this connection.\n void objectLocalClearAlways(NetObject *object); ///< The specified object should not be always in scope for this connection.\n\n NetObject *resolveGhost(S32 id); ///< Given an object's ghost id, returns the ghost of the object (on the client side).\n NetObject *resolveGhostParent(S32 id); ///< Given an object's ghost id, returns the source object (on the server side).\n void ghostPushNonZero(GhostInfo *gi); ///< Moves the specified GhostInfo into the range of the ghost array for non-zero updateMasks.\n void ghostPushToZero(GhostInfo *gi); ///< Moves the specified GhostInfo into the range of the ghost array for zero updateMasks.\n void ghostPushZeroToFree(GhostInfo *gi); ///< Moves the specified GhostInfo into the range of the ghost array for free (unused) GhostInfos.\n inline void ghostPushFreeToZero(GhostInfo *info); ///< Moves the specified GhostInfo from the free area into the range of the ghost array for zero updateMasks.\n\n S32 getGhostIndex(NetObject *object); ///< Returns the client-side ghostIndex of the specified server object, or -1 if the object is not available on the client.\n\n /// Returns true if the object is available on the client.\n bool isGhostAvailable(NetObject *object) { return getGhostIndex(object) != -1; }\n\n void resetGhosting(); ///< Stops ghosting objects from this GhostConnection to the remote host, which causes all ghosts to be destroyed on the client.\n void activateGhosting(); ///< Begins ghosting objects from this GhostConnection to the remote host, starting with the GhostAlways objects.\n bool isGhosting() { return mGhosting; } ///< Returns true if this connection is currently ghosting objects to the remote host.\n\n void detachObject(GhostInfo *info); ///< Notifies the GhostConnection that the specified GhostInfo should no longer be scoped to the client.\n\n /// RPC from server to client before the GhostAlwaysObjects are transmitted\n TNL_DECLARE_RPC(rpcStartGhosting, (U32 sequence));\n\n /// RPC from client to server sent when the client receives the rpcGhostAlwaysActivated\n TNL_DECLARE_RPC(rpcReadyForNormalGhosts, (U32 sequence));\n\n /// RPC from server to client sent to notify that ghosting should stop\n TNL_DECLARE_RPC(rpcEndGhosting, ());\n};\n\n//----------------------------------------------------------------------------\n\n/// Each GhostInfo structure tracks the state of a single NetObject's ghost for a single GhostConnection.\nstruct GhostInfo\n{\n // NOTE:\n // if the size of this structure changes, the\n // NetConnection::getGhostIndex function MUST be changed\n // to reflect.\n\n NetObject *obj; ///< The real object on the server.\n U32 updateMask; ///< The current out-of-date state mask for the object for this connection.\n GhostConnection::GhostRef *lastUpdateChain; ///< The GhostRef for this object in the last packet it was updated in,\n /// or NULL if that last packet has been notified yet.\n GhostInfo *nextObjectRef; ///< Next GhostInfo for this object in the doubly linked list of GhostInfos across\n /// all connections that scope this object\n GhostInfo *prevObjectRef; ///< Previous GhostInfo for this object in the doubly linked list of GhostInfos across\n /// all connections that scope this object\n\n GhostConnection *connection; ///< The connection that owns this GhostInfo\n GhostInfo *nextLookupInfo; ///< Next GhostInfo in the hash table for NetObject*->GhostInfo*\n U32 updateSkipCount; ///< How many times this object has NOT been updated in writePacket\n\n U32 flags; ///< Current flag status of this object for this connection.\n F32 priority; ///< Priority for the update of this object, computed after the scoping process has run.\n U32 index; ///< Fixed index of the object in the mGhostRefs array for the connection, and the ghostId of the object on the client.\n S32 arrayIndex; ///< Position of the object in the mGhostArray for the connection, which changes as the object is pushed to zero, non-zero and free.\n\n enum Flags\n {\n InScope = BIT(0), ///< This GhostInfo's NetObject is currently in scope for this connection.\n ScopeLocalAlways = BIT(1), ///< This GhostInfo's NetObject is always in scope for this connection.\n NotYetGhosted = BIT(2), ///< This GhostInfo's NetObject has not been sent to or constructed on the remote host.\n Ghosting = BIT(3), ///< This GhostInfo's NetObject has been sent to the client, but the packet it was sent in hasn't been acked yet.\n KillGhost = BIT(4), ///< The ghost of this GhostInfo's NetObject should be destroyed ASAP.\n KillingGhost = BIT(5), ///< The ghost of this GhostInfo's NetObject is in the process of being destroyed.\n\n /// Flag mask - if any of these are set, the object is not yet available for ghost ID lookup.\n NotAvailable = (NotYetGhosted | Ghosting | KillGhost | KillingGhost),\n };\n};\n\n\ninline void GhostConnection::ghostPushNonZero(GhostInfo *info)\n{\n TNLAssert(info->arrayIndex >= mGhostZeroUpdateIndex && info->arrayIndex < mGhostFreeIndex, \"Out of range arrayIndex.\");\n TNLAssert(mGhostArray[info->arrayIndex] == info, \"Invalid array object.\");\n if(info->arrayIndex != mGhostZeroUpdateIndex)\n {\n mGhostArray[mGhostZeroUpdateIndex]->arrayIndex = info->arrayIndex;\n mGhostArray[info->arrayIndex] = mGhostArray[mGhostZeroUpdateIndex];\n mGhostArray[mGhostZeroUpdateIndex] = info;\n info->arrayIndex = mGhostZeroUpdateIndex;\n }\n mGhostZeroUpdateIndex++;\n //TNLAssert(validateGhostArray(), \"Invalid ghost array!\");\n}\n\ninline void GhostConnection::ghostPushToZero(GhostInfo *info)\n{\n TNLAssert(info->arrayIndex < mGhostZeroUpdateIndex, \"Out of range arrayIndex.\");\n TNLAssert(mGhostArray[info->arrayIndex] == info, \"Invalid array object.\");\n mGhostZeroUpdateIndex--;\n if(info->arrayIndex != mGhostZeroUpdateIndex)\n {\n mGhostArray[mGhostZeroUpdateIndex]->arrayIndex = info->arrayIndex;\n mGhostArray[info->arrayIndex] = mGhostArray[mGhostZeroUpdateIndex];\n mGhostArray[mGhostZeroUpdateIndex] = info;\n info->arrayIndex = mGhostZeroUpdateIndex;\n }\n //TNLAssert(validateGhostArray(), \"Invalid ghost array!\");\n}\n\ninline void GhostConnection::ghostPushZeroToFree(GhostInfo *info)\n{\n TNLAssert(info->arrayIndex >= mGhostZeroUpdateIndex && info->arrayIndex < mGhostFreeIndex, \"Out of range arrayIndex.\");\n TNLAssert(mGhostArray[info->arrayIndex] == info, \"Invalid array object.\");\n mGhostFreeIndex--;\n if(info->arrayIndex != mGhostFreeIndex)\n {\n mGhostArray[mGhostFreeIndex]->arrayIndex = info->arrayIndex;\n mGhostArray[info->arrayIndex] = mGhostArray[mGhostFreeIndex];\n mGhostArray[mGhostFreeIndex] = info;\n info->arrayIndex = mGhostFreeIndex;\n }\n //TNLAssert(validateGhostArray(), \"Invalid ghost array!\");\n}\n\ninline void GhostConnection::ghostPushFreeToZero(GhostInfo *info)\n{\n TNLAssert(info->arrayIndex >= mGhostFreeIndex, \"Out of range arrayIndex.\");\n TNLAssert(mGhostArray[info->arrayIndex] == info, \"Invalid array object.\");\n if(info->arrayIndex != mGhostFreeIndex)\n {\n mGhostArray[mGhostFreeIndex]->arrayIndex = info->arrayIndex;\n mGhostArray[info->arrayIndex] = mGhostArray[mGhostFreeIndex];\n mGhostArray[mGhostFreeIndex] = info;\n info->arrayIndex = mGhostFreeIndex;\n }\n mGhostFreeIndex++;\n //TNLAssert(validateGhostArray(), \"Invalid ghost array!\");\n}\n\n};\n\n#endif\n//-----------------------------------------------------------------------------------\n//\n// Torque Network Library\n// Copyright (C) 2004 GarageGames.com, Inc.\n// For more information see http://www.opentnl.org\n//\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// For use in products that are not compatible with the terms of the GNU \n// General Public License, alternative licensing options are available \n// from GarageGames.com.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n//\n//------------------------------------------------------------------------------------\n\n#ifndef _TNL_PLATFORM_H_\n#define _TNL_PLATFORM_H_\n\n#ifndef _TNL_TYPES_H_\n#include \"tnlTypes.h\"\n#endif\n\nnamespace TNL {\n\n/// Platform specific functionality is gathered here to enable easier porting.\n///\n/// If you are embedding TNL in a complex application, you may want to replace\n/// these with hooks to your own code - for instance the alerts really should\n/// bring up an actual message box; currently they just emit a log item.\nnamespace Platform\n{\n /// Prints a string to the OS specific debug log.\n void outputDebugString(const char *string);\n\n /// Stops the program in the debugger, if it is being debugged.\n void debugBreak();\n\n /// Forces the program to exit immediately.\n ///\n /// @note This is probably a bit strong for a networking library. -- BJG\n void forceQuit();\n\n /// Brings up a dialog window with a message and an \"OK\" button\n void AlertOK(const char *windowTitle, const char *message);\n\n /// Brings up a dialog window with the message, and \"OK\" and \"Cancel\" buttons\n bool AlertOKCancel(const char *windowTitle, const char *message);\n\n /// Brings up a dialog window with the message, and \"Retry\" and \"Cancel\" buttons\n bool AlertRetry(const char *windowTitle, const char *message);\n\n /// Elapsed time in milliseconds.\n ///\n /// Usually since last reboot, but it varies from platform to platform. It is\n /// guaranteed to always increase, however, up to the limit of a U32 - about\n /// 7 weeks worth of time. If you are developing a server you want to run for longer\n /// than that, prepared to see wraparounds.\n U32 getRealMilliseconds();\n\n /// Returns a high-precision time value, in a platform-specific time value\n S64 getHighPrecisionTimerValue();\n\n /// Converts a high precision timer delta into milliseconds\n F64 getHighPrecisionMilliseconds(S64 timerDelta);\n\n /// Put the process to sleep for the specified millisecond interva.\n void sleep(U32 msCount);\n\n /// checks the status of the memory allocation heap\n bool checkHeap();\n};\n\n\n#define TIME_BLOCK(name,block) { S64 st = Platform::getHighPrecisionTimerValue(); {block} S64 delta = Platform::getHighPrecisionTimerValue() - st; F64 ms = Platform::getHighPrecisionMilliseconds(delta); /*logprintf(\"Timer: %s Elapsed: %g ms\", #name, ms);*/ }\n\n#if defined (TNL_SUPPORTS_VC_INLINE_X86_ASM) || defined (TNL_SUPPORTS_MWERKS_INLINE_X86_ASM)\n#define TNL_DEBUGBREAK() { __asm { int 3 }; }\n#elif defined(TNL_SUPPORTS_GCC_INLINE_X86_ASM)\n#define TNL_DEBUGBREAK() { asm ( \"int $3\"); }\n#else\n/// Macro to do in-line debug breaks, used for asserts. Does inline assembly where appropriate\n#define TNL_DEBUGBREAK() Platform::debugBreak();\n#endif\n\n#define TNL_CHECK_HEAP() { bool status = TNL::Platform::checkHeap(); if(!status) TNL_DEBUGBREAK(); }\n\nextern bool atob(const char *str); ///< String to boolean conversion.\n\n/// Printf into string with a buffer size.\n///\n/// This will print into the specified string until the buffer size is reached.\nextern int dSprintf(char *buffer, U32 bufferSize, const char *format, ...);\n\n/// Vsprintf with buffer size argument.\n///\n/// This will print into the specified string until the buffer size is reached.\nextern int dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist); ///< compiler independent\n\ninline char dToupper(const char c) { if (c >= char('a') && c <= char('z')) return char(c + 'A' - 'a'); else return c; } ///< Converts an ASCII character to upper case.\ninline char dTolower(const char c) { if (c >= char('A') && c <= char('Z')) return char(c - 'A' + 'a'); else return c; } ///< Converts an ASCII character to lower case.\n\n#define QSORT_CALLBACK FN_CDECL\n\n};\n\n#include \n#include \n\n#if defined (__GNUC__)\n\nint stricmp(const char *str1, const char *str2);\nint strnicmp(const char *str1, const char *str2, unsigned int len);\n\n#endif\n\n\n#endif\n#ifndef __P_CONSTANTS_H__\r\n#define __P_CONSTANTS_H__\r\n\r\n\r\n\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJSetBallDecl();\r\nCKERROR CreateJSetBallProto(CKBehaviorPrototype **pproto);\r\nint JSetBall(const CKBehaviorContext& behcontext);\r\nCKERROR JSetBallCB(const CKBehaviorContext& behcontext);\r\n\r\nenum bbInputs\r\n{\r\n\r\n\tbI_ObjectB,\r\n\tbI_Anchor,\r\n\tbI_AnchorRef,\r\n\tbbI_SwingAxis,\r\n\tbbI_PMode,\r\n\tbbI_PDistance,\r\n\tbbI_Collision,\r\n\tbbI_SwingLimit,\r\n\tbbI_TwistHighLimit,\r\n\tbbI_TwistLowLimit,\r\n\tbbI_SwingSpring,\r\n\tbbI_TwistSpring,\r\n\tbbI_JointSpring\r\n};\r\n\r\n//************************************\r\n// Method: FillBehaviorJSetBallDecl\r\n// FullName: FillBehaviorJSetBallDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJSetBallDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJBall\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Sets/modifies a ball joint.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2df921e4,0x20295f52));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJSetBallProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJSetBallProto\r\n// FullName: CreateJSetBallProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJSetBallProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJBall\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJBall \r\n\r\n\t
\r\n\tPJBall is categorized in \\ref Joints\r\n\t
\r\n\t
See pJBall.cmo.\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates or modifies a sphere joint.\r\n\t
\r\n\t
\r\n\tDOFs removed: 3
\r\n\tDOFs remaining: 3
\r\n\t
\r\n\t\\image html sphericalJoint.png\r\n\t\r\n\tA spherical joint is the simplest kind of joint. It constrains two points on two different bodies from coinciding. \r\n\tThis point, located in world space, is the only parameter that has to be specified (the other parameters are optional). \r\n\tSpecifying the anchor point (point that is forced to coincide) in world space guarantees that the point in the local space of each \r\n\tbody will coincide when the point is transformed back from local into world space. \r\n\r\n\tBy attaching a series of spherical joints and bodies, chains/ropes can be created. \r\n\tAnother example for a common spherical joint is a person's shoulder, which is quite limited in its range of motion.\r\n\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJBall.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\tAnchor:A point in world space coordinates. See pJointBall::setAnchor().\r\n\t
\r\n\tAnchor Reference: A helper entity to transform a local anchor into the world space.\r\n\t
\r\n\tSwing Limt Axis: Limit axis defined in the joint space of body a. See pJointBall::setSwingLimitAxis().\r\n\t
\r\n\tProjection Mode: Joint projection mode. See pJointBall::setProjectionMode() and #ProjectionMode.\r\n\t
\r\n\t
\r\n\tProjection Distance: If any joint projection is used, it is also necessary to set \r\n\t\t\t\tprojectionDistance to a small value greater than zero. When the joint error is larger than projectionDistance the SDK will change it so that the joint error is equal to projectionDistance. Setting projectionDistance too \r\n\t\t\t\tsmall will introduce unwanted oscillations into the simulation.\r\n\t
\r\n\tCollision :Enable Collision. See pJointRevolute::enableCollision().\r\n\t
\r\n\t
\r\n\tSwing Limit: Swing limit of the twist axis.\r\n\t
\r\n\t
\r\n\tTwist High Limit: Higher rotation limit around twist axis. See pJointBall::setTwistHighLimit().\r\n\t
\r\n\t
\r\n\tTwist Low Limit: Lower rotation limit around twist axis. See pJointBall::setTwistLowLimit().\r\n\t
\r\n\t
\r\n\r\n\tSwing Spring: .The spring that works against swinging. See pJointBall::setSwingSpring().\r\n\t
\r\n\r\n\tTwist Spring: .The spring that works against twisting. See pJointBall::setTwistSpring().\r\n\t
\r\n\r\n\tJoint Spring: .The spring that lets the joint get pulled apart. See pJointBall::setJointSpring().\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\r\n\tSwing Limit: Enables parameter input for swing limit.\r\n\t
\r\n\tTwist High Limit: Enables parameter input for high twist limit.\r\n\t
\r\n\tTwist Low Limit: Enables parameter input for low twist limit.\r\n\t
\r\n\tSwing Spring: .Enables parameter input for swing spring.\r\n\t
\r\n\tTwist Spring: .Enables parameter input for twist spring.\r\n\t
\r\n\tJoint Spring: .Enables parameter input for joint spring.\r\n\t
\r\n\r\n\t

Spherical Joint Limits

\r\n\t\r\n\t\tSpherical joints allow limits that can approximate the physical limits of motion on a human arm. \r\n\t\tIt is possible to specify a cone which limits how far the arm can swing from a given axis. \r\n\t\tIn addition, a twist limit can be specified which controls how much the arm is allowed to twist around its own axis.\r\n\r\n\t\\image html sphericalLimits.png\r\n\r\n\tNOTE: There are similar restrictions on the twist limits for spherical joints as there are for revolute joints.\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\t\\include PJSetBall.vsl\r\n\t\r\n\t
\r\n\r\n\t

VSL : Limit Modification


\r\n\t\r\n\t\\include PJSetBallLimits.vsl\r\n\t\r\n\t
\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createJointBall().
\r\n\r\n\t*/\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\tproto->SetBehaviorCallbackFct( JSetBallCB );\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->DeclareInParameter(\"Anchor\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Anchor Reference\",CKPGUID_3DENTITY,\"0.0f\");\r\n\tproto->DeclareInParameter(\"Limit Swing Axis\",CKPGUID_VECTOR,\"0.0f\");\r\n\r\n\tproto->DeclareInParameter(\"Projection Mode\",VTE_JOINT_PROJECTION_MODE,\"0\");\r\n\tproto->DeclareInParameter(\"Projection Distance\",CKPGUID_FLOAT,\"0\");\r\n\tproto->DeclareInParameter(\"Collision\",CKPGUID_BOOL,\"TRUE\");\r\n\r\n\r\n\r\n\tproto->DeclareInParameter(\"Swing Limit\",VTS_JLIMIT,\"\");\r\n\tproto->DeclareInParameter(\"Twist High Limit\",VTS_JLIMIT);\r\n\tproto->DeclareInParameter(\"Twist Low Limit\",VTS_JLIMIT);\r\n\t\r\n\tproto->DeclareInParameter(\"Swing Spring\",VTS_JOINT_SPRING);\r\n\tproto->DeclareInParameter(\"Twist Spring\",VTS_JOINT_SPRING);\r\n\tproto->DeclareInParameter(\"Joint Spring\",VTS_JOINT_SPRING);\r\n\r\n\t\r\n\r\n\tproto->DeclareSetting(\"Swing Limit\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Twist Limit\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\r\n\tproto->DeclareSetting(\"Swing Spring\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Twist Spring\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Joint Spring\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\r\n\r\n\t\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\tproto->SetFunction(JSetBall);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JSetBall\r\n// FullName: JSetBall\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JSetBall(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\r\n\r\n\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Spherical))\r\n\t\t{\r\n\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA && ! worldB )\r\n\t\t{\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\t\t\t\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\r\n\r\n\t\t//anchor : \r\n\t\tVxVector anchor = GetInputParameterValue(beh,bI_Anchor);\r\n\t\tVxVector anchorOut = anchor;\r\n\t\tCK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);\r\n\r\n\t\tif (anchorReference)\r\n\t\t{\r\n\t\t\tanchorReference->Transform(&anchorOut,&anchor);\r\n\t\t}\r\n\r\n\t\t//swing axis\r\n\t\tVxVector swingAxis = GetInputParameterValue(beh,bbI_SwingAxis);\r\n\r\n\t\tProjectionMode mode =GetInputParameterValue(beh,bbI_PMode); \r\n\t\tfloat distance = GetInputParameterValue(beh,bbI_PDistance); \r\n\t\tint coll = GetInputParameterValue(beh,bbI_Collision);\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//swing limit : \r\n\t\tpJointLimit sLimit;\r\n\t\tDWORD swingLimit;\r\n\t\tbeh->GetLocalParameterValue(0,&swingLimit);\r\n\t\tif (swingLimit)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_SwingLimit);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tsLimit = pFactory::Instance()->createLimitFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//twist limit high : \r\n\t\tpJointLimit tLimitH;\r\n\t\tDWORD twistLimit;\r\n\t\tbeh->GetLocalParameterValue(1,&twistLimit);\r\n\t\tif (twistLimit)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_TwistHighLimit);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\ttLimitH = pFactory::Instance()->createLimitFromParameter(rPar);\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//twist limit low : \r\n\t\tpJointLimit tLimitL;\r\n\t\tif (twistLimit)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_TwistLowLimit);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\ttLimitL = pFactory::Instance()->createLimitFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tDWORD swingSpring;\r\n\t\tpSpring sSpring; \r\n\t\tbeh->GetLocalParameterValue(2,&swingSpring);\r\n\t\tif (swingSpring)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_SwingSpring);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\tsSpring = pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tDWORD twistSpring;\r\n\t\tpSpring tSpring; \r\n\t\tbeh->GetLocalParameterValue(3,&twistSpring);\r\n\t\tif (twistSpring)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_TwistSpring);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\ttSpring= pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\tDWORD jointSpring;\r\n\t\tpSpring jSpring;\r\n\t\tbeh->GetLocalParameterValue(4,&jointSpring);\r\n\t\tif (jointSpring)\r\n\t\t{\r\n\t\t\tCKParameterIn *par = beh->GetInputParameter(bbI_JointSpring);\r\n\t\t\tif (par)\r\n\t\t\t{\r\n\t\t\t\tCKParameter *rPar = par->GetRealSource();\r\n\t\t\t\tif (rPar)\r\n\t\t\t\t{\r\n\t\t\t\t\t jSpring = pFactory::Instance()->createSpringFromParameter(rPar);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tpJointBall *joint = static_cast(worldA->getJoint(target,targetB,JT_Spherical));\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//joint create ? \r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createBallJoint(target,targetB,anchorOut,swingAxis));\r\n\t\t\t}\r\n\t\t\t////////////////////////////////////////////////////////////////////////// Modification : \r\n\t\t\tif (joint)\r\n\t\t\t{\r\n\r\n\t\t\t\tjoint->setAnchor(anchorOut);\r\n\t\t\t\tjoint->setSwingLimitAxis(swingAxis);\r\n\t\t\t\tjoint->setProjectionMode(mode);\r\n\t\t\t\tjoint->setProjectionDistance(distance);\r\n\t\t\t\tjoint->enableCollision(coll);\r\n\t\t\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif(swingLimit)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setSwingLimit(sLimit);\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\tjoint->enableFlag(NX_SJF_SWING_LIMIT_ENABLED,swingLimit);\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif (twistLimit)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setTwistHighLimit(tLimitH);\r\n\t\t\t\t\tjoint->setTwistLowLimit(tLimitL);\r\n\t\t\t\t}\r\n\t\t\t\tjoint->enableFlag(NX_SJF_TWIST_LIMIT_ENABLED,twistLimit);\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif (swingSpring)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setSwingSpring(sSpring);\r\n\t\t\t\t}\r\n\t\t\t\tjoint->enableFlag(NX_SJF_SWING_SPRING_ENABLED,swingSpring);\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif (twistSpring)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setTwistSpring(tSpring);\r\n\t\t\t\t}\r\n\t\t\t\tjoint->enableFlag(NX_SJF_TWIST_SPRING_ENABLED,twistSpring);\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tif (jointSpring)\r\n\t\t\t\t{\r\n\t\t\t\t\tjoint->setJointSpring(jSpring);\r\n\t\t\t\t}\r\n\t\t\t\tjoint->enableFlag(NX_SJF_JOINT_SPRING_ENABLED,jointSpring);\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(0);\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JSetBallCB\r\n// FullName: JSetBallCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JSetBallCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\r\n\t\t\tDWORD swingLimit;\r\n\t\t\tbeh->GetLocalParameterValue(0,&swingLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_SwingLimit,swingLimit);\r\n\t\r\n\t\t\tDWORD twistLimit;\r\n\t\t\tbeh->GetLocalParameterValue(1,&twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_TwistHighLimit,twistLimit);\r\n\t\t\tbeh->EnableInputParameter(bbI_TwistLowLimit,twistLimit);\r\n\r\n\t\t\tDWORD springSwing;\r\n\t\t\tbeh->GetLocalParameterValue(2,&springSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_SwingSpring,springSwing);\r\n\r\n\t\t\tDWORD twistSwing;\r\n\t\t\tbeh->GetLocalParameterValue(3,&twistSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_TwistSpring,twistSwing);\r\n\r\n\t\t\tDWORD jointSwing;\r\n\t\t\tbeh->GetLocalParameterValue(4,&jointSwing);\r\n\t\t\tbeh->EnableInputParameter(bbI_JointSpring,jointSwing);\r\n\r\n\t\tbreak;\r\n\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}#ifndef __xDistributedObject_h\r\n#define __xDistributedObject_h\r\n\r\n#include \"xNetObject.h\"\r\n#include \"xNetTypes.h\"\r\n\r\nclass xDistributed3DObject;\r\nclass xDistributedClass;\r\nclass xDistributedProperty;\r\n\r\n\r\n\r\n\r\nclass xDistributedObject : public xNetObject\r\n{\r\n\ttypedef xNetObject Parent;\r\n\tpublic:\r\n\t\txDistributedObject();\r\n\t\tvirtual ~xDistributedObject();\r\n\r\n\t\tenum MaskBits {\n\t\t\tInitialMask = (1 << 0), ///< This mask bit is never set explicitly, so it can be used for initialization data.\n\t\t};\r\n\r\n\t\tint getEntityID() const { return m_EntityID; }\r\n\t\tvoid setEntityID(int val) { m_EntityID = val; }\r\n\t\tint getGhostDebugID() const { return m_GhostDebugID; }\r\n\t\tvoid setGhostDebugID(int val) { m_GhostDebugID = val; }\r\n\r\n\t\tvoid getOwnership();\r\n\r\n\t\txDistributedClass * getDistributedClass() { return m_DistributedClass; }\r\n\t\tvoid setDistributedClass(xDistributedClass * val) { m_DistributedClass = val; }\r\n\r\n\t\tint getObjectFlags() { return m_ObjectFlags; }\r\n\t\tvoid setObjectFlags(int val) { m_ObjectFlags = val; }\r\n\r\n\t\tint getServerID() const { return m_ServerID; }\r\n\t\tvoid setServerID(int val) { m_ServerID = val; }\r\n\r\n\t\tfloat getCreationTime() const { return m_creationTime; }\r\n\t\tvoid setCreationTime(float val) { m_creationTime = val; }\r\n\r\n\r\n\t\tfloat getCreationTimeout() const { return m_creationTimeout; }\r\n\t\tvoid setCreationTimeout(float val) { m_creationTimeout = val; }\r\n\t\t\r\n\t\tint getInterfaceFlags() const { return m_InterfaceFlags; }\r\n\t\tvoid setInterfaceFlags(int val) { m_InterfaceFlags = val; }\r\n\t\t\r\n\t\tint& getUpdateFlags() { return m_UpdateFlags; }\r\n\t\tvoid setUpdateFlags(int val) { m_UpdateFlags = val; }\r\n\r\n\t\tTNL::BitSet32& getUpdateBits() { return m_UpdateBits; }\r\n\t\tvoid setUpdateBits(TNL::BitSet32 val) { m_UpdateBits = val; }\r\n\r\n\t\tTNL::BitSet32& getGhostUpdateBits(){ return m_GhostUpdateBits; }\r\n\t\tvoid setGhostUpdateBits(TNL::BitSet32 val) { m_GhostUpdateBits = val; }\r\n\r\n\r\n\t\tvirtual void writeControlState(xNStream *stream);\r\n\t\tvirtual void readControlState(xNStream * bstream){}\r\n\t\tvirtual void initProperties();\r\n\r\n\t\tvirtual void destroy();\r\n\t\t\r\n\t\txDistributed3DObject *cast(xDistributedObject* _in);\r\n\t\txDistributedPropertyArrayType *m_DistrtibutedPorperties;\r\n\t\txDistributedPropertyArrayType * getDistributedPorperties(){ return m_DistrtibutedPorperties; }\r\n\t\tvoid setDistributedPorperties(xDistributedPropertyArrayType * val) { m_DistrtibutedPorperties = val; }\r\n\r\n\t\tvirtual void pack(xNStream *bstream);\r\n\t\tvirtual void unpack(xNStream *bstream,float sendersOneWayTime);\r\n\t\tvirtual void prepare();\r\n\t\tTNL::U32 getGhostID() const { return mGhostID; }\r\n\t\tvoid setGhostID(TNL::U32 val) { mGhostID = val; }\r\n\t\tint getUpdateState() const { return m_UpdateState; }\r\n\t\tvoid setUpdateState(int val) { m_UpdateState = val; }\r\n\r\n\r\n\r\n\t\tTNL::BitSet32& getOwnershipState() { return m_OwnershipState; }\r\n\t\tvoid setOwnershipState(TNL::BitSet32 val) { m_OwnershipState = val; }\r\n\t\tbool isOwner(){ return getOwnershipState().test( 1<#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedClient.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xDistributedSession.h\"\r\n#include \r\n#include \"xLogger.h\"\r\n#include \"vtLogTools.h\"\r\nCKObjectDeclaration\t*FillBehaviorNServerIsRunningDecl();\r\nCKERROR CreateNServerIsRunningProto(CKBehaviorPrototype **);\r\nint NServerIsRunning(const CKBehaviorContext& behcontext);\r\nCKERROR NServerIsRunningCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n#define BEH_IN_INDEX_MIN_COUNT 2\r\n#define BEH_OUT_MIN_COUNT 3\r\n#define BEH_OUT_MAX_COUNT 1\r\n\r\n\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorNServerIsRunningDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NServerIsRunning\");\t\r\n\tod->SetDescription(\"Checks for the embedded servers state\");\r\n\t\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x3d40087,0xe265210));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateNServerIsRunningProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_IT\r\n{\r\n\tBB_IT_IN,\r\n\tBB_IT_OFF,\r\n\tBB_IT_NEXT,\r\n};\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_ADDRESS,\r\n\tBB_IP_MAXCLIENTS,\r\n\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\tBB_O_OUT,\r\n\tBB_O_ERROR,\r\n\r\n};\r\n\r\ntypedef enum BB_OP\r\n{\r\n\tBB_OP_SERVER_ADDRESS,\r\n\tBB_OP_ERROR\r\n};\r\n\r\n\r\nCKERROR CreateNServerIsRunningProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NServerIsRunning\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Yes\");\r\n\tproto->DeclareOutput(\"No\");\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(NServerIsRunning);\r\n\tproto->SetBehaviorCallbackFct(NServerIsRunningCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint NServerIsRunning(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKParameterManager *pam = static_cast(ctx->GetParameterManager());\r\n\tusing namespace vtTools::BehaviorTools;\r\n\r\n\t\r\n\tif (beh->IsInputActive(0))\r\n\t{\r\n\t\t\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\t\t\r\n\t\txNetInterface *cin = GetNM()->GetServerNetInterface();\r\n\t\tif (cin)\r\n\t\t{\r\n\r\n\t\t\tTNL::Socket *socket = &cin->getSocket();\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tif (socket->isValid())\r\n\t\t\t\t{\r\n\t\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\t\treturn CKBR_OK;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbeh->ActivateOutput(1);\r\n\t\t\r\n\t\t\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR NServerIsRunningCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) \r\n\t{\r\n\t\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}\r\n/* Some code about firewall: This code does not work */\r\n\r\n\r\n#include \r\n#include \r\n\r\n\r\n/* Fin de fonction asynchrone/synchrone */ \r\n#define RETURN(pD,x) \\\r\n { if( (! IsBadWritePtr(pD,sizeof *pD)) && pD->File.bAsyncMode ) \\\r\n { PostMessage(pD->Msg.hParentWnd,pD->Msg.nCompletedMessage,TRUE,x); \\\r\n return FTPERR_OK; } \\\r\n else { return x; } }\r\n#define SizeOfTab(t) ( sizeof (t) / sizeof (t[0]) )\r\n#define TN_SUCCESS 1\r\n\r\n/* -------------------------------------- */\r\n/* debugging info */\r\n/* -------------------------------------- */\r\n#define DBG_FIREWALL +\r\n#ifdef DBG_FIREWALL\r\nstatic void wMsgBox (char *szStr, char *szArg, int nArg)\r\n{\r\nchar szDbg[256];\r\nLPProcData pProcData;\r\n\r\n pProcData = FtpDataPtr();\r\n if (szArg==NULL) wsprintf (szDbg, szStr, nArg);\r\n else if (nArg==11111) wsprintf (szDbg, szStr, szArg);\r\n else wsprintf (szDbg, szStr, szArg, nArg);\r\n MessageBox (pProcData->hParentWnd, szDbg, \"Ftp4w\", MB_OK);\r\n} /* wMsgBox */\r\n#else\r\n# define wMsgBox(a,b,c)\r\n#endif /* DBG_FIREWALL */\r\n\r\n\r\n\r\n/* Note: two undocumented functions are used in this code: */\r\n/* - IntTnSend which sends a message to the remote host on */\r\n/* socket S */\r\n/* - IntFtpGetAnswerCode which waits for an answer from the */\r\n/* server and returns the 3 digits code sent by the server */\r\n\r\nint PASCAL FAR IntFtpGetAnswerCode (LPFtpData pFtpData); \r\nint PASCAL FAR IntTnSend (SOCKET s, LPSTR szString, \r\n BOOL bHighPriority, HFILE hf);\r\n\r\n\r\n/* ------------------------------------------------------------ */\r\n/* Fonction DLL FtpFirewallLogin */\r\n/* ------------------------------------------------------------ */\r\n\r\nstruct S_Firewall\r\n{ \r\n int nType;\r\n BOOL bFWUserPwd;\r\n LPSTR szCmd;\r\n LPSTR szUserStr;\r\n}; /* struct S_Firewall */\r\n\r\nstatic struct S_Firewall sFirewall[] =\r\n{ \r\n { FTP4W_FWSITE, TRUE, \"SITE %s\", \"USER %s\" },\r\n { FTP4W_FWPROXY, FALSE, \"OPEN %s\", \"USER %s\" },\r\n { FTP4W_FWUSERWITHLOGON, TRUE, NULL, \"USER %s@%s\" },\r\n { FTP4W_FWUSERNOLOGON, FALSE, NULL, \"USER %s@%s\" },\r\n}; /* struct S_Firewall sFirewall */\r\n\r\n\r\nint PASCAL FAR FtpFirewallLogin(\r\n LPSTR szFWHost, LPSTR szFWUser, LPSTR szFWPasswd,\r\n LPSTR szRemHost,LPSTR szRemUser,LPSTR szRemPasswd,\r\n int nFirewallType,\r\n HWND hParentWnd, UINT wMsg)\r\n{\r\nint Idx;\r\nint Rc;\r\nLPProcData pProcData;\r\nchar szTnS[256];\r\n\r\n /* Reads data structure */\r\n pProcData = FtpDataPtr ();\r\n if (pProcData == NULL) return FTPERR_NOTINITIALIZED;\r\n \r\n /* The message to be sent in async mode */\r\n pProcData->Msg.nCompletedMessage = wMsg;\r\n pProcData->Msg.hParentWnd = hParentWnd;\r\n /* ýcheck parameters */\r\n if (szFWHost==NULL || szRemHost==NULL) return FTPERR_INVALIDPARAMETER;\r\n /* Get FW structure */\r\n for (Idx=0 ; \r\n Idx= SizeOfTab(sFirewall)) return FTPERR_INVALIDPARAMETER;\r\n wMsgBox (\"Index DB sFirewall: %d\", NULL, Idx);\r\n\r\n /* open connection with firewall */\r\n Rc = FtpOpenConnection (szFWHost);\r\nwMsgBox (\"Retour FtpOpenConnection: %d\", NULL, Rc);\r\n if (Rc==FTPERR_CANTCONNECT) Rc=FTPERR_FWCANTCONNECT;\r\n if (Rc==FTPERR_CONNECTREJECTED) Rc=FTPERR_FWCONNECTREJECTED;\r\n if (Rc!=FTPERR_OK) RETURN (pProcData, Rc);\r\n if (sFirewall[Idx].bFWUserPwd)\r\n {\r\n if (Rc==FTPERR_OK && szFWUser!=NULL) Rc =FtpSendUserName(szFWUser);\r\n if (Rc==FTPERR_ENTERPASSWORD && szFWPasswd!=NULL) \r\n Rc = FtpSendPasswd (szFWPasswd);\r\n if (Rc==FTPERR_LOGINREFUSED) Rc=FTPERR_FWLOGINREFUSED;\r\n if (Rc!=FTPERR_OK) RETURN (pProcData, Rc);\r\nwMsgBox (\"Retour Firewall LOGON: %d\", NULL, Rc);\r\n } /* Log on fiirewall */\r\n \r\n /* Connection with the remote destination */\r\n if (sFirewall[Idx].szCmd!=NULL)\r\n {\r\n wsprintf (szTnS, sFirewall[Idx].szCmd, szRemHost);\r\n Rc = IntTnSend (pProcData->ftp.ctrl_socket, szTnS, \r\n FALSE, pProcData->ftp.hLogFile);\r\n if (Rc!=TN_SUCCESS) RETURN (pProcData, FTPERR_SENDREFUSED)\r\n if ( IntFtpGetAnswerCode (& pProcData->ftp)/100 != 2 )\r\n RETURN (pProcData, FTPERR_CANTCONNECT);\r\n } /* szCmd pas NULL -> SITE ou PROXY */\r\n \r\n /* Authentification */\r\n wsprintf (szTnS, sFirewall[Idx].szUserStr, szRemUser, szRemHost);\r\n Rc = IntTnSend (pProcData->ftp.ctrl_socket, szTnS, \r\n FALSE, pProcData->ftp.hLogFile);\r\n if (Rc!=TN_SUCCESS) RETURN (pProcData, FTPERR_SENDREFUSED)\r\n Rc = IntFtpGetAnswerCode (& pProcData->ftp);\r\nwMsgBox (\"Retour UserStr FWUSER: %d\", NULL, Rc);\r\n /* analyses returned message */\r\n switch (Rc)\r\n {\r\n case 230 : RETURN (pProcData, FTPERR_OK); break;\r\n case 331 : Rc = FtpSendPasswd (szRemPasswd); \r\nwMsgBox (\"Retour UserStr PASSWD: %d\", NULL, Rc);\r\n RETURN (pProcData, Rc); break;\r\n default : RETURN (pProcData, FTPERR_CANTCONNECT);\r\n break;\r\n } /* User */\r\n} /* FtpFirewallLogin */\r\n/********************************************************************\r\n\tcreated:\t2009/02/17\r\n\tcreated:\t17:2:2009 8:14\r\n\tfilename: \tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\include\\core\\Common\\vtParameterSubItemIdentifiers_Joints.h\r\n\tfile path:\tx:\\ProjectRoot\\svn\\local\\vtPhysX\\SDK\\include\\core\\Common \r\n\tfile base:\tvtParameterSubItemIdentifiers_Joints\r\n\tfile ext:\th\r\n\tauthor:\t\t\r\n\t\r\n\tpurpose:\tJoint parameter items for custom structures. \r\n*********************************************************************/\r\n#ifndef __VTPARAMETERSUBITEMIDENTIFIERS_JOINTS_H__\r\n#define __VTPARAMETERSUBITEMIDENTIFIERS_JOINTS_H__\r\n \r\nenum PS_JPOINT_ON_LINE_MEMBERS\r\n{\r\n\tPS_JPOL_BODY_B,\r\n\tPS_JPOL_ANCHOR,\r\n\tPS_JPOL_ANCHOR_REF,\r\n\r\n\tPS_JPOL_AXIS,\r\n\tPS_JPOL_AXIS_REF,\r\n\tPS_JPOL_COLLISION,\r\n\r\n\tPS_JPOL_MAX_FORCE,\r\n\tPS_JPOL_MAX_TORQUE,\r\n};\r\n\r\nenum PS_JPOINT_IN_PLANE_MEMBERS\r\n{\r\n\tPS_JPIP_BODY_B,\r\n\tPS_JPIP_ANCHOR,\r\n\tPS_JPIP_ANCHOR_REF,\r\n\r\n\tPS_JPIP_AXIS,\r\n\tPS_JPIP_AXIS_REF,\r\n\tPS_JPIP_COLLISION,\r\n\r\n\tPS_JPIP_MAX_FORCE,\r\n\tPS_JPIP_MAX_TORQUE,\r\n};\r\n\r\nenum PS_JREVOLUTE\r\n{\r\n\r\n\tPS_JREVOLUTE_BODY_B,\r\n\tPS_JREVOLUTE_ANCHOR,\r\n\tPS_JREVOLUTE_ANCHOR_REF,\r\n\r\n\tPS_JREVOLUTE_AXIS,\r\n\tPS_JREVOLUTE_AXIS_REF,\r\n\tPS_JREVOLUTE_COLLISION,\r\n\r\n\tPS_JREVOLUTE_PROJ_MODE,\r\n\tPS_JREVOLUTE_PROJ_DISTANCE,\r\n\tPS_JREVOLUTE_PROJ_ANGLE,\r\n \r\n\tPS_JREVOLUTE_SPRING,\r\n\tPS_JREVOLUTE_LIMIT_HIGH,\r\n\tPS_JREVOLUTE_LIMIT_LOW,\r\n\tPS_JREVOLUTE_MOTOR,\r\n\r\n\tPS_JREVOLUTE_MAX_FORCE,\r\n\tPS_JREVOLUTE_MAX_TORQUE,\r\n\r\n};\r\nenum PS_JCYLINDRICAL_MEMBERS\r\n{\r\n\t\r\n\tPS_JCYLINDRICAL_BODY_B,\r\n\tPS_JCYLINDRICAL_ANCHOR,\r\n\tPS_JCYLINDRICAL_ANCHOR_REF,\r\n\r\n\tPS_JCYLINDRICAL_AXIS,\r\n\tPS_JCYLINDRICAL_AXIS_REF,\r\n\tPS_JCYLINDRICAL_COLLISION,\r\n\r\n\tPS_JCYLINDRICAL_MAX_FORCE,\r\n\tPS_JCYLINDRICAL_MAX_TORQUE,\r\n\r\n\r\n};\r\nenum PS_JPRISMATIC_MEMBERS\r\n{\r\n\tPS_JPRISMATIC_BODY_B,\r\n\tPS_JPRISMATIC_ANCHOR,\r\n\tPS_JPRISMATIC_ANCHOR_REF,\r\n\r\n\tPS_JPRISMATIC_AXIS,\r\n\tPS_JPRISMATIC_AXIS_REF,\r\n\tPS_JPRISMATIC_COLLISION,\r\n\tPS_JPRISMATIC_MAX_FORCE,\r\n\tPS_JPRISMATIC_MAX_TORQUE,\r\n};\r\nenum PS_JBALL_MEMBERS\r\n{\r\n\tPS_JBALL_BODY_B,\r\n\tPS_JBALL_ANCHOR,\r\n\tPS_JBALL_ANCHOR_REF,\r\n\tPS_JBALL_GLOBAL_AXIS,\r\n\tPS_JBALL_GLOBAL_AXIS_REF,\r\n\tPS_JBALL_LIMIT_SWING_AXIS,\r\n\tPS_JBALL_PROJ_MODE,\r\n\tPS_JBALL_PROJ_DISTANCE,\r\n\tPS_JBALL_COLLISION,\r\n\tPS_JBALL_SWING_LIMIT,\r\n\tPS_JBALL_TWIST_HIGH,\r\n\tPS_JBALL_TWIST_LOW,\r\n\tPS_JBALL_SWING_SPRING,\r\n\tPS_JBALL_TWIST_SPRING,\r\n\tPS_JBALL_JOINT_SPRING,\r\n\r\n\tPS_JBALL_MAX_FORCE,\r\n\tPS_JBALL_MAX_TORQUE,\r\n\r\n\r\n};\r\n\r\nenum PS_JFIXED_MEMBERS\r\n{\r\n\tPS_JFIXED_BODY_B,\r\n\tPS_JFIXED_MAX_FORCE,\r\n\tPS_JFIXED_MAX_TORQUE,\r\n};\r\nenum PS_JDISTANCE_MEMBERS\r\n{\r\n\tPS_JDISTANCE_BODY_B,\r\n\tPS_JDISTANCE_LOCAL_ANCHOR_A_POS,\r\n\tPS_JDISTANCE_LOCAL_ANCHOR_A_REF,\r\n\r\n\tPS_JDISTANCE_LOCAL_ANCHOR_B_POS,\r\n\tPS_JDISTANCE_LOCAL_ANCHOR_B_REF,\r\n\r\n\tPS_JDISTANCE_COLL,\r\n\tPS_JDISTANCE_MIN_DISTANCE,\r\n\tPS_JDISTANCE_MAX_DISTANCE,\r\n\tPS_JDISTANCE_SPRING,\r\n\r\n\tPS_JDISTANCE_MAX_FORCE,\r\n\tPS_JDISTANCE_MAX_TORQUE,\r\n};\r\n\r\nenum PS_JLIMIT_PLANE_MEMBERS\r\n{\r\n\tPS_JLP_BODY_B_REF,\r\n\tPS_JLP_JOINT_TYPE,\r\n\tPS_JLP_RESTITUTION,\r\n\tPS_JLP_IS_ON_BODY_B,\r\n\tPS_JLP_LIMIT_POINT,\r\n\tPS_JLP_LIMIT_POINT_REF,\r\n\tPS_JLP_NORMAL,\r\n\tPS_JLP_NORMAL_REF,\r\n\tPS_JLP_PT_IN_PLANE,\r\n\tPS_JLP_PT_IN_PLANE_REF,\r\n};\r\n\r\nenum PS_D6_AXIS_ITEM\r\n{\r\n\tPS_D6_AXIS_ITEM_MODE,\r\n\tPS_D6_AXIS_ITEM_LIMIT,\r\n};\r\n\r\nenum PS_D6\r\n{\r\n\tPS_JD6_BODY_B,\r\n\tPS_JD6_ANCHOR,\r\n\tPS_JD6_ANCHOR_REF,\r\n\r\n\tPS_JD6_AXIS,\r\n\tPS_JD6_AXIS_REF,\r\n\r\n\tPS_JD6_AXIS_MASK,\r\n\r\n\tPS_JD6_X,\r\n\tPS_JD6_Y,\r\n\tPS_JD6_Z,\r\n\tPS_JD6_TWIST_SWING1,\r\n\tPS_JD6_TWIST_SWING2,\r\n\tPS_JD6_TWIST_LOW,\r\n\tPS_JD6_TWIST_HIGH,\r\n};\r\n#endif/*\n * Tcp4u v 3.31 Creation 10/07/1997 Last Revision 16/10/1997 3.11\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: udp4u.h\n * Purpose: main functions for udp protocol management\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n#ifndef UDP4UX_API\n\n\n#ifndef _WINSOCKAPI_\t/* winsock.h has not been loaded -> unix */\n# include \n# include \n#endif\n\n#ifdef __cplusplus \nextern \"C\" { /* Assume C declarations for C++ */ \n#endif /* __cplusplus */ \n\n\nstruct sUdpData\n{\n SOCKET UdpSock; /* Socket descriptor */\n struct sockaddr_in saSendAddr; /* destination */\n struct sockaddr_in saRecvAddr; /* last received frame header */\n struct in_addr saFilter; /* Fileter en reception */\n BOOL bSemiConnected; /* received only from SendAddr */\n}; /* struct sUdpData */\n\ntypedef struct sUdpData UDPSOCK;\ntypedef UDPSOCK far * LPUDPSOCK;\n\n/* different modes */\n#define UDP4U_CLIENT 45\n#define UDP4U_SERVER 56\n\n\nint API4U UdpInit (LPUDPSOCK far *pUdp, LPCSTR szHost, \n unsigned short uRemotePort, unsigned short uLocalPort);\nint API4U UdpCleanup (LPUDPSOCK Udp);\nint API4U UdpSend (LPUDPSOCK Udp,\n LPCSTR sData, int nDataSize,\n BOOL bHighPriority, HFILE hLogFile);\nint API4U UdpRecv (LPUDPSOCK pUdp, LPSTR sData, int nDataSize, \n unsigned uTimeOut, HFILE hLogFile);\nint API4U UdpBind (LPUDPSOCK pUdp, BOOL bFilter, int nMode);\nunsigned short API4U Udp4uServiceToPort (LPCSTR szService);\n\n\n#ifdef __cplusplus \n} /* End of extern \"C\" */ \n#endif /* ifdef __cplusplus */\n\n#define UDP4UX_API loaded\n#endif /* ifndef UDP4UX_API */\n#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n\r\n#include \"tnlRandom.h\"\n#include \"tnlSymmetricCipher.h\"\n#include \"tnlAsymmetricKey.h\"\r\n#include \r\n#include \n#include \"xLogger.h\"\n\n\nclass vtLogConsumer : public xLogConsumer\n{\npublic:\n\t\n\tvoid logString(const char *string)\n\t{\n\t\t\n\t\tXString newLog(string);\n\t\tif (GetNM()->GetLastLogEntry().Compare(newLog))\r\n\t\t{\r\n\t\tif ( string && strlen(string) < 255)\r\n\t\t{\r\n\t\t\tGetNM()->SetLastLogEntry(string);\r\n\t\t\tctx()->OutputToConsoleEx(newLog.Str());\r\n\r\n\t\t}\r\n\r\n\t\t//printf(\"%s\\n\", string);\r\n\t\t}\r\n\t}\n\n}gVTLogger;\n\nclass DedicatedServerLogConsumer : public TNL::LogConsumer\n{\npublic:\n\tvoid logString(const char *string)\n\t{\n\t\tgVTLogger.logString(string);\n\t\t/*\n\t\tXString newLog(string);\n\t\tif (GetNM()->GetLastLogEntry().Compare(newLog))\r\n\t\t{\r\n\t\t\tif ( string && strlen(string) < 255)\r\n\t\t\t{\r\n\t\t\t\tGetNM()->SetLastLogEntry(string);\r\n\t\t\t\tctx()->OutputToConsoleEx(newLog.Str());\r\n\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//printf(\"%s\\n\", string);\r\n\t\t}\r\n\r\n\t\t*/\r\n\t}\n} gDedicatedServerLogConsumer;\n\n\n\nvoid vtNetworkManager::initLogger()\n{\n\n\txLogger::GetInstance()->addLogItem(E_LI_SESSION);\r\n\t//xLogger::GetInstance()->enableLoggingLevel(E_LI_SESSION,ELOGINFO,1);\r\n\t//xLogger::GetInstance()->enableLoggingLevel(E_LI_SESSION,ELOGTRACE,1);\r\n\txLogger::GetInstance()->addLogItem(E_LI_CLIENT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_3DOBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_2DOBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_DISTRIBUTED_BASE_OBJECT);\r\n\txLogger::GetInstance()->addLogItem(E_LI_DISTRIBUTED_CLASS_DESCRIPTORS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_MESSAGES);\r\n\txLogger::GetInstance()->addLogItem(E_LI_ARRAY_MESSAGES);\r\n\txLogger::GetInstance()->addLogItem(E_LI_CONNECTION);\r\n\txLogger::GetInstance()->addLogItem(E_LI_NET_INTERFACE);\r\n\txLogger::GetInstance()->addLogItem(E_LI_GHOSTING);\r\n\txLogger::GetInstance()->addLogItem(E_LI_STATISTICS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_BUILDINGBLOCKS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_VSL);\r\n\txLogger::GetInstance()->addLogItem(E_LI_CPP);\r\n\txLogger::GetInstance()->addLogItem(E_LI_ASSERTS);\r\n\txLogger::GetInstance()->addLogItem(E_LI_PREDICTION);\r\n\txLogger::GetInstance()->addLogItem(E_LI_SERVER_MESSAGES);\r\n\r\n\txLogger::GetInstance()->addItemDescription(\"Session\");\r\n\txLogger::GetInstance()->addItemDescription(\"Client\");\r\n\txLogger::GetInstance()->addItemDescription(\"3dObject\");\r\n\txLogger::GetInstance()->addItemDescription(\"2dObject\");\r\n\txLogger::GetInstance()->addItemDescription(\"DistBase Object\");\r\n\txLogger::GetInstance()->addItemDescription(\"DistClassDescr\");\r\n\txLogger::GetInstance()->addItemDescription(\"Messages\");\r\n\txLogger::GetInstance()->addItemDescription(\"ArrayMessages\");\r\n\txLogger::GetInstance()->addItemDescription(\"Connection\");\r\n\txLogger::GetInstance()->addItemDescription(\"NetInterface\");\r\n\txLogger::GetInstance()->addItemDescription(\"Ghosting\");\r\n\txLogger::GetInstance()->addItemDescription(\"Stats\");\r\n\txLogger::GetInstance()->addItemDescription(\"BB\");\r\n\txLogger::GetInstance()->addItemDescription(\"VSL\");\r\n\txLogger::GetInstance()->addItemDescription(\"CPP\");\r\n\txLogger::GetInstance()->addItemDescription(\"Asserts\");\r\n\txLogger::GetInstance()->addItemDescription(\"Prediction\");\r\n\txLogger::GetInstance()->addItemDescription(\"ServerMsg\");\n\n}#ifndef __XMATH_STREAM_H__\r\n#define __XMATH_STREAM_H__\r\n\r\n#ifndef _XNET_TYPES_H_\r\n\t#include \"xNetTypes.h\"\r\n#endif\r\n\r\n#ifndef _XPOINT_H_\r\n\t#include \"xPoint.h\"\r\n#endif\r\n\r\n#ifndef _XQUAT_H_\r\n\t#include \"xQuat.h\"\r\n#endif\r\nnamespace xMath\r\n{\r\n\r\n\tnamespace stream\r\n\t{\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, Point2F* p)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&p->x);\r\n\t\t\tsuccess &= stream.read(&p->y);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, Point3F* p)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&p->x);\r\n\t\t\tsuccess &= stream.read(&p->y);\r\n\t\t\tsuccess &= stream.read(&p->z);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, Point4F* p)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&p->x);\r\n\t\t\tsuccess &= stream.read(&p->y);\r\n\t\t\tsuccess &= stream.read(&p->z);\r\n\t\t\tsuccess &= stream.read(&p->w);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, Point3D* p)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&p->x);\r\n\t\t\tsuccess &= stream.read(&p->y);\r\n\t\t\tsuccess &= stream.read(&p->z);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\tinline bool mathRead(TNL::BitStream& stream, PlaneF* p)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&p->x);\r\n\t\t\tsuccess &= stream.read(&p->y);\r\n\t\t\tsuccess &= stream.read(&p->z);\r\n\t\t\tsuccess &= stream.read(&p->d);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, Box3F* b)\r\n\t\t{\r\n\t\t\tbool success = mathRead(stream, &b->min);\r\n\t\t\tsuccess &= mathRead(stream, &b->max);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, SphereF* s)\r\n\t\t{\r\n\t\t\tbool success = mathRead(stream, &s->center);\r\n\t\t\tsuccess &= stream.read(&s->radius);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\t/*inline bool mathRead(TNL::BitStream& stream, RectI* r)\r\n\t\t{\r\n\t\t\tbool success = mathRead(stream, &r->point);\r\n\t\t\tsuccess &= mathRead(stream, &r->extent);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, RectF* r)\r\n\t\t{\r\n\t\t\tbool success = mathRead(stream, &r->point);\r\n\t\t\tsuccess &= mathRead(stream, &r->extent);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathRead(TNL::BitStream& stream, MatrixF* m)\r\n\t\t{\r\n\t\t\tbool success = true;\r\n\t\t\tF32* pm = *m;\r\n\t\t\tfor (U32 i = 0; i < 16; i++)\r\n\t\t\t\tsuccess &= stream.read(&pm[i]);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\t*/\r\n\t\t\r\n\t\tinline bool mathRead(TNL::BitStream& stream, QuatF* q)\r\n\t\t{\r\n\t\t\tbool success = stream.read(&q->x);\r\n\t\t\tsuccess &= stream.read(&q->y);\r\n\t\t\tsuccess &= stream.read(&q->z);\r\n\t\t\tsuccess &= stream.read(&q->w);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* */\r\n\t\t/************************************************************************/\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point2I& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point3I& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\tsuccess &= stream.write(p.z);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point2F& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point3F& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\tsuccess &= stream.write(p.z);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point4F& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\tsuccess &= stream.write(p.z);\r\n\t\t\tsuccess &= stream.write(p.w);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Point3D& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\tsuccess &= stream.write(p.z);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const PlaneF& p)\r\n\t\t{\r\n\t\t\tbool success = stream.write(p.x);\r\n\t\t\tsuccess &= stream.write(p.y);\r\n\t\t\tsuccess &= stream.write(p.z);\r\n\t\t\tsuccess &= stream.write(p.d);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const Box3F& b)\r\n\t\t{\r\n\t\t\tbool success = mathWrite(stream, b.min);\r\n\t\t\tsuccess &= mathWrite(stream, b.max);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const SphereF& s)\r\n\t\t{\r\n\t\t\tbool success = mathWrite(stream, s.center);\r\n\t\t\tsuccess &= stream.write(s.radius);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const MatrixF& m)\r\n\t\t{\r\n\t\t\tbool success = true;\r\n\t\t\tconst F32* pm = m;\r\n\t\t\tfor (U32 i = 0; i < 16; i++)\r\n\t\t\t\tsuccess &= stream.write(pm[i]);\r\n\t\t\treturn success;\r\n\t\t}\r\n\r\n\t\t*/\r\n\t\tinline bool mathWrite(TNL::BitStream& stream, const QuatF& q)\r\n\t\t{\r\n\t\t\tbool success = stream.write(q.x);\r\n\t\t\tsuccess &= stream.write(q.y);\r\n\t\t\tsuccess &= stream.write(q.z);\r\n\t\t\tsuccess &= stream.write(q.w);\r\n\t\t\treturn success;\r\n\t\t}\r\n\t}\r\n}\r\n#endif#ifndef NX_INTERFACE_H\r\n#define NX_INTERFACE_H\r\n/*----------------------------------------------------------------------------*\\\r\n|\r\n|\t\t\t\t\t\tPublic Interface to Ageia PhysX Technology\r\n|\r\n|\t\t\t\t\t\t\t www.ageia.com\r\n|\r\n\\*----------------------------------------------------------------------------*/\r\n\r\nenum NxInterfaceType\r\n{\r\n\tNX_INTERFACE_STATS,\r\n\tNX_INTERFACE_LAST\r\n};\r\n\r\n\r\nclass NxInterface\r\n{\r\npublic:\r\n virtual int getVersionNumber(void) const = 0;\r\n virtual NxInterfaceType getInterfaceType(void) const = 0;\r\n\r\nprotected:\r\n virtual ~NxInterface(){};\r\n};\r\n\r\n#endif\r\n//AGCOPYRIGHTBEGIN\r\n///////////////////////////////////////////////////////////////////////////\r\n// Copyright (c) 2005 AGEIA Technologies.\r\n// All rights reserved. www.ageia.com\r\n///////////////////////////////////////////////////////////////////////////\r\n//AGCOPYRIGHTEND\r\n#include \r\n\r\n#include \"pCommon.h\"\r\n\r\n#include \"IParameter.h\"\r\n#include \"pVehicleAll.h\"\r\n#include \r\n\r\nCKObjectDeclaration\t*FillBehaviorPVSetMotorValuesDecl();\r\nCKERROR CreatePVSetMotorValuesProto(CKBehaviorPrototype **pproto);\r\nint PVSetMotorValues(const CKBehaviorContext& behcontext);\r\nCKERROR PVSetMotorValuesCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools::BehaviorTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\r\nenum bInputs\r\n{\r\n\r\n\tI_XML,\r\n\tI_Flags,\r\n\tI_Clutch,\r\n\r\n\tI_maxRPM,\r\n\tI_minRPM,\r\n\tI_maxTorque,\r\n\r\n\tI_intertia,\r\n\tI_engineFriction,\r\n\tI_breakCoeff,\r\n\tI_GroundForceFeedBackScale,\r\n\r\n\tI_tList,\r\n};\r\n\r\n\r\n\r\n#define BB_SSTART 0\r\n\r\nBBParameter pInMap5[] = \r\n{\r\n\r\n\t\r\n\tBB_SPIN(I_XML,VTE_XML_VMOTOR_SETTINGS,\"XML Link\",\"None\"),\r\n\tBB_SPIN(I_Flags,VTF_VEHICLE_ENGINE_FLAGS,\"Flags\",\"None\"),\r\n\tBB_SPIN(I_Clutch,CKPGUID_FLOAT,\"Clutch\",\"None\"),\r\n\r\n\tBB_SPIN(I_maxRPM,CKPGUID_FLOAT,\"Maximum RPM\",\"None\"),\r\n\tBB_SPIN(I_minRPM,CKPGUID_FLOAT,\"Minimum RPM\",\"None\"),\r\n\tBB_SPIN(I_maxTorque,CKPGUID_FLOAT,\"Maximum Torque\",\"None\"),\r\n\r\n\tBB_SPIN(I_intertia,CKPGUID_FLOAT,\"Inertia\",\"None\"),\r\n\tBB_SPIN(I_engineFriction,CKPGUID_FLOAT,\"Friction\",\"1.0f\"),\r\n\tBB_SPIN(I_breakCoeff,CKPGUID_FLOAT,\"Break Factor\",\"0.0f\"),\r\n\tBB_SPIN(I_GroundForceFeedBackScale,CKPGUID_FLOAT,\"Ground Force Scale\",\"0.0f\"),\r\n\r\n\tBB_SPIN(I_tList,VTS_VMOTOR_TVALUES,\"Torque per RPM\",\"None\"),\r\n\r\n};\r\n\r\n#define gPIMAP pInMap5\r\n\r\nCKERROR PVSetMotorValuesCB(const CKBehaviorContext& behcontext)\r\n{\r\n\t\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tBB_DECLARE_PMAP;\r\n\tswitch(behcontext.CallbackMessage) \r\n\t{\r\n\r\n\r\n\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tBB_LOAD_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CKM_BEHAVIORDETACH:\r\n\t\t{\r\n\t\t\tBB_DESTROY_PIMAP;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORATTACH:\r\n\t\t{\r\n\t\t\tBB_INIT_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\tBB_REMAP_PIMAP(gPIMAP,BB_SSTART);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n//************************************\r\n// Method: FillBehaviorPVSetMotorValuesDecl\r\n// FullName: FillBehaviorPVSetMotorValuesDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration*FillBehaviorPVSetMotorValuesDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVMotor\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Modifies motor parameters of a vehicle controller\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x7b044c81,0xde9489a));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVSetMotorValuesProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVSetMotorValuesProto\r\n// FullName: CreatePVSetMotorValuesProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVSetMotorValuesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVMotor\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\t\r\n\r\n\t//BB_EVALUATE_PINS(gPIMAP)\r\n\tBB_EVALUATE_SETTINGS(gPIMAP);\r\n\r\n\r\n\t/*! PVMotor \r\n\r\n\tPVSetMotorValues is categorized in \\ref Vehicle\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tModifies various physical parameters.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVMotor.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::setCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::setKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::enableGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::enableCollision(). \r\n\t
\r\n\tMass Offset: The new mass center in the bodies local space.\r\n\t
\r\n\tPivot Offset: The initial shape position in the bodies local space.\r\n\t
\r\n\tNotify Collision: Enables collision notification.This is necessary to use collisions related building blocks. \r\n\t
\r\n\tTransformation Locks: Specifies in which dimension a a transformation lock should occour.\r\n\t
\r\n\tLinear Damping: The new linear damping scale.\r\n\t
\r\n\tAngular Damping: The new linear damping scale.\r\n\t
\r\n\r\n\tFilter Groups: Sets the filter mask of the initial or sub shape.\r\n\t
\r\n\r\n\r\n\tCollisions Group: Enables input for collisions group.\r\n\t
\r\n\tKinematic Object: Enables input for kinematic object.\r\n\t
\r\n\tGravity: Enables input for gravity.\r\n\t
\r\n\tCollision: Enables input for collision. \r\n\t
\r\n\tMas Offset: Enables input for mass offset. \r\n\t
\r\n\tPivot Offset: Enables input for pivot offset.\r\n\t
\r\n\tNotify Collision: Enables input for collision. \r\n\t
\r\n\tLinear Damping: Enables input for linear damping.\r\n\t
\r\n\tAngular Damping: Enables input for angular damping.\r\n\t
\r\n\tFilter Groups: Enables input for filter groups.\r\n\t
\r\n\t\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\\include PBSetEx.cpp\r\n\t\r\n\t*/\r\n\r\n\t//proto->DeclareSetting(\"Collisions Group\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\tproto->SetBehaviorCallbackFct( PVSetMotorValuesCB );\r\n\t\r\n\t\r\n\r\n\t//proto->DeclareSetting(\"Output Curve\",CKPGUID_BOOL,\"TRUE\");\r\n\t//proto->DeclareSetting(\"Automatic Gears\",CKPGUID_BOOL,\"TRUE\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVSetMotorValues);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint PVSetMotorValues(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target )\tbbSErrorME(E_PE_REF);\r\n\r\n\t\tpRigidBody *body = GetPMan()->getBody(target);\r\n\t\tif (!body)\t\tbbSErrorME(E_PE_NoBody);\r\n\r\n\t\tpVehicle *v = body->getVehicle();\r\n\t\tif (!v)\t\t\tbbSErrorME(E_PE_NoVeh);\r\n\r\n\t\tif (!v->isValidEngine())\r\n\t\t\tbbErrorME(\"Vehicle is not complete\");\r\n\r\n\t\tpEngine *engine = v->getEngine();\r\n\t\tif (!engine)\t\t\tbbErrorME(\"No valid engine\");\r\n\t\t\r\n\t\t\r\n\t\tCK2dCurve* pOCurve = NULL;\t//optional \r\n\r\n\t\tBB_DECLARE_PIMAP;//retrieves the parameter input configuration array\r\n\t\tBBSParameter(I_XML);//our bb settings concated as s##I_XML\r\n\t\tBBSParameter(I_Flags);\r\n\t\tBBSParameter(I_Clutch);\r\n\t\tBBSParameter(I_tList);\r\n\t\tBBSParameter(I_maxRPM);\r\n\t\tBBSParameter(I_minRPM);\r\n\t\tBBSParameter(I_maxTorque);\r\n\t\tBBSParameter(I_intertia);\r\n\t\tBBSParameter(I_engineFriction);\r\n\t\tBBSParameter(I_breakCoeff);\r\n\t\tBBSParameter(I_GroundForceFeedBackScale);\r\n\r\n\t\tif (sI_XML){\r\n\t\t\tint xmlLink = GetInputParameterValue(beh,BB_IP_INDEX(I_XML));\r\n\t\t}\r\n\t\t\r\n\t\tif (sI_GroundForceFeedBackScale)\r\n\t\t\tengine->setForceFeedbackScale(GetInputParameterValue(beh,BB_IP_INDEX(I_GroundForceFeedBackScale)));\r\n\r\n\t\tif (sI_Flags)\r\n\t\t\tengine->setFlags(GetInputParameterValue(beh,BB_IP_INDEX(I_Flags)));\r\n\t\tif (sI_Clutch)\r\n\t\t\tengine->setClutch(GetInputParameterValue(beh,BB_IP_INDEX(I_Clutch)));\r\n\r\n\t\tif (sI_maxTorque)\r\n\t\t\tengine->setMaxTorque(GetInputParameterValue(beh,BB_IP_INDEX(I_maxTorque)));\r\n\r\n\t\tif (sI_maxTorque)\r\n\t\t\tengine->setMaxTorque(GetInputParameterValue(beh,BB_IP_INDEX(I_maxTorque)));\r\n\t\tif (sI_maxRPM)\r\n\t\t\tengine->setMaxRPM(GetInputParameterValue(beh,BB_IP_INDEX(I_maxRPM)));\r\n\t\tif (sI_minRPM)\r\n\t\t\tengine->setIdleRPM(GetInputParameterValue(beh,BB_IP_INDEX(I_minRPM)));\r\n\t\tif (sI_engineFriction)\r\n\t\t\tengine->setFriction(GetInputParameterValue(beh,BB_IP_INDEX(I_engineFriction)));\r\n\t\tif (sI_intertia)\r\n\t\t\tengine->SetInertia(GetInputParameterValue(beh,BB_IP_INDEX(I_intertia)));\r\n\r\n\t\tif (sI_breakCoeff)\r\n\t\t\tengine->setBrakingCoeff(GetInputParameterValue(beh,BB_IP_INDEX(I_breakCoeff)));\r\n\r\n\r\n\t\tif (sI_tList){\r\n\r\n\t\t\tCKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_tList));\r\n\t\t\tCKParameter *pout= inP->GetDirectSource();\r\n\t\t\tif (pout)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tif (engine->getTorqueCurve())\r\n\t\t\t\t{\r\n\t\t\t\t\tpLinearInterpolation &curve = *engine->getTorqueCurve();\r\n\r\n\t\t\t\t\tcurve.clear();\r\n\t\t\t\t\tIParameter::Instance()->copyTo(curve,pout);\r\n\t\t\t\t\tengine->preStep();\r\n\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t//engine->setTorqueCurve();\r\n\t\t}\r\n\r\n\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//a optinal curve to display ratio between horse power and rpm\r\n\r\n/*\t\tDWORD outputCurve;\tbeh->GetLocalParameterValue(BB_PMAP_SIZE(gPIMAP),&outputCurve);//special settings !\r\n\t\tif (outputCurve)\r\n\t\t\tbeh->GetOutputParameterValue(0,&pOCurve);\r\n\r\n*/\r\n\t\t\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\t\t\tChecking we have to replace of the entire motor object ! \r\n\t\t//\r\n\t\tif (sI_tList)\r\n\t\t{\r\n\t\t\tfloat maxInputRPM =0.0f;\t\t\t\r\n\t\t\tfloat maxInputNM =0.0f;\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t//\r\n\t\t\t// this is only a test run ! \r\n\t\t\tpLinearInterpolation nTable;\r\n\t\t\t//getNewTorqueTable(beh,nTable,maxInputRPM,maxInputNM,NULL);\r\n\r\n\t\t\tif (nTable.getSize() )\r\n\t\t\t{\r\n\r\n\t\t\t\t/*\r\n\t\t\t\tif (pOCurve)\r\n\t\t\t\t{\r\n\t\t\t\t\twhile (pOCurve->GetControlPointCount())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tpOCurve->DeleteControlPoint(pOCurve->GetControlPoint(0));\r\n\t\t\t\t\t\tpOCurve->Update();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t*/\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t//\twe just copy into the motor we can get !\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t// we make a new torque ratios \r\n\r\n\t\t\t\t//getNewTorqueTable(beh,mDesc->torqueCurve,maxInputRPM,maxInputNM,pOCurve);\r\n\t\t\t\t\r\n\t\t\t\t/*\r\n\t\t\t\tif (!mDesc->isValid())\t\t\t\t\tbbErrorME(\"motor description was invalid, aborting update \");\r\n\r\n\t\t\t\tif (!motor)\r\n\t\t\t\t{\r\n\t\t\t\t\tmotor = pFactory::Instance()->createVehicleMotor(*mDesc);\r\n\t\t\t\t\tv->setMotor(motor);\r\n\t\t\t\t}else\r\n\t\t\t\t{\r\n\t\t\t\t\tif (mDesc->torqueCurve.getSize())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tmotor->loadNewTorqueCurve(mDesc->torqueCurve);\r\n\t\t\t\t\t}\r\n\t\t\t\t}*/\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\t\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\r\n\t\t//\tFlexibility : \r\n\t\t//\r\n\t\t\r\n\t\t/*\r\n\t\tif (sI_minRDown &&\t\tmotor )motor->setMinRpmToGearDown(mDDown);\r\n\t\tif (sI_maxRUp &&\t\t\tmotor )motor->setMaxRpmToGearUp(mDUp);\r\n\t\tif (sI_maxR\t&&\t\t\tmotor )motor->setMaxRpm(maxR);\r\n\t\tif (sI_minR\t&&\t\t\tmotor )motor->setMinRpm(minR);\r\n\r\n\t\t*/\r\n\t\tif ( pOCurve\t)\r\n\t\t{\r\n\t\t\t/*\r\n\t\t\t#ifdef _DEBUG\r\n\t\t\t\t\t\tXString error;\r\n\t\t\t\t\t\terror << \"t curve created with \" << pOCurve->GetControlPointCount() << \" with l : \" << pOCurve->GetLength();\r\n\t\t\t\t\t\tbbErrorME(error.CStr());\r\n\t\t\t#endif\r\n\t\t\t*/\r\n\r\n\r\n\t\t\t/*\r\n\t\t\tfor (int i = 0 ; i < pOCurve->GetControlPointCount() ; i++)\r\n\t\t\t{\r\n\t\t\t\tCK2dCurvePoint* point = pOCurve->GetControlPoint(i);\r\n\t\t\t\tpoint->SetLinear(true);\r\n\t\t\t}\r\n\t\t\tpOCurve->Update();\r\n\t\t\tbeh->SetOutputParameterValue(0,&pOCurve);\r\n\t\t\t*/\r\n\r\n\t\t}\r\n\t\t//delete mDesc;\r\n\t\t//mDesc = NULL;\r\n\t}\r\n\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//somebody wants to enter new torque values : \r\n//if (outputCurve && sI_tList )\r\n//\tbeh->GetOutputParameterValue(0,&pOCurve);\r\n\r\n/*\r\nif (sI_tList)\r\n{\r\n\r\nfloat maxInputRPM =0.0f;\t\t\tfloat maxInputNM =0.0f;\r\n\r\npLinearInterpolation torqueCurve;\r\nCKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_tList));\t\t\tCKParameter *pout= inP->GetDirectSource();\r\n\r\nif (pout)\r\n{\r\nfloat rpm = 0.0f;\t\t\t\tfloat nm = 0.0f;\r\n\r\nbool maximaFound = false;\t\t\t\tbool dataCollected = false;\r\n\r\n\r\nevaluate:\r\nfor (int i = 0 ; i < 6 ; i++)\r\n{\r\nCK_ID* paramids = static_cast(pout->GetReadDataPtr());\r\nCKParameter * sub = static_cast(GetPMan()->m_Context->GetObject(paramids[i]));\r\nif (sub)\r\n{\r\n\r\nrpm = GetValueFromParameterStruct(sub,0,false);\r\nnm = GetValueFromParameterStruct(sub,1,false);\r\n\r\n\r\nif ( rpm >0.0f && nm > 0.0f )\r\n{\r\n\r\nif (rpm > maxInputRPM) maxInputRPM = rpm;\r\nif (nm > maxInputNM) maxInputNM = nm;\r\n\r\n\r\nif (maximaFound || !outputCurve\t)\r\n{\r\ntorqueCurve.insert(rpm,nm);\r\ndataCollected =true;\r\n}\r\n\r\n\r\nif (maximaFound && outputCurve )\r\n{\r\npOCurve->AddControlPoint(Vx2DVector(rpm/maxInputRPM , nm/maxInputNM) );\r\ndataCollected =true;\r\n}\r\n}\r\n}\r\n}\r\n\r\n\r\n\r\n\r\nif (dataCollected)\t\t\t\t{\t\t\t\t\tgoto end;\t\t\t\t}\r\n\r\nif ( maxInputRPM >0.0f && maxInputNM> 0.0f )\r\n{\r\nmaximaFound = true;\r\ngoto evaluate;\r\n}\r\n\r\nend :\r\n\r\nif (dataCollected )\r\n{\r\n\r\nif (outputCurve)\r\nbeh->SetOutputParameterValue(0,&pOCurve);\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\nif (!motor)\r\n{\r\n\r\nmDesc = new pVehicleMotorDesc();\r\nmDesc->setToDefault();\r\n\r\nmDesc->maxRpmToGearUp = sI_maxRUp ? mDUp : mDesc->maxRpmToGearUp;\r\nmDesc->minRpmToGearDown = sI_minRDown = mDDown : mDesc->minRpmToGearDown ;\r\nmDesc->torqueCurve = torqueCurve;\r\nmotor = pFactory::Instance()->createVehicleMotor(*mDesc);\r\nv->setMotor(motor);\r\n}\r\n\r\n}\r\n}\r\n}\r\n\r\n*/#pragma once\r\n\r\n// DistributedNetworkClassDialogToolbarDlg.h : header file\r\n//\r\n\r\n//toolbar dialog creation function, to be called by Virtools Dev\r\nDllToolbarDlg*\tfCreateToolbarDlg(HWND parent);\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// ToolbarDlg dialog\r\n\r\nclass DistributedNetworkClassDialogToolbarDlg : public DllToolbarDlg\r\n{\r\npublic:\r\n\t//called on creation of the dialog by Virtools Dev interface\r\n\t//the PluginInterface will be avalaible only when the OnInterfaceInit() has been called\r\n\tvirtual void OnInterfaceInit();\r\n\t//called on destruction of the dialog by Virtools Dev interface\r\n\tvirtual void OnInterfaceEnd();\r\n\t//callback for receiving notification\r\n\tvirtual HRESULT ReceiveNotification(UINT MsgID,DWORD Param1=0,DWORD Param2=0,CKScene* Context=NULL);\r\n\r\n\r\n// Construction\r\npublic:\r\n\tDistributedNetworkClassDialogToolbarDlg(CWnd* pParent = NULL); // standard constructor\r\n\r\n// Dialog Data\r\n\t//{{AFX_DATA(DistributedNetworkClassDialogToolbarDlg)\r\n\tenum { IDD = IDD_TOOLBAR };\r\n\t\t// NOTE: the ClassWizard will add data members here\r\n\t//}}AFX_DATA\r\n\r\n\r\n// Overrides\r\n\t// ClassWizard generated virtual function overrides\r\n\t//{{AFX_VIRTUAL(DistributedNetworkClassDialogToolbarDlg)\r\n\tpublic:\r\n\tvirtual BOOL PreTranslateMessage(MSG* pMsg);\r\n\tprotected:\r\n\tvirtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support\r\n\t//}}AFX_VIRTUAL\r\n\r\n// Implementation\r\nprotected:\r\n\r\n\t// Generated message map functions\r\n\t//{{AFX_MSG(DistributedNetworkClassDialogToolbarDlg)\r\n\tvirtual BOOL OnInitDialog();\r\n\t//}}AFX_MSG\r\n\tDECLARE_MESSAGE_MAP()\r\n};\r\n\r\n//{{AFX_INSERT_LOCATION}}\r\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\nBOOL PhysicManager::checkDemo(CK3dEntity* a)\r\n{\r\n\treturn true;\r\n\r\n\t/*\r\n\tif (!a)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t//VxVector scale = vtODE::math::BoxGetZero(a);\r\n\t/*if ( scale.x > 400 || scale.y > 100 || scale.z > 400 )\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tif (GetPMan()->DefaultWorld() && GetPMan()->DefaultWorld()->NumBodies() > 30 )\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\t//return true;\r\n\tCKMesh *mesh = (CKMesh *)a->GetCurrentMesh();\r\n\r\n\tif (mesh)\r\n\t{\r\n\t\tint vcount = mesh->GetVertexCount();\r\n\t\tif (vcount ==960 ||vcount ==559 || vcount ==4096 ||vcount ==106 ||vcount ==256 || vcount ==17 || vcount ==24 || vcount == 266 || vcount == 841 )\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n\t*/\r\n}#include \"StdAfx.h\"\r\n#include \"InitMan.h\"\r\n#include \"vt_python_funcs.h\"\r\n#include \nusing std::cout;\n#include \r\n#include \"pyembed.h\"\r\n\r\n\r\n\r\n#include \"PythonModule.h\"\r\n//************************************\r\n// Method: ClearModules\r\n// FullName: vt_python_man::ClearModules\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n//************************************\r\nvoid\r\nvt_python_man::ClearPythonModules()\r\n{\r\n\r\n\t/*\r\n\tPModulesIt begin = GetPModules().begin();\r\n\tPModulesIt end = GetPModules().end();\r\n\twhile(begin!=end)\r\n\t{\r\n\r\n\t\tif (begin->second)\r\n\t\t{\r\n\t\t\tPy_XDECREF(begin->second);\r\n\t\t\tbegin->second = NULL;\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n\tGetPModules().clear();\r\n\t*/\r\n}\r\n/*\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,long& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n\r\n}\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,double& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,XString func,const Arg_mmap& args,std::string& ret)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr(),args,ret);\r\n\t\t}\r\n\t}\r\n}\r\nvoid\r\nvt_python_man::CallPyModule(CK_ID id,Arg_mmap *args,XString func)\r\n{\r\n\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr());\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid \r\nvt_python_man::CallPyModule(CK_ID id,XString func)\r\n{\r\n\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPyObject *module = GetPModule(id);\r\n\t\tif (module)\r\n\t\t{\r\n\t\t\tthis->py->call(module,func.CStr());\r\n\t\t}\r\n\t}\r\n}*/\r\n//************************************\r\n// Method: RemovePModule\r\n// FullName: vt_python_man::RemovePModule\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n//************************************\r\n/*\r\nvoid\r\nvt_python_man::DestroyPythonModule(CK_ID bid)\r\n{\r\n\tCKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it != GetPModules().end() )\r\n\t\t{\r\n if (it->second)\r\n {\r\n\t\t\t\tPy_DECREF(it->second);\r\n\t\t\t\tit->second = NULL;\r\n\t\t\t\tGetPModules().erase(it);\r\n }\r\n\t\t}\r\n\t}\r\n\t\r\n}\r\n*/\r\n//************************************\r\n// Method: GetPModule\r\n// FullName: vt_python_man::GetPModule\r\n// Access: public \r\n// Returns: PyObject*\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n//************************************\r\nPythonModule*\r\nvt_python_man::GetPythonModule(CK_ID bid)\r\n{\r\n\t/*CKObject* obj = m_Context->GetObject(id);\r\n\tif(obj)\r\n\t{\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it != GetPModules().end() )\r\n\t\t{\r\n\t\t\treturn it->second;\r\n\t\t}else\r\n\t\t{\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}*/\r\n\treturn NULL;\r\n}\r\n\r\n//************************************\r\n// Method: InsertPModule\r\n// FullName: vt_python_man::InsertPModule\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: CK_ID id\r\n// Parameter: XString name\r\n// Parameter: bool reload\r\n//************************************\r\nPythonModule*\r\nvt_python_man::CreatePythonModule(char*file,char*func,CK_ID bid)\r\n{\r\n\r\n /*CKObject* obj = m_Context->GetObject(id);\r\n\r\n\tif(obj)\r\n\t{\r\n\t\tif (GetPModule(id))\r\n\t\t{\r\n\t\t\tRemovePModule(id);\r\n\t\t}\r\n\t\t//bit = BArray.insert(BArray.end(),std::make_pair(target,bodyI));\r\n\t\tPModulesIt it = GetPModules().find(id);\r\n\t\tif(it == GetPModules().end() )\r\n\t\t{\r\n\r\n\t\t\ttry \r\n\t\t\t{\r\n\r\n\t\t\t\tPyObject* namep = PyString_FromString( name.CStr() );\n\t\t\t\tPyObject* module = PyImport_Import(namep); \n\n\t\t\t\tif (reload)\n\t\t\t\t\tPyImport_ReloadModule(module);\n\n\t\t\t\tPy_DECREF(namep);\n\t\t\t\tGetPModules().insert( GetPModules().end(),std::make_pair(id,module ) );\r\n\r\n\t\t\t\tif (!module)\n\t\t\t\t{\n\t\t\t\t\tstd::ostringstream oss;\n\t\t\t\t\tm_Context->OutputToConsoleEx(\"PyErr : \\t Failed to load module\" );\n\t\t\t\t\treturn NULL;\n\t\t\t\t\t\n\t\t\t\t}\r\n\r\n\t\t\t\treturn module;\n\t\t\t}\tcatch (Python_exception ex)\r\n\t\t\t{\r\n\t\t\t\tm_Context->OutputToConsoleEx(\"PyErr : \\t %s\",(CKSTRING)ex.what());\r\n\t\t\t\tstd::cout << ex.what() << \"pyexeption in beh : \";\r\n\t\t\t\tPyErr_Clear();\r\n\t\t\t\t//beh->ActivateOutput(1,TRUE);\r\n\t\t\t}\n \n\n\t\t\r\n\t\t\t//GetPModules().insert( GetPModules().end(),std::make_pair(id,module ) );\r\n\t\t\t//return module;\r\n\t\t}\r\n\t}\r\n\t*/\r\n\treturn NULL;\r\n}\r\n\r\n\r\n\r\n\r\n#ifndef __VTNET_CONFIG_H_\r\n#define __VTNET_CONFIG_H_\r\n\r\n//#define HAS_DISTOBJECTS 0\r\n//#undef HAS_DISTOBJECTS\r\n#define OUTPUT_ON_VIRTOOLS_CONSOLE 1\r\n\r\n\r\n#endif//\r\n// 3DTrans.cpp : Defines the initialization routines for the DLL.\r\n//\r\n#include \"CKAll.h\"\r\n#include \"MidiManager.h\"\r\n\r\n#ifdef macintosh\r\n#include \"BehaviorExport.h\"\r\n#endif\r\n\r\n\r\n#ifdef CK_LIB\r\n\t#define RegisterBehaviorDeclarations\tRegister_MidiBehaviors_BehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\t_MidiBehaviors_InitInstance\r\n\t#define ExitInstance\t\t\t\t\t_MidiBehaviors_ExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGet_MidiBehaviors_PluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGet_MidiBehaviors_PluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_MidiBehaviors_PluginInfo\r\n#else\r\n\t#define RegisterBehaviorDeclarations\tRegisterBehaviorDeclarations\r\n\t#define InitInstance\t\t\t\t\tInitInstance\r\n\t#define ExitInstance\t\t\t\t\tExitInstance\r\n\t#define CKGetPluginInfoCount\t\t\tCKGetPluginInfoCount\r\n\t#define CKGetPluginInfo\t\t\t\t\tCKGetPluginInfo\r\n\t#define g_PluginInfo\t\t\t\t\tg_PluginInfo\r\n#endif\r\n\r\n\r\nCKERROR InitInstance(CKContext* context);\r\nCKERROR ExitInstance(CKContext* context);\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg);\r\n\r\n#define MIDI_BEHAVIOR\tCKGUID(0x58176f2d,0x6b80544c)\r\n#define CKOGUID_ISNOTEACTIVE CKDEFINEGUID(0x25d70112,0x683835b8)\r\n\r\nCKPluginInfo g_PluginInfo[2];\r\n\r\nint CKGetPluginInfoCount() { return 2; }\r\n\r\nCKPluginInfo* CKGetPluginInfo(int Index)\r\n{\r\n\tg_PluginInfo[0].m_Author\t\t\t= \"Virtools\";\r\n\tg_PluginInfo[0].m_Description\t\t= \"Midi Building Blocks\";\r\n\tg_PluginInfo[0].m_Extension\t\t\t= \"\";\r\n\tg_PluginInfo[0].m_Type\t\t\t\t= CKPLUGIN_BEHAVIOR_DLL;\r\n\tg_PluginInfo[0].m_Version\t\t\t= 0x000001;\r\n\tg_PluginInfo[0].m_InitInstanceFct\t= NULL;\r\n\tg_PluginInfo[0].m_ExitInstanceFct\t= NULL;\r\n\tg_PluginInfo[0].m_GUID\t\t\t\t= MIDI_BEHAVIOR;\r\n\tg_PluginInfo[0].m_Summary\t\t\t= \"Midi Building Blocks\";\r\n\r\n\tg_PluginInfo[1].m_Author\t\t\t= \"Virtools\";\r\n\tg_PluginInfo[1].m_Description\t\t= \"Midi Manager\";\r\n\tg_PluginInfo[1].m_Extension\t\t\t= \"\";\r\n\tg_PluginInfo[1].m_Type\t\t\t\t= CKPLUGIN_MANAGER_DLL;\r\n\tg_PluginInfo[1].m_Version\t\t\t= 0x000001;\r\n\tg_PluginInfo[1].m_InitInstanceFct\t= InitInstance;\r\n\tg_PluginInfo[1].m_ExitInstanceFct\t= ExitInstance;\r\n\tg_PluginInfo[1].m_GUID\t\t\t\t= MIDI_MANAGER_GUID;\r\n\tg_PluginInfo[1].m_Summary\t\t\t= \"Midi Manager\";\r\n\r\n\treturn &g_PluginInfo[Index];\r\n}\r\n/**********************************************************************************/\r\n/**********************************************************************************/\r\n\r\n///////////////////////\r\n/// Param Op ///\r\n///////////////////////\r\nvoid BoolIsNoteActiveIntInt (CKContext *ctx, CKParameterOut *res, CKParameterIn *p1, CKParameterIn *p2){\r\n int note;\r\n p1->GetValue(&note);\r\n\r\n int channel;\r\n p2->GetValue(&channel);\r\n\r\n MidiManager *mm = (MidiManager *) ctx->GetManagerByGuid( MIDI_MANAGER_GUID );\r\n CKBOOL isNoteActive=mm->IsNoteActive(note, channel);\r\n\r\n res->SetValue(&isNoteActive);\r\n \r\n}\r\n\r\n////////////////////////\r\n// Initializations //\r\n////////////////////////\r\nCKERROR InitInstance(CKContext* ctx)\r\n{\r\n CKParameterManager *pm = ctx->GetParameterManager();\r\n\r\n //--- register a new Operation Type\r\n pm->RegisterOperationType(CKOGUID_ISNOTEACTIVE, \"Is Note Active\");\r\n\r\n //--- register a new Parameter Operation\r\n pm->RegisterOperationFunction(CKOGUID_ISNOTEACTIVE ,CKPGUID_BOOL, CKPGUID_INT, CKPGUID_INT, BoolIsNoteActiveIntInt);\r\n\r\n new MidiManager(ctx);\r\n\r\n\treturn CK_OK;\r\n}\r\n\r\nCKERROR ExitInstance(CKContext* ctx)\r\n{\r\n CKParameterManager *pm = ctx->GetParameterManager();\r\n\r\n //--- register a new Operation Type\r\n pm->UnRegisterOperationType(CKOGUID_ISNOTEACTIVE);\r\n \r\n MidiManager* man=(MidiManager*)ctx->GetManagerByGuid(MIDI_MANAGER_GUID);\r\n delete man;\r\n\r\n return CK_OK;\r\n}\r\n\r\n\r\n////////////////////////////////\r\n// Behaviors Registrations //\r\n////////////////////////////////\r\nvoid RegisterBehaviorDeclarations(XObjectDeclarationArray *reg)\r\n{\r\n RegisterBehavior(reg, FillBehaviorReadMidiSignalDecl);\r\n RegisterBehavior(reg, FillBehaviorMidiEventDecl);\r\n RegisterBehavior(reg, FillBehaviorSwitchOnMidiDecl);\r\n RegisterBehavior(reg, FillBehaviorMidiPlayerDecl);\r\n \r\n RegisterBehavior(reg, FillBehaviorSetMidiOutPortDecl);\r\n RegisterBehavior(reg, FillBehaviorGetMidiINDevicesDecl);\r\n RegisterBehavior(reg, FillBehaviorGetMidiOutDevicesDecl );\r\n RegisterBehavior(reg, FillBehaviorSetInMidiPortDecl);\r\n\r\n\r\n RegisterBehavior(reg, FillBehaviorSendMidiSignalDecl );\r\n\r\n}\r\n\r\n\r\n\r\nCRITICAL_SECTION gMidiCS;\r\n\r\n#if !defined(CK_LIB)\r\nBOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to the DLL module\r\n DWORD fdwReason, // reason for calling function\r\n LPVOID lpvReserved // reserved\r\n){\r\n\r\n\tswitch(fdwReason){\r\n\t\tcase DLL_PROCESS_ATTACH:\r\n\t\t\tInitializeCriticalSection(&gMidiCS); \r\n\t\t\tbreak;\r\n\t\r\n\t\tcase DLL_PROCESS_DETACH:\r\n\t\t\tDeleteCriticalSection(&gMidiCS); \t\t\t\r\n\t\t\tbreak;\r\n\r\n\t}\r\n\t\r\n\treturn TRUE;\r\n}\r\n#endif#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVWGetDecl();\r\nCKERROR CreatePVWGetProto(CKBehaviorPrototype **pproto);\r\nint PVWGet(const CKBehaviorContext& behcontext);\r\nCKERROR PVWGetCB(const CKBehaviorContext& behcontext);\r\n\r\nusing namespace vtTools;\r\nusing namespace BehaviorTools;\r\n\r\n\r\n\r\nenum bbI_Inputs\r\n{\r\n\tbbI_BodyReference,\r\n\r\n};\r\n\r\n#define BB_SSTART 0\r\n\r\nenum bbOutputs\r\n{\r\n\tO_AxleSpeed,\r\n\tO_WheelRollAngle,\r\n\tO_RPM,\r\n\tO_SteerAngle,\r\n\tO_MotorTorque,\r\n\tO_BreakTorque,\r\n\tO_Suspension,\r\n\tO_SuspensionTravel,\r\n\tO_Radius,\r\n\tO_WFlags,\r\n\tO_WSFlags,\r\n\tO_LatFunc,\r\n\tO_LongFunc,\r\n\tO_Contact,\r\n\r\n};\r\n\r\nBBParameter pOutMap[] = \r\n{\r\n\tBB_SPOUT(O_AxleSpeed,CKPGUID_FLOAT,\"Axle Speed\",\"0.0\"),\r\n\tBB_SPOUT(O_WheelRollAngle,CKPGUID_FLOAT,\"Roll Angle\",\"0.0\"),\r\n\tBB_SPOUT(O_RPM,CKPGUID_FLOAT,\"RPM\",\"0.0\"),\r\n\tBB_SPOUT(O_SteerAngle,CKPGUID_ANGLE,\"Steer Angle\",\"0.0\"),\r\n\tBB_SPOUT(O_MotorTorque,CKPGUID_FLOAT,\"Motor Torque\",\"0.0\"),\r\n\tBB_SPOUT(O_BreakTorque,CKPGUID_FLOAT,\"Break Torque\",\"0.0\"),\r\n\tBB_SPOUT(O_Suspension,VTS_JOINT_SPRING,\"Suspension Spring\",\"0.0\"),\r\n\tBB_SPOUT(O_SuspensionTravel,CKPGUID_FLOAT,\"Suspension Spring\",\"0.0\"),\r\n\tBB_SPOUT(O_Radius,CKPGUID_FLOAT,\"Radius\",\"0.0\"),\r\n\tBB_SPOUT(O_WFlags,VTS_PHYSIC_WHEEL_FLAGS,\"Wheel Flags\",\"0.0\"),\r\n\tBB_SPOUT(O_WSFlags,VTF_VWSHAPE_FLAGS,\"Wheel Shape Flags\",\"0.0\"),\r\n\tBB_SPOUT(O_LatFunc,VTF_VWTIRE_SETTINGS,\"Lateral Force Settings\",\"0.0\"),\r\n\tBB_SPOUT(O_LongFunc,VTF_VWTIRE_SETTINGS,\"Longitudinal Force Settings\",\"0.0\"),\r\n\tBB_SPOUT(O_Contact,VTS_WHEEL_CONTACT,\"Contact Data\",\"0.0\"),\r\n\t//BB_SPOUT(O_LongFunc,VTF_VWTIRE_SETTINGS,\"Longitudinal Force Settings\",\"0.0\"),\r\n};\r\n\r\n#define gOPMap pOutMap\r\n\r\n\r\nCKERROR PVWGetCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tint cb = behcontext.CallbackMessage;\r\n\tBB_DECLARE_PMAP;\r\n\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\r\n\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t\t{\r\n\t\t\t\tBB_LOAD_POMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase CKM_BEHAVIORDETACH:\r\n\t\t\t{\r\n\t\t\t\tBB_DESTROY_PMAP;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORATTACH:\r\n\t\t\t{\r\n\t\t\t\tBB_INIT_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t}\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t\t{\r\n\t\t\t\tBB_REMAP_PMAP(gOPMap,BB_SSTART);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKObjectDeclaration\t*FillBehaviorPVWGetDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PVWGet\");\t\r\n\tod->SetCategory(\"Physic/Vehicle\");\r\n\tod->SetDescription(\"Retrieves wheel related parameters.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x24b704e4,0x65ed5fad));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePVWGetProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePVWGetProto\r\n// FullName: CreatePVWGetProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreatePVWGetProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PVWGet\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\r\n\t/*! \\page PVWGet \r\n\r\n\tPVWGet is categorized in \\ref Vehicle\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tRetrieves various physical informations.
\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PVWGet.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tTarget: The 3D Entity associated to the rigid body.\r\n\t
\r\n\t
\r\n\tCollisions Group: Which collision group this body is part of.See pRigidBody::getCollisionsGroup().\r\n\t
\r\n\tKinematic Object: The kinematic state. See pRigidBody::isKinematic().\r\n\t
\r\n\tGravity: The gravity state.See pRigidBody::isAffectedByGravity().\r\n\t
\r\n\tCollision: Determines whether the body reacts to collisions.See pRigidBody::isCollisionEnabled(). \r\n\t
\r\n\t
\r\n\tCollisions Group: Enables output for collisions group.\r\n\t
\r\n\tKinematic Object: Enables output for kinematic object.\r\n\t
\r\n\tGravity: Enables output for gravity.\r\n\t
\r\n\tCollision: Enables output for collision. \r\n\t
\r\n\t
\r\n\t
\r\n\r\n\t
\r\n\t

Warning

\r\n\tThe body must be dynamic.\r\n\t
\r\n\t
\r\n\t

Note

\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager.
\r\n\r\n\t

VSL


\r\n\t\r\n\t\t\\include PBGetEx.cpp\r\n\t\r\n\t*/\r\n\t\r\n\r\n\t//proto->DeclareInParameter(\"World Reference\",CKPGUID_3DENTITY,\"pDefaultWorld\");\r\n\t//proto->DeclareInParameter(\"Body Reference\",CKPGUID_3DENTITY,\"Body\");\r\n\r\n\t\r\n\t/*proto->DeclareSetting(\"Collisions Group\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Kinematic\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Mass Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareSetting(\"Pivot Offset\",CKPGUID_BOOL,\"FALSE\");\r\n\r\n\t\r\n\t\r\n\tproto->DeclareOutParameter(\"Collisions Group\",CKPGUID_INT,\"0\");\r\n\tproto->DeclareOutParameter(\"Kinematic Object\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Gravity\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Collision\",CKPGUID_BOOL,\"FALSE\");\r\n\tproto->DeclareOutParameter(\"Mass Offset\",CKPGUID_VECTOR,\"0.0f\");\r\n\tproto->DeclareOutParameter(\"Pivot Offset\",CKPGUID_VECTOR,\"0.0f\");\r\n\r\n\t*/\r\n\r\n\tproto->SetBehaviorCallbackFct( PVWGetCB );\r\n\r\n\r\n\tBB_EVALUATE_SETTINGS(gOPMap);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// We just want create the building block pictures\r\n\t//\r\n\t#ifdef _DOC_ONLY_\r\n\t\tBB_EVALUATE_OUTPUTS(gOPMap);\r\n\t#endif // _DOC_ONLY_\r\n\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(PVWGet);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PVWGet\r\n// FullName: PVWGet\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PVWGet(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tif( !target ) \tbbErrorME(\"No Reference Object specified\");\r\n\r\n\t\tpRigidBody *body = NULL;\r\n\r\n\r\n\t\tbody = GetPMan()->getBody(target);\r\n\t\tif (!body)\tbbErrorME(\"No Reference Object specified\");\r\n\r\n\r\n\t\t\r\n\t\tpWheel *wheel = body->getWheel(target);\r\n\t\tif (!wheel)bbErrorME(\"pWheel object doesnt exist!\");\r\n\r\n\t\tpWheel2 *wheel2 = wheel->castWheel2();\r\n\r\n\t\t//if (!wheel2)bbErrorME(\"Couldnt cast a pWheel2 object\");\r\n\r\n\t\tBB_DECLARE_PMAP;\r\n\r\n\r\n\t\t/************************************************************************/\r\n\t\t/* retrieve settings state */\r\n\t\t/*****\r\n\t\t*******************************************************************/\r\n\r\n\t\tBBSParameter(O_AxleSpeed);\r\n\t\tBBSParameter(O_WheelRollAngle);\r\n\t\tBBSParameter(O_RPM);\r\n\t\tBBSParameter(O_SteerAngle);\r\n\t\tBBSParameter(O_MotorTorque);\r\n\t\tBBSParameter(O_BreakTorque);\r\n\t\tBBSParameter(O_Suspension);\r\n\t\tBBSParameter(O_SuspensionTravel);\r\n\t\tBBSParameter(O_Radius);\r\n\t\tBBSParameter(O_WFlags);\r\n\t\tBBSParameter(O_WSFlags);\r\n\t\tBBSParameter(O_LatFunc);\r\n\t\tBBSParameter(O_LongFunc);\r\n\t\tBBSParameter(O_Contact);\r\n\r\n\t\tBB_O_SET_VALUE_IF(float,O_AxleSpeed,wheel2->getAxleSpeed());\r\n\t\tBB_O_SET_VALUE_IF(float,O_WheelRollAngle,wheel->getWheelRollAngle());\r\n\t\tBB_O_SET_VALUE_IF(float,O_RPM,wheel2->getRpm());\r\n\t\t\r\n\t\tif (wheel2)\r\n\t\t{\r\n\t\t\tBB_O_SET_VALUE_IF(float,O_SteerAngle,wheel2->GetHeading());\r\n\t\t}\r\n\r\n\t\t/*\r\n\t\tBB_O_SET_VALUE_IF(float,O_SteerAngle,wheel2->rotationV.x);*/\r\n\t\tBB_O_SET_VALUE_IF(float,O_MotorTorque,wheel2->getWheelShape()->getMotorTorque());\r\n\t\tBB_O_SET_VALUE_IF(float,O_BreakTorque,wheel2->getWheelShape()->getBrakeTorque());\r\n\t\tBB_O_SET_VALUE_IF(float,O_SuspensionTravel,wheel2->getWheelShape()->getSuspensionTravel());\r\n\t\tBB_O_SET_VALUE_IF(float,O_Radius,wheel2->getWheelShape()->getRadius());\r\n\r\n\t\tBB_O_SET_VALUE_IF(int,O_WFlags,wheel->mWheelFlags);\r\n\t\tBB_O_SET_VALUE_IF(int,O_WSFlags,wheel2->getWheelShape()->getWheelFlags());\r\n\r\n\r\n\r\n\t\tif (wheel2){\r\n\r\n\t\t\tif (sO_LatFunc)\r\n\t\t\t{\r\n\t\t\t\tNxTireFunctionDesc tf = wheel2->getWheelShape()->getLateralTireForceFunction();\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_INDEX(O_LatFunc));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,1,tf.extremumSlip);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,2,tf.extremumValue);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,3,tf.asymptoteSlip);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,4,tf.asymptoteValue);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,5,tf.stiffnessFactor);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (sO_LongFunc)\r\n\t\t\t{\r\n\t\t\t\tNxTireFunctionDesc tf = wheel2->getWheelShape()->getLongitudalTireForceFunction();\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_INDEX(O_LongFunc));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,1,tf.extremumSlip);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,2,tf.extremumValue);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,3,tf.asymptoteSlip);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,4,tf.asymptoteValue);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,5,tf.stiffnessFactor);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\tif (wheel2)\r\n\t\t{\r\n\t\t\tif (sO_Suspension)\r\n\t\t\t{\r\n\t\t\t\tNxSpringDesc s = wheel2->getWheelShape()->getSuspension();\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_INDEX(O_Suspension));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,0,s.damper);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,1,s.spring);\r\n\t\t\t\t\tvtTools::ParameterTools::SetParameterStructureValue(pout,2,s.targetValue);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (sO_Contact)\r\n\t\t\t{\r\n\r\n\t\t\t\tpWheelContactData cData = *wheel2->getContact();\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(BB_OP_INDEX(O_Contact));\r\n\t\t\t\tif (pout)\r\n\t\t\t\t{\r\n\t\t\t\t\tpFactory::Instance()->copyTo(pout,cData);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tbeh->ActivateOutput(0);\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PVWGetCB\r\n// FullName: PVWGetCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\n#ifndef __VT_STRUCT_HELPER_H__\r\n#define __VT_STRUCT_HELPER_H__\r\n\r\n\r\n\r\n\r\nnamespace vtTools\r\n{\r\n\r\n\tnamespace ParameterTools\r\n\t{\r\n\r\n\t\tstruct StructurMember\r\n\t\t{\r\n\t\t\tCKGUID guid;\t\tXString name;\tXString defaultValue;\r\n\t\t\tCKObject *par;\r\n\t\t\tStructurMember()\r\n\t\t\t{\r\n\t\t\t\tguid = CKGUID(0,0);\t\tname = \"\";\t\tdefaultValue = \"\";\r\n\t\t\t}\r\n\r\n\t\t\tStructurMember(CKGUID _guid,XString _name,XString _defaultValue) :\r\n\t\t\tguid(_guid) , name(_name) , defaultValue(_defaultValue)\r\n\t\t\t{\r\n\t\t\t}\r\n\r\n\t\t};\r\n\r\n\t\tclass CustomStructure\r\n\t\t{\r\n\r\n\t\tpublic :\r\n\t\t\tCustomStructure(){}\r\n\t\t\tCustomStructure(XString name,CKGUID guid,StructurMember members[],int size) : mGuid(guid) , mName(name)\r\n\t\t\t{\r\n\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tStructurMember *p=new StructurMember(members[i].guid,members[i].name,members[i].defaultValue);\r\n\t\t\t\t\tgetArray().push_back(p);\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\tstd::vectorpars;\r\n\t\t\tstd::vector&getArray()\r\n\t\t\t{\r\n\t\t\t\treturn pars;\r\n\t\t\t}\r\n\r\n\t\t\tCKGUID mGuid;\r\n\t\t\tXString mName;\r\n\t\t};\r\n\r\n\t\tclass StructHelper\r\n\t\t{\r\n\r\n\t\tpublic :\r\n\r\n\t\t\tstatic XArraygetMemberGuids(CustomStructure _inStructure)\r\n\t\t\t{\r\n\t\t\t\tXArrayresult;\r\n\r\n\t\t\t\tint size = _inStructure.getArray().size();\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tStructurMember *m=_inStructure.getArray().at(i);\r\n\t\t\t\t\tresult.PushBack(m->guid);\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t\tstatic XString getLabelNames(CustomStructure _inStructure)\r\n\t\t\t{\r\n\t\t\t\tXString result;\r\n\r\n\t\t\t\tint size = _inStructure.getArray().size();\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tStructurMember *m=_inStructure.getArray().at(i);\r\n\t\t\t\t\tresult << m->name.CStr();\r\n\r\n\t\t\t\t\tif (i != size -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\r\n\t\t\tstatic XString getDefaultValue(CustomStructure _inStructure)\r\n\t\t\t{\r\n\t\t\t\tXString result;\r\n\r\n\t\t\t\tint size = _inStructure.getArray().size();\r\n\t\t\t\tfor (int i = 0 ; i < size ; i ++)\r\n\t\t\t\t{\r\n\t\t\t\t\tStructurMember *m=_inStructure.getArray().at(i);\r\n\t\t\t\t\tresult << m->defaultValue.CStr();\r\n\t\t\t\t\tif (i != size -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult << \";\";\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t}\r\n}\r\n\r\n#define STRUCT_ATTRIBUTE(G,N,D) vtTools::ParameterTools::StructurMember(G,N,D)\r\n#define DECLARE_STRUCT(T,N,G,A,S) CustomStructure cs##T(N,G,A,S)\r\n\r\n#define STRUCT_SIZE(SOURCE_MAP)\t(sizeof(SOURCE_MAP) / sizeof(SOURCE_MAP[0]))\r\n#define STRUCT_MEMBER_NAMES(SRC) vtTools::ParameterTools::StructHelper::getLabelNames(cs##SRC)\r\n#define STRUCT_MEMBER_GUIDS(SRC) vtTools::ParameterTools::StructHelper::getMemberGuids(cs##SRC)\r\n#define STRUCT_MEMBER_DEFAULTS(SRC) vtTools::ParameterTools::StructHelper::getDefaultValue(cs##SRC)\r\n\r\n\r\n#define REGISTER_CUSTOM_STRUCT(NAME,ENUM_TYPE,GUID,MEMBER_ARRAY,HIDDEN) DECLARE_STRUCT(ENUM_TYPE,NAME,GUID,MEMBER_ARRAY,STRUCT_SIZE(MEMBER_ARRAY)); \\\r\n\tXArray ListGuid##ENUM_TYPE = STRUCT_MEMBER_GUIDS(ENUM_TYPE);\\\r\n\tpm->RegisterNewStructure(GUID,NAME,STRUCT_MEMBER_NAMES(ENUM_TYPE).Str(),ListGuid##ENUM_TYPE);\\\r\n\tCKParameterTypeDesc* param_type##ENUM_TYPE=pm->GetParameterTypeDescription(GUID);\\\r\n\tif (param_type##ENUM_TYPE && HIDDEN) param_type##ENUM_TYPE->dwFlags|=CKPARAMETERTYPE_HIDDEN;\\\r\n\t_getCustomStructures().Insert(GUID,(CustomStructure*)&MEMBER_ARRAY)\r\n\r\n\r\n\r\n\r\n\r\n#define REGISTER_STRUCT_AS_ATTRIBUTE(NAME,ENUM_TYPE,CATEGORY,GUID,CLASS,MEMBER_ARRAY,USE_DEFAULTS) int att##ENUM_TYPE = attman->RegisterNewAttributeType(NAME,GUID,CLASS);\\\r\n\tattman->SetAttributeCategory(att##ENUM_TYPE,CATEGORY);\\\r\n\tif(USE_DEFAULTS)\\\r\n\tattman->SetAttributeDefaultValue(att##ENUM_TYPE,STRUCT_MEMBER_DEFAULTS(ENUM_TYPE).Str());\r\n\r\n\r\n\r\n#endif\r\n#ifndef __P_ATTRIBUTE_HELPER_H__\r\n#define __P_ATTRIBUTE_HELPER_H__\r\n\r\n#define PHYSIC_BODY_CAT \"Physic\"\r\n\r\n#define ATT_FUNC_TABLE_SIZE 12\r\n\r\n#include \"vtParameterGuids.h\"\r\n#include \"pManagerTypes.h\"\r\n\r\n//################################################################\r\n//\r\n// Declaration of rigid body related attribute callback function\r\n//\r\nint registerRigidBody(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\n\r\n//################################################################\r\n//\r\n// Declaration of various joint attribute callback functions \r\n//\r\nint registerJDistance(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJFixed(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJBall(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\n\r\nint registerJPrismatic(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJCylindrical(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJPointInPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJPointOnLine(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJRevolute(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJD6(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJD6Drive(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\nint registerJLimitPlane(CK3dEntity *target,int attributeType,bool set,bool isPostJob);\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief The global map of parameter type and registration function\r\n//\r\nstatic ObjectRegistration attributeFunctionMap[] = \r\n{\r\n\tObjectRegistration(VTS_PHYSIC_ACTOR,registerRigidBody),\r\n\tObjectRegistration(VTS_JOINT_DISTANCE,registerJDistance),\r\n\tObjectRegistration(VTS_JOINT_FIXED,registerJFixed),\r\n\tObjectRegistration(VTS_JOINT_BALL,registerJBall),\r\n\tObjectRegistration(VTS_JOINT_PRISMATIC,registerJPrismatic),\r\n\tObjectRegistration(VTS_JOINT_POINT_IN_PLANE,registerJPointInPlane),\r\n\tObjectRegistration(VTS_JOINT_POINT_ON_LINE,registerJPointOnLine),\r\n\tObjectRegistration(VTS_JOINT_CYLINDRICAL,registerJCylindrical),\r\n\tObjectRegistration(VTS_JOINT_REVOLUTE,registerJRevolute),\r\n\tObjectRegistration(VTS_JOINT_D6,registerJD6),\r\n\tObjectRegistration(VTS_JOINT_D6_DRIVES,registerJD6Drive),\r\n\tObjectRegistration(VTS_PHYSIC_JLIMIT_PLANE,registerJLimitPlane),\r\n};\r\n\r\n\r\n//################################################################\r\n//\r\n// Misc prototypes\r\n//\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief\tThis is the attribute callback function which is expected from Virtools.\r\n//\t\t\tWe only use this as dispatcher function because we have our own sub set.\r\n//\r\nvoid\tPObjectAttributeCallbackFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);\r\n\r\n\r\n//################################################################\r\n//\r\n// OLD \r\n//\r\n\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n//! \\brief this has become obselete \r\n//\r\nvoid\trecheckWorldsFunc(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);\t\t// --> old !\r\n\r\nvoid rigidBodyAttributeCallback(int AttribType,CKBOOL Set,CKBeObject *obj,void *arg);\t//-->new !\r\n\r\n\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#ifdef HAS_FLUIDS\r\n\r\n#include \"pFluid.h\"\r\n\nint RenderParticles_P(CKRenderContext *dev,CKRenderObject *obj,void *arg)\n{\r\n\tCK3dEntity* ent = (CK3dEntity *)obj;\r\n\tpFluid *fluid = (pFluid*)arg;\r\n\r\n\tif (!ent)\r\n\t\treturn 0;\r\n\r\n\r\n\r\n\r\n\tif (!fluid)\r\n\t\treturn 0;\r\n\r\n\r\n\tCKMesh *mesh = ent->GetCurrentMesh();\r\n\tint vCount = mesh->GetVertexCount();\r\n\n\tVxDrawPrimitiveData* data = dev->GetDrawPrimitiveStructure(CKRST_DP_TR_CL_VC,vCount);\n\tVxMatrix oldmatrix = dev->GetWorldTransformationMatrix();\n\tdev->SetWorldTransformationMatrix(oldmatrix*ent->GetInverseWorldMatrix());\n\n\t// we don't let write to the ZBuffer\n\tdev->SetTexture(NULL);\n\tdev->SetState(VXRENDERSTATE_ZWRITEENABLE , FALSE);\n\tdev->SetState(VXRENDERSTATE_SRCBLEND, VXBLEND_SRCALPHA);\n\tdev->SetState(VXRENDERSTATE_DESTBLEND, VXBLEND_ONE);\n\tdev->SetState(VXRENDERSTATE_ALPHABLENDENABLE, TRUE);\n\tdev->SetTextureStageState(CKRST_TSS_STAGEBLEND,0,1);\n\n\tfloat averageSize = 1 * 2.0f;\n\tfloat minSize = 4.0f;\n\tfloat maxSize = 10000.0f;\n\n\tfloat pointScaleA = 1.0f;\n\tfloat pointScaleB = 1.0f;\n\tfloat pointScaleC = 1.0f;\n\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\n\n\r\n\tdev->SetState(VXRENDERSTATE_SPECULARENABLE, FALSE);\r\n\tdev->SetState(VXRENDERSTATE_FILLMODE, VXFILL_SOLID);\r\n\tdev->SetState(VXRENDERSTATE_SHADEMODE, VXSHADE_GOURAUD);\r\n\r\n\tdev->SetTextureStageState(CKRST_TSS_TEXTUREMAPBLEND,VXTEXTUREBLEND_MODULATEALPHA);\r\n\tdev->SetTextureStageState(CKRST_TSS_MAGFILTER , VXTEXTUREFILTER_LINEAR);\r\n\tdev->SetTextureStageState(CKRST_TSS_MINFILTER , VXTEXTUREFILTER_LINEARMIPLINEAR);\r\n\r\n\t// States\r\n\tdev->SetState(VXRENDERSTATE_WRAP0 , 0);\r\n\tdev->SetState(VXRENDERSTATE_CULLMODE, VXCULL_NONE);\r\n\tdev->SetState(VXRENDERSTATE_SRCBLEND, VXBLEND_SRCALPHA);\r\n\tdev->SetState(VXRENDERSTATE_DESTBLEND, VXBLEND_ONE);\n\tdev->SetState(VXRENDERSTATE_ALPHABLENDENABLE, TRUE);\r\n\tdev->SetState(VXRENDERSTATE_ZWRITEENABLE , FALSE);\n\n\tdev->SetTextureStageState(CKRST_TSS_STAGEBLEND,0,1);\r\n\tdev->SetTextureStageState(CKRST_TSS_TEXTURETRANSFORMFLAGS, 0);\r\n\tdev->SetTextureStageState(CKRST_TSS_TEXCOORDINDEX, 0);\n\n\tdev->SetState(VXRENDERSTATE_POINTSPRITEENABLE,\tTRUE);\n\n\tdev->SetState(VXRENDERSTATE_POINTSIZE,\t*(DWORD*)&averageSize);\n\tdev->SetState(VXRENDERSTATE_POINTSIZE_MIN,*(DWORD*)&minSize);\n\tdev->SetState(VXRENDERSTATE_POINTSIZE_MAX,*(DWORD*)&maxSize);\n\tdev->SetState(VXRENDERSTATE_POINTSCALEENABLE,\tTRUE);\n\n\t\n\n\tdev->SetState(VXRENDERSTATE_POINTSCALE_A,*(DWORD*)&pointScaleA);\n\tdev->SetState(VXRENDERSTATE_POINTSCALE_B,*(DWORD*)&pointScaleB);\n\tdev->SetState(VXRENDERSTATE_POINTSCALE_C,*(DWORD*)&pointScaleC);\n\n\tXPtrStrided positions(data->Positions);\n\tXPtrStrided\tcolors(data->Colors);\n\n\n\n\tpParticle *particles = fluid->getParticles();\n\n\tfor (int i = 0 ; i < vCount ; i++)\r\n\t{\r\n\t\tVxColor color;\r\n\t\tcolor.Set(1.0f);\r\n\n\t\tpParticle *p = &(fluid->mParticleBuffer[i]);\n\t\tVxVector posi = getFrom(p->position);\n\t\t*positions\t= VxVector4(posi.x,posi.y,posi.z,0);\n\t\t*colors\t\t= RGBAFTOCOLOR(&(color));\n\t\t// next point\n\t\t//p = p->next;\n\n\t\t++colors;\n\t\t++positions;\n\t}\n\n\n\t// The drawing\n\tdev->DrawPrimitive(VX_POINTLIST,(WORD*)NULL,vCount,data);\n\tdev->SetState(VXRENDERSTATE_ZWRITEENABLE , TRUE);\n\tdev->SetWorldTransformationMatrix(oldmatrix);\n\r\n\treturn 0;\r\n}\r\n#endif@ECHO OFF\r\n\r\nrmdir .\\CMakeFiles /s /q\r\ndel .\\*.vcproj /q /f\r\ndel *.sln /q /f\r\ndel CMakeCache.txt /q /f\r\ndel cmake_install.cmake /q /f\r\n\r\n\r\n@ECHO ON\r\n\r\n#include \"Path.h\"\r\n\r\nchar* \r\nXPath::GetFileName(){\r\n\r\n\tchar *pc = data_.Str();\r\n\tint LastBackSlash =-1;\r\n\tint iChar = 0;\r\n\twhile(pc[iChar] != 0){\r\n\t\tif(pc[iChar] == '\\\\')LastBackSlash = iChar;\r\n\t\t\tiChar++;\r\n\t}\r\n\treturn pc + LastBackSlash +1;\r\n}\r\n\r\nchar*\r\nXPath::GetPath(){\r\n\t\r\n\tchar* PathCopy = data_.Str();\r\n\tPathRemoveFileSpec(PathCopy);\r\n\treturn PathCopy;\r\n\r\n}\r\n\r\n#include \r\nint\r\nXPath::absolute_levels()const{\r\n\r\n\t//count path_sepīs\r\n\t/*\r\n\tusing namespace std;\r\n\r\n\r\n\tstring s = data_.CStr();\r\n\tstring::iterator cit = find(s.begin(),s.end(),path_separator_);\r\n\tint n = 0;//;-) or how do you make this?\r\n\twhile ( cit != s.end()){\r\n\t\t++n;\r\n\t\tcit = find(cit+1 ,s.end(),path_separator_);\r\n\t}*/\r\n\treturn 1;\r\n}\r\n\r\n\r\n\r\n\r\n// vtAgeiaInterfaceEditorDlg.cpp : implementation file\r\n//\r\n\r\n#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceEditor.h\"\r\n#include \"vtAgeiaInterfaceEditorDlg.h\"\r\n#include \"vtAgeiaInterfaceKeyboardShortcuts.h\"\r\n#include \"vtAgeiaInterfaceCallback.h\"\r\n\r\n\r\n\r\n#ifdef _MFCDEBUGNEW\r\n#ifdef _DEBUG\r\n#define new DEBUG_NEW\r\n#undef THIS_FILE\r\nstatic char THIS_FILE[] = __FILE__;\r\n#endif\r\n#endif\r\n\r\nextern vtAgeiaInterfaceEditorApp theApp;\r\n\r\n\r\nDllEditorDlg* fCreateEditorDlg(HWND parent)\r\n{\r\n\tHRESULT r = CreateDllDialog(parent,IDD_EDITOR,&g_Editor);\r\n\treturn (DllEditorDlg*)g_Editor;\r\n}\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceEditorDlg dialog\r\n\r\n\r\nvtAgeiaInterfaceEditorDlg::vtAgeiaInterfaceEditorDlg(CWnd* pParent /*=NULL*/)\r\n\t: DllEditorDlg(vtAgeiaInterfaceEditorDlg::IDD, pParent)\r\n{\r\n\tmContext = NULL;\r\n\tpMan = NULL;\r\n\r\n\t//{{AFX_DATA_INIT(vtAgeiaInterfaceEditorDlg)\r\n\t\t// NOTE: the ClassWizard will add member initialization here\r\n\t//}}AFX_DATA_INIT\r\n}\r\n\r\n\r\nvoid vtAgeiaInterfaceEditorDlg::DoDataExchange(CDataExchange* pDX)\r\n{\r\n\tDllEditorDlg::DoDataExchange(pDX);\r\n\t//{{AFX_DATA_MAP(vtAgeiaInterfaceEditorDlg)\r\n\t\t// NOTE: the ClassWizard will add DDX and DDV calls here\r\n\t//}}AFX_DATA_MAP\r\n}\r\n\r\n\r\nBEGIN_MESSAGE_MAP(vtAgeiaInterfaceEditorDlg, DllEditorDlg)\r\n\t//{{AFX_MSG_MAP(vtAgeiaInterfaceEditorDlg)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\n/////////////////////////////////////////////////////////////////////////////\r\n// vtAgeiaInterfaceEditorDlg message handlers\r\n\r\nLRESULT vtAgeiaInterfaceEditorDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\tswitch (message)\r\n\t{\r\n\tcase WM_KEYDOWN:\r\n\t\t{\r\n\t\t\tKeyboardShortcutManager* ksm = GetInterface()->GetKeyboardShortcutManager();\r\n\t\t\t/*int commandID\t= ksm->TestKS(STR_CATEGORY,wParam);\r\n\t\t\tif (commandID)\r\n\t\t\t\tOnGlobalKeyboardShortcut(commandID);\r\n\t\t\t*/\r\n\t\t}break;\r\n\t}\r\n\t\r\n\treturn DllEditorDlg::WindowProc(message, wParam, lParam);\r\n}\r\n\r\nBOOL vtAgeiaInterfaceEditorDlg::SaveData(CKInterfaceObjectManager* iom)\r\n{\r\n\r\n\tif( !iom ) return FALSE;\r\n\r\n\tconst int chunkCount = iom->GetChunkCount();\r\n\r\n\tCKStateChunk* chunk = iom->GetChunk( 0 );\r\n\tif( !chunk ) return FALSE;\r\n\r\n\r\n\tint a = 0 ;\r\n\treturn TRUE;\r\n}\r\n\r\nBOOL vtAgeiaInterfaceEditorDlg::LoadData(CKInterfaceObjectManager* iom)\r\n{\r\n\r\n\r\n\tif( !iom ) return FALSE;\r\n\r\n\tconst int chunkCount = iom->GetChunkCount();\r\n\r\n\tCKStateChunk* chunk = iom->GetChunk( 0 );\r\n\tif( !chunk ) return FALSE;\r\n\r\n\tchunk->StartRead();\r\n\r\n\tchunk->CloseChunk();\r\n\treturn TRUE;\r\n\r\n\r\n}\r\nBOOL vtAgeiaInterfaceEditorDlg::PreTranslateMessage(MSG* pMsg) \r\n{\r\n\t// TODO: Add your specialized code here and/or call the base class\r\n\r\n\t/*if (\r\n\t\tpMsg->message >= WM_MOUSEFIRST &&\r\n\t\tpMsg->message <= WM_MOUSELAST)\r\n\t{\r\n\t\tMSG msg;\r\n\t\t::CopyMemory(&msg, pMsg, sizeof(MSG));\r\n\t\tm_wndToolTip.RelayEvent(pMsg);\r\n\t}\r\n\t*/\r\n\t/*switch(pMsg->message)\r\n\t{\r\n\tcase WM_MOUSEMOVE:\r\n\t\t{\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase WM_SYSKEYDOWN:\r\n\tcase WM_KEYDOWN:\r\n\t\t{\r\n\t\t\t\r\n\t\t}break;\r\n\t}*/\r\n\r\n\treturn DllEditorDlg::PreTranslateMessage(pMsg);\r\n}\r\n\r\nBOOL vtAgeiaInterfaceEditorDlg::OnInitDialog() \r\n{\r\n\tDllEditorDlg::OnInitDialog();\r\n\t\r\n\t// TODO: Add extra initialization here\r\n\r\n\t//EnableToolTips(TRUE);\r\n\t//CreateTooltip();\r\n\r\n\treturn TRUE; // return TRUE unless you set the focus to a control\r\n\t // EXCEPTION: OCX Property Pages should return FALSE\r\n}\r\n\r\n//this is the almost equivalent of OnInitDialog you should use if you want to\r\n//use the PluginInterface with GetInterface or if you want to be sure the toolbar is present\r\nvoid vtAgeiaInterfaceEditorDlg::OnInterfaceInit()\r\n{\r\n\tif (theApp.mContext && theApp.pMan)\r\n\t{\r\n\t\tinit(theApp.mContext,theApp.pMan);\r\n\t}\r\n\t//sample code : here we ask to listen to the _CKFILELOADED notification\r\n\t//which is send when a file is loaded from Virtools Dev's user interface\r\n\tObserveNotification(CUIK_NOTIFICATION_CKFILELOADED);\r\n\t\r\n\tObserveNotification(CUIK_NOTIFICATION_LEVEL_LOADED);\r\n\tObserveNotification(CUIK_NOTIFICATION_CKFILELOADED);\r\n\tObserveNotification(CUIK_NOTIFICATION_PRECKFILELOADED);\r\n\t\r\n\tObserveNotification(CUIK_NOTIFICATION_OBJECTROTCHANGED);\r\n\tObserveNotification(CUIK_NOTIFICATION_OBJECTPOSCHANGED);\r\n\tObserveNotification(CUIK_NOTIFICATION_SELECTIONCHANGED);\r\n\tObserveNotification(CUIK_NOTIFICATION_UPDATESETUP);\r\n\tObserveNotification(CUIK_NOTIFICATION_OBJECTPARAMSCHANGED);\r\n\r\n\r\n\r\n\r\n}\r\n\r\nvoid vtAgeiaInterfaceEditorDlg::objectSelChanged(DWORD par1,DWORD par2)\r\n{\r\n\r\n\t/*\r\n\tif (getContext())\r\n\t{\r\n\r\n\t\tgetContext()->OutputToConsoleEx(\"sel changed :\");\r\n\t\treturn ;\r\n\t\tCKBeObject *object = (CKBeObject*)mContext->GetObject(par1);\r\n\t\tif (object)\r\n\t\t{\r\n\t\t\tCKSTRING name = object->GetName();\r\n\t\t\tgetContext()->OutputToConsoleEx(\"sel changed : %s\",name);\r\n\r\n\t\t}\r\n\t}*/\r\n}\r\nvoid vtAgeiaInterfaceEditorDlg::objectPosChanged(CK_ID objID)\r\n{\r\n\tint id = objID;\r\n\t///MessageBox(\"asdasd\",\"asdasd\",1);\r\n/*\r\n\r\n\tif (mContext)\r\n\t{\r\n\t\tCKBeObject *object = (CKBeObject*)mContext->GetObject(objID);\r\n\t\tif (objID)\r\n\t\t{\r\n\t\t\tint a = 0 ; \r\n\t\t\tCKSTRING name = object->GetName();\r\n\t\t\tCKSTRING name2 = object->GetName();\r\n\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t*/\r\n}\r\nvoid vtAgeiaInterfaceEditorDlg::init(CKContext *ctx,PhysicManager *pm)\r\n{\r\n\tpMan = pm;\r\n\tmContext = ctx;\r\n\r\n}\r\n\r\n//called on WM_DESTROY\r\nvoid vtAgeiaInterfaceEditorDlg::OnInterfaceEnd() \r\n{\r\n}\r\n\r\nHRESULT vtAgeiaInterfaceEditorDlg::ReceiveNotification(UINT MsgID,DWORD Param1,DWORD Param2,CKScene* Context)\r\n{\r\n\tswitch(MsgID)\r\n\t{\r\n\t//sample code : \r\n\tcase CUIK_NOTIFICATION_CKFILELOADED:\r\n\t\t{\r\n\t\t}break;\r\n\tcase CUIK_NOTIFICATION_OBJECTPOSCHANGED:\r\n\t{\r\n\t\t//objectPosChanged(Param1);\r\n\t}\r\n\tcase CUIK_NOTIFICATION_SELECTIONCHANGED:\r\n\t\t{\r\n\r\n\t\t\t//objectSelChanged(Param1,Param2);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tcase CUIK_NOTIFICATION_UPDATESETUP:\r\n\t{\r\n\t\t\t//objectSelChanged(Param1,Param2);\r\n\t\t\tbreak;\r\n\t}\r\n\tcase CUIK_NOTIFICATION_OBJECTPARAMSCHANGED:\r\n\t\t{\r\n\t\t\t//objectSelChanged(Param1,Param2);\r\n\t\t\tbreak;\r\n\t\t}\r\n\tbreak;\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nvoid vtAgeiaInterfaceEditorDlg::CreateTooltip()\r\n{\r\n\tm_wndToolTip.Create(this);\r\n\tm_wndToolTip.Activate(TRUE);\r\n\r\n\t//delay after which the tooltip apppear, value of 1 is immediate, 0 is default (that is 500 for windows)\r\n\tm_wndToolTip.SetDelayTime(500);\r\n\r\n\t//change tooltip back color\r\n\t//m_wndToolTip.SetTipBkColor(CZC_176);\t\r\n\t//change tooltip text color\r\n\t//m_wndToolTip.SetTipTextColor(CZC_BLACK);\r\n\r\n\t//for each control you want to add a tooltip on, add the following line\r\n\t//m_wndToolTip.AddTool(CWnd* target,const char* tooltip_string);\r\n\r\n\t//delay after which the tooltip will auto close itself\r\n\tm_wndToolTip.SetDelayTime(TTDT_AUTOPOP,5000);\r\n\r\n\tm_wndToolTip.SetWindowPos(&(CWnd::wndTopMost),0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);\r\n\r\n\t//if you want multiline tooltip, you must add the following line (note that this represent the max tooltip width in pixel)\r\n\tm_wndToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, 500);\r\n}\r\nint vtAgeiaInterfaceEditorDlg::OnGlobalKeyboardShortcut(int commandID)\r\n{\r\n\treturn 0;\t//return 1 if successfull/keyboard shortcut has been processed\r\n}\r\n\r\nint vtAgeiaInterfaceEditorDlg::OnLocalKeyboardShortcut(int commandID)\r\n{\r\n\treturn 0;\t//return 1 if successfull/keyboard shortcut has been processed\r\n}\r\nvoid vtAgeiaInterfaceEditorDlg::OnCustomMenu(CMenu* menu,int startingCommandID,int endingCommandID)\r\n{\r\n\tmenu->AppendMenu(0,0 /*base ID*/ + startingCommandID,\"Sample Command 1\");\r\n\tmenu->AppendMenu(0,1 /*base ID*/ + startingCommandID,\"Sample Command 2\");\r\n}\r\n\r\nvoid vtAgeiaInterfaceEditorDlg::OnCustomMenu(int commandID)\r\n{\r\n\tswitch(commandID) {\r\n\tcase 0:\r\n\t\tAfxMessageBox(\"sample command 1 called\");\r\n\t\tbreak;\r\n\tcase 1:\r\n\t\tAfxMessageBox(\"sample command 2 called\");\r\n\t\tbreak;\r\n\t}\r\n}\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t AddNodalLink\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"N3dGraph.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorAddNodalLinkDecl();\r\nCKERROR CreateAddNodalLinkProto(CKBehaviorPrototype **);\r\nint AddNodalLink(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorAddNodalLinkDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Create Nodal Edge\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x47ea2c5c,0x5b6b2b81));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateAddNodalLinkProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"3D Transformations/Nodal Path\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateAddNodalLinkProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"Create Nodal Edge\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Nodal Path\",CKPGUID_GROUP);\r\n\tproto->DeclareInParameter(\"Start Node\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"End Node\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Difficult\",CKPGUID_FLOAT);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( AddNodalLink );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint AddNodalLink(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKAttributeManager* attman = ctx->GetAttributeManager();\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tCKGroup* group = (CKGroup*)beh->GetInputParameterObject(0);\t\t\t\r\n\tCKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName));\r\n\tif(!param) throw \"Given Group isn't a Network\";\r\n\tN3DGraph* graph;\r\n\tparam->GetValue(&graph);\r\n\r\n\tCK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\tCK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2);\r\n\tfloat b;\r\n\tbeh->GetInputParameterValue(3,&b);\r\n\tgraph->InsertEdge(s,e,b);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\r\n\r\n\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#ifndef __P_CALLBACK_SIGNATURE_H__\r\n#define __P_CALLBACK_SIGNATURE_H__\r\n\r\n#include \"pCommon.h\"\r\n#include \"IParameter.h\"\r\n#include \"vtBBHelper.h\"\r\n#include \"xDebugTools.h\"\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// wheel contact modify callback inputs\r\n//\r\ntypedef enum bInputsWheelContactModifyCallback\r\n{\r\n\tbbIWC_SrcObject,\r\n\tbbIWC_Point,\r\n\tbbIWC_Normal,\r\n\tbbIWC_Position,\r\n\tbbIWC_NormalForce,\r\n\tbbIWC_OtherMaterialIndex,\r\n\tbbIWC_Stub0,\r\n\tbbIWC_Stub1,\r\n};\r\nstatic BBParameter pInMapWheelContactModifyCallback[]=\r\n{\r\n\tBB_PIN(bbIWC_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbIWC_Point,CKPGUID_VECTOR,\"point\",\"\"),\r\n\tBB_PIN(bbIWC_Normal,CKPGUID_VECTOR,\"normal\",\"\"),\r\n\tBB_PIN(bbIWC_Position,CKPGUID_FLOAT,\"position\",\"\"),\r\n\tBB_PIN(bbIWC_NormalForce,CKPGUID_FLOAT,\"normalForce\",\"\"),\r\n\tBB_PIN(bbIWC_OtherMaterialIndex,CKPGUID_INT,\"otherMaterialIndex\",\"\"),\r\n\tBB_PIN(bbIWC_Stub0,CKPGUID_INT,\"stub0\",\"\"),\r\n\tBB_PIN(bbIWC_Stub1,CKPGUID_INT,\"stub1\",\"\"),\r\n};\r\n//----------------------------------------------------------------\r\n//\r\n// wheel contact modify callback outputs\r\n//\r\ntypedef enum bOutputsWheelContactModifyCallback\r\n{\r\n\tbbOWC_CreateContact,\r\n\tbbOWC_ModificationFlags,\r\n\tbbOWC_Point,\r\n\tbbOWC_Normal,\r\n\tbbOWC_Position,\r\n\tbbOWC_NormalForce,\r\n\tbbOWC_OtherMaterialIndex,\r\n\tbbOWC_Stub0,\r\n\tbbOWC_Stub1,\r\n};\r\nstatic BBParameter pOutMapWheelContactModifyCallback[]=\r\n{\r\n\tBB_PIN(bbOWC_CreateContact,CKPGUID_BOOL,\"createContact\",\"\"),\r\n\tBB_PIN(bbOWC_ModificationFlags,VTF_WHEEL_CONTACT_MODIFY_FLAGS,\"modificationFlags\",\"\"),\r\n\tBB_PIN(bbOWC_Point,CKPGUID_VECTOR,\"_point\",\"\"),\r\n\tBB_PIN(bbOWC_Normal,CKPGUID_VECTOR,\"_normal\",\"\"),\r\n\tBB_PIN(bbOWC_Position,CKPGUID_FLOAT,\"_position\",\"\"),\r\n\tBB_PIN(bbOWC_NormalForce,CKPGUID_FLOAT,\"_normalForce\",\"\"),\r\n\tBB_PIN(bbOWC_OtherMaterialIndex,CKPGUID_INT,\"_otherMaterialIndex\",\"\"),\r\n\tBB_PIN(bbOWC_Stub0,CKPGUID_INT,\"_stub0\",\"\"),\r\n\tBB_PIN(bbOWC_Stub1,CKPGUID_INT,\"_stub1\",\"\"),\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// contact modify callback ( has input and output )\r\n//\r\ntypedef enum bInputsContactModifyCallback\r\n{\r\n\tbbICM_SrcObject,\r\n\tbbICM_OtherObject,\r\n\tbbICM_MinImpulse,\r\n\tbbICM_MaxImpulse,\r\n\tbbICM_Error,\r\n\tbbICM_Target,\r\n\tbbICM_LP0,\r\n\tbbICM_LP1,\r\n\tbbICM_LO0,\r\n\tbbICM_LO1,\r\n\tbbICM_SF0,\r\n\tbbICM_SF1,\r\n\tbbICM_DF0,\r\n\tbbICM_DF1,\r\n\tbbICM_Restitution,\r\n};\r\nstatic BBParameter pInMapContactModifyCallback[]=\r\n{\r\n\tBB_PIN(bbICM_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbICM_OtherObject,CKPGUID_3DENTITY,\"otherObject\",\"\"),\r\n\tBB_PIN(bbICM_MinImpulse,CKPGUID_FLOAT,\"minImpulse\",\"\"),\r\n\tBB_PIN(bbICM_MaxImpulse,CKPGUID_FLOAT,\"maxImpulse\",\"\"),\r\n\tBB_PIN(bbICM_Error,CKPGUID_VECTOR,\"error\",\"\"),\r\n\tBB_PIN(bbICM_Target,CKPGUID_VECTOR,\"target\",\"\"),\r\n\tBB_PIN(bbICM_LP0,CKPGUID_VECTOR,\"localPosition0\",\"\"),\r\n\tBB_PIN(bbICM_LP1,CKPGUID_VECTOR,\"localPosition1\",\"\"),\r\n\tBB_PIN(bbICM_LO0,CKPGUID_QUATERNION,\"localOrientation0\",\"\"),\r\n\tBB_PIN(bbICM_LO0,CKPGUID_QUATERNION,\"localOrientation1\",\"\"),\r\n\tBB_PIN(bbICM_SF0,CKPGUID_FLOAT,\"staticFriction0\",\"\"),\r\n\tBB_PIN(bbICM_SF1,CKPGUID_FLOAT,\"staticFriction1\",\"\"),\r\n\tBB_PIN(bbICM_DF0,CKPGUID_FLOAT,\"dynamicFriction0\",\"\"),\r\n\tBB_PIN(bbICM_DF0,CKPGUID_FLOAT,\"dynamicFriction1\",\"\"),\r\n\tBB_PIN(bbICM_DF0,CKPGUID_FLOAT,\"restitution\",\"\"),\r\n};\r\n\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// contact modify callback ( has input and output )\r\n//\r\ntypedef enum bOutputsContactModifyCallback\r\n{\r\n\tbbOCM_ModifyFlags,\r\n\tbbOCM_CreateContact,\r\n\tbbOCM_MinImpulse,\r\n\tbbOCM_MaxImpulse,\r\n\tbbOCM_Error,\r\n\tbbOCM_Target,\r\n\tbbOCM_LP0,\r\n\tbbOCM_LP1,\r\n\tbbOCM_LO0,\r\n\tbbOCM_LO1,\r\n\tbbOCM_SF0,\r\n\tbbOCM_SF1,\r\n\tbbOCM_DF0,\r\n\tbbOCM_DF1,\r\n\tbbOCM_Restitution,\r\n};\r\n\r\nstatic BBParameter pOutMapContactModifyCallback[]=\r\n{\r\n\tBB_PIN(bbOCM_ModifyFlags,VTF_CONTACT_MODIFY_FLAGS,\"_modifyFlags\",\"\"),\r\n\tBB_PIN(bbOCM_CreateContact,CKPGUID_BOOL,\"createContact\",\"\"),\r\n\tBB_PIN(bbOCM_MinImpulse,CKPGUID_FLOAT,\"_minImpulse\",\"\"),\r\n\tBB_PIN(bbOCM_MaxImpulse,CKPGUID_FLOAT,\"_maxImpulse\",\"\"),\r\n\tBB_PIN(bbOCM_Error,CKPGUID_VECTOR,\"_error\",\"\"),\r\n\tBB_PIN(bbOCM_Target,CKPGUID_VECTOR,\"_target\",\"\"),\r\n\tBB_PIN(bbOCM_LP0,CKPGUID_VECTOR,\"_localPosition0\",\"\"),\r\n\tBB_PIN(bbOCM_LP1,CKPGUID_VECTOR,\"_localPosition1\",\"\"),\r\n\tBB_PIN(bbOCM_LO0,CKPGUID_QUATERNION,\"_localOrientation0\",\"\"),\r\n\tBB_PIN(bbOCM_LO0,CKPGUID_QUATERNION,\"_localOrientation1\",\"\"),\r\n\tBB_PIN(bbOCM_SF0,CKPGUID_FLOAT,\"_staticFriction0\",\"\"),\r\n\tBB_PIN(bbOCM_SF1,CKPGUID_FLOAT,\"_staticFriction1\",\"\"),\r\n\tBB_PIN(bbOCM_DF0,CKPGUID_FLOAT,\"_dynamicFriction0\",\"\"),\r\n\tBB_PIN(bbOCM_DF0,CKPGUID_FLOAT,\"_dynamicFriction1\",\"\"),\r\n\tBB_PIN(bbOCM_DF0,CKPGUID_FLOAT,\"_restitution\",\"\"),\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// contact notify callback\r\n//\r\ntypedef enum bInputsContactCallback\r\n{\r\n\tbbI_SrcObject,\r\n\tbbI_EventType,\r\n\tbbI_NormalForce,\r\n\tbbI_FForce,\r\n\tbbI_Point,\r\n\tbbI_PointNormalForce,\r\n\tbbI_FaceNormal,\r\n\tbbI_FaceIndex,\r\n\tbbI_Distance,\r\n\tbbI_OtherObject,\r\n};\r\nstatic BBParameter pInMapContactCallback[]=\r\n{\r\n\tBB_PIN(bbI_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbI_EventType,VTF_COLLISIONS_EVENT_MASK,\"eventType\",\"\"),\r\n\tBB_PIN(bbI_FaceNormal,CKPGUID_VECTOR,\"sumNormalForce\",\"\"),\r\n\tBB_PIN(bbI_FForce,CKPGUID_VECTOR,\"sumFrictionForce\",\"\"),\r\n\tBB_PIN(bbI_Point,CKPGUID_VECTOR,\"point\",\"\"),\r\n\tBB_PIN(bbI_PointNormalForce,CKPGUID_FLOAT,\"pointNormalForce\",\"\"),\r\n\tBB_PIN(bbI_FaceNormal,CKPGUID_VECTOR,\"faceNormal\",\"\"),\r\n\tBB_PIN(bbI_FaceIndex,CKPGUID_INT,\"faceIndex\",\"\"),\r\n\tBB_PIN(bbI_Distance,CKPGUID_FLOAT,\"distance\",\"\"),\r\n\tBB_PIN(bbI_OtherObject,CKPGUID_3DENTITY,\"otherObject\",\"\"),\r\n};\r\n//----------------------------------------------------------------\r\n//\r\n// trigger\r\n//\r\ntypedef enum bInputsTriggerCallback\r\n{\r\n\tbbIT_SrcObject,\r\n\tbbIT_EventType,\r\n\tbbIT_OtherObject,\r\n};\r\nstatic BBParameter pInMapTriggerCallback[]=\r\n{\r\n\tBB_PIN(bbIT_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbIT_EventType,VTF_TRIGGER,\"eventType\",\"\"),\r\n\tBB_PIN(bbIT_OtherObject,CKPGUID_3DENTITY,\"otherObject\",\"\"),\r\n};\r\n\r\n//----------------------------------------------------------------\r\n//\r\n// trigger\r\n//\r\ntypedef enum bInputsRaycastHitCallback\r\n{\r\n\tbbRH_SrcObject,\r\n\tbbRH_OtherObject,\r\n\tbbRH_WorldImpact,\r\n\tbbRH_WorldNormal,\r\n\tbbRH_FIndex,\r\n\tbbRH_FInternalIdex,\r\n\tbbRH_Distance,\r\n\tbbRH_UV,\r\n\tbbRH_Material,\r\n\tbbRH_Flags,\r\n};\r\n\r\ntypedef enum bInputsJointBreakCallback\r\n{\r\n\tbbJB_SrcObject,\r\n\tbbJB_OtherObject,\r\n\tbbJB_Force,\r\n\r\n};\r\n\r\nstatic BBParameter pInMapRaycastHitCallback[]=\r\n{\r\n\tBB_PIN(bbRH_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbRH_OtherObject,CKPGUID_3DENTITY,\"otherObject\",\"\"),\r\n\tBB_PIN(bbRH_WorldImpact,CKPGUID_VECTOR,\"impact\",\"\"),\r\n\tBB_PIN(bbRH_WorldNormal,CKPGUID_VECTOR,\"normal\",\"\"),\r\n\tBB_PIN(bbRH_FIndex,CKPGUID_INT,\"faceIndex\",\"\"),\r\n\tBB_PIN(bbRH_FInternalIdex,CKPGUID_INT,\"faceInternalIndex\",\"\"),\r\n\tBB_PIN(bbRH_Distance,CKPGUID_FLOAT,\"distance\",\"\"),\r\n\tBB_PIN(bbRH_UV,CKPGUID_2DVECTOR,\"uv\",\"\"),\r\n\tBB_PIN(bbRH_Material,CKPGUID_INT,\"material\",\"\"),\r\n\tBB_PIN(bbRH_Flags,VTF_RAY_HINTS,\"flags\",\"\"),\r\n\r\n};\r\n\r\n\r\nstatic BBParameter pInMapJointBreakCallback[]=\r\n{\r\n\tBB_PIN(bbJB_SrcObject,CKPGUID_3DENTITY,\"sourceObject\",\"\"),\r\n\tBB_PIN(bbJB_OtherObject,CKPGUID_3DENTITY,\"otherObject\",\"\"),\r\n\tBB_PIN(bbJB_Force,CKPGUID_FLOAT,\"Break Force\",\"\"),\r\n};\r\n\r\n#endif#include \"xDistributedPoint2F.h\"\r\n#include \"xMathStream.h\"\r\n#include \"xPredictionSetting.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n\r\nuxString \r\nxDistributedPoint2F::print(TNL::BitSet32 flags)\r\n{\r\n\treturn uxString();\r\n}\r\nvoid \r\nxDistributedPoint2F::updateFromServer(TNL::BitStream *stream)\r\n{\r\n\r\n\txMath::stream::mathRead(*stream,&mLastServerValue);\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t\txMath::stream::mathRead(*stream,&mLastServerDifference);\r\n\tsetValueState(E_DV_UPDATED);\r\n}\r\n\r\nvoid\r\nxDistributedPoint2F::updateGhostValue(TNL::BitStream *stream)\r\n{\r\n\r\n\txMath::stream::mathWrite(*stream,mCurrentValue);\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t\txMath::stream::mathWrite(*stream,mDifference);\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint2F::unpack(TNL::BitStream *bstream,float sendersOneWayTime)\r\n{\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tsendersOneWayTime *= 0.001f;\r\n\r\n\t\t\r\n\t\tPoint2F p;\r\n\t\txMath::stream::mathRead(*bstream,&p);\r\n\t\tPoint2F v;\t\r\n\t\txMath::stream::mathRead(*bstream,&v);\r\n\r\n\t\tPoint2F predictedPos = p + v * sendersOneWayTime;\r\n\t\tsetOwnersOneWayTime(sendersOneWayTime);\r\n\t\t\r\n\t\tmLastValue = mCurrentValue;\r\n\t\tmCurrentValue = predictedPos;\r\n\t\tmDifference= mCurrentValue - mLastValue;\r\n\t}\r\n\t\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tPoint2F p;\r\n\t\txMath::stream::mathRead(*bstream,&p);\r\n\t\tmLastValue = mCurrentValue;\r\n\t\tmLastServerValue =p;\r\n\t\tmCurrentValue = p;\r\n\t}\r\n\r\n\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvoid xDistributedPoint2F::pack(TNL::BitStream *bstream)\r\n{\r\n\t\r\n\txMath::stream::mathWrite(*bstream,mCurrentValue);\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t\txMath::stream::mathWrite(*bstream,mDifference);\r\n\t\r\n\tint flags = getFlags();\r\n\tflags &= (~E_DP_NEEDS_SEND);\r\n\tsetFlags(flags);\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\n\r\nbool\r\nxDistributedPoint2F::updateValue(Point2F value,xTimeType currentTime)\r\n{\r\n\tbool result = false;\r\n\t\r\n\tmLastTime = mCurrentTime;\r\n\tmCurrentTime = currentTime;\r\n\tmLastDeltaTime = mCurrentTime - mLastTime;\r\n\t\r\n\tmLastValue = mCurrentValue;\r\n mCurrentValue = value;\r\n\tmDifference = mCurrentValue - mLastValue;\r\n\t\r\n\tmThresoldTicker +=mLastDeltaTime;\r\n\r\n\tfloat lengthDiff = fabsf(mDifference.len());\r\n\tfloat timeDiffMs = ((float)mThresoldTicker) / 1000.f;\r\n\r\n\tint flags = getFlags();\r\n\tflags =E_DP_OK;\r\n\t\r\n\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_PREDICTED)\r\n\t{\r\n\t\tif (lengthDiff > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tPoint2F serverDiff = mCurrentValue-mLastServerValue ;\r\n\t\t\r\n\t\tif ( fabsf( serverDiff.len() ) > getPredictionSettings()->getMinDifference() )\r\n\t\t{\r\n\t\t\tif (mThresoldTicker2 > (getPredictionSettings()->getMinSendTime() * 0.2f) )\r\n\t\t\t{\r\n\t\t\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\t\t\tresult = true ;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (mThresoldTicker2 > getPredictionSettings()->getMinSendTime())\r\n\t\t{\r\n\t\t\tmThresoldTicker2 = 0 ;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t}\r\n\t}\r\n\tif (this->getPropertyInfo()->mPredictionType == E_PTYPE_RELIABLE)\r\n\t{\r\n\t\tflags =E_DP_NEEDS_SEND;\t\r\n\t\tresult = true ;\r\n\t\tmLastValue = value;\r\n\t\tmCurrentValue = value;\r\n\t}\r\n\tsetFlags(flags);\r\n\t\r\n\treturn result;\r\n}#include \"CKAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xDistTools.h\"\r\n#include \"xDistTypesAll.h\"\r\n#include \"xMathTools.h\"\r\n#include \"xDistributed3DObject.h\"\r\n#include \"xDistributedProperty.h\"\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \"xNetInterface.h\"\r\n#include \"vtConnection.h\"\r\n\r\n#include \"xDistributedBaseClass.h\"\r\n#include \"xDistributed3DObjectClass.h\"\r\n#include \"IDistributedClasses.h\"\r\n#include \"xDOStructs.h\"\r\n\r\n#include \"IDistributedObjectsInterface.h\"\r\n\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n#include \"xDistributedString.h\"\r\n#include \"xDistributedInteger.h\"\r\n#include \"xLogger.h\"\r\n\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorConnectToServerDecl();\r\nCKERROR CreateConnectToServerProto(CKBehaviorPrototype **);\r\nint ConnectToServer(const CKBehaviorContext& behcontext);\r\nCKERROR ConnectToServerCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorConnectToServerDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"NConnect\");\t\r\n\tod->SetDescription(\"Connects to a Server\");\r\n\tod->SetCategory(\"TNL/Server\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x69b86522,0x34cf3563));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateConnectToServerProto);\r\n\tod->SetCompatibleClassId(CKCID_OBJECT);\r\n\treturn od;\r\n}\r\n\r\n\r\ntypedef enum BB_INPAR\r\n{\r\n\tBB_IP_HOSTS,\r\n\tBB_IP_MODULES,\r\n\tBB_IP_LOGIN,\r\n\tBB_IP_PASSWORD\r\n};\r\n\r\ntypedef enum BB_OT\r\n{\r\n\r\n\tBB_O_CONNECTED,\r\n\tBB_O_WAITING,\r\n\tBB_O_TIME_OUT,\r\n\tBB_O_ERROR,\r\n\tBB_O_IN_USE,\r\n\r\n};\r\ntypedef enum BB_OP\r\n{\r\n\r\n\tBB_OP_CONNECTION_ID,\r\n\tBB_OP_HOST,\r\n\tBB_OP_PORT,\r\n\tBB_OP_ERROR,\r\n\tBB_OP_MAX_PLAYERS,\r\n\tBB_OP_CLIENT_ID\r\n};\r\n\r\nCKERROR CreateConnectToServerProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"NConnect\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"Connect\");\r\n\t\r\n\tproto->DeclareOutput(\"Connected\");\r\n\tproto->DeclareOutput(\"Waiting for Answer\");\r\n\tproto->DeclareOutput(\"Timeout\");\r\n\tproto->DeclareOutput(\"Error\");\r\n\tproto->DeclareOutput(\"Connection In Use\");\r\n\t\r\n\tproto->DeclareInParameter(\"Hosts\", CKPGUID_DATAARRAY, \"Hosts\");\r\n\tproto->DeclareInParameter(\"Modules\", CKPGUID_DATAARRAY, \"Modules\");\r\n\tproto->DeclareInParameter(\"Login\", CKPGUID_STRING, \"Player\");\r\n\tproto->DeclareInParameter(\"Password\", CKPGUID_STRING, \"Player\");\r\n\t\r\n\t\r\n\tproto->DeclareOutParameter(\"Connection ID\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Host\", CKPGUID_STRING, \"None\");\r\n\tproto->DeclareOutParameter(\"Port\", CKPGUID_INT, \"-1\");\r\n\tproto->DeclareOutParameter(\"Error\", VTE_NETWORK_ERROR, \"0\");\r\n\tproto->DeclareOutParameter(\"Client ID\", CKPGUID_INT, \"-1\");\r\n\r\n\tproto->DeclareSetting(\"Connection Timeout\", CKPGUID_FLOAT,\"2000\");\r\n\tproto->DeclareLocalParameter(\"currentArrayIndex\", CKPGUID_INT,0 );\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(ConnectToServer);\r\n\tproto->SetBehaviorCallbackFct(ConnectToServerCB);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n#include \"vtLogTools.h\"\r\n\r\n\r\nint ConnectToServer(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKMessageManager* mm = behcontext.MessageManager;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tvtNetworkManager *nman = GetNM();\r\n\tbbNoError(E_NWE_OK);\r\n\tCKDataArray* hostsarray = static_cast(beh->GetInputParameterObject(0));\r\n\tif (!hostsarray) \r\n\t{\r\n\t\tbbError(E_NWE_INVALID_PARAMETER);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\r\n\tint arrayIndex = 0;\r\n\tbeh->GetLocalParameterValue(1,&arrayIndex);\r\n\r\n\tfloat timeOut = 0.0f;\r\n\tbeh->GetLocalParameterValue(0,&timeOut);\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\r\n\t\r\n\tif (!nman->GetClientNetInterface())\r\n\t{\r\n\t\tnman->CreateClient(true,0,NULL);\r\n\t\tnman->GetClientNetInterface()->setConnectionTimeOut(timeOut);\r\n\t}\r\n\r\n\tfloat elapsed = nman->GetClientNetInterface()->getElapsedConnectionTime() + behcontext.DeltaTime;\r\n\tnman->GetClientNetInterface()->setElapsedConnectionTime(elapsed);\r\n\t\r\n\tif (arrayIndex > hostsarray->GetRowCount() -1 )\r\n\t{\r\n\t\tarrayIndex = 0;\r\n\t\tbeh->SetLocalParameterValue(1,&arrayIndex);\r\n\t\tbbError(E_NWE_NO_SERVER);\r\n\t\treturn FALSE;\r\n\t}\r\n\r\n\tif (nman->GetClientNetInterface()->isConnected())\r\n\t{\r\n beh->ActivateOutput(4);\r\n\t\treturn FALSE;\r\n\t}\r\n\t\r\n\t/************************************************************************/\r\n\t/* first start ?\t\t\t\t\t\t\t\t\t */\r\n\t/************************************************************************/\r\n\tif (!nman->GetClientNetInterface()->isConnectionInProgress())\r\n\t{\r\n\t\tCKCHAR fixedBuffer[256];\r\n\t\tCKSTRING hosts = fixedBuffer;\r\n\t\thostsarray->GetElementStringValue(arrayIndex,0,hosts);\r\n\t\tTNL::Address addr(hosts);\r\n\r\n\t\tif (strlen(hosts))\r\n\t\t{\r\n\t\t\txLogger::xLog(ELOGINFO,E_LI_CONNECTION,\"connecting to server:%s\",fixedBuffer);\r\n\t\t}\r\n\t\tnman->ConnectToServer(true,hosts);\r\n\t\tnman->GetClientNetInterface()->sendPing(hosts);\r\n\t\tnman->GetClientNetInterface()->setConnectionInProgress(true);\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* we are already trying to connect : */\r\n\t/************************************************************************/\r\n\tif(nman->GetClientNetInterface()->isConnectionInProgress())\r\n\t{\r\n\t\tif (nman->GetClientNetInterface()->getConnection())\r\n\t\t{\r\n\t\t\t/////////////////////////////////////////////////////////////////////////\r\n\t\t\t//connection established ?\r\n\t\t\tif (nman->GetClientNetInterface()->isValid())\r\n\t\t\t{\r\n\t\t\t\tnman->GetClientNetInterface()->setConnectionInProgress(false);\r\n\t\t\t\tTNL::Address addr = nman->GetClientNetInterface()->getConnection()->getNetAddress();\r\n\t\t\t\tarrayIndex = 0;\r\n\t\t\t\tbeh->SetLocalParameterValue(1,&arrayIndex);\r\n\t\t\t\tnman->GetClientNetInterface()->setConnected(true);\r\n\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\t/* we set the connection parameters :\t\t\t */\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\tCKCHAR fixedBuffer[256];\r\n\t\t\t\tCKSTRING hosts = fixedBuffer;\r\n\t\t\t\thostsarray->GetElementStringValue(arrayIndex,0,hosts);\r\n\t\t\t\tCKParameterOut *pout = beh->GetOutputParameter(1);\r\n\t\t\t\tpout->SetStringValue(hosts);\r\n\t\t\t\t\r\n\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\tint userID = nman->GetClientNetInterface()->getConnection()->getUserID();\r\n\t\t\t\t\r\n\r\n\t\t\t\tint connectionID = nman->GetClientNetInterface()->getConnectionList().size();\r\n\t\t\t\tbeh->SetOutputParameterValue(0,&connectionID);\r\n\t\t\t\tbeh->SetOutputParameterValue(4,&userID);\r\n\r\n\r\n\r\n\t\t\t\tbeh->ActivateOutput(0);\r\n\t\t\t\treturn CKBR_OK;\r\n\t\t\t}\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t// we check the time out\r\n\t\t\tif (nman->GetClientNetInterface()->getElapsedConnectionTime() > nman->GetClientNetInterface()->getConnectionTimeOut() )\r\n\t\t\t{\r\n\t\t\t\t//\r\n\t\t\t\tnman->GetClientNetInterface()->setElapsedConnectionTime(0.0f);\r\n\t\t\t\tnman->GetClientNetInterface()->setConnectionInProgress(false);\r\n\t\t\t\t\r\n\t\t\t\t//we delete all our data : \r\n\t\t\t\tif (nman->GetClientNetInterface()->getConnection())\r\n\t\t\t\t{\r\n\t\t\t\t\tnman->GetClientNetInterface()->getConnection()->disconnect(\"keiner\");\r\n\t\t\t\t\tnman->GetClientNetInterface()->setConnection(NULL);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//more hosts ? \r\n\t\t\t\tif (arrayIndex < hostsarray->GetRowCount() )\r\n\t\t\t\t{\r\n\t\t\t\t\tarrayIndex++;\r\n\t\t\t\t\tbeh->SetLocalParameterValue(1,&arrayIndex);\r\n\t\t\t\t\t//beh->ActivateOutput(2);\r\n\t\t\t\t}else\r\n\t\t\t\t{\r\n\t\t\t\t\txLogger::xLog(ELOGWARNING,E_LI_CONNECTION,\"No server was available\");\r\n\t\t\t\t\tbbError(E_NWE_NO_SERVER);\r\n\t\t\t\t\tarrayIndex = 0;\r\n\t\t\t\t\tbeh->SetLocalParameterValue(1,&arrayIndex);\r\n\t\t\t\t\tbeh->ActivateOutput(2);\r\n\t\t\t\t\treturn FALSE;\r\n\t\t\t\t}\r\n\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\tbeh->ActivateOutput(1);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn CKBR_ACTIVATENEXTFRAME;\r\n}\r\n\r\nCKERROR ConnectToServerCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKBeObject *beo = (CKBeObject *)beh->GetTarget();\r\n\tif (!beo) {\r\n\t\treturn CKBR_OWNERERROR;\r\n\t}\r\n \r\n\tif (behcontext.CallbackMessage==CKM_BEHAVIORATTACH) \r\n\t{\r\n\t\tint arrayIndex = 0;\r\n\t\tbeh->SetLocalParameterValue(1,&arrayIndex);\r\n\r\n\t}\r\n\r\n\treturn CKBR_OK;\r\n}#include \r\n#include \"CustomPlayerApp.h\"\r\n#include \"CustomPlayer.h\"\r\n#include \"CustomPlayerDefines.h\"\r\n\r\n#include \"resourceplayer.h\"\r\n#include \"CustomPlayerDialogGraphicPage.h\"\r\n#include \"CustomPlayerDialog.h\"\r\n\r\nIMPLEMENT_DYNAMIC(CustomPlayerDialog, CPropertySheet)\r\n\r\nBEGIN_MESSAGE_MAP(CustomPlayerDialog, CPropertySheet)\r\n\t//{{AFX_MSG_MAP(CModalShapePropSheet)\r\n\tON_COMMAND(ID_APPLY_NOW, OnApplyNow)\r\n\t//}}AFX_MSG_MAP\r\nEND_MESSAGE_MAP()\r\n\r\nCustomPlayerDialogAboutPage*aboutPage=NULL;\r\nCustomPlayerDialogGraphicPage *stylePage=NULL;\r\nCustomPlayerDialogErrorPage *errorPage=NULL;\r\n//************************************\r\n// Method: CModalShapePropSheet\r\n// FullName: CModalShapePropSheet::CModalShapePropSheet\r\n// Access: public \r\n// Returns: // Qualifier: : CPropertySheet(AFX_IDS_APP_TITLE, pWndParent)\r\n// Parameter: CWnd* pWndParent \r\n// Parameter: int displayErrorPage\r\n// Parameter: CString errorText\r\n//************************************\r\nCustomPlayerDialog::CustomPlayerDialog(CWnd* pWndParent,CString errorText)\r\n: CPropertySheet(AFX_IDS_APP_TITLE, pWndParent)\r\n{\r\n\t\t\r\n\r\n\tif (GetPlayer().GetPAppStyle()->g_ShowConfigTab)\r\n\t{\r\n\t\tAddPage(&m_GraphicPage);\r\n\t\tstylePage = &m_GraphicPage;\r\n\t}\r\n\tif (strlen(errorText))\r\n\t{\r\n\t\tAddPage(&m_errorPage);\r\n\t\terrorPage = &m_errorPage;\r\n\t\tm_ErrorText = errorText;\r\n\t\tm_errorPage.errorText = errorText;\r\n\t}\r\n\r\n\tif (GetPlayer().GetPAppStyle()->g_ShowAboutTab)\r\n\t{\r\n\t\tAddPage(&m_aboutPage);\r\n\t\taboutPage = &m_aboutPage;\r\n\t}\r\n}\r\n\r\nbool _checkOpenGLVersion(XString driverName)\r\n{\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tXArray::Iterator begin = ewinfo->g_OpenGLMask.Begin();\r\n\tXArray::Iterator end = ewinfo->g_OpenGLMask.End();\r\n\r\n\twhile(begin!=end)\r\n\t{\r\n\t\tXString supportedOpenglVersionString = *begin;\r\n\t\tif (supportedOpenglVersionString.Length())\r\n\t\t{\r\n\t\t\tif (driverName.Contains(supportedOpenglVersionString))\r\n\t\t\t{\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n return false;\r\n}\r\n//************************************\r\n// Method: _UpdateDriverList\r\n// FullName: _UpdateDriverList\r\n// Access: public \r\n// Returns: void\r\n// Qualifier:\r\n// Parameter: int DriverId\r\n//************************************\r\nvoid _UpdateDriverList(int DriverId)\r\n{\r\n\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tint count = GetPlayer().GetEnginePointers()->TheRenderManager->GetRenderDriverCount();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we fill the driver list :\r\n\tfor (int i=0;iTheRenderManager->GetRenderDriverDescription(i);\r\n\r\n\t\tXString driverName = desc->DriverName.CStr();\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we are using an OpenGL version restriction, the versions are specified in the player.ini seperated by a comma : 1.1,2.0\r\n\t\tif (driverName.Contains(\"OpenGL\"))\r\n\t\t{\r\n if (!_checkOpenGLVersion(driverName))\r\n {\r\n\t\t\t\tcontinue;\r\n }\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we add it to the drivers combo box : \r\n\t\tstylePage->m_Driver.AddString(desc->DriverName.CStr());\r\n\r\n\t\t//we set the driver in the listbox to driver we found in the player.ini\r\n\t\tif (i==DriverId)\r\n\t\t{\r\n\t\t\tstylePage->m_Driver.SetCurSel(i);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\r\nvoid _UpdateResolutionLists(HWND hwndDlg,int DriverId)\r\n{\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\tint count = GetPlayer().GetEnginePointers()->TheRenderManager->GetRenderDriverCount();\r\n\tint i=0;\r\n\tchar ChaineW[256];\r\n\tbool driverfound = false;\r\n\r\n\tint targetDriver = ewinfo->g_GoFullScreen ? ewinfo->g_FullScreenDriver : ewinfo->g_WindowedDriver ; \r\n\tVxDriverDesc *MainDesc=ep->TheRenderManager->GetRenderDriverDescription(targetDriver);\r\n\r\n\r\n\tXArraybpps;//temporary storage to avoid doubles in the list\r\n\tXArrayrrates;//temporary storage to avoid doubles in the list\r\n\tXArraymodes;//temporary storage to avoid doubles in the list\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we only display window resolutions according to the current display settings:\r\n\tHDC hdc;\r\n\tPAINTSTRUCT ps ;\r\n\thdc = BeginPaint (hwndDlg, &ps) ;\r\n\tint currentDesktopBpp = GetDeviceCaps (hdc, BITSPIXEL) ;\r\n\tint currentDesktopRRate = GetDeviceCaps (hdc, VREFRESH) ;\r\n\tEndPaint(hwndDlg,&ps);\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//we fill the bpp list \r\n\tfor (i=0;iDisplayModes.Size();i++)\r\n\t{\r\n\t\tXArray::Iterator it = bpps.Find(MainDesc->DisplayModes[i].Bpp);\r\n\r\n\r\n\t\tif( it == bpps.End() )\r\n\t\t{\r\n\t\t\tbpps.PushBack(MainDesc->DisplayModes[i].Bpp);\r\n\t\t\tsprintf(ChaineW,\"%d\",MainDesc->DisplayModes[i].Bpp);\r\n\t\t\tstylePage->m_Bpps.AddString(ChaineW);\r\n\r\n\t\t\tif (ewinfo->g_Bpp== MainDesc->DisplayModes[i].Bpp)\r\n\t\t\t{\r\n\t\t\t\tstylePage->m_Bpps.SetCurSel(stylePage->m_Bpps.GetCount()-1);\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//\twe fill the refresh list : \r\n\t\tit = rrates.Find(MainDesc->DisplayModes[i].RefreshRate);\r\n\t\tif( it == rrates.End() )\r\n\t\t{\r\n\t\t\trrates.PushBack(MainDesc->DisplayModes[i].RefreshRate);\r\n\t\t\tsprintf(ChaineW,\"%d\",MainDesc->DisplayModes[i].RefreshRate);\r\n\t\t\tstylePage->m_RRates.AddString(ChaineW);\r\n\t\t\tif (ewinfo->g_RefreshRate == MainDesc->DisplayModes[i].RefreshRate)\r\n\t\t\t{\r\n\t\t\t\tstylePage->m_RRates.SetCurSel(stylePage->m_RRates.GetCount()-1);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//we fill the resolution list, pseudo code : \r\n\t\t\r\n\t\t// create a string of the resolution given by the description \"MainDesc\", : \"WidthHeight\" or ie.: \"800600\"\r\n\t\tXString mode;mode<DisplayModes[i].Width<DisplayModes[i].Height;\r\n\r\n\t\t// have a look in temporary array whether it already exists : \r\n\t\tit = modes.Find(mode.ToInt());\r\n\r\n\t\t//\tthe iterator couldn't find the resolution, so add it to the modes (full screen + windowed) combo box \r\n\t\tif( it == modes.End() )\r\n\t\t{\r\n\r\n\t\t\t// create the final string for combo box item : \r\n\t\t\tsprintf(ChaineW,\"%d x %d\",MainDesc->DisplayModes[i].Width,MainDesc->DisplayModes[i].Height);\r\n\r\n\r\n\t\t\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n //we have a resolution restriction ? \r\n\t\t\tif (ewinfo->g_HasResMask)\r\n\t\t\t{\r\n\t\t\t\t// in the player.ini file you have two entries : \"XResolutions\" and \"YResolutions\", ie.: \r\n\t\t\t\t// XResolutions = 1024,800\r\n\t\t\t\t// YResolutions = 768,600\r\n // where you must have always an appropriate value for x or y ! \r\n\t\t\t\t\r\n\t\t\t\t// we check that the given width from the MainDescr is in the resolution mask \"ewinfo->g_ResMaskArrayX\"\r\n\t\t\t\t// which is filled during the startup in the function CCustomPlayer::PLoadEngineWindowProperties (CustomPlayerProfileXML.cpp)\r\n\r\n\t\t\t\tXArray::Iterator itx = ewinfo->g_ResMaskArrayX.Find( MainDesc->DisplayModes[i].Width);\r\n\r\n\t\t\t\t// if not, we just skip the current MainDescr : \r\n\t\t\t\tif(itx==ewinfo->g_ResMaskArrayX.End())\r\n\t\t\t\t{\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}else\r\n\t\t\t\t{\r\n\t\t\t\t\t//Ok, the given width is in the mask, so we also check that height matches :\r\n\r\n\t\t\t\t\t// we take the appropriate y value from the mask y-array : \r\n\t\t\t\t\tint widthsIndex = ewinfo->g_ResMaskArrayX.GetPosition(MainDesc->DisplayModes[i].Width) ;\r\n\t\t\t\t\tint appropriateYValue = *ewinfo->g_ResMaskArrayY.At(widthsIndex);\r\n\r\n\t\t\t\t\tif(appropriateYValue !=MainDesc->DisplayModes[i].Height )\r\n\t\t\t\t\t{\r\n //No !, so we can skip the MainDescr.\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\t////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t// add the modes string representation to our temp array : \r\n\t\t\t\tmodes.PushBack(mode.ToInt());\r\n\r\n\t\t\t\t// create the final string for combo box item : \r\n\t\t\t\t//sprintf(ChaineW,\"%d x %d\",MainDesc->DisplayModes[i].Width,MainDesc->DisplayModes[i].Height);\r\n\r\n\t\t\t\t// now add it to full screen resolution combo box : \r\n\t\t\t\tstylePage->m_FModes.AddString(ChaineW);\r\n\r\n\t\t\t\t//and to the windowed resolution combo box : \r\n\t\t\t\tstylePage->m_windowMode.AddString(ChaineW);\r\n\r\n\t\t\t\t// the current resolution equals the player.ini full screen value? so we set it as the selected one in the combo box :\r\n\t\t\t\tif (ewinfo->g_Height == MainDesc->DisplayModes[i].Height && ewinfo->g_Width == MainDesc->DisplayModes[i].Width )\r\n\t\t\t\t{\r\n\t\t\t\t\tstylePage->m_FModes.SetCurSel( stylePage->m_FModes.GetCount()-1 );\r\n\r\n\t\t\t\t}\r\n\t\t\t\t// the current resolution equals the player.ini windowed resolution value ? so we set it as the selected one in the combo box :\r\n\t\t\t\tif (ewinfo->g_HeightW == MainDesc->DisplayModes[i].Height && ewinfo->g_WidthW == MainDesc->DisplayModes[i].Width )\r\n\t\t\t\t{\r\n\t\t\t\t\tstylePage->m_windowMode.SetCurSel( stylePage->m_windowMode.GetCount()-1 );\r\n\t\t\t\t}\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\t// add the modes string representation to our temp array : \r\n\t\t\t\tmodes.PushBack(mode.ToInt());\r\n\r\n\t\t\t\t// create the final string for combo box item : \r\n\t\t\t\t//sprintf(ChaineW,\"%d x %d\",MainDesc->DisplayModes[i].Width,MainDesc->DisplayModes[i].Height);\r\n\r\n\t\t\t\t// now add it to full screen resolution combo box : \r\n\t\t\t\tstylePage->m_FModes.AddString(ChaineW);\r\n\r\n\t\t\t\t//and to the windowed resolution combo box : \r\n\t\t\t\tstylePage->m_windowMode.AddString(ChaineW);\r\n\r\n\t\t\t\t// the current resolution equals the player.ini full screen value? so we set it as the selected one in the combo box :\r\n\t\t\t\tif (ewinfo->g_Height == MainDesc->DisplayModes[i].Height && ewinfo->g_Width == MainDesc->DisplayModes[i].Width )\r\n\t\t\t\t{\r\n\t\t\t\t\tstylePage->m_FModes.SetCurSel( stylePage->m_FModes.GetCount()-1 );\r\n\r\n\t\t\t\t}\r\n\t\t\t\t// the current resolution equals the player.ini windowed resolution value ? so we set it as the selected one in the combo box :\r\n\t\t\t\tif (ewinfo->g_HeightW == MainDesc->DisplayModes[i].Height && ewinfo->g_WidthW == MainDesc->DisplayModes[i].Width )\r\n\t\t\t\t{\r\n\t\t\t\t\tstylePage->m_windowMode.SetCurSel( stylePage->m_windowMode.GetCount()-1 );\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nBOOL CustomPlayerDialog::OnInitDialog()\r\n{\r\n\r\n\t\r\n\t\r\n\r\n\tBOOL bResult = CPropertySheet::OnInitDialog();\r\n\r\n\t// add the preview window to the property sheet.\r\n\tCRect rectWnd;\r\n\tGetWindowRect(rectWnd);\r\n\tSetWindowPos(NULL, 0, 0,\t\trectWnd.Width() ,\t\trectWnd.Height(),\t\tSWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);\r\n\t\r\n\tCenterWindow();\r\n\r\n\r\n\tif(GetPlayer().GetPAppStyle()->g_ShowConfigTab)\r\n\t{\r\n\r\n\t\t\r\n\t\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\t\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\r\n\t\tif(ewinfo->g_GoFullScreen)\r\n\t\t\t_UpdateDriverList(ewinfo->g_FullScreenDriver);\r\n\t\telse\r\n\t\t\t_UpdateDriverList(ewinfo->g_WindowedDriver);\r\n\r\n\r\n\t\tif(ewinfo->g_GoFullScreen)\r\n\t\t{\r\n\t\t\t_UpdateResolutionLists(NULL,ewinfo->g_FullScreenDriver);\r\n\t\t\t\r\n\t\t\tif (ewinfo->g_FullScreenDriver < stylePage->m_Driver.GetCount() )\r\n\t\t\t{\r\n\t\t\t\tstylePage->m_Driver.SetCurSel( ewinfo->g_FullScreenDriver);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\telse{\r\n\r\n\t\t\t_UpdateResolutionLists(NULL,ewinfo->g_WindowedDriver);\r\n\r\n\t\t\t\r\n\t\t\tif (ewinfo->g_WindowedDriver < stylePage->m_Driver.GetCount() )\r\n\t\t\t{\r\n\t\t\t\tstylePage->m_Driver.SetCurSel( ewinfo->g_WindowedDriver );\r\n\t\t\t}\r\n\t\t\t\r\n\r\n\t\t}\r\n\r\n\r\n\r\n\r\n\r\n\t\tm_errorPage.errorText = m_ErrorText;\r\n\r\n\t\tstylePage->m_CB_FSSA.AddString(\"0\");\r\n\t\tstylePage->m_CB_FSSA.AddString(\"1\");\r\n\t\tstylePage->m_CB_FSSA.AddString(\"2\");\r\n\t\tstylePage->m_CB_FSSA.AddString(\"4\");\r\n\t\tstylePage->m_CB_FSSA.AddString(\"8\");\r\n\r\n\t\tstylePage->m_CB_FSSA.SetCurSel(ewinfo->FSSA/2);\r\n\t\tstylePage->m_CB_FSSA.UpdateData();\r\n\r\n\t\tstylePage->m_Bpps.SetCurSel(ewinfo->g_Bpp);\r\n\t\tstylePage->m_FullScreenBtn.SetCheck(ewinfo->g_GoFullScreen);\r\n\r\n\r\n\t}\r\n\r\n\tif(GetPlayer().GetPAppStyle()->g_ShowAboutTab)\r\n\t{\r\n\r\n\t\tthis->SetActivePage((CPropertyPage*)&m_aboutPage);\t\t\r\n\r\n\t}\r\n\r\n\tif ( m_ErrorText.GetLength() )\r\n\t{\r\n\t\tthis->SetActivePage((CPropertyPage*)&m_errorPage);\t\t\r\n\t}\r\n\r\n\treturn bResult;\r\n}\r\nvoid CustomPlayerDialog::OnApplyNow()\r\n{\r\n\tDefault();\r\n\r\n\tvtPlayer::Structs::xSEnginePointers* ep = GetPlayer().GetEnginePointers();\r\n\tvtPlayer::Structs::xSEngineWindowInfo* ewinfo = GetPlayer().GetEngineWindowInfo();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString bpp;\r\n\tstylePage->m_Bpps.GetLBText(stylePage->m_Bpps.GetCurSel(),bpp);\r\n\tXString oBpp(bpp);\r\n\tewinfo->g_Bpp = oBpp.ToInt();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString rr;\r\n\tstylePage->m_RRates.GetLBText(stylePage->m_RRates.GetCurSel(),rr);\r\n\tXString oRR(rr);\r\n\tewinfo->g_RefreshRate= oRR.ToInt();\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString fssa;\r\n\tstylePage->m_CB_FSSA.GetLBText(stylePage->m_CB_FSSA.GetCurSel(),fssa);\r\n\tXString oFSSA(fssa);\r\n\tewinfo->FSSA= oFSSA.ToInt();\r\n\r\n\tif (ewinfo->g_GoFullScreen)\r\n\t\tewinfo->g_FullScreenDriver = stylePage->m_Driver.GetCurSel();\r\n\telse\r\n\t\tewinfo->g_WindowedDriver = stylePage->m_Driver.GetCurSel();\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tewinfo->g_GoFullScreen = stylePage->m_FullScreenBtn.GetCheck();\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\tCString fmode;\r\n\tstylePage->m_FModes.GetLBText(stylePage->m_FModes.GetCurSel(),fmode);\r\n\r\n\r\n\tXStringTokenizer\ttokizer(fmode, \"x\");\r\n\tconst char*tok = NULL;\r\n\ttok = tokizer.NextToken(tok);\r\n\tXString width(tok);\r\n\ttok = tokizer.NextToken(tok);\r\n\tXString height(tok);\r\n\tewinfo->g_Width = width.ToInt();\r\n\tewinfo->g_Height = height.ToInt();\r\n\r\n\t{\r\n\r\n\t\tCString wmode;\r\n\t\tstylePage->m_windowMode.GetLBText(stylePage->m_windowMode.GetCurSel(),wmode);\r\n\t\tXStringTokenizer\ttokizer(wmode, \"x\");\r\n\t\tconst char*tok = NULL;\r\n\t\ttok = tokizer.NextToken(tok);\r\n\t\tXString width(tok);\r\n\t\ttok = tokizer.NextToken(tok);\r\n\t\tXString height(tok);\r\n\t\tewinfo->g_WidthW = width.ToInt();\r\n\t\tewinfo->g_HeightW = height.ToInt();\r\n\t}\r\n\r\n\tGetPlayer().PSaveEngineWindowProperties(CUSTOM_PLAYER_CONFIG_FILE,*GetPlayer().GetEngineWindowInfo());\r\n\r\n}\r\n\r\n\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetNodalDifficult\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"N3dGraph.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetNodalDifficultDecl();\r\nCKERROR CreateSetNodalDifficultProto(CKBehaviorPrototype **);\r\nint SetNodalDifficult(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetNodalDifficultDecl()\r\n{ \r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"SetNodalDifficult\");\t\r\n\tod->SetDescription(\"\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x77a61036,0x47496bde));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetNodalDifficultProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\tod->SetCategory(\"3D Transformations/Nodal Path\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetNodalDifficultProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = NULL;\r\n\tproto = CreateCKBehaviorPrototype(\"SetNodalDifficult\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\r\n\tproto->DeclareInParameter(\"Nodal Path\",CKPGUID_GROUP);\r\n\tproto->DeclareInParameter(\"Node\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Difficult\",CKPGUID_FLOAT);\r\n\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction( SetNodalDifficult );\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\t\r\n}\r\n\r\n\r\nint SetNodalDifficult(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\tCKAttributeManager* attman = ctx->GetAttributeManager();\r\n\r\n\tbeh->ActivateInput(0,FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\tCKGroup* group = (CKGroup*)beh->GetInputParameterObject(0);\t\t\t\r\n\tCKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName));\r\n\tif(!param) throw \"Given Group isn't a Network\";\r\n\tN3DGraph* graph;\r\n\tparam->GetValue(&graph);\r\n\r\n\tCK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1);\r\n\t\r\n\tfloat b;\r\n\tbeh->GetInputParameterValue(2,&b);\r\n\r\n\tgraph->SetDifficult(s,b);\r\n\tbeh->ActivateOutput(0);\r\n\r\n\treturn CKBR_OK;\r\n}\r\n#ifndef __P_FLUID_RENDER_SETTINGS_H__\r\n\t#define __P_FLUID_RENDER_SETTINGS_H__\r\n\r\n#include \"pTypes.h\"\r\n\r\n\r\nclass MODULE_API pFluidRenderSettings\r\n{\r\npublic:\r\n\r\n\tpFluidRenderSettings();\r\n\r\n\t// Constructor\r\n\tpFluidRenderSettings(CKContext* ctx,CK_ID entity,char* name);\r\n\r\n\t// the emitter 3d entity\r\n\tCK_ID\t\tm_Entity;\r\n\tCK_ID\t\tm_Texture;\r\n\tCK_ID\t\tm_Group;\r\n\tint\t\t\tm_MessageType;\r\n\tVxBbox\t\tm_EntityBbox;\r\n\r\n\tpParticleRenderType mRenderType;\r\n\r\n\tint m_MaximumParticles;\r\n\t// total number of particles\r\n\tint totalParticles;\r\n\t// particles already emitted\r\n\tint particleCount;\r\n\t// emits per frame\r\n\tint emitsPerFrame;\r\n\t// emits variation\r\n\tint emitsVar;\r\n\t// medium lifeSpan\r\n\tfloat m_Life;\r\n\t// life variation\r\n\tfloat m_LifeVariation;\r\n\r\n\t// trailing particles\r\n\tint\tm_TrailCount;\r\n\t// historic of recent particles.\r\n\r\n\t// render callback\r\n\tint (*m_RenderParticlesCallback)(CKRenderContext *dev,CKRenderObject *mov,void *arg);\r\n\r\n\tvoid SetState(CKRenderContext* dev,CKBOOL gouraud = FALSE);\r\n\t// NULL terminated linked list\r\n\t\r\n\t// the particles pool\r\n\tBYTE*\t\tm_BackPool;\r\n\r\n\r\n\t// start size\r\n\tfloat m_StartSize;\r\n\tfloat m_StartSizeVar;\r\n\t// end size\r\n\tfloat m_EndSize;\r\n\tfloat m_EndSizeVar;\r\n\r\n\r\n\t// Blend Modes\r\n\tVXBLEND_MODE m_SrcBlend;\r\n\tVXBLEND_MODE m_DestBlend;\r\n\r\n\t// Colors\r\n\t/////////////\r\n\tVxColor m_StartColor;\r\n\tVxColor m_StartColorVar;\r\n\tVxColor m_EndColor;\r\n\tVxColor m_EndColorVar;\r\n\r\n\t// Texture\r\n\t/////////////\r\n\tint m_InitialTextureFrame;\r\n\tint m_InitialTextureFrameVariance;\r\n\tint m_SpeedTextureFrame;\r\n\tint m_SpeedTextureFrameVariance;\r\n\tint m_TextureFrameCount;\r\n\tint m_TextureFrameloop;\r\n\r\n\t// FLAGS\r\n\tint m_EvolutionsFlags;\r\n\tint m_VariancesFlags;\r\n\tint m_InteractorsFlags;\r\n\tint m_DeflectorsFlags;\r\n\tint m_RenderMode;\r\n\r\n\t// Mesh\r\n\tCK_ID\tm_Mesh;\r\n\r\n\r\n\t// Context\r\n\tCKContext*\tm_Context;\r\n\r\n\tpFluidEmitter* mEmitter;\r\n\t\r\n\tpFluidEmitter* getEmitter() const { return mEmitter; }\r\n\tvoid setEmitter(pFluidEmitter* val) { mEmitter = val; }\r\n\r\n\tvoid setToDefault();\r\n\r\n\tstruct\tParticleHistoric\r\n\t{\r\n\t\tinline ParticleHistoric() {}\r\n\t\tinline ParticleHistoric(unsigned int size) :\r\n\t\tstart(0),\r\n\t\t\tcount(0)\r\n\t\t{\r\n\t\t\tparticles.Resize(size);\r\n\t\t}\r\n\r\n\t\tint\t\tstart;\r\n\t\tint\t\tcount;\r\n\t\tXArray\tparticles;\r\n\t};\r\n\t// Old particles.\r\n\tXClassArray old_pos;\r\n\tParticleHistoric\t&GetParticleHistoric(pParticle *part);\r\n\t\r\n\t\r\n\tCKBehavior*\t\t\tm_Behavior;\r\n\t\r\n\tvolatile bool hasBeenRendered; //used for cases where we compute once and render twice\r\n\tvolatile bool hasBeenEnqueud; //used for cases where we compute once and render twice\r\n\r\n\r\n\r\nprotected:\r\nprivate:\r\n};\r\n\r\n\r\n\r\n#endif#ifndef _XSTRING_H__\r\n#define _XSTRING_H__\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n\r\ntypedef char\t\tTAnsiChar;\r\n\r\n#ifdef _WIN32\r\n\ttypedef wchar_t TUnicodeChar;\r\n#else\r\n\ttypedef unsigned short TUnicodeChar;\r\n#endif\r\n\r\n\r\n//\r\n// Define an alias for the native character data type\r\n//\r\n#ifdef _UNICODE\r\n\ttypedef TUnicodeChar\t\tTChar;\r\n#else\r\n\ttypedef TAnsiChar\t\tTChar;\r\n#endif\r\n\r\n//\r\n// This macro creates an ASCII string (actually a no-op)\r\n//\r\n#define __xA(x) (x)\r\n\r\n//\r\n// This macro creates a Unicode string by adding the magic L before the string\r\n//\r\n#define __xU(x) (L##x)\r\n\r\n//\r\n// Define an alias for building a string in the native format\r\n//\r\n#ifdef _UNICODE\r\n#define __xT __xU\r\n#else\r\n#define __xT __xA\r\n#endif\r\n\r\n\r\nclass xString \r\n{\r\n\t\r\npublic:\r\n\r\n//\ttypedef xString uniStringPtr;\r\n\t//=======================================================\r\n\t//\r\n\t// Construction and destruction\r\n\t//\r\n\t\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Accessors\r\n\t//\r\n\tTChar *GetString();\r\n\tconst TAnsiChar *CStr() const;\r\n\t\r\n\tint GetLength()const;\r\n\tbool IsNull() const;\r\n\tbool IsValidIndex(const int Index)const ;\r\n\r\n\t//=======================================================\r\n\t//\r\n\t// Regular transformation functions\r\n\t//\t\r\n\tint Compare(const xString& ins, bool IgnoreCase = false)const; \r\n\r\n\tbool Find(xString& Str, int& Pos, bool IgnoreCase=false)\tconst\t;\r\n\tvoid Delete(int Pos, int Count);\r\n\tvoid Insert(int Pos, TChar c);\r\n\tvoid Insert(int Pos, const xString& input);\t\r\n\txString GetSubString(int Start, int Count, xString& Dest);\t\t// Crops out a substring.\r\n\t\r\n\t//=======================================================\r\n\t//\r\n\t// Special transformation functions\r\n\t//\r\n\tvoid VarArg(TChar *Format, ...);\r\n\tvoid EatLeadingWhitespace();\r\n\tvoid EatTrailingWhitespace()\t;\r\n\r\n\t \r\n\t//=======================================================\r\n\t//\r\n\t// Conversion functions\r\n\t//\r\n\tTAnsiChar *ToAnsi(TAnsiChar *Buffer, int BufferLen) const;\r\n\tTUnicodeChar *ToUnicode(TUnicodeChar *Buffer, int BufferLen) const;\r\n\tint ToInt() const;\r\n\t//=======================================================\r\n\t\r\n\r\n\txString();\r\n\txString(const xString& input);\r\n\txString(const TUnicodeChar *input);\r\n\txString(int size)\r\n\t{\r\n\r\n\t\tSize = size;\r\n\t\tLen = size -1;\r\n\t\tText = AllocStr(Size);\r\n\t}\r\n\r\n\tvirtual ~xString();\r\n\t//=======================================================\r\n\t//\r\n\t// Concatenation operators\r\n\t//\r\n\t\t// Concatenates two strings (see text)\r\n\r\n\t\r\n\tfriend xString operator +(const xString& Str1, const xString& Str2);\t// Concatenates two strings (see text)\r\n\t\r\n\t/*\r\n\txString& operator +(const TChar& Str,const xString& Str1);\r\n\txString& operator +(const char left[],const xString &right);\r\n\txString& operator +(const xString &right,const char left[]);\r\n\txString& operator +(const xString &right);\r\n\t*/\r\n\t\r\n\t/*\r\n\txString& operator +=(const xString& String)\t\t// Adds another string to the end of the\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// current one.\r\n\t\tif (String.Len > 0)\r\n\t\t{\r\n\t\t\tGrow(String.Len);\r\n\t\t\t_tcsncpy(&Text[Len], String.Text, String.Len);\r\n\t\t\tLen += String.Len;\r\n\t\t}\r\n\t}*/\r\n\r\n\t\r\n\r\n\t//xString& operator +=(const char input[]);\r\n\r\n\tvoid AssignFrom(const TAnsiChar *String)\t// Constructor building a Unicode string from a regular C\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// string in ANSI format (used for doing conversions).\r\n\t\tif (String == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = strlen(String) + 1;\t\t\t\t// Use ANSI strlen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iUnicode char-by-char\r\n\t\t\tText[i] = (TUnicodeChar)String[i];\r\n\t\tText[Len] = __xA('\\0');\r\n\t}\r\n\r\n\txString& operator +=(const xString& String)\t\t// Adds another string to the end of the\r\n\t{\t\r\n\t\tEatLeadingWhitespace();\r\n\t\tEatTrailingWhitespace();\r\n \r\n\t\t//Insert(Len,String);\r\n\t\t\r\n\r\n\t\tint len2 = strlen(CStr()); \r\n\t\tstd::string a1;\r\n\t\ta1+=CStr();\r\n\t\ta1+= String.CStr();\r\n\t\tFreeStr(Text);\r\n\t\tAssignFrom(a1.c_str());\r\n\r\n return *this;\r\n\r\n\t\t// current one.\r\n\t\tif (String.Len > 0)\r\n\t\t{\r\n\t\t\tGrow(String.Len);\r\n\t\t\tstrncpy(&Text[Len], String.Text, 2);\r\n\t\t\tLen += String.Len;\r\n\t\t}\r\n\t\treturn *this;\r\n\t}\r\n\t\r\n\t/*xString& operator +=(const char* String)\t\t// Adds another string to the end of the\r\n\t{\r\n\t\r\n\t\treturn *this << xString(String);\r\n\t}*/\r\n\t\r\n\t//=======================================================\r\n\t//\r\n\t// Access operators\r\n\t//\r\n\tTAnsiChar*Str();\r\n\toperator TAnsiChar*()\r\n\t{\r\n\t\r\n\t\t/*TAnsiChar*out =new TAnsiChar[Size];\r\n\t\tToAnsi(out,Size);\r\n\t\treturn out ? out : NULL ;*/\r\n\t return Text;\r\n\r\n\t}\r\n\toperator TUnicodeChar *() const;\r\n\tTChar& xString::operator [](int Pos);\r\n\r\n\t//\r\n\t// Assignment operators\r\n\t//\r\n\tvoid operator =(const xString& String)\t\t// Sets this string to the contents of another string.\r\n\t{\r\n\t\tAssignFrom(String);\r\n\t}\r\n\t\r\n#ifndef _UNICODE\r\n\tvoid operator =(const TAnsiChar *String)\t// Sets this string to the contents of a character array\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t// in ANSI format (only included in Unicode builds)\r\n\t\tif (String == NULL)\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = strlen(String) + 1;\t\t\t// Use ANSI strlen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iUnicode char-by-char\r\n\t\t\tText[i] = (TUnicodeChar)String[i];\r\n\t\tText[Len] = __xA('\\0');\r\n\t}\r\n\txString(const TAnsiChar *String)\t// Constructor building a Unicode string from a regular C\r\n\t{\t\t\t\t\t\t\t\t\t\t\t// string in ANSI format (used for doing conversions).\r\n\t\tif (String == NULL)\t\t\t\t\t\t// Early out if string is NULL\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = strlen(String) + 1;\t\t\t\t// Use ANSI strlen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iUnicode char-by-char\r\n\t\t\tText[i] = (TUnicodeChar)String[i];\r\n\t\tText[Len] = __xA('\\0');\r\n\t}\r\n#else\r\n\tvoid operator =(const TUnicodeChar *String)\t// Sets this string to the contents of a character array\r\n\t{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// in Unicode format (only included in ANSI builds)\r\n\t\tif (String == NULL)\r\n\t\t{\r\n\t\t\tText = NULL;\r\n\t\t\tSize = Len = 0;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tSize = wcslen(String) + 1;\t\t// Use Unicode wcslen function\r\n\t\tLen = Size-1;\r\n\t\tText = AllocStr(Size);\r\n\t\tfor (int i=0 ; iANSI char-by-char\r\n\t\t\tText[i] = (TAnsiChar)String[i];\r\n\t\tText[Len] = __xA('\\0');\r\n\t}\r\n\t\r\n#endif\r\n\r\n\r\n\r\n\t\r\n\t//=======================================================\r\n\t//\r\n\t// Comparison operators (operates through Compare()).\r\n\t// Functions exist for comparing both string objects and character arrays.\r\n\t//\r\n\t\r\n\tbool operator < (const xString& Str) const\t{ return (bool)(Compare(Str) == -1);\t\t\t\t}\r\n\tbool operator > (const xString& Str) const\t{ return (bool)(Compare(Str) == 1);\t\t\t\t\t}\r\n\tbool operator <=(const xString& Str) const\t{ return (bool)(Compare(Str) != 1);\t\t\t\t\t}\r\n\tbool operator >=(const xString& Str) const\t{ return (bool)(Compare(Str) != -1);\t\t\t\t}\r\n\tbool operator ==(const xString& Str) const\t{ return (bool)(Compare(Str) == 0);\t\t\t\t\t}\r\n\tbool operator !=(const xString& Str) const\t{ return (bool)(Compare(Str) != 0);\t\t\t\t\t}\r\n\tbool operator < (const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) == -1);\t}\r\n\tbool operator > (const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) == 1);\t\t}\r\n\tbool operator <=(const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) != 1);\t\t}\r\n\tbool operator >=(const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) != -1);\t}\r\n\tbool operator ==(const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) == 0);\t\t}\r\n\tbool operator !=(const TChar *Chr) const\t\t{ return (bool)(Compare(xString(Chr)) != 0);\t\t}\r\n\t\r\n\t// Concatenation operator\r\n\txString& operator << (const TChar* rValue);\r\n\r\n\tvoid _attachRight(const TCHAR*rValue);\r\n\t// Concatenation operator\r\n\txString& operator << (const char iValue);\r\n\r\n\t// Concatenation operator\r\n\txString& operator << (const int iValue);\r\n\r\n\t// Concatenation operator\r\n\t//xString& operator << (const signed iValue);\r\n\r\n\t// Concatenation operator\r\n\txString& operator << (const unsigned int iValue);\r\n\r\n\t// Concatenation operator\r\n\txString& operator << (const float iValue);\r\n\r\n\t// Concatenation operator\r\n\txString& operator << (const void* iValue);\r\n\t//=======================================================\r\n\t//\r\n\t// Protected low-level functions\r\n\t//\r\n\r\n\tvoid AssignFrom(const xString& Str);\r\n\tvoid AssignFrom(const TUnicodeChar *Str);\r\n\t\r\n\t\r\n\t\r\nprotected:\r\n\tvoid Optimize();\r\n\tvoid Grow(int Num);\r\n\t\r\n\r\n\tstatic TChar *AllocStr(int Size);\r\n\tstatic void FreeStr(TChar *Ptr);\r\n\t//=======================================================\r\n\t//\r\n\t// Protected data members\r\n\t//\r\n//protected:\r\n\tTChar\t\t\t\t\t\t*Text;\t\t\t// The actual character array\r\n\tint\t\t\t\t\t\tSize;\t\t\t\t// Number of bytes allocated for string\r\n\tint\t\t\t\t\t\tLen;\t\t\t\t// Number of characters in string\r\n\r\n\t\r\n\r\n};\r\n\r\n\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"vtAttributeHelper.h\"\r\n#include \r\n\r\n\r\nusing namespace vtTools::AttributeTools;\r\nusing namespace vtTools::ParameterTools;\r\n\r\nvtTools::ParameterTools::StructurMember breakTable[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"0\",\"250\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"1\",\"250\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"2\",\"300\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"3\",\"350\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"4\",\"450\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"5\",\"575\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"6\",\"625\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"7\",\"700\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"8\",\"1000\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"9\",\"1000\"),\r\n};\r\n\r\nvtTools::ParameterTools::StructurMember myStructWheelContactData[] =\r\n{\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Contact Point\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Contact Normal\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Longitudes Direction\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_VECTOR,\"Lateral Direction\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Contact Force\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Longitudes Slip\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Lateral Slip\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Longitudes Impulse\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Lateral Impulse\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(VTS_MATERIAL,\"Other Material\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_FLOAT,\"Contact Pos\",\"\"),\r\n\tSTRUCT_ATTRIBUTE(CKPGUID_3DENTITY,\"Colliding Entity\",\"\"),\r\n};\r\n\r\nvoid PhysicManager::_RegisterVehicleParameters()\r\n{\r\n\tCKParameterManager *pm = m_Context->GetParameterManager();\r\n\tCKAttributeManager* attman = m_Context->GetAttributeManager();\r\n\r\n\tCKParameterTypeDesc* param_type = NULL;\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Tire Function \r\n\t//\r\n\tpm->RegisterNewStructure(VTF_VWTIRE_SETTINGS,\"pTireFunction\",\r\n\t\t\"XML Link,Extremum Slip,Extremum Value,Asymptote Slip,Asymptote Value,Stiffness Factor\",\r\n\t\tVTE_XML_TIRE_SETTINGS,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT,CKPGUID_FLOAT);\t\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Motor related \r\n\t//\r\n\tpm->RegisterNewStructure(VTS_VMOTOR_ENTRY,\"RPM / Newton Meter\",\"RPM,Newton Meter\",CKPGUID_FLOAT,CKPGUID_FLOAT);\r\n\tparam_type=pm->GetParameterTypeDescription(VTS_VMOTOR_ENTRY);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\r\n\tpm->RegisterNewStructure(VTS_VMOTOR_TVALUES,\"pVehicleMotor Torques\",\"1,2,3,4,5,6,7\",\t\tVTS_VMOTOR_ENTRY,VTS_VMOTOR_ENTRY,\t\tVTS_VMOTOR_ENTRY,VTS_VMOTOR_ENTRY,\t\tVTS_VMOTOR_ENTRY,VTS_VMOTOR_ENTRY,\t\tVTS_VMOTOR_ENTRY);\r\n\r\n\r\n\tpm->RegisterNewStructure(VTS_VGEAR_RATIO_ENTRY,\"Gear / Ratio\",\"Gear,Ratio\",CKPGUID_INT,CKPGUID_FLOAT);\r\n\tparam_type=pm->GetParameterTypeDescription(VTS_VGEAR_RATIO_ENTRY);\n\tif (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN;\r\n\tpm->RegisterNewStructure(VTS_VGEAR_RATIOS,\"pVehicleGear List\",\"1,2,3,4,5,6,7\",\t\tVTS_VGEAR_RATIO_ENTRY,VTS_VGEAR_RATIO_ENTRY,\t\tVTS_VGEAR_RATIO_ENTRY,VTS_VGEAR_RATIO_ENTRY,\t\tVTS_VGEAR_RATIO_ENTRY,VTS_VGEAR_RATIO_ENTRY,\t\tVTS_VGEAR_RATIO_ENTRY);\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Vehicle Common\r\n\t//\r\n\tpm->RegisterNewFlags(VTF_VSTATE_FLAGS,\"pVehicleStateFlags\",\"Is Moving=1,Is Accelerated=2,Is Accelerated Forward=4,Is Accelerated Backward=8,All Wheels On Ground=16,Is Falling=32,Handbrake=64,Is Braking=128,Is Steering=256,Has Gearbox=512,Has Motor=1024\");\r\n\tpm->RegisterNewEnum(VTE_BRAKE_LEVEL,\"pVehicleBreakLevel\",\"No Break=-1,Small=0,Medium=1,High=2\");\r\n\tpm->RegisterNewEnum(VTE_BRAKE_XML_LINK,\"pVehicleXMLBrakeSettings\",\"Stub=1\");\r\n\tpm->RegisterNewEnum(VTE_VEHICLE_XML_LINK,\"pVehicleXMLLink\",\"Stub=1\");\r\n\r\n\tpm->RegisterNewFlags(VTF_BRAKE_FLAGS,\"pVehicleBreakFlags\",\"Use Table=1,Auto Break=2\");\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pVehicleBreakTable\",E_VBT_STRUCT,VTS_BRAKE_TABLE,breakTable,FALSE);\r\n\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Wheel \r\n\t//\r\n\r\n\tREGISTER_CUSTOM_STRUCT(\"pWheelContactData\",E_WCD_STRUCT,VTS_WHEEL_CONTACT,myStructWheelContactData,FALSE);\r\n\r\n\tpm->RegisterNewFlags(VTS_PHYSIC_WHEEL_FLAGS,\"pWheelFlags\",\"Steerable Input=1,Steerable Auto=2,Affected By Handbrake=4,Accelerated=8,Controlled by Vehicle=16,Affected by Differential=32,Ignore Tire Function=64\");\r\n\t//pm->RegisterNewFlags(VTS_PHYSIC_WHEEL_FLAGS,\"pWheelFlags\",\"Steerable Input=1,Steerable Auto=2,Affected By Handbrake=4,Accelerated=8,Build Lower Half=256,Use Wheel Shape=512,Controlled by Vehicle\");\r\n\tpm->RegisterNewFlags(VTF_VWSHAPE_FLAGS,\"pWheelShapeFlags\",\"AxisContactNormal=1,InputLateralSlip=2,InputLongitudinal=4,UnscaledSpringBehavior=8,EmulateLegacyWheel=32,ClampedFriction=64\");\r\n\r\n\tpm->RegisterNewStructure(VTS_PHYSIC_WHEEL_DESCR,\"pWheelDescr\",\r\n\t\t\"XML Link,Suspension,Spring Restitution,Spring Bias,Spring Damping,Maximum Brake Force,Friction To Side,Friction To Front,Inverse Wheel Mass,Wheel Flags,Wheel Shape Flags,Lateral Force Settings,Longitudinal Force Settings\",\r\n\t\tVTE_XML_WHEEL_SETTINGS,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tCKPGUID_FLOAT,\r\n\t\tVTS_PHYSIC_WHEEL_FLAGS,\r\n\t\tVTF_VWSHAPE_FLAGS,\r\n\t\tVTF_VWTIRE_SETTINGS,\r\n\t\tVTF_VWTIRE_SETTINGS);\t\r\n\r\n\tatt_wheelDescr = attman->RegisterNewAttributeType(\"pWheel\",VTS_PHYSIC_WHEEL_DESCR,CKCID_BEOBJECT);\r\n\tattman->SetAttributeCategory(att_wheelDescr ,\"Physic\");\r\n\r\n}\r\n#ifndef __xDistributed3DObject_h\r\n#define __xDistributed3DObject_h\r\n\r\n\r\n#include \"xDistributedObject.h\"\r\nclass x3DObjectData;\r\nclass xDistributedProperty;\r\n\r\nnamespace TNL\r\n{\r\n\tclass GhostConnection;\r\n}\r\n\r\n\r\n\r\nclass xDistributed3DObject\t: public xDistributedObject\r\n{\r\n\ttypedef xDistributedObject Parent;\r\n\tpublic:\r\n\t\txDistributed3DObject();\r\n\t\t~xDistributed3DObject();\r\n\r\n\t\t\n\t\tenum MaskBits {\n\t\t\tInitialMask = BIT(0), ///< This mask bit is never set explicitly, so it can be used for initialization data.\n\t\t\tPositionMask = BIT(1), ///< This mask bit is set when the position information changes on the server.\n\t\t};\r\n\r\n\t\t\r\n\t\tvoid doInitUpdate();\r\n\t\tvoid updateAll();\r\n\t\tvoid onGhostRemove();\r\n\t\tbool onGhostAdd(TNL::GhostConnection *theConnection);\n\t\tvoid onGhostAvailable(TNL::GhostConnection *theConnection);\n\t\tTNL::U32 packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream);\n\t\tvoid unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream);\r\n\t\tvoid performScopeQuery(TNL::GhostConnection *connection);\r\n\r\n\t\tTNL_DECLARE_RPC(c2sGetOwnerShip,(TNL::U32 userSrcID));\r\n\t\t\r\n\t\tvirtual void destroy();\r\n\t\tvirtual void update(float time);\r\n\r\n\r\n\t\tvirtual void initProperties();\r\n\t\tvoid pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvoid prepare();\r\n\t\t\r\n\t\txDistributedProperty *getProperty(int nativeType);\r\n\t\txDistributedProperty *getUserProperty(const char*name);\r\n\t\tuxString print(TNL::BitSet32 flags);\r\n\r\n\t\t\r\n\tprotected:\r\n\r\n\t\tTNL::StringPtr m_localAddress;\r\n\t\t\r\n\tpublic:\r\n\t\tTNL_DECLARE_CLASS(xDistributed3DObject);\r\n};\r\n#endif\r\n#pragma once\r\n\r\n\r\n// PBodyMainMDIEx frame with splitter\r\n\r\nclass PBodyMainMDIEx : public CMDIChildWndEx\r\n{\r\n\tDECLARE_DYNCREATE(PBodyMainMDIEx)\r\nprotected:\r\n\tPBodyMainMDIEx(); // protected constructor used by dynamic creation\r\n\tvirtual ~PBodyMainMDIEx();\r\n\r\n\tCSplitterWnd m_wndSplitter;\r\n\r\npublic:\r\n\tvirtual void OnFinalRelease();\r\n\r\nprotected:\r\n\tvirtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);\r\n\r\n\tDECLARE_MESSAGE_MAP()\r\n\tDECLARE_DISPATCH_MAP()\r\n\tDECLARE_INTERFACE_MAP()\r\n};\r\n\r\n\r\n#ifndef __base_macros_h__\r\n#define __base_macros_h__\r\n\r\n\r\n#ifndef API_EXPORT\r\n\t#define API_EXPORT __declspec(dllexport)\r\n#endif\r\n\r\n#ifndef API_INLINE\r\n\t#define API_INLINE __inline\r\n#endif\r\n\r\n#ifndef API_sCALL\r\n\t#define API_sCALL __stdcall\r\n#endif\r\n\r\n#ifndef API_cDECL\r\n\t#define API_cDECL __cdecl\r\n#endif\r\n\r\n#endif#ifndef SKINNED_MESH_H\r\n\r\n#define SKINNED_MESH_H\r\n\r\nclass NxMat34;\r\nclass NxScene;\r\nclass NxPhysicsSDK;\r\nclass NxShape;\r\n// Creates the illusion of a soft body simulation by mapping a deformable mesh to a set of constrained rigid bodies.\r\n// Can also be used for ragdoll graphics.\r\n\r\nnamespace NXU\r\n{\r\n\r\nclass NxuPhysicsCollection;\r\n\r\n};\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nclass SkinnedMeshInstance;\r\nclass SkinnedMesh;\r\nclass SoftMeshSystem;\r\n\r\nSkinnedMesh *sm_CreateSkinnedMesh(const char *fname);\r\n\r\nSkinnedMeshInstance *sm_CreateSkinnedMeshInstance(SkinnedMesh *model,NxScene *scene,const NxMat34 *rootNode);\r\n\r\nvoid sm_ReleaseSkinnedMeshInstance(SkinnedMeshInstance *fb);\r\nvoid sm_ReleaseSkinnedMesh(SkinnedMesh *fm);\r\nvoid sm_RenderSkinnedMeshInstance(SkinnedMeshInstance *fb);\r\nbool sm_MatchSkinnedMesh(const SkinnedMesh *model,const char *name); // true if these are the same names.\r\nvoid sm_onDeviceReset(SkinnedMesh *fsm,void *device);\r\nSoftMeshSystem * sm_locateRenderContext(NxShape *shape); // builds a rendering context for a shape of this type.\r\n\r\n};\r\n\r\n\r\n#endif\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorJSetFixedDecl();\r\nCKERROR CreateJSetFixedProto(CKBehaviorPrototype **pproto);\r\nint JSetFixed(const CKBehaviorContext& behcontext);\r\nCKERROR JSetFixedCB(const CKBehaviorContext& behcontext);\r\n\r\n\r\n\r\n//************************************\r\n// Method: FillBehaviorJSetFixedDecl\r\n// FullName: FillBehaviorJSetFixedDecl\r\n// Access: public \r\n// Returns: CKObjectDeclaration\t*\r\n// Qualifier:\r\n//************************************\r\nCKObjectDeclaration\t*FillBehaviorJSetFixedDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PJFixed\");\t\r\n\tod->SetCategory(\"Physic/Joints\");\r\n\tod->SetDescription(\"Creates a Fixed Joint between world('None') or an entity.\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2d80b0a,0x3d5a0caf));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateJSetFixedProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreateJSetFixedProto\r\n// FullName: CreateJSetFixedProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nCKERROR CreateJSetFixedProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PJFixed\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PJFixed \r\n\r\n\t
\r\n\tPJFixed is categorized in \\ref Joints\r\n\t
\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tCreates a fixed joint between a two bodies or the world.\r\n\t
\r\n\t
\r\n\r\n\t\r\n\t\\image html fixedJoint.png\r\n\r\n\t\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PJFixed.png\r\n\t\r\n\tThe fixed joint effectively glues two bodies together with no remaining degrees of freedom for relative motion. It is useful to set it to be breakable (see Breakable Joint) to simulate simple fracture effects.\r\n\r\n\tAn example for a fixed joint is a factory chimney divided into sections, each section held together with fixed joints. When the chimney is hit, it will break apart and topple over by sections rather than unrealistically falling over in one piece.\r\n\r\n\tDOFs removed: 6\r\n\tDOFs remaining: 0\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tOut: is activated when the process is completed.\r\n\t
\r\n\t
\r\n\tBody B: The second body. Leave blank to create a joint constraint with the world. \r\n\t
\r\n\t
\r\n\r\n\r\n\t

VSL : Creation


\r\n\t\r\n\t\\include pJFixed.vsl\r\n\t\r\n\t
\r\n\r\n\tIs utilizing #pRigidBody #pWorld #PhysicManager #pFactory::createJointFixed().
\r\n\r\n\t*/\r\n\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Body B\",CKPGUID_3DENTITY,\"ball2\");\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetFunction(JSetFixed);\r\n\tproto->SetBehaviorCallbackFct( JSetFixedCB);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: JSetFixed\r\n// FullName: JSetFixed\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint JSetFixed(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t//the object A: \r\n\t\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\t\tCK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);\r\n\t\t\r\n\t\tif (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Fixed))\r\n\t\t{\r\n\t\t\treturn CK_OK;\r\n\t\t}\r\n\r\n\t\t// the world : \r\n\t\tpWorld *worldA=GetPMan()->getWorldByBody(target); \r\n\t\tpWorld *worldB=GetPMan()->getWorldByBody(targetB); \r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tworldA = worldB;\r\n\t\t}\r\n\t\tif (!worldA)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t// the physic object A : \r\n\t\tpRigidBody*bodyA= worldA->getBody(target);\r\n\t\tpRigidBody*bodyB= worldA->getBody(targetB);\r\n\r\n\t\tif(bodyA || bodyB)\r\n\t\t{\r\n\r\n\t\t\tpJointFixed*joint =static_cast(worldA->getJoint(target,targetB,JT_Fixed));\r\n\t\t\t\r\n\t\t\tif (!joint)\r\n\t\t\t{\r\n\t\t\t\tjoint = static_cast(pFactory::Instance()->createFixedJoint(target,targetB));\r\n\t\t\t}\r\n\t\t\tbeh->ActivateOutput(0);\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n//************************************\r\n// Method: JSetFixedCB\r\n// FullName: JSetFixedCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR JSetFixedCB(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\treturn CKBR_OK;\r\n\r\n}/********************************************************************\r\n\tcreated:\t2006/01/18\r\n\tcreated:\t18:1:2006 17:12\r\n\tfilename: \te:\\public\\vt midi\\MidiManager.cpp\r\n\tfile path:\te:\\public\\vt midi\r\n\tfile base:\tMidiManager\r\n\tfile ext:\tcpp\r\n\t\r\n\tpurpose:\tmidi low-level-stuff\r\n*********************************************************************/\r\n\r\n\r\n\r\n#include \"CKAll.h\"\r\n#include \"MidiManager.h\"\r\n\r\n#include \"MidiSound/MidiSound.h\"\r\n\r\n// Constructor\r\nMidiManager::MidiManager(CKContext *ctx):CKMidiManager(ctx,\"Midi Manager\")\r\n{\r\n memset(noteState,0,sizeof(noteState));\r\n ctx->RegisterNewManager(this);\r\n}\r\n\r\n// Destructor\r\nMidiManager::~MidiManager()\r\n{\r\n}\r\n\r\n\r\n//-----------------------------\r\n// Midi Callback Function\r\n//-----------------------------\r\nvoid CALLBACK MidiInProc( HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ){\r\n\r\n\tMidiManager *mm = (MidiManager *) dwInstance;\r\n\r\n\tif (!mm->midiDeviceIsOpen)\r\n\t\treturn;\r\n\t\r\n\r\n\t midiMessage tmp;\r\n\t tmp.channel = (BYTE)((dwParam1 & 0x0F));\r\n\t tmp.command = (BYTE)((dwParam1 & 0xF0) >> 4);\r\n\t tmp.note = (BYTE)((dwParam1 & 0xFF00) >> 8);\r\n\t tmp.attack = (BYTE)((dwParam1 & 0xFF0000) >> 16);\r\n\t tmp.time = dwParam2;\r\n\r\n\t mm->listFromCallBack.PushBack(tmp);\r\n\r\n\r\n\t if( tmp.command==9 && tmp.attack!=0 ){ // note activated\r\n\t\tmm->ActivateNote(tmp.note, tmp.channel, TRUE);\r\n\t\treturn;\r\n\t }\r\n\t if( tmp.command==9 || tmp.command==8 ){ // note deactivated\r\n\t\tmm->ActivateNote(tmp.note, tmp.channel, FALSE);\r\n\t\treturn;\r\n\t }\r\n}\r\n\r\nvoid CALLBACK MidiOutProc( HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ){\r\n\r\n\tMidiManager *mm = (MidiManager *) dwInstance;\r\n\r\n\r\n}\r\n//-------------------\r\n// Midi Note State\r\n//-------------------\r\nvoid MidiManager::ActivateNote( int note, int channel, CKBOOL state){\r\n int notedec = note>>3;\r\n int dec = abs( (channel<<4) + notedec );\r\n \r\n if( dec>=MIDI_MAXNOTES ) dec = MIDI_MAXNOTES-1;\r\n\r\n if( state ){\r\n noteState[dec] |= 1 << (note-(notedec<<3));\r\n } else {\r\n noteState[dec] &= ~(1 << (note-(notedec<<3)));\r\n }\r\n}\r\n\r\nCKBOOL MidiManager::IsNoteActive(int note, int channel){\r\n int notedec = note>>3;\r\n int dec = abs( (channel<<4) + notedec );\r\n \r\n if( dec>=MIDI_MAXNOTES ) dec = MIDI_MAXNOTES-1;\r\n\r\n if( noteState[dec] & (1 << (note-(notedec<<3))) ) return TRUE;\r\n\r\n return FALSE;\r\n}\r\n\r\n\r\n//------------------\r\n//------------------\r\n// Manager Events\r\n//------------------\r\n//------------------\r\nCKERROR MidiManager::OnCKPlay()\r\n{\r\n if( m_Context->IsReseted() ){ // to be sure it's not a un-resume PLAY\r\n\t\tif (midiDeviceBBrefcount) {\r\n\t\t\tif (OpenMidiIn(DesiredmidiDevice)!=CK_OK || OpenMidiOut(DesiredmidiOutDevice)!=CK_OK ) {\r\n\t\t\t\t//m_Context->OutputToConsole(\"Trying to open default port (0)\");\r\n\t\t\t\tif( DesiredmidiDevice!=0 ){\r\n\t\t\t\t\tif( OpenMidiIn(0)!=CK_OK) {\r\n\t\t\t\t\t\t//m_Context->OutputToConsole(\"Unable to open Default port (0)\");\r\n\t\t\t\t\t\treturn CKERR_INVALIDOPERATION;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n }\r\n\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::OnCKInit()\r\n{\r\n\r\n midiDeviceHandle = 0;\r\n midiDeviceOutHandle = 0 ;\r\n midiDeviceIsOpen = FALSE;\r\n midiOutDeviceIsOpen = FALSE;\r\n midiCurrentDevice = 0;\r\n midiCurrentOutDevice = 0;\r\n DesiredmidiDevice = 0;\r\n DesiredmidiOutDevice= 0;\r\n midiDeviceBBrefcount = 0;\r\n \r\n\r\n int midiDeviceCount = midiInGetNumDevs();\r\n int midiOutDeviceCount = midiOutGetNumDevs();\r\n\r\n if( !midiDeviceCount ){\r\n m_Context->OutputToConsole(\"No Midi Device !\");\r\n return CK_OK;\r\n }\r\n\r\n MIDIINCAPS tmp; // get midi devices infos\r\n for( int a=0 ; a< midiDeviceCount ; a++ ){\r\n midiInGetDevCaps(a, &tmp,sizeof(tmp) );\r\n }\r\n\r\n MIDIOUTCAPS tmpO; // get midi out devices infos\r\n for( int z=0 ; z< midiOutDeviceCount ; z++ ){\r\n\t midiOutGetDevCaps(z, &tmpO,sizeof(tmpO) );\r\n }\r\n\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::OnCKEnd()\r\n{\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::OnCKReset()\r\n{\r\n if (midiDeviceIsOpen )\r\n\treturn CloseMidiIn();\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::CloseMidiIn() {\r\n\r\n\tif( midiDeviceHandle && midiDeviceIsOpen ){\r\n\t\tif (midiInStop( midiDeviceHandle )== MMSYSERR_NOERROR) {\r\n\r\n\t\t\tif (midiInClose(midiDeviceHandle) == MMSYSERR_NOERROR) {\r\n\r\n\t\t\t\tmidiDeviceIsOpen = FALSE;\r\n\t\t\t\treturn CK_OK;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n return CKERR_INVALIDOPERATION;\r\n}\r\n\r\nCKERROR MidiManager::CloseMidiOut() {\r\n\r\n\tif( midiDeviceOutHandle && midiOutDeviceIsOpen ){\r\n\t\t\tif (midiOutClose(midiDeviceOutHandle) == MMSYSERR_NOERROR) {\r\n\t\t\t\tmidiOutDeviceIsOpen = FALSE;\r\n\t\t\t\treturn CK_OK;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\treturn CKERR_INVALIDOPERATION;\r\n}\r\nCKERROR MidiManager::OpenMidiOut(int DesiredmidiDevice) {\r\n\r\n\tif(midiOutDeviceIsOpen) {\r\n\t\tm_Context->OutputToConsole(\"Midi Out Device Already open\",false);\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n\r\n\tMMRESULT mr;\r\n\t\r\n\tmr = midiOutOpen( &midiDeviceOutHandle, DesiredmidiOutDevice, 0, 0, CALLBACK_NULL);\r\n\r\n\r\n\tif(!midiDeviceOutHandle|| (mr!=MMSYSERR_NOERROR) )\t{\r\n\t\tm_Context->OutputToConsole(\"Failed to open Desired Midi Out Device\");\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n\tmidiOutDeviceIsOpen = TRUE;\r\n\tmidiCurrentOutDevice = DesiredmidiOutDevice;\r\n\r\n\tif (mr!=MMSYSERR_NOERROR){\r\n\t\tm_Context->OutputToConsole(\"Failed to Start Desired Midi Out Device\");\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\nCKERROR MidiManager::OpenMidiIn(int DesiredmidiDevice) {\r\n\r\n\tif(midiDeviceIsOpen) {\r\n\t\tm_Context->OutputToConsole(\"Midi Device Already open\");\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n \r\n MMRESULT mr;\r\n\t//midiDeviceHandle = NULL;\r\n\tmr = midiInOpen( &midiDeviceHandle, DesiredmidiDevice, (DWORD)MidiInProc, (unsigned long)this, CALLBACK_FUNCTION|MIDI_IO_STATUS );\r\n\t\r\n\r\n if(!midiDeviceHandle || (mr!=MMSYSERR_NOERROR) )\t{\r\n\t\tm_Context->OutputToConsole(\"Failed to open Desired Midi IN Device\");\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n\tmidiDeviceIsOpen = TRUE;\r\n\tmidiCurrentDevice = DesiredmidiDevice;\r\n ZeroMemory(&noteState, MIDI_MAXNOTES);\r\n mr = midiInStart( midiDeviceHandle );\r\n\tif (mr!=MMSYSERR_NOERROR){\r\n\t\tm_Context->OutputToConsole(\"Failed to Start Desired Midi IN Device\");\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n\treturn CK_OK;\r\n \r\n}\r\n\r\nCKERROR MidiManager::PostClearAll()\r\n{\r\n midiDeviceBBrefcount = 0;\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::PreProcess()\r\n{\r\n listFromCallBack.Swap(listForBehaviors);\r\n \r\n\r\n return CK_OK;\r\n}\r\n\r\nCKERROR MidiManager::PostProcess()\r\n{\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\tlistForBehaviors.Clear();\r\n\tif (midiDeviceIsOpen && (midiCurrentDevice!=DesiredmidiDevice)) {\r\n\t\tMMRESULT mreset;\r\n\t\tmreset = midiInReset(midiDeviceHandle);\r\n\t\tif (mreset != MMSYSERR_NOERROR) {\r\n\t\tm_Context->OutputToConsole(\"Unable to Reset the current Midi Device, before opening a new Midi device\",false);\r\n\t\treturn CKERR_INVALIDOPERATION;\r\n\t\t}\r\n\t\tif (CloseMidiIn()!= CK_OK)\r\n\t\t\treturn CKERR_INVALIDOPERATION;\r\n\r\n\t\tmidiDeviceIsOpen = FALSE;\r\n\r\n\t\tif (OpenMidiIn(DesiredmidiDevice)!=CK_OK)\r\n\t\t\treturn CKERR_INVALIDOPERATION;\r\n\t}\r\n\r\n //////////////////////////////////////////////////////////////////////////\r\n\r\n if (midiOutDeviceIsOpen && (midiCurrentOutDevice!=DesiredmidiOutDevice)) {\r\n\t MMRESULT mreset;\r\n\t mreset = midiOutReset(midiDeviceOutHandle);\r\n\t if (mreset != MMSYSERR_NOERROR) {\r\n\t\t m_Context->OutputToConsole(\"Unable to Reset the current Midi Out Device, before opening a new Midi Out device\",false);\r\n\t\t return CKERR_INVALIDOPERATION;\r\n\t }\r\n\t if (CloseMidiOut()!= CK_OK)\r\n\t\t return CKERR_INVALIDOPERATION;\r\n\r\n\t midiOutDeviceIsOpen = FALSE;\r\n\t if (OpenMidiOut(DesiredmidiOutDevice)!=CK_OK){\r\n m_Context->OutputToConsole(\"couldn't attach new midi out device\");\t\t\r\n\t\t return CKERR_INVALIDOPERATION;\r\n\t }\r\n }\r\n\r\n return CK_OK;\r\n}\r\n\r\n// Midi Sound Functions\r\nCKERROR \r\nMidiManager::SetSoundFileName(void* source,CKSTRING filename) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->SetSoundFileName(filename);\r\n}\r\n\r\nCKSTRING \r\nMidiManager::GetSoundFileName(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return NULL;\r\n\r\n\treturn (CKSTRING)ms->GetSoundFileName();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Play(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Start();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Restart(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Restart();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Stop(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Stop();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Pause(void* source,CKBOOL pause) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Pause();\r\n}\r\n\r\nCKBOOL \r\nMidiManager::IsPlaying(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\t\r\n\treturn ms->IsPlaying();\r\n}\r\n\r\nCKBOOL \r\nMidiManager::IsPaused(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\t\r\n\treturn ms->IsPaused();\r\n}\r\n\r\nvoid* \r\nMidiManager::Create(void* hwnd) \r\n{\r\n\treturn new MidiSound(hwnd);\r\n}\r\n\r\nvoid\t\r\nMidiManager::Release(void* source) \r\n{\r\n\tCloseFile(source);\r\n\tdelete ((MidiSound*)(source));\r\n}\r\n\r\nCKERROR \r\nMidiManager::OpenFile(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->OpenFile();\r\n}\r\n\r\nCKERROR \r\nMidiManager::CloseFile(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->CloseFile();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Preroll(void* source) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Preroll();\r\n}\r\n\r\nCKERROR \r\nMidiManager::Time(void* source,CKDWORD* pTicks) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->Time((DWORD*)pTicks);\r\n}\r\n\r\nCKDWORD \r\nMidiManager::MillisecsToTicks(void* source,CKDWORD msOffset) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->MillisecsToTicks(msOffset);\r\n}\r\n\r\nCKDWORD \r\nMidiManager::TicksToMillisecs(void* source,CKDWORD tkOffset) \r\n{\r\n\tMidiSound* ms = (MidiSound*)source;\r\n\tif (!ms) return CKERR_INVALIDPARAMETER;\r\n\r\n\treturn ms->TicksToMillisecs(tkOffset);\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n\r\n\r\n\r\nvoid PhysicManager::reloadXMLDefaultFile(const char*fName)\r\n{\r\n\r\n\t\r\n\tif (! fName || !strlen(fName))return;\r\n\r\n\r\n\r\n\t////////////////////////////////////////Load our physic default xml document : \r\n\tif (getDefaultConfig())\r\n\t{\r\n\t\tdelete m_DefaultDocument;\r\n\t\tm_DefaultDocument = NULL;\r\n\t\txLogger::xLog(XL_START,ELOGTRACE,E_LI_MANAGER,\"Deleted old default config\");\r\n\r\n\t} \r\n\r\n\tTiXmlDocument * defaultDoc = loadDefaults(XString(fName));\r\n\tif (!defaultDoc)\r\n\t{\r\n\t\tenableFlag(_getManagerFlags(),E_MF_LOADING_DEFAULT_CONFIG_FAILED);\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,\"Loading default config : PhysicDefaults.xml: failed\");\r\n\t\tsetDefaultConfig(NULL);\r\n\t}else\r\n\t{\r\n\t\tsetDefaultConfig(defaultDoc);\r\n\t}\r\n\r\n}dofile(\"ModuleConfig.lua\")\r\n\r\n\r\n--\tPrepares a Visual Studio Project\r\nfunction createDummyProject (packageConfig)\r\n\r\n\tproject(packageConfig.Name)\r\n\r\n\tkind \"StaticLib\"\r\n\r\n\tlanguage \"C++\"\r\n\r\n\tpremake.buildconfigs()\r\n\r\n\t-- \tExternal Virtools Directories ? If not, the variables from ModuleConfig.lua will be used !\r\n\t--\t\tThis assumes that the virtools headers and libs are in inside the module path : Dependencies\\vt\\...\r\n\tif _OPTIONS[\"ExternalVTDirectory\"] then\r\n\t\tdofile(_OPTIONS[\"ExternalVTDirectory\"])\r\n\tend\r\n\r\n\treturn premake.CurrentContainer\r\n\r\nend\r\n\r\n\r\n--\tModifies an project according to a supplied package config\r\nfunction evaluateConfigs(prj,packageConfig)\r\n\r\n\tfor cfg in premake.eachconfig(prj) do\r\n\r\n\tconfiguration(cfg.name)\r\n\r\n\t\tif packageConfig.TargetSuffix then\r\n\t\t\tsetfields(\"targetdir\", getBinDir(1)..\"/\"..cfg.name..\"/\".._OPTIONS[\"Dev\"]..packageConfig.TargetSuffix)\r\n\t\telse\r\n\t\t\tsetfields(\"targetdir\", getBinDir(1)..\"/\"..cfg.name..\"/\".._OPTIONS[\"Dev\"])\r\n\t\tend\r\n\r\n\r\n\t\tif packageConfig.Language then\r\n\t\t\tsetfields(\"language\", packageConfig.Language)\r\n\t\tend\r\n\r\n\r\n\t\tcfgDefine = { \t}\r\n\t\tcfgLinks = \t{\t}\r\n\r\n\t\t--~ \tHandling Virtools Packages\r\n\t\tif table.contains(packageConfig.Defines,\"VIRTOOLS_USER_SDK\") then\r\n\r\n\t\t\t--\t\t\tCompile to Virtools Dev directory ? :\r\n \t\t\tif _OPTIONS[\"DeployDirect\"] ==\"TRUE\" then\r\n \t\t\t\tsetfields(\"targetdir\", getVTDirectory():lower()..packageConfig.TargetSuffix )\r\n \t\t\tend\r\n\r\n\t\t\t-- \tNo?, then we compile to ../Bin/CfgName/Dev-Version and add a post compile step`which copies all stuff to dev\r\n\t\t\tif (_OPTIONS[\"DeployDirect\"]==nil and packageConfig.PostCommand and packageConfig.Type == \"SharedLib\") then\r\n\t\t\t\tsetfields(\"postbuildcommands\", packageConfig.PostCommand)\r\n\t\t\tend\r\n\r\n\t\t\tif _OPTIONS[\"Static\"] ==\"TRUE\" then\r\n\t\t\t\tcfgDefine = table.join( cfgDefine, { \"VX_LIB\" ; \"CK_LIB\" ; \"VNK_LI\" ; \"VSU_LIB\" ; \"VSM_LIB\" ; \"VSS_LIB\" ; \"CUSTOM_PLAYER_STATIC\";\"_AFXDLL\" } )\r\n\t\t\t\tif (packageConfig.Type==\"WindowApp\") or ( packageConfig.StaticOptions and (table.contains(packageConfig.StaticOptions,\"vtstatic\")) ) then\r\n\t\t\t\t\tcfgLinks = table.join( cfgLinks, { \"VxMathStatic\" ; \"CK2Static\" ; \"CKZlibStatic\" } )\r\n\t\t\t\tend\r\n\r\n\t\t\telse\r\n\t\t\t\tcfgDefine = table.join( cfgDefine, { \"MODULE_BASE_EXPORTS\" } )\r\n\t\t\t\tcfgLinks = table.join( cfgLinks, { \"VxMath\" ; \"CK2\" } )\r\n\t\t\tend\r\n\r\n\t\tend\r\n\r\n\r\n\t\tif _OPTIONS[\"Static\"] ==\"TRUE\" then\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"MODULE_STATIC\" } )\r\n\t\telse\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"MODULE_BASE_EXPORTS\" } )\r\n\t\tend\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\tsetfields(\"objdir\", OUTPUT_PATH_OFFSETT_TO_TMP..\"/\".._ACTION..\"/\"..prj.name..\"/\"..cfg.name )\r\n\r\n\r\n\r\n\r\n\t\t-- If the compilation is intended as end-user distribution, please define ReleaseRedist\r\n\t\t--\tOtherwise the end user can use OUR building blocks for authoring. This is explicitly\r\n\t\t--\trestricted and a license violation towards VTMOD\r\n\t\tif cfg.name == \"ReleaseRedist\" then\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"ReleaseRedist\" ; \"VIRTOOLS_RUNTIME_VERSION\" } )\r\n\t\tend\r\n\r\n\t\tif cfg.name == \"ReleaseDemo\" then\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"ReleaseDemo\" } )\r\n\t\tend\r\n\r\n\t\t--\tSolving a Premake Bug\r\n\t\tif cfg.name == \"Debug\" then\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"DEBUG\" ; \"_DEBUG\" } )\r\n setfields(\"flags\", \"Symbols\" )\r\n\t\telse\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"NDEBUG\" } )\r\n\t\t\tsetfields(\"flags\", \"Optimize\" )\r\n\t\tend\r\n\r\n\t\tif cfg.name == \"ReleaseDebug\" then\r\n setfields(\"flags\", \"Symbols\" )\r\n\t\tend\r\n\r\n\t\t-- Visual Studio 2005 specific\r\n\r\n\t\tif ( _ACTION == \"vs2005\") then\r\n\t\t\tcfgDefine = table.join( cfgDefine, { \"_CRT_SECURE_NO_DEPRECATE\" } )\r\n\t\tend\r\n\r\n\r\n\t\t--\tweb player fix\r\n\t\tif _OPTIONS[\"ExtraDefines\"] and _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\t\t\tpackageConfig.Defines = table.join(packageConfig.Defines,{ \"WebPack\" })\r\n\t\t\t\t--cfgDefine = table.join( cfgDefine, { \"ReleaseRedist\" ; \"VIRTOOLS_RUNTIME_VERSION\" } )\r\n\t\tend\r\n\r\n\r\n\t\tsetfields(\"buildoptions\", table.join( packageConfig.Options ) )\r\n\t\tsetfields(\"defines\", table.join( table.join(packageConfig.Defines),cfgDefine ) )\r\n\t\tsetfields(\"links\", table.join( table.join(packageConfig.links),cfgLinks) )\r\n\r\n\r\n\tend\r\n\r\nend\r\n\r\n\r\n\r\n\r\n\r\nfunction createStaticPackage (packageConfig)\r\n\r\n\r\n\r\n\tlastProject = createDummyProject(packageConfig)\r\n\tlastProject.name = packageConfig.Name\r\n\r\n\tsetfields(\"location\",\"./\".._ACTION.._OPTIONS[\"Dev\"])\r\n\tsetfields(\"files\",table.join(packageConfig.Files))\r\n\r\n\t--if table.contains(packageConfig.Defines,\"VIRTOOLS_USER_SDK\") then\r\n\t\tif (_OPTIONS[\"Static\"] ==\"TRUE\" and packageConfig.Type==\"SharedLib\" ) then\r\n\t\t\tif ( packageConfig.StaticOptions and (table.contains(packageConfig.StaticOptions,\"convert\")) ) then\r\n\t\t\tpackageConfig.Type =\"StaticLib\"\r\n\t\t\tend\r\n\t\tend\r\n\t--end\r\n\r\n\tsetfields(\"kind\",packageConfig.Type)\r\n\tsetfields(\"links\", table.join( packageConfig.Libs ) )\r\n\r\n\r\n\t--~ \tHandling a Virtools Package\r\n\tif table.contains(packageConfig.Defines,\"VIRTOOLS_USER_SDK\") then\r\n\r\n\t\t--~ \t\tVirtools Include Directories\r\n\r\n\r\n\t\tif _OPTIONS[\"ExtraDefines\"] and _OPTIONS[\"ExtraDefines\"]==\"WebPack\" then\r\n\t\t\tpackageConfig.Libs = table.join(packageConfig.Libs,{ \"Camera\" })\r\n\t\t\tsetfields(\"links\", table.join( packageConfig.Libs ) )\r\n\t\tend\r\n\r\n\t\tDevIncludeDir = {\tgetVTDirectory():lower()..\"/SDK/Includes\"\t}\r\n\t\tpackageConfig.Includes = table.join(packageConfig.Includes,DevIncludeDir)\r\n\r\n\t\t--~ \t\tVirtools Library Directories\r\n\t\tDevLibDir = {\tgetVTDirectory():lower()..\"/SDK/Lib/Win32/Release\"\t}\r\n\t\tpackageConfig.LibDirectories = table.join(packageConfig.LibDirectories,DevLibDir)\r\n\r\n\t\t--\t\tHandling Static ----\r\n\r\n\r\n\tend\r\n\r\n\r\n\tsetfields(\"includedirs\", table.join(packageConfig.Includes))\r\n\tsetfields(\"libdirs\", table.join( packageConfig.LibDirectories ) )\r\n\r\n\tif packageConfig.ExludeFiles then\r\n\t\tsetfields(\"excludes\",table.join(packageConfig.ExludeFiles))\r\n\tend\r\n\r\n\tevaluateConfigs(lastProject,packageConfig)\r\n\r\nend\r\n\r\nfunction getVTDirectory()\r\n\r\n\tif _OPTIONS[\"Dev\"] == \"Dev35\" then\r\n\t\treturn DEV35DIR\r\n\tend\r\n\r\n\tif _OPTIONS[\"Dev\"] == \"Dev40\" then\r\n\t\treturn DEV40DIR\r\n\tend\r\n\r\n\tif _OPTIONS[\"Dev\"] == \"Dev41\" then\r\n\t\treturn DEV41DIR\r\n\tend\r\n\r\n\tif _OPTIONS[\"Dev\"] == \"Dev5\" then\r\n\t\treturn DEV5DIR\r\n\tend\r\n\r\n\treturn DEV40DIR\r\n\r\nend\r\n\r\nfunction setfields (name, value)\r\n\r\n\tlocal kind = premake.fields[name].kind\r\n\tlocal scope = premake.fields[name].scope\r\n\tlocal allowed = premake.fields[name].allowed\r\n\r\n\tif (kind == \"string\") then\r\n\t\treturn premake.setstring(scope, name, value, allowed)\r\n\telseif (kind == \"path\") then\r\n\t\treturn premake.setstring(scope, name, path.getabsolute(value))\r\n\telseif (kind == \"list\") then\r\n\t\treturn premake.setarray(scope, name, value, allowed)\r\n\telseif (kind == \"dirlist\") then\r\n\t\treturn premake.setdirarray(scope, name, value)\r\n\telseif (kind == \"filelist\") then\r\n\t\treturn premake.setfilearray(scope, name, value)\r\n\tend\r\n\r\n\r\nend\r\n\r\nfunction getBinDir(oneUp)\r\n\tres= OUTPUT_PATH_OFFSETT_TO_PROJECTFILES\r\n\r\n\tif oneUp==1 then\r\n\t\tres= OUTPUT_PATH_OFFSETT_TO_PROJECTFILES_MINUS_ONE\r\n\tend\r\n\r\n\treturn res\r\n\r\nend\r\n\r\nnewoption\r\n{\r\n\ttrigger = \"Static\",\r\n\tvalue = \"false\",\r\n\tdescription = \"Compiles static library or output\"\r\n}\r\n\r\nnewoption\r\n{\r\n\ttrigger = \"Dev\",\r\n\tvalue = \"Dev40\",\r\n\tdescription = \"Sets the Virtools version\"\r\n}\r\n\r\n\r\nnewoption\r\n{\r\n\ttrigger = \"DeployDirect\",\r\n\tvalue = \"TRUE\",\r\n\tdescription = \"Compiles to ../Bin/ConfigName/DevVersion/ or to DEV_XX_BIN\"\r\n\r\n}\r\n\r\nnewoption\r\n{\r\n\ttrigger = \"ExternalVTDirectory\",\r\n\tvalue = \"TRUE\",\r\n\tdescription = \"Uses the Virtools directories, specified in VTPaths.lua or ModuleConfig.lua(DEVXXDIR)\"\r\n\r\n}\r\n\r\nnewoption\r\n{\r\n\ttrigger = \"ExtraDefines\",\r\n\tvalue = \"\",\r\n\tdescription = \"Adds additional macro directives\",\r\n\r\n}\r\n#include \"xDistributedPropertyInfo.h\"\r\n\r\n#include \r\n#include \"pCommon.h\"\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWOBBOverlapDecl();\r\nCKERROR CreatePWOBBOverlapProto(CKBehaviorPrototype **pproto);\r\nint PWOBBOverlap(const CKBehaviorContext& behcontext);\r\nCKERROR PWOBBOverlapCB(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorPWOBBOverlapDecl()\r\n{\r\n\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"PWOBBOverlap\");\r\n\tod->SetCategory(\"Physic/Collision\");\r\n\tod->SetDescription(\"Performs an overlap test against masked shape groups.Outputs an object only!\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x16a46d79,0xa951a4a));\r\n\tod->SetAuthorGuid(VTCX_AUTHOR_GUID);\r\n\tod->SetAuthorName(VTCX_AUTHOR);\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreatePWOBBOverlapProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(GUID_MODULE_MANAGER);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n//************************************\r\n// Method: CreatePWOBBOverlapProto\r\n// FullName: CreatePWOBBOverlapProto\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: CKBehaviorPrototype **pproto\r\n//************************************\r\nenum bInput\r\n{\r\n\r\n\t//bbI_WorldRef,\r\n\tbbI_SIZE,\r\n\tbbI_Center,\r\n\tbbI_Ref,\r\n\tbbI_ShapesType,\r\n\tbbI_Accurate,\r\n\tbbI_Groups,\r\n\tbbI_Mask,\r\n\r\n\r\n};\r\n\r\nenum bbS\r\n{\r\n\tbbS_Result=0,\r\n\tbbS_Index,\r\n\tbbS_Size,\r\n\tbbS_Groups=3,\r\n\tbbS_Mask=4\r\n};\r\n\r\nenum bbOT\r\n{\r\n\tbbOT_Yes,\r\n\tbbOT_No,\r\n\tbbOT_Finish,\r\n\tbbOT_Next,\r\n};\r\nCKERROR CreatePWOBBOverlapProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"PWOBBOverlap\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t/*! \\page PWOBBOverlap \r\n\r\n\r\n\tPWOBBOverlap is categorized in \\ref Collision\r\n\r\n\t

Description

\r\n\tApply to a 3DEntity
\r\n\tPerforms an overlap test against masked shape groups.
\r\n\tSee PWOverlaps.cmo for example.\r\n\r\n\t

Technical Information

\r\n\r\n\t\\image html PWOBBOverlap.png\r\n\r\n\tIn: triggers the process\r\n\t
\r\n\tNext: Iterate through next hit.\r\n\t
\r\n\t
\r\n\r\n\tYes: Hit occured.\r\n\t
\r\n\tNo: No hits.\r\n\t
\r\n\tFinish: Last hit.\r\n\t
\r\n\tNext: Loop out.\r\n\t
\r\n\t
\r\n\r\n\r\n\tTarget: World Reference. pDefaultWorld!\r\n\t
\r\n\tSize: The box dimension.\r\n\t
\r\n\tCenter: The box center in world space.If shape reference is given, then its transforming this value in its local space.\r\n\t
\r\n\tShapes Types: Adds static and/or dynamic shapes to the test.\r\n\t
\r\n\tAccurate: True to test the sphere against the actual shapes, false to test against the AABBs only.\r\n\t
\r\n\tGroups: Includes specific groups to the test. \r\n\t
\r\n\tGroups Mask: Alternative mask used to filter shapes. See #pRigidBody::setGroupsMask\r\n\t
\r\n\r\n\r\n\t
\r\n\t

Note


\r\n\r\n\r\n\t
\r\n\t
\r\n\r\n\tIs utilizing #pWorld::overlapOBBShapes()
\r\n\r\n\t*/\r\n\t\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareInput(\"Next\");\r\n\r\n\r\n\r\n\t\r\n\tproto->DeclareOutput(\"Yes\");\r\n\tproto->DeclareOutput(\"No\");\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"Next\");\r\n\r\n\tproto->DeclareInParameter(\"Size\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Center\",CKPGUID_VECTOR);\r\n\tproto->DeclareInParameter(\"Shape Reference\",CKPGUID_3DENTITY);\r\n\tproto->DeclareInParameter(\"Shapes Type\",VTF_SHAPES_TYPE);\r\n\tproto->DeclareInParameter(\"Accurate\",CKPGUID_BOOL);\r\n\tproto->DeclareInParameter(\"Groups\",CKPGUID_INT);\r\n\tproto->DeclareInParameter(\"Filter Mask\",VTS_FILTER_GROUPS);\r\n\r\n\r\n\tproto->DeclareLocalParameter(\"result\", CKPGUID_GROUP);\r\n\tproto->DeclareLocalParameter(\"index\", CKPGUID_INT);\r\n\tproto->DeclareLocalParameter(\"size\", CKPGUID_INT);\r\n\r\n\tproto->DeclareSetting(\"Groups\",CKPGUID_BOOL,\"false\");\r\n\tproto->DeclareSetting(\"Groups Mask\",CKPGUID_BOOL,\"false\");\r\n\r\n\r\n\tproto->DeclareOutParameter(\"Touched Body\",CKPGUID_3DENTITY);\r\n\t\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\t\r\n\tproto->SetBehaviorCallbackFct( PWOBBOverlapCB );\r\n\tproto->SetFunction(PWOBBOverlap);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//************************************\r\n// Method: PWOBBOverlap\r\n// FullName: PWOBBOverlap\r\n// Access: public \r\n// Returns: int\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nint PWOBBOverlap(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\tPhysicManager *pm = GetPMan();\r\n\t\r\n\tpFactory *pf = pFactory::Instance();\r\n\r\n\tusing namespace vtTools::BehaviorTools;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//the object : \r\n\tCK3dEntity *target = (CK3dEntity *) beh->GetTarget();\r\n\tif( !target ) return CKBR_OWNERERROR;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t// the world : \r\n\tpWorld *world=GetPMan()->getWorld(target->GetID());\r\n\tif (!world)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tNxScene *scene = world->getScene();\r\n\tif (!scene)\r\n\t{\r\n\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(0,FALSE);\r\n\r\n\r\n\t\tCKGroup *carray = (CKGroup*)beh->GetLocalParameterObject(bbS_Result);\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\t//carray->clear();\r\n\t\t\tcarray->Clear();\r\n\t\t}else\r\n\t\t{\r\n\t\t\t\r\n\t\t\tCK_OBJECTCREATION_OPTIONS creaoptions = (CK_OBJECTCREATION_OPTIONS)(CK_OBJECTCREATION_NONAMECHECK|CK_OBJECTCREATION_DYNAMIC);\r\n\t\t\tcarray = (CKGroup*)ctx()->CreateObject(CKCID_GROUP,\"asdasd\",creaoptions);\r\n\r\n\t\t}\r\n\t\t\r\n\t\tbeh->SetLocalParameterObject(0,carray);\r\n\r\n\t\tint hitIndex = 0;\r\n\t\tbeh->SetLocalParameterValue(bbS_Index,&hitIndex);\r\n\t\tint hitSize = 0;\r\n\t\tbeh->SetLocalParameterValue(bbS_Size,&hitSize);\r\n\r\n\r\n\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\r\n\t\tint types = GetInputParameterValue(beh,bbI_ShapesType);\r\n\t\tint accurate = GetInputParameterValue(beh,bbI_Accurate);\r\n\r\n\r\n\r\n\t\tDWORD groupsEnabled;\r\n\t\tDWORD groups = 0xffffffff;\r\n\t\tbeh->GetLocalParameterValue(bbS_Groups,&groupsEnabled);\r\n\t\tif (groupsEnabled)\r\n\t\t{\r\n\t\t\tgroups = GetInputParameterValue(beh,bbI_Groups);\r\n\t\t}\r\n\r\n\t\tpGroupsMask *gmask = NULL;\r\n\t\tDWORD mask;\r\n\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\tif (mask)\r\n\t\t{\r\n\t\t\tCKParameter *maskP = beh->GetInputParameter(bbI_Mask)->GetRealSource();\r\n\t\t\tgmask->bits0 = GetValueFromParameterStruct(maskP,0);\r\n\t\t\tgmask->bits1 = GetValueFromParameterStruct(maskP,1);\r\n\t\t\tgmask->bits2 = GetValueFromParameterStruct(maskP,2);\r\n\t\t\tgmask->bits3 = GetValueFromParameterStruct(maskP,3);\r\n\r\n\t\t}\r\n\r\n\t\tVxVector size = GetInputParameterValue(beh,bbI_SIZE);\r\n\t\tVxVector center = GetInputParameterValue(beh,bbI_Center);\r\n\r\n\t\tVxBbox box;\r\n\t\tbox.SetCenter(center,size/2);\r\n\t\tbox.SetDimension(center,size);\r\n\r\n\r\n\r\n\t\tCK3dEntity *shape = (CK3dEntity*)beh->GetInputParameterObject(bbI_Ref);\r\n\r\n\t\tint nbShapes = world->overlapOBBShapes(box,shape,(pShapesType)types,carray,groups,gmask,accurate);\r\n\t\tif (nbShapes)\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbOT_Yes);\r\n\t\t\tbeh->ActivateInput(1,TRUE);\r\n\r\n\t\t}else{\r\n\t\t\tbeh->ActivateOutput(bbOT_No);\r\n\t\t}\r\n\t}\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\r\n\t\tbeh->ActivateInput(1,FALSE);\r\n\t\tCKGroup *carray = (CKGroup*)beh->GetLocalParameterObject(bbS_Result);\r\n\t\t\r\n\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\tif (carray)\r\n\t\t{\r\n\t\t\tif (carray->GetObjectCount())\r\n\t\t\t{\r\n\t\t\t\tCKBeObject *hit = carray->GetObject(carray->GetObjectCount()-1);\r\n\t\t\t\tif (hit)\r\n\t\t\t\t{\r\n\r\n\r\n\t\t\t\t\tbeh->SetOutputParameterObject(0,hit);\r\n\t\t\t\t\tcarray->RemoveObject(hit);\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\tif (carray->GetObjectCount())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Next);\r\n\t\t\t\t\t}else\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t\t\t\t\tCKDestroyObject(carray);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t\t\tCKDestroyObject(carray);\r\n\t\t\t}\r\n\t\t}else\r\n\t\t{\r\n\t\t\tbeh->ActivateOutput(bbOT_Finish);\r\n\t\t\tCKDestroyObject(carray);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n\r\n//************************************\r\n// Method: PWOBBOverlapCB\r\n// FullName: PWOBBOverlapCB\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n// Parameter: const CKBehaviorContext& behcontext\r\n//************************************\r\nCKERROR PWOBBOverlapCB(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior *beh = behcontext.Behavior;\r\n\r\n\tswitch(behcontext.CallbackMessage) {\r\n\t\r\n\tcase CKM_BEHAVIORATTACH:\r\n\tcase CKM_BEHAVIORLOAD:\r\n\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\r\n\t\t\t\r\n\r\n\t\t\tDWORD groups;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Groups,&groups);\r\n\t\t\tbeh->EnableInputParameter(bbI_Groups,groups);\r\n\r\n\t\t\tDWORD mask;\r\n\t\t\tbeh->GetLocalParameterValue(bbS_Mask,&mask);\r\n\t\t\tbeh->EnableInputParameter(bbI_Mask,mask);\r\n\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t}\r\n\t\tbreak;\r\n\t}\r\n\treturn CKBR_OK;\r\n\r\n}\r\n\r\n#ifndef SOFT_SKELETON_H\r\n\r\n#define SOFT_SKELETON_H\r\n\r\nnamespace NXU\r\n{\r\nclass NxuSkeleton;\r\n};\r\n\r\nclass NxActor;\r\n\r\nnamespace SOFTBODY\r\n{\r\n\r\nclass SoftSkeleton;\r\n\r\n// create a bone mapping skeleton between a list of actors and the bones in a graphics skeleton.\r\nSoftSkeleton * createSoftSkeleton(unsigned int acount,NxActor **alist,NXU::NxuSkeleton *skeleton);\r\nconst float ** getTransforms(SoftSkeleton *sk); // synchronizes the actors with\tgraphics skeleton and rebuilds the graphics transforms.\r\nvoid releaseSoftSkeleton(SoftSkeleton *sk);\r\nvoid debugRender(SoftSkeleton *sk);\r\n\r\n}; // end of namespace\r\n\r\n#endif\r\n#ifndef __P_VEHICLE_H__\r\n#define __P_VEHICLE_H__\r\n\r\n#include \"vtPhysXBase.h\"\r\n\r\n#include \"pWheel.h\"\r\n#include \"NxArray.h\"\r\n#include \"NxUserContactReport.h\"\r\n#include \"pVehicleGears.h\"\r\n#include \"pVTireFunction.h\"\r\n#include \"pReferencedObject.h\"\r\n#include \"pCallbackObject.h\"\r\n\r\n\r\nclass pEngine;\r\nclass pGearBox;\r\nclass pDifferential;\r\nclass pDriveLine;\r\nclass pVehicleSteer;\r\n\r\n\r\n\r\n/** \\addtogroup Vehicle\r\n@{\r\n*/\r\ntypedef std::vectorWheelArrayType;\r\n\r\n/**\r\n\\brief A abstract base class for a vehicle object.\r\n*/\r\n\r\ntypedef enum pVehicleControlStateItem\r\n{\r\n\tE_VCS_ACCELERATION,\r\n\tE_VCS_STEERING,\r\n\tE_VCS_HANDBRAKE,\r\n\tE_VCS_BRAKING,\r\n\tE_VCS_GUP,\r\n\tE_VCS_GDOWN,\r\n\tE_VCS_TCLUTCH,\r\n\tE_VCS_STARTER,\r\n\tE_VCS_BRAKES,\r\n};\r\nenum ControlTypes\r\n// Which kind of controls do we have?\r\n{\r\n\tT_STEER_LEFT,T_STEER_RIGHT,\r\n\tT_THROTTLE,T_BRAKES,\r\n\tT_SHIFTUP,T_SHIFTDOWN,\r\n\tT_CLUTCH,\r\n\tT_HANDBRAKE,\r\n\tT_STARTER,\r\n\tT_HORN,\r\n\tMAX_CONTROLLER_TYPE\r\n};\r\n\r\ntypedef enum pVehicleControlStateItemMode\r\n{\r\n\tE_VCSM_ANALOG,\r\n\tE_VCSM_DIGITAL,\r\n};\r\n\r\ntypedef enum pVehicleBreakCase\r\n{\r\n\tBC_NoUserInput,\r\n\tBC_DirectionChange,\r\n\tBC_UserBreak,\r\n\tBC_Handbrake,\r\n\tBC_NumBreakCases,\r\n};\r\n\r\ntypedef enum pVehicleBreakLevel\r\n{\r\n\tBL_NoBreak=-1,\r\n\tBL_Small,\r\n\tBL_Medium,\r\n\tBL_High,\r\n\tBL_NumBreakLevels,\r\n};\r\n\r\ntypedef enum\r\n{\r\n\tVBF_UseTable=(1<<0),\r\n\tVBF_Autobreak=(1<<1),\r\n\r\n};\r\nenum VehicleStatus\r\n{\r\n\tVS_IsMoving=(1<<0),\r\n\tVS_IsAccelerated=(1<<1),\r\n\tVS_IsAcceleratedForward=(1<<2),\r\n\tVS_IsAcceleratedBackward=(1<<3),\r\n\tVS_AllWheelsOnGround=(1<<4),\r\n\tVS_IsFalling=(1<<5),\r\n\tVS_Handbrake=(1<<6),\r\n\tVS_IsBraking=(1<<7),\r\n\tVS_IsSteering=(1<<8),\r\n\tVS_HasGearBox=(1<<9),\r\n\tVS_HasMotor=(1<<10),\r\n\tVS_IsRollingForward=(1<<11),\r\n\tVS_IsRollingBackward=(1<<12),\r\n};\r\n\r\nclass MODULE_API pVehicle : \r\n\tpublic xEngineObjectAssociation,\r\n\tpublic pCallbackObject\r\n{\r\n\r\npublic:\r\n\t\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// new engine code \r\n\t//\r\n\tenum Max\r\n\t{\r\n\t\tMAX_WHEEL=8,\r\n\t\tMAX_DIFFERENTIAL=3, // Enough for a 4WD Jeep\r\n\t\tMAX_WING=10, // Front, rear and perhaps others\r\n\t\tMAX_CAMERA=10\t\t\t// Max #camera's around car\r\n\t};\r\n\tpEngine *engine;\r\n\tpGearBox *gearbox;\r\n\tpDifferential *differential[MAX_DIFFERENTIAL];\r\n\tint differentials;\r\n\tpDriveLine *driveLine;\r\n\tpVehicleSteer *steer;\r\n\t\r\n\r\n\tfloat motorTorque;\r\n\tfloat breakTorque;\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// public access\r\n\t//\r\n\tpDifferential *getDifferential(int n){ return differential[n]; }\r\n\tpEngine *getEngine(){ return engine; }\r\n\tpDriveLine *getDriveLine(){ return driveLine; }\r\n\tpGearBox *getGearBox(){ return gearbox; }\r\n\tpVehicleSteer * getSteer() { return steer; }\r\n\tvoid setSteer(pVehicleSteer * val) { steer = val; }\r\n\r\n\tvoid findDifferentialWheels(int& wheel1Index,int& wheel2Index);\r\n\r\n\t\r\n\t\r\n\tint getNbDifferentials(){ return differentials; }\r\n\tvoid addDifferential(pDifferential *diff);\r\n\r\n\tfloat getRPM();\r\n\tbool isStalled();\r\n\tbool isAutoClutch();\r\n\tbool isAutoShifting();\r\n\tint getGear();\r\n\tbool isValidEngine();\r\n\tbool hasDifferential();\r\n\tbool shiftUp();\r\n\tbool shiftDown();\r\n\tint setGear(int gear);\r\n\tfloat getTorque(int component);\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// control \r\n\t//\r\n\tvoid setControlState(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake);\r\n\tvoid setControlState(int parameter,float value);\r\n\tvoid setControlMode(int parameter,int mode);\r\n\tvoid getControlState(int parameter,float &value,int &mode);\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// internal \r\n\t//\r\n\tint initEngine(int flags);\r\n\tint doEngine(int flags,float dt);\r\n\tvoid preCalculate();\r\n\tvoid calcForces();\r\n\tvoid integrate();\r\n\tvoid postStep();\r\n\tvoid cleanup();\r\n\t\r\n\tvoid PreCalcDriveLine();\r\n\r\n\tvoid calculateForces();\r\n\r\n\r\n\tvoid preAnimate();\r\n\tvoid postAnimate();\r\n\r\n\tvoid setClutch(float clutch);\r\n\tfloat getClutch();\r\n\r\n\r\n\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// manager calls\r\n\t//\r\n\tvoid step(float dt);\r\n\r\n\r\n\tvoid advanceTime(float lastDeltaMS);\r\n\t\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// manager calls \r\n\t//\r\n\tint onPreProcess();\r\n\tint onPostProcess();\r\n\r\n\tvoid processPostScript();\r\n\tvoid processPreScript();\r\n\r\n\r\n\tXString debugPrint(int mask);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Break functions\r\n\t//\r\n\r\n\tbool useBreakTable;\r\n\tint breakFlags;\r\n\tint breakConditionLevels[BC_NumBreakCases];\r\n\tfloat mBreakPressures[BL_NumBreakLevels];\r\n\tfloat mBrakeTable[BL_NumBreakLevels][BREAK_TABLE_ENTRIES]; //!< Brake Table to take advantage of a certain brake lvl at any one time\r\n\t\r\n\tpVehicleBrakeTable mSmallBrakeTable;\r\n\tpVehicleBrakeTable mMediumBrakeTable;\r\n\tpVehicleBrakeTable mHighBrakeTable;\r\n\r\n\tbool mBreakLastFrame;\r\n\r\n\tfloat mTimeBreaking;\r\n\tfloat mBrakeMediumThresold;\r\n\tfloat mBrakeHighThresold;\r\n\r\n\r\n\r\n\tvoid setBreakPressure(int breakLevel,float pressure);\r\n\tfloat getBreakPressure(int breakLevel);\r\n\tint getBreakFlags() const { return breakFlags; }\r\n\tvoid setBreakFlags(int val) { breakFlags = val; }\r\n\r\n\tbool isUsingBreakTable() const { return useBreakTable; }\r\n\tvoid setUsingBreakTable(bool val) { useBreakTable = val; }\r\n\tpVehicleBreakCase calculateBreakCase(int currentAccelerationStatus);\r\n\r\n\r\n\tvoid setBreakCaseLevel(pVehicleBreakCase breakCase,pVehicleBreakLevel level);\r\n\tpVehicleBreakLevel getBreaklevelForCase(pVehicleBreakCase breakCase) { return (pVehicleBreakLevel)breakConditionLevels[breakCase]; }\r\n\r\n\tfloat getBrakeTorque();\r\n\r\n\tvoid setMeasurementWheel(CK3dEntity*wheelReference);\r\n\tfloat getBrakeAmount(pVehicleBreakLevel brakeLevel);\r\n\tfloat getBrakeAmountFromTable(pVehicleBreakLevel brakeLevel);\r\n\r\n\t\r\n\r\n\tfloat getBrakeSmallPressure() {return mBreakPressures[BL_Small];} \r\n\tfloat getBrakeMediumPressure() {return mBreakPressures[BL_Medium];} \r\n\tfloat getBrakeHighPressure() {return mBreakPressures[BL_High];} \r\n\r\n\tfloat getBrakeMediumApplyTime() {return mBrakeMediumThresold;} \r\n\tfloat getBrakeHighApplyTime() {return mBrakeHighThresold;} \r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// misc\r\n\t//\r\n\t\r\n\tint mVSFlags;\r\n\tfloat _cSteering;\r\n\tfloat _cAcceleration;\r\n\tint _cShiftStateUp;\r\n\tint _cShiftStateDown;\r\n\tbool _cAnalogSteering;\r\n\tbool _cAnalogAcceleration;\r\n\tbool _cHandbrake;\r\n\r\n\t\r\n\tNxArray\t\t_wheels;\r\n\t\r\n\r\n\t\r\n\r\n\t\r\n\t//WheelArrayType _wheels;\r\n\t//NxArray getWheels() const { return _wheels; }\r\n\r\n\r\n\tNxArray& getWheels() { return _wheels; }\r\n\r\n\r\n\tint& getStateFlags() { return mVSFlags; }\r\n\tvoid setVSFlags(int val) { mVSFlags = val; }\r\n\r\n\r\n\tvoid printAllToConsole();\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// old code\r\n\t//\r\n\tpVehicleGears*\t\t\t_vehicleGears;\r\n\tpVehicleMotor*\t\t\t_vehicleMotor;\r\n\r\n\r\n\tpVehicleMotor* getMotor() const { return _vehicleMotor; }\r\n\tvoid setMotor(pVehicleMotor* val) { _vehicleMotor = val; }\r\n\t\r\n\tpVehicleGears* getGears() const { return _vehicleGears; }\r\n\tvoid setGears(pVehicleGears* val) { _vehicleGears = val; }\r\n\r\n\tfloat\t\t\t\t\t_steeringWheelState;\r\n\tfloat\t\t\t\t\t_accelerationPedal;\r\n\tfloat\t\t\t\t\t_brakePedal;\r\n\tbool\t\t\t\t\t_brakePedalChanged;\r\n\tbool\t\t\t\t\t_handBrake;\r\n\tfloat\t\t\t\t\t_acceleration;\r\n\r\n\tfloat\t\t\t\t\t_digitalSteeringDelta;\r\n\tfloat\t\t\t\t\t_mass;\r\n\r\n\tfloat\t\t\t\t\t_lastDT;\r\n\tVxVector _centerOfMass;\r\n\r\n\tVxVector\t\t\t\t_steeringTurnPoint;\r\n\r\n\tVxVector\t\t\t\t_steeringSteerPoint;\r\n\tfloat getMass();\r\n\tvoid setMass(float val) { _mass = val; }\r\n\r\n\t\r\n\t\r\n\tVxVector getCenterOfMass() const { return _centerOfMass; }\r\n\tvoid setCenterOfMass(VxVector val) { _centerOfMass = val; }\r\n\r\n\t\r\n\tfloat getDigitalSteeringDelta() const { return _digitalSteeringDelta; }\r\n\tvoid setDigitalSteeringDelta(float val) { _digitalSteeringDelta = val; }\r\n\t\r\n\t\r\n\r\n\r\n\tVxVector getSteeringTurnPoint() const { return _steeringTurnPoint; }\r\n\tvoid setSteeringTurnPoint(VxVector val) { _steeringTurnPoint = val; }\r\n\t\r\n\t\r\n\tVxVector getSteeringSteerPoint() const { return _steeringSteerPoint; }\r\n\tvoid setSteeringSteerPoint(VxVector val) { _steeringSteerPoint = val; }\r\n\t\r\n\tfloat getMotorForce() const { return _motorForce; }\r\n\tvoid setMotorForce(float val) { _motorForce = val; }\r\n\r\n\tfloat\t\t\t\t\t_transmissionEfficiency;\r\n\tfloat\t\t\t\t\t_steeringMaxAngleRad;\r\n\r\n\tfloat\t\t\t\t\t_motorForce;\r\n\tNxVec3\t\t\t\t\t_localVelocity;\r\n\tbool\t\t\t\t\t_braking;\r\n\tbool\t\t\t\t\t_releaseBraking;\r\n\tfloat\t\t\t\t\t_maxVelocity;\r\n\tNxMaterial*\t\t\t\t_carMaterial;\r\n\tfloat\t\t\t\t\t_cameraDistance;\r\n\r\n\r\n\tNxActor*\t\t\t\t_mostTouchedActor;\r\n\tbool mAutomaticMode;\r\n\r\n\tfloat\t\t\t\t\t_differentialRatio;\r\n\r\n\r\n\tfloat getTransmissionEfficiency() const { return _transmissionEfficiency; }\r\n\tvoid setTransmissionEfficiency(float val) { _transmissionEfficiency = val; }\r\n\t\r\n\t\r\n\tfloat getDifferentialRatio() const { return _differentialRatio; }\r\n\tvoid setDifferentialRatio(float val) { _differentialRatio = val; }\r\n\r\n\t\r\n\t\r\n\tfloat getMaxVelocity() const { return _maxVelocity; }\r\n\tvoid setMaxVelocity(float val) { _maxVelocity = val; }\r\n\r\n\t\r\n\tbool getAutomaticMode() const { return mAutomaticMode; }\r\n\t\r\n\r\n\tfloat getMPH(int type=0);\r\n\r\n\tvoid setAutomaticMode(bool autoMode);\r\n\r\n\tvoid\t\t\t\t\t_computeMostTouchedActor();\r\n\tvoid\t\t\t\t\t_computeLocalVelocity();\r\n\tfloat\t\t\t\t\t_computeAxisTorque();\r\n\tfloat\t\t\t\t\t_computeAxisTorqueV2();\r\n\tfloat\t\t\t\t\t_computeRpmFromWheels();\r\n\tfloat\t\t\t\t\t_computeMotorRpm(float rpm);\r\n\r\n\tvoid\t\t\t\t\t_updateRpms();\r\n\r\n\tfloat\t\t\t\t\t_getGearRatio();\r\n\r\n\tvoid\t\t\t\t\t_controlSteering(float steering, bool analogSteering);\r\n\tvoid\t\t\t\t\t_controlAcceleration(float acceleration, bool analogAcceleration);\r\n\r\n\t\r\n\t\r\n\tfloat getMaxSteering() const { return _steerMax; }\r\n\tvoid setMaxSteering(float val) { _steerMax = val; \t}\r\n\r\n\tfloat\t\t\t\t\t_steerMax;\r\n\tint _nbTouching;\r\n\tint _nbNotTouching;\r\n\tint _nbHandbrakeOn;\r\n\tint _currentStatus;\r\n\r\n\tint flags;\r\n\r\n\tint _calculateCurrentStatus();\r\n\tint _calculateReaction();\r\n\tint _calculateNextSteering();\r\n\tint _performSteering(float dt);\r\n\tvoid doSteering();\r\n\tint _performAcceleration(float dt);\r\n\r\n\t\r\n\tfloat calculateBraking(float dt);\r\n\t\r\n\tpRigidBody *mBody;\r\n\tNxActor *mActor;\r\n\t\r\n\r\n\t\r\n\tpublic : \r\n\t\tpVehicle();\r\n\t\tpVehicle(pVehicleDesc descr,CK3dEntity *referenceObject);\r\n\r\n\t\tpRigidBody * getBody() const { return mBody; }\r\n\t\tvoid setBody(pRigidBody * val) { mBody = val; }\r\n\t\tvoid setToDefault();\r\n\r\n\t\tint initWheels(int flags);\r\n\r\n\t\tvoid updateWheels(int flags= 0);\r\n\r\n\t\tvoid\t\t\t\t\thandleContactPair(NxContactPair* pair, int carIndex);\r\n\t\tvoid updateVehicle(float lastTimeStepSize);\r\n\t\tvoid\t\t\t\t\tcontrol (float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake);\r\n\t\tvoid\t\t\t\t\tupdateControl(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake);\r\n\t\tvoid\t\t\t\t\tgearUp();\r\n\t\tvoid\t\t\t\t\tgearDown();\r\n\t\tvoid\t\t\t\t\tstandUp();\r\n\t\tfloat\t\t\t\t\tgetDriveVelocity();\r\n\t\tfloat\t\t\t\t\tgetMaxVelocity() { return _maxVelocity; }\r\n\t\tint\t\t\t\t\tgetNbWheels() { return _wheels.size(); }\r\n\t\tconst pWheel*\t\t\tgetWheel(int i);\r\n\t\tpWheel*getWheel(CK3dEntity* wheelReference);\r\n\r\n\t\t\r\n\t\tNxActor *getActor();\r\n\t\tvoid setActor(NxActor * val) { mActor = val; }\r\n\t\tint load(const pVehicleDesc& src );\r\n\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n/** @} */\r\n\r\n#endif#ifndef __VT_WORLD_STRUCTS_H__\r\n#define __VT_WORLD_STRUCTS_H__\r\n\r\n\r\n\r\nenum PS_W_DOMINANCE_CONSTRAINT\r\n{\r\n\tPS_WDC_A,\r\n\tPS_WDC_B,\r\n};\r\n\r\n\r\nenum PS_W_DOIMINANCE\r\n{\r\n\r\n\tPS_WD_GROUP_A,\r\n\tPS_WD_GROUP_B,\r\n\tPS_WD_CONSTRAINT,\r\n};\r\n\r\n\r\nenum PS_W_DOIMINANCE_SETUP\r\n{\r\n\r\n\tPS_WDS_ITEM1,\r\n\tPS_WDS_ITEM2,\r\n\tPS_WDS_ITEM3,\r\n\tPS_WDS_ITEM4,\r\n\tPS_WDS_ITEM5,\r\n\r\n};\r\n\r\n\r\n\r\n\r\n\r\n#endif#ifndef __xDistributedInteger_H\r\n#define __xDistributedInteger_H\r\n\r\n#include \"xDistributedProperty.h\"\r\n\r\n\r\nclass xDistributedInteger : public xDistributedProperty\r\n{\r\n\r\n\tpublic:\r\n\r\n\r\n\t\ttypedef xDistributedProperty Parent;\r\n\r\n\t\txDistributedInteger ( xDistributedPropertyInfo *propInfo, xTimeType maxWriteInterval, xTimeType maxHistoryTime ) : xDistributedProperty(propInfo)\r\n\t\t{\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tmLastValue=0;\r\n\t\t\tmCurrentValue=0;\r\n\t\t\tmLastTime = 0;\r\n\t\t\tmCurrentTime = 0;\r\n\t\t\tmLastDeltaTime = 0 ; \r\n\t\t\tmFlags = 0;\r\n\t\t\tmThresoldTicker = 0;\r\n\t\t\tmLastServerValue = 0 ;\r\n\t\t\tmLastServerDifference = 0;\r\n\t\t\tmDifference = 0;\r\n\t\t}\r\n\r\n\t\t~xDistributedInteger(){}\r\n\r\n\t\tTNL::S32 mLastValue;\r\n\t\tTNL::S32 mCurrentValue;\r\n\t\tTNL::S32 mDifference;\r\n\t\tTNL::S32 mLastServerValue;\r\n\t\tTNL::S32 mLastServerDifference;\r\n\t\t\r\n\t\tbool updateValue(TNL::S32 value,xTimeType currentTime);\r\n void pack(TNL::BitStream *bstream);\r\n\t\tvoid unpack(TNL::BitStream *bstream,float sendersOneWayTime);\r\n\t\tvoid updateGhostValue(TNL::BitStream *stream);\r\n\t\tvoid updateFromServer(TNL::BitStream *stream);\r\n\t\tvirtual uxString print(TNL::BitSet32 flags);\r\n \r\n\t\t\r\n\r\n};\r\n\r\n#endif\r\n#pragma once\r\n\r\n//-----------------------------------------------------------------------------\r\n//CATEGORY FLAGS---------------------------------------------------------------\r\n#define FIXED\tKeyboardShortcutManager::KSCategory::FIXED\r\n#define GLOBAL\tKeyboardShortcutManager::KSCategory::GLOBAL\r\n#define ACTIVE\tKeyboardShortcutManager::KSCategory::ACTIVE\r\n#define HIDDEN\tKeyboardShortcutManager::KSCategory::HIDDEN\r\n\r\n//Notes :\r\n//\r\n//for Global shortcuts, you can check for them in WindowProc\r\n// on WM_KEYDOWN\r\n// VirtoolsExternalPlugin::KeyboardShortcutManager* ksm = GetInterface()->GetKeyboardShortcutManager();\r\n// int commandID\t= ksm->TestKS(STR_CATEGORY,pMsg->wParam);\r\n//\r\n//for Local shortcuts you can check for them in PreTranslateMessage\r\n// on WM_SYSKEYDOWN (for alt+key or F10) or WM_KEYDOWN\r\n// VirtoolsExternalPlugin::KeyboardShortcutManager* ksm = GetInterface()->GetKeyboardShortcutManager();\r\n// int commandID\t= ksm->TestKS(STR_CATEGORY,pMsg->wParam);\r\n\r\n//category name under which you want to have your keyboard shortcuts\r\n#define STR_CATEGORY\t\"vtAgeiaInterface Keyboard Shortcuts Category\"\r\n\r\n//command ids sample - command ID min must be 1\r\n#define CID_A\t\t1\r\n#define CID_B\t\t2\r\n\r\n//names of these commands, sample\r\n#define STR_A\t\t\"Command A\"\r\n#define STR_B\t\t\"Command B\"\r\n//command ids sample end\r\n\r\n\r\n//IMPORTANT!\r\n//by default these functions are called in vtAgeiaInterfacecallback.cpp\r\n//if you do not use callback (do not have vtAgeiaInterfacecallback.cpp), you should call these functions manually\r\n\r\n//register keyboard shortcut category (shortcuts of this category will be saved when Virtools Dev is closed)\r\nint RegisterKeyboardShortcutCategory();\r\n//unregister keyboard shortcut category (shortcuts of this category will be saved no more when Virtools Dev is closed)\r\nint\tUnregisterKeyboardShortcutCategory();\r\n//register keyboard shortcuts for your editor. Fill this function\r\nint\tRegisterKeyboardShortcuts();\r\n\r\n//function that returns command name from its command id\r\n//used in RegisterActionEditorKSCategory, as a callback for the keyboard shortcut category\r\n//to know the command name\r\n//Note : in ksm->RegisterCategory,\r\n// you can set the callback to NULL (change \"GetCommandName\" into \"NULL\"\r\n// but you should then put directly names into keyboard shortcuts you register in that category\r\n// see in RegisterActionEditorKS();\r\n// ks.key\t\t\t= 'A';\r\n// ks.flags\t\t= ks.KS_CONTROL|ks.KS_SHIFT|ks.KS_ALT;\r\n// ks.commandID\t= CID_A;\r\n// ks.name\t\t= \"Command A\";\t\t//LINE TO ADD TO SET NAME DIRECTLY\r\n// ksm->RegisterKS(index,ks);\r\n// but in that case, it will be less easy to integrate into popup menus\r\nconst char*\tGetCommandName(int commandID);\r\n\r\n//function that returns command name \r\n//usefull for popup menus\r\nconst char*\tGetCommandMenuName(int commandID,XString &name);\r\n\r\n/*\r\n//here the sample code to fill a menu\r\n#define MENUSTR(commandID) GetActionEditorMenuName(commandID,name)\r\n\r\n\tPOINT p;\r\n\tGetCursorPos(&p);\r\n\tXString name;\r\n\tCKVIPopupMenu menu;\r\n\tmenu.AddItem(MENUSTR(CID_A),CID_A);\r\n\tmenu.AddItem(MENUSTR(CID_B),CID_B);\r\n\tm_ActionMenu.AddSeparator();\r\n\tmenu.Show(p.x,p.y);\r\n*/#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n#include \"vtNetworkManager.h\"\r\n#include \r\n#include \"xMathTools.h\"\r\n\r\n//#undef TNL::Point3F\r\nint counter = 0 ;\r\n\r\n\r\n#include \"xDistributedPoint3F.h\"\r\n#include \"xDistributedPoint4F.h\"\r\n#include \"xDistributedPoint2F.h\"\r\n#include \"xDistributedPoint1F.h\"\r\n\r\n#include \"xDistributedSession.h\"\r\n\r\n\r\nvoid\r\nvtNetworkManager::performGhostUpdates()\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//this is to store states in our dist objects\r\n\r\n\txNetInterface *nInterface = GetClientNetInterface();\r\n\tif (!nInterface) return;\r\n\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\tif (nInterface->IsServer())return;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\tif (dobj)\r\n\t\t{\r\n\t\t\txDistributedClass *_class = dobj->getDistributedClass();\r\n\t\t\tif (_class != NULL )\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\t/* */\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\txDistributedSession*session = static_cast(dobj);\r\n\t\t\t\t\tif (session)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\t\t\t\t\t\txDistributedPropertyArrayType &props = *session->getDistributedPorperties();\r\n\r\n\t\t\t\t\t\tint gFlags = session->getGhostUpdateBits().getMask();\r\n\r\n\t\t\t\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\t\t\t\t\tdobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\t/* */\r\n\t\t\t\t/************************************************************************/\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributed3DObject *dobj3D = static_cast(dobj);\r\n\t\t\t\t\tif (dobj3D)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\t\t\t\t\t\txDistributedPropertyArrayType &props = *dobj3D->getDistributedPorperties();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tint gFlags = dobj->getGhostUpdateBits().getMask();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif ( blockIndex < _class->getFirstUserField() && dobj->getGhostUpdateBits().testStrict(1<GetObject(dobj3D->getGhostDebugID());\r\n\t\t\t\t\t\t\t\tCK3dEntity *bindObject = (CK3dEntity*)m_Context->GetObject(dobj3D->getEntityID());\r\n\r\n\t\t\t\t\t\t\t\tswitch(propInfo->mNativeType)\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tcase E_DC_3D_NP_WORLD_POSITION:\r\n\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\txDistributedPoint3F *propValue = static_cast(prop);\r\n\r\n\t\t\t\t\t\t\t\t\t\tPoint3F currentPos = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\tPoint3F velocity = propValue->mLastServerDifference;\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t/************************************************************************/\r\n\t\t\t\t\t\t\t\t\t\t/* we are updated by remote :\t\t\t\t\t\t */\r\n\t\t\t\t\t\t\t\t\t\t/************************************************************************/\r\n\t\t\t\t\t\t\t\t\t\tif (bindObject && dobj3D->getInterfaceFlags() & E_DO_BINDED && dobj3D->getUserID() != nInterface->getConnection()->getUserID() )\r\n\t\t\t\t\t\t\t\t\t\t{\r\n \r\n\t\t\t\t\t\t\t\t\t\t\tupdateLocalPosition(dobj,bindObject,prop);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (ghostDebug)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\tVxVector realPos;\r\n\t\t\t\t\t\t\t\t\t\t\t\tghostDebug->GetPosition(&realPos);\r\n\t\t\t\t\t\t\t\t\t\t\t\tPoint3F realPos2(realPos.x,realPos.y,realPos.z);\r\n\t\t\t\t\t\t\t\t\t\t\t\tfloat oneWayTime = (dobj3D->getNetInterface()->GetConnectionTime() / 1000.0f);\r\n\t\t\t\t\t\t\t\t\t\t\t\toneWayTime +=oneWayTime * prop->getPredictionSettings()->getPredictionFactor();\r\n\t\t\t\t\t\t\t\t\t\t\t\tPoint3F predictedPos = currentPos + velocity * oneWayTime;\r\n\t\t\t\t\t\t\t\t\t\t\t\tPoint3F realPosDiff = - predictedPos - realPos2 ;\r\n\t\t\t\t\t\t\t\t\t\t\t\tVxVector posNew(predictedPos.x,predictedPos.y,predictedPos.z);\r\n\t\t\t\t\t\t\t\t\t\t\t\t//VxVector posNew2 = realPos + ( posNew - realPos )*0.5;\r\n\t\t\t\t\t\t\t\t\t\t\t\tghostDebug->SetPosition(&posNew);\r\n\t\t\t\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t\t\t\tcase E_DC_3D_NP_WORLD_ROTATION:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (bindObject && dobj3D->getInterfaceFlags() & E_DO_BINDED && dobj3D->getUserID() != nInterface->getConnection()->getUserID() )\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tupdateLocalRotation(dobj,bindObject,prop);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (ghostDebug)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\t\txDistributedQuatF*propValue = static_cast(prop);\r\n\t\t\t\t\t\t\t\t\t\t\tif (propValue)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t/*\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPoint3F currentPos = propValue->mLastServerValue;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPoint3F velocity = propValue->mLastServerDifference;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tVxVector realPos;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tghostDebug->GetPosition(&realPos);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPoint3F realPos2(realPos.x,realPos.y,realPos.z);\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tfloat oneWayTime = (dobj3D->GetNetInterface()->GetConnectionTime() / 1000.0f);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\toneWayTime +=oneWayTime * prop->getPredictionSettings()->getPredictionFactor();\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPoint3F predictedPos = currentPos + velocity * oneWayTime;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tPoint3F realPosDiff = - predictedPos - realPos2 ;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tVxVector posNew(predictedPos.x,predictedPos.y,predictedPos.z);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t//VxVector posNew2 = realPos + ( posNew - realPos )*0.5;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tghostDebug->SetPosition(&posNew);\r\n\t\t\t\t\t\t\t\t\t\t\t\t*/\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tdobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\nvoid\r\nvtNetworkManager::UpdateDistributedObjects(DWORD flags)\r\n{\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//this is to store states in our dist objects\r\n\r\n\txNetInterface *nInterface = GetClientNetInterface();\r\n\tif (!nInterface) return;\r\n\t\r\n\tIDistributedObjects *doInterface = nInterface->getDistObjectInterface();\r\n\txDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects();\r\n\txDistObjectIt begin = distObjects->begin();\r\n\txDistObjectIt end = distObjects->end();\r\n\tnInterface->setObjectUpdateCounter(0);\r\n\tif (nInterface->IsServer())return;\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\twhile (begin!=end)\r\n\t{\r\n\t\txDistributedObject* dobj = *begin;\r\n\t\t\r\n\t\tif (dobj && dobj->getOwnershipState().test(1<getDistributedClass();\r\n\r\n\t\t\tif (_class != NULL )\r\n\t\t\t{\r\n\t\t\t\tXString name(dobj->GetName().getString()); \r\n\t\t\t\tXString cName = _class->getClassName().getString();\r\n\t\t\t\tint entType = _class->getEnitityType();\r\n\t\t\t\t\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_SESSION)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tdobj->setUpdateState( E_DO_US_OK );\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (_class->getEnitityType() == E_DC_BTYPE_3D_ENTITY )\r\n\t\t\t\t{\r\n\t\t\t\t\txDistributed3DObject *dobj3D = static_cast(dobj);\r\n\t\t\t\t\tif (dobj3D)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCK3dEntity *entity = (CK3dEntity*)m_Context->GetObject(dobj3D->getEntityID());\r\n\t\t\t\t\t\t//////////////////////////////////////////////////////////////////////////\r\n\t\t\t\t\t\t//if the object is ours then store the last known position in the state info : \r\n\t\t\t\t\t\tint oID = dobj3D->getUserID();\r\n\t\t\t\t\t\tint myID = nInterface->getConnection()->getUserID();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tDWORD oFlags = dobj->getObjectFlags();\r\n DWORD iFlags = dobj3D->getInterfaceFlags();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif (entity)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tTNL::U32 currentTime = TNL::Platform::getRealMilliseconds();\r\n\t\t\t\t\t\t\tdobj->setUpdateState( E_DO_US_OK );\r\n\r\n\t\t\t\t\t\t\txDistributedPropertyArrayType &props = *dobj3D->getDistributedPorperties();\r\n\t\t\t\t\t\t\tfor (unsigned int i = 0 ; i < props.size() ; i++ )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\txDistributedProperty *prop = props[i];\r\n\t\t\t\t\t\t\t\txDistributedPropertyInfo*propInfo = prop->getPropertyInfo();\r\n\t\t\t\t\t\t\t\tint blockIndex = prop->getBlockIndex();\r\n\t\t\t\t\t\t\t\tif (propInfo)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tswitch(propInfo->mNativeType)\r\n\t\t\t\t\t\t\t\t\t{\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\tcase E_DC_3D_NP_WORLD_POSITION :\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\txDistributedPoint3F * dpoint3F = (xDistributedPoint3F*)prop;\r\n\t\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tVxVector posW;\r\n\t\t\t\t\t\t\t\t\t\t\t\tentity->GetPosition(&posW);\r\n\t\t\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(posW),currentTime);\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tcase E_DC_3D_NP_WORLD_ROTATION:\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\txDistributedQuatF * dpoint3F = (xDistributedQuatF*)prop;\r\n\t\t\t\t\t\t\t\t\t\t\tif (dpoint3F)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tVxQuaternion vquat;\r\n\t\t\t\t\t\t\t\t\t\t\t\tentity->GetQuaternion(&vquat);\r\n\t\t\t\t\t\t\t\t\t\t\t\tbool update = dpoint3F->updateValue(xMath::getFrom(vquat),currentTime);\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tbegin++;\r\n\t}\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/******************************************************************************\r\nFile : CustomPlayer.h\r\n\r\nDescription: This file contains the CCustomPlayer class which\r\nis the \"interface\" with the Virtools SDK. All other files are Windows/MFC\r\nspecific code.\r\n\r\nVirtools SDK\r\nCopyright (c) Virtools 2005, All Rights Reserved.\r\n******************************************************************************/\r\n\r\n#if !defined(CUSTOMPLAYER_H)\r\n#define CUSTOMPLAYER_H\r\n\r\n#include \"CustomPlayerApp.h\"\r\n\r\n/*************************************************************************\r\nSummary: This class defines the implementation of the Virtools Runtime/Player.\r\n\r\nDescription: This class provides member functions for initializing the\r\nvirtools runtime and for running it.\r\n\r\nRemarks: This class is a singleton. It means there is only one instance of it\r\nand you cannot instanciate it. To get an instance of the class use\r\nCCustomPlayer::Instance.\r\n\r\nSee also: CCustomPlayerApp, Instance.\r\n*************************************************************************/\r\nclass CCustomPlayer\r\n{\r\npublic :\r\n\r\n\t/*************************************************************************\r\n\tSummary: Retrieve the unique instance of the player.\r\n\t*************************************************************************/\r\n\tstatic CCustomPlayer& Instance();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Release all data which has been created during the initializating\r\n\tand the execution of the player.\r\n\t*************************************************************************/\r\n\t~CCustomPlayer();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Initialize the player.\r\n\r\n\tDescription: This function intialize the virtools engine (ck, render engine, ...) and load\r\n\tthe composition\r\n\r\n\tParameters:\r\n\t\tiMainWindow: the main window of the application.\r\n\t\tiRenderWindow: the render window.\r\n\t\tiConfig: the configuration of the player (see EConfigPlayer).\r\n\t\tiData: pointer to a string (if iDataSize==0) containing the name of the filename\r\n\t\tto load or pointer to the memory where the application is located (if iDataSize!=0).\r\n\t\tiDataSize: Size of the memory where the application is located if it is alredy in memory (can be null).\r\n\t*************************************************************************/\r\n\tBOOL InitPlayer(HWND iMainWindow, HWND iRenderWindow, int iConfig, const void* iData, int iDataSize);\r\n\r\n\t\r\n\t/*************************************************************************\r\n\tSummary: Initialize the engine.\r\n\r\n\tDescription: This function intialize the virtools engine (ck, render engine, ...) \r\n\r\n\t*************************************************************************/\r\n\tint InitEngine(HWND iMainWindow);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Play the composition.\r\n\t*************************************************************************/\r\n\tvoid Play();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Pause the composition.\r\n\t*************************************************************************/\r\n\tvoid Pause();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Reset the composition and play it.\r\n\t*************************************************************************/\r\n\tvoid Reset();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Process one frame of the compisition\r\n\t*************************************************************************/\r\n\tBOOL Process(int iConfig);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Switch from fullscreen/windowed to windowed/fullscreen.\r\n\r\n\tRemarks: The player try to retrieve the resolution (fullscreen or windowed)\r\n\tfrom level attributes before switching.\r\n\t*************************************************************************/\r\n\tBOOL SwitchFullscreen();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Change the current resolution (fullscreen or windowed\r\n\r\n\tRemarks: The player try to retrieve the resolution (fullscreen or windowed)\r\n\tfrom level attributes. If nothing has changed nothing is done.\r\n\t*************************************************************************/\r\n\tBOOL ChangeResolution();\r\n\t\r\n\t/*************************************************************************\r\n\tSummary: Manage the mouse clipping\r\n\r\n\tParameters: TRUE to enable the mouse clipping.\r\n\t*************************************************************************/\r\n\tBOOL ClipMouse(BOOL iEnable);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the WM_PAINT windows event.\r\n\r\n\tDescription: In windowed mode we use the render context to render\r\n\tthe scene.\r\n\t*************************************************************************/\r\n\tvoid OnPaint();\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the mouse left button click.\r\n\r\n\tDescription: Send a message (click or double click) to the object \"picked\"\r\n\tby the mouse, if any.\r\n\t*************************************************************************/\r\n\tvoid OnMouseClick(int iMessage);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the focus changement.\r\n\r\n\tDescription:\r\n\t\t- if the application is minimized (no focus) we paused it.\r\n\t\t- if the application is no more minimized (but was minimized) we restart it.\r\n\t\t- if the application focus is changin depending of the \"Focus Lost Behavior\"\r\n\t\t (see CKContext::GetFocusLostBehavior or the \"Focus Lost Behavior\" in the\r\n\t\t variable manager).\r\n\t*************************************************************************/\r\n\tvoid OnFocusChange(BOOL iFocus);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage the activty of the application.\r\n\r\n\tDescription: If the application is deactivated while it is in fullscreen\r\n\tmode, we must switch to windowed mode.\r\n\t*************************************************************************/\r\n\tvoid OnActivateApp(BOOL iActivate);\r\n\r\n\t/*************************************************************************\r\n\tSummary: Manage system keys (ALT + KEY)\r\n\r\n\tDescription: If system keys are not diabled (see eDisableKeys)\r\n\t\t- ALT + ENTER -> SwitchFullscreen\r\n\t\t- ALT + F4 -> Quit the application\r\n\t*************************************************************************/\r\n\tLRESULT\tOnSysKeyDownMainWindow(int iConfig, int iKey);\r\n\t/*************************************************************************\r\n\tSummary: Manage the activty of the application.\r\n\r\n\tDescription: If the application is deactivated while it is in fullscreen\r\n\tmode, we must switch to windowed mode.\r\n\t*************************************************************************/\r\n\tint DoSystemCheck();\r\n\r\n\tvoid _InitContextAnd();\r\n\tvoid _InitManagers();\r\n\r\n\r\n\tvoid SetMainWindow(HWND _main){ m_MainWindow = _main;}\r\n\r\n\tvtPlayer::Structs::xEApplicationMode m_AppMode;\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t// [11/28/2007 mc007]\r\n\t\r\n\txSEngineWindowInfo m_EngineWindowInfo;\r\n\tUSHORT PLoadEngineWindowProperties(const char *configFile);\r\n\txSEngineWindowInfo& GetEWindowInfo(){return m_EngineWindowInfo;}\r\n\r\n\txSEnginePaths m_EPaths;\r\n\tUSHORT PLoadEnginePathProfile(const char* configFile);\r\n\txSEnginePaths& GetEPathProfile(){return m_EPaths;}\r\n\r\n\txSApplicationWindowStyle m_AWStyle;\r\n\r\n\tUSHORT PLoadAppStyleProfile(const char* configFile);\t\r\n\txSApplicationWindowStyle&GetPAppStyle(){ return m_AWStyle;}\r\n\r\n\txEApplicationMode PGetApplicationMode(const char* pstrCommandLine);\r\n\txEApplicationMode PGetApplicationMode(){return m_AppMode;}\r\n\t \r\n\tAPI_INLINE vtPlayer::Structs::xSEnginePointers *GetEnginePointers();\r\n\tAPI_INLINE vtPlayer::Structs::xSEngineWindowInfo *GetEngineWindowInfo();\r\n\t\r\n\tvoid ShowSplash();\r\n\tvoid SetSplashText(const char* text);\r\n\tvoid HideSplash();\r\n\r\n\r\n\r\n\t////////////////////////////////////////\r\n\t// accessors\r\n\r\n\tint& RasterizerFamily();\r\n\tint& RasterizerFlags();\r\n\tint& WindowedWidth();\r\n\tint& WindowedHeight();\r\n\tint& MininumWindowedWidth();\r\n\tint& MininumWindowedHeight();\r\n\tint& FullscreenWidth();\r\n\tint& FullscreenHeight();\r\n\tint Driver();\r\n\tint& FullscreenBpp();\r\n\tCKRenderContext* GetRenderContext();\r\n\r\nprotected:\r\n\r\n\tenum DriverFlags \r\n\t{\r\n\t\teFamily\t\t\t= 1,\r\n\t\teDirectXVersion\t= 2,\r\n\t\teSoftware\t\t= 4\r\n\t};\r\n\t\r\n\r\n\tenum PlayerState\r\n\t{\r\n\t\teInitial\t= 0,\r\n\t\tePlaying\t= 1,\r\n\t\tePlaused\t= 2,\r\n\t\teFocusLost\t= 3,\r\n\t\teMinimized\t= 4\r\n\t};\r\n\r\n\r\n\tBOOL\t_FinishLoad();\r\n\tBOOL\t_InitPlugins(CKPluginManager& iPluginManager);\r\n\tint\t\t_InitRenderEngines(CKPluginManager& iPluginManager);\r\n\tCKERROR\t_Load(const char* str);\r\n\tCKERROR\t_Load(const void* iMemoryBuffer, int iBufferSize);\r\n\tvoid\t_MissingGuids(CKFile* iFile, const char* iResolvedFile);\r\n\tBOOL\t_GetWindowedResolution();\r\n\tBOOL\t_GetFullScreenResolution();\r\n\tvoid\t_SetResolutions();\r\n\r\n\tBOOL\t_InitDriver();\r\n\tBOOL\t_CheckDriver(VxDriverDesc* iDesc, int iFlags);\r\n\tBOOL\t_CheckFullscreenDisplayMode(BOOL iDoBest);\r\n\r\n\tint\t\t\t\t\tm_State;\r\n\tpublic:\r\n\tHWND\t\t\t\tm_MainWindow;\r\n\tHWND\t\t\t\tm_RenderWindow;\r\n\t// ck objects (context, managers, ...)\r\n\t\r\n\tCKContext*\t\t\tm_CKContext;\r\n\tCKRenderContext*\tm_RenderContext;\r\n\tCKMessageManager*\tm_MessageManager;\r\n\tCKRenderManager*\tm_RenderManager;\r\n\tCKTimeManager*\t\tm_TimeManager;\r\n\tCKAttributeManager*\tm_AttributeManager;\r\n\tCKInputManager*\t\tm_InputManager;\r\n\r\n\tvtPlayer::Structs::xSEnginePointers m_EnginePointers;\r\n\r\n\r\n\tCKLevel*\t\t\tm_Level;\r\n\t// attributes\r\n\t// from an exemple about using this attributes see sample.cmo which is delivered with this player sample\r\n\tint\t\t\t\t\tm_QuitAttType;\t\t\t\t\t// attribut without type, name is \"Quit\"\r\n\tint\t\t\t\t\tm_SwitchFullscreenAttType;\t\t// attribut without type, name is \"Switch Fullscreen\"\r\n\tint\t\t\t\t\tm_SwitchResolutionAttType;\t\t// attribut without type, name is \"Switch Resolution\"\r\n\tint\t\t\t\t\tm_SwitchMouseClippingAttType;\t// attribut without type, name is \"Switch Mouse Clipping\"\r\n\tint\t\t\t\t\tm_WindowedResolutionAttType;\t// attribut which type is Vector 2D, name is \"Windowed Resolution\"\r\n\tint\t\t\t\t\tm_FullscreenResolutionAttType;\t// attribut which type is Vector 2D, name is \"Fullscreen Resolution\"\r\n\tint\t\t\t\t\tm_FullscreenBppAttType;\t\t\t// attribut which type is Integer, name is \"Fullscreen Bpp\"\r\n\t// messages\r\n\tint\t\t\t\t\tm_MsgClick;\r\n\tint\t\t\t\t\tm_MsgDoubleClick;\r\n\t// display configuration\r\n\tint\t\t\t\t\tm_RasterizerFamily;\t\t// see CKRST_RSTFAMILY\r\n\tint\t\t\t\t\tm_RasterizerFlags;\t\t// see CKRST_SPECIFICCAPS\r\n\tint\t\t\t\t\tm_WindowedWidth;\t\t// windowed mode width\r\n\tint\t\t\t\t\tm_WindowedHeight;\t\t// windowed mode height\r\n\tint\t\t\t\t\tm_MinWindowedWidth;\t\t// windowed mode minimum width\r\n\tint\t\t\t\t\tm_MinWindowedHeight;\t// windowed mode minumum height\r\n\tint\t\t\t\t\tm_FullscreenWidth;\t\t// fullscreen mode width\r\n\tint\t\t\t\t\tm_FullscreenHeight;\t\t// fullscreen mode height\r\n\tint\t\t\t\t\tm_FullscreenBpp;\t\t// fullscreen mode bpp\r\n\tint\t\t\t\t\tm_Driver;\t\t\t\t// index of the current driver\r\n\tBOOL\t\t\t\tm_FullscreenEnabled;\t// is fullscreen enable\r\n\tBOOL\t\t\t\tm_EatDisplayChange;\t\t// used to ensure we are not switching mode will we are already switching\r\n\tBOOL\t\t\t\tm_MouseClipped;\t\t\t// used to know if the mouse is acutally cliped\r\n\tRECT\t\t\t\tm_MainWindowRect;\r\n\r\n\tint\t\t\t\t\tm_FullscreenRefreshRate;\t\t// fullscreen mode bpp\r\n\tint m_LastError;\r\n\tXString m_LastErrorText;\r\n\r\nprivate:\r\n\r\n\t// {secret}\r\n\tCCustomPlayer();\r\n\t// {secret}\r\n\tCCustomPlayer(const CCustomPlayer&);\r\n\t// {secret}\r\n\tCCustomPlayer& operator=(const CCustomPlayer&);\r\n\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n// [11/28/2007 mc007]\r\n\r\n#define GetPlayer() CCustomPlayer::Instance()\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n//************************************\r\n// Method: GetEnginePointers\r\n// FullName: CCustomPlayer::GetEnginePointers\r\n// Access: public \r\n// Returns: vtPlayer::Structs::xSEnginePointers*\r\n// Qualifier:\r\n//************************************\r\nvtPlayer::Structs::xSEnginePointers*\r\nCCustomPlayer::GetEnginePointers()\r\n{\r\n\treturn &m_EnginePointers;\r\n}\r\n\r\n//************************************\r\n// Method: GetEngineWindowInfo\r\n// FullName: CCustomPlayer::GetEngineWindowInfo\r\n// Access: public \r\n// Returns: vtPlayer::Structs::xSEngineWindowInfo*\r\n// Qualifier:\r\n//************************************\r\nvtPlayer::Structs::xSEngineWindowInfo*\r\nCCustomPlayer::GetEngineWindowInfo()\r\n{\r\n\treturn &m_EngineWindowInfo;\r\n}\r\n//////////////////////////////////////////////////////////////////////////\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\ninline int& CCustomPlayer::RasterizerFamily()\r\n{\r\n\treturn m_RasterizerFamily;\r\n}\r\n\r\ninline int& CCustomPlayer::RasterizerFlags()\r\n{\r\n\treturn m_RasterizerFlags;\r\n}\r\n\r\ninline int& CCustomPlayer::WindowedWidth()\r\n{\r\n\treturn m_WindowedWidth;\r\n}\r\n\r\ninline int& CCustomPlayer::WindowedHeight()\r\n{\r\n\treturn m_WindowedHeight;\r\n}\r\n\r\ninline int& CCustomPlayer::MininumWindowedWidth()\r\n{\r\n\treturn m_MinWindowedWidth;\r\n}\r\n\r\ninline int& CCustomPlayer::MininumWindowedHeight()\r\n{\r\n\treturn m_MinWindowedHeight;\r\n}\r\n\r\ninline int& CCustomPlayer::FullscreenWidth()\r\n{\r\n\treturn m_FullscreenWidth;\r\n}\r\n\r\ninline int& CCustomPlayer::FullscreenHeight()\r\n{\r\n\treturn m_FullscreenHeight;\r\n}\r\n\r\ninline int CCustomPlayer::Driver()\r\n{\r\n\treturn m_Driver;\r\n}\r\n\r\ninline int& CCustomPlayer::FullscreenBpp()\r\n{\r\n\treturn m_FullscreenBpp;\r\n}\r\n\r\ninline CKRenderContext* CCustomPlayer::GetRenderContext()\r\n{\r\n\treturn m_RenderContext;\r\n}\r\n\r\n\r\n#endif // CUSTOMPLAYER_H/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t\t SetFOV Camera\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetFOVDecl();\r\nCKERROR CreateSetFOVProto(CKBehaviorPrototype **pproto);\r\nint SetFOV(const CKBehaviorContext& behcontext);\r\n\r\n\r\nCKObjectDeclaration\t*FillBehaviorSetFOVDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Set FOV\");\t\r\n\tod->SetDescription(\"Sets the Field Of View of the camera\");\r\n\t/* rem:\r\n\tIn: triggers the process.
\r\n\tOut: is activated when the process is completed.
\r\n\t
\r\n\tAngle: field of view angle, expressed in radians.
\r\n
\r\n See Also: 'Set Zoom'.
\r\n */\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0xaaaacccc, 0xaaaacccc));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateSetFOVProto);\r\n\tod->SetCompatibleClassId(CKCID_CAMERA);\r\n\tod->SetCategory(\"Cameras/Basic\");\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateSetFOVProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Set FOV\");\r\n\tif(!proto) \r\n\t\treturn CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Angle\", CKPGUID_ANGLE, \"0:50\");\r\n\r\n proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(SetFOV);\r\n proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE);\r\n\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n\r\n}\r\n\r\n\r\nint SetFOV(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\r\n\tCKCamera *cam = (CKCamera *) beh->GetTarget();\r\n if( !cam ) return CKBR_OWNERERROR;\r\n\t\r\n\tfloat angle = 50.0f*PI/180;\r\n\tbeh->GetInputParameterValue(0, &angle);\r\n\t\r\n\tcam->SetFov( angle );\r\n\t\r\n\tbeh->ActivateInput(0, FALSE);\r\n\tbeh->ActivateOutput(0);\r\n\t\r\n\treturn CKBR_OK;\r\n}\r\n#include \"precomp.h\"\r\n#include \"vtPrecomp.h\"\r\n#include \"vtNetAll.h\"\r\n#include \"xLogger.h\"\r\nint liftimeMax = 2000;\r\n\r\nstatic vtNetworkManager *_im;\r\nextern xNetInterface* GetNetInterfaceServer();\r\nextern xNetInterface *GetNetInterfaceClient();\r\nextern void SetNetInterfaceClient(xNetInterface *cInterface);\r\nextern void SetNetInterfaceServer(xNetInterface *cInterface);\r\n\r\n\r\nvtNetworkManager::vtNetworkManager(CKContext* context):CKBaseManager(context,NET_MAN_GUID,\"vtNetworkManager\")//Name as used in profiler\r\n{\r\n\tm_Context->RegisterNewManager(this);\r\n\r\n\tlocalConnection = NULL;\r\n\t_im = this;\r\n\tmCurrentThresholdTicker = 0.0f;\r\n\tm_MinTickTime = 10.0f;\r\n\r\n\t\r\n\tinitLogger();\r\n\r\n\r\n\tTNL::logprintf(\"asdasdd\");\r\n\txLogger::xLog(ELOGINFO,XL_START,\"binding object\");\r\n\r\n\r\n\r\n \r\n\t/*\r\n\txBitSet test = xLogger::GetInstance()->getLogLevel(E_LI_SESSION);\r\n\tbool f = test.test(1 << ELOGWARNING);\r\n\tbool f2 = test.test(1 << ELOGTRACE);\r\n\tint h =2;*/\r\n\r\n\t//xLogger::GetInstance()->SetLogVerbosity(ELOGINFO);\r\n\t//xLogger::GetInstance()->SetLogVerbosity(ELOGERROR);\r\n\r\n\r\n}\r\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \r\nvtNetworkManager*vtNetworkManager::Instance(){\treturn _im;}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nvtNetworkManager::~vtNetworkManager()\r\n{\r\n\r\n\tif (GetServerNetInterface())\r\n\t{\r\n\t\tSetServerNetInterface(NULL);\r\n\t}\r\n\r\n\tif (GetClientNetInterface())\r\n\t{\r\n\t\tSetClientNetInterface(NULL);\r\n\t}\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR vtNetworkManager::PostProcess()\r\n{\r\n\r\n\tif(GetClientNetInterface() && isFlagOn(GetNetInterfaceClient()->getInterfaceFlags(),E_NI_DESTROYED_BY_SERVER) )\r\n\t{\r\n\t\t//TNL::logprintf(\"server left\");\r\n\t\tSetClientNetInterface(NULL);\r\n\t\treturn 0;\r\n\t}\r\n\t mCurrentThresholdTicker =getCurrentThresholdTicker() + m_Context->GetTimeManager()->GetLastDeltaTime();\r\n\r\n\t if (getCurrentThresholdTicker() > getMinTickTime() )\r\n\t{\r\n\t\tmCurrentThresholdTicker = 0.0f;\r\n\t}\r\n\t/************************************************************************/\r\n\t/* advance subsystems time : */\r\n\t/************************************************************************/\r\n\tif (GetServerNetInterface())\r\n\t{\r\n\t\t//GetServerNetInterface()->advanceTime(TNL::Platform::getRealMilliseconds(),m_Context->GetTimeManager()->GetLastDeltaTime());\r\n\t\tGetServerNetInterface()->getMessagesInterface()->advanceTime(m_Context->GetTimeManager()->GetLastDeltaTime());\r\n\t}\r\n\r\n\tif(GetClientNetInterface())\r\n\t{\r\n\t\tGetClientNetInterface()->advanceTime(TNL::Platform::getRealMilliseconds(),m_Context->GetTimeManager()->GetLastDeltaTime());\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* passing app values to distributed values, position,etc.... */\r\n\t/************************************************************************/\r\n\r\n\tif(GetClientNetInterface())\r\n\t{\r\n\t\r\n\t\tif(GetClientNetInterface()->isValid())\r\n\t\t{\r\n\t\t\tif (getCurrentThresholdTicker() < getMinTickTime() )\r\n\t\t\t{\r\n\t\t\t\tUpdateDistributedObjects(0);\r\n\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tGetClientNetInterface()->getMessagesInterface()->checkMessages();\n\t\tGetClientNetInterface()->getMessagesInterface()->deleteAllOldMessages();\r\n\t}\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\t\r\n\tif (GetServerNetInterface())\r\n\t{\r\n\t\tGetServerNetInterface()->tick();\r\n\t\tGetServerNetInterface()->getMessagesInterface()->checkMessages();\n\t\tGetServerNetInterface()->getMessagesInterface()->deleteAllOldMessages();\r\n\t}\r\n\r\n\tif(GetClientNetInterface())\r\n\t{\r\n\t\tGetClientNetInterface()->tick();\r\n\t}\r\n\r\n\r\n\r\n\tif(GetClientNetInterface() && GetClientNetInterface()->isValid())\r\n\t{\r\n\t\tif (getCurrentThresholdTicker() < getMinTickTime() )\r\n\t\t{\r\n\t\t\tperformGhostUpdates();\r\n\t\t}\r\n\t}\r\n\r\n\treturn CK_OK;\r\n}\r\n\t\r\n\r\n//************************************\r\n// Method: PreProcess\r\n// FullName: vt_python_man::PreProcess\r\n// Access: public \r\n// Returns: CKERROR\r\n// Qualifier:\r\n//************************************\r\nCKERROR\r\nvtNetworkManager::PreProcess()\r\n{\r\n\t\r\n\treturn CK_OK;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR vtNetworkManager::PostClearAll(){ \treturn CK_OK; }\r\nCKERROR vtNetworkManager::OnCKEnd(){\treturn CK_OK;}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: \r\n*\r\n* Description: \r\n* \r\n* Parameters: \r\n*\r\n* Returns: \r\n*\r\n*******************************************************************\r\n*/\r\nCKERROR vtNetworkManager::OnCKReset()\r\n{\r\n\r\n\tif (GetNetInterfaceClient())\r\n\t{\r\n\t\tSetClientNetInterface(NULL);\r\n\t}\r\n\r\n\tif (GetNetInterfaceServer())\r\n\t{\r\n\t\tSetServerNetInterface(NULL);\r\n\t}\r\n\treturn CK_OK;\r\n\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR vtNetworkManager::OnCKPlay()\r\n{\r\n\t\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\nCKERROR vtNetworkManager::OnCKInit(){\r\n\t\r\n\tm_Context->ActivateManager((CKBaseManager*) this,true);\t\r\n\t\r\n\r\n\treturn CK_OK;\r\n}\r\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid\r\nvtNetworkManager::Test(const char*inpo)\r\n{\r\n\r\n\txNetInterface *si= GetServerNetInterface();\r\n\r\n\tif (si)\r\n\t{\r\n\t\tusing namespace TNL;\r\n\t\tSocket *socket = &si->getSocket();\r\n\t\tif (socket)\r\n\t\t{\r\n\t\t\tbool o = socket->isValid();\r\n\r\n\t\t\tint o1 =0;\r\n\r\n\t\t}\r\n\r\n\t\tint csize = si->getConnectionList().size();\r\n\r\n\r\n\t\tint op = 9 ; \r\n\r\n\t}\r\n}#ifndef _ISESSION_H_\r\n#define _ISESSION_H_\r\n\r\n#include \"xNetTypes.h\"\r\n\r\nclass xNetInterface;\r\nclass xDistributedSession;\r\nclass xDistributedClient;\r\n\r\n\r\nclass ISession\r\n{\r\n\tpublic:\r\n\t\tISession(xNetInterface *nInterface) :mNetInterface(nInterface) {}\r\n\t\txNetInterface * getNetInterface() const { return mNetInterface; }\r\n\r\n\t\tint create(xNString name,int maxUsers,xNString password,int type);\r\n\t\txDistributedSession *get(xNString name);\r\n\t\txDistributedSession *getByUserID(int userID);\r\n\t\txDistributedSession *get(int sessionID);\r\n\t\tvoid deleteSession(int sessionID);\r\n\t\tint getNumSessions();\r\n\t\tint joinClient(xDistributedClient*client, int sessionID,xNString password);\r\n\t\tint removeClient(xDistributedClient*client,int sessionID,bool destroy=false);\r\n\t\tvoid removeClient(int clientID);\r\n\t\tvoid lockSession(int userID,int sessionID);\r\n\t\tvoid unlockSession(int userID,int sessionID);\r\n\t\tuxString print(TNL::BitSet32 flags);\r\n\r\n\tprotected:\r\n\tprivate:\r\n\t\txNetInterface *mNetInterface;\r\n\t\t\r\n\r\n};\r\n#endif#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n#include \"tinyxml.h\"\r\n\r\n#include \r\n\r\n\r\npWheel* pFactory::createWheel(CK3dEntity *bodyReference,CK3dEntity*srcReference,pWheelDescr wheelDescr,pConvexCylinderSettings convexCylinder,VxVector localPositionOffset)\r\n{\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// main objects\r\n\t//\r\n\tpRigidBody *body= GetPMan()->getBody(bodyReference);\r\n\tpWheel *wheel = NULL;\r\n\tbool assertCondition = true;\r\n\t\r\n\tiAssertWR(bodyReference,\"\",assertCondition);\r\n\tiAssertWR(body,\"\",assertCondition);\r\n\tiAssertWR(srcReference,\"\",assertCondition);\r\n\r\n\tif (!assertCondition)\r\n\t\treturn NULL;\r\n\r\n\r\n\tiAssertWR(wheelDescr.isValid(),wheelDescr.setToDefault(),assertCondition);\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// adjust wheel description data\r\n\t//\r\n\tiAssertW(wheelDescr.radius.isValid(),wheelDescr.radius.evaluate(srcReference),\"\");\r\n\tif(!wheelDescr.radius.isValid())\r\n\t\twheelDescr.radius.value = srcReference->GetRadius();\r\n\r\n\t\r\n\r\n\tpObjectDescr objectDescription;\r\n\tobjectDescription.hullType = HT_Wheel;\r\n\tobjectDescription.density = 1.0f;\r\n\t\r\n\tobjectDescription.flags = (BodyFlags)(BF_SubShape|BF_Collision);\r\n\t\r\n\tobjectDescription.setWheel(wheelDescr);\r\n\tobjectDescription.mask|=OD_Wheel;\r\n\t\r\n\r\n\tif(body->addCollider(objectDescription,srcReference))\r\n\t{\r\n\r\n\t\tNxShape*wheelShape = body->getSubShape(srcReference);\r\n\t\t//----------------------------------------------------------------\r\n\t\t//\r\n\t\t// handle wheel types \r\n\t\t//\r\n\t\t//if( wheelShape && wheelShape->isWheel() && wheelDescr.wheelFlags & WF_UseWheelShape)\r\n\t\t//WF_UseWheelShape\r\n\t\tif( wheelShape && wheelShape->isWheel() )\r\n\t\t{\r\n\t\t\twheel = (pWheel*)createWheel(body,wheelDescr,srcReference);\r\n\t\t\t((pWheel2*)wheel)->setWheelShape((NxWheelShape*)wheelShape);\r\n\t\t\twheel->setEntID(srcReference->GetID());\r\n//\t\t\t((pWheel2*)wheel)->setEntity(static_cast(GetPMan()->GetContext()->GetObject(srcReference->GetID())));\r\n\t\t\t((pSubMeshInfo*)(wheelShape->userData))->wheel = wheel;\r\n\t\t\twheel->setFlags(wheelDescr.wheelFlags);\r\n\t\t}\r\n\t}\r\n\r\n\treturn wheel;\r\n\r\n}\r\n\r\nNxShape*pFactory::createWheelShape2(CK3dEntity *bodyReference,CK3dEntity*wheelReference,pWheelDescr wheelDescr)\r\n{\r\n\t\r\n\r\n\tNxWheelShape *result = NULL;\r\n\tbool assertResult = true;\r\n\tpRigidBody *body=GetPMan()->getBody(bodyReference);\r\n\t\r\n\tiAssertWR(bodyReference && wheelReference && wheelDescr.isValid() && body ,\"\",assertResult);\r\n\tif (!assertResult)\r\n\t\treturn NULL;\r\n\r\n\tCKMesh *mesh = wheelReference->GetCurrentMesh();\r\n\tVxVector box_s = mesh->GetLocalBox().GetSize();\r\n\tfloat radius = wheelDescr.radius.value > 0.0f ? wheelDescr.radius.value : box_s.v[wheelDescr.radius.referenceAxis] * 0.5f;\r\n\r\n\tVxQuaternion quatOffset;\r\n\tVxVector posOffset;\r\n\tvtAgeia::calculateOffsets(bodyReference,wheelReference,quatOffset,posOffset);\r\n\r\n\tCK_ID srcID = mesh->GetID();\r\n\r\n\r\n\tNxWheelShapeDesc shape;\r\n\tshape.setToDefault();\r\n\r\n\tshape.radius = radius;\r\n\tshape.localPose.M = pMath::getFrom(quatOffset);\r\n\tshape.localPose.t = pMath::getFrom(posOffset);\r\n\r\n\tfloat heightModifier = (wheelDescr.wheelSuspension + radius ) / wheelDescr.wheelSuspension;\r\n\tshape.suspension.spring = wheelDescr.springRestitution*heightModifier;\r\n\tshape.suspension.damper = wheelDescr.springDamping * heightModifier;\r\n\tshape.suspension.targetValue = wheelDescr.springBias * heightModifier;\r\n\tshape.suspensionTravel = wheelDescr.wheelSuspension;\r\n\tshape.inverseWheelMass = wheelDescr.inverseWheelMass;\r\n\r\n\r\n\tconst pTireFunction& latFunc = wheelDescr.latFunc;\r\n\tconst pTireFunction& longFunc = wheelDescr.longFunc;\r\n\r\n\r\n\tNxTireFunctionDesc lngTFD;\r\n\tlngTFD.extremumSlip = longFunc.extremumSlip ;\r\n\tlngTFD.extremumValue = longFunc.extremumValue;\r\n\tlngTFD.asymptoteSlip = longFunc.asymptoteSlip;\r\n\tlngTFD.asymptoteValue = longFunc.asymptoteValue;\r\n\tlngTFD.stiffnessFactor = longFunc.stiffnessFactor;\r\n\r\n\tNxTireFunctionDesc latTFD;\r\n\tlatTFD.extremumSlip = latFunc.extremumSlip ;\r\n\tlatTFD.extremumValue = latFunc.extremumValue;\r\n\tlatTFD.asymptoteSlip = latFunc.asymptoteSlip;\r\n\tlatTFD.asymptoteValue = latFunc.asymptoteValue;\r\n\tlatTFD.stiffnessFactor = latFunc.stiffnessFactor;\r\n\r\n\r\n\tshape.lateralTireForceFunction =latTFD;\r\n\tshape.longitudalTireForceFunction = lngTFD;\r\n\r\n\tshape.wheelFlags =wheelDescr.wheelShapeFlags;\r\n\t\r\n\tresult = (NxWheelShape*)body->getActor()->createShape(shape);\r\n\r\n\r\n\treturn (NxShape*)result;\r\n\r\n}\r\n\r\nNxShape *pFactory::_createWheelShape1(NxActor *actor,pWheel1 *dstWheel,pObjectDescr *descr,pWheelDescr *wheelDescr,CK3dEntity*srcReference,CKMesh *mesh,VxVector localPos,VxQuaternion localRotation)\r\n{\r\n\t\r\n\t#ifdef _DEBUG\r\n\t\tassert(dstWheel);\r\n\t\tassert(descr);\r\n\t\tassert(wheelDescr);\r\n\t\tassert(srcReference || mesh );\r\n\t#endif // _DEBUG\r\n\r\n\tNxShape *result = NULL;\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// some setup data\r\n\t//\r\n\tNxQuat rot = pMath::getFrom(localRotation);\r\n\tNxVec3 pos = getFrom(localPos);\r\n\tCK_ID srcID = mesh->GetID();\r\n\r\n\tNxConvexShapeDesc shape;\r\n\tif (!_createConvexCylinder(&shape,srcReference))\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create convex cylinder mesh\");\r\n\r\n\tshape.density = descr->density;\r\n\tshape.localPose.t = pMath::getFrom(localPos);\r\n\tshape.localPose.M = rot;\r\n\tif (descr->skinWidth!=-1.0f)\r\n\t\tshape.skinWidth = descr->skinWidth;\r\n\t\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Create the convex shape : \r\n\t//\r\n\tdstWheel->setWheelConvex(actor->createShape(shape)->isConvexMesh());\r\n\t\r\n\t//if (!_createConvexCylinder(shape,srcReference))\r\n\t//\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Couldn't create convex cylinder mesh\");\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Find the wheels cylinder description\r\n\r\n\tpConvexCylinderSettings cylDescr;\r\n\tfindSettings(cylDescr,srcReference);\r\n\tcylDescr.radius.value *=0.5f; \r\n\r\n\t//################################################################\r\n\t//\r\n\t// Create a joint spring for the suspension \r\n\t//\r\n\r\n\tNxReal heightModifier = (wheelDescr->wheelSuspension + cylDescr.radius.value) / wheelDescr->wheelSuspension;\r\n\tif (wheelDescr->wheelSuspension < 1)\r\n\t\theightModifier = 1.f / wheelDescr->wheelSuspension;\r\n\r\n\tNxSpringDesc wheelSpring;\r\n\twheelSpring.spring\t\t\t\t\t= wheelDescr->springRestitution*heightModifier;\r\n\twheelSpring.damper\t\t\t\t\t= wheelDescr->springDamping*heightModifier;\r\n\twheelSpring.targetValue\t\t\t\t= wheelDescr->springBias*heightModifier;\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// The original code creates a material here ! We skip this !\r\n\t//\r\n\r\n\t\t\t//#########################\r\n\t\r\n\r\n\t//################################################################\r\n\t//\r\n\t// The wheel capsule is perpendicular to the floor\r\n\t//\r\n\r\n\tNxVec3 forwardAxis = getFrom(cylDescr.forwardAxis);\r\n\tNxVec3 downAxis = getFrom(cylDescr.downAxis);\r\n\tNxVec3 wheelAxis = getFrom(cylDescr.rightAxis);\r\n\r\n\r\n\tNxMaterialDesc materialDesc;\r\n\tmaterialDesc.restitution\t\t\t= 0.0f;\r\n\tmaterialDesc.dynamicFriction\t\t= wheelDescr->frictionToSide;\r\n\tmaterialDesc.staticFriction\t\t\t= 2.0f;\r\n\tmaterialDesc.staticFrictionV\t\t= wheelDescr->frictionToFront*4;\r\n\tmaterialDesc.dynamicFrictionV\t\t= wheelDescr->frictionToFront;\r\n\tmaterialDesc.dirOfAnisotropy\t\t= forwardAxis;\r\n\tmaterialDesc.frictionCombineMode\t= NX_CM_MULTIPLY;\r\n\tmaterialDesc.flags\t\t\t\t\t|= NX_MF_ANISOTROPIC;\r\n\r\n\t\r\n\r\n\tdstWheel->material = actor->getScene().createMaterial(materialDesc);\r\n\r\n\tNxCapsuleShapeDesc capsuleShape;\r\n\tcapsuleShape.radius = cylDescr.radius.value * 0.1f;\r\n\tcapsuleShape.height = wheelDescr->wheelSuspension + cylDescr.radius.value;\r\n\tcapsuleShape.flags = NX_SWEPT_SHAPE;\r\n\r\n\t//capsuleShape.localPose.M.setColumn(0, NxVec3( 1, 0, 0));\r\n\t//capsuleShape.localPose.M.setColumn(1, NxVec3( 0,-1, 0));\r\n\t//capsuleShape.localPose.M.setColumn(2, NxVec3( 0, 0,-1));\t//rotate 180 degrees around x axis to cast downward!\r\n\r\n\tcapsuleShape.materialIndex = dstWheel->material->getMaterialIndex();\r\n\r\n\r\n\tcapsuleShape.localPose.M.setColumn(0, forwardAxis);\r\n\tcapsuleShape.localPose.M.setColumn(1, downAxis);\r\n\tcapsuleShape.localPose.M.setColumn(2, wheelAxis);\r\n\tif(wheelDescr->wheelSuspension >= 1) \r\n\t{\r\n\t\tcapsuleShape.localPose.t = pos + downAxis*(cylDescr.radius.value);\r\n\t}\r\n\telse \r\n\t{\r\n\t\tcapsuleShape.localPose.t = pos + (-1.0f *downAxis)*((cylDescr.radius.value + wheelDescr->wheelSuspension)*0.5f);\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Finalize \r\n\t//\r\n\tresult = dstWheel->getWheelConvex();\r\n\tif (!capsuleShape.isValid())\r\n\t{\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Capsule shape description during wheel1 construction was invalid\");\r\n\t}\r\n\t\r\n\tdstWheel->setWheelCapsule(actor->createShape(capsuleShape)->isCapsule());\r\n\t\r\n\r\n\r\n\tdstWheel->_radius = cylDescr.radius.value;\r\n\tdstWheel->_turnAngle = 0;\r\n\tdstWheel->_turnVelocity = 0;\r\n\tdstWheel->_perimeter = dstWheel->_radius * NxTwoPi;\r\n\tdstWheel->_maxSuspension = wheelDescr->wheelSuspension;\r\n\tdstWheel->_wheelWidth = cylDescr.height.value;\r\n\tdstWheel->_maxPosition = localPos;\r\n\t\r\n\tdstWheel->_frictionToFront = wheelDescr->frictionToFront;\r\n\tdstWheel->_frictionToSide = wheelDescr->frictionToSide;\r\n\r\n\r\n\tNxU32 contactReportFlags = actor->getContactReportFlags();\r\n\tcontactReportFlags |=NX_NOTIFY_ON_TOUCH;\r\n\tactor->setContactReportFlags(contactReportFlags);\r\n\treturn dstWheel->getWheelCapsule();\r\n\r\n}\r\n\r\n\r\npWheel *pFactory::createWheelSubShape(pRigidBody *body,CK3dEntity* subEntity,CKMesh *mesh,pObjectDescr *descr,VxVector localPos, VxQuaternion localRotation,NxShape*dstShape)\r\n{\r\n\t//################################################################\r\n\t//\r\n\t// Sanity checks\r\n\t//\r\n\t#ifdef _DEBUG\r\n\t\tassert(body && subEntity && descr );\t// Should never occur ! \r\n\t#endif // _DEBUG\r\n\r\n\r\n\tXString errorStr;\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Retrieve the wheel setting from attribute \r\n\t//\r\n\tint attTypeWheelSettings = GetPMan()->att_wheelDescr;\r\n\tint attTypeConvexCylinderSettings = GetPMan()->getAttributeTypeByGuid(VTS_PHYSIC_CONVEX_CYLDINDER_WHEEL_DESCR);\r\n\t\r\n\tif (!subEntity->HasAttribute(attTypeWheelSettings))\r\n\t{\r\n\t\terrorStr.Format(\"Object %s has been set as wheel but there is no wheel attribute attached\",subEntity->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,errorStr.CStr());\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\tpWheelDescr *wDescr = new pWheelDescr();\r\n\tCKParameterOut *par = subEntity->GetAttributeParameter(attTypeWheelSettings);\r\n\tif (par)\r\n\t{\r\n\t\t\r\n\t\tint err = copyTo(wDescr,par);\r\n\t\tif (!wDescr->isValid() )\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Wheel Description is invalid\");\r\n\t\t\tSAFE_DELETE(wDescr);\r\n\t\t\treturn NULL;\r\n\t\t}\r\n\t}\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Construct the final wheel object basing on the type of the wheel\r\n\t//\r\n\r\n\tpWheel *result = NULL;\r\n\r\n\r\n\t//if(wDescr->wheelFlags & WF_UseWheelShape)\t{\r\n\t\r\n\tresult = new pWheel2(body,wDescr,subEntity);\r\n\t\r\n\t/*else\r\n\t{\r\n\t\t//################################################################\r\n\t\t// Wheel type 1 specified, check there is also a override for the convex cylinder \r\n\t\tif (!subEntity->HasAttribute(attTypeConvexCylinderSettings))\r\n\t\t{\r\n\t\t\terrorStr.Format(\"Object %s has been created with default settings for convex cylinder shape\",subEntity->GetName());\r\n\t\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errorStr.CStr());\r\n\t\t}\r\n\t\tresult = new pWheel1(body,wDescr);\r\n\t}*/\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Create the wheel shape \r\n\t//\r\n\t\r\n\r\n\r\n\t//if(wDescr->wheelFlags & WF_UseWheelShape){\r\n\t\r\n\tdstShape=_createWheelShape2(body->getActor(),descr,wDescr,subEntity,mesh,localPos,localRotation);\r\n\t((pWheel2*)result)->setWheelShape((NxWheelShape*)dstShape);\r\n//\t}\r\n\t/*else\r\n\t{\r\n\t\tdstShape=_createWheelShape1(body->getActor(),(pWheel1*)result,descr,wDescr,subEntity,mesh,localPos,localRotation);\r\n\t}*/\r\n\r\n\tif (!dstShape)\r\n\t{\r\n\t\terrorStr.Format(\"Couldn't create wheel shape for object %s\",subEntity->GetName());\r\n\t\txLogger::xLog(XL_START,ELOGWARNING,E_LI_MANAGER,errorStr.CStr());\r\n\t\t\r\n\t\tSAFE_DELETE(wDescr);\r\n\t\tSAFE_DELETE(result);\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\r\n\t//################################################################\r\n\t//\r\n\t// Finalize wheel setup\r\n\t//\r\n\r\n\tresult->setEntID(subEntity->GetID());\r\n\r\n\r\n\treturn result;\r\n}\r\n\r\n\r\npTireFunction pFactory::createTireFuncFromParameter(CKParameter *par)\r\n{\r\n\tpTireFunction result;\r\n\tresult.setToDefault();\r\n\r\n\tif (!par)\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\tresult.extremumSlip = vtTools::ParameterTools::GetValueFromParameterStruct(par,1);\r\n\tresult.extremumValue = vtTools::ParameterTools::GetValueFromParameterStruct(par,2);\r\n\tresult.asymptoteSlip = vtTools::ParameterTools::GetValueFromParameterStruct(par,3);\r\n\tresult.asymptoteValue= vtTools::ParameterTools::GetValueFromParameterStruct(par,4);\r\n\tresult.stiffnessFactor = vtTools::ParameterTools::GetValueFromParameterStruct(par,5);\r\n\r\n\t/************************************************************************/\r\n\t/* Lat Tire Func from XML ? */\r\n\t/************************************************************************/\r\n\tint xmlLinkId = vtTools::ParameterTools::GetValueFromParameterStruct(par,0);\r\n\tif (xmlLinkId!=0)\r\n\t{\r\n\t\tXString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_TIRE_SETTINGS,xmlLinkId );\r\n\t\tloadFrom(result,nodeName.CStr(),getDefaultDocument());\r\n\t\tif (!result.isValid())\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Latitude Tire Function was incorrect, setting to default\");\r\n\t\t\tresult.setToDefault();\r\n\t\t}else{\r\n\t\t\tcopyTo((CKParameterOut*)par,result);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tif (!result.isValid())\r\n\t{\r\n\t\tresult.setToDefault();\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nint pFactory::copyTo(pWheelDescr *dst,CKParameter *src)\r\n{\r\n\r\n\tint result = 1;\r\n\tif (!src || !dst)\r\n\t{\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tusing namespace vtTools::ParameterTools;\r\n\tdst->setToDefault();\r\n\r\n\r\n\tdst->wheelSuspension = GetValueFromParameterStruct(src,E_WD_SUSPENSION);\r\n\tdst->springRestitution= GetValueFromParameterStruct(src,E_WD_SPRING_RES);\r\n\tdst->springBias = GetValueFromParameterStruct(src,E_WD_SPRING_BIAS);\r\n\tdst->springDamping= GetValueFromParameterStruct(src,E_WD_DAMP);\r\n\r\n\tdst->maxBrakeForce= GetValueFromParameterStruct(src,E_WD_MAX_BFORCE);\r\n\tdst->frictionToSide= GetValueFromParameterStruct(src,E_WD_FSIDE);\r\n\tdst->frictionToFront= GetValueFromParameterStruct(src,E_WD_FFRONT);\r\n\t\r\n\tCKParameterOut *pOld = GetParameterFromStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\tif (pOld)\r\n\t{\r\n\t\tif (pOld->GetGUID() == CKPGUID_FLOAT)\r\n\t\t{\r\n\t\t\tdst->inverseWheelMass= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\t\t}\r\n\r\n\t\tif (pOld->GetGUID() == CKPGUID_INT)\r\n\t\t{\r\n\t\t\tdst->wheelApproximation= GetValueFromParameterStruct(src,E_WD_INVERSE_WHEEL_MASS);\r\n\t\t}\r\n\t}\r\n\r\n\t//dst->wheelApproximation= GetValueFromParameterStruct(float,E_WD_INVERSE_WHEEL_MASS);\r\n\r\n\tdst->wheelFlags= (WheelFlags)GetValueFromParameterStruct(src,E_WD_FLAGS);\r\n\tdst->wheelShapeFlags=(WheelShapeFlags) GetValueFromParameterStruct(src,E_WD_SFLAGS);\r\n\r\n\r\n\tCKParameterOut *parLatFunc = GetParameterFromStruct(src,E_WD_LAT_FUNC);\r\n\tCKParameterOut *parLongFunc = GetParameterFromStruct(src,E_WD_LONG_FUNC);\r\n\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* XML Setup ? */\r\n\t/************************************************************************/\r\n\tint xmlLinkId= GetValueFromParameterStruct(src,E_WD_XML);\r\n\tbool wIsXML=false;\r\n\tbool latIsXML= false;\r\n\tbool longIsXML=false;\r\n\r\n\tXString nodeName;\r\n\tif ( xmlLinkId !=0 )\r\n\t{\r\n\t\tnodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_WHEEL_SETTINGS,xmlLinkId);\r\n\t\tloadWheelDescrFromXML(*dst,nodeName.CStr(),getDefaultDocument());\r\n\t\twIsXML =true;\r\n\t\tif (!dst->isValid())\r\n\t\t{\r\n\t\t\txLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,\"Wheel Description was invalid\");\r\n\t\t}\r\n\r\n\r\n\t\tif (dst->latFunc.xmlLink!=0)\r\n\t\t{\r\n\t\t\tlatIsXML=true;\r\n\t\t}\r\n\r\n\t\tif (dst->longFunc.xmlLink!=0)\r\n\t\t{\r\n\t\t\tlongIsXML=true;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\tif (!latIsXML)\r\n\t{\r\n\t\tdst->latFunc = createTireFuncFromParameter(parLatFunc);\r\n\t}\r\n\r\n\r\n\tif (!longIsXML)\r\n\t{\r\n\t\tdst->longFunc= createTireFuncFromParameter(parLongFunc);\r\n\t}\r\n\r\n\tif (wIsXML)\r\n\t{\r\n\t\tcopyTo((CKParameterOut*)src,dst);\r\n\t}\r\n\r\n\t\r\n\tif (longIsXML)\r\n\t{\r\n\t\tcopyTo(GetParameterFromStruct(src,E_WD_LONG_FUNC),dst->longFunc);\r\n\t}\r\n\r\n\tif (latIsXML)\r\n\t{\r\n\t\tcopyTo(GetParameterFromStruct(src,E_WD_LAT_FUNC),dst->latFunc);\r\n\t}\r\n\t\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\nNxShape *pFactory::_createWheelShape2(NxActor *actor, pObjectDescr *descr, pWheelDescr *wheelDescr, CK3dEntity*srcReference,CKMesh *mesh, VxVector localPos, VxQuaternion localRotation)\r\n{\r\n\r\n\tNxWheelShape *result = NULL;\r\n\r\n\tif (!actor || !descr || !mesh )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\tint hType = descr->hullType;\r\n\tVxVector box_s = mesh->GetLocalBox().GetSize();\r\n\tfloat density = descr->density;\r\n\tfloat skinWidth = descr->skinWidth;\r\n\tfloat radius = box_s.x*0.5f;\r\n\tNxQuat rot = pMath::getFrom(localRotation);\r\n\r\n\tCK_ID srcID = mesh->GetID();\r\n\r\n\r\n\tNxWheelShapeDesc shape;\r\n\tshape.setToDefault();\r\n\r\n\tshape.radius = box_s.z*0.5f;\r\n\tshape.density = density;\r\n\tshape.localPose.M = rot;\r\n\tshape.localPose.t = pMath::getFrom(localPos);\r\n\tif (skinWidth!=-1.0f)\r\n\t\tshape.skinWidth = skinWidth;\r\n\r\n\tfloat heightModifier = (wheelDescr->wheelSuspension + radius ) / wheelDescr->wheelSuspension;\r\n\tshape.suspension.spring = wheelDescr->springRestitution*heightModifier;\r\n\tshape.suspension.damper = wheelDescr->springDamping * heightModifier;\r\n\tshape.suspension.targetValue = wheelDescr->springBias * heightModifier;\r\n\tshape.suspensionTravel = wheelDescr->wheelSuspension;\r\n\r\n\t//shape.lateralTireForceFunction.stiffnessFactor *= wheelDescr->frictionToSide;\r\n\t//shape.longitudalTireForceFunction.stiffnessFactor*=wheelDescr->frictionToFront;\r\n\tshape.inverseWheelMass = wheelDescr->inverseWheelMass;\r\n\r\n\t\r\n\tconst pTireFunction& latFunc = wheelDescr->latFunc;\r\n\tconst pTireFunction& longFunc = wheelDescr->longFunc;\r\n\r\n\r\n\tNxTireFunctionDesc lngTFD;\r\n\tlngTFD.extremumSlip = longFunc.extremumSlip ;\r\n\tlngTFD.extremumValue = longFunc.extremumValue;\r\n\tlngTFD.asymptoteSlip = longFunc.asymptoteSlip;\r\n\tlngTFD.asymptoteValue = longFunc.asymptoteValue;\r\n\tlngTFD.stiffnessFactor = longFunc.stiffnessFactor;\r\n\r\n\tNxTireFunctionDesc latTFD;\r\n\tlatTFD.extremumSlip = latFunc.extremumSlip ;\r\n\tlatTFD.extremumValue = latFunc.extremumValue;\r\n\tlatTFD.asymptoteSlip = latFunc.asymptoteSlip;\r\n\tlatTFD.asymptoteValue = latFunc.asymptoteValue;\r\n\tlatTFD.stiffnessFactor = latFunc.stiffnessFactor;\r\n\r\n\r\n\tif ( !(wheelDescr->wheelFlags & WF_IgnoreTireFunction) )\r\n\t{\r\n\t\tshape.lateralTireForceFunction =latTFD;\r\n\t\tshape.longitudalTireForceFunction = lngTFD;\r\n\t}\r\n\t//shape.wheelFlags = wheelDescr->wheelFlags;\r\n\t//shape.wheelFlags |= (NxWheelShapeFlags(NX_WF_WHEEL_AXIS_CONTACT_NORMAL));\r\n\t//shape.shapeFlags = wheelDescr->wheelShapeFlags;\r\n\tshape.wheelFlags =wheelDescr->wheelShapeFlags;\r\n\r\n\t/*\r\n\tif (wheelDescr->wheelFlags & (WF_Accelerated|WF_UseWheelShape) )\r\n\t{\r\n\t\tint isValid = shape.isValid();\r\n\r\n\t}\r\n\t*/\r\n\t\r\n\r\n\r\n\tint isValid = shape.isValid();\r\n\tresult = (NxWheelShape*)actor->createShape(shape);\r\n\r\n\tif (result)\r\n\t{\r\n\t\t\r\n\r\n\t\t//result->setWheelFlags(wheelDescr->wheelFlags);\r\n\t\t//pWheel::getWheelFlag()\r\n\r\n\r\n\t\t/*\t\tif ( & E_WF_VEHICLE_CONTROLLED )\r\n\t\t{\r\n\t\tint isValid = shape.isValid();\r\n\r\n\t\t}\r\n\t\t*/\r\n\t}\r\n\r\n\r\n\r\n\treturn (NxShape*)result;\r\n\r\n\r\n}\r\n\r\nNxShape *pFactory::createWheelShape(NxActor *actor, pObjectDescr *descr, pWheelDescr *wheelDescr, CK3dEntity*srcReference,CKMesh *mesh, VxVector localPos, VxQuaternion localRotation)\r\n{\r\n\r\n//\tif(wheelDescr->wheelFlags & WF_UseWheelShape){\r\n\t\t\r\n\treturn _createWheelShape2(actor,descr,wheelDescr,srcReference,mesh,localPos,localRotation);\r\n\t\r\n\t/*}else\r\n\t\treturn NULL;//_createWheelShape1(actor,descr,wheelDescr,srcReference,mesh,localPos,localRotation);\r\n*/\r\n\treturn NULL;\r\n\r\n\r\n\r\n}\r\n\r\n\r\npWheel*pFactory::createWheel(pRigidBody *body,pWheelDescr descr,CK3dEntity *wheelShapeReference)\r\n{\r\n\r\n\tpWheel *result = NULL;\r\n\tif (!body || !body->isValid() )\r\n\t{\r\n\t\treturn result;\r\n\t}\r\n\r\n\t//if(descr.wheelFlags & WF_UseWheelShape)\t{\r\n\t\r\n\tresult = new pWheel2(body,&descr,wheelShapeReference);\r\n\t\r\n/*\t}else\r\n\t{\r\n\t\tresult = new pWheel1(body,&descr);\r\n\t}\r\n*/\r\n\r\n\tif (result)\r\n\t{\r\n\t\tresult->setFlags(descr.wheelFlags);\r\n\t}//\r\n\treturn result;\r\n}\r\n\r\nXString pFactory::_getVehicleTireFunctionAsEnumeration(const TiXmlDocument * doc)\r\n{\r\n\r\n\tif (!doc)\r\n\t{\r\n\t\treturn XString(\"\");\r\n\t}\r\n\r\n\tXString result(\"None=0\");\r\n\tint counter = 1;\r\n\r\n\r\n\t/************************************************************************/\r\n\t/* */\r\n\t/************************************************************************/\r\n\tif ( doc)\r\n\t{\r\n\t\tconst TiXmlElement *root = getFirstDocElement(doc->RootElement());\r\n\t\tfor (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() )\r\n\t\t{\r\n\t\t\tif ( (child->Type() == TiXmlNode::ELEMENT))\r\n\t\t\t{\r\n\t\t\t\tXString name = child->Value();\r\n\t\t\t\tif (!strcmp(child->Value(), \"tireFunction\" ) )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tconst TiXmlElement *sube = (const TiXmlElement*)child;\r\n\r\n\t\t\t\t\tconst char* vSName = NULL;\r\n\t\t\t\t\tvSName = sube->Attribute(\"name\");\r\n\t\t\t\t\tif (vSName && strlen(vSName))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (result.Length())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresult << \",\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresult << vSName;\r\n\t\t\t\t\t\tresult << \"=\" << counter;\r\n\t\t\t\t\t\tcounter ++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn result;\r\n}\r\n\r\n\r\n\r\nint pFactory::copyTo(pWheelDescr &dst,CKParameterOut *src)\r\n{\r\n\tif (!src)return false;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\t//SetParameterStructureValue(dst,E_WD_SPRING_BIAS,src.,false);\r\n\r\n\treturn result;\r\n\r\n\r\n}\r\n\r\nint pFactory::copyTo(CKParameterOut *dst,const pTireFunction& src)\r\n{\r\n\r\n\tif (!dst)return false;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\tSetParameterStructureValue(dst,0,src.xmlLink,false);\r\n\tSetParameterStructureValue(dst,1,src.extremumSlip,false);\r\n\tSetParameterStructureValue(dst,2,src.extremumValue,false);\r\n\tSetParameterStructureValue(dst,3,src.asymptoteSlip,false);\r\n\tSetParameterStructureValue(dst,4,src.asymptoteValue,false);\r\n\tSetParameterStructureValue(dst,5,src.stiffnessFactor,false);\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pFactory::copyTo(CKParameterOut *dst,pWheelDescr *src)\r\n{\r\n\r\n\tif (!src)return false;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\tSetParameterStructureValue(dst,E_WD_SPRING_BIAS,src->springBias,false);\r\n\tSetParameterStructureValue(dst,E_WD_SPRING_RES,src->springRestitution,false);\r\n\tSetParameterStructureValue(dst,E_WD_DAMP,src->springDamping,false);\r\n\tSetParameterStructureValue(dst,E_WD_MAX_BFORCE,src->maxBrakeForce,false);\r\n\tSetParameterStructureValue(dst,E_WD_FFRONT,src->frictionToFront,false);\r\n\tSetParameterStructureValue(dst,E_WD_FSIDE,src->frictionToSide,false);\r\n\tSetParameterStructureValue(dst,E_WD_FLAGS,src->wheelFlags,false);\r\n\tSetParameterStructureValue(dst,E_WD_SFLAGS,src->wheelShapeFlags,false);\r\n\tSetParameterStructureValue(dst,E_WD_INVERSE_WHEEL_MASS,src->inverseWheelMass,false);\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\nint pFactory::copyTo(CKParameterOut *dst,const pWheelContactData& src)\r\n{\r\n\r\n\tif (!dst)return false;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\tint result = 0;\r\n\r\n\tSetParameterStructureValue(dst,E_WCD_CPOINT,src.contactPoint,false);\r\n\tSetParameterStructureValue(dst,E_WCD_CNORMAL,src.contactNormal,false);\r\n\tSetParameterStructureValue(dst,E_WCD_LONG_DIR,src.longitudalDirection,false);\r\n\tSetParameterStructureValue(dst,E_WCD_LAT_DIR,src.lateralDirection,false);\r\n\r\n\tSetParameterStructureValue(dst,E_WCD_CONTACT_FORCE,src.contactForce,false);\r\n\r\n\tSetParameterStructureValue(dst,E_WCD_LONG_SLIP,src.longitudalSlip,false);\r\n\tSetParameterStructureValue(dst,E_WCD_LAT_SLIP,src.lateralSlip,false);\r\n\r\n\tSetParameterStructureValue(dst,E_WCD_LONG_IMPULSE,src.longitudalImpulse,false);\r\n\tSetParameterStructureValue(dst,E_WCD_LAT_IMPULSE,src.lateralImpulse,false);\r\n\r\n\tSetParameterStructureValue(dst,E_WCD_C_POS,src.contactPosition,false);\r\n\r\n\tif (src.contactEntity)\r\n\t{\r\n\t\tSetParameterStructureValue(dst,E_WCD_CONTACT_ENTITY,src.contactEntity->GetID(),false);\r\n\t}\r\n\r\n\tCKParameter *materialParameter = vtTools::ParameterTools::GetParameterFromStruct(dst,E_WCD_OTHER_MATERIAL_INDEX,false);\r\n\tpFactory::Instance()->copyTo((CKParameterOut*)materialParameter,src.otherMaterial);\r\n\r\n\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\nbool pFactory::loadFrom(pWheelDescr& dst,const char* nodeName)\r\n{\r\n\treturn loadWheelDescrFromXML(dst,nodeName,getDefaultDocument());\r\n\r\n}/*********************************************************************NVMH4****\r\nPath: SDK\\LIBS\\inc\\shared\r\nFile: NV_StringFuncs.cpp\r\n\r\nCopyright NVIDIA Corporation 2002\r\nTO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED\r\n*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS\r\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS\r\nBE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES\r\nWHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,\r\nBUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)\r\nARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS\r\nBEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r\n\r\n\r\n\r\nComments:\r\nSee NV_StringFuncs.h for comments.\r\n\r\n\r\n******************************************************************************/\r\n\r\n\r\n\r\n#include \"3D\\NV_StringFuncs.h\"\r\n#include \"3D\\NV_Common.h\"\r\n#include \"3D\\NV_Error.h\"\r\n\r\n#pragma warning(disable : 4786)\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n\r\nnamespace NVStringConv\r\n{\r\n\t// use as an alternative to wcstombs()\r\n\tstd::string WStringToString( const std::wstring * in_pwstring )\r\n\t{\r\n\t\tif( in_pwstring == NULL )\r\n\t\t\treturn( \"\" );\r\n\t\treturn( lpcwstrToString( in_pwstring->c_str() ));\r\n\t}\r\n\r\n\tstd::string WStringToString( std::wstring & in_wstring )\r\n\t{\r\n\t\treturn( lpcwstrToString( in_wstring.c_str() ));\r\n\t}\r\n\r\n\tstd::string lpcwstrToString( LPCWSTR in_lpcwstr )\r\n\t{\r\n\t\t//@ consider using windows.h WideCharToMultiByte(..)\r\n\t\tchar * mbBuf;\r\n\t\tsize_t sz;\r\n\t\tsz = 2 * wcslen( in_lpcwstr );\r\n\t\tmbBuf = new char[sz];\r\n\t\tif( mbBuf == NULL )\r\n\t\t\treturn( \"\" );\r\n\t\twcstombs( mbBuf, in_lpcwstr, sz );\t\t// convert the string \r\n\t\tstd::string outstr;\r\n\t\toutstr = mbBuf;\r\n\t\tdelete [] mbBuf;\r\n\t\treturn( outstr );\r\n\t}\r\n\r\n\tstd::wstring StringToWString( const std::string * in_pString )\r\n\t{\r\n\t\tstd::wstring wstr = L\"\";\r\n\t\tif( in_pString != NULL )\r\n\t\t\twstr = lpcstrToWString( in_pString->c_str() );\r\n\t\treturn( wstr );\r\n\t}\r\n\r\n\tstd::wstring StringToWString( std::string & in_String )\r\n\t{\r\n\t\treturn( lpcstrToWString( in_String.c_str() ));\r\n\t}\r\n\r\n\tstd::wstring lpcstrToWString( LPCSTR lpstr )\r\n\t{\r\n\t\tint nLen = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, NULL);\r\n\t\tLPWSTR lpszW = new WCHAR[nLen+1];\r\n\t\tMultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpszW, nLen);\r\n\t\tlpszW[nLen] = '\\0';\r\n\t\tstd::wstring wstr;\r\n\t\twstr.reserve( nLen );\r\n\t\twstr.insert( 0, lpszW );\r\n//\t\twstr = lpszW;\r\n\t\tdelete[] lpszW;\r\n\t\treturn( wstr );\r\n\t}\r\n};\t\t\t\t// namespace NVStringConv\r\n\r\n\r\n//---------------------------------------------------------------------------\r\n\r\n\t// Create a string using va_args, just like printf, sprintf, etc.\r\nstd::string StrPrintf( const char * szFormat, ... )\r\n{\r\n\tstd::string out;\r\n\r\n\tconst int bufsz = 2048;\r\n\tchar buffer[ bufsz ];\r\n\r\n\tva_list args;\r\n\tva_start( args, szFormat );\r\n\t_vsnprintf( buffer, bufsz, szFormat, args );\r\n\tva_end( args );\r\n\r\n\tbuffer[bufsz-1] = '\\0';\t\t\t// terminate in case of overflow\r\n\tout = buffer;\r\n\r\n\treturn( out );\r\n}\r\n\r\nstd::string StrToUpper( const std::string & strIn )\r\n{\r\n\tunsigned int i;\r\n\tstd::string out;\r\n\tout.reserve( strIn.size() );\r\n\tfor( i=0; i < strIn.size(); i++ )\r\n\t{\r\n\t\tout += toupper( strIn.at(i) );\r\n\t}\r\n\treturn( out );\r\n}\r\n\t\r\nstd::string StrToLower( const std::string & strIn )\r\n{\r\n\tunsigned int i;\r\n\tstd::string out;\r\n\tout.reserve( strIn.size() );\r\n\tfor( i=0; i < strIn.size(); i++ )\r\n\t{\r\n\t\tout += tolower( strIn.at(i) );\r\n\t}\r\n\treturn( out );\r\n}\r\n\r\n\r\nstd::string StrsToString( const std::vector< std::string > & vstrIn )\r\n{\r\n\treturn( StrsToString( vstrIn, \" \" ));\r\n}\r\n\r\n\t// same as above, but lets you specify the separator\r\nstd::string StrsToString( const std::vector< std::string > & vstrIn, const std::string & separator )\r\n{\r\n\tstd::string out;\r\n\tout.reserve( vstrIn.size() * 5 );\t// rough estimate, 5 chars per string\r\n\tunsigned int i;\r\n\tfor( i=0; i < vstrIn.size(); i++ )\r\n\t{\r\n\t\tout += vstrIn.at(i) + separator;\r\n\t}\r\n\treturn( out );\r\n}\r\n\r\nstd::string StrsToString( const std::list< std::string > & lstrIn, const std::string & separator )\r\n{\r\n\tstd::string out;\r\n\tout.reserve( lstrIn.size() * 5 );\r\n\tstd::list< std::string>::const_iterator p;\r\n\tfor( p = lstrIn.begin(); p != lstrIn.end(); p++ )\r\n\t{\r\n\t\tout += (*p) + separator;\r\n\t}\r\n\treturn( out );\r\n}\r\n\r\n\r\n\r\nstd::string * StrReplace( const std::string & sequence_to_replace, \r\n\t\t\t\t\t\t\tconst std::string & replacement_string,\r\n\t\t\t\t\t\t\tconst std::string & strIn,\r\n\t\t\t\t\t\t\tstd::string * pOut,\r\n\t\t\t\t\t\t\tbool bVerbose )\r\n{\r\n\tif( pOut == NULL )\r\n\t\treturn( pOut );\r\n\tif( & strIn == pOut )\r\n\t{\r\n\t\t// can't have strIn and pOut point to the same thing\r\n\t\t// have to copy the input string\r\n\t\tstd::string incpy = strIn;\r\n\t\treturn( StrReplace( sequence_to_replace, replacement_string, incpy, pOut ));\r\n\t}\r\n\r\n\r\n\t// Similar functionality to CString::Replace(), but no MFC required.\r\n\tunsigned int i;\r\n\tstd::vector< size_t > vpos;\r\n\tstd::string::size_type pos;\r\n\tpos = 0;\r\n\r\n\t*pOut = \"\";\r\n\r\n\tdo\r\n\t{\r\n\t\tpos = strIn.find( sequence_to_replace, pos );\r\n\t\tif( pos != std::string::npos )\r\n\t\t{\r\n\t\t\tvpos.push_back( pos );\r\n\t\t\tpos++;\r\n\t\t}\r\n\t} while( pos != std::string::npos );\r\n\r\n\tif( bVerbose )\r\n\t{\r\n\t\tFMsg(\"found at \");\r\n\t\tfor( i=0; i < vpos.size(); i++ )\r\n\t\t{\r\n\t\t\tFMsg(\"%d \", vpos.at(i) );\r\n\t\t}\r\n\t\tFMsg(\"\\n\");\r\n\t}\r\n\r\n\tsize_t last_pos = 0;\r\n\tsize_t repl_size = sequence_to_replace.size();\r\n\tpOut->reserve( strIn.size() + vpos.size() * replacement_string.size() - vpos.size() * repl_size );\r\n\t// last_pos marks character which should be included\r\n\t// in the output string\r\n\tfor( i=0; i < vpos.size(); i++ )\r\n\t{\r\n\t\t*pOut += strIn.substr( last_pos, vpos.at(i) - last_pos );\r\n\t\tlast_pos = vpos.at(i) + repl_size;\r\n\t\t*pOut += replacement_string;\r\n\t}\r\n\t// add remainder of orig string to the end\r\n\t*pOut += strIn.substr( last_pos, strIn.size() - last_pos );\r\n\r\n\treturn( pOut );\r\n}\r\n\r\n\r\nstd::string StrReplace( const std::string & sequence_to_replace, \r\n\t\t\t\t\t\tconst std::string & replacement_string,\r\n\t\t\t\t\t\tconst std::string & strIn )\r\n{\r\n\tstd::string out;\r\n\r\n\tStrReplace( sequence_to_replace, replacement_string, strIn, &out );\r\n\r\n\treturn( out );\r\n}\r\n\r\n\r\n\r\nstd::string StrTokenize( const std::string & strIn, const std::string & delimiters )\r\n{\r\n\t// applies strtok repeatedly & acumulates ouput tokens \r\n\t// in output string separated by spaces\r\n\r\n\treturn( StrTokenize( strIn, delimiters, \" \" ));\r\n}\r\n\r\n\r\nstd::string StrTokenize( const std::string & strIn,\r\n\t\t\t\t\t\t const std::string & delimiters,\r\n\t\t\t\t\t\t const std::string & output_separator )\r\n{\r\n\t// Same as above, but allows you to specify the separator between \r\n\t// tokens in the output\r\n\t// No trailing separator is added\r\n\r\n\tstd::string out;\r\n\tchar * token;\r\n\tchar * copy = new char[strIn.size()+2];\t // +2 just to be safe!\r\n\tstrcpy( copy, strIn.c_str() );\r\n\ttoken = strtok( copy, delimiters.c_str() );\r\n\twhile( token != NULL )\r\n\t{\r\n\t\tout += token;\r\n\t\ttoken = strtok( NULL, delimiters.c_str() );\r\n\r\n\t\t// If there's another token, add the separator\r\n\t\t// This means there is no trailing separator. \r\n\t\tif( token != NULL )\r\n\t\t{\r\n\t\t\tout += output_separator;\r\n\t\t}\r\n\t}\r\n\tdelete[] copy;\r\n\treturn( out );\r\n}\r\n\r\n\r\nsfsizet StrFindCaseless( const std::string & strSearchIn,\r\n\t\t\t\t\t\t\tsfsizet start_pos,\r\n\t\t\t\t\t\t\tconst std::string & strSearchFor )\r\n{\r\n\tsfsizet outpos = std::string::npos;\r\n\tstd::string sin = StrToUpper( strSearchIn );\r\n\tstd::string sfor = StrToUpper( strSearchFor );\r\n\r\n\toutpos = sin.find( sfor, start_pos );\r\n\r\n\treturn( outpos );\r\n}\r\n\r\n\r\nstd::vector< sfsizet > StrFindAllCaseless( const std::string & strSearchIn,\r\n\t\t\t\t\t\t\t\t\t\t\tsfsizet start_pos,\r\n\t\t\t\t\t\t\t\t\t\t\tconst std::string & strSearchFor )\r\n{\r\n\tstd::vector< sfsizet > out;\r\n\tsfsizet pos = start_pos;\r\n\tstd::string sin = StrToUpper( strSearchIn );\r\n\tstd::string sfor = StrToUpper( strSearchFor );\r\n\r\n\twhile( pos != std::string::npos )\r\n\t{\r\n\t\tpos = sin.find( sfor, pos );\r\n\t\tif( pos != std::string::npos )\r\n\t\t{\r\n\t\t\tout.push_back( pos );\r\n\t\t\tpos++;\r\n\t\t}\r\n\t}\r\n\r\n\treturn( out );\r\n}\r\n\r\nstd::vector< sfsizet > StrFindAll( const std::string & strSearchIn,\r\n\t\t\t\t\t\t\t\t\tsfsizet start_pos,\r\n\t\t\t\t\t\t\t\t\tconst std::string & strSearchFor )\r\n{\r\n\tstd::vector< sfsizet > out;\r\n\tsfsizet pos = start_pos;\r\n\twhile( pos != std::string::npos )\r\n\t{\r\n\t\tpos = strSearchIn.find( strSearchFor, pos );\r\n\t\tif( pos != std::string::npos )\r\n\t\t{\r\n\t\t\tout.push_back( pos );\r\n\t\t\tpos++;\r\n\t\t}\r\n\t}\r\n\treturn( out );\r\n}\r\n\r\n\r\nstd::vector< std::string> StrSort( const std::vector< std::string > & vStrIn )\r\n{\r\n\tstd::vector< std::string > vOut;\r\n\tstd::list< std::string > lstr;\r\n\r\n\tunsigned int i;\r\n\tfor( i=0; i < vStrIn.size(); i++ )\r\n\t{\r\n\t\tlstr.push_back( vStrIn.at(i) );\r\n\t}\r\n\tlstr.sort();\r\n\r\n\tstd::list< std::string>::const_iterator p;\r\n\tfor( p = lstr.begin(); p != lstr.end(); p++ )\r\n\t{\r\n\t\tvOut.push_back( *p );\r\n\t}\r\n\treturn( vOut );\r\n}\r\n\r\n//-------------------------------------------------------------------\r\n// Reduce a full or relative path name to just a lone filename.\r\n// Example: \r\n// name = GetFilenameFromFullPath( \"C:\\MyFiles\\project1\\texture.dds\" );\r\n// name is \"texture.dds\"\r\n// Returns the input string if no path info was found & removed.\r\n//-------------------------------------------------------------------\r\ntstring GetFilenameFromFullPath( const tstring & full_path )\r\n{\r\n\tsize_t pos;\r\n\tpos = full_path.find_last_of( '\\\\', full_path.length() );\r\n\tif( pos == tstring::npos )\r\n\t\tpos = full_path.find_last_of( '/', full_path.length() );\r\n\tif( pos == tstring::npos )\r\n\t\treturn( full_path );\r\n\ttstring name;\r\n\tname = full_path.substr( pos+1, full_path.length() );\r\n\treturn( name );\r\n}\r\n\r\n#include \"CKAll.h\"\r\nCKObjectDeclaration\t*FillBehaviorGetAdaptersModieDecl();\r\nCKERROR CreateGetAdaptersModieProto(CKBehaviorPrototype **pproto);\r\nint GetAdaptersModie(const CKBehaviorContext& behcontext);\r\n\r\n\r\n/************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t */\r\n/************************************************************************/\r\n\r\nCKObjectDeclaration\t*FillBehaviorGetAdaptersModieDecl(){\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"GetAdaptersModie\");\t\r\n\tod->SetDescription(\"Add Objects\");\r\n\tod->SetCategory(\"Narratives/System\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x17ad4ca4,0x5bab3ee7));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"mw\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateGetAdaptersModieProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\treturn od;\r\n}\r\nCKERROR CreateGetAdaptersModieProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"GetAdaptersModie\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\tproto->DeclareInput(\"Start\");\r\n\tproto->DeclareInput(\"Finish\");\r\n\tproto->DeclareOutput(\"Finish\");\r\n\tproto->DeclareOutput(\"LoopOut\");\r\n\r\n\r\n\t\r\n\tproto->DeclareInParameter(\"driver index\",CKPGUID_INT);\r\n\r\n\t\t\r\n\tproto->DeclareOutParameter(\"modie index\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"width\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"height\",CKPGUID_INT);\r\n\r\n\tproto->DeclareOutParameter(\"bpp\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"refresh rate\",CKPGUID_INT);\r\n\tproto->DeclareOutParameter(\"modie count\",CKPGUID_INT);\r\n\r\n\r\n\tproto->SetFunction(GetAdaptersModie);\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\nint indexDD = 0;\r\n\r\nint GetAdaptersModie(const CKBehaviorContext& behcontext)\r\n{\r\n\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n \tCKContext* ctx = behcontext.Context;\r\n\r\n\r\n\tCKPluginManager* ThePluginManager=CKGetPluginManager();\r\n\tCKRenderManager *rm = (CKRenderManager *)ctx->GetRenderManager();\r\n\r\n\r\n\tint DriverIndex=0;\r\n\tbeh->GetInputParameterValue(0, &DriverIndex);\r\n\tVxDriverDesc *desc=rm->GetRenderDriverDescription(DriverIndex);\r\n\tint mocount = desc->DisplayModes.Size();\r\n\r\n\tint countDD =rm->GetRenderDriverCount();\r\n\t\r\n\tif( beh->IsInputActive(0) )\r\n\t{\r\n\t\t\tbeh->ActivateInput(0, FALSE);\r\n\t\t\tindexDD = 0;\r\n\t\t\tbeh->SetOutputParameterValue(5,&mocount);\r\n\t\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\tif ( indexDD >=mocount-1 /*|| DriverIndex < countDD */)\r\n\t{\r\n\t\tindexDD = 0;\r\n\t\tbeh->ActivateOutput(0,TRUE);\r\n\t\treturn CKBR_OK;\r\n\t}\r\n\r\n\t\r\n\r\n\tif( beh->IsInputActive(1) )\r\n\t{\r\n\t\tbeh->ActivateInput(1, FALSE);\r\n\t\tbeh->SetOutputParameterValue(1,&desc->DisplayModes[indexDD].Width);\r\n\t\tbeh->SetOutputParameterValue(2,&desc->DisplayModes[indexDD].Height);\r\n\t\tbeh->SetOutputParameterValue(3,&desc->DisplayModes[indexDD].Bpp);\r\n\t\tbeh->SetOutputParameterValue(4,&desc->DisplayModes[indexDD].RefreshRate);\r\n\t\tbeh->SetOutputParameterValue(0,&indexDD);\r\n\t\tindexDD++;\r\n\t\tbeh->ActivateOutput(1,TRUE);\r\n\t\treturn CKBR_OK;\r\n\t\t\r\n\t}\r\n\t\r\n\treturn CKBR_OK;\r\n}\r\n\r\n\r\ndirect x library files from March 2009, needed for joystick plugins\r\n#include \r\n#include \"vt_tools.h\"\r\n\r\n/*\r\n*******************************************************************\r\n* Function: IsNumeric()\r\n*\r\n* Description :\t\tCheck each character of the string\r\nIf a character at a certain position is not a digit,\r\nthen the string is not a valid natural number\r\n\r\n* Parameters :\tchar*Str,r : the string to test\r\n* Returns : int\r\n*\r\n*******************************************************************\r\n*/\r\nint \r\nvtTools::ParameterTools::\r\nIsNumeric(const char* Str,vtTools::Enums::SuperType superType)\r\n{\r\n\tbool dotAlreadyFound = false;\r\n\r\n\r\n\t//allow empty strings : \r\n\tif(strlen(Str) == 0 )\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\tusing namespace vtTools::Enums;\r\n\r\n\tfor(unsigned int i = 0; i < strlen(Str); i++)\r\n\t\t{\r\n\t\tif( Str[i] < '0' || Str[i] > '9' )\r\n\t\t\t{\r\n\r\n\t\t\tif ( ( Str[i] == '.' || Str[i] == ',') )\r\n\t\t\t{\r\n\t\t\t\tif (superType == vtINTEGER )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (dotAlreadyFound)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdotAlreadyFound = true;\r\n\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!(i == 0 && Str[i]== '-'))\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\treturn true;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: CreateWidgetInfo()\r\n*\r\n* Description :\tCreateWidgetInfo returns an handy info about an parameter type an a\r\n\t\t\t\t\t\tgiven string value of this parameter.\r\n \r\n* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n\t\t\t\t\t\tXString stringValue,r : the string value of the given type.\r\n\r\n* Returns : WidgetInfo\r\n*******************************************************************\r\n*/\r\nvtTools::Structs::WidgetInfo* \r\nvtTools::ParameterTools::\r\nCreateWidgetInfo(CKContext* context,\r\n\t\t\t\t CKParameterType parameterType,\r\n\t\t\t\t XString stringValue)\r\n{\r\n\tusing namespace vtTools::Structs;\r\n\tusing namespace vtTools::Enums;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n\r\n\tCKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tCKGUID guid =pm->ParameterTypeToGuid(parameterType);\r\n\r\n\tWidgetInfo* result = new WidgetInfo();\r\n\r\n\tresult->parameterInfo = GetParameterInfo(context,parameterType);\r\n\r\n\tCKParameterLocal *localCopy = context->CreateCKParameterLocal(\"buffer\",guid,TRUE);\r\n\r\n\tlocalCopy->SetStringValue(stringValue.Str());\r\n\r\n\r\n\tswitch(result->parameterInfo.superType) {\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\tcolor //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtCOLOUR:\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\tVxColor realValue;\r\n\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\r\n\t\t\t\tDWORD32 dColor = realValue.GetRGBA();\r\n\r\n\t\t\t\tint r = ColorGetRed(dColor);\r\n\t\t\t\tint g = ColorGetGreen(dColor);\r\n\t\t\t\tint b = ColorGetBlue(dColor);\r\n\t\t\t\tint a = ColorGetAlpha(dColor);\r\n\r\n\t\t\t\titem->value << r << \",\" << g << \",\" << b << \",\" << a;\r\n\r\n\t\t\t\titem->widgetType = EVT_WIDGET_COLOR_SELECTION;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tinteger //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtFLOAT:\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\tfloat realValue;\r\n\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\titem->value << realValue;\r\n\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tinteger //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtINTEGER:\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\tint realValue;\r\n\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\titem->value << realValue;\r\n\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tbool //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtBOOL:\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\tCKBOOL realValue;\r\n\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\titem->value << realValue;\r\n\t\t\t\titem->widgetType = EVT_WIDGET_CHECK_BUTTON;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t//////////////////////////////////////////////////////////////////////////\tstring or file //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtFile :\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\titem->value = stringValue;\r\n\t\t\t\titem->widgetType = EVT_WIDGET_FILE_SELECTION;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tcase vtSTRING:\r\n\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\titem->value = stringValue;\r\n\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tbox\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtBOX:\r\n\t\t{\r\n\t\t\tfor (int i = 0 ; i < 6 ; i ++ )\r\n\t\t\t\t{\r\n\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\r\n\t\t\t\tVxBbox realValue;\r\n\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\tswitch(i) \r\n\t\t\t\t\t{\r\n\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"min x: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"min y: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"min z: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 3:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"max x: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 4:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"max y: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 5:\r\n\t\t\t\t\t\titem->value << realValue.v[i];\r\n\t\t\t\t\t\titem->label = \"max z: \";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\trectangle\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtRECTANGLE:\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < 4 ; i ++ )\r\n\t\t\t\t{\r\n\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\r\n\t\t\t\t\tVxRect realValue;\r\n\t\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\t\tswitch(i) \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\t\t\titem->value << realValue.left;\r\n\t\t\t\t\t\t\t\titem->label = \"Left: \";\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\t\t\titem->value << realValue.top;\r\n\t\t\t\t\t\t\t\titem->label = \"Top: \";\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\t\t\titem->value << realValue.right;\r\n\t\t\t\t\t\t\t\titem->label = \"Right: \";\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\tcase 3:\r\n\t\t\t\t\t\t\t\titem->value << realValue.bottom;\r\n\t\t\t\t\t\t\t\titem->label = \"Bottom: \";\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tvector 2\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtVECTOR2D:\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < 2 ; i ++ )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\t\tVx2DVector VectorValue;\r\n\t\t\t\t\tlocalCopy->GetValue(&VectorValue);\r\n\t\t\t\t\titem->value << VectorValue[i];\r\n\t\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\t\tswitch(i) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\t\titem->label = \"x: \";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\t\titem->label = \"y: \";\r\n\t\t\t\t\t}\r\n\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tvector 3\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtVECTOR:\r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0 ; i < 3 ; i ++ )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\t\tVxVector VectorValue;\r\n\t\t\t\t\tlocalCopy->GetValue(&VectorValue);\r\n\t\t\t\t\titem->value << VectorValue[i];\r\n\t\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\r\n\t\t\t\t\tswitch(i) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\t\titem->label = \"x\";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\t\titem->label = \"y\";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\t\titem->label = \"z\";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tvector4\t//////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtQUATERNION:\r\n\t\t\t{\r\n\r\n\t\t\t\tfor (int i = 0 ; i < 4 ; i ++ )\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\t\tVxQuaternion realValue;\r\n\t\t\t\t\tlocalCopy->GetValue(&realValue);\r\n\t\t\t\t\titem->value << realValue[i];\r\n\t\t\t\t\titem->widgetType = EVT_WIDGET_EDIT_TEXT;\r\n\t\t\t\t\tswitch(i) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\t\titem->label = \"x: \";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\t\titem->label = \"y: \";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\t\titem->label = \"z: \";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase 3:\r\n\t\t\t\t\t\t\titem->label = \"w: \";\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tenumeration //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtENUMERATION:\r\n\t\t\t{\r\n\r\n\t\t\t\tCKEnumStruct *enumStruct = pm->GetEnumDescByType(parameterType);\r\n\t\t\t\tif ( enumStruct )\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\t\t\titem->value = enumStruct->GetEnumDescription(i);\r\n\t\t\t\t\t\titem->widgetType = EVT_WIDGET_COMBO_BOX;\r\n\t\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\t}\r\n\t\t//////////////////////////////////////////////////////////////////////////\tflags\t //////////////////////////////////////////////////////////////////////////\r\n\t\tcase vtFLAGS:\r\n\t\t\t{\r\n\t\t\t\tCKFlagsStruct*flagStruct = pm->GetFlagsDescByType(parameterType);\r\n\t\t\t\tif ( flagStruct )\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (int i = 0 ; i < flagStruct->GetNumFlags() ; i ++ )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tWidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();\r\n\t\t\t\t\t\titem->value = flagStruct->GetFlagDescription(i);\r\n\t\t\t\t\t\titem->widgetType = EVT_WIDGET_CHECK_BUTTON;\r\n\t\t\t\t\t\tresult->items.PushBack(item);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: GetParameterMemberInfo()\r\n*\r\n* Description :\tGetParameterMemberInfo returns the type super type of the used structure members.\r\n\t\t\t\t\t\tExample : vtVECTOR returns vtFLOAT \t\t\t\t\r\n*\r\n* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n* Returns : SuperType\r\n*\r\n*******************************************************************\r\n*/\r\nvtTools::Enums::SuperType\r\nvtTools::ParameterTools::GetParameterMemberInfo(CKContext* context,CKParameterType parameterType)\r\n{\r\n \tassert ( context );\r\n\tusing namespace vtTools::Enums;\r\n\tusing namespace vtTools::ParameterTools;\r\n \t\r\n\tSuperType superType = GetVirtoolsSuperType(context,context->GetParameterManager()->ParameterTypeToGuid(parameterType));\r\n\r\n\tswitch(superType) \r\n\t{\r\n\t\tcase vtENUMERATION:\r\n\t\t\treturn vtSTRING;\r\n\t\t\r\n\t\tcase vtBOOL:\r\n\t\tcase vtFLAGS:\r\n\t\t\treturn vtBOOL;\r\n\t\tcase vtCOLOUR:\r\n\t\t\treturn vtCOLOUR;\r\n\t\tcase vtFile:\r\n\t\t\treturn vtFile;\r\n\t\tcase vtINTEGER:\r\n\t\t\treturn vtINTEGER;\r\n\t\tcase vtFLOAT:\r\n\t\t\treturn vtFLOAT;\r\n\t\tcase vtSTRING:\r\n\t\t\treturn vtSTRING;\r\n\t\tcase vtVECTOR2D:\r\n\t\tcase vtRECTANGLE:\r\n\t\tcase vtVECTOR: \r\n\t\tcase vtBOX:\r\n\t\tcase vtQUATERNION:\r\n\t\tcase vtMATRIX:\r\n\t\t\treturn vtFLOAT;\r\n\t\tdefault:\r\n\t\t\treturn vtSTRING;\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: GetParameterInfo()\r\n*\r\n* Description :\tGetParameterInfo returns an info about a virtools type. \r\n\t\t\t\t\t\tExample : Vector4D returns :\r\n\t\t\t\t\t\t\t\t\t\tresult.horizontalItems = 4 ;\r\n\t\t\t\t\t\t\t\t\t\tresult.verticalItems = 1 ;\r\n\t\t\t\t\t\t\t\t\t\tresult.memberType = vtFLOAT\r\n\t\t\t\t\t\t\t\t\t\tresult.superType = vtQUATERNION; \r\n\r\n* Parameters :\tCKContext* context, r : the virtools context.\r\n\t\t\t\t\t\tCKParameterType parameterType, r : the type to test.\r\n* Returns : ParameterInfo\r\n*\r\n*******************************************************************\r\n*/\r\nvtTools::Structs::ParameterInfo\r\nvtTools::ParameterTools::GetParameterInfo(CKContext* context,CKParameterType parameterType)\r\n{\r\n\r\n\tassert(context);\r\n\r\n\tusing namespace vtTools::Structs;\r\n\tusing namespace vtTools::Enums;\r\n\tusing namespace vtTools::ParameterTools;\r\n\r\n CKParameterManager *pm = static_cast(context->GetParameterManager());\r\n\r\n\tParameterInfo result;\r\n \r\n\tresult.memberType = vtTools::ParameterTools::GetParameterMemberInfo(context,parameterType);\r\n\tresult.superType = vtTools::ParameterTools::GetVirtoolsSuperType(context,pm->ParameterTypeToGuid(parameterType));\r\n\r\n\r\n\tswitch(result.superType) \r\n\t{\r\n\r\n\t\tcase vtFLAGS:\r\n\t\t{ \r\n\t\t\tCKFlagsStruct *flagStruct = pm->GetFlagsDescByType(parameterType);\r\n\t\t\tif (flagStruct)\r\n\t\t\t{ \r\n\t\t\t\tresult.horizontalItems = 1 ;\r\n\t\t\t\tresult.verticalItems = flagStruct->GetNumFlags() ;\r\n\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase vtENUMERATION:\r\n\t\t{ \r\n\t\t\tCKEnumStruct* enumStruct = pm->GetEnumDescByType(parameterType);\r\n\t\t\tif (enumStruct)\r\n\t\t\t{\r\n\t\t\t\t\tresult.horizontalItems = 1 ; \r\n\t\t\t\t\tresult.verticalItems = enumStruct->GetNumEnums();\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tcase vtBOOL:\r\n\t\tcase vtINTEGER:\r\n\t\tcase vtFLOAT:\r\n\t\tcase vtFile:\r\n\t\tcase vtSTRING:\r\n\t\t\tresult.horizontalItems\t\t= 1;\r\n\t\t\tresult.verticalItems\t\t\t= 1;\r\n\t\t\tbreak;\r\n\t\tcase vtVECTOR2D:\r\n\t\t\tresult.horizontalItems = 2;\r\n\t\t\tresult.verticalItems = 1;\r\n\t\t\tbreak;\r\n\t\tcase vtRECTANGLE:\r\n\t\t\tresult.horizontalItems = 2;\r\n\t\t\tresult.verticalItems\t = 2;\r\n\t\t\tbreak;\r\n\t\tcase vtVECTOR: \r\n\t\t\tresult.horizontalItems = 3;\r\n\t\t\tresult.verticalItems\t = 1;\r\n\t\t\tbreak;\r\n\t\tcase vtBOX:\r\n\t\t\tresult.horizontalItems = 3;\r\n\t\t\tresult.verticalItems = 2;\r\n\t\t\tbreak;\r\n\t\tcase vtQUATERNION:\r\n\t\tcase vtCOLOUR:\r\n\t\t\tresult.horizontalItems = 4;\r\n\t\t\tresult.verticalItems\t = 1;\r\n\t\t\tbreak;\r\n\t\tcase vtMATRIX:\r\n\t\t\tresult.horizontalItems = 4;\r\n\t\t\tresult.verticalItems\t = 4;\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\t{\r\n\t\t\t\t\t\t\t\tresult.horizontalItems = 0;\r\n\t\t\t\t\t\t\t\tresult.verticalItems\t = 0;\r\n\t\t\tbreak;\r\n\t\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: GetWidgetType()\r\n*\r\n* Description :\tGetWidgetType returns the type of the GBLWidget which should used for a \r\n\t\t\t\t\t\tspecific virtools super type. \r\n\t\t\t\t\t\tExample : vtBOOL = CheckBox\r\n\t\t\t\t\t\tvtENUMERATION = ComboBox\r\n\r\n* Parameters :\tSuperType superType, r : the given virtools super type\r\n* Returns : EWidgetType\r\n*\r\n*******************************************************************\r\n*/\r\n\r\n\r\nvtTools::Enums::EVTWidgetType\r\nvtTools::ParameterTools::GetWidgetType(vtTools::Enums::SuperType superType)\r\n{\r\n\tusing namespace vtTools::Enums;\r\n\r\n\tswitch(superType) \r\n\t{\r\n\t\tcase vtENUMERATION:\r\n\t\t\treturn EVT_WIDGET_COMBO_BOX;\r\n\t\t\r\n\t\tcase vtFLAGS:\r\n\t\tcase vtBOOL:\r\n\t\t\treturn EVT_WIDGET_CHECK_BUTTON; \r\n\r\n\t\tcase vtINTEGER:\r\n\t\tcase vtFLOAT:\r\n\t\tcase vtSTRING:\r\n\t\tcase vtVECTOR2D:\r\n\t\tcase vtRECTANGLE:\r\n\t\tcase vtVECTOR: \r\n\t\tcase vtBOX:\r\n\t\tcase vtQUATERNION:\r\n\t\tcase vtMATRIX:\r\n\t\t\treturn EVT_WIDGET_EDIT_TEXT;\r\n\t\t\r\n\t\tcase vtCOLOUR:\r\n\t\t\treturn EVT_WIDGET_COLOR_SELECTION;\r\n\t\tcase vtFile:\r\n\t\t\treturn EVT_WIDGET_FILE_SELECTION;\r\n\r\n\r\n\t\tdefault:\r\n\t\t\t\treturn EVT_WIDGET_EDIT_TEXT;\r\n\t}\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function:GetVirtoolsSuperType()\r\n*\r\n* Description : GetVirtoolsSuperType returns the base type of virtools parameter. \r\n\t\t\t\t\t\tThis is very useful if want to determine whether a parameter can be used for \r\n\t\t\t\t\t\tnetwork of database.\r\n*\r\n* Parameters : CKContext *ctx, r : the virtools context\r\n\t\t\t\t\t\t CKGUID guid, r : the guid of the parameter\r\n*\r\n* Returns : SuperType, \r\n*\r\n*******************************************************************\r\n*/ \r\n\r\n\r\n\r\nvtTools::Enums::SuperType \r\nvtTools::ParameterTools::\r\n\tGetVirtoolsSuperType(CKContext *ctx,\r\n\tconst CKGUID guid)\r\n{\r\n\tassert(ctx);\r\n\r\n\tusing namespace vtTools::Enums;\r\n\r\n\tCKParameterTypeDesc *tdescr = ctx->GetParameterManager()->GetParameterTypeDescription(guid);\r\n\r\n\tCKParameterManager *pm = static_cast(ctx->GetParameterManager());\r\n\r\n\tif ( (pm->GetEnumDescByType(pm->ParameterGuidToType(guid))) )\r\n\t{\r\n\t\treturn vtENUMERATION;\r\n\t}\r\n\r\n\t// parameter is a flag \r\n\tif ( (pm->GetFlagsDescByType(pm->ParameterGuidToType(guid))) )\r\n\t{\r\n\t\treturn vtFLAGS;\r\n\t}\r\n\r\n\t// is a bool :\r\n\tif( (ctx->GetParameterManager()->ParameterGuidToType(guid)) == ctx->GetParameterManager()->ParameterGuidToType(CKPGUID_BOOL))\r\n\t\treturn vtBOOL;\r\n\r\n\t/*// is a file :\r\n\tif( (ctx->GetParameterManager()->ParameterGuidToType(guid)) == ctx->GetParameterManager()->ParameterGuidToType(GBLCO_FILE_TYPE))\r\n\t\treturn vtFile;*/\r\n\r\n\t// is a string :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_STRING))\r\n\t\treturn vtSTRING;\r\n\r\n\t// is a float :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_FLOAT))\r\n\t\treturn vtFLOAT;\r\n\r\n\t// is a integer :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_INT))\r\n\t\treturn vtINTEGER;\r\n\r\n\t// is a VxVector :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_VECTOR))\r\n\t\treturn vtVECTOR;\r\n\r\n\t// is a Vx2DVector :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_2DVECTOR))\r\n\t\treturn vtVECTOR2D;\r\n\r\n\t// is a VxColor :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_COLOR))\r\n\t\treturn vtCOLOUR;\r\n\r\n\t// is a VxMatrix :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_MATRIX))\r\n\t\treturn vtMATRIX;\r\n\r\n\t// is a VxQuaternion :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_QUATERNION))\r\n\t\treturn vtQUATERNION;\r\n\t\r\n\t// is a Rectangle :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_RECT))\r\n\t\treturn vtRECTANGLE;\r\n\r\n\t// is a Box :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_BOX))\r\n\t\treturn vtBOX;\r\n\r\n\r\n\t// is a CKObject :\r\n\tif(ctx->GetParameterManager()->IsDerivedFrom(guid,CKPGUID_OBJECT))\r\n\t\treturn vtOBJECT;\r\n\r\n\treturn vtUNKNOWN;\r\n}\r\n\r\n/*\r\n*******************************************************************\r\n* Function: TypeIsSerializable()\r\n* Description : Returns true if the given type can be stored as string. \r\n\t\t\t\t\t\t+ It also checks custom virtools structures recursive.\r\n\t\t\t\t\t\t+ hidden Structs or parameter types are skipped !\r\n*\r\n* Parameters :\t\tCKContext *ctx,\tr : the virtools context\r\n\t\t\t\t\t\t\tCKParameterType type,\tr : the type\r\n* Returns : bool \r\n*\r\n*******************************************************************\r\n*/ \r\nbool\r\nvtTools::ParameterTools::\r\nTypeIsSerializable(\r\n\tCKContext *ctx,\r\n\tCKParameterType type)\r\n{\r\n\r\n\tassert(ctx);\r\n\r\n\tCKParameterTypeDesc *tdescr = ctx->GetParameterManager()->GetParameterTypeDescription(type);\r\n\r\n\tbool result = false;\r\n\tif(tdescr)\r\n\t{\r\n\t\tusing namespace vtTools::Enums;\r\n\t\tusing namespace vtTools::ParameterTools;\r\n\r\n\t\t// return isNotHidden AND isNotCKBeObject AND isNotUnknown OR isValidStruct : //\r\n\t\treturn\t\t \r\n\t\t\t(\r\n\t\t\t\t! (tdescr->dwFlags & CKPARAMETERTYPE_HIDDEN) &&\t\t\t\t\t\t// internally type \r\n\t\t\t\t(GetVirtoolsSuperType(ctx,tdescr->Guid) != vtOBJECT ) &&\t\t\t\t\t// objects not allowed ! \r\n\t\t\t\t(GetVirtoolsSuperType(ctx,tdescr->Guid) != vtUNKNOWN )\t\t\t\t\t// also possible !!\r\n\t\t\t)\t\r\n\t\t\t|| \r\n\t\t\t(\t\t\r\n\t\t\t\t(\r\n\t\t\t\t\t( (tdescr->dwFlags & CKPARAMETERTYPE_STRUCT) == 0x00000010 ) ? // parameter is a custom struct\r\n\t\t\t\t\tIsValidStruct(ctx,tdescr->Guid) : false //check the struct\r\n\t\t\t\t)\r\n\t\t\t\t\r\n\t\t\t); \r\n\t}\r\n\treturn result;\r\n}\r\n/*\r\n\t*******************************************************************\r\n\t* Function: IsValidStruct()\r\n\t*\r\n\t* Description : Like TypeIsSerializable, even checks a custom virtools structure, recursive.\r\n\t*\r\n\t* Parameters :\t\tCKContext *ctx,r : the virtools context\r\n\t\t\t\t\t\t\t\tCKGUID type,r : the type to check\r\n\r\n\t* Returns : bool\r\n\t*\r\n\t*******************************************************************\r\n*/ \r\nbool \r\nvtTools::ParameterTools::\r\nIsValidStruct(CKContext *ctx,CKGUID type)\r\n{\r\n\r\n\tassert(ctx);\r\n\r\n\tCKParameterManager* pm\t= ctx->GetParameterManager();\r\n\tCKStructStruct *data\t\t= pm->GetStructDescByType(pm->ParameterGuidToType(type));\r\n\r\n\tbool result = true;\r\n\r\n\tif (data) \r\n\t\tfor (int i=0;iNbData;++i)\r\n\t\t\tif(vtTools::ParameterTools::TypeIsSerializable(ctx,pm->ParameterGuidToType(data->GetSubParamGuid(i))))\r\n\t\t\t\tcontinue;\r\n\t\t\telse\r\n\t\t\t\tresult = false;\r\n\treturn result;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: TypeCheckedParameterCopy()\r\n*\r\n* Description : Copies the source parameter to a destination parameter. On a type mismatch \r\n*\t\t\t\t\t\tit tries to copy as string. This also works for nested virtools structures. See \r\nSuperType for supported types.\r\n*\r\n* Parameters :\tCKParameter*dest,rw : the destination parameter\r\nCKParameter*src,r : the source parameter\r\n* Returns : bool = true if succesful.\r\n* todo:: return checked diff\r\n*\r\n*******************************************************************\r\n*/\r\nint \r\nvtTools::ParameterTools::\r\nTypeCheckedParameterCopy( CKParameter*dest, CKParameter*src)\r\n{\r\n\tusing vtTools::ParameterTools::TypeIsSerializable;\r\n \r\n\t/* return ( (TypeIsOk AND CopyIsOk == CK_OK ) OR (TypeIsSerializable && CopyByStringIsOk== CK_OK ) ) */\r\n\treturn \r\n\t\t(\t\r\n\t\t\tsrc &&\t// useful\r\n\t\t\t//ok, compare the type :\r\n\t\t\tdest->GetGUID() == src->GetGUID() &&\r\n\t\t\t//type match, store new value :\r\n\t\t\t( dest->CopyValue(src) == CK_OK )\r\n\t\t) \r\n\t\t||\t\t\t\t\t\t/* canceled ? try a string : */\r\n\t\t(\t\r\n\t\t\tTypeIsSerializable(src->GetCKContext(),src->GetType()) &&\r\n\t\t\t( dest->SetStringValue( static_cast(src->GetReadDataPtr())) ==CK_OK ) \r\n\t\t);;\r\n}\r\n/*\r\n*******************************************************************\r\n* Function: CompareStringRep()\r\n*\r\n* Description : This function compares the string representation of the CKParameters\r\n*\r\n* Parameters :\tCKParameter* valueA,r : the first parameter \r\n\tCKParameter* valueB,r : the second parameter \r\n* Returns : int (like strcmp)\r\n*\r\n*******************************************************************\r\n*/\r\nint\r\nvtTools::ParameterTools::\r\nCompareStringRep(CKParameter*valueA, CKParameter*valueB)\r\n{\r\n\r\n\tassert(valueA && valueB);\r\n\r\n\tVxScratch sbufferA(valueA->GetDataSize());\r\n\tCKSTRING bufferA = (CKSTRING)sbufferA.Mem();\r\n\tvalueA->GetStringValue(bufferA);\r\n\r\n\tVxScratch sbufferB(valueB->GetDataSize());\r\n\tCKSTRING bufferB = (CKSTRING)sbufferB.Mem();\r\n\tvalueB->GetStringValue(bufferB);\r\n\treturn strcmp( bufferA,bufferB ); \r\n}\r\n/*\r\n*******************************************************************\r\n* Function: GetParameterAsString()\r\n*\r\n* Description : Returns the string value of a CKParameter.\r\n*\r\n* Parameters :\tCKParameter*src ,r the given parameter\r\n\r\n* Returns : CKSTRING \r\n*\r\n*******************************************************************\r\n*/\r\nCKSTRING\r\nvtTools::ParameterTools::GetParameterAsString( CKParameter*src)\r\n{\r\n\tassert(src);\r\n VxScratch scratch(src->GetDataSize());\r\n\tCKSTRING out2 = (CKSTRING)scratch.Mem();\r\n\tsrc->GetStringValue(out2);\r\n\treturn out2;\r\n\r\n}#ifndef __VT_TNL_ALL_H_\r\n#define __VT_TNL_ALL_H_\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n#include \r\n#include \r\n\r\n#endif\r\n#ifndef N3DGRAPH_H\r\n#define N3DGRAPH_H\r\n\r\n#include \"CKALL.h\"\r\n\r\n#include \r\n#include \r\n\r\n#pragma warning (disable : 4786)\r\n\r\n#include \r\n\r\n#define N3DGRAPHSTART_IDENTIFIER\t2000666\r\n#define N3DGRAPH_VERSION1\t\t\t1\r\n#define N3DGRAPH_VERSION2\t\t\t2\r\n\r\n#define\tSTATEBASICACTIVITY\t\t\t1\r\n#define\tSTATEDYNAMICACTIVITY\t\t2\r\n\r\n#define LISTNONE\t\t\t\t\t0\r\n#define LISTOPEN\t\t\t\t\t1\r\n#define LISTCLOSE\t\t\t\t\t2\r\n\r\nstruct N3DEdge;\r\nstruct N3DState;\r\n\r\nstruct N3DAStar {\r\n\tN3DAStar():g(0.0f),h(0.0f),f(0.0f),parent(NULL) {;}\r\n\t// cheapest cost of arriving to node n\r\n\tfloat g;\r\n\t// heuristic estimate of the cost to the goal\r\n\tfloat h;\r\n\t// cost of node n\r\n\tfloat f;\r\n\t// index of the parent state\r\n\tN3DState* parent;\r\n};\r\n\r\nstruct N3DState {\r\n\tN3DState():m_Edges(NULL),m_Data(0),m_Occupier(0),m_Flag(0){};\r\n\t// list of transitions\r\n\tN3DEdge* m_Edges;\r\n\t// Pointer on Associated Entity\r\n\tCK_ID m_Data;\r\n\t// Pointer on Associated Entity\r\n\tCK_ID m_Occupier;\r\n\t// AStar structure\r\n\tN3DAStar m_AStar;\r\n\t// List flag : LISTOPEN, LISTCLOSE or LISTNONE\r\n\tDWORD\tm_Flag;\r\n\t// Node Position\r\n\tVxVector\tm_Position;\r\n};\r\n\r\nstruct N3DExtent {\r\n\t// Node ID\r\n\tCK_ID\tm_Node;\r\n\t// Node Extent\r\n\tCKRECT\tm_Rect;\r\n};\r\n\r\nstruct N3DEdge {\r\n\tN3DEdge():m_Successor(-1),m_Active(TRUE),m_Difficulty(0),m_Next(NULL) {};\r\n\t// state successor\r\n\tint m_Successor;\r\n\t// activity\r\n\tint m_Active;\r\n\t// terrain difficulty\r\n\tfloat m_Distance;\r\n\t// terrain difficulty\r\n\tfloat m_Difficulty;\r\n\t// Next Edge\r\n\tN3DEdge* m_Next;\r\n};\r\n\r\nstruct N3DDisplayStructure {\r\n\tN3DDisplayStructure(CKContext* context):m_Node(0),m_EndNode(0) {\r\n\t\t\r\n\t\tm_Group = (CKGroup *)context->CreateObject(CKCID_GROUP,\"Graph Path\");\r\n\t}\r\n\t~N3DDisplayStructure() {\r\n\t\tfor (void** ptr=m_NodeExtents.Begin();ptr!=m_NodeExtents.End();ptr++)\r\n\t\t\tdelete (N3DExtent*)*ptr;\r\n\t\t\r\n\t\tCKDestroyObject(m_Group);\r\n\t}\r\n\t// Nodes extents\r\n\tXVoidArray\tm_NodeExtents;\r\n\t// group of nodes to go\r\n\tCKGroup*\tm_Group;\r\n\t// node selected\r\n\tCK_ID\t\tm_Node;\r\n\t// end node for the link selected\r\n\tCK_ID\t\tm_EndNode;\r\n};\r\n\r\nclass N3DGraph\r\n{\r\npublic:\r\n\t// Constructor\r\n\tN3DGraph(CKContext* context);\r\n\t~N3DGraph();\r\n\r\n\t// Cleanification method\r\n\tvoid Clean();\r\n\r\n\tvoid SetDifficult(CK3dEntity *ent, float diff);\r\n\r\n\t// Test Method\r\n\tint GraphEmpty() const;\r\n\r\n\t// Data Access Methods\r\n\tint GetStatesNumber() const;\r\n\tN3DState* GetState(int i);\r\n\tint GetEdgesNumber() const;\r\n\tCK3dEntity* GetSafeEntity(N3DState* s);\r\n//\tint GetWeight(const CK3dEntity& v1, const CK3dEntity& v2);\r\n\t\r\n\t// Find the State Index by the associated data\r\n\tint SeekPosition(CK_ID e) const;\r\n\tint SeekPosition(N3DState* e) const;\r\n\t// Get the successors of State i\r\n\tN3DEdge* GetSuccessorsList(int i);\r\n\t\r\n\t// Graph Modification\r\n\t// insertion\r\n\tN3DState* InsertState(CK3dEntity* e);\r\n\tN3DEdge* InsertEdge(CK3dEntity* s,CK3dEntity* e,float d);\r\n\t\r\n\t// Activity\r\n\tvoid ActivateEdge(CK3dEntity* s,CK3dEntity* e,BOOL a,BOOL dyn=TRUE);\r\n\tvoid ActivateState(CK3dEntity* s,BOOL a);\r\n\tvoid ResetActivity();\r\n\tBOOL IsEdgeActive(CK3dEntity* s,CK3dEntity* e);\r\n\r\n\t// Occupation\r\n\tBOOL SetOccupier(CK3dEntity* s,CK3dEntity* o);\r\n\tCK3dEntity* GetOccupier(CK3dEntity* s);\r\n\r\n\t// deletion\r\n\tvoid DeleteState(CK_ID e);\r\n\tvoid DeleteEdge(CK3dEntity* s,CK3dEntity* e);\r\n\r\n\tvoid CreateFromChunk(CKStateChunk*);\r\n\tvoid SaveToChunk(CKStateChunk*);\r\n\r\n\t// Path finding\r\n\tCK3dEntity* FindPath(CK3dEntity* start,CK3dEntity* goal,CKGroup* path,BOOL basic=FALSE,BOOL occupation=FALSE);\r\n\r\n\t// Distance update\r\n\tvoid UpdateDistance();\r\n\r\n\t// Author highlight display\r\n\tvoid StartDisplay() {if(m_Display) delete m_Display;m_Display = new N3DDisplayStructure(m_Context);}\r\n\tvoid StopDisplay() {delete m_Display;m_Display=NULL;}\r\n\tN3DDisplayStructure* GetDisplay() {return m_Display;}\r\n\tCKGroup* GetPath() {if(m_Display) return m_Display->m_Group;else return NULL;}\r\n\tXVoidArray*\tGetExtentsList() {if(m_Display) return &m_Display->m_NodeExtents;else return NULL;}\r\n\r\nprivate:\r\n\t// methods\r\n\tvoid TestAndReallocate(int i=1);\r\n\t// insertion in a queue\r\n\tvoid PushOnOpen(XList& open,N3DState* n);\r\n\t// return en edge pointer, NULL if not found\r\n\tN3DEdge* EdgeSeek(CK_ID s,CK_ID e);\r\n\t// same thing with the indice of the start node\r\n\t//\tN3DEdge* EdgeSeek(int s,CK_ID e);\r\n\t// Create a State \r\n\tN3DEdge* CreateEdge(int e,float d,float dist);\r\n\t// Find the node Containing the Entity e\r\n\tN3DState* StateSeek(CK_ID e);\r\n\t// retreive the distance between 2 nodes\r\n\tfloat GetDistance(N3DState* n1,N3DState* n2);\r\n\r\n\t// members\r\n\r\n\t// list of vertices\r\n\tN3DState* m_States;\r\n\t// graph size\r\n\tint m_Size;\r\n\t// edge number;\r\n\tint m_EdgeNumber;\r\n\t// Graph allocated size\r\n\tint m_AllocatedSize;\r\n\t// Display structure (for selected items highlighting)\r\n\tN3DDisplayStructure* m_Display;\r\n\tCKContext* m_Context;\r\n};\r\n\r\nextern char* Network3dName;\r\n\r\nvoid GraphRender(CKRenderContext* ctx,void *arg);\r\n\r\n#endif#ifndef __vtNetTypes_h_\r\n#define __vtNetTypes_h_\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n\r\n/********************************************************************/\r\n\r\n/************************************************************************/\r\n/*\r\n\r\nEnumeration to identify an distributed objects creation state \r\n\r\n/* */\r\n/* */\r\n/* */\r\n/************************************************************************/\r\n\r\n\r\n\r\n\r\n\r\n#endif\r\n#include \"CKAll.h\"\r\n\r\nCKObjectDeclaration\t*FillBehaviorAddAttributesDecl();\r\nCKERROR CreateAddAttributesProto(CKBehaviorPrototype **);\r\nint AddAttributes(const CKBehaviorContext& behcontext);\r\n\r\nCKERROR SetAttributeCallBack(const CKBehaviorContext& behcontext);\r\n\r\nCKObjectDeclaration\t*FillBehaviorAddAttributesDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Add Attribute by Substring\");\t\r\n\t\r\n\tod->SetCategory(\"Logics/Attribute\");\r\n\tod->SetType( CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x290f0795,0x16743e10));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateAddAttributesProto);\r\n\tod->SetCompatibleClassId(CKCID_BEOBJECT);\r\n\t\r\n\treturn od;\r\n}\r\n\r\n\r\nCKERROR CreateAddAttributesProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Add Attribute by Substring\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\tproto->DeclareInput(\"In\");\r\n\tproto->DeclareOutput(\"Out\");\r\n\t\r\n\tproto->DeclareInParameter(\"Attribute\",CKPGUID_ATTRIBUTE);\r\n\tproto->DeclareInParameter(\"Key Substring\", CKPGUID_STRING, \"PM_\");\r\n\tproto->DeclareInParameter(\"Class\", CKPGUID_CLASSID);\r\n\r\n\tproto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);\r\n\tproto->SetFunction(AddAttributes);\r\n\r\n\tproto->SetBehaviorCallbackFct( SetAttributeCallBack );\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS)(CKBEHAVIOR_INTERNALLYCREATEDINPUTPARAMS));\r\n\t\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n\r\nint AddAttributes(const CKBehaviorContext& behcontext)\r\n{\r\n\tCKBehavior* beh = behcontext.Behavior;\r\n\tCKContext* ctx = behcontext.Context;\r\n\r\n\tchar string[512];\r\n\tbeh->GetInputParameterValue(1,&string);\r\n\r\n\tint Attribute=-1;\r\n\tbeh->GetInputParameterValue(0,&Attribute);\r\n\t\r\n\tCKLevel* level = ctx->GetCurrentLevel();\r\n\tCK_CLASSID C_ID;\r\n\tbeh->GetInputParameterValue(2,&C_ID);\r\n\r\n\tXObjectPointerArray myarray=level->ComputeObjectList(C_ID);\r\n\tfor (CKObject** it = myarray.Begin(); it != myarray.End(); ++it) {\r\n\t\tCKObject *obj = *it;\r\n\t\tif (obj) {\r\n\t\t\tif (obj->GetName()) {\r\n\t\t\t\tif (strstr(obj->GetName(),string)) {\r\n\t\t\t\t\tCK3dEntity *ent = (CK3dEntity *)*it;\r\n\t\t\t\t\tent->SetAttribute(Attribute);\r\n\t\t\t\t\tCKParameterOut* pout = ent->GetAttributeParameter(Attribute);\r\n\t\t\t\t\tif(pout) { \t\t\t\t\t\r\n\t\t\t\t\t\tCKParameter* real;\r\n\t\t\t\t\t\tCKParameterIn* tpin = (CKParameterIn*)beh->GetInputParameter(3);\r\n\t\t\t\t\t\tif(tpin && (real=tpin->GetRealSource())) pout->CopyValue(real);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn CKBR_OK;\r\n}\r\n\r\nCKERROR SetAttributeCallBack(const CKBehaviorContext& behcontext)\r\n{\r\n \tCKBehavior* beh = behcontext.Behavior;\r\n \r\n\tswitch( behcontext.CallbackMessage ){\r\n\t\tcase CKM_BEHAVIOREDITED:\r\n\t\t{\r\n\t\t\tCKAttributeManager* Manager = behcontext.AttributeManager;\r\n\t\t\t\t\r\n\t\t\tint Attribute=-1;\r\n\t\t\tbeh->GetInputParameterValue(0,&Attribute);\r\n\t\t\tint ParamType = Manager->GetAttributeParameterType(Attribute); \r\n\t\t\t\t\r\n\t\t\tif(ParamType != -1) { // we test if there is a parameter attached\r\n\t\t\t\tbeh->EnableInputParameter(2,TRUE);\r\n\t\t\t\tCKParameterIn* pin = beh->GetInputParameter(3);\r\n\t\t\t\tif (pin) {\r\n\t\t\t\t\tif (pin->GetType()!=ParamType){\r\n\t\t\t\t\t\tpin->SetType( ParamType );\r\n\t\t\t\t\t}\r\n\t\t\t\t} else beh->CreateInputParameter(\"Attribute Value\",ParamType);\r\n\t\t\t} else beh->EnableInputParameter(3,FALSE);\r\n\t\t}\r\n\r\n\t}\r\n\tbeh->ActivateOutput(0);\r\n\t\r\n \treturn CKBR_OK; \r\n}\r\n\r\n\r\n/* *************************************************************** */\r\n/* */\r\n/* */\r\n/* */\r\n/* FTP4W.DLL (Version 3.0) */\r\n/* */\r\n/* */\r\n/* By (SNCF 30.12.98) */\r\n/* Internet */\r\n/* Copyright SNCF 94-97 */\r\n/* *************************************************************** */\r\n\r\n\r\n#ifndef _FTP4W_API_\r\n\r\n#include \r\n\r\n#ifdef __cplusplus \r\nextern \"C\" { /* Assume C declarations for C++ */ \r\n#endif /* __cplusplus */ \r\n\r\n#define FTP_DATABUFFER 4096 /* a good value for X25/Ethernet/Token Ring */\r\n\r\n\r\n\r\n/* ----------------------------------------------------------- */\r\n\r\n/* ASCII or binary transfer */\r\n#define TYPE_A 'A'\r\n#define TYPE_I 'I'\r\n#define TYPE_L8 'L'\r\n#define TYPE_DEFAULT 0\r\n \r\n/* actions requested by user */\r\n#define FTP4W_STORE_ON_SERVER 65\r\n#define FTP4W_APPEND_ON_SERVER 87\r\n#define FTP4W_GET_FROM_SERVER 223\r\n\r\n/* Firewall Types */\r\n#define FTP4W_FWSITE 100\r\n#define FTP4W_FWPROXY 103\r\n#define FTP4W_FWUSERWITHLOGON 106\r\n#define FTP4W_FWUSERNOLOGON 109\r\n\r\n \r\n/* ----------------------------------------------------------- */\r\n/* Return codes of FTP functions */\r\n/* ----------------------------------------------------------- */\r\n/* success */\r\n#define FTPERR_OK 0 /* succesful function */\r\n/* OK but waits for further parameters */\r\n#define FTPERR_ENTERPASSWORD 1 /* userid need a password */\r\n#define FTPERR_ENTERACCOUNT 2 /* user/pass OK but account required */\r\n#define FTPERR_ACCOUNTNEEDED 2 /* user/pass OK but account required */\r\n#define FTPERR_RESTARTOK 3 /* Restart command successful */\r\n#define FTPERR_ENDOFDATA 4 /* server has closed the data-conn */\r\n#define FTPERR_CANCELBYUSER -1 /* Transfer aborted by user FtpAbort */\r\n/* user's or programmer's Errors */\r\n#define FTPERR_INVALIDPARAMETER 1000 /* Error in parameters */\r\n#define FTPERR_SESSIONUSED 1001 /* User has already a FTP session */\r\n#define FTPERR_NOTINITIALIZED 1002 /* FtpInit has not been call */\r\n#define FTPERR_NOTCONNECTED 1003 /* User is not connected to a server */\r\n#define FTPERR_CANTOPENFILE 1004 /* can not open specified file */\r\n#define FTPERR_CANTOPENLOCALFILE FTPERR_CANTOPENFILE\r\n#define FTPERR_CANTWRITE 1005 /* can't write into file (disk full?)*/\r\n#define FTPERR_NOACTIVESESSION 1006 /* FtpRelease without FtpInit */\r\n#define FTPERR_STILLCONNECTED 1007 /* FtpRelease without any Close */\r\n#define FTPERR_SERVERCANTEXECUTE 1008 /* file action not taken */\r\n#define FTPERR_LOGINREFUSED 1009 /* Server rejects usrid/passwd */\r\n#define FTPERR_NOREMOTEFILE 1010 /* server can not open file */\r\n#define FTPERR_TRANSFERREFUSED 1011 /* Host refused the transfer */\r\n#define FTPERR_WINSOCKNOTUSABLE 1012 /* A winsock.DLL ver 1.1 is required */\r\n#define FTPERR_CANTCLOSE 1013 /* Close failed (cmd is in progress) */\r\n#define FTPERR_FILELOCKED 1014 /* temporary error during FtpDelete */\r\n#define FTPERR_FWLOGINREFUSED 1015 /* Firewallrejects usrid/passwd */\r\n#define FTPERR_ASYNCMODE 1016 /* FtpMGet only in synchronous mode */\r\n/* TCP errors */\r\n#define FTPERR_UNKNOWNHOST 2001 /* can not resolve host adress */\r\n#define FTPERR_NOREPLY 2002 /* host does not send an answer */\r\n#define FTPERR_CANTCONNECT 2003 /* Error during connection */\r\n#define FTPERR_CONNECTREJECTED 2004 /* host has no FTP server */\r\n#define FTPERR_SENDREFUSED 2005 /* can't send data (network down) */\r\n#define FTPERR_DATACONNECTION 2006 /* connection on data-port failed */\r\n#define FTPERR_TIMEOUT 2007 /* timeout occured */\r\n#define FTPERR_FWCANTCONNECT 2008 /* Error during connection with FW */\r\n#define FTPERR_FWCONNECTREJECTED 2009 /* Firewall has no FTP server */\r\n/* FTP server errors */\r\n#define FTPERR_UNEXPECTEDANSWER 3001 /* answer was not expected */\r\n#define FTPERR_CANNOTCHANGETYPE 3002 /* host rejects the TYPE command */\r\n#define FTPERR_CMDNOTIMPLEMENTED 3003 /* host recognize but can't exec cmd*/\r\n#define FTPERR_PWDBADFMT 3004 /* PWD cmd OK, but answer has no \" */\r\n#define FTPERR_PASVCMDNOTIMPL 3005 /* Server don't support passive mode*/\r\n/* Resource errors */\r\n#define FTPERR_CANTCREATEWINDOW 5002 /* Insufficent free resources */\r\n#define FTPERR_INSMEMORY 5003 /* Insuffisent Heap memory */\r\n#define FTPERR_CANTCREATESOCKET 5004 /* no more socket */\r\n#define FTPERR_CANTBINDSOCKET 5005 /* bind is not succesful */\r\n#define FTPERR_SYSTUNKNOWN 5006 /* host system not in the list */\r\n\r\n\r\n\r\n/* **************************************************************** */\r\n/* */\r\n/* P R O T O T Y P E S */\r\n/* */\r\n/* **************************************************************** */\r\n\r\nLPSTR PASCAL FAR FtpBufferPtr (void);\r\nLPSTR PASCAL FAR FtpErrorString (int Rc);\r\nint PASCAL FAR WEP (int nType);\r\nint PASCAL FAR Ftp4wVer (LPSTR szVerStr, int nStrSize);\r\n\r\n/* change default parameters */\r\nint PASCAL FAR FtpSetVerboseMode (BOOL bVerboseMode, HWND hVerboseWnd, UINT wMsg);\r\nlong PASCAL FAR FtpBytesTransferred (void);\r\nlong PASCAL FAR FtpBytesToBeTransferred(void);\r\nvoid PASCAL FAR FtpSetDefaultTimeOut (int nTo_in_sec);\r\nvoid PASCAL FAR FtpSetDefaultPort(int nDefPort);\r\nvoid PASCAL FAR FtpSetAsynchronousMode(void);\r\nvoid PASCAL FAR FtpSetSynchronousMode(void);\r\nBOOL PASCAL FAR FtpIsAsynchronousMode(void); \r\nvoid PASCAL FAR FtpSetNewDelay(int x); \r\nvoid PASCAL FAR FtpSetNewSlices(int x,int y) ;\r\nvoid PASCAL FAR FtpSetPassiveMode (BOOL bPassive);\r\nvoid PASCAL FAR FtpLogTo (HFILE hLogFile);\r\n/* mispelled functions - only for backwards compatibilty */\r\nlong PASCAL FAR FtpBytesTransfered (void);\r\nlong PASCAL FAR FtpBytesToBeTransfered(void);\r\n\r\n/* Init functions */\r\nint PASCAL FAR FtpRelease (void);\r\nint PASCAL FAR FtpInit (HWND hParentWnd);\r\nint PASCAL FAR FtpMtInit ( HWND hParentWnd, DWORD (FAR *f)(void) );\r\nint PASCAL FAR FtpFlush (void);\r\n\r\n/* Connection */\r\nint PASCAL FAR FtpLogin (LPCSTR szHost, LPCSTR szUser, LPCSTR szPasswd,\r\n HWND hParentWnd, UINT wMsg);\r\nint PASCAL FAR FtpOpenConnection (LPCSTR szHost);\r\nint PASCAL FAR FtpCloseConnection (void);\r\nint PASCAL FAR FtpLocalClose (void);\r\n\r\n/* authentification */\r\nint PASCAL FAR FtpSendUserName (LPCSTR szUserName);\r\nint PASCAL FAR FtpSendPasswd (LPCSTR szPasswd);\r\nint PASCAL FAR FtpSendAccount (LPCSTR szAccount);\r\n\r\n/* commands */\r\nint PASCAL FAR FtpHelp (LPCSTR szArg, LPSTR szBuf, UINT uBufSize);\r\nint PASCAL FAR FtpDeleteFile (LPCSTR szRemoteFile);\r\nint PASCAL FAR FtpRenameFile (LPCSTR szFrom, LPCSTR szTo);\r\nint PASCAL FAR FtpQuote (LPCSTR szCmd, LPSTR szReplyBuf, UINT uBufSize);\r\nint PASCAL FAR FtpSyst (LPCSTR FAR *szSystemStr);\r\nint PASCAL FAR FtpSetType(char cType);\r\nint PASCAL FAR FtpCWD (LPCSTR szPath);\r\nint PASCAL FAR FtpCDUP (void);\r\nint PASCAL FAR FtpPWD (LPSTR szBuf, UINT uBufSize);\r\nint PASCAL FAR FtpMKD (LPCSTR szPath, LPSTR szFullDir, UINT uBufSize);\r\nint PASCAL FAR FtpRMD (LPCSTR szPath);\r\n\r\n/* file transfer */\r\nint PASCAL FAR FtpAbort (void);\r\nint PASCAL FAR FtpSendFile (LPCSTR szLocal, LPCSTR szRemote, char cType, \r\n BOOL bNotify, HWND hParentWnd, UINT wMsg);\r\nint PASCAL FAR FtpAppendToRemoteFile (LPCSTR szLocal, LPCSTR szRemote,char cType,\r\n BOOL bNotify, HWND hParentWnd, UINT wMsg);\r\nint PASCAL FAR FtpRecvFile (LPCSTR szRemote, LPCSTR szLocal, char cType, \r\n BOOL bNotify, HWND hParentWnd, UINT wMsg);\r\nint PASCAL FAR FtpAppendToLocalFile (LPCSTR szLocal, LPCSTR szRemote,char cType,\r\n BOOL bNotify, HWND hParentWnd, UINT wMsg);\r\nDWORD PASCAL FAR FtpGetFileSize (void);\r\nint PASCAL FAR FtpMGet (LPCSTR szFilter, char cType, BOOL bNotify,\r\n BOOL (CALLBACK *f) (LPCSTR szRemFile, LPCSTR szLocalFile, int Rc) );\r\n\r\nint PASCAL FAR FtpRestart (long lByteCount);\r\nint PASCAL FAR FtpRestartSendFile (HFILE hLocal, LPCSTR szRemote, char cType, \r\n BOOL bNotify, long lByteCount,\r\n HWND hParentWnd, UINT wMsg);\r\nint PASCAL FAR FtpRestartRecvFile (LPCSTR szRemote, HFILE hLocal, char cType, \r\n BOOL bNotify, long lByteCount,\r\n HWND hParentWnd, UINT wMsg);\r\n\r\n\r\n/* Directory */\r\nint PASCAL FAR FtpDir (LPCSTR szDef, LPCSTR szLocalFile,\r\n BOOL bLongDir, HWND hParentWnd, UINT wMsg);\r\n\r\n/* Advanced function */\r\nint PASCAL FAR FtpOpenDataConnection (LPCSTR szRemote,int nAction,char cType);\r\nint PASCAL FAR FtpRecvThroughDataConnection (LPSTR szBuf,\r\n unsigned int far *lpBufSize);\r\nint PASCAL FAR FtpSendThroughDataConnection(LPCSTR szBuf,unsigned int uBufSize);\r\nint PASCAL FAR FtpCloseDataConnection (void);\r\n\r\n/* Firewall function: Not Available */\r\nint PASCAL FAR FtpFirewallLogin(LPCSTR szFWHost, LPCSTR szFWUser, LPCSTR szFWPass,\r\n LPCSTR szRemHost,LPCSTR szRemUser,LPCSTR szRemPass,\r\n int nFirewallType,\r\n HWND hParentWnd, UINT wMsg);\r\n/* hidden exported functions */\r\nint PASCAL FAR IntFtpGetAnswerCode ();\r\nint PASCAL FAR FtpAutomate (int nIdx, LPCSTR szParam);\r\n\r\n\r\n/* _______________________________________________________________ */\r\n\r\n#ifdef __cplusplus \r\n} /* End of extern \"C\" */ \r\n#endif /* ifdef __cplusplus */ \r\n\r\n#define _FTP4W_API_ loaded\r\n#endif /* ifndef FTP4W_API */\r\n\r\n#ifndef __VT_GUIDS_H\r\n#define __VT_GUIDS_H\r\n\r\n#define PARAM_OP_TYPE_GET_ERROR_TEXT CKGUID(0xbc339b6,0x795302cc)\r\n#define VTE_NETWORK_ERROR\t\tCKGUID(0x6fca5bf6,0x77ed61e8)\r\n\r\n#endifDEV35DIR=\"c:/sdk/dev35\"\r\nDEV40DIR=\"c:/sdk/dev4\"\r\nDEV41DIR=\"c:/sdk/dev41R\"\r\nDEV5DIR=\"c:/sdk/dev5GA\"\r\nWEBPLAYERDIR=\"c:/Programme/Virtools/3D Life Player\"\r\n#include \"stdafx2.h\"\r\n#include \"vtAgeiaInterfaceEditor.h\"\r\n#include \"vtAgeiaInterfaceEditorDlg.h\"\r\n#include \"vtAgeiaInterfaceKeyboardShortcuts.h\"\r\n\r\nvoid\tGlobalKSCallback(int commandID)\r\n{\r\n if (g_Editor)\r\n g_Editor->OnGlobalKeyboardShortcut(commandID);\r\n}\r\n\r\nint\t\tRegisterKeyboardShortcutCategory()\r\n{\r\n\tKeyboardShortcutManager* ksm = s_Plugininterface->GetKeyboardShortcutManager();\r\n\tif (ksm)\r\n\t{\r\n\t\t//remove the comments delimiters to register global keyboard shortcut category\r\n\t\t//that will be detected by the application whatever the focused window is.\r\n\t\tint index = ksm->RegisterCategory(STR_CATEGORY,NULL,ACTIVE/*+GLOBAL*/,NULL,NULL/*GlobalKSCallback*/,GetCommandName);\r\n\t\tif (index>=0)\r\n\t\t\treturn 1;\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint\t\tUnregisterKeyboardShortcutCategory()\r\n{\r\n\tKeyboardShortcutManager* ksm = s_Plugininterface->GetKeyboardShortcutManager();\r\n\tif (ksm)\r\n\t{\r\n\t\treturn ksm->UnregisterCategory(STR_CATEGORY);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint\t\tRegisterKeyboardShortcuts()\r\n{\r\n\tKeyboardShortcutManager* ksm = s_Plugininterface->GetKeyboardShortcutManager();\r\n\tKeyboardShortcutManager::KS ks;\r\n\r\n\tint index\t\t= ksm->GetCategoryIndex(STR_CATEGORY);\r\n\r\n//sample code to register Ctrl+shift+alt+A with commandid_a and B with commandid_b\r\n\tks.key\t\t\t= 'A';\r\n\tks.flags\t\t= ks.KS_CONTROL|ks.KS_SHIFT|ks.KS_ALT;\r\n\tks.commandID\t= CID_A;\r\n\tksm->RegisterKS(index,ks);\r\n\r\n\tks.key\t\t\t= 'B';\r\n\tks.flags\t\t= 0;\r\n\tks.commandID\t= CID_B;\r\n\tksm->RegisterKS(index,ks);\r\n//end sample code\r\n\r\n\treturn 1;\t\r\n}\r\n\r\nconst char*\tGetCommandName(int commandID)\r\n{\r\n//sample code\r\n\tswitch(commandID)\r\n\t{\r\n\tcase CID_A:\r\n\t\treturn STR_A;\r\n\tcase CID_B:\r\n\t\treturn STR_B;\r\n\t}\r\n//sample code\r\n\treturn NULL;\r\n}\r\n\r\nconst char*\tGetCommandMenuName(int commandID,XString &name)\r\n{\r\n\tname=\"\";\r\n\tconst char* cstr\t= GetCommandName(commandID);\r\n\tif (!cstr)\r\n\t\treturn NULL;\r\n\r\n\tname\t\t\t\t= cstr;\r\n\r\n\tKeyboardShortcutManager* ksm = s_Plugininterface->GetKeyboardShortcutManager();\r\n\tif (ksm)\r\n\t{\r\n\t\tksm->GetKSName(\tSTR_CATEGORY,\r\n\t\t\t\t\t\tcommandID,\r\n\t\t\t\t\t\tname,\r\n\t\t\t\t\t\tFALSE/*do not clear string*/,\r\n\t\t\t\t\t\tTRUE/*add tab to string if string not empty*/);\r\n\t}\r\n\r\n\treturn name.CStr();\r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"Stream.h\"\r\n#include \"cooking.h\"\r\n\r\n\r\n\r\npCloth::~pCloth()\r\n{\r\n\r\n\r\n\r\n\tif (!getCloth())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tgetWorld()->getScene()->releaseCloth(*mCloth);\r\n\t//getWorld()->getScene()->\r\n\treleaseReceiveBuffers();\r\n\tsetEntityID(-1);\r\n\r\n\r\n}\r\nvoid pCloth::detachFromShape(CKBeObject *shape)\r\n{\r\n\tif (!shape)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\tNxShape *aShape = getWorld()->getShapeByEntityID(shape->GetID());\r\n\tif (aShape)\r\n\t{\r\n\t\tgetCloth()->detachFromShape(aShape);\r\n\t}\r\n\r\n}\r\nvoid pCloth::dominateVertex(int vertexId, float expirationTime, float dominanceWeight)\r\n{\r\n\tgetCloth()->dominateVertex(vertexId,expirationTime,dominanceWeight);\r\n}\r\n\r\nvoid pCloth::freeVertex(const int vertexId)\r\n{\r\n\tgetCloth()->freeVertex(vertexId);\r\n}\r\n\r\nvoid pCloth::attachVertexToGlobalPosition(const int vertexId, const VxVector &pos)\r\n{\r\n\r\n\tgetCloth()->attachVertexToGlobalPosition(vertexId,getFrom(pos));\r\n\r\n}\r\nvoid pCloth::attachVertexToShape(int vertexId, CKBeObject *shape, const VxVector &localPos, int attachmentFlags)\r\n{\r\n\r\n\tif (!shape)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (!getWorld())\r\n\t\treturn;\r\n\r\n\tNxShape *aShape = getWorld()->getShapeByEntityID(shape->GetID());\r\n\tif (aShape)\r\n\t{\r\n\t\tgetCloth()->attachVertexToShape(vertexId,aShape,getFrom(localPos),attachmentFlags);\r\n\t}\r\n}\r\n\r\nvoid pCloth::attachToCore(CK3dEntity *body, float impulseThreshold, float penetrationDepth, float maxDeformationDistance)\r\n{\r\n\r\n\tpRigidBody *rbody = GetPMan()->getBody(body);\r\n\tif (!body)\r\n\t{\r\n\t\treturn ;\r\n\t}\r\n\r\n\tif (rbody->getWorld() != getWorld() )\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\tgetCloth()->attachToCore(rbody->getActor(),impulseThreshold,penetrationDepth,maxDeformationDistance);\r\n\r\n\r\n}\r\n\r\nvoid pCloth::attachToCollidingShapes(int attachmentFlags)\r\n{\r\n\tmCloth->attachToCollidingShapes(attachmentFlags);\r\n}\r\nvoid pCloth::attachToShape(CKBeObject *shape, int attachmentFlags)\r\n{\r\n\r\n\tif (!shape)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tif (!getWorld())\r\n\t\treturn;\r\n\r\n\tNxShape *aShape = getWorld()->getShapeByEntityID(shape->GetID());\r\n\tif (aShape)\r\n\t{\r\n\t\tgetCloth()->attachToShape(aShape,attachmentFlags);\r\n\t}\r\n\t\r\n\r\n}\r\n\r\nvoid pCloth::setCollisionResponseCoefficient(float coefficient)\r\n{\r\n\tmCloth->setCollisionResponseCoefficient(coefficient);\r\n}\r\nvoid pCloth::addDirectedForceAtPos(const VxVector& position, const VxVector& force, float radius, ForceMode mode /* = FM_Force */)\r\n{\r\n\tmCloth->addDirectedForceAtPos(getFrom(position),getFrom(force),(NxForceMode)mode );\r\n}\r\nvoid pCloth::addForceAtVertex(const VxVector& force, int vertexId, ForceMode mode /* = FM_Force */)\r\n{\r\n\tmCloth->addForceAtVertex(getFrom(force),vertexId,(NxForceMode)mode);\r\n}\r\n\r\nvoid pCloth::addForceAtPos(const VxVector& position, float magnitude, float radius, ForceMode mode /* = FM_Force */)\r\n{\r\n\tmCloth->addForceAtPos(getFrom(position),magnitude,radius,(NxForceMode)mode);\r\n}\r\n\r\nvoid pCloth::wakeUp(float wakeCounterValue /* = NX_SLEEP_INTERVAL */)\r\n{\r\n\tmCloth->wakeUp(wakeCounterValue);\r\n}\r\n\r\nvoid pCloth::putToSleep()\r\n{\r\n\tmCloth->putToSleep();\r\n}\r\n\r\nvoid pCloth::setFlags(int flags)\r\n{\r\n\tmCloth->setFlags(flags);\r\n}\r\nvoid pCloth::setSleepLinearVelocity(float threshold)\r\n{\r\n\tmCloth->setSleepLinearVelocity(threshold);\r\n}\r\nvoid pCloth::setExternalAcceleration(VxVector acceleration)\r\n{\r\n\tmCloth->setExternalAcceleration(getFrom(acceleration));\r\n}\r\nvoid pCloth::setWindAcceleration(VxVector acceleration)\r\n{\r\n\tmCloth->setWindAcceleration(getFrom(acceleration));\r\n}\r\nvoid pCloth::setMinAdhereVelocity(float velocity)\r\n{\r\n\tmCloth->setMinAdhereVelocity(velocity);\r\n}\r\nvoid pCloth::setToFluidResponseCoefficient(float coefficient)\r\n{\r\n\tmCloth->setToFluidResponseCoefficient(coefficient);\r\n}\r\nvoid pCloth::setFromFluidResponseCoefficient(float coefficient)\r\n{\r\n\tmCloth->setFromFluidResponseCoefficient(coefficient);\r\n}\r\nvoid pCloth::setAttachmentResponseCoefficient(float coefficient)\r\n{\r\n\tmCloth->setAttachmentResponseCoefficient(coefficient);\r\n}\r\nvoid pCloth::setVelocity(const VxVector& velocity, int vertexId)\r\n{\r\n\tmCloth->setVelocity(getFrom(velocity),vertexId);\r\n}\r\nvoid pCloth::setValidBounds(const VxBbox& validBounds)\r\n{\r\n\tNxBounds3 box;\r\n\tbox.set( getFrom(validBounds.Min), getFrom(validBounds.Max));\r\n\tmCloth->setValidBounds(box);\r\n}\r\n\r\nvoid pCloth::setGroup(int collisionGroup)\r\n{\r\n\tmCloth->setGroup(collisionGroup);\r\n}\r\nvoid pCloth::setSolverIterations(int iterations)\r\n{\r\n\tmCloth->setSolverIterations(iterations);\r\n}\r\nvoid pCloth::setThickness(float thickness)\r\n{\r\n\tmCloth->setThickness(thickness);\r\n}\r\nvoid pCloth::setAttachmentTearFactor(float factor)\r\n{\r\n\tmCloth->setAttachmentTearFactor(factor);\r\n}\r\nvoid pCloth::setTearFactor(float factor)\r\n{\r\n\tmCloth->setTearFactor(factor);\r\n}\r\nvoid pCloth::setPressure(float pressure)\r\n{\r\n\tmCloth->setPressure(pressure);\r\n}\r\nvoid pCloth::setFriction(float friction)\r\n{\r\n\tmCloth->setFriction(friction);\r\n}\r\nvoid pCloth::setDampingCoefficient(float dampingCoefficient)\r\n{\r\n\tmCloth->setDampingCoefficient(dampingCoefficient);\r\n}\r\n\r\nvoid pCloth::setStretchingStiffness(float stiffness)\r\n{\r\n\tmCloth->setStretchingStiffness(stiffness);\r\n}\r\nvoid pCloth::setBendingStiffness(float stiffness)\r\n{\r\n\tmCloth->setBendingStiffness(stiffness);\r\n}\r\n\r\nvoid pCloth::updateVirtoolsMesh()\r\n{\r\n\r\n\tNxMeshData *data = getReceiveBuffers();\r\n\tCK3dEntity *srcEntity =(CK3dEntity*) GetPMan()->GetContext()->GetObject(getEntityID());\r\n\tif (!srcEntity)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t/*\r\n\tif (getCloth()->isSleeping())\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\r\n\t*/\r\n\tCKMesh *mesh = srcEntity->GetCurrentMesh();\r\n\tNxReal *vertices = (NxReal*)data->verticesPosBegin;\r\n\t\r\n\r\n\tVxVector pos;\r\n\tsrcEntity->GetPosition(&pos);\r\n\tfor (int i = 0 ; i< mesh->GetVertexCount() ; i++ )\r\n\t{\r\n\t\tVxVector v;\r\n\t\tv.x = vertices[i * 3];\r\n\t\tv.y = vertices[i * 3 + 1];\r\n\t\tv.z = vertices[i * 3 + 2];\r\n\t\tVxVector outIV;\r\n\t\tsrcEntity->InverseTransform(&outIV,&v);\r\n\t\tmesh->SetVertexPosition(i,&outIV);\r\n\t}\r\n\tint t = 3;\r\n\r\n}\r\n\r\nbool pCloth::cookMesh(NxClothMeshDesc* desc)\r\n{\r\n\r\n\t// we cook the mesh on the fly through a memory stream\r\n\t// we could also use a file stream and pre-cook the mesh\r\n\tMemoryWriteBuffer wb;\r\n\tint dValid = desc->isValid();\r\n\r\n\r\n\tbool status = InitCooking();\r\n\tif (!status) {\r\n\t\txLogger::xLog(ELOGERROR,E_LI_AGEIA,\"Couldn't initiate cooking lib!\");\r\n\t\treturn NULL;\r\n\t}\r\n\r\n\tbool success = CookClothMesh(*desc, wb);\r\n\r\n\tif (!success) \r\n\t\treturn false;\r\n\r\n\tMemoryReadBuffer rb(wb.data);\r\n\r\n\tmClothMesh = GetPMan()->getPhysicsSDK()->createClothMesh(rb);\r\n\r\n\tCloseCooking();\r\n\r\n\treturn true;\r\n\r\n}\r\n\r\nbool pCloth::generateMeshDesc(pClothDesc cDesc,NxClothMeshDesc *desc, CKMesh*mesh)\r\n{\r\n\r\n\tif (!mesh)\r\n\t{\r\n\t\treturn false;\r\n\t}\r\n\r\n\tint numVerts = mesh->GetVertexCount();\r\n\tint numFaces = mesh->GetFaceCount();\r\n\r\n\t// allocate flag buffer\r\n\tif(desc->vertexFlags == 0)\r\n\t\tdesc->vertexFlags = malloc(sizeof(NxU32)*desc->numVertices);\r\n\r\n\t// create tear lines\r\n\tNxU32* flags = (NxU32*)desc->vertexFlags;\r\n\r\n\tNxReal *vertices = new float[3 * numVerts];\r\n\t//NxVec3 *verts = new NxVec3[numVerts];\r\n\r\n\tfor (int i = 0 ; i< numVerts ; i++ )\r\n\t{\r\n\t\tVxVector v;\r\n\t\tmesh->GetVertexPosition(i,&v);\r\n\t\tvertices[i * 3] = v.x;\r\n\t\tvertices[i * 3 + 1] =v.y;\r\n\t\tvertices[i * 3 + 2] = v.z;\r\n\r\n\t\t\r\n\r\n\t\tif (desc->flags & NX_CLOTH_MESH_TEARABLE)\r\n\t\t{\r\n\t\t\tDWORD vColor = mesh->GetVertexColor(i);\r\n\t\t\tDWORD cColor = RGBAFTOCOLOR(&cDesc.tearVertexColor);\r\n\t\t\tif (vColor == cColor )\r\n\t\t\t{\r\n\t\t\t\tint op2 =0;\r\n\t\t\t\tflags[i] = NX_CLOTH_VERTEX_TEARABLE;\r\n\t\t\t\tint k = 0 ;\r\n\t\t\t\tk++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tNxU32 *indices2 = new NxU32[numFaces*3];\r\n\r\n\tfor(int j = 0 ; j < numFaces ; j++)\r\n\t{\r\n\r\n\t\tint findicies[3];\r\n\t\tmesh->GetFaceVertexIndex(j,findicies[0],findicies[1],findicies[2]);\r\n\t\tindices2[ j *3 ]\t\t\t= findicies[0];\r\n\t\tindices2[ j *3 + 1 ]\t= findicies[1];\r\n\t\tindices2[ j *3 + 2 ]\t= findicies[2];\r\n\t}\r\n\tdesc->numVertices\t\t\t= numVerts;\r\n\tdesc->pointStrideBytes\t= sizeof(NxReal)*3;\r\n\tdesc->points\t\t\t\t= vertices;\r\n\tdesc->numTriangles\t\t= numFaces;\r\n\tdesc->triangles\t\t\t= indices2;\r\n\tdesc->triangleStrideBytes\t= sizeof(NxU32)*3;\r\n\tdesc->flags\t\t\t\t= 0;\r\n\tdesc->vertexMasses\t\t\t\t= 0;\r\n\tdesc->vertexFlags\t\t\t\t= 0;\r\n\tdesc->flags\t\t\t\t\t\t= NX_CLOTH_MESH_WELD_VERTICES;\r\n\tdesc->weldingDistance\t\t\t= 0.0001f;\r\n\r\n\treturn true;\r\n\r\n\r\n}\r\n\r\n\r\nvoid pCloth::allocateClothReceiveBuffers(int numVertices, int numTriangles)\r\n{\r\n\r\n\t// here we setup the buffers through which the SDK returns the dynamic cloth data\r\n\t\t// we reserve more memory for vertices than the initial mesh takes\r\n\t\t// because tearing creates new vertices\r\n\t\t// the SDK only tears cloth as long as there is room in these buffers\r\n\t\t\r\n\t\r\n\tmReceiveBuffers = new NxMeshData();\r\n\r\n\tNxU32 maxVertices = 3 * numVertices;\r\n\tmReceiveBuffers->verticesPosBegin = (NxVec3*)malloc(sizeof(NxVec3)*maxVertices);\r\n\tmReceiveBuffers->verticesNormalBegin = (NxVec3*)malloc(sizeof(NxVec3)*maxVertices);\r\n\tmReceiveBuffers->verticesPosByteStride = sizeof(NxVec3);\r\n\tmReceiveBuffers->verticesNormalByteStride = sizeof(NxVec3);\r\n\tmReceiveBuffers->maxVertices = maxVertices;\r\n\tmReceiveBuffers->numVerticesPtr = (NxU32*)malloc(sizeof(NxU32));\r\n\r\n\t// the number of triangles is constant, even if the cloth is torn\r\n\tNxU32 maxIndices = 3*numTriangles;\r\n\tmReceiveBuffers->indicesBegin = (NxU32*)malloc(sizeof(NxU32)*maxIndices);\r\n\tmReceiveBuffers->indicesByteStride = sizeof(NxU32);\r\n\tmReceiveBuffers->maxIndices = maxIndices;\r\n\tmReceiveBuffers->numIndicesPtr = (NxU32*)malloc(sizeof(NxU32));\r\n\r\n\t// the parent index information would be needed if we used textured cloth\r\n\tNxU32 maxParentIndices = maxVertices;\r\n\tmReceiveBuffers->parentIndicesBegin = (NxU32*)malloc(sizeof(NxU32)*maxParentIndices);\r\n\tmReceiveBuffers->parentIndicesByteStride = sizeof(NxU32);\r\n\tmReceiveBuffers->maxParentIndices = maxParentIndices;\r\n\tmReceiveBuffers->numParentIndicesPtr = (NxU32*)malloc(sizeof(NxU32));\r\n\r\n\t// init the buffers in case we want to draw the mesh \r\n\t// before the SDK as filled in the correct values\r\n\t*mReceiveBuffers->numVerticesPtr = 0;\r\n\t*mReceiveBuffers->numIndicesPtr = 0;\r\n}\r\n\r\nvoid pCloth::releaseReceiveBuffers()\r\n{\r\n\r\n\t// Parent Indices is always allocated\r\n/*\tfree (mReceiveBuffers.parentIndicesBegin);\r\n\r\n\tmReceiveBuffers.setToDefault();*/\r\n\r\n}\r\n\r\nvoid pCloth::releaseMeshDescBuffers(const NxClothMeshDesc* desc)\r\n{\r\n\r\n\tNxVec3* p = (NxVec3*)desc->points;\r\n\tNxU32* t = (NxU32*)desc->triangles;\r\n\tNxReal* m = (NxReal*)desc->vertexMasses;\r\n\tNxU32* f = (NxU32*)desc->vertexFlags;\r\n\tfree(p);\r\n\tfree(t);\r\n\tfree(m);\r\n\tfree(f);\r\n}\r\n\r\n\r\npCloth::pCloth()\r\n{\r\n\r\n}\r\n\r\n/*----------------------------------------------------------------------------*/\r\n\r\npClothDesc::pClothDesc()\r\n{\r\n\t//setToDefault();\r\n\r\n}\r\n\r\n/*----------------------------------------------------------------------------*/\r\n\r\nvoid pClothDesc::setToDefault()\r\n{\r\n\tthickness = 0.01f;\r\n\tdensity = 1.0f;\r\n\tbendingStiffness = 1.0f;\r\n\r\n\tstretchingStiffness = 1.0f;\r\n\tdampingCoefficient = 0.5f;\r\n\tfriction = 0.5f;\r\n\r\n\tpressure = 1.0f;\r\n\ttearFactor = 1.5f;\r\n\tattachmentTearFactor = 1.5f;\r\n\r\n\tattachmentResponseCoefficient = 0.2f;\r\n\tattachmentTearFactor = 1.5f;\r\n\tcollisionResponseCoefficient = 0.2f;\r\n\ttoFluidResponseCoefficient = 1.0f;\r\n\r\n\tfromFluidResponseCoefficient = 1.0f;\r\n\tminAdhereVelocity = 1.0f;\r\n\tflags = PCF_Gravity|PCF_CollisionTwoway;\r\n\r\n\tsolverIterations = 5;\r\n\twakeUpCounter = NX_SLEEP_INTERVAL;\r\n\tsleepLinearVelocity = -1.0f;\r\n\tcollisionGroup = 0;\r\n\tforceFieldMaterial = 0;\r\n\texternalAcceleration =VxVector(0.0f, 0.0f, 0.0f);\r\n\twindAcceleration=VxVector(0.0f, 0.0f, 0.0f);\r\n\tgroupsMask.bits0 = 0;\r\n\tgroupsMask.bits1 = 0;\r\n\tgroupsMask.bits2 = 0;\r\n\tgroupsMask.bits3 = 0;\r\n\tvalidBounds = VxBbox();\r\n\trelativeGridSpacing = 0.25f;\r\n\ttearVertexColor.Set(1.0f);\r\n\r\n\r\n}\r\n\r\n/*----------------------------------------------------------------------------*/\r\n\r\nbool pClothDesc::isValid() const\r\n{\r\n\t//\tif (flags & NX_CLF_SELFCOLLISION) return false;\t// not supported at the moment\r\n\r\n\r\n\tif(thickness < 0.0f) return false;\r\n\tif(density <= 0.0f) return false;\r\n\tif(bendingStiffness < 0.0f || bendingStiffness > 1.0f) return false;\r\n\tif(stretchingStiffness <= 0.0f || stretchingStiffness > 1.0f) return false;\r\n\tif(pressure < 0.0f) return false;\r\n\tif(tearFactor <= 1.0f) return false;\r\n\tif(attachmentTearFactor <= 1.0f) return false;\r\n\tif(solverIterations < 1) return false;\r\n\tif(friction < 0.0f || friction > 1.0f) return false;\r\n\tif(dampingCoefficient < 0.0f || dampingCoefficient > 1.0f) return false;\r\n\tif(collisionResponseCoefficient < 0.0f) return false;\r\n\tif(wakeUpCounter < 0.0f) return false;\r\n\tif(attachmentResponseCoefficient < 0.0f || attachmentResponseCoefficient > 1.0f) return false;\r\n\tif(toFluidResponseCoefficient < 0.0f) return false;\r\n\tif(fromFluidResponseCoefficient < 0.0f) return false;\r\n\tif(minAdhereVelocity < 0.0f) return false;\r\n\tif(relativeGridSpacing < 0.01f) return false;\r\n\tif(collisionGroup >= 32) return false; // We only support 32 different collision groups\r\n\treturn true;\r\n}\r\n#ifndef __X_PLATFORM__\r\n\t#define __X_PLATFORM__\r\n\r\n\tenum E_ASSERTION_FAILURE_SEVERITY\r\n\t{\r\n\t\tAFS__MIN,\r\n\t\t\r\n\t\tAFS_ASSERT=AFS__MIN,\r\n\t\tAFS_CHECK,\r\n\r\n\t\tAFS__MAX,\r\n\t};\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// host identifier\r\n\t//\r\n\r\n\t#define xTARGET_OS_GENUNIX\t1\r\n\t#define xTARGET_OS_WINDOWS\t2\r\n\t#define xTARGET_OS_QNX\t\t3\r\n\t#define xTARGET_OS_MAC\t\t4\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// base types\r\n\t//\r\n\t#if !defined(__LINE__)\r\n\t\textern const unsigned int __LINE__;\r\n\t#endif \r\n\r\n\r\n\t#if !defined(__FILE__)\r\n\t\textern const char *const __FILE__;\r\n\t#endif \r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// Determine platform\r\n\t//\r\n\r\n\t#if defined(_WINDOWS) || defined(_WIN32)\r\n\r\n\t\t#define xTARGET_OS\t\t\txTARGET_OS_WINDOWS\r\n\r\n\t#elif defined(__QNX__)\r\n\r\n\t\t#define xTARGET_OS\t\t\txTARGET_OS_QNX\r\n\r\n\t#elif defined(__APPLE__)\r\n\r\n\t\t#define xTARGET_OS\t\t\txTARGET_OS_MAC\r\n\r\n\t#endif\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// determine call convention\r\n\t//\r\n\t#if xTARGET_OS == xTARGET_OS_WINDOWS\r\n\r\n\t\t#define xCONVENTION_METHOD\r\n\t\t#define xCONVENTION_API __stdcall\r\n\t\t#define xCONVENTION_CALLBACK __stdcall\r\n\r\n\r\n\t#else // #if xTARGET_OS != xTARGET_OS_WINDOWS\r\n\r\n\t\t#define xCONVENTION_METHOD\r\n\t\t#define xCONVENTION_API\r\n\t\t#define xCONVENTION_CALLBACK\r\n\r\n\t#endif\r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// cpu bandwidth \r\n\t//\r\n\t#if !defined(xTARGET_BITS)\r\n\t\r\n\t\t#if defined(_LP64) || defined(_WIN64)\r\n\t\t\t#define xTARGET_BITS\t\t\txTARGET_BITS_64\r\n\t\t#else \r\n\t\t\t#define xTARGET_BITS\t\t\txTARGET_BITS_32\r\n\t\t#endif \r\n\r\n\t#else // #if defined(xTARGET_BITS)\r\n\r\n\t\t#if xTARGET_BITS <= 0 || xTARGET_BITS >= xTARGET_BITS__MAX\r\n\r\n\t\t\t#error Please define a valid value for xTARGET_BITS\r\n\r\n\t\t#endif \r\n\r\n\t#endif \r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// determine compiler\r\n\t//\r\n\r\n\t#define xCOMPILER__OTHER\t1\r\n\t#define xCOMPILER_GCC\t2\r\n\t#define xCOMPILER_MSVC\t3\r\n\r\n\t#define xCOMPILER__MAX\t4\r\n\r\n\r\n\t#define xCOMPILER_VERSION__OTHER\t\t1\r\n\t#define xCOMPILER_VERSION_MSVC1998\t2\r\n\t#define xCOMPILER_VERSION_GCCLT4\t\t3\r\n\r\n\t#define xCOMPILER_VERSION__MAX\t\t4\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\r\n\t#if !defined(xCOMPILER)\r\n\r\n\t\t#if defined(__GNUC__)\r\n\r\n\t\t\t#define xCOMPILER\t\txCOMPILER_GCC\r\n\r\n\t\t\t#if __GNUC__ < 4\r\n\t\t\t\r\n\t\t\t\t#define xCOMPILER_VERSION\txCOMPILER_VERSION_GCCLT4\r\n\t\t\t\r\n\t\t\t#endif \r\n\t\r\n\t\t\r\n\t\t#elif defined(_MSC_VER)\r\n\r\n\t\t\t#define xCOMPILER\t\txCOMPILER_MSVC\r\n\r\n\t\t\t\t#if _MSC_VER <= 1200\r\n\r\n\t\t\t\t\t#define xCOMPILER_VERSION\txCOMPILER_VERSION_MSVC1998\r\n\r\n\t\t\t\t#endif \r\n\r\n\t\t#else \r\n\r\n\t\t\t#define xCOMPILER\t\txCOMPILER__OTHER\r\n\r\n\t\t#endif \r\n\r\n\r\n\t#else \r\n\r\n\t\t#if xCOMPILER <= 0 || xCOMPILER >= xCOMPILER__MAX\r\n\r\n\t\t\t#error Please define a valid value for xCOMPILER\r\n\r\n\t\t#endif \r\n\r\n\t#endif \r\n\r\n\t\r\n\t#if !defined(xCOMPILER_VERSION)\r\n\r\n\t\t#define xCOMPILER_VERSION xCOMPILER_VERSION__OTHER\r\n\r\n\t#endif \r\n\r\n\r\n\t\r\n\t#if xCOMPILER_VERSION <= 0 || xCOMPILER_VERSION >= xCOMPILER_VERSION__MAX\r\n\r\n\t\t#error Please define a valid value for xCOMPILER_VERSION\r\n\r\n\t#endif \r\n\r\n\r\n\t//----------------------------------------------------------------\r\n\t//\r\n\t// inline , always inline\r\n\t//\r\n\t#if !defined(_xINLINES_DEFINED)\r\n\r\n\t\t#define _xINLINES_DEFINED\r\n\r\n\r\n\t\t#if xCOMPILER == xCOMPILER_GCC\r\n\r\n\t\t\t#define xALWAYSINLINE_PRE__DEFINITION inline\r\n\t\t\t#define xALWAYSINLINE_IN__DEFINITION __attribute__((always_inline))\r\n\r\n\t\t#elif xCOMPILER == xCOMPILER_MSVC\r\n\r\n\t\t\t#define xALWAYSINLINE_PRE__DEFINITION __forceinline\r\n\t\t\t#define xALWAYSINLINE_IN__DEFINITION\r\n\r\n\t\t#else \r\n\r\n\t\t\t#define xALWAYSINLINE_PRE__DEFINITION inline\r\n\t\t\t#define xALWAYSINLINE_IN__DEFINITION\r\n\r\n\t\t#endif \r\n\r\n\r\n\r\n\t\t#if defined(_DEBUG)\r\n\r\n\t\t\t#define xALWAYSINLINE_PRE inline\r\n\t\t\t#define xALWAYSINLINE_IN\r\n\t\t\t#define xINLINE inline\r\n\t\t\r\n\t\t#else\r\n\r\n\t\t\t#define xALWAYSINLINE_PRE xALWAYSINLINE_PRE__DEFINITION\r\n\t\t\t#define xALWAYSINLINE_IN xALWAYSINLINE_IN__DEFINITION\r\n\t\t\t#define xINLINE inline\r\n\t\t#endif \r\n\r\n\t#endif // #if !defined(_xINLINES_DEFINED)\r\n\r\n\r\n#endif/*\n * Tcp4u v 3.31 Last Revision 06/06/1997 3.10\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: http4u.c\n * Purpose: manage http 1.0 protocol\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n \n\n/*******************************\n * Http4u miscellaneous define\n *******************************/\n#ifdef UNIX\n# define trace 1\n#else\n# define trace 0\n#endif\n\n\n/*******************************\n * Http4u global variables\n *******************************/\nstruct S_http4u_errors \n{\n enum HTTP4_RETURN_CODE eErr;\n LPCSTR sErr;\n} \ntHttp4uErrors[] = \n{\n {HTTP4U_BAD_URL, \"Url does not conform to Http protocol.\", },\n {HTTP4U_TCP_CONNECT, \"can't reach the http server.\", },\n {HTTP4U_HOST_UNKNOWN, \"can not resolve host address\", },\n {HTTP4U_TCP_FAILED, \"call to Tcp4u library failed.\", },\n {HTTP4U_FILE_ERROR, \"file stream error.\", },\n {HTTP4U_INSMEMORY, \"insuffisant memory.\", }, \n {HTTP4U_BAD_PARAM, \"bad parameter in the function call.\", },\n {HTTP4U_OVERFLOW, \"user buffer so little .\", },\n {HTTP4U_CANCELLED, \"tranfser aborted.\", },\n {HTTP4U_NO_CONTENT, \"data is empty.\", },\n {HTTP4U_MOVED, \"request moved to other server.\", },\n {HTTP4U_BAD_REQUEST, \"bad request received by the server.\", },\n {HTTP4U_FORBIDDEN, \"request forbidden.\", },\n {HTTP4U_NOT_FOUND, \"destination file not found.\", },\n {HTTP4U_PROTOCOL_ERROR, \"protocol error.\", },\n {HTTP4U_UNDEFINED, \"miscellaneous error.\", },\n {HTTP4U_TIMEOUT, \"timeout in TCP dialog.\", },\n {HTTP4U_SUCCESS, \"Successful call.\" },\n};\n\n\n/*######################################################################\n *##\n *## NAME: Http4uErrorString\n *##\n *## PURPOSE: Writes a message explaining a function error\n *##\n *####################################################################*/\nLPCSTR API4U Http4uErrorString(\n int msg_code /* le code d'erreur de Http4U */\n )\n{\nint Idx;\nLPCSTR p;\n\n Tcp4uLog (LOG4U_HIPROC, \"Http4uErrorString\");\n\n for ( Idx=0 ; \n Idx= SizeOfTab(tHttp4uErrors) ? (LPSTR) \"Not an Http4u return code\" :\n tHttp4uErrors[Idx].sErr;\n\n Tcp4uLog (LOG4U_HIEXIT, \"Http4uErrorString\");\nreturn p;\n} /* END Http4uErrorString */\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n//\r\n//\t Mouse Camera Orbit\r\n//\r\n/////////////////////////////////////////////////////\r\n/////////////////////////////////////////////////////\r\n#include \"CKAll.h\"\r\n#include \"GeneralCameraOrbit.h\"\r\n\r\n#define CKPGUID_MOUSEBUTTON CKDEFINEGUID(0x1ff24d5a,0x122f2c1f)\r\n\r\nCKObjectDeclaration\t*FillBehaviorMouseCameraOrbitDecl();\r\nCKERROR CreateMouseCameraOrbitProto(CKBehaviorPrototype **pproto);\r\nint MouseCameraOrbit(const CKBehaviorContext& behcontext);\r\nvoid ProcessMouseInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping);\r\nCKERROR MouseCameraOrbitCallback(const CKBehaviorContext& context);\r\n\r\nCKObjectDeclaration\t*FillBehaviorMouseCameraOrbitDecl()\r\n{\r\n\tCKObjectDeclaration *od = CreateCKObjectDeclaration(\"Mouse Camera Orbit\");\r\n\tod->SetDescription(\"Makes a Camera orbit round a 3D Entity using Mouse.\");\r\n\t/* rem:\r\n\tOn: activates the process.
\r\n\tOff: deactivates the process.
\r\n\t
\r\n\tExit On: is activated if the building block is activated.
\r\n\tExit Off: is activated if the building block is deactivated.
\r\n\t
\r\n\tTarget Position: Position we are turning around.
\r\n\tTarget Referential: Referential where the position is defined.
\r\n\tMove Speed: Speed in angle per second used when the user moves the camera.
\r\n\tReturn Speed: Speed in angle per second used when the camera returns.
\r\n\tMin Horizontal: Minimal angle allowed on the horizontal rotation. Must have a negative value.
\r\n\tMax Horizontal:Maximal angle allowed on the horizontal rotation. Must have a positive value.
\r\n\tMin Vertical: Minimal angle allowed on the vertical rotation. Must have a negative value.
\r\n\tMax Vertical: Maximal angle allowed on the vertical rotation. Must have a positive value.
\r\n\tZoom Speed: Speed of the zoom in distance per second.
\r\n\tZoom Min: Minimum zoom value allowed. Must have a negative value.
\r\n\tZoom Max: Maximum zoom value allowed. Must have a positive value.
\r\n\t
\r\n\tThe following keys are used by default to move the Camera around its target:
\r\n\t
\r\n\tPage Up: Zoom in.
\r\n\tPage Down: Zoom out.
\r\n\tUp and Down Arrows: Rotate vertically.
\r\n\tLeft and Right Arrows: Rotate horizontally.
\r\n\tThe arrow keys are the inverted T arrow keys and not the ones of the numeric keypad.
\r\n
\r\n\tReturns: Does the camera systematically returns to its original position.
\r\n\tKey Rotate Left: Key used to rotate left.
\r\n\tKey Rotate Right: Key used to rotate right.
\r\n\tKey Rotate Up: Key used to rotate up.
\r\n\tKey Rotate Down: Key used to rotate down.
\r\n\tKey Zoom in: Key used to zoom in.
\r\n\tKey Zoom out: Key used to zoom in.
\r\n
\r\n\t*/\r\n\tod->SetCategory(\"Cameras/Movement\");\r\n\tod->SetType(CKDLL_BEHAVIORPROTOTYPE);\r\n\tod->SetGuid(CKGUID(0x2356342f,0x9542674f));\r\n\tod->SetAuthorGuid(VIRTOOLS_GUID);\r\n\tod->SetAuthorName(\"Virtools\");\r\n\tod->SetVersion(0x00010000);\r\n\tod->SetCreationFunction(CreateMouseCameraOrbitProto);\r\n\tod->SetCompatibleClassId(CKCID_3DENTITY);\r\n\tod->NeedManager(INPUT_MANAGER_GUID);\r\n\treturn od;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tPrototype creation\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR CreateMouseCameraOrbitProto(CKBehaviorPrototype **pproto)\r\n{\r\n\tCKBehaviorPrototype *proto = CreateCKBehaviorPrototype(\"Mouse Camera Orbit\");\r\n\tif(!proto) return CKERR_OUTOFMEMORY;\r\n\r\n\t// General Description\r\n\tCKERROR error = FillGeneralCameraOrbitProto(proto);\r\n\tif (error != CK_OK)\r\n\t\treturn (error);\r\n\r\n\t// Additional Input and Output\r\n\tproto->DeclareInput(\"Resume\");\r\n\tproto->DeclareOutput(\"Exit Resume\");\r\n\r\n\tproto->SetBehaviorFlags((CK_BEHAVIOR_FLAGS) (CKBEHAVIOR_TARGETABLE|CKBEHAVIOR_INTERNALLYCREATEDINPUTS|CKBEHAVIOR_INTERNALLYCREATEDOUTPUTS));\r\n\r\n\t// Set the execution functions\r\n\tproto->SetFunction(MouseCameraOrbit);\r\n\tproto->SetBehaviorCallbackFct(MouseCameraOrbitCallback,CKCB_BEHAVIORSETTINGSEDITED|CKCB_BEHAVIORLOAD|CKCB_BEHAVIORCREATE);\r\n\r\n\t// return OK\r\n\t*pproto = proto;\r\n\treturn CK_OK;\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\t\tMain Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nint MouseCameraOrbit(const CKBehaviorContext& behcontext)\r\n{\r\n\treturn ( GeneralCameraOrbit(behcontext,ProcessMouseInputs) );\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tFunction that process the inputs\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nvoid ProcessMouseInputs(VxVector* RotationAngles, CKBehavior* beh, CKInputManager *input, float delta, CKBOOL &Returns, CKBOOL &stopping)\r\n{\r\n\t// Is the move limited ?\r\n\tCKBOOL Limited = TRUE;\r\n\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\t\r\n\t// Gets the mouse displacement informations\r\n\tVxVector mouseDisplacement;\r\n\tinput->GetMouseRelativePosition(mouseDisplacement);\r\n\r\n\r\n\t////////////////////\r\n\t// Resume Input\r\n\t////////////////////\r\n\tif ( Returns && beh->IsInputActive(2) )\r\n\t{\r\n\t\t// Input / Output Status\r\n\t\tbeh->ActivateInput(2, FALSE);\r\n\t\tbeh->ActivateOutput(2);\r\n\r\n\t\t// We're not stopping anymore\r\n\t\tstopping = FALSE;\r\n\t\tbeh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);\r\n\t}\r\n\r\n\t////////////////////\r\n\t// Position Update\r\n\t////////////////////\r\n\t// If the users is moving the camera\r\n\tif ( !stopping )\r\n\t{\r\n\t\tfloat SpeedAngle = 0.87f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_MOVE,&SpeedAngle);\r\n\t\tSpeedAngle *= delta / 1000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinH = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_H, &MinH);\r\n\r\n\t\t\tfloat MaxH = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_H, &MaxH);\r\n\r\n\t\t\tfloat MinV = -PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_V, &MinV);\r\n\r\n\t\t\tfloat MaxV = PI/2;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_V, &MaxV);\r\n\r\n\t\t\tRotationAngles->x -= mouseDisplacement.x * SpeedAngle;\r\n\t\t\tRotationAngles->x = XMin(RotationAngles->x, MaxH);\r\n\t\t\tRotationAngles->x = XMax(RotationAngles->x, MinH);\r\n\r\n\t\t\tRotationAngles->y -= mouseDisplacement.y * SpeedAngle;\r\n\t\t\tRotationAngles->y = XMin(RotationAngles->y, MaxV);\r\n\t\t\tRotationAngles->y = XMax(RotationAngles->y, MinV);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tRotationAngles->x -= mouseDisplacement.x * SpeedAngle;\r\n\t\t\tRotationAngles->y -= mouseDisplacement.y * SpeedAngle;\r\n\t\t}\r\n\t}\r\n\telse if (Returns && ((RotationAngles->x != 0) || (RotationAngles->y != 0)))\r\n\t{\r\n\t\tfloat ReturnSpeedAngle = 1.75f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_RETURN, &ReturnSpeedAngle);\r\n\t\tReturnSpeedAngle *= delta / 1000;\r\n\r\n\t\tif( RotationAngles->x < 0 ) RotationAngles->x += XMin(ReturnSpeedAngle, -RotationAngles->x);\r\n\t\tif( RotationAngles->x > 0 ) RotationAngles->x -= XMin(ReturnSpeedAngle, RotationAngles->x);\r\n\t\tif( RotationAngles->y < 0 ) RotationAngles->y += XMin(ReturnSpeedAngle, -RotationAngles->y);\r\n\t\tif( RotationAngles->y > 0 ) RotationAngles->y -= XMin(ReturnSpeedAngle, RotationAngles->y);\r\n\t}\r\n\r\n\r\n\t////////////////\r\n\t// Zoom Update\r\n\t////////////////\r\n\tif ( (mouseDisplacement.z != 0) && !stopping ) \r\n\t{\r\n\t\tfloat ZoomSpeed = 40.0f;\r\n\t\tbeh->GetInputParameterValue(IN_SPEED_ZOOM,&ZoomSpeed);\r\n\t\tZoomSpeed *= delta / 10000;\r\n\r\n\t\tif (Limited)\r\n\t\t{\r\n\t\t\tfloat MinZoom = -40.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MIN_ZOOM, &MinZoom);\r\n\r\n\t\t\tfloat MaxZoom = 10.0f;\r\n\t\t\tbeh->GetInputParameterValue(IN_MAX_ZOOM, &MaxZoom);\r\n\r\n\t\t\tRotationAngles->z -= mouseDisplacement.z * ZoomSpeed;\r\n\t\t\tRotationAngles->z = XMin(RotationAngles->z, -MinZoom);\r\n\t\t\tRotationAngles->z = XMax(RotationAngles->z, -MaxZoom);\r\n\t\t}\r\n\t\telse\r\n\t\t\tRotationAngles->z -= mouseDisplacement.z * ZoomSpeed;\r\n\t}\r\n}\r\n\r\n\r\n//////////////////////////////////////////////////////////////////////////////\r\n//\r\n//\t\t\t\t\t\tMouse Specific Callback Function\r\n//\r\n//////////////////////////////////////////////////////////////////////////////\r\n\r\nCKERROR MouseCameraOrbitCallback(const CKBehaviorContext& context)\r\n{\r\n\tCKBehavior* beh = context.Behavior;\r\n\r\n\tswitch(context.CallbackMessage)\r\n\t{\r\n\t\tcase CKM_BEHAVIORCREATE:\r\n\t\tcase CKM_BEHAVIORLOAD:\r\n\t\t{\r\n\t\t\tVxVector InitialAngles(INF,INF,INF);\r\n\t\t\tbeh->SetLocalParameterValue(LOCAL_INIT,&InitialAngles);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\tcase CKM_BEHAVIORSETTINGSEDITED:\r\n\t\t{\r\n\t\t\t// Update the needed input for \"returns\"\r\n\t\t\tCKBOOL Returns = TRUE;\r\n\t\t\tbeh->GetLocalParameterValue(LOCAL_RETURN,&Returns);\r\n\t\t\tbeh->EnableInputParameter(IN_SPEED_RETURN, Returns);\r\n\t\t\tif ( Returns && (beh->GetInputCount() == 2) )\r\n\t\t\t{\r\n\t\t\t\tbeh->AddInput(\"Resume\");\r\n\t\t\t\tbeh->AddOutput(\"Exit Resume\");\r\n\t\t\t}\r\n\t\t\telse if (!Returns && (beh->GetOutputCount() == 3) )\r\n\t\t\t{\r\n\t\t\t\tbeh->DeleteInput(2);\r\n\t\t\t\tbeh->DeleteOutput(2);\r\n\t\t\t}\r\n\r\n\t\t\t// Updates the needed inputs for limiting the move\r\n\t\t\tCKBOOL Limited = TRUE;\r\n\t\t\tbeh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_H,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_H,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_V,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_V,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MIN_ZOOM,Limited);\r\n\t\t\tbeh->EnableInputParameter(IN_MAX_ZOOM,Limited);\r\n\t\t}\r\n\t\tbreak;\r\n\r\n\t\tdefault:\r\n\t\tbreak;\r\n\t}\r\n\r\n\treturn CKBR_OK; \r\n}\r\n#include \r\n#include \"vtPhysXAll.h\"\r\n#include \"VSLManagerSDK.h\"\r\n\r\n//#include \"pVehicle.h\"\r\n\r\n\r\n\r\n\r\nPhysicManager *ourMan = NULL;\r\n\r\nCKGUID GetPhysicManagerGUID() { \treturn GUID_MODULE_MANAGER;}\r\n\r\nvoid __newpVehicleDescr(BYTE *iAdd)\r\n{\r\n\r\n\t\tnew (iAdd)pVehicleDesc();\r\n}\r\n\r\nvoid __newpVehicleMotorDesc(BYTE *iAdd)\r\n{\r\n\tnew (iAdd)pVehicleMotorDesc();\r\n}\r\n\r\nvoid __newpVehicleGearDesc(BYTE *iAdd)\r\n{\r\n\tnew(iAdd)pVehicleGearDesc();\r\n}\r\n\r\n//////////////////////////////////////////////////////////////////////////\r\n\r\n#define TESTGUID CKGUID(0x2c5c47f6,0x1d0755d9)\r\n\r\n\r\nvoid PhysicManager::_RegisterVSL()\r\n{\r\n\t\r\n\tourMan = GetPMan();\r\n\r\n\tint z = D6DT_Position;\r\n\tint y = D6DT_Velocity;\r\n\t\t\r\n\t\r\n\tSTARTVSLBIND(m_Context)\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleMotorDesc)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpmToGearUp)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpmToGearDown)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,maxRpm)\r\n\tDECLAREMEMBER(pVehicleMotorDesc,float,minRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotorDesc,void,setToCorvette)\r\n\r\n\tDECLAREPOINTERTYPE(pVehicleGearDesc)\r\n\tDECLAREMEMBER(pVehicleGearDesc,int,nbForwardGears)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToDefault)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,void,setToCorvette)\r\n\tDECLAREMETHOD_0(pVehicleGearDesc,bool,isValid)\r\n\r\n\t\r\n\r\n\tDECLAREOBJECTTYPE(pWheelDescr)\r\n\tDECLARECTOR_0(__newpWheelDescr)\r\n\r\n\tDECLAREOBJECTTYPE(pVehicleDesc)\r\n\tDECLARECTOR_0(__newpVehicleDescr)\r\n\tDECLAREMEMBER(pVehicleDesc,float,digitalSteeringDelta)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringSteerPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,VxVector,steeringTurnPoint)\r\n\tDECLAREMEMBER(pVehicleDesc,float,steeringMaxAngle)\r\n\tDECLAREMEMBER(pVehicleDesc,float,transmissionEfficiency)\r\n\tDECLAREMEMBER(pVehicleDesc,float,differentialRatio)\r\n\tDECLAREMEMBER(pVehicleDesc,float,maxVelocity)\r\n\tDECLAREMEMBER(pVehicleDesc,float,motorForce)\r\n\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleGearDesc*,getGearDescription)\r\n\tDECLAREMETHOD_0(pVehicleDesc,pVehicleMotorDesc*,getMotorDescr)\r\n\tDECLAREMETHOD_0(pVehicleDesc,void,setToDefault)\r\n\t\t\r\n\tDECLAREPOINTERTYPE(pWheel)\r\n\tDECLAREPOINTERTYPE(pVehicle)\r\n\tDECLAREPOINTERTYPE(pVehicleMotor)\r\n\tDECLAREPOINTERTYPE(pVehicleGears)\r\n\r\n\tDECLAREPOINTERTYPE(pWheel1)\r\n\tDECLAREPOINTERTYPE(pWheel2)\r\n\r\n\tDECLAREINHERITANCESIMPLE(\"pWheel\",\"pWheel1\")\r\n\tDECLAREINHERITANCESIMPLE(\"pWheel\",\"pWheel2\")\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\t\t\t\tVehicle : \r\n\t//\r\n\tDECLAREMETHOD_1(pVehicle,void,updateVehicle,float)\r\n\tDECLAREMETHOD_5(pVehicle,void,setControlState,float,bool,float,bool,bool)\r\n\r\n\r\n\tDECLAREMETHOD_1(pVehicle,pWheel*,getWheel,CK3dEntity*)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleMotor*,getMotor)\r\n\tDECLAREMETHOD_0(pVehicle,pVehicleGears*,getGears)\r\n\r\n\tDECLAREMETHOD_0(pVehicle,void,gearUp)\r\n\tDECLAREMETHOD_0(pVehicle,void,gearDown)\r\n\t\r\n\t\r\n\tDECLAREMETHOD_0(pVehicleGears,int,getGear)\r\n\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//motor : \r\n\tDECLAREMETHOD_0(pVehicleMotor,float,getRpm)\r\n\tDECLAREMETHOD_0(pVehicleMotor,float,getTorque)\r\n\r\n\r\n\tDECLAREMETHOD_0(pWheel,pWheel1*,castWheel1)\r\n\tDECLAREMETHOD_0(pWheel,pWheel2*,castWheel2)\r\n\r\n\tDECLAREMETHOD_0(pWheel,float,getWheelRollAngle)\r\n\tDECLAREMETHOD_0(pWheel2,float,getRpm)\r\n\tDECLAREMETHOD_0(pWheel2,float,getAxleSpeed)\r\n\tDECLAREMETHOD_0(pWheel2,float,getSuspensionTravel)\r\n\tDECLAREMETHOD_0(pWheel2,VxVector,getGroundContactPos)\r\n\r\n\r\n\r\n\tDECLAREMETHOD_2(pFactory,pVehicle*,createVehicle,CK3dEntity*,pVehicleDesc)\r\n\t\r\n\t\r\n\t\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\t\t\t\tMANAGER\r\n\t//\r\n\tDECLAREFUN_C_0(CKGUID, GetPhysicManagerGUID)\r\n\tDECLAREOBJECTTYPE(PhysicManager)\r\n\tDECLARESTATIC_1(PhysicManager,PhysicManager*,Cast,CKBaseManager* iM)\r\n\tDECLAREFUN_C_0(PhysicManager*, GetPhysicManager)\r\n\t\r\n\tDECLAREMETHOD_0(PhysicManager,pWorld*,getDefaultWorld)\r\n\tDECLAREMETHOD_1(PhysicManager,pRigidBody*,getBody,CK3dEntity*)\r\n\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorldByBody,CK3dEntity*)\r\n\tDECLAREMETHOD_1(PhysicManager,pWorld*,getWorld,CK_ID)\r\n\tDECLAREMETHOD_3_WITH_DEF_VALS(PhysicManager,pJoint*,getJoint,CK3dEntity*,NODEFAULT,CK3dEntity*,NULL,JType,JT_Any)\r\n\r\n//\t\tDECLAREMETHOD_0(PhysicManager,void,makeDongleTest)\r\n\r\n\r\n\t//////////////////////////////////////////////////////////////////////////\r\n\t//\r\n\t//\t\t\t\t\tWorld\r\n\t//\r\n\t\r\n\tDECLAREMETHOD_1(pWorld,pRigidBody*,getBody,CK3dEntity*)\r\n\tDECLAREMETHOD_1(pWorld,pVehicle*,getVehicle,CK3dEntity*)\r\n\tDECLAREMETHOD_3(pWorld,pJoint*,getJoint,CK3dEntity*,CK3dEntity*,JType)\r\n\r\n\tDECLAREMETHOD_3(pWorld,void,setFilterOps,pFilterOp,pFilterOp,pFilterOp)\r\n\tDECLAREMETHOD_1(pWorld,void,setFilterBool,bool)\r\n\tDECLAREMETHOD_1(pWorld,void,setFilterConstant0,const pGroupsMask&)\r\n\tDECLAREMETHOD_1(pWorld,void,setFilterConstant1,const pGroupsMask&)\r\n\r\n\r\n\r\n\r\n\t//\r\n\tDECLAREMETHOD_5_WITH_DEF_VALS(pWorld,bool,raycastAnyBounds,const VxRay&,NODEFAULT,pShapesType,NODEFAULT,pGroupsMask,NODEFAULT,int,0xffffffff,float,NX_MAX_F32)\r\n\tDECLAREMETHOD_8(pWorld,bool,overlapSphereShapes,CK3dEntity*,const VxSphere&,CK3dEntity*,pShapesType,CKGroup*,int,const pGroupsMask*,BOOL)\r\n\r\n\t//(const VxRay& worldRay, pShapesType shapesType, pGroupsMask groupsMask,unsigned int groups=0xffffffff, float maxDist=NX_MAX_F32);\r\n\r\n\r\n\tSTOPVSLBIND\r\n\t\r\n\r\n}\r\n\r\n\r\nPhysicManager*GetPhysicManager()\r\n{\r\n\treturn GetPMan();\r\n}\r\n\r\n/*\r\nvoid __newvtWorldSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pWorldSettings();\r\n}\r\nvoid __newvtSleepingSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pSleepingSettings();\r\n}\r\nvoid __newvtJointSettings(BYTE *iAdd) \r\n{\r\nnew (iAdd) pJointSettings();\r\n}\r\n\r\n\r\nint TestWS(pWorldSettings pWS)\r\n{\r\nVxVector grav = pWS.Gravity();\r\nreturn 2;\r\n}\r\n\r\npFactory* GetPFactory();\r\n\r\n\r\npFactory* GetPFactory()\r\n{\r\nreturn pFactory::Instance();\r\n}\r\n\r\n\r\nextern pRigidBody*getBody(CK3dEntity*ent);\r\n*/#include \r\n#include \"vtPhysXAll.h\"\r\n\r\n#include \"pMathTools.h\"\r\n\r\nnamespace pMath\r\n{\r\n\r\nVxQuaternion getFromStream(NxQuat source)\r\n{\r\n\r\n\tVxQuaternion result;\r\n\r\n\tresult.x = source.x;\r\n\tresult.y = source.z;\r\n\tresult.z = source.y;\r\n\tresult.w = source.w;\r\n\r\n\treturn result;\r\n\r\n\r\n}\r\nVxVector getFromStream(NxVec3 source)\r\n{\r\n\r\n\tVxVector result;\r\n\tresult.x = source.x;\r\n\tresult.y = source.z;\r\n\tresult.z = source.y;\r\n\treturn result;\r\n\r\n}\r\n\r\n\r\nNxQuat getFrom(VxQuaternion source)\r\n{\r\n\tNxQuat result;\r\n\tresult.setx(-source.x);\r\n\tresult.sety(-source.y);\r\n\tresult.setz(-source.z);\r\n\tresult.setw(source.w);\r\n\treturn result;\r\n}\r\n VxQuaternion getFrom(NxQuat source)\r\n{\r\n\r\n\tVxQuaternion result;\r\n\tsource.getXYZW(result.v);\r\n\tresult.x = -result.x;\r\n\tresult.z = -result.z;\r\n\tresult.y = -result.y;\r\n\treturn result;\r\n}\r\n\r\n}\r\n\r\n/*\n * Tcp4u v 3.31 Last Revision 27/06/1997 3.30\n *\n *===========================================================================\n *\n * Project: Tcp4u, Library for tcp protocol\n * File: http4u_url.c\n * Purpose: everything which deals with URLs\n *\n *===========================================================================\n *\n * This software is Copyright (c) 1996-1998 by and \n *\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Library General Public\n * License as published by the Free Software Foundation; either\n * version 2 of the License, or (at your option) any later version.\n * \n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Library General Public License for more details.\n * \n * You should have received a copy of the GNU Library General Public\n * License along with this library; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 02111-1307, USA.\n *\n *\n * If you make modifications to this software that you feel\n * increases it usefulness for the rest of the community, please\n * email the changes, enhancements, bug fixes as well as any and\n * all ideas to me. This software is going to be maintained and\n * enhanced as deemed necessary by the community.\n *\n *\n * ()\n */\n\n\n#include \"build.h\"\n\n\n#define SLASH '/'\n#define PERIOD ':'\n#define HTTP_SERVICE \"http\"\n#define HTTP_PORT 80\n\n\n/* ------------------------------------------------------------------------- */\n/* HttpIsValidURL: Retourne TRUE si l'URL est valide. De plus les differents */\n/* composants de l'URL sont retournes a l'utilisateur */\n/* ------------------------------------------------------------------------- */\n\nBOOL API4U HttpIsValidURL \n (LPCSTR szURL, unsigned short far *lpPort, \n LPSTR szService, int uServiceSize,\n LPSTR szHost, int uHostSize,\n LPSTR szFile, int uFileSize )\n{\nLPCSTR p, q;\nint ServerLength;\n\n Tcp4uLog (LOG4U_HIPROC, \"HttpIsValidURL\");\n\n szHost[0]=0;\n /* default service : HTTP */\n Strcpyn (szService, HTTP_SERVICE, uServiceSize);\n\n /* if URL begins with \"service:\" do the job then forget it */\n p = Tcp4uStrIStr (szURL, \"://\");\n if (p!=NULL)\n {\n Strcpyn (szService, szURL, min ((int) (p - szURL + 1), uServiceSize) );\n szURL = p+1;\n }\n /* The same if URL begins with \"//\" */\n if (szURL[0]==SLASH && szURL[1]==SLASH) szURL+=2;\n\n /* URL is now either \"Host:Port/File\" or \"Host/File\" */\n for (p=szURL ; *p!=0 && *p!=SLASH ; p++); if (*p==0) p=NULL;\n if (szFile!=NULL) Strcpyn (szFile, p==NULL ? \"/\" : p, uFileSize); \n \n /* search for port which should be before File */\n if (p==NULL) p = szURL + Strlen(szURL) - 1; /* last character */\n for (q=p ; q>szURL && *q!=':' ; q--);\n if (q==szURL) q=NULL; /* -> : not found */\n *lpPort = q==NULL ? HTTP_PORT : Tcp4uAtoi (q+1);\n \n /* Host is to be copied */\n ServerLength = p==NULL ? Strlen (szURL) :\n (q==NULL ? (p-szURL) : (q-szURL) ); \n Strcpyn (szHost, szURL, min (ServerLength+1, uHostSize));\n \n Tcp4uLog (LOG4U_HIEXIT, \"HttpIsValidURL\");\nreturn szHost[0]!=0; /* rejects if no host specified otherwise accepts anything */\n} /* HttpIsValidURL */\n\n\n#ifdef TEST\nmain (int argc, char *argv[])\n{\nchar szService[10], szHost[10], szFichier[30]; /* short string to test limits */\nunsigned short usPort;\nint Rc;\n\n /* ------------------------------init */\n memset (szService, 0, sizeof szService); \n memset (szHost, 0, sizeof szHost); \n memset (szFichier, 0, sizeof szFichier); \n usPort = -1;\n /* ------------------------------init */\n\n Rc=HttpIsValidURL(argv[1], &usPort, szService, 10, szHost, 10, szFichier, 30);\n\n printf (\"l'URL <%s> est-elle valide ? .... %s\\n\", \n argv[1], Rc ? \"oUi\" : \"Non\");\n {\n printf (\"Port : %d\\n\", usPort);\n printf (\"Serveur : <%s>\\n\", szHost);\n printf (\"Service : <%s>\\n\", szService);\n printf (\"Fichier : <%s>\\n\", szFichier);\n }\n}\n#endif\n"},"directory_id":{"kind":"string","value":"6ec31b9f564cf79640f74e87c08f98fff0e49d58"},"languages":{"kind":"list like","value":["Makefile","C#","XML","C","INI","CMake","Logos","Batchfile","Rascal","Text","Python","C++","Lua"],"string":"[\n \"Makefile\",\n \"C#\",\n \"XML\",\n \"C\",\n \"INI\",\n \"CMake\",\n \"Logos\",\n \"Batchfile\",\n \"Rascal\",\n \"Text\",\n \"Python\",\n \"C++\",\n \"Lua\"\n]"},"num_files":{"kind":"number","value":795,"string":"795"},"repo_language":{"kind":"string","value":"Makefile"},"repo_name":{"kind":"string","value":"gbaumgart/vt"},"revision_id":{"kind":"string","value":"d1a0b0afa5b1500eee6dfe5191870868f24135f8"},"snapshot_id":{"kind":"string","value":"714dcfe12642556631cc42064b88f095778cd91e"}}},{"rowIdx":9912,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"jonnathanpena/BluOrk_Landing/src/app/providers/url.providers.ts\nimport { Injectable } from '@angular/core';\n\n@Injectable()\nexport class ULRProvider {\n\n public dominio: String = 'http://www.hotspotg.com/bluork/api/';\n\n /* USERS */\n public getAllUsers() {\n return this.dominio + 'users/getAll.php';\n }\n\n public getUserByEmail() {\n return this.dominio + 'users/getByEmail.php';\n }\n\n public getUserById() {\n return this.dominio + 'users/getById.php';\n }\n\n public insertUser() {\n return this.dominio + 'users/insert.php';\n }\n\n public updateUser() {\n return this.dominio + 'users/update.php';\n }\n\n public updatePassword() {\n return this.dominio + 'users/cambiarClave.php';\n }\n /* END USERS */\n\n}\n/src/app/login/login.component.ts\nimport { Component, OnInit} from '@angular/core';\nimport notify from 'devextreme/ui/notify';\n\nimport { LoginProvider } from './login.providers';\n\nimport {\n AuthService,\n FacebookLoginProvider,\n GoogleLoginProvider\n} from 'angular-6-social-login';\n\n@Component({\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.scss']\n})\n\nexport class LoginComponent implements OnInit {\n usuario: any;\n guardando: boolean;\n\n constructor(\n private services: LoginProvider,\n private socialAuthService: AuthService\n ) {}\n\n ngOnInit() {\n this.usuario = {\n email_users: '',\n clave: '',\n remember: 0\n };\n this.guardando = false;\n /*this.services.allUsers().subscribe((response: Response) => {\n console.log('respuesta', response);\n });*/\n }\n\n login(e) {\n e.preventDefault();\n this.services.userByEmail(this.usuario).subscribe(response => {\n if (response['data'].length > 0) {\n if (response['data'][0]['password_users'] === this.usuario.clave) {\n console.log('puede ingresar');\n } else {\n notify('Usuario y/o Clave no coinciden', 'error', 2000);\n }\n } else {\n notify('Usuario no registrado', 'error', 2000);\n this.cancelar();\n }\n });\n }\n\n cancelar() {\n this.ngOnInit();\n }\n\n remember(e) {\n if (this.usuario.remember === 0) {\n this.usuario.remember = 1;\n } else {\n this.usuario.remember = 0;\n }\n }\n\n public socialSignIn(socialPlatform: string) {\n let socialPlatformProvider;\n if (socialPlatform === 'facebook') {\n socialPlatformProvider = FacebookLoginProvider.PROVIDER_ID;\n } else if (socialPlatform === 'google') {\n socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID;\n }\n this.socialAuthService.signIn(socialPlatformProvider).then(\n (userData) => {\n console.log(socialPlatform + ' sign in data : ' , userData);\n // Now sign-in with userData\n // ...\n }\n );\n }\n}\n/src/app/signup/signup.component.module.ts\nimport { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { Routes, RouterModule } from '@angular/router';\n\nimport { SignUpRoutes } from './signup.routing';\nimport { SignUpComponent } from './signup.component';\n\nimport { ULRProvider } from '../providers/url.providers';\nimport { SignUpProvider } from './signup.providers';\n\nimport {\n DxTextBoxModule,\n DxValidatorModule,\n DxValidationSummaryModule,\n DxButtonModule\n} from 'devextreme-angular';\n\n@NgModule({\n imports: [\n CommonModule,\n RouterModule.forChild(SignUpRoutes),\n FormsModule,\n DxTextBoxModule,\n DxValidatorModule,\n DxValidationSummaryModule,\n DxButtonModule\n ],\n declarations: [\n SignUpComponent\n ],\n providers: [\n ULRProvider,\n SignUpProvider\n ]\n})\n\nexport class SignUpModule {}\n/src/app/signup/signup.component.ts\nimport { Component, OnInit} from '@angular/core';\nimport notify from 'devextreme/ui/notify';\n\nimport { SignUpProvider } from './signup.providers';\n\n@Component({\n templateUrl: './signup.component.html',\n styleUrls: ['./signup.component.scss']\n})\n\nexport class SignUpComponent implements OnInit {\n usuario: any;\n guardando: boolean;\n\n constructor(\n private services: SignUpProvider\n ) {}\n\n ngOnInit() {\n this.usuario = {\n firstName_users: '',\n lastName_users: '',\n email_users: '',\n password_users: '',\n confirme: ''\n };\n this.guardando = false;\n /*this.services.allUsers().subscribe((response: Response) => {\n console.log('respuesta', response);\n });*/\n }\n\n signup(e) {\n e.preventDefault();\n this.guardando = true;\n if (this.usuario.password_users !== this.usuario.confirme) {\n this.usuario.password_users = '';\n this.usuario.confirme = '';\n notify('Las claves no coinciden', 'error', 2000);\n this.guardando = false;\n } else {\n this.consultaExistencia();\n }\n }\n\n consultaExistencia() {\n this.services.userByEmail(this.usuario).subscribe(\n response => this.insert(response)\n );\n }\n\n insert(response) {\n if (response.data.length > 0) {\n notify('Email ya registrado', 'error', 2000);\n } else {\n this.services.insertUser(this.usuario).subscribe(resp => this.postInsert(resp));\n }\n }\n\n postInsert(response) {\n if (response > 0) {\n notify('Usuario registrado exitosamente', 'success', 2000);\n } else {\n notify('Algo malo sucedió, por favor, intente nuevamente', 'error', 2000);\n }\n this.cancelar();\n }\n\n cancelar() {\n this.usuario = {\n firstName_users: '',\n lastName_users: '',\n email_users: '',\n password_users: '',\n confirme: ''\n };\n this.guardando = false;\n }\n}\n/src/app/signup/signup.providers.ts\nimport { ULRProvider } from '../providers/url.providers';\nimport { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { HttpHeaders } from '@angular/common/http';\n\n@Injectable()\nexport class SignUpProvider {\n httpOptions: any = {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json',\n 'Authorization': 'my-auth-token'\n })\n };\n\n constructor(\n private urlProvider: ULRProvider,\n private http: HttpClient\n ) {}\n\n public allUsers() {\n return this.http.get(this.urlProvider.getAllUsers());\n }\n\n public userByEmail(objeto: any) {\n return this.http.post(this.urlProvider.getUserByEmail(), JSON.stringify(objeto), this.httpOptions);\n }\n\n public userById(objeto: any) {\n return this.http.post(this.urlProvider.getUserById(), JSON.stringify(objeto), this.httpOptions);\n }\n\n public insertUser(objeto: any) {\n return this.http.post(this.urlProvider.insertUser(), JSON.stringify(objeto), this.httpOptions);\n }\n\n public updateUser(objeto: any) {\n return this.http.post(this.urlProvider.updateUser(), JSON.stringify(objeto), this.httpOptions);\n }\n\n}\n"},"directory_id":{"kind":"string","value":"373d4353c4951031a59a3dccc7898e0cdc87de60"},"languages":{"kind":"list like","value":["TypeScript"],"string":"[\n \"TypeScript\"\n]"},"num_files":{"kind":"number","value":5,"string":"5"},"repo_language":{"kind":"string","value":"TypeScript"},"repo_name":{"kind":"string","value":"jonnathanpena/BluOrk_Landing"},"revision_id":{"kind":"string","value":"22a875b0cc73835f5554a13169208697947150cf"},"snapshot_id":{"kind":"string","value":"5c99488c8fb200d76e5e4dafde97185d6569e903"}}},{"rowIdx":9913,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"$error:#df3c31;\n\np {\n font-size: 20px;\n}\n.circulo {\n padding-top: 25px;\n padding-left: 25px;\n height:100px;\n width:100px;\n border-radius:100px;\n border: 2px solid $error;\n\n mat-icon {\n font-size: 45px;\n color: $error !important;\n }\n}$light:#b8b6b4;\n$dark: rgb(15, 18, 20);\n\n.borderless td, .borderless th {\n border: none;\n}\nselect {\n background-color: $dark !important;\n color: $light !important;\n border: 2px solid $dark !important;\n}\n\n.basic {\n color: #ffffff;\n}\n.gold {\n color: rgb(209, 149, 71);\n}\n\n.silver {\n color: rgb(143, 142, 142);\n}\n\n.bronce {\n color: #946b41;\n}\n\n.gold-b {\n background-color: rgb(209, 149, 71);\n}\n\n.silver-b {\n background-color: rgb(146, 146, 146);\n}\n\n.bronce-b {\n background-color: #865829;\n}\n\ntr:hover {\n cursor: pointer;\n color: white !important;\n}\n\ntr {\n border: 2px solid #1e212b;\n}\n//Login - María\nvar pass = '';\nvar emailValido = '';\nvar emailInvalido = '';\n\ndescribe('Login', () => {\n\n beforeEach(() => {\n // Abrimos la web\n cy.visit('https://pfg-survivor.netlify.app');\n // Click botón login\n cy.get('#btn-login').click();\n });\n\n it('Validación correcta', () => {\n // Submit del formulario\n cy.get('#login').submit();\n\n // Se muestran los mensajes de validación\n cy.contains('Este campo es obligatorio.');\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n it('Login correcto', () => {\n // Email\n cy.get('#email').type(emailValido).should('have.value', emailValido);\n\n // Contraseña\n cy.get('#pass').type(pass).should('have.value', pass);\n\n // Submit del formulario\n cy.get('#login').submit();\n\n // Espera 3s\n cy.wait(3000);\n \n // La url ahora debe contener /home\n cy.url().should('include', '/home');\n\n // Espera 3s\n cy.wait(3000);\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n it('Login incorrecto', () => {\n // Email\n cy.get('#email').type(emailInvalido).should('have.value', emailInvalido);\n\n // Contraseña\n cy.get('#pass').type(pass).should('have.value', pass);\n\n // Submit del formulario\n cy.get('#login').submit();\n\n // Alerta login incorrecto\n cy.contains('No se ha podido iniciar sesión. Revise sus credenciales.');\n\n // Espera 1s\n cy.wait(1000);\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n\n});//Login - María\nvar emailValido = '';\nvar emailInvalido = '';\n\ndescribe('Contraseña olvidada', () => {\n\n beforeEach(() => {\n // Abrimos la web\n cy.visit('https://pfg-survivor.netlify.app');\n // Click botón registro\n cy.get('#btn-login').click();\n // Click he olvidado la contraseña\n cy.get('#forgotPass').click();\n });\n\n it('Validación correcta', () => {\n // Submit del formulario\n cy.get('#passOlvidada').submit();\n\n // Se muestran los mensajes de validación\n cy.contains('Este campo es obligatorio.');\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n it('Correo enviado correctamente', () => {\n // Espera 1s\n cy.wait(1000);\n\n // Email\n cy.get('#email').type(emailValido).should('have.value', emailValido);\n\n // Submit del formulario\n cy.get('#passOlvidada').submit();\n\n // Alerta email enviado correctamente\n cy.contains('Se ha enviado un mensaje al correo electrónico para restablecer la contraseña.');\n\n // Espera 1s\n cy.wait(1000);\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n it('Email invalido', () => {\n // Espera 1s\n cy.wait(1000);\n\n // Email\n cy.get('#email').type(emailInvalido).should('have.value', emailInvalido);\n\n // Submit del formulario\n cy.get('#passOlvidada').submit();\n\n // Alerta email no registrado en la aplicación\n cy.contains('No hay ningún usuario registrado con el correo electrónico solicitado.');\n\n // Espera 1s\n cy.wait(1000);\n\n // Hacemos captura de pantalla\n cy.screenshot();\n });\n\n\n});import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFireAuthModule } from '@angular/fire/auth';\nimport { RouterTestingModule } from '@angular/router/testing';\nimport { environment } from 'src/environments/environment';\nimport { HomeComponent } from '../views/home/home.component';\nimport { HttpClientModule } from '@angular/common/http';\n\nimport { ChatService } from './chat.service';\n\ndescribe('ChatService', () => {\n let service: ChatService;\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [\n AngularFireModule.initializeApp(environment.firebaseConfig),\n AngularFireAuthModule,\n RouterTestingModule,\n HttpClientModule,\n RouterTestingModule.withRoutes([\n { path: 'home', component: HomeComponent }\n ])\n ],\n });\n service = TestBed.inject(ChatService);\n });\n\n it('should be created', () => {\n expect(service).toBeTruthy();\n }); \n\n});\nimport { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport firebase from 'firebase/app';\nimport 'firebase/firestore';\nimport { environment } from 'src/environments/environment';\nimport * as _ from \"lodash\";\nimport { AngularFireStorage } from '@angular/fire/storage';\nimport { Subject } from 'rxjs';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ChatService {\n msgEnviar = ''; // Variable ngmodel de enviar mensaje !!!Cambiar\n userAuth: any | null; // Usuario guardado en session local storage\n friends = []; // Lista de amigos\n messagesFriends = []; // Array de mensajes de tus amigos\n messagesWithFriend = []; // Array de mensajes de amigos ya convertidos: mensajes que se van mostrando en cada chat\n uidFriendSelected = ''; // Amigo seleccionado al cambiar de chat\n chatEnabled = false; // Se activa cuando se pulsa un chat, permite ver los mensajes\n listeningSnapsMessages = []; // Array que contiene los escuchas de los mensajes de los amigos para poder desactivarlos al cerrar sesión\n listeningFriends = []; // Array que contiene las escuchas de los amigos para poder desactivarlos al cerrar sesión\n messagesWithoutRead = []; // Mensajes de cada chat sin leer\n gotAllMessages: boolean = false; // Comprueba si ya se han obtenido todos los mensajes (sin leer) al recargar la página \n friendSelected: any; // Guarda toda la información el usuario seleccionado\n urlImg: any; // Guarda la url de la imagen del chat para mostrarla en el modal\n suggestedFriends = []; // Sugerencias de amigos \"Amigos de mis amigos\"\n sentRequested = []; // Array que contiene los uid que el usuario mandó solicitud\n msgsWithoutReadNotif = []; // Mensajes sin leer para las notificaciones del chat\n urlImgsChat = []; // URL de las imágenes que el usuario ha compartido con cada chat\n // Avisa al componente de que se ha recibido/enviado un nuevo mensaje para que el scroll baje automáticamente\n private countdownEndSource = new Subject();\n public countdownEnd$ = this.countdownEndSource.asObservable();\n nFriends: number = 0;\n tokenUser: string = '';\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CONSTRUCTOR~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n constructor(\n public firestorage: AngularFireStorage,\n private http: HttpClient) {\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Obtiene el usuario almacenado en localStorage, el cual se almacena al iniciar sesión\n */\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n this.tokenUser = this.userAuth['stsTokenManager']['accessToken'];\n }\n\n /**\n * Vacía los mensajes al cerrar sesión \n */\n cleanMessages() {\n this.messagesWithoutRead = [];\n this.msgsWithoutReadNotif = [];\n }\n\n /**\n * Marcar como conectado/desconectado\n * @param type 1: conectado / 2: desconectado\n */\n setStatusOnOff(type: number) {\n this.getUser();\n\n var status;\n if (type == 1) {\n status = 'online';\n } else {\n status = 'offline';\n }\n\n const url = environment.dirBack + \"updateStatus/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { 'user': this.userAuth, status: status }, { headers: headers })\n .subscribe(() => { });\n\n }\n\n /**\n * Suena mensaje dependiendo del tipo\n * @param type 1: mensaje sin leer / 2: borrar mensaje / 3: borrar chat\n */\n sonidito(type: number) {\n if (type == 1) {\n var audio = new Audio('../../assets/tonos/tono-mensaje.mp3');\n } else if (type == 2) {\n var audio = new Audio('../../assets/tonos/tono-delete.mp3');\n } else if (type == 3) {\n var audio = new Audio('../../assets/tonos/tono-delete-chat.mp3');\n }\n audio.play();\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GET FRIENDS & LISTEN FRIENDS~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Cargar amigos\n */\n getFriends() {\n this.friends = [];\n this.getUser();\n var contAmigos;\n // Obtener nº de amigos -> Si obtiene 0 vuelve a la vista si no pone en escucha los mensajes\n this.getFriendsData(this.userAuth.uid)\n .subscribe(\n (response) => {\n contAmigos = response['message'].length;\n if (contAmigos == 0) {\n this.gotAllMessages = true;\n return;\n }\n });\n\n this.listenFriends(contAmigos);\n\n }\n\n /**\n * Pone en escucha la lista de amigos\n */\n listenFriends(contAmigos) {\n this.getUser();\n var db = firebase.firestore();\n var query = db.collection('users').doc(this.userAuth.uid).collection('friends')\n\n var unsubscribe = query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach((change, index) => {\n // Obtener nº de amigos si se añade un nuevo amigo, no se pase a poner en esucucha a los mensajes hasta obtenerlos todos\n this.getFriendsData(this.userAuth.uid)\n .subscribe(\n (response) => {\n this.nFriends = response['message'].length;\n\n // Amigo borrado\n if (change.type === 'removed') {\n this.friends.forEach((user, i) => {\n if (user.uid == change.doc.id) {\n this.friends.splice(i, 1);\n }\n });\n this.closeChat();\n }\n // Cargando todos los amigos o nuevo amigo añadido\n else {\n\n // Obtener datos generales\n this.getUserData(change.doc.id)\n .subscribe(\n (responseUser) => {\n // Obtener fecha inicio de amistad\n this.getFriendShipData(change.doc.id)\n .subscribe(\n (responseDataFriend) => {\n\n const friend = {\n 'uid': responseUser['message'].uid,\n 'status': responseUser['message'].status,\n 'displayName': responseUser['message'].displayName,\n 'photoURL': responseUser['message'].photoURL,\n 'email': responseUser['message'].email,\n 'coins': responseUser['message'].coins,\n 'friendshipDate': responseDataFriend['message']\n }\n this.friends.push(friend);\n\n // Pone en escucha la información del amigo\n this.listenDataFriend(change.doc.id);\n\n // var pos = this.friends.length - 1;\n // this.listenFriendMessages(friend, pos);\n\n // Ultima pos del array -> obtiene los amigos sugeridos\n if (this.nFriends == index + 1) { \n this.getSuggestedFriends();\n this.stopListeningReListenFM(2);\n //this.listenFriendMessages();\n }else {\n // Se ha añadido un nuevo amigo\n if (contAmigos != this.nFriends) { \n this.getSuggestedFriends();\n this.stopListeningReListenFM(2);\n }\n }\n\n });\n });\n }\n\n });\n\n });\n });\n this.listeningFriends.push(unsubscribe);\n }\n\n\n /**\n * Obtiene información de amigos del usuario logeado (uids -> nº de amigos)\n * @returns \n */\n getFriendsData(userUID) {\n const url = `${environment.dirBack}getFriendsUID/${userUID}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.get(url, { headers: headers });\n }\n\n /**\n * Obtiene la información del amigo\n * @param userUID \n * @returns \n */\n getUserData(userUID) {\n const url = `${environment.dirBack}getUser/${userUID}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.get(url, { headers: headers });\n }\n\n /**\n * Obtiene la información de la relación de amistad (fecha de inicio)\n * @param userUID \n * @returns \n */\n getFriendShipData(userUID) {\n const url = `${environment.dirBack}getDataFriendship/${this.userAuth.uid}/${userUID}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.get(url, { headers: headers });\n }\n\n /**\n * Pone en escucha los datos del usuario\n * Para ver actualizado su estado (online/offline) entre otros\n * @param userUID \n */\n listenDataFriend(userUID) {\n var db = firebase.firestore();\n var unsubscribe = db.collection(\"users\").doc(userUID)\n .onSnapshot({\n includeMetadataChanges: true\n }, (doc) => {\n // Buscar usuario y actualizar sus datos\n this.friends.forEach(friend => {\n if (friend.uid == userUID) {\n friend.status = doc.data().status;\n friend.email = doc.data().email;\n friend.displayName = doc.data().displayName;\n friend.coins = doc.data().coins;\n }\n });\n });\n this.listeningFriends.push(unsubscribe);\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUGGESTED FRIENDS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Sugerencias de amigos \"Amigos de mis amigos\"\n */\n getSuggestedFriends() {\n this.suggestedFriends = [];\n if (this.friends.length == 0) { return };\n\n // Obtener peticiones de amistad enviadas\n this.getSentFriendsRequests()\n .subscribe(\n (response) => {\n this.sentRequested = response['message'];\n\n // Recorrer mis amigos para buscar los amigos de cada uno\n this.friends.forEach(friend => {\n // Obtener amigos de mi amigo\n this.getFriendsData(friend.uid)\n .subscribe(\n (response) => {\n var friendsUID = response['message'];\n // Buscamos si el usuario está entre los amigos del usuario \n friendsUID.forEach(user => {\n // Excluyendo al usuario logeado\n if (user.uid != this.userAuth.uid) {\n var encontrado = this.searchUserArrays(user);\n\n if (!encontrado) {\n // Se crea el amigo sugerido con datos vacíos ya que tarda en obtener los datos y al buscarlo en el array de\n // sugeridos todavía no lo encuentra y duplica la información\n const suggestedFriend = {\n 'uid': user.uid,\n 'status': '',\n 'displayName': '',\n 'photoURL': '',\n 'email': '',\n 'coins': '',\n 'relation': 'unknown'\n }\n this.suggestedFriends.push(suggestedFriend);\n var pos = this.suggestedFriends.length - 1;\n this.getUserData(user.uid)\n .subscribe(\n (response) => {\n this.suggestedFriends[pos].status = response['message'].status;\n this.suggestedFriends[pos].displayName = response['message'].displayName;\n this.suggestedFriends[pos].photoURL = response['message'].photoURL;\n this.suggestedFriends[pos].email = response['message'].email;\n this.suggestedFriends[pos].coins = response['message'].coins;\n });\n }\n }\n });\n });\n });\n });\n }\n\n /**\n * Busca a un usuario en la lista de amigos, sugeridos y peticiones enviadas\n * @param user \n * @returns true: encontrado / false: no encontrado\n */\n searchUserArrays(user) {\n var encontrado = false;\n // Recorro la lista de mis amigos\n this.friends.forEach(friend => {\n if (friend.uid == user.uid) {\n encontrado = true;\n }\n });\n // Recorro la lista de peticiones de amistad enviadas\n this.sentRequested.forEach(uidRequested => {\n if (uidRequested == user.uid) {\n encontrado = true;\n }\n });\n // Recorro la lista de sugerencias\n this.suggestedFriends.forEach(suggestedFriend => {\n if (suggestedFriend.uid == user.uid) {\n encontrado = true;\n }\n });\n return encontrado;\n }\n\n /**\n * Obtiene las peticiones de amistad enviadas del usuario logeado\n * Para que estos usuarios no aparezcan en recomendados\n * @returns \n */\n getSentFriendsRequests() {\n const url = `${environment.dirBack}getSentFriendsRequests/${this.userAuth.uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.get(url, { headers: headers });\n }\n\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~LISTEN FRIEND MESSAGES~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Pone en escucha los mensajes de todos los amigos\n * para recibir en tiempo real cualquier cambio\n */\n listenFriendMessages() {\n var db = firebase.firestore();\n this.getUser();\n this.messagesFriends = [];\n this.messagesWithoutRead = [];\n this.msgsWithoutReadNotif = [];\n var msgs = [];\n var msg: any;\n var read = true;\n\n if (this.friends.length > 0) {\n this.friends.forEach((friend, index) => {\n msgs = [];\n\n var query = db.collection('users').doc(this.userAuth.uid).collection('friends')\n .doc(friend.uid).collection('messages')\n .orderBy('timestamp', 'asc')\n\n var unsubscribe = query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Mensaje eliminado\n if (change.type === 'removed') {\n read = false;\n this.messagesFriends.forEach(user => {\n if (user.uid == friend.uid) {\n user.messages.forEach((message, index) => {\n if (message.id == change.doc.id) {\n console.log('Mensaje borrado: ', message.id);\n user.messages.splice(index, 1);\n // Si todavía no está leido -> Descontar uno del contador de mensajes sin leer\n if (message.isRead == false && message.uid == friend.uid) { // !!!\n this.messagesWithoutRead.forEach(msg => {\n if (msg.uid == friend.uid) {\n var n = msg.messages - 1;\n msg.messages = n;\n }\n });\n }\n }\n });\n }\n });\n }\n // Mensaje actualizado (marcado como leído)\n else if (change.type === 'modified') {\n read = false;\n this.messagesFriends.forEach(user => {\n if (user.uid == this.uidFriendSelected) {\n user.messages.forEach(message => {\n if (message.id == change.doc.id) {\n console.log('Mensaje actualizado: ', message.id);\n message.isRead = true;\n }\n });\n }\n });\n }\n // Mensaje añadido/recibido\n else {\n read = true;\n var h = '';\n h += change.doc.data().timestamp.toDate();\n // var year = h.substring(11, 15);\n\n const message = {\n 'id': change.doc.id,\n 'uid': change.doc.data().uid,\n 'displayName': change.doc.data().displayName,\n 'text': change.doc.data().text,\n 'imageURL': change.doc.data().imageURL,\n 'isRead': change.doc.data().isRead,\n 'storageRef': change.doc.data().storageRef,\n 'timestamp': h.substring(16, 21),\n 'day': h.substring(8, 11) + h.substring(4, 7)\n }\n msgs.push(message);\n msg = message;\n }\n });\n\n if (read) {\n this.addMessages(friend, msg, msgs);\n msgs = [];\n }\n\n // Obtener nº mensajes sin leer panel de notificaciones\n this.countMessagesWithoutRead(friend, index);\n\n // Ha terminado de obtener los mensajes\n if (this.friends.length - 1 == index && this.gotAllMessages == false) {\n console.log(this.msgsWithoutReadNotif);\n this.gotAllMessages = true;\n console.log('Termine');\n }\n\n });\n\n // Añadir al array para poder dejar de escuchar al cerrar sesión y q al volver a entrar no vuelva a escuchar y x lo tanto haya duplicidad de mensajes\n this.listeningSnapsMessages.push(unsubscribe);\n\n\n });\n }\n\n }\n\n /**\n * Añade un mensaje al array de mensajes totales y pendientes por leer\n * @param friend \n * @param msg \n * @param msgs \n */\n addMessages(friend, msg, msgs) {\n var db = firebase.firestore();\n var encontrado = false;\n\n // Cargar nuevo mensaje\n if (this.messagesFriends.length > 0) {\n this.messagesFriends.forEach(user => {\n // Cargar un solo mensaje al enviar o recibir\n if (user.uid == friend.uid || user.uid == this.userAuth.uid) {\n encontrado = true;\n user.messages[user.messages.length] = msg;\n // Recibes nuevo mensaje: evento para bajar scroll\n this.countdownEndSource.next();\n\n // Comprobar el chat que tengo abierto\n db.collection(\"users\").doc(this.userAuth.uid).get()\n .then((doc) => {\n // En caso de no tener el chat abierto añadimos un mensaje más sin leer\n if (doc.data().chatOpen != friend.uid) {\n if (msg.uid == friend.uid && msg.isRead == false) {\n this.messagesWithoutRead.forEach(msg => {\n if (msg.uid == friend.uid) {\n var n = msg.messages + 1;\n msg.messages = n;\n }\n });\n console.log('Mensajes sin leer:', this.messagesWithoutRead);\n this.sonidito(1);\n }\n }\n });\n }\n });\n }\n // Cargar mensajes inicialmente\n if (!encontrado) {\n //console.log('CARGAR MENSAJES INICIALES', friend.uid);\n //console.log(friend.uid, msgs);\n\n this.messagesFriends.push({\n 'uid': friend.uid,\n 'displayName': friend.displayName,\n 'photoURL': friend.photoURL,\n 'messages': msgs\n });\n console.log(this.messagesFriends);\n\n // Se suman aquellos mensajes sin leer y cuyo uid sea del amig\n var cont = 0;\n msgs.forEach(msg => {\n if (msg.uid == friend.uid && msg.isRead == false) {\n cont++;\n }\n });\n this.messagesWithoutRead.push({\n 'uid': friend.uid,\n 'displayName': friend.displayName,\n 'photoURL': friend.photoURL,\n 'messages': cont\n });\n\n // console.log('M LEER', this.messagesWithoutRead.length);\n\n }\n }\n\n /**\n * Array de mensajes lista de notificación\n * @param friend \n * @param index \n */\n countMessagesWithoutRead(friend, index) {\n //console.log('Hay mensajes sin leer', this.messagesWithoutRead);\n if (this.messagesWithoutRead[index]) {\n setTimeout(() => {\n if (this.messagesWithoutRead[index].messages > 0) {\n var enc = false;\n //console.log('Hay mensajes sin leer', this.messagesWithoutRead[index].uid);\n this.msgsWithoutReadNotif.forEach(msg => {\n if (msg.uid == this.messagesWithoutRead[index].uid) {\n enc = true;\n var ms = this.messagesWithoutRead[index].messages;\n msg.messages = ms++;\n }\n });\n if (!enc) {\n this.msgsWithoutReadNotif.push({ 'uid': friend.uid, 'messages': this.messagesWithoutRead[index].messages });\n }\n }\n //Buscarlo y borrarlo\n else {\n this.msgsWithoutReadNotif.forEach((msg, index2) => {\n if (msg.uid == this.messagesWithoutRead[index].uid) {\n this.msgsWithoutReadNotif.splice(index2, 1);\n }\n });\n }\n }, 500);\n }\n\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CHAT WITH FRIEND~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Abrir mensajes de un chat con amigo\n * En caso de que los mensajes no estén leídos los marca como leidos\n * @param friend amigo seleccionado\n */\n chatWith(friend: any) {\n this.messagesWithFriend = [];\n this.uidFriendSelected = friend.uid;\n this.friendSelected = friend;\n console.log('MENSAJES AMIGOS', this.messagesFriends);\n\n this.messagesFriends.forEach(user => {\n if (user.uid == friend.uid) {\n this.messagesWithFriend = user.messages;\n console.log('Mensajes del chat abierto: ', this.messagesWithFriend);\n\n // Marcar chat abierto\n this.setChatOpen(user.uid);\n\n // Poner en leído los mensajes del chat correspondiente\n this.messagesWithFriend.forEach(msg => {\n if (msg.uid != this.userAuth.uid && msg.isRead == false) {\n this.setMessagesRead(user.uid, msg.id);\n msg.isRead = true;\n }\n });\n\n // Marcar en leído en el array que notifica cuantos mensajes te faltan x leer\n this.messagesWithoutRead.forEach(msg => {\n if (msg.uid == user.uid) {\n msg.messages = 0;\n }\n });\n\n }\n });\n this.chatEnabled = true;\n }\n\n /**\n * Guardar el chat que tiene el usuario abierto\n * @param uidFriend \n */\n setChatOpen(uidFriend) {\n const url = `${environment.dirBack}setChatOpen/${this.userAuth.uid}/${uidFriend}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { headers: headers })\n .subscribe(() => { });\n }\n\n /**\n * Marca en leído el mensaje en ambos usuarios\n * @param uidFriend \n * @param idMsg \n */\n setMessagesRead(uidFriend, idMsg) {\n const url = `${environment.dirBack}setMessagesRead/${this.userAuth.uid}/${uidFriend}/${idMsg}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { headers: headers })\n .subscribe(() => { });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SEND MESSAGE TO FRIEND~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Enviar mensaje al amigo cuyo chat tienes abierto\n */\n sendMessageFriend() {\n var msg = this.msgEnviar;\n this.msgEnviar = '';\n\n const url = `${environment.dirBack}sendMessage/${this.userAuth.uid}/${this.uidFriendSelected}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { 'user': this.userAuth, 'message': msg }, { headers: headers })\n .subscribe(\n (response) => {\n var msgid = response['message'];\n this.checkUserChat(msgid);\n });\n }\n\n\n /**\n * Comprueba si el usuario tiene el chat abierto, en caso de tenerlo\n * marca los mensajes como leídos\n * @param msgid \n */\n checkUserChat(msgid: any) {\n const url = `${environment.dirBack}checkUserChat/${this.userAuth.uid}/${this.uidFriendSelected}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n var open = response['message'];\n if (open) {\n this.setMessagesRead(this.uidFriendSelected, msgid);\n }\n });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SEND IMAGE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Enviar imágen en un chat\n * @param event \n */\n sendImg(event) {\n var file = event.target.files[0];\n var imgName = Math.floor(Math.random() * 100000000);\n var filePathUser = `images/${this.userAuth.uid}/${this.uidFriendSelected}/${imgName}`;\n var filePathFriend = `images/${this.uidFriendSelected}/${this.userAuth.uid}/${imgName}`;\n\n // Subir imagen storage loged user\n this.firestorage.ref(filePathUser).put(file).then(fileSnapshot => {\n fileSnapshot.ref.getDownloadURL()\n .then(url => {\n // Añadir firestore loged user\n this.sendImgFriend(this.userAuth, this.uidFriendSelected, url, imgName)\n .subscribe(\n (response) => {\n var msgid = response['message'];\n\n // Subir imagen storage friend\n this.firestorage.ref(filePathFriend).put(file).then(fileSnapshot => {\n fileSnapshot.ref.getDownloadURL()\n .then(url => {\n // Añadir firestore friend\n this.sendImgWithId(msgid, this.userAuth, this.uidFriendSelected, url, imgName)\n .subscribe(() => {\n // Comprobar chat abierto marcar leídos\n this.checkUserChat(msgid);\n });\n });\n });\n });\n });\n });\n }\n\n /**\n * Enviar imagen a amigo\n * @param emisor \n * @param receptorUID \n * @param url \n * @param nombreImg \n * @returns \n */\n sendImgFriend(emisor: any, receptorUID: any, urlPhoto: string, namePhoto: any) {\n const url = `${environment.dirBack}sendImgFriend/${emisor.uid}/${receptorUID}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.put(url, { 'user': emisor, 'urlPhoto': urlPhoto, 'namePhoto': namePhoto }, { headers: headers });\n }\n\n /**\n * Enviar imagen a amigo estableciendole el id al mensaje para que sea el mismo en ambos mensajes\n * @param id \n * @param emisor \n * @param receptorUID \n * @param url \n * @param nombreImg \n * @returns \n */\n sendImgWithId(id: string, emisor: any, receptorUID: any, urlPhoto: string, namePhoto: any) {\n const url = `${environment.dirBack}sendImgFriendId/${emisor.uid}/${receptorUID}/${id}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.put(url, { 'user': emisor, 'urlPhoto': urlPhoto, 'namePhoto': namePhoto }, { headers: headers });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DELETE MESSAGES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Elimina un mensaje\n * @param message mensaje seleccionado para borrar\n * @param type 1: eliminar para mi // 2: eliminar para todos\n */\n deleteMsgs(message: any, type: number) {\n this.sonidito(2);\n\n // Eliminar para mi\n this.deleteMessages(this.userAuth.uid, this.uidFriendSelected, message);\n\n // Eliminar para todos\n if (type == 2) {\n this.deleteMessages(this.uidFriendSelected, this.userAuth.uid, message);\n }\n }\n\n /**\n * Elimina un mensaje del chat, en el caso que tenga foto asociada la\n * elimina también del storage\n * @param uidEmisor \n * @param uidReceptor \n * @param message \n */\n deleteMessages(uidEmisor: string, uidReceptor: string, message: any) {\n var photoName = null;\n if (message.storageRef) {\n photoName = message.storageRef;\n }\n\n const url = `${environment.dirBack}deleteMessage/${uidEmisor}/${uidReceptor}/${message.id}/${photoName}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.delete(url, { headers: headers })\n .subscribe(() => { });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CLOSE CHAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Cierra el chat abierto\n */\n closeChat() {\n this.getUser();\n this.uidFriendSelected = '';\n this.chatEnabled = false;\n var uidFriend = 'none';\n\n const url = `${environment.dirBack}setChatOpen/${this.userAuth.uid}/${uidFriend}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { headers: headers })\n .subscribe(\n (response) => {\n console.log('RESPONSE: ', response);\n });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~STOP LISTENING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Parar escucha de los mensajes del amigo. Este método se llama al cerrar sesión y \n * a la hora de cargar los amigos, así en caso de que se añada una nuevo, se reiniciará la escucha\n */\n stopListeningReListenFM(type: number) {\n this.listeningSnapsMessages.forEach(unsubscribe => {\n unsubscribe();\n });\n\n if(type == 2) {\n this.listenFriendMessages();\n }\n }\n\n /**\n * Parar escucha los amigos. Este método se llama al cerrar sesión\n */\n stopListeningFriends() {\n this.listeningFriends.forEach(unsubscribe => {\n unsubscribe();\n });\n }\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DELETE CHAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Vacia el chat del usuario logeado\n * @param deleteImg boolean: borrar imagenes tmb o no\n */\n deleteChat(deleteImg: boolean) {\n const url = `${environment.dirBack}deleteChat/${this.userAuth.uid}/${this.uidFriendSelected}/${deleteImg}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.delete(url, { headers: headers })\n .subscribe(\n (response) => {\n this.sonidito(3);\n console.log(response);\n });\n }\n\n\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GET IMAGES WITH USER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n /**\n * Cargar imágenes de un chat\n */\n getImagenesChat() {\n this.urlImgsChat = [];\n\n const url = environment.dirBack + \"getImgsChat\";\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.post(url, { 'uid': this.userAuth.uid, uidFriend: this.uidFriendSelected }, { headers: headers });\n\n }\n\n\n}\nFROM alpine:3.10\n\n# Variables de entorno\nENV HOME=/PFG-Survivor\nENV ANGULAR_CLI_VERSION=8.1.0\n\nRUN mkdir $HOME\nWORKDIR $HOME\n\n# Instalación node npm angular\nRUN apk add --update nodejs nodejs-npm\nRUN npm install -g @angular/cli@$ANGULAR_CLI_VERSION\n\nCOPY ./ /PFG-Survivor\n\n# Puertos\nEXPOSE 4200\n\n# Comandos de entrada cuando el contenedor se lanze \nCMD sh -c \"npm install; npm run start\"\n$online:#4caf50;\n$offline:#f44336;\n$fondo-chat: #21252e;\n$scroll: #50667e;\n\n.border-green {\n border: 2px solid $online;\n}\n.border-red {\n border: 2px solid $offline;\n}\n\n.morePhotos {\n cursor: pointer;\n height: 120px;\n display: block;\n text-align: center;\n}\n\nmat-icon {\n font-size: 40px;\n margin-right: 16px;\n margin-top: 20px;\n}\n\n.photos {\n max-height: 700px;\n overflow-y: auto;\n\n &::-webkit-scrollbar {\n width: 11px;\n }\n &::-webkit-scrollbar-track {\n background: $fondo-chat;\n border-radius: 20px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: $scroll;\n border-radius: 20px;\n }\n &::-webkit-scrollbar-thumb:hover {\n box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.2);\n }\n}export const environment = {\n production: true,\n firebaseConfig: {\n apiKey: \"\",\n authDomain: \"pfg-survivor-cd919.firebaseapp.com\",\n projectId: \"pfg-survivor-cd919\",\n storageBucket: \"pfg-survivor-cd919.appspot.com\",\n messagingSenderId: \"530404504797\",\n appId: \"1:530404504797:web:a2efd13f039584133dd734\",\n measurementId: \"G-XSHMWHFTZ6\"\n },\n SESSION_KEY_USER_AUTH: 'AUTH_USER_123456789',\n dirBack: 'https://survivorback.herokuapp.com/api/'\n};\nimport { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { LoginComponent } from '../login/login.component';\n\n@Component({\n selector: 'app-pass',\n templateUrl: './pass.component.html',\n styleUrls: ['./pass.component.scss']\n})\nexport class PassComponent implements OnInit {\n passOlvidada: FormGroup;\n msg: string = null;\n \n constructor(public ngmodal: NgbModal,\n public activeModal: NgbActiveModal,\n private formBuilder: FormBuilder,\n public auth: AuthService) {\n\n this.passOlvidada = this.formBuilder.group({\n email: ['', [Validators.required, Validators.email]]\n });\n }\n\n ngOnInit(): void {\n }\n\n get formPassOlvidada() { return this.passOlvidada.controls; }\n\n onSubmit() {\n if (this.passOlvidada.invalid) {\n return;\n }\n\n this.auth.sendPasswordResetEmail()\n .subscribe(\n (response) => {\n console.log('Correo enviado:', response['message']);\n this.auth.emailPass = '';\n this.activeModal.close();\n const modalRef = this.ngmodal.open(LoginComponent, { size: 'md' });\n modalRef.componentInstance.msgPassword = 'Se ha enviado un mensaje al correo electrónico para restablecer la contraseña.';\n },\n (error) => {\n var code = error['error']['message'].code;\n if (code === 'auth/too-many-requests') {\n this.msg = 'Hemos bloqueado todas las solicitudes de este dispositivo debido a una actividad inusual. Vuelve a intentarlo más tarde.'\n }else if(code === 'auth/user-not-found'){\n this.msg = 'No hay ningún usuario registrado con el correo electrónico solicitado.';\n }\n });\n }\n\n /**\n * Cierra modal contraseña olvidada y abre modal Login\n */\n backLogin(){\n this.activeModal.close();\n this.ngmodal.open(LoginComponent, { size: 'md' });\n }\n\n}\nimport { Injectable } from '@angular/core';\nimport { environment } from 'src/environments/environment';\nimport { AuthService } from './auth.service';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ShopService {\n items = [];\n\n constructor(private auth: AuthService,\n private http: HttpClient) {}\n\n /**\n * Recupera los items disponibles en la tienda\n */\n getItems() {\n const url = environment.dirBack + \"getItems\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n return this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.items = response['message'];\n // Si el usuario está logeado obtenemos si tiene el arma comprada o no\n if (this.auth.user) {\n console.log('Items user', this.auth.itemsLogedUser);\n this.items.forEach(itemShop => {\n this.auth.itemsLogedUser.forEach(myitem => {\n if (itemShop.id == myitem.id) {\n itemShop.owned = true;\n itemShop.obtainedDate = myitem.obtainedDate;\n }\n });\n });\n }\n });\n }\n\n /**\n * Comprueba si el usuario puede comprar o no el arma con las monedas que tiene\n * @param item \n * @returns \n */\n checkItem(item: any) {\n var canBuy = true;\n if (item.price > this.auth.user.coins) {\n canBuy = false;\n }\n return canBuy;\n }\n\n /**\n * Comprar item\n * @param item \n */\n buyItem(item: any) {\n const url = environment.dirBack + \"buyItem\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n return this.http.put(url, { 'user': this.auth.user, 'item': item }, { headers: headers })\n .subscribe(\n (response) => {\n console.log(response['message']);\n\n // Actualizar estado del item en la tienda\n this.items.forEach(itemShop => {\n if (itemShop.id == item.id) {\n itemShop.owned = true;\n itemShop.obtainedDate = 'Ahora mismo';\n }\n });\n\n // Añadir item & restar monedas\n this.auth.addItem(item);\n var coinsRestantes = this.auth.user.coins - item.price;\n this.auth.setCoins(coinsRestantes);\n\n });\n }\n\n}\nimport { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'filtroAmigos'\n})\nexport class FiltroAmigosPipe implements PipeTransform {\n\n transform(value: any, arg: any): any {\n if(arg === '') return value;\n const amigosFilter = [];\n for(const amigo of value) { \n var amigoF = amigo.displayName.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\").toLowerCase();\n var busqueda = arg.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\").toLowerCase();\n if(amigoF.indexOf(busqueda) > -1) {\n amigosFilter.push(amigo);\n }\n }\n return amigosFilter;\n }\n\n}\nimport { Component, OnInit } from '@angular/core';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { environment } from 'src/environments/environment';\nimport { DomSanitizer } from '@angular/platform-browser';\n\n@Component({\n selector: 'app-home',\n templateUrl: './home.component.html',\n styleUrls: ['./home.component.scss']\n})\nexport class HomeComponent implements OnInit {\n userAuth: any | null;\n cargar: boolean = false;\n pathDownload: string = '../../../assets/videogame/Survivor1.0.0.apk';\n \n constructor(public auth: AuthService,\n public friendService: FriendsService,\n public chat: ChatService,\n private _sanitizer: DomSanitizer) {\n\n this.getUser();\n console.log('CONSTRUCTOR HOME');\n if (this.auth.loginRecharge && this.userAuth != null) {\n this.chat.closeChat();\n this.auth.getUser();\n }\n\n }\n\n ngOnInit(): void { }\n ngAfterViewChecked() { }\n ngOnDestroy() { }\n\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n }\n\n getVideoIframe(url) {\n var video, results;\n\n if (url === null) {\n return '';\n }\n results = url.match('[\\\\?&]v=([^&#]*)');\n video = (results === null) ? url : results[1];\n \n return this._sanitizer.bypassSecurityTrustResourceUrl('https://www.youtube.com/embed/' + video);\n\n }\n\n\n}\nimport { Injectable } from '@angular/core';\nimport { AngularFireAuth } from '@angular/fire/auth';\nimport firebase from 'firebase/app';\nimport { Router } from '@angular/router';\nimport { environment } from 'src/environments/environment';\nimport { ChatService } from './chat.service';\nimport { FriendsService } from './friends.service';\nimport { RankingsService } from './rankings.service';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthService {\n // Variables\n // Login\n emailLogin = '';\n passLogin = '';\n // Registro\n emailRegistro = '';\n nombreRegistro = '';\n passRegistro = '';\n // Pass olvidada\n emailPass = '';\n // User\n user = null;\n loginRecharge: boolean = true;\n userAuth: any | null;\n providerId: string = null;\n itemsLogedUser = [];\n itemsUser = [];\n\n constructor(public auth: AngularFireAuth,\n private router: Router,\n private chat: ChatService,\n private friends: FriendsService,\n private rankings: RankingsService,\n private http: HttpClient) { }\n\n\n /**\n * Método que se llama desde los constructores de los componentes para en el caso de haber\n * recargado volver a establecer esta variable a false\n */\n setRechargeFalse() {\n this.loginRecharge = false;\n }\n\n addItem(item) {\n this.itemsLogedUser.push(item);\n }\n setCoins(coins) {\n this.user.coins = coins;\n }\n setPhoto(photoURL) {\n this.user.photoURL = photoURL;\n }\n setName(name) {\n this.user.displayName = name;\n }\n setEmail(email) {\n this.user.email = email;\n }\n\n getProviderID() {\n this.providerId = null;\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n this.providerId = this.userAuth.providerData[0].providerId;\n }\n\n /**\n * Método que llama a todos los métodos necesarios para obtener todos los datos para iniciar sesión\n * Amigos, escuchar mensajes de amigos, peticiones de amistad...\n * @param user \n */\n prepareLogin(user: any) {\n localStorage.setItem(environment.SESSION_KEY_USER_AUTH, JSON.stringify(user));\n this.updateUserData(user);\n this.loginRecharge = false;\n this.getItemsUser(1);\n this.friends.listenFriendsRequests();\n this.friends.listenSentFriendsRequests();\n this.chat.getFriends();\n this.rankings.stopListeningRankingsItems();\n this.rankings.setGetRankingsTrue();\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.router.navigate(['home']);\n }\n\n getItemsUser(type: number, uid?: string) {\n if (type == 1) {\n this.itemsLogedUser = [];\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n uid = this.userAuth.uid;\n } else {\n this.itemsUser = [];\n }\n\n const url = environment.dirBack + \"getItemsUser\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.post(url, { 'uid': uid }, { headers: headers })\n .subscribe(\n (response) => {\n var items = response['message'];\n\n if (type == 1) {\n this.itemsLogedUser = items;\n } else {\n this.itemsUser = items;\n }\n });\n }\n\n /**\n * Registro con email y contraseña\n * @returns \n */\n registro() {\n const url = environment.dirBack + \"registro\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n return this.http.post(url, { 'email': this.emailRegistro, 'pass': , 'name': this.nombreRegistro }, { headers: headers });\n }\n\n\n /**\n * Login con email y contraseña\n * @returns \n */\n login() {\n const url = environment.dirBack + \"login\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n return this.http.post(url, { 'email': this.emailLogin, 'pass': this.Login }, { headers: headers });\n }\n\n /**\n * Login con cuenta de Google\n */\n loginGoogle() {\n return this.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());\n }\n\n /**\n * Login con cuenta de Facebook\n */\n loginFacebook() {\n return this.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider());\n }\n\n /**\n * Añadir foto de Facebook al usuario cuando se logea por 1º vez\n * @param user \n */\n updateProfileFB(user) {\n if (user.user.photoURL.startsWith('https://graph.facebook.com/')) {\n user.user.updateProfile({\n photoURL: user.additionalUserInfo.profile['picture']['data']['url']\n }).then(() => {\n this.prepareLogin(user.user);\n });\n } else {\n this.prepareLogin(user.user);\n }\n }\n\n /**\n * Guardar usuario en base de datos\n * @param user \n */\n updateUserData(user: any) {\n const url = environment.dirBack + \"updateUserLogin\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.post(url, { 'user': user }, { headers: headers })\n .subscribe(\n (response) => {\n console.log('USER:', response);\n this.getUser();\n });\n }\n\n /**\n * Obtener los datos del usuario logeado\n */\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n var token = this.userAuth['stsTokenManager']['accessToken'];\n \n const url = `${environment.dirBack}getUser/${this.userAuth.uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${token}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.user = {\n 'uid': response['message'].uid,\n 'status': response['message'].status,\n 'displayName': response['message'].displayName,\n 'photoURL': response['message'].photoURL,\n 'email': response['message'].email,\n 'coins': response['message'].coins,\n }\n });\n }\n\n\n /**\n * Envía correo al email introducido donde se le permite cambiar la contraseña de la cuenta.\n */\n sendPasswordResetEmail() {\n const url = environment.dirBack + \"sendPasswordResetEmail\";\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n return this.http.post(url, { 'email': this.emailPass }, { headers: headers });\n }\n\n\n /**\n * Cerrar sesión cuenta\n */\n logout() {\n this.user = null;\n this.auth.signOut();\n this.setRechargeFalse();\n this.rankings.stopListeningRankingsItems();\n this.chat.setStatusOnOff(2);\n this.chat.stopListeningReListenFM(1);\n this.chat.stopListeningFriends();\n this.friends.stopListeningRequests();\n this.chat.closeChat();\n this.friends.resetSearchFriends();\n this.rankings.setGetRankingsTrue();\n this.chat.cleanMessages();\n this.limpiarFormularios();\n\n setTimeout(() => {\n localStorage.removeItem(environment.SESSION_KEY_USER_AUTH)\n }, 500);\n this.router.navigate(['home']);\n }\n\n /**\n * Método que limpia los inputs de los formularios login/registro/pass\n */\n limpiarFormularios() {\n this.emailLogin = '';\n this.nombreRegistro = '';\n this.passLogin = '';\n this.emailRegistro = '';\n this.passRegistro = '';\n }\n\n}\nimport { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\n\n@Component({\n selector: 'app-confirm-modal',\n templateUrl: './confirm-modal.component.html',\n styleUrls: ['./confirm-modal.component.scss']\n})\nexport class ConfirmModalComponent implements OnInit {\n @Input() public msg: any;\n @Output() confirm: EventEmitter = new EventEmitter();\n\n constructor(public ngmodal: NgbModal,\n public activeModal: NgbActiveModal) {\n }\n\n ngOnInit(): void {\n\n }\n\n accept() {\n const del = document.getElementById(\"deleteAll\") as HTMLInputElement;\n this.confirm.emit(del.checked);\n this.activeModal.close();\n }\n\n\n cancel() {\n this.activeModal.close();\n }\n\n}\nimport { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\nimport { AmigosComponent } from './views/amigos/amigos.component';\nimport { ComunidadComponent } from './views/comunidad/comunidad.component';\nimport { HomeComponent } from './views/home/home.component';\nimport { LoginComponent } from './views/login/login.component';\nimport { PerfilComponent } from './views/perfil/perfil.component';\nimport { RankingsComponent } from './views/rankings/rankings.component';\nimport { RegistroComponent } from './views/registro/registro.component';\nimport { TiendaComponent } from './views/tienda/tienda.component';\n\nconst routes: Routes = [\n /* { path: '', redirectTo: '/home', pathMatch: 'full' }, */\n {path: '', component: HomeComponent},\n {path: 'home', component: HomeComponent},\n {path: 'perfil', component: PerfilComponent},\n {path: 'login', component: LoginComponent},\n {path: 'registro', component: RegistroComponent},\n {path: 'tienda', component: TiendaComponent},\n {path: 'rankings', component: RankingsComponent},\n {path: 'amigos', component: AmigosComponent},\n {path: 'comunidad', component: ComunidadComponent}\n];\n\n@NgModule({\n imports: [RouterModule.forRoot(routes)],\n exports: [RouterModule]\n})\nexport class AppRoutingModule { }\nimport { Component, OnInit } from '@angular/core';\nimport { NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { ToastrService } from 'ngx-toastr';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { RankingsService } from 'src/app/services/rankings.service';\nimport { UserComponent } from '../user/user.component';\n\n@Component({\n selector: 'app-comunidad',\n templateUrl: './comunidad.component.html',\n styleUrls: ['./comunidad.component.scss']\n})\nexport class ComunidadComponent implements OnInit {\n palabraBuscar: string = '';\n\n constructor(public friendService: FriendsService,\n public chat: ChatService,\n public auth: AuthService,\n public toastr: ToastrService,\n public rankings: RankingsService,\n public ngmodal: NgbModal) {\n\n // Has recargado... cargar de nuevo amigos y mensajes asociados, peticiones de amistad\n if (this.auth.loginRecharge) {\n this.auth.setRechargeFalse();\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.auth.getUser();\n this.auth.getItemsUser(1);\n this.chat.getFriends();\n this.chat.closeChat();\n this.friendService.listenFriendsRequests();\n this.friendService.listenSentFriendsRequests();\n }\n }\n\n ngOnInit(): void { }\n\n ngAfterViewInit() {\n document.getElementById('buscarAmigoAgregar')\n .addEventListener('change', this.updateValue.bind(this));\n }\n\n\n updateValue(e) {\n this.palabraBuscar = e.target.value;\n this.friendService.searchFriends(e.target.value);\n }\n\n openProfileUser(user: any) {\n this.auth.getItemsUser(2, user.uid);\n const modalRef = this.ngmodal.open(UserComponent, { size: 'lg' });\n modalRef.componentInstance.user = user;\n modalRef.componentInstance.addUser = 'search';\n }\n\n}\nimport { Component, OnInit } from '@angular/core';\nimport { ToastrService } from 'ngx-toastr';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { RankingsService } from 'src/app/services/rankings.service';\nimport { ShopService } from 'src/app/services/shop.service';\nimport { environment } from 'src/environments/environment';\n\n@Component({\n selector: 'app-tienda',\n templateUrl: './tienda.component.html',\n styleUrls: ['./tienda.component.scss']\n})\nexport class TiendaComponent implements OnInit {\n userAuth: any | null;\n\n constructor(public auth: AuthService,\n public friendService: FriendsService,\n public chat: ChatService,\n public shop: ShopService,\n public rankings: RankingsService,\n public toastr: ToastrService) {\n\n this.getUser();\n\n if (this.auth.loginRecharge && this.userAuth != null) {\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.auth.setRechargeFalse();\n this.auth.getUser();\n this.auth.getItemsUser(1);\n this.chat.getFriends();\n this.chat.closeChat();\n this.friendService.listenFriendsRequests();\n this.friendService.listenSentFriendsRequests();\n }\n\n this.shop.getItems();\n }\n\n ngOnInit(): void {}\n\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n }\n\n /**\n * Comprar item\n * @param item \n */\n buyItem(item: any) {\n var canBuy;\n canBuy = this.shop.checkItem(item);\n if (canBuy) {\n // Confirmación comprar\n this.shop.buyItem(item);\n } else {\n this.toastr.warning(`No tienes suficientes monedas para comprar ${item.name}`);\n }\n }\n}\n
\n
\n

Tienda Survivor

\n

Saldo: {{auth.user.coins}}\n \"\"\n

\n
\n\n
\n
\n \n
\n \n
\n \"{{item.name}}\"\n
\n
\n \n
\n {{item.name}} \n
\n - {{item.price}}\n \"\"\n \n
\n
\n\n

{{item.description}}

\n \n \n \n
\n \n
\n En propiedad\n
\n \n
\n
\n Próximamente...\n
\n
\n
\n
\n
\n
\n
\n
@media only screen and (max-width:988px) {\n #videogame {\n height: 500px !important;\n margin-top: 15vh;\n }\n #trailer {\n width: 470px;\n }\n}import { Injectable } from '@angular/core';\nimport firebase from 'firebase/app';\nimport { environment } from 'src/environments/environment';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class RankingsService {\n getRankings: boolean = true;\n rankingCoins = [];\n lvlRankings = [];\n logedUserRankings = [];\n unsubscribeListeners = [];\n userAuth: any | null;\n logedUserRankingCoins = [];\n top = 7;\n\n constructor(private http: HttpClient) { }\n\n /**\n * Obtiene el usuario almacenado en localStorage, el cual se almacena al iniciar sesión\n */\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n }\n /**\n * Establecer false variable para obtener rankings\n */\n setGetRankingsFalse() {\n this.getRankings = false;\n }\n /**\n * Establecer a true variable para obtener rankings\n */\n setGetRankingsTrue() {\n this.getRankings = true;\n }\n\n //------------------------------------------------------------------------------------------------------\n //------------------------------------------------------------------------------------------------------\n //------------------------------------------------------------------------------------------------------\n\n /**\n * Obtener rankings de monedas\n */\n getRankingCoins() {\n console.log('Cargar ranking coins...');\n this.rankingCoins = [];\n this.getUser();\n\n var query = firebase.firestore().collection('users')\n .orderBy('coins', 'desc')\n .limit(this.top)\n\n var unsubscribe = query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Monedas han cambiado\n if (change.type === 'modified') {\n // Modificar en el array el valor\n this.rankingCoins.forEach(user => {\n if (user.uid == change.doc.id) {\n user.coins = change.doc.data().coins;\n }\n });\n // Re ordenar array por nº de monedas\n this.rankingCoins.sort(function (o1, o2) {\n if (o1.coins < o2.coins) {\n return 1;\n } else if (o1.coins > o2.coins) {\n return -1;\n }\n return 0;\n });\n\n }\n // Cargar ususario\n else if (change.type == 'added') {\n // Hay cambios en el podium monedas\n if (this.rankingCoins.length == this.top) {\n this.podiumCoinsChanges();\n }\n // Cargar usuario\n else {\n const user = {\n 'uid': change.doc.id,\n 'displayName': change.doc.data().displayName,\n 'email': change.doc.data().email,\n 'photoURL': change.doc.data().photoURL,\n 'coins': change.doc.data().coins,\n 'me': false\n }\n this.rankingCoins.push(user);\n if (this.userAuth != undefined) {\n if (change.doc.id == this.userAuth.uid) {\n user.me = true;\n }\n }\n\n }\n }\n\n });\n });\n this.unsubscribeListeners.push(unsubscribe);\n }\n\n /**\n * Cambios en el podium de monedas -> reordenar usuarios\n */\n podiumCoinsChanges() {\n this.getUser();\n var uid;\n\n if (this.userAuth == undefined || this.userAuth == null) {\n uid = null;\n } else {\n uid = this.userAuth.uid;\n }\n\n const url = `${environment.dirBack}getPodiumCoins/${uid}`;\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.rankingCoins = response['message'];\n });\n }\n\n /**\n * Obtener posicion del usuario logeado en ranking monedas\n */\n getPositionRankingCoins() {\n this.getUser();\n this.logedUserRankingCoins = [];\n var query = firebase.firestore().collection('users').orderBy('coins', 'desc')\n\n query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Obtener pos del usuario logeado\n if (change.doc.id === this.userAuth.uid) {\n var cont = 1;\n query.get()\n .then(doc => {\n doc.forEach(docU => {\n if (docU.id == change.doc.id) {\n this.logedUserRankingCoins[0] = cont;\n this.logedUserRankingCoins[1] = docU.data().coins;\n }\n cont++;\n });\n });\n }\n\n });\n });\n }\n\n //------------------------------------------------------------------------------------------------------\n //------------------------------------------------------------------------------------------------------\n //------------------------------------------------------------------------------------------------------\n\n /**\n * Obtener rankings de todos los niveles\n */\n getRankingsLevels() {\n this.lvlRankings = [];\n this.getUser();\n\n const url = `${environment.dirBack}getLevelRankings`;\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.lvlRankings = response['message'];\n\n // Ponemos en escucha los rankings de los niveles disponibles\n this.lvlRankings.forEach(level => {\n // QUERY\n var query = firebase.firestore().collection('rankings').doc(level.id).collection('users')\n .limit(this.top)\n\n // PUNTUACION\n this.listenPunctuationRanking(query, level);\n // ENEMIGOS\n this.listenEnemiesRanking(query, level);\n // TIEMPO\n this.listenTimeRanking(query, level);\n\n console.log(this.lvlRankings);\n\n });\n });\n }\n\n /**\n * Escucha del ranking (top) de los stats de puntuacion de un nivel\n * @param query \n * @param level \n */\n listenPunctuationRanking(query, level) {\n var unsubscribe = query.orderBy('punctuation', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n\n // Datos modificados del usuario\n if (change.type === 'modified') {\n // Update puntuacion\n this.lvlRankings[level.Nivel - 1].RankingPuntuacion.forEach(user => {\n if (user.uid == change.doc.id) {\n user.punctuation = change.doc.data().punctuation;\n }\n });\n }\n // Cargar ususario puntuacion\n else if (change.type == 'added') {\n // Cambios podium puntuacion\n if (this.lvlRankings[level.Nivel - 1].RankingPuntuacion.length == this.top) {\n this.podiumLevelsChanges(level, 1);\n }\n // Cargar usuario\n else {\n this.searchInfoUser(change.doc, level, 1);\n }\n }\n // Re-Ordenar ranking puntuacion\n this.lvlRankings[level.Nivel - 1].RankingPuntuacion.sort(function (o1, o2) {\n if (o1.punctuation < o2.punctuation) {\n return 1;\n } else if (o1.punctuation > o2.punctuation) {\n return -1;\n }\n return 0;\n });\n });\n });\n this.unsubscribeListeners.push(unsubscribe);\n }\n\n /**\n * Escucha del ranking (top) de los stats de enemigos matados de un nivel\n * @param query \n * @param level \n */\n listenEnemiesRanking(query, level) {\n var unsubscribe = query.orderBy('enemiesKilled', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n\n if (change.type === 'modified') {\n // Update Enemigos matados\n this.lvlRankings[level.Nivel - 1].RankingEnemigos.forEach(user => {\n if (user.uid == change.doc.id) {\n user.enemiesKilled = change.doc.data().enemiesKilled;\n }\n });\n }\n // Cargar ususario enemigos\n else if (change.type == 'added') {\n // Cambios podium enemigos\n if (this.lvlRankings[level.Nivel - 1].RankingEnemigos.length == this.top) {\n this.podiumLevelsChanges(level, 2);\n }\n // Cargar usuario\n else {\n this.searchInfoUser(change.doc, level, 2);\n }\n\n }\n // Re-Ordenar ranking enemigos \n this.lvlRankings[level.Nivel - 1].RankingEnemigos.sort(function (o1, o2) {\n if (o1.enemiesKilled < o2.enemiesKilled) {\n return 1;\n } else if (o1.enemiesKilled > o2.enemiesKilled) {\n return -1;\n }\n return 0;\n });\n });\n });\n this.unsubscribeListeners.push(unsubscribe);\n }\n\n /**\n * Escucha del ranking (top) de los stats de tiempo sobrevivido de un nivel\n * @param query \n * @param level \n */\n listenTimeRanking(query, level) {\n var unsubscribe = query.orderBy('time', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n\n if (change.type === 'modified') {\n // Update Tiempo aguantado\n this.lvlRankings[level.Nivel - 1].RankingTiempo.forEach(user => {\n if (user.uid == change.doc.id) {\n user.time = change.doc.data().time;\n }\n });\n }\n // Cargar ususario tiempo\n else if (change.type == 'added') {\n // Cambios podium tiempo\n if (this.lvlRankings[level.Nivel - 1].RankingTiempo.length == this.top) {\n this.podiumLevelsChanges(level, 3);\n }\n // Cargar usuario\n else {\n this.searchInfoUser(change.doc, level, 3);\n }\n }\n // Re-Ordenar ranking tiempo\n this.lvlRankings[level.Nivel - 1].RankingTiempo.sort(function (o1, o2) {\n if (o1.time < o2.time) {\n return 1;\n } else if (o1.time > o2.time) {\n return -1;\n }\n return 0;\n });\n\n });\n });\n this.unsubscribeListeners.push(unsubscribe);\n }\n\n /**\n * Crea usuario con todos sus datos\n * @param userD infor usuario\n * @param doc pos array niveles\n * @param type 1: puntuacion / 2: enemigos / 3: tiempo\n */\n searchInfoUser(userD: any, level: any, type: number) {\n var uid = userD.id.trim();\n const user = {\n 'uid': uid,\n 'enemiesKilled': userD.data().enemiesKilled,\n 'punctuation': userD.data().punctuation,\n 'time': userD.data().time,\n 'photoURL': '',\n 'displayName': '',\n 'coins': '',\n 'email': '',\n 'me': false\n }\n\n if (type == 1) {\n this.lvlRankings[level.Nivel - 1].RankingPuntuacion.push(user);\n } else if (type == 2) {\n this.lvlRankings[level.Nivel - 1].RankingEnemigos.push(user);\n } else if (type == 3) {\n this.lvlRankings[level.Nivel - 1].RankingTiempo.push(user);\n }\n\n // Buscar información del usuario para buscar su nombre, foto de perfil...\n const url = `${environment.dirBack}getUser/${userD.id}`;\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n user.photoURL = response['message'].photoURL;\n user.displayName = response['message'].displayName;\n user.coins = response['message'].coins;\n user.email = response['message'].email;\n\n if (this.userAuth != undefined) {\n if (userD.id == this.userAuth.uid) {\n user.me = true;\n }\n }\n });\n }\n\n /**\n * El podium de algun nivel ha cambiado, se reobtienen las posiciones\n * @param doc pos array niveles\n * @param type 1: puntuacion / 2: enemigos / 3: tiempo\n */\n podiumLevelsChanges(level: any, type: number) {\n // QUERY\n var query = firebase.firestore().collection('rankings').doc(level.id).collection('users')\n .limit(this.top)\n var orderBy = '';\n\n if (type == 1) {\n this.lvlRankings[level.Nivel - 1].RankingPuntuacion = [];\n orderBy = 'punctuation';\n }\n else if (type == 2) {\n this.lvlRankings[level.Nivel - 1].RankingEnemigos = [];\n orderBy = 'enemiesKilled';\n }\n else if (type == 3) {\n this.lvlRankings[level.Nivel - 1].RankingTiempo = [];\n orderBy = 'time';\n }\n\n query.orderBy(orderBy, 'desc').get()\n .then(docUser => {\n docUser.forEach(docU => {\n this.searchInfoUser(docU, level, type);\n });\n });\n\n }\n\n /**\n * Obtener posicion del usuario logeado en todos los rankings\n */\n getPositionRankings() {\n this.logedUserRankings = [];\n this.getUser();\n\n const url = `${environment.dirBack}getLevelRankings`;\n let headers = new HttpHeaders({ 'Content-Type': 'application/json' });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.logedUserRankings = response['message'];\n\n this.logedUserRankings.forEach(level => {\n // QUERY\n var query = firebase.firestore().collection('rankings').doc(level.id).collection('users');\n\n this.listenPunctuationGlobal(query, level);\n\n this.listenEnemiesGlobal(query, level);\n\n this.listenTimeGlobal(query, level);\n\n console.log(this.logedUserRankings);\n\n });\n });\n }\n\n /**\n * Escucha de todos los usuarios de los stats de puntuacion de un nivel\n * @param query \n * @param level \n */\n listenPunctuationGlobal(query, level) {\n query.orderBy('punctuation', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Obtener pos del usuario logeado\n if (change.doc.id == this.userAuth.uid) {\n var cont = 1;\n query.orderBy('punctuation', 'desc').get()\n .then(docUser => {\n docUser.forEach(docU => {\n if (docU.id == change.doc.id) {\n this.logedUserRankings[level.Nivel - 1].RankingPuntuacion[0] = cont;\n }\n cont++;\n });\n });\n this.logedUserRankings[level.Nivel - 1].RankingPuntuacion[1] = change.doc.data().punctuation;\n }\n });\n });\n }\n\n \n /**\n * Escucha de todos los usuarios de los stats de enemigos matados de un nivel\n * @param query \n * @param level \n */\n listenEnemiesGlobal(query, level) {\n query.orderBy('enemiesKilled', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Obtener pos del usuario logeado\n if (change.doc.id == this.userAuth.uid) {\n var cont = 1;\n query.orderBy('enemiesKilled', 'desc').get()\n .then(docUser => {\n docUser.forEach(docU => {\n if (docU.id == change.doc.id) {\n this.logedUserRankings[level.Nivel - 1].RankingEnemigos[0] = cont;\n }\n cont++;\n });\n });\n this.logedUserRankings[level.Nivel - 1].RankingEnemigos[1] = change.doc.data().enemiesKilled;\n }\n });\n });\n }\n\n \n /**\n * Escucha de todos los usuarios de los stats de tiempo sobrevivido de un nivel\n * @param query \n * @param level \n */\n listenTimeGlobal(query, level) {\n query.orderBy('time', 'desc')\n .onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Obtener pos del usuario logeado\n if (change.doc.id == this.userAuth.uid) {\n var cont = 1;\n query.orderBy('time', 'desc').get()\n .then(docUser => {\n docUser.forEach(docU => {\n if (docU.id == change.doc.id) {\n this.logedUserRankings[level.Nivel - 1].RankingTiempo[0] = cont;\n }\n cont++;\n });\n });\n this.logedUserRankings[level.Nivel - 1].RankingTiempo[1] = change.doc.data().time;\n }\n });\n });\n }\n\n /**\n * Dejar de escuchar los listeners para que no haya duplicidad de escucha\n */\n stopListeningRankingsItems() {\n this.unsubscribeListeners.forEach(unsubscribe => {\n unsubscribe();\n });\n }\n\n}\nimport { Component, OnInit } from '@angular/core';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { PerfilService } from 'src/app/services/perfil.service';\nimport { RankingsService } from 'src/app/services/rankings.service';\nimport { environment } from 'src/environments/environment';\n@Component({\n selector: 'app-rankings',\n templateUrl: './rankings.component.html',\n styleUrls: ['./rankings.component.scss']\n})\nexport class RankingsComponent implements OnInit {\n userAuth: any | null;\n rankingMonedas: boolean = true;\n stats: number = 0;\n ranking: any;\n\n constructor(public auth: AuthService,\n public perfilService: PerfilService,\n public friendService: FriendsService,\n public chat: ChatService,\n public rankings: RankingsService) {\n\n this.getUser();\n\n if (this.rankings.getRankings == true) {\n this.rankings.setGetRankingsFalse();\n this.rankings.getRankingCoins();\n this.rankings.getRankingsLevels();\n }\n\n if (this.auth.loginRecharge && this.userAuth != null) {\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.auth.setRechargeFalse();\n this.auth.getUser();\n this.auth.getItemsUser(1);\n this.chat.getFriends();\n this.chat.closeChat();\n this.friendService.listenFriendsRequests();\n this.friendService.listenSentFriendsRequests();\n }\n }\n\n ngOnInit(): void { }\n\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n }\n\n\n\n onChange(value: any) {\n if (value == 0) {\n this.rankingMonedas = true;\n } else {\n this.rankingMonedas = false;\n }\n\n this.rankings.lvlRankings.forEach(ranking => {\n if (value == ranking.Nivel) {\n this.ranking = ranking;\n }\n });\n }\n\n onChangeStats(value: any) {\n if (value == 0) {\n this.stats = 0;\n } else if (value == 1) {\n this.stats = 1;\n } else {\n this.stats = 2;\n }\n }\n\n}import { Component, Input, OnInit } from '@angular/core';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\n\n@Component({\n selector: 'app-user',\n templateUrl: './user.component.html',\n styleUrls: ['./user.component.scss']\n})\nexport class UserComponent implements OnInit {\n @Input() public user: any;\n @Input() public addUser: string;\n @Input() public msgs: string;\n profile: boolean = true;\n\n constructor(\n public ngmodal: NgbModal,\n public activeModal: NgbActiveModal,\n public friendService: FriendsService,\n public chat: ChatService,\n public auth: AuthService) {\n }\n\n ngOnInit(): void { }\n\n /**\n * Eliminar amigo\n * @param uid \n */\n deleteFriend(uid: string) {\n this.friendService.deleteFriend(uid);\n this.activeModal.close();\n }\n\n /**\n * Gestión peticiones de amistad\n * @param uid \n * @param type \n * 1: aceptar solicitud de amistad, \n * 2: denegar solicitud de amistad,\n * 3: enviar solicitud de amistad,\n * 4: cancelar envio solicitud de amistad\n */\n friendRequest(uid: string, type: number) {\n if (type == 1) {\n this.friendService.acceptFriendRequest(uid);\n } else if (type == 2) {\n this.friendService.deleteFriendRequest(uid);\n } else if (type == 3) {\n this.friendService.sendFriendRequest(uid);\n } else if (type == 4) {\n this.friendService.cancelFriendRequest(uid);\n }\n this.activeModal.close();\n }\n\n seePhotos() {\n this.profile = false;\n }\n\n seeProfile() {\n this.profile = true;\n }\n\n}\n//$fondo-chat: #275757;\n$fondo-chat: #21252e;\n$header-input: rgba(0,0,0,0.3);\n$mymsg: #F5F5F5;\n$othermsg: #82ccdd;\n\n$online:#4caf50;\n$offline:#f44336;\n\n.h-70 {\n height: 70vh;\n}\n\n.mat-menu-item .mat-icon-no-color, .mat-menu-item-submenu-trigger::after {\n color: #a5a5a5;\n}\n.circulo {\n height:10px;\n width:10px;\n border-radius:50px;\n}\n.badge {\n font-size: 12px;\n border-radius: 25px;\n padding: 6px 8px;\n background-color: #ac3027;\n}\n\n.circuloChat {\n padding-top: 25px;\n padding-left: 25px;\n height:100px;\n width:100px;\n border-radius:100px;\n \n mat-icon {\n font-size: 50px;\n }\n}\n\n.noFriends {\n height: 230px;\n mat-icon {\n font-size: 50px;\n }\n}\n\n.green {\n background: $online;\n}\n.border-green {\n border: 2px solid $online;\n}\n.red {\n background: $offline;\n}\n.border-red {\n border: 2px solid $offline;\n}\n.menuOP:hover {\n background: $fondo-chat;\n}\n\n.column-friends {\n max-height: 77vh;\n overflow-y: auto;\n\n .friendSelected {\n background: $fondo-chat;\n }\n\n .friend-description {\n color: white;\n padding: 10px 15px;\n display: flex;\n align-items: center;\n vertical-align: baseline;\n justify-content: center;\n transition: .3s ease;\n border-bottom: 1.5px solid $fondo-chat;\n img {\n width: 60px;\n height: 60px;\n border-radius: 40px;\n }\n .text {\n width: 80%;\n span {\n font-size: 20px;\n margin-left: 20px;\n }\n div span {\n font-size: 14px;\n color: rgba(255,255,255,0.6); \n }\n \n }\n \n &:hover {\n background: $fondo-chat;\n cursor: pointer; \n }\n \n }\n}\n\n\n.card { \n max-height: 87vh;\n min-height: 87vh;\n border: none;\n border-radius: 0px;\n\n .card-header {\n background-color: $header-input;\n position: relative;\n border-bottom: 0;\n \n .user_img {\n height: 70px;\n width: 70px;\n &:hover {\n cursor: pointer; \n }\n }\n \n .user_info {\n margin-top: auto;\n margin-bottom: auto;\n margin-left: 15px;\n & span {\n font-size: 20px;\n color: white;\n }\n & p {\n font-size: 12px;\n color: rgba(255,255,255,0.6);\n }\n }\n }\n \n .card-body {\n overflow-y: auto;\n \n .chat-bubble {\n padding: 10px 14px;\n margin: 10px 30px;\n border-radius: 13px;\n position: relative;\n animation: fadeIn 1s ease-in;\n word-break: break-all;\n \n &:after {\n content: '';\n position: absolute;\n top: 50%;\n width: 0;\n height: 0;\n border: 20px solid transparent;\n border-bottom: 0;\n margin-top: -10px;\n }\n \n &--left {\n background-color: $othermsg;\n .msg_time {\n min-width: 100px;\n position: absolute;\n left: 0;\n bottom: -19px;\n color: rgba(255,255,255,0.5);\n font-size: 12px;\n }\n &:after {\n left: 0;\n border-right-color: $othermsg;\n border-left: 0;\n margin-left: -20px;\n }\n }\n \n &--right {\n background-color: $mymsg;\n .msg_time_send { \n min-width: 100px;\n position: absolute;\n right:0;\n padding-left: 5px;\n bottom: -19px;\n color: rgba(255,255,255,0.5);\n font-size: 12px;\n }\n\n &:after {\n right: 0;\n border-left-color: $mymsg;\n border-right: 0;\n margin-right: -20px; \n }\n } \n }\n }\n\n .card-footer {\n border-radius: 0 0 15px 15px;\n border-top: 0;\n .attach_btn {\n border-radius: 15px 0 0 15px;\n background-color: $header-input;\n border:0;\n color: white;\n cursor: pointer;\n }\n .type_msg {\n background-color: $header-input;\n border:0 ;\n color:white;\n height: 60px;\n overflow-y: auto;\n &:focus{\n box-shadow:none;\n outline:0px;\n }\n }\n .send_btn {\n border-radius: 0 15px 15px 0;\n background-color: $header-input;\n border:0 ;\n color: white;\n cursor: pointer;\n }\n \n }\n}\n\nimg {\n align-self: center;\n\n}\n.img-chat {\n width: 400px;\n height: 300px;\n}\n\n@media only screen and (min-width:0px) and (max-width: 773px) {\n .display-none,\n .chat-bubble--left:after,\n .chat-bubble--right:after {\n display: none;\n }\n .img-chat {\n width: 280px;\n height: 260px;\n }\n .chat-bubble.chat-bubble--right.ml-auto,\n .chat-bubble.chat-bubble--left.mr-auto {\n margin: 0px;\n }\n\n .chat-bubble.chat-bubble--left.img-class,.chat-bubble.chat-bubble--right.img-class {\n background-color: transparent;\n padding: 0;\n img {\n border-radius: 20px;\n }\n } \n}\n\n@media only screen and (min-width:773px) and (max-width: 1179px) {\n .img-chat {\n width: 280px;\n height: 260px;\n }\n}\n\n\n@media only screen and (min-width:773px) {\n .noneSearch100 {\n display: none;\n }\n\n}import { FiltroAmigosPipe } from './filtro-amigos.pipe';\n\ndescribe('FiltroAmigosPipe', () => {\n it('create an instance', () => {\n const pipe = new FiltroAmigosPipe();\n expect(pipe).toBeTruthy();\n });\n});\nimport { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { ToastrService } from 'ngx-toastr';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { PerfilService } from 'src/app/services/perfil.service';\nimport { RankingsService } from 'src/app/services/rankings.service';\n\n@Component({\n selector: 'app-perfil',\n templateUrl: './perfil.component.html',\n styleUrls: ['./perfil.component.scss']\n})\nexport class PerfilComponent implements OnInit {\n msg: string = null;\n name: FormGroup;\n email: FormGroup;\n pass: FormGroup;\n enabledName: boolean = false;\n enabledEmail: boolean = false;\n enabledPass: boolean = false;\n hide1 = true;\n hide2 = true;\n\n constructor(public auth: AuthService,\n public perfilService: PerfilService,\n public toastr: ToastrService,\n public chat: ChatService,\n public friendService: FriendsService,\n private formBuilder: FormBuilder,\n private rankings: RankingsService) {\n\n this.name = this.formBuilder.group({\n name: ['', [Validators.required, Validators.minLength(3)]]\n });\n\n this.email = this.formBuilder.group({\n email: ['', [Validators.required, Validators.email]]\n });\n\n this.pass = this.formBuilder.group({\n password: ['', [Validators.required, Validators.minLength(6)]],\n confirmPassword: ['', [Validators.required, Validators.pattern]]\n });\n\n this.auth.getProviderID();\n\n // Has recargado... cargar de nuevo amigos y mensajes asociados, peticiones de amistad\n if (this.auth.loginRecharge) {\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.auth.setRechargeFalse();\n this.auth.getUser();\n this.auth.getItemsUser(1);\n this.chat.getFriends();\n this.chat.closeChat();\n this.friendService.listenFriendsRequests();\n this.friendService.listenSentFriendsRequests();\n }\n }\n\n ngOnInit(): void {\n }\n\n get formName() { return this.name.controls; }\n get formEmail() { return this.email.controls; }\n get formPass() { return this.pass.controls; }\n\n /**\n * Submit formulario cambiar nombre\n * @returns \n */\n updateName() {\n if (this.name.invalid) {\n return;\n }\n this.enableDisableUpdateName(2);\n this.perfilService.updateDisplayName(this.name.value.name);\n this.name.reset();\n }\n\n /**\n * Submit formulario cambiar email\n * @returns \n */\n updateEmail() {\n if (this.email.invalid) {\n return;\n }\n this.perfilService.updateEmail(this.email.value.email)\n .subscribe(\n (response) => {\n console.log('RESPONSE', response);\n this.toastr.success(`Correo electrónico actualizado`);\n this.auth.setEmail(this.email.value.email);\n this.enableDisableUpdateEmail(2);\n this.email.reset();\n },\n (error) => {\n var code = error['error']['message'].code;\n if (code === 'auth/requires-recent-login') {\n this.msg = 'Debes relogearte para poder cambiar el email.';\n } else if (code === 'auth/email-already-in-use') {\n this.msg = 'El email introducido ya está registrado';\n }\n });\n }\n\n /**\n * Submit formulario cambiar contraseña\n * @returns \n */\n updatePass() {\n if (this.pass.invalid) {\n return;\n }\n\n this.perfilService.updatePass(this.pass.value.password)\n .subscribe(\n (response) => {\n console.log('RESPONSE', response);\n this.toastr.success(`Contraseña actualizada`);\n this.enableDisableUpdatePass(2);\n this.pass.reset();\n },\n (error) => {\n console.log('Ha ocurrido un error actualizando la contraseña', error); \n });\n }\n\n\n /**\n * Activar o desactivar cambiar nombre\n * @param type 1: Activar | 2: Desactivar\n */\n enableDisableUpdateName(type: number) {\n if (type == 1) {\n this.enabledName = true;\n this.enabledPass = false;\n this.enabledEmail = false;\n } else {\n this.enabledName = false;\n }\n }\n\n /**\n * Activar o desactivar cambiar email\n * @param type 1: Activar | 2: Desactivar\n */\n enableDisableUpdateEmail(type: number) {\n if (type == 1) {\n this.enabledEmail = true;\n this.enabledPass = false;\n this.enabledName = false;\n } else {\n this.enabledEmail = false;\n this.msg = '';\n }\n }\n\n /**\n * Activar o desactivar cambiar contraseña\n * @param type 1: Activar | 2: Desactivar\n */\n enableDisableUpdatePass(type: number) {\n if (type == 1) {\n this.enabledPass = true;\n this.enabledEmail = false;\n this.enabledName = false;\n } else {\n this.enabledPass = false;\n this.msg = '';\n }\n }\n\n openFileSelection() {\n document.getElementById('file').click();\n }\n}\necho '*********************************************************'\necho '********************BUILDING IMAGE***********************'\necho '*********************************************************'\ndocker build -t meryjv00/angular_alpine:0.0.1 .\n\necho '*********************************************************'\necho '*******************STARTING CONTAINER********************'\necho '*********************************************************'\ndocker run -d --name PFG-Survivor -p 4200:4200 meryjv00/angular_alpine:0.0.1\n# DESARROLLO\n# -v $(pwd):/PFG-Survivor\n\necho '**********************************************************'\necho '********************APP READY*****************************'\necho '******************LOCALHOST:4200**************************'\necho '**********************************************************'\n\n# Volver a reejecutar docker aparece este error: 'can't stat '/home/maria/Escritorio/PFG-Survivor/.config''\n# Ejecutar:\n# sudo rm -rf .config\n# sudo rm -rf .npm\n# sudo rm -rf node_modules\n# Volver a lanzar init.sh\nimport { Component, OnInit, ViewChild, ElementRef, Output, EventEmitter } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { Subscription } from 'rxjs';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { ChatService } from 'src/app/services/chat.service';\nimport { FriendsService } from 'src/app/services/friends.service';\nimport { RankingsService } from 'src/app/services/rankings.service';\nimport { ConfirmModalComponent } from '../confirm-modal/confirm-modal.component';\nimport { UserComponent } from '../user/user.component';\n\n@Component({\n selector: 'app-amigos',\n templateUrl: './amigos.component.html',\n styleUrls: ['./amigos.component.scss']\n})\nexport class AmigosComponent implements OnInit {\n chatFriends: FormGroup;\n @ViewChild('scrollMe') private myScrollContainer: ElementRef;\n disableScrollDown = false;\n urlImg = '';\n filtroAmigo = '';\n // En esucha si se envian nuevos mensajes para que el scroll baje automáticamente\n @Output() onComplete = new EventEmitter();\n countdownEndRef: Subscription = null;\n\n constructor(public chat: ChatService,\n private formBuilder: FormBuilder,\n public auth: AuthService,\n public friends: FriendsService,\n public rankings: RankingsService,\n public ngmodal: NgbModal) {\n\n this.chatFriends = this.formBuilder.group({\n text: ['', [Validators.required]],\n });\n\n // Has recargado... cargar de nuevo amigos y mensajes asociados, peticiones de amistad\n if (this.auth.loginRecharge) {\n this.auth.getUser();\n this.rankings.getPositionRankings();\n this.rankings.getPositionRankingCoins();\n this.auth.setRechargeFalse();\n this.auth.getItemsUser(1);\n this.chat.getFriends();\n this.chat.closeChat();\n this.friends.listenFriendsRequests();\n this.friends.listenSentFriendsRequests();\n }\n\n }\n\n get formChat() { return this.chatFriends.controls; }\n\n ngOnInit(): void {\n this.countdownEndRef = this.chat.countdownEnd$.subscribe(() => {\n this.onComplete.emit();\n this.disableScrollDown = false;\n });\n }\n\n ngOnDestroy() {\n this.chat.urlImgsChat = [];\n }\n\n ngAfterViewChecked() {\n this.scrollToBottom();\n }\n\n onScroll() {\n let element = this.myScrollContainer.nativeElement\n let atBottom = element.scrollHeight - element.scrollTop === element.clientHeight\n if (this.disableScrollDown && atBottom) {\n this.disableScrollDown = false\n } else {\n this.disableScrollDown = true\n }\n }\n\n scrollToBottom(): void {\n if (this.disableScrollDown) {\n return\n }\n try {\n this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;\n } catch (err) { }\n }\n\n onSubmit() {\n if (this.chatFriends.invalid) {\n return;\n }\n this.chat.sendMessageFriend();\n }\n\n openFileSelection() {\n document.getElementById('file').click();\n }\n\n chatWith(friend) {\n this.disableScrollDown = false;\n this.chat.chatWith(friend);\n }\n\n enableScollDown() {\n this.disableScrollDown = false;\n }\n\n saveImgModal(urlImg: string) {\n this.urlImg = urlImg;\n }\n\n openProfileUser(user: any) {\n this.chat.getImagenesChat()\n .subscribe(\n (response) => {\n console.log(response['message']);\n this.chat.urlImgsChat = response['message'];\n const modalRef = this.ngmodal.open(UserComponent, { size: 'lg' });\n modalRef.componentInstance.user = user;\n modalRef.componentInstance.addUser = 'see';\n modalRef.componentInstance.msgs = this.chat.messagesWithFriend.length;\n\n },\n (error) => {\n console.log(error);\n }\n );\n\n }\n\n openConfirmModal() {\n const modalRef = this.ngmodal.open(ConfirmModalComponent, { size: 'xs' });\n modalRef.componentInstance.msg = `Eliminar archivos multimedia con ${this.chat.friendSelected.displayName}`;\n modalRef.componentInstance[\"confirm\"].subscribe((event: any) => {\n this.chat.deleteChat(event);\n });\n }\n\n\n}\nimport { Component, OnInit } from '@angular/core';\nimport { AuthService } from '../services/auth.service';\nimport { NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { LoginComponent } from '../views/login/login.component';\nimport { RegistroComponent } from '../views/registro/registro.component';\nimport { ChatService } from '../services/chat.service';\nimport { FriendsService } from '../services/friends.service';\nimport { UserComponent } from '../views/user/user.component';\n\n@Component({\n selector: 'app-menu',\n templateUrl: './menu.component.html',\n styleUrls: ['./menu.component.scss']\n})\nexport class MenuComponent implements OnInit {\n pathLogo: string = '../../../assets/imgs/logo.png';\n\n constructor(public auth: AuthService,\n public ngmodal: NgbModal,\n public friendService: FriendsService,\n public chat: ChatService) {\n\n }\n\n ngOnInit(): void {\n }\n\n openLogin() {\n this.ngmodal.open(LoginComponent, { size: 'md' });\n }\n\n openRegistro() {\n this.ngmodal.open(RegistroComponent, { size: 'md' });\n }\n\n openProfileUser(user: any) {\n this.auth.getItemsUser(2, user.uid);\n const modalRef = this.ngmodal.open(UserComponent, { size: 'lg' });\n modalRef.componentInstance.user = user;\n modalRef.componentInstance.addUser = 'add';\n }\n}\nimport { Injectable } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\nimport firebase from 'firebase/app';\nimport 'firebase/firestore';\nimport { Subject } from 'rxjs';\nimport { environment } from 'src/environments/environment';\nimport { ChatService } from './chat.service';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FriendsService {\n userAuth: any | null;\n users = []; // Recoge los usuarios\n friendsRequests = [];\n sentFriendsRequests = [];\n listeningItems = [];\n newFriendInfo: any = '';\n tokenUser: string = '';\n private newFriend = new Subject();\n public newFriend$ = this.newFriend.asObservable();\n\n constructor(public firestorage: AngularFireStorage,\n public chat: ChatService,\n private http: HttpClient) { }\n\n /**\n * Obtiene el usuario almacenado en localStorage, el cual se almacena al iniciar sesión\n */\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n this.tokenUser = this.userAuth['stsTokenManager']['accessToken'];\n }\n\n /**\n * Vacía el array users (usuarios obtenidos del buscador de amigos)\n */\n resetSearchFriends() {\n this.users = [];\n }\n\n /**\n * Búsqueda de nuevos amigos\n * @param value \n */\n searchFriends(value: string) {\n this.getUser();\n this.resetSearchFriends();\n\n if (value.length >= 1) {\n const url = environment.dirBack + \"getUsers/\" + value + \"/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.users = response['message'];\n\n this.users.forEach(user => {\n // Comprobar si ya está entre mis amigos\n this.chat.friends.forEach(friend => {\n if (user.uid == friend.uid) {\n // Usuario encontrado ya está en mi lista de amigos\n user.relation = 'friends';\n }\n });\n // Comprobar si ya le he enviado solicitud\n this.sentFriendsRequests.forEach(friend => {\n if (user.uid == friend.uid) {\n // Usuario encontrado ya ha sido enviada una solicitud\n user.relation = 'sentRequest';\n }\n });\n });\n });\n }\n }\n\n /**\n * Envía solicitud de amistad al usuario seleccionado\n * @param uid \n */\n sendFriendRequest(uid: string) {\n this.getUser();\n\n const url = `${environment.dirBack}sendFriendRequest/${this.userAuth.uid}/${uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { headers: headers })\n .subscribe(\n (response) => {\n console.log('Response:', response);\n // Actualizar relación: solicitud enviada\n this.users.forEach(friend => {\n if (friend.uid == uid) {\n friend.relation = 'sentRequest';\n }\n });\n // Eliminar de amigos sugeridos\n this.chat.suggestedFriends.forEach((friendSuggested, index) => {\n if (friendSuggested.uid == uid) {\n this.chat.suggestedFriends.splice(index, 1);\n }\n });\n\n });\n }\n\n /**\n * Eliminar amigo, es decir, dejar de ser amigos\n * @param uid \n */\n deleteFriend(uid: string) {\n this.getUser();\n\n const url = `${environment.dirBack}deleteFriend/${this.userAuth.uid}/${uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.delete(url, { headers: headers })\n .subscribe(\n (response) => {\n console.log('Response:', response);\n });\n }\n\n /**\n * Aceptar solicitud de amistad -> os convertis en amigos\n * @param uid \n */\n acceptFriendRequest(uid: string) {\n this.getUser();\n\n const url = `${environment.dirBack}acceptFriendRequest/${this.userAuth.uid}/${uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { headers: headers })\n .subscribe(\n (response) => {\n console.log('Response:', response);\n\n this.sentFriendsRequests.forEach(sentFriend => {\n if (sentFriend.uid == uid) {\n this.deleteRequests(uid,this.userAuth.uid).subscribe(() => {});\n }\n });\n // Eliminar de amigos sugeridos\n this.chat.suggestedFriends.forEach((friendSuggested, index) => {\n if (friendSuggested.uid == uid) {\n this.chat.suggestedFriends.splice(index, 1);\n }\n });\n this.deleteFriendRequest(uid);\n });\n }\n\n /**\n * Rechazar solicitud de amistad\n * @param uid \n */\n deleteFriendRequest(uid: string) {\n this.getUser();\n this.deleteRequests(this.userAuth.uid,uid)\n .subscribe(\n (response) => {\n console.log('Response:', response);\n this.friendsRequests.forEach((friend, index) => {\n if (friend.uid == uid) {\n this.friendsRequests.splice(index, 1);\n }\n });\n });\n }\n\n\n deleteRequests(uidUser, uidFriend) {\n const url = `${environment.dirBack}deleteFriendRequest/${uidUser}/${uidFriend}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.delete(url, { headers: headers })\n }\n\n /**\n * Cancelar envío de la solicitud de amistad\n * @param uid \n */\n cancelFriendRequest(uid: string) {\n this.deleteRequests(uid, this.userAuth.uid)\n .subscribe(\n (response) => {\n console.log('Response:', response);\n this.sentFriendsRequests.forEach((friend, index) => {\n if (friend.uid == uid) {\n this.sentFriendsRequests.splice(index, 1);\n }\n });\n this.users.forEach(friend => {\n if (friend.uid == uid) {\n friend.relation = 'unknown';\n }\n });\n });\n }\n\n /**\n * Pone en escucha las peticiones de amistad que te envian\n */\n listenFriendsRequests() {\n var db = firebase.firestore();\n this.friendsRequests = [];\n this.getUser();\n\n var query = db.collection('users').doc(this.userAuth.uid).collection('friendsRequests')\n var unsubscribe = query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Peticion de amistad borrada\n if (change.type === 'removed') {\n this.friendsRequests.forEach((friend, index) => {\n if (friend.uid == change.doc.id) {\n this.friendsRequests.splice(index, 1);\n }\n });\n this.friendRequestDeleted(change);\n }\n // Peticion de amistad recogida\n else {\n if (change.doc.id != this.userAuth.uid) {\n this.loadFriendRequest(change, 1);\n }\n }\n });\n //console.log('Solicitudes de amistad', this.friendsRequests);\n });\n this.listeningItems.push(unsubscribe);\n }\n\n\n /**\n * Pone en escucha las peticiones de amistad que he enviado\n */\n listenSentFriendsRequests() {\n var db = firebase.firestore();\n this.sentFriendsRequests = [];\n this.getUser();\n\n var query = db.collection('users').doc(this.userAuth.uid).collection('sentFriendsRequests')\n var unsubscribe = query.onSnapshot(snapshot => {\n snapshot.docChanges().forEach(change => {\n // Peticion de amistad enviada borrada\n if (change.type === 'removed') {\n this.sentFriendsRequests.forEach((friend, index) => {\n if (friend.uid == change.doc.id) {\n this.sentFriendsRequests.splice(index, 1);\n }\n });\n this.friendRequestDeleted(change);\n }\n // Peticion de amistad enviada recogida\n else {\n if (change.doc.id != this.userAuth.uid) {\n this.loadFriendRequest(change, 2);\n }\n }\n });\n //console.log('Solicitudes de amistad enviadas', this.sentFriendsRequests);\n });\n this.listeningItems.push(unsubscribe);\n }\n\n /**\n * Solicitud de amistad borrada, puede haberla rechazado o denegado.\n * Comprobaremos si ahora somos amigos\n * @param change \n */\n friendRequestDeleted(change: any) {\n var encontrado = false;\n\n const url = `${environment.dirBack}getFriendsUID/${this.userAuth.uid}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n var friendsUID = response['message'];\n // Buscamos si el usuario está entre los amigos del usuario \n friendsUID.forEach(user => {\n if (user.uid == change.doc.id) {\n encontrado = true;\n this.newFriendInfo = user.uid;\n }\n });\n\n // Evento de nuevo amigo\n if (encontrado) {\n const url = `${environment.dirBack}getUser/${this.newFriendInfo}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n this.newFriendInfo = response['message'].displayName;\n console.log('He aceptado solicitud');\n this.newFriend.next();\n });\n }\n\n this.users.forEach(friend => {\n friend.relation = 'unknown';\n if (friend.uid == change.doc.id) {\n if (encontrado) {\n friend.relation = 'friends';\n }\n }\n });\n\n });\n }\n\n /**\n * Añadir petición de amistad \n * @param change doc usuario a buscar\n * @param type 1: peticion de amistad recibida / 2: peticion de amistad enviada\n */\n loadFriendRequest(change: any, type: number) {\n const url = `${environment.dirBack}getUser/${change.doc.id}`;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.get(url, { headers: headers })\n .subscribe(\n (response) => {\n const friend = {\n 'uid': response['message'].uid,\n 'status': response['message'].status,\n 'displayName': response['message'].displayName,\n 'photoURL': response['message'].photoURL,\n 'email': response['message'].email,\n 'coins': response['message'].coins,\n }\n if (type == 1) {\n this.friendsRequests.push(friend);\n this.chat.sonidito(1);\n } else if (type == 2) {\n this.sentFriendsRequests.push(friend);\n }\n });\n }\n\n /**\n * Para de escuchar las peticiones de amistad tantoo las que se envian como las que se reciben.\n * Este método se llama al cerrar sesión\n */\n stopListeningRequests() {\n this.listeningItems.forEach(unsubscribe => {\n unsubscribe();\n });\n }\n\n}\nimport { Component, EventEmitter, Output } from '@angular/core';\nimport { ToastrService } from 'ngx-toastr';\nimport { Subscription } from 'rxjs';\nimport { environment } from 'src/environments/environment';\nimport { AuthService } from './services/auth.service';\nimport { ChatService } from './services/chat.service';\nimport { FriendsService } from './services/friends.service';\n\n@Component({\n selector: 'app-root',\n templateUrl: './app.component.html',\n styleUrls: ['./app.component.scss']\n})\nexport class AppComponent {\n title = 'PFG-Survivor';\n userAuth: any | null;\n\n @Output() onCompleteFriends = new EventEmitter();\n newFriend: Subscription = null;\n\n constructor(public friendService: FriendsService,\n public chat: ChatService,\n public auth: AuthService,\n public toastr: ToastrService) {\n }\n\n ngOnInit(): void {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n // Usuario logeado\n if (this.userAuth != null) {\n console.log('INIT APP');\n \n // Marcar como conectado\n this.chat.setStatusOnOff(1);\n // Subscribe New Friend -> Alert\n this.newFriend = this.friendService.newFriend$.subscribe(() => {\n this.onCompleteFriends.emit();\n this.toastr.success('Ahora ' + this.friendService.newFriendInfo + ' y tú sois amigos');\n });\n // Cierre navegador\n window.addEventListener(\"unload\", event => {\n console.log('CIERRE NAVEGADOR');\n this.chat.setStatusOnOff(2);\n this.chat.closeChat();\n });\n\n }\n }\n\n}\n# Proyecto Fin de Grado - DAW & DAM\n\n- Juega nuestros diferentes niveles 🎮\n- Supera tus records 💯\n- Sobrevive a los enemigos 👽\n- Consigue monedas 💰\n- Conoce gente nueva 👬\n- Chatea con amigos ⌨️\n- Recibe notificaciones 🚨\n- Compra objetos 🔫\n- Y mucho más 🔥\n\n```\nhttps://pfg-survivor.netlify.app\n```\n```\nhttps://survivorback.herokuapp.com\n```\n\n### Documentación 📰\n- KANBAN: https://github.com/meryjv00/PFG-Survivor/projects/1 \n- WIKI: https://github.com/meryjv00/PFG-Survivor/wiki \n\n### Repositorios 📦\nEl proyecto consta de tres repositorios:\n- [FRONTEND SURVIVOR](https://github.com/meryjv00/PFG-Survivor) - (Angular y SASS)\n- [BACKEND SURVIVOR](https://github.com/meryjv00/PFG-Survivor-Back) - (NodeJS y Firebase)\n- [VIDEOGAME SURVIVOR](https://github.com/DiegoS3/Survivor) - (Unity)\n\n ### Código fuente Videojuego 👨‍💻: \n [source] \n \n ### Videos 📹 \n \n - Vídeo explicativo: [video] \n - Trailer: [trailer]\n\n### Manuales Usuario 📕\n\n- WEB: [ManualWeb] \n- VIDEOJUEGO: [ManualVideo] \n\n### Despliegue docker 🧱\n\nRequisitos:\n- Docker y docker compose\n\nPara desplegar el entorno de producción siempre y cuando cumplas los requisitos, solo tendrás que ejecutar los scripts (iniciar.sh) de los correspondientes repositorios.\nEn el repositorio del front hay dos scripts con diferentes alternativas, puedes ejecutar el de tu preferencia.\n\n### Planificación tareas 📜 \nhttps://trello.com/b/rb3vJOeO/proyecto-fin-de-grado-dam-daw\n\n### Autores 🖋\n* **** - [meryjv00](https://github.com/meryjv00)\n* **** - [DiegoS3](https://github.com/DiegoS3)\n\n[source]: https://drive.google.com/file/d/1osHOYslKC93BuPduVjzo8Q13FT_9kyTs/view?usp=sharing\n[video]: https://youtu.be/i52JLuK1n9A\n[trailer]: https://youtu.be/eNcuMn3SGqU\n[ManualWeb]: https://meryjv00.github.io/PFG-Survivor/\n[ManualVideo]: https://diegos3.github.io/Survivor/\nimport { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFireAuthModule } from '@angular/fire/auth';\nimport { RouterTestingModule } from '@angular/router/testing';\nimport { environment } from 'src/environments/environment';\nimport { HomeComponent } from '../views/home/home.component';\nimport { AuthService } from './auth.service';\nimport { HttpClientModule } from '@angular/common/http';\n\ndescribe('AuthService', () => {\n let service: AuthService;\n\n beforeEach(() => {\n TestBed.configureTestingModule({\n imports: [\n AngularFireModule.initializeApp(environment.firebaseConfig),\n AngularFireAuthModule,\n RouterTestingModule,\n HttpClientModule,\n RouterTestingModule.withRoutes([\n { path: 'home', component: HomeComponent }\n ])\n ],\n });\n service = TestBed.inject(AuthService);\n });\n\n it('should be created', () => {\n expect(service).toBeTruthy();\n });\n\n\n describe('Casos login', () => {\n\n it('Login correcto', (done: DoneFn) => {\n service.emailLogin = '';\n service.passLogin = '';\n service.login().subscribe(\n (response) => {\n var user = response['message'];\n var code = response['status'];\n expect(user).not.toBeNull();\n expect(code).toBe(200);\n expect(service.emailLogin).toBe(user.email);\n done();\n });\n });\n\n it('Login email incorrecto', (done: DoneFn) => {\n service.emailLogin = 'kk ';\n service.passLogin = '';\n service.login().subscribe(\n () => { },\n (error) => {\n var code = error['error']['message'].code;\n expect(code).toBe('auth/user-not-found');\n done();\n });\n });\n\n it('Login pass incorrecta', (done: DoneFn) => {\n service.emailLogin = '';\n service.passLogin = '';\n service.login().subscribe(\n () => { },\n (error) => {\n var code = error['error']['message'].code;\n expect(code).toBe('auth/wrong-password');\n done();\n });\n });\n\n\n });\n\n describe('Casos Registro', () => {\n\n it('Registro correcto', (done: DoneFn) => {\n service.emailRegistro = '';\n service.passRegistro = '';\n service.registro().subscribe(\n (response) => {\n var user = response['message'];\n var code = response['status'];\n expect(user).not.toBeNull();\n expect(code).toBe(200);\n expect(service.emailRegistro).toBe(user.email);\n done();\n });\n }); \n\n it('Correo electrónico ya registrado', (done: DoneFn) => {\n service.emailRegistro = '';\n service.passRegistro = '';\n service.registro().subscribe(\n () => { },\n (error) => {\n var code = error['error']['message'].code;\n expect(code).toBe('auth/email-already-in-use');\n done();\n });\n });\n\n });\n\n\n});\n/* You can add global styles to this file, and also import other style files */\n@import 'scss/customTheme.scss';\n@import '~bootstrap/scss/bootstrap';\n\n@font-face {\n font-family: mandali;\n src: url(assets/fonts/Mandali-Regular.ttf) format(\"opentype\");\n}import { Component, Input, OnInit } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { RegistroComponent } from '../registro/registro.component';\nimport { ToastrService } from 'ngx-toastr';\nimport { PassComponent } from '../pass/pass.component';\nimport { ChatService } from 'src/app/services/chat.service';\n\n@Component({\n selector: 'app-login',\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.scss']\n})\nexport class LoginComponent implements OnInit {\n // Variables\n login: FormGroup;\n hide = true;\n msg: string = null;\n @Input() public msgPassword: any;\n\n constructor(private formBuilder: FormBuilder,\n public auth: AuthService,\n public ngmodal: NgbModal,\n public activeModal: NgbActiveModal,\n public toastr: ToastrService,\n public chat: ChatService) {\n\n this.login = this.formBuilder.group({\n email: ['', [Validators.required, Validators.email]],\n password: ['', [Validators.required]]\n });\n }\n\n ngOnInit(): void {\n }\n\n get formLogin() { return this.login.controls; }\n\n /**\n * Login con email y contraseña\n * @returns \n */\n onSubmit() {\n if (this.login.invalid) {\n return;\n }\n // var btnlog = document.getElementById(\"btnlogin\") as HTMLInputElement;\n // btnlog.disabled = true;\n\n this.auth.login()\n .subscribe(\n (response) => {\n console.log('Login éxito');\n var user = response['message'];\n this.auth.prepareLogin(user);\n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n },\n (error) => {\n var code = error['error']['message'].code;\n if (code === 'auth/wrong-password' || code === 'auth/user-not-found') {\n this.msg = 'No se ha podido iniciar sesión. Revise sus credenciales.';\n } else if (code === 'auth/too-many-requests') {\n this.msg = 'El acceso a esta cuenta se ha desactivado temporalmente debido a muchos intentos fallidos de inicio de sesión. \\\n Intentalo más tarde o restaura tu contraseña.';\n }\n });\n }\n\n /**\n * Login con cuenta de Google\n */\n loginGoogle() {\n this.auth.loginGoogle()\n .then(response => {\n var user = response.user;\n this.auth.prepareLogin(user);\n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n })\n .catch(error => {\n console.log(\"Error al logear con Google: \", error.code);\n });\n }\n\n /**\n * Login con cuenta de Facebook\n */\n loginFacebook() {\n this.auth.loginFacebook()\n .then(user => {\n this.auth.updateProfileFB(user);\n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n })\n .catch(error => {\n console.log(\"Error al logear con Facebook: \", error.code);\n\n if (error.code === 'auth/account-exists-with-different-credential') {\n this.msg = 'Ya existe una cuenta con esta dirección de correo electrónico pero con diferentes credenciales de inicio de sesión. \\\n Intenta iniciar sesión mediante correo electrónico o Google.';\n }\n });\n }\n\n /**\n * Cierra modal login y abre modal registro\n */\n openRegistro() {\n this.activeModal.close();\n this.ngmodal.open(RegistroComponent, { size: 'md' });\n }\n\n /**\n * Cierra modal login y abre modal contraseña olvidada\n */\n openPassOlvidada() {\n this.activeModal.close();\n this.ngmodal.open(PassComponent, { size: 'lg' });\n }\n\n}\nimport { Component, OnInit } from '@angular/core';\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\nimport { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';\nimport { ToastrService } from 'ngx-toastr';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { LoginComponent } from '../login/login.component';\n\n@Component({\n selector: 'app-registro',\n templateUrl: './registro.component.html',\n styleUrls: ['./registro.component.scss']\n})\n\nexport class RegistroComponent implements OnInit {\n // Variables\n registro: FormGroup;\n hide1 = true;\n hide2 = true;\n msg: string = null;\n\n constructor(private formBuilder: FormBuilder,\n public auth: AuthService,\n public ngmodal: NgbModal,\n public activeModal: NgbActiveModal,\n public toastr: ToastrService) {\n\n this.registro = this.formBuilder.group({\n email: ['', [Validators.required, Validators.email]],\n nombre: ['', [Validators.required, Validators.minLength(3)]],\n password: ['', [Validators.required, Validators.minLength(6)]],\n confirmPassword: ['', [Validators.required, Validators.pattern]]\n });\n }\n\n ngOnInit(): void {\n }\n\n get formRegistro() { return this.registro.controls; }\n\n /**\n * Registro con email y contraseña\n * @returns \n */\n onSubmit() {\n if (this.registro.invalid) {\n return;\n }\n // var btnregistro = document.getElementById(\"btnregistro\") as HTMLInputElement;\n // btnregistro.disabled = true;\n\n this.auth.registro()\n .subscribe(\n (response) => {\n console.log('Login éxito');\n var user = response['message'];\n this.auth.prepareLogin(user); \n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n },\n (error) => {\n var code = error['error']['message'].code;\n if (code === 'auth/email-already-in-use') {\n this.msg = 'El correo electrónico introducido ya está registrado.'\n }\n });\n }\n\n /**\n * Login con cuenta de Google\n */\n loginGoogle() {\n this.auth.loginGoogle()\n .then(response => {\n var user = response.user; \n this.auth.prepareLogin(user); \n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n })\n .catch(error => {\n console.log(\"Error al logear con Google: \", error);\n }); \n }\n\n /**\n * Login con cuenta de Facebook\n */\n loginFacebook() {\n this.auth.loginFacebook()\n .then(response => {\n var user = response.user; \n this.auth.updateProfileFB(response);\n this.toastr.success('Bienvenido/a!');\n this.activeModal.close();\n })\n .catch(error => {\n console.log(\"Error al logear con Facebook: \", error.code);\n\n if (error.code === 'auth/account-exists-with-different-credential') {\n this.msg = 'Ya existe una cuenta con esta dirección de correo electrónico pero con diferentes credenciales de inicio de sesión. \\\n Intenta iniciar sesión mediante correo electrónico o Google.';\n }\n })\n }\n\n /**\n * Cierra modal registro y abre modal login\n */\n openLogin() {\n this.activeModal.close();\n this.ngmodal.open(LoginComponent, { size: 'md' });\n }\n\n\n}\n\n// This file can be replaced during build by using the `fileReplacements` array.\n// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.\n// The list of file replacements can be found in `angular.json`.\n\nexport const environment = {\n production: false,\n firebaseConfig: {\n apiKey: \"\",\n authDomain: \"pfg-survivor-cd919.firebaseapp.com\",\n projectId: \"pfg-survivor-cd919\",\n storageBucket: \"pfg-survivor-cd919.appspot.com\",\n messagingSenderId: \"530404504797\",\n appId: \"1:530404504797:web:a2efd13f039584133dd734\",\n measurementId: \"G-XSHMWHFTZ6\"\n },\n SESSION_KEY_USER_AUTH: 'AUTH_USER_123456789',\n dirBack: 'http://localhost:6060/api/'\n};\n\n/*\n * For easier debugging in development mode, you can import the following file\n * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.\n *\n * This import should be commented out in production mode because it will have a negative impact\n * on performance if an error is thrown.\n */\n// import 'zone.js/dist/zone-error'; // Included with Angular CLI.\nimport { Injectable } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\nimport { AuthService } from './auth.service';\nimport { Router } from '@angular/router';\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\nimport { environment } from 'src/environments/environment';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PerfilService {\n userAuth: any | null; // Usuario guardado en session storage para obtener bien los datos al recargar la pagina\n tokenUser:string = '';\n\n constructor(public firestorage: AngularFireStorage,\n public auth: AuthService,\n public router: Router,\n private http: HttpClient) {\n }\n\n\n /**\n * Obtiene el usuario almacenado en localStorage, el cual se almacena al iniciar sesión\n */\n getUser() {\n this.userAuth = localStorage.getItem(environment.SESSION_KEY_USER_AUTH);\n this.userAuth = JSON.parse(this.userAuth);\n this.tokenUser = this.userAuth['stsTokenManager']['accessToken'];\n }\n\n /**\n * Cambiar nombre\n * @param name \n */\n updateDisplayName(name: string) {\n this.getUser();\n \n const url = environment.dirBack + \"updateName/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.put(url, { 'name': name }, { headers: headers })\n .subscribe(\n (response) => {\n console.log('RESPONSE', response);\n this.auth.setName(name);\n });\n\n }\n\n /**\n * Cambiar foto de perfil\n * @param event \n */\n updateProfileImage(event) {\n this.getUser();\n\n if (event.target.files[0]) {\n var file = event.target.files[0];\n\n // Subir imágen a storage\n this.firestorage.ref('profileImages/' + this.userAuth.uid).put(file).then(fileSnapshot => {\n return fileSnapshot.ref.getDownloadURL()\n .then(photoURL => { \n // Actualizar imágen a el usuario\n const url = environment.dirBack + \"updateProfilePhoto/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n this.http.post(url, { 'user': this.userAuth, 'photoURL': photoURL }, { headers: headers }).subscribe(()=>{\n this.auth.setPhoto(photoURL);\n });\n });\n });\n }\n\n }\n\n /**\n * Cambiar email de inicio de sesión\n * @param email \n * @returns \n */\n updateEmail(email: string) {\n this.getUser();\n\n const url = environment.dirBack + \"updateEmail/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.put(url, { 'email': email }, { headers: headers });\n }\n\n /**\n * Cambiar contraseña de inicio de sesión\n * @param pass \n * @returns \n */\n updatePass(pass: string) {\n this.getUser();\n\n const url = environment.dirBack + \"updatePass/\" + this.userAuth.uid;\n let headers = new HttpHeaders({ Authorization: `Bearer ${this.tokenUser}` });\n return this.http.put(url, { 'pass': pass }, { headers: headers });\n }\n\n\n}\necho '*********************************************************'\necho '*******************STARTING CONTAINERS*******************'\necho '*********************************************************'\ndocker-compose down\ndocker-compose build\ndocker-compose up -d\n\n\necho '**********************************************************'\necho '********************APP READY*****************************'\necho '*******************LOCALHOST:4200*************************'\necho '**********************************************************'\n\n# En caso de error: error checking context: 'can't stat directorio. EJ: '/home/maria/Escritorio/frontmaria/.config''.\n# Ejecutar:\n# sudo rm -rf .config\n# sudo rm -rf .npm\n# sudo rm -rf node_modules\n# Volver a lanzar init.sh\n"},"directory_id":{"kind":"string","value":"a2215cbebd91ff95011b93878e0b6148b4b0743c"},"languages":{"kind":"list like","value":["SCSS","HTML","Shell","Markdown","Dockerfile","JavaScript","TypeScript"],"string":"[\n \"SCSS\",\n \"HTML\",\n \"Shell\",\n \"Markdown\",\n \"Dockerfile\",\n \"JavaScript\",\n \"TypeScript\"\n]"},"num_files":{"kind":"number","value":39,"string":"39"},"repo_language":{"kind":"string","value":"SCSS"},"repo_name":{"kind":"string","value":"meryjv00/PFG-Survivor"},"revision_id":{"kind":"string","value":"db07a6e30039345c943d9b3d7ff6a633cd368094"},"snapshot_id":{"kind":"string","value":"0610fefa82d7d0a732f50cda3200e9a29f78f2fe"}}},{"rowIdx":9914,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"---\nlayout: post\ntitle: \"Ruby on Rails Project\"\ndate: 2021-02-02 23:58:15 +0000\npermalink: ruby_on_rails_project\n---\n\n\nAs the Rails module is gradually coming to end, now is the time to start thinking about the final project. When it came to this module, it wasn't much different from the previous module when we were studying up on the Sinatra framework. There were much similarities between Sinatra and Rails, which made learning Rails all that much more simple. However, with Rails being a much bigger framework than Sinatra, of cource Rails would have its own way of doing things. \n\nWhen it came down to the final project for the Rails module, some of the requirements were very similar, but not identical to the Sinatra final project, except for the fact that the project had to be built using the Rails framework. The set up process for the project was quick, easy, and similar to Sinatra; just setting up the models and their associations, along with the migration files for setting up the database. Then, came the part where Rails differs from Sinatra; although both \nframeworks are built around the MVC architecture, Rails, of course, does things differently than Sinatra. After the models came setting up the controllers and linking each controller action with the corresponding route. Sinatra does not use routes like Rails does. Next, came setting up the views files using partials for setting up forms that could be used across different pages. Once I got the basic backbone of the project came my favorite part: setting up sessions and authentications for the different types of users. \n\nThe idea of my Rails project is that there are two types of users: a student or a professor, so upon initially accessing the website, the user will be prompted to sign in as a student or to sign in as a professor. If the user is signing in as a student, then they will see a student login form, but if the user is a professor, then that user will see a professor sign in form. Basically, the two different users will see a similar login form, however, the idea is that upon signing in, a student has less admin credentials when being compared to a professor. \n\nOverall, if you didn't struggle and had fun with Sinatra, then you'll definitely love Rails and it'll be a breeze. So far, it has been my favorite module of the cohort and I can't wait to see what the rest of the program has to offer with JavaScript being the next module.\n# Site settings\nauthor: \ntitle: First Mile Struggles\nheader-img: img/home-bg.png\nemail: \ncopyright_name: \ndescription: > # this means to ignore newlines until \"baseurl:\"\n The start\nbaseurl: \"\" # the subpath of your site, e.g. /blog\ntwitter_username: \ngithub_username: Jzweifel15\n\n# Build settings\nmarkdown: kramdown\nhighlighter: rouge\npermalink: pretty\npaginate: 5\nexclude: [\"less\",\"node_modules\",\"Gruntfile.js\",\"package.json\",\"README.md\"]\n\ngems: [jekyll-paginate, jekyll-feed]\n---\nlayout: post\ntitle: \"Commonalities between Real life and Code\"\ndate: 2021-01-29 21:58:00 +0000\npermalink: commonalities_between_real_life_and_code\n---\n\n\nHello everybody,\n\nSince going through the cohort and learning how to properly code, all I now see is code. I continuously point out little aspects and events in my life by saying in my head how it can be coded. For example, if im hungry, I'll say something nerdy like, \"if hungry -> go get food; else if smelly -> take shower; else -> do nothing\". Not sure if i'm the only one doing this, but ever since I started working with code and on smaller projects, I definitely think in code, probably more than I should, but i'm going to go out on a limb and say that this is a good thing since we're all aspiring software engineers in the making. \n---\nlayout: post\ntitle: \"JavaScript/Rails Project\"\ndate: 2021-02-04 07:21:12 +0000\npermalink: javascript_rails_project\n---\n\nHello Everyone, \n\nIt felt like just last week we were finishing our Rails portfolio projects and wrapping up the third module of the cohort. Now, we're already in project week for the fourth module (JavaScript) and getting ready to enter the two-weeks of project assessments at the time i'm writing this blog post. \n\nI sincerely enjoyed the JavaScript module. I had already heard about JavaScript being a very important language to understand when it comes working on the front-end of web applications, and before Flatiron, I had always intended to try to take it up on my own time to learn JavaScript, but never really got around to it. I primarily thought JavaScript was used for animations and other little things that sometimes wasn't always necessary to have in every website or that could easily be done using CSS keyframes. However, after going through this fourth module, I was completely wrong. There is much more that can go on behind the scenes if you're wanting to build your own full-stack web application.\n\nGoing through the readings and completing the labs is always helpful. However, I also did some other research of my own on JavaScript and tried to work with as much as I could, incorporating my own little test projects to work through its quirks and tricks because I know just how important JavaScript is and anyone reading this, I would highly recommend doing your own research on JavaScript as well. Not saying the lessons weren't helpful. Without the lessons, I would not have known what to look up and research. I just wanted to take everything the readings and labs had to offer in this fourth module and go one step further by doing a little extra research on each topic that I was currently on. \n\nWhen it comes to this project, the requirements were very straightforward and I had no questions to ask. Once I had an idea, I went to the drawing board and started building out the project. For this project, you're definitely going to spend more time working on your front-end than you will with the back-end. The back-end portion was pretty straightforward and the only time I really spent in the back-end was by changing up my database making sure I had all the tables and\ncolumns that I wanted for my project and ensuring I had the proper seed data to work with. Originally, I was going to pull from a third-party API, but had really no luck finding any end-points to pull from, so I just created some of my own dummy data to work with. I didn't want to spend too much time trying to find something that really didn't matter all too much; I wanted to ensure I actually got the project working, and if I had time later, could implement this functionality instead of saturating the database with data that it doesn't really need. \n\nEven after doing my own research and little test projects with JavaScript, this project gave me quite a bit of trouble; but, I think that's typically to be expected in the field of software development. If anyone goes into this career not expecting there to be headaches, then I hate to be a burden, but you're in the wrong career field. Anyways, the main problem I was having wasn't pulling the data from the back-end; that was actually the easiest part of the project, but was\nactually getting little, certain functionality (that I wanted to be precise) to work. I think I spent a whole two days trying to figure out what I was doing wrong, but didn't get anywhere. I was able to get the functionality \"half,\" working, and by \"half,\" I mean that it did what I wanted it to do up to a certain point, but once that point was reached, it was downhill from there. It was a small little bug that didn't necessarily crash the project or make the project not work properly, but it was just a little qwirk that I didn't like because, I might be somewhat of a perfectionist, and just wanted my project to be \"perfect,\" in my eyes. \n\nAll-in-all, I still can't believe that we're already at the end of the fourth module, which is the second-to-last module of the cohort!!! Once this module is officially over, it'll be a new year (at the time this blog is being made, we are 2-weeks out from 2021) and we'll have a little less than two-months of my cohort. I must say, I learned a lot while going through this cohort with Flatiron. Not only have I learned the ins-and-outs of being a full-stack web developer, but I also learned how to be a software engineer. I leanred how to also teach myself; that way, if I ever wanted to pursue a different path in this field (rather than web development), I know how to teach myself and what I should do in order to sufficiently and efficiently study and research. \n\nWith that being said, we're in the end-game now...\n---\nlayout: post\ntitle: \"Final Portfolio Project: React/Redux\"\ndate: 2021-02-21 19:58:39 +0000\npermalink: final_portfolio_project_react_redux\n---\n\n\nSo, how was React/Redux... well, honestly for me, it was 50/50. I thoroughly enjoyed learning and using the React framework. However, when it comes to Redux... well, even though we're in project mode, I can tell you, I'm still struggling to understand how to use it. I understand its purpose and the reasons for using it, but it's the understanding exactly how to properly use it. At the time of writing this blog, I still have plenty of time to do some more research on Redux and to review all of the labs, readings, and code-alongs from the curriculum to hopefully better understand Redux. So, overall, React was very much my friend, where Redux was, not necessarily an enemy, but just kind of a nuisance. \n\nFor my final project for this final module of the cohort, I will be making a fitness tracker for those gym-monkies that are out there. This web application will allow the user to keep track of their daily workouts; you can log the number of sets and repetitions for each exercise that you carryout within a particular workout. Not only can the application keep track of your workouts, but you can also keep track of the meals you eat and your calorie consumption for a full day based on the particular foods you have entered for the day. This project of course will utilize full CRUD functionality, allowing a user to enter new workouts and new meals for a particular day, but if they also need to either edit or delete a particular workout/meal, then they can definitely do so. I will also be incorporating a component that will be a calculator/tracker of the user's Body Mass Index (BMI), as well as, a component that will contain a line graph that can be used to view how their BMI has changed over the course of either a week, a month, or a year depending on how long the user has an account, of course. \n\nRoughly 10-months ago when I first started my cohort, I have been dreaming of this day. The day where my cohort officially enters the \"end-game.\" We are officially in, not just final project mode for the module, but the final-final project mode, where the end of this project will officially mark the end of the software engineering curriculum for my cohort. Once everyone passes their project review, we'll officially be in the \"job hunt.\" The reason I put \"job hunt,\" in quotation\nmarks is because, where I'm sure most, if not all, of my cohort-mates will be transitioning straight into a job after their time at Flatiron schools, myself, however, will actually be continuing my education after graduating Flatiron. I have the opportunity to attend a community college around where I live to pursue a 2-year, Associates of Applied Science in Computer Science degree. Most people would probably ask, \"well, you don't really need a college degree to become a \nsoftware engineer, so why bother?\" That is a great question and I'm glad you asked. The only reason why I have decided to pursue this path after Flatiron is because my employer offers tuition assistance to associates who have worked at least one full year at the company, and in the middle of my cohort, I actually hit my one year anniversary with my employer. So, not only will my employer be providing assistance to help pay for this degree, but they'll actually be covering... what for it... 95% of the tuition for this degree.\n\nYes, I promise you that number is correct... they'll be providing 95% of the tuition, so I won't even need to apply for any loans/financial aid, since that last 5% will be a small amount that I can just pay for myself, so I will have absolutely no debt after finishing this degree program, which makes it even better. So, if I were to find a job and leave my current employer, I may never have this opportunity again, so I figured I would utilize it while I can, even if it means putting off the official job hunt for a little while longer.\n\nSo, for all of my cohort-mates, I wish you all the best of luck with your final projects and your projects reviews, as well as, your hunting for a job to officially start your new careers as software engineers. To those who are just starting or in the middle of your cohorts at Flatiron, I wish you all the best of luck with the rest of your cohort and with your job hunt, as well when you get to that point. \n---\nlayout: post\ntitle: \"Sinatra Project\"\ndate: 2021-02-02 01:41:16 +0000\npermalink: sinatra_project\n---\n\n\nThe second module of the Part-time Online Software Engineering Cohort for Flatiron Schools was primarily about creating and setting up databases for web-applications that use an MVC (Model, View, Controller) layout, using RESTful naming patterns to perform CRUD (Create, Read, Update, Destroy) actions on those databases, and sending HTTP requests to a local server to display a View that shows the user certain data from the database based on those requests. In this module I have learned so much about creating relationships amongst different Models and setting up associations for those models to a database. One of the most important things that I learned during this module was how to use the Sinatra Gem. Sinatra, in Ruby, is a library that allows any programmer [that knows how to properly use the gem] to build a somewhat smaller MVC web-application. Even though Sinatra was learned more towards the end of this module, everything before it was important to understand in order to successfully comprehend how to properly use Sinatra. \n\nNow, that we're in project week for our second portfolio project it was time to show off what I had learned from this module. We had to create a web-application (using Sinatra of course) that utilizes an MVC layout, has more than one model that can be created/associated to a database, uses the RESTful naming patterns for routes to transition from view-to-view, and successfully perform CRUD actions on a database. For my project, I decided to create a small music playlist creator. This application will allow anyone to sign up (or, sign in if you already have an account) and create your own playlist filled with the music you love. A user can create as many playlists as they want with however many songs they want to add and can name their playlist whatever they want. If they want to add a song to an existing playlist, they can edit/update an already existing playlist, or if the user just does not want the playlist on their homescreen anymore, they can simply delete/destroy the playlist from existence. \n\nOf course with any project, one of the hardest parts is actually figuring out where to start. For anyone wanting to create a Sinatra application, there is actually this really nice, extremely helpful and time-saving gem called 'Corneal' that I highly recommend any Rubyist downloads locally to their computer. The Corneal gem actually sets up everything you'll need to get started building your Sinatra application right away without any headaches. All you'll need to type into your terminal\n(after installing the gem of course) is \"corneal new [APP-NAME]\" where \"[APP-NAME]\" is the whatever you want to name your project. After you type all that in, you'll see a bunch of files and folders automatically created for you. Just open the new directory in your favorite code editor and get started. \n\nLike I said, I learned a lot from this module, however, I definitely learned the most by actually trying to build my own project. I ran into all sorts of problems (as any software engineer does when working on any project), but being able to troubleshoot these errors/bugs within my own code allowed me to really think/brainstorm logical soultions that would eventually lead to the problem being solved.\n\nOverall, I'm very proud of my code and my complete project. I spent a lot of time working on it the past two-weeks and I can't wait to move on to the next module of the cohort (assuming my project review goes well).\n---\nlayout: post\ntitle: \"Ruby CLI Project\"\ndate: 2021-01-31 00:31:05 +0000\npermalink: ruby_cli_project\n---\n\nThe first portfolio project that is due for the first module when participating in the Flatiron School's Software Engineering\nprogram is building a command line interface Ruby gem that scrapes data from a webpage and allows any user to interact with\nthat data in some way. I decided to create a gem that would allow any user to see the top grossing movies of all time. This gem\nwould scrape data from the Rotten Tomatoes webpage where they have a list of 50 movies in order starting from the #1 top grossing\nmovie and working its way down. \n\nWhen I first started this project, I had a small idea of where to start, so what I did was first look for a website that my gem\nwas to scrape data from and after about 10-15 minutes of searching, I came across the Rotten Tomatoes webpage, which is where\nmy gem scrapes from. I played around with the website for a while, finding the data I needed and how I was going to go about\ngetting that data and displaying it in a nice, organized manner to the user. When it comes to working on any project, I have learned\nthat just playing around with code can go a long way. I probably spent a good, 4-5 hours just messing with the Nokogiri and \nOpen-URI modules to scrape different data from the website, then another couple of hours iterating through that data to display\nit how I wanted it to be layed out to the user. \n\nNext, was actually starting to build the project and this was where I was stumped because I had never actually built my own Ruby\ngem and had no idea where to start. Thankfully, Flatiron provides some very helpful resources that allowed me to get a small\nblueprint (or, rough draft) of my project formed. This blueprint consisted of hardcoding some of the data, but it was to get my\nproject off the ground and into the air. I knew that later down the road major changes were going to be made, but I felt much\nbetter than before knowing that I at least had a baby project started.\n\nAs of Tuesday, June 23rd of 20202, I have officially completed my first portfolio project for the part-time online software engineering program at Flatiron. \nWe were required to build a ruby gem that allowed any user to interact with an interface of data using the command line. This data had to come from a webpage of \nour choice, but we were not allowed to hardcode this data. We had to either scrape this data from the website or request this data from the websites API. For my\nproject, I decided to scrape my data. \n\nMy project, called Top_Movies_Cli scrapes data from the Rotten Tomatoes webpage on the top 50 highest grossing (most money made) movies of all time, turns each \nmovie into a Movie object using some corresponding information that can be found for each movie on the webpage, like the movie's title, value, release date, and \na description of the movie. Anyone who uses this gem will have access to seeing the list of movies and can interact with this data by choosing and typing a number\none through fifty to select a movie, which the gem will spit back out the corresponding information for that movie. \n\nAlthough my project is plain and simple, and the project does not do very much, I am still very proud of my project. It was a giant headache in the making, but it\nalways feels so good when it finally works and does what you're expecting of it to do. Hopefully, this small little project is just the first step to something\nmuch, much bigger in the future.\n\n\n\n---\nlayout: post\ntitle: \"Why Did I Decide to Learn Software Development\"\ndate: 2021-01-29 21:53:11 +0000\npermalink: why_did_i_decide_to_learn_software_development\n---\n\n\nHello everybody,\n\nI decided to learn software development because it has always been a dream of mine to get into some type of technical field where I can help people. In the realm of computer science, there are many paths that can be taken when learning how to program. Software development is not the only career path that I plan to look into upon going through my cohort, but becoming a software engineer is definitely a big one. Especially, how high the deman is for SEs. I'm hoping that one day, with the knowledge that I obtain, I can one day give back to those who are wanting to do the same thing.\n"},"directory_id":{"kind":"string","value":"040ba39228920db22cb3b88444da5482315d8718"},"languages":{"kind":"list like","value":["Markdown","YAML"],"string":"[\n \"Markdown\",\n \"YAML\"\n]"},"num_files":{"kind":"number","value":8,"string":"8"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Jzweifel15/Jzweifel15.github.io"},"revision_id":{"kind":"string","value":"4c780b08e0e416d269fa5ef0854072906f5efef0"},"snapshot_id":{"kind":"string","value":"547239bdc4c25c45ea7b73ecedafbc4c4841957b"}}},{"rowIdx":9915,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"import 'package:flutter/material.dart';\n\nclass ActiveTrip extends StatelessWidget {\n final Color color;\n\n const ActiveTrip({Key key, this.color}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return Container(\n child: Column(\n children: [\n Expanded(\n flex: 1,\n child: SizedBox(),\n ),\n Container(\n alignment: Alignment.center,\n child: Text('No Active Trip', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500,color: Colors.red[200])),\n ),\n Expanded(\n flex: 1,\n child: SizedBox(),\n ),\n ],\n ),\n );\n }\n}import 'package:flutter/material.dart';\n\n\nclass LogoContainer extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n appBar: AppBar(\n title: Row(\n mainAxisAlignment: MainAxisAlignment.center,\n children: [\n Image.asset('assets/icpep.png',\n fit: BoxFit.contain,\n height: 30,\n ),\n Container(\n padding: const EdgeInsets.all(8.0), child: Text('ICpEP Singapore'))\n ],\n ),\n );\n }\n}\nimport 'package:flutter/material.dart';\n\n\nclass LogoContainer extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n AssetImage assetImage = AssetImage('assets/images/ct_logo.png');\n Image image = Image(image: assetImage);\n return Container(\n child: image\n );\n }\n}"},"directory_id":{"kind":"string","value":"dab6b435c27efc62b7f65e7f9e4ba95947ea9e56"},"languages":{"kind":"list like","value":["Dart"],"string":"[\n \"Dart\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"Dart"},"repo_name":{"kind":"string","value":"itlog/ct_icpep"},"revision_id":{"kind":"string","value":"687ab9e63c9c31acd694c1b3e5ddb72ba56af778"},"snapshot_id":{"kind":"string","value":"0527338c3e31b1155329572c8066e4f33c012019"}}},{"rowIdx":9916,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# Lecture 6 (1/26)\n#Lin177\n\nRecall issue with infinite nucleus from Lecture 5. \n\t* Use Length?\n\t\t* No, that’s not principled. Language not actually based on magic value like length. Want to model what we think is happening linguistically\n```\nnucleus([A,B]) :-\n\tphone(A), not(cns(A)),\n\tphone(B), not(cns(B)),\n\tnot(A = B).\n```\n\nRecall the issue of excluding the ‘err’ sound:\n```\nonset([A]) :-\n\tphone(A), cns(A), alv(A), not(pal(A)).\n\noneset([A]) :-\n\tphone(A), cns(A), not(alv(A)).\n```\n\t* Not great. It would be better to have one natural class that gives all solutions. But prof is not sure if this is possible given our syllable properties.\n\t* The problem on the homework is a little easier, presumably…\n\n-> Chapter on phenetics ends on english syllables, and goes into semantics.\n- - - -\n# Semantics\n## The Procedural Definition of Semantics\n“The planet closest to the sun” -> Mercury\n“The planet Mercury” -> Mercury\n-> This meaning is called the **Reference**\n\nBoth of these phrases refer to Mercury, but do they mean the same thing? Not necessarily.\n\t* The method we use to get to the meaning is different\n\t* The procedure to get to meaning is affected by the current state of the world.\n\t* So we have to make some sort of distinction or else “The President of the US” would always mean (the horror!)\n-> This procedure is called the **Sense**.\n\n* specific entities are given with underlines:\nSid -> _Sid_\nNancy -> _Nancy_\n\t* In this particular universe, there is only one sid and one nancy\n\t\n* Next, we can add relation between S & N\nloves -> (Nancy -> Sid)\n\t -> (Sid -> Nancy)\n\n* Given any english sentence, and leaf of the sentence structure, we can evaluate it to a true or false.\n“ Nancy”\n Sid Sid \n true \n\nFor each phrase type, there’s a particular thing you are looking for:\n\t* Nouns: looking for entities\n\t* Verbs: looking for relations\n\t* Sentences: looking for T/F\n-> See example above\n\t\t* You can see how Prolog will be very good at this\n\t\t* The way Prolog handles procedure/variable bindings is identical to the way we are relating things in this procedural definition of semantics\n\n## Expressing References in Prolog\n```\nReference :: (Reference is 3+2).\nReference :: (Reference is 1+4).\n```\n\t* Note how it distinguishes the difference between reference and expression.\n\n```\nnum(0).\nnum(N) :-\n\tnum(M),\n\tN is M + 1.\n```\n\t* The set of all positive integers.\n\t* If you do a `findall`, it’ll find all numbers until it runs out of memory. \n\t* In linguistic, we need to do a better job referencing infinite sets. Because lots of things are an infinite set in linguistics\n```\nReference :: (findall(A, num(A), Reference)).\t\n```\n\t* Can’t evaluate it (because will run out of memory).\n\t* But we can still express it in a principled way. \n\t%: Not exactly sure what the point of this is, but presumably it will come up later… \n\n# Lecture 9 (2/5)\n#Lin177\n\nCoding Challenge in class. Turn in on HW4 for extra points (or something).\nI, being the kiss-ass I am, showed off my program in class, and he said it was basically correct:\n```Prolog\nword(make, [verb]).\nword(made, [verb]).\nword(cat, [noun]).\nword(tend, [noun]).\nword(done, [verb]).\nprefix(Word, Prefixed) :- \n word(Word, [verb]),\n atom_concat(pre, Word, Prefixed).\n```\n\n# Lecture 4 (1/19)\n#Lin177\n\nMake sure you can do the following in prolog:\n1. Run swipl\n2. open a file\n3. consult within a file\n- - - -\n## Homework 1 Intro\nAll questions adapted from text.\n1. Tons of examples to choose from\n2. Sound alike and mean different\nMean alike but sound differently\n-> actually more difficult\n3. See excursive given in the book\n\t* You’ll see it’s very similar to spanish, but slightly different\n\t* Modify spanish program, not writing something from scratch\n\t* similar enough that edits are fine\n4. Don’t overthink this. \n\t* The solution to 4 is incredibly short\n\t* presumably translate from spanish to english, then english to japanese\n\t\t* Could this be one line?\n- - - -\n\n# More stuff about Properties of Phones\n* We don’t normally want just one sound in isolation: `phone(X), cns(X)`\n\t* Gives one at a time\n* We want the full set of solutions:\n\t* “Natural Class”\n\t* The overlap between different features \n```\nfindall(\n\tVariable,\n\tConditions we want to be true, // can be more than one in parenthetical block\n\tOutput Variable\n)\n\nEX:\n?- findall(X, (phone(X), cns(X), ant(X)), Y).\nY = [p, b, m, t, n, f...].\n```\nYou may find that Prolog truncates this output.\nTo fix this, there is a program called Full Display\n`[‘fulldisplay.swipl’]` if it doesn’t work, get new version\n\n```\nfindall(X), (phone(X), not(cns(X))), Y).\n# note the use of not(cns(X)) to select vowels\n```\n\n# More About Syllables\n* Remember “Strengths” having a complex coda \n* In Japanese, the only possible coda is a nasal, no complex coda allowed\n\t* Reason for odd syllable arrangement when pronouncing foreign words\n\t* Spice (english) -> su | spi | su (follows japanese syllabic rules)\n\t* If you break rules, you have things that are “unpronouceable”\n\n* How many possible syllables are there in English?\n\t* A Lot! But there are rules that restrict range\n\t* `tranz` is a syllable\n\t* Can we have `tlanz`? No!\n\n### Page 64 & 65: Rules of English Syllables\n\n```\nR1. The sequence of an onset and a rhyme is a syllable.\n```\n```\nR2. Any consonantic nonnasal phone is an onset (so p, b, t, d, k, g, f, v, θ, ð, s, z, ʃ, ʒ, č, ǰ, j, l, ɹ, j, w, h are all onsets).\n```\n```\nR3. Any nonvelar nasal phone is an onset (so m and n are both onsets).\n```\n```\nR4. Any nonsonorant, noncontinuant, nonpalatal phone followed by an al-\nveolar palatal phone is an onset (so pɹ, bɹ, tɹ, dɹ, kɹ, and gɹ are all on-\nsets).\n```\n```\nR5. Any nonsonorant, noncontinuant, noncoronal phone followed by a son-\norant, nonnasal, alveolar, nonpalatal phone is an onset (so pl, bl, kl,\nand gl are all onsets).\n```\n```\nR6. Any nonsonorant, noncontinuant, nonlabial, nonpalatal phone followed\nby a velar continuant phone is an onset (so tw, dw, kw, and gw are all\nonsets).\n```\n```\nR7. Any nonvoiced, continuant, labial phone followed by a sonorant con-\ntinuant alveolar phone is an onset (so fl and fɹ are both onsets).\n```\n```\nR8. Any nonvoiced, continuant, nonalveolar, coronal phone followed by an\nalveolar palatal phone is an onset (so θɹ and ðɹ are both onsets).\n```\n```\nR9. Any nonvoiced, continuant, alveolar phone followed by a consonantic, sonorant, nonnasal, nonpalatal phone is an onset (so sl and sw are both\nonsets).\n```\n```\nR10. Any nonvoiced, continuant, alveolar phone followed by a nasal non-\nvelar phone is an onset (so sm and sn are both onsets).\n```\n```\nR11. Any nonvoiced, continuant, alveolar phone followed by an onset headed by a nonvoiced, noncontinuant, nonpalatal is an onset (so sx is an onset if x is itself an onset–albeit one that begins with p, t, or k).\n```\n```\nR12. The sequence of a nucleus and a coda is a rhyme.\n```\n```\nR13. Any nonconsonantic phone is a nucleus (so i, ɪ, u, ʊ, e, o, ə, ʌ, a and\næ are all nuclei).\n```\n```\nR14. Any mid noncentral phone followed by a consonantic, sonorant,\nnonnasal, nonalveolar phone is a nucleus (so ej, ew, oj, and ow are all\nnuclei).\n```\n```\nR15. Any low back phone followed by a consonantic, sonorant, non-nasal,\nnonalveolar phone is a nucleus (so aj and aw are both nuclei).\n```\n```\nR16. Any nonsonorant phone is a coda (so p, b, t, d, k, g, f, v, θ, ð, s, z, ʃ, ʒ, č, ǰ, j, l, ɹ, and h are all codas).\n```\n```\nR17. Any nasal phone is a coda (so m, n, and ŋ are all codas). R18. Any liquid phone is a coda (so l and ɹ are both codas).\n```\n\n-> All of these rules are loaded into `syllable.swipl`\n-> He’s going over this now. \n\n\n\n\n\n\n\n\n# Lecture 3 (1/17) \n#Lin177\n\n* Spanish Program diagrammed out on page 36 of the textbook\n-> You can rewrite this as rules and postulates\n\t* eva is Postulate 1 (P1)\n\t* Transitive very is Postulate 6 (P6)\n* This is shown on page 38 of the textbook\n* You end up with the derivational history of the program in simple expression: `R4(P1,R3(P6,R2(P2)))`\n\n- - - -\n* First Homework has a problem very similar to this\n* Homework will go up tomorrow\n* Due Monday\n* Mostly material from chapter 1, with one question about Phentics that’s easy\n- - - -\n\n# Chapter 2: Phonetics (the sounds themselves)\nEvery language has unique set of sounds\n-> “Phones”\n* IPA (international Phonetic alphabet) tries to give a symbol to all human sounds\n* Hundreds of symbols\n\n### How do you split up these sounds?\n* Look at anatomical differences in producing sounds\n\n#### Constances \n* Voicing \n* Place \n* Manner\n\n Complete or partial closure\n* “puh” closes completely\n* “shhh” obsctructs air to make noise\n\n#### Vowels\n* height\n* frontness\n* tense/lax\n\t* Sheet (tense)\n\t* Shit (lax)\n\n``` properties.swipl\n# Defines set of properties (explained on page 58 in text)\n```\n\nThe properties we have in mind are the following:\n## Consonant Properties\n```\r• CONSONANTIC: This property is true of sounds articulated with some degree of obstruction in the oral cavity; it therefore applies to all of the consonants (but none of the vowels) of Section 2 above.\n```\n```\r• SONORANT: This property applies to sounds which are naturally (or normally, or most effortlessly) voiced (see below). In English, the class of sonorants includes nothing but the vowels, the nasals (m, n, ŋ), the lateral (l), the approximant (ɹ), and the glides (j, w).\n```\n```\n• NASAL: This property holds only of sounds which resonate in the nasal (rather than the oral) cavity. Consequently, in English, it applies only to m, n, and ŋ.\n```\n```\n• VOICED: This property characterizes sounds that involve vibrating vocal folds (the lip-like organs in the larynx, which is commonly known as Adam's apple). Thus, in English, it applies only to b, d, g, v, ð, z, ʒ, ǰ— as well as to all sonorants.\n```\n```\r• CONTINUANT: This property is true of phones throughout the articula- tion of which the air flows uninterrupted. In English it is true of all phones other than the stops (p, b, t, d, k, g, m, n, ŋ) and the affricates (č, ǰ).\n\t* We can extend past some length\n\t* Anything you can control the length of\n```\n```\r• LABIAL: This property applies only to the phones that involve the lips. It therefore describes, in English, the bilabials (p, b, m), the labiodentals (f, v), the lip-rounded glide (w), and nothing else.\n```\n```\r• ALVEOLAR: This property holds of phones which are articulated at the alveolar ridge. Thus, in English, it holds only of t, d, n, s, z, l, and ɹ.\r6 I am indebted to my colleague for help with deciding on this set of properties.\n```\n```\r• PALATAL: This property characterizes the phones articulated at the pal- ate (or roof of the mouth). In English it holds of the palatals proper (ʃ, ʒ, č, ǰ, j) and the alveopalatal (ɹ), which is both alveolar and palatal.\n```\n-> Hard to recognize, probably should memorize sounds as palatal\n```\r• ANTERIOR: This property is true of phones articulated with an obstruc- tion at the alveolar ridge or before. In English it therefore applies to all labial (p, b, m, f, v) and alveolar (t, d, n, s, z, l, ɹ) consonantic phones.\n```\n\n```\r• VELAR: This property applies to sounds articulated at the velum (or soft palate)—the veil like continuation of the palate. In English, these would be k, g, ŋ, and w.\n```\n```\r• CORONAL: This property holds of phones involving the tip (or crown) of the tongue. Thus, in English, it is true of the interdentals (θ, ð), the al- veolars (t, d, n, s, z, l, ɹ), and the palatals (ʃ, ʒ, č, ǰ, j, ɹ).\n```\n\n```\r• SIBILANT: This property characterizes ‘whistling’ (or s-like) phones. In English, these phones are only s, z, ʃ, ʒ, č, ǰ.\n```\n\n## Vowel Properties\n```\r• HIGH: This property is true of vowels articulated with the tongue in a relatively high position. Consequently, it applies in English only to i, ɪ, u, and ʊ.\n```\n```\r• MID: This property applies to vowels articulated with the tongue at middle height. In English, this describes only e, o, ə, and ʌ.\n```\n```\r• LOW: This property holds of vowels articulated with the tongue in a relatively low position. In English, this property is extremely discrimi- nating, as it is true only of two phones: a and æ.\n```\n\n\n```\r• BACK: This property characterizes vowels articulated with the tongue in a relatively back position. In English, this describes only u, ʊ, o, and a.\n```\n```\r• CENTRAL: This property is true of vowels articulated with the tongue at mid-back (or mid-front) position. In English, this property, too, is ex- tremely discriminating, as it is true only of two phones: ə and ʌ.\n```\n\n\n```\r• TENSED: This property applies to vowels articulated with relatively high muscular tension. Again, only two phones satisfy this property in Eng- lish. They are i and u.\n```\n```\r• STRESSED: This property holds of vowels that may serve as syllabic nuclei. In English they are all except ə.\n```\n\n\n## Properties.swipl\n* first call in phone.swipl \n\t* gives it all the possible symbols \n\t* need to use unicode values throughout\n* cns/1 rules are consonantic\n* voi/1 rules are voices\n* cnt/1\nEtc. etc.\n\n-> Let’s run it:\n```Prolog \n?- ['properties.swipl'].\ntrue\n?- phone(A).\nA = p ;\nA = b ;\netc. etc.\n\n?- cnt(A).\nA = f ;\nA = v ;\netc. etc.\n\n?- vel(A), snt(A). # a sound that has both of these properties\nA = w ;\netc.\n\n?- mid(A), bck(A).\nA = o ; \nfalse.\n```\n\n-> That’s pretty much all we need for the phonetics\n\t* the symbols and the properties of the sounds\n\n## Syllables\nSome things to mention before we continue\n\t* one of the most important things in Phonology is the syllable \n\t* Syllable structure is arbitrary to a language\n\n### Parts of a Syllable\n* Onset\n* Nucleus (rime)\n\t* the most sonorant part of the syllable\n\t* any sound with sonorant property\n* Coda (rime)\n\nEX: “ton”\n\t* onset: ’t’\n\t* nucleus: ^ (uh)\n\t* Coda: ’n’\n\nEX: “tahn”\n\t* pronounceable, but not an actual word\n\t* add complex onset, ‘tr’\n\t\t* tron, that’s a word\n\t* add complex coda: ’ns’\n\t\t* trons\n\n\n\n\n\n\n# Lecture 5 (1/24)\n#Lin177\n\n## Homework 1 Answers\n1. Any recursive word\n2. Bear (n.), bear (v.)\nLawyer, attorney / car, automobile\n3. Best way to approach that is to edit the spanish program into the japanese program\n4. consult japanese.swipl and spanish.swipl\n```\nspanishjapanese(A,B) :-\n\tspanish(A,_,English,_),\n\tjapanese(B,_,English,_).\n```\n\n- - - -\n## Homework 2\n* in back of book: page 331, there’s a list of prolog tutorials\n* Highly recommended that you do one of these\n\n1. structural description: \nderivational history:\nsignature: \ndraw it out\n2. create `trilingual/1` rule\nneed some kind of predicate to verify a given person\n3. \n4. eleven english words. express the parts of speech\nNot terribly easy, for things like too\nwe would want to use this information to make valid sentences\n5. must be principled\n\n- - - -\n## Syllable.swipl\n* defines onset, rhyme. What makes a valid english syllable\n```\n?- findall(X, syllable(X), Y).\n-> giant list of syllables\n-> number of syllables > number of words\n\n?- findall(X,syllable(X), Y), length(Y, Length).\nLength = 20608\n```\n\n# Syllables in Japanese\nonset: cns\nnucleus: not(cns(X)). (any vowel)\ncoda: nas(X) (only a nasal)\n```\n:- ['properties.swipl'].\n\nonset([A]) :-\n\tphone(A), cns(A). %any sound that is a consonant\nonset([]).\n\nnucleus([A]) :-\n\tphone(A), not(cns(A)).\n\nnucleus([A, B]) :-\n\tnucleus(A),\n\tnucleus(B). % two nuclei in sequence is an allowable nucleus\n% NOTE: This causes infinite recursion. This will be adressed on Friday\n\ncoda([A]) :-\n\tphone(A), nas(A).\n\ncoda([]).\n\nrime(A) :-\n\tnucleus(B),\n\tcoda(C),\n\tappend(B, C, A).\n\nsyllable(A) :-\n\tonset(B),\n\trime(C),\n\tappend(B,C,A).\n```\n\n\n\n\n\n\n\n\n\n\n\n# Lecture 7 (1/31)\n#Lin177\n\n* Review homework assignment\n* Preview next homework\n\n## Homework 2\n1. structural description, similar to diagram in book\nderivational history: same structure, given in Postulates (P) and Rules (R)\nsignature: combine with parentheses\n2. Trilingual program:\n\t* :/ \n3. Why ill-informed facts. \n\t* atoms cannot contain spaces\n\t* capital letters are reserved for variable definitions\n\t* missing period\n\t* statements may not begin with numbers\n4. Parts of speech. fine. \n5. `spanish([nino],[noun, masculine, singlular],[boy],[property, male, single]).`\n\t* “something like this is fine” :/ \n\n## Next Assignment (HW 3)\n\t* looking at properties of prolog syntax more closely\n\t* head and tail\n1. Just evaluate and give the outcome from Prolog. For the ones that don’t work. find out why\n2. explain what the prolog program (in prose). Basically explain the head and tail relationship.\n3. same thing. explain why it works in prose. \n\n- - - -\n# More on the Semantics Model\nSome property vocabulary:\n\t* **Unary predicate** property of single element. something like `male(fred)`.\n\t* **Binary predicate** property of two elements. Lot’s we can do with these.\n\t\t* `parent(bob, sally)`.\n\t* \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Lecture 2 (1/12)\n#Lin177\n\n## Prolog Spanish Example (from book)\nMake rules:\n\t* Noun Phrase (subject) -> Noun\n\t* Noun Phrase (object) -> Noun (accusative)\n\t* Verb Phrase -> Verb + Noun Phrase (object)\n\t* Subject -> N.Phrase (sub) + Verb Phrase \n\n## More Prolog\n* Atoms\n\t* facts. building blocks not further defined\n\t* lowercase\n* Lists []\n\t* Just means that there can be one or more things\n* Variables\n\t* Capital Letters# Lecture 1 (1/10)\n#Lin177\n\n* Week 1, focus is getting Prolog installed (not coding till next week)\n* We are going to start with an overview of Linguistics\n\n- - - -\n## What is a Language?\n-> can give examples easily\n-> but harder to give a general definition\n-> We are going to split a language into multiple pieces, model them independently\n\n### For every language we have:\n\t* Sounds\n\t* Signs\n\t* Combinations \n\t-> Combinations of signs -> words -> sentences -> whatever\n\n\t1. Phonetics \n\t\t* The “gestures” of languages\n\t\t\t* put mouth in a certain position, coordinate air, make a sound\n\t\t* The articulation of sound, or the acoustics of a sound\n\t2. Phonology\n\t\t* The perception of sounds…\n\t\t\t* “Pot”\n\t\t\t\t* Starts with voiceless articulation of “Puh” \n\t\t\t\t* Needs a certain amount of air puff, otherwise people will perceive it as “Bot” \n\t\t\t\t\t* Perception of sounds depends on this kind of Phonology, spelling isn’t enough\n\t3. Morphology\n\t\t* the Study of words\n\t\t* more than just grouping sounds:\n\t\t\t* “Add an ’s’ to a group to make it plural”\n\t\t\t\t* Pot + s -> add s sound\n\t\t\t\t* Pan + s -> add z sound\n\t\t\t\t* Church + s -> add es sound\n\t\t\t-> So it’s more complicated. Can’t simply put an s on something.\n\t4. Syntax\n\t\t* Word order\n\t\t\t* There’s all kinds of patterns: Subject-Verb-Object is an example\n\t\t\t* Is there a principled way of writing a sentence in correct order?\n\t3. Semantic\n\t\t* Word meaning\n\t\t\t* All kinds of complications:\n\t\t\t\t* Difference between “chair” and “stool”?\n\t\t\t\t* There’s some precise difference between chair and stool that people agree on, but hard to define.\n\t\t* Hardest one to deal with in Computational Linguistics, but there is a way to do it. We’ll get there later. \n\n-> So “What is a language?” is too hard, but we can discuss “What are the morphological properties of a language?”\n\t* Note: Every language is going to have some set of sounds, but every language is different\n\t\t* So every property in a given language is arbitrarily different. \n\t* However, there are some shared elements:\n\t\t* Almost all languages have vowels, but that depends on how you look at it \n\t\t I don’t really know what he’s talking about right now, but I don’t think it matters.\n\n## Why are we using Prolog?\n\t* Closer to what we think the mind is doing. Not procedural.\n\t* Obviously, you wouldn’t write Siri in Prolog, but we’re able to focus more on the Linguistics this way.\n\t* We are going to try to come up with a “grammar” to model a language…\n\n## Goals of our Grammar\n\t1. Explicit\n\t\t* set of specific rules\n\t\t* Enough details that our Prolog declarations create a functioning program\n\t2. Accuracy \n\t\t* Needs to be recognizable as a real language\n\t\t* There will come a time where we have our rules all set up and the program spits out garbage. Caused by either too many or not enough rules. \n\t3. Principled-ness\n\t\t* We want to do what we think the mind is doing.\n\t\t* We don’t want to take shortcuts \n\t\t\t* Antithetical to regular programming where we optimize to get the same result faster\n\t\t* Don’t just make a series of hacky rules to generate the outcome we want\n\t4. Simplicity\n\t\t* We want the solution to be as simple as possible\n\t\t* But needs to be principled! \n\n## Introduction to Prolog\n\t* We are not giving Prolog commands to execute\n\t* We are giving Prolog a set of facts, some proceudure finds solutions based on facts we give it\n``` testword.swipl\nword(blah). %blah is a word\nword(X-blah) :- word(X). %something is a word if followed by blah\n```\n\n``` swipl\n?- ['testword.swipl'].\ntrue. \n?- word(Y). % give me all solutions that are a word\nblah ; \nblah-blah ;\nblah-blah-blah ;\n...\n```\n\n- - - -\n-> He’s explaining `spanish.swipl` (which is posted online)\n\n\n\n\n\n"},"directory_id":{"kind":"string","value":"c524e73e6c09e392c16605ff626da87482857625"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":8,"string":"8"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"andrewthecope/Lin177-Notes"},"revision_id":{"kind":"string","value":"87488bb1ae0308e840e13c8d32c9ef0331b90732"},"snapshot_id":{"kind":"string","value":"4fead44b6563796206658b3dbe8de20e1a975347"}}},{"rowIdx":9917,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"using System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\nusing System.Linq;\nusing System.Web;\n\nnamespace OGL.Models\n{\n public class Advertisement\n {\n [Key]\n [Display(Name = \"Id\")]\n public int Id { get; set; }\n\n [Display(Name = \"Advertisement content\")]\n [MaxLength(500)]\n [Required]\n public string Content { get; set; }\n\n [Display(Name = \"Advertisement title\")]\n [MaxLength(72)]\n [Required]\n public string Title { get; set; }\n\n [Display(Name = \"Add date\")]\n [DataType(DataType.Date)]\n [DisplayFormat(DataFormatString = \"{0:dd.MM.yyyy}\", ApplyFormatInEditMode = true)]\n [Required]\n public DateTime AddDateTime { get; set; }\n\n [Required]\n public string ApplicationUserId { get; set; }\n\n public virtual ICollection Advertisement_Category { get; set; }\n\n public virtual ApplicationUser ApplicationUser { get; set; }\n\n public Advertisement()\n {\n Advertisement_Category = new HashSet();\n }\n }\n}# OGL\n\nASP.NET MVC Simple learning project - advertisement service\n\nProject is based on:\n`C# 6.0 i MVC 5 - Tworzenie nowoczesnych portali internetowych`\nby `` and `` - `Helion`.\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel.DataAnnotations;\nusing System.Linq;\nusing System.Web;\n\nnamespace OGL.Models\n{\n public class Category\n {\n [Key]\n [Display(Name = \"Id\")]\n public int Id { get; set; }\n\n [Display(Name = \"Category name\")]\n [Required]\n public string Name { get; set; }\n\n [Display(Name = \"Parent id\")]\n [Required]\n public int ParentId { get; set; }\n\n #region SEO\n\n [Display(Name = \"Title in Google\")]\n [MaxLength(72)]\n public string MetaTitle { get; set; }\n\n [Display(Name = \"Description in Google\")]\n [MaxLength(160)]\n public string MetaDescription { get; set; }\n\n [Display(Name = \"Tags for Google\")]\n [MaxLength(160)]\n public string MetaTags { get; set; }\n\n [Display(Name = \"Page content\")]\n [MaxLength(500)]\n public string Content { get; set; }\n\n #endregion\n\n public virtual ICollection Advertisement_Category { get; set; }\n\n public Category()\n {\n Advertisement_Category = new HashSet();\n }\n }\n}using System.Data.Entity;\nusing System.Security.Claims;\nusing System.Threading.Tasks;\nusing Microsoft.AspNet.Identity;\nusing Microsoft.AspNet.Identity.EntityFramework;\nusing System.Data.Entity.ModelConfiguration.Conventions;\n\nnamespace OGL.Models\n{\n public class OglContext : IdentityDbContext\n {\n public DbSet Category { get; set; }\n public DbSet Advertisement { get; set; }\n public DbSet ApplicationUser { get; set; }\n public DbSet Advertisement_Category { get; set; }\n\n public OglContext() : base(\"DefaultConnection\")\n {\n }\n\n public static OglContext Create()\n {\n return new OglContext();\n }\n\n protected override void OnModelCreating(DbModelBuilder modelBuilder)\n {\n base.OnModelCreating(modelBuilder);\n\n // disable auto tables rename when generating database from code model\n modelBuilder.Conventions.Remove();\n\n // disable default cascade delete and configure fluent api\n modelBuilder.Conventions.Remove();\n modelBuilder.Entity()\n .HasRequired(x => x.ApplicationUser)\n .WithMany(x => x.Advertisement)\n .HasForeignKey(x => x.ApplicationUserId)\n .WillCascadeOnDelete(true);\n }\n }\n}"},"directory_id":{"kind":"string","value":"613a2b80cbc28454fb70b3625f232e9445e68694"},"languages":{"kind":"list like","value":["C#","Markdown"],"string":"[\n \"C#\",\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":4,"string":"4"},"repo_language":{"kind":"string","value":"C#"},"repo_name":{"kind":"string","value":"gabr/OGL"},"revision_id":{"kind":"string","value":"ca21d373f14ec505099cde4b9e98564cd4b3a311"},"snapshot_id":{"kind":"string","value":"34e048b8b01c8f163ae8c1ef9ae25d98970af47f"}}},{"rowIdx":9918,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"#!/usr/bin/env bash\n\nssserver -m chacha20-ietf-poly1305 \\\n -p 443 \\\n -k password \\\n $*\n# docker-shadowsocks\nA light shadowsocks server.\n\n```\n# docker run -d \\\n --restart=always \\\n -p :443 \\\n abreto/shadowsocks[ -k ][ --workers ]\n```\n# Shadowsocks\nFROM ubuntu\n\nLABEL maintainer=\"Abreto<>\"\n\nRUN apt-get update && apt-get install -qy \\\n git \\\n python-pip \\\n python-pysodium\n\nRUN pip install git+https://github.com/shadowsocks/shadowsocks.git@master\n\nWORKDIR /bootstrap\nCOPY entrypoint.sh .\n\nEXPOSE 443\nENTRYPOINT [ \"bash\", \"entrypoint.sh\" ]\n"},"directory_id":{"kind":"string","value":"37d78fce9ea4dd74a523c6d8c643718bce8e6723"},"languages":{"kind":"list like","value":["Markdown","Shell","Dockerfile"],"string":"[\n \"Markdown\",\n \"Shell\",\n \"Dockerfile\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Abreto/docker-shadowsocks"},"revision_id":{"kind":"string","value":"a649b2227d35b20f662e92b1c2bbd34588309fbc"},"snapshot_id":{"kind":"string","value":"6f61d4759c29d4d208bd22c7eb4adc32908189c1"}}},{"rowIdx":9919,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"oriyanh/Bridge-AI/trick.py\nfrom copy import copy\nfrom typing import Dict, KeysView, ValuesView, ItemsView\n\nfrom cards import Suit, Card\nfrom players import POSITIONS, Player, PositionEnum\n\n\nclass Trick:\n \"\"\"\n A set of 4 cards played by each player in turn, during the play of a deal.\n \"\"\"\n\n def __init__(self, trick, starting_suit=None):\n self.trick: Dict[Player, Card] = trick\n self.starting_suit = starting_suit # type: Suit\n\n def __len__(self):\n return len(self.trick)\n\n def __copy__(self):\n trick = Trick({})\n for player, card in self.trick.items():\n trick.add_card(copy(player), card)\n return trick\n\n def create_from_other_players(self, players):\n new_trick = Trick({}, self.starting_suit)\n if self.trick is None:\n return new_trick\n for player in players:\n card = self.trick.get(player)\n if card:\n new_trick.add_card(player, card)\n return new_trick\n\n def players(self) -> KeysView[Player]:\n \"\"\"\n Get all players with cards in current trick.\n :return: Iterable of all players.\n \"\"\"\n return self.trick.keys()\n\n def cards(self) -> ValuesView[Card]:\n \"\"\"\n Get all cards in current trick.\n :return: Iterable of all cards.\n \"\"\"\n return self.trick.values()\n\n def items(self) -> ItemsView[Player, Card]:\n \"\"\"\n Get all pairs of players and their cards in current trick.\n :return: Iterable of all pairs.\n \"\"\"\n return self.trick.items()\n\n def add_card(self, player: Player, card: Card) -> None:\n \"\"\"\n Add player's action to trick.\n :param player: The player placing the action.\n :param card: The action being played.\n :return: None\n \"\"\"\n assert (player not in self.trick)\n if not self.trick:\n self.starting_suit = card.suit\n self.trick[player] = card\n\n def get_card(self, player: Player) -> Card:\n \"\"\"\n Get the action that a player played.\n :param player: The player who's action in wanted.\n :return: The played action.\n \"\"\"\n return self.trick.get(player)\n\n def get_winner(self) -> PositionEnum:\n \"\"\"\n If all players played - return player with highest action.\n :return: Winning player.\n \"\"\"\n assert (len(self.trick) == len(POSITIONS))\n relevant_players = []\n for player, card in self.items():\n if card.is_trump or card.suit == self.starting_suit:\n relevant_players.append(player)\n return max(relevant_players, key=self.trick.get).position\n\n def reset(self) -> None:\n \"\"\"\n Reset trick.\n :return: None\n \"\"\"\n self.trick: Dict[Player, Card] = {}\n self.starting_suit = None\n/README.md\n# Double Dummy Bridge Solver\nIn this project we try to create a sophisticated computer agent to play the Contact Bridge card game. Our goal is to develop an agent that is tough to play against, with fast reaction time so it is able to play in real time against humans. We approached this as a search problem, and implemented search-tree heuristics based on Minimax and Monte Carlo Tree Search.
\nImplemented as a final project for the \"Introduction to Aritifical Intelligence\" course of the Hebrew University of Jerusalem.
\n\n# Running Instructions\n* Create a `virtualenv` with `python3.7` - `virtualenv -p python3.7 venv` \n* Activate virtual environment - `source venv/bin/activate.csh` if using `tcsh`; if using `bash`, use `source venv/bin/activate`\n* `pip install -r requirements.txt` to install project dependencies.\n* To run a match, run `python3.7 match.py --agent1 --agent2 --num_games --verbose_mode <0/1>` where each agent encoding is of the form described in match.py’s documentation.\n* When done, run `deactivate` to deactivate the virtual environment\n\nWe encourage you to try and run match.py with some of the following arguments preferably from a console outside of an IDE (during the game press the Enter key to perform the next action):\n\nSimple vs Simple:\n* `--agent1 Random --agent2 Random`\n* `--agent1 HighestFirst --agent2 SoftLongGreedy`\n\nAlphaBeta vs Simple:\n* `--agent1 AlphaBeta-ShortGreedyEvaluation-5 --agent2 LowestFirst`\n* `--agent1 AlphaBeta-LongGreedyEvaluation-10 --agent2 Random`\n* `--agent1 AlphaBeta-HandEvaluation-5 --agent2 HighestFirst`\n* `--agent1 AlphaBeta-CountOfTricksWon-10 --agent2 HighestFirst`\n\nMCTS vs Simple:\n* `--agent1 MCTS-simple-HardLongGreedy-50 --agent2 HardShortGreedy`\n* `--agent1 MCTS-stochastic-Random-500 --agent2 SoftShortGreedy`\n* `--agent1 MCTS-pure-LowestFirst-250 --agent2 Random`\n\nIf you wish to run games automatically without seeing each game state and without pressing Enter after each move, add the argument “--verbose_mode 0”.\nFor more arguments, refer to `match.py`.\n
\n# Authors\n* \n* \n* \n* \n
\n/match.py\n\"\"\"\nrun with the following arguments:\n--agent1 --agent2 --num_games \n\nWhere each agent encoding is of in one of the following forms:\nSimple-\nAlphaBeta--\nMCTS-<'simple'/'stochastic'/'pure'>--\nHuman\n\nOptional arguments:\n--name_games - defaults to 100\n--verbose_mode - if 0, will only print end result of match with no user interaction. If 1, enter interactive mode.\n--seed - if a number >= 0, set random seed of match for reproducibility. Else, use system default value.\n\"\"\"\n\nimport os\nimport sys\nimport numpy as np\nfrom argparse import ArgumentParser, ArgumentTypeError\nfrom time import perf_counter\nfrom tqdm import tqdm\n\nfrom game import Game\nfrom multi_agents import *\nfrom trick import Trick\n\n\nclass Match:\n \"\"\" Represents a series of games of bridge, with same opponents.\"\"\"\n\n def __init__(self,\n agent: IAgent,\n other_agent: IAgent,\n num_games: int,\n verbose_mode: bool = True,\n cards_in_hand: int = 13):\n self.agent = agent\n self.other_agent = other_agent\n self.num_games = num_games\n self.verbose_mode = verbose_mode\n self.cards_in_hand = cards_in_hand\n\n self.games_counter: List[int] = [0, 0, ] # [Team 0, Team 1]\n\n def __str__(self):\n ret = \"\"\n\n ret += f\"Total score: \" \\\n f\"{self.games_counter[0]:02} - {self.games_counter[1]:02}\\n\"\n\n return ret\n\n def run(self) -> None:\n \"\"\"\n Main match runner.\n :return: None\n \"\"\"\n\n start_t = perf_counter()\n for _ in tqdm(range(self.num_games),\n leave=False, disable=self.verbose_mode, file=sys.stdout):\n curr_game = create_game(self.agent, self.other_agent,\n self.games_counter, self.verbose_mode,\n cards_in_hand=self.cards_in_hand)\n curr_game.run()\n self.games_counter[curr_game.winning_team] += 1\n end_t = perf_counter()\n if self.verbose_mode:\n os.system('clear' if 'linux' in sys.platform else 'cls')\n print(self)\n print(self)\n print(f\"Total time for match: {end_t - start_t} seconds; \"\n f\"Average {(end_t - start_t) / float(self.num_games)} \"\n f\"seconds per game\")\n\n\ndef create_game(agent, other_agent, games_counter, verbose_mode,\n from_db=False, cards_in_hand=13):\n \"\"\" Returns Game object, either new random game or a game initialized from game DB\"\"\"\n if from_db:\n pass\n # todo(maryna): create single game from db. pay attention to players\n # initialization + the iterator.\n trick_counter = [0, 0, ] # [Team 0, Team 1]\n previous_tricks = []\n game = Game(agent, other_agent, games_counter, trick_counter, verbose_mode,\n previous_tricks, Trick({}), cards_in_hand=cards_in_hand)\n return game\n\n\ndef parse_args():\n \"\"\" Parses command line arguments. Returns namespace of arguments.\"\"\"\n parser = ArgumentParser()\n parser.add_argument('--agent1', required=True)\n parser.add_argument('--agent2', required=True)\n parser.add_argument('--num_games', type=int, default=100)\n parser.add_argument('--cards_in_hand', type=int, default=13)\n parser.add_argument('--verbose_mode', type=int, default=1)\n parser.add_argument('--seed', type=int, default=-1)\n\n return parser.parse_args()\n\n\ndef str_to_agent(agent_str):\n agent_str = agent_str.split('-')\n if agent_str[0] == \"Simple\": # Simple agent\n if agent_str[1] in simple_agent_names:\n return SimpleAgent(\n simple_func_names[simple_agent_names.index(\n agent_str[1])])\n else:\n print(\"Bad arguments for Simple agent. Should be:\\n\"\n \"Simple-\")\n return -1\n\n elif agent_str[0] == \"AlphaBeta\": # AlphaBeta agent\n if agent_str[1] in simple_agent_names:\n return AlphaBetaAgent(\n evaluation_function=ab_evaluation_func_names[\n ab_evaluation_agent_names.index(agent_str[1])],\n depth=int(agent_str[2]))\n else:\n print(\"Bad arguments for AlphaBeta agent. Should be:\\n\"\n \"AlphaBeta--\")\n return -1\n\n elif agent_str[0] == \"MCTS\": # MCTS agent\n if agent_str[1] == 'simple':\n return SimpleMCTSAgent(\n action_chooser_function=simple_func_names[\n simple_agent_names.index(agent_str[2])],\n num_simulations=int(agent_str[3]))\n elif agent_str[1] == 'stochastic':\n return StochasticSimpleMCTSAgent(\n action_chooser_function=simple_func_names[\n simple_agent_names.index(agent_str[2])],\n num_simulations=int(agent_str[3]))\n elif agent_str[1] == 'pure':\n return PureMCTSAgent(\n action_chooser_function=simple_func_names[\n simple_agent_names.index(agent_str[2])],\n num_simulations=int(agent_str[3]))\n else:\n print(\"Bad arguments for MCTS agent. Should be:\\n\"\n \"MCTS-<'simple'/'stochastic'/'pure'>-\"\n \"-\")\n return -1\n\n elif agent_str[0] == \"Human\": # Human agent\n return HumanAgent()\n\n else:\n raise ArgumentTypeError()\n\n\ndef run_match():\n try:\n a0 = str_to_agent(args.agent1)\n a1 = str_to_agent(args.agent2)\n except ArgumentTypeError:\n print(\"ArgumentTypeError: Bad arguments usage\", file=sys.stderr)\n print(f\"USAGE: run with the following arguments - \", file=sys.stderr)\n print(\" python3.7 match.py --agent1 --agent2 [--cards_in_hand --num_games --verbose_mode --seed ]\\n\"\n \"Where each agent encoding is of in one of the following forms:\\n\"\n \"* Simple-\\n\"\n \"* AlphaBeta--\\n\"\n \"* MCTS-<'simple'/'stochastic'/'pure'>--\\n\"\n \"* Human\", file=sys.stderr)\n exit(1)\n\n match = Match(agent=a0,\n other_agent=a1,\n num_games=args.num_games,\n verbose_mode=bool(args.verbose_mode),\n cards_in_hand=args.cards_in_hand)\n match.run()\n\n\nif __name__ == '__main__':\n args = parse_args()\n if args.seed >= 0:\n np.random.seed(args.seed)\n run_match()\n input(\"Press Enter button to exit\")\n/multi_agents.py\nimport numpy as np\nfrom abc import ABC, abstractmethod\nfrom collections import defaultdict\nfrom concurrent.futures.thread import ThreadPoolExecutor\nfrom copy import copy\nfrom queue import Queue\nfrom typing import Dict, List, Set\n\nfrom cards import Card\nfrom game import SimulatedGame\nfrom players import is_players_in_same_team, get_legal_actions, PLAYERS_CYCLE\nfrom state import State\n\nsimple_func_names = [\n 'highest_first_action',\n 'lowest_first_action',\n 'random_action',\n 'hard_short_greedy_action',\n 'hard_long_greedy_action',\n 'soft_short_greedy_action',\n 'soft_long_greedy_action',\n]\n\nsimple_agent_names = [\n 'HighestFirst',\n 'LowestFirst',\n 'Random',\n 'HardShortGreedy',\n 'HardLongGreedy',\n 'SoftShortGreedy',\n 'SoftLongGreedy',\n]\n\nab_evaluation_func_names = [\n 'greedy_evaluation_function1',\n 'greedy_evaluation_function2',\n 'hand_evaluation_heuristic',\n 'count_tricks_won_evaluation_function',\n]\n\nab_evaluation_agent_names = [\n 'ShortGreedyEvaluation',\n 'LongGreedyEvaluation',\n 'HandEvaluation',\n 'CountOfTricksWon',\n]\n\n\ndef lookup(name, namespace):\n \"\"\"\n Get a method or class from any imported module from its name.\n Usage: lookup(functionName, globals())\n :returns: method/class reference\n :raises Exception: If the number of classes/methods existing in namespace with name is != 1\n \"\"\"\n\n dots = name.count('.')\n if dots > 0:\n module_name, obj_name = '.'.join(name.split('.')[:-1]), name.split('.')[-1]\n module = __import__(module_name)\n return getattr(module, obj_name)\n else:\n modules = [obj for obj in namespace.values() if str(type(obj)) == \"\"]\n options = [getattr(module, name) for module in modules if name in dir(module)]\n options += [obj[1] for obj in namespace.items() if obj[0] == name]\n if len(options) == 1:\n return options[0]\n if len(options) > 1:\n raise Exception('Name conflict for %s')\n raise Exception('%s not found as a method or class' % name)\n\n\nclass IAgent(ABC):\n \"\"\" Interface for bridge-playing agents.\"\"\"\n\n @abstractmethod\n def __init__(self, target):\n self.target = target # TODO [oriyan] Not completely sure what this should be -\n # it is only used in one place compared to a player's score.\n # Do we need this? Investigate later.\n\n @abstractmethod\n def get_action(self, state: State) -> Card:\n \"\"\"\n Pick a action to play based on the environment and a programmed strategy.\n :param state:\n :return: The action to play.\n \"\"\"\n raise NotImplementedError\n\n\n# ------------------------------------SimpleAgent------------------------------------- #\n\nclass SimpleAgent(IAgent):\n \"\"\" Deterministic agent that plays according to input action.\"\"\"\n\n def __init__(self, action_chooser_function='random_action', target=None):\n \"\"\"\n\n :param str action_chooser_function: name of action to take, or a function.\n Function should map State -> Card\n :param target: See comment in IAgent's constructor\n \"\"\"\n\n if isinstance(action_chooser_function, str):\n self.action_chooser_function = lookup(action_chooser_function, globals())\n else:\n self.action_chooser_function = action_chooser_function\n super().__init__(target)\n\n def get_action(self, state):\n return self.action_chooser_function(state)\n\n\ndef random_action(state):\n \"\"\"\n Picks random action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n return np.random.choice(state.get_legal_actions())\n\n\ndef lowest_first_action(state):\n \"\"\"\n Always picks the lowest value action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n return min(state.get_legal_actions())\n\n\ndef highest_first_action(state):\n \"\"\"\n Always picks the highest value action\n :param State state:\n :returns Card: action to take\n \"\"\"\n return max(state.get_legal_actions())\n\n\ndef hard_short_greedy_action(state):\n \"\"\"\n If can beat current trick cards - picks highest value action available.\n If cannot - picks lowest value action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n legal_moves = state.get_legal_actions()\n best_move = max(legal_moves)\n if len(state.trick) == 0: # Trick is empty - play best action.\n return best_move\n\n best_in_current_trick = max(state.trick.cards())\n worst_move = min(legal_moves)\n\n if best_move > best_in_current_trick: # Can be best in current trick.\n return best_move\n else: # Cannot win - play worst action.\n return worst_move\n\n\ndef hard_long_greedy_action(state):\n \"\"\"\n If can beat current trick cards - picks highest value action available.\n If cannot - picks lowest value action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n legal_moves = state.get_legal_actions()\n best_move = max(legal_moves)\n worst_move = min(legal_moves)\n\n # pick a first card in trick that possibly could lead to win\n if len(state.trick) == 0: # Trick is empty - play best action.\n cards = starting_trick_cards(state)\n if len(cards) > 0:\n return max(cards)\n return worst_move\n\n best_in_current_trick = max(state.trick.cards())\n\n # if there are cards in the trick- try to play a winning card against the hands of the\n # opponent and the cards in the trick\n op_cards = get_opponents_legal_card(state)\n if op_cards is not None:\n opponent_best = max(op_cards)\n card_to_win = max([opponent_best, best_in_current_trick])\n if best_move > card_to_win:\n return best_move\n\n # if the opponent has no legal card, try to get the trick\n elif best_move > best_in_current_trick:\n return best_move\n # Cannot win - play worst action.\n return worst_move\n\n\ndef soft_short_greedy_action(state):\n \"\"\"\n If can beat current trick cards - picks the lowest value action available\n that can become the current best in trick.\n If cannot - picks lowest value action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n legal_moves = state.get_legal_actions()\n worst_move = min(legal_moves)\n best_move = max(legal_moves)\n\n if len(state.trick) == 0: # Trick is empty - play worst action.\n return worst_move\n\n best_in_current_trick = max(state.trick.cards())\n\n if best_move > best_in_current_trick: # Can be best in current trick.\n weakest_wining_move = min(filter(lambda move: move > best_in_current_trick, legal_moves))\n return weakest_wining_move\n return worst_move # Cannot win - play worst action.\n\n\ndef soft_long_greedy_action(state):\n \"\"\"\n If can beat current trick cards - picks the lowest value action available\n that can become the current best in trick.\n If cannot - picks lowest value action.\n :param State state:\n :returns Card: action to take\n \"\"\"\n legal_moves = state.get_legal_actions()\n worst_move = min(legal_moves)\n best_move = max(legal_moves)\n\n # pick a first card in trick that possibly could lead to win\n if len(state.trick) == 0: # Trick is empty - play worst action.\n cards = starting_trick_cards(state)\n if len(cards) > 0:\n return min(cards)\n return worst_move\n\n best_in_current_trick = max(state.trick.cards())\n\n # if there are cards in the trick- try to play a winning card against the hands of the\n # opponent and the cards in the trick\n op_cards = get_opponents_legal_card(state)\n if op_cards is not None:\n opponent_best = max(op_cards)\n card_to_win = max([opponent_best, best_in_current_trick])\n wining_moves = list(filter(lambda move: move > card_to_win, legal_moves))\n if len(wining_moves) > 0:\n return min(wining_moves)\n\n # if the opponent has no legal card, try to get the trick\n elif best_move > best_in_current_trick:\n weakest_wining_move = min(filter(lambda move: move > best_in_current_trick, legal_moves))\n return weakest_wining_move\n # Cannot win - play worst action.\n return worst_move\n\n\ndef get_opponents_legal_card(state):\n \"\"\"\n used unly in case the trick is initialized and the current player in the trick has an\n opponent that will play the trick later.\n :param state:\n :return: the cards of the opponent of the current player\n \"\"\"\n i = len(state.trick)\n op_cards = None\n if i == 1 or i == 2:\n opponent = state.players_pos[PLAYERS_CYCLE[state.curr_player.position]]\n op_cards = get_legal_actions(state.trick.starting_suit, opponent, state.already_played)\n return op_cards\n\n\ndef starting_trick_cards(state):\n \"\"\"\n pick the cards for openning the trick, trying to win it.\n The list will hold the following cards:\n If current player has a winning card against all other hands of player.\n If the teammate of the current player has a winning card of a suit the current player will play\n If the other players has no cards in the suit\n If the other teammate doesn't have cards in suit but can win against other trumps\n :param state:\n :return:\n \"\"\"\n curr_player_moves = state.get_legal_actions()\n\n # all opponent's hands united to single list of cards to observe\n opp_reg_cards, opp_trump_cards, teammate_reg_cards, teammate_trump_cards = \\\n get_hand_trump_opponent_teammate(state)\n\n cards = []\n for card in curr_player_moves:\n # the opponent has cards of the current suit. trump cards are part of legal cards,\n # hence the highest card is both from the suit or from trump card.\n if opp_reg_cards.get(card.suit.suit_type) is not None:\n best_curr = card\n if len(teammate_trump_cards) > 0:\n best_curr = max([teammate_trump_cards[-1], card])\n if teammate_reg_cards.get(card.suit.suit_type):\n best_curr = max([teammate_reg_cards[card.suit.suit_type][-1], best_curr])\n best_opp = opp_reg_cards[card.suit.suit_type][-1]\n if len(opp_trump_cards) > 0:\n best_opp = max(best_opp, opp_trump_cards[-1])\n # if the best card of curr team is winning against the strongest legal card of the\n # opponent- the card suggested to open the trick\n if best_curr > best_opp:\n cards.append(card)\n else:\n # the opponent has no cards of the suit. hence he will play trump card or a card\n # from other suit. only trump card could possibly win the trick\n if len(teammate_trump_cards) > 0:\n if len(opp_trump_cards) > 0:\n best_curr = teammate_trump_cards[-1]\n best_opp = opp_trump_cards[-1]\n if best_curr > best_opp:\n cards.append(card)\n else:\n cards.append(card)\n else:\n if not len(opp_trump_cards) > 0:\n cards.append(card)\n return cards\n\n\ndef get_hand_trump_opponent_teammate(state):\n opp1 = state.players_pos[PLAYERS_CYCLE[state.curr_player.position]]\n teammate = state.players_pos[PLAYERS_CYCLE[opp1.position]]\n opp2 = state.players_pos[PLAYERS_CYCLE[teammate.position]]\n\n # the following hands are sorted. 1st card is the smallest\n opp1_reg_cards, opp1_trump_cards = opp1.hand.get_cards_sorted_by_suits(state.already_played)\n opp2_reg_cards, opp2_trump_cards = opp2.hand.get_cards_sorted_by_suits(state.already_played)\n opp1_reg_cards.update(opp2_reg_cards)\n opp_reg_cards = opp1_reg_cards\n opp_trump_cards = opp1_trump_cards + opp2_trump_cards\n\n teammate_reg_cards, teammate_trump_cards = teammate.hand.get_cards_sorted_by_suits(\n state.already_played)\n return opp_reg_cards, opp_trump_cards, teammate_reg_cards, teammate_trump_cards\n\n\ndef add_randomness_to_action(func, epsilon):\n \"\"\"\n Wraps a `State->Card` function with a randomizing factor -\n w.p. epsilon, action is chosen at random.\n :param func: `State->Card` function\n :param float epsilon: Probability of choosing action at random. In range [0,1]\n :returns: Function mapping `State->Card` with additional randomizing factor\n \"\"\"\n\n def randomized_action(state):\n if np.random.rand() < epsilon:\n return random_action(state)\n return func(state)\n\n return randomized_action\n\n\n# ---------------------------MultiAgentSearchAgent--------------------------- #\nclass MultiAgentSearchAgent(IAgent):\n \"\"\"Abstract agent implementing IAgent that searches a game tree\"\"\"\n\n def __init__(self, evaluation_function='score_evaluation_function',\n depth=2, target=None):\n \"\"\"\n :param evaluation_function: function mapping (State, *args) -> Card ,\n where *args is determined by the agent itself.\n :param int depth: -1 for full tree, any other number > 1 for depth bounded tree\n :param target:\n \"\"\"\n self.evaluation_function = lookup(evaluation_function, globals())\n self.depth = depth\n super().__init__(target)\n\n def get_action(self, state):\n return NotImplementedError\n\n\nclass AlphaBetaAgent(MultiAgentSearchAgent):\n \"\"\" Agent implementing AlphaBeta pruning (with MinMax tree search)\"\"\"\n\n def __init__(self, evaluation_function='count_tricks_won_evaluation_function',\n depth=2, target=None):\n super().__init__(evaluation_function, depth, target)\n\n def get_action(self, state):\n legal_moves = state.get_legal_actions()\n successors = [state.get_successor(action=action)\n for action in legal_moves]\n\n if self.depth == 0:\n scores = [self.evaluation_function(successor)\n for successor in successors]\n best_score = max(scores)\n best_indices = [index for index in range(len(scores))\n if scores[index] == best_score]\n chosen_index = np.random.choice(best_indices) # Pick randomly among the best\n return legal_moves[chosen_index]\n else:\n a, b = -np.inf, np.inf\n chosen_index = 0\n for i, successor in enumerate(successors):\n next_child_score = self.score(successor, self.depth,\n 1, False, a, b)\n if next_child_score > a:\n chosen_index = i\n a = next_child_score\n if b <= a:\n break\n return legal_moves[chosen_index]\n\n def score(self, state, max_depth, curr_depth, is_max, a, b):\n \"\"\" Recursive method returning score for current state (the node in search tree).\n\n :param State state: State of game\n :param int max_depth: Max tree depth to search\n :param int curr_depth: Current depth in search tree\n :param bool is_max: True if current player is Max player, False if Min player\n :param float a: Current alpha score\n :param float b: Current beta score\n :returns float: Score for current state (the node)\n \"\"\"\n if curr_depth >= max_depth:\n return self.evaluation_function(state, is_max, self.target)\n\n # get current player moves\n curr_player = state.curr_player\n legal_moves = state.get_legal_actions()\n\n if not legal_moves:\n return self.evaluation_function(state, is_max, self.target)\n possible_states = [state.get_successor(action=action)\n for action in legal_moves]\n\n if is_max:\n for next_state in possible_states:\n next_player = next_state.curr_player\n is_next_max = True if is_players_in_same_team(curr_player, next_player) else False\n next_depth = curr_depth if is_next_max else curr_depth + 1\n if not is_next_max:\n b = min((b, self.score(next_state, max_depth, next_depth, is_next_max, a, b)))\n else:\n a = max((a, self.score(next_state, max_depth, next_depth, is_next_max, a, b)))\n if b <= a:\n break\n return a\n\n for next_state in possible_states:\n next_player = next_state.curr_player\n is_next_max = False if is_players_in_same_team(curr_player, next_player) else True\n next_depth = curr_depth + 1 if is_next_max else curr_depth\n if is_next_max:\n a = max((a, self.score(next_state, max_depth, next_depth, is_next_max, a, b)))\n else:\n b = min((b, self.score(next_state, max_depth, next_depth, is_next_max, a, b)))\n if b <= a:\n break\n return b\n\n\ndef is_target_reached_evaluation_function(state, is_max=True, target=None):\n \"\"\"\n Score of state is 1 if current player is Max player and target has been reached.\n 0 Otherwise.\n\n :param State state: game state\n :param bool is_max: is max player\n :param target:\n :returns float: score of state\n \"\"\"\n if not target:\n return 0\n # if max return True if met the score of the team of the current player\n # else return if the opposite team met the required score\n player_score = state.get_score(is_max)\n if target <= player_score:\n return 1\n return 0\n\n\ndef count_tricks_won_evaluation_function(state, is_max=True, target=None):\n \"\"\"\n weighted score of current state with respect to is_max, and number of tricks this player has won.\n\n :param State state: game state\n :param bool is_max: is max player\n :param target:\n :returns float: score of state\n \"\"\"\n return state.get_score(is_max)\n\n\ndef greedy_evaluation_function1(state, is_max=True, target=None):\n \"\"\"\n returns a value for the gives state, calculated by count of legal moves of the current \n player, ignoring the hands of other players.\n :param State state: game state\n :param bool is_max: is max player\n :param target:\n :returns float: score of state\n \"\"\"\n value = state.get_score(is_max)\n if len(state.trick) == 0: # Trick is empty - play worst action.\n return value\n\n greedy_moves_count = greedy_legal_moves_count1(state)\n return 13 * value + greedy_moves_count\n\n\ndef greedy_evaluation_function2(state, is_max=True, target=None):\n \"\"\"\n returns a value for the gives state, calculated by count of legal winning moves by observing \n the hands of all the players in the game.\n :param State state: game state\n :param bool is_max: is max player\n :param target:\n :returns float: score of state\n \"\"\"\n value = state.get_score(is_max)\n greedy_moves_count = greedy_legal_moves_count2(state)\n return 13 * value + greedy_moves_count\n\n\ndef greedy_legal_moves_count1(state):\n legal_moves = state.get_legal_actions()\n best_move = max(legal_moves)\n best_in_current_trick = max(state.trick.cards())\n if best_move > best_in_current_trick: # Can be best in current trick.\n count_wining_moves = len(list(filter(lambda move: move > best_in_current_trick,\n legal_moves)))\n return count_wining_moves\n return 0\n\n\ndef greedy_legal_moves_count2(state):\n legal_moves = state.get_legal_actions()\n wining_moves_count= 0\n i = len(state.trick)\n if i == 0:\n cards = starting_trick_cards(state)\n wining_moves_count = 1 if len(cards) > 0 else 0\n else:\n best_in_current_trick = max(state.trick.cards())\n if i == 1 or i == 2:\n opponent_legal_cards = get_opponents_legal_card(state)\n opponent_best = max(opponent_legal_cards)\n card_to_win = max([opponent_best, best_in_current_trick])\n wining_moves = list(filter(lambda move: move > card_to_win, legal_moves))\n teammate = state.players_pos[PLAYERS_CYCLE[PLAYERS_CYCLE[state.curr_player.position]]]\n teammate_legal_moves = get_legal_actions(state.trick.starting_suit, teammate, state.already_played)\n teammate_wining_moves = list(filter(lambda move: move > card_to_win, teammate_legal_moves))\n wining_moves_count = 2 * len(wining_moves) + len(teammate_wining_moves)\n wining_moves_count = 1 if wining_moves_count > 0 else 0\n if i == 3:\n best_move = max(legal_moves)\n if best_move > best_in_current_trick:\n wining_moves_count = len(list(filter(lambda move: move > best_in_current_trick,\n legal_moves)))\n wining_moves_count = 1 if wining_moves_count > 0 else 0\n return wining_moves_count\n\n\ndef hand_evaluation_heuristic(state, is_max=True, target=None):\n \"\"\"\n returns the value of the hand, evaluated by giving highest value for each card, and taking\n advantage of hands containing more cards of a same suit.\n :param state: \n :param is_max: \n :param target: \n :return: \n \"\"\"\n value = state.get_score(is_max)\n hand_value = state.curr_player.hand.get_hand_value(state.already_played)\n return 13 * value + hand_value\n\n\n# ---------------------------------MCTSAgent--------------------------------- #\n\nclass SimpleMCTSAgent(IAgent):\n \"\"\" Agent implementing simplified version of MCTS -\n only looks at end-results of simulation, without backpropogation.\n Our agent's local decision rule is decided by `action_chooser_function`, while\n the opponent's local decisions are chosen randomly.\"\"\"\n\n def __init__(self, action_chooser_function='random_action', num_simulations=100):\n \"\"\"\n\n :param str action_chooser_function: See `super().__init__()` docstring\n :param int num_simulations: How many simulations for rollout\n \"\"\"\n\n self.action_chooser_function = lookup(action_chooser_function,\n globals())\n self.num_simulations_total = 0\n self.action_value = defaultdict(lambda: 0) # type: Dict[Card, int] # Maps values of playable actions\n self.num_simulations = num_simulations\n self.executor = ThreadPoolExecutor()\n super().__init__(None)\n\n def get_action(self, state):\n action = self.rollout(state, self.num_simulations)\n return action\n\n def rollout(self, state, num_simulations):\n \"\"\"\n Performs `num_simulations` rollouts - i.e. stochastically simulate `num_simlations` games.\n\n :param State state: Current state of the game\n :param int num_simulations: How many games to simulate. Our agent's choices are made according to `action_chooser_function`\n while the opoonent's are chosen randomly.\n :returns Card: Best action\n \"\"\"\n\n legal_actions = state.get_legal_actions()\n rollout_actions = np.random.choice(legal_actions, # Pre-select initial actions\n size=num_simulations, replace=True)\n best_action = np.random.choice(legal_actions)\n\n # Simulate games on separate threads\n games = [SimulatedGame(SimpleAgent(self.action_chooser_function),\n SimpleAgent('random_action'), False,\n state, action) for action in rollout_actions]\n futures = [self.executor.submit(game.run) for game in games]\n futures_queue = Queue(num_simulations)\n for future in futures:\n futures_queue.put(future)\n\n # Poll threads for termination. Each future's return value is a boolean.\n while not futures_queue.empty():\n future = futures_queue.get()\n futures_queue.task_done()\n if future.running():\n futures_queue.put(future)\n else:\n assert future.result()\n\n # Collect results\n for game in games:\n assert game.winning_team != -1\n winning_team = game.teams[game.winning_team]\n if winning_team.has_player(state.curr_player):\n self.action_value[game.starting_action] += 1\n\n self.num_simulations_total += 1\n\n # Choose best action\n for action in legal_actions:\n best_action = action if self.action_value[action] > self.action_value[best_action] \\\n else best_action\n\n return best_action\n\n\nclass StochasticSimpleMCTSAgent(SimpleMCTSAgent):\n \"\"\" Same as `SimpleMCTSAgent`, but with randomness injected into\n our agent's choices within simulations.\"\"\"\n\n def __init__(self, action_chooser_function='random_action', num_simulations=100, epsilon=0.1):\n \"\"\"\n\n :param action_chooser_function: See `super().__init__()` docstring\n :param num_simulations: See `super().__init__()` docstring\n :param float epsilon: Value in range [0,1]. w.p. `epsilon` our agent chooses random action.\n \"\"\"\n\n assert 0 <= epsilon <= 1\n super().__init__(action_chooser_function, num_simulations)\n self.epsilon = epsilon\n self.action_chooser_function = add_randomness_to_action(self.action_chooser_function, self.epsilon)\n\n\nclass PureMCTSAgent(SimpleMCTSAgent):\n \"\"\" Implements the full MCTS algorithm, in context of Bridge.\"\"\"\n\n def __init__(self, action_chooser_function='random_action', num_simulations=100):\n \"\"\"\n\n :param str action_chooser_function: See `super().__init__()` docstring\n :param int num_simulations: How many simulations for rollout\n \"\"\"\n\n self.action_chooser_function = lookup(action_chooser_function,\n globals())\n super().__init__(action_chooser_function, num_simulations)\n # self.root = None # type: MCTSNode\n self.root = None # type: MCTSNode\n\n def get_action(self, state):\n if not state.prev_tricks:\n # New game, first play for current player, create new root\n # self.roots[state.curr_player] = MCTSNode(state)\n self.root = MCTSNode(state)\n\n else:\n # Need to remove impossible paths from tree\n self.prune_tree(state)\n\n # Prepare tree for evaluation of best move\n # root = self.roots[state.curr_player]\n root = self.root\n for _ in range(0, self.num_simulations):\n # Exploration stage\n expanded_node = self.explore(root)\n # Rollout stage\n reward = expanded_node.rollout()\n # Backpropogation stage\n expanded_node.backpropagate(reward)\n\n # Exploitation stage\n best_child = root.best_child(uct_param=1.4)\n best_action = best_child.parent_action\n\n return best_action\n def prune_tree(self, state):\n \"\"\"\n Removes unreachable paths from tree, and updates root node.\n :param State state: current game state\n \"\"\"\n\n if not state.prev_tricks: # new game, no need for pruning\n return\n\n # Evaluates plays since last time current player played\n prev_trick = state.prev_tricks[-1]\n\n curr_trick = state.trick\n actions = []\n for player in state.players:\n action = prev_trick.get_card(player)\n if not action:\n action = curr_trick.get_card(player)\n assert action is not None\n actions.append(action)\n\n current_root = self.root\n next_root = None\n # Traverse tree according to order of play.\n # Tree may not contain this path due to nature of MCTS, in which case we create a new tree.\n for child in current_root.children:\n if child.parent_action in actions:\n next_root = child\n break\n if next_root is None:\n self.root = MCTSNode(state)\n return\n current_root = next_root\n actions.remove(current_root.parent_action)\n next_root = None\n\n for child in current_root.children:\n if child.player_pos == state.curr_player.position \\\n and child.parent_action in actions:\n next_root = child\n break\n\n if next_root is None:\n # This means the last move did not lead to current player,\n # so we need to create a new tree\n self.root = MCTSNode(state)\n return\n\n # This path exists in old tree, make this node the root,\n # and eliminate illegal paths\n current_root = next_root\n assert current_root.player_pos == state.curr_player.position\n self._make_root_node(current_root, state)\n\n def _make_root_node(self, node, state):\n \"\"\"\n Updates `player`'s root node to be `node`.\n :param MCTSNode node: New root for `player`\n :param Player player: Player whose root we are changing\n :param State state: Current game state\n \"\"\"\n\n node.parent_action = None\n node.parent = None\n new_children = []\n for child in node.children:\n if child.parent_action not in state.already_played:\n new_children.append(child)\n node.children = new_children\n\n untried_actions = set()\n tried_actions = set()\n for action in node.untried_actions:\n if action not in state.already_played:\n untried_actions.add(action)\n else:\n tried_actions.add(action)\n\n node._untried_actions = untried_actions\n node._tried_actions.update(tried_actions)\n self.root = node\n\n def explore(self, root):\n \"\"\"\n Explores tree, choosing a leaf node for rollout stage. Expands leaf node if not terminal.\n :param MCTSNode root: Root to explore\n :returns MCTSNode: node on which to perform rollout\n \"\"\"\n\n current_node = root\n while not current_node.is_terminal:\n if not current_node.is_fully_expanded:\n return current_node.expand()\n else:\n current_node = current_node.best_child()\n return current_node\n\n\nclass MCTSNode:\n \"\"\" Node in search tree for Pure MCTS\"\"\"\n\n def __init__(self, state, parent=None,\n parent_action=None, action_chooser_func='random_action'):\n \"\"\"\n\n :param State state: current game state\n :param MCTSNode parent: Parent of node. If None, this node is assumed to be a root node.\n :param Card parent_action: If `parent` is not None,\n this is the action made by parent that lead to this node. Else, value is ignored.\n :param str action_chooser_function: See `super().__init__()` docstring\n \"\"\"\n\n if isinstance(action_chooser_func, str):\n self.action_chooser_func = lookup(action_chooser_func, globals())\n else:\n self.action_chooser_func = action_chooser_func\n\n self.state = copy(state)\n self.parent = parent\n self.children = []\n if not self.parent: # Is root node\n self.parent_action = None\n if self.state.teams[0].has_player(self.state.curr_player):\n self.team = self.state.teams[0]\n else:\n self.team = self.state.teams[1]\n\n else:\n self.team = parent.team\n self.parent_action = parent_action\n\n self._number_of_visits = 0.\n self._results = defaultdict(lambda: 0) # type: Dict[int, int] # maps team# to no. of wins\n self._untried_actions = None # type: Set[Card]\n self._tried_actions = set() # type: Set[Card]\n self.max_player = 1 if self.team.has_player(self.state.curr_player) else -1\n self.player_pos = state.curr_player.position\n\n\n def best_child(self, uct_param=1.4):\n \"\"\"\n Returns child node with best UCT upper bound value\n :param float uct_param: Scaling factor for UCT value calculation. Default 1.4 ~ sqrt(2)\n :returns MCTSNode: best child node\n \"\"\"\n\n choices_weights = [self.UCT_value(child, uct_param) for child in self.children]\n child_idx = int(np.argmax(choices_weights))\n return self.children[child_idx]\n\n def UCT_value(self, node, uct_param):\n \"\"\"\n Calculates UCT value for node\n :param MCTSNode node: node for calculation\n :param float uct_param: Scaling factor for UCT value calculation\n :returns float: UCT value\n \"\"\"\n\n return (node.q_value / node.num_visits) + \\\n uct_param * np.sqrt((2 * np.log(self.num_visits) / node.num_visits))\n\n def rollout_policy(self, possible_moves):\n \"\"\"\n Chooses \"arm\" of root node on which to perform rollout\n (\"arm\" as in the \"Multi armed bandit\" problem).\n Action is chosen at random.\n :param List[Card] possible_moves: List of \"arms\"\n :returns Card: chosen \"arm\", i.e. action to take for rollout\n \"\"\"\n\n return np.random.choice(possible_moves)\n\n @property\n def untried_actions(self) -> List[Card]:\n \"\"\" List of actions still unexplored\"\"\"\n\n if self._untried_actions is None:\n self._untried_actions = set(self.state.curr_player.hand.cards)\n return list(self._untried_actions.intersection(self.state.get_legal_actions()))\n\n @property\n def q_value(self) -> int:\n \"\"\" Difference between wins and losses count for current node\"\"\"\n\n wins = self._results[self.max_player]\n loses = self._results[-1 * self.max_player]\n return wins - loses\n\n @property\n def num_visits(self) -> float:\n \"\"\" Number of time node was visited, updated each rollout\"\"\"\n\n return self._number_of_visits\n\n def expand(self):\n \"\"\" Expands a child node that wasn't explored yet.\n Assumes not all children were explored.\n :returns MCTSNode: Child node for exploration\n \"\"\"\n\n action = self.untried_actions.pop()\n next_state = self.state.get_successor(action)\n assert action not in self.state.already_played\n assert action in self.state.curr_player.hand.cards\n child_node = MCTSNode(next_state, parent=self, parent_action=action)\n self.children.append(child_node)\n self._untried_actions.remove(action)\n self._tried_actions.add(action)\n return child_node\n\n @property\n def is_terminal(self) -> bool:\n \"\"\" Is current node a terminal node\"\"\"\n return self.state.is_game_over\n\n def rollout(self):\n \"\"\" Performs single rollout on current node -\n i.e. simulates a single game with current state as initial state. \"\"\"\n\n if self.is_terminal:\n reward = 1 if self.team.has_player(self.state.curr_player) else -1\n return reward\n\n current_rollout_state = self.state\n possible_moves = current_rollout_state.get_legal_actions()\n action = self.rollout_policy(possible_moves)\n game = SimulatedGame(SimpleAgent(self.action_chooser_func),\n SimpleAgent('random_action'), False,\n current_rollout_state, action)\n assert game.run()\n winning_team_idx = game.winning_team\n winning_team = current_rollout_state.teams[winning_team_idx]\n reward = 1 if self.team == winning_team else -1\n return reward\n\n @property\n def is_fully_expanded(self) -> bool:\n \"\"\" Whether all children of node were previously expanded\"\"\"\n return len(self.untried_actions) == 0\n\n def backpropagate(self, result) -> None:\n \"\"\"\n Backpropogates result of single rollout up the tree.\n :param int result: 1 if max player won in rollout, -1 if min player won.\n \"\"\"\n\n self._number_of_visits += 1.\n self._results[result] += 1.\n if self.parent is not None:\n self.parent.backpropagate(result)\n\n# ---------------------------------HumanAgent-------------------------------- #\nclass HumanAgent(IAgent):\n \"\"\"\n Ask user for action, in format of .\n can be entered as a number or a lowercase/uppercase letter.\n can be entered as an ASCII of suit or a lowercase/uppercase letter.\n \"\"\"\n\n def __init__(self):\n super().__init__(self)\n\n def get_action(self, state):\n while True:\n inp = input()\n if inp == '':\n print(f\" is not a valid action, try again\")\n continue\n try:\n card_suit, card_number = inp[:-1], inp[-1]\n action = Card(card_number, card_suit, state.trump)\n legal_moves = state.get_legal_actions()\n if action in legal_moves:\n return action\n else:\n print(f\"{card_suit, card_number} \"\n f\"is not a legal card to play, try again\")\n\n except ValueError or IndexError or TypeError:\n print(f\"{inp} is not a valid action, try again\")\n/players.py\nfrom copy import copy\nfrom enum import Enum\nfrom typing import List\n\nfrom cards import Hand, Card\n\n\nPositionEnum = Enum(\"PlayersEnum\", ['N', 'E', 'S', 'W'])\n\nPOSITIONS = list(PositionEnum)\n\nTEAMS = [(PositionEnum.N, PositionEnum.S), (PositionEnum.W, PositionEnum.E)]\n\nPLAYERS_CYCLE = {PositionEnum.N: PositionEnum.E,\n PositionEnum.E: PositionEnum.S,\n PositionEnum.S: PositionEnum.W,\n PositionEnum.W: PositionEnum.N}\n\nTEAMMATES = {PositionEnum.N: PositionEnum.S,\n PositionEnum.S: PositionEnum.N,\n PositionEnum.E: PositionEnum.W,\n PositionEnum.W: PositionEnum.E}\n\n\nclass Player:\n \"\"\" Represents one of the 4 players in the game.\"\"\"\n\n def __init__(self, position: PositionEnum, hand: Hand):\n \"\"\"\n\n :param position: Position of player\n :param hand: Initial hand of player\n \"\"\"\n self.position = position\n self.hand = hand\n self.played = set()\n\n def __copy__(self):\n hand = copy(self.hand)\n player = Player(self.position, hand)\n player.played = set(self.played)\n return player\n\n def play_card(self, card: Card) -> None:\n \"\"\" Plays card from hand. card is no longer available.\"\"\"\n assert card not in self.played\n self.hand.play_card(card)\n self.played.add(card)\n\n def get_legal_actions(self, trick, already_played) -> List[Card]:\n \"\"\" Returns list of legal actions for player in current trick\n\n :param Trick trick: Current trick\n :param already_played: Set of cards already used in state, used for unit testing.\n :returns: legal actions for player:\n \"\"\"\n legal_actions = self.hand.get_cards_from_suite(trick.starting_suit, already_played)\n assert self.played.isdisjoint(legal_actions)\n assert already_played.isdisjoint(legal_actions)\n if not legal_actions:\n legal_actions = self.hand.cards\n assert already_played.isdisjoint(legal_actions)\n return legal_actions\n\n def __str__(self):\n return self.position.name\n\n def __eq__(self, other):\n return self.position == other.position\n\n def __hash__(self):\n return hash(self.position)\n\n\ndef get_legal_actions(suit, player, already_played) -> List[Card]:\n legal_actions = player.hand.get_cards_from_suite(suit, already_played)\n if not legal_actions:\n legal_actions = player.hand.cards\n else:\n trump_cards = [card for card in player.hand.cards if card.is_trump]\n legal_actions.extend(trump_cards)\n return legal_actions\n\n\nclass Team:\n \"\"\" Team of two players sitting on opposite sides of table.\"\"\"\n\n def __init__(self, p0: Player, p1: Player):\n self.players = [p0, p1]\n self.teammate = {p0.position: p1, # todo [ORIYAN] Possibly remove?\n p1.position: p0}\n # todo(maryna): maybe add the score directly into the team object?\n\n def __copy__(self):\n p0, p1 = self.players[0], self.players[1]\n copy_p0, copy_p1 = copy(p0), copy(p1)\n return Team(copy_p0, copy_p1)\n\n def __str__(self):\n return f\"{self.players[0]}{self.players[1]}\"\n\n def has_player(self, p: Player) -> bool:\n \"\"\" Is player `p` on the team \"\"\"\n return p in self.players\n\n def get_players(self) -> List[Player]:\n return self.players\n\n # more useful to be outside as static method.\n def get_teammate(self, p: Player) -> Player:\n assert (p in self.players)\n return self.teammate[p.position]\n\n def __hash__(self) -> int:\n return hash(frozenset(self.players))\n\n def __eq__(self, other) -> bool:\n return frozenset(self.teammate.keys()).issubset(other.teammate.keys())\n\n\ndef is_players_in_same_team(p1: Player, p2: Player) -> bool:\n if (p1.position, p2.position) in TEAMS or (p2.position, p1.position) in TEAMS:\n return True\n return False\n/state.py\nfrom copy import copy\nfrom typing import Dict, List\n\nfrom cards import Card, TrumpType\nfrom players import PLAYERS_CYCLE, Player, Team\nfrom trick import Trick\n\n\nclass State:\n \"\"\" Current state of the game of Bridge.\"\"\"\n\n def __init__(self, trick: Trick,\n teams: List[Team],\n players: List[Player],\n prev_tricks: List[Trick],\n score: Dict[Team, int],\n curr_player=None,\n trump: TrumpType=TrumpType.NT) -> None:\n self.trick = trick\n self.teams = teams\n self.players = players\n self.prev_tricks = prev_tricks\n self.score = score # tricks won by teams\n self.curr_player = curr_player\n self.players_pos = {player.position: player for player in self.players}\n\n self.already_played = set()\n self.trump = trump\n\n def get_successor(self, action: Card):\n \"\"\"\n\n :param action: Card to play\n :returns State: Resulting state of game if playing `action`\n \"\"\"\n assert (action in self.get_legal_actions())\n\n teams = [copy(self.teams[i]) for i in range(len(self.teams))]\n score = {teams[i]: self.score[team] for i, team in\n enumerate(self.teams)}\n players = teams[0].get_players() + teams[1].get_players()\n trick = self.trick.create_from_other_players(players)\n curr_player = [p for p in players if p == self.curr_player][0]\n\n successor = State(trick, teams, players, self.prev_tricks, score,\n curr_player, trump=self.trump)\n successor.apply_action(action)\n return successor\n\n def apply_action(self, card: Card, is_real_game: bool = False) -> Trick:\n \"\"\"\n\n :param card: Action to apply on current state\n :param is_real_game: indicator to differentiate a state used in simulation of a game\n by the object Game, from a state used within tree search.\n :returns Trick: Trick status after applying card.\n \"\"\"\n assert (len(self.trick) < len(self.players_pos))\n assert card not in self.already_played\n\n prev_num_cards = len(self.curr_player.hand.cards)\n self.curr_player.play_card(card)\n curr_num_cards = len(self.curr_player.hand.cards)\n assert prev_num_cards != curr_num_cards\n\n self.trick.add_card(self.curr_player, card)\n self.already_played.add(card)\n assert self.already_played.isdisjoint(self.curr_player.hand.cards)\n curr_trick = self.trick\n if len(self.trick) == len(self.players_pos): # last card played - open new trick\n if is_real_game:\n self.prev_tricks.append(copy(self.trick))\n winner_position = self.trick.get_winner()\n self.curr_player = self.players_pos[winner_position]\n i = 0 if self.teams[0].has_player(self.curr_player) else 1\n self.score[self.teams[i]] += 1\n self.trick = Trick({})\n else:\n assert self.curr_player in self.players_pos.values()\n assert self.curr_player in self.players\n # print(f\"Mapping of position->next player: {repr(self.players_pos)}\")\n self.curr_player = self.players_pos[PLAYERS_CYCLE[self.curr_player.position]]\n assert self.curr_player in self.players_pos.values()\n assert self.curr_player in self.players\n return curr_trick\n\n def get_legal_actions(self) -> List[Card]:\n legal_actions = self.curr_player.get_legal_actions(self.trick, self.already_played)\n assert self.already_played.isdisjoint(legal_actions)\n return legal_actions\n\n def get_score(self, curr_team_indicator) -> int:\n \"\"\" Returns score of team\n :param curr_team_indicator: if true return the score of the team of the current player,\n else return the score of the opposite player. used in alpha-beta search tree to indicate\n score of max-min players\n :returns: current score of team\n \"\"\"\n # assume there are 2 teams\n i, j = (0, 1) if self.teams[0].has_player(self.curr_player) else (1, 0)\n curr_team, other_team = self.teams[i], self.teams[j]\n if curr_team_indicator:\n return self.score[curr_team]\n return self.score[other_team]\n\n def __copy__(self):\n trick = copy(self.trick)\n prev_tricks = [copy(trick) for trick in self.prev_tricks]\n teams = [copy(team) for team in self.teams]\n score = {teams[0]: self.score[self.teams[0]],\n teams[1]: self.score[self.teams[1]]}\n players = [copy(player) for player in self.players]\n curr_player_pos = self.curr_player.position\n state = State(trick, teams, players, prev_tricks, score, None, trump=self.trump)\n state.curr_player = state.players_pos[curr_player_pos]\n played = set(self.already_played)\n state.already_played = played\n return state\n\n @property\n def is_game_over(self) -> bool:\n for player in self.players:\n if len(player.hand.cards) != 0:\n return False\n return True\n/validation.py\nimport numpy as np\nfrom collections import defaultdict\nfrom copy import deepcopy\nfrom itertools import cycle, islice\nfrom typing import Tuple, List, TextIO\n\nfrom cards import Card, SUITS, SuitType, TrumpType, Hand\nfrom game import SimulatedGame\nfrom multi_agents import IAgent, SimpleAgent, AlphaBetaAgent\nfrom players import Player, PositionEnum, POSITIONS, PLAYERS_CYCLE, TEAMS, Team\nfrom state import State\nfrom trick import Trick\n\nnp.seterr(divide='ignore', invalid='ignore')\n\n\nTEAMS_CYCLE = {TEAMS[0]: TEAMS[1], TEAMS[1]: TEAMS[0]}\nPLAYERS_DICT = {'N': 0, 'E': 1, 'S': 2, 'W': 3}\n\n\nclass TrickValidation(Trick):\n \"\"\"\n Class of Trick, with added characteristic of order of cards given by\n remembering the starting player.\n \"\"\"\n def __init__(self):\n super().__init__({})\n self.first_position = None\n\n def add_first_position(self, position: PositionEnum):\n self.first_position = position\n\n\nclass DataGame:\n \"\"\"\n Class which stores a recorded game, with option to take a snapshot from any\n point in it.\n \"\"\"\n def __init__(self, players: List[Player], tricks: List[TrickValidation],\n winner: Tuple[PositionEnum], trump: TrumpType):\n self.players = players\n self.tricks = tricks\n self.winner = winner\n self.trump = trump\n\n def position_to_player(self, position: PositionEnum):\n for p in self.players:\n if p.position == position:\n return p\n else:\n raise ValueError(\"something wrong in self.players\")\n\n def snapshot(self, trick_idx: int, position: PositionEnum) -> \\\n Tuple[List[Player], Trick, Card]:\n \"\"\"\n Image of one moment in game, in trick_idx trick, when player should play\n :param trick_idx: first trick is 0\n :param position: the player to commit its turn now\n :return: current hands situation (ordered list of players), trick on\n desk and the chosen card (by player in given position).\n \"\"\"\n if trick_idx >= len(self.tricks):\n raise IndexError(f\"trick_idx argument has to be smaller then \"\n f\"{len(self.tricks)}\")\n\n # Load initial hands situation\n curr_hands = deepcopy(self.players)\n\n # Remove cards from all last tricks from hands\n for i in range(trick_idx):\n for j, p in enumerate(curr_hands):\n curr_hands[j].hand.play_card(self.tricks[i].trick[p])\n\n # Remove cards of current trick from hands of all players which play\n # before given player. In addition, store these cards\n curr_pos = self.tricks[trick_idx].first_position\n curr_player = self.position_to_player(curr_pos)\n curr_trick = Trick({})\n while curr_player.position != position:\n curr_hands[PLAYERS_DICT[curr_player.position.name]].play_card(\n self.tricks[trick_idx].trick[curr_player])\n curr_trick.add_card(\n curr_player, self.tricks[trick_idx].trick[curr_player])\n curr_player = self.players[PLAYERS_DICT[\n PLAYERS_CYCLE[curr_player.position].name]]\n chosen_card = self.tricks[trick_idx].trick[curr_player]\n\n return curr_hands, curr_trick, chosen_card\n\n def all_relevant_snapshots(self) -> \\\n Tuple[List[List[Player]], List[Trick], List[Card]]:\n \"\"\"\n Get all relevant data from DataGame: snapshots from all tricks, for the\n positions of both winners.\n :return: tuple of 3 elements:\n 1. list of all sets-of-hands during game, one set-of-hands for every trick\n 2. list of all open cards in specific trick, one set-of-cards for every trick\n 3. list of all real cards the player should act, one for every trick\n all above are *concatenation* of results of both winners. For example,\n cards_list = [cards_list_winner_1] + [cards_list_winner_2]\n \"\"\"\n winners_indices = [w.value - 1 for w in self.winner]\n # List of hands and trick for every winner\n hands_list_1: List[List[Player]] = []\n\n curr_hands = deepcopy(self.players)\n for trick_idx in range(len(self.tricks)):\n hands_list_1.append(deepcopy(curr_hands))\n for player_idx, player in enumerate(curr_hands):\n curr_hands[player_idx].hand.play_card(\n self.tricks[trick_idx].trick[player])\n hands_list_2 = deepcopy(hands_list_1)\n\n trick_list_1: List[Trick] = []\n trick_list_2: List[Trick] = []\n trick_list = [trick_list_1, trick_list_2]\n chosen_cards_list_1: List[Card] = []\n chosen_cards_list_2: List[Card] = []\n chosen_cards_list = [chosen_cards_list_1, chosen_cards_list_2]\n\n for winner_idx, winner_list in enumerate([hands_list_1, hands_list_2]):\n for trick_idx, hands in enumerate(winner_list):\n curr_player = self.position_to_player(\n self.tricks[trick_idx].first_position)\n curr_trick = Trick({})\n while curr_player.position != POSITIONS[winners_indices[winner_idx]]:\n winner_list[trick_idx][\n PLAYERS_DICT[curr_player.position.name]].play_card(\n self.tricks[trick_idx].trick[curr_player])\n curr_trick.add_card(\n curr_player, self.tricks[trick_idx].trick[curr_player])\n curr_player = self.players[PLAYERS_DICT[\n PLAYERS_CYCLE[curr_player.position].name]]\n trick_list[winner_idx].append(curr_trick)\n chosen_cards_list[winner_idx].append(\n self.tricks[trick_idx].trick[curr_player])\n\n return hands_list_1 + hands_list_2, trick_list_1 + trick_list_2, \\\n chosen_cards_list_1 + chosen_cards_list_2\n\n\nclass Parser:\n def __init__(self, file_paths: List[str]):\n self.games: List[DataGame] = []\n for file in file_paths:\n self.games += (self.parse_file(file))\n\n def parse_file(self, file_name: str) -> List[DataGame]:\n \"\"\"\n Get a path of PBN file, and parse it to list of DataGame objects\n \"\"\"\n games = []\n with open(file_name) as f:\n for line in f:\n if line[1:6] == \"Deal \":\n players_line = line\n elif line[1:9] == \"Declarer\":\n win_team, trump = self._parse_winners_and_trump(line, f)\n if trump is None:\n continue\n players = self._parse_players(players_line[7:-3], trump)\n elif line[1:5] == \"Play\":\n tricks = self._parse_tricks(line, f, players)\n if len(tricks) == 0 or trump is None: # delete empty games\n continue\n games.append(DataGame(players, tricks, win_team, trump))\n return games\n\n @staticmethod\n def _parse_players(line: str, trump: TrumpType) -> List[Player]:\n \"\"\"\n Helper for parse_file.\n Example: line is such -\n [Deal \"E:AK872.KQJT.K.Q94 QT95.85.AQJ2.AK7 4.A962.96.J86532 J63.743.T87543.T\"]\n And the result is list of Player object. First is Player(PositionEnum.E, Hand)\n such that Hand is list contain A, K, 8, 7, 2 faces of suit ♠, ect.\n :param line: line from PBN file, which starts with \"[Deal \"\n :return: list of 4 Player objects, sorted by (N, E, S, W)\n \"\"\"\n player_str, all_hands_str = line.split(':')\n next_position = POSITIONS[PLAYERS_DICT[player_str]]\n\n players = [None, None, None, None]\n players_str = all_hands_str.split(' ') # spaces separate every two players\n for p in players_str:\n curr_position = next_position\n cards_str = p.split('.') # dots separate every two suits\n cards = []\n for i, suit in enumerate(cards_str):\n for face in suit:\n cards.append(Card(face=face, suit=SuitType(SUITS[i]).name,\n trump=trump))\n next_position = PLAYERS_CYCLE[curr_position]\n players[curr_position.value - 1] = Player(curr_position, Hand(cards))\n\n return players\n\n @staticmethod\n def _parse_winners_and_trump(line: str, f: TextIO) -> \\\n Tuple[Tuple[PositionEnum], TrumpType]:\n \"\"\"\n Helper for parse_file.\n Example: for sequential 3 lines [Declarer \"E\"], [Contract \"4H\"], [Result \"10\"]\n the result is that trump is ♥ and the team east-west is the winner.\n :param line: line from PBN file, which starts with \"[Declarer\"\n :param f: TextIO object, of the PBN file that read\n :return: tuple of Enums of winners, and the trump suit.\n \"\"\"\n # Irregular situations\n if line[11] == '\\\"' or line[11] == '^':\n return None, None\n\n declarer = POSITIONS[PLAYERS_DICT[line[11]]]\n declare_team = TEAMS[0] if declarer in TEAMS[0] else TEAMS[1]\n\n bid_line = f.readline()\n obligation = int(bid_line[11]) + 6\n if (bid_line[12:-3] == \"NT\") or (bid_line[12:-4] == \"NT\"):\n trump = TrumpType.NT\n else:\n trump = TrumpType[bid_line[12]]\n\n res_line = f.readline()\n result = int(res_line[8:-2].split('\\\"')[1][-1])\n win_team = declare_team if result >= obligation else TEAMS_CYCLE[declare_team]\n return win_team, trump\n\n @staticmethod\n def _parse_tricks(player_line: str, f: TextIO, players: List[Player]) -> \\\n List[TrickValidation]:\n \"\"\"\n Helper for parse_file.\n Example: for sequential lines [Play \"W\"], HT H3 HA H6, C2 C3 C9 CJ, ..., *\n the meaning is that W starts the first trick with card 10♥, then N with\n 3♥, E with A♥ and S with 6♥. The winner was E, so he starts the next\n trick with 9♣ and so on. (Order of cards in file is not the order of\n game! First player in every line is [Play <>], and the winner is\n inferred from line before)\n :param player_line: line from PBN file, which starts with \"[\"Play\"\n :param f: TextIO object, of the PBN file that read\n :param players: list of 4 Player objects, sorted by (N, E, S, W)\n :return: list of all tricks of a game\n \"\"\"\n first_position = POSITIONS[PLAYERS_DICT[player_line[7]]]\n iter_num = islice(cycle([0, 1, 2, 3]), PLAYERS_DICT[player_line[7]], None)\n curr_player = players[next(iter_num)]\n tricks = []\n\n trick_line = f.readline()\n while trick_line[0] != '*':\n curr_trick = TrickValidation()\n cards = trick_line.split(' ')\n # Irregular situations\n if '-' in cards or '-\\n' in cards or len(cards) != 4:\n break\n for c in cards:\n curr_trick.add_card(curr_player, Card(face=c[1], suit=c[0]))\n curr_player = players[next(iter_num)]\n curr_trick.add_first_position(first_position)\n tricks.append(curr_trick)\n first_position = curr_trick.get_winner()\n trick_line = f.readline()\n\n return tricks\n\n\ndef validate_agent_action(dg: DataGame,\n trick_idx: int,\n position: PositionEnum,\n agent: IAgent) -> bool:\n curr_hands, curr_trick, chosen_card = dg.snapshot(trick_idx, position)\n\n teams = [Team(curr_hands[0], curr_hands[2]),\n Team(curr_hands[1], curr_hands[3])]\n\n curr_state = State(trick=curr_trick,\n teams=teams,\n players=curr_hands,\n prev_tricks=dg.tricks[:trick_idx],\n score=dict.fromkeys(teams),\n curr_player=curr_hands[position.value - 1])\n\n sg = SimulatedGame(agent=agent,\n other_agent=None,\n verbose_mode=False,\n state=curr_state)\n\n played_card = sg.play_single_move()\n print(f\"Expected: {chosen_card}, Actual: {played_card}\")\n\n return played_card == chosen_card\n\n\ndef validate_agent_per_data_game(agent: IAgent, dg: DataGame, min_tricks: int=0)\\\n -> Tuple[np.ndarray, np.ndarray]:\n \"\"\"\n Validate a agent by comparing its performances to data.\n :param agent: IAgent to check vs the data\n :param dg: DataGame object\n :param min_tricks: minimum tricks index to start validation from\n :return: tuple of 2 arrays for experiences and succeeds. each element in\n each array represents the number of played tricks (== 13 - (#card in hand))\n \"\"\"\n all_hands, all_tricks, chosen_cards = dg.all_relevant_snapshots()\n tricks_num = len(all_hands) // 2\n checks, succeeds = np.zeros(12), np.zeros(12)\n\n for pos_idx, position in enumerate(dg.winner):\n for trick_idx in range(min_tricks, tricks_num):\n curr_hands = all_hands[pos_idx * tricks_num + trick_idx]\n curr_trick = all_tricks[pos_idx * tricks_num + trick_idx]\n chosen_card = chosen_cards[pos_idx * tricks_num + trick_idx]\n # Create teams, such that first team is the winner\n teams = [Team(curr_hands[0], curr_hands[2]),\n Team(curr_hands[1], curr_hands[3])]\n if curr_hands[0].position not in dg.winner:\n teams[0], teams[1] = teams[1], teams[0]\n\n curr_state = State(trick=curr_trick,\n teams=teams,\n players=curr_hands,\n prev_tricks=dg.tricks[:trick_idx],\n score=defaultdict.fromkeys(teams, 0),\n curr_player=curr_hands[position.value - 1])\n\n sg = SimulatedGame(agent=agent,\n other_agent=SimpleAgent('soft_long_greedy_action'),\n verbose_mode=False,\n state=curr_state)\n\n validation = 'simple' if isinstance(agent, SimpleAgent) else ''\n played_card = sg.play_single_move(validation=validation)\n if played_card == chosen_card:\n succeeds[trick_idx] += 1\n checks[trick_idx] += 1\n\n return checks, succeeds\n/game.py\nimport os\nimport sys\nimport numpy as np\nfrom copy import copy\nfrom typing import List\n\nfrom cards import Deck, TrumpType\nfrom players import POSITIONS, Player, PositionEnum, TEAMS, Team\nfrom state import State\nfrom trick import Trick\n\n\nclass Game:\n\n def __init__(self,\n agent,\n other_agent,\n games_counter: List[int],\n tricks_counter: List[int],\n verbose_mode: bool = True,\n previous_tricks: List[Trick] = None,\n curr_trick: Trick = None,\n starting_pos: PositionEnum = None,\n trump=None,\n cards_in_hand=13):\n # todo(oriyan/maryna): think how to reproduce game from database -\n # or randomly generate new game\n self.cards_in_hand=cards_in_hand\n self.agent = agent # type: IAgent\n self.other_agent = other_agent # type: IAgent\n self.games_counter = games_counter\n self.verbose_mode = verbose_mode\n if trump is None:\n trump = np.random.choice(TrumpType)\n else:\n trump = TrumpType.from_str(trump)\n self.trump = trump # type: TrumpType\n self.deck = Deck(self.trump)\n hands = self.deck.deal(cards_in_hand=cards_in_hand)\n self.players = {pos: Player(pos, hand) for pos, hand in\n zip(POSITIONS, hands)}\n self.teams = [Team(self.players[pos1], self.players[pos2]) for\n pos1, pos2 in TEAMS]\n\n self.curr_trick = curr_trick\n self.previous_tricks = previous_tricks\n self.tricks_counter = tricks_counter\n self.winning_team: int = -1\n\n if starting_pos is None:\n starting_pos = np.random.choice(POSITIONS)\n self.curr_player = self.players[starting_pos]\n self._state = None\n\n def __str__(self):\n\n ret = \"\"\n\n ret += f\"Match score: \" \\\n f\"{self.teams[0]}:{self.games_counter[0]:02} - \" \\\n f\"{self.teams[1]}:{self.games_counter[1]:02}\\n\"\n\n ret += f\"Game score: \" \\\n f\"{self.teams[0]}:{self.tricks_counter[0]:02} - \" \\\n f\"{self.teams[1]}:{self.tricks_counter[1]:02}\\n\"\n ret += f\"Trump Suite: {self.trump.value}\\n\"\n ret += f\"Current trick: \"\n for player, card in self.curr_trick.items():\n ret += f\"{player}:{card} \"\n if len(self.curr_trick) == 4:\n ret += f\", {self.players[self.curr_trick.get_winner()]} won trick.\"\n ret += f\"\\n\"\n\n for player in self.players.values():\n ret += f\"\\n{player}\\n{player.hand}\"\n\n return ret\n\n def run(self) -> bool:\n \"\"\"\n Main game runner.\n :return: None\n \"\"\"\n score = {self.teams[0]: 0, self.teams[1]: 0}\n initial_state = State(self.curr_trick, self.teams,\n list(self.players.values()),\n self.previous_tricks, score,\n self.curr_player, trump=self.trump)\n self._state = initial_state\n self.previous_tricks = self._state.prev_tricks\n self.game_loop()\n return True\n\n def game_loop(self) -> None:\n while max(self.tricks_counter) < np.ceil(self.cards_in_hand / 2): # Winner is determined.\n\n for i in range(len(POSITIONS)): # Play all hands\n self.play_single_move()\n if self.verbose_mode:\n self.show()\n if self.verbose_mode:\n self.show()\n\n # Game ended, calc result.\n self.winning_team = int(np.argmax(self.tricks_counter))\n\n def play_single_move(self) -> None:\n \"\"\"\n Called when its' the givens' player turn. The player will pick a\n action to play and it will be taken out of his hand a placed into the\n trick.\n \"\"\"\n if self.teams[0].has_player(self.curr_player):\n card = self.agent.get_action(self._state)\n else:\n card = self.other_agent.get_action(self._state)\n assert(card is not None)\n\n curr_trick = self._state.apply_action(card, True)\n self.curr_trick = curr_trick\n self.curr_player = self._state.curr_player # Current player of state is trick winner\n self.tricks_counter = [self._state.score[self._state.teams[0]],\n self._state.score[self._state.teams[1]]]\n\n def show(self) -> None:\n \"\"\"\n Update GUI\n :return: None\n \"\"\"\n\n os.system('clear' if 'linux' in sys.platform else 'cls')\n print(self)\n input()\n\n\nclass SimulatedGame(Game):\n \"\"\" Simulates a game with a non-empty state\"\"\"\n\n def __init__(self, agent, other_agent,\n verbose_mode: bool = True, state: State = None, starting_action=None):\n \"\"\"\n\n :param State state: Initial game state.\n :param Card starting_action: Initial play of current player.\n If None, chosen according to `agent`'s policy.\n \"\"\"\n\n state_copy = copy(state)\n self.players = {player.position: player for player in state_copy.players}\n self.teams = state_copy.teams\n self.tricks_counter = [state_copy.score[state_copy.teams[0]],\n state_copy.score[state_copy.teams[1]]]\n self.starting_action = starting_action\n self.first_play = True\n self.agent = agent # type: IAgent\n self.other_agent = other_agent # type: IAgent\n self.games_counter = [0, 0]\n self.verbose_mode = verbose_mode\n self.trump = state_copy.trump\n self.deck = Deck(self.trump)\n self.curr_trick = state_copy.trick\n self.previous_tricks = state_copy.prev_tricks\n self.winning_team: int = -1\n self.curr_player = state_copy.curr_player\n self._state = state_copy\n\n def play_single_move(self, validation=''):\n if self.first_play and self.starting_action is not None:\n card = self.starting_action\n self.first_play = False\n elif self.teams[0].has_player(self.curr_player):\n card = self.agent.get_action(self._state)\n else:\n card = self.other_agent.get_action(self._state)\n\n if validation == 'simple':\n return card\n\n curr_trick = self._state.apply_action(card, True)\n self.curr_trick = curr_trick\n self.curr_player = self._state.curr_player # Current player of state is trick winner\n self.tricks_counter = [self._state.score[self._state.teams[0]],\n self._state.score[self._state.teams[1]]]\n return card\n\n def game_loop(self) -> None:\n if len(self.curr_trick.cards()) > 0:\n for card in self.curr_trick.cards():\n self._state.already_played.add(card)\n for _ in range(13 - len(self._state.prev_tricks)):\n for __ in range(4 - len(self.curr_trick.cards())): # Play all hands\n self.play_single_move()\n if self.verbose_mode:\n self.show()\n if max(self.tricks_counter) >= 7: # Winner is determined.\n break\n self.winning_team = int(np.argmax(self.tricks_counter))\n\n def run(self) -> bool:\n self.game_loop()\n return True\n/cards.py\n\"\"\"\nThis module holds classes that represent cards and their derivative classes.\n\"\"\"\n\nimport numpy as np\nfrom copy import copy\nfrom enum import Enum\nfrom typing import List\n\n\nFACES = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', ]\n\nface_value = {'A': 4.5,\n 'K': 3,\n 'Q': 1.5,\n 'J': 0.75,\n 'T': 0.25,\n '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}\n\n\nSUITS = ['♠', '♥', '♦', '♣', ]\nSUITS_ALT = {'S': '♠', 'H': '♥', 'D': '♦', 'C': '♣'}\n\n\nclass SuitType(Enum):\n \"\"\" Enum representing card suit\"\"\"\n\n Spades = '♠'\n S = '♠'\n\n Hearts = '♥'\n H = '♥'\n\n Diamonds = '♦'\n D = '♦'\n\n Clubs = '♣'\n C = '♣'\n\n @staticmethod\n def from_str(suit: str):\n \"\"\" Parses string into SuitType object\n\n :param suit: Suit string to parse into SuitType\n :returns SuitType: parsed suit\n :raises ValueError: If `suit` is unsupported.\n \"\"\"\n\n try:\n suit_key = suit.capitalize()\n return SuitType[suit_key]\n\n except KeyError:\n raise ValueError(f\"Unsupported Suit {suit}. \"\n f\"Must be one of {set(suit.name for suit in list(SuitType))}\")\n\n\nclass TrumpType(Enum):\n \"\"\" Enum representing match's trump suit\"\"\"\n\n Spades = '♠'\n S = '♠'\n\n Hearts = '♥'\n H = '♥'\n\n Diamonds = '♦'\n D = '♦'\n\n Clubs = '♣'\n C = '♣'\n\n NoTrump = 'NT'\n NT = 'NT'\n\n @staticmethod\n def from_str(suit: str):\n \"\"\" Parses string into SuitType object\n\n :param suit: Suit string to parse into SuitType\n :returns SuitType: parsed suit\n :raises ValueError: If `suit` is unsupported.\n \"\"\"\n if suit.upper() == 'NT':\n return TrumpType.NT\n\n if suit == 'NoTrump':\n return TrumpType.NoTrump\n try:\n suit_key = suit.capitalize()\n return TrumpType[suit_key]\n\n except KeyError:\n raise ValueError(f\"Unsupported Suit {suit}. \"\n f\"Must be one of {set(suit.name for suit in list(TrumpType))}\")\n\n\n\nclass Suit:\n suit_type: SuitType\n trump_suit: TrumpType = TrumpType.NT\n\n def __init__(self, suit_type: SuitType, trump_suit: TrumpType = TrumpType.NT) -> None:\n self.suit_type = suit_type\n self.trump_suit = trump_suit\n self.is_trump = self.trump_suit.value == self.suit_type.value\n\n def __repr__(self) -> str:\n return self.suit_type.value\n\n def __eq__(self, other):\n if isinstance(other, str):\n return self.suit_type.value == other\n return self.suit_type.value == other.suit_type.value\n\n def __ne__(self, other):\n return self.suit_type.value != other.suit_type.value\n\n def __lt__(self, other):\n if self != other:\n if self.is_trump:\n return False\n\n if other.is_trump:\n return True\n\n return SUITS.index(self.suit_type.value) > SUITS.index(\n other.suit_type.value)\n\n return False\n\n def __gt__(self, other):\n return other < self\n\n def __le__(self, other):\n return self < other or self == other\n\n def __ge__(self, other):\n return other <= self\n\n def __hash__(self) -> int:\n return hash(self.suit_type)\n\nclass Card:\n \"\"\"\n A playing card.\n \"\"\"\n\n def __init__(self, face: str, suit: str, trump: TrumpType = TrumpType.NT):\n \"\"\"\n\n :param face: value of card - one of {'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'}\n\n :param suit: suit of card, one of {'S' or 'Spades', 'C' or 'Clubs', 'D' or 'Diamonds, 'H' or 'Hearts'}\n :raises ValueError: If `face` or `suit` are unsupported.\n \"\"\"\n suit_type = SuitType.from_str(suit)\n self.suit = Suit(suit_type, trump_suit=trump)\n self.is_trump = self.suit.is_trump\n if face.capitalize() not in FACES:\n raise ValueError(\n f\"Unsupported Card Value {face}, must be one of {set(FACES)}\")\n\n self.face = face.capitalize()\n\n def __copy__(self):\n new_card = Card(self.face, self.suit.suit_type.name, self.suit.trump_suit)\n new_card.is_trump = self.is_trump\n return new_card\n\n def __repr__(self):\n return f\"{self.face}{self.suit}\"\n\n def __eq__(self, other):\n return self.face == other.face and self.suit == other.suit\n\n def __ne__(self, other):\n return not (self == other)\n\n def __lt__(self, other):\n if other.is_trump and not self.is_trump:\n return True\n\n if self.is_trump and not other.is_trump:\n return False\n\n if self.suit == other.suit:\n return FACES.index(self.face) < FACES.index(other.face)\n\n return SUITS.index(self.suit.suit_type.value) < SUITS.index(\n self.suit.suit_type.value) and \\\n FACES.index(self.face) < FACES.index(other.face)\n\n def __gt__(self, other):\n return other < self\n\n def __le__(self, other):\n return not (other < self)\n\n def __ge__(self, other):\n return not (self < other)\n\n def __hash__(self) -> int:\n return hash((self.suit, self.face))\n\nclass Deck:\n \"\"\" Deck of cards.\"\"\"\n\n def __init__(self, trump: TrumpType = TrumpType.NT):\n self.trump = trump\n self.cards = []\n for face in FACES:\n for suit in SUITS_ALT:\n card = Card(face, suit, self.trump)\n self.cards.append(card)\n\n def deal(self, cards_in_hand=13, recreate_game=''):\n \"\"\"\n Returns 4 randomly dealt Hands, one for each player in the game.\n :param recreate_game: if supplied, will allow recreating a set of hands from a database. Currently unsupported.\n :returns List[Hand]: 4 hands\n \"\"\"\n if not recreate_game:\n cards = np.random.choice(self.cards, 4*cards_in_hand, replace=False)\n shuffled_deck = \\\n np.random.permutation(cards).reshape(4, cards_in_hand).tolist()\n hands = [Hand(cards) for cards in shuffled_deck]\n return hands\n # todo(oriyan/mar): create new deck from database representation\n\n\nclass Hand:\n \"\"\" A Player's hand . Holds their cards.\"\"\"\n\n def __init__(self, cards: List[Card]):\n \"\"\" Initial hand of player is initialized with list of Card object.\"\"\"\n self.cards = cards\n assert len(set(cards)) == len(cards)\n\n def __len__(self):\n return len(self.cards)\n\n def __copy__(self):\n cards = [copy(card) for card in self.cards]\n return Hand(cards)\n\n def play_card(self, card: Card):\n \"\"\" Plays card from hand. After playing this card, it is no longer available in the player's hand.\"\"\"\n assert card in self.cards\n prev_num_cards = len(self.cards)\n self.cards.remove(card)\n assert len(self.cards) != prev_num_cards\n\n def get_cards_from_suite(self, suite: Suit, already_played):\n \"\"\" Returns all cards from player's hand that are from `suite`.\n If None, returns all cards.\"\"\"\n if suite is None:\n cards = self.cards\n assert already_played.isdisjoint(cards)\n return self.cards\n\n cards = list(filter(lambda card: card.suit == suite, self.cards))\n assert already_played.isdisjoint(cards)\n return cards\n\n def get_cards_not_from_suite(self, suite: Suit):\n \"\"\" Returns all cards from player's hand that are not from `suite`.\n If None, returns all cards.\"\"\"\n if suite is None:\n return self.cards\n\n cards = list(filter(lambda card: card.suit != suite, self.cards))\n return cards\n\n def get_cards_sorted_by_suits(self, already_played):\n sorted_hand = dict()\n trump = []\n for card in self.cards:\n if not sorted_hand.get(card.suit.suit_type):\n sorted_suit = sorted(self.get_cards_from_suite(card.suit, already_played))\n if card.is_trump:\n trump = sorted_suit\n else:\n sorted_hand[card.suit.suit_type] = sorted_suit\n return sorted_hand, trump\n\n def get_hand_value(self, already_played):\n \"\"\"\n calculated following the steps:\n 1. HCP value of the hand\n 2. adjust of HCP\n 3. adjust suit lenght\n 4. adjust hands with top five cards of a suit\n 5. total starting points (added in the heuristic)\n :param already_played:\n :return:\n \"\"\"\n hand_value = 0\n adjust_suit_lenght = 0\n aces_10s_count = 0\n queens_jecks_count = 0\n\n hand_values_by_suits = dict()\n for card in self.cards:\n if not hand_values_by_suits.get(card.suit.suit_type):\n card_of_suit = self.get_cards_from_suite(card.suit, already_played)\n if len(card_of_suit) > 0:\n adjust_suit_lenght += max([0, len(card_of_suit) - 4])\n values_of_card = [face_value[card.face] for card in card_of_suit\n if face_value[card.face] != 0]\n hand_values_by_suits[card.suit.suit_type] = values_of_card\n\n for suit, values in hand_values_by_suits.items():\n if len(values) > 0:\n hand_value += sum(values)\n aces_10s_count += values.count(0.25) # tens\n aces_10s_count += values.count(4.5) # aces\n queens_jecks_count += values.count(1.5) # queens\n queens_jecks_count += values.count(0.75) # jacks\n if len(values) == 5: # adjust rule 4\n hand_value += 3\n\n adjust_hand_value_value = abs(aces_10s_count - queens_jecks_count)\n sign = 1 if aces_10s_count > queens_jecks_count else -1\n if adjust_hand_value_value > 2:\n hand_value += sign\n if adjust_hand_value_value > 5:\n hand_value += sign\n\n return hand_value\n\n def __str__(self):\n ret = \"\"\n for suit in SUITS:\n ret += f\"{suit}: \"\n for card in self.cards:\n if card.suit == suit:\n ret += f\"{card.face} \"\n ret += f\"\\n\"\n\n return ret\n/compare_agents.py\nimport time\n\nimport matplotlib.patheffects as path_effects\nimport matplotlib.pyplot as plt\n\nfrom match import *\nfrom multi_agents import simple_func_names, simple_agent_names, \\\n ab_evaluation_func_names, ab_evaluation_agent_names\n\nNUM_CARDS = 13\nGAMES_PER_MATCH = 100\n\n\n\ndef compare_simple_agents():\n def run_all_simple_actions_matches(results_matrix):\n for i in range(len(simple_func_names)):\n for j in range(len(simple_func_names)):\n # For each pair of agents\n agent0, agent1 = \\\n simple_func_names[i], \\\n simple_func_names[j]\n print(f\"{simple_agent_names[i]} vs. \"\n f\"{simple_agent_names[j]}\")\n\n # Run match\n curr_match = Match(SimpleAgent(agent0),\n SimpleAgent(agent1),\n GAMES_PER_MATCH, False)\n curr_match.run()\n\n # Print match result and update scores table\n print(f\"Score: {curr_match.games_counter[0]:02} -\"\n f\" {curr_match.games_counter[1]:02}\\n\")\n results_matrix[i, j] = 100 * curr_match.games_counter[\n 0] / GAMES_PER_MATCH\n return results_matrix\n\n def display_table_simple_agents(results_matrix):\n fig, ax = plt.subplots(dpi=600)\n ax.imshow(results_matrix, cmap='plasma', vmin=0, vmax=100)\n ax.set_xticks(np.arange(len(simple_agent_names)))\n ax.set_yticks(np.arange(len(simple_agent_names)))\n ax.set_xticklabels(simple_agent_names)\n ax.set_yticklabels(simple_agent_names)\n plt.setp(ax.get_xticklabels(), rotation=45, ha=\"right\",\n rotation_mode=\"anchor\")\n for i in range(len(simple_agent_names)):\n for j in range(len(simple_agent_names)):\n text = ax.text(\n j, i, f\"{results_matrix[i, j]:04.1f}\",\n ha=\"center\", va=\"center\", color=\"w\")\n text.set_path_effects(\n [path_effects.Stroke(linewidth=2, foreground='black'),\n path_effects.Normal()])\n\n title = \"Simple vs Simple Agents\\n\" + \\\n f\"y-axis win %, higher is better\"\n ax.set_title(title, fontsize=16, fontweight=\"bold\")\n fig.tight_layout()\n plt.show()\n\n print()\n start_time = time.time()\n results = np.empty((len(simple_func_names),\n len(simple_func_names)))\n results[:] = np.nan\n\n run_all_simple_actions_matches(results)\n display_table_simple_agents(results)\n print(f\"--- Graph generation took \"\n f\"{int(time.time() - start_time)} seconds ---\")\n\n\ndef compare_simple_agents_vs_ab_agents(depth, ab_first=True):\n def run_all_simple_agents_vs_ab_matches(depth, results_matrix):\n for i in range(len(ab_evaluation_func_names)):\n for j in range(len(simple_func_names)):\n\n ab_agent = AlphaBetaAgent(ab_evaluation_func_names[i], depth)\n simple_agent = SimpleAgent(simple_func_names[j])\n print(f\"{ab_evaluation_agent_names[i]} vs. \"\n f\"{simple_agent_names[j]}\")\n\n if ab_first:\n curr_match = Match(ab_agent, simple_agent,\n num_games=GAMES_PER_MATCH,\n verbose_mode=False,\n cards_in_hand=NUM_CARDS)\n else:\n curr_match = Match(simple_agent, ab_agent,\n num_games=GAMES_PER_MATCH,\n verbose_mode=False,\n cards_in_hand=NUM_CARDS)\n\n curr_match.run()\n print(f\"Score: {curr_match.games_counter[0]:02} -\"\n f\" {curr_match.games_counter[1]:02}\\n\")\n results_matrix[i, j] = \\\n 100 * curr_match.games_counter[0] / GAMES_PER_MATCH\n\n if not ab_first:\n results_matrix = 100 - results_matrix\n return results_matrix\n\n def display_table_simple_agents_vs_ab(depth, results_matrix):\n fig, ax = plt.subplots(dpi=600)\n ax.imshow(results_matrix, cmap='plasma', vmin=0, vmax=100)\n ax.set_xticks(np.arange(len(simple_agent_names)))\n ax.set_yticks(np.arange(len(ab_evaluation_agent_names)))\n ax.set_xticklabels(simple_agent_names)\n ax.set_yticklabels(ab_evaluation_agent_names)\n plt.setp(ax.get_xticklabels(), rotation=45, ha=\"right\",\n rotation_mode=\"anchor\")\n for i in range(len(simple_agent_names)):\n for j in range(len(ab_evaluation_agent_names)):\n text = ax.text(\n i, j, f\"{results_matrix[j, i]:04.1f}\",\n ha=\"center\", va=\"center\", color=\"w\")\n text.set_path_effects(\n [path_effects.Stroke(linewidth=2, foreground='black'),\n path_effects.Normal()])\n\n title = f\"AlphaBeta vs Simple Agents\\n\" \\\n f\"{'AlphaBeta' if ab_first else 'Simple'} agent play first\\n\" \\\n f\"y-axis win %, depth={depth}\"\n\n ax.set_title(title, fontsize=16, fontweight=\"bold\")\n fig.tight_layout()\n plt.show()\n\n print()\n start_time = time.time()\n\n results = np.empty((len(ab_evaluation_func_names),\n len(simple_func_names)))\n results[:] = np.nan\n\n run_all_simple_agents_vs_ab_matches(depth, results)\n display_table_simple_agents_vs_ab(depth, results)\n print(f\"--- Graph generation took \"\n f\"{int(time.time() - start_time)} seconds ---\")\n\ndef run_all_simple_agents_vs_mcts(agent_cls, num_cards=13, **kwargs):\n results = np.empty((len(simple_func_names),\n len(simple_func_names)))\n results[:] = np.nan\n for i in range(len(simple_func_names)):\n for j in range(len(simple_func_names)):\n agent0 = simple_func_names[i]\n print(f\"{agent_cls.__name__} ({simple_func_names[j]} rule) vs. {simple_agent_names[i]}\")\n curr_match = Match(agent_cls(simple_func_names[j], **kwargs),\n SimpleAgent(agent0),\n GAMES_PER_MATCH, False, cards_in_hand=num_cards)\n curr_match.run()\n print(f\"Score: {curr_match.games_counter[0]:02} -\"\n f\" {curr_match.games_counter[1]:02}\\n\")\n results[j, i] = 100 * curr_match.games_counter[0] / GAMES_PER_MATCH\n display_table_simple_agents_vs_MCTS(results, agent_cls, num_cards=num_cards, **kwargs)\n\ndef display_table_simple_agents_vs_MCTS(results, agent_cls, num_simulations=1, epsilon=None, num_cards=13):\n fig, ax = plt.subplots(dpi=300)\n im = ax.imshow(results, cmap='plasma', vmin=0, vmax=100)\n ax.set_xticks(np.arange(len(simple_agent_names)))\n ax.set_yticks(np.arange(len(simple_agent_names)))\n mcts_agent_names = [f\"{agent_cls.__name__}({name})\" for name in simple_agent_names]\n title = f\"Win % of {agent_cls.__name__} vs normal agent\\n\" \\\n f\"{GAMES_PER_MATCH} games, {num_cards} cards, {num_simulations} sims.\"\n ax.set_title(title, fontsize=12, fontweight=\"bold\")\n ax.set_xticklabels(simple_agent_names, fontsize=8)\n ax.set_yticklabels(mcts_agent_names, fontsize=8)\n plt.setp(ax.get_xticklabels(), rotation=45, ha=\"right\",\n rotation_mode=\"anchor\")\n for i in range(len(simple_agent_names)):\n for j in range(len(simple_agent_names)):\n text = ax.text(\n j, i, f\"{results[i, j]:3.0f}%\",\n ha=\"center\", va=\"center\", color=\"w\", fontsize=8)\n text.set_path_effects(\n [path_effects.Stroke(linewidth=2, foreground='black'),\n path_effects.Normal()])\n fig.tight_layout()\n plot_dir = os.path.join(os.getcwd(), 'plots')\n os.makedirs(plot_dir, exist_ok=True)\n plot_fname = os.path.join(plot_dir, f\"{agent_cls.__name__}_\"\n f\"_{GAMES_PER_MATCH}games_{num_cards}cards_{num_simulations}sims\"\n f\"{f'_{epsilon:1.2}eps' if epsilon else ''}.jpg\")\n plt.tight_layout()\n plt.savefig(plot_fname)\n plt.show()\n\nLEGAL_AGENT_TYPES =[\"AB\", \"MCTS\", \"SIMPLE\"]\ndef parse_args():\n parser = ArgumentParser()\n parser.add_argument('--agent', required=True, type=str, choices=LEGAL_AGENT_TYPES, dest='agent')\n parser.add_argument('--games', default=100, type=int)\n parser.add_argument('--simulations', default=1000, type=int)\n parser.add_argument('--cards', default=5, type=int)\n parser.add_argument('--depth', default=5, type=int)\n parser.add_argument('--epsilon', default=0., type=float)\n args = parser.parse_args()\n return args\n\ndef mcts_main(num_games, num_simulations, num_cards, epsilon):\n global GAMES_PER_MATCH\n GAMES_PER_MATCH = num_games\n MCTS_classes = [SimpleMCTSAgent, PureMCTSAgent]\n for agent_cls in MCTS_classes:\n run_all_simple_agents_vs_mcts(agent_cls, num_simulations=num_simulations, num_cards=num_cards)\n\n run_all_simple_agents_vs_mcts(StochasticSimpleMCTSAgent, num_simulations=num_simulations, num_cards=num_cards, epsilon=epsilon)\n\ndef ab_main(num_games, num_cards, depth):\n global GAMES_PER_MATCH, NUM_CARDS\n GAMES_PER_MATCH = num_games\n NUM_CARDS = num_cards\n compare_simple_agents_vs_ab_agents(depth=5, ab_first=True)\n compare_simple_agents_vs_ab_agents(depth=5, ab_first=False)\n compare_simple_agents_vs_ab_agents(depth=10, ab_first=True)\n compare_simple_agents_vs_ab_agents(depth=10, ab_first=False)\n compare_simple_agents_vs_ab_agents(depth=15, ab_first=True)\n compare_simple_agents_vs_ab_agents(depth=15, ab_first=False)\n\nif __name__ == '__main__':\n args = parse_args()\n if args.agent.upper() == 'MCTS':\n mcts_main(args.games, args.simulations, args.cards, args.epsilon)\n if args.agent.upper() == 'AB':\n ab_main(args.games, args.cards, args.depth)\n if args.agent.upper() == 'SIMPLE':\n compare_simple_agents()\n/requirements.txt\nnumpy~=1.17.4\ntqdm~=4.47.0\nmatplotlib~=3.1.2/tests_validation.py\nimport os\n\nfrom validation import *\nfrom multi_agents import SimpleAgent, AlphaBetaAgent, SimpleMCTSAgent, \\\n StochasticSimpleMCTSAgent, PureMCTSAgent\nfrom compare_agents import simple_func_names, simple_agent_names, \\\n ab_evaluation_func_names, ab_evaluation_agent_names\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom time import perf_counter\n\n\ndef test_snapshot():\n file = \"bridge_data_1/Aulpll23.pbn\"\n # file = \"bridge_data_1/Dkofro20.pbn\"\n files = Parser([file])\n # out = files.games[0].snapshot(0, POSITIONS[0])\n # out = files.games[0].snapshot(0, POSITIONS[2])\n # out = files.games[0].snapshot(1, POSITIONS[2])\n out = files.games[0].snapshot(1, POSITIONS[0])\n # out = games[0].snapshot(6, POSITIONS[0])\n return out\n\n\ndef test_all_snapshots_single_game():\n file = \"bridge_data_1/Aulpll23.pbn\"\n games = Parser([file])\n # out = games.games[0].all_relevant_snapshots()\n # out = games.games[2].all_relevant_snapshots()\n # out = games.games[4].all_relevant_snapshots()\n out = games.games[6].all_relevant_snapshots()\n return out\n\n\ndef load_all_game():\n games_dir = os.path.join(os.getcwd(), 'bridge_data_1')\n files_name = os.listdir(games_dir)\n pbn_files = []\n for file in files_name:\n if file[-3:] == 'pbn':\n pbn_files.append(os.path.join('bridge_data_1', file))\n files = Parser(np.random.permutation(pbn_files).tolist())\n print(\"succeed loading\")\n return files\n\n\ndef test_valid_games():\n games = load_all_game()\n for i, g in enumerate(games.games):\n trick_idx = max(0, len(g.tricks) - 1)\n g.snapshot(trick_idx, POSITIONS[0])\n print(\"all are valid\")\n\n\ndef test_all_snapshots():\n games = load_all_game()\n for i, g in enumerate(games.games):\n g.all_relevant_snapshots()\n print(\"all snapshots for all games done\")\n return\n\n\ndef games_length():\n games = load_all_game()\n histogram = np.zeros(12)\n for g in games.games:\n histogram[len(g.tricks) - 1] += 1\n print(histogram)\n plt.bar(np.arange(12) + 1, histogram)\n plt.title(\"Number of Tricks Histogram\")\n plt.xlabel(\"# tricks\")\n plt.ylabel(\"# games\")\n plt.show()\n\n\ndef test_validate_agent_action():\n curr_agent = SimpleAgent('highest_first_action')\n\n file = \"bridge_data_1/Aulpll23.pbn\"\n files = Parser([file])\n return validate_agent_action(dg=files.games[4],\n trick_idx=1,\n position=PositionEnum.N,\n agent=curr_agent)\n\n\ndef test_validate_agent_by_the_whole_game():\n curr_agent = SimpleAgent('highest_first_action')\n\n file = \"bridge_data_1/Aulpll23.pbn\"\n files = Parser([file])\n return validate_agent_per_data_game(agent=curr_agent, dg=files.games[4])\n\n\ndef display_results(agents_scores: List[np.ndarray], names: List[str],\n num_of_games: int, min_tricks_num: int=0):\n labels = [i for i in range(13 - min_tricks_num, 1, -1)]\n x = np.arange(len(labels)) # the label locations\n num_agents = len(agents_scores)\n width = 1 / (num_agents+2) # the width of the bars\n\n fig, ax = plt.subplots()\n rects_list = []\n for i in range(num_agents):\n rects_list.append(ax.bar(x + ((i - ((num_agents-1) / 2)) * width),\n agents_scores[i], width, label=names[i]))\n\n ax.set_ylabel('Match success rate (%)')\n ax.set_xlabel('Hand size (cards)')\n ax.set_title(f'Scores by trick and agent\\n (data from {num_of_games} games)')\n ax.set_title(f'Prediction success rate as func. of # cards in hand\\naveraged over {num_of_games} games')\n ax.set_xticks(x)\n ax.set_xticklabels(labels)\n ax.legend(loc='best')\n ax.set_ylim([0, 119])\n fig.tight_layout()\n plt.show()\n\n\ndef run_validation(agents_list: List[IAgent], num_of_games: int,\n min_tricks: int=0) -> List[np.ndarray]:\n \"\"\"\n\n :param agents_list:\n :param num_of_games: if 0: run all games\n :param min_tricks: trick index to start validation from (0 for start of game)\n :return: list of arrays, one for every agent. the array is consist of 12\n entries, each represents the score of agent respectivly to the number\n of remaining cards in its hand.\n \"\"\"\n agents_scores = [np.zeros(12) for _ in agents_list]\n games = load_all_game()\n if num_of_games == 0:\n num_of_games = len(games.games)\n\n for agent_idx, agent in enumerate(agents_list):\n start = perf_counter()\n all_checks, all_succeeds = np.zeros(12), np.zeros(12)\n for i in range(num_of_games):\n curr_checks, curr_succeeds = validate_agent_per_data_game(\n agent, games.games[i], min_tricks)\n all_checks += curr_checks\n all_succeeds += curr_succeeds\n if (i+1) % 25 == 0:\n print(f\"Finished {i+1}/{num_of_games} games for agent {agent.__class__.__name__}\")\n agents_scores[agent_idx] = (all_succeeds / all_checks) * 100\n print(f\"agent {agent_idx}: {(perf_counter() - start)/num_of_games} seconds/game, {num_of_games} games\")\n print(agents_scores)\n return agents_scores\n\n\nif __name__ == '__main__':\n ### Tests\n # test_snapshot()\n # test_all_snapshots_single_game()\n # test_validate_agent_action()\n # test_load_all_game()\n # test_valid_games()\n # test_all_snapshots()\n # games_length()\n # test_validate_agent_by_the_whole_game()\n\n num_of_games = 1 # how many data_games to use for validation\n minimum_round = 8 # trick index to start validation from (0 for start of game)\n\n ### Run Simple agents\n # agents_list = [SimpleAgent(kind) for kind in simple_func_names]\n # agents_scores_list = run_validation(agents_list, num_of_games, min_tricks_num)\n # display_results(agents_scores_list, simple_agent_names, num_of_games)\n\n ### Run AB agents\n # agents_list = [AlphaBetaAgent(kind, depth=12) for kind in ab_evaluation_func_names]\n # agents_scores_list = run_validation(agents_list, num_of_games, min_tricks_num)\n # display_results([agent[min_tricks_num:] for agent in agents_scores_list],\n # ab_evaluation_agent_names, num_of_games, min_tricks_num)\n\n ### Run MTCs (choose one agents_list every time not to be a comment)\n num_of_simulations = 10\n agents_list = [SimpleMCTSAgent(kind, num_simulations=num_of_simulations)\n for kind in simple_func_names]\n agent_names = [f\"{agent_cls.__class__.__name__}({func_name})\" for agent_cls, func_name in zip(agents_list, simple_func_names)]\n # agents_list = [StochasticSimpleMCTSAgent(kind, num_simulations=num_of_simulations)\n # for kind in simple_func_names]\n # agents_list = [PureMCTSAgent(kind, num_simulations=num_of_simulations)\n # for kind in simple_func_names]\n agents_scores_list = run_validation(agents_list, num_of_games, minimum_round)\n display_results([agent[minimum_round:] for agent in agents_scores_list],\n agent_names, num_of_games, minimum_round)\n"},"directory_id":{"kind":"string","value":"bc243e76c3325268e8a1e835e6813d5d79a3c952"},"languages":{"kind":"list like","value":["Markdown","Text","Python"],"string":"[\n \"Markdown\",\n \"Text\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":12,"string":"12"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"oriyanh/Bridge-AI"},"revision_id":{"kind":"string","value":"c613ffb08d774fa17145133eec3d5f0c6022c70d"},"snapshot_id":{"kind":"string","value":"ef740d8ac596b1482002ddd80a1b02a61700471e"}}},{"rowIdx":9920,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"basit-7/File_Handling_in_Python/README.md\nFile Handling\n\n- .txt file are imported in .ipynb\n\n- file_handling.ipynb is the example and their explanation\n\n- try_it_yourself.ipynb us the exercise part."},"directory_id":{"kind":"string","value":"d62f8f209777dd8b08b70bfbfb123f966444e6f8"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"basit-7/File_Handling_in_Python"},"revision_id":{"kind":"string","value":"3c57d9a48db44324650aa751614f5a237e3bb688"},"snapshot_id":{"kind":"string","value":"4cd9d9e4b1f8dd394a8052ba7dcbfbb1c8236b94"}}},{"rowIdx":9921,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"export default {\n song_current: state => state.song_current,\n playlist_list: state => state.playlist_list\n};\n\n\n\n\n\n\n\n\nexport default {\n update_time: 10,\n song_current: '',\n playlist_crc: '',\n volume: 50,\n track_position: 0,\n track_length: 0,\n player_status: {\n status: 'OK',\n RepeatFile: '0',\n RandomFile: '0'\n },\n playlist_list: [\n {\n name: '1 - Travelin Alone',\n length: '236559'\n }, {\n name: '2 - Travelin Alone',\n length: '236559'\n }, {\n name: '3 - Travelin Alone',\n length: '236559'\n }, {\n name: '4 - Travelin Alone',\n length: '236559'\n }, {\n name: '5 - Travelin Alone',\n length: '236559'\n }, {\n name: '6 - Travelin Alone',\n length: '236559'\n }, {\n name: '7 - Travelin Alone',\n length: '236559'\n }, {\n name: '8 - Travelin Alone',\n length: '236559'\n }, {\n name: '9 - Travelin Alone',\n length: '236559'\n }, {\n name: '10 - Travelin Alone',\n length: '236559'\n }, {\n name: '11 - Travelin Alone',\n length: '236559'\n }, {\n name: '12 - Travelin Alone',\n length: '236559'\n }, {\n name: '13 - Travelin Alone',\n length: '236559'\n }, {\n name: '14 - Travelin Alone',\n length: '236559'\n }\n ]\n};\nconst fs = require('fs');\nconst path = require('path');\nconst getDirName = require('path').dirname;\nconst mkdirp = require('mkdirp');\n\nlet file = process.argv.slice(2)[0];\n\nif (!file) {\n const _red = '\\u001b\\[31m';\n const _cyan = '\\u001b\\[36m';\n const _green = '\\u001b\\[32m';\n const _off = '\\u001b\\[0m';\n\n console.log('');\n console.log(`${_red}Empty file name!!!${_off}`);\n console.log('example:');\n const example = [\n _cyan,\n path.basename(process.argv[0]),\n ' ',\n path.basename(process.argv[1]),\n ' ',\n _green,\n 'Component-name',\n _off\n ].join('');\n\n console.log(` ${example}`);\n console.log('');\n process.exit(1);\n}\n\nfile = path.normalize(file);\n\nfile = path.join(__dirname, 'src', 'components', file);\n\nif (!(/.*\\.vue$/).test(file)) {\n file += '.vue';\n}\n\n// Get template\nconst content = require('./create-tmpl').tmp(file);\n\nwriteFile(file, content)\n .then(() => {\n console.log(`\\n \\uD83D\\uDC4D ${file}\\n`);\n })\n .catch((err) => {\n console.log('\\uD83D\\uDC80');\n console.log(err);\n });\n\n/**\n * Functions ======\n */\n\nfunction writeFile(path, contents) {\n return new Promise((resolve, reject) => {\n mkdirp(getDirName(path), function(err) {\n if (err) {\n return reject(err);\n }\n fs.writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n return reject(err);\n }\n resolve();\n });\n });\n });\n}\n\n\n\n\n\n\n\n# aimp-web-ctl-vue\n\n> A Vue.js project\n\n\n[Material](https://getmdl.io/components/index.html#layout-section)\n\n[Icon](https://material.io/icons)\n\n[Vue-resource](https://github.com/pagekit/vue-resource)\n\n[Style of controls](http://nisnom.com/veb-razrabotki/effekt-kak-by-vdavlivayushhihsya-knopok-pri-nazhatii/)\n\n\n***\n\n[-] get_playlist_list\n[] get_version_string\n[] get_version_number\n[] get_update_time - получение настроек обновления\n[] get_playlist_songs\n[] get_playlist_crc\n[-] get_player_status\n[] get_song_current\n[] get_volume\n[] get_track_position\n[] get_track_length\n[] get_custom_status\n\n[] set_volume\n[] set_track_position\n[] set_custom_status\n[] set_song_play\n[] set_song_position - меняем позицицю песни, и обновляем список песен\n[] set_custom_status\n[] set_player_status\n\n[] player_play\n[] player_pause\n[] player_stop\n[] player_prevous\n[] player_next\n\n[] playlist_sort\n[] playlist_add_file\n[] playlist_del_file\n[] playlist_queue_add\n[] playlist_queue_remove\n\n====\n\nget_track_position\nget_volume\nget_song_current\nget_player_status\nget_playlist_crc\n\r\n\r\n\r\n\r\n\r\n\r\n\n\n\n\n\n\n\nimport api from './../api';\n\nexport default {\n GET_STATUS(context) {\n return Promise.all([\n api('get_player_status').then(data => context.commit('status', data))\n ]);\n },\n GET_PLAYLIST_LIST(context, action) {\n return api('get_playlist_list', action.payload).then(data => {\n context.commit('playlist_list', data);\n });\n }\n};\n\n\n/*\nget_playlist_list\nget_song_current\nget_volume\nget_player_status\nget_playlist_crc\n*/\nexport default {\n HOST: 'http://localhost',\n API: ':38475/'\n};\n\r\n\r\n\r\n\r\n\r\n\n\n\n\n\nimport Vue from 'vue';\nimport Router from 'vue-router';\nimport Playlist from '@/components/Playlist/Playlist';\n\nVue.use(Router);\n\nexport default new Router({\n routes: [\n {\n path: '/',\n name: 'playlist',\n component: Playlist\n }\n ]\n});\n"},"directory_id":{"kind":"string","value":"001b0bb7c9df50537d6db5f7aef82cd591efabd9"},"languages":{"kind":"list like","value":["Markdown","Vue","JavaScript"],"string":"[\n \"Markdown\",\n \"Vue\",\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":13,"string":"13"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"avil13/aimp-web-ctl-vue"},"revision_id":{"kind":"string","value":"6a0c3bb943be4c1d94ed11f114c4e6fba30730ce"},"snapshot_id":{"kind":"string","value":"98a9d80ea95d076f2534667d1ffd4b4f9eaed59a"}}},{"rowIdx":9922,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"sudddy/Just-Copy/README.md\n# Just-Copy CHROME EXTENSION\n\nJUST COPY - Copy all tab links in just one click.\n\nYou can perform any of the following :\n \n1. Copy Links from Current Window Tabs \n2. Copy Links from Other Window Tabs \n3. Copy Selected Links\n\n\n#Developed by Sudharsan.\n\n#Design by \nhttps://dribbble.com/Lakshmi_Narasimhan\n\nWatch how it works: \nYouTube - https://www.youtube.com/watch?v=1am6ACqPUmo&feature=youtu.be\n\nFor Non-Chrome OS Users: \n\nHOW TO USE: \n\n1. Download this project using \"Clone or Download\" option.\n2. Goto \"Chrome://extensions\" in Google Chrome.\n3. Enable Developer Mode options in right corner.\n4. Then, Click on \"Load unpacked Extension\" and upload the downloaded folder. \n5. Now you will see the \"JUST COPY\" Extension added to your chrome.\n"},"directory_id":{"kind":"string","value":"df42ee8698c7d749610ab16a77367842ccdc6a46"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"sudddy/Just-Copy"},"revision_id":{"kind":"string","value":"9bdfec74f79324c7bc74e878dbac7cb9d934eeb6"},"snapshot_id":{"kind":"string","value":"17fc1555c9a7298189abbaeab4c7526f5bd51668"}}},{"rowIdx":9923,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"//////////\r\n//\r\n//\tFile:\t\tVRMovies.h\r\n//\r\n//\tContains:\tSupport for QuickTime movie playback in VR nodes.\r\n//\r\n//\tWritten by:\t\r\n//\r\n//\tCopyright:\t© 1997 by Apple Computer, Inc., all rights reserved.\r\n//\r\n//\tChange History (most recent first):\r\n//\r\n// <2> 10/21/02 era building Mach-O\r\n//\t <1>\t \t12/11/96\trtm\t\tfirst file \r\n//\t \r\n//////////\r\n\r\n#pragma once\r\n\r\n//////////\r\n//\t \r\n// header files\r\n//\t \r\n//////////\r\n\r\n#ifdef __MACH__\r\n\t#include \r\n\t#include \r\n#else\r\n\t#ifndef __MOVIES__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __MEDIAHANDLERS__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __QDOFFSCREEN__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __COLORPICKER__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __FIXMATH__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __QUICKTIMEVR__\r\n\t#include \r\n\t#endif\r\n#endif\r\n\r\n#ifndef __QTVRUtilities__\r\n#include \"QTVRUtilities.h\"\r\n#endif\r\n\r\n#ifndef __QTUtilities__\r\n#include \"QTUtilities.h\"\r\n#endif\r\n\r\n#if TARGET_OS_WIN32\r\n\t#ifndef _INC_COMMDLG\r\n\t#include \r\n\t#endif\r\n#endif\r\n\r\n#include \"ComApplication.h\"\r\n#include \"ComFramework.h\"\r\n\r\n\r\n//////////\r\n//\t \r\n// compiler macros\r\n//\t \r\n//////////\r\n\r\n#define RECT_WIDTH(rect)\t\t\t((rect).right-(rect).left)\r\n#define RECT_HEIGHT(rect)\t\t\t((rect).bottom-(rect).top)\r\n\r\n\r\n//////////\r\n//\t \r\n// constants\r\n//\t \r\n//////////\r\n\r\n#define kDefaultEmbMovieWidth\t\tQTVRUtils_DegreesToRadians(20.0)\r\n#define kColorPickerTextStringID\t128\r\n\r\n\r\n//////////\r\n//\t \r\n// function prototypes\r\n//\t \r\n//////////\r\n\r\nApplicationDataHdl\t\t\t\t\tVRMoov_InitWindowData (WindowObject theWindowObject);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_DumpWindowData (WindowObject theWindowObject);\r\nBoolean\t\t\t\t\t\t\t\tVRMoov_GetEmbeddedMovie (WindowObject theWindowObject);\r\nBoolean\t\t\t\t\t\t\t\tVRMoov_LoadEmbeddedMovie (FSSpec *theMovieFile, WindowObject theWindowObject);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_LoopEmbeddedMovie (Movie theMovie);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_DumpEmbeddedMovie (WindowObject theWindowObject);\r\nOSErr\t\t\t\t\t\t\t\tVRMoov_InstallBackBufferImagingProc (QTVRInstance theInstance, WindowObject theWindowObject);\r\nOSErr\t\t\t\t\t\t\t\tVRMoov_CalcImagingMatrix (WindowObject theWindowObject, Rect *theBBufRect);\r\nOSErr\t\t\t\t\t\t\t\tVRMoov_SetupDecompSeq (WindowObject theWindowObject, GWorldPtr theDestGWorld);\r\nOSErr\t\t\t\t\t\t\t\tVRMoov_RemoveDecompSeq (WindowObject theWindowObject);\r\nPASCAL_RTN OSErr\t\t\t\t\tVRMoov_BackBufferImagingProc (QTVRInstance theInstance, Rect *theRect, UInt16 theAreaIndex, UInt32 theFlagsIn, UInt32 *theFlagsOut, long theRefCon);\r\nfloat\t\t\t\t\t\t\t\tVRMoov_GetEmbeddedMovieWidth (WindowObject theWindowObject);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_SetEmbeddedMovieWidth (WindowObject theWindowObject, float theWidth);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_GetEmbeddedMovieCenter (WindowObject theWindowObject, QTVRFloatPoint *theCenter);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_SetEmbeddedMovieCenter (WindowObject theWindowObject, const QTVRFloatPoint *theCenter);\r\nfloat\t\t\t\t\t\t\t\tVRMoov_GetEmbeddedMovieScale (WindowObject theWindowObject);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_SetEmbeddedMovieScale (WindowObject theWindowObject, float theScale);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_SetChromaColor (WindowObject theWindowObject);\r\nPASCAL_RTN OSErr\t\t\t\t\tVRMoov_UncoverProc (Movie theMovie, RgnHandle theRegion, long theRefCon);\r\nPASCAL_RTN Boolean\t\t\t\t\tVRMoov_ColorDialogEventFilter (EventRecord *theEvent);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_SetVideoGraphicsMode (Movie theMovie, ApplicationDataHdl theAppData, Boolean theSetVGM);\r\nshort\t\t\t\t\t\t\t\tVRMoov_GetVideoGraphicsPixelDepth (Movie theMovie);\r\n#if TARGET_OS_WIN32\r\nvoid\t\t\t\t\t\t\t\tVRMoov_MacRGBToWinRGB (RGBColorPtr theRGBColor, COLORREF *theColorRef);\r\nvoid\t\t\t\t\t\t\t\tVRMoov_WinRGBToMacRGB (RGBColorPtr theRGBColor, COLORREF theColorRef);\r\n#endif//////////\r\n//\r\n//\tFile:\t\tVRMovies.c\r\n//\r\n//\tContains:\tSupport for QuickTime movie playback in VR nodes.\r\n//\r\n//\tWritten by:\t\r\n//\t\t\t\tSome code borrowed from QTVRSamplePlayer by .\r\n//\r\n//\tCopyright:\t© 1996-1998 by Apple Computer, Inc., all rights reserved.\r\n//\r\n//\tChange History (most recent first):\r\n//\r\n//\t <16>\t \t03/20/00\trtm\t\tmade changes to get things running under CarbonLib\r\n//\t <15>\t \t06/23/99\trtm\t\tadded VRMoov_MacRGBToWinRGB and VRMoov_WinRGBToMacRGB\r\n//\t <14>\t \t06/22/99\trtm\t\tmore work on matrices; now everything works okay (AFAICT)\r\n//\t <13>\t \t06/21/99\trtm\t\tadded call to UpdateMovie to back buffer imaging procedure\r\n//\t <12>\t \t06/18/99\trtm\t\tgot movie matrices working correctly; added color picking to Windows\r\n//\t <11>\t \t06/17/99\trtm\t\treworked geometry of back buffer yet again; now we copy from the\r\n//\t\t\t\t\t\t\t\t\toffscreen GWorld to back buffer using use DecompressSequenceFrameS\r\n//\t <10>\t \t05/16/99\trtm\t\tadded VRMoov_DumpWindowData; further work on geometry of back buffer\r\n//\t <9>\t \t05/15/99\trtm\t\treworked geometry handling to support horizontal back buffer in QT 4.0\r\n//\t <8>\t \t05/04/98\trtm\t\tadded automatic rotation of movie\r\n//\t <7>\t \t03/06/97\trtm\t\tstarted to implement video masking\r\n//\t <6>\t \t03/05/97\trtm\t\tadded VRMoov_SetChromaColor; added fChromaColor to app data record\r\n//\t <5>\t \t03/04/97\trtm\t\tfixed compositing problems at back buffer edges\r\n//\t <4>\t \t03/03/97\trtm\t\tadded VRMoov_SetVideoGraphicsMode to handle compositing\r\n//\t\t\t\t\t\t\t\t\twithout using an offscreen GWorld\r\n//\t <3>\t \t02/27/97\trtm\t\tfurther development: borrowed some ideas from QTVRSamplePlayer;\r\n//\t\t\t\t\t\t\t\t\tadded VRMoov_SetEmbeddedMovieWidth etc.\r\n//\t <2>\t \t12/12/96\trtm\t\tfurther development: borrowed some ideas from BoxMoov demo \r\n//\t <1>\t \t12/11/96\trtm\t\tfirst file \r\n//\t \r\n// This code draws the QuickTime movie frames into the back buffer, either directly\r\n// or indirectly (via an offscreen GWorld). Direct drawing gives the best performance,\r\n// but indirect drawing is necessary for some visual effects. \r\n//\r\n//////////\r\n\r\n// TO DO:\r\n// + finish video masking by custom 'hide' hot spots (so video goes *behind* such hot spots)\r\n// + verify that everything works okay if *images* are used instead of movies (scaling seems to be a problem)\r\n\r\n\r\n//////////\r\n//\t \r\n// header files\r\n//\t \r\n//////////\r\n\r\n#include \"VRMovies.h\"\r\n\r\n\r\n//////////\r\n//\t \r\n// constants\r\n//\t \r\n//////////\r\n\r\nconst RGBColor\t\t\tkClearColor = {0x0000, 0xffff, 0x0000};\t\t// the default chroma key color\r\nconst RGBColor\t\t\tkBlackColor = {0x0000, 0x0000, 0x0000};\r\nconst RGBColor\t\t\tkWhiteColor = {0xffff, 0xffff, 0xffff};\r\n\r\n\r\n//////////\r\n//\t \r\n// global variables\r\n//\t \r\n//////////\r\n\r\n#if TARGET_OS_MAC\r\nUserEventUPP\t\t\tgColorFilterUPP = NULL;\t\t\t\t\t\t// UPP to our custom color picker dialog event filter\r\n#endif\r\n\r\n//////////\r\n//\r\n// VRMoov_InitWindowData\r\n// Initialize any window-specific data.\r\n//\r\n//////////\r\n\r\nApplicationDataHdl VRMoov_InitWindowData (WindowObject theWindowObject)\r\n{\r\n#pragma unused(theWindowObject)\r\n\r\n\tApplicationDataHdl\tmyAppData;\r\n\t\r\n\tmyAppData = (ApplicationDataHdl)NewHandleClear(sizeof(ApplicationDataRecord));\r\n\tif (myAppData != NULL) {\r\n\t\t(**myAppData).fMovie = NULL;\r\n\t\t(**myAppData).fOffscreenGWorld = NULL;\r\n\t\t(**myAppData).fOffscreenPixMap = NULL;\r\n\t\t(**myAppData).fPrevBBufGWorld = NULL;\r\n\t\t(**myAppData).fMovieCenter.x = 0.0;\r\n\t\t(**myAppData).fMovieCenter.y = 0.0;\r\n\t\t(**myAppData).fMovieScale = 1.0;\r\n\t\t(**myAppData).fMovieWidth = kDefaultEmbMovieWidth;\r\n\t\t(**myAppData).fUseOffscreenGWorld = false;\r\n\t\t(**myAppData).fUseMovieCenter = true;\r\n\t\t(**myAppData).fQTMovieHasSound = false;\r\n\t\t(**myAppData).fCompositeMovie = false;\r\n\t\t(**myAppData).fUseHideRegion = false;\r\n\t\t(**myAppData).fChromaColor = kClearColor;\r\n\t\t(**myAppData).fHideRegion = NULL;\r\n\t\t(**myAppData).fBackBufferIsHoriz = false;\r\n\t\t(**myAppData).fImageDesc = NULL;\r\n\t\t(**myAppData).fImageSequence = 0;\r\n\t\t\r\n\t\tSetIdentityMatrix(&(**myAppData).fMovieMatrix);\r\n\t\tSetIdentityMatrix(&(**myAppData).fOrigMovieMatrix);\r\n\t\t\r\n\t\t// create a new routine descriptor\r\n\t\t(**myAppData).fBackBufferProc = NewQTVRBackBufferImagingUPP(VRMoov_BackBufferImagingProc);\r\n\t}\r\n\r\n#if TARGET_OS_MAC\t\r\n\tif (gColorFilterUPP == NULL)\r\n\t\tgColorFilterUPP = NewUserEventUPP(VRMoov_ColorDialogEventFilter);\r\n#endif\r\n\t\t\r\n\treturn(myAppData);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_DumpWindowData\r\n// Dispose of any window-specific data.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_DumpWindowData (WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\treturn;\r\n\r\n\tVRMoov_DumpEmbeddedMovie(theWindowObject);\r\n\t\r\n\tDisposeQTVRBackBufferImagingUPP((**myAppData).fBackBufferProc);\r\n}\r\n\r\n\r\n///////////\r\n//\r\n// VRMoov_GetEmbeddedMovie\r\n// Get the QuickTime movie to be embedded in a panorama.\r\n// Returns a Boolean to indicate success (true) or failure (false).\r\n//\r\n//////////\r\n\r\nBoolean VRMoov_GetEmbeddedMovie (WindowObject theWindowObject)\r\n{\r\n\tFSSpec\t\t\t\t\tmyFSSpec;\r\n\tOSType \t\t\t\t\tmyTypeList = kQTFileTypeMovie;\r\n\tOSErr\t\t\t\t\tmyErr = paramErr;\r\n\r\n\t// do some preliminary parameter checking\r\n\tif (theWindowObject == NULL)\r\n\t\treturn(false);\r\n\t\r\n\tif (!QTFrame_IsWindowObjectOurs(theWindowObject))\r\n\t\treturn(false);\r\n\t\r\n\t// elicit the movie file from user\r\n\tmyErr = QTFrame_GetOneFileWithPreview(1, (QTFrameTypeListPtr)&myTypeList, &myFSSpec, NULL);\r\n\tif (myErr != noErr) {\r\n\t\tVRMoov_DumpEmbeddedMovie(theWindowObject); \t// clean up any existing embedded movie\r\n\t\treturn(false);\r\n\t}\r\n\t\t\r\n\treturn(VRMoov_LoadEmbeddedMovie(&myFSSpec, theWindowObject));\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_LoadEmbeddedMovie\r\n// Load the QuickTime movie in the specified file.\r\n// Returns a Boolean to indicate success (true) or failure (false).\r\n//\r\n//////////\r\n\r\nBoolean VRMoov_LoadEmbeddedMovie (FSSpec *theMovieFile, WindowObject theWindowObject)\r\n{\r\n\tshort\t\t\t\t\tmyMovieFileRef;\r\n\tMovie\t\t\t\t\tmyMovie;\r\n\tGWorldPtr\t\t\t\tmyGWorld = NULL;\r\n\tRect\t\t\t\t\tmyRect;\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\tOSErr\t\t\t\t\tmyErr = paramErr;\r\n\t\t\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\tgoto bail;\r\n\r\n\tHLock((Handle)myAppData);\r\n\t\r\n\t//////////\r\n\t//\r\n\t// open the movie file and the movie\r\n\t//\r\n\t//////////\r\n\t\r\n\tmyErr = OpenMovieFile(theMovieFile, &myMovieFileRef, fsRdPerm);\r\n\tif (myErr != noErr)\r\n\t\tgoto bail;\r\n\r\n\tmyErr = NewMovieFromFile(&myMovie, myMovieFileRef, NULL, (StringPtr)NULL, newMovieActive, NULL);\r\n\tif (myErr != noErr)\r\n\t\tgoto bail;\r\n\r\n\t//////////\r\n\t//\r\n\t// get the movie geometry\r\n\t//\r\n\t//////////\r\n\t\r\n\tGetMovieBox(myMovie, &myRect);\r\n\tGetMovieMatrix(myMovie, &(**myAppData).fOrigMovieMatrix);\r\n\tMacOffsetRect(&myRect, -myRect.left, -myRect.top);\r\n\tSetMovieBox(myMovie, &myRect);\r\n\r\n\t// keep track of the movie and movie rectangle (in our app-specific data structure)\r\n\t(**myAppData).fMovie = myMovie;\r\n\t(**myAppData).fMovieBox = myRect;\r\n\r\n\t// determine the orientation of the back buffer\r\n\t(**myAppData).fBackBufferIsHoriz = QTVRUtils_IsBackBufferHorizontal((**theWindowObject).fInstance);\r\n\t\r\n\t// get rid of any existing offscreen graphics world\r\n\tif ((**myAppData).fOffscreenGWorld != NULL) {\r\n\t\tDisposeGWorld((**myAppData).fOffscreenGWorld);\r\n\t\t(**myAppData).fOffscreenGWorld = NULL;\r\n\t}\r\n\t\r\n\t// clear out any existing custom cover/uncover functions and reset the video media graphics mode\r\n\t// (these may have been modified for direct-screen drawing)\r\n\tSetMovieCoverProcs(myMovie, NULL, NULL, 0L);\r\n\tVRMoov_SetVideoGraphicsMode(myMovie, myAppData, false);\r\n\t\r\n\t//////////\r\n\t//\r\n\t// if necessary, create an offscreen graphics world\r\n\t//\r\n\t// this is where we'll image the movie before copying it into the back buffer\r\n\t// when we want to do special effects\r\n\t//\r\n\t//////////\r\n\t\r\n\tif ((**myAppData).fUseOffscreenGWorld) {\r\n\t\tmyErr = NewGWorld(&myGWorld, 0, &myRect, NULL, NULL, 0);\r\n\t\t(**myAppData).fOffscreenGWorld = myGWorld;\r\n\t\t(**myAppData).fOffscreenPixMap = GetGWorldPixMap(myGWorld);\r\n\t\t\r\n\t\t// make an image description, which is needed by DecompressSequenceBegin\r\n\t\tLockPixels((**myAppData).fOffscreenPixMap);\r\n\t\tMakeImageDescriptionForPixMap((**myAppData).fOffscreenPixMap, &((**myAppData).fImageDesc));\r\n\t\tUnlockPixels((**myAppData).fOffscreenPixMap);\r\n\t} else {\r\n\t\t// set the video media graphics mode to drop out the chroma key color in a movie;\r\n\t\t// we also need to install an uncover function that doesn't erase the uncovered region\r\n\t\tif ((**myAppData).fCompositeMovie) {\r\n\t\t\tVRMoov_SetVideoGraphicsMode(myMovie, myAppData, true);\r\n\t\t\tSetMovieCoverProcs(myMovie, NewMovieRgnCoverUPP(VRMoov_UncoverProc), NULL, (long)theWindowObject);\r\n\t\t}\r\n\t}\r\n\t\r\n\t//////////\r\n\t//\r\n\t// install the back-buffer imaging procedure\r\n\t//\r\n\t//////////\r\n\t\r\n\tif ((**theWindowObject).fInstance != NULL)\r\n\t\tmyErr = VRMoov_InstallBackBufferImagingProc((**theWindowObject).fInstance, theWindowObject);\r\n\t\t\r\n\t// start the movie playing in a loop\r\n\tVRMoov_LoopEmbeddedMovie(myMovie);\r\n\r\nbail:\r\n\t// we don't want to edit the embedded movie, so we can close the movie file\r\n\tif (myMovieFileRef != 0)\r\n\t\tCloseMovieFile(myMovieFileRef);\r\n\t\t\r\n\tHUnlock((Handle)myAppData);\r\n\r\n\treturn(myErr == noErr);\r\n}\r\n\t\r\n\t\r\n//////////\r\n//\r\n// VRMoov_LoopEmbeddedMovie\r\n// Start the QuickTime movie playing in a loop.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_LoopEmbeddedMovie (Movie theMovie)\r\n{\r\n\tTimeBase\t\tmyTimeBase;\r\n\r\n\t// throw the movie into loop mode\r\n\tmyTimeBase = GetMovieTimeBase(theMovie);\r\n\tSetTimeBaseFlags(myTimeBase, GetTimeBaseFlags(myTimeBase) | loopTimeBase);\r\n\r\n\t// start playing the movie\r\n\tStartMovie(theMovie);\r\n}\r\n\t\r\n\r\n//////////\r\n//\r\n// VRMoov_DumpEmbeddedMovie\r\n// Stop any existing embedded movie from playing and then clean up.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_DumpEmbeddedMovie (WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\r\n\tif (theWindowObject == NULL) \r\n\t\tgoto bail;\r\n\t\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\tgoto bail;\r\n\t\r\n\t// if we have an embedded movie, stop it from playing and dispose of it\r\n\tif ((**myAppData).fMovie != NULL) {\r\n\t\tStopMovie((**myAppData).fMovie);\r\n\t\tDisposeMovie((**myAppData).fMovie);\r\n\t\t(**myAppData).fMovie = NULL;\r\n\t}\r\n\t\r\n\t// get rid of any existing offscreen graphics world\r\n\tif ((**myAppData).fOffscreenGWorld != NULL) {\r\n\t\tDisposeGWorld((**myAppData).fOffscreenGWorld);\r\n\t\t(**myAppData).fOffscreenGWorld = NULL;\r\n\t}\r\n\t\r\n\t// clear the existing back buffer imaging proc\r\n\tQTVRSetBackBufferImagingProc((**theWindowObject).fInstance, NULL, 0, NULL, 0);\r\n\t\r\n\t// clear out any other movie-specific data\r\n\t(**myAppData).fPrevBBufGWorld = NULL;\r\n\tMacSetRect(&(**myAppData).fPrevBBufRect, 0, 0, 0, 0);\r\n\t\r\n\tMacSetRect(&(**myAppData).fMovieBox, 0, 0, 0, 0);\r\n\tSetIdentityMatrix(&(**myAppData).fMovieMatrix);\r\n\tSetIdentityMatrix(&(**myAppData).fOrigMovieMatrix);\r\n\t\r\n\tif ((**myAppData).fImageDesc != NULL) {\r\n\t\tDisposeHandle((Handle)(**myAppData).fImageDesc);\r\n\t\t(**myAppData).fImageDesc = NULL;\r\n\t}\r\n\t\r\n\tVRMoov_RemoveDecompSeq(theWindowObject);\r\n\t\r\n\t// make sure the back buffer is clean\r\n\tQTVRRefreshBackBuffer((**theWindowObject).fInstance, 0);\r\n\r\nbail:\r\n\treturn;\r\n}\r\n\t\r\n\r\n//////////\r\n//\r\n// VRMoov_InstallBackBufferImagingProc\r\n// Install a back buffer imaging procedure.\r\n// (This routine might sometimes be called to move or resize the area of interest within the panorama.)\r\n//\r\n//////////\r\n\r\nOSErr VRMoov_InstallBackBufferImagingProc (QTVRInstance theInstance, WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tQTVRAreaOfInterest\t\tmyArea;\r\n\tfloat\t\t\t\t\tmyWidth, myHeight;\r\n\tOSErr\t\t\t\t\tmyErr = noErr;\r\n\r\n\t//////////\r\n\t//\r\n\t// initialize; clean up any existing back buffer procedure\r\n\t//\r\n\t//////////\r\n\t\r\n\tif ((theInstance == NULL) || (theWindowObject == NULL)) \r\n\t\treturn(paramErr);\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL) \r\n\t\treturn(paramErr);\r\n\r\n\tHLock((Handle)myAppData);\r\n\t\r\n\t// remove any existing back buffer imaging procedure\r\n\tif ((**myAppData).fBackBufferProc != NULL)\r\n\t\tQTVRSetBackBufferImagingProc(theInstance, NULL, 0, NULL, 0);\r\n\r\n\t//////////\r\n\t//\r\n\t// set the area of interest\r\n\t//\r\n\t// the panAngle and tiltAngle fields define the top-left corner, in panorama space, of the area of interest;\r\n\t// so here we do not have to worry about whether the back buffer is oriented vertically or horizontally\r\n\t//\r\n\t//////////\r\n\t\r\n\t// the application data structure holds the desired width, center, size, and scale of the movie\r\n\tmyWidth = (**myAppData).fMovieWidth * (**myAppData).fMovieScale;\r\n\tmyHeight = myWidth * (((float)(**myAppData).fMovieBox.bottom) / ((float)(**myAppData).fMovieBox.right));\r\n\t\r\n\tif ((**myAppData).fUseMovieCenter) {\r\n\t\t// use the stored movie center\r\n\t\tmyArea.panAngle = (**myAppData).fMovieCenter.x + (myWidth/2);\r\n\t\tmyArea.tiltAngle = (**myAppData).fMovieCenter.y + (myHeight/2);\r\n\t} else {\r\n\t\t// center the movie on the current pan and tilt angles\r\n\t\tmyArea.panAngle = QTVRGetPanAngle(theInstance) + (myWidth/2);\r\n\t\tmyArea.tiltAngle = QTVRGetTiltAngle(theInstance) + (myHeight/2);\r\n\t}\r\n\r\n\tmyArea.width = myWidth;\r\n\tmyArea.height = myHeight;\r\n\r\n\t//////////\r\n\t//\r\n\t// set the back buffer flags and install the back buffer procedure\r\n\t//\r\n\t//////////\r\n\t\r\n\t// make sure we get called on every idle event, so we can keep playing the embedded movie;\r\n\t// also make sure we get called on every back buffer update\r\n\tif ((**myAppData).fCompositeMovie)\r\n\t\tmyArea.flags = kQTVRBackBufferEveryIdle | kQTVRBackBufferEveryUpdate | kQTVRBackBufferAlwaysRefresh;\r\n\telse\r\n\t\tmyArea.flags = kQTVRBackBufferEveryIdle | kQTVRBackBufferEveryUpdate;\r\n\t\r\n\t// if the back buffer is oriented horizontally, set the appropriate flag\r\n\tif ((**myAppData).fBackBufferIsHoriz)\r\n\t\tmyArea.flags |= kQTVRBackBufferHorizontal;\r\n\r\n\t// install our procedure\r\n\tmyErr = QTVRSetBackBufferImagingProc(theInstance, (**myAppData).fBackBufferProc, 1, &myArea, (SInt32)theWindowObject);\r\n\r\n\tHUnlock((Handle)myAppData);\r\n\treturn(myErr);\r\n}\r\n\t\r\n\t\r\n//////////\r\n//\r\n// VRMoov_CalcImagingMatrix\r\n// Calculate the movie matrix required to draw the embedded movie into the specified rectangle.\r\n//\r\n//////////\r\n\r\nOSErr VRMoov_CalcImagingMatrix (WindowObject theWindowObject, Rect *theBBufRect)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\tRect\t\t\t\t\tmyDestRect = *theBBufRect;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL) \r\n\t\treturn(paramErr);\r\n\t\t\r\n\t// reset the current movie matrix with the original movie matrix of the embedded movie;\r\n\t// we need to preserve that matrix in our calculations below if we are not drawing the\r\n\t// movie into an offscreen GWorld\r\n\t(**myAppData).fMovieMatrix = (**myAppData).fOrigMovieMatrix;\r\n\t\r\n\t// in general, it's easiest to construct the desired matrix by first doing the scaling\r\n\t// and then doing the rotation and translation (if necessary); so we need to swap the\r\n\t// right and bottom edges of the back buffer rectangle before doing the scaling, if a\r\n\t// rotation will also be necessary\r\n\tif (!(**myAppData).fBackBufferIsHoriz) {\r\n\t\tmyDestRect.bottom = theBBufRect->right;\r\n\t\tmyDestRect.right = theBBufRect->bottom;\r\n\t}\r\n\t\r\n\t// set up the scaling matrix\r\n\t// (MapMatrix concatenates the new matrix to the existing matrix, whereas RectMatrix first\r\n\t// sets the existing matrix to the identity matrix)\r\n\tif ((**myAppData).fUseOffscreenGWorld)\r\n\t\tRectMatrix(&(**myAppData).fMovieMatrix, &(**myAppData).fMovieBox, &myDestRect);\r\n\telse\r\n\t\tMapMatrix(&(**myAppData).fMovieMatrix, &(**myAppData).fMovieBox, &myDestRect);\r\n\r\n\t// add a rotation and translation, if necessary\r\n\tif (!(**myAppData).fBackBufferIsHoriz) {\r\n\t\tRotateMatrix(&(**myAppData).fMovieMatrix, Long2Fix(-90), 0, 0);\r\n\t\tTranslateMatrix(&(**myAppData).fMovieMatrix, 0, Long2Fix(RECT_HEIGHT(*theBBufRect)));\r\n\t}\r\n\t\r\n\treturn(noErr);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetupDecompSeq\r\n// Set up the decompression sequence for DecompressionSequenceFrameS.\r\n//\r\n// This needs to be called whenever either the rectangle or the GWorld of the back buffer changes.\r\n//\r\n//////////\r\n\r\nOSErr VRMoov_SetupDecompSeq (WindowObject theWindowObject, GWorldPtr theDestGWorld)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\tshort\t\t\t\t\tmyMode = srcCopy;\r\n\tOSErr\t\t\t\t\tmyErr = noErr;\r\n\t\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL) \r\n\t\treturn(paramErr);\r\n\t\r\n\t// make sure we don't have a decompression sequence already open\r\n\tVRMoov_RemoveDecompSeq(theWindowObject);\r\n\t\r\n\t// set up the transfer mode\r\n\tif ((**myAppData).fCompositeMovie)\r\n\t\tmyMode = srcCopy | transparent;\r\n\t\t\r\n\t// set up the image decompression sequence\r\n\tmyErr = DecompressSequenceBegin(\t&(**myAppData).fImageSequence,\r\n\t\t\t\t\t\t\t\t\t\t(**myAppData).fImageDesc,\r\n\t\t\t\t\t\t\t\t\t\t(CGrafPtr)theDestGWorld,\r\n\t\t\t\t\t\t\t\t\t\tNULL,\r\n\t\t\t\t\t\t\t\t\t\tNULL,\t\t\t\t\t\t\t// entire source image\r\n\t\t\t\t\t\t\t\t\t\t&(**myAppData).fMovieMatrix,\r\n\t\t\t\t \t\t\t\t\t\tmyMode,\r\n\t\t\t\t\t\t\t\t\t\tNULL,\t\t\t\t\t\t\t// no mask\r\n\t\t\t\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t\t\t\t(**(**myAppData).fImageDesc).spatialQuality,\r\n\t\t\t\t\t\t\t\t\t\tNULL);\r\n\t\t\t\t\t\t\t\t\t\r\n\treturn(myErr);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_RemoveDecompSeq\r\n// Remove the decompression sequence for DecompressionSequenceFrameS.\r\n//\r\n//////////\r\n\r\nOSErr VRMoov_RemoveDecompSeq (WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\tOSErr\t\t\t\t\tmyErr = paramErr;\r\n\t\r\n\tif (theWindowObject != NULL) {\r\n\t\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\t\tif (myAppData != NULL) \r\n\t\t\tif ((**myAppData).fImageSequence != 0) {\r\n\t\t\t\tmyErr = CDSequenceEnd((**myAppData).fImageSequence);\r\n\t\t\t\t(**myAppData).fImageSequence = 0;\r\n\t\t\t}\r\n\t}\r\n\t\r\n\treturn(myErr);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_BackBufferImagingProc\r\n// The back buffer imaging procedure: get a frame of movie and image it into the back buffer.\r\n// Also, do any additional compositing that might be desired.\r\n//\r\n//////////\r\n\r\nPASCAL_RTN OSErr VRMoov_BackBufferImagingProc (QTVRInstance theInstance, Rect *theRect, UInt16 theAreaIndex, UInt32 theFlagsIn, UInt32 *theFlagsOut, long theRefCon)\r\n{\r\n#pragma unused(theAreaIndex)\r\n\tWindowObject\t\t\tmyWindowObject = (WindowObject)theRefCon;\r\n\tApplicationDataHdl\t\tmyAppData = NULL;\r\n\tMovie\t\t\t\t\tmyMovie = NULL;\r\n\tBoolean\t\t\t\t\tmyIsDrawing = theFlagsIn & kQTVRBackBufferRectVisible;\r\n\tGWorldPtr\t\t\t\tmyBBufGWorld, myMovGWorld;\r\n\tGDHandle\t\t\t\tmyBBufGDevice, myMovGDevice;\r\n\tRect\t\t\t\t\tmyRect;\r\n\tOSErr\t\t\t\t\tmyErr = paramErr;\r\n\t\r\n\t//////////\r\n\t//\r\n\t// initialize; make sure that we've got the data we need to continue\r\n\t//\r\n\t//////////\r\n\r\n\t// assume we're not going to draw anything\r\n\t*theFlagsOut = 0;\r\n\t\r\n\tif ((theInstance == NULL) || (myWindowObject == NULL)) \r\n\t\tgoto bail;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(myWindowObject);\r\n\tif (myAppData == NULL) \r\n\t\tgoto bail;\r\n\r\n\tHLock((Handle)myAppData);\r\n\r\n\tmyMovie = (**myAppData).fMovie;\r\n\tif (myMovie == NULL) {\r\n\t\t// we don't have an embedded movie, so remove this back-buffer imaging procedure\r\n\t\tVRMoov_DumpEmbeddedMovie(myWindowObject);\r\n\t\tgoto bail;\r\n\t}\r\n\t\r\n\t//////////\r\n\t//\r\n\t// make sure that the movie GWorld is set correctly;\r\n\t// note that we call SetMovieGWorld only if we have to (for performance reasons)\r\n\t//\r\n\t//////////\r\n\t\r\n\t// get the current graphics world\r\n\t// (on entry, the current graphics world is [usually] set to the back buffer)\r\n\tGetGWorld(&myBBufGWorld, &myBBufGDevice);\r\n\r\n\t// get the embedded movie's graphics world\r\n\tGetMovieGWorld(myMovie, &myMovGWorld, &myMovGDevice);\r\n\r\n\tif ((**myAppData).fUseOffscreenGWorld) {\r\n\t\t// we're using an offscreen graphics world, so set movie's GWorld to be that offscreen graphics world\r\n\t\tif (myMovGWorld != (**myAppData).fOffscreenGWorld)\r\n\t\t\tSetMovieGWorld(myMovie, (**myAppData).fOffscreenGWorld, GetGWorldDevice((**myAppData).fOffscreenGWorld));\t\t\t\r\n\t} else {\r\n\t\t// we're not using an offscreen graphics world, so set movie GWorld to be the back buffer;\r\n\t\tif ((myMovGWorld != myBBufGWorld) || (myMovGDevice != myBBufGDevice))\r\n\t\t\tSetMovieGWorld(myMovie, myBBufGWorld, myBBufGDevice);\r\n\t}\r\n\r\n\t//////////\r\n\t//\r\n\t// make sure the movie rectangle and movie matrix are set correctly\r\n\t//\r\n\t//////////\r\n\t\r\n\tif (myIsDrawing) {\r\n\t\t// if we weren't previously visible, make sure we are now\r\n\t\tGetMovieBox(myMovie, &myRect);\r\n\t\tif (EmptyRect(&myRect))\r\n\t\t\tSetMovieBox(myMovie, &(**myAppData).fMovieBox);\r\n\t\t\r\n\t\t// when no offscreen GWorld is being used...\r\n\t\tif (!(**myAppData).fUseOffscreenGWorld) {\r\n\t\t\t\r\n\t\t\t// ...make sure the movie matrix is set correctly...\r\n\t\t\tif (!MacEqualRect(theRect, &(**myAppData).fPrevBBufRect)) {\r\n\t\t\t\tVRMoov_CalcImagingMatrix(myWindowObject, theRect);\r\n\t\t\t\tSetMovieMatrix(myMovie, &(**myAppData).fMovieMatrix);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// ...and, if we are compositing, force QuickTime to draw a movie frame when MoviesTask is called\r\n\t\t\t// (since the previous frame was automatically erased from the back buffer by QuickTime VR)\r\n\t\t\tif ((**myAppData).fCompositeMovie)\r\n\t\t\t\tUpdateMovie(myMovie);\r\n\t\t}\r\n\t\t\r\n\t} else {\r\n\t\t// if we're not visible, set the movie rectangle to an empty rectangle\r\n\t\t// so we're not wasting time trying to draw a movie frame\r\n\t\tMacSetRect(&myRect, 0, 0, 0, 0);\r\n\t\tSetMovieBox(myMovie, &myRect);\r\n\t}\r\n\r\n\t//////////\r\n\t//\r\n\t// draw a new movie frame into the movie's graphics world (and play movie sound)\r\n\t//\r\n\t//////////\r\n\t\r\n\tMoviesTask(myMovie, 1L);\r\n//\tMoviesTask(myMovie, 0);\r\n\t\r\n\t// if we got here, everything is okay so far\r\n\tmyErr = noErr;\r\n\t\r\n\t//////////\r\n\t//\r\n\t// perform any additional compositing\r\n\t//\r\n\t//////////\r\n\t\r\n\t// that is, draw, using the current chroma key color, anything to be dropped out of the image;\r\n\t// note that this technique works *only* if we're using an offscreen graphics world\r\n\tif ((**myAppData).fUseOffscreenGWorld && (**myAppData).fCompositeMovie && myIsDrawing) {\r\n\t\tRGBColor\tmyColor;\r\n\t\r\n\t\t// since we're using an offscreen graphics world, make sure we draw there\r\n\t\tSetGWorld((**myAppData).fOffscreenGWorld, GetGWorldDevice((**myAppData).fOffscreenGWorld));\r\n\r\n\t\t// set up compositing environment\r\n\t\tGetForeColor(&myColor);\r\n\t\tRGBForeColor(&(**myAppData).fChromaColor);\r\n\t\t\r\n\t\t// do the drawing\r\n\t\tif ((**myAppData).fHideRegion != NULL)\r\n\t\t\tMacPaintRgn((**myAppData).fHideRegion);\r\n\t\t\t\r\n\t\t// restore original drawing environment\r\n\t\tRGBForeColor(&myColor);\r\n\t\t\r\n\t\t// restore original graphics world\r\n\t\tSetGWorld(myBBufGWorld, myBBufGDevice);\r\n\t}\r\n\r\n\t//////////\r\n\t//\r\n\t// if we're using an offscreen graphics world, copy it into the back buffer\r\n\t//\r\n\t//////////\r\n\t\r\n\tif (myIsDrawing) {\r\n\t\r\n\t\tif ((**myAppData).fUseOffscreenGWorld) {\r\n\t\t\tPixMapHandle\tmyPixMap;\r\n\t\t\t\r\n\t\t\t// if anything relevant to DecompressSequenceFrameS has changed, reset the decompression sequence\r\n\t\t\tif ((myBBufGWorld != (**myAppData).fPrevBBufGWorld) || !(MacEqualRect(theRect, &(**myAppData).fPrevBBufRect))) {\r\n\t\t\t\tVRMoov_CalcImagingMatrix(myWindowObject, theRect);\r\n\t\t\t\tVRMoov_SetupDecompSeq(myWindowObject, myBBufGWorld);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tmyPixMap = GetGWorldPixMap((**myAppData).fOffscreenGWorld);\r\n\t\t\tLockPixels(myPixMap);\r\n\t\t\t\r\n\t\t\t// set the chroma key color, if necessary\r\n\t\t\tif ((**myAppData).fCompositeMovie)\r\n\t\t\t\tRGBBackColor(&(**myAppData).fChromaColor);\r\n\t\t\t\r\n\t\t\t// copy the image from the offscreen graphics world into the back buffer\r\n\t\t\tmyErr = DecompressSequenceFrameS(\t(**myAppData).fImageSequence,\r\n#if TARGET_CPU_68K\r\n\t\t\t\t\t\t\t\t\t\t\t\tStripAddress(GetPixBaseAddr(myPixMap)),\r\n#else\r\n\t\t\t\t\t\t\t\t\t\t\t\tGetPixBaseAddr(myPixMap),\r\n#endif\r\n\t\t\t\t\t\t\t\t\t\t\t\t(**(**myAppData).fImageDesc).dataSize,\r\n\t\t\t\t\t\t\t\t\t\t\t\t0,\r\n\t\t\t\t\t\t\t\t\t\t\t\tNULL,\r\n\t\t\t\t\t\t\t\t\t\t\t\tNULL);\r\n\r\n\t\t\t// reset the chroma key color;\r\n\t\t\t// we need to do this because the buffer we just drew into might NOT actually\r\n\t\t\t// be the real back buffer (see Virtual Reality Programming With QuickTime VR, p. 1-154);\r\n\t\t\t// the copy between the intermediate buffer and the back buffer respects the current back color.\r\n\t\t\tif ((**myAppData).fCompositeMovie)\r\n\t\t\t\tRGBBackColor(&kWhiteColor);\r\n\t\t\t\t\r\n\t\t\tUnlockPixels(myPixMap);\r\n\t\t}\r\n\t}\r\n\t\r\n\t//////////\r\n\t//\r\n\t// finish up\r\n\t//\r\n\t//////////\r\n\t\r\n\t// keep track of the GWorld and rectangle passed to us this time\r\n\t(**myAppData).fPrevBBufGWorld = myBBufGWorld;\r\n\t(**myAppData).fPrevBBufRect = *theRect;\r\n\t\r\n\t// if we drew something, tell QuickTime VR\r\n\tif (myIsDrawing)\r\n\t\t*theFlagsOut = kQTVRBackBufferFlagDidDraw;\r\n\t\r\nbail:\t\r\n\tHUnlock((Handle)myAppData);\r\n\treturn(myErr);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_GetEmbeddedMovieWidth\r\n// Get the width of the embedded movie.\r\n//\r\n//////////\r\n\r\nfloat VRMoov_GetEmbeddedMovieWidth (WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tfloat\t\t\t\t\tmyWidth;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\tmyWidth = 0;\r\n\telse\r\n\t\tmyWidth = (**myAppData).fMovieWidth;\r\n\t\t\r\n\treturn(myWidth);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetEmbeddedMovieWidth\r\n// Set the width of the embedded movie.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_SetEmbeddedMovieWidth (WindowObject theWindowObject, float theWidth)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tQTVRInstance\t\t\tmyInstance;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\treturn;\r\n\t\t\r\n\tmyInstance = (**theWindowObject).fInstance;\r\n\tif (myInstance == NULL)\r\n\t\treturn;\r\n\t\r\n\t// install the desired width in our application data structure\r\n\t(**myAppData).fMovieWidth = theWidth;\r\n\t\r\n\t// clear out the existing area of interest\r\n\tQTVRRefreshBackBuffer(myInstance, 0);\r\n\r\n\t// reinstall the back buffer imaging procedure\r\n\tVRMoov_InstallBackBufferImagingProc(myInstance, theWindowObject);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_GetEmbeddedMovieCenter\r\n// Get the center of the embedded movie.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_GetEmbeddedMovieCenter (WindowObject theWindowObject, QTVRFloatPoint *theCenter)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL) {\r\n\t\ttheCenter->x = 0.0;\r\n\t\ttheCenter->y = 0.0;\r\n\t} else {\r\n\t\ttheCenter->x = (**myAppData).fMovieCenter.x;\r\n\t\ttheCenter->y = (**myAppData).fMovieCenter.y;\r\n\t}\r\n\t\t\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetEmbeddedMovieCenter\r\n// Set the center of the embedded movie.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_SetEmbeddedMovieCenter (WindowObject theWindowObject, const QTVRFloatPoint *theCenter)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tQTVRInstance\t\t\tmyInstance;\r\n\tfloat\t\t\t\t\tmyX, myY;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\treturn;\r\n\t\t\r\n\tmyInstance = (**theWindowObject).fInstance;\r\n\tif (myInstance == NULL)\r\n\t\treturn;\r\n\t\r\n\tmyX = theCenter->x;\r\n\tmyY = theCenter->y;\r\n\t\r\n\t// subject the values passed in to the current view constraints\r\n\tQTVRWrapAndConstrain(myInstance, kQTVRPan, myX, &myX);\r\n\tQTVRWrapAndConstrain(myInstance, kQTVRTilt, myY, &myY);\r\n\t\t\t\r\n\t// install the desired center in our application data structure\r\n\t(**myAppData).fMovieCenter.x = myX;\r\n\t(**myAppData).fMovieCenter.y = myY;\r\n\t\r\n\t// clear out the existing area of interest\r\n\tQTVRRefreshBackBuffer(myInstance, 0);\r\n\r\n\t// reinstall the back buffer imaging procedure\r\n\tVRMoov_InstallBackBufferImagingProc(myInstance, theWindowObject);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_GetEmbeddedMovieScale\r\n// Get the scale of the embedded movie.\r\n//\r\n//////////\r\n\r\nfloat VRMoov_GetEmbeddedMovieScale (WindowObject theWindowObject)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tfloat\t\t\t\t\tmyScale;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\tmyScale = 0;\r\n\telse\r\n\t\tmyScale = (**myAppData).fMovieScale;\r\n\t\t\r\n\treturn(myScale);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetEmbeddedMovieScale\r\n// Set the scale factor of the embedded movie.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_SetEmbeddedMovieScale (WindowObject theWindowObject, float theScale)\r\n{\r\n\tApplicationDataHdl\t\tmyAppData;\r\n\tQTVRInstance\t\t\tmyInstance;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\treturn;\r\n\t\t\r\n\tmyInstance = (**theWindowObject).fInstance;\r\n\tif (myInstance == NULL)\r\n\t\treturn;\r\n\t\r\n\t// install the desired scale factor in our application data structure\r\n\t(**myAppData).fMovieScale = theScale;\r\n\t\r\n\t// clear out the existing area of interest\r\n\tQTVRRefreshBackBuffer(myInstance, 0);\r\n\r\n\t// reinstall the back buffer imaging procedure\r\n\tVRMoov_InstallBackBufferImagingProc(myInstance, theWindowObject);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetChromaColor\r\n// Set the chroma key color for a window object:\r\n// display color picker dialog and remember the newly-selected color.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_SetChromaColor (WindowObject theWindowObject)\r\n{\r\n#if TARGET_OS_MAC\r\n\tColorPickerInfo\t\tmyColorInfo;\r\n#endif\t\r\n#if TARGET_OS_WIN32\r\n\tstatic CHOOSECOLOR\tmyColorRec;\r\n\tstatic COLORREF\t\tmyColorRef[16];\r\n#endif\t\r\n\tApplicationDataHdl\tmyAppData;\r\n\r\n\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindowObject(theWindowObject);\r\n\tif (myAppData == NULL)\r\n\t\treturn;\r\n\r\n#if TARGET_OS_MAC\r\n\t// pass in existing color\r\n\tmyColorInfo.theColor.color.rgb.red = (**myAppData).fChromaColor.red;\r\n\tmyColorInfo.theColor.color.rgb.green = (**myAppData).fChromaColor.green;\r\n\tmyColorInfo.theColor.color.rgb.blue = (**myAppData).fChromaColor.blue;\r\n\t\r\n\t// not much here...\r\n\tmyColorInfo.theColor.profile = 0L;\r\n\tmyColorInfo.dstProfile = 0L;\r\n\tmyColorInfo.flags = 0L;\r\n\tmyColorInfo.placeWhere = kCenterOnMainScreen;\r\n\tmyColorInfo.pickerType = 0L;\r\n\tmyColorInfo.eventProc = gColorFilterUPP;\r\n\tmyColorInfo.colorProc = NULL;\r\n\tmyColorInfo.colorProcData = 0L;\r\n\tGetIndString(myColorInfo.prompt, kColorPickerTextStringID, 1);\r\n\t\r\n\t// set Edit menu info\r\n\tmyColorInfo.mInfo.editMenuID = kEditMenuResID;\r\n\tmyColorInfo.mInfo.undoItem = MENU_ITEM(IDM_EDITUNDO);\r\n\tmyColorInfo.mInfo.cutItem = MENU_ITEM(IDM_EDITCUT);\r\n\tmyColorInfo.mInfo.copyItem = MENU_ITEM(IDM_EDITCOPY);\r\n\tmyColorInfo.mInfo.pasteItem = MENU_ITEM(IDM_EDITPASTE);\r\n\tmyColorInfo.mInfo.clearItem = MENU_ITEM(IDM_EDITCLEAR);\r\n\t\r\n\t// call Color Picker\r\n\tif ((PickColor(&myColorInfo) == noErr) && (myColorInfo.newColorChosen)) {\r\n\t\t// install the newly chosen color in the palette\r\n\t\t(**myAppData).fChromaColor.red = myColorInfo.theColor.color.rgb.red;\r\n\t\t(**myAppData).fChromaColor.green = myColorInfo.theColor.color.rgb.green;\r\n\t\t(**myAppData).fChromaColor.blue = myColorInfo.theColor.color.rgb.blue;\r\n\t}\r\n#endif\r\n#if TARGET_OS_WIN32\r\n\tmyColorRec.lStructSize = sizeof(CHOOSECOLOR);\r\n\tmyColorRec.hwndOwner = NULL;\r\n\tmyColorRec.hInstance = NULL;\r\n\t\r\n\tVRMoov_MacRGBToWinRGB(&(**myAppData).fChromaColor, &(myColorRec.rgbResult));\r\n\t\r\n\tmyColorRec.lpCustColors = myColorRef;\r\n\tmyColorRec.Flags = CC_RGBINIT | CC_FULLOPEN;\r\n\tmyColorRec.lCustData = 0;\r\n\tmyColorRec.lpfnHook = NULL;\r\n\tmyColorRec.lpTemplateName = NULL;\r\n\t\r\n\t// call Common Color dialog\r\n\tif (ChooseColor(&myColorRec)) {\r\n\t\t// install the newly chosen color in the palette\r\n\t\tVRMoov_WinRGBToMacRGB(&(**myAppData).fChromaColor, myColorRec.rgbResult);\r\n\t}\r\n#endif\r\n}\r\n\t\r\n\r\n//////////\r\n//\r\n// VRMoov_ColorDialogEventFilter\r\n// Handle events before they get passed to the Color Picker dialog box.\r\n//\r\n//////////\r\n\r\nPASCAL_RTN Boolean VRMoov_ColorDialogEventFilter (EventRecord *theEvent)\r\n{\r\n#if TARGET_OS_WIN32\r\n#pragma unused(theEvent)\r\n#endif\r\n\tBoolean\t\t\t\tmyEventHandled = false;\r\n\tOSErr\t\t\t\tmyErr = noErr;\r\n\r\n#if TARGET_OS_MAC\r\n\tswitch (theEvent->what) {\r\n\t\tcase updateEvt: {\r\n\t\t\tif ((WindowPtr)theEvent->message != FrontWindow()) {\r\n\t\t\t\tQTFrame_HandleEvent(theEvent);\r\n\t\t\t\tmyEventHandled = true;\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tcase nullEvent: {\r\n\t\t\t// do idle-time processing for all open windows in our window list\r\n\t\t\tWindowObject\t\tmyWindowObject = NULL;\r\n\t\t\tApplicationDataHdl\tmyAppData = NULL;\r\n\t\t\tWindowReference\t\tmyWindow = NULL;\r\n\r\n\t\t\tmyWindow = QTFrame_GetFrontMovieWindow();\r\n\t\t\twhile (myWindow != NULL) {\r\n\t\t\t\tmyWindowObject = (WindowObject)QTFrame_GetWindowObjectFromWindow(myWindow);\r\n\t\t\t\tmyAppData = (ApplicationDataHdl)QTFrame_GetAppDataFromWindow(myWindow);\r\n\t\t\t\tif ((myWindowObject != NULL) && (myAppData != NULL))\r\n\t\t\t\t\tif ((**myAppData).fMovie != NULL)\r\n\t\t\t\t\t\tQTVRUpdate((**myWindowObject).fInstance, kQTVRCurrentMode);\r\n\t\t\t\tmyWindow = QTFrame_GetNextMovieWindow(myWindow);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tmyEventHandled = false;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t\r\n\t\tcase kHighLevelEvent:\r\n\t\t\tmyErr = AEProcessAppleEvent(theEvent);\r\n\t\t\tif (myErr != noErr)\r\n\t\t\t\tmyEventHandled = true;\r\n\t\t \tbreak;\r\n\t\t\t\r\n\t\tdefault:\r\n\t\t\tmyEventHandled = false;\r\n\t\t\tbreak;\r\n\t}\t\r\n\t\r\n#endif\r\n\treturn(myEventHandled);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_UncoverProc\r\n// The uncover function of the embedded movie.\r\n//\r\n//////////\r\n\r\nPASCAL_RTN OSErr VRMoov_UncoverProc (Movie theMovie, RgnHandle theRegion, long theRefCon)\r\n{\r\n#pragma unused(theMovie, theRegion, theRefCon)\r\n\treturn(noErr);\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_SetVideoGraphicsMode\r\n// Set the video media graphics mode of the embedded movie.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_SetVideoGraphicsMode (Movie theMovie, ApplicationDataHdl theAppData, Boolean theSetVGM)\r\n{\r\n\tlong\t\t\t\tmyTrackCount;\r\n\tshort\t\t\t\tmyIndex;\r\n\tTrack\t\t\t\tmyTrack = NULL;\r\n\tMedia\t\t\t\tmyMedia = NULL;\r\n\tOSType\t\t\t\tmyMediaType;\r\n\t\r\n\tif ((theMovie == NULL) || (theAppData == NULL))\r\n\t\treturn;\r\n\t\r\n\tmyTrackCount = GetMovieTrackCount(theMovie);\r\n\tfor (myIndex = 1; myIndex <= myTrackCount; myIndex++) {\r\n\t\tmyTrack = GetMovieIndTrack(theMovie, myIndex);\r\n\t\tmyMedia = GetTrackMedia(myTrack);\r\n\t\tGetMediaHandlerDescription(myMedia, &myMediaType, NULL, NULL);\r\n\t\tif (myMediaType == VideoMediaType) {\r\n\t\t\tif (theSetVGM)\r\n\t\t\t\tMediaSetGraphicsMode(GetMediaHandler(myMedia), srcCopy | transparent, &(**theAppData).fChromaColor);\r\n\t\t\telse\r\n\t\t\t\tMediaSetGraphicsMode(GetMediaHandler(myMedia), srcCopy, &kWhiteColor);\r\n\t\t}\r\n\t}\r\n\t\r\n\treturn;\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_GetVideoGraphicsPixelDepth\r\n// Return the highest pixel depth supported by a QuickTime movie.\r\n//\r\n//////////\r\n\r\nshort VRMoov_GetVideoGraphicsPixelDepth (Movie theMovie)\r\n{\r\n\tlong\t\t\t\tmyTrackCount;\r\n\tshort\t\t\t\tmyIndex;\r\n\tTrack\t\t\t\tmyMovieTrack = NULL;\r\n\tMedia\t\t\t\tmyMedia;\r\n\tOSType\t\t\t\tmyMediaType;\r\n\tshort\t\t\t\tmyQuality;\r\n\t\r\n\tmyTrackCount = GetMovieTrackCount(theMovie);\r\n\tfor (myIndex = 1; myIndex <= myTrackCount; myIndex++) {\r\n\t\tmyMovieTrack = GetMovieIndTrack(theMovie, myIndex);\r\n\t\tmyMedia = GetTrackMedia(myMovieTrack);\r\n\t\tGetMediaHandlerDescription(myMedia, &myMediaType, NULL, NULL);\r\n\t\tif (myMediaType == VideoMediaType) {\r\n\t\t\tmyQuality = GetMediaQuality(myMedia);\r\n\t\t\tif (myQuality >> 5)\r\n\t\t\t\treturn(32);\r\n\t\t\tif (myQuality >> 4)\r\n\t\t\t\treturn(16);\r\n\t\t\tif (myQuality >> 3)\r\n\t\t\t\treturn(8);\r\n\t\t\tif (myQuality >> 2)\r\n\t\t\t\treturn(4);\r\n\t\t\tif (myQuality >> 1)\r\n\t\t\t\treturn(2);\r\n\t\t\tif (myQuality >> 0)\r\n\t\t\t\treturn(1);\r\n\t\t}\r\n\t}\r\n\t\r\n\treturn(0);\r\n}\r\n\r\n\r\n///////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n//\r\n// Color conversion utilities.\r\n//\r\n// Macintosh usually represents colors using an RGBColor structure, where each color component is a 16-bit\r\n// unsigned integer. Windows represents colors using a 32-bit unsigned COLORREF, where each color component\r\n// occupies 8 bits. The following two functions allow us to convert from Mac to Windows colors and back. We\r\n// need to do this because we use Mac-style colors when doing compositing.\r\n//\r\n///////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\r\n#if TARGET_OS_WIN32\r\n\r\n#define kMaxMacRGBValue\t\t\t\t0xffff\r\n#define kMaxWinRGBValue\t\t\t\t0x00ff\r\n#define MAC_TO_WIN_COMP(color)\t\t(color*((float)kMaxWinRGBValue/(float)kMaxMacRGBValue))\r\n#define WIN_TO_MAC_COMP(color)\t\t(color*((float)kMaxMacRGBValue/(float)kMaxWinRGBValue))\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_MacRGBToWinRGB\r\n// Convert an RGBColor structure into a COLORREF value.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_MacRGBToWinRGB (RGBColorPtr theRGBColor, COLORREF *theColorRef)\r\n{\r\n\t*theColorRef = RGB(\t(BYTE)MAC_TO_WIN_COMP(theRGBColor->red),\r\n\t\t\t\t\t\t(BYTE)MAC_TO_WIN_COMP(theRGBColor->green),\r\n\t\t\t\t\t\t(BYTE)MAC_TO_WIN_COMP(theRGBColor->blue));\r\n}\r\n\r\n\r\n//////////\r\n//\r\n// VRMoov_WinRGBToMacRGB\r\n// Convert a COLORREF value into an RGBColor structure.\r\n//\r\n//////////\r\n\r\nvoid VRMoov_WinRGBToMacRGB (RGBColorPtr theRGBColor, COLORREF theColorRef)\r\n{\r\n\ttheRGBColor->red = (unsigned long)WIN_TO_MAC_COMP(GetRValue(theColorRef));\r\n\ttheRGBColor->green = (unsigned long)WIN_TO_MAC_COMP(GetGValue(theColorRef));\r\n\ttheRGBColor->blue = (unsigned long)WIN_TO_MAC_COMP(GetBValue(theColorRef));\r\n}\r\n#endif\t// TARGET_OS_WIN32\r\n\r\n\r\nREADME - VRMovies\r\n\r\nVRMovies uses the QuickTime VR API to provide support for \r\nplaying QuickTime movies in a panorama. \r\n\r\nPowerPC, 680x0, and Windows versions are provided.\r\n\r\nEnjoy,\r\nQuickTime Team\r\n//////////\r\n//\r\n//\tFile:\t\tComApplication.h\r\n//\r\n//\tContains:\tFunctions that could be overridden in a specific application.\r\n//\r\n//\tWritten by:\t\r\n//\r\n//\tCopyright:\t© 1999 by Apple Computer, Inc., all rights reserved.\r\n//\r\n//\tChange History (most recent first):\r\n//\r\n// <2> 10/21/02\tera\t\tbuilding Mach-O\r\n//\t <1>\t \t11/05/99\trtm\t\tfirst file; based on earlier sample code\r\n//\t \r\n//////////\r\n\r\n#pragma once\r\n\r\n#ifndef __ComApplication__\r\n#define __ComApplication__\r\n\r\n\r\n//////////\r\n//\r\n// header files\r\n//\r\n//////////\r\n\r\n#ifdef __MACH__\r\n\t#include \r\n\t#include \r\n#else\r\n\t#ifndef __QUICKTIMEVR__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __TEXTUTILS__\r\n\t#include \r\n\t#endif\r\n\r\n\t#ifndef __SCRIPT__\r\n\t#include \r\n\t#endif\r\n\r\n\t#if TARGET_OS_MAC\r\n\t#ifndef __APPLEEVENTS__\r\n\t#include \r\n\t#endif\r\n\t#endif\r\n#endif\r\n\r\n#if TARGET_OS_MAC\r\n#include \"MacFramework.h\"\r\n#endif\r\n\r\n#if TARGET_OS_WIN32\r\n#include \"WinFramework.h\"\r\n#endif\r\n\r\n#ifndef __QTUtilities__\r\n#include \"QTUtilities.h\"\r\n#endif\r\n\r\n#include \"ComResource.h\"\r\n\r\n\r\n//////////\r\n//\r\n// constants\r\n//\r\n//////////\r\n\r\n\r\n//////////\r\n//\r\n// structures\r\n//\r\n//////////\r\n\r\n// application-specific data\r\ntypedef struct ApplicationDataRecord {\r\n\tMovie\t\t\t\t\t\tfMovie;\t\t\t\t// the embedded movie to play\r\n\tGWorldPtr\t\t\t\t\tfOffscreenGWorld;\t// the offscreen graphics world used for imaging embedded movies\r\n\tPixMapHandle\t\t\t\tfOffscreenPixMap;\t// the pixmap of the offscreen graphics world\r\n\tGWorldPtr\t\t\t\t\tfPrevBBufGWorld;\t// the previous offscreen graphics world used for the back buffer\r\n\tRect\t\t\t\t\t\tfPrevBBufRect;\t\t// the previous rectangle of the area of interest\r\n\tQTVRFloatPoint\t\t\t\tfMovieCenter;\t\t// the center in the panorama of the movie screen (in angles: x = pan; y = tilt)\r\n\tRect\t\t\t\t\t\tfMovieBox;\t\t\t// the movie box\r\n\tfloat\t\t\t\t\t\tfMovieScale;\t\t// a scale factor for the movie rectangle\r\n\tfloat\t\t\t\t\t\tfMovieWidth;\t\t// the width (in radians) of the embedded movie\r\n\tBoolean\t\t\t\t\t\tfUseOffscreenGWorld;// use an offscreen GWorld?\r\n\tBoolean\t\t\t\t\t\tfUseMovieCenter;\t// use the specified movie center?\r\n\tBoolean\t\t\t\t\t\tfQTMovieHasSound;\t// does the embedded movie have a sound track?\r\n\tBoolean\t\t\t\t\t\tfCompositeMovie;\t// does the embedded movie need to be composited?\r\n\tBoolean\t\t\t\t\t\tfUseHideRegion;\t\t// use the specified movie hide region?\r\n\tQTVRBackBufferImagingUPP\tfBackBufferProc;\t// a routine descriptor for our back buffer routine\r\n\tRGBColor\t\t\t\t\tfChromaColor;\t\t// the color for chroma key compositing\r\n\tRgnHandle\t\t\t\t\tfHideRegion;\t\t// the region that obscures the embedded movie\r\n\tMatrixRecord\t\t\t\tfMovieMatrix;\t\t// the matrix we use to (optionally) rotate the movie\r\n\tMatrixRecord\t\t\t\tfOrigMovieMatrix;\t// the movie's original matrix\r\n\tBoolean\t\t\t\t\t\tfBackBufferIsHoriz;\t// is the backbuffer oriented horizontally?\r\n\tImageDescriptionHandle\t\tfImageDesc;\t\t\t// image description for DecompressSequenceFrameS\r\n\tImageSequence\t\t\t\tfImageSequence;\t\t// image sequence for DecompressSequenceFrameS\t\r\n} ApplicationDataRecord, *ApplicationDataPtr, **ApplicationDataHdl;\r\n\r\n\r\n//////////\r\n//\r\n// function prototypes\r\n//\r\n//////////\r\n\r\n#if TARGET_OS_MAC\r\nvoid\t\t\t\t\tQTApp_InstallAppleEventHandlers (void);\r\nPASCAL_RTN OSErr\t\tQTApp_HandleOpenApplicationAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, long theRefcon);\t\t\t\r\nPASCAL_RTN OSErr\t\tQTApp_HandleOpenDocumentAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, long theRefcon);\r\nPASCAL_RTN OSErr\t\tQTApp_HandlePrintDocumentAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, long theRefcon);\r\nPASCAL_RTN OSErr\t\tQTApp_HandleQuitApplicationAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, long theRefcon);\r\n#endif\t// TARGET_OS_MAC\r\n\r\n// the other function prototypes are in the file MacFramework.h or WinFramework.h\r\n\r\n#endif // __ComApplication__"},"directory_id":{"kind":"string","value":"13a5cf8be702451a7bc5917dcbd1ee153a5e32fc"},"languages":{"kind":"list like","value":["Text","C"],"string":"[\n \"Text\",\n \"C\"\n]"},"num_files":{"kind":"number","value":4,"string":"4"},"repo_language":{"kind":"string","value":"Text"},"repo_name":{"kind":"string","value":"fruitsamples/vrmovies.win"},"revision_id":{"kind":"string","value":"948bed3b2786009e85671785166cef85ba3580ba"},"snapshot_id":{"kind":"string","value":"33195405d1818745ea1af3fa865db16332c18329"}}},{"rowIdx":9924,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"jaimeneto85/hicamera/README.md\n# HiCamera\n\nMódulo para gerenciamento de câmera para fotos, vídeos e enviar da galeria para o React Native.\n\nO objetivo do módulo é tornar mais prático o recurso visual de visualizar e selecionar imagens e/ou vídeo do aparelho.\n\n## Dependências\n- `react-native-camera`\n- `fotoapparat`\n\n## CameraVideo\n\nMódulo que retorna component com a Câmera ativa. Uso:\n\n```\nimport {CameraVideo} from 'hicamera'\n```\n\n##### Props\n* [containerStyle](#containerStyle)\n* [cameraStyle](#cameraStyle)\n* [cameraType](#cameraType)\n\n* [orientation](#orientation)\n* [maxDuration](#maxDuration)\n\n###### containerStyle\n`Object` estilo da View que leva a câmera\n\n###### cameraStyle\n`Object` estilo da Câmera em si\n\n###### cameraType\n`Integer` valor `0` (default) ou `1`, onde representa:\n- `0` camera traseira\n- `1` camera dianteira\n\n\n\n###### orientation\n`String` orientação da câmera. Valores: \"portrait\", \"portraitUpsideDown\", \"landscapeLeft\" or \"landscapeRight\"\n\n###### maxDuration\n`Integer` valor máximo (em segundos) da gravação do vídeo. Sem atribuir a propriedade, o vídeo só é encerrado quando o usuário escolher\n\n##### Methods\n* getVideo\n* onStartRecording\n* onStopRecording\n\n\n## CameraPhoto\n\n## Gallery\n\nMódulo que retorna as fotos do aparelho. Uso:\n\n```\nimport {Gallery} from 'hicamera'\n```\n\n##### Props\n* [itemStyle](#itemStyle)\n* [title](#title)\n* [titleStyle](#titleStyle)\n* [containerStyle](#containerStyle)\n* [galleryType](#galleryType)\n* [group](#group)\n* [filterBy](#filterBy)\n* [selectedStyle](#selectedStyle)\n* [selectedComponent](#selectedComponent)\n* [maxSelect](#maxSelect)\n* [overwriteSelected](#overwriteSelected)\n\n\n###### itemStyle\n`Object` estilo de cada item de mídia a ser apresentado na galeria\n\n###### title\n`String` título a ser exibido no topo da galeria (não enviar a propriedade faz com que o título não exista)\n\n###### titleStyle\n`Object` estilo do título do componente\n\n###### containerStyle\n`Object` estilo de todo componente\n\n###### galleryType\n`String` Utilize uma das opções: 'All', 'Photos', 'Videos'\n'Photos' é o valor default\n\n###### group\n- Album\n- All\n- Event\n- Faces\n- Library\n- PhotoStream\n- SavedPhotos // default\n\n###### filterBy\n`String` or `null` Utilize para filtrar o retorno das mídias de acordo com o álbum escolhido.\nExemplo:\n```javascript\n this.setState({filter: 'MyAlbum'})}>\n Ver MyAlbum\n\n\n```\n\n###### selectedStyle\n`Object` Estilo para os items selecionados\n\n###### selectedComponent\n`JSX` or `null`\nReact Component para elemento que aparecerá junto à mídia selecionada.\nRecomendo utilizar style com position *absolute*\n\n###### maxSelect\n`Number` Máximo de items que podem ser selecionados (default: 1) - precisa ser maior ou igual a 1\n\n###### overwriteSelected\n`Boolean` Quando o número máximo de items for maior que 1, você pode escolher o comportamento. \n- `true` quando o número de items ultrapassa o limite, ele começa a substituir os items selecionados, acrescentando o último\n- `false` (default) quando o número de items atinge o limite, os próximos toques se tornam sem ação (para selecionar novos) - para desselecionar o toque continua funcionando.\n\n##### Methods\n* getAlbums\n* selectedItems\n\n###### getAlbums\nMétodo que retorna os albums do dispositivo. Assim, é possível utilizar a propriedade filterBy\n\nExemplo:\n```javascript\n_getAlbums = (albums) => {\n this.setState({albums})\n}\n\n```\n\n###### selectedItems\nMétodo que retorna um array com os items selecionados.\nExemplo:\n```javascript\n_selectedItems = (items) => {\n this.setState({itemsSelected: items})\n}\n\n```\n\n\n"},"directory_id":{"kind":"string","value":"016989a8a861f33534b26f95afd3a4e8588fe4c0"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"jaimeneto85/hicamera"},"revision_id":{"kind":"string","value":"387a3590f747a8ca2243a2c58606495b33bfa44b"},"snapshot_id":{"kind":"string","value":"1b68d961d8d0f397c9b27f06a6409febe73cacc5"}}},{"rowIdx":9925,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"fabiaov/loja/loja/index.php\n\n\n\n\t\t

Bem vindo à loja do Fabio!!

\n\n\t\t\n\t\t\t

Você esta logado como .

\n\t\t\n\t\t\t

Login

\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Email:
Senha:\" name=\"senha\">
\n\t\t\t
\n\t\n\n/loja/banco-categoria.php\n/loja/cabecalho.php\n\n\n\n\n Minha loja\n \n \n \n\n\n\n\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\tMinha Loja \n\t\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t
\n\t\t
\n\t
\n\n\n
\n\n
\n \n \n "},"directory_id":{"kind":"string","value":"67de2f623e690875567c599a86b534f793ccd999"},"languages":{"kind":"list like","value":["PHP"],"string":"[\n \"PHP\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"PHP"},"repo_name":{"kind":"string","value":"fabiaov/loja"},"revision_id":{"kind":"string","value":"038667729e504ada440d6daf2176d0f2ed6cf3f9"},"snapshot_id":{"kind":"string","value":"19028be924f569156513804fe183f709ac1adc50"}}},{"rowIdx":9926,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"(function() {\n if (/*@cc_on!@*/0) { // execute only in Internet Explorer\n var elements = [\n \"abbr\", // for IE 6\n \"mark\",\n \"meter\",\n \"progress\",\n \"time\"//,\n ],\n i = elements.length;\n \n while (i--) {\n document.createElement(elements[i]);\n }\n }\n})();\n(function() {\n if (/*@cc_on!@*/0) { // execute only in Internet Explorer\n var elements = [\n \"article\",\n \"aside\",\n \"footer\",\n \"header\",\n \"hgroup\",\n \"nav\",\n \"section\"//,\n ],\n i = elements.length;\n \n while (i--) {\n document.createElement(elements[i]);\n }\n }\n})();\n"},"directory_id":{"kind":"string","value":"9124beb19f58e050202d664ed5a5b9b307006a17"},"languages":{"kind":"list like","value":["JavaScript"],"string":"[\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"cgriego/html5-scaffold"},"revision_id":{"kind":"string","value":"02061fea3559b1721abb460feb0b62c66a009ec3"},"snapshot_id":{"kind":"string","value":"eed524149e9c11e408bed68558d49f686f083d7f"}}},{"rowIdx":9927,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"gobinbash/next-apollo-auth/server/services/passport.js\nconst passport = require('passport')\nconst mongoose = require('mongoose')\n\nconst User = require('../models/User')\n\nconst GitHubStrategy = require('passport-github').Strategy\n\npassport.use(\n\tnew GitHubStrategy(\n\t\t{\n\t\t\tclientID: process.env.GithubClientID,\n\t\t\tclientSecret: process.env.GithubClientSecret,\n\t\t\tcallbackURL: process.env.GithubCallbackURL\n\t\t},\n\t\t(accessToken, refreshToken, profile, cb) => {\n\t\t\tconst { email, name } = profile._json\n\n\t\t\t// Auto-link account\n\n\t\t\tUser.findOne({ email })\n\t\t\t\t.then(user => {\n\t\t\t\t\tif (!user) {\n\t\t\t\t\t\tlet data = {\n\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\tfullname: name,\n\t\t\t\t\t\t\tproviders: ['github']\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tUser.create(data).then(user => cb(null, user))\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Update Provider to DB if not added\n\n\t\t\t\t\t\tUser.findOneAndUpdate(\n\t\t\t\t\t\t\t{ email, providers: { $ne: 'github' } },\n\t\t\t\t\t\t\t{ $push: { providers: 'github' } }\n\t\t\t\t\t\t).exec()\n\n\t\t\t\t\t\treturn cb(null, user)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(err => cb(err))\n\t\t}\n\t)\n)\n\npassport.use(User.createStrategy())\n\npassport.serializeUser(User.serializeUser())\npassport.deserializeUser(User.deserializeUser())\n"},"directory_id":{"kind":"string","value":"ebfcdd24110ba90648b4d41732812132fb1d4c0e"},"languages":{"kind":"list like","value":["JavaScript"],"string":"[\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"gobinbash/next-apollo-auth"},"revision_id":{"kind":"string","value":"30d3d5cc23f751ce789d35a2ec7d28f3aefe4def"},"snapshot_id":{"kind":"string","value":"e58f6741aa46b6516def42c066519dbf11817ed9"}}},{"rowIdx":9928,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"# RepoLearning4\ntomcatnew\n"},"directory_id":{"kind":"string","value":"e46ee3a47d7d08b72ec2f894473a3b39d15c197e"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"jason0429hebei/RepoLearning4"},"revision_id":{"kind":"string","value":"5ba29fa880be7be96ad88405d5b53bfffea7833d"},"snapshot_id":{"kind":"string","value":"557417295d3c1fbf183461480ee40e31da4911fb"}}},{"rowIdx":9929,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"#### Introdução\n\nA Flora Energia é uma empresa de tecnologia energética, sustentável e acessível a todos. A Flora gera energia em suas fazendas sustentáveis e injeta na rede elétrica, recebendo em troca créditos da distribuidora. O público alvo da Flora são os consumidores de baixa tensão com contas até R$ 50.000,00 reais, tipicamente o consumo residencial, que ao aderir à solução passa a ter descontos na conta de Energia Elétrica e a pagar uma parte de serviço à Flora de forma que a soma dos pagamentos sempre resulte menor que a fatura normal do consumidor. Para que o cliente (consumidor que se enquadra no público alvo) faça adesão à solução ou mesmo solicite informações sobre quais serão seus descontos, é necessário que a Flora conheça seu perfil de consumo entre outras informações constantes na fatura desse cliente.\n\n**A estória de usuário enxergada para esse projeto é:\nPreciso de uma aplicação para extrair dados de campos específicos da fatura e disponibilizar os dados em um banco que pode ser acessado via uma API(Application Programming Interface).**\nDessa forma, como trata-se de uma solução tipificada como varejo, a quantidade de clientes e potenciais clientes que terão suas faturas analisadas é absurdamente alta, fazendo-se necessário um processo automatizado que elimine desperdícios de tempo e dinheiro. Outro ponto importantíssimo é proporcionar uma boa experiência ao cliente por meio de um processo simples e rápido solicitação de informações e a adesão facilitada. Uma possível limitação na automação desse processo é a qualidade do artefato enviado pelo cliente, no caso, a fatura de Energia Elétrica.\n\n#### Linguagens, Frameworks e Infraestrutura\n\n* A linguagem escolhida foi o Python, por ser a linguagem mais consagrada no quesito extração e tratamento de dados.\n* Foi adotado o Framework Flask, uma vez que a forma mais evidente de entregar a solução proposta é via WEB.\n* A extração de dados via OCR(Optical Character Recognition) foi feita usando a API do google conhecida como Vision. A escolha foi feita por conta de sua precisão, uma vez erros de leitura em valores podem ter alto impacto no negócio. Precificação de uso da API Vision em https://cloud.google.com/vision/pricing#example .\n* O Banco de Dados escolhido foi o MongoDB, por proporcionar alta velocidade de leitura/gravação e facilitar a expansão da solução depois que ela já estiver em produção. Em um momento futuro, pode-se considerar a indexação do MongoDB com Elasticsearch, para buscas mais rápidas e inteligentes.\n* Apesar de ser um MVP(Minimum Viable Product), no quesito infraestrutura, esse projeto é pensado para em um momento posterior, ser implantado em soluções nativas de nuvem, baseada em microsserviços, usando soluções escaláveis e de alta performance, como é o caso de containers em kubernetes preferencialmente em nuvem pública.\n\n#### Especificações\n\nA solução foi solicitada no modelo de API, dessa forma os serviços podem ser consumidos por aplicações WEB, aplicativos Mobile (smartphones etc) e inclusive sistemas integrados corporativos(ERPs). O microsserviço tratado por esse MVP é responsável por receber de forma eletrônica a fatura do cliente, extrair os dados necessários usando tecnologia OCR e gravar esses dados em um banco de dados NoSQL, no caso o MongoDB.\n##### Demonstração\nPara facilitar a demonstração, foi disponibilizada uma interface web para upload da fatura e verificação dos dados extraídos. Como o objetivo é apenas teste, não foram aplicados efeitos visuais nem folhas de estilo. Não foi implantado o mecanismo de autenticação.\n\n#### Código Fonte\n\n##### Estrutura de pastas e arquivos\n\nO projeto foi escrito tendo como objetivo a simplicidade, com uma visão minimalista. A estrutura de arquivos e pastas foi definida para a pasta **templates** abrigar a página de teste de envio de arquivos (apesar de isso poder ser feito pelo Postman por exemplo). A Pasta conta-images, guarda localmente uma cópia do arquivo enviado. O arquivo **db.py**, contém as informações para conexão com o banco de dados MongoDB, que está online no AtlasDB usando o free Tier. O arquivo googlekey.json contém as credenciais da service account utilizada para autorizar o uso da API Vision do google, nesse caso, foi criada a conta de e-mail e configurado o período de avaliação gratuito de 90 dias do GCP(Google Cloud Platform). O requirements.txt contém os requisitos para o projeto funcionar. Por último, mas não menos importante, o **server.py**, que é o arquivo principal onde estão as rotas e a lógica da API (não foi aplicado o padrão MVC).\n\nfrom flask import Flask, render_template, request\nfrom werkzeug.utils import secure_filename\nfrom google.cloud import vision\nfrom google.oauth2 import service_account\nfrom numpy import asarray\nfrom pdf2image import convert_from_path\nimport io\nimport re\nimport pandas as pd\nimport json\nimport os\nimport db as d\n\napp = Flask(__name__)\n\nAPP_ROOT = os.path.dirname(os.path.abspath(__file__))\n\n# Rota que apresenta os botões de envio da conta\n@app.route('/flora/conta/', methods=['GET'])\ndef conta_upload_file():\n return render_template('upload.html')\n\n# Rota para envio da conta\n@app.route('/flora/conta/upload', methods=['POST'])\ndef conta_upload():\n\n # Credenciais service account google para uso da API\n os.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = \\\n r'/home/user/Documentos/path_to_your_key/googleKey.json'\n \n client = vision.ImageAnnotatorClient()\n \n # Caminho para a pasta local\n target = os.path.join(APP_ROOT, 'conta-images/')\n \n # Cria a pasta se ela não existir\n if not os.path.isdir(target):\n os.mkdir(target)\n \n # Nome da collection no banco\n conta_db_table = d.mongo.db.contas\n if request.method == 'POST':\n \n # Envio de multiplas contas\n for upload in request.files.getlist(\"conta_image\"):\n filename = secure_filename(upload.filename)\n destination = \"/\".join([target, filename])\n upload.save(destination)\n \n # converte o pdf para uma imagem, geralmente a conta só tem uma página \n pages = convert_from_path(destination, 500)\n for page in pages:\n page.save('fatura.png', 'PNG')\n\n \n # identificando a imagem da fatura usando a biblioteca io e colocando em content\n with io.open('fatura.png', 'rb') as image_file:\n content = image_file.read()\n\n # prepara a imagem para a api\n image = vision.types.Image(content=content)\n\n\n # faz OCR\n response = client.text_detection(image=image)\n\n # pega o texto da ocr\n texts = response.text_annotations\n\n\n # identifica as posições das bouding box com as informações desejadas em texts\n a_dict = ['124','137','138','202','234','349','350','365','366','375','376', \\\n '384','385','387','388','390','391','393','394','396','397','400','401', \\\n '403','404','406','407','426','416','427','428','440','447','452']\n \n # coloca a legenda de cada posição\n b_dict = ['conta_mes','vencimento','total','tusd','te','mes0','consumomes0', \\\n 'mes2','consumomes2','mes3','consumomes3','mes4','consumomes4','mes5', \\\n 'consumomes5','mes6','consumomes6','mes7','consumomes7','mes8','consumomes8', \\\n 'mes9','consumomes9','mes10','consumomes10','mes11','consumomes11','mes12', \\\n 'consumomes12','mes13','consumomes13','saldo','saldo_pm','part']\n \n\n lst={}\n \n \n # fazer um loop em text para pegar cada parte de texto que a ocr indentificou\n for i, text in enumerate(texts):\n \n\n # faz um loop em a_dict para pegar as posições pré definimos\n for j, key in enumerate(a_dict):\n\n # transforma o que está em a_dict em numero\n key=int(key)\n \n # pega a posição definida manualmente dentro do ocr total, eliminando o que não é desejado \n if key == i:\n \n # retorna a informação associada a posição definida manualmente\n texto=text.description\n\n # coloca um label na posição\n descricao=b_dict[j]\n \n # insere tudo em um dicionário\n lst.update({descricao: texto})\n\n # coloca a informação no mongodb \n conta_db_table.insert({'conta_image': lst})\n\n\n return {'Geral': {'conta_mes': lst['conta_mes'], 'VENCIMENTO': lst['vencimento'], \\\n 'TOTAL_A_PAGAR': lst['total']}, 'Operacao': {'ENERGIA_ATIVA_FORNECIDA': lst['tusd'], \\\n 'ENERGIA_ATIVA_INJETADA': lst['te']}, 'Informacoes': {'Saldo': lst['saldo'], \\\n 'Saldo_a_expirar': lst['saldo_pm'], 'Participacao': lst['part']}, \\\n 'Historico': {lst['mes2']: lst['consumomes2'], lst['mes3']: lst['consumomes3'], \\\n lst['mes4']: lst['consumomes4'], lst['mes5']: lst['consumomes5'], \\\n lst['mes6']: lst['consumomes6'], lst['mes7']: lst['consumomes7'], \\\n lst['mes8']: lst['consumomes8'], lst['mes9']: lst['consumomes9'], \\\n lst['mes10']: lst['consumomes10'], lst['mes11']: lst['consumomes11'], \\\n lst['mes12']: lst['consumomes12'], lst['mes13']: lst['consumomes13']}}\n\nif __name__ == '__main__':\n app.run()from flask_pymongo import PyMongo\nimport server as s\n\ns.app.config['MONGO_DBNAME'] = 'samuka'\n\ns.app.config['MONGO_URI'] = 'mongodb+srv://user:password@cluster0.daw3o.mongodb.net/flora?retryWrites=true&w=majority'\n\nmongo = PyMongo(s.app)\n"},"directory_id":{"kind":"string","value":"2cdc1abeeb536bef3726f5838d05c01bd6e8fad5"},"languages":{"kind":"list like","value":["Markdown","Python"],"string":"[\n \"Markdown\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"batistasamuel/flask_ocr_api_google_vision"},"revision_id":{"kind":"string","value":"a62e9665b5b4923e902f2f1d8e17a04c09836619"},"snapshot_id":{"kind":"string","value":"369ead843696112194fd6406db61bda5b3098e15"}}},{"rowIdx":9930,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"Luc-Darme/source_symfony/userBundle/Entity/ProjectApplication.php\nid;\n }\n \n /**\n * Set young\n *\n * @param string $message\n * @return ProjectApplication\n */\n public function setMessage($message)\n {\n $this->message = $message;\n\n return $this;\n }\n\n /**\n * Get message\n *\n * @return string \n */\n public function getMessage()\n {\n return $this->message;\n }\n\n /**\n * Set young\n *\n * @param \\stdClass $young\n * @return ProjectApplication\n */\n public function setYoung($young)\n {\n $this->young = $young;\n\n return $this;\n }\n\n /**\n * Get young\n *\n * @return \\stdClass \n */\n public function getYoung()\n {\n return $this->young;\n }\n\n /**\n * Set project\n *\n * @param \\stdClass $project\n * @return ProjectApplication\n */\n public function setProject($project)\n {\n $this->project = $project;\n $project->addProjectApplication($this);\n\n return $this;\n }\n\n /**\n * Get project\n *\n * @return \\stdClass \n */\n public function getProject()\n {\n return $this->project;\n }\n\n /**\n * set status\n *\n * @param string\n */\n \n public function setStatus($status)\n {\n $this->status = $status;\n }\n \n public function __toString()\n {\n return $this->id.\"\";//$this->young->__toString().\" - \".$this->project->__toString();\n }\n\n\n /**\n * Get status\n *\n * @return string \n */\n public function getStatus()\n {\n return $this->status;\n }\n\n /**\n * set statusDate\n *\n * @param date\n */\n \n public function setStatusDate($statusDate)\n {\n $this->statusDate = $statusDate;\n }\n \n\n /**\n * Get statusDate\n *\n * @return array \n */\n public function getStatusDate()\n {\n return $this->statusDate;\n }\n}\n/userBundle/Entity/Young.php\ninstitutions = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->appliedProjects = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n \n public function __toString()\n {\n return $this->getUser()->__toString();\n }\n \n public function getPAByStatus($stat)\n {\n return $this->appliedProjects->filter(function($p) use ($stat){return $p->getStatus()==$stat;});\n }\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n \n /**\n * Set user\n *\n * @param string $user\n * @return InstitutionMember\n */\n public function setUser($user)\n {\n $this->user = $user;\n $user->setYoung($this);\n\n return $this;\n }\n\n /**\n * Get username\n *\n * @return string \n */\n public function getUser()\n {\n return $this->user;\n }\n\n /**\n * Add institutions\n *\n * @param eclore\\userBundle\\Entity\\Institution $institution\n */\n \n public function addInstitution(\\eclore\\userBundle\\Entity\\Institution $institution)\n {\n $this->institutions[] = $institution;\n $institution->addYoung($this);\n }\n \n /**\n * Remove institutions\n *\n * @param eclore\\userBundle\\Entity\\Institution $institution\n */\n public function removeInstitution(\\eclore\\userBundle\\Entity\\Institution $institution) \n {\n $this->institutions->removeElement($institution);\n }\n\n /**\n * Get institutions\n *\n * @return array \n */\n public function getInstitutions()\n {\n return $this->institutions;\n }\n\n /**\n * Add applied projects\n *\n * @param eclore\\userBundle\\Entity\\ProjectApplication $projectApplication\n */\n \n public function addAppliedProject(\\eclore\\userBundle\\Entity\\ProjectApplication $projectApplication) \n {\n $this->appliedProjects[] = $projectApplication;\n }\n \n /**\n * Remove applied projects\n *\n * @param eclore\\userBundle\\Entity\\ProjectApplication $projectApplication\n */\n public function removeAppliedProject(\\eclore\\userBundle\\Entity\\ProjectApplication $projectApplication) \n {\n $this->appliedProjects->removeElement($projectApplication);\n }\n\n /**\n * Get appliedProjects\n *\n * @return array \n */\n public function getAppliedProjects()\n {\n return $this->appliedProjects;\n }\n\n \n public function hasApplied($project)\n {\n foreach($project->getProjectApplications() as $PA){\n if($PA->getYoung()->getId() == $this->getId()) return True;\n }\n return false;\n }\n \n public function getCurrentProjects()\n {\n $res=array();\n foreach($this->getAppliedProjects() as $PA)\n if($PA->getProject()->isStarted())\n $res[]=$PA->getProject();\n return $res;\n }\n \n}\n/userBundle/Resources/views/page_lambda.html.twig\n{%if form is defined %}\n{% form_theme form 'ecloreuserBundle:Form:fields.html.twig' %}\n{%endif%}\n\n\n \n \n{%block title%}{% endblock %}\n \n \n\t \n \n\t\n\t\n \n \n \n \n \n \n\t\n\t\n\t
\n
\n\t\t\n\n\n\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t
\n\t\t\t\t{% include 'ecloreuserBundle::menu.html.twig' %}\t\n\t\t\t
\n\t\t
\n\n\t\t\t\n\t\n\n\t
\n \n\t
\n\n \n
\n
\n \n
\n \n {{first}}\n {%if second is defined %}\n \n {{second}}\n {%endif%}\n\t\t\t\t\n
\n
\n
\n \t
\n\t\t\t\n {% for key, messages in app.session.flashbag.all() %}\n {% for message in messages %}\n
{{ message|trans({}, 'FOSUserBundle') }}
\n {% endfor %}\n {% endfor %} \n
\n\n {%block content %}\n {%endblock%}\n\t\t\n
\n
\n \n\t\n\t\n\t\n\t \n \n\n\t\n\t
\n \n\n/userBundle/Timeline/TimelineSpread.php\ncontainer = $container;\n }\n \n public function supports(ActionInterface $action)\n {\n // here you define what actions you want to support, you have to return a boolean.\n return true;\n }\n\n public function process(ActionInterface $action, EntryCollection $coll)\n { //common part to all spreads\n $subjectId = $action->getSubject()->getIdentifier();\n $complementId = $action->getComponent('complement')->getIdentifier();\n $em = $this->container->get('doctrine')->getManager();\n //reps\n $userRep = $em->getRepository('ecloreuserBundle:User');\n $projectRep = $em->getRepository('ecloreuserBundle:Project');\n $assoRep = $em->getRepository('ecloreuserBundle:Association');\n $instMRep = $em->getRepository('ecloreuserBundle:InstitutionMember');\n $this->informedUsers=array();\n \n if($action->getVerb() == 'mark_young'){\n //markedYoung\n $user = $userRep->find($complementId);\n if(isset($user) && $user->getPrivacyLevel() != 2){\n $this->informsYoungInstM($user);\n }\n }elseif(($action->getVerb() == 'take_part' || $action->getVerb() == 'apply')){\n //validatedPA or newPA\n $user = $userRep->find($subjectId);\n $project = $projectRep->find($complementId);\n if(isset($user) && isset($project) && $user->getPrivacyLevel() != 2){\n // informs project\n $coll->add(new Entry($action->getComponent('complement')));\n $this->informsUserContacts($user);\n $this->informsYoungInstM($user);\n // informs projects responsibles\n foreach($project->getResponsibles() as $assoM)\n $this->informedUsers[]=$assoM->getUser()->getId();\n }\n }elseif($action->getVerb() == 'contact'){\n //contactAck\n $ackUser = $userRep->find($subjectId);\n $requestingUser = $userRep->find($complementId);\n if(isset($ackUser) && isset($requestingUser)){\n // informs requestingUser\n if($requestingUser->getPrivacyLevel() != 2){\n $this->informedUsers[]=$requestingUser->getId();\n $this->informsUserContacts($requestingUser);\n }\n if($ackUser->getPrivacyLevel() != 2){\n $this->informsUserContacts($ackUser);\n }\n $this->informsUserContacts($ackUser);\n \n }\n }elseif($action->getVerb() == 'mark_project'){\n //markedProject\n $user = $userRep->find($subjectId);\n $project = $projectRep->find($complementId);\n if(isset($project) && isset($user) && $user->getPrivacyLevel() != 2){\n // informs project\n $coll->add(new Entry($action->getComponent('complement')));\n $this->informsYoungInstM($user);\n // informs project responsibles\n foreach($project->getResponsibles() as $resp)\n $this->informedUsers[]=$resp->getUser()->getId();\n }\n }elseif($action->getVerb() == 'be_rejected'){\n //rejectedPA\n $user = $userRep->find($subjectId);\n $project = $projectRep->find($complementId);\n if(isset($user) && isset($project) && $user->getPrivacyLevel() != 2){\n $this->informsYoungInstM($user);\n // informs projects responsibles\n foreach($project->getResponsibles() as $assoM)\n $this->informedUsers[]=$assoM->getUser()->getId();\n }\n }elseif($action->getVerb() == 'create_project'){\n //newProject\n $asso = $assoRep->find($subjectId);\n $project = $projectRep->find($complementId);\n if(isset($project) && isset($asso)){\n // informs project\n $coll->add(new Entry($action->getComponent('complement')));\n // informs all instM\n foreach($instMRep->findAll() as $instM)\n $this->informedUsers[]=$instM->getUser()->getId();\n // informs all assoM of asso\n foreach($asso->getMembers() as $assoM)\n $this->informedUsers[]=$assoM->getUser()->getId();\n // informs youngs who took part in one of asso projects\n foreach($asso->getProjects() as $proj)\n foreach($proj->getProjectApplications() as $PA)\n $this->informedUsers[]=$PA->getYoung()->getUser()->getId();\n }\n }elseif($action->getVerb() == 'registered'){\n //newUser\n $user = $userRep->find($subjectId);\n if(isset($user) && $user->getPrivacyLevel() != 2){\n if($user->hasRole('ROLE_YOUNG')){\n $this->informsYoungInstM($user);\n // informs youngs from inst\n foreach($user->getYoung()->getInstitutions() as $inst)\n foreach($inst->getYoungs() as $yg)\n $this->informedUsers[]=$yg->getUser()->getId();\n }elseif($user->hasRole('ROLE_ASSOM')){\n //informs other assom\n foreach($user->getAssoM()->getAssociations() as $asso)\n foreach($asso->getMembers() as $assoM)\n $this->informedUsers[]=$assoM->getUser()->getId();\n }elseif($user->hasRole('ROLE_INSTM')){\n // informs other instm\n foreach($user->getInstM()->getInstitutions() as $inst)\n foreach($inst->getMembers() as $instM)\n $this->informedUsers[]=$instM->getUser()->getId();\n // informs young of inst\n foreach($user->getInstM()->getInstitutions() as $inst)\n foreach($inst->getYoungs() as $yg)\n $this->informedUsers[]=$yg->getUser()->getId();\n }\n }\n }\n \n //informs every required users\n foreach(array_unique($this->informedUsers) as $id)\n $coll->add(new EntryUnAware(self::USER_CLASS, $id)); \n }\n \n public function informsYoungInstM($user){\n foreach($user->getYoung()->getInstitutions() as $inst)\n foreach($inst->getMembers() as $instM)\n $this->informedUsers[]=$instM->getUser()->getId();\n $this->informedUsers[]=$user->getId();\n }\n \n public function informsUserContacts($user){\n foreach($user->getContacts() as $people)\n $this->informedUsers[]=$people->getId();\n $this->informedUsers[]=$user->getId();\n }\n \n}/userBundle/Resources/views/AssoM/edit-asso.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Mettre à jour le profil de l'association{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n{{ form(form) }}\n
\n
\n{% endblock %}\n/userBundle/Resources/views/AssoM/manage-application.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n\nBienvenue {{app.user.username}} !
\nVous êtes dans l'espace d'administration de la candidature de {{pa.young}} au projet {{pa.project}}.\n
\nEtat de la candidature: {{pa.status|PAStatus}}\n
Derniere communication: {{pa.message}}\n
\nDate de dernière modification: {{pa.statusDate|date(\"d/m/Y\")}}\n
\n{% if pa.status == 'PENDING' or (pa.status=='VALIDATED' and pa.project.isFinished) %} \n{{ form(form) }}\n{%endif%}\n
\n
\n{% endblock %}\n/userBundle/Resources/views/Static/sitemap.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n

Un peu perdu ?

\nLe site du réseau Eclore est divisé en deux parties:\n
    \n
  1. Une partie publique, où vous avez accès aux actualités du réseau.\nVous y trouverez principalement: \nla page générale d'accueil et de présentation, \nla page pour rechercher un projet parmi ceux déjà déposés, \nla page de connexion/inscription à votre espace membre\n
  2. \n
  3. Une partie privée (votre espace membre), où vous avez accès en plus aux fonctionnalités du réseau, comme: \nvotre annuaire, \nla page pour proposer un projet si vous faites partie d'une association, \nla gestion de votre profil, \nla gestion générale de votre activité (projets/candidatures)\n
  4. \n
\n\nNote: le site ayant été lancé il y a peu de temps, nous vous serions \nreconnaissants de signaler toute erreur rencontrée en nous ?subject=Erreur\">envoyant un mail. Merci !\n{% endblock %}\n/userBundle/Form/Type/ProfileFormType.php\ncontainer = $container;\n }\n \n public function buildForm(FormBuilderInterface $builder, array $options)\n {\n \n $builder->add('birthDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\")-100, (int)date(\"Y\")), 'label'=>\"Date de naissance\"))\n ->add('lastName', 'text', array( 'label'=>\" Nom de famille :\"))\n ->add('firstName', 'text', array( 'label'=>\" Prénom :\"))\n ->add('mobile','text', array( 'label'=>\"Numéro de téléphone :\"))\n ->add('quality','text', array( 'label'=>\"Votre situation actuelle (par exemple: 2ème année de BTS, président d'association, etc...)\"))\n ->add('privacyLevel', 'choice', array('choices'=>$this->container->getParameter('privacyLevels'), 'label'=>\"Confidentialité de vos données personnelles\"))\n ->add('headshot', new ImageType(), array( 'label'=>\"Photo de profil\"))\n ;\n }\n\n public function getName()\n {\n return 'eclore_user_profile';\n }\n}\n\n?>/userBundle/Resources/views/Static/mentions.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\nMentions légales\n{% endblock %}/userBundle/Resources/views/Profile/show_content.html.twig\n{% trans_default_domain 'FOSUserBundle' %}\n\n

Mes informations profil

\n
\n\n
\n Image de profil: \n \n
\n
\n

{{ 'profile.show.username'|trans }}: {{ user.username }}

\n

{{ 'profile.show.email'|trans }}: {{ user.email }}

\n

Téléphone: {{ user.mobile }}

\n

Date de naissance: {{ user.birthDate|date('d/m/Y') }}

\n

Prénom: {{ user.firstName }}

\n

Nom: {{ user.lastName }}

\n

Niveau de confidentialité: {{ user.privacyLevel|privacyLevels }}

\n {%if app.user.hasRole('ROLE_ASSOM') or app.user.hasRole('ROLE_INSTM') or app.user.hasRole('ROLE_YOUNG')%}\n

Situation : {{ user.quality }}

\n {%endif%}\n
\n
\n Modifier mes informations\n
\n Modifier mon mot de passe\n
/userBundle/Resources/views/AssoM/Temp web/manage-project.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n{% set rejected = proj.PAByStatus('REJECTED') %}\n{% set validated = proj.PAByStatus('VALIDATED') %}\n{% set pending = proj.PAByStatus('PENDING') %}\n\nBienvenue {{app.user.username}} !
\nVous êtes dans l'espace d'administration du projet {{proj.projectName}}.\n
\n\nNom du projet: {{proj}}
\nDescription: {{proj.description}}
\nDate de début: {{proj.startdate|date(\"m-d-Y\")}}
\nDate de fin: {{proj.enddate|date(\"m-d-Y\")}}
\nLocalisation: {{proj.address}}
\nResponsables du projet: {{proj.responsibles|join(', ') }}
\nStatut du projet:\n{%if not proj.enabled%}\n Ce projet est en attente de validation de la part des administrateurs. Vous serez averti de sa validation.\n{%else%}\n\n {%if proj.isFinished %}\n Terminé.\n {%elseif not proj.isFinished and proj.isStarted %}\n En cours.\n {%else%}\n Publié.\n {%endif%}\n
\n Modifier ce projet \n
\n Statut sur les participants: \n {%if not proj.isFinished%}\n {%if proj.isFull %}Ce projet possède le nombre de participants requis.\n {%else%}{{proj.required - proj.getPAByStatus('VALIDATED')|length}} participants encore souhaités.\n {%endif%}\n {%else%} \n Merci de clôturer les candidatures des jeunes ayant participé.
\n {%endif%}\n\n
\n\n {%if not proj.isFinished%}\n {% if validated|length >0 %}\n Candidatures à clôturer:\n
    \n {% for pa in validated %}\n
  • {{pa.young}} \n Clôturer
  • \n {% endfor %}\n
\n {% else %}\n Pas de candidatures à clôturer\n {% endif %}\n {%else%}\n {% if pending|length >0 %}\n
\n Candidatures à traiter:\n
    \n {% for pa in pending %}\n
  • {{pa.young}} Manager
  • \n {% endfor %}\n
\n {% else %}\n Pas de candidatures à traiter.\n {% endif %}\n
\n {% if validated|length >0 %}\n Candidatures validées:\n
    \n {% for pa in validated %}\n
  • {{pa.young}} \n Manager
  • \n {% endfor %}\n
\n {% else %}\n Pas de candidatures validées.\n {% endif %}\n
\n {% if rejected|length >0 %}\n Candidatures rejetées:\n
    \n {% for pa in rejected %}\n
  • {{pa.young}} Manager
  • \n {% endfor %}\n
\n {% else %}\n Pas de candidatures rejetées.\n {% endif %}\n
\n Si vous souhaitez modifier ce projet, le supprimer, ou ajouter des responsables, merci de contacter le réseau à \n {%endif%}\n\n{%endif%}\n
\n
\n{% endblock %}\n/userBundle/Entity/ProjectRepository.php\n_em->createQueryBuilder();\n $projects = $qb->select('n')\n ->from($this->_entityName, 'n')\n ->where('n.enabled = :enabled')\n ->setParameter('enabled', true)\n ->getQuery()->getResult();\n foreach($projects as $proj)\n if($proj->getPAByStatus('VALIDATED')->count() >= $proj->getRequired())\n $projects->remove($proj);\n return $projects;\n }\n}\n/userBundle/Resources/views/InstM/display-young.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n

Fiche de suivi de {{young}}.

\n\n\n\n

{{young}} est inscrit aux projets suivants :

\n\n\n\n\n

Historique de ses projets :

\n\n\n
\n
\n{% endblock %}\n/userBundle/Resources/public/css/lambda/menu.css\n\n.menu\n{\n width:100%; \n height:3.7em;\n margin:0em 0 0 0px ; \n left: -2px; \ncolor:#fff;\nz-index:300;\n}\n\n.menu.bleu {\n background: url(\"../../images/menu_fond_bleu.png\") no-repeat 0 0 ;\n background-size: 100% 3.7em;\n}\n.menu.vert {\n background: url(\"../../images/menu_fond_vert.png\") no-repeat 0 0 ;\n background-size: 100% 3.7em;\n}\n.menu.orange {\n background: url(\"../../images/menu_fond_orange.png\") no-repeat 0 0 ;\n background-size: 100% 3.7em;\n}\n\n.menu ul\n{\n margin:0;\n padding:0.5em 2em 0 0;\n\t\t\n}\n \n.menu a\n{\n\tcolor:#fff;\n\ttext-decoration: none;\n}\n \n.menu h3\n {\n \tmargin-top:-0em;\n }\n \n.menu li\n{\n\tpadding: 0 0.1em 0 0.1em;\n height:2.3em;\n float:left;\n text-align:center;\n overflow:hidden;\n\tbackground: url('../../images/fond_sousmenu.png') no-repeat; \n\tposition:relative;\n\t border-left:1px solid #fff;\n\tz-index:21; \n}\n\n.menu.bleu li\n{\n\tbackground: url('../../images/fond_sousmenu_bleu.png') no-repeat;\n}\n.menu.vert li\n{\n\tbackground: url('../../images/fond_sousmenu_vert.png') no-repeat;\n}\n.menu.orange li\n{\n\tbackground: url('../../images/fond_sousmenu_orange.png') no-repeat;\n}\n\n.menu li a {\n /* z-index must be higher than .hover class */\n z-index:20; \n padding-top:0.3em;\n /* display as block and set the height according to the height of the menu to make the whole LI clickable */\n display:block; \n height:2.2em;\n\t\twidth:100%;\n position:relative;\n \n}\n\n\n.menu li a .hover\n{\n/* mouseover image */\n background:url(../../images/fondhover_sousmenu.png) no-repeat center center; \n\tbackground-size: 100% 100%;\n/* must be postion absolute */ \n position:absolute; \n opacity:0.8;\n/* width, height, left and top to fill the whole LI item */\n width:100%; \n height:2.6em;\n left:0em;\n top:-0.4em; \n \n/* display under the Anchor tag */\n z-index:0; \n \n/*hide it by default */\n display:none; \n}\n\n.menu.bleu li a .hover\n{\n background:url(../../images/fondhover_sousmenu_bleu.png) no-repeat center center; \n\tbackground-size: 100% 100%; \n}\n.menu.vert li a .hover\n{\n background:url(../../images/fondhover_sousmenu_vert.png) no-repeat center center; \n\tbackground-size: 100% 100%; \n}\n.menu.orange li a .hover\n{\n background:url(../../images/fondhover_sousmenu_orange.png) no-repeat center center; \n\tbackground-size: 100% 100%; \n}\n\n.sousmenu span{\nposition : absolute ; \nleft:0;\nwidth:100%;\nz-index : 30;\n\n}\n\n\n \n @media screen and (min-width: 1400px) {\n\t.menu li{\n width:200px;\n\t}\n}\n@media screen and (max-width: 1400px) {\n\t.menu li{\n width:150px;\n\tfont-size:0.8em;\n\t}\n}\n/userBundle/Resources/views/index_simple.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Réseau Eclore !{% endblock %}\n\n{%set color='vert'%}\n{%set first='Bienvenue !'%}\n\n{% block content %}\n
\n\t\t\n \n {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}\n\t\t\n {%else%}\n\t\t\n \n {%endif%}\n\t\n\n\t\n\t\n
\n\n\n\n\n
\n\n

Bienvenue sur le réseau Éclore !

\n Ce site est appelé à grandir dans les semaines qui viennent mais vous pouvez d'ores et déjà vous inscrire et déposer des projets. \n\n \n \n \n\n\n
\n\n\t
\n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t
\n\n{% endblock %}/userBundle/Extensions/Twig/templateFunctionsHelper.php\ncontainer = $container;\n $this->context = $context;\n }\n \n\n public function getFilters() \n {\n return array(\n 'printName' => new \\Twig_Filter_Method($this, 'printName', array('is_safe' => array('html'))),\n 'printAsso' => new \\Twig_Filter_Method($this, 'printAsso', array('is_safe' => array('html'))),\n 'printInst' => new \\Twig_Filter_Method($this, 'printInst', array('is_safe' => array('html'))),\n 'PAStatus' => new \\Twig_Filter_Method($this, 'PAStatus', array('is_safe' => array('html'))),\n 'privacyLevels' => new \\Twig_Filter_Method($this, 'privacyLevels', array('is_safe' => array('html'))),\n 'printDate' => new \\Twig_Filter_Method($this, 'printDate', array('is_safe' => array('html')))\n );\n }\n\n\n public function printName($user2)\n { $first = \"generate('displayMember', array('id'=>$user2->getId())).\"'>\";\n \n if(!$this->context->isGranted('IS_AUTHENTICATED_REMEMBERED'))\n return $first.$user2->getUsername().\"\";\n \n $user=$this->context->getToken()->getUser();\n \n if($user->getContacts()->contains($user2))\n return $first.$user2->__toString().\"\";\n \n if($user->getId() == $user2->getId())\n return $first.\"vous\";\n \n return $first.$user2->getUsername().\"\";\n }\n \n public function printInst($inst)\n {\n return \"generate('displayInst', array('id'=>$inst->getId())).\"'>\".$inst->getInstitutionName().\"\";\n }\n \n public function printAsso($asso)\n {\n return \"generate('displayAsso', array('id'=>$asso->getId())).\"'>\".$asso->getAssociationName().\"\";\n }\n \n public function printDate($date)\n {\n return $date->format('d/m/Y');\n }\n \n public function PAStatus($status)\n { \n return $this->container->getParameter('PAStatus')[$status];\n }\n \n public function privacyLevels($pl)\n { \n return $this->container->getParameter('privacyLevels')[$pl];\n }\n\n public function getName()\n {\n return 'templateFunctions';\n }\n\n}\n?>/userBundle/Resources/views/Members/display-member.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n\n{% block content %}\n
\n\n\n\n
\n
\n\t

{{u.username}}

\n{%if is_granted(\"IS_AUTHENTICATED_REMEMBERED\") and u in app.user.contacts and u.privacyLevel != 2 %}\n\t\t
{{u}}, {{u.age}} ans, téléphone: {{u.mobile}}, email: {{u.email}}
\n\t\t{% if u.hasRole('ROLE_ASSOM') %}\n\t\t\tFonction: {{u.assoM.quality}}
\n\t\t\tAssociations: {{u.assoM.associations|join(', ')}}
\n\t\t{%elseif u.hasRole('ROLE_INSTM') %}\n\t\t\tFonction: {{u.instM.quality}}
\n\t\t\tInstitutions: {{u.instM.institutions|join(', ')}}
\n\t\t{%elseif u.hasRole('ROLE_YOUNG') %}\n\t\t\tInstitutions: {{u.young.institutions|join(', ')}}
\n\t\t{%endif%}\n\t{%elseif contactRequested %}\n Vous avez déjà envoyé une demande de contact à cette utilisateur.\n{%else%}\n Envoyer une demande de contact\n{%endif%}\n\t\n
\n{% endblock %}\n\n\n\n\n\n/userBundle/Resources/views/Profile/albums.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\nVos albums photo
\n\n{%if app.user.albums|length>0 %}\n {%for album in app.user.albums %}\n
{{album.name}} ({{album.pictures|length}} photos)
\n Supprimer l'album\n {%if album.pictures|length > 0 %}\n {%for pic in album.pictures %}\n \n Supprimer\n {%endfor%}\n {%endif%}\n
\n {%endfor%}\n{%else%}\n Vous n'avez pas d'albums.\n{%endif%}\nCréer un album\n
\n
\n{% endblock %}\n/userBundle/Controller/AssoMController.php\nget('security.context')->getToken()->getUser();\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Association');\n $asso = $repository->find($id);\n \n if(!$asso || !$user->getAssoM()->getAssociations()->contains($asso)){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n \\'êtes pas concerné par cette page!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n if($user->hasRole('ROLE_TBC')){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil doit être validé par le réseau avant de pouvoir effectuer cette action. Il devrait l\\'être rapidement.'); \n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n $form = $this->container->get('form.factory')->create(new AssoEditType(), $asso); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($asso);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'association a été correctement mise à jour!');\n return $this->redirect($this->generateUrl('displayAsso', \n array('id'=>$asso->getId())));\n }\n }\n \n \n return $this->render('ecloreuserBundle:AssoM:edit-asso.html.twig',\n array('form' => $form->createView()));\n }\n public function displayHomeAction()\n {\n $user = $this->get('security.context')->getToken()->getUser();\n //get timeline\n $actionManager = $this->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($user);\n $timelineManager = $this->get('spy_timeline.timeline_manager');\n $timeline = $timelineManager->getTimeline($subject, array('page' => 1, 'max_per_page' => '10', 'paginate' => true));\n \n return $this->render('ecloreuserBundle:AssoM:home.html.twig', array('timeline_coll'=>$timeline));\n \n }\n \n public function manageProjectAction($id)\n {\n $user = $this->get('security.context')->getToken()->getUser();\n \n $repository = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:Project');\n $project = $repository->find($id);\n \n // verification que le projet est bien managé par $user\n if(!$project || !$user->getAssoM()->getManagedProjects()->contains($project))\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n \\'êtes pas responsable de ce projet!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n return $this->render('ecloreuserBundle:AssoM:manage-project.html.twig', array('proj'=>$project));\n \n }\n \n public function manageApplicationAction($id)\n { \n $request = $this->getRequest();\n $user = $this->get('security.context')->getToken()->getUser();\n $em = $repository = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:ProjectApplication');\n $PA = $repository->find($id);\n // verifie que la candidature concerne bien un projet managé par $user\n if(!$PA || !$user->getAssoM()->getManagedProjects()->contains($PA->getProject()))\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette candidature ne concerne pas un de vos projets!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n } \n // creation formulaires validation/rejet ou cloture\n $recomm = new Notification();\n $formbuilder = $this->createFormBuilder($recomm);\n \n \n if($PA->getStatus() == 'VALIDATED' && $PA->getProject()->isFinished()){\n $formbuilder->add('message', 'textarea', array('required'=>false)) \n ->add('terminate','submit');\n }elseif($PA->getStatus() == 'PENDING'){\n $formbuilder->add('message', 'textarea', array('required'=>false))\n ->add('validate','submit')\n ->add('reject','submit');\n }\n $form = $formbuilder->getForm();\n \n $form->handleRequest($request);\n \n if($form->isValid()) {\n $PA->setStatusDate(new \\DateTime);\n $PA->setMessage($recomm->getMessage());\n if ($form->has('validate') && $form->get('validate')->isClicked()){\n $PA->setStatus('VALIDATED');\n $event = new PAEvent($PA);\n $this->get('event_dispatcher')->dispatch(TimelineEvents::onValidatedPA, $event);\n }\n elseif ($form->has('reject') && $form->get('reject')->isClicked()){\n $PA->setStatus('REJECTED');\n $event = new PAEvent($PA);\n $this->get('event_dispatcher')->dispatch(TimelineEvents::onRejectedPA, $event);\n }\n elseif ($form->has('terminate') && $form->get('terminate')->isClicked()) \n {\n //cloture candidature\n $PA->setStatus('TERMINATED');\n // creation recommandation\n $recomm->setSender($user);\n $recomm->setProject($PA->getProject());\n $recomm->addReceiver($PA->getYoung()->getUser());\n $recomm->setInitDate(new \\DateTime());\n $recomm->setType('RECOMMENDATION');\n $em->persist($recomm);\n $event = new MarkedEvent($PA);\n $this->get('event_dispatcher')->dispatch(TimelineEvents::onMarkedYoung, $event);\n }\n $em->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Mise à jour effectuée!');\n }\n\n $choices=array('PENDING'=>'En attente de validation',\n 'VALIDATED'=>'Validée', 'REJECTED'=>'Rejetée', 'WITHDRAWN'=>'Retirée',\n 'TERMINATED'=>'Clôturée', 'MARKED'=>'Avis jeune enregistré');\n\n return $this->render('ecloreuserBundle:AssoM:manage-application.html.twig', \n array('pa'=>$PA, 'form'=>$form->createView()));\n \n }\n \n public function registerProjectAction(Request $request)\n {$user = $this->get('security.context')->getToken()->getUser();\n if($user->hasRole('ROLE_TBC')){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil doit être validé par le réseau avant de pouvoir effectuer cette action. Il devrait l\\'être rapidement.'); \n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n // create project registration forms\n $project = new Project();\n $form = $this->createForm(new ProjectRegisterType($this->get('security.context'), $this->container), $project); \n \n $project->addResponsible($this->get('security.context')->getToken()->getUser()->getAssoM());\n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($project);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Le projet a été correctement créé! Il est soumis à validation.');\n //event dispatcher\n $event = new Event();\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onPendingValidation, $event);\n return $this->redirect($this->generateUrl('assom_manageProject', \n array('id'=>$project->getId())));\n }\n }\n return $this->render('ecloreuserBundle:AssoM:register-project.html.twig',\n array('form' => $form->createView()));\n }\n \n public function editProjectAction($id, Request $request)\n {\n $user = $this->get('security.context')->getToken()->getUser();\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Project');\n $proj = $repository->find($id);\n \n if(!$proj || !$user->getAssoM()->getManagedProjects()->contains($proj)){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n \\'êtes pas concerné par cette page!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n $form = $this->container->get('form.factory')->create(new ProjectRegisterType($this->get('security.context'), $this->container), $proj); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($proj);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Le projet a été correctement mis à jour!');\n return $this->redirect($this->generateUrl('assom_manageProject', \n array('id'=>$proj->getId())));\n }\n }\n return $this->render('ecloreuserBundle:AssoM:register-project.html.twig',\n array('form' => $form->createView()));\n }\n \n}\n/userBundle/Resources/views/Profile/annuaire.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n

Gestion de vos contacts

\n\n{%if contact_not|length>0 %}\n

Demandes de contact à gérer

\n
    \n{% for notif in contact_not %}\n
  • {{notif.initDate|date('d-m-Y')}} de {{notif.sender}}: {{notif.message}} \n Accepter\n Refuser\n
  • \n{% endfor %}\n
\n{%else%}\n\n{%endif%}\n\n{%if app.user.contacts|length>0 %}\n\n{%if app.user.getContactsByRole('ROLE_YOUNG')|length > 0 %}\n\n

Jeunes

\n\t{%for contact in app.user.getContactsByRole('ROLE_YOUNG') %}\n\t\n\t
\n
\n\t

{{contact|printName}}

\n\t{{contact.mobile}}, \n\t{{contact.email}}
\n\t{{contact.young.institutions|join(', ')}}
\t\t\n\tDétails...\n\tSupprimer\n\t
\n\n\t{%endfor%}\n\n{%endif%}\n\n\n{%if app.user.getContactsByRole('ROLE_ASSOM')|length > 0 %}\n

Membres associatifs

\n\n{%for contact in app.user.getContactsByRole('ROLE_ASSOM') %}\n\t
\n
\n\t

{{contact|printName}}

\n\t{{contact.mobile}}, \n\t{{contact.email}}
\n\t{{contact.assoM.associations|join(', ')}}
\t\t\n\tDétails...\n\tSupprimer\n\t
\n{%endfor%}\n\n{%endif%}\n\n{%if app.user.getContactsByRole('ROLE_INSTM')|length > 0 %}\n

Membres institutionnels

\n\n{%for contact in app.user.getContactsByRole('ROLE_INSTM') %}\n\n\t
\n
\n\t

{{contact|printName}}

\n\t{{contact.mobile}}, \n\t{{contact.email}}
\n\t{{contact.instM.institutions|join(', ')}}
\t\t\n\tDétails...\n\tSupprimer\n\t
\n\n{%endfor%}\n\n{%endif%}\n{%else%}\nPas encore de contacts dans votre annuaire.\n{%endif%}\n
\n
\n{% endblock %}\n/userBundle/Admin/ProjectApplicationAdmin.php\nadd('young', 'entity', array('class'=>'ecloreuserBundle:Young')) \n ->add('project', 'entity', array('class'=>'ecloreuserBundle:Project')) \n ->add('message', 'textarea')\n ->add('status', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('PAStatus')))\n ->add('statusDate')\n \n ;\n }\n\n // Fields to be shown on filter forms\n /*protected function configureDatagridFilters(DatagridMapper $datagridMapper)\n {\n $datagridMapper\n ->add('young', 'entity', array('class'=>'ecloreuserBundle:Young')) \n ->add('project', 'entity', array('class'=>'ecloreuserBundle:Project')) \n ->add('status')\n ->add('statusDate')\n ;\n }*/\n\n // Fields to be shown on lists\n protected function configureListFields(ListMapper $listMapper)\n {\n $listMapper\n ->addIdentifier('id')\n ->add('young', 'entity', array('class'=>'ecloreuserBundle:Young')) \n ->add('project', 'entity', array('class'=>'ecloreuserBundle:Project')) \n ->add('status', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('PAStatus')))\n ->add('statusDate')\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n}/userBundle/Resources/views/Young/home.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n

Bienvenue {{app.user.username}} !

\n\nTu es dans ton espace membre.\n\n

Actualités récentes

\n
    \n {% for action in timeline_coll %}\n
  • {{ timeline_render(action) }}
  • \n {% endfor %}\n
\n
\n{% if timeline_coll|length <1 %}\n Pas d'actualités.\n {%endif%}\n
\n
\n{% endblock %}\n/userBundle/Resources/views/Projects/temp web/show-project.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Rechercher un projet{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n\nNom du projet: {{proj}}
\nDescription: {{proj.description}}
\nDate de début: {{proj.startdate|date(\"m-d-Y\")}}
\nDate de fin: {{proj.enddate|date(\"m-d-Y\")}}
\nLocalisation: {{proj.address}}
\n{%set validated = proj.PAByStatus('VALIDATED') %}\n{%set terminated = proj.PAByStatus('TERMINATED') %}\n{%set marked = proj.PAByStatus('MARKED') %}\n{% if is_granted(\"IS_AUTHENTICATED_REMEMBERED\") %}\n {%if app.user.hasRole('ROLE_YOUNG') and not app.user.young.hasApplied(proj)%}\n Candidater à ce projet!\n {%endif%}\n {% if date(proj.enddate) < date() %}\n Ce projet est terminé.
\n {{validated|length+terminated|length+marked|length}} participants.\n \n {%else%}\n Jeunes inscrits à ce projet:
    \n {%for part in validated%}\n
  • {{part.young.user|printName}}
  • \n {%endfor%}\n
\n {%endif%}\n{%else%}\n {{validated|length}} participants enregistrés.\n{% endif %}\n
\n{% for action in timeline_coll %}\n {{ timeline_render(action) }}
\n{% endfor %}\n
\n{{timeline_coll|length}} actions in timeline.\n{% endblock %}\n/userBundle/Admin/ImageAdmin.php\nadd('id')\n ->add('ext')\n ->add('file', 'entity', array('class'=>'ecloreuserBundle:Image', 'template' => 'ecloreuserBundle:Admin:list_image.html.twig'))\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n\n ;\n }\n\n /**\n * @param FormMapper $formMapper\n */\n protected function configureFormFields(FormMapper $formMapper)\n {\n $image = $this->getSubject();\n $fileFieldOptions = array();\n if ($image && ($webPath = $image->getWebPath())) {\n $container = $this->getConfigurationPool()->getContainer();\n $fullPath = $container->get('request')->getBasePath().'/'.$webPath;\n $fileFieldOptions['help'] = '';\n }\n $formMapper\n ->add('file', 'file', $fileFieldOptions)\n ;\n }\n\n /**\n * @param ShowMapper $showMapper\n */\n protected function configureShowFields(ShowMapper $showMapper)\n {\n $showMapper\n ->add('id')\n ->add('ext')\n ->add('file', 'entity', array('class'=>'ecloreuserBundle:Image','template' => 'ecloreuserBundle:Admin:show_image.html.twig'))\n ;\n }\n}\n/userBundle/Entity/Institution.php\ngetInstitutionName();\n }\n \n public function getHeadshot()\n {\n return $this->headshot;\n }\n \n public function setHeadshot(\\eclore\\userBundle\\Entity\\Image $headshot)\n {\n return $this->headshot = $headshot;\n }\n \n public function __construct()\n {\n $this->members = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->youngs = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n\n /**\n * Set institutionName\n *\n * @param string $institutionName\n * @return Institution\n */\n public function setInstitutionName($institutionName)\n {\n $this->institutionName = $institutionName;\n\n return $this;\n }\n\n /**\n * Get institutionName\n *\n * @return string \n */\n public function getInstitutionName()\n {\n return $this->institutionName;\n }\n\n /**\n * Set description\n *\n * @param string $description\n * @return Institution\n */\n public function setDescription($description)\n {\n $this->description = $description;\n\n return $this;\n }\n\n /**\n * Get description\n *\n * @return string \n */\n public function getDescription()\n {\n return $this->description;\n }\n\n /**\n * Set location\n *\n * @param string $location\n * @return Institution\n */\n public function setLocation($location)\n {\n $this->location = $location;\n\n return $this;\n }\n\n /**\n * Get location\n *\n * @return string \n */\n public function getLocation()\n {\n return $this->location;\n }\n \n /**\n * Add Members\n *\n * @param eclore\\userBundle\\Entity\\InstitutionMember $member\n */\n \n public function addMember(\\eclore\\userBundle\\Entity\\InstitutionMember $member) \n {\n $this->members[] = $member;\n }\n \n /**\n * Remove Members\n *\n * @param eclore\\userBundle\\Entity\\InstitutionMember $member\n */\n public function removeMember(\\eclore\\userBundle\\Entity\\InstitutionMember $member) \n {\n $this->members->removeElement($member);\n }\n\n /**\n * Get Members\n *\n * @return array \n */\n public function getMembers()\n {\n return $this->members;\n }\n \n /**\n * Add young\n *\n * @param eclore\\userBundle\\Entity\\Young $young\n */\n \n public function addYoung(\\eclore\\userBundle\\Entity\\Young $young) \n {\n $this->youngs[] = $young;\n }\n \n /**\n * Remove young\n *\n * @param eclore\\userBundle\\Entity\\Young $young\n */\n public function removeYoung(\\eclore\\userBundle\\Entity\\Young $young) \n {\n $this->youngs->removeElement($young);\n }\n\n /**\n * Get youngs\n *\n * @return array \n */\n public function getYoungs()\n {\n return $this->youngs;\n }\n \n}\n/userBundle/Resources/public/js/accueil/anim.js\n$(document).ready(function(){\n\n\n\n\n\n\n\n\n\n// Scrolling down when clicking on the word ---------------------------------------\n/*\n$('a[href*=#]').each(function() {\n\tif (location.pathname.replace(/^\\//,'') == this.pathname.replace(/^\\//,'')\n\t&& location.hostname == this.hostname\n\t&& this.hash.replace(/#/,'') ) { // remove the hash in front of the anchor part of the url, basically making sure that we are at an anchor\n\t\tvar $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');\n\t\tvar $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;\n\t\tif ($target) {\n\t\t\tvar targetOffset = $target.offset().top;\n\t\t\t$(this).click(function() {\n\t\t\t\t\t$(\"#nav li a\").removeClass(\"active\");\n\t\t\t\t\t$(this).addClass('active');\n\t\t\t$('html, body').animate({scrollTop: targetOffset}, 2000);\n\t\t\treturn false;\n\t\t\t});\n\t\t}\n\t}\n});\n*/\n// -------------------------------------------------------------------------------------------\n// ----------------------Animation for the onglet effect of the site ----------------\n// -------------------------------------------------------------------------------------------\n\n\nvar $window = $(window);\nvar winHeight = $window.height();\nvar winWidth = $window.width();\n\nvar $eclore = $('#eclore');\nvar $reseau = $('#reseau');\nvar $proj = $('#projet');\nvar $cloud = $('#cloud');\nvar $container = $('#container');\nvar $footer = $('footer');\n\nvar $descrmod = $('div.descr.mod');\nvar $descrbleu = $('div.descr.bleu');\nvar $descrvert = $('.descr.vert');\nvar $descrorange = $('.descr.orange');\n\nvar $ongletbleu = $('a.onglet.bleu');\nvar $ongletvert = $('a.onglet.vert');\nvar $ongletorange = $('a.onglet.orange');\nvar $ongletorange = $('a.onglet.orange');\n\nvar $descriptions = $('.descriptions');\nvar $onglets = $('.onglet');\n\nvar isdeveloped = 0;\n\n\n\n // Animating the word cloud and the onglet-------------------------\n\n function colorOngletIn(col){\n\t var descr = \".descr.mod\";\n\t ChangeCol($(descr),col)\n}\n\nfunction colorIn(n){\n\tvar fore = $('.cloud_f')[n];\n $('#cloud_bkg').stop().animate({opacity: 0.2},{queue:false, duration:2000, easing: 'easeOutExpo'});\n\t$(fore).stop().fadeIn('2000');\n};\n\n function colorOut(){\n $('#cloud_bkg').stop().animate({opacity: 1},{queue:false, duration:2000, easing: 'easeOutExpo'});\n\t$('.cloud_f').stop().fadeOut('2000')\n};\n \n //When mouse rolls over\n $('#area_projet').mouseover(\n\t\tfunction(){colorOngletIn('bleu');colorIn(0);}\n\t); \n\t$('#area_reseau').mouseover(\n\t\tfunction(){colorOngletIn('orange');colorIn(2);}\n\t); \n\t$('#area_eclore').mouseover(\n\t\tfunction(){colorOngletIn('vert');colorIn(1);}\n\t); \n\t$ongletbleu.mouseover(\n\t\tfunction(){colorOngletIn('bleu');colorIn(0);}\n\t); \n\t$ongletorange.mouseover(\n\t\tfunction(){colorOngletIn('orange');colorIn(2);}\n\t); \n\t$ongletvert.mouseover(\n\t\tfunction(){colorOngletIn('vert');colorIn(1);}\n\t); \n //When mouse is removed\n $('#navarea a').mouseout(function(){\n\tcolorOut() ;\n });\n\t$onglets.mouseout(function(){\n\tcolorOut() ;\n });\n\n\n\n\n\n\n // Auxilliary Changing color of an element --------------------------------------------------------\n function ChangeCol($el,col) {\n $el.addClass(col).removeClass('bleu').removeClass('orange').removeClass('vert').addClass(col);\n }\n \n// Auxilliary function swapping the onglet place --------------------------------------------------------\n \n function swaponglet(col) {\n var descri = \".descriptions.\"+ col;\n var ongl = \".onglet.\"+ col;\n$(descri).insertBefore('.descriptions:nth-child(1)');\n$(ongl).insertBefore('.onglet:nth-child(1)');\n//alert(ongl);\n}\n// main function \n\nfunction devpanel(col) {\n\tvar $element ; var descrel;\n\tif (col == 'bleu'){$element = $proj; $descrel = $descrbleu;};\n\tif (col == 'orange'){$element = $reseau; $descrel = $descrorange;};\n\tif (col == 'vert'){$element = $eclore; $descrel = $descrvert};\n\t$descrmod.css('display','none');\n\t$descrbleu.css('display','none');$descrvert.css('display','none');$descrorange.css('display','none');\n\t$descrel.css('display','inline-block');\n\tif (isdeveloped == 0) {\n\t\t$container.css('left','-'+ winWidth +'px');\n\t\t$element.css('display','inline-block');$cloud.css('display','none');$container.css('width','');\n\t\t$container.animate({left: 0},{queue:false, duration:3000, easing: 'easeOutExpo'});\t\n\t\t// change footer color and launch specific animation\n\t\tChangeCol($footer,col);ChangeCol($('.menu'),col);swaponglet(col);LauchCarouProj();LauchCarouActu();\n\t\t//change the height of the left line\n\t\t$descriptions.css('height',$element.css('height'));\n\t\t// mark that the onglet are developed\n\t\tisdeveloped = 1;\n\t\t}\n\tif (isdeveloped == 1) {\n\t\t$descrmod.css('display','none');\n\t\t$eclore.css('display','none');$proj.css('display','none');$reseau.css('display','none');\n\t\t$element.css('display','inline-block');\n\t\tChangeCol($footer,col);ChangeCol($('.menu'),col);swaponglet(col);LauchCarouProj();LauchCarouActu();\n\t\t$descriptions.css('height',$element.css('height'));\n\t}\t\n};\n\n//-------- Basic CSS change\n\n\n\n$ongletbleu.click( function() {\n\tdevpanel('bleu');\n\t});\n$ongletvert.click( function() {\n\tdevpanel('vert');\n\t});\n$ongletorange.click( function() {\n\tdevpanel('orange');\n\t});\n$(area_projet).click( function() {\n\tdevpanel('bleu');\n\t});\n$(area_reseau).click( function() {\n\tdevpanel('orange');\n\t});\n$(area_eclore).click( function() {\n\tdevpanel('vert');\n\t});\n\n\n\n\n// Animation for the parallax (scrolling effect) part of the site ---------------------------------------\n\n/*\nvar $window = $(window);\nvar $proj = $('#projet');\nvar $banproj = $('#banner_projet');\nvar $wordproj = $('#word_projet');\nvar $reseau = $('#reseau');\nvar $banreseau = $('#banner_reseau');\nvar $wordreseau = $('#word_reseau');\nvar $eclore = $('#eclore');\nvar $baneclore = $('#banner_eclore');\nvar $wordeclore = $('#word_eclore');\nvar windowHeight = $window.height();\n\t\n\n\t\nfunction newPos($el, windowHeight, scrollpos, vel, origin){\n\tvar x = $el.css('backgroundPosition').slice(0,$el.css('backgroundPosition').indexOf(' ')).trim();\n//\tvar baseunit = windowHeight;\n//\talert((scrollpos - origin) * vel);\n\treturn x + ' ' + ( (scrollpos - origin) * (vel-1) ) + \"px\"; // adjuster start\n}\n\t\n\t\nfunction Move(){\n var pos = $window.scrollTop();\n//\talert(newPos($banproj, windowHeight, pos, 300, 200));\n// $banproj.css('backgroundPosition', '' + newPos($banproj, windowHeight, pos, -0.95, 58.8 ));\n $wordproj.css('backgroundPosition', '' + newPos($wordproj, windowHeight, pos, 0.2 , 1460));\n// $banreseau.css('backgroundPosition', '' + newPos($banreseau, windowHeight, pos, -0.95, 140+58.8 ));\n $wordreseau.css('backgroundPosition', '' + newPos($wordreseau, windowHeight, pos, 0.2 , 2625 ));\n// $baneclore.css('backgroundPosition', '' + newPos($baneclore, windowHeight, pos, -0.95, 280+58.8 ));\n $wordeclore.css('backgroundPosition', '' + newPos($wordeclore, windowHeight, pos, 0.2 , 3940 ));\n}\n\n$window.resize(function(){\n Move();\n});\n\n$window.bind('scroll', function(){\n\tMove();\n});\n\n$(function() {\n Move();\n});\n\n*/\n\n\nfunction LauchCarouProj() {\n\n$('#projcarousel').carouFredSel({\n\n\t\tauto : {\n\t items : 3,\n\t duration : 1000,\n\t easing : \"easeInOutCubic\",\n\t\t},\n\n\n items : 3,\n\t\tresponsive : true,\n\t\t\n\t\tprev : {\n\t button : \"#carousel_prev\",\n\t key : \"left\",\n\t items : 1,\n\t easing : \"easeInOutCubic\",\n\t duration : 750\n\t },\n\t next : {\n\t button : \"#carousel_next\",\n\t key : \"right\",\n\t items : 1,\n\t easing : \"easeInOutCubic\",\n\t duration : 1250\n\t\t}\t\n\t\t\n});\n\n}\n\n\n\nfunction LauchCarouActu() {\n\n$(\"#foccarousel\").carouFredSel({\n\tresponsive\t: true,\n\tscroll\t\t: {\n\t\tfx\t\t\t: \"crossfade\" ,\n\t\tduration : 1500,\n\t},\n\titems\t\t: {\n\t\tvisible\t\t: 1,\n\t\theight\t\t: 390,\n\t}\n});\n\n}\n\n$('#tweet').tweecool({\n //settings\n username : 'ResEclore', \n limit : 4 \n });\n\t\t\n\n\n\n\n\n\n // Using custom configuration\n\t\n\n});/userBundle/Resources/views/AssoM/register-project.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Enregistrer un projet{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n\n\n \n\n\n
\n{{ form(form) }}\n
\n\n\n
\n
\n{% endblock %}\n/userBundle/Resources/views/Registration/email.html.twig\n{% block subject %}\nConfirmation d'inscription\n{% endblock %}\n\n{% block body_html %}\nBonjour {{user.username}},

\nMerci de cliquer sur ce lien pour confirmer votre inscription!\n

\nL'équipe du Réseau Eclore\n{% endblock %}\n/userBundle/Resources/views/Admin/email-pending-validation.html.twig\n{% block subject %}\ndu nouveau à valider!\n{% endblock %}\n\n{% block body_html %}\nsalut !\n
\nil y a du nouveau à valider dans la partie admin !\n
\nL'admin\n{% endblock %}\n/userBundle/Resources/views/InstM/home.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
\n

Bienvenue {{app.user.username}} !

\n\nVous êtes dans votre espace membre. Vous pouvez y voir le parcours des jeunes qui appartiennent à votre établissement.
\n\n\n{% for inst in instM.institutions %}\n

Jeunes membre de : {{inst|printInst}}

\n {% if inst.youngs|length > 0 %}\n
    \n {% for young in inst.youngs %}\n
  • {{young}}, Manager
  • \n {% endfor %}\n
\n \n {% endif %}\n{% endfor %}\n\n\n

Actualités récentes

\n
    \n {% for action in timeline_coll %}\n
  • {{ timeline_render(action) }}
  • \n {% endfor %}\n
\n
\n{% if timeline_coll|length == 0 %}\n Pas d'actualités.\n {%endif%}\n
\n
\n{% endblock %}\n/userBundle/Timeline/ContactAckEvent.php\nrequestingUser = $requestingUser;\n $this->ackUser = $ackUser;\n }\n \n public function getRequestingUser()\n {\n return $this->requestingUser;\n }\n \n public function getAckUser()\n {\n return $this->ackUser;\n }\n}/userBundle/Resources/views/Timeline/verbs/mark_young.html.twig\n
  • \n{{ timeline_component_render(timeline, 'subject') }}\na évalué\n{{ timeline_component_render(timeline,'complement') }}\n
  • /userBundle/Resources/views/Resetting/email.html.twig\n{% block subject %}\nRéinitialisation de votre mot de passe\n{% endblock %}\n\n{% block body_html %}\nBonjour {{user.username}}!

    \nPour réinitialiser votre mot de passe, merci de cliquer sur ce lien.\n

    \nCordialement,\n

    \nL'équipe du Réseau Eclore\n{% endblock %}\n/userBundle/Entity/Association.php\nmembers = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->projects = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n \n public function __toString()\n {\n return $this->getAssociationName();\n }\n \n public function getHeadshot()\n {\n return $this->headshot;\n }\n \n public function setHeadshot(\\eclore\\userBundle\\Entity\\Image $headshot)\n {\n return $this->headshot = $headshot;\n }\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n\n /**\n * Set associationName\n *\n * @param string $associationName\n * @return Association\n */\n public function setAssociationName($associationName)\n {\n $this->associationName = $associationName;\n\n return $this;\n }\n\n /**\n * Get associationName\n *\n * @return string \n */\n public function getAssociationName()\n {\n return ucwords($this->associationName);\n }\n\n /**\n * Set description\n *\n * @param string $description\n * @return Association\n */\n public function setDescription($description)\n {\n $this->description = $description;\n\n return $this;\n }\n\n /**\n * Get description\n *\n * @return string \n */\n public function getDescription()\n {\n return $this->description;\n }\n \n /**\n * Set location\n *\n * @param string $location\n * @return Institution\n */\n public function setLocation($location)\n {\n $this->location = $location;\n\n return $this;\n }\n\n /**\n * Get location\n *\n * @return string \n */\n public function getLocation()\n {\n return $this->location;\n }\n \n /**\n * Add Projects\n *\n * @param eclore\\userBundle\\Entity\\Project $project\n */\n \n public function addProject(\\eclore\\userBundle\\Entity\\Project $project) \n {\n $this->projects[] = $project;\n }\n \n /**\n * Remove Projects\n *\n * @param eclore\\userBundle\\Entity\\Project $project\n */\n public function removeProject(\\eclore\\userBundle\\Entity\\Project $project) \n {\n $this->projects->removeElement($project);\n }\n\n /**\n * Get Projects\n *\n * @return array \n */\n public function getProjects()\n {\n return $this->projects;\n }\n \n /**\n * Add Members\n *\n * @param eclore\\userBundle\\Entity\\AssociationMember $member\n */\n \n public function addMember(\\eclore\\userBundle\\Entity\\AssociationMember $member) \n {\n $this->members[] = $member;\n }\n \n /**\n * Remove Members\n *\n * @param eclore\\userBundle\\Entity\\AssociationMember $member\n */\n public function removeMember(\\eclore\\userBundle\\Entity\\AssociationMember $member) \n {\n $this->members->removeElement($member);\n }\n\n /**\n * Get Members\n *\n * @return array \n */\n public function getMembers()\n {\n return $this->members;\n }\n public function getHeadshotWebPath()\n {\n if($this->headshot==null)\n return 'uploads/img/symbole_eclore.png';\n return $this->headshot->getWebPath();\n }\n}\n/userBundle/Form/ProjectType.php\nsecurityContext = $securityContext;\n $this->container = $container;\n }\n \n public function buildForm(FormBuilderInterface $builder, array $options)\n {\n $user = $this->securityContext->getToken()->getUser();\n \n $data;\n foreach($user->getAssoM()->getAssociations() as $value)\n {\n $data[$value->getId()]=$value;\n }\n \n $builder\n ->add('projectName' , 'text', array('label' => ' Intitulé du projet :'))\n ->add('shortDescription' , 'textarea', array('label' => ' Votre projet en une phrase !') )\n ->add('description' , 'textarea', array('label' => 'Décrivez plus précisement le projet :'))\n ->add('association', 'entity', array('class' => 'eclore\\userBundle\\Entity\\Association',\n 'choices' => $data))\n ->add('labels', 'entity', array('class' => 'eclore\\userBundle\\Entity\\ProjectLabels', 'label' => ' Catégorie :'))\n ->add('startDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\"), (int)date(\"Y\")+50) , 'label' => ' Date de début du projet'))\n ->add('endDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\"), (int)date(\"Y\")+50) , 'label' => ' Date de fin du projet'))\n ->add('address', 'text', array('attr' => array('class'=>'addressPickerInput') , 'label' => \"Lieu du projet\") )\n ->add('required', 'text', array('label' => ' Nombre souhaité de jeunes :')) \n ->add('investmentRequired', 'choice', array('choices'=>$this->container->getParameter('investmentRequired'), 'label' => ' Investissement nécessaire :'))\n ->add('projectApplications', 'entity', array('class'=>'ecloreuserBundle:ProjectApplication',\n 'property'=>'id', 'multiple'=>true, 'required'=>false))\n ->add('lat', 'hidden', array('attr' => array('class'=>'addressPickerLat')))\n ->add('lng', 'hidden', array('attr' => array('class'=>'addressPickerLng')))\n ->add('city', 'hidden', array('attr' => array('class'=>'addressPickerCity')))\n ->add('country', 'hidden', array('attr' => array('class'=>'addressPickerCountry')))\n ->add('postcode', 'hidden', array('attr' => array('class'=>'addressPickerPostcode')))\t ->add('responsibles', 'entity', array('class' => 'eclore\\userBundle\\Entity\\AssociationMember',\n 'multiple'=>true))\n ->add('save', 'submit' , array( 'label' => 'Déposer le projet !' ))\n ;\n }\n\n public function setDefaultOptions(OptionsResolverInterface $resolver)\n {\n $resolver->setDefaults(array(\n 'data_class' => 'eclore\\userBundle\\Entity\\Project'\n ));\n }\n\n public function getName()\n {\n return 'eclore_userbundle_projecttype';\n }\n}/userBundle/Controller/RegistrationProfileController.php\ncontainer->get('security.context')->getToken()->getUser();\n $token = $this->get('security.context')->getToken();\n \n // create young registration forms\n $young = new Young();\n $youngFormBuilder = $this->get('form.factory')->createNamedBuilder('young', 'form', $young);\n $youngFormBuilder\n ->setMethod('POST')\n ->add('institutions', 'entity', array('class'=>'ecloreuserBundle:Institution',\n 'property'=>'institutionName', 'multiple'=>true, 'label'=>'A quelle(s) institution(s) es-tu rattaché ?', 'empty_data'=>'Aucune.'))\n ->add('quality', 'textarea', array('mapped'=>false, 'label'=>'Tes activités'))\n ->add('submitYoung', 'submit', array('label'=>'Finir l\\'inscription'));\n \n // create institutionmember registration forms\n $instM = new InstitutionMember();\n $instMFormBuilder = $this->get('form.factory')->createNamedBuilder('instM', 'form', $instM);\n $instMFormBuilder\n ->setMethod('POST')\n ->add('institutions', 'entity', array('class'=>'ecloreuserBundle:Institution',\n 'property'=>'institutionName', 'multiple'=>true, 'label'=>'De quelles institutions faites-vous partie ?')) \n ->add('quality', 'textarea', array('mapped'=>false, 'label'=>'Quel est vôtre rôle dans dans cette (ces) institution(s) ?'))\n ->add('submitInstM', 'submit', array('label'=>'Finir l\\'inscription'));\n\n // create associationmember registration forms\n $assoM = new AssociationMember();\n $assoMFormBuilder = $this->get('form.factory')->createNamedBuilder('assoM', 'form', $assoM);\n $assoMFormBuilder\n ->setMethod('POST')\n ->add('associations', 'entity', array('class'=>'ecloreuserBundle:Association',\n 'property'=>'associationName', 'multiple'=>true, 'label'=>'De quelles associations faites-vous partie ?'))\n ->add('quality', 'textarea', array('mapped'=>false, 'label'=>'Quel est vôtre rôle dans dans cette (ces) association(s) ?'))\n ->add('submitAssoM', 'submit', array('label'=>'Finir l\\'inscription')); \n \n $instMForm = $instMFormBuilder->getForm();\n $assoMForm = $assoMFormBuilder->getForm();\n $youngForm = $youngFormBuilder->getForm();\n \n if('POST' === $request->getMethod()) {\n if ($request->request->has('young')) {\n $youngForm->bind($request);\n if ($youngForm->isValid()) {\n $user->setQuality($youngForm->get('quality')->getData());\n $young->setUser($user);\n $em = $this->getDoctrine()->getManager();\n $em->persist($young);\n $user->addRole(\"ROLE_YOUNG\");\n $em->persist($user);\n $em->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil a été correctement créé!');\n //event dispatcher\n $event = new NewUserEvent($user);\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onNewUser, $event);\n // Generate new token with new roles\n $token = new \\Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken(\n $user,\n null,\n 'main',\n $user->getRoles()\n );\n $this->container->get('security.context')->setToken($token);\n // Get the userManager and refresh user\n $userManager = $this->container->get('fos_user.user_manager');\n $userManager->refreshUser($user);\n return $this->redirect($this->generateUrl('ecloreuser_younghome'));\n }\n }\n if ($request->request->has('instM')) {\n $instMForm->bind($request);\n if ($instMForm->isValid()) {\n $user->setQuality($instMForm->get('quality')->getData());\n $instM->setUser($user);\n $em = $this->getDoctrine()->getManager();\n $em->persist($instM);\n $user->addRole(\"ROLE_TBC\");\n $user->addRole(\"ROLE_INSTM\");\n $em->persist($user);\n $em->flush();\n // Generate new token with new roles\n $token = new \\Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken(\n $user,\n null,\n 'main',\n $user->getRoles()\n );\n $this->container->get('security.context')->setToken($token);\n // Get the userManager and refresh user\n $userManager = $this->container->get('fos_user.user_manager');\n $userManager->refreshUser($user);\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil a correctement été créé!');\n //event dispatcher\n $event = new Event();\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onPendingValidation, $event);\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n }\n if ($request->request->has('assoM')) {\n $assoMForm->bind($request);\n if ($assoMForm->isValid()) {\n $user->setQuality($assoMForm->get('quality')->getData());\n $assoM->setUser($user);\n $em = $this->getDoctrine()->getManager();\n $em->persist($assoM);\n $user->addRole(\"ROLE_TBC\");\n $user->addRole(\"ROLE_ASSOM\");\n $em->persist($user);\n $em->flush();\n // Generate new token with new roles\n $token = new \\Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken(\n $user,\n null,\n 'main',\n $user->getRoles()\n );\n $this->container->get('security.context')->setToken($token);\n // Get the userManager and refresh user\n $userManager = $this->container->get('fos_user.user_manager');\n $userManager->refreshUser($user);\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil a correctement été créé!');\n //event dispatcher\n $event = new Event();\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onPendingValidation, $event);\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n }\n }\n \n return $this->render('ecloreuserBundle:Registration:registerProfile.html.twig', array(\n 'youngForm' => $youngForm->createView(),'instMForm' => $instMForm->createView(),\n 'assoMForm' => $assoMForm->createView(),\n ));\n }\n \n}\n/userBundle/Entity/InstitutionMember.php\ngetUser()->__toString().\" (\".implode('; ',array_map(function($elem){return $elem->__toString();},$this->getInstitutions()->toArray())).\")\";\n }\n \n public function __construct()\n {\n $this->institutions = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n \n /**\n * Set user\n *\n * @param string $user\n * @return InstitutionMember\n */\n public function setUser($user)\n {\n $this->user = $user;\n $user->setInstM($this);\n\n return $this;\n }\n\n /**\n * Get username\n *\n * @return string \n */\n public function getUser()\n {\n return $this->user;\n }\n\n /**\n * Add institutions\n *\n * @param eclore\\userBundle\\Entity\\Institution $institution\n */\n \n public function addInstitution(\\eclore\\userBundle\\Entity\\Institution $institution)\n {\n $this->institutions[] = $institution;\n $institution->addMember($this);\n }\n \n /**\n * Remove institutions\n *\n * @param eclore\\userBundle\\Entity\\Institution $institution\n */\n public function removeInstitution(\\eclore\\userBundle\\Entity\\Institution $institution) \n {\n $institutions->removeMember($this);\n $this->institutions->removeElement($institution);\n }\n \n /**\n * Get institutions\n *\n * @return array \n */\n public function getInstitutions()\n {\n return $this->institutions;\n }\n}\n/userBundle/Controller/HomeController.php\nget('security.context')->getToken()->getUser();\n if($user->hasRole('ROLE_YOUNG') || $user->hasRole('ROLE_ASSOM') || $user->hasRole('ROLE_INSTM')){\n // redirect user to his home\n if($user->hasRole('ROLE_YOUNG'))return $this->redirect($this->generateUrl('ecloreuser_younghome'));\n if($user->hasRole('ROLE_INSTM'))return $this->redirect($this->generateUrl('ecloreuser_instmhome'));\n if($user->hasRole('ROLE_ASSOM'))return $this->redirect($this->generateUrl('ecloreuser_assomhome'));\n\n }\n elseif($user->hasRole('ROLE_TBC')){\n // user role is awaiting confirmation\n return $this->render('ecloreuserBundle:Registration:waitConfirmation.html.twig');\n }\n // user has not any role yet, he must create at least one.\n return $this->forward('ecloreuserBundle:RegistrationProfile:registerProfile');\n }\n\n}\n/userBundle/Entity/NewsPostRepository.php\n_em->createQueryBuilder();\n \n $qb->select('a')\n ->from('ecloreuserBundle:NewsPost', 'a')\n ->where('a.endDate > :datecourant')\n ->setParameter('datecourant', new \\Datetime(date('Y-m-d')))\n ->orderBy('a.id', 'DESC');\n \n return $qb->getQuery()\n ->getResult();\n }\n\n}\n/userBundle/Form/AlbumType.php\nadd('name', 'text')\n ->add('pictures', 'collection', array('type' => new ImageType(),\n 'allow_add' => true,\n 'allow_delete' => true,\n 'required' => false,\n 'by_reference' => false))\n ->add('save', 'submit')\n ;\n }\npublic function setDefaultOptions(OptionsResolverInterface $resolver)\n {\n $resolver->setDefaults(array(\n 'data_class' => 'eclore\\userBundle\\Entity\\Album'\n ));\n }\n\n public function getName()\n {\n return 'eclore_userbundle_albumtype';\n }\n}/userBundle/Entity/Album.php\npictures = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n \n public function __toString()\n {\n return $this->name;\n }\n\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n \n public function addPicture(\\eclore\\userBundle\\Entity\\Image $image) \n {\n $this->pictures[] = $image;\n $image->setAlbum($this);\n }\n \n public function removePicture(\\eclore\\userBundle\\Entity\\Image $image) \n {\n $this->pictures->removeElement($image);\n }\n\n public function getPictures()\n {\n return $this->pictures;\n }\n \n public function setPictures($pics)\n {\n foreach ($pics as $pic) {\n $this->addPicture($pic);\n }\n }\n\n /**\n * Set owner\n *\n * @param \\stdClass $owner\n * @return Album\n */\n public function setOwner($owner)\n {\n $this->owner = $owner;\n $owner->addAlbum($this);\n return $this;\n }\n\n /**\n * Get owner\n *\n * @return \\stdClass \n */\n public function getOwner()\n {\n return $this->owner;\n }\n\n /**\n * Set name\n *\n * @param string $name\n * @return Album\n */\n public function setName($name)\n {\n $this->name = $name;\n\n return $this;\n }\n\n /**\n * Get name\n *\n * @return string \n */\n public function getName()\n {\n return $this->name;\n }\n}\n/userBundle/Resources/views/Registration/registerProfile.html.twig\n{% extends \"FOSUserBundle::layout.html.twig\" %}\n\n\n\n{% block fos_user_content %}\n

    Votre inscription est presque terminée !

    \n

    Afin de profitez des possibilités du réseau Eclore, reliez votre compte à une institution ou à une association.

    \n
    \n
    \n \n \n
    \n
    \n
    \n {{ form(youngForm) }}\n {{ form(instMForm) }}\n {{ form(assoMForm) }} \n Votre association n'est pas dans la liste ? Créez là !
    \n Votre institution n'est pas dans la liste ? Créez là !\n
    \n\n{% endblock fos_user_content %}\n/userBundle/Resources/views/Projects/temp web/rechercher.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Rechercher un projet{% endblock %}\n\n{%set color='vert'%}\n{%set first='Les projets'%}\n{%set second='Rechercher un projet'%}\n\n\n{% block content %}\nceci est la page de recherche des projets
    \n
    Chargement en cours...\n \n
    \n\n\n
    \n
    \n
    \n \n \n\n\n\n\n\n{% endblock %}\n/userBundle/Resources/views/Admin/show_headshot.html.twig\n{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}\n\n{% block field%}\n {%if object.headshot is not null %}\n \n {%else%}\n Pas de photo \n {%endif%}\n{% endblock %}/userBundle/Controller/MembersController.php\ncontainer->get('security.context'); \n \n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:User');\n $user2 = $repository->find($id);\n\n // verifie que le user existe et n'est pas terminé.\n if(!$user2 || $user2->getPrivacyLevel() == 2)\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Ce profil n\\'existe pas');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n $contactRequested=False;\n if( $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){\n \n $user = $this->get('security.context')->getToken()->getUser();\n \n //check que une demande de contact n'existe pas deja.\n $rep = $em->getRepository('ecloreuserBundle:Notification');\n $contactRequested = $rep->contactRequested($user, $user2);\n }\n return $this->render('ecloreuserBundle:Members:display-member.html.twig', array('u'=>$user2, 'contactRequested'=>$contactRequested));\n }\n \n public function displayAssoAction($id)\n {\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Association');\n $asso = $repository->find($id);\n if(!$asso)\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette association n\\'existe pas');\n return $this->redirect($this->generateUrl('ecloreuser_homepage'));\n }\n \n return $this->render('ecloreuserBundle:Members:display-asso.html.twig', array('asso'=>$asso));\n \n }\n \n public function createAssoAction(Request $request)\n {\n $asso = new Association();\n $form = $this->container->get('form.factory')->create(new AssoEditType(), $asso); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($asso);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'association a été correctement crée!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n }\n return $this->render('ecloreuserBundle:Members:create-asso.html.twig',\n array('form' => $form->createView()));\n }\n public function createInstAction(Request $request)\n {\n $inst = new Institution();\n $form = $this->container->get('form.factory')->create(new InstEditType(), $inst); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($inst);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'association a été correctement crée!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n }\n return $this->render('ecloreuserBundle:Members:create-inst.html.twig',\n array('form' => $form->createView()));\n }\n \n public function displayInstAction($id)\n {\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Institution');\n $inst = $repository->find($id);\n if(!$inst)\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette association n\\'existe pas');\n return $this->redirect($this->generateUrl('ecloreuser_homepage'));\n }\n \n return $this->render('ecloreuserBundle:Members:display-inst.html.twig', array('inst'=>$inst));\n }\n}\n/userBundle/Controller/InstMController.php\nget('security.context')->getToken()->getUser();\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Institution');\n $inst = $repository->find($id);\n \n if(!$inst || !$user->getInstM()->getInstitutions()->contains($inst)){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n \\'êtes pas concerné par cette page!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n if($user->hasRole('ROLE_TBC')){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Votre profil doit être validé par le réseau avant de pouvoir effectuer cette action. Il devrait l\\'être rapidement.'); \n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n $form = $this->container->get('form.factory')->create(new InstEditType(), $inst); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $this->getDoctrine()->getManager()->persist($asso);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'institution a été correctement mise à jour!');\n return $this->redirect($this->generateUrl('displayInst', \n array('id'=>$inst->getId())));\n }\n }\n \n \n return $this->render('ecloreuserBundle:InstM:edit-inst.html.twig',\n array('form' => $form->createView()));\n }\n \n public function displayHomeAction()\n {\n $user = $this->get('security.context')->getToken()->getUser();\n //get timeline\n $actionManager = $this->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($user);\n $timelineManager = $this->get('spy_timeline.timeline_manager');\n $timeline = $timelineManager->getTimeline($subject, array('page' => 1, 'max_per_page' => '10', 'paginate' => true));\n \n return $this->render('ecloreuserBundle:InstM:home.html.twig', \n array('instM'=>$user->getInstM(),'timeline_coll'=>$timeline));\n \n }\n \n public function displayYoungAction($id)\n {\n $user = $this->get('security.context')->getToken()->getUser();\n \n $repository = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:Young');\n $young = $repository->find($id);\n\n if($user->getInstM()->getInstitutions()\n ->forAll(function($k, $i) use ($young){return !$i->getYoungs()->contains($young);}))\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n \\'êtes pas responsable de ce jeune!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n return $this->render('ecloreuserBundle:InstM:display-young.html.twig', array('young'=>$young));\n \n }\n\n}\n/userBundle/Resources/views/Admin/show_image.html.twig\n{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}\n\n{% block field%}\n \n{% endblock %}/userBundle/Entity/AssociationMember.php\ngetUser()->__toString().\" (\".implode('; ',array_map(function($elem){return $elem->__toString();},$this->getAssociations()->toArray())).\")\";\n }\n \n public function __construct()\n {\n $this->associations = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->managedProjects = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n \n /**\n * Set user\n *\n * @param string $user\n * @return InstitutionMember\n */\n public function setUser($user)\n {\n $this->user = $user;\n $user->setAssoM($this);\n\n return $this;\n }\n\n /**\n * Get username\n *\n * @return string \n */\n public function getUser()\n {\n return $this->user;\n }\n \n /**\n * Add associations\n *\n * @param eclore\\userBundle\\Entity\\Association $association\n */\n \n public function addAssociation(\\eclore\\userBundle\\Entity\\Association $association)\n {\n $this->associations[] = $association;\n $association->addMember($this);\n }\n \n /**\n * Remove associations\n *\n * @param eclore\\userBundle\\Entity\\Association $association\n */\n public function removeAssociation(\\eclore\\userBundle\\Entity\\Association $association) \n {\n $association->removeMember($this);\n $this->associations->removeElement($association);\n }\n\n /**\n * Get associations\n *\n * @return array \n */\n public function getAssociations()\n {\n return $this->associations;\n }\n \n /**\n * Add proj\n *\n * \\eclore\\userBundle\\Entity\\Project $project\n */\n \n public function addManagedProject(\\eclore\\userBundle\\Entity\\Project $project)\n {\n $this->managedProjects[] = $project;\n }\n \n /**\n * Remove proj\n *\n * \\eclore\\userBundle\\Entity\\Project $project\n */\n public function removeManagedProjects(\\eclore\\userBundle\\Entity\\Project $project) \n {\n $this->managedProjects->removeElement($project);\n }\n\n /**\n * Get proj\n *\n * @return array \n */\n public function getManagedProjects()\n {\n return $this->managedProjects;\n }\n}\n/userBundle/Resources/views/Timeline/verbs/contact.html.twig\n
  • \n{{ timeline_component_render(timeline, 'subject') }}\nest en contact avec\n{{ timeline_component_render(timeline,'complement') }}\n
  • /userBundle/Admin/NotificationAdmin.php\nadd('type', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('Notification')))\n ->add('message', 'textarea')\n ->add('initDate')\n ->add('project', 'entity', array('class'=>'ecloreuserBundle:Project', 'required'=>false))\n ->add('sender', 'entity', array('class'=>'ecloreuserBundle:User'))\n ->add('receivers', 'entity', array('class'=>'ecloreuserBundle:User',\n 'multiple'=>true))\n ;\n }\n\n // Fields to be shown on filter forms\n /*protected function configureDatagridFilters(DatagridMapper $datagridMapper)\n {\n $datagridMapper\n ->add('user')\n ->add('schoolSituation')\n ->add('institutions')\n ->add('appliedProjects')\n ->add('friends')\n ;\n }*/\n\n // Fields to be shown on lists\n protected function configureListFields(ListMapper $listMapper)\n {\n $listMapper\n ->addIdentifier('id')\n ->add('type', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('Notification')))\n ->add('message', 'textarea')\n ->add('initDate')\n ->add('project', 'entity', array('class'=>'ecloreuserBundle:Project', 'required'=>false))\n ->add('sender', 'entity', array('class'=>'ecloreuserBundle:User'))\n ->add('receivers', 'entity', array('class'=>'ecloreuserBundle:User',\n 'multiple'=>true))\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n}/userBundle/Resources/config/params_choicelist.yml\nparameters:\n PAStatus:\n PENDING: 'En attente de validation'\n VALIDATED: 'Validée'\n REJECTED: 'Rejetée'\n TERMINATED: 'Clôturée'\n MARKED: 'Avis jeune enregistré'\n \n Notification:\n MARK: 'Avis jeune'\n CONTACT: 'Demande de contact'\n RECOMMENDATION: 'Recommandation'\n \n privacyLevels:\n 0: 'Tout le monde peut voir mon profil réduit, mais pas mes activités'\n 1: 'Mes contacts peuvent voir mon profil complet et mes activités'\n 2: 'Invisible'\n \n investmentRequired:\n 1: 'Week-end seulement'\n 0: 'Soirs de semaine et Week-end'\n 2: 'Jours de semaine et WE'\n/userBundle/Resources/views/menu_user.html.twig\n
    \n {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}\n \n \n \n \n {%if app.user.hasRole('ROLE_YOUNG') %}\n \n \n {%elseif app.user.hasRole('ROLE_ASSOM') %}\n \n \n \n {%endif%}\n {%else%}\n \n \n {%endif%}\n
    \n/userBundle/Resources/views/Projects/rechercher.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Rechercher un projet{% endblock %}\n\n{%set color='bleu'%}\n{%set first='Les projets'%}\n{%set second='Rechercher un projet'%}\n\n\n{% block content %}\n

    Rechercher un projet

    \n
    Chargement en cours...\n \n
    \n\n\n\n
    \n
    \n\n\n\n
    \n \n \n\n\n\n\n\n{% endblock %}\n/userBundle/Resources/views/Registration/waitConfirmation.html.twig\n{% extends \"ecloreuserBundle::layout.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{% block fos_user_content %}\nBienvenue {{app.user.username}} !
    \nVuos venez d'enregistrer votre profil.\n
    \nUne fois que l'équipe du réseau l'aura validé, vous aurez accès à l'ensemble des fonctionnalités du user.\n
    Un email vous sera envoyé dès que votre profil aura été validé.\n{% endblock fos_user_content %}\n/userBundle/Resources/views/Members/display-inst.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n\n{% block content %}\n\n\n\t

    {{inst.institutionName}}

    \n\t
    {{inst.location}}
    \n\t{{inst.description}}\n

    \n{%if inst.youngs|length ==0 %}\nAucun jeune n'est inscrit dans cette institution.\n{%else%}\n\tJeunes inscrits dans cette institution: \n\t

      \n\t{%for membre in inst.youngs %}\n\t\t{%if membre.user.privacyLevel != 2 %}\n\t\t
    • {{membre.user|printName}}
    • \n\t\t{%endif%}\n\t{%endfor%}\n\t
    \n{%endif%}\n

    \n

    \n{%if inst.members|length ==0 %}\nAucun membre n'est inscrit dans cette institution.\n{%else%}\n\tMembres de cette institution: \n\t

      \n\t{%for membre in inst.members %}\n\t\t{%if membre.user.privacyLevel != 2 %}\n\t\t
    • {{membre.user|printName}}
    • \n\t\t{%endif%}\n\t{%endfor%}\n\t
    \n{%endif%}\n

    \n
    \n\n{% endblock %}\n/userBundle/Entity/NewsPost.php\npictures = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n public function addPicture(\\eclore\\userBundle\\Entity\\Image $image) \n {\n $this->pictures[] = $image;\n }\n \n public function removePicture(\\eclore\\userBundle\\Entity\\Image $image) \n {\n $this->pictures->removeElement($image);\n }\n\n public function getPictures()\n {\n return $this->pictures;\n }\n \n public function setPictures($pics)\n {\n foreach ($pics as $pic) {\n $this->addPicture($pic);\n }\n }\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n\n /**\n * Set title\n *\n * @param string $title\n * @return NewsPost\n */\n public function setTitle($title)\n {\n $this->title = $title;\n\n return $this;\n }\n\n /**\n * Get title\n *\n * @return string \n */\n public function getTitle()\n {\n return $this->title;\n }\n\n /**\n * Set publishDate\n *\n * @param \\DateTime $date\n * @return NewsPost\n */\n public function setPublishDate($publishDate)\n {\n $this->publishDate = $publishDate;\n\n return $this;\n }\n\n /**\n * Get publishDate\n *\n * @return \\DateTime \n */\n public function getPublishDate()\n {\n return $this->publishDate;\n }\n \n public function setEndDate($endDate)\n {\n $this->endDate = $endDate;\n\n return $this;\n }\n\n public function getEndDate()\n {\n return $this->endDate;\n }\n\n /**\n * Set header\n *\n * @param string $header\n * @return NewsPost\n */\n public function setHeader($header)\n {\n $this->header = $header;\n\n return $this;\n }\n\n /**\n * Get header\n *\n * @return string \n */\n public function getHeader()\n {\n return $this->header;\n }\n\n /**\n * Set text\n *\n * @param string $text\n * @return NewsPost\n */\n public function setText($text)\n {\n $this->text = $text;\n\n return $this;\n }\n \n\n /**\n * Get text\n *\n * @return string \n */\n public function getText()\n {\n return $this->text;\n }\n}\n/userBundle/Controller/StaticController.php\ngetDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Project');\n $projs = $repository->findBy(array(), array('id'=>'DESC'));\n $repository = $em->getRepository('ecloreuserBundle:NewsPost');\n $posts = $repository->findBy(array(), array('id'=>'DESC'));\n \n return $this->render('ecloreuserBundle::index.html.twig', array('projs'=>$projs, 'posts'=>$posts));\n }\n \n public function displayNewsPostAction($id)\n {\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:NewsPost');\n $post = $repository->find($id);\n \n if(!$post){\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette page n\\'existe pas!');\n return $this->redirect($this->generateUrl('ecloreuser_homepage'));\n }\n \n return $this->render('ecloreuserBundle:Static:newspost.html.twig',\n array('post' => $post));\n \n }\npublic function displayNewsPostsAction()\n {\n $em = $this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:NewsPost');\n $posts = $repository->getCurrentNewsPosts();\n \n return $this->render('ecloreuserBundle:Static:newsposts.html.twig',\n array('posts' => $posts));\n \n }\n \n}\n/userBundle/Resources/views/Timeline/verbs/registered.html.twig\n
  • \n{{ timeline_component_render(timeline, 'subject') }}\na rejoint le réseau.\n
  • /userBundle/Resources/views/Young/manage-application.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mes projets'%}\n{%set second='Manager ma candidature'%}\n\n{% block content %}\n\n

    Administration de votre candidature au projet {{pa.project}}

    \n
    \nEtat de la candidature: {{pa.status|PAStatus}}. La dernière modification remonte au {{pa.statusDate|date(\"d/m/Y\")}}.\n\n{%if pa.message|length >0 %}\n

    Derniere communication :

    \n{{pa.message}}\n\n{%endif%}\n\n \n{% if pa.status == \"TERMINATED\" %}\n{{ form(form) }}\n{%endif%}\n\n{% endblock %}\n/userBundle/Form/temp web/AssoEditType.php\nadd('associationName', 'text', array('label' => \" Nom de l'association :\"))\n ->add('description','textarea', array('label' => \" Quelles sont les activités de votre association ?\"))\n ->add('location', 'text', array('attr' => array('class'=>'addressPickerInput') , 'label' => \"Adresse de l'association\") )\n ->add('headshot', new ImageType(), array('required'=>false, , 'label' => \"Logo de l'association\"))\n ->add('save', 'submit')\n ;\n }\npublic function setDefaultOptions(OptionsResolverInterface $resolver)\n {\n $resolver->setDefaults(array(\n 'data_class' => 'eclore\\userBundle\\Entity\\Association'\n ));\n }\n\n public function getName()\n {\n return 'eclore_user_assoedittype';\n }\n}/userBundle/Resources/views/Static/en-construction.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='vert'%}\n{%set first='Réseau Eclore'%}\n\n{% block content %}\n
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t

    Cette page est encore en construction

    \n\t\t\t\t\t\tRetournez à la page précédente\t\t\t\t\t\t\t\t\t\n\t\t\t\t
    \n{% endblock %}/userBundle/Admin/UserAdmin.php\nadd('username')\n ->add('email')\n ->add('enabled')\n ->add('lastLogin')\n ->add('locked')\n ->add('expired')\n ->add('roles')\n ->add('credentialsExpired')\n ->add('birthDate')\n ->add('lastName')\n ->add('firstName')\n ->add('registrationDate')\n ->add('mobile')\n ->add('location')\n ->add('lastSeenDate')\n ;\n }*/\n\n /**\n * @param ListMapper $listMapper\n */\n protected function configureListFields(ListMapper $listMapper)\n {$roles;\n foreach($this->getConfigurationPool()->getContainer()\n ->getParameter('security.role_hierarchy.roles') as $key=>$value)\n {\n $roles[$key]=$key;\n }\n $listMapper\n ->add('username')\n ->add('email')\n ->add('young')\n ->add('instM')\n ->add('assoM')\n ->add('quality')\n ->add('enabled')\n ->add('locked')\n ->add('expired')\n ->add('albums') \n ->add('roles', 'choice', array('choices'=>$roles,'multiple'=>true ))\n ->add('credentialsExpired')\n ->add('lastName')\n ->add('firstName') \n ->add('birthDate', 'date') \n ->add('contacts', 'entity', array('class'=>'ecloreuserBundle:User',\n 'multiple'=>true, 'required' =>false)) \n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n\n /**\n * @param FormMapper $formMapper\n */\n protected function configureFormFields(FormMapper $formMapper)\n {$roles;\n foreach($this->getConfigurationPool()->getContainer()\n ->getParameter('security.role_hierarchy.roles') as $key=>$value)\n {\n $roles[$key]=$key;\n }\n \n $headshot = $this->getSubject()->getHeadshot();\n $fileFieldOptions = array('required'=>false, 'help'=>'Pas de photo');\n if ($headshot && ($webPath = $headshot->getWebPath())) {\n $container = $this->getConfigurationPool()->getContainer();\n $fullPath = $container->get('request')->getBasePath().'/'.$webPath;\n $fileFieldOptions['help'] = '';\n }\n \n \n $formMapper\n ->add('username')\n ->add('usernameCanonical')\n ->add('young', 'entity', array('class'=>'ecloreuserBundle:Young',\n 'required' => false ) )\n ->add('instM', 'entity', array('class'=>'ecloreuserBundle:InstitutionMember',\n 'required' => false ) )\n ->add('assoM', 'entity', array('class'=>'ecloreuserBundle:AssociationMember',\n 'required' => false ) )\n ->add('email')\n ->add('quality')\n ->add('emailCanonical')\n ->add('enabled', 'checkbox', array('required' => false ))\n ->add('locked', 'checkbox', array('required' => false ))\n ->add('expired', 'checkbox', array('required' => false ))\n ->add('roles', 'choice', array('choices'=>$roles,'multiple'=>true ))\n ->add('credentialsExpired', 'checkbox', array('required' => false ))\n ->add('credentialsExpireAt', 'date', array( 'widget' => 'single_text', 'required'=>false))\n ->add('birthDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\")-100, (int)date(\"Y\"))))\n ->add('lastName')\n ->add('firstName')\n ->add('mobile')\n ->add('headshot', new ImageType(), $fileFieldOptions)\n ->add('lastSeenDate', 'date')\n ->add('contacts', 'entity', array('class'=>'ecloreuserBundle:User',\n 'multiple'=>true, 'required' =>false))\n ;\n }\n\n /**\n * @param ShowMapper $showMapper\n */\n protected function configureShowFields(ShowMapper $showMapper)\n {\n $showMapper\n ->add('username')\n ->add('usernameCanonical')\n ->add('email')\n ->add('emailCanonical')\n ->add('enabled')\n ->add('quality')\n ->add('salt')\n ->add('password')\n ->add('lastLogin', 'date')\n ->add('locked')\n ->add('expired')\n ->add('expiresAt', 'date')\n ->add('confirmationToken')\n ->add('passwordRequestedAt', 'date')\n ->add('roles')\n ->add('credentialsExpired')\n ->add('credentialsExpireAt', 'date')\n ->add('id')\n ->add('birthDate', 'date')\n ->add('lastName')\n ->add('firstName')\n ->add('registrationDate', 'date')\n ->add('mobile')\n ->add('headshot', 'entity', array('class'=>'ecloreuserBundle:Image',\n 'required' =>false, 'template' => 'ecloreuserBundle:Admin:show_headshot.html.twig'))\n ->add('lastSeenDate', 'date')\n ->add('contacts', 'entity', array('class'=>'ecloreuserBundle:User',\n 'multiple'=>true, 'required' =>false))\n ;\n }\n}\n/userBundle/Resources/public/js/lambda/anim_lambda.js\n$(function () {\n\n\t $('.wrapper_el_projets').click(function(){\n\t\t\t$('.wrapper_el_projets').css({\"border\" : \"\", \"border-radius\": \"\", \"box-shadow\" : \" 1px 1px 2px 2px #fff\" });\n\t\t\t$(this).css({\"border\" : \" 1px solid #ccc\", \"border-radius\": \" 5px\", \"box-shadow\" : \" 1px 1px 2px 2px #ccc\" });\n\t\t\t$('.projet_el_liste_bas').css({\"display\" : \"none\"});\n\t\t\t$(this).children('.expandlink').children('.projet_el_liste_bas').css('display','block');\n });\n\t\n\t\n\t $(\"#defprofil>form>div\").hide();\n\t\n $('#fos_choix_type_membre').change(function(){\n\t $(\"#defprofil>form>div\").fadeOut(100);\n if ($('#fos_choix_type_membre').val() == 0){ \n $(\"#young\").fadeIn(100); \n }\n\t\tif ($('#fos_choix_type_membre').val() == 1){ \n $(\"#instM\").fadeIn(100); \n }\n\t if ($('#fos_choix_type_membre').val() == 2){ \n $(\"#assoM\").fadeIn(100); \n }\n\t\t\n })\n\t\n $('#assoM_associations').data(\"placeholder\",\"Rechercher...\").chosen({width: \"60%\"});\n $('#young_institutions').data(\"placeholder\",\"Rechercher...\").chosen({width: \"60%\"});\n $('#instM_institutions').data(\"placeholder\",\"Rechercher...\").chosen({width: \"60%\"});\n});\n/userBundle/Timeline/TimelineEvents.php\n/userBundle/Resources/views/Timeline/verbs/take_part.html.twig\n
  • \n{{ timeline_component_render(timeline, 'subject') }}\nparticipe au projet\n{{ timeline_component_render(timeline,'complement') }}\n
  • /userBundle/Timeline/TimelineListener.php\ncontainer = $container;\n }\n \n public function onContactAck(ContactAckEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getAckUser());\n $complement = $actionManager->findOrCreateComponent($event->getRequestingUser());\n $action = $actionManager->create($subject, 'contact', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onValidatedPA(PAEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getPA()->getYoung()->getUser());\n $complement = $actionManager->findOrCreateComponent($event->getPA()->getProject());\n $action = $actionManager->create($subject, 'take_part', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onNewPA(PAEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getPA()->getYoung()->getUser());\n $complement = $actionManager->findOrCreateComponent($event->getPA()->getProject());\n $action = $actionManager->create($subject, 'apply', array('complement' => $complement));\n $actionManager->updateAction($action);\n //send email email-newPA.html.twig\n /*\n $template = $this->container->get('twig')->loadTemplate('ecloreuserBundle:AssoM:email-newPA.html.twig');\n $subject = $template->renderBlock('subject', array('project'=>$event->getPA()->getProject()));\n $htmlBody = $template->renderBlock('body_html', array('project'=>$event->getPA()->getProject()));\n\n $resps_emails = []\n foreach($event->getPA()->getProject()->getResponsibles() as $resp)\n $resps_emails[]=$resp->getUser()->getEmail();\n \n $message = \\Swift_Message::newInstance()\n ->setSubject($subject)\n ->setFrom('')\n ->setTo($resps_emails)\n ->setBody($htmlBody, 'text/html');\n $this->container->get('mailer')->send($message);\n */\n }\n \n public function onRejectedPA(PAEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getPA()->getYoung()->getUser());\n $complement = $actionManager->findOrCreateComponent($event->getPA()->getProject());\n $action = $actionManager->create($subject, 'be_rejected', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onNewProject(NewProjectEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getProject()->getAssociation());\n $complement = $actionManager->findOrCreateComponent($event->getProject());\n $action = $actionManager->create($subject, 'create_project', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onMarkedProject(MarkedEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getPA()->getYoung()->getUser());\n $complement = $actionManager->findOrCreateComponent($event->getPA()->getProject());\n $action = $actionManager->create($subject, 'mark_project', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onMarkedYoung(MarkedEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getPA()->getProject()->getAssociation());\n $complement = $actionManager->findOrCreateComponent($event->getPA()->getYoung()->getUser());\n $action = $actionManager->create($subject, 'mark_young', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onNewUser(NewUserEvent $event)\n {\n $actionManager = $this->container->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($event->getUser());\n $complement = $actionManager->findOrCreateComponent($event->getUser());\n $action = $actionManager->create($subject, 'registered', array('complement' => $complement));\n $actionManager->updateAction($action);\n }\n \n public function onPendingValidation(Symfony\\Component\\EventDispatcher\\Event $event)\n {\n $message = \\Swift_Message::newInstance();\n $template = $this->container->get('twig')->loadTemplate('ecloreuserBundle:Admin:email-pending-validation.html.twig');\n $subject = $template->renderBlock('subject', array('subject' => 'subject'));\n $htmlBody = $template->renderBlock('body_html',array('body_html' => 'body_html'));\n\n $message = \\Swift_Message::newInstance()\n ->setSubject($subject)\n ->setFrom('')\n ->setTo('')\n ->setBody($htmlBody, 'text/html');\n $this->container->get('mailer')->send($message);\n }\n\n}\n/userBundle/Resources/views/Static/newspost.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='orange'%}\n{%set first='Actualité'%}\n{%set second= post.title %}\n\n{% block content %}\n\n\n
    \n\t{#{%for pic in post.pictures %}#}\n\t {%if post.pictures|length >0 %}\n\t\n\t{%endif%}\n\t{#{%endfor%}#}\t\t\t\n
    \n\n\n
    \n\t

    {{post.header}}

    \n\t Publiée le {{post.publishDate|date(\"m-d-Y\")}}\t
    \n\t{{post.text}}\t\t\t\t\t\t\n
    \n\n\n{% endblock %}/userBundle/Entity/Notification.php\ninitDate = new \\DateTime();\n $this->receivers = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n }\n\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n\n /**\n * Set sender\n *\n * @param \\stdClass $sender\n * @return Notification\n */\n public function setSender($sender)\n {\n $this->sender = $sender;\n $sender->addNotification($this);\n return $this;\n }\n\n /**\n * Get sender\n *\n * @return \\stdClass \n */\n public function getSender()\n {\n return $this->sender;\n }\n\n\n /**\n * Set type\n *\n * @param string $type\n * @return Notification\n */\n public function setType($type)\n {\n $this->type = $type;\n\n return $this;\n }\n\n /**\n * Get type\n *\n * @return string \n */\n public function getType()\n {\n return $this->type;\n }\n\n /**\n * Set initDate\n *\n * @param \\DateTime $initDate\n * @return Notification\n */\n public function setInitDate($initDate)\n {\n $this->initDate = $initDate;\n\n return $this;\n }\n\n /**\n * Get initDate\n *\n * @return \\DateTime \n */\n public function getInitDate()\n {\n return $this->initDate;\n }\n\n /**\n * Set message\n *\n * @param string $message\n * @return Notification\n */\n public function setMessage($message)\n {\n $this->message = $message;\n\n return $this;\n }\n\n /**\n * Get message\n *\n * @return string \n */\n public function getMessage()\n {\n return $this->message;\n }\n \n public function setProject($project)\n {\n $this->project = $project;\n\n return $this;\n }\n\n /**\n * Get message\n *\n * @return string \n */\n public function getProject()\n {\n return $this->project;\n }\n \n public function addReceiver($receiver)\n {\n $this->receivers[] = $receiver;\n }\n \n /**\n * Remove institutions\n *\n * @param \\eclore\\userBundle\\Entity\\User $receiver\n */\n public function removeReceiver($receiver) \n {\n $this->receivers->removeElement($receiver);\n }\n \n /**\n * Get institutions\n *\n * @return array \n */\n public function getReceivers()\n {\n return $this->receivers;\n }\n}\n/userBundle/Resources/views/AssoM/manage-project.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
    \n{% set rejected = proj.PAByStatus('REJECTED') %}\n{% set validated = proj.PAByStatus('VALIDATED') %}\n{% set pending = proj.PAByStatus('PENDING') %}\n\n\n

    Espace d'administration du projet {{proj.projectName}}.

    \n\n\n \n
    \n Modifier ce projet \n
    \n\n

    Statut du projet

    \n{%if not proj.enabled%}\n Ce projet est en attente de validation de la part des administrateurs. Vous serez averti de sa validation.\n{%else%}\n\n\n
    \n\t
    \n {%if proj.isFinished %}\n Terminé.\n {%elseif (not proj.isFinished) and proj.isStarted %}\n En cours. \n {%else%}\n Publié.\n {%endif%}\n
    \n\n\n
    \n
    \n {%if not proj.isFinished%}\n {%if proj.isFull %}Ce projet possède le nombre de participants requis.\n {%else%}{{proj.required - proj.getPAByStatus('VALIDATED')|length}} participants encore souhaités.\n {%endif%}\n {%else%} \n Merci de clôturer les candidatures des jeunes ayant participé.
    \n {%endif%}\n
    \n\n
    \n\t
    \n {%if proj.isFinished%}\n\t\n {% if validated|length >0 %}\n Candidatures à clôturer:\n
      \n {% for pa in validated %}\n
    • {{pa.young}} \n Clôturer
    • \n {% endfor %}\n
    \n {% else %}\n \n {% endif %}\n {%else%}\n\t\t\n {% if pending|length >0 %}\n
    \n Candidatures à traiter:\n
      \n {% for pa in pending %}\n
    • {{pa.young}} Manager
    • \n {% endfor %}\n
    \n {% else %}\n Pas de candidatures à traiter.\n {% endif %}\n
    \n {% if validated|length >0 %}\n Candidatures validées:\n
      \n {% for pa in validated %}\n
    • {{pa.young}} \n Manager
    • \n {% endfor %}\n
    \n {% else %}\n {# Pas de candidatures validées. #}\n {% endif %}\n
    \n {% if rejected|length >0 %}\n Candidatures rejetées:\n
      \n {% for pa in rejected %}\n
    • {{pa.young}} Manager
    • \n {% endfor %}\n
    \n {% else %}\n {# Pas de candidatures rejetées. #}\n {% endif %}\n\n {%endif%}\n\t
    \nSi vous souhaitez supprimer ce projet, ou ajouter des responsables, merci de contacter le réseau à \n
    \n
    \n\t\n{%endif%}\n\n
    \n{% endblock %}\n/userBundle/Resources/views/AssoM/email-newPA.html.twig\n{% block subject %}\nNouvelle candidature au projet {{project.projectName}}\n{% endblock %}\n\n{% block body_html %}\nà mettre à jour avec le design prévu\n{% endblock %}\n/userBundle/Resources/views/Admin/home.html.twig\n\n{% block title %}Administration{% endblock%}\n\n{% block content %}\n{% for key, messages in app.session.flashbag.all() %}\n {% for message in messages %}\n
    \n {{ message|trans({}, 'FOSUserBundle') }}\n
    \n {% endfor %}\n{% endfor %} \n\n\nAccéder à la plateforme de gestion des enregistrements\n
    \n{% if assoMs |length>0 or instMs|length>0 %}\n

    Profils en attente de validation

    \n {% if assoMs |length>0 %}\n

    Membres d'associations

    \n \n {% for assoM in assoMs %}\n \n \n \n {% endfor%}\n
    {{assoM}}{{assoM.user.quality}}{{assoM.user.registrationDate|date(\"m-d-Y\")}}Valider
    \n {%endif%}\n
    \n {% if instMs |length>0%}\n

    Membres d'institutions

    \n \n {% for instM in instMs %}\n \n \n \n {% endfor%}\n
    {{instM}}{{instM.user.quality}}{{instM.user.registrationDate|date(\"m-d-Y\")}}Valider
    \n {%endif%}\n{%endif%}\n \n{% if projects|length>0 %}\n
    \n

    Projets en attente de validation

    \n \n {% for proj in projects %}\n \n \n \n {% endfor%}\n
    {{proj}}{{proj.association}}{{proj.description}}{{proj.responsibles|join(', ') }}{{proj.startDate|date(\"m-d-Y\")}}Valider
    \n{%endif%}\n\n{% endblock %}/userBundle/Resources/views/Block/overviewBlock.html.twig\n{% extends 'SonataBlockBundle:Block:block_base.html.twig' %}\n{% block block %}\n\n
    Bienvenue dans la plateforme de gestion des enregistrements
    \n\nSont enregistrés à ce jour:\n
      \n
    • {{count.proj}} projets
    • \n
    • {{count.pa}} candidatures
    • \n
    • {{count.young}} jeunes
    • \n
    • {{count.image}} images
    • \n
    • {{count.asso}} associations totalisant {{count.assoM}} membres
    • \n
    • {{count.inst}} institutions totalisant {{count.instM}} membres
    • \n
    \n

    \nPage de démarrage\n{% endblock %}/userBundle/Block/overviewBlockService.php\nem = $entityManager;\n }\n \n public function execute(BlockContextInterface $blockContext, Response $response = null)\n {\n $data = array('proj'=>'ecloreuserBundle:Project',\n 'pa'=>'ecloreuserBundle:ProjectApplication',\n 'assoM'=>'ecloreuserBundle:AssociationMember',\n 'instM'=>'ecloreuserBundle:InstitutionMember',\n 'asso'=>'ecloreuserBundle:Association',\n 'inst'=>'ecloreuserBundle:Institution',\n 'young'=>'ecloreuserBundle:Young',\n 'image'=>'ecloreuserBundle:Image');\n $count;\n foreach($data as $key=>$value)\n $count[$key]= $this->em->getRepository($value)\n ->createQueryBuilder('p')\n ->select('COUNT(p)')\n ->getQuery()\n ->getSingleScalarResult();\n return $this->renderResponse($blockContext->getTemplate(), array(\n 'block' => $blockContext->getBlock(),\n 'settings' => $blockContext->getSettings(),\n 'count' => $count\n ), $response);\n }\n\n /**\n * {@inheritdoc}\n */\n public function validateBlock(ErrorElement $errorElement, BlockInterface $block)\n {\n // TODO: Implement validateBlock() method.\n }\n\n /**\n * {@inheritdoc}\n */\n public function getName()\n {\n return 'Overview';\n }\n\n /**\n * {@inheritdoc}\n */\n public function setDefaultSettings(OptionsResolverInterface $resolver)\n {\n $resolver->setDefaults(array(\n 'template' => 'ecloreuserBundle:Block:overviewBlock.html.twig'\n ));\n }\n}\n/userBundle/Resources/public/js/projects/Temp web/2_map.js\nvar geocoder;\nvar map;\nvar objects;\n\nvar labels=[];\nvar associations=[];\nvar markers = [];\nvar infowindows = [];\nvar colors = [\"808080\", \"336666\", \"357723\"];\ndefault_location=new google.maps.LatLng(48.817348,2.371005);\nvar previousOpen=-1;\n\nfunction initialize() {\n var mapOptions = {\n zoom: 10,\n center: default_location,\n\tscaleControl: true\n }\n map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);\n}\n\n//functions for displaying and removing markers\nfunction addMarker(obj) {\n lat=obj.lat\n lng=obj.lng\n descr=obj.description+\"
    Plus de détails...\"\n titre =obj.project_name\n id = obj.id\n start_date = new Date(obj.start_date*1000);\n end_date = new Date(obj.end_date*1000);\n asso = obj.association.associationName\n var content = ''+titre+' ('+asso+') du '+start_date.toLocaleDateString()+' au '+end_date.toLocaleDateString()+'
    '+descr\n var infowindow = new google.maps.InfoWindow({content: content, maxWidth: 500});\n var marker = new google.maps.Marker({\n position: new google.maps.LatLng(lat,lng),\n map: map,\n icon: \"http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|\"+colors[id % colors.length],\n title: titre});\n google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker);});\n markers[id]=marker\n infowindows[id]=infowindow\n}\n\nfunction setAllMap(map) {\n for (var key in markers) {\n markers[key].setMap(map);\n }\n}\n\nfunction deleteMarkers() {\n setAllMap(null);\n markers = [];\n infowindows = [];\n}\n\nfunction codeAddress(address) {\n //returns [lat, lng] from adress\n return geocoder.geocode( { 'address': address}, function(results, status) {\n if (status == google.maps.GeocoderStatus.OK) {\n map.setCenter(new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng()));\n map.setZoom(10)\n\n } else {\n alert(\"Geocode was not successful for the following reason: \" + status);\n }\n });\n }\n \n function showMarkers(){\n deleteMarkers() \n var filteredDivs = $(\"#example div.item \"); \n $.each(filteredDivs, function (index, div) {\n addMarker(objects[parseInt(div.attr('id'))])\n });\n setAllMap(map)\n }\n \nfunction getDuration(obj){\nreturn parseInt((obj.end_date - obj.start_date)/86400.0)\n}\n\nfunction sortJSON(data, key, way) {\n data.sort(function(a, b) {\n var x;\n var y;\n switch(key){\n case 'duration':\n x = getDuration(a);\n y = getDuration(b);\n break;\n case 'association':\n x = a.association.associationName;\n y = b.association.associationName;\n break;\n default:\n x = a[key];\n y = b[key];\n }\n if (way === '+' ) { return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }\n if (way === '-') { return ((x > y) ? -1 : ((x < y) ? 1 : 0)); }\n });\n return data\n}\n\nfunction filterData(data){\nif($(\"#label_select\").val() != null)\n data = $.grep(data, function(proj, i){return $(\"#label_select\").val().indexOf(proj.labels.id+\"\") > -1});\nif($(\"#association_select\").val() != null)\n data = $.grep(data, function(proj, i){return $(\"#association_select\").val().indexOf(proj.association.id+\"\") > -1});\n return data\n}\n\nfunction sortData(data){\ncritere = $('#tri').val();\ndata = sortJSON(data, critere.substring(0, critere.length-1), critere.charAt(critere.length-1));\nreturn data\n}\n \nfunction displayProjects(data){\n data = filterData(data)\n data = sortData(data)\n deleteMarkers()\n $(\"#results\").empty()\n $.each(data, function(idx, obj){\n addMarker(obj)\n start_date = new Date(obj.start_date*1000)\n $(\"#results\").append(\n \n \n ' '\n) \n });\n if(data.length==0)$(\"#results\").append('Pas de résultats.');\n}\n\nfunction populate(id, table, id_select, option){\n if(table.indexOf(id) == -1){\n $(id_select).append(option)\n table.push(id)\n }\n}\n\n$(document).ready(function() { \n \n google.maps.event.addDomListener(window, 'load', initialize);\n geocoder = new google.maps.Geocoder();\n var request = $.ajax({\n url: url,\n type: \"POST\",\n dataType: \"json\"\n });\n //chargement resultats\n request.done(function( data ) {\n objects = data\n $.each(data, function(idx, obj){\n //populate label selection tool\n populate(obj.labels.id, labels, \"#label_select\", \"\")\n populate(obj.association.id, associations, \"#association_select\", \"\")\n });\n displayProjects(data)\n \n //label selection tool\n $(\"#label_select\").change(function(){displayProjects(data)});\n \n //association selection tool\n $(\"#association_select\").change(function(){displayProjects(data)});\n \n //tri tool\n $(\"#tri\").change(function(){displayProjects(data)});\n \n //centrer la carte sur ce projet et ouvrir l'infowindow\n $(\"#results ul.item \").click( function() {\n var i = parseInt($(this).attr('id'))\n map.setCenter(markers[i].getPosition());\n if(previousOpen != -1){infowindows[previousOpen].close();}\n infowindows[i].open(map,markers[i]);\n previousOpen = i\n }); \n \n //showMarkers()\n \n $(\"#loading\").fadeOut() \n $(\"#search_zone\").fadeIn() \n $(\"#label_select\").chosen();\n $(\"#association_select\").chosen();\n $(\"#tri\").data(\"placeholder\",\"Trier les projets...\").chosen();\n });\n \n \n\n request.fail(function( jqXHR, textStatus ) {\n $('#results').html( \"Request failed: \" + textStatus+jqXHR.status );\n $(\"#loading\").fadeOut() \n $(\"#search_zone\").fadeIn() \n });\n \n $(\"#loc_submit\").click(function(){\n if($(\"#loc\").val() !=\"\"){\n codeAddress($(\"#loc\").val());\n }\n });\n \n $(\"#loc\").keyup(function(event){\n if(event.keyCode == 13){\n $(\"#loc_submit\").click();\n }\n});\n \n \n \n });/userBundle/Resources/views/Static/newsposts.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='orange'%}\n{%set first='Actualité'%}\n{%set second='Toutes les actualités' %}\n\n{% block content %}\n\n\n
    \n\n\n{%for post in posts %}\npost\n{%endfor%}\n\n\n{% endblock %}\n/userBundle/Resources/views/Members/display-asso.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n
    \n\n
    \n
    \n\t

    {{asso.associationName}}

    \n\t
    {{asso.location}}
    \n\t{{asso.description}}\n

    \n{%if asso.members|length ==0 %}\nCette association n'a pas de membres.\n{%else%}\n\tMembres de cette association: \n\t

      \n\t{%for membre in asso.members %}\n\t\t{%if membre.user.privacyLevel != 2 %}\n\t\t
    • {{membre.user|printName}}
    • \n\t\t{%endif%}\n\t{%endfor%}\n\t
    \n{%endif%}\n

    \n
    \n{% endblock %}\n/userBundle/Form/ProjectRegisterType.php\nremove('projectApplications');\n $builder->remove('responsibles');\n\n }\n \n public function getName()\n {\n return 'eclore_userbundle_projectregistertype';\n }\n \n}/userBundle/Entity/User.php\ncontacts = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->notifications = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->albums = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->lastSeenDate = new \\DateTime();\n $this->registrationDate = new \\DateTime();\n }\n \n public function getHeadshot()\n {\n return $this->headshot;\n }\n \n public function setHeadshot(\\eclore\\userBundle\\Entity\\Image $headshot)\n {\n return $this->headshot = $headshot;\n }\n \n public function getPrivacyLevel()\n {\n return $this->privacyLevel;\n }\n \n public function setPrivacyLevel($lvl)\n {\n return $this->privacyLevel = $lvl;\n }\n \n public function getYoung()\n {\n return $this->young;\n }\n \n public function getAssoM()\n {\n return $this->assoM;\n }\n \n public function getInstM()\n {\n return $this->instM;\n }\n \n public function setYoung(\\eclore\\userBundle\\Entity\\Young $young)\n {\n $this->young = $young;\n return $this;\n }\n \n public function setAssoM(\\eclore\\userBundle\\Entity\\AssociationMember $assoM)\n {\n $this->assoM = $assoM;\n return $this;\n }\n \n public function setInstM(\\eclore\\userBundle\\Entity\\InstitutionMember $instM)\n {\n $this->instM = $instM;\n return $this;\n }\n \n public function __toString()\n {\n return $this->getFirstName().\" \".$this->getLastName();\n }\n \n public function getExpiresAt()\n {\n return $this->expiresAt;\n }\n \n public function getCredentialsExpireAt()\n {\n return $this->credentialsExpireAt;\n }\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n\n /**\n * Set birthDate\n *\n * @param \\DateTime $birthDate\n * @return Member\n */\n public function setBirthDate($birthDate)\n {\n $this->birthDate = $birthDate;\n\n return $this;\n }\n\n /**\n * Get birthDate\n *\n * @return \\DateTime \n */\n public function getBirthDate()\n {\n return $this->birthDate;\n }\n\n /**\n * Set lastName\n *\n * @param string $lastName\n * @return Member\n */\n public function setLastName($lastName)\n {\n $this->lastName = ucfirst($lastName);\n\n return $this;\n }\n\n /**\n * Get lastName\n *\n * @return string \n */\n public function getLastName()\n {\n return $this->lastName;\n }\n\n /**\n * Set firstName\n *\n * @param string $firstName\n * @return Member\n */\n public function setFirstName($firstName)\n {\n $this->firstName = ucfirst($firstName);\n\n return $this;\n }\n\n /**\n * Get firstName\n *\n * @return string \n */\n public function getFirstName()\n {\n return $this->firstName;\n }\n\n /**\n * Set registrationDate\n *\n * @param \\DateTime $registrationDate\n * @return Member\n */\n public function setRegistrationDate($registrationDate)\n {\n $this->registrationDate = $registrationDate;\n\n return $this;\n }\n\n /**\n * Get registrationDate\n *\n * @return \\DateTime \n */\n public function getRegistrationDate()\n {\n return $this->registrationDate;\n }\n\n /**\n * Set mobile\n *\n * @param string $mobile\n * @return Member\n */\n public function setMobile($mobile)\n {\n $this->mobile = $mobile;\n\n return $this;\n }\n\n /**\n * Get mobile\n *\n * @return string \n */\n public function getMobile()\n {\n return $this->mobile;\n }\n\n /**\n * Set lastSeenDate\n *\n * @param \\DateTime $lastSeenDate\n * @return Member\n */\n public function setLastSeenDate($lastSeenDate)\n {\n $this->lastSeenDate = $lastSeenDate;\n\n return $this;\n }\n\n /**\n * Get lastSeenDate\n *\n * @return \\DateTime \n */\n public function getLastSeenDate()\n {\n return $this->lastSeenDate;\n }\n \n /**\n * Add contacts\n *\n * @param eclore\\userBundle\\Entity\\User $user\n */\n \n public function addContact(\\eclore\\userBundle\\Entity\\User $user) \n {\n if(!$this->contacts->contains($user))\n $this->contacts[] = $user;\n }\n \n /**\n * Remove contacts\n *\n * @param eclore\\userBundle\\Entity\\User $user\n */\n public function removeContact(\\eclore\\userBundle\\Entity\\User $user) \n {\n $this->contacts->removeElement($user);\n }\n\n /**\n * Get contacts\n *\n * @return array \n */\n public function getContacts()\n {\n return $this->contacts;\n }\n \n public function addAlbum(\\eclore\\userBundle\\Entity\\Album $album) \n {\n $this->albums[] = $album;\n }\n \n public function removeAlbum(\\eclore\\userBundle\\Entity\\Album $album) \n {\n $this->albums->removeElement($album);\n }\n\n public function getAlbums()\n {\n return $this->albums;\n }\n \n public function addNotification(\\eclore\\userBundle\\Entity\\Notification $notification) \n {\n $this->notifications[] = $notification;\n }\n \n public function removeNotification(\\eclore\\userBundle\\Entity\\Notification $notification) \n {\n $this->notifications->removeElement($notification);\n }\n\n public function getNotifications()\n {\n return $this->notifications;\n }\n \n /**\n * Set quality\n *\n * @param string $quality\n * @return User\n */\n public function setQuality($quality)\n {\n $this->quality = $quality;\n\n return $this;\n }\n\n /**\n * Get quality\n *\n * @return string \n */\n public function getQuality()\n {\n return $this->quality;\n }\n \n public function getAge()\n {\n $today = new \\DateTime;\n return (int)(($today->format('U') - $this->getBirthDate()->format('U'))/(365*24*3600));\n }\n \n public function getContactsByRole($role)\n {\n $res=array();\n foreach($this->getContacts() as $contact)\n if($contact->hasRole($role))\n $res[]=$contact;\n return $res;\n }\n \n public function getHeadshotWebPath()\n {\n if($this->headshot==null)\n return 'uploads/img/defaultHeadshot.jpg';\n return $this->headshot->getWebPath();\n }\n \n}/userBundle/Admin/NewsPostAdmin.php\nadd('title')\n ->add('publishDate')\n ->add('endDate')\n ->add('header')\n ->add('text')\n ->add('pictures', 'entity', array('class'=>'ecloreuserBundle:Image',\n 'multiple'=>true, 'required' =>false))\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n\n /**\n * @param FormMapper $formMapper\n */\n protected function configureFormFields(FormMapper $formMapper)\n {\n $images = $this->getSubject()->getPictures();\n $fileFieldOptions = array('type' => new ImageType(),\n 'allow_add' => true,\n 'allow_delete' => true,\n 'required' => false,\n 'by_reference' => false,\n 'help'=>'');\n foreach($images as $image)\n if ($image && ($webPath = $image->getWebPath())) {\n $container = $this->getConfigurationPool()->getContainer();\n $fullPath = $container->get('request')->getBasePath().'/'.$webPath;\n $fileFieldOptions['help'] .= '';\n }\n \n $formMapper\n ->add('title')\n ->add('publishDate')\n ->add('endDate')\n ->add('header')\n ->add('text')\n ->add('pictures', 'collection', $fileFieldOptions) \n ;\n }\n\n /**\n * @param ShowMapper $showMapper\n */\n protected function configureShowFields(ShowMapper $showMapper)\n {\n $showMapper\n ->add('title')\n ->add('publishDate')\n ->add('endDate')\n ->add('header')\n ->add('text')\n ->add('pictures', 'entity', array('class'=>'ecloreuserBundle:Image',\n 'multiple'=>true, 'required' =>false, 'template' => 'ecloreuserBundle:Admin:show_album_pictures.html.twig')) \n ;\n }\n}\n/userBundle/Form/InstEditType.php\nadd('institutionName','text' , array('label' => 'Nom de l\\'institution :'))\n ->add('description','textarea' , array('label' => 'Courte description :'))\n ->add('location', 'text', array('attr' => array('class'=>'addressPickerInput') , 'label' => \"Adresse de l'institution :\") )\n ->add('headshot', new ImageType(), array('required'=>false, 'label' => 'Logo :'))\n ->add('save', 'submit', array( 'label' => 'Ajouter' ) )\n ;\n }\npublic function setDefaultOptions(OptionsResolverInterface $resolver)\n {\n $resolver->setDefaults(array(\n 'data_class' => 'eclore\\userBundle\\Entity\\Institution'\n ));\n }\n\n public function getName()\n {\n return 'eclore_user_instedittype';\n }\n}/userBundle/Resources/views/index.html.twig\n\n\n\n\n\n\n Le Réseau Éclore, des jeunes pour des projets associatifs\n \n\t\n\t\n\t\n\t\n\t\n\t\n\n\n \n\t \n\n\n\n\n\n\n\n\n\n\n
    \n\t
    \n\n\n
    \n\t\t\t\t{% include 'ecloreuserBundle::menu.html.twig' %}\t\n\t\t
    \n\t\t\t\n\t\t
    \n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t
    \n\t
    \n\n\t
    \n\t\n\t\t\"Logo \n\t\n\t
    \n\n
    \n\n\t\n\t
    \t\n\t\t
    \n\t\t\t\n\t\t\t\n\t\t\t\t\t\n\t\t
    \n\t\t\t
    \n\t \t\t
    \n\t\t\t
    \n\t\t\t
    \n
    \n\t\n\t\n\t
    \n\t\n
    \n \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    Trouvez ou déposez un projet !

    \n\t\t\t
    \n\t\t
    \n\n\n\t\t\n\t\t\n\t\t\n\t\t
    \n\t\t\n\t\t\t

    Les derniers projets ajoutés

    \n\t\t\t \t\n\t\t\t
    \n\t\t\t \t\t\t\n\t\t\t\t
    \n\t\t\t\t{%for proj in projs %}\n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\t\"Image \n\t\t\t\t\t\t
    • {{proj.city}}
    • Projet de {{proj.getDuration//12}} mois
    \n\t\t\t\t\t\t\"Image \n\t\t\t\t\t
    \n\t\t\t\t\t

    {{proj.projectName}}

    \n\t\t\t\t\t

    {{proj.shortDescription}}

    \n\t\t\t\t
    \n {%endfor%}\n\t\t\t\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t prev \n\t\t\t\tnext\n\n\t\t\t
    \n\t\t
    \n\t\n\t
    \n \n\n \t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    Découvrez la vie du réseau

    \n\t\t\t
    \n\t\t
    \n\n\n\t\t\t\n\t\t
    \n\t\t\t\t\t\n\t\t \t
    \n\t\t\t\t
    \n\t\t\t\t\t{%for post in posts %}\n {%if post.pictures|length >0 %}\n
    \n 1 %} {{app.request.basepath}}/{{ post.pictures[1].getWebPath }} {% else %} {{app.request.basepath}}/{{ post.pictures|first.getWebPath }} {% endif %} \" alt=\"Image 1 du focus\"> \n
    {{post.title}}
    \n
    \n {%endif%}\n {%endfor%}\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\n\t\t
    \n\t\t\t\n\t\t
    \n\n\t\t\t

    Les actualités du réseau

    \n\t\t\t {%for post in posts %}\n\t\t\t
    \n\t\t\t\"Cadre \n\t\t\t

    {{post.title}}

    \t\n\t\t\t

    {{post.header}}

    \n\t\t\t\t
    \n\t\t\t\t voir plus >> \n\t\t\t\t\"Barre \n\t\t\t\t
    \t\n\t\t\t
    \t \n {%endfor%}\n\t\t\t \n\n\t\t
    \n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t\t \"Lien \n\t\t
    \n\t\t\t \n\t\t
    \n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t
    \n\t\t\n\t\t
    \n\n
    \n \n\n\n
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t

    Le réseau Éclore veut développer l'engagement des jeunes comme acteurs du milieu associatif

    \n\t\t\t
    \n\t\t
    \n\n\n\t\t
    \n\t\t\t

    Vidéo de présentation (à venir) ;)

    \n\t\t\t\n\t\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t\"Mascotte \n\t\t\t\tNous sommes 6 jeunes autour de 25 ans, étudiants, jeunes professionnels, passés par des associations\n\t\t\t\tvariées qui nous ont fait confiance et convaincus que cela a été une chance pour notre propre parcours. \n\t\t\t\tNous apportons ainsi nos différentes expériences au réseau Éclore pour partager cette chance avec tous les jeunes. \n\t\t\t
    \n\t\t\t
    \n\t\t\t \"Mascotte \n\t\t\t\tLe réseau s’adresse à la fois aux associations qui souhaitent impliquer dans \n\t\t\t\tleurs projets des jeunes bénévoles, et aux jeunes souhaitant s’engager dans\n\t\t\t\tle milieu associatif. Il vise à mettre en relation des \n\t\t\t\tjeunes et des projets associatifs locaux, afin de promouvoir \n\t\t\t\tl’engagement bénévole dans la société civile et de développer les liens entre les\n\t\t\t\tassociations et les nouvelles générations.\n\t\t\t
    \n\t\t\t
    \n\t\t\t\"Mascotte \n\t\t\tToute association engagée dans un projet vers les autres, de même que \n\t\t\ttout jeune désireux de s’engager dans un tel projet, peut s’inscrire \n\t\t\tau réseau Éclore, si elle ou il adhère à la charte et aux valeurs du \n\t\t\tréseau.\n\t\t\t
    \n\t\t
    \n
    \n\n \n \n
    \n\t\t
    \t\n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t
    \t\n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t
    \t\t\n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t\t
    \t\n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t
    \n\t
    \n\t\n\t
    \n\t\t\t\t\n\t\t\n\t\t\t\t\n\t\t\n\t\t\t\n\t\t\n\t
    \n\t\n \n \n
    \n \n \n \n
    \n \n\t\n\n\n \n \n \n \n\t\t\n\n\n/userBundle/Resources/views/AssoM/Temp web/projects.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n\t\n{% endblock %}/userBundle/Resources/views/Registration/register.html.twig\n{% extends \"FOSUserBundle::layout.html.twig\" %}\n\n{% block fos_user_content %}\n

    Inscription

    \nBonjour ! Bienvenue sur le réseau Éclore. L'inscription est totalement gratuite \net vous permet de candidater ou de déposer des projets associatifs.\n{% include \"FOSUserBundle:Registration:register_content.html.twig\" %}\n{% endblock fos_user_content %}\n/userBundle/Admin/AssociationAdmin.php\ngetSubject()->getHeadshot();\n $fileFieldOptions = array('required'=>false, 'help'=>'Pas de photo');\n if ($headshot && ($webPath = $headshot->getWebPath())) {\n $container = $this->getConfigurationPool()->getContainer();\n $fullPath = $container->get('request')->getBasePath().'/'.$webPath;\n $fileFieldOptions['help'] = '';\n }\n \n $formMapper\n ->add('associationName')\n ->add('headshot', new ImageType(), $fileFieldOptions)\n ->add('description')\n ->add('location')\n ->add('members', 'entity', array('class'=>'ecloreuserBundle:AssociationMember',\n 'multiple'=>true, 'required'=>false))\n ->add('projects', 'entity', array('class'=>'ecloreuserBundle:Project',\n 'multiple'=>true, 'required'=>false))\n ;\n }\n\n // Fields to be shown on filter forms\n /*protected function configureDatagridFilters(DatagridMapper $datagridMapper)\n {\n $datagridMapper\n ->add('associationName')\n ->add('description')\n ->add('location')\n ;\n }*/\n\n // Fields to be shown on lists\n protected function configureListFields(ListMapper $listMapper)\n {\n $listMapper\n ->addIdentifier('associationName')\n ->add('description')\n ->add('location')\n ->add('members', 'entity', array('class'=>'ecloreuserBundle:AssociationMember',\n 'multiple'=>true, 'required'=>false))\n ->add('projects', 'entity', array('class'=>'ecloreuserBundle:Project',\n 'multiple'=>true, 'required'=>false))\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n \n protected function configureShowFields(ShowMapper $showMapper)\n {\n $showMapper\n ->add('associationName')\n ->add('headshot', 'entity', array('class'=>'ecloreuserBundle:Image',\n 'required' =>false, 'template' => 'ecloreuserBundle:Admin:show_headshot.html.twig'))\n ->add('description')\n ->add('location')\n ->add('members', 'entity', array('class'=>'ecloreuserBundle:AssociationMember',\n 'multiple'=>true, 'required'=>false))\n ->add('projects', 'entity', array('class'=>'ecloreuserBundle:Project',\n 'multiple'=>true, 'required'=>false))\n ;\n }\n}/userBundle/Resources/views/Timeline/verbs/mark_project.html.twig\n
  • \n{{ timeline_component_render(timeline, 'subject') }}\na évalué\n{{ timeline_component_render(timeline,'complement') }}\n
  • /userBundle/Entity/NotificationRepository.php\n_em->createQueryBuilder();\n $qb->select('n')\n ->from($this->_entityName, 'n')\n ->where('n.type = :type')\n ->setParameter('type', $type)\n ->join('n.receivers', 'r')\n ->andWhere($qb->expr()->in('r.id',$user->getId()))\n ->orderBy('n.initDate', 'DESC');\n return $qb->getQuery()->getResult();\n }\n \n public function findBySenderAndType($user, $type) \n {\n $qb = $this->_em->createQueryBuilder();\n $qb->select('n')\n ->from($this->_entityName, 'n')\n ->where('n.type = :type')\n ->setParameter('type', $type)\n ->join('n.sender', 'r')\n ->andWhere('r.id = :id')\n ->setParameter('id', $user->getId())\n ->orderBy('n.initDate', 'DESC');\n return $qb->getQuery()->getResult();\n }\n \n public function contactRequested($user1, $user2)\n {\n $rep = $this->_em->getRepository('ecloreuserBundle:Notification'); \n $ct_not_recby1 = $rep->findByReceiverAndType($user1, 'CONTACT');\n $ct_not_recby2 = $rep->findByReceiverAndType($user2, 'CONTACT');\n \n foreach($ct_not_recby1 as $ct_not)\n if($ct_not->getSender()->getId() == $user2->getId())\n return True;\n foreach($ct_not_recby2 as $ct_not)\n if($ct_not->getSender()->getId() == $user1->getId())\n return True;\n return False;\n }\n}\n/userBundle/Entity/Project.php\ngetPAByStatus('VALIDATED'));\n }\n \n public function getReducedAssociation()\n {\n return array('id'=>$this->getAssociation()->getId(), \n 'associationName'=>$this->getAssociation()->getAssociationName(),\n 'associationHeadshot'=>$this->getAssociation()->getHeadshotWebPath());\n }\n \n public function getStartDateTimestamp()\n {\n return $this->getStartDate()->format('U');\n }\n \n public function getEndDateTimestamp()\n {\n return $this->getEndDate()->format('U');\n }\n \n public function getInvestmentRequired()\n {\n return $this->investmentRequired;\n }\n \n public function setInvestmentRequired($inv)\n {\n return $this->investmentRequired = $inv;\n }\n \n \n public function getPAByStatus($stat)\n {\n return $this->projectApplications->filter(function($p) use ($stat){return $p->getStatus()==$stat;});\n }\n \n public function __construct()\n {\n $this->projectApplications = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->responsibles = new \\Doctrine\\Common\\Collections\\ArrayCollection();\n $this->enabled=False;\n }\n \n public function __toString()\n {\n return $this->getProjectName();\n }\n \n public function hasResponsible($resp)\n {$data;\n \n foreach($this->getResponsibles() as $value) $data[]=$value->getId();\n \n return in_array($resp->getId(), $data);\n }\n\n\n /**\n * Get id\n *\n * @return integer \n */\n public function getId()\n {\n return $this->id;\n }\n \n public function getRequired()\n {\n return $this->required;\n }\n \n public function setRequired($required)\n {\n return $this->required = $required;\n }\n\n /**\n * Set projectName\n *\n * @param string $projectName\n * @return Project\n */\n public function setProjectName($projectName)\n {\n $this->projectName = $projectName;\n\n return $this;\n }\n\n /**\n * Get projectName\n *\n * @return string \n */\n public function getProjectName()\n {\n return $this->projectName;\n }\n \n public function setShortDescription($shortDescription)\n {\n $this->shortDescription = $shortDescription;\n\n return $this;\n }\n\n public function getShortDescription()\n {\n return $this->shortDescription;\n }\n\n /**\n * Set description\n *\n * @param string $description\n * @return Project\n */\n public function setDescription($description)\n {\n $this->description = $description;\n\n return $this;\n }\n\n /**\n * Get description\n *\n * @return string \n */\n public function getDescription()\n {\n return $this->description;\n }\n\n /**\n * Set responsibles\n *\n * @param \\eclore\\userBundle\\Entity\\AssociationMember $responsible\n * @return Project\n */\n public function addResponsible(\\eclore\\userBundle\\Entity\\AssociationMember $responsible)\n {\n $this->responsibles[] = $responsible;\n $responsible->addManagedProject($this);\n\n return $this;\n }\n \n /**\n * remove responsibles\n *\n * @param \\eclore\\userBundle\\Entity\\AssociationMember $responsible\n * @return Project\n */\n public function removeResponsible(\\eclore\\userBundle\\Entity\\AssociationMember $responsible)\n {\n $this->responsibles->removeElement($responsible);\n\n return $this;\n }\n\n /**\n * Get responsible\n *\n * @return \\stdClass \n */\n public function getResponsibles()\n {\n return $this->responsibles;\n }\n \n /**\n * Set association\n *\n * @param \\eclore\\userBundle\\Entity\\Association $association\n * @return Project\n */\n public function setAssociation(\\eclore\\userBundle\\Entity\\Association $association)\n {\n $this->association = $association;\n $association->addProject($this);\n\n return $this;\n }\n\n /**\n * Get association\n *\n * @return Association\n */\n public function getAssociation()\n {\n return $this->association;\n }\n\n /**\n * Set startDate\n *\n * @param \\DateTime $startDate\n * @return Project\n */\n public function setStartDate($startDate)\n {\n $this->startDate = $startDate;\n\n return $this;\n }\n\n /**\n * Get startDate\n *\n * @return \\DateTime \n */\n public function getStartDate()\n {\n return $this->startDate;\n }\n\n /**\n * Set endDate\n *\n * @param \\DateTime $endDate\n * @return Project\n */\n public function setEndDate($endDate)\n {\n $this->endDate = $endDate;\n\n return $this;\n }\n\n /**\n * Get endDate\n *\n * @return \\DateTime \n */\n public function getEndDate()\n {\n return $this->endDate;\n }\n\n /**\n * Set labels\n *\n * @param \\eclore\\userBundle\\Entity\\ProjectLabels $labels\n * @return Project\n */\n public function setLabels(\\eclore\\userBundle\\Entity\\ProjectLabels $labels)\n {\n $this->labels = $labels;\n\n return $this;\n }\n\n /**\n * Get labels\n *\n * @return \\eclore\\userBundle\\Entity\\ProjectLabels\n */\n public function getLabels()\n {\n return $this->labels;\n }\n\n /**\n * Set address\n *\n * @param string $address\n * @return Project\n */\n public function setAddress($address)\n {\n $this->address = $address;\n\n return $this;\n }\n\n /**\n * Get address\n *\n * @return string \n */\n public function getAddress()\n {\n return $this->address;\n }\n \n /**\n * Add ProjectApplications\n *\n * @param eclore\\userBundle\\Entity\\ProjectApplication $projectApplication\n */\n \n public function addProjectApplication(\\eclore\\userBundle\\Entity\\ProjectApplication $projectApplication) \n {\n $this->projectApplications[] = $projectApplication;\n }\n \n /**\n * Remove ProjectApplications\n *\n * @param eclore\\userBundle\\Entity\\ProjectApplication $projectApplication\n */\n public function removeProjectApplication(\\eclore\\userBundle\\Entity\\ProjectApplication $projectApplication) \n {\n $this->projectApplications->removeElement($projectApplication);\n }\n\n /**\n * Get ProjectApplications\n *\n * @return array \n */\n public function getProjectApplications()\n {\n return $this->projectApplications;\n }\n \n public function setCity($city)\n {\n $this->city = $city;\n return $this;\n }\n \npublic function getCity()\n {\n return $this->city;\n }\n\npublic function setCountry($country)\n {\n $this->country = $country;\n return $this;\n }\n \npublic function getCountry()\n {\n return $this->country;\n }\n \npublic function setPostcode($postcode)\n {\n $this->postcode = $postcode;\n return $this;\n }\n \npublic function getPostcode()\n {\n return $this->postcode;\n }\n \npublic function setLat($lat)\n {\n $this->lat = $lat;\n return $this;\n }\n \npublic function getLat()\n {\n return $this->lat;\n }\n \npublic function setLng($lng)\n {\n $this->lng = $lng;\n return $this;\n }\n \npublic function getLng()\n {\n return $this->lng;\n }\n \npublic function isFinished()\n {\n $today = new \\DateTime();\n return $today->format('U') > $this->getEndDate()->format('U');\n }\n \npublic function isStarted()\n {\n $today = new \\DateTime();\n return $today->format('U') >= $this->getStartDate()->format('U');\n }\n \n \n /**\n * Set enabled\n *\n * @param boolean $enabled\n * @return Test\n */\n public function setEnabled($enabled)\n {\n $this->enabled = $enabled;\n\n return $this;\n }\n\n /**\n * Get enabled\n *\n * @return boolean \n */\n public function getEnabled()\n {\n return $this->enabled;\n }\n \n //validators\n \n public function isResponsiblesValid()\n {\n // vérifie si les responsables sont de la meme association\n foreach($this->getResponsibles() as $resp)\n if(!$resp->getAssociations()->contains($this->getAssociation()))\n return False;\n }\n \n public function isEndDateValid()\n {\n return $this->getEndDate()->format('U') >= $this->getStartDate()->format('U');\n }\n \n public function getDuration()\n {\n return (int) ($this->getEndDate()->format('U') - $this->getStartDate()->format('U'))/86400;\n }\n \n public function isFull()\n {\n return count($this->getPAByStatus('VALIDATED')) >= $this->getRequired();\n }\n}\n/userBundle/Admin/ProjectAdmin.php\nadd('startDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\")-50, (int)date(\"Y\")+50)))\n ->add('endDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\")-50, (int)date(\"Y\")+50)))\n ->add('enabled', 'checkbox', array('required'=> false))\n ->add('address')\n ->add('city')\n ->add('postcode', 'text', array('required'=> false))\n ->add('country', 'text', array('required'=> false))\n ->add('lat')\n ->add('lng')\n ->add('shortDescription')\n ->add('description')\n ->add('projectName')\n ->add('required')\n ->add('investmentRequired', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('investmentRequired')))\n ->add('projectApplications', 'entity', array('class'=>'ecloreuserBundle:ProjectApplication',\n 'property'=>'id', 'multiple'=>true, 'required'=>false))\n ->add('labels', 'entity', array('class' => 'eclore\\userBundle\\Entity\\ProjectLabels'))\n ->add('responsibles', 'entity', array('class' => 'eclore\\userBundle\\Entity\\AssociationMember',\n 'multiple'=>true))\n ->add('association', 'entity', array('class' => 'eclore\\userBundle\\Entity\\Association'))\n \n ;\n }\n\n // Fields to be shown on filter forms\n /*protected function configureDatagridFilters(DatagridMapper $datagridMapper)\n {\n $datagridMapper\n ->add('startDate')\n ->add('endDate')\n ->add('location')\n ->add('description')\n ->add('projectName')\n ->add('labels', 'entity', array('class' => 'eclore\\userBundle\\Entity\\ProjectLabels'))\n ->add('responsible', 'entity', array('class' => 'eclore\\userBundle\\Entity\\AssociationMember'))\n ->add('association', 'entity', array('class' => 'eclore\\userBundle\\Entity\\Association'))\n ;\n }*/\n\n // Fields to be shown on lists\n protected function configureListFields(ListMapper $listMapper)\n {\n $listMapper\n ->addIdentifier('id')\n ->add('startDate')\n ->add('endDate')\n ->add('enabled')\n ->add('city')\n ->add('shortDescription')\n ->add('projectName')\n ->add('required')\n ->add('labels', 'entity', array('class' => 'eclore\\userBundle\\Entity\\ProjectLabels'))\n ->add('responsibles', 'entity', array('class' => 'eclore\\userBundle\\Entity\\AssociationMember'))\n ->add('association', 'entity', array('class' => 'eclore\\userBundle\\Entity\\Association'))\n ->add('_action', 'actions', array(\n 'actions' => array(\n 'show' => array(),\n 'edit' => array(),\n 'delete' => array(),\n )\n ))\n ;\n }\n \n protected function configureShowFields(ShowMapper $showMapper)\n {\n $showMapper->add('startDate', 'date')\n ->add('endDate', 'date')\n ->add('enabled')\n ->add('address')\n ->add('city')\n ->add('postcode')\n ->add('country')\n ->add('lat')\n ->add('lng')\n ->add('shortDescription')\n ->add('description')\n ->add('projectName')\n ->add('required')\n ->add('investmentRequired', 'choice', array('choices'=>$this->getConfigurationPool()->getContainer()->getParameter('investmentRequired')))\n ->add('projectApplications', 'entity', array('class'=>'ecloreuserBundle:ProjectApplication',\n 'property'=>'id', 'multiple'=>true, 'required'=>false))\n ->add('labels', 'entity', array('class' => 'eclore\\userBundle\\Entity\\ProjectLabels'))\n ->add('responsibles', 'entity', array('class' => 'eclore\\userBundle\\Entity\\AssociationMember',\n 'multiple'=>true))\n ->add('association', 'entity', array('class' => 'eclore\\userBundle\\Entity\\Association'))\n \n ;\n }\n}\n/userBundle/Controller/AdminController.php\ngetDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:AssociationMember')\n ->findByRole('ROLE_TBC'); \n \n $instMs = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:InstitutionMember')\n ->findByRole('ROLE_TBC');\n \n $projects = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:Project')\n ->findByEnabled(False);\n \n return $this->render('ecloreuserBundle:Admin:home.html.twig', array('assoMs'=>$assoMs,\n 'instMs'=>$instMs, 'projects'=>$projects));\n }\n \n public function validateProfileAction($type, $id)\n {\n $formatted_type = 'InstitutionMember';\n if($type=='AssoM')$formatted_type = 'AssociationMember';\n $em = $this->getDoctrine()->getManager();\n $profile = $em->getRepository('ecloreuserBundle:'.$formatted_type)\n ->find($id); \n if(!$profile || !$profile->getUser()->hasRole('ROLE_TBC'))\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Erreur: le profil est déjà validé ou n\\'existe pas.');\n }\n elseif($profile->getUser()->hasRole('ROLE_TBC'))\n {\n $profile->getUser()->removeRole('ROLE_TBC'); \n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Profil validé! L\\'utilisateur a été averti.'); \n $em->persist($profile->getUser());\n $em->flush();\n //event dispatcher\n $event = new NewUserEvent($profile->getUser());\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onNewUser, $event);\n // Generate new token with new roles\n $token = new \\Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken(\n $profile->getUser(),\n null,\n 'main',\n $profile->getUser()->getRoles()\n );\n $this->container->get('security.context')->setToken($token);\n // Get the userManager and refresh user\n $userManager = $this->container->get('fos_user.user_manager');\n $userManager->refreshUser($profile->getUser());\n \n // send mail to user\n $profile->getUser()->getEmail();\n \n }\n return $this->redirect($this->generateUrl('admin_page'));\n }\n \n public function validateProjectAction($id)\n {\n $em = $this->getDoctrine()->getManager();\n $project = $em->getRepository('ecloreuserBundle:Project')\n ->find($id); \n if(!$project || $project->getEnabled())\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Erreur: le projet est déjà validé ou n\\'existe pas.');\n }\n elseif(!$project->getEnabled())\n {\n $project->setEnabled(True); \n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Projet validé! Le responsable a été averti.'); \n $em->flush(); \n // event dispatcher\n $event = new NewProjectEvent($project);\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onNewProject, $event);\n \n }\n return $this->redirect($this->generateUrl('admin_page'));\n }\n}\n/userBundle/Timeline/PAEvent.php\nPA = $PA;\n }\n \n public function getPA()\n {\n return $this->PA;\n }\n}/userBundle/Controller/YoungController.php\nget('security.context')->getToken()->getUser();\n //get timeline\n $actionManager = $this->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($user);\n $timelineManager = $this->get('spy_timeline.timeline_manager');\n $timeline = $timelineManager->getTimeline($subject, array('page' => 1, 'max_per_page' => '10', 'paginate' => true));\n\n return $this->render('ecloreuserBundle:Young:home.html.twig', array('timeline_coll'=>$timeline)); \n }\n \n public function applyAction($id)\n {\n $request = $this->getRequest();\n $user = $this->get('security.context')->getToken()->getUser();\n $em =$this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:Project');\n $project = $repository->find($id);\n \n // verifie que le projet existe et n'est pas terminé.\n if(!$project || $project->isFinished() || !$project->getEnabled() || $project->isFull())\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Ce projet n\\'existe pas, est terminé, ou tu as déja candidaté!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n // verifie que $user a mis une evaluation a toutes ses candidatures\n if($user->getYoung()->getPAByStatus('TERMINATED')->count() > 0)\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Tu dois donner ton avis sur tes précédents projets avant de pouvoir candidater!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n \n // verifie que $user n'a pas deja candidaté\n if($user->getYoung()->hasApplied($project))\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Tu as déjà candidaté à ce projet!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n }\n //cree le formulaire\n $PA = new ProjectApplication();\n $form = $this->createFormBuilder($PA)\n ->add('message', 'textarea')\n ->add('save', 'submit')\n ->getForm();\n \n $form->handleRequest($request); \n if ($form->isValid()) {\n $PA->setYoung($user->getYoung());\n $PA->setStatus('PENDING');\n $PA->setStatusDate(new \\DateTime);\n $PA->setProject($project);\n $this->getDoctrine()->getManager()->persist($PA);\n $this->getDoctrine()->getManager()->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Ta candidature a bien été envoyée !');\n // automatically connect young and project responsibles... TBC\n foreach($PA->getProject()->getResponsibles() as $resp)\n {$resp->getUser()->addContact($user);\n $user->addContact($resp->getUser());\n $em->persist($resp->getUser());\n } \n $em->persist($user);\n $em->flush();\n // event dispatcher\n $event = new PAEvent($PA);\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onNewPA, $event);\n return $this->redirect($this->generateUrl('ecloreuser_home')); \n }\n return $this->render('ecloreuserBundle:Young:apply.html.twig', array('proj'=>$project,'form' => $form->createView())); \n }\n \n public function manageApplicationAction($id)\n {\n $request = $this->getRequest();\n $user = $this->get('security.context')->getToken()->getUser();\n $em =$this->getDoctrine()->getManager();\n $repository = $em->getRepository('ecloreuserBundle:ProjectApplication');\n $PA = $repository->find($id);\n \n // verifie que la candidature concerne bien $user\n if(!$PA || $PA->getYoung()->getId() != $user->getYoung()->getId())\n {\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette candidature n\\'existe pas ou ne te concerne pas!');\n return $this->redirect($this->generateUrl('ecloreuser_home'));\n } \n //creation formulaire\n $recomm = new Notification();\n $formbuilder = $this->createFormBuilder($recomm);\n $formbuilder->add('message', 'textarea')\n ->add('mark','submit');\n $form = $formbuilder->getForm();\n \n $form->handleRequest($request); \n if($form->isValid()) {\n $PA->setStatusDate(new \\DateTime);\n $PA->setMessage($recomm->getMessage());\n //cloture candidature coté jeune\n $PA->setStatus('MARKED');\n // event dispatcher\n $event = new MarkedEvent($PA);\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onMarkedProject, $event);\n // creation note\n $recomm->setSender($user);\n $recomm->setProject($PA->getProject());\n foreach($PA->getProject()->getResponsibles() as $resp) $recomm->addReceiver($resp->getUser());\n $recomm->setInitDate(new \\DateTime());\n $recomm->setType('MARK');\n $em->persist($recomm);\n $em = $this->getDoctrine()->getManager();\n $em->flush();\n $this->get('session')->getFlashBag()->add(\n 'notice',\n 'Avis enregistré!');\n }\n\n return $this->render('ecloreuserBundle:Young:manage-application.html.twig',\n array('pa'=>$PA,'form'=>$form->createView()));\n \n }\n\n \n \n}\n/userBundle/Timeline/NewProjectEvent.php\nproject = $project;\n }\n \n public function getProject()\n {\n return $this->project;\n }\n}/userBundle/Form/Type/RegistrationFormType.php\ncontainer = $container;\n }\n\n public function buildForm(FormBuilderInterface $builder, array $options)\n {\n parent::buildForm($builder, $options);\n \n $builder->add('birthDate', 'date', array( 'widget' => 'choice', 'years'=>range((int)date(\"Y\")-100, (int)date(\"Y\")), 'label' => 'Date de naissance :'))\n ->add('lastName' , 'text' , array('label' => 'Nom :') )\n ->add('firstName' , 'text' , array('label' => 'Prénom :'))\n ->add('mobile' ,'text', array('label' => 'Numéro de téléphone : '))\n ->remove('quality')\n ->add('privacyLevel', 'choice', array('choices'=>$this->container->getParameter('privacyLevels') , 'label' => 'Paramètres de confidentialité :'))\n ->add('headshot', new ImageType(), array('required'=>false , 'label' => 'Photo de profil : '))\n ;\n }\n\n public function getName()\n {\n return 'eclore_user_registration';\n }\n}\n\n?>/config.yml\nimports:\n - { resource: parameters.yml }\n - { resource: security.yml }\n - { resource: @ecloreuserBundle/Resources/config/services.yml }\n \nspy_timeline:\n paginator: ~\n drivers:\n orm:\n object_manager: doctrine.orm.entity_manager\n classes:\n query_builder: ~ # Spy\\TimelineBundle\\Driver\\ORM\\QueryBuilder\\QueryBuilder\n timeline: eclore\\userBundle\\Entity\\Timeline\n action: eclore\\userBundle\\Entity\\Action\n component: eclore\\userBundle\\Entity\\Component\n action_component: eclore\\userBundle\\Entity\\ActionComponent \n filters:\n data_hydrator:\n priority: 20\n service: spy_timeline.filter.data_hydrator\n filter_unresolved: false\n locators:\n - spy_timeline.filter.data_hydrator.locator.doctrine_orm\n duplicate_key: ~ \n spread:\n on_subject: true # DEFAULT IS TRUE Spread each action on subject too\n on_global_context: true # Spread automatically on global context\n deployer: spy_timeline.spread.deployer.default\n delivery: immediate\n render:\n path: 'ecloreuserBundle:Timeline/verbs'\n \n\nframework:\n #esi: ~\n translator: { fallback: \"%locale%\" }\n secret: \"%secret%\"\n router:\n resource: \"%kernel.root_dir%/config/routing.yml\"\n strict_requirements: ~\n form: ~\n csrf_protection: ~\n validation:\n enabled: true\n api: 2.4\n enable_annotations: true \n templating:\n engines: ['twig']\n #assets_version: SomeVersionScheme\n default_locale: \"%locale%\"\n trusted_hosts: ~\n trusted_proxies: ~\n session:\n # handler_id set to null will use default session handler from php.ini\n handler_id: ~\n fragments: ~\n http_method_override: true\n\n# Twig Configuration\ntwig:\n debug: \"%kernel.debug%\"\n strict_variables: \"%kernel.debug%\"\n\n# Assetic Configuration\nassetic:\n debug: \"%kernel.debug%\"\n read_from: \"%kernel.root_dir%/../www\"\n bundles: [ecloreuserBundle]\n #java: /usr/bin/java\n filters:\n cssrewrite: ~\n #closure:\n # jar: \"%kernel.root_dir%/Resources/java/compiler.jar\"\n #yui_css:\n # jar: \"%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar\"\n #yui_js:\n # jar: \"%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar\"\n\n# Doctrine Configuration\ndoctrine:\n dbal:\n driver: \"%database_driver%\"\n host: \"%database_host%\"\n port: \"%database_port%\"\n dbname: \"%database_name%\"\n user: \"%database_user%\"\n password: \"%%\"\n charset: UTF8\n # if using pdo_sqlite as your database driver, add the path in parameters.yml\n # e.g. database_path: \"%kernel.root_dir%/data/data.db3\"\n # path: \"%database_path%\"\n\n orm:\n auto_generate_proxy_classes: \"%kernel.debug%\"\n auto_mapping: true\n\n# Swiftmailer Configuration\nswiftmailer:\n transport: \"%mailer_transport%\"\n host: \"%mailer_host%\"\n username: \"%mailer_user%\"\n password: \"%%\"\n spool: { type: memory }\n \nfos_user:\n db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'\n firewall_name: main\n user_class: eclore\\userBundle\\Entity\\User\n service:\n mailer: fos_user.mailer.twig_swift\n user_provider : fos_user.user_provider.username\n from_email:\n address: \n sender_name: \"\"\n profile:\n form:\n type: eclore_user_profile\n registration:\n form:\n type: eclore_user_registration\n confirmation:\n enabled: false\n template: ecloreuserBundle:Registration:email.html.twig\n resetting:\n token_ttl: 86400\n email:\n template: ecloreuserBundle:Resetting:email.html.twig\n \n#Sonata Block Bundle\nsonata_block:\n default_contexts: [cms]\n blocks:\n sonata.admin.block.admin_list:\n contexts: [admin]\n sonata.block.service.text: ~\n sonata.block.service.action: ~\n sonata.block.service.rss: ~\n sonata.block.service.overview: ~\n\nsonata_admin:\n title: \"Plateforme de gestion des enregistrements\"\n #title_logo: ~\n dashboard:\n blocks:\n \n # display a dashboard block\n - { position: left, type: sonata.admin.block.admin_list }\n - { position: right, type: sonata.block.service.overview } \n \n/userBundle/Resources/views/Young/projects.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
    \n\n

    Mes projets

    \n\n
    \n{% set pending = app.user.young.PAByStatus('PENDING') %}\n{% set validated = app.user.young.PAByStatus('VALIDATED') %}\n{% set rejected = app.user.young.PAByStatus('REJECTED') %}\n{% set terminated = app.user.young.PAByStatus('TERMINATED') %}\n{% set marked = app.user.young.PAByStatus('MARKED') %}\n\n\n{%if pending|length == 0 and validated|length == 0%}\nVous n'avez pas encore candidaté à un projet. Vous pouvez chercher dans notre base de donnée \nun projet associatif qui vous convienne.\n{%endif%}\n\n\n{%if pending|length > 0%}\n
    \n

    Candidatures en attente de réponse :

    \n \n
    \n{%else%}\n \n{%endif%}\n\n{%if terminated|length > 0%}\n
    \n

    Donne ton avis !

    \n \n
    \n{%else%}\n \n{%endif%}\n\n{%if marked|length > 0%}\n
    \n

    Projets terminés :

    \n \n
    \n{%else%}\n \n{%endif%}\n\n{%if validated|length > 0%}\n
    \n

    Candidatures validées :

    \n \n
    \n{%else%}\n \n{%endif%}\n\n\n{%if rejected|length > 0%}\n
    \n

    Candidatures rejetées :

    \n \n\t\tN'hésitez pas à contacter l'association pour demander des précisions.\n
    \n{%else%}\n \n{%endif%}\n\n\n
    \n
    \n{% endblock %}/userBundle/Resources/views/Projects/show-project.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Rechercher un projet{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n\n

    {{proj}}

    \n
    Du {{proj.startdate|date(\"m-d-Y\")}} au {{proj.enddate|date(\"m-d-Y\")}}. {{proj.address}}
    \n\n
    {{proj.description}}
    \n
    Responsable du projet: {%for resp in proj.responsibles%}{{resp.user|printName}} {%endfor%}
    \n\n
    \n{%set validated = proj.PAByStatus('VALIDATED') %}\n{%set terminated = proj.PAByStatus('TERMINATED') %}\n{%set marked = proj.PAByStatus('MARKED') %}\n{%if (is_granted(\"IS_AUTHENTICATED_REMEMBERED\") and app.user.hasRole('ROLE_YOUNG')) or not is_granted(\"IS_AUTHENTICATED_REMEMBERED\")%}\n Candidater à ce projet!\n{%endif%}\n{% if is_granted(\"IS_AUTHENTICATED_REMEMBERED\") %}\n {% if date(proj.enddate) < date() %}\n Ce projet est terminé.
    \n {{validated|length+terminated|length+marked|length}} participants.\n \n {%else%}\n\t\t

    \n\t\t{% if validated|length+terminated|length+marked|length > 0 %}\n\t\t\tJeunes inscrits à ce projet:
      \n\t\t\t\t{%for part in validated%}\n\t\t\t\t {%if part.young.user.privacyLevel != 2%}\n\t\t\t\t\t
    • {{part.young.user|printName}}
    • \n\t\t\t\t {%endif%}\n\t\t\t\t{%endfor%}\n\t\t\t\t
    \n\t\t\t{% endif%}\n {%endif%}\n{%else%}\n {{validated|length}} participants enregistrés.\n{% endif %}\n
    \n
    \n\n\n
    \n\t
    \n\t
    Projet porté par {{proj.association}}
    \n\t\t Découvrir cette association \n\t
    \n
    \n\n
    \n

    Action récentes liées à ce projets

    \n{% for action in timeline_coll %}\n {{ timeline_render(action) }}
    \n{% endfor %}\n
    \n
    \n{% endblock %}\n/userBundle/Controller/ProfileController.php\ncontainer->get('templating')->renderResponse('ecloreuserBundle:Profile:albums.html.twig');\n }\n \n public function removeAlbumAction($id)\n {\n $em = $rep = $this->container->get('doctrine')->getManager();\n $rep = $em->getRepository('ecloreuserBundle:Album');\n $album = $rep->find($id);\n $user = $this->container->get('security.context')->getToken()->getUser();\n \n if($album->getOwner()->getId() != $user->getId()) \n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n\\'êtes pas concerné par cet album!');\n else \n {\n $em->remove($album);\n $em->flush();\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'album a été supprimé.');\n }\n \n return new RedirectResponse($this->container->get('router')->generate('user_albums'));\n }\n \n public function removePicAction($id)\n {\n $em = $rep = $this->container->get('doctrine')->getManager();\n $rep = $em->getRepository('ecloreuserBundle:Image');\n $image = $rep->find($id);\n $user = $this->container->get('security.context')->getToken()->getUser();\n \n if($image->getAlbum()->getOwner()->getId() != $user->getId()) \n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n\\'êtes pas concerné par cette image!');\n else \n {\n $em->remove($image);\n $em->flush();\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'image a été supprimée.');\n }\n \n return new RedirectResponse($this->container->get('router')->generate('user_albums'));\n }\n \n public function createAlbumAction(Request $request)\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n $em = $this->container->get('doctrine')->getManager();\n $album = new Album();\n $form = $this->container->get('form.factory')->create(new AlbumType(), $album); \n \n if('POST' === $request->getMethod()) {\n $form->bind($request); \n if ($form->isValid()) { \n $album->setOwner($user);\n $em->persist($album);\n $em->flush();\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'L\\'album a correctement été créé.');\n return new RedirectResponse($this->container->get('router')->generate('user_albums'));\n }\n }\n \n return $this->container->get('templating')->renderResponse('ecloreuserBundle:Profile:create-album.html.twig', \n array('form'=> $form->createView()));\n }\n \n public function getAnnuaireAction()\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n \n $rep = $this->container->get('doctrine')\n ->getManager()\n ->getRepository('ecloreuserBundle:Notification');\n $contact_not = $rep->findByReceiverAndType($user, 'CONTACT');\n $contact_send = $rep->findBySenderAndType($user, 'CONTACT');\n return $this->container->get('templating')->renderResponse('ecloreuserBundle:Profile:annuaire.html.twig',\n array('contact_not'=>$contact_not, 'contact_send'=>$contact_send));\n }\n \n public function getRecommendationsAction()\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n \n $rep = $this->container->get('doctrine')\n ->getManager()\n ->getRepository('ecloreuserBundle:Notification');\n $notType = 'MARK';\n if($user->hasRole('ROLE_YOUNG'))$notType = 'RECOMMENDATION';\n $recomm = $rep->findByReceiverAndType($user, $notType);\n return $this->container->get('templating')->renderResponse('ecloreuserBundle:Profile:recommendations.html.twig',\n array('recomm'=>$recomm));\n }\n \n public function acknowledgeContactAction($id, $action)\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n $em = $this->container->get('doctrine')->getManager();\n $rep = $em->getRepository('ecloreuserBundle:Notification'); \n $contacts_not = $rep->findByReceiverAndType($user, 'CONTACT'); \n $contact_not;\n // recupere la contact_not\n foreach($contacts_not as $ct)\n if($ct->getId() == $id)\n $contact_not = $ct;\n // si la not n'existe pas\n if(!isset($contact_not))\n {\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Vous n\\'êtes pas concerné par cette notification.');\n }\n else{\n if(StringUtils::equals($action, 'ack')){\n $user2 = $contact_not->getSender();\n $user->addContact($user2);\n $user2->addContact($user);\n $em->persist($user);\n $em->persist($user2);\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Ce contact a été ajouté à votre annuaire.');\n // event dispatcher\n $event = new ContactAckEvent($user2, $user);\n $this->container->get('event_dispatcher')->dispatch(TimelineEvents::onContactAck, $event);\n }else{\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Notification supprimée.');\n }\n $em->remove($contact_not);\n $em->flush();\n }\n \n return new RedirectResponse($this->container->get('router')->generate('user_annuaire'));\n\n }\n \n public function sendDemandAction($id)\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n $em = $this->container->get('doctrine')->getManager();\n $rep = $em->getRepository('ecloreuserBundle:User');\n $user2 = $rep->find($id);\n \n $rep = $em->getRepository('ecloreuserBundle:Notification'); \n \n // si $user2 n'existe pas ou ets en mode invisible\n if(!$user2 || $user2->getPrivacyLevel() == 2)\n {\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Cet utilisateur n\\'existe pas!');\n }\n //si une demande de contact existe deja entre les deux ou qu'ils sont deja contacts\n elseif($user->getContacts()->contains($user2) || $rep->contactRequested($user, $user2) || ($user->getId() == $user2->getId()))\n {\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette personne est déjà dans vos contacts ou vous avez déjà une demande de contact en attente pour cette personne!');\n }\n else\n {\n $not = new Notification();\n $not->setType('CONTACT');\n $not->setSender($user);\n $not->setMessage('');\n $not->addReceiver($user2);\n $em->persist($not);\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'La demande a bien été envoyée.');\n $em->flush();\n }\n \n return new RedirectResponse($this->container->get('router')->generate('user_annuaire'));\n }\n \n public function removeContactAction($id)\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n $em = $this->container->get('doctrine')->getManager();\n $rep = $em->getRepository('ecloreuserBundle:User');\n $user2 = $rep->find($id);\n \n // si $user2 n'existe pas\n if(!$user2)\n { $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Cet utilisateur n\\'existe pas!');\n }\n //si user2 n'est pas contact de user\n elseif(!$user->getContacts()->contains($user2))\n { $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Cette personne n\\'est pas dans vos contacts!');\n }\n else\n { $user->removeContact($user2);\n $user2->removeContact($user);\n $em->persist($user);\n $em->persist($user2);\n $this->container->get('session')->getFlashBag()->add(\n 'notice',\n 'Contact supprimé.');\n $em->flush();\n }\n return new RedirectResponse($this->container->get('router')->generate('user_annuaire'));\n }\n\n public function editAction(Request $request)\n {\n $user = $this->container->get('security.context')->getToken()->getUser();\n if (!is_object($user) || !$user instanceof UserInterface) {\n throw new AccessDeniedException('This user does not have access to this section.');\n }\n\n /** @var $dispatcher \\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface */\n $dispatcher = $this->container->get('event_dispatcher');\n\n $event = new GetResponseUserEvent($user, $request);\n $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_INITIALIZE, $event);\n\n if (null !== $event->getResponse()) {\n return $event->getResponse();\n }\n\n /** @var $formFactory \\FOS\\UserBundle\\Form\\Factory\\FactoryInterface */\n $formFactory = $this->container->get('fos_user.profile.form.factory');\n\n $form = $formFactory->createForm();\n\n if(!$user->hasRole('ROLE_YOUNG')&&!$user->hasRole('ROLE_INSTM')&&!$user->hasRole('ROLE_ASSOM'))\n $form->remove('quality');\n \n $form->setData($user);\n\n \n if ('POST' === $request->getMethod()) {\n $form->bind($request);\n\n if ($form->isValid()) {\n /** @var $userManager \\FOS\\UserBundle\\Model\\UserManagerInterface */\n $userManager = $this->container->get('fos_user.user_manager');\n\n $event = new FormEvent($form, $request);\n $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event);\n \n $userManager->updateUser($user);\n\n $em = $this->container->get('doctrine')->getEntityManager();\n $em->persist($user);\n $em->flush();\n \n if (null === $response = $event->getResponse()) {\n $url = $this->container->get('router')->generate('fos_user_profile_show');\n $response = new RedirectResponse($url);\n }\n\n $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response));\n\n return $response;\n }\n }\n\n return $this->container->get('templating')->renderResponse(\n 'FOSUserBundle:Profile:edit.html.'.$this->container->getParameter('fos_user.template.engine'),\n array('form' => $form->createView())\n );\n }\n}\n/userBundle/Resources/public/js/lambda/anim_menu.js\n$(document).ready(function(){\n\n// Unfolding the menu ---------------------------------------\n\n// We start by adding data to each node corresponding to the value they have to expand\nvar menu1 = $(\"div[class*='menu'] ul li\")[0];\nvar menu2 = $(\"div[class*='menu'] ul li\")[1];\nvar menu3 = $(\"div[class*='menu'] ul li\")[2];\n//var menu4 = $(\"div[class*='menu'] ul li\")[3];\n\n$.data(menu1, 'taillef', {l: 8.9});\n$.data(menu2, 'taillef', {l: 8.9});\n$.data(menu3, 'taillef', {l: 8.9});\n//$.data(menu4, 'taillef', {l: 11.4});\n\n//$.data(menu1,'taillef').l;\n\n //When mouse rolls over\n $(\"div[class*='menu'] ul li:lt(3)\").mouseover(function(){\n $(this).stop().animate({height: $.data(this,'taillef').l +'em'},{queue:false, duration:600, easing: 'easeOutExpo'})\n });\n //When mouse is removed\n $(\"div[class*='menu'] ul li:lt(3)\").mouseout(function(){\n $(this).stop().animate({height:'2.5em'},{queue:false, duration:600, easing: 'easeOutExpo'})\n });\n \n\n$('
    ').appendTo($('div[class*=\"menu\"] ul li h3~a'));\n//$('
  • Deuxième élément bis
  • ').insertAfter($('li'));\n$('div[class*=\"menu\"] ul li h3~a').hover( //Mouseover, fadeIn the hidden hover class \n function(){ $(this).children('div').stop(true,true).fadeIn('2000');}, //Mouseout, fadeOut the hover class \n function(){ $(this).children('div').stop(true,true).fadeOut('2000'); }\n ) ;\n \n });/userBundle/Resources/views/menu.html.twig\n\n\t\t\t\t\t\t\n/userBundle/Timeline/NewUserEvent.php\nuser = $user;\n }\n \n public function getUser()\n {\n return $this->user;\n }\n}/userBundle/Resources/views/Static/statuts.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Le réseau Eclore{% endblock %}\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n

    Nos statuts

    \n\n

    Article 1 - Constitution et dénomination

    \nIl est formé entre les adhérents aux présents statuts une association régie par la loi du 1er juillet 1901 et le décret du 16 août 1901, ayant pour titre « Réseau Éclore » (ci-après « l'association »).\n\n

    Article 2 - Objet

    \nL’association « Réseau Éclore » a pour objet de susciter et de faciliter l’investissement de jeunes dans les milieux associatifs et dans le développement de nouveaux projets. Pour cela, elle développe une connaissance des milieux associatifs et de leurs besoins, elle fait la promotion de l’engagement auprès de jeunes et les met en relation avec les associations et lanceurs de projet. Enfin, elle veille sur la nature de la collaboration réalisée, et accompagne les jeunes, y compris dans la valorisation de cette expérience. \n\n

    Article 3 - Siège social

    \nLe siège social est fixé à Ivry-sur-Seine. Il pourra être transféré sur simple décision du Conseil d'Administration.\n\n

    Article 4 - Durée de l'association

    \nLa durée de l'association est illimitée.\n\n

    Article 5 - Composition

    \nL'association se compose de :
    \n1° - membres fondateurs ;
    \n2° - membres d'honneur ;
    \n3° - membres actifs ;
    \n4° - membres associés.

    \n\nTous participent à l’Assemblée générale.
    \n\nLes membres fondateurs sont les personnes qui ont participé à la création de l’association. Ils sont dispensés du versement d’une cotisation. Ils disposent d’une voix délibérative aux assemblées générales et sont éligibles à toutes les instances.
    \n\nLes membres d’honneur sont les personnes qui ont rendu des services signalés à l’association ou qui ont apporté une contribution financière ou matérielle importante à l’association. Ils sont dispensés du versement d’une cotisation. Ils disposent d’une voix consultative uniquement aux assemblées générales et ne sont pas éligibles.
    \n\nLes membres actifs sont les personnes impliquées dans la vie de l’association. Ils versent une cotisation annuelle fixée par le Conseil d’administration. Ils disposent d’une voix délibérative aux assemblées générales et sont éligibles à toutes les instances.
    \n\n\nLes membres associés sont les personnes physiques ou morales qui bénéficient des activités de l’association, sans s’impliquer de façon active dans sa gestion. Elles versent une cotisation annuelle fixée par le Conseil d’administration. Les personnes morales sont représentées par leur représentant légal ou toute autre personne dûment habilitée à cet effet. Elles disposent d’une voix consultative aux assemblées générales. Un certain nombre de sièges peut leur être réservé en conseil d’administration.\n\n

    Article 6 - Admission

    \nPour être membre d'honneur ou membre actif, il faut être agréé par le Bureau qui statue lors de chacune de ses réunions sur les demandes d'adhésion présentées ainsi que sur la qualité de membre correspondante. En cas de refus, le Bureau n'a pas à motiver sa décision.\nPour être membre associé, il faut être impliqué dans des projets de l’association. Le règlement intérieur précise les conditions de l’admission.\n\n

    Article 7 - Perte de la qualité de membre

    \nLa qualité de membre se perd par :
    \n1°- la démission ;
    \n2° - le décès ;
    \n3° - le non-versement de la cotisation annuelle pour les membres actifs et pour les membres associés le cas échéant ;
    \n4° - la fin de l’implication dans des projets de l’association pour les membres associés, dans des conditions précisées par le règlement intérieur ;
    \n5° - la radiation prononcée par le Conseil d'administration pour motif grave, l'intéressé ayant été préalablement invité à fournir des explications au Conseil d'administration. Le non-respect des valeurs de l'association peut constituer un motif grave.
    \n

    Article 8 - Ressources

    \nLes ressources de l’association comprennent :
    \n- des cotisations annuelles des membres actifs et associés, et éventuellement de cotisations exceptionnelles de tout membre.
    \n- des subventions allouées par l’État, les collectivités locales, les établissements publics ou tout tiers autorisé ;
    \n- des dons manuels des personnes physiques et morales ;
    \n- des produits des activités commerciales et manifestations liées à l'objet ;
    \n- toute autre ressource autorisée par la loi.
    \n

    Article 9 - Assemblée générale ordinaire

    \nL’assemblée générale ordinaire comprend tous les membres de l’association. L’assemblée générale ordinaire se réunit chaque année sur convocation du Conseil d'administration ou du quart des membres délibérants de l'association. Quinze jours au moins avant la date fixée, les membres de l’association sont convoqués par les soins du secrétaire, qui indique l'ordre du jour.\n
    \nL'Assemblée entend les rapports sur la situation morale et financière de l'association et délibère. Elle ne délibère que sur les questions mises à l'ordre du jour et pourvoit s'il y a lieu au renouvellement des membres du Conseil d'administration.\nL'Assemblée délibère valablement quel que soit le nombre de membres présents. Tout membre de l'association peut s'y faire représenter par un autre en renseignant le pouvoir joint à la convocation. Le vote par correspondance n'est pas admis. \n Les décisions sont prises à main levée, à la majorité des suffrages exprimés par les membres présents ou représentés. Le scrutin secret peut être également demandé par au moins deux membres présents.\n\n

    Article 10 - Assemblée générale extraordinaire

    \nL'assemblée générale extraordinaire a seule compétence pour modifier les statuts, décider de la dissolution de l'association et de l'attribution des biens de l'association ou de sa fusion avec toute autre association poursuivant un but analogue.\nElle doit être convoquée à la demande du Président ou à la demande de la moitié des membres ayant le droit de vote, suivant les modalités prévues par l'article 9. L'assemblée générale extraordinaire ne délibère valablement que si la moitié des membres ayant le droit de vote sont présents ou représentés.\n\n

    Article 11 - Le Conseil d'administration

    \nL'association est administrée par un Conseil. Le Conseil d'administration met en œuvre les orientations décidées par l'Assemblée générale ; il décide de la tenue des assemblées générales et en adopte, sur proposition du bureau, l'ordre du jour ; il prend la décision d'ester en justice pour la sauvegarde des intérêts de l'association.\nLe Conseil d'administration est composé :
    \n1° du bureau ;
    \n2° de représentants élus pour une durée de un an renouvelable en leur groupe respectivement par :
    \n a) - les membres fondateurs et actifs ;
    \n b) - les membres associés, pouvant être divisés en plusieurs sous-groupes, chaque sous-groupe élisant ses représentants ;
    \nLe nombre de représentants élus de chaque catégorie est fixé par l’assemblée générale sur proposition du Bureau ;
    \n3° de personnes nommées par le conseil d'administration, sur proposition du président, et dans la limite de trois personnes, pour une durée de un an renouvelable.
    \n
    \nLe nombre d'administrateurs ne peut excéder quinze personnes.\nEn cas de vacance de poste, le Conseil d'administration peut pourvoir provisoirement au remplacement de ses membres. Les pouvoirs des membres ainsi nommés prennent fin à l'époque où devait normalement expirer le mandat des membres remplacés.\n
    \nLe Conseil d’administration se réunit autant de fois que l’intérêt de l’association l’exige et au moins à trois reprises dans l’année sur convocation du Président de l’association.\nLes convocations sont adressées au plus tard dix jours avant la réunion. Elles mentionnent l’ordre du jour de la réunion arrêté par le Président de l’association en accord avec le secrétaire de l’association. En cas d’urgence, dûment justifiée par le Président, le délai de convocation peut être ramené à cinq jours.\nChaque administrateur dispose d’une voix délibérative. Tout administrateur absent ou empêché peut donner à un autre administrateur mandat de le représenter. Aucun membre ne peut être porteur de plus de un mandat, en sus du sien.\nLe Conseil d’administration délibère valablement en présence de la moitié de ses membres présents ou représentés.\nLes décisions sont prises à la majorité des suffrages exprimés des membres présents ou représentés. En cas de partage des voix, celle du président est prépondérante.\n
    \nSi l’association a moins de deux ans d’existence ou si le nombre de ses membres ne dépasse pas 30, l’assemblée générale peut décider de ne pas élire de Conseil d’administration. Dans ce cas, le Bureau assume les responsabilités du Conseil d’administration. Cette décision doit être renouvelée à chaque nouvelle assemblée générale.\n

    Article 12 - Le Bureau

    \nLe Bureau assure le fonctionnement permanent de l'association et décide des actions de l'association à engager dans le cadre des orientations définies par le Conseil d'administration.\nLe Bureau est élu en bloc par l'Assemblée générale pour une durée de un an renouvelable. \nLe Bureau est composé de, au minimum :
    \n1° - un Président ;
    \n2° - un Trésorier ;
    \n3° - un Secrétaire.
    \nLe nombre de membres du Bureau ne peut excéder dix personnes.\n

    \nPRÉSIDENT\nLe président du Bureau est chargé d'exécuter les décisions du Bureau et d’assurer le bon fonctionnement de l’association.\nIl représente l’association dans tous les actes de la vie civile et est investi de tous les pouvoirs à cet effet. Il a notamment qualité pour agir en justice au nom de l'association.\nLe Président convoque les assemblées générales et les réunions du Bureau.
    \nIl fait ouvrir et fonctionner au nom de l’association, auprès de toute banque ou tout établissement de crédit, tout compte.\nIl peut déléguer à un autre membre ou à un permanent de l’association certains des pouvoirs ci-dessus énoncés.\n

    \nTRÉSORIER\nLe trésorier est chargé de la gestion de l’association.\nIl perçoit les recettes, effectue les paiements, sous le contrôle du président.\nIl tient une comptabilité régulière de toutes les opérations et rend compte à l’assemblée générale qui statue sur la gestion.\nComme le président, il fait ouvrir et fonctionner au nom de l’association, auprès de toute banque ou tout établissement de crédit, tout compte.\n

    \nSECRÉTAIRE\nLe secrétaire est chargé de tout ce qui concerne la correspondance et les archives.\nIl rédige les procès-verbaux de réunions des assemblées et du Conseil d’administration et en assure la transcription sur les registres, notamment le registre spécial prévu par la loi et le registre des délibérations.\nIl est en charge, en général, de toutes les écritures concernant le fonctionnement de l’association, à l’exception de celles qui concernent la comptabilité.\n

    \nEn cas de vacance, le Bureau pourvoit provisoirement au remplacement du ou des membres parmi les membres éligibles de l’association. Le remplacement définitif des membres ainsi cooptés intervient à la plus proche assemblée générale et leurs pouvoirs prennent fin durant cette même assemblée générale. \n\nLe Bureau se réunit au moins une fois tous les six mois et aussi souvent que l’intérêt de l’association l’exige, sur convocation du Président ou à la demande de au moins deux membres du Bureau.\nTout membre du Bureau qui, sans excuse, n’aura pas assisté à trois réunions consécutives, pourra être considéré comme démissionnaire.\n\nLa présence de la moitié des membres est nécessaire pour la validité des délibérations. Si ce quorum n’est pas atteint, le Bureau est à nouveau convoqué à quelques jours d’intervalle et peut alors délibérer quel que soit le nombre de membres présents ou représentés.\nLes décisions sont prises à la majorité des voix ; en cas de partage, la voix du président est prépondérante. Le secrétaire décide des règles de vote au sein du Bureau.\n\n

    Article 13 - Valeurs de l'association

    \nLes valeurs de l'association sont :
    \n1°- l’entraide ;
    \n2°- le respect ;
    \n3°- la fraternité ;
    \n4°- le dialogue ;
    \n5°- la gratuité.
    \n\n

    Article 14 – Règlement Intérieur

    \nUn règlement intérieur peut être établi par le bureau qui le fait alors soumettre à l’assemblée générale.\n\nCe règlement éventuel est destiné à fixer les divers points non prévus par les statuts notamment ceux relatifs à l’administration interne de l’association.\n\n

    Article 15 – Dissolution

    \nLa dissolution de l'association est prononcée par l'Assemblée générale convoquée spécialement à cet effet.\nEn cas de dissolution, l’Assemblée générale extraordinaire désigne un ou plusieurs liquidateurs qui seront chargés de la liquidation des biens de l’Association et dont elle détermine les pouvoirs. L’actif net subsistant sera obligatoirement attribuée à une ou plusieurs associations poursuivant des buts similaires et qui seront nommément désignées par l’Assemblée générale extraordinaire, conformément à l'article 9 de la loi du 1er juillet 1901 et au décret du 16 août 1901.\n\n{% endblock %}/userBundle/Resources/config/services.yml\nparameters:\n# ecloreuser.example.class: eclore\\userBundle\\Example\n\nservices:\n eclore.twig.extension:\n class: eclore\\userBundle\\Extensions\\Twig\\templateFunctionsHelper\n arguments: [@service_container, @security.context]\n tags:\n - { name: twig.extension }\n \n ecloreuser.image_type_extension:\n class: eclore\\userBundle\\Form\\Extension\\ImageTypeExtension\n tags:\n - { name: form.type_extension, alias: file }\n \n \n ecloreuser.admin.album:\n class: eclore\\userBundle\\Admin\\AlbumAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Entités\", label: \"Album\" }\n arguments: [~, eclore\\userBundle\\Entity\\Album, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.project:\n class: eclore\\userBundle\\Admin\\ProjectAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Entités\", label: \"Projets\" }\n arguments: [~, eclore\\userBundle\\Entity\\Project, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.projectlabels:\n class: eclore\\userBundle\\Admin\\ProjectLabelsAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Entités\", label: \"Labels de projets\" }\n arguments: [~, eclore\\userBundle\\Entity\\ProjectLabels, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.projectapplication:\n class: eclore\\userBundle\\Admin\\ProjectApplicationAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Entités\", label: \"Candidatures\" }\n arguments: [~, eclore\\userBundle\\Entity\\ProjectApplication, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n\n eclore_user.registration.form.type:\n class: eclore\\userBundle\\Form\\Type\\RegistrationFormType\n arguments: [%fos_user.model.user.class%, @service_container]\n tags:\n - { name: form.type, alias: eclore_user_registration }\n \n eclore_user.profile.form.type:\n class: eclore\\userBundle\\Form\\Type\\ProfileFormType\n arguments: [%fos_user.model.user.class%, @service_container]\n tags:\n - { name: form.type, alias: eclore_user_profile }\n\n ecloreuser.admin.associationmember:\n class: eclore\\userBundle\\Admin\\AssociationMemberAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Profils\", label: \"AssociationMember\" }\n arguments: [~, eclore\\userBundle\\Entity\\AssociationMember, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.institutionmember:\n class: eclore\\userBundle\\Admin\\InstitutionMemberAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Profils\", label: \"InstitutionMember\" }\n arguments: [~, eclore\\userBundle\\Entity\\InstitutionMember, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.institution:\n class: eclore\\userBundle\\Admin\\InstitutionAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Groupes\", label: \"Institution\" }\n arguments: [~, eclore\\userBundle\\Entity\\Institution, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n \n ecloreuser.admin.association:\n class: eclore\\userBundle\\Admin\\AssociationAdmin\n tags:\n - { name: sonata.admin, manager_type: orm, group: \"Groupes\", label: \"Association\" }\n arguments: [~, eclore\\userBundle\\Entity\\Association, SonataAdminBundle:CRUD]\n calls:\n - [ setTranslationDomain, [ecloreuserBundle]]\n\n ecloreuser.admin.user:\n class: eclore\\userBundle\\Admin\\UserAdmin\n arguments: [~, eclore\\userBundle\\Entity\\User, SonataAdminBundle:CRUD]\n tags:\n - {name: sonata.admin, manager_type: orm, group: \"Membres\", label: User}\n\n ecloreuser.admin.young:\n class: eclore\\userBundle\\Admin\\YoungAdmin\n arguments: [~, eclore\\userBundle\\Entity\\Young, SonataAdminBundle:CRUD]\n tags:\n - {name: sonata.admin, manager_type: orm, group: \"Profils\", label: \"Jeune\"}\n \n ecloreuser.admin.notification:\n class: eclore\\userBundle\\Admin\\NotificationAdmin\n arguments: [~, eclore\\userBundle\\Entity\\Notification, SonataAdminBundle:CRUD]\n tags:\n - {name: sonata.admin, manager_type: orm, group: \"Entités\", label: \"Notifications\"}\n \n ecloreuser.admin.image:\n class: eclore\\userBundle\\Admin\\ImageAdmin\n arguments: [~, eclore\\userBundle\\Entity\\Image, SonataAdminBundle:CRUD]\n tags:\n - {name: sonata.admin, manager_type: orm, group: \"Entités\", label: Image}\n \n sonata.block.service.overview:\n class: eclore\\userBundle\\Block\\overviewBlockService\n arguments: [\"sonata.block.service.overview\", @templating, @doctrine.orm.entity_manager]\n tags:\n - {name: sonata.block, }\n\n spy_timeline.timeline_spread:\n class: eclore\\userBundle\\Timeline\\TimelineSpread\n arguments: [@service_container]\n tags:\n - {name: spy_timeline.spread} \n \n ecloreuser.timeline_listener:\n class: eclore\\userBundle\\Timeline\\TimelineListener\n arguments: [@service_container]\n tags:\n - { name: kernel.event_listener, event: ecloreuser.timeline.contact_ack, method: onContactAck }\n - { name: kernel.event_listener, event: ecloreuser.timeline.validated_PA, method: onValidatedPA }\n - { name: kernel.event_listener, event: ecloreuser.timeline.new_PA, method: onNewPA }\n - { name: kernel.event_listener, event: ecloreuser.timeline.rejected_PA, method: onRejectedPA }\n - { name: kernel.event_listener, event: ecloreuser.timeline.new_project, method: onNewProject }\n - { name: kernel.event_listener, event: ecloreuser.timeline.marked_young, method: onMarkedYoung }\n - { name: kernel.event_listener, event: ecloreuser.timeline.marked_project, method: onMarkedProject }\n - { name: kernel.event_listener, event: ecloreuser.timeline.new_user, method: onNewUser }\n - { name: kernel.event_listener, event: ecloreuser.timeline.pending_validation, method: onPendingValidation }\n\n ecloreuser.admin.news_post:\n class: eclore\\userBundle\\Admin\\NewsPostAdmin\n arguments: [~, eclore\\userBundle\\Entity\\NewsPost, SonataAdminBundle:CRUD]\n tags:\n - {name: sonata.admin, manager_type: orm, group: admin, label: NewsPost}\n \n\n\n/userBundle/Controller/ProjectsController.php\ncontainer->get('request'); \n \n if($request->isXmlHttpRequest())\n {\n $projects = $this->getDoctrine()\n ->getManager()\n ->createQuery('select p FROM ecloreuserBundle:Project p\n WHERE p.endDate > :date AND p.enabled = :enabled')\n ->setParameter('date', new \\DateTime())\n ->setParameter('enabled', true)\n ->getResult();\n $serializer = $this->container->get('jms_serializer');\n $response = new Response();\n $response->setContent($serializer->serialize($projects, 'json'));\n $response->headers->set('Content-Type', 'application/json');\n return $response;\n /*\n [{\"id\":1,\"project_name\":\"sdfgdsg\",\"description\":\"sdrgsdg\",\n \"association\":{\"id\":1,\"associationName\":\"banqure alim\"},\n \"project_applications\":0,\"start_date\":\"2014-01-01T00:00:00+0000\",\"end_date\":\"2017-01-01T00:00:00+0000\",\n \"labels\":{\"id\":1,\"name\":\"social\"},\"address\":\"Aix-en-Provence, France\",\"city\":\"Aix-en-Provence\",\n \"country\":\"France\",\"lat\":\"43.529742\",\"lng\":\"5.4474270000000615\"}]\n */\n }else\n {\n $repository = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:ProjectLabels');\n $labels = $repository->findAll(); \n \n return $this->render('ecloreuserBundle:Projects:rechercher.html.twig');\n }\n }\n \n \n public function showProjectAction($id)\n {\n $repository = $this->getDoctrine()\n ->getManager()\n ->getRepository('ecloreuserBundle:Project');\n $project = $repository->find($id);\n //get timeline\n $actionManager = $this->get('spy_timeline.action_manager');\n $subject = $actionManager->findOrCreateComponent($project);\n $timelineManager = $this->get('spy_timeline.timeline_manager');\n $timeline = $timelineManager->getTimeline($subject, array('page' => 1, 'max_per_page' => '10', 'paginate' => true));\n \n return $this->render('ecloreuserBundle:Projects:show-project.html.twig', array('proj'=>$project, 'timeline_coll'=>$timeline));\n }\n \n \n}\n/userBundle/Resources/views/Profile/recommendations.html.twig\n{% extends \"ecloreuserBundle::page_lambda.html.twig\" %}\n\n{% block title %}Espace membre{% endblock %}\n\n{%set color='vert'%}\n{%set first='Mon Éclore'%}\n{%set second='Espace personnel'%}\n\n{% block content %}\n{%include \"ecloreuserBundle::menu_user.html.twig\"%}\n
    \n

    Mes recommandations

    \n{%if app.user.hasRole('ROLE_YOUNG')%}\nCes recommandations sont visibles par les responsables des projets auxquels vous postulez. N'hésitez pas à les utiliser également hors du réseau Eclore !\n

    \n{%endif%}\n\n\n{%if recomm|length>0 %}\n\n\n {% for rec in recomm %}\n\t

    Recommandation de {{rec.sender}} en date du {{rec.initDate|date('m/d/Y')}}.

    \n
    {{rec.project}}
    \n\t{{rec.message}}\n {%endfor%}\n\n{%else%}\n Pas encore de recommandations.\n{%endif%}\n
    \n
    \n{% endblock %}\n"},"directory_id":{"kind":"string","value":"a248e675b26b8b64211eaaf210634223aebd18d3"},"languages":{"kind":"list like","value":["Twig","YAML","JavaScript","PHP","CSS"],"string":"[\n \"Twig\",\n \"YAML\",\n \"JavaScript\",\n \"PHP\",\n \"CSS\"\n]"},"num_files":{"kind":"number","value":104,"string":"104"},"repo_language":{"kind":"string","value":"Twig"},"repo_name":{"kind":"string","value":"Luc-Darme/source_symfony"},"revision_id":{"kind":"string","value":"f3549d63c144fa47cbcb79bcc696977bcfda027a"},"snapshot_id":{"kind":"string","value":"9b132682efe97c18d0378d9e2f2ad5593e0293c1"}}},{"rowIdx":9931,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"/**\n * Paper Card (pseudo)\n */\n\n.card\n\tdisplay: block\n\tposition: relative\n\tbackground: $white\n\tborder-radius: 2px\n\tmargin: 0 0 $base-spacing\n\tpadding: $base-spacing\n\t@extend %shadow\n\n\th2\n\t\tmargin-bottom: $base-spacing\n\t\n\t@media screen and (min-width: 800px)\n\t\tmargin: 1vh auto\n\t\twidth: 75%\n\t@media screen and (min-width: 1200px)\n\t\tmargin: 1vh auto\n\t\twidth: 50%const initialState = {\n loading: false,\n scroll: 0\n}\n\nexport default (state = initialState, action) => {\n // console.log(action)\n // console.log(state)\n\n switch (action.type) {\n case 'LOADING':\n return Object.assign({}, state, {\n loading: true\n })\n\n case 'NOT_LOADING':\n return Object.assign({},state,{\n loading: false\n })\n\n case 'SAVESCROLL':\n return Object.assign({},state,{\n scroll: action.scroll\n })\n\n default:\n return state\n }\n}\n.btn\n text-align: right\n text-transform: small-caps\n a\n color: $black\n padding: 10px\n margin: 13px\n border: 1px solid $black\n border-radius: 5px\n cursor: pointer\n a:hover\n color: $white\n background: $black\n padding: 10px\n margin: 13px\n border: 1px solid $white\n border-radius: 5px\n cursor: pointer\n/**\n * `Home` Page Component\n */\n\n.page__home\n\tul\n\t\tpadding-left: 2 * $base-spacing\n\t.content\n\t\tdisplay: block\n .url\n float: right\n line-height: 3em\n .logo\n display: inline-block\n width: 10%\n height: 2em\n object-fit: contain\n // float: right\n .read\n float: left\n width: 49%\n display: inline-block\n .small\n font-size: 0.8em\n display: inline-block\n width: 50%\n text-align: right\n\t.card\n\t\tmin-height: 110px\n\t\tdisplay: block\n\n\n\t.refresh-background\n\t\tbackground-color: #D91E36\n\t\twidth: 50px\n\t\theight: 50px\n\t\tborder-radius: 50%\n\t\tposition: fixed\n\t\tbottom: 5%\n\t\tright: 5%\n\t\tcursor: pointer\n\t\t.refresh\n\t\t\tline-height: 50px\n\t\t\tcolor: white\n\t\t\t// padding: 14px\n\t\t\ttransform: translateX(12.5px)\n\n\n\n\n\n\timg\n\t\twidth: 110%\n\t\tmax-height: 110px\n\t\t// border-radius: 3px\n\t\t// float: right\n\t\t// right: 1%\n\t\t// top: 1%\n\t\t// position: absolute\n\t\tobject-fit: cover\n\t\tdisplay: block\n\t\tmargin: $base-unit auto\n\t\t// max-width: 60 * $base-spacing // 960\n\n\n\timg.loader\n\t width: 100px\n\t height: auto\n\t display: block\n\t margin: 10vh auto\n\t position: relative\nconst initialState = {\n articles: [],\n sources: [],\n remoteSources: []\n}\n\nexport default (state = initialState, action) => {\n // console.log(action)\n // console.log(state.articles[action.id])\n // let sources\n\n switch (action.type) {\n case 'LOADED':\n let newArticles = action.articles.sort((a,b)=>{\n if (new Date(a.publishedAt) < new Date(b.publishedAt)) return 1\n if (new Date(a.publishedAt) > new Date(b.publishedAt)) return -1\n return 0\n })\n // console.log('LOADED NEWS')\n return Object.assign({}, state,{\n articles: newArticles\n })\n\n case 'CLEAR':\n return {\n articles: []\n }\n\n case 'ADD SOURCE':\n let sources = state.sources.concat([action.source])\n // console.log('added source', sources)\n return Object.assign({}, state, {\n sources\n })\n\n case 'REMOVE SOURCE':\n sources = state.sources.filter(source=>source!==action.source)\n // console.log('removed source', sources)\n return Object.assign({}, state, {\n sources\n })\n\n case 'LOAD REMOTE SOURCES':\n return Object.assign({}, state, {\n remoteSources: action.remoteSources\n })\n\n case 'READ':\n let readArticles = state.articles.map((article, index)=>{\n if(index === action.id){\n article['read'] = true\n return article\n }else{\n return article\n }\n })\n return Object.assign({}, state, {\n articles: readArticles\n })\n\n\n\n default:\n // console.log('DEFAULT NEWS');\n return state\n }\n}\n/**\n * `Article` Page Component\n */\n\n.page__settings\n\t.logo-container\n\t\tdisplay: flex\n\t\tjustify-content: center\n\t\tflex-wrap: wrap\n\n\t.logo\n\t\twidth: 120px\n\t\theight: 120px\n\t\tobject-fit: contain\n\t\talign-self: center\n\t\tmargin: 5px\n\t\tpadding: 10px\n\t\tborder-radius: 5px\n\t.glow\n\t\tbox-shadow: 0px 0px 10px #3fb0ac\nrequire(\"babel-polyfill\");\nimport { render } from 'preact';\nimport 'whatwg-fetch';\nimport './index.sass';\n\nlet elem, App;\nfunction init() {\n\tApp = require('./views').default;\n\telem = render(App, document.getElementById('root'), elem);\n}\n\ninit();\n\nif (process.env.NODE_ENV === 'production') {\n\t// cache all assets if browser supports serviceworker\n require('offline-plugin/runtime').install();\n\tif ('serviceWorker' in navigator && location.protocol === 'https:') {\n\t\t// navigator.serviceWorker.register('/service-worker.js');\n\n\t}\n\n\t// add Google Analytics\n\t(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\t})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');\n\tga('create', 'UA-XXXXXXXX-X', 'auto');\n\tga('send', 'pageview');\n} else {\n\t// use preact's devtools\n\trequire('preact/devtools');\n\t// listen for HMR\n\tif (module.hot) {\n\t\tmodule.hot.accept('./views', init);\n\t}\n}\n/**\n * `Article` Page Component\n */\n\n.page__article\n\th1\n\t\ttext-transform: capitalize\n\t\tmargin-bottom: $base-spacing\n\tsmall\n\t\tdisplay: block\n\t\ttext-indent: $base-spacing\n\t\tfont-size: 65%\n\t\topacity: 0.65\n\t\tfont-style: italic\n\t.back, p\n\t\tdisplay: block\n\t\tmargin-bottom: $base-spacing\n\timg\n\t\tdisplay: block\n\t\tmargin: 10px auto\n\t\tborder-radius: 5px\n\t\twidth: 33%\n\t\theight: auto\n\t@media screen and (min-width: 800px)\n\t\tmargin: 1vh auto\n\t\twidth: 75%\n\t@media screen and (min-width: 1200px)\n\t\tmargin: 1vh auto\n\t\twidth: 50%\n\t@media screen and (max-width: 320px)\n\t\timg\n\t\t\twidth: 80%\n\t\t\theight: auto\n\t@media screen and (max-width: 540px)\n\t\timg\n\t\t\twidth: 80%\n\t\t\theight: auto\n\t\n// Ya need sum cawfee! If yous know what im sayin! Spoken like a tru New Yorka.\n\n'use strict'\nconst admin = require('firebase-admin');\nconst fetch = require('node-fetch');\nconst {NEWSAPI_KEY, MERCURY_KEY, FB_URL} = require('./secrets.json');\nconst serviceAccount = require('./sa.json');\n// const serviceAccount = JSON.parse(SA)\nadmin.initializeApp({\n credential: admin.credential.cert(serviceAccount),\n databaseURL: \"https://newscraper-21f8a.firebaseio.com\"\n})\nconst database = admin.database();\n\ndatabase.ref('/news').set({});\n\n//fetch sources in a promise\nconst fetchSources = () => new Promise(resolve => {\n fetch(`https://newsapi.org/v2/sources?country=us&language=en&apiKey=${NEWSAPI_KEY}`)\n .then(r=>r.json())\n .then(data=>resolve(data.sources.map(source=> source.id)));\n});\n\nconst fetchHeadlines = source => new Promise(resolve => {\n fetch(`https://newsapi.org/v2/top-headlines?pageSize=100&sources=${source}&apiKey=${NEWSAPI_KEY}`)\n .then(r=>r.json())\n .then(data=>resolve(data.articles));\n});\n\nconst scrapeContent = article => new Promise(resolve => {\n let options = {\n headers: {\n 'x-api-key': MERCURY_KEY\n }\n }\n fetch(`https://mercury.postlight.com/parser?url=${article.url}`,options)\n .then(r=>r.json())\n .then(data=> {\n article['content'] = data['content'];\n article['word_count'] = data['word_count'];\n resolve(article);\n })\n .catch(err=>{\n console.log(err);\n resolve(article);\n })\n});\n\n//take advantage of the async await cycle to\n//avoid callback hell\nasync function worker(){\n let sources = await fetchSources();\n console.log('SOURCES', sources.length);\n let articles = {\n length: 0\n };\n console.log('Working on it...');\n\n for(let i=0; i < sources.length; i++) {\n console.log('trying', sources[i]);\n let tempArticles = await fetchHeadlines(sources[i]);\n console.log(tempArticles.length);\n if(!tempArticles) continue;\n\n console.log('scraping...');\n let scrapedArticles = [];\n for(let j=0; j < tempArticles.length; j++) {\n let tempArticle = tempArticles[j];\n tempArticle = await scrapeContent(tempArticle);\n if (tempArticle['content']) {\n scrapedArticles.push(JSON.stringify(tempArticle));\n }\n }\n articles[sources[i]] = scrapedArticles;\n articles.length += articles[sources[i]].length;\n }\n\n database.ref('/news').set(articles)\n .then(snap=>{\n console.log(articles.length, ' items set!');\n process.exit();\n })\n .catch(r=>console.log(r));\n}\n\nworker();\n/**\n * Nav / Header\n */\n\n$header-height: 10 * $base-unit\n\n.home-button\n\tleft: 0\n\tfloat: left\n.cog-button\n\tright: 0\n\tfloat: right\n\n.header\n\tposition: absolute\n\theight: $header-height\n\twidth: 100%\n\tpadding: 0\n\ttop: 0\n\tleft: 0\n\tright: 0\n\tbackground: $primary\n\t@extend %shadow\n\tz-index: 50\n\n\t.material-icons\n\t\tfont-size: 36px\n\t\ttransform: translateY(13px)\n\n\th1\n\t\t// position: absolute\n\t\tmargin: 0 auto\n\t\tpadding: 0 $base-spacing\n\t\tfont-size: 24px\n\t\tline-height: $header-height\n\t\tfont-weight: 400\n\t\tcolor: $white\n\n\tnav\n\t\tfont-size: 100%\n\n\t\ta\n\t\t\tposition: absolute\n\t\t\ttop: 0\n\t\t\tdisplay: inline-block\n\t\t\theight: $header-height\n\t\t\tline-height: $header-height\n\t\t\tpadding: 0 $base-spacing\n\t\t\ttext-align: center\n\t\t\tmin-width: 50px\n\t\t\tbackground: rgba($white, 0)\n\t\t\twill-change: background-color\n\t\t\ttext-decoration: none\n\t\t\tcolor: $offwhite\n\t\t\t&:hover,\n\t\t\t&:active\n\t\t\t\tbackground: rgba($white, 0.3)\n\n\t@media screen and (max-width: 401px)\n\t\tnav a\n\t\t\tpadding: 0 $base-spacing/2\n\t\t\tmin-width: $base-spacing*2\n\t@media screen and (max-width: 321px)\n\t\th1\n\t\t\tfont-size: 18px\nimport {\n take,\n call,\n put,\n takeEvery,\n takeLatest\n} from 'redux-saga/effects';\n\n//BAD SCOPING IDK. TODO OPTIMIZE\nlet articles = []\nlet sources = []\nlet userSources = []\n\nexport function* helloSaga() {\n // console.log('Hello Sagas!');\n}\n\n\nexport async function fetchSources(){\n // console.log('in fetch sources');\n let returnData;\n await fetch('https://newsapi.org/v1/sources?language=en&country=us').then(r=>r.json()).then(data=> returnData = data);\n // console.log(returnData);\n return returnData.sources;\n}\n\nexport async function fetchNews(source){\n // console.log('in fetch');\n let returnData;\n await fetch('https://newscraper-21f8a.firebaseio.com/news/'+source+'.json').then(r=>r.json()).then(data=> returnData = data);\n let transformedArticles = [];\n if (returnData) transformedArticles = returnData.map(d=>JSON.parse(d));\n return transformedArticles;\n}\n\nexport function* loadSources() {\n // console.log('in the saga for loading news');\n // yield put({type: 'LOADING'})\n try {\n sources = yield fetchSources();\n yield put({ type: 'LOAD REMOTE SOURCES', remoteSources: sources})\n }catch(e){\n // console.log(e)\n }\n}\n\nexport function* loadNews(action) {\n // console.log('got it');\n yield put({type: 'LOADING'});\n try{\n // console.log('this far');\n articles = []\n userSources = [].concat(action.sources);\n // console.log(articles);\n while (userSources.length > 0 ){\n articles = articles.concat(yield fetchNews(userSources.pop()))\n }\n\n yield put({type: 'LOADED', articles});\n yield put({type: 'NOT_LOADING'});\n } catch(e){\n console.log(e);\n yield put({type: 'NOT_LOADING'});\n }\n\n}\n\nexport function* watchLoadNews(){\n yield takeLatest('LOAD', loadNews);\n yield takeLatest('LOAD SOURCES', loadSources);\n}\n\nexport default function* rootSaga() {\n yield [\n helloSaga(),\n watchLoadNews()\n ]\n}\n// Worker ants are proud of this file.\n\n'use strict'\nconst admin = require('firebase-admin')\nconst request = require('request')\nconst {NEWSAPI_KEY, MERCURY_KEY, FB_URL} = require('./secrets.json')\nconst serviceAccount = require('./sa.json')\n// const serviceAccount = JSON.parse(SA)\nadmin.initializeApp({\n credential: admin.credential.cert(serviceAccount),\n databaseURL: \"https://newscraper-21f8a.firebaseio.com\"\n})\nconst database = admin.database();\n\ndatabase.ref('/news').set({})\n\n//fetch sources\nrequest.get(`https://newsapi.org/v2/sources?country=us&language=en&apiKey=${NEWSAPI_KEY}`, (err, response, data) => {\n data = JSON.parse(data)\n let sourcelist = data.sources.map(source=> source.id);\n let final = {length: 0}\n console.log(sourcelist.length, \"SOURCES\")\n request.get(`https://newsapi.org/v2/top-headlines?pageSize=100&sources=${sourcelist.toString()}&apiKey=${NEWSAPI_KEY}`, (err, response, body) => {\n let data = JSON.parse(body)\n console.log(data.totalResults, \"RESULTS\")\n data.articles.map((article, articlesIndex) => {\n let options = {\n url: `https://mercury.postlight.com/parser?url=${article.url}`,\n headers: {\n 'x-api-key': MERCURY_KEY\n }\n }\n request.get(options, (err, response, scraped) => {\n article['content'] = JSON.parse(scraped)['content']\n\n let tmpArticle = JSON.stringify(article);\n if (final[article.source.id]) {\n final[article.source.id].push(tmpArticle);\n } else {\n final[article.source.id] = [tmpArticle];\n }\n\n final.length++;\n\n if (final.length === data.articles.length) {\n database.ref('/news').set(final)\n .then(snap=>{\n console.log('set!');\n process.exit();\n }).catch(r=>console.log(r));\n console.log(final.length, \"ITEMS\")\n }\n })\n })\n })\n})\n# NewScraper 2.0\n\n![screen](screenshot.png)\n\nProgressive web app for reading fresh news offline in the **subway** from various news sources. Open [NewScraper 2.0](https://newscraper.surge.sh) on your phone and add it to your homescreen to see the magic!\n\n## Tech Stack\n\n- [Webtask](https://webtask.io)\n- [Preact-JS Starter](https://github.com/lukeed/preact-starter) - For this awesome offline ready boilerplate. [Preact](https://preactjs.com/) Isn't that different from React, it only weighs 3KB!\n- [The News Api](http://newsapi.org) - Awesome news aggregation api. I'll definitely expand this app to take full advantage of the many sources here.\n- [Mercury Api](https://mercury.postlight.com/web-parser/) - Amazing time saver, it goes and builds a _readable_ version of whatever article you supply it. _Think pocket/instapaper._\n\n## Running/Deploying\n\n#### Installation\n\n - `git clone` to clone this repo.\n - `npm install` (or `yarn` if you're hip like me).\n\n#### Running Locally\n\n - Make sure you have the `MERCURY_KEY` and `NEWS_API` keys in the file called `secrets.json`.\n - If you're working on the worker, save your firebase-admin sevice account as `sa.json`.\n - `npm run watch`\n\n#### Deploying\n\n - Run `npm run build`, this will spit out the production front-end in `dist` for you to serve on static hosting.\n\n\n\n## To-Do\n\n- More news sources. √\n- Loading bar because I'm masochistic? _(I heard they were super hard.)_\n- Transitions between views.\n- Refine service worker, to make it more reliable. √\n- Style for iOS devices (Ew! But needed for dumb iPhone X).\nimport { h } from 'preact';\n\nexport default function (props) {\n\treturn
    { props.children }
    \n}\nimport { h } from 'preact';\nimport Card from '../tags/card';\n\nconst links = [{\n\tname: 'lukeed/preact-starter',\n\tdesc: 'A Webpack2 starter for building SPA / PWA / offline front-end apps with Preact',\n\thref: 'https://github.com/lukeed/preact-starter'\n}, {\n\tname: 'developit/preact',\n\tdesc: 'Fast 3kb React alternative with the same ES6 API. Components & Virtual DOM.',\n\thref: 'https://www.npmjs.com/package/preact'\n}, {\n\tname: 'developit/preact-router',\n\tdesc: 'URL router for Preact.',\n\thref: 'https://www.npmjs.com/package/preact-router'\n}, {\n\tname: 'webpack/webpack',\n\tdesc: 'A bundler for javascript and friends. Allows for code splitting & asynchronous lazy-loading.',\n\thref: 'https://github.com/webpack/webpack'\n}, {\n\tname: 'FormidableLabs/webpack-dashboard',\n\tdesc: 'A CLI dashboard for webpack-dev-server',\n\thref: 'https://github.com/FormidableLabs/webpack-dashboard'\n}, {\n\tname: 'zeit/now',\n\tdesc: 'Free (OSS) realtime global deployments',\n\thref: 'https://zeit.co/now'\n}, {\n\tname: 'zeit/serve',\n\tdesc: 'Single-command HTTP directory listing and file serving',\n\thref: 'https://github.com/zeit/serve'\n}];\n\nexport default function (props) {\n\treturn (\n\t\t
    \n\t\t\t\n\t\t\t\t

    Credits:

    \n\t\t\t\t

    Resources used within boilerplate:

    \n\t\t\t
    \n\n\t\t\t\n\t\t
    \n\t)\n}\nimport { h } from 'preact';\nimport { Link } from 'preact-router';\nimport Card from '../tags/card';\nimport Button from '../tags/button';\nimport CardLink from '../tags/card-link';\nimport {connect} from 'react-redux'\nimport timeago from 'timeago.js';\n\nconst mapStateToProps = state =>({\n news: state.news.articles,\n sources: state.news.sources,\n ui: state.ui\n})\n\nconst mapDispatchToProps = dispatch =>({\n load: (sources)=> {\n // console.log('map state')\n dispatch({type: 'LOAD', sources})\n },\n read: id=> dispatch({type: 'READ', id: id}),\n saveScroll: ()=> dispatch({type: 'SAVESCROLL', scroll: window.scrollY})\n})\n\n\nconst Home = ({ui,news, sources, load, saveScroll, read}) => {\n console.log(sources)\n setTimeout(()=>window.scrollTo(0,ui.scroll),50)\n\n const imgError = e =>{\n e.target.style.display = \"none\"\n }\n\tif(ui.loading){\n return (\n
    \n
    \n
    \n

    This takes a bit, hold onto your socks
    ( ͡° ͜ʖ ͡°)

    \n \"loading\"\n
    \n
    \n )\n }else{\n return (\n \t\t
    \n {news.length == 0 ?\n
    \n

    Hey! Welcome to my app!

    \n

    Newscraper is an app for reading news from popular news sources offline.

    \n

    You should add it to your homescreen for the best experience!

    \n
    \n
    \n

    \n Pick your favorite sources!\n

    \n
    \n
    \n :\n

    Latest News

    \n }\n {news.map((article,index)=>{\n\n //only return lengthy things, helps filter out weird stuff from hacker news\n if (article.content && article.content.length < 100) return null\n\n return(\n \n
    {read(index);saveScroll()}} className=\"content\">\n

    {article.url.split(\"/\")[2]}

    \n \n

    {article.title}

    \n {article.urlToImage ?\n e.target.src = \"/img/na.jpg\"}\n src={\"//api.rethumb.com/v1/square/300/\"+article.urlToImage} />\n :\n \n }\n

    {article.description}

    \n

    {article['read'] ? '✅' : ''}

    \n

    {\n timeago().format(new Date(article.publishedAt))\n }

    \n
    \n\n
    \n )\n })}\n
    \n
    load(sources)} class=\"refresh-background\">\n refresh\n
    \n
    \n \t\t
    \n \t)\n }\n}\n\nexport default connect(mapStateToProps,mapDispatchToProps)(Home)\nimport { h } from 'preact';\nimport { Link } from 'preact-router';\n\nexport default function (props) {\n return (\n \n )\n}\n/**\n * Reusable values\n */\n\n$purple: #34465d\n$black: #173e43\n$offwhite: md-color('grey', '100')\n$white: #FFF\n\n$primary: $purple\n\n$base-unit: 6px\n$base-spacing: 2 * $base-unit\nimport { h } from 'preact';\nimport { Link } from 'preact-router';\n\n\nconst extraHeader = () => {\n if(navigator.userAgent.includes('iPhone')||navigator.userAgent.includes('iPad')){\n return (\n {\n height: '72px',\n paddingTop: '12px'\n }\n )\n }else{\n return {}\n }\n}\n\nexport default function () {\n\n\treturn (\n\t\t
    \n\t\t\t

    NewScraper 2.0

    \n\t\t\t\n\t\t
    \n\t)\n}\nimport { h } from 'preact';\nimport { Link } from 'preact-router';\nimport Card from '../tags/card';\n\nimport {connect} from 'react-redux'\n\nconst mapStateToProps = state =>({\n\tsources: state.news.sources,\n\tremoteSources: state.news.remoteSources\n})\n\nconst mapDispatchToProps = dispatch =>({\n addSource: (source)=> {\n dispatch({type: 'ADD SOURCE', source})\n },\n removeSource: (source)=> {\n dispatch({type: 'REMOVE SOURCE', source})\n },\n loadSources: ()=> dispatch({type: 'LOAD SOURCES'})\n})\n\n\n// const sources = fetchSources().sources\n\n// const categories = {}\n// sources.map(source=>{\n// \tcategories[source.category] = ''\n// })\n// categories = Object.keys(categories)\n\nconst Settings = ({addSource, removeSource, loadSources, sources, remoteSources}) => { // <---- (props)\n\n\tlet checkButton;\n\tremoteSources.length == 0 ? loadSources() : checkButton = true;\n\n const imgError = e =>{\n e.target.style.display = \"none\"\n }\n\n\treturn (\n\t\t
    \n\t\t\t
    \n\n\t\t\t\t{remoteSources.map(item=>\n\t\t\t\t\tsources.indexOf(item.id) >= 0 ?\n removeSource(item.id)}\n class=\"logo glow\"\n onError={imgError}\n src={\"//logo.clearbit.com/\"+item.url.split(\"/\")[2]} />\n :\n addSource(item.id)}\n class=\"logo\"\n onError={imgError}\n src={\"//logo.clearbit.com/\"+item.url.split(\"/\")[2]} />\n\t\t\t\t)}\n\t\t\t
    \n\t\t
    \n\t)\n}\n\nexport default connect(mapStateToProps, mapDispatchToProps)(Settings)\n"},"directory_id":{"kind":"string","value":"ff6b2081ed8bd94a80820c01b20cf81b55d31d95"},"languages":{"kind":"list like","value":["Markdown","Sass","JavaScript"],"string":"[\n \"Markdown\",\n \"Sass\",\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":20,"string":"20"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"fizal619/newscraper-pwa"},"revision_id":{"kind":"string","value":"319312218e0f8b5bb7571e4ccb2c437a24ea9345"},"snapshot_id":{"kind":"string","value":"cced0c08781439226d8c594f7cff8703c42c894d"}}},{"rowIdx":9932,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"libsvm-csharp\n=============\n\nPublic source of C# implementation of libsvm by http://www.matthewajohnson.org/"},"directory_id":{"kind":"string","value":"9be23329a0cd716abc14a6bb441b55f01f544047"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Termina1/libsvm-csharp"},"revision_id":{"kind":"string","value":"ed79b74a8ee8670a2b50bbe3246dc3c930a0c8f1"},"snapshot_id":{"kind":"string","value":"a560f9e64c0b1d216e132104871ab98658a043a9"}}},{"rowIdx":9933,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"jwodder/botw-checklist/Makefile\nchecklist.pdf : checklist.tex\n\tpdflatex checklist.tex\n\tpdflatex checklist.tex\n\nchecklist.tex : mklist.py checklist.json\n\tpython3 mklist.py\n\nclean :\n\trm -f *.aux *.log checklist.tex\n/mklist.py\n#!/usr/bin/env python3\nfrom collections import defaultdict\nfrom contextlib import redirect_stdout\nfrom itertools import groupby\nimport json\nfrom operator import itemgetter\nimport re\n\nWEAPON_SPACE_START = 9\nWEAPON_SPACE_MAX = WEAPON_SPACE_START + 11\nBOW_SPACE_START = 5\nBOW_SPACE_MAX = BOW_SPACE_START + 8\nSHIELD_SPACE_START = 4\nSHIELD_SPACE_MAX = SHIELD_SPACE_START + 16\n\nwith open('checklist.json') as fp:\n data = json.load(fp)\n\ndef classify(iterable, field):\n classed = defaultdict(list)\n for obj in iterable:\n classed[obj[field]].append(obj)\n return classed\n\nshrines_by_region = classify(data[\"shrines\"], 'region')\nfor v in shrines_by_region.values():\n v.sort(key=itemgetter(\"name\"))\n\nquests_by_region = classify(data[\"side_quests\"], 'region')\nfor v in quests_by_region.values():\n v.sort(key=itemgetter(\"name\"))\n\nwith open('checklist.tex', 'w') as fp, redirect_stdout(fp):\n print(r'''\n\\documentclass[10pt]{article}\n\\usepackage{amssymb}\n\\usepackage{bbding}\n\\usepackage{enumitem}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{longtable}\n\\usepackage{multicol}\n\\usepackage{tikz}\n\\newcommand{\\dlc}{\\emph}\n\\newcommand{\\amiibo}{\\emph}\n\\newsavebox\\ltmcbox\n\\raggedcolumns\n\\makeatletter\n\\newlength{\\chest@width}\n\\setlength{\\chest@width}{1em}\n\\newlength{\\chest@height}\n\\setlength{\\chest@height}{\\dimexpr\\chest@width*618/1000\\relax}\n\\newlength{\\chest@roundness}\n\\setlength{\\chest@roundness}{\\dimexpr\\chest@width/5\\relax}\n\\newlength{\\chest@latchsize}\n\\setlength{\\chest@latchsize}{\\dimexpr\\chest@width/5\\relax}\n\\newlength{\\chest@latchHeight}\n\\setlength{\\chest@latchHeight}{\\dimexpr\\chest@height/2\\relax}\n\\newcommand{\\chest}{\n \\tikz{\n \\draw (0,0)\n [rounded corners=\\chest@roundness]\n -- (0, \\chest@height)\n -- (\\chest@width, \\chest@height)\n [sharp corners]\n -- (\\chest@width, 0)\n -- (0,0);\n \\node (latch) at (\\dimexpr\\chest@width/2, \\chest@latchHeight)\n [circle,minimum width=\\chest@latchsize,inner sep=0,draw] {};\n \\draw ( 0, \\chest@latchHeight) -- (latch.west);\n \\draw (\\chest@width, \\chest@latchHeight) -- (latch.east);\n }\n}\n\\makeatother\n\\begin{document}\n''')\n\n print(r'\\begin{multicols}{2}')\n\n print(r'\\section*{Main Quests}')\n print(r'\\begin{itemize}[label=$\\square$]')\n for quest in data[\"main_quests\"]:\n print(r'\\item', quest)\n for quest in data[\"dlc_main_quests\"]:\n print(r'\\item \\dlc{', quest, '}', sep='')\n print(r'\\end{itemize}')\n\n print(r'\\columnbreak')\n print(r'\\section*{Recovered Memories}')\n print(r'\\begin{itemize}[label=$\\square$]')\n for i, mem in enumerate(data[\"memories\"], start=1):\n print(r'\\item ', i, '. ', mem, sep='')\n print(r'\\end{itemize}')\n\n print(r'\\end{multicols}')\n\n for region in data[\"regions\"]:\n print(r'\\section*{' + region[\"tower\"] + ' Region}')\n\n print(r'\\begin{itemize}[label=$\\square$]')\n print(r'\\item Activate', region[\"tower\"])\n print(r'\\end{itemize}')\n\n if quests_by_region[region[\"name\"]]:\n print(r'\\begin{multicols}{2}')\n print(r'\\subsection*{Shrines}')\n else:\n print(r'\\begin{multicols}{2}[\\subsection*{Shrines}]')\n print(r'\\begin{itemize}[label=$\\square$\\thinspace\\protect\\chest]')\n for shrine in shrines_by_region[region[\"name\"]]:\n if not shrine[\"dlc\"]:\n print(r'\\item {name} \\emph{{({trial})}}'.format(**shrine))\n if shrine[\"quest\"] is not None:\n print(r'\\begin{itemize}[label=$\\square$]')\n print(r'\\item Shrine Quest:', shrine[\"quest\"])\n print(r'\\end{itemize}')\n print(r'\\end{itemize}')\n\n if quests_by_region[region[\"name\"]]:\n print(r'\\columnbreak')\n print(r'\\subsection*{Side Quests}')\n print(r'\\begin{itemize}[label=$\\square$]')\n for quest in quests_by_region[region[\"name\"]]:\n print(r'\\item', quest[\"name\"])\n print(r'\\end{itemize}')\n\n print(r'\\end{multicols}')\n\n assert all((quest[\"region\"] is None) == quest.get(\"dlc\", False)\n for quest in data[\"side_quests\"])\n print(r'\\section*{DLC Side Quests}')\n print(r'\\begin{itemize}[label=$\\square$]')\n for quest in quests_by_region[None]:\n print(r'\\item \\dlc{', quest[\"name\"], '}', sep='')\n print(r'\\end{itemize}')\n\n print(r'\\newpage')\n print(r'\\begin{multicols}{2}[\\section*{Enhance Armor}]')\n # \n print(r'\\setbox\\ltmcbox\\vbox{\\makeatletter\\col@number\\@ne')\n print(r'\\begin{longtable}{r|ccccc}')\n boxes = r' & $\\square$' + r' & \\FiveStarOpen' * 4 + r'\\\\'\n armor_sets = classify(data[\"enhanceable_armor\"], 'set')\n ### TODO: Sort by headgear name instead of set name:\n for aset in sorted(k for k in armor_sets.keys() if k is not None):\n chest,head,legs = sorted(armor_sets[aset], key=itemgetter(\"body_part\"))\n if chest[\"amiibo\"]:\n pre, post = r'\\amiibo{', '}'\n else:\n pre, post = '', ''\n print(pre, head[\"name\"], post, boxes, sep='')\n print(pre, chest[\"name\"], post, boxes, sep='')\n print(pre, legs[\"name\"], post, boxes, sep='')\n print(r'\\hline')\n for armor in sorted(armor_sets[None], key=itemgetter(\"name\")):\n if armor[\"amiibo\"]:\n print(r'\\amiibo{', armor[\"name\"], '}', boxes, sep='')\n else:\n print(armor[\"name\"], boxes, sep='')\n print(r'\\end{longtable}')\n print(r'\\unskip\\unpenalty\\unpenalty}\\unvbox\\ltmcbox')\n print(r'\\end{multicols}')\n\n max_spaces = max(WEAPON_SPACE_MAX, BOW_SPACE_MAX, SHIELD_SPACE_MAX)\n print(r'\\section*{Expand Inventory}')\n print(r'\\begin{tabular}{r|', r'@{\\enskip}'.join('c' * max_spaces), '}',\n sep='')\n for i in range(1, max_spaces+1):\n print('&', i, end='')\n print(r'\\\\ \\hline')\n for label, start, maxxed in [\n ('Weapons', WEAPON_SPACE_START, WEAPON_SPACE_MAX),\n ('Bows', BOW_SPACE_START, BOW_SPACE_MAX),\n ('Shields', SHIELD_SPACE_START, SHIELD_SPACE_MAX),\n ]:\n print(label, '& --' * start, r'& $\\square$' * (maxxed - start),\n '& ' * (max_spaces - maxxed), r'\\\\')\n print(r'\\end{tabular}')\n\n print(r'\\section*{Overworld Mini-bosses}')\n for sg, pl, key, species in [\n ('Hinox', 'Hinoxes', 'hinoxes', 'Hinox'),\n ('Talus', 'Taluses', 'taluses', 'Stone Talus'),\n ('Molduga', 'Moldugas', 'moldugas', 'Molduga'),\n ]:\n print(r'\\subsection*{', pl, '}', sep='')\n print(r'\\begin{itemize}[label=$\\square$]')\n for boss in data[key]: ### TODO: Sort\n print(r'\\item', boss[\"region\"], '---', boss[\"display_location\"])\n if boss[\"species\"] != species:\n m = re.fullmatch(\n r'{} \\((.+)\\)'.format(re.escape(species)),\n boss[\"species\"],\n )\n if m:\n print('(', m.group(1), ')', sep='')\n else:\n print('(', boss[\"species\"], ')', sep='')\n print(r'\\item Get Medal of Honor:', sg, 'from Kilton')\n print(r'\\end{itemize}')\n\n print(r'\\section*{Other}')\n print(r'\\begin{itemize}[label=$\\square$]')\n for other in data[\"other\"]:\n print(r'\\item', other[\"name\"])\n print(r\"\\item Find dogs' buried treasures:\")\n print(r'\\begin{itemize}[label=$\\square$]')\n for dog in data[\"dogs\"]:\n print(r'\\item', dog[\"location\"])\n if dog.get(\"item_qty\"):\n print(r'({item} $\\times {item_qty}$)'.format_map(dog))\n else:\n print(r'({item})'.format_map(dog))\n print(r'\\end{itemize}')\n print(r'\\end{itemize}')\n\n print(r'\\newpage')\n print(r'\\section*{Hyrule Compendium}')\n print(r'\\begin{multicols}{2}')\n for section, entries in groupby(data[\"compendium\"], itemgetter(\"section\")):\n print(r'\\subsection*{', section, '}', sep='')\n print(r'\\begin{itemize}[label=$\\square$]')\n for e in entries:\n number = e[\"dlc_number\"]\n master = e[\"dlc_master_number\"]\n name = e[\"name\"]\n if number is None:\n number = '---'\n name = r'\\textbf{' + e[\"name\"] + '}'\n else:\n number = str(number).rjust(3, '~')\n if e[\"number\"] is None:\n name = r'\\dlc{' + e[\"name\"] + '}'\n print(r'\\item ', number, r'/\\textbf{', master, '}. ', name, sep='')\n print(r'\\end{itemize}')\n print(r'\\end{multicols}')\n\n ### TODO: DLC shrines\n\n print(r'\\end{document}')\n"},"directory_id":{"kind":"string","value":"29c57c8d78f4ada821aa8749e428654a16862350"},"languages":{"kind":"list like","value":["Makefile","Python"],"string":"[\n \"Makefile\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"Makefile"},"repo_name":{"kind":"string","value":"jwodder/botw-checklist"},"revision_id":{"kind":"string","value":"dc2640447819d03ef55789ba481aac9a5f2ce823"},"snapshot_id":{"kind":"string","value":"0293ddfd7fc5a6d293a1c5c3cdac983e213fa219"}}},{"rowIdx":9934,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"#define the model of the dataset or it is python dict configuration file\nSWARM_DESCRIPTION = {\n \"includedFields\": [ #information regarding the fields\n {\n \"fieldName\": \"timestamp\",\n \"fieldType\": \"datetime\"\n },\n {\n \"fieldName\": \"kw_energy_consumption\",\n \"fieldType\": \"float\",\n \"maxValue\": 53.0,\n \"minValue\": 0.0\n }\n ],\n \"streamDef\": { #defines fro where the input is coming from\n \"info\": \"kw_energy_consumption\",\n \"version\": 1,\n \"streams\": [\n {\n \"info\": \"Rec Center\",\n \"source\": \"file://rec-center-hourly.csv\",#source file i.e csv file\n \"columns\": [\n \"*\" #all the columns\n ]\n }\n ]\n },\n\n \"inferenceType\": \"TemporalMultiStep\",#type of prediction\n \"inferenceArgs\": {\n \"predictionSteps\": [#how many steps of future we want to predict\n 1\n ],\n \"predictedField\": \"kw_energy_consumption\"#field which is to be predicted\n },\n \"iterationCount\": -1,#-1 indicates all rows 1 indicates 1 row\n \"swarmSize\": \"medium\"#small is for debugging medium is fine large takes a lot of time and evaluates more models\n}\n# htm-NuPIC-\nMachine learning using HTM\nfrom nupic.frameworks.opf.modelfactory import ModelFactory\nfrom model_params import model_params\nfrom nupic.data.inference_shifter import InferenceShifter\nimport nupic_output\nimport datetime\nimport csv\nDATE_FORMAT = \"%m/%d/%y %H:%M\"\ndef createModel():\n print(\"executing\")\n model = ModelFactory.create(model_params.MODEL_PARAMS)\n model.enableInference({\n \"predictedField\": \"kw_energy_consumption\"\n })\n return model\ndef runModel(model):\n print(\"executing\")\n inputFilePath = \"rec-center-hourly.csv\"\n inputFile = open(inputFilePath, \"rb\")\n csvReader = csv.reader(inputFile)\n csvReader.next()\n csvReader.next()\n csvReader.next()\n shifter = InferenceShifter()\n output = nupic_output.NuPICPlotOutput([\"Rec Center\"])\n counter = 0\n for row in csvReader:\n counter += 1\n if counter % 100 == 0:\n print(\"Read %i lines ...\"%counter)\n timestamp = datetime.datetime.strptime(row[0], DATE_FORMAT)\n consumption = float(row[1])\n result = model.run({\n \"timestamp\": timestamp,\n \"kw_energy_consumption\": consumption\n })\n result = shifter.shift(result)\n prediction = result.inferences[\"multiStepBestPredictions\"][1]\n output.write([timestamp], [consumption], [prediction])\n inputFile.close()\n output.close()\ndef runHotGym():\n print(\"executing\")\n model = createModel()\n runModel(model)\nif __name__ == \"__main__\": \n runHotGym()"},"directory_id":{"kind":"string","value":"fcb5de11bab5218a9173896bdc83b714dda049b4"},"languages":{"kind":"list like","value":["Markdown","Python"],"string":"[\n \"Markdown\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"nattesharan/htm-NuPIC-"},"revision_id":{"kind":"string","value":"4ffc010bbb1f73e944158a5051248c3fdc9341fc"},"snapshot_id":{"kind":"string","value":"188838b9d4aaf14ffe0fbb87cc8b0052d43ad950"}}},{"rowIdx":9935,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"from copy import deepcopy\n\nfrom .visualization import Visualization\nfrom .data import Data\nfrom .values import ValueRef\nfrom .properties import PropertySet\nfrom .scales import DataRef, Scale\nfrom .marks import MarkProperties, MarkRef, Mark\nfrom .axes import Axis\n\ntry:\n import pandas as pd\nexcept ImportError:\n pd = None\n\ntry:\n import numpy as np\nexcept ImportError:\n np = None\n\n\n# TODO: list of factories:\n# - line\n# - bar\n# - stairs\n# - stem\n# - pie\n# - area\n# - polar\n# - rose\n# - compass\n# - box\n# - semilog / loglog\n# - hist\n# - contour\n# - scatter\n# - map\n\n\nclass BarFactory(object):\n\n def __init__(self, x_scale=None, y_scale=None, mark=None, width=None,\n height=None):\n if x_scale:\n self.x_scale = x_scale\n else:\n self.x_scale = Scale(\n name='x', range='width', type='ordinal',\n domain=DataRef(data='table', field='data.x'))\n\n if y_scale:\n self.y_scale = y_scale\n else:\n self.y_scale = Scale(\n name='y', range='height', type='linear', nice=True,\n domain=DataRef(data='table', field='data.y'))\n\n if mark:\n self.mark = mark\n else:\n self.mark = Mark(\n type='rect', from_=MarkRef(data='table'),\n properties=MarkProperties(\n enter=PropertySet(\n x=ValueRef(scale='x', field='data.x'),\n y=ValueRef(scale='y', field='data.y'),\n width=ValueRef(scale='x', band=True, offset=-1),\n y2=ValueRef(scale='y', value=0)),\n update=PropertySet(fill=ValueRef(value='steelblue'))))\n\n self.width = width or 400\n self.height = height or 200\n self.padding = {'top': 10, 'left': 30, 'bottom': 20, 'right': 10}\n self.x_axis = Axis(type='x', scale='x')\n self.y_axis = Axis(type='y', scale='y')\n\n def __call__(self, x, y, color=None, make_copies=True):\n\n vis = Visualization(width=self.width, height=self.height,\n padding=self.padding)\n\n vis.data.append(Data.from_iters(x=x, y=y))\n\n if make_copies:\n maybe_copy = deepcopy\n else:\n maybe_copy = lambda x: x\n\n vis.scales.extend(maybe_copy([self.x_scale, self.y_scale]))\n vis.axes.extend(maybe_copy([self.x_axis, self.y_axis]))\n vis.marks.extend(maybe_copy([self.mark]))\n\n if color:\n vis.marks[0].properties.update.fill.value = color\n\n return vis\n\n @property\n def color(self):\n return self.mark.properties.update.fill.value\n\n @color.setter\n def color(self, value):\n self.mark.properties.update.fill.value = value\n"},"directory_id":{"kind":"string","value":"6b8c8eb9b5ffe7075ec4a7c99f9a952d7060271e"},"languages":{"kind":"list like","value":["Python"],"string":"[\n \"Python\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Python"},"repo_name":{"kind":"string","value":"gauden/vincent"},"revision_id":{"kind":"string","value":"50262c7f26c6396cda324c5491d83ed1ebc6949e"},"snapshot_id":{"kind":"string","value":"b896d4c237c1964489a52012fc16b6e60b7e527a"}}},{"rowIdx":9936,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"dangpham3040/Dubaothoitiet/settings.gradle\ninclude ':app'\nrootProject.name = \"Dubaothoitiet\""},"directory_id":{"kind":"string","value":"a10211020ee61de78d434e9f360590d74bc2df9b"},"languages":{"kind":"list like","value":["Gradle"],"string":"[\n \"Gradle\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Gradle"},"repo_name":{"kind":"string","value":"dangpham3040/Dubaothoitiet"},"revision_id":{"kind":"string","value":"eb589b2d555df6ae48ac9d1a7201fa69ddcd5001"},"snapshot_id":{"kind":"string","value":"c1a0bb05d4257e5a621c51c0caf082680d5ea29d"}}},{"rowIdx":9937,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"jaeyoungchun/singularity-test-repos/README.md\n# singularity-test-repos\n\nTest repositories for Singularity binary images\n\n- bwa\n- samtools\n\n\nNOTE: you might need `git lfs` for big files./.gitattributes\nimages/bwa.img filter=lfs diff=lfs merge=lfs -text\nimages/samtools.img filter=lfs diff=lfs merge=lfs -text\n"},"directory_id":{"kind":"string","value":"47511fefd860c99a70eca23e95a5bbf9af0c0e25"},"languages":{"kind":"list like","value":["Git Attributes","Markdown"],"string":"[\n \"Git Attributes\",\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"Git Attributes"},"repo_name":{"kind":"string","value":"jaeyoungchun/singularity-test-repos"},"revision_id":{"kind":"string","value":"aac44ed5db2b89d674ae7795d66091c1b28ea6ea"},"snapshot_id":{"kind":"string","value":"9104f07e3d4fe1ef7f205d73efafa8de0ee92ad8"}}},{"rowIdx":9938,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# 达令\n\n\n-------------------\n\n[TOC]\n\n## 达令介绍\n\n>达令™是一家专注于全球好货的电商APP,与海外300多家知名品牌直接签约,商品都是全职买手从世界各地搜罗来的精品好货 —— [达令](https://baike.baidu.com/item/%E8%BE%BE%E4%BB%A4/17543007?fr=aladdin)\n###技术栈\n>vue2 + vuex + vue-router + webpack + ES6 \n\n\n### 项目运行\n>#####克隆到本地\ngit clone https://github.com/LImengna123/daling.git\n\n>##### 安装依赖\nnpm install\n\n >#####开启本地服务器localhost:8080\nnpm run dev\n\n>##### 发布环境\nnpm run build"},"directory_id":{"kind":"string","value":"d0d833b32548c4f6827c4e5ed4473c71e1eca9df"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"LImengna123/daling"},"revision_id":{"kind":"string","value":"02c0a0211c1a7c49ecd7690f70151307f31744e8"},"snapshot_id":{"kind":"string","value":"488b2d707d0624230f1b731a4ae4bdad743b176e"}}},{"rowIdx":9939,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"package gall.api;\n\nimport gall.impl.Image;\n\nimport java.util.Set;\n\n/**\n * Created by W on 13.06.2014.\n */\npublic interface GalleryDAO {\n void setGalleryExisting(String login);\n\n void removeAll(int id);\n\n String searchForGallery(String login);\n\n int putImg(int userId, String imgFilePath);\n\n Set getAllImg(int userId);\n\n Image viewImg(int imgId);\n}\n<%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%>\n<%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\" %>\n\n \n \n \n\n\n\n${message}\n\n
    \n\n
    \n
    \n Welcome ${login} !\n \"Home\"\n \"Log\n \"Remove\n \n
    \n\n

    \n

    \n
    \n User information:

    \n \n \n \n
    \n
    \n\n

    \n \"Add\n
    \n
    \n
    \n\n
    \n

    Vacancy |\n Search |\n Home>>

    \n
    \n\n
    \n

    ${errorMessage}


    \n \n \"Add\n \"Remove\n \n \n \"${id}\"\n \n\n \n \n\n \"Create\n\n \n
    \n\n

    \n

    Copyright (c)maret

    \n
    \n
    \n\n\npackage gall.impl;\n\nimport org.springframework.jdbc.core.RowMapper;\n\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\n/**\n * Created by W on 14.06.2014.\n */\npublic class GalleryRowMapper implements RowMapper {\n public Object mapRow(ResultSet rs, int rowNum) throws SQLException {\n\n Image image = new Image();\n image.setId(rs.getInt(\"ID\"));\n image.setUserId(rs.getInt(\"user_ID\"));\n image.setImgFilePath(rs.getString(\"img\"));\n return image;\n\n }\n}\npackage gall.impl;\n\nimport gall.api.GalleryDAO;\nimport org.springframework.dao.IncorrectResultSizeDataAccessException;\nimport org.springframework.jdbc.core.support.JdbcDaoSupport;\nimport org.springframework.jdbc.core.PreparedStatementCreator;\nimport org.springframework.jdbc.support.GeneratedKeyHolder;\nimport org.springframework.jdbc.support.KeyHolder;\n\nimport java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\nimport java.util.*;\n\n/**\n * Created by W on 13.06.2014.\n */\npublic class JDBCGalleryDAO extends JdbcDaoSupport implements GalleryDAO {\n @Override\n public void setGalleryExisting(String login) {\n String sql = \"UPDATE account \" + \"SET gallery = 'available'\"\n + \" WHERE login = ?\";\n getJdbcTemplate().update(sql, new Object[]{login});\n }\n\n @Override\n public void removeAll(int id) {\n\n String sqlForGallery = \"DELETE FROM gallery WHERE user_ID = ?\";\n getJdbcTemplate().update(sqlForGallery, new Object[]{id});\n\n String sqlForAccount = \"UPDATE account \" + \"SET gallery = null\"\n + \" WHERE ID = ?\";\n getJdbcTemplate().update(sqlForAccount, new Object[]{id});\n }\n\n @Override\n public String searchForGallery(String login) {\n String sql = \"SELECT gallery FROM account WHERE login = ?\";\n\n String galleryStatus = getJdbcTemplate().queryForObject(\n sql, new Object[]{login}, String.class);\n\n return galleryStatus;\n }\n\n\n @Override\n public int putImg(final int userId, final String imgFilePath) {\n final String sql = \"INSERT INTO gallery \" +\n \"(img, user_ID) VALUES (?, ?)\";\n KeyHolder keyHolder = new GeneratedKeyHolder();\n getJdbcTemplate().update(\n new PreparedStatementCreator() {\n public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {\n PreparedStatement ps =\n connection.prepareStatement(sql, new String[]{\"ID\"});\n ps.setString(1, imgFilePath);\n ps.setInt(2, userId);\n return ps;\n }\n },\n keyHolder\n );\n\n return keyHolder.getKey().intValue();\n\n }\n\n\n\n @Override\n @SuppressWarnings(\"rawtypes\")\n public Set getAllImg(int userId) {\n String sql = \"SELECT * FROM gallery WHERE user_ID = ?\";\n\n Set images = new HashSet();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{userId});\n for (Map row : rows) {\n Image img = new Image();\n\n img.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n img.setUserId(Integer.parseInt(String.valueOf(row.get(\"user_ID\"))));\n img.setImgFilePath((String) row.get(\"img\"));\n\n images.add(img);\n }\n return images;\n }\n\n @Override\n @SuppressWarnings({\"unchecked\"})\n public Image viewImg(int imgId) {\n String sql = \"SELECT * FROM gallery WHERE ID = ?\";\n\n Image image = null;\n try {\n image = (Image) getJdbcTemplate().queryForObject(sql, new Object[]{imgId}, new GalleryRowMapper());\n } catch (IncorrectResultSizeDataAccessException e) {\n image = null;\n }\n\n return image;\n }\n}\npackage com.web.controll;\n\n\nimport account.except.NotAllFieldsFilledException;\nimport account.impl.NullValidator;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.security.core.Authentication;\nimport org.springframework.security.core.context.SecurityContextHolder;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.ui.ModelMap;\nimport org.springframework.web.bind.annotation.*;\nimport vacancy.api.VacancyManagement;\nimport vacancy.except.NoVacancyException;\nimport vacancy.impl.Vacancy;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 18.03.14\n * Time: 10:28\n * To change this template use File | Settings | File Templates.\n */\n@Controller\npublic class VacancyController {\n\n @Autowired\n @Qualifier(\"VacancyManagementBean\")\n public VacancyManagement vacancyManagement;\n\n\n @RequestMapping(value = \"/vacancy\", method = RequestMethod.GET)\n public String openVacancyPage(ModelMap model) {\n\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n\n model.addAttribute(\"login\", login);\n model.addAttribute(\"message\", \"Vacancies\");\n\n return \"vacancies\";\n }\n\n @RequestMapping(value = \"/view_vacancy\", method = RequestMethod.GET)\n public String viewVacancy(@RequestParam(\"vacancy_id\") String id, ModelMap model) {\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n Integer vacancyId = Integer.valueOf(id);\n model.addAttribute(\"login\", login);\n model.addAttribute(\"message\", \"View vacancy\");\n try {\n Vacancy vacancy = vacancyManagement.viewVacancy(vacancyId);\n\n Map vacancyInf = new HashMap();\n\n vacancyInf.put(\"vacancy_name\", vacancy.getName());\n vacancyInf.put(\"category\", vacancy.getCategory());\n vacancyInf.put(\"occupation\", vacancy.getOccupation());\n vacancyInf.put(\"location\", vacancy.getLocation());\n vacancyInf.put(\"tell\", vacancy.getTell());\n vacancyInf.put(\"mail\", vacancy.getMail());\n vacancyInf.put(\"body\", vacancy.getBody());\n\n model.addAllAttributes(vacancyInf);\n\n } catch (NoVacancyException e) {\n model.addAttribute(\"errorMessage\", \"You must fill all fields!\");\n return \"view_vacancy\";\n }\n return \"view_vacancy\";\n }\n\n\n @RequestMapping(value = \"/open_vacancy\", method = RequestMethod.POST)\n public String openVacancy(@RequestParam(\"name\") String name, @RequestParam(\"category\") String category, @RequestParam(\"location\") String location, @RequestParam(\"occupation\") String occupation, @RequestParam(\"tell\") String tell, @RequestParam(\"mail\") String mail, @RequestParam(\"content\") String body, ModelMap model) {\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n model.addAttribute(\"login\", login);\n model.addAttribute(\"message\", \"Vacancies\");\n\n try {\n NullValidator.checkNull(name, location, occupation, mail, tell, body);\n Vacancy vacancy = vacancyManagement.openNewVacancy(name, category, occupation, location, tell, mail, body);\n model.addAttribute(\"Message\", \"You have opened new vacancy \");\n\n model.addAttribute(\"id\", vacancy.getId());\n\n Map vacancyInf = new HashMap();\n\n vacancyInf.put(\"vacancy_name\", vacancy.getName());\n vacancyInf.put(\"category\", vacancy.getCategory());\n vacancyInf.put(\"occupation\", vacancy.getOccupation());\n vacancyInf.put(\"location\", vacancy.getLocation());\n vacancyInf.put(\"tell\", vacancy.getTell());\n vacancyInf.put(\"mail\", vacancy.getMail());\n\n model.addAllAttributes(vacancyInf);\n\n } catch (NotAllFieldsFilledException e) {\n model.addAttribute(\"errorMessage\", \"You must fill all fields!\");\n return \"vacancies\";\n }\n return \"vacancy_open_success\";\n }\n\n\n @RequestMapping(value = \"/search_for_vacancies\", method = RequestMethod.GET, produces = \"application/json\")\n @ResponseBody\n public Map viewVacancyList(@RequestParam(\"category\") String category, @RequestParam(\"occupation\") String occupation, @RequestParam(\"location\") String location) {\n\n\n Map vacancies = null;\n try {\n if ((occupation.equals(\"\")) && (location.equals(\"\"))) {\n if (!category.equals(\"All\")) {\n vacancies = vacancyManagement.searchByCategory(category);\n } else {\n vacancies = vacancyManagement.showAllVacancies();\n }\n }\n if ((!occupation.equals(\"\")) && (location.equals(\"\"))) {\n if (!category.equals(\"All\")) {\n vacancies = vacancyManagement.searchByCategoryOccupation(category, occupation);\n } else {\n vacancies = vacancyManagement.searchByOccupation(occupation);\n }\n }\n if ((occupation.equals(\"\")) && (!location.equals(\"\"))) {\n if (!category.equals(\"All\")) {\n vacancies = vacancyManagement.searchByCategoryLocation(category, location);\n } else {\n vacancies = vacancyManagement.searchByLocation(location);\n }\n }\n if ((!occupation.equals(\"\")) && (!location.equals(\"\"))) {\n if (!category.equals(\"All\")) {\n vacancies = vacancyManagement.searchByCategoryOccupationLocation(category, occupation, location);\n } else {\n vacancies = vacancyManagement.searchByOccupationAndLocation(occupation, location);\n }\n }\n } catch (NoVacancyException e) {\n vacancies = null;\n }\n return vacancies;\n }\n}\n\npackage account.except;\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 15.01.14\n * Time: 13:05\n * To change this template use File | Settings | File Templates.\n */\npublic class AuthorityException extends Exception {\n private String message;\n\n public AuthorityException() {\n this.message = ErrorMessage.IncorrectPasswords.getErrorMassage();\n }\n\n public static enum ErrorMessage {\n IncorrectPasswords(\"Passwords do not match\" + \"\\n\");\n private String errorMassage;\n\n ErrorMessage(String errorMassage) {\n this.errorMassage = errorMassage;\n }\n\n private String getErrorMassage() {\n return errorMassage;\n }\n }\n\n @Override\n public String toString() {\n return message;\n }\n}\npackage account.impl;\n\nimport account.api.AccountDAO;\nimport org.springframework.dao.IncorrectResultSizeDataAccessException;\nimport org.springframework.jdbc.core.support.JdbcDaoSupport;\n\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * Created by W on 18.04.2014.\n */\npublic class JDBCAccountDAO extends JdbcDaoSupport implements AccountDAO {\n\n\n @Override\n public void putAccountToBase(Account account) {\n String sql = \"INSERT INTO account \" +\n \"(login, password_hash, name, surname, category, occupation, location, mail, sex) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\";\n\n getJdbcTemplate().update(sql, new Object[]{account.getLogin(), account.getPasswordHash(), account.getName(), account.getSurname(), account.getCategory(),\n account.getOccupation(), account.getLocation(), account.getMail(), account.getSex()});\n }\n\n @Override\n public void updateAccount(int id, String login, String newName, String newSurname, String newCategory, String newOccupation, String newLocation, String newSex, String newMail) {\n String sql = \"UPDATE account \" + \"SET login = ?, name = ?, surname = ?, category = ?, occupation = ?, location = ?, mail = ?, sex = ?\"\n + \" WHERE id = ?\";\n getJdbcTemplate().update(sql, new Object[]{login, newName, newSurname, newCategory,\n newOccupation, newLocation, newMail, newSex, id});\n }\n\n @Override\n public String getPasswordFromBase(String login) {\n\n String sql = \"SELECT password_hash FROM account WHERE login = ?\";\n\n String password_hash = getJdbcTemplate().queryForObject(\n sql, new Object[]{login}, String.class);\n\n return password_hash;\n\n }\n\n @Override\n @SuppressWarnings({\"unchecked\"})\n public Account getAccountFromBase(String login) {\n String sql = \"SELECT * FROM account WHERE login = ?\";\n Account account = null;\n try {\n account = (Account) getJdbcTemplate().queryForObject(sql, new Object[]{login}, new AccountRowMapper());\n } catch (IncorrectResultSizeDataAccessException e) {\n account = null;\n }\n\n return account;\n }\n\n @Override\n @SuppressWarnings(\"rawtypes\")\n public Map getAllEmp() {\n String sql = \"SELECT * FROM account\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql);\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n\n @Override\n public void removeAccountFromBase(String login) {\n String sql = \"DELETE FROM account WHERE login = ?\";\n getJdbcTemplate().update(sql, new Object[]{login});\n }\n\n @Override\n public Map getByCategory(String category) {\n String sql = \"SELECT * FROM account WHERE category = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{category});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n\n\n @Override\n public Map getByLocation(String location) {\n String sql = \"SELECT * FROM account WHERE location = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{location});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n @Override\n public Map getByOccupation(String occupation) {\n String sql = \"SELECT * FROM account WHERE occupation = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{occupation});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n @Override\n public Map getByOccupationLocation(String occupation, String location) {\n String sql = \"SELECT * FROM account WHERE occupation = ? AND location = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{occupation, location});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n\n @Override\n public Map getByCategoryLocation(String category, String location) {\n String sql = \"SELECT * FROM account WHERE category = ? AND location = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{category, location});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n @Override\n public Map getByCategoryOccupation(String category, String occupation) {\n String sql = \"SELECT * FROM account WHERE category = ? AND occupation = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{category, occupation});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n\n @Override\n public Map getByCategoryOccupationLocation(String category, String occupation, String location) {\n String sql = \"SELECT * FROM account WHERE category = ? AND occupation = ? AND location = ?\";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{category, occupation, location});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n @Override\n public Map getByLogin(String userLogin) {\n String sql = \"SELECT * FROM account WHERE login = ? \";\n\n Map accounts = new HashMap();\n List> rows = getJdbcTemplate().queryForList(sql, new Object[]{userLogin});\n\n for (Map row : rows) {\n Account account = new Account();\n\n account.setId(Integer.parseInt(String.valueOf(row.get(\"ID\"))));\n account.setLogin((String) row.get(\"login\"));\n account.setName((String) row.get(\"name\"));\n account.setSurname((String) row.get(\"surname\"));\n account.setCategory((String) row.get(\"category\"));\n account.setOccupation((String) row.get(\"occupation\"));\n account.setLocation((String) row.get(\"location\"));\n account.setMail((String) row.get(\"mail\"));\n account.setSex((String) row.get(\"sex\"));\n account.setCv((String) row.get(\"cv\"));\n\n accounts.put((String) row.get(\"login\"), account);\n }\n return accounts;\n }\n\n\n}\npackage vacancy.impl;\n\nimport account.impl.Account;\nimport org.springframework.jdbc.core.RowMapper;\n\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\n/**\n * Created by W on 18.04.2014.\n */\n@SuppressWarnings(\"rawtypes\")\npublic class VacancyRowMapper implements RowMapper {\n public Object mapRow(ResultSet rs, int rowNum) throws SQLException {\n\n Vacancy vacancy = new Vacancy();\n vacancy.setId(rs.getInt(\"ID\"));\n vacancy.setName(rs.getString(\"name\"));\n vacancy.setCategory(rs.getString(\"category\"));\n vacancy.setOccupation(rs.getString(\"occupation\"));\n vacancy.setLocation(rs.getString(\"location\"));\n vacancy.setMail(rs.getString(\"mail\"));\n vacancy.setTell(rs.getString(\"tell\"));\n vacancy.setBody(rs.getString(\"body\"));\n return vacancy;\n }\n}\npackage com.web.controll;\n\nimport account.api.AccountManagement;\nimport account.impl.Account;\nimport com.web.config.FileUpload;\nimport gall.api.GalleryManagement;\nimport gall.except.AvailabilityGalleryException;\nimport gall.impl.Image;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.http.MediaType;\nimport org.springframework.security.core.Authentication;\nimport org.springframework.security.core.context.SecurityContextHolder;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.ui.ModelMap;\nimport org.springframework.web.bind.annotation.*;\nimport org.springframework.web.multipart.MultipartFile;\n\nimport java.io.*;\nimport java.util.*;\n\n/**\n * Created by W on 02.06.2014.\n */\n@Controller\npublic class ImgUploadController {\n @Autowired\n @Qualifier(\"GalleryManagementBean\")\n public GalleryManagement galleryManagement;\n\n @Autowired\n @Qualifier(\"AccountManagementBean\")\n public AccountManagement management;\n\n @RequestMapping(value = \"/upload_images\", method = RequestMethod.GET)\n public String openUploadingPage(ModelMap model) {\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n model.addAttribute(\"login\", login);\n\n model.addAttribute(\"message\", \"Uploading page\");\n return \"upload_img\";\n }\n\n @RequestMapping(value = \"/upload_file\", method = RequestMethod.POST)\n public String uploadFile(@ModelAttribute(\"uploadForm\") FileUpload uploadForm,\n ModelMap model) throws IllegalStateException, IOException {\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n\n\n MultipartFile[] uploadedFiles = uploadForm.getFiles();\n List files = Arrays.asList(uploadedFiles);\n\n model.addAttribute(\"login\", login);\n\n int userId = management.viewAccount(login).getId();\n try {\n List imagesId = galleryManagement.addImg(login, files, userId);\n\n if (imagesId.isEmpty() == false) {\n model.addAttribute(\"files\", imagesId);\n model.addAttribute(\"login\", login);\n model.addAttribute(\"user_login\", login);\n model.addAttribute(\"Message\", \"Files have been successfully uploaded!\");\n return \"uploading_success\";\n } else {\n model.addAttribute(\"errorMessage\", \"No files have been uploaded\");\n return \"upload_img\";\n }\n } catch (IOException e) {\n model.addAttribute(\"errorMessage\", \"Sorry, request can't be processed.\");\n return \"upload_img\";\n } catch (AvailabilityGalleryException e) {\n model.addAttribute(\"errorMessage\", \"Sorry, request can't be processed. Please return to your account home-page and try create gallery again.\");\n return \"upload_img\";\n }\n }\n\n @RequestMapping(value = \"/remove_all_img\", method = RequestMethod.GET)\n public String removeAll(ModelMap model) throws IllegalStateException, IOException {\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n\n Account account = management.viewAccount(login);\n\n galleryManagement.removeGallery(login, account.getId());\n\n List imgIds = new ArrayList();\n\n String galleryStatus = galleryManagement.checkGalleryStatus(login);\n if (galleryStatus != null) {\n\n Set images = galleryManagement.viewAllImg(account.getId());\n for (Image image : images) {\n int imageId = image.getId();\n imgIds.add(imageId);\n }\n model.addAttribute(\"portfolio\", \"available\");\n model.addAttribute(\"files\", imgIds);\n\n } else {\n model.addAttribute(\"portfolio\", \"none\");\n }\n\n Map userInf = new HashMap();\n userInf.put(\"login\", login);\n userInf.put(\"message\", \"User information\");\n userInf.put(\"name\", account.getName());\n userInf.put(\"surname\", account.getSurname());\n userInf.put(\"category\", account.getCategory());\n userInf.put(\"occupation\", account.getOccupation());\n userInf.put(\"mail\", account.getMail());\n userInf.put(\"location\", account.getLocation());\n userInf.put(\"sex\", account.getSex());\n\n model.addAllAttributes(userInf);\n model.addAttribute(\"message\", \"User information\");\n\n return \"user_info\";\n }\n\n\n @RequestMapping(value = \"/image/{login}/{id}\", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)\n @ResponseBody\n public byte[] displayJPGImage(@PathVariable(\"id\") String id, @PathVariable(\"login\") String\n login) throws\n IOException {\n\n int ImgId = Integer.valueOf(id);\n try {\n byte[] bytes = galleryManagement.displayImg(login, ImgId);\n\n return bytes;\n\n } catch (IOException e) {\n return null;\n\n }\n }\n}\n\n\nPortfolioGallery\n\n\"PortfolioGallery\" is java-based enterprise application which uses next technologies: \n\n\n- Java core as server-side\n- Spring Framework (including Spring Security, Spring MVC and Spring IoC)\n- HTML, CSS, JavaScript (JQuery/Ajax) within JSP as front-end\n- MySQL database with JDBC\n\n\n---------------------------------------------------------------------------\n\n\nWeb-application is employment\\portfolio site which provides next functionalities:\n\n\n- Registration/Authorization to manage user information (as employee)\n- Post vacancies depends of categories and other selections\n- Create and fill up portfolio (add and remove images)\n- Search for vacancies\n- Search for users in various ways to find employees\npackage account.except;\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 17.01.14\n * Time: 14:14\n * To change this template use File | Settings | File Templates.\n */\npublic class IncorrectInputException extends Exception {\n private String messege;\n\n public IncorrectInputException(String errorMassage) {\n this.messege = errorMassage;\n }\n\n\n\n public IncorrectInputException() {\n this.messege = ErrorMessage.WrongPassword.getErrorMassage();\n }\n\n\n public IncorrectInputException(ErrorMessage enumMember) {\n this.messege = enumMember.getErrorMassage();\n }\n\n\npublic static enum ErrorMessage {\n WrongPassword(\"Password must be not shorter than 6 symbols\" + \"\\n\"), PasswordsDoNotMatch(\"Passwords do not match\" + \"\\n\");\n\n private String errorMessage;\n\n private ErrorMessage(String errorMassage) {\n this.errorMessage = errorMassage;\n }\n\n private String getErrorMassage() {\n return errorMessage;\n }\n\n}\n @Override\n public String toString() {\n return messege;\n }\n\n}package vacancy.impl;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Component;\n\n/**\n * Created by W on 05.04.2014.\n */\n@Component\npublic class Vacancy {\n private int id;\n private String category;\n private String occupation;\n private String location;\n private String tell;\n private String mail;\n private String body;\n private String name;\n\n public Vacancy(String name, String category, String occupation, String location, String tell, String mail, String body) {\n this.category = category;\n this.occupation = occupation;\n this.location = location;\n this.tell = tell;\n this.mail = mail;\n this.body = body;\n this.name = name;\n }\n\n public Vacancy() {\n }\n\n\n public int getId() {\n return id;\n }\n\n public String getName() {\n return name;\n }\n\n public String getCategory() {\n return category;\n }\n\n public String getOccupation() {\n return occupation;\n }\n\n public String getLocation() {\n return location;\n }\n\n public String getTell() {\n return tell;\n }\n\n public String getMail() {\n return mail;\n }\n\n public String getBody() {\n return body;\n }\n\n public void setName(String name) {\n this.name = name;\n }\n\n @Autowired\n public void setId(int id) {\n this.id = id;\n }\n\n @Autowired\n public void setCategory(String category) {\n this.category = category;\n }\n\n @Autowired\n public void setOccupation(String occupation) {\n this.occupation = occupation;\n }\n\n @Autowired\n public void setLocation(String location) {\n this.location = location;\n }\n\n @Autowired\n public void setTell(String tell) {\n this.tell = tell;\n }\n\n @Autowired\n public void setMail(String mail) {\n this.mail = mail;\n }\n\n @Autowired\n public void setBody(String body) {\n this.body = body;\n }\n}\npackage gall.impl;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Component;\n\n/**\n * Created by W on 13.06.2014.\n */\n@Component\npublic class Image {\n private String imgFilePath;\n private int id;\n private int userId;\n\n public Image() {\n }\n\n public Image(String imgFilePath, int id, int userId) {\n this.imgFilePath = imgFilePath;\n this.id = id;\n this.userId = userId;\n }\n\n public String getImgFilePath() {\n return imgFilePath;\n }\n\n public int getId() {\n return id;\n }\n\n public int getUserId() {\n return userId;\n }\n\n @Autowired\n public void setImgFilePath(String imgFilePath) {\n this.imgFilePath = imgFilePath;\n }\n\n @Autowired\n public void setId(int id) {\n this.id = id;\n }\n\n @Autowired\n public void setUserId(int userId) {\n this.userId = userId;\n }\n}\npackage account.impl;\n\nimport account.api.AccountManagement;\nimport account.except.AuthorityException;\nimport account.except.AvailabilityAccountException;\nimport account.except.IncorrectInputException;\nimport account.except.NotAllFieldsFilledException;\nimport gall.except.AvailabilityGalleryException;\nimport gall.impl.GalleryManagementImpl;\nimport gall.impl.JDBCGalleryDAO;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.security.authentication.encoding.ShaPasswordEncoder;\nimport org.springframework.stereotype.Component;\nimport org.springframework.beans.factory.annotation.Autowired;\n\nimport java.io.IOException;\nimport java.util.Map;\n\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 14.01.14\n * Time: 13:35\n * To change this template use File | Settings | File Templates.\n */\n@Component\n@Qualifier(\"AccountManagementBean\")\npublic class AccountManagementImpl implements AccountManagement {\n\n private JDBCAccountDAO accountDAO;\n private GalleryManagementImpl galleryManagement;\n\n public AccountManagementImpl() {\n }\n\n @Autowired\n public void setAccountDAO(JDBCAccountDAO accountDAO) {\n this.accountDAO = accountDAO;\n }\n\n @Autowired\n public void setGalleryManagement(GalleryManagementImpl galleryManagement) {\n this.galleryManagement = galleryManagement;\n }\n\n @Override\n public Account registerNewAccount(String login, String password, String comfPassword, String name, String surname, String category, String occupation, String location, String sex, String mail) throws IncorrectInputException, NotAllFieldsFilledException, AvailabilityAccountException {\n\n\n Account presentAccount = accountDAO.getAccountFromBase(login);\n if (presentAccount != null) {\n throw new AvailabilityAccountException();\n }\n if (!password.equals(comfPassword)) {\n throw new IncorrectInputException(IncorrectInputException.ErrorMessage.PasswordsDoNotMatch);\n }\n\n Account account = new Account(login, name, surname, category, occupation, location, sex, mail, password);\n\n accountDAO.putAccountToBase(account);\n\n return account;\n }\n\n\n @Override\n public String changePassword(String login, String oldPassword, String newPassword) throws IncorrectInputException, AuthorityException {\n\n\n String accountPassword = accountDAO.getPasswordFromBase(login);\n if (PasswordValidator.isPasswordValid(newPassword) == false) {\n throw new IncorrectInputException(IncorrectInputException.ErrorMessage.WrongPassword);\n }\n ShaPasswordEncoder passwordEnc = new ShaPasswordEncoder(512);\n String encodedPassword = passwordEnc.encodePassword(oldPassword, login);\n PasswordValidator.checkPassword(encodedPassword, accountPassword);\n\n Account account = accountDAO.getAccountFromBase(login);\n\n account.setPasswordHash(encodedPassword);\n\n String response = \"Password has been successfully changed \" + \"\\n\";\n return response;\n }\n\n @Override\n public Map searchByCategoryOccupation(String category, String occupation) throws AvailabilityAccountException {\n Map employees = accountDAO.getByCategoryOccupation(category, occupation);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n @Override\n public Map searchByOccupation(String occupation) throws AvailabilityAccountException {\n Map employees = accountDAO.getByOccupation(occupation);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n @Override\n public Map searchByCategory(String category) throws AvailabilityAccountException {\n Map employees = accountDAO.getByCategory(category);\n\n return employees;\n }\n\n @Override\n public Map searchByCategoryLocation(String category, String location) throws AvailabilityAccountException {\n Map employees = accountDAO.getByCategoryLocation(category, location);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n @Override\n public Map searchByLocation(String location) throws AvailabilityAccountException {\n Map employees = accountDAO.getByLocation(location);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n @Override\n public Map searchByLogin(String login) throws AvailabilityAccountException {\n Map employees = accountDAO.getByLogin(login);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n @Override\n public Map searchByCategoryOccupationLocation(String category, String occupation, String location) throws AvailabilityAccountException {\n Map employees = accountDAO.getByCategoryOccupationLocation(category, occupation, location);\n\n for (Map.Entry entry : employees.entrySet()) {\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n }\n return employees;\n }\n\n @Override\n public Map searchByOccupationLocation(String occupation, String location) throws AvailabilityAccountException {\n Map employees = accountDAO.getByOccupationLocation(occupation, location);\n\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n\n return employees;\n }\n\n @Override\n public Map showAllEmp() throws AvailabilityAccountException {\n Map employees = accountDAO.getAllEmp();\n if (employees.isEmpty() == true) {\n throw new AvailabilityAccountException(AvailabilityAccountException.ErrorMessage.AccountNotExist);\n }\n return employees;\n }\n\n\n @Override\n public void removeAccount(String login) throws AvailabilityGalleryException, IOException {\n Account account = accountDAO.getAccountFromBase(login);\n\n\n String galleryStatus = galleryManagement.checkGalleryStatus(login);\n if (galleryStatus != null) {\n boolean isRemoved = galleryManagement.removeGallery(account.getLogin(), account.getId());\n if (isRemoved == true) accountDAO.removeAccountFromBase(login);\n {\n }\n }\n\n }\n\n @Override\n public void updateUserInformation(int id, String login, String newName, String newSurname, String newCategory, String newOccupation, String newLocation, String newSex, String newMail) {\n accountDAO.updateAccount(id, login, newName, newSurname, newCategory, newOccupation, newLocation, newSex, newMail);\n }\n\n public String getUserPasswordHash(String login) {\n String accountPassword = accountDAO.getPasswordFromBase(login);\n return accountPassword;\n }\n\n\n @Override\n public Account viewAccount(String login) {\n Account account = accountDAO.getAccountFromBase(login);\n return account;\n }\n\n\n}\n\n\n 4.0.0\n\n groupId\n PortfolioGallery\n 1.0-SNAPSHOT\n war\n\n \n \n java.net\n http://search.maven.org/\n \n\n \n spring-libs-snapshot\n Spring Snapshot Repository\n http://repo.springsource.org/snapshot\n \n \n\n \n \n \n org.apache.maven.plugins\n maven-compiler-plugin\n 2.5.1\n \n 1.6\n 1.6\n \n \n\n \n org.apache.tomcat.maven\n tomcat7-maven-plugin\n 2.2\n \n http://www.mydomain.com:1234/mymanager\n \n \n\n \n org.apache.maven.plugins\n maven-war-plugin\n \n false\n \n \n \n \n\n\n \n\n \n jstl\n jstl\n 1.2\n \n\n \n com.kenai.nbpwr\n junit\n 4.7-201002241900\n \n\n \n org.mockito\n mockito-all\n 1.9.5\n \n\n \n org.apache.commons\n commons-lang3\n 3.3\n \n\n \n org.apache.directory.studio\n org.apache.commons.codec\n 1.8\n \n\n \n org.springframework\n spring-core\n 4.0.2.RELEASE\n \n\n \n org.springframework\n spring-web\n 4.0.2.RELEASE\n \n\n \n org.springframework\n spring-webmvc\n 4.0.2.RELEASE\n \n\n \n javax.servlet\n javax.servlet-api\n 3.0.1\n provided\n \n \n cglib\n cglib-nodep\n 2.2.2\n \n\n \n org.springframework.security\n spring-security-core\n 3.2.3.RELEASE\n jar\n compile\n \n \n org.springframework.security\n spring-security-web\n 3.2.3.RELEASE\n jar\n compile\n \n \n org.springframework.security\n spring-security-config\n 3.2.3.RELEASE\n jar\n compile\n \n \n org.springframework.security\n spring-security-taglibs\n 3.2.3.RELEASE\n jar\n compile\n \n\n\n \n org.springframework.security\n spring-security-javaconfig\n 1.0.0.CI-SNAPSHOT\n \n\n \n org.codehaus.jackson\n jackson-mapper-asl\n 1.9.13\n \n\n \n org.codehaus.jackson\n jackson-core-asl\n 1.9.13\n \n\n \n mysql\n mysql-connector-java\n 5.1.6\n \n \n\n org.springframework\n spring-jdbc\n 4.0.2.RELEASE\n\n \n\n \n org.compass-project\n compass\n 2.2.0\n \n\n \n \n commons-fileupload\n commons-fileupload\n 1.2.2\n \n\n \n \n commons-io\n commons-io\n 1.3.2\n \n\n \n javax.servlet\n jstl\n 1.1.2\n \n\n \n taglibs\n standard\n 1.1.2\n \n\n \n\n\n\n\n\npackage com.web.controll;\n\nimport org.springframework.security.core.Authentication;\nimport org.springframework.security.core.context.SecurityContextHolder;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.ui.ModelMap;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 14.03.14\n * Time: 11:36\n * To change this template use File | Settings | File Templates.\n */\n\n\n@Controller\npublic class HelloController {\n\n\n @RequestMapping(value = \"/welcome\", method = RequestMethod.GET)\n public String openWelcomePage( ModelMap model) {\n\n Authentication auth = SecurityContextHolder.getContext().getAuthentication();\n String login = auth.getName();\n\n model.addAttribute(\"login\", login);\n model.addAttribute(\"message\", \"Welcome to Portfolio database!\");\n return \"hello\";\n }\n\n}\n\npackage account.impl;\n\nimport org.springframework.jdbc.core.RowMapper;\n\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\n/**\n * Created by W on 18.04.2014.\n */\n@SuppressWarnings(\"rawtypes\")\npublic class AccountRowMapper implements RowMapper {\n public Object mapRow(ResultSet rs, int rowNum) throws SQLException {\n\n Account account = new Account();\n account.setId(rs.getInt(\"ID\"));\n account.setLogin(rs.getString(\"login\"));\n account.setName(rs.getString(\"name\"));\n account.setSurname(rs.getString(\"surname\"));\n account.setCategory(rs.getString(\"category\"));\n account.setOccupation(rs.getString(\"occupation\"));\n account.setLocation(rs.getString(\"location\"));\n account.setMail(rs.getString(\"mail\"));\n account.setSex(rs.getString(\"sex\"));\n account.setCv(rs.getString(\"cv\"));\n account.setGallery(rs.getString(\"gallery\"));\n return account;\n\n }\n}\npackage vacancy.except;\n\n/**\n * Created by W on 05.04.2014.\n */\npublic class NoVacancyException extends Exception{\n private String massage;\n public NoVacancyException() {\n this.massage = ErrorMassage.NoVacancy.getErrorMassage();\n }\n\n\n public static enum ErrorMassage {\n NoVacancy(\"There are no vacancies for your request\" + \"\\n\");\n\n private String errorMassage;\n\n private ErrorMassage(String errorMassage) {\n this.errorMassage = errorMassage;\n }\n\n private String getErrorMassage() {\n return errorMassage;\n }\n\n }\n\n @Override\n public String toString() {\n return massage;\n }\n\n}package account.except;\n\n/**\n * Created with IntelliJ IDEA.\n * User: W\n * Date: 21.01.14\n * Time: 12:03\n * To change this template use File | Settings | File Templates.\n */\npublic class AvailabilityAccountException extends Exception {\n private String message;\n\n public AvailabilityAccountException() {\n this.message = ErrorMessage.AccountExists.getErrorMessage();\n }\n\n\n public AvailabilityAccountException(ErrorMessage enumMember) {\n this.message = enumMember.getErrorMessage();\n }\n\n\n public static enum ErrorMessage {\n AccountExists(\"Account is already exist. Please, choose another login\" + \"\\n\"), AccountNotExist(\"Account is not exist\" + \"\\n\");\n\n private String errorMessage;\n\n private ErrorMessage(String errorMessage) {\n this.errorMessage = errorMessage;\n }\n\n private String getErrorMessage() {\n return errorMessage;\n }\n\n }\n\n @Override\n public String toString() {\n return message;\n }\n\n}"},"directory_id":{"kind":"string","value":"8f538a9d81d7f48600b6e08cafa59f230c05a749"},"languages":{"kind":"list like","value":["Java","Markdown","Java Server Pages","Maven POM"],"string":"[\n \"Java\",\n \"Markdown\",\n \"Java Server Pages\",\n \"Maven POM\"\n]"},"num_files":{"kind":"number","value":19,"string":"19"},"repo_language":{"kind":"string","value":"Java"},"repo_name":{"kind":"string","value":"maretOlia/PortfolioGallery"},"revision_id":{"kind":"string","value":"f63a3eb5bb82833e3374c583d258626240167eed"},"snapshot_id":{"kind":"string","value":"100bcbdc55abffc7c41f329bb3331a3de5ca41d8"}}},{"rowIdx":9940,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"\n\n\n\n\n\n\n\n\n\nimport Vue from 'vue'\nimport Vuex from 'vuex'\nimport activityLog from './modules/nlpLog'\nimport pouchLayer from './modules/pouchLayer'\n\n/**Because of the code below I could actually programattically initialize the nlp plugin\n * \n\n //my object\n var sendData = {\n field1: value1,\n field2: value2\n };\n\n //add element\n sendData['field3'] = value3;\n */\n\n\nVue.use(Vuex)\n\nexport default new Vuex.Store({\n modules: {\n activityLog,\n pouchLayer\n }\n})import Vue from 'vue'\nimport Router from 'vue-router'\nimport DailyLog from '@/components/DailyLog'\nimport Suppliers from '@/components/Suppliers'\n\nVue.use(Router)\n\nexport default new Router({\n routes: [\n {\n path: '/',\n name: 'DailyLog',\n component: DailyLog\n },\n {\n path: '/suppliers',\n name: 'Suppliers',\n component: Suppliers\n }\n ]\n})\nimport crud from '@/api/pouchDB'\n\n\n\n\nvar suppliersJSON = '[{ \"name\": \"\", \"email\": \"\", \"nickName\": \"\", \"_id\": \"supplier_Bluff Hardware Store\", \"_rev\": \"1-902f6f7a7ae54976a637639c9fcab4ab\" }, { \"name\": \"\", \"email\": \"\", \"nickName\": \"\", \"_id\": \"supplier_Bluff Hardware Store\", \"_rev\": \"1-902f6f7a7ae54976a637639c9fcab4ab\" }, { \"name\": \"\", \"email\": \"\", \"nickName\": \"Checkers\", \"_id\": \"supplier_Checkers Bluff\", \"_rev\": \"1-4f1aab0865a44bc9886f6878af3797c3\" }]'\n\n\n\nvar suppliersArray = JSON.parse(suppliersJSON)\n\nconsole.log(\"suppliers Array \", suppliersArray)\n\n\n\n\nconst state = {\n testRemoteDispatch: false,\n suppliers: [],\n supplierTags: {}\n};\n\nconst getters = {\n testRemoteDispatch(state) {\n return state.testRemoteDispatch;\n },\n suppliers(state) {\n return state.suppliers;\n },\n};\n\nconst mutations = {\n testRemoteDispatch(state, payload) {\n // mutate state\n console.log(\"testRemoteDispatch was: \", state.testRemoteDispatch);\n state.testRemoteDispatch = payload;\n console.log(\"testRemoteDispatch is now: \", state.testRemoteDispatch);\n },\n suppliers(state, payload) {\n // mutate state\n state.suppliers = payload;\n console.log('suppliers updated', JSON.stringify(state.suppliers))\n },\n};\n\nconst actions = {\n // Dialogue actions\n testRemoteDispatch: ({\n commit\n }, payload) => {\n commit(\"testRemoteDispatch\", payload);\n\n },\n captureNewSupplier: ({\n dispatch\n }, payload) => {\n payload._id = \"supplier_\" + payload.name\n crud.create(payload)\n crud.info()\n dispatch('fetchAllSuppliers')\n\n let supplierTags = {\n _id: 'supTags',\n [payload.nickName]: 'Supplier'\n }\n console.log('supplierTags', supplierTags)\n },\n updateExistingSupplier: ({\n commit\n }, payload) => {\n crud.update(payload)\n },\n fetchAllSuppliers: ({\n commit\n }) => {\n crud.getAllType('supplier_').then(result => {\n console.log('fetchAllSuppliers', result)\n commit(\"suppliers\", result)\n var newWords = {}\n\n //var words = Object.assign(newWord)\n result.forEach(function (element) {\n var strName = String(element.name).toLowerCase()\n var strNick = String(element.nickName).toLowerCase()\n newWords = Object.assign(newWords, {\n [strName]: 'Supplier',\n [strNick]: 'Supplier'\n })\n });\n commit('supplierTags', newWords)\n console.log(\"new words\", newWords)\n })\n\n }\n};\n\nexport default {\n state,\n mutations,\n actions,\n getters\n}\n\n"},"directory_id":{"kind":"string","value":"20293a68af9b56d8c50663d14a7f21ccd579f06b"},"languages":{"kind":"list like","value":["Vue","JavaScript"],"string":"[\n \"Vue\",\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":7,"string":"7"},"repo_language":{"kind":"string","value":"Vue"},"repo_name":{"kind":"string","value":"L-K-Mist/nlpTextToTables"},"revision_id":{"kind":"string","value":"085f69e7b79211b51e0db4059bf06350f180e956"},"snapshot_id":{"kind":"string","value":"80186798caeade945d93c9e2d3e28b5109cb2894"}}},{"rowIdx":9941,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"rezadim/pos/app/Database/Seeds/SupplierSeeder.php\n'Dimas',\n 'supplier_phone_number'=>'0987654321',\n 'supplier_address'=>'Sukoharjo, Jawa Tengah'\n ];\n $data2 = [\n 'supplier_name'=>'Putra',\n 'supplier_phone_number'=>'09876654323',\n 'supplier_address'=>'Sukoharjo, Jawa Tengah'\n ];\n\n $this->db->table('suppliers')->insert($data1);\n $this->db->table('suppliers')->insert($data2);\n }\n}/app/Database/Migrations/2020-11-25-030158_suppliers.php\nforge->addField([\n\t\t\t'supplier_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'supplier_name' => [\n\t\t\t\t'type'=>'VARCHAR',\n\t\t\t\t'constraint'=>'100'\n\t\t\t],\n\t\t\t'supplier_phone_number' => [\n\t\t\t\t'type'=>'VARCHAR',\n\t\t\t\t'constraint'=>'100',\n\t\t\t\t'null'=>true\n\t\t\t],\n\t\t\t'supplier_address' => [\n\t\t\t\t'type'=>'TEXT',\n\t\t\t\t'null'=>true\n\t\t\t]\n\t\t]);\n\n\t\t$this->forge->addKey('supplier_id', true);\n\t\t$this->forge->createTable('suppliers');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('suppliers', true);\n\t}\n}\n/app/Views/sale/show.php\n\n\n\n
    \n
    \n
    \n
    \n
    \n

    Detail Sale

    \n
    \n
    \n
      \n
    1. \n Home\n
    2. \n
    3. \n Sales\n
    4. \n
    5. Detail Sale
    6. \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n getFlashdata('success'))): ?>\n
    \n getFlashdata('success'); ?>\n
    \n \n getFlashdata('info'))): ?>\n
    \n getFlashdata('info'); ?>\n
    \n \n getFlashdata('warning'))): ?>\n
    \n getFlashdata('warning'); ?>\n
    \n \n\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    Sale IdTotal PurchaseCreated At
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n Produk Pesanan\n \n \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n $row): ?>\n \n \n \n \n \n \n \n \n \n \n
    #ProductQuantityPriceSubtotalAction
    \n \" class=\"btn btn-sm btn-success\">\n
  • \n
    \n \" class=\"btn btn-sm btn-danger\" onclick=\"return confirm('Yakin???');\">\n
  • \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n\n
    \n\n\n\n\n
    \n
    \n
    \n
    \n
    Tambah Pesanan
    \n \n
    \n
    \n
    \" method=\"post\">\n \">\n \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    /app/Database/Migrations/2020-11-25-031354_trx_purchase_details.php\ndb->enableForeignKeyChecks();\n\t\t$this->forge->addField([\n\t\t\t'purchase_detail_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'trx_purchase_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'null'=>true\n\t\t\t],\n\t\t\t'product_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'null'=>true,\n\t\t\t\t'unsigned'=>true\n\t\t\t],\n\t\t\t'purchase_quantity' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'purchase_price' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'purchase_subtotal' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t]\n\t\t]);\n\n\t\t$this->forge->addKey('purchase_detail_id', true);\n\t\t$this->forge->addForeignKey('trx_purchase_id', 'trx_purchases', 'trx_purchase_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->addForeignKey('product_id', 'products', 'product_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->createTable('trx_purchase_details');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('trx_purchase_details', true);\n\t}\n}\n/app/Views/supplier/index.php\n\n\n\n
    \n
    \n
    \n
    \n
    \n

    Suppliers

    \n
    \n
    \n
      \n
    1. \n Home\n
    2. \n
    3. Suppliers
    4. \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n \n
    \n\n getFlashdata('success'))): ?>\n
    \n getFlashdata('success'); ?>\n
    \n \n getFlashdata('info'))): ?>\n
    \n getFlashdata('info'); ?>\n
    \n \n getFlashdata('warning'))): ?>\n
    \n getFlashdata('warning'); ?>\n
    \n \n\n
    \n \n \n \n \n \n \n \n \n \n $row):?>\n \n \n \n \n \n \n \n \n \n
    #Supplier NamePhone NumberAddressAction
    \n \" class=\"btn btn-sm btn-info\">\n
  • \n
    \n \" class=\"btn btn-sm btn-success\">\n
  • \n
    \n \" class=\"btn btn-sm btn-danger\" onclick=\"return confirm('Yakin???');\">\n
  • \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n/app/Controllers/Purchase.php\npurchase = new Purchase_model();\n $this->supplier = new Supplier_model();\n $this->purchaseDetail = new PurchaseDetail_model();\n $this->product = new Product_model();\n }\n\n public function index()\n {\n $data['purchases'] = $this->purchase->getPurchase();\n\n return view('purchase/index', $data);\n }\n public function create()\n {\n $data['suppliers'] = $this->supplier->findAll();\n\n return view('purchase/create', $data);\n }\n public function store()\n {\n $validation = \\Config\\Services::validation();\n\n $data = [\n 'supplier_id'=>$this->request->getPost('supplier_id'),\n 'purchase_created_at'=>date('Y-m-d H:i:s')\n ];\n\n if($validation->run($data, 'purchase') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('purchase/create'));\n }else{\n $save = $this->purchase->insertPurchase($data);\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('purchase'));\n }\n }\n }\n public function delete($id)\n {\n $delete = $this->purchase->deletePurchase($id);\n\n if($delete){\n session()->setFlashdata('warning', 'Deleted');\n return redirect()->to(base_url('purchase'));\n }\n }\n public function show($id)\n {\n $data['purchase'] = $this->purchase->getPurchase($id);\n $data['purchaseDetail'] = $this->purchaseDetail->getPurchaseDetail($id);\n $data['products'] = $this->product->findAll();\n\n return view('purchase/show', $data);\n }\n \n public function storePurchase()\n {\n $validation = \\Config\\Services::validation();\n\n $trx_purchase_id = $this->request->getPost('trx_purchase_id');\n $qty = $this->request->getPost('purchase_quantity');\n $price = $this->request->getPost('purchase_price');\n $data = [\n 'trx_purchase_id'=>$trx_purchase_id,\n 'product_id'=>$this->request->getPost('product_id'),\n 'purchase_quantity'=>$qty,\n 'purchase_price'=>$price,\n 'purchase_subtotal'=>$qty*$price\n ];\n\n if($validation->run($data, 'purchaseDetail') == false){\n session()->setFlashdata('errors', $validation->getErros());\n }else{\n $save = $this->purchaseDetail->insertPurchaseDetail($data);\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('purchase/show/'.$trx_purchase_id));\n }\n\n }\n }\n\n public function deletePurchase($id)\n {\n $trx_purchase_id = $this->request->getPost('trx_purchase_id');\n $delete = $this->purchaseDetail->deletePurchaseDetail($id);\n\n if($delete){\n session()->setFlashdata('warning', 'Deleted');\n return redirect()->to(base_url('purchase/show/'.$trx_purchase_id));\n }\n }\n \n\n\n}/app/Controllers/Sale.php\nsale = new Sale_model();\n $this->saleDetail = new SaleDetail_model();\n $this->product = new Product_model();\n }\n\n public function index()\n {\n $data['sales'] = $this->sale->getSale();\n\n return view('sale/index', $data);\n }\n public function create()\n {\n return view('sale/create');\n }\n public function store()\n {\n $validation = \\Config\\Services::validation();\n\n $data = [\n 'sale_created_at'=>$this->request->getPost('sale_created_at')\n ];\n\n if($validation->run($data, 'sale') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('sale/create'));\n }else{\n $save = $this->sale->insertSale($data);\n\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('sale'));\n }\n }\n }\n public function delete($id)\n {\n $delete = $this->sale->deleteSale($id);\n\n if($delete){\n session()->setFlashdata('warning', 'Deleted');\n return redirect()->to(base_url('sale'));\n }\n }\n public function show($id)\n {\n $data['sale'] = $this->sale->getSale($id);\n $data['saleDetail'] = $this->saleDetail->getSaleDetail($id);\n $data['products'] = $this->product->findAll();\n\n return view('sale/show', $data);\n }\n public function storeSale()\n {\n $validation = \\Config\\Services::validation();\n\n $trx_sale_id = $this->request->getPost('trx_sale_id');\n $qty = $this->request->getPost('sale_quantity');\n $price = 0;\n $data = [\n 'trx_sale_id'=>$trx_sale_id,\n 'product_id'=>$this->request->getPost('product_id'),\n 'sale_quantity'=>$qty,\n 'sale_subtotal'=>$qty*$price\n ];\n\n if($validation->run($data, 'saleDetail') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n }else{\n $save = $this->saleDetail->insertSaleDetail($data);\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('sale/show/'.$trx_sale_id));\n }\n }\n }\n\n}/app/Config/Validation.php\n 'CodeIgniter\\Validation\\Views\\list',\n\t\t'single' => 'CodeIgniter\\Validation\\Views\\single',\n\t];\n\n\t//--------------------------------------------------------------------\n\t// Rules\n\t//--------------------------------------------------------------------\n\n\tpublic $product = [\n\t\t'product_code'=>'required'\n\t];\n\tpublic $product_errors = [\n\t\t'product_code' => ['required'=>'Kode Produk harus diisi']\n\t];\n\n\tpublic $purchase = [\n\t\t'supplier_id'=>'required'\n\t];\n\tpublic $purchase_errors = [\n\t\t'supplier_id' => ['required'=>'Supplier harus diisi']\n\t];\n\n\tpublic $sale = [\n\t\t'sale_created_at' => 'required'\n\t];\n\tpublic $sale_errors = [\n\t\t'sale_created_at'=>['required'=>'Sale ID harus diisi']\n\t];\n\n\tpublic $supplier = [\n\t\t'supplier_name'=>'required'\n\t];\n\tpublic $supplier_errors = [\n\t\t'supplier_name'=>['required'=>'Nama Supplier harus diisi']\n\t];\n\n\tpublic $purchaseDetail = [\n\t\t'product_id'=>'required'\n\t];\n\tpublic $purchaseDetail_errors = [\n\t\t'product_id'=>['required'=>'Product harus diisi']\n\t];\n\n\tpublic $saleDetail = [\n\t\t'product_id' => 'required'\n\t];\n\tpublic $saleDetail_errors = [\n\t\t'product_id'=>['required'=>'Product harus diisi']\n\t];\n\n}\n/db_workshop_pos.sql\n-- phpMyAdmin SQL Dump\n-- version 5.0.2\n-- https://www.phpmyadmin.net/\n--\n-- Host: 127.0.0.1\n-- Waktu pembuatan: 15 Des 2020 pada 03.34\n-- Versi server: 10.4.14-MariaDB\n-- Versi PHP: 7.4.10\n\nSET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\nSTART TRANSACTION;\nSET time_zone = \"+00:00\";\n\n\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n/*!40101 SET NAMES utf8mb4 */;\n\n--\n-- Database: `db_workshop_pos`\n--\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `migrations`\n--\n\nCREATE TABLE `migrations` (\n `id` bigint(20) UNSIGNED NOT NULL,\n `version` varchar(255) NOT NULL,\n `class` text NOT NULL,\n `group` varchar(255) NOT NULL,\n `namespace` varchar(255) NOT NULL,\n `time` int(11) NOT NULL,\n `batch` int(11) UNSIGNED NOT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `migrations`\n--\n\nINSERT INTO `migrations` (`id`, `version`, `class`, `group`, `namespace`, `time`, `batch`) VALUES\n(167, '2020-11-25-021322', 'App\\\\Database\\\\Migrations\\\\Categories', 'default', 'App', 1606532500, 1),\n(168, '2020-11-25-021741', 'App\\\\Database\\\\Migrations\\\\Products', 'default', 'App', 1606532500, 1),\n(169, '2020-11-25-023526', 'App\\\\Database\\\\Migrations\\\\Users', 'default', 'App', 1606532500, 1),\n(170, '2020-11-25-024217', 'App\\\\Database\\\\Migrations\\\\TrxSales', 'default', 'App', 1606532501, 1),\n(171, '2020-11-25-025249', 'App\\\\Database\\\\Migrations\\\\TrxSaleDetails', 'default', 'App', 1606532501, 1),\n(172, '2020-11-25-030158', 'App\\\\Database\\\\Migrations\\\\Suppliers', 'default', 'App', 1606532502, 1),\n(173, '2020-11-25-030603', 'App\\\\Database\\\\Migrations\\\\TrxPurchases', 'default', 'App', 1606532502, 1),\n(174, '2020-11-25-031354', 'App\\\\Database\\\\Migrations\\\\TrxPurchaseDetails', 'default', 'App', 1606532503, 1);\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `products`\n--\n\nCREATE TABLE `products` (\n `product_id` bigint(100) UNSIGNED NOT NULL,\n `product_code` varchar(100) DEFAULT NULL,\n `product_name` varchar(100) DEFAULT NULL,\n `purchase_price` bigint(100) NOT NULL DEFAULT 0,\n `sale_price` bigint(100) NOT NULL DEFAULT 0,\n `stock` bigint(100) NOT NULL DEFAULT 0,\n `product_description` text DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `products`\n--\n\nINSERT INTO `products` (`product_id`, `product_code`, `product_name`, `purchase_price`, `sale_price`, `stock`, `product_description`) VALUES\n(1, '1q2w3e', 'T-Shirt', 20000, 0, 10, 'All Size'),\n(2, '4e5r6t', 'Hoodie', 30000, 0, 31, 'All Size'),\n(3, '4r5t6y', 'Celana Panjang', 10000, 0, 0, 'plplpl');\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `suppliers`\n--\n\nCREATE TABLE `suppliers` (\n `supplier_id` bigint(100) NOT NULL,\n `supplier_name` varchar(100) NOT NULL,\n `supplier_phone_number` varchar(100) DEFAULT NULL,\n `supplier_address` text DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `suppliers`\n--\n\nINSERT INTO `suppliers` (`supplier_id`, `supplier_name`, `supplier_phone_number`, `supplier_address`) VALUES\n(1, 'Dimas', '0987654321', 'Sukoharjo, Jawa Tengah'),\n(2, 'Putra', '09876654323', 'Sukoharjo, Jawa Tengah');\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `trx_purchases`\n--\n\nCREATE TABLE `trx_purchases` (\n `trx_purchase_id` bigint(100) NOT NULL,\n `supplier_id` bigint(100) DEFAULT NULL,\n `total_purchase` bigint(100) NOT NULL DEFAULT 0,\n `purchase_created_at` datetime DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `trx_purchases`\n--\n\nINSERT INTO `trx_purchases` (`trx_purchase_id`, `supplier_id`, `total_purchase`, `purchase_created_at`) VALUES\n(1, 1, 0, '2020-11-27 10:27:27');\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `trx_purchase_details`\n--\n\nCREATE TABLE `trx_purchase_details` (\n `purchase_detail_id` bigint(100) NOT NULL,\n `trx_purchase_id` bigint(100) DEFAULT NULL,\n `product_id` bigint(100) UNSIGNED DEFAULT NULL,\n `purchase_quantity` bigint(100) NOT NULL DEFAULT 0,\n `purchase_price` bigint(100) NOT NULL DEFAULT 0,\n `purchase_subtotal` bigint(100) NOT NULL DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `trx_purchase_details`\n--\n\nINSERT INTO `trx_purchase_details` (`purchase_detail_id`, `trx_purchase_id`, `product_id`, `purchase_quantity`, `purchase_price`, `purchase_subtotal`) VALUES\n(7, 1, 1, 15, 20000, 0),\n(8, 1, 2, 40, 30000, 0);\n\n--\n-- Trigger `trx_purchase_details`\n--\nDELIMITER $$\nCREATE TRIGGER `deletePurchase` AFTER DELETE ON `trx_purchase_details` FOR EACH ROW UPDATE products SET stock = stock-OLD.purchase_quantity WHERE product_id = OLD.product_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `purchasePrice` AFTER INSERT ON `trx_purchase_details` FOR EACH ROW UPDATE products SET purchase_price = NEW.purchase_price WHERE product_id = NEW.product_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `stockProducts` AFTER INSERT ON `trx_purchase_details` FOR EACH ROW UPDATE products SET stock = stock+NEW.purchase_quantity WHERE product_id = NEW.product_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `totalPurchase_afterDelete` AFTER DELETE ON `trx_purchase_details` FOR EACH ROW UPDATE trx_purchases SET total_purchase = total_purchase-OLD.purchase_subtotal WHERE trx_purchase_id = OLD.trx_purchase_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `totalPurchases` AFTER INSERT ON `trx_purchase_details` FOR EACH ROW UPDATE trx_purchases SET total_purchase = total_purchase+NEW.purchase_subtotal WHERE trx_purchase_id = NEW.trx_purchase_id\n$$\nDELIMITER ;\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `trx_sales`\n--\n\nCREATE TABLE `trx_sales` (\n `trx_sale_id` bigint(100) UNSIGNED NOT NULL,\n `total_sale` bigint(100) NOT NULL DEFAULT 0,\n `sale_created_at` datetime DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `trx_sales`\n--\n\nINSERT INTO `trx_sales` (`trx_sale_id`, `total_sale`, `sale_created_at`) VALUES\n(3, 0, '2020-12-25 16:06:50');\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `trx_sale_details`\n--\n\nCREATE TABLE `trx_sale_details` (\n `sale_detail_id` bigint(100) NOT NULL,\n `trx_sale_id` bigint(100) UNSIGNED DEFAULT NULL,\n `product_id` bigint(100) UNSIGNED DEFAULT NULL,\n `sale_quantity` bigint(100) NOT NULL DEFAULT 0,\n `sale_subtotal` bigint(100) NOT NULL DEFAULT 0\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `trx_sale_details`\n--\n\nINSERT INTO `trx_sale_details` (`sale_detail_id`, `trx_sale_id`, `product_id`, `sale_quantity`, `sale_subtotal`) VALUES\n(4, 3, 1, 5, 0),\n(5, 3, 2, 9, 0);\n\n--\n-- Trigger `trx_sale_details`\n--\nDELIMITER $$\nCREATE TRIGGER `deleteSale` AFTER DELETE ON `trx_sale_details` FOR EACH ROW UPDATE products SET stock = stock+OLD.sale_quantity WHERE product_id = OLD.product_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `stockAfterSale` AFTER INSERT ON `trx_sale_details` FOR EACH ROW UPDATE products SET stock = stock-NEW.sale_quantity WHERE product_id = NEW.product_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `totalSale_afterDelete` AFTER DELETE ON `trx_sale_details` FOR EACH ROW UPDATE trx_sales SET total_sale = total_sale+OLD.sale_subtotal WHERE trx_sale_id = OLD.trx_sale_id\n$$\nDELIMITER ;\nDELIMITER $$\nCREATE TRIGGER `totalSales` BEFORE INSERT ON `trx_sale_details` FOR EACH ROW UPDATE trx_sales SET total_sale = total_sale+NEW.sale_subtotal WHERE trx_sale_id = NEW.trx_sale_id\n$$\nDELIMITER ;\n\n-- --------------------------------------------------------\n\n--\n-- Struktur dari tabel `users`\n--\n\nCREATE TABLE `users` (\n `user_id` bigint(100) NOT NULL,\n `username` varchar(100) NOT NULL,\n `password` varchar(255) NOT NULL,\n `user_created_at` datetime DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\n--\n-- Dumping data untuk tabel `users`\n--\n\nINSERT INTO `users` (`user_id`, `username`, `password`, `user_created_at`) VALUES\n(1, 'admin', '123', '2020-11-27 21:02:24'),\n(2, 'user', '123', '2020-11-27 21:02:24');\n\n--\n-- Indexes for dumped tables\n--\n\n--\n-- Indeks untuk tabel `migrations`\n--\nALTER TABLE `migrations`\n ADD PRIMARY KEY (`id`);\n\n--\n-- Indeks untuk tabel `products`\n--\nALTER TABLE `products`\n ADD PRIMARY KEY (`product_id`);\n\n--\n-- Indeks untuk tabel `suppliers`\n--\nALTER TABLE `suppliers`\n ADD PRIMARY KEY (`supplier_id`);\n\n--\n-- Indeks untuk tabel `trx_purchases`\n--\nALTER TABLE `trx_purchases`\n ADD PRIMARY KEY (`trx_purchase_id`),\n ADD KEY `trx_purchases_supplier_id_foreign` (`supplier_id`);\n\n--\n-- Indeks untuk tabel `trx_purchase_details`\n--\nALTER TABLE `trx_purchase_details`\n ADD PRIMARY KEY (`purchase_detail_id`),\n ADD KEY `trx_purchase_details_trx_purchase_id_foreign` (`trx_purchase_id`),\n ADD KEY `trx_purchase_details_product_id_foreign` (`product_id`);\n\n--\n-- Indeks untuk tabel `trx_sales`\n--\nALTER TABLE `trx_sales`\n ADD PRIMARY KEY (`trx_sale_id`);\n\n--\n-- Indeks untuk tabel `trx_sale_details`\n--\nALTER TABLE `trx_sale_details`\n ADD PRIMARY KEY (`sale_detail_id`),\n ADD KEY `trx_sale_details_trx_sale_id_foreign` (`trx_sale_id`),\n ADD KEY `trx_sale_details_product_id_foreign` (`product_id`);\n\n--\n-- Indeks untuk tabel `users`\n--\nALTER TABLE `users`\n ADD PRIMARY KEY (`user_id`);\n\n--\n-- AUTO_INCREMENT untuk tabel yang dibuang\n--\n\n--\n-- AUTO_INCREMENT untuk tabel `migrations`\n--\nALTER TABLE `migrations`\n MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=175;\n\n--\n-- AUTO_INCREMENT untuk tabel `products`\n--\nALTER TABLE `products`\n MODIFY `product_id` bigint(100) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;\n\n--\n-- AUTO_INCREMENT untuk tabel `suppliers`\n--\nALTER TABLE `suppliers`\n MODIFY `supplier_id` bigint(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;\n\n--\n-- AUTO_INCREMENT untuk tabel `trx_purchases`\n--\nALTER TABLE `trx_purchases`\n MODIFY `trx_purchase_id` bigint(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;\n\n--\n-- AUTO_INCREMENT untuk tabel `trx_purchase_details`\n--\nALTER TABLE `trx_purchase_details`\n MODIFY `purchase_detail_id` bigint(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;\n\n--\n-- AUTO_INCREMENT untuk tabel `trx_sales`\n--\nALTER TABLE `trx_sales`\n MODIFY `trx_sale_id` bigint(100) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;\n\n--\n-- AUTO_INCREMENT untuk tabel `trx_sale_details`\n--\nALTER TABLE `trx_sale_details`\n MODIFY `sale_detail_id` bigint(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;\n\n--\n-- AUTO_INCREMENT untuk tabel `users`\n--\nALTER TABLE `users`\n MODIFY `user_id` bigint(100) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;\n\n--\n-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)\n--\n\n--\n-- Ketidakleluasaan untuk tabel `trx_purchases`\n--\nALTER TABLE `trx_purchases`\n ADD CONSTRAINT `trx_purchases_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`supplier_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n--\n-- Ketidakleluasaan untuk tabel `trx_purchase_details`\n--\nALTER TABLE `trx_purchase_details`\n ADD CONSTRAINT `trx_purchase_details_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n ADD CONSTRAINT `trx_purchase_details_trx_purchase_id_foreign` FOREIGN KEY (`trx_purchase_id`) REFERENCES `trx_purchases` (`trx_purchase_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n\n--\n-- Ketidakleluasaan untuk tabel `trx_sale_details`\n--\nALTER TABLE `trx_sale_details`\n ADD CONSTRAINT `trx_sale_details_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n ADD CONSTRAINT `trx_sale_details_trx_sale_id_foreign` FOREIGN KEY (`trx_sale_id`) REFERENCES `trx_sales` (`trx_sale_id`) ON DELETE CASCADE ON UPDATE CASCADE;\nCOMMIT;\n\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n/app/Models/Supplier_model.php\ndb->table($this->table)->get()->getResultArray();\n }else{\n return $this->db->table($this->table)->where(['supplier_id'=>$id])->get()->getRowArray();\n }\n }\n public function insertSupplier($data)\n {\n return $this->db->table($this->table)->insert($data);\n }\n public function updateSupplier($data, $id)\n {\n return $this->db->table($this->table)->update($data, ['supplier_id'=>$id]);\n }\n public function deleteSupplier($id)\n {\n return $this->db->table($this->table)->delete(['supplier_id'=>$id]);\n }\n\n\n}/app/Controllers/Supplier.php\nmodel = new Supplier_model();\n }\n\n public function index()\n {\n $data['suppliers'] = $this->model->getSupplier();\n\n return view('supplier/index', $data);\n }\n public function create()\n {\n return view('supplier/create');\n }\n public function store()\n {\n $validation = \\Config\\Services::validation();\n\n $data = [\n 'supplier_name'=>$this->request->getPost('supplier_name'),\n 'supplier_phone_number'=>$this->request->getPost('supplier_phone_number'),\n 'supplier_address'=>$this->request->getPost('supplier_address')\n ];\n\n if($validation->run($data, 'supplier') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('supplier/create'));\n }else{\n $save = $this->model->insertSupplier($data);\n\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('supplier'));\n }\n }\n }\n public function edit($id)\n {\n $data['supplier'] = $this->model->getSupplier($id);\n\n return view('supplier/edit', $data);\n }\n public function update()\n {\n $validation = \\Config\\Services::validation();\n\n $id = $this->request->getPost('supplier_id');\n $data = [\n 'supplier_name'=>$this->request->getPost('supplier_name'),\n 'supplier_phone_number'=>$this->request->getPost('supplier_phone_number'),\n 'supplier_address'=>$this->request->getPost('supplier_address')\n ];\n\n if($validation->run($data, 'supplier') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('supplier/ceate'));\n }else{\n $update = $this->model->updateSupplier($data, $id);\n\n if($update){\n session()->setFlashdata('info', 'Updated');\n return redirect()->to(base_url('supplier'));\n }\n }\n }\n public function delete($id)\n {\n $delete = $this->model->deleteSupplier($id);\n\n if($delete){\n session()->setFlashdata('warning', 'Deleted');\n return redirect()->to(base_url('supplier'));\n }\n }\n\n}/app/Views/report/index.php\n\n\n\n
    \n
    \n
    \n
    \n
    \n

    Report

    \n
    \n
    \n
      \n
    1. \n Home\n
    2. \n
    3. Report
    4. \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n \n
    \n\n getFlashdata('success'))): ?>\n
    \n getFlashdata('success'); ?>\n
    \n \n getFlashdata('info'))): ?>\n
    \n getFlashdata('info'); ?>\n
    \n \n getFlashdata('warning'))): ?>\n
    \n getFlashdata('warning'); ?>\n
    \n \n\n \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n/app/Models/SaleDetail_model.php\ndb->table($this->table)->join('trx_sales', 'trx_sales.trx_sale_id = trx_sale_details.trx_sale_id', 'CASCADE', 'CASCADE')->join('products', 'products.product_id = trx_sale_details.product_id', 'CASCADE', 'CASCADE', 'full')->where('trx_sale_details.trx_sale_id', $id)->get()->getResultArray();\n }\n public function insertSaleDetail($data)\n {\n return $this->db->table($this->table)->insert($data);\n }\n public function deleteSaleDetail($id)\n {\n return $this->db->table($this->table)->delete(['sale_detail_id'=>$id]);\n }\n\n}/app/Controllers/Report.php\npurchase = new Purchase_model();\n $this->purchaseDetail = new PurchaseDetail_model();\n $this->sale = new Sale_model();\n $this->saleDetail = new SaleDetail_model();\n $this->product = new Product_model();\n $this->supplier = new Supplier_model();\n }\n public function index()\n {\n return view('report/index');\n }\n\n}/app/Views/purchase/show.php\n\n\n\n
    \n
    \n
    \n
    \n
    \n

    Detail Purchase

    \n
    \n
    \n
      \n
    1. \n Home\n
    2. \n
    3. \n Purchases\n
    4. \n
    5. Detail Purchase
    6. \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    Purchase IdSupplierTotal PurchaseCreated At
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n Produk Pembelian\n \n
    \n
    \n
    \n \n getFlashdata('success'))): ?>\n
    \n getFlashdata('success'); ?>\n
    \n \n getFlashdata('info'))): ?>\n
    \n getFlashdata('info'); ?>\n
    \n \n getFlashdata('warning'))): ?>\n
    \n getFlashdata('warning'); ?>\n
    \n \n\n \n \n \n \n \n \n \n \n \n \n \">\n $row): ?>\n \n \n \n \n \n \n \n \n \n \n
    #ProductQuantityPriceSubtotalAction
    \n \" class=\"btn btn-sm btn-success\">\n
  • \n
    \n \" class=\"btn btn-sm btn-danger\" onclick=\"return confirm('Yakin???');\">\n
  • \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n\n
    \n\n\n\n\n\n
    \n
    \n
    \n
    \n
    Tambah Pesanan
    \n \n
    \n
    \n
    \" method=\"post\">\n \">\n
    \n \n \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    /app/Database/Migrations/2020-11-25-024217_trx_sales.php\ndb->enableForeignKeyChecks();\n\t\t$this->forge->addField([\n\t\t\t'trx_sale_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'unsigned'=>true,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'total_sale' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'sale_created_at'=>[\n\t\t\t\t'type'=>'DATETIME',\n\t\t\t\t'null'=>true\n\t\t\t]\n\t\t]);\n\n\t\t$this->forge->addKey('trx_sale_id', true);\n\t\t$this->forge->createTable('trx_sales');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('trx_sales', true);\n\t}\n}\n/app/Database/Migrations/2020-11-25-030603_trx_purchases.php\ndb->enableForeignKeyChecks();\n\t\t$this->forge->addField([\n\t\t\t'trx_purchase_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'supplier_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'null'=>true\n\t\t\t],\t\t\t\n\t\t\t'total_purchase' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'purchase_created_at' => [\n\t\t\t\t'type'=>'DATETIME',\n\t\t\t\t'null'=>true\n\t\t\t]\n\t\t]);\n\n\t\t$this->forge->addKey('trx_purchase_id', true);\n\t\t$this->forge->addForeignKey('supplier_id', 'suppliers', 'supplier_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->createTable('trx_purchases');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('trx_purchases', true);\n\t}\n}\n/app/Models/PurchaseDetail_model.php\ndb->table($this->table)->join('trx_purchases', 'trx_purchases.trx_purchase_id = trx_purchase_details.trx_purchase_id', 'CASCADE', 'CASCADE')->join('products', 'products.product_id = trx_purchase_details.product_id', 'CASCADE', 'CASCADE')->get()->getResultArray();\n }else{\n return $this->db->table($this->table)->join('trx_purchases', 'trx_purchases.trx_purchase_id = trx_purchase_details.trx_purchase_id', 'CASCADE', 'CASCADE')->join('products', 'products.product_id = trx_purchase_details.product_id', 'CASCADE', 'CASCADE')->where('trx_purchase_details.trx_purchase_id', $id)->get()->getResultArray();\n }\n }\n public function insertPurchaseDetail($data)\n {\n return $this->db->table($this->table)->insert($data);\n }\n public function deletePurchaseDetail($id)\n {\n return $this->db->table($this->table)->delete(['purchase_detail_id'=>$id]);\n }\n\n\n}/app/Database/Migrations/2020-11-25-021741_products.php\ndb->enableForeignKeyChecks();\n\t\t$this->forge->addField([\n\t\t\t'product_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'unsigned'=>true,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'product_code' => [\n\t\t\t\t'type'=>'VARCHAR',\n\t\t\t\t'constraint'=>'100',\n\t\t\t\t'null'=>true\n\t\t\t],\n\t\t\t'product_name' => [\n\t\t\t\t'type'=>'VARCHAR',\n\t\t\t\t'constraint'=>'100',\n\t\t\t\t'null'=>true\n\t\t\t],\n\t\t\t'purchase_price' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'sale_price' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'stock' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'product_description' => [\n\t\t\t\t'type'=>'TEXT',\n\t\t\t\t'null'=>true\n\t\t\t]\n\t\t]);\n\t\t$this->forge->addKey('product_id', true);\n\t\t// $this->forge->addForeignKey('category_id', 'categories', 'category_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->createTable('products');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('products', true);\n\t}\n}\n/app/Database/Seeds/UserSeeder.php\n'admin',\n 'password'=>'123',\n 'user_created_at'=>date('Y-m-d H:i:s')\n ];\n $data2 = [\n 'username'=>'user',\n 'password'=>'123',\n 'user_created_at'=>date('Y-m-d H:i:s')\n ];\n\n $this->db->table('users')->insert($data1);\n $this->db->table('users')->insert($data2);\n }\n}/app/Controllers/Product.php\nmodel = new Product_model();\n }\n\n public function index()\n {\n $data['products'] = $this->model->getProduct();\n\n return view('product/index', $data);\n }\n public function create()\n {\n return view('product/create');\n }\n public function store()\n {\n $validation = \\Config\\Services::validation();\n\n $data = [\n 'product_code'=>$this->request->getPost('product_code'),\n 'product_name'=>$this->request->getPost('product_name'),\n 'sale_price'=>$this->request->getPost('sale_price'),\n 'stock'=>$this->request->getPost('stock'),\n 'product_description'=>$this->request->getPost('product_description')\n ];\n\n if($validation->run($data, 'product') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('product/create'));\n }else{\n $save = $this->model->insertProduct($data);\n if($save){\n session()->setFlashdata('success', 'Created');\n return redirect()->to(base_url('product'));\n }\n }\n }\n public function edit($id)\n {\n $data['product'] = $this->model->getProduct($id);\n\n return view('product/edit', $data);\n }\n public function update()\n {\n $validation = \\Config\\Services::validation();\n\n $id = $this->request->getPost('product_id');\n\n $data = [\n 'product_code'=>$this->request->getPost('product_code'),\n 'product_name'=>$this->request->getPost('product_name'),\n 'sale_price'=>$this->request->getPost('sale_price'),\n 'stock'=>$this->request->getPost('stock'),\n 'product_description'=>$this->request->getPost('product_description')\n ];\n\n if($validation->run($data, 'product') == false){\n session()->setFlashdata('errors', $validation->getErrors());\n return redirect()->to(base_url('product/edit'));\n }else{\n $update = $this->model->updateProduct($data, $id);\n if($update){\n session()->setFlashdata('info', 'Updatedd');\n return redirect()->to(base_url('product'));\n }\n }\n }\n public function delete($id)\n {\n $delete = $this->model->deleteProduct($id);\n\n if($delete){\n session()->setFlashdata('warning', 'Deleted');\n return redirect()->to(base_url('product'));\n }\n }\n\n}/app/Models/Purchase_model.php\ndb->table($this->table)->join('suppliers', 'suppliers.supplier_id = trx_purchases.supplier_id', 'CASCADE', 'cascade')->get()->getResultArray();\n }else{\n return $this->db->table($this->table)->join('suppliers', 'suppliers.supplier_id = trx_purchases.supplier_id', 'CASCADE', 'CASCADE')->where(['trx_purchases.trx_purchase_id'=>$id])->get()->getRowArray();\n }\n }\n public function insertPurchase($data)\n {\n return $this->db->table($this->table)->insert($data);\n }\n public function deletePurchase($id)\n {\n return $this->db->table($this->table)->delete(['purchase_id'=>$id]);\n }\n\n}\n/app/Models/Sale_model.php\ndb->table($this->table)->get()->getResultArray();\n }else{\n return $this->db->table($this->table)->where('trx_sale_id', $id)->get()->getRowArray();\n }\n }\n public function insertSale($data)\n {\n return $this->db->table($this->table)->insert($data);\n }\n public function deleteSale($id)\n {\n return $this->db->table($this->table)->delete(['trx_sale_id'=>$id]);\n }\n\n\n}/app/Database/Migrations/2020-11-25-025249_trx_sale_details.php\ndb->enableForeignKeyChecks();\n\t\t$this->forge->addField([\n\t\t\t'sale_detail_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'auto_increment'=>true\n\t\t\t],\n\t\t\t'trx_sale_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'null'=>true,\n\t\t\t\t'unsigned'=>true\n\t\t\t],\n\t\t\t'product_id' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'null'=>true,\n\t\t\t\t'unsigned'=>true\n\t\t\t],\n\t\t\t'sale_quantity' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t],\n\t\t\t'sale_subtotal' => [\n\t\t\t\t'type'=>'BIGINT',\n\t\t\t\t'constraint'=>100,\n\t\t\t\t'default'=>0\n\t\t\t]\n\t\t]);\n\n\t\t$this->forge->addKey('sale_detail_id', true);\n\t\t$this->forge->addForeignKey('trx_sale_id', 'trx_sales', 'trx_sale_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->addForeignKey('product_id', 'products', 'product_id', 'CASCADE', 'CASCADE');\n\t\t$this->forge->createTable('trx_sale_details');\n\t}\n\n\t//--------------------------------------------------------------------\n\n\tpublic function down()\n\t{\n\t\t$this->forge->dropTable('trx_sale_details', true);\n\t}\n}\n/app/Database/Seeds/ProductSeeder.php\n'1q2w3e',\n 'product_name'=>'T-Shirt',\n 'purchase_price'=>0,\n 'sale_price'=>0,\n 'stock'=>0,\n 'product_description'=>'All Size'\n ];\n $data2 = [\n 'product_code'=>'4e5r6t',\n 'product_name'=>'Hoodie',\n 'purchase_price'=>0,\n 'sale_price'=>0,\n 'stock'=>0,\n 'product_description'=>'All Size'\n ];\n\n $this->db->table('products')->insert($data1);\n $this->db->table('products')->insert($data2);\n }\n}"},"directory_id":{"kind":"string","value":"18daf939efd7be9ca8fda2d57bacefa540605908"},"languages":{"kind":"list like","value":["SQL","PHP"],"string":"[\n \"SQL\",\n \"PHP\"\n]"},"num_files":{"kind":"number","value":25,"string":"25"},"repo_language":{"kind":"string","value":"SQL"},"repo_name":{"kind":"string","value":"rezadim/pos"},"revision_id":{"kind":"string","value":"ccaf2020553528c190b2a7a549d945b8a515dc92"},"snapshot_id":{"kind":"string","value":"8300173401d96e80a65c62e6b8b5e48f6efe362a"}}},{"rowIdx":9942,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"package com.epam.train;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Train {\n private List train = new ArrayList();\n\n public Train() {\n this.train.add(Carriage.LOCOMOTIVE);\n }\n\n public void add(Carriage carriage) {\n this.train.add(carriage);\n }\n\n public void add(Carriage carriage, int count) {\n for (int i = 0; i < count; i++) this.train.add(carriage);\n }\n\n public void remove(Carriage carriage) {\n this.train.remove(carriage);\n }\n\n public void removeAll(Carriage carriage) {\n ArrayList temp = (ArrayList) this.train;\n ArrayList trainClone = (ArrayList) temp.clone();\n for (Carriage i : this.train) {\n if (i.equals(carriage)) trainClone.remove(i);\n }\n this.train = trainClone;\n }\n\n public int getWeight() {\n int weight = 0;\n for (Carriage i : this.train) {\n weight += i.getWeight();\n }\n return weight;\n }\n\n public int getForce() {\n int force = 0;\n for (Carriage i : this.train) {\n force += i.getForce();\n }\n return force;\n }\n\n public int length() {\n return this.train.size();\n }\n}\npackage com.epam.train;\n\npublic class Main {\n\n public static void main(String[] args) {\n Train train = new Train();\n train.add(Carriage.COUPE, 20);\n TrainStation trainStation = new TrainStation();\n System.out.println(trainStation.canLet(train));\n }\n}\npackage com.epam.train;\r\n\r\npublic class TrainStation {\r\n private double resistance;\r\n private double minSpeedUp;\r\n\r\n public TrainStation() {\r\n this.resistance = 0.1;\r\n this.minSpeedUp = 0.01;\r\n }\r\n\r\n public TrainStation(double resistance, double minSpeedUp) {\r\n this.resistance = resistance;\r\n this.minSpeedUp = minSpeedUp;\r\n }\r\n\r\n public boolean canLet(Train train) {\r\n double weight = train.getWeight();\r\n double force = train.getForce();\r\n double speedUp = (force - weight*this.resistance)/weight;\r\n String message = (speedUp > this.minSpeedUp? \"Success: \" : \"Fail: \") + \"speed-up = %.4f m/s^2\\n\";\r\n System.out.printf(message, speedUp);\r\n return speedUp > this.minSpeedUp;\r\n }\r\n\r\n public void setMinSpeedUp(double minSpeedUp) {\r\n this.minSpeedUp = minSpeedUp;\r\n }\r\n\r\n public void setResistance(double resistance) {\r\n this.resistance = resistance;\r\n }\r\n\r\n public double getMinSpeedUp() {\r\n return minSpeedUp;\r\n }\r\n\r\n public double getResistance() {\r\n return resistance;\r\n }\r\n}\r\n"},"directory_id":{"kind":"string","value":"93f9a95fd9f12fc9a2043961fc2046243984c210"},"languages":{"kind":"list like","value":["Java"],"string":"[\n \"Java\"\n]"},"num_files":{"kind":"number","value":3,"string":"3"},"repo_language":{"kind":"string","value":"Java"},"repo_name":{"kind":"string","value":"OnjeyGray/Train"},"revision_id":{"kind":"string","value":"3252d289ce9fec34de03df2e5858d36e10808663"},"snapshot_id":{"kind":"string","value":"85a8acd7da75014c80166e31c6039601cea97b6b"}}},{"rowIdx":9943,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, String\nfrom geometry_msgs.msg import Pose\nfrom numpy import sign\n\n\nclass transControlNode():\n def __init__(self):\n rospy.init_node(\"trans_control\")\n\n self.data_lock = threading.RLock()\n self.strategy = \"follow\"\n\n self.control_frequency = 20.0\n\n rospy.Timer(rospy.Duration(1.0/self.control_frequency), self.trans_control)\n\n self.vorsteuerung = -0.05\n # Parameter static\n self.xy_p_gain = 0.21\n self.xy_i_gain = 0.16\n self.xy_d_gain = 0.1\n # Dynamic Parameter\n self.vertical_p_gain = 0.375\n self.vertical_i_gain = 0.09\n self.vertical_d_gain = 0.1\n\n self.setpoint_buf_len = 5\n self.i_buf_len = 20\n self.i_buf = Pose()\n self.i_buf.position.x = [0.0] * self.i_buf_len\n self.i_buf.position.y = [0.0] * self.i_buf_len\n self.i_buf.position.z = [0.0] * self.i_buf_len\n self.setpoint_buf = Pose()\n self.setpoint_buf.position.x = [0.0] * self.setpoint_buf_len\n self.setpoint_buf.position.y = [0.0] * self.setpoint_buf_len\n self.setpoint_buf.position.z = [0.0] * self.setpoint_buf_len\n self.pos_setpoint = Pose()\n self.pos_setpoint.position.x = 0.0\n self.pos_setpoint.position.y = 0.0\n self.pos_setpoint.position.z = -0.5\n self.pos = self.pos_setpoint\n self.sensor_time = rospy.get_time()\n # rospy.loginfo(self.setpoint_buf.position.x)\n # rospy.loginfo(self.i_buf.position.z)\n\n self.thrust = 0.0\n self.vertical_thrust = 0.0\n self.lateral_thrust = 0.0\n\n self.thrust_pub = rospy.Publisher(\"thrust\",\n Float64,\n queue_size=1)\n self.vertical_thrust_pub = rospy.Publisher(\"vertical_thrust\",\n Float64,\n queue_size=1)\n self.lateral_thrust_pub = rospy.Publisher(\"lateral_thrust\",\n Float64,\n queue_size=1)\n\n self.setpoint_sub = rospy.Subscriber(\"pos_setpoint\",\n Pose,\n self.on_setpoint,\n queue_size=1)\n\n self.pos_sub = rospy.Subscriber(\"robot_pos\",\n Pose,\n self.pos_callback,\n queue_size=1)\n\n self.depth_sub = rospy.Subscriber(\"depth\", Float64,\n self.depth_callback,\n queue_size=1)\n\n self.strategy_sub = rospy.Subscriber(\"strategy\",\n String,\n self.strategy_callback,\n queue_size=1)\n\n # Reconfigure Options via subscriber\n self.kp_dyn_sub = rospy.Subscriber(\"kp_xy\", Float64,\n self.kp_xy_callback, queue_size=1)\n self.ki_dyn_sub = rospy.Subscriber(\"ki_xy\", Float64,\n self.ki_xy_callback, queue_size=1)\n self.kd_dyn_sub = rospy.Subscriber(\"kd_xy\", Float64,\n self.kd_xy_callback, queue_size=1)\n # Reconfigure Options via subscriber\n self.kp_sta_sub = rospy.Subscriber(\"kp_vert\", Float64,\n self.kp_vert_callback, queue_size=1)\n self.ki_sta_sub = rospy.Subscriber(\"ki_vert\", Float64,\n self.ki_vert_callback, queue_size=1)\n self.kd_sta_sub = rospy.Subscriber(\"kd_vert\", Float64,\n self.kd_vert_callback, queue_size=1)\n self.vor_static_sub = rospy.Subscriber(\"vor\", Float64,\n self.vor_callback,\n queue_size=1)\n\n def strategy_callback(self, msg):\n self.strategy = msg.data\n #self.trans_control()\n\n def kp_xy_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.xy_p_gain = msg.data\n else:\n rospy.logwarn(\"Received negative Kp\")\n\n def ki_xy_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.xy_i_gain = msg.data\n else:\n rospy.logwarn(\"Received negative Ki\")\n\n def kd_xy_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.xy_d_gain = msg.data\n else:\n rospy.logwarn(\"Received negative Kd\")\n\n def kp_vert_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.vertical_p_gain = msg.data\n else:\n rospy.logwarn(\"Received negative dyn Kp\")\n\n def ki_vert_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.vertical_i_gain = msg.data\n else:\n rospy.logwarn(\"Received negative dyn Ki\")\n\n def kd_vert_callback(self, msg):\n with self.data_lock:\n if msg.data >= 0:\n self.vertical_d_gain = msg.data\n else:\n rospy.logwarn(\"Received self.vertical_thrustnegative dyn Kd\")\n\n def vor_callback(self, msg):\n with self.data_lock:\n self.vorsteuerung = msg.data\n\n def on_setpoint(self, msg):\n with self.data_lock:\n # if not self.isRegion(msg.position):\n self.pos_setpoint = msg\n self.setpoint_buf.position = self.setBuffer(self.setpoint_buf.position,\n self.pos_setpoint.position,\n self.setpoint_buf_len)\n #self.trans_control()\n\n def pos_callback(self, msg):\n with self.data_lock:\n self.pos.position.x = msg.position.x\n self.pos.position.y = msg.position.y\n # self.pos.position.z = msg.position.z\n self.sensor_time = rospy.get_time()\n #self.trans_control()\n\n def depth_callback(self, msg):\n with self.data_lock:\n self.pos.position.z = msg.data\n # self.sensor_time = rospy.get_time()\n #self.trans_control()\n\n def setBuffer(self, buf, msgAppend, len):\n for i in range(0, len-1):\n buf.x[i] = buf.x[i+1]\n for i in range(0, len-1):\n buf.y[i] = buf.y[i+1]\n for i in range(0, len-1):\n buf.z[i] = buf.z[i+1]\n buf.x[-1] = msgAppend.x\n buf.y[-1] = msgAppend.y\n buf.z[-1] = msgAppend.z\n return buf\n\n def publish(self):\n # rospy.loginfo(\"Hallo\")\n msg_thrust = Float64()\n msg_thrust.data = self.thrust\n self.thrust_pub.publish(msg_thrust)\n\n msg_vertical_thrust = Float64()\n msg_vertical_thrust.data = self.vertical_thrust\n self.vertical_thrust_pub.publish(msg_vertical_thrust)\n\n msg_lateral_thrust = Float64()\n msg_lateral_thrust.data = self.lateral_thrust\n self.lateral_thrust_pub.publish(msg_lateral_thrust)\n \n def trans_control(self, *args):\n if rospy.get_time() - self.sensor_time > 5:\n rospy.logwarn(\"Sensor Timeout\")\n self.thrust = 0.0\n self.setGains(self.setpoint_buf.position.z)\n self.vertical_thrust = self.getThrust(self.pos.position.z,\n self.pos_setpoint.position.z,\n self.i_buf.position.z, True)\n self.lateral_thrust = 0.0\n self.publish()\n return\n elif self.strategy == \"search\":\n # rospy.loginfo(\"searching\")\n self.thrust = 0.0\n self.vertical_thrust = self.vorsteuerung\n self.lateral_thrust = 0.0\n self.publish()\n return\n # rospy.loginfo(\"following\")\n i_buf_Append = Pose()\n i_buf_Append.position.x = self.pos_setpoint.position.x - self.pos.position.x\n i_buf_Append.position.y = self.pos_setpoint.position.y - self.pos.position.y\n i_buf_Append.position.z = self.pos_setpoint.position.z - self.pos.position.z\n self.i_buf.position = self.setBuffer(self.i_buf.position,\n i_buf_Append.position,\n self.i_buf_len)\n\n \"\"\" if sign(self.i_buf) == sign(self.i_buf):\n i_buf_tmp = [j for j in self.i_buf]\n else:\n i_buf_tmp = [0 for j in self.i_buf] \"\"\"\n # rospy.loginfo(\"following\")\n self.setGains(True)\n # rospy.loginfo(self.pos_setpoint.position)\n self.lateral_thrust = -self.getThrust(self.pos.position.x,\n self.pos_setpoint.position.x,\n self.i_buf.position.x, False)\n self.setGains(True)\n self.thrust = self.getThrust(self.pos.position.y,\n self.pos_setpoint.position.y,\n self.i_buf.position.y, False)\n self.setGains(False)\n self.vertical_thrust = self.getThrust(self.pos.position.z,\n self.pos_setpoint.position.z,\n self.i_buf.position.z, True)\n\n \"\"\" if self.isRegion(self.pos.position.z) == 1:\n self.vertical_thrust = -0.4\n elif self.isRegion(self.pos.position.z) == -1:\n self.vertical_thrust = 0.4 \"\"\"\n\n self.publish()\n\n def getThrust(self, pos, setpoint, i_buf, vor_activate):\n thrust = (self.act_p_gain * (setpoint - pos)\n + self.act_i_gain * sum(i_buf) * (1.0/self.control_frequency)\n + self.act_d_gain * (i_buf[-1] - i_buf[-2]))\n if vor_activate:\n thrust += self.vorsteuerung\n if abs(thrust) > 1:\n thrust = sign(thrust)\n return thrust\n\n def isRegion(self, setpoint):\n if setpoint.z > -0.1 or setpoint.x > 0.1 or setpoint.y > 0.1:\n return 1\n elif setpoint.z < -0.8 or setpoint.x < 1.9 or setpoint.y < 3.2:\n return -1\n else:\n return 0\n\n def setGains(self, dirXY):\n if dirXY:\n self.act_p_gain = self.xy_p_gain\n self.act_i_gain = self.xy_i_gain\n self.act_d_gain = self.xy_d_gain\n else:\n self.act_p_gain = self.vertical_p_gain\n self.act_i_gain = self.vertical_i_gain\n self.act_d_gain = self.vertical_d_gain\n\n def publish(self):\n # rospy.loginfo(\"Hallo\")\n msg_thrust = Float64()\n msg_thrust.data = self.thrust\n self.thrust_pub.publish(msg_thrust)\n\n msg_vertical_thrust = Float64()\n msg_vertical_thrust.data = self.vertical_thrust\n self.vertical_thrust_pub.publish(msg_vertical_thrust)\n\n msg_lateral_thrust = Float64()\n msg_lateral_thrust.data = self.lateral_thrust\n self.lateral_thrust_pub.publish(msg_lateral_thrust)\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = transControlNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport numpy as np\nimport threading\nfrom std_msgs.msg import Int16, String\nfrom mavros_msgs.srv import CommandBool\nfrom geometry_msgs.msg import Pose\n\n\nclass strategyNode():\n def __init__(self):\n rospy.init_node(\"strategy_planer\")\n self.data_lock = threading.RLock()\n self.tagNumber = 0\n self.tag_threshold = 3\n self.pos_threshold = 0.1\n self.pos_threshold_y= 0.1\n self.actual_pos = np.array([10.0, 10.0, 10.0])\n self.lock = False\n\n self.strategy_pub = rospy.Publisher(\"strategy\",\n String,\n queue_size=1)\n\n self.setpoint_sub = rospy.Subscriber(\"number_tags\",\n Int16,\n self.tag_callback,\n queue_size=1)\n\n self.doArm = rospy.get_param(\"~doArm\", False)\n if self.doArm:\n self.arm_vehicle()\n\n self.setpoint_sub = rospy.Subscriber(\"ring_pos\",\n Pose,\n self.pos_callback,\n queue_size=1)\n \n self.strategy_frequency = 5.0\n rospy.Timer(rospy.Duration(1.0/self.strategy_frequency), self.update_strategy)\n\n def tag_callback(self, msg):\n # with self.data_lock:\n self.tagNumber = msg.data\n\n def pos_callback(self, msg):\n #with self.data_lock:\n self.actual_pos[0] = msg.position.x\n self.actual_pos[1] = msg.position.y\n self.actual_pos[2] = msg.position.z\n\n def update_strategy(self, *args):\n msg = String()\n if self.lock:\n msg.data = \"rescue\"\n self.strategy_pub.publish(msg)\n return\n if self.tagNumber < self.tag_threshold:\n msg.data = \"search\"\n elif abs(self.actual_pos[0]) > self.pos_threshold or abs(self.actual_pos[2]) > self.pos_threshold:\n msg.data = \"approach\"\n elif self.actual_pos[1] > self.pos_threshold_y:\n msg.data = \"stich\"\n else:\n msg.data = \"rescue\"\n self.lock = True\n self.strategy_pub.publish(msg)\n \n\n def arm_vehicle(self):\n # wait until the arming serivce becomes available\n rospy.wait_for_service(\"mavros/cmd/arming\")\n # connect to the service\n arm = rospy.ServiceProxy(\"mavros/cmd/arming\", CommandBool)\n # call the service to arm the vehicle until call was successfull\n while not arm(True).success:\n rospy.logwarn(\"Could not arm vehicle. Keep trying.\")\n rospy.sleep(1.0)\n rospy.loginfo(\"Armed successfully.\")\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = strategyNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nfrom std_msgs.msg import Float64\nimport numpy as np\n\n\nclass DepthSetpointNode():\n def __init__(self):\n rospy.init_node(\"depth_setpoints\")\n\n self.setpoint_pub = rospy.Publisher(\"depth_setpoint\",\n Float64,\n queue_size=1)\n\n def run(self):\n mode = 'step'\n\n if mode == 'const':\n rate = rospy.Rate(50.0)\n while not rospy.is_shutdown():\n msg = Float64()\n # fill msg with example setpoint\n msg.data = -0.5\n self.setpoint_pub.publish(msg)\n rate.sleep()\n elif mode == 'sin':\n rate = rospy.Rate(10.0)\n while not rospy.is_shutdown():\n xs = np.linspace(0, 2*np.pi, num=200)\n for x in xs:\n msg = Float64()\n # fill msg with example setpoint\n msg.data = 0.2*np.sin(x) - 0.4\n self.setpoint_pub.publish(msg)\n rate.sleep()\n elif mode == 'step':\n rate = rospy.Rate(5.0)\n while not rospy.is_shutdown():\n xs = np.linspace(0, 2*np.pi, num=200)\n for x in xs:\n msg = Float64()\n # fill msg with example setpoint\n msg.data = 0.4*float(x < np.pi) - 0.6\n self.setpoint_pub.publish(msg)\n rate.sleep()\n else:\n pass\n # TODO: add ros logger error\n\n\ndef main():\n node = DepthSetpointNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nfrom std_msgs.msg import Float64\nfrom sensor_msgs.msg import FluidPressure\n\ndepth_buf = [-0.5] * 5\ndepth_buf_len = 5\n\n\ndef pressure_callback(msg, depth_pub):\n pascal_per_meter = 9.81*1000.0\n depth_tmp = - (msg.fluid_pressure - 101325) / pascal_per_meter\n\n depth_buf.append(depth_tmp)\n if len(depth_buf) > depth_buf_len:\n depth_buf.pop(0)\n depth = sum(depth_buf) / len(depth_buf)\n\n depth_msg = Float64()\n # depth_raw_msg = Float64()\n # depth_msg.data = depth\n depth_msg.data = depth # offset, water level is zero\n # depth_raw_msg.data = depth_tmp + 10\n depth_pub.publish(depth_msg)\n # depth_raw_pub.publish(depth_raw_msg)\n\n\ndef main():\n rospy.init_node(\"depth_calculator\")\n\n depth_pub = rospy.Publisher(\"depth\", Float64, queue_size=1)\n # depth_raw_pub = rospy.Publisher(\"depth_raw\", Float64, queue_size=1)\n rospy.Subscriber(\"pressure\", FluidPressure,\n pressure_callback,\n (depth_pub))\n rospy.spin()\n\n\nif __name__ == \"__main__\":\n main()\n#pragma once\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n\nnamespace gazebo {\nstatic constexpr auto kDefaultPubRate = 7.0;\nstatic constexpr auto kDefaultRangesTopic = \"tag_detections_sim\";\nstatic constexpr auto kDefaultRangesNoise = 0.1;\nstatic constexpr auto kDefaultFov = 90;\nstatic constexpr auto kDefaultViewingAngle = 140;\nstatic constexpr auto kDefaultDropProb = 0.05;\nstatic constexpr auto kDefaultMaxDetectionDist = 5.0;\nstatic constexpr auto kDefaultDistDropProbExponent = 2.0;\n\nclass RangesPlugin : public ModelPlugin {\n public:\n RangesPlugin();\n virtual ~RangesPlugin();\n\n protected:\n virtual void Load(physics::ModelPtr model, sdf::ElementPtr sdf);\n virtual void OnUpdate(const common::UpdateInfo &);\n void getSdfParams(sdf::ElementPtr sdf);\n range_sensor::RangeMeasurement GetRangeMsg(\n int id, ignition::math::Vector3d sensor_to_tag);\n bool IsDetected(ignition::math::Vector3d sensor_to_tag,\n ignition::math::Vector3d body_x_axis);\n bool IsDetected_bottom(ignition::math::Vector3d sensor_to_tag,\n ignition::math::Vector3d body_z_axis);\n double GetDistanceDropProp(double dist);\n\n private:\n std::string namespace_;\n physics::ModelPtr model_;\n physics::WorldPtr world_;\n event::ConnectionPtr update_connection_;\n std::string ranges_topic_;\n double range_noise_std_;\n double max_fov_angle_;\n double max_viewing_angle_;\n double drop_prob_;\n double max_detection_dist_;\n double dist_drop_prob_exponent_;\n\n ros::NodeHandle *node_handle_;\n ros::Publisher ranges_pub_;\n\n double pub_rate_;\n\n std::default_random_engine random_generator_;\n std::normal_distribution standard_normal_distribution_;\n std::uniform_real_distribution uniform_real_distribution_;\n\n common::Time last_pub_time_;\n common::Time last_time_;\n\n ignition::math::Vector3d pos_tag_1_;\n ignition::math::Vector3d pos_tag_2_;\n ignition::math::Vector3d pos_tag_3_;\n ignition::math::Vector3d pos_tag_4_;\n\n ignition::math::Vector3d tag_axis_;\n ignition::math::Vector3d tag_axis_bottom_;\n\n bool initialized_;\n\n std::vector floor_tags_;\n};\n} // namespace gazebo\n#!/usr/bin/env python\nimport rospy\nfrom std_msgs.msg import Float64, Int16\nfrom geometry_msgs.msg import Pose\nfrom nav_msgs.msg import Odometry\n\n\nclass groundTruthTestNode():\n def __init__(self):\n rospy.init_node(\"ground_truth_compare\")\n self.pos = Pose()\n self.pos.position.x = 0.0\n self.pos.position.y = 0.0\n self.pos.position.z = 0.0\n self.pos.orientation.x = 0.0\n self.pos.orientation.y = 0.0\n self.pos.orientation.z = 0.0\n self.pos.orientation.w = 0.0\n\n self.number_tags = 4\n\n self.range_sub = rospy.Subscriber(\"/ground_truth/state\",\n Odometry,\n self.posCallback,\n queue_size=1)\n self.pos_pub = rospy.Publisher(\"robot_pos\",\n Pose,\n queue_size=1)\n self.err_x_pub = rospy.Publisher(\"pos_err_x\",\n Float64,\n queue_size=1)\n self.err_y_pub = rospy.Publisher(\"pos_err_y\",\n Float64,\n queue_size=1)\n self.err_z_pub = rospy.Publisher(\"pos_err_z\",\n Float64,\n queue_size=1)\n self.tag_pub = rospy.Publisher(\"number_tags\",\n Int16,\n queue_size=1)\n\n def posCallback(self, msg):\n # rospy.loginfo(\"Hallo1\")\n self.pos.position.x = msg.pose.pose.position.x\n self.pos.position.y = msg.pose.pose.position.y\n self.pos.position.z = msg.pose.pose.position.z\n self.pos.orientation.x = msg.pose.pose.orientation.x\n self.pos.orientation.y = msg.pose.pose.orientation.y\n self.pos.orientation.z = msg.pose.pose.orientation.z\n self.pos.orientation.w = msg.pose.pose.orientation.w\n self.pos_pub.publish(self.pos)\n msg = Int16()\n msg.data = self.number_tags\n self.tag_pub.publish(msg)\n \n\n def run(self):\n rospy.spin()\n\n\ndef main():\n rospy.loginfo(\"Hallo0\")\n node = groundTruthTestNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\ncmake_minimum_required(VERSION 3.0.2)\nproject(depth_controller)\n\nfind_package(catkin REQUIRED COMPONENTS\n message_generation\n std_msgs\n)\n\n# add_message_files(\n# FILES\n# )\n\n# generate_messages(\n# DEPENDENCIES\n# std_msgs\n#)\n\ncatkin_package(\n# INCLUDE_DIRS include\n# LIBRARIES depth_controller\n# CATKIN_DEPENDS other_catkin_pkg\n# DEPENDS system_lib\n)\n\ninclude_directories(\n# include\n# ${catkin_INCLUDE_DIRS}\n)\n#!/usr/bin/env python\nimport tf.transformations as tf\nimport numpy as np\nimport rospy\nfrom nav_msgs.msg import Odometry\nfrom geometry_msgs.msg import PoseWithCovarianceStamped, Vector3\n\n\nclass YawTranslator():\n def __init__(self):\n rospy.init_node(\"yaw_translator\")\n\n self.pose_sub = rospy.Subscriber(\"/ground_truth/state\", Odometry,\n self.simCallback, queue_size=1)\n\n self.angle_pub = rospy.Publisher(\"/nav_controller/angle\",\n Vector3,\n queue_size=1)\n\n self.angle = Vector3()\n self.angle.x = 0.0\n self.angle.y = 0.0\n self.angle.z = 0.0\n\n def simCallback(self, msg):\n orient = msg.pose.pose.orientation\n quat = np.array([orient.x, orient.y, orient.z, orient.w])\n euler = tf.euler_from_quaternion(quat, axes='sxyz')\n self.angle.x = euler[0]\n self.angle.y = euler[1]\n self.angle.z = euler[2]\n self.publish()\n\n def publish(self):\n angleMsg = Vector3()\n angleMsg.x = self.angle.x\n angleMsg.y = self.angle.y\n angleMsg.z = self.angle.z\n self.angle_pub.publish(angleMsg)\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = YawTranslator()\n node.run()\n\n\nif __name__ == '__main__':\n main()\n#!/usr/bin/env python\nimport tf.transformations as tf\nimport numpy as np\nimport rospy\nimport threading\nfrom nav_msgs.msg import Odometry\nfrom geometry_msgs.msg import PoseWithCovarianceStamped, Vector3, Pose\n\n\nclass ringTranslator():\n def __init__(self):\n rospy.init_node(\"ring_translator\")\n\n self.pose_sub = rospy.Subscriber(\"/ground_truth/state\", Odometry,\n self.simCallback, queue_size=1)\n\n self.rob_sub = rospy.Subscriber(\"robot_pos_ls\", Pose, self.rob_callback, queue_size=1)\n\n self.ring_sub = rospy.Subscriber(\"ring_pos\",\n Pose,\n self.pos_callback,\n queue_size=1)\n\n self.ring_pub = rospy.Publisher(\"ringWorld\",\n Pose,\n queue_size=1)\n\n self.euler = np.zeros(3)\n self.pos = np.zeros(3)\n self.ring_abs = np.zeros(3)\n self.ring_rel = np.zeros(3)\n\n def simCallback(self, msg):\n orient = msg.pose.pose.orientation\n quat = np.array([orient.x, orient.y, orient.z, orient.w])\n self.euler = tf.euler_from_quaternion(quat, axes='sxyz')\n\n def rob_callback(self, msg):\n pos = msg.position\n self.pos = np.array([pos.x, pos.y, pos.z])\n \n def pos_callback(self, msg):\n pos = msg.position\n self.ring_rel = np.array([-pos.x, pos.y, -pos.z])-\\\n np.array([0.0, -0.1, -0.1])\n self.transform()\n\n def transform(self):\n # R = tf.euler_matrix(-self.euler[0], -self.euler[1], -self.euler[2], 'sxyz')\n # print(self.euler)\n yaw = -(self.euler[2]-np.pi/2)\n R = np.array([[np.cos(yaw), -np.sin(yaw), 0],\n [np.sin(yaw), np.cos(yaw), 0],\n [0, 0, 1]])\n ring_rel_tank = np.matmul(R, self.ring_rel)\n self.ring_abs = ring_rel_tank + self.pos #- \\\n # np.array([0.2, -0.25, 0.2])\n # print(self.ring_abs)\n # print(ring_rel_tank, self.ring_rel)\n self.publish()\n\n def publish(self):\n msg = Pose()\n msg.position.x = self.ring_abs[0]\n msg.position.y = self.ring_abs[1]\n msg.position.z = self.ring_abs[2]\n self.ring_pub.publish(msg)\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = ringTranslator()\n node.run()\n\n\nif __name__ == '__main__':\n main()\n#!/usr/bin/env python\nimport rospy\nfrom bluerov_sim.msg import ActuatorCommands\nfrom mavros_msgs.msg import MotorSetpoint\n\n\nclass MixerNode():\n def __init__(self, name):\n rospy.init_node(name)\n self.thrusters = self.init_mixing()\n self.motor_setpoint_pub = rospy.Publisher(\n \"mavros/setpoint_motor/setpoint\", MotorSetpoint, queue_size=1)\n rospy.Subscriber(\"~actuator_commands\",\n ActuatorCommands,\n self.actuator_callback,\n queue_size=1)\n\n def actuator_callback(self, msg):\n output = MotorSetpoint()\n output.header.stamp = rospy.Time.now()\n for i, thruster in enumerate(self.thrusters):\n output.setpoint[i] = (\n thruster[\"roll\"] * msg.roll + thruster[\"pitch\"] * msg.pitch +\n thruster[\"yaw\"] * msg.yaw + thruster[\"thrust\"] * msg.thrust +\n thruster[\"lateral_thrust\"] * msg.lateral_thrust +\n thruster[\"vertical_thrust\"] * msg.vertical_thrust)\n self.motor_setpoint_pub.publish(output)\n\n def init_mixing(self):\n thruster = [None] * 8\n # roll, pitch, yaw, thrust, lateral thrust, vertical thrust\n thruster[0] = dict(roll=0.0,\n pitch=0.0,\n yaw=1.0,\n thrust=1.0,\n lateral_thrust=1.0,\n vertical_thrust=0.0)\n thruster[1] = dict(roll=0.0,\n pitch=0.0,\n yaw=-1.0,\n thrust=1.0,\n lateral_thrust=-1.0,\n vertical_thrust=0.0)\n thruster[2] = dict(roll=0.0,\n pitch=0.0,\n yaw=1.0,\n thrust=1.0,\n lateral_thrust=-1.0,\n vertical_thrust=0.0)\n thruster[3] = dict(roll=0.0,\n pitch=0.0,\n yaw=-1.0,\n thrust=1.0,\n lateral_thrust=1.0,\n vertical_thrust=0.0)\n thruster[4] = dict(roll=-1.0,\n pitch=-1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=1.0)\n thruster[5] = dict(roll=-1.0,\n pitch=1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=-1.0)\n thruster[6] = dict(roll=1.0,\n pitch=-1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=-1.0)\n thruster[7] = dict(roll=1.0,\n pitch=1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=1.0)\n\n return thruster\n\n\ndef main():\n node = MixerNode(\"mixer\")\n rospy.spin()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64\n# from mavros_msgs.msg import MotorSetpoint\nfrom mavros_msgs.srv import CommandBool\nfrom numpy import sign\n\n\nclass depthControllerNode():\n def __init__(self):\n rospy.init_node(\"depthController\")\n\n self.arm_vehicle()\n\n self.data_lock = threading.RLock()\n\n self.roll_pub = rospy.Publisher(\"roll\",\n Float64,\n queue_size=1)\n self.pitch_pub = rospy.Publisher(\"pitch\",\n Float64,\n queue_size=1)\n self.yaw_pub = rospy.Publisher(\"yaw\",\n Float64,\n queue_size=1)\n self.thrust_pub = rospy.Publisher(\"thrust\",\n Float64,\n queue_size=1)\n self.vertical_thrust_pub = rospy.Publisher(\"vertical_thrust\",\n Float64,\n queue_size=1)\n self.lateral_thrust_pub = rospy.Publisher(\"lateral_thrust\",\n Float64,\n queue_size=1)\n self.roll = 0.0\n self.pitch = 0.0\n self.yaw = 0.0\n self.thrust = 0.0\n self.vertical_thrust = 0.0\n self.lateral_thrust = 0.0\n\n self.setpoint_sub = rospy.Subscriber(\"depth_setpoint\",\n Float64,\n self.on_setpoint,\n queue_size=1)\n # self.setpointMotor_sub = rospy.Subscriber(\"mavros/setpoint_motor/setpoint\",\n # MotorSetpoint,\n # self.on_setpoint_,\n # queue_size=1)\n\n self.depth_sub = rospy.Subscriber(\"depth\", Float64,\n self.depth_callback,\n queue_size=1)\n\n rospy.Timer(rospy.Duration(secs=5), self.control)\n\n \"\"\" # Parameter Theory -> not working\n self.Kp_krit = 2.32\n self.T_krit = 2.8\n self.p_gain = 0.6 * self.Kp_krit\n self.i_gain = self.p_gain / (0.5 * self.T_krit)\n self.d_gain = 0.125 * self.p_gain * self.T_krit \"\"\"\n # Parameter static\n self.static_p_gain = 0.4\n self.static_i_gain = 0.5\n self.static_d_gain = 0.1\n self.static_vorsteuerung = -0.05\n # Dynamic Parameter\n self.dynamic_p_gain = 0.8\n self.dynamic_i_gain = 0.2\n self.dynamic_d_gain = 0.4\n self.dynamic_vorsteuerung_up = 0.05\n self.dynamic_vorsteuerung_down = -0.1\n\n # Reconfigure Options via subscriber\n self.kp_dyn_sub = rospy.Subscriber(\"kp_dyn\", Float64,\n self.kp_dyn_callback, queue_size=1)\n self.ki_dyn_sub = rospy.Subscriber(\"ki_dyn\", Float64,\n self.ki_dyn_callback, queue_size=1)\n self.kd_dyn_sub = rospy.Subscriber(\"kd_dyn\", Float64,\n self.kd_dyn_callback, queue_size=1)\n # Reconfigure Options via subscriber\n self.kp_sta_sub = rospy.Subscriber(\"kp_sta\", Float64,\n self.kp_sta_callback, queue_size=1)\n self.ki_sta_sub = rospy.Subscriber(\"ki_sta\", Float64,\n self.ki_sta_callback, queue_size=1)\n self.kd_sta_sub = rospy.Subscriber(\"kd_sta\", Float64,\n self.kd_sta_callback, queue_size=1)\n\n self.i_buf = [0.0] * 10\n self.setpoint_buf = [0.0] * 5\n self.depth_setpoint = -0.5\n self.depth = self.depth_setpoint\n self.depth_old = self.depth\n self.depth_buf = [self.depth]\n self.depth_buffer_len = 5\n self.sensor_time = rospy.get_time()\n\n def publish(self):\n msg_roll = Float64()\n msg_roll.data = self.roll\n self.roll_pub.publish(msg_roll)\n\n msg_pitch = Float64()\n msg_pitch.data = self.pitch\n self.pitch_pub.publish(msg_pitch)\n\n msg_yaw = Float64()\n msg_yaw.data = self.yaw\n self.yaw_pub.publish(msg_yaw)\n\n msg_thrust = Float64()\n msg_thrust.data = self.thrust\n self.thrust_pub.publish(msg_thrust)\n\n msg_vertical_thrust = Float64()\n msg_vertical_thrust.data = self.vertical_thrust\n self.vertical_thrust_pub.publish(msg_vertical_thrust)\n\n msg_lateral_thrust = Float64()\n msg_lateral_thrust.data = self.lateral_thrust\n self.lateral_thrust_pub.publish(msg_lateral_thrust)\n\n def on_setpoint(self, msg):\n with self.data_lock:\n if not self.isRegion(msg.data):\n self.depth_setpoint = msg.data\n self.setpoint_buf.append(self.depth_setpoint)\n self.setpoint_buf.pop(0)\n self.control()\n\n def kp_dyn_callback(self, msg):\n with self.data_lock:\n self.dynamic_p_gain = msg.data\n\n def ki_dyn_callback(self, msg):\n with self.data_lock:\n self.dynamic_i_gain = msg.data\n\n def kd_dyn_callback(self, msg):\n with self.data_lock:\n self.dynamic_d_gain = msg.data\n\n def kp_sta_callback(self, msg):\n with self.data_lock:\n self.static_p_gain = msg.data\n\n def ki_sta_callback(self, msg):\n with self.data_lock:\n self.static_i_gain = msg.data\n\n def kd_sta_callback(self, msg):\n with self.data_lock:\n self.static_d_gain = msg.data\n\n def depth_callback(self, msg):\n with self.data_lock:\n self.depth = msg.data\n self.sensor_time = rospy.get_time()\n self.control()\n\n # might be redundant if only self.run is used\n def control(self, *args):\n if rospy.get_time() - self.sensor_time > 5:\n rospy.logwarn(\"Sensor Timeout\")\n self.vertical_thrust = 0\n self.publish()\n return\n\n if self.isStatic():\n self.act_p_gain = self.static_p_gain\n self.act_i_gain = self.static_i_gain\n self.act_d_gain = self.static_d_gain\n self.act_vorsteuerung = self.static_vorsteuerung\n else:\n self.act_p_gain = self.dynamic_p_gain\n self.act_i_gain = self.dynamic_i_gain\n self.act_d_gain = self.dynamic_d_gain\n if self.depth_setpoint > self.depth:\n self.act_vorsteuerung = self.dynamic_vorsteuerung_up\n else:\n self.act_vorsteuerung = self.dynamic_vorsteuerung_down\n\n self.i_buf.append(self.depth_setpoint - self.depth)\n self.i_buf.pop(0)\n self.vertical_thrust = \\\n self.act_p_gain * (self.depth_setpoint - self.depth) +\\\n self.act_i_gain * sum(self.i_buf) / len(self.i_buf) +\\\n self.act_d_gain * (self.i_buf[-4] - self.i_buf[-1])\\\n + self.act_vorsteuerung\n # self.depth_old = self.depth_setpoint - self.depth\n\n if abs(self.vertical_thrust) > 1:\n self.vertical_thrust = sign(self.vertical_thrust)\n\n if self.isRegion(self.depth) == 1:\n self.vertical_thrust = -0.1\n elif self.isRegion(self.depth) == -1:\n self.vertical_thrust = 0.1\n\n self.publish()\n\n def isRegion(self, setpoint):\n if setpoint > -0.1:\n return 1\n elif setpoint < -0.8:\n return -1\n else:\n return 0\n\n def isStatic(self):\n if self.i_buf[-4] == self.i_buf[-1]:\n return True\n else:\n return True\n\n def arm_vehicle(self):\n # wait until the arming serivce becomes available\n rospy.wait_for_service(\"mavros/cmd/arming\")\n # connect to the service\n arm = rospy.ServiceProxy(\"mavros/cmd/arming\", CommandBool)\n # call the service to arm the vehicle until service call was successfull\n while not arm(True).success:\n rospy.logwarn(\"Could not arm vehicle. Keep trying.\")\n rospy.sleep(1.0)\n rospy.loginfo(\"Armed successfully.\")\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = depthControllerNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, Int16\nfrom geometry_msgs.msg import Vector3, Pose\nfrom nav_msgs.msg import Odometry\nimport numpy as np\n\n\nclass NavigationNode():\n def __init__(self):\n rospy.init_node(\"navigationNode\")\n self.data_lock = threading.RLock()\n\n self._useGT = rospy.get_param(\"~useGT\", False)\n\n self.ring_sub = rospy.Subscriber(\"ring_pos\",\n Pose,\n self.ringCallback,\n queue_size=1)\n # use ground truth localization or not\n if not self._useGT: \n self.pos_sub = rospy.Subscriber(\"robot_pos\",\n Pose,\n self.posCallback,\n queue_size=1)\n else:\n self.gt_sub = rospy.Subscriber(\"/ground_truth/state\",\n Odometry,\n self.gtCallback,\n queue_size=1)\n self.num_tag = rospy.Subscriber(\"number_tags\", \n Int16,\n self.numTagsCallback,\n queue_size=1)\n self.setpoint_pub = rospy.Publisher(\"pos_setpoint\",\n Pose,\n queue_size=1)\n\n self.x = np.array([0.7, 2.0, -0.5])\n self.xr = np.zeros(3)\n self.numTags = 0\n self.setpoint = np.zeros(3)\n\n def ringCallback(self, msg):\n with self.data_lock:\n self.xr[0] = msg.position.x\n self.xr[1] = msg.position.y\n self.xr[2] = msg.position.z\n\n def posCallback(self, msg):\n with self.data_lock:\n self.x[0] = msg.position.x\n self.x[1] = msg.position.y\n self.x[2] = msg.position.z\n\n def gtCallback(self, msg):\n with self.data_lock:\n self.x[0] = msg.pose.pose.position.x\n self.x[1] = msg.pose.pose.position.y\n self.x[2] = msg.pose.pose.position.z\n\n def numTagsCallback(self, msg):\n with self.data_lock:\n self.numTags = msg.data\n\n def getSetpoint(self):\n _tol = 0.1\n # first move to correct x and z position,\n # then move towards\n # finally, move up\n if abs(self.xr[0]) > _tol or abs(self.xr[2]) > _tol:\n self.setpoint[0] = self.x[0] - self.xr[0]\n self.setpoint[2] = self.x[2] - self.xr[2]\n elif abs(self.xr[1]) > _tol:\n self.setpoint = self.x - self.xr\n else:\n self.setpoint = self.x\n self.setpoint[2] = -0.1\n msg = Pose()\n msg.position.x = self.setpoint[0]\n msg.position.y = self.setpoint[1]\n msg.position.z = self.setpoint[2]\n self.setpoint_pub.publish\n\ndef main():\n node = NavigationNode()\n rospy.spin()\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64\nfrom mavros_msgs.msg import MotorSetpoint\n\n\nclass MixerNode():\n def __init__(self):\n rospy.init_node(\"mixer\")\n\n self.setpoint_pub = rospy.Publisher(\"mavros/setpoint_motor/setpoint\",\n MotorSetpoint,\n queue_size=1)\n\n self.data_lock = threading.RLock()\n\n self.thruster = self.init_mixing()\n\n self.roll = 0.0\n self.pitch = 0.0\n self.yaw = 0.0\n self.thrust = 0.0\n self.vertical_thrust = 0.0\n self.lateral_thrust = 0.0\n\n self.roll_sub = rospy.Subscriber(\"roll\",\n Float64,\n self.on_roll,\n queue_size=1)\n self.pitch_sub = rospy.Subscriber(\"pitch\",\n Float64,\n self.on_pitch,\n queue_size=1)\n self.yaw_sub = rospy.Subscriber(\"yaw\",\n Float64,\n self.on_yaw,\n queue_size=1)\n self.thrust_sub = rospy.Subscriber(\"thrust\",\n Float64,\n self.on_thrust,\n queue_size=1)\n self.vertical_thrust_sub = rospy.Subscriber(\"vertical_thrust\",\n Float64,\n self.on_vertical_thrust,\n queue_size=1)\n self.lateral_thrust_sub = rospy.Subscriber(\"lateral_thrust\", Float64,\n self.on_lateral_thrust)\n\n def run(self):\n rate = rospy.Rate(50.0)\n while not rospy.is_shutdown():\n msg = self.mix()\n self.setpoint_pub.publish(msg)\n rate.sleep()\n\n def on_roll(self, msg):\n with self.data_lock:\n self.roll = msg.data\n\n def on_pitch(self, msg):\n with self.data_lock:\n self.pitch = msg.data\n\n def on_yaw(self, msg):\n with self.data_lock:\n self.yaw = msg.data\n\n def on_thrust(self, msg):\n with self.data_lock:\n self.thrust = msg.data\n\n def on_vertical_thrust(self, msg):\n with self.data_lock:\n self.vertical_thrust = msg.data\n\n def on_lateral_thrust(self, msg):\n with self.data_lock:\n self.lateral_thrust = msg.data\n\n def mix(self):\n msg = MotorSetpoint()\n msg.header.stamp = rospy.Time.now()\n with self.data_lock:\n for i in range(8):\n msg.setpoint[i] = (\n self.roll * self.thruster[i][\"roll\"] +\n self.pitch * self.thruster[i][\"pitch\"] +\n self.yaw * self.thruster[i][\"yaw\"] +\n self.thrust * self.thruster[i][\"thrust\"] +\n self.vertical_thrust * self.thruster[i][\"vertical_thrust\"] +\n self.lateral_thrust * self.thruster[i][\"lateral_thrust\"])\n return msg\n\n def init_mixing(self):\n thruster = [None] * 8\n # roll, pitch, yaw, thrust, lateral thrust, vertical thrust\n thruster[0] = dict(roll=0.0,\n pitch=0.0,\n yaw=1.0,\n thrust=1.0,\n lateral_thrust=1.0,\n vertical_thrust=0.0)\n thruster[1] = dict(roll=0.0,\n pitch=0.0,\n yaw=-1.0,\n thrust=1.0,\n lateral_thrust=-1.0,\n vertical_thrust=0.0)\n thruster[2] = dict(roll=0.0,\n pitch=0.0,\n yaw=1.0,\n thrust=1.0,\n lateral_thrust=-1.0,\n vertical_thrust=0.0)\n thruster[3] = dict(roll=0.0,\n pitch=0.0,\n yaw=-1.0,\n thrust=1.0,\n lateral_thrust=1.0,\n vertical_thrust=0.0)\n thruster[4] = dict(roll=-1.0,\n pitch=-1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=1.0)\n thruster[5] = dict(roll=-1.0,\n pitch=1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=-1.0)\n thruster[6] = dict(roll=1.0,\n pitch=-1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=-1.0)\n thruster[7] = dict(roll=1.0,\n pitch=1.0,\n yaw=0.0,\n thrust=0.0,\n lateral_thrust=0.0,\n vertical_thrust=1.0)\n\n return thruster\n\n\ndef main():\n node = MixerNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport numpy as np\nfrom apriltag_ros.msg import AprilTagDetectionArray\nfrom range_sensor.msg import RangeMeasurementArray, RangeMeasurement\n\n\nclass RangeSensorNode():\n def __init__(self):\n rospy.init_node(\"range_sensor\")\n\n self.range_pub = rospy.Publisher(\"ranges\",\n RangeMeasurementArray,\n queue_size=1)\n self.simulation = rospy.get_param(\"~sim\", True)\n\n rospy.Subscriber(\"tag_detections_sim\",\n RangeMeasurementArray,\n self.on_sim_dist,\n queue_size=1)\n\n def on_sim_dist(self, msg):\n self.range_pub.publish(msg)\n\n def on_apriltag(self, tag_array_msg):\n num_tags = len(tag_array_msg.detections)\n\n range_array_msg = RangeMeasurementArray()\n range_array_msg.header = tag_array_msg.header\n\n # if tags are detected\n if num_tags:\n for i, tag in enumerate(tag_array_msg.detections):\n range_msg = RangeMeasurement()\n\n # tag id -> our numbers for each anchor\n if tag.id[0] == 0:\n range_msg.id = 1\n elif tag.id[0] == 2:\n range_msg.id = 2\n elif tag.id[0] == 3:\n range_msg.id = 3\n elif tag.id[0] == 4:\n range_msg.id = 4\n\n range_msg.range = np.sqrt(tag.pose.pose.pose.position.x**2 +\n tag.pose.pose.pose.position.y**2 +\n tag.pose.pose.pose.position.z**2)\n range_msg.header = tag_array_msg.header\n range_array_msg.measurements.append(range_msg)\n\n self.range_pub.publish(range_array_msg)\n\n\ndef main():\n node = RangeSensorNode()\n\n while not rospy.is_shutdown():\n rospy.spin()\n\n\nif __name__ == \"__main__\":\n main()\n#include \n\nnamespace gazebo {\nGZ_REGISTER_MODEL_PLUGIN(PressurePlugin)\n\nPressurePlugin::PressurePlugin()\n : ModelPlugin(), baro_rnd_y2_(0.0), baro_rnd_use_last_(false) {}\n\nPressurePlugin::~PressurePlugin() { update_connection_->~Connection(); }\n\nvoid PressurePlugin::getSdfParams(sdf::ElementPtr sdf) {\n namespace_.clear();\n if (sdf->HasElement(\"robotNamespace\")) {\n namespace_ = sdf->GetElement(\"robotNamespace\")->Get();\n }\n if (sdf->HasElement(\"pubRate\")) {\n pub_rate_ = sdf->GetElement(\"pubRate\")->Get();\n } else {\n pub_rate_ = kDefaultPubRate;\n gzwarn << \"[pressure_plugin] Using default publication rate of \"\n << pub_rate_ << \"Hz\\n\";\n }\n if (sdf->HasElement(\"pressureTopic\")) {\n pressure_topic_ = sdf->GetElement(\"pressureTopic\")->Get();\n } else {\n pressure_topic_ = kDefaultPressureTopic;\n }\n if (sdf->HasElement(\"noise\")) {\n pressure_noise_ = sdf->GetElement(\"noise\")->Get();\n } else {\n pressure_noise_ = kDefaultPressureNoise;\n }\n}\n\nvoid PressurePlugin::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {\n getSdfParams(sdf);\n model_ = model;\n world_ = model_->GetWorld();\n last_time_ = world_->SimTime();\n last_pub_time_ = world_->SimTime();\n\n if (!ros::isInitialized()) {\n ROS_FATAL_STREAM(\"Ros node for gazebo not initialized\");\n return;\n }\n node_handle_ = new ros::NodeHandle(namespace_);\n\n update_connection_ = event::Events::ConnectWorldUpdateBegin(\n boost::bind(&PressurePlugin::OnUpdate, this, _1));\n\n pressure_pub_ =\n node_handle_->advertise(pressure_topic_, 1);\n}\n\nvoid PressurePlugin::OnUpdate(const common::UpdateInfo &) {\n common::Time current_time = world_->SimTime();\n double dt = (current_time - last_pub_time_).Double();\n\n if (dt > 1.0 / pub_rate_) {\n sensor_msgs::FluidPressure msg;\n double z_height =\n model_->GetLink(\"pressure_sensor_link\")->WorldPose().Pos().Z();\n\n msg.header.stamp = ros::Time::now();\n msg.header.frame_id = \"map\";\n // pressure increases by 10 kPa/m water depth.\n // pressure decreases roughly 100 Pa/8m in air.\n double msl_pressure = 101325.0;\n\n if (z_height > 0)\n msg.fluid_pressure = msl_pressure - z_height * 12.5;\n else\n msg.fluid_pressure = msl_pressure - z_height * 10000;\n\n // generate Gaussian noise sequence using polar form of Box-Muller\n // transformation\n double x1, x2, w, y1;\n if (!baro_rnd_use_last_) {\n do {\n x1 = 2.0 * standard_normal_distribution_(random_generator_) - 1.0;\n x2 = 2.0 * standard_normal_distribution_(random_generator_) - 1.0;\n w = x1 * x1 + x2 * x2;\n } while (w >= 1.0);\n w = sqrt((-2.0 * log(w)) / w);\n // calculate two values - the second value can be used next time because\n // it is uncorrelated\n y1 = x1 * w;\n baro_rnd_y2_ = x2 * w;\n baro_rnd_use_last_ = true;\n } else {\n // no need to repeat the calculation - use the second value from last\n // update\n y1 = baro_rnd_y2_;\n baro_rnd_use_last_ = false;\n }\n\n // apply noise.\n double noise = pressure_noise_ * y1;\n msg.fluid_pressure += noise;\n\n pressure_pub_.publish(msg);\n last_pub_time_ = current_time;\n }\n}\n} // namespace gazebo\n#!/usr/bin/env python\nimport rospy\nfrom visualization_msgs.msg import Marker\nfrom nav_msgs.msg import Odometry\n\n\nclass VisualizerNode():\n def __init__(self):\n rospy.init_node(\"rviz_visualizer\")\n self.bluerov_marker_pub = rospy.Publisher(\"bluerov_marker\",\n Marker,\n queue_size=30)\n self.ground_truth_sub = rospy.Subscriber(\"ground_truth/state\", Odometry,\n self.on_ground_truth)\n\n def run(self):\n rospy.spin()\n\n def publish_marker(self, pose, header):\n msg = Marker()\n msg.header = header\n msg.ns = \"bluerov_ns\"\n msg.id = 27\n msg.type = Marker.MESH_RESOURCE\n msg.pose = pose\n msg.mesh_resource = \"package://bluerov_sim/models/uuv_bluerov2_heavy/meshes/BlueROV2heavy.dae\"\n msg.color.a = 1.0\n msg.color.r = 1.0\n msg.color.g = 1.0\n msg.color.b = 1.0\n msg.scale.x = 1\n msg.scale.y = 1\n msg.scale.z = 1\n self.bluerov_marker_pub.publish(msg)\n\n def on_ground_truth(self, msg):\n self.publish_marker(msg.pose.pose, msg.header)\n\n\ndef main():\n node = VisualizerNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, Int16\nfrom geometry_msgs.msg import Vector3, Pose\nfrom apriltag_ros.msg import AprilTagDetectionArray\nfrom range_sensor.msg import RangeMeasurementArray\nfrom nav_msgs.msg import Odometry\nimport tf.transformations as trans\nfrom scipy.optimize import minimize, least_squares\nimport numpy as np\nfrom numpy.linalg import norm\n\np = []\ntank_bound_lower = np.array([0.0, 0.0, -1.3])\ntank_bound_upper = np.array([2.0, 4.0, 0.0])\n\nfor j in range(9):\n for i in range(7):\n p.append(np.array([1.56-i*0.25, 0.06+j*0.39375, -1.3]))\n\np = np.array(p)\n\nclass localizationNodeLS():\n def __init__(self):\n rospy.init_node(\"localizationNodeLS\")\n self.data_lock = threading.RLock()\n self.range_sub = rospy.Subscriber(\"ranges\", RangeMeasurementArray, self.rangeCallback, queue_size=1)\n self.pos_pub = rospy.Publisher(\"robot_pos_ls\", Pose, queue_size=1)\n #self.tag_num_pub = rospy.Publisher(\"number_tags\", Int16, queue_size=1)\n self.x0 = np.zeros(3)\n self.avg_buf = []\n self.avg_dist_buf = [[] for _ in range(63)]\n self.avg_buf_len = 3\n self.avg_buf_len_dist = 5\n\n def rangeCallback(self, msg):\n with self.data_lock:\n dists = np.zeros(63)\n for measure in msg.measurements:\n if measure.id >= 5:\n id = measure.id-4\n dists[id-1] = measure.range\n #tagNumerMsg = Int16()\n #tagNumerMsg.data = len([1 for dist in dists if dist != 0])\n #self.tag_num_pub.publish(tagNumerMsg)\n for i in range(63):\n if dists[i] != 0:\n self.avg_dist_buf[i].append(dists[i])\n if len(self.avg_dist_buf[i]) > self.avg_buf_len_dist:\n self.avg_dist_buf[i].pop(0)\n if len(self.avg_dist_buf[i]) > 0:\n dists[i] = sum(self.avg_dist_buf[i]) / \\\n len(self.avg_dist_buf[i])\n self.x0 = self.optimization(dists, self.x0)\n self.avg_buf.append(self.x0)\n if len(self.avg_buf) > self.avg_buf_len:\n self.avg_buf.pop(0)\n self.x0 = sum(self.avg_buf) / len(self.avg_buf)\n \n poseMsg = Pose()\n poseMsg.position.x = self.x0[0]\n poseMsg.position.y = self.x0[1]\n poseMsg.position.z = self.x0[2]\n self.pos_pub.publish(poseMsg)\n\n # def depth_callback(self, msg):\n # with self.data_lock:\n # self.depth = msg.data\n\n # def gt_callback(self, msg):\n # with self.data_lock:\n # self.z_gt = msg.pose.pose.position.z+0.08\n\n def optimization(self, dists, x0):\n def objective_function(x):\n return np.array([norm(p[i]-x)-dists[i]\n for i in range(63) if dists[i] != 0])\n return least_squares(objective_function, x0, ftol=1e-7,\n bounds=(tank_bound_lower, tank_bound_upper)).x\n\n\ndef main():\n node = localizationNodeLS()\n rospy.spin()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\n\nimport rospy\nimport pygame\nimport rospkg\nimport os\nfrom bluerov_sim.msg import ActuatorCommands\nfrom mavros_msgs.srv import CommandBool\n\n\nclass Text(object):\n def __init__(self, font_name=None, size=30, text=\"empty text\"):\n self.font_name = font_name\n self.font_size = size\n self.color_fg = (255, 255, 255)\n self.color_bg = (0, 0, 0)\n self._aa = True\n self._text = text\n self.font = pygame.font.SysFont(font_name, size)\n self.screen = pygame.display.get_surface()\n\n self.dirty = True\n self.image = None\n self.rect = None\n self._render()\n\n def _render(self):\n self.dirty = False\n self.image = self.font.render(self._text, self.aa, self.color_fg)\n self.rect = self.image.get_rect()\n\n def draw(self):\n if self.dirty or (self.image is None):\n self._render()\n self.screen.blit(self.image, self.rect)\n\n @property\n def text(self):\n return self._text\n\n @text.setter\n def text(self, text):\n if text != self._text:\n self.dirty = True\n self._text = text\n\n @property\n def aa(self):\n return self._aa\n\n @aa.setter\n def aa(self, aa):\n self.dirty = True\n self._aa = aa\n\n\nclass TextGrid(object):\n def __init__(self, layout, padding, size):\n self.texts = []\n for row in range(layout[0]):\n row_list = []\n for col in range(layout[1]):\n row_list.append(Text(\"dejavusansmono\", size, \"{}x{}\".format(row, col)))\n self.texts.append(row_list)\n \n self.padding = padding\n self.font_size = size\n self.screen = pygame.display.get_surface()\n self.layout = layout\n self.draw()\n\n def draw(self):\n self.dirty = False\n col_widths = self.get_column_widths()\n row_heights = self.get_row_heights()\n x_col_offsets = [self.padding[0]] * self.layout[1]\n y_row_offsets = [self.padding[1]] * self.layout[0]\n for col in range(1, self.layout[1]):\n x_col_offsets[col] = x_col_offsets[\n col - 1] + self.padding[0] + col_widths[col - 1]\n for row in range(1, self.layout[0]):\n y_row_offsets[row] = y_row_offsets[\n row - 1] + self.padding[1] + row_heights[row - 1]\n\n for row in range(self.layout[0]):\n for col in range(self.layout[1]):\n self.texts[row][col].rect.top = y_row_offsets[row]\n self.texts[row][col].rect.left = x_col_offsets[col]\n self.texts[row][col].draw()\n\n def get_column_widths(self):\n widths = []\n for col in range(self.layout[1]):\n max_width = 0\n for row in range(self.layout[0]):\n if self.texts[row][col].rect.width > max_width:\n max_width = self.texts[row][col].rect.width\n widths.append(max_width)\n return widths\n\n def get_row_heights(self):\n heights = []\n for row in range(self.layout[0]):\n max_height = 0\n for col in range(self.layout[1]):\n if self.texts[row][col].rect.height > max_height:\n max_height = self.texts[row][col].rect.height\n heights.append(max_height)\n return heights\n\n def set_text(self, row, col, string):\n self.texts[row][col].text = string\n\n\nclass KeyboardControlNode():\n WINDOW_SIZE = (640, 200)\n DISPLAY_FLAGS = pygame.DOUBLEBUF\n\n def __init__(self, name):\n pygame.init()\n pygame.mixer.quit()\n rospy.init_node(name)\n\n self.arm_vehicle()\n\n self.thrust = 0.0\n self.thrust_stepsize = 0.1\n self.thrust_scaler = 0.4\n self.lateral_thrust = 0.0\n self.lateral_thrust_stepsize = 0.1\n self.lateral_thrust_scaler = 0.4\n self.vertical_thrust = 0.0\n self.vertical_thrust_stepsize = 0.1\n self.vertical_thrust_scaler = 0.4\n self.yaw_rate = 0.0\n self.yaw_rate_stepsize = 0.1\n self.yaw_rate_scaler = 0.2\n\n # create GUI\n self.screen = self.init_display()\n self.text_grid = self.init_text_grid()\n\n self.controls = self.init_controls()\n\n self.actuator_pub = rospy.Publisher(\"mixer/actuator_commands\",\n ActuatorCommands,\n queue_size=1)\n\n def arm_vehicle(self):\n rospy.wait_for_service(\"mavros/cmd/arming\")\n arm = rospy.ServiceProxy(\"mavros/cmd/arming\", CommandBool)\n while not arm(True).success:\n rospy.logwarn_throttle(1, \"Could not arm vehicle. Keep trying.\")\n rospy.loginfo(\"Armed successfully.\")\n\n def disarm_vehicle(self):\n rospy.wait_for_service(\"mavros/cmd/arming\")\n arm = rospy.ServiceProxy(\"mavros/cmd/arming\", CommandBool)\n arm(False)\n\n def init_display(self):\n screen = pygame.display.set_mode(self.WINDOW_SIZE, self.DISPLAY_FLAGS)\n vehicle_name = rospy.get_namespace().strip(\"/\")\n pygame.display.set_caption(\n \"Keyboard Control of {}\".format(vehicle_name))\n\n icon_path = os.path.join(self.get_resource_path(), \"icon.png\")\n icon = pygame.image.load(icon_path)\n pygame.display.set_icon(icon)\n return screen\n\n def init_text_grid(self):\n text_grid = TextGrid((4, 2), (5, 5), 30)\n text_grid.set_text(0, 0, \"Thrust Scaling (1/2):\")\n text_grid.set_text(0, 1, \"0.0\")\n text_grid.set_text(1, 0, \"Yaw Scaling(3/4):\")\n text_grid.set_text(1, 1, \"0.0\")\n text_grid.set_text(2, 0, \"Vertical Thrust Scaling(5/6):\")\n text_grid.set_text(2, 1, \"0.0\")\n text_grid.set_text(3, 0, \"Lateral Thrust Scaling(7/8):\")\n text_grid.set_text(3, 1, \"0.0\")\n text_grid.draw()\n return text_grid\n\n def update_text_grid(self):\n self.text_grid.set_text(0, 1, \"{:.2f}\".format(self.thrust_scaler))\n self.text_grid.set_text(1, 1, \"{:.2f}\".format(self.yaw_rate_scaler))\n self.text_grid.set_text(2, 1,\n \"{:.2f}\".format(self.vertical_thrust_scaler))\n self.text_grid.set_text(3, 1,\n \"{:.2f}\".format(self.lateral_thrust_scaler))\n self.text_grid.draw()\n\n def run(self):\n rate = rospy.Rate(30.0)\n\n while not rospy.is_shutdown():\n self.handle_events()\n self.screen.fill((0, 0, 0))\n self.update_text_grid()\n pygame.display.flip()\n self.publish_message()\n rate.sleep()\n\n def set_thrust(self, value):\n value *= self.thrust_scaler\n self.thrust = max(-1, min(1, value))\n\n def set_yaw_rate(self, value):\n value *= self.yaw_rate_scaler\n self.yaw_rate = max(-1, min(1, value))\n\n def set_vertical_thrust(self, value):\n value *= self.vertical_thrust_scaler\n self.vertical_thrust = max(-1, min(1, value))\n\n def set_lateral_thrust(self, value):\n value *= self.lateral_thrust_scaler\n self.lateral_thrust = max(-1, min(1, value))\n\n def increase_thrust_scaler(self, value):\n self.thrust_scaler += value\n self.thrust_scaler = max(0, min(1, self.thrust_scaler))\n\n def increase_yaw_rate_scaler(self, value):\n self.yaw_rate_scaler += value\n self.yaw_rate_scaler = max(0, min(1, self.yaw_rate_scaler))\n\n def increase_vertical_thrust_scaler(self, value):\n self.vertical_thrust_scaler += value\n self.vertical_thrust_scaler = max(0, min(1,\n self.vertical_thrust_scaler))\n\n def increase_lateral_thrust_scaler(self, value):\n self.lateral_thrust_scaler += value\n self.lateral_thrust_scaler = max(0, min(1, self.lateral_thrust_scaler))\n\n def init_controls(self):\n controls = {\n pygame.K_q:\n dict(\n pressed=False,\n changed=False,\n description=\"Turn left.\",\n pressed_callback=(lambda: self.set_yaw_rate(1)),\n released_callback=(lambda: self.set_yaw_rate(0)),\n ),\n pygame.K_e:\n dict(\n pressed=False,\n changed=False,\n description=\"Turn right.\",\n pressed_callback=(lambda: self.set_yaw_rate(-1)),\n released_callback=(lambda: self.set_yaw_rate(0)),\n ),\n pygame.K_UP:\n dict(\n pressed=False,\n changed=False,\n description=\"Positive vertical thrust.\",\n pressed_callback=(lambda: self.set_vertical_thrust(1)),\n released_callback=(lambda: self.set_vertical_thrust(0)),\n ),\n pygame.K_DOWN:\n dict(\n pressed=False,\n changed=False,\n description=\"Negative vertical thrust.\",\n pressed_callback=(lambda: self.set_vertical_thrust(-1)),\n released_callback=(lambda: self.set_vertical_thrust(0)),\n ),\n pygame.K_a:\n dict(\n pressed=False,\n changed=False,\n description=\"Positive lateral thrust.\",\n pressed_callback=(lambda: self.set_lateral_thrust(1)),\n released_callback=(lambda: self.set_lateral_thrust(0)),\n ),\n pygame.K_d:\n dict(\n pressed=False,\n changed=False,\n description=\"Negative lateral thrust.\",\n pressed_callback=(lambda: self.set_lateral_thrust(-1)),\n released_callback=(lambda: self.set_lateral_thrust(0)),\n ),\n pygame.K_w:\n dict(\n pressed=False,\n changed=False,\n description=\"Forward thrust.\",\n pressed_callback=(lambda: self.set_thrust(1)),\n released_callback=(lambda: self.set_thrust(0)),\n ),\n pygame.K_s:\n dict(\n pressed=False,\n changed=False,\n description=\"Backward thrust.\",\n pressed_callback=(lambda: self.set_thrust(-1)),\n released_callback=(lambda: self.set_thrust(0)),\n ),\n pygame.K_1:\n dict(\n pressed=False,\n changed=False,\n description=\"Decrease forward thrust.\",\n pressed_callback=(\n lambda: self.increase_thrust_scaler(-self.thrust_stepsize)),\n ),\n pygame.K_2:\n dict(\n pressed=False,\n changed=False,\n description=\"Increase forward thrust.\",\n pressed_callback=(\n lambda: self.increase_thrust_scaler(self.thrust_stepsize)),\n ),\n pygame.K_3:\n dict(\n pressed=False,\n changed=False,\n description=\"Decrease yaw rate.\",\n pressed_callback=(lambda: self.increase_yaw_rate_scaler(\n -self.yaw_rate_stepsize)),\n ),\n pygame.K_4:\n dict(\n pressed=False,\n changed=False,\n description=\"Increase yaw rate.\",\n pressed_callback=(lambda: self.increase_yaw_rate_scaler(\n self.yaw_rate_stepsize)),\n ),\n pygame.K_5:\n dict(\n pressed=False,\n changed=False,\n description=\"Decrease vertical thrust.\",\n pressed_callback=(lambda: self.increase_vertical_thrust_scaler(\n -self.vertical_thrust_stepsize)),\n ),\n pygame.K_6:\n dict(\n pressed=False,\n changed=False,\n description=\"Increase vertical thrust.\",\n pressed_callback=(lambda: self.increase_vertical_thrust_scaler(\n self.vertical_thrust_stepsize)),\n ),\n pygame.K_7:\n dict(\n pressed=False,\n changed=False,\n description=\"Decrease lateral thrust.\",\n pressed_callback=(lambda: self.increase_lateral_thrust_scaler(\n -self.lateral_thrust_stepsize)),\n ),\n pygame.K_8:\n dict(\n pressed=False,\n changed=False,\n description=\"Increase lateral thrust.\",\n pressed_callback=(lambda: self.increase_lateral_thrust_scaler(\n self.lateral_thrust_stepsize)),\n ),\n }\n return controls\n\n def print_controls(self, controls):\n print(\"Controls:\")\n for key in controls:\n print(\"{}: {}\".format(pygame.key.name(key),\n controls[key][\"description\"]))\n\n def get_resource_path(self):\n res_path = rospkg.RosPack().get_path(\"bluerov_sim\")\n res_path = os.path.join(res_path, \"res\")\n return res_path\n\n def print_current_values(self):\n print(\"thrust: {}\\nyaw_rate: {}\\nlateral_thrust: {}\\n\"\n \"vertical_thrust: {}\".format(self.thrust, self.yaw_rate,\n self.lateral_thrust,\n self.vertical_thrust))\n\n def handle_events(self):\n events = pygame.event.get()\n for event in events:\n if event.type == pygame.KEYDOWN:\n if event.key in self.controls:\n control = self.controls[event.key]\n if \"pressed_callback\" in control:\n control[\"pressed_callback\"]()\n elif event.type == pygame.KEYUP:\n if event.key in self.controls:\n control = self.controls[event.key]\n if \"released_callback\" in control:\n control[\"released_callback\"]()\n\n elif event.type == pygame.QUIT:\n pygame.quit()\n rospy.signal_shutdown(\"Quitting\")\n\n def publish_message(self):\n msg = ActuatorCommands()\n msg.header.stamp = rospy.Time.now()\n msg.thrust = self.thrust\n msg.yaw = self.yaw_rate\n msg.lateral_thrust = self.lateral_thrust\n msg.vertical_thrust = self.vertical_thrust\n self.actuator_pub.publish(msg)\n\n\ndef main():\n node = KeyboardControlNode(\"keyboard\")\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, Int16\nfrom geometry_msgs.msg import Vector3, Pose\nfrom apriltag_ros.msg import AprilTagDetectionArray\nfrom range_sensor.msg import RangeMeasurementArray\nfrom nav_msgs.msg import Odometry\nimport tf.transformations as trans\nfrom scipy.optimize import minimize, least_squares\nimport numpy as np\nfrom numpy.linalg import norm\n\n__radius_ring__ = np.sqrt(2.0*0.12**2.0)\n\ndef node_at_angle(phi):\n r = __radius_ring__\n return r*np.array([np.cos(phi), 0.0, np.sin(phi)])\n\ntag1 = node_at_angle(np.pi/4.0)\ntag2 = node_at_angle(3.0*np.pi/4.0)\ntag3 = node_at_angle(-3.0*np.pi/4.0)\ntag4 = node_at_angle(-np.pi/4.0)\np = np.array([tag1, tag2, tag3, tag4])\n# tank_bound_lower = np.array([-1.6, 0.0, -1.0])\n# tank_bound_upper = np.array([1.6, 3.35, 1.0])\ntank_bound_lower = np.array([-4.0, 0.0, -1.0])\ntank_bound_upper = np.array([4.0, 4.0, 1.0])\n\nhook_offset = np.array([0.0, -0.1, -0.15])\n\nclass localizationNode():\n def __init__(self):\n rospy.init_node(\"ringLocalizationNode\")\n self.data_lock = threading.RLock()\n self.range_sub = rospy.Subscriber(\"ranges\", RangeMeasurementArray, self.rangeCallback, queue_size=1)\n self.pos_pub = rospy.Publisher(\"ring_pos\", Pose, queue_size=1)\n self.tag_num_pub = rospy.Publisher(\"number_tags\", Int16, queue_size=1)\n self.x0 = np.array([0.0, 1.0, 0.0])\n self.avg_buf = []\n self.avg_dist_buf = [[] for _ in range(4)]\n self.avg_buf_len = 3\n self.avg_buf_len_dist = 5\n\n def rangeCallback(self, msg):\n with self.data_lock:\n dists = np.zeros(4)\n for measure in msg.measurements:\n if measure.id < 5:\n id = measure.id\n dists[id-1] = measure.range\n tagNumerMsg = Int16()\n tagNumerMsg.data = len([1 for dist in dists if dist != 0])\n self.tag_num_pub.publish(tagNumerMsg)\n for i in range(4):\n if dists[i] != 0:\n self.avg_dist_buf[i].append(dists[i])\n if len(self.avg_dist_buf[i]) > self.avg_buf_len_dist:\n self.avg_dist_buf[i].pop(0)\n if len(self.avg_dist_buf[i]) > 0:\n dists[i] = sum(self.avg_dist_buf[i]) / \\\n len(self.avg_dist_buf[i])\n if len([1 for d in dists if d != 0]) < 3:\n return\n self.x0 = self.optimization(dists, self.x0)\n # self.avg_buf.append(self.x0)\n # if len(self.avg_buf) > self.avg_buf_len:\n # self.avg_buf.pop(0)\n # self.x0 = sum(self.avg_buf) / len(self.avg_buf)\n \n poseMsg = Pose()\n poseMsg.position.x = self.x0[0] + hook_offset[0]\n poseMsg.position.y = self.x0[1] + hook_offset[1]\n poseMsg.position.z = self.x0[2] + hook_offset[2]\n self.pos_pub.publish(poseMsg)\n\n def optimization(self, dists, x0):\n def objective_function(x):\n return np.array([norm(p[i]-x)-dists[i]\n for i in range(4) if dists[i] != 0])\n return least_squares(objective_function, x0, ftol=1e-7,\n bounds=(tank_bound_lower, tank_bound_upper)).x\n # return least_squares(objective_function, x0, ftol=1e-7).x\n\ndef main():\n node = localizationNode()\n rospy.spin()\n\nif __name__ == \"__main__\":\n main()\ncmake_minimum_required(VERSION 2.8.3)\nproject(bluerov_sim)\n\n\nfind_package(catkin REQUIRED COMPONENTS\n gazebo_ros\n gazebo_plugins\n roscpp\n std_msgs\n message_generation\n range_sensor\n)\n\nadd_compile_options(-std=c++14)\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}\")\n\nfind_package(gazebo REQUIRED)\n\nadd_message_files(\n FILES\n ActuatorCommands.msg\n)\n\ngenerate_messages(\n DEPENDENCIES\n std_msgs\n)\n\nlink_directories(${GAZEBO_LIBRARY_DIRS})\n\ninclude_directories(include ${catkin_INCLUDE_DIRS}\n ${GAZEBO_INCLUDE_DIRS}\n ${Boost_INCLUDE_DIR})\n\ncatkin_package(\n# INCLUDE_DIRS include\n DEPENDS \n roscpp \n gazebo_ros\n CATKIN_DEPENDS \n message_runtime\n)\n\nadd_library(gazebo_pressure_plugin plugins/gazebo_pressure_plugin.cpp)\nadd_dependencies(gazebo_pressure_plugin ${catkin_EXPORTED_TARGETS})\ntarget_link_libraries(gazebo_pressure_plugin ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES})\n\nadd_library(gazebo_range_sensor_plugin plugins/gazebo_range_sensor_plugin.cpp)\nadd_dependencies(gazebo_range_sensor_plugin ${catkin_EXPORTED_TARGETS})\ntarget_link_libraries(gazebo_range_sensor_plugin ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES})\n\n#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, Int16\nfrom geometry_msgs.msg import Vector3, Pose\nfrom apriltag_ros.msg import AprilTagDetectionArray\nfrom range_sensor.msg import RangeMeasurementArray, RangeMeasurement\nfrom nav_msgs.msg import Odometry\nimport tf.transformations as trans\n# from scipy.optimize import minimize, least_squares\nimport numpy as np\nfrom numpy.linalg import norm,inv\n\np = []\ntank_bound_lower = np.array([0.0, 0.0, -1.3])\ntank_bound_upper = np.array([2.0, 4.0, 0.0])\n\nfor j in range(9):\n for i in range(7):\n p.append(np.array([1.56-i*0.25, 0.06+j*0.39375, -1.3]))\nrange_buf = np.zeros(len(p))\ntank_bound_lower = np.array([0.0, 0.0, -1.0])\ntank_bound_upper = np.array([1.6, 3.35, 0.0])\n\n\nxref = np.array([t[0] for t in p])\nyref = np.array([t[1] for t in p])\nzref = np.array([t[2] for t in p])\n\nclass localizationNode():\n def __init__(self):\n rospy.init_node(\"localizationNode\", log_level = rospy.DEBUG)\n self.data_lock = threading.RLock()\n\n self.range_sub = rospy.Subscriber(\"ranges\", RangeMeasurementArray, self.rangeCallback, queue_size=1)\n self.depth_sub = rospy.Subscriber(\"depth\", Float64,\n self.depth_callback,\n queue_size=1)\n self.groundTruth_sub = rospy.Subscriber(\"/ground_truth/state\", Odometry, self.gt_callback, queue_size=1)\n self.z_gt = 0.0\n self.pos_pub = rospy.Publisher(\"robot_pos\", Pose, queue_size=1)\n self.range_est_pub = rospy.Publisher(\"range_estimates\", RangeMeasurementArray, queue_size=1)\n self.range_meas_pub = rospy.Publisher(\"range_measurements\", RangeMeasurementArray, queue_size=1)\n self.x0 = np.zeros(3)\n self.Sigma0 = np.diag([0.01, 0.01, 0.01])\n self.avg_buf = []\n self.avg_dist1_buf = []\n self.avg_dist2_buf = []\n self.avg_dist3_buf = []\n self.avg_dist4_buf = []\n self.avg_buf_len = 10\n self.avg_buf_len_dist = 10\n self.y = 0.0\n\n def rangeCallback(self, msg):\n with self.data_lock:\n dists = np.zeros(63)\n for measure in msg.measurements:\n if measure.id >= 5:\n id = measure.id-4\n dists[id-1] = measure.range\n \n (self.x0, self.Sigma0) = kalmanP(dists, self.depth * 1.0e4, self.x0, self.Sigma0)\n\n x0 = self.x0\n\n poseMsg = Pose()\n poseMsg.position.x = x0[0]\n poseMsg.position.y = x0[1]\n poseMsg.position.z = x0[2]\n\n # Output the estimated range measurement based on the position estimate\n range_est_array_msg = RangeMeasurementArray()\n for i in range(len(p)):\n x_diff = x0[0] - p[i][0]\n y_diff = x0[1] - p[i][1]\n z_diff = x0[2] - p[i][2]\n range_est_msg = RangeMeasurement()\n range_est_msg.id = i\n range_est_msg.range = np.sqrt(x_diff**2 + y_diff**2 + z_diff**2)\n\n range_est_array_msg.measurements.append(range_est_msg)\n\n # Output the true range measurements. When no new measurement is received, the last value is held.\n range_meas_array_msg = RangeMeasurementArray()\n for i in range(len(p)-1):\n range_meas_msg = RangeMeasurement()\n range_meas_msg.id = i\n if(dists[i]):\n range_meas_msg.range = dists[i]\n range_buf[i] = dists[i]\n else:\n range_meas_msg.range = range_buf[i]\n\n range_meas_array_msg.measurements.append(range_meas_msg)\n\n self.range_est_pub.publish(range_est_array_msg)\n self.range_meas_pub.publish(range_meas_array_msg)\n self.pos_pub.publish(poseMsg)\n\n def depth_callback(self, msg):\n with self.data_lock:\n self.depth = msg.data\n # self.sensor_time = rospy.get_time()\n\n def gt_callback(self, msg):\n with self.data_lock:\n self.z_gt = msg.pose.pose.position.z+0.08\n\n\ndef kalmanP(dists, pressure, x0, Sigma0):\n # Parameters\n\n Q = np.diag([0.01, 0.01, 0.01]) # system noise covariance\n\n # Output and measurement noise covariance matrix calculation for up to 4 AprilTag distances and the pressure sensor reading\n iter = np.array(range(dists.shape[0]))[dists != 0]\n num_tags = iter.shape[0]\n C = np.zeros((num_tags + 1, 3))\n measurement_covs = np.zeros(num_tags + 1)\n\n for i in range(num_tags):\n C[i,0] = (x0[0] - p[iter[i]][0]) / dists[iter[i]]\n C[i,1] = (x0[1] - p[iter[i]][1]) / dists[iter[i]]\n C[i,2] = (x0[2] - p[iter[i]][2]) / dists[iter[i]]\n\n measurement_covs[i] = 0.1 # covariance of a distance measurement\n C[num_tags, 0] = 0\n C[num_tags, 1] = 0\n C[num_tags, 2] = 1.0e-4 # pressure divided by pascals per meter \n\n measurement_covs[num_tags] = 0.2 # covariance of a depth measurement. Should account for the offset between camera and pressure sensor\n\n R = np.diag(measurement_covs)\n\n # Predicted state. For the P Kalman filter, the predicted state (position) is the same as the last position.\n x_pred = x0\n\n # Predicted covariance Sigma. For the P Kalman filter, the system noise covariance is simply added.\n Sigma_pred = Sigma0 + Q\n\n # Calculation of predicted measurements\n\n h = np.zeros(num_tags + 1)\n for i in range(num_tags):\n h[i] = np.sqrt(np.float_power((x_pred[0] - p[iter[i]][0]),2) + np.float_power((x_pred[1] - p[iter[i]][1]),2) + np.float_power((x_pred[2] - p[iter[i]][2]),2))\n h[num_tags] = pressure / 1.0e4\n\n # Correction\n\n K = Sigma_pred.dot(np.transpose(C)).dot(inv(C.dot(Sigma_pred).dot(np.transpose(C)) + R))\n z = np.append(dists[dists!=0], [pressure])\n\n x1 = x_pred + np.matmul(K,(z - h))\n Sigma1 = (np.eye(3) - K.dot(C)).dot(Sigma_pred)\n\n return x1, Sigma1\n\n\ndef main():\n node = localizationNode()\n rospy.spin()\n\n\nif __name__ == \"__main__\":\n main()\n#!/usr/bin/env python\nimport rospy\nfrom geometry_msgs.msg import Pose\nfrom std_msgs.msg import Float64\nimport numpy as np\n\n\nclass PosSetpointNode():\n def __init__(self):\n rospy.init_node(\"pos_setpoint\")\n\n self.setpoint_pub = rospy.Publisher(\"pos_setpoint\",\n Pose,\n queue_size=1)\n\n def run(self):\n mode = 'const'\n\n if mode == 'const':\n rate = rospy.Rate(50.0)\n while not rospy.is_shutdown():\n msg1 = Pose()\n # fill msg with example setpoint\n msg1.position.x = 1.0\n msg1.position.y = 3.0\n msg1.position.z = -0.5\n self.setpoint_pub.publish(msg1)\n\n rate.sleep()\n elif mode == 'sin':\n rate = rospy.Rate(10.0)\n while not rospy.is_shutdown():\n xs = np.linspace(0, 2*np.pi, num=200)\n for x in xs:\n msg = Pose()\n # fill msg with example setpoint\n msg.data = 0.2*np.sin(x) - 0.4\n self.setpoint_pub.publish(msg)\n rate.sleep()\n elif mode == 'step':\n rate = rospy.Rate(10.0)\n while not rospy.is_shutdown():\n xs = np.linspace(0, 2*np.pi, num=400)\n for x in xs:\n msg1 = Pose()\n msg1.position.x = 1.0 + 0.5*float(x < np.pi)\n msg1.position.y = 1.0 + 1.0*float(x < np.pi)\n msg1.position.z = -0.5 - 0.5*float(x < np.pi)\n self.setpoint_pub.publish(msg1)\n rate.sleep()\n else:\n pass\n # TODO: add ros logger error\n\n\ndef main():\n node = PosSetpointNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()\n#include \n#include \n\nnamespace gazebo {\nGZ_REGISTER_MODEL_PLUGIN(RangesPlugin)\n\nRangesPlugin::RangesPlugin() : ModelPlugin() {}\n\nRangesPlugin::~RangesPlugin() { update_connection_->~Connection(); }\n\nvoid RangesPlugin::getSdfParams(sdf::ElementPtr sdf) {\n namespace_.clear();\n if (sdf->HasElement(\"robotNamespace\")) {\n namespace_ = sdf->GetElement(\"robotNamespace\")->Get();\n }\n if (sdf->HasElement(\"pubRate\")) {\n pub_rate_ = sdf->GetElement(\"pubRate\")->Get();\n } else {\n pub_rate_ = kDefaultPubRate;\n gzwarn << \"[ranges_plugin] Using default publication rate of \" << pub_rate_\n << \"Hz\\n\";\n }\n if (sdf->HasElement(\"rangesTopic\")) {\n ranges_topic_ = sdf->GetElement(\"rangesTopic\")->Get();\n } else {\n ranges_topic_ = kDefaultRangesTopic;\n }\n if (sdf->HasElement(\"rangeNoiseStd\")) {\n range_noise_std_ = sdf->GetElement(\"rangeNoiseStd\")->Get();\n } else {\n range_noise_std_ = kDefaultRangesNoise;\n gzwarn << \"[ranges_plugin] Using default noise \" << kDefaultRangesNoise\n << \"\\n\";\n }\n if (sdf->HasElement(\"fovCamera\")) {\n // we'll check visibility using half the fov angle\n max_fov_angle_ =\n sdf->GetElement(\"fovCamera\")->Get() / 2.0 * (M_PI / 180.0);\n } else {\n max_fov_angle_ = (kDefaultFov / 2.0) * (M_PI / 180.0);\n gzwarn << \"[ranges_plugin] Using default field of view angle \"\n << kDefaultFov << \"\\n\";\n }\n if (sdf->HasElement(\"viewingAngle\")) {\n // we'll check visibility using half the viewing angle\n max_viewing_angle_ =\n sdf->GetElement(\"viewingAngle\")->Get() / 2.0 * (M_PI / 180.0);\n } else {\n max_viewing_angle_ = (kDefaultViewingAngle / 2.0) * (M_PI / 180.0);\n gzwarn << \"[ranges_plugin] Using default viewing angle \"\n << kDefaultViewingAngle << \"\\n\";\n }\n if (sdf->HasElement(\"dropProb\")) {\n drop_prob_ = sdf->GetElement(\"dropProb\")->Get();\n } else {\n drop_prob_ = kDefaultDropProb;\n gzwarn << \"[ranges_plugin] Using default probability \" << kDefaultDropProb\n << \" for dropping measurements\\n\";\n }\n if (sdf->HasElement(\"maxDetectionDist\")) {\n max_detection_dist_ = sdf->GetElement(\"maxDetectionDist\")->Get();\n } else {\n max_detection_dist_ = kDefaultMaxDetectionDist;\n gzwarn << \"[ranges_plugin] Using default max detection distance \"\n << kDefaultMaxDetectionDist << \"\\n\";\n }\n if (sdf->HasElement(\"maxDetectionDist\")) {\n dist_drop_prob_exponent_ =\n sdf->GetElement(\"maxDetectionDist\")->Get();\n } else {\n dist_drop_prob_exponent_ = kDefaultDistDropProbExponent;\n gzwarn << \"[ranges_plugin] Using default Exponent \"\n << kDefaultDistDropProbExponent\n << \" for probability that too far away measurements are dropped \\n\";\n }\n}\n\nvoid RangesPlugin::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {\n getSdfParams(sdf);\n model_ = model;\n world_ = model_->GetWorld();\n last_time_ = world_->SimTime();\n last_pub_time_ = world_->SimTime();\n\n if (!ros::isInitialized()) {\n ROS_FATAL_STREAM(\"ROS node for gazebo not initialized\");\n return;\n }\n node_handle_ = new ros::NodeHandle(namespace_);\n\n update_connection_ = event::Events::ConnectWorldUpdateBegin(\n boost::bind(&RangesPlugin::OnUpdate, this, _1));\n\n ranges_pub_ = node_handle_->advertise(\n ranges_topic_, 1);\n\n initialized_ = false;\n tag_axis_ = ignition::math::Vector3d(0.0, 1.0, 0.0);\n tag_axis_bottom_ = ignition::math::Vector3d(0.0, 0.0, -1.0);\n}\n\nvoid RangesPlugin::OnUpdate(const common::UpdateInfo &) {\n common::Time current_time = world_->SimTime();\n double dt = (current_time - last_pub_time_).Double();\n\n if (true || !initialized_) {\n auto model = world_->ModelByName(\"ring\");\n if (model && model->GetChildLink(\"tag_1_link\")) {\n pos_tag_1_ = world_->ModelByName(\"ring\")\n ->GetChildLink(\"tag_1_link\")\n ->WorldPose()\n .Pos();\n // gzmsg << \"[ranges plugin] Tag 1 Position at \"<< pos_tag_1_ << \" \\n\";\n }\n if (model && model->GetChildLink(\"tag_2_link\")) {\n pos_tag_2_ = world_->ModelByName(\"ring\")\n ->GetChildLink(\"tag_2_link\")\n ->WorldPose()\n .Pos();\n // gzmsg << \"[ranges plugin] Tag 2 Position at \"<< pos_tag_2_ << \" \\n\";\n }\n if (model && model->GetChildLink(\"tag_3_link\")) {\n pos_tag_3_ = world_->ModelByName(\"ring\")\n ->GetChildLink(\"tag_3_link\")\n ->WorldPose()\n .Pos();\n // gzmsg << \"[ranges plugin] Tag 3 Position at \"<< pos_tag_3_ << \" \\n\";\n }\n if (model && model->GetChildLink(\"tag_4_link\")) {\n pos_tag_4_ = world_->ModelByName(\"ring\")\n ->GetChildLink(\"tag_4_link\")\n ->WorldPose()\n .Pos();\n // gzmsg << \"[ranges plugin] Tag 4 Position at \"<< pos_tag_4_ << \" \\n\";\n initialized_ = true;\n }\n // Generate Grid for floor AprilTags\n for(double j=0.0; j<9.0 ; ++j){\n for(double i=0.0; i<7.0; ++i){\n auto tmp_tag = ignition::math::Vector3d(1.56-i*0.25, 0.06+j*0.39375, -1.3);\n floor_tags_.push_back(tmp_tag);\n //gzmsg << \"[ranges plugin] Tag \" << i+j*7.0 << \" pos at \" << tmp_tag << \"\\n\";\n }\n }\n }\n\n if ((dt > 1.0 / pub_rate_) && (initialized_)) {\n range_sensor::RangeMeasurementArray msg_array;\n msg_array.measurements.clear();\n msg_array.header.stamp = ros::Time::now();\n msg_array.header.frame_id = \"map\";\n\n // get world pose\n ignition::math::Vector3d pos_sensor =\n model_->GetLink(\"range_sensor_link\")->WorldPose().Pos();\n // gzmsg << \"[ranges_plugin] Pos Tag 1 \" << pos_sensor << \" \\n\";\n // get orientation of body x-axis\n ignition::math::Vector3d x_unit_vector(1.0, 0.0, 0.0);\n ignition::math::Vector3d body_x_axis = model_->GetLink(\"range_sensor_link\")\n ->WorldPose()\n .Rot()\n .RotateVector(x_unit_vector);\n ignition::math::Vector3d z_unit_vector(0.0, 0.0, -1.0);\n ignition::math::Vector3d body_z_axis = model_->GetLink(\"range_sensor_link\")\n ->WorldPose()\n .Rot()\n .RotateVector(z_unit_vector);\n ignition::math::Vector3d tag_axis_ = world_->ModelByName(\"ring\")\n ->GetChildLink(\"base_link\")\n ->WorldPose() \n .Rot()\n .RotateVector(z_unit_vector); \n // gzmsg << \"Tag axis: \" << tag_axis_ << \"\\n\"; \n // ignition::math::Vector3d pos_ring =\n // model_->GetLink(\"ring::base_link\")->WorldPose().Pos();\n auto model_ring = world_->ModelByName(\"ring\");\n ignition::math::Vector3d pos_ring;\n if(model_ring && model_ring->GetChildLink(\"base_link\")){\n pos_ring = world_->ModelByName(\"ring\")\n ->GetChildLink(\"base_link\")\n ->WorldPose()\n .Pos();\n //gzmsg << \"[ranges_plugin] Ring\" << pos_ring << \"\\n\";\n }\n // auto pos_tag_1_abs = pos_ring + pos_tag_1_;\n // auto pos_tag_2_abs = pos_ring + pos_tag_2_;\n // auto pos_tag_3_abs = pos_ring + pos_tag_3_;\n // auto pos_tag_4_abs = pos_ring + pos_tag_4_;\n // tag 1\n ignition::math::Vector3d sensor_to_tag_1 = pos_tag_1_ - pos_sensor;\n if (IsDetected(sensor_to_tag_1, body_x_axis)) {\n range_sensor::RangeMeasurement msg = GetRangeMsg(1, sensor_to_tag_1);\n msg_array.measurements.push_back(msg);\n }\n\n // tag 2\n ignition::math::Vector3d sensor_to_tag_2 = pos_tag_2_ - pos_sensor;\n if (IsDetected(sensor_to_tag_2, body_x_axis)) {\n range_sensor::RangeMeasurement msg = GetRangeMsg(2, sensor_to_tag_2);\n msg_array.measurements.push_back(msg);\n }\n\n // tag 3\n ignition::math::Vector3d sensor_to_tag_3 = pos_tag_3_ - pos_sensor;\n if (IsDetected(sensor_to_tag_3, body_x_axis)) {\n range_sensor::RangeMeasurement msg = GetRangeMsg(3, sensor_to_tag_3);\n msg_array.measurements.push_back(msg);\n }\n\n // tag 4\n ignition::math::Vector3d sensor_to_tag_4 = pos_tag_4_ - pos_sensor;\n if (IsDetected(sensor_to_tag_4, body_x_axis)) {\n range_sensor::RangeMeasurement msg = GetRangeMsg(4, sensor_to_tag_4);\n msg_array.measurements.push_back(msg);\n }\n for(int i=0; i<63; ++i){\n ignition::math::Vector3d tmp_to_tag = floor_tags_.at(i) - pos_sensor;\n if (IsDetected_bottom(tmp_to_tag, body_z_axis)) {\n range_sensor::RangeMeasurement msg = GetRangeMsg(i+5, tmp_to_tag);\n msg_array.measurements.push_back(msg);\n }\n }\n\n ranges_pub_.publish(msg_array);\n last_pub_time_ = current_time;\n }\n}\n\nbool RangesPlugin::IsDetected(ignition::math::Vector3d sensor_to_tag,\n ignition::math::Vector3d body_x_axis) {\n // tag might not be visible, determine whether tag is in fov of camera\n double fov_angle = acos(sensor_to_tag.Dot(body_x_axis) /\n (sensor_to_tag.Length() * body_x_axis.Length()));\n\n // camera might not be facing tag from front\n double viewing_angle = acos(tag_axis_.Dot(body_x_axis) /\n (tag_axis_.Length() * body_x_axis.Length()));\n\n bool is_visible =\n (fov_angle < max_fov_angle_) && (viewing_angle < max_viewing_angle_);\n // measurement might be dropped for whatever reason\n double p = uniform_real_distribution_(random_generator_);\n // additional drop probability that increases with distance to tag\n double p_dist = uniform_real_distribution_(random_generator_);\n double drop_prob_dist = GetDistanceDropProp(sensor_to_tag.Length());\n\n bool is_not_dropped = (p > drop_prob_) && (p_dist > drop_prob_dist);\n \n return is_visible && is_not_dropped;\n //return true;\n}\n\nbool RangesPlugin::IsDetected_bottom(ignition::math::Vector3d sensor_to_tag,\n ignition::math::Vector3d body_z_axis ) {\n // determine fov angle for both x and y\n double fov_angle = acos(sensor_to_tag.Dot(body_z_axis) /\n (sensor_to_tag.Length() * body_z_axis.Length())); \n double viewing_angle = acos(tag_axis_bottom_.Dot(body_z_axis) /\n (tag_axis_bottom_.Length() * body_z_axis.Length()));\n bool is_visible =\n (fov_angle < max_fov_angle_) && (viewing_angle < max_viewing_angle_);\n //gzmsg << \"[ranges_plugin] (fov, view) \" << fov_angle << \", \" << viewing_angle << \"\\n\";\n // measurement might be dropped for whatever reason\n double p = uniform_real_distribution_(random_generator_);\n // additional drop probability that increases with distance to tag\n double p_dist = uniform_real_distribution_(random_generator_);\n double drop_prob_dist = GetDistanceDropProp(sensor_to_tag.Length());\n\n bool is_not_dropped = (p > drop_prob_) && (p_dist > drop_prob_dist);\n\n return is_visible && is_not_dropped;\n // return true;\n}\n\nrange_sensor::RangeMeasurement RangesPlugin::GetRangeMsg(\n int id, ignition::math::Vector3d sensor_to_tag) {\n range_sensor::RangeMeasurement msg;\n msg.header.stamp = ros::Time::now();\n msg.header.frame_id = \"map\";\n msg.id = id;\n\n double distance = sensor_to_tag.Length();\n // add noise\n double noise =\n standard_normal_distribution_(random_generator_) * range_noise_std_;\n msg.range = distance + noise;\n return msg;\n}\n\ndouble RangesPlugin::GetDistanceDropProp(double dist) {\n double p = (1.0 / pow(max_detection_dist_, dist_drop_prob_exponent_)) *\n pow(dist, dist_drop_prob_exponent_);\n if (p > 1.0) {\n p = 1.0;\n }\n return p;\n}\n\n} // namespace gazebo\n#pragma once\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nnamespace gazebo {\nstatic constexpr auto kDefaultPubRate = 50.0;\nstatic constexpr auto kDefaultPressureTopic = \"pressure\";\nstatic constexpr auto kDefaultPressureNoise = 100.0;\n\nclass PressurePlugin : public ModelPlugin {\n public:\n PressurePlugin();\n virtual ~PressurePlugin();\n\n protected:\n virtual void Load(physics::ModelPtr model, sdf::ElementPtr sdf);\n virtual void OnUpdate(const common::UpdateInfo &);\n void getSdfParams(sdf::ElementPtr sdf);\n\n private:\n std::string namespace_;\n physics::ModelPtr model_;\n physics::WorldPtr world_;\n event::ConnectionPtr update_connection_;\n std::string pressure_topic_;\n double pressure_noise_;\n\n ros::NodeHandle *node_handle_;\n ros::Publisher pressure_pub_;\n\n double pub_rate_;\n\n std::default_random_engine random_generator_;\n std::normal_distribution standard_normal_distribution_;\n\n common::Time last_pub_time_;\n common::Time last_time_;\n\n double baro_rnd_y2_;\n bool baro_rnd_use_last_;\n};\n} // namespace gazebo\n#!/usr/bin/env python\nimport numpy as np\nimport rospy\nfrom std_msgs.msg import Int16\nfrom geometry_msgs.msg import Pose\n\n\nclass alarmNode():\n def __init__(self):\n rospy.init_node(\"alarmNode\")\n self.tagNumber = 0\n self.tag_threshold = 3\n\n self.ring_sub = rospy.Subscriber(\"ringWorld\",\n Pose,\n self.alarm_callback,\n queue_size=1)\n self.setpoint_sub = rospy.Subscriber(\"number_tags\",\n Int16,\n self.tag_callback,\n queue_size=1)\n\n def tag_callback(self, msg):\n self.tagNumber = msg.data\n if self.tagNumber > 0 and self.tagNumber <= self.tag_threshold:\n rospy.loginfo(\"Maybe I found something\")\n\n\n def alarm_callback(self, msg):\n self.actual_pos = np.array([msg.position.x, msg.position.y, msg.position.z])\n if self.tagNumber > self.tag_threshold:\n rospy.logwarn(\"Alarm!!!!!!!!! Object found at:\")\n rospy.logwarn(self.actual_pos)\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = alarmNode()\n node.run()\n\n\nif __name__ == '__main__':\n main()#!/usr/bin/env python\nimport rospy\nimport threading\nfrom std_msgs.msg import Float64, String\nfrom geometry_msgs.msg import Pose, Vector3\nimport numpy as np\n\n\nclass rotControlNode():\n def __init__(self):\n rospy.init_node(\"rot_control\")\n\n self.data_lock = threading.RLock()\n self.strategy = \"search\"\n self.search_thrust = 0.09\n self.dirLock = False\n\n self.yaw_thrust = 0.0\n self.yaw = 0.0\n self.yaw_setpoint = 0.0\n\n self.rot_p_gain = 0.08\n self.rot_i_gain = 0.0\n self.rot_d_gain = 0.0\n\n self.yaw_pub = rospy.Publisher(\"yaw\",\n Float64,\n queue_size=1)\n\n self.depth_sub = rospy.Subscriber(\"/nav_controller/angle\",\n Vector3,\n self.rot_callback,\n queue_size=1)\n\n self.strategy_sub = rospy.Subscriber(\"strategy\",\n String,\n self.strategy_callback,\n queue_size=1)\n\n # Reconfigure Options via subscriber\n self.search_thrust_sub = rospy.Subscriber(\"search_thrust\",\n Float64,\n self.search_thrust_callback,\n queue_size=1)\n\n self.rot_control_frequency = 20.0\n rospy.Timer(rospy.Duration(1.0/self.rot_control_frequency), self.rot_control)\n\n def strategy_callback(self, msg):\n self.strategy = msg.data\n if self.strategy != \"search\" and not self.dirLock:\n if self.yaw <= 0.1:\n self.yaw_setpoint = 0.0\n elif 0.1 < self.yaw <= np.pi/2:\n self.yaw_setpoint = 1.5707\n elif np.pi/2 < self.yaw <= np.pi:\n self.yaw_setpoint = np.pi\n elif np.pi < self.yaw <= 3*np.pi/2:\n self.yaw_setpoint = 3*np.pi/2\n else:\n self.yaw_setpoint = 0.0\n self.dirLock = True\n\n def rot_callback(self, msg):\n self.roll = msg.x\n self.pitch = msg.y\n self.yaw = msg.z\n\n def search_thrust_callback(self, msg):\n with self.data_lock:\n self.search_thrust = msg.data\n\n # might be redundant if only self.run is used\n def rot_control(self, *args):\n rospy.loginfo(self.yaw_setpoint)\n if not self.dirLock:\n self.roll_thrust = 0.0\n self.pitch_thrust = 0.0\n self.yaw_thrust = self.search_thrust\n else:\n self.yaw_thrust = (self.rot_p_gain * (self.yaw_setpoint - self.yaw))\n self.publish()\n\n def publish(self):\n msg_yaw = Float64()\n msg_yaw.data = self.yaw_thrust\n self.yaw_pub.publish(msg_yaw)\n\n def run(self):\n rospy.spin()\n\n\ndef main():\n node = rotControlNode()\n node.run()\n\n\nif __name__ == \"__main__\":\n main()"},"directory_id":{"kind":"string","value":"485ebc2821699db03fcdbf4e323c3f8a213427c0"},"languages":{"kind":"list like","value":["XML","CMake","C++","Python"],"string":"[\n \"XML\",\n \"CMake\",\n \"C++\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":27,"string":"27"},"repo_language":{"kind":"string","value":"XML"},"repo_name":{"kind":"string","value":"CarlGiest/FormulasAndVehicles"},"revision_id":{"kind":"string","value":"f14daa2d07fa7abbf360ec7a045b2539c6d4ccf0"},"snapshot_id":{"kind":"string","value":"5cf9039f72a8205142139bd3ddcc3c55270a8760"}}},{"rowIdx":9944,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"# sms_spam_collection\n\nlibraries:\n\n* numpy\n* sklearn\n* pandas\n* seaborn\n* pipeline\n* stopwords\n\nusage:\n\n* sms_spam.py\n* spam.csv\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport scipy as sp\nget_ipython().run_line_magic('matplotlib', 'inline')\nsms = pd.read_csv(\"...../Downloads/project/spam.csv\")\nsms.head()\n\nsms = sms.drop('2', 1)\nsms = sms.drop('3', 1)\nsms = sms.drop('4', 1)\nsms.head()\n\nsms = sms.rename(columns = {'v1':'label','v2':'message'})\nsms.groupby('label').describe()\nsms['length'] = sms['message'].apply(len)\n\nsms.head()\nsms['length'].plot(bins=100, kind='hist') \ncount_Class=pd.value_counts(sms[\"label\"], sort= True)\ncount_Class.plot(kind = 'bar',color = [\"green\",\"red\"])\nplt.title('Bar Plot')\nplt.show();\nsms.length.describe()\n\nsms[sms['length'] == 910]['message'].iloc[0]\n\nsms.hist(column='length', by='label', bins=50,figsize=(12,4))\n\n#nlp\nimport string\nfrom nltk.corpus import stopwords\ndef text_process(mess):\n nopunc = [char for char in mess if char not in string.punctuation]\n nopunc = ''.join(nopunc)\n return [word for word in nopunc.split() if word.lower() not in stopwords.words('english')]\nsms['message'].head(5).apply(text_process)\n\nfrom sklearn.feature_extraction.text import CountVectorizer\nbow_transformer = CountVectorizer(analyzer=text_process).fit(sms['message'])\nprint(len(bow_transformer.vocabulary_))\n\nsms_bow = bow_transformer.transform(sms['message'])\n\nprint('Shape of Sparse Matrix: ', sms_bow.shape)\nprint('Amount of Non-Zero occurences: ', sms_bow.nnz)\nsparsity = (100.0 * sms_bow.nnz / (sms_bow.shape[0] * sms_bow.shape[1]))\nprint('sparsity: {}'.format(round(sparsity)))\n\nfrom sklearn.feature_extraction.text import TfidfTransformer\ntfidf_transformer = TfidfTransformer().fit(sms_bow)\nsms_tfidf = tfidf_transformer.transform(sms_bow)\nprint(sms_tfidf.shape)\n\n#naive bayes\nfrom sklearn.naive_bayes import MultinomialNB\nspam_detect_model = MultinomialNB().fit(sms_tfidf, sms['label'])\n\nall_predictions = spam_detect_model.predict(sms_tfidf)\nprint(all_predictions)\n\nfrom sklearn.metrics import classification_report\nprint (classification_report(sms['label'], all_predictions))\n\nfrom sklearn.model_selection import train_test_split\nmsg_train, msg_test, label_train, label_test = train_test_split(sms['message'], sms['label'], test_size=0.2)\n\nprint(len(msg_train), len(msg_test), len(msg_train) + len(msg_test))\n\n# DATA PIPELINE\n\nfrom sklearn.pipeline import Pipeline\n\npipeline = Pipeline([\n ('bow', CountVectorizer(analyzer=text_process)), # strings to token integer counts\n ('tfidf', TfidfTransformer()), # integer counts to weighted TF-IDF scores\n ('classifier', MultinomialNB()), # train on TF-IDF vectors w/ Naive Bayes classifier\n])\n\npipeline.fit(msg_train,label_train)\npredictions = pipeline.predict(msg_test)\nprint(classification_report(predictions,label_test))\n\n\n\n\n"},"directory_id":{"kind":"string","value":"123dadc08c965e59812cc1e8db4f01f6a37f3a62"},"languages":{"kind":"list like","value":["Markdown","Python"],"string":"[\n \"Markdown\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Abarnakumar28/sms_spam_collection"},"revision_id":{"kind":"string","value":"e865391bd34c02c00928c775d782e90126b28950"},"snapshot_id":{"kind":"string","value":"87ba2243f674cc0c693982a064ed449971865970"}}},{"rowIdx":9945,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"blueeyes007/workshops/DataScienceTools/demos/reports/1980_census2.tex\n\\documentclass{article}\n\n\\title{My Report}\n\n\\begin{document}\n\n\\maketitle\n\n\\section{Population of the United States in 1980}\nThe 1980 Census reported $\\input{output/1980_census_sum2.tex}$ people living in the United States.\n\n\\end{document}\n\n"},"directory_id":{"kind":"string","value":"2cc26b13bef263563e90d4236ea9d4745799763a"},"languages":{"kind":"list like","value":["TeX"],"string":"[\n \"TeX\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"TeX"},"repo_name":{"kind":"string","value":"blueeyes007/workshops"},"revision_id":{"kind":"string","value":"e6b6f9e65aff024b7ccb2b5e7bd8745f446fcd88"},"snapshot_id":{"kind":"string","value":"0b90356993986e18701fdf972fdab97510698aab"}}},{"rowIdx":9946,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"miadea/portfolio-website-builder/app/components/css/page-design.less\n#websiteDesign {\n}\n/app/components/html/Art.jsx\nimport React from 'react';\n\nclass Body extends React.Component {\n\n\trender() {\n\t\treturn(\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t \t\t

    Art

    \n\t\t\t\t\t\t

    I create digital art that mainly foccuses on character design and personal projects.

    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t
    \n\n\n\n\n )\n }}\n\nmodule.exports = Body\n/app/components/css/page-footer.less\n.page-footer {\n background-color: black;\n .footer-wrapper{\n display: flex;\n }\n .footer-style{\n font-family: 'Josefin Sans', sans-serif;\n font-size: 1.5rem;\n color: white;\n padding: 0 20px;\n margin-left: auto;\n margin-right: auto;\n letter-spacing: 3px;\n }\n .made-by{\n background-color: #333333;\n color: gray;\n display: flex;\n padding: 10px;\n font-size: 0.8rem;\n }\n}\n/app/index.jsx\nimport React from 'react';\nimport {render} from 'react-dom';\n\nimport Header from './components/html/Header.jsx';\nimport Footer from './components/html/Footer.jsx';\nimport Design from './components/html/Design.jsx';\nimport Photos from './components/html/Photos.jsx';\nimport Art from './components/html/Art.jsx';\n\nimport BackToTop from './components/html/BackToTop.jsx';\nimport './components/css/main.less';\nimport \"normalize-css\";\n\nclass App extends React.Component {\n constructor() {\n super()\n this.state = {\n lang: 'es'\n }\n }\n render () {\n let lang = this.state.lang\n return (
    \n \t
    \n \n \n \n\t\t\t
    \n\t\t\t{/* */}\n\t\t
    );\n }\n onChange(lang) {\n this.setState({lang})\n }\n}\n\nrender(, document.getElementById('app'));\n/app/components/css/page-header.less\n.page-header {\n background-image: url(\"https://photos.smugmug.com/WF/Emma-Stoumen-Portfolio/Details/n-F9VBR9/i-H8M6qPn/0/X3/i-H8M6qPn-X3.jpg\");\n background-position: center;\n background-size: cover;\n background-repeat: no-repeat;\n height: 100vh;\n display: flex;\n flex-direction: column;\n}\n\n.page-header .title-wrapper {\n flex-grow: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.page-header .title {\n font-size: 6rem;\n font-family: 'Josefin Sans', sans-serif;\n animation: fadein 4s;\n}\n\n\n@keyframes fadein {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n/app/components/css/page-art.less\n#Art {\n}\n/app/components/css/navbar.less\n\n .navStyle {\n padding: 20px 0;\n font-family: 'Josefin Sans', sans-serif;\n font-size: 2rem;\n }\n\n .navStyle ul {\n list-style-type: none;\n margin: 0;\n padding: 0;\n }\n\n .navStyle li {\n display: inline;\n }\n\n .navStyle a {\n color: black;\n text-align: center;\n text-decoration: none;\n padding: 20px;\n }\n\n .navStyle a:hover{\n background-color: rgba(0,0,0,0.1);\n }\n\n // #segment-header a{\n // display: block;\n // color: white;\n // text-align: center;\n // padding: 14px 16px;\n // }\n/app/components/html/Header.jsx\nimport React from 'react';\n\nclass Header extends React.Component {\n\trender () {\n\t\treturn(\n\t\t\t
    \n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\t

    \n\t\t\t\t
    \n
    \n\t\t)\n\t}\n}\n\nmodule.exports = Header\n/app/components/html/Design.jsx\nimport React from 'react';\n\nclass Body extends React.Component {\n\n\trender() {\n\t\treturn(\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t \t\t

    Website Design

    \n\t\t\t\t\t\t

    I create and design modern websites. I focus on marketing websites for companies.

    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t
    \n\n\n\n\n )\n }}\n\nmodule.exports = Body\n/app/components/css/main.less\n@import url('https://fonts.googleapis.com/css?family=Josefin+Sans:300|Raleway:200|Work+Sans:200');\n@import \"./page-header.less\";\n@import \"./navbar.less\";\n@import \"./page-footer.less\";\n@import \"./page-design.less\";\n@import \"./page-photos.less\";\n@import \"./page-art.less\";\n\nhtml, body, #app {\n margin: 0;\n padding: 0;\n font-size: 16px;\n transition: font-size 0.5s;\n}\n\n@media screen and (max-width: 1024px) {\n html, body {\n font-size: 70%;\n }\n}\n\n@media screen and (max-width: 667px) {\n html, body {\n font-size: 60%;\n }\n}\n\n.page-content{\n height: 50vh;\n background-color: #ccc;\n display: flex;\n .image-wrapper{\n width: 50vw;\n }\n .content-wrapper{\n width: 50vw;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n border-style: solid;\n border-width: 5px 0px 10px 0px;\n border-color: gray;\n border-radius: 2px;\n }\n .position{\n max-width: 70%;\n }\n .content-title{\n background-color: #333;\n color: white;\n font-family: 'Josefin Sans', sans-serif;\n font-size: 2rem;\n }\n .content-subtitle{\n font-size: 1.5rem;\n font-family: 'Work Sans', sans-serif;\n }\n .block{\n border-style: solid;\n border-color: black;\n border-width: 20px;\n border-radius: 20px;\n background-color: black;\n }\n\n}\n"},"directory_id":{"kind":"string","value":"87c4ce56de779f61db5c6c0b3cc8939b5fa5ba3b"},"languages":{"kind":"list like","value":["JavaScript","Less"],"string":"[\n \"JavaScript\",\n \"Less\"\n]"},"num_files":{"kind":"number","value":10,"string":"10"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"miadea/portfolio-website-builder"},"revision_id":{"kind":"string","value":"8b6ec66a7a8f0f9bda845764b1a7ed36239cdcfc"},"snapshot_id":{"kind":"string","value":"2c46281d35c2dbff79257d43c3a5ca5af3ea28aa"}}},{"rowIdx":9947,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"therealjedeye98/Crime-Data-Assignment/mainfile.py\n########\r\n#modules\r\n########\r\nimport csv\r\nimport sys\r\nimport collections\r\nimport datetime\r\n\r\n########\r\n#enter csv\r\n########\r\npath = \"crime.csv\"\r\ndatafile = open(path) #, newline=''\r\n# reader function to parse csv data from file\r\nreader = csv.reader(datafile)\r\n#first line is header\r\nheader = next(reader) #next function extracts first line\r\n#now we read data \r\ndata = [row for row in reader]\r\n\r\n########\r\n\r\n########\r\n#functions\r\n########\r\n \r\n\r\ndef date_to_day(date):\r\n\tdate_format = date.split(' ')[0].split('-')\r\n\tday = int(date_format[0])\r\n\tmonth = int(date_format[1])\r\n\tyear = int('20'+date_format[2])\r\n\tborn = datetime.date(year, month, day)\r\n\r\n\treturn born.strftime(\"%A\")\r\n\r\ndef num_2015():\r\n\tnum_crimes_2015 = 0\r\n\tfor i in range(len(data)):\r\n\t\r\n\t\t#python find() returns -1 if not found\r\n\t\tif data[i][7].find(\"-15\") != -1:\r\n\t\t\tnum_crimes_2015 = num_crimes_2015 + 1\r\n\r\n\tprint(num_crimes_2015)\r\n\t\r\n\r\ndef shootings_2018():\r\n\tnum_shootings_2018=0\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif (data[i][6] != '') and (data[i][7].find(\"-18\") != -1):\r\n\t\t\tnum_shootings_2018 = num_shootings_2018 + 1\r\n\r\n\tprint(num_shootings_2018)\r\n\t\r\ndef larceny_2017():\r\n\tnum_larceny = 0\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif (data[i][2].find(\"Larceny\") != -1) and (data[i][7].find(\"-17\") != -1):\r\n\t\t\tnum_larceny = num_larceny + 1\r\n\r\n\tprint(num_larceny)\r\n\r\ndef drugviolation_AB():\r\n\tnum_violations = 0\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif (data[i][4].find(\"A\") != -1) or (data[i][4].find(\"B\") != -1):\r\n\t\t\tif (data[i][2].find(\"Drug Violation\") != -1):\r\n\t\t\t\tnum_violations = num_violations + 1\r\n\t\r\n\tprint(num_violations)\r\n\r\ndef common_codes():\r\n\tdata.sort(reverse=True)\r\n\tnew_list = []\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][7].find(\"-16\") != -1:\r\n\t \t\tnew_list.append(data[i][1])\r\n\r\n\tnew_list.sort(reverse=True)\r\n\r\n\tc = collections.Counter(new_list)\r\n\r\n\tc = [key for key, _ in c.most_common(2)]\r\n\t\r\n\tprint(c[0])\r\n\treturn(c[1])\r\n\t\r\n\t\r\ndef most_robberies():\r\n\t#empty array to store collection of most\r\n\tarray = []\r\n\r\n\tfor b in [\"-18\", \"-17\", \"-16\", \"-15\", \"-14\"]:\r\n\t\tcounter = 0\r\n\t\tfor i in range(len(data)):\r\n\t\t \tif (data[i][2].find(\"Robbery\") != -1) and (data[i][7].find(b) != -1):\r\n\t\t \t\tcounter = counter + 1\r\n\t\tarray.append([counter, b])\r\n\r\n\tarray.sort(reverse=True)\r\n\tprint('20'+array[0][1][1:] + '\\n20'+ array[1][1][1:])\r\n\r\n\r\ndef crime_streets():\r\n\tdata.sort(reverse=True)\r\n\tnew_list = []\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][9].find(\" \") != -1:\r\n\t \t\tnew_list.append(data[i][9])\r\n\r\n\tnew_list.sort(reverse=True)\r\n\r\n\tc = collections.Counter(new_list)\r\n\r\n\tc = [key for key, _ in c.most_common(3)]\r\n\r\n\r\n\r\n\tprint(c[0])\r\n\tprint(c[1])\r\n\tprint(c[2])\r\n\r\n\r\ndef offense_codes():\r\n\r\n\tlist2 = []\r\n\r\n\tdistricts = [\"A\",\"E\",\"C\"]\r\n\r\n\t\t\t\r\n\t\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][4].find(districts[0]) != -1:\r\n\t\t\tif date_to_day(str(data[i][7][0:8])) == \"Friday\" or date_to_day(str(data[i][7][0:8])) == \"Saturday\" or date_to_day(str(data[i][7][0:8])) == \"Sunday\":\r\n\t\t\t\tlist2.append(data[i][1])\r\n\t\t\t\r\n\r\n\t\tif data[i][4].find(districts[1]) != -1:\r\n\t\t\tif date_to_day(str(data[i][7][0:8])) == \"Friday\" or date_to_day(str(data[i][7][0:8])) == \"Saturday\" or date_to_day(str(data[i][7][0:8])) == \"Sunday\":\r\n\t\t\t\tlist2.append(data[i][1])\r\n\r\n\t\tif data[i][4].find(districts[2]) != -1:\r\n\t\t\tif date_to_day(str(data[i][7][0:8])) == \"Friday\" or date_to_day(str(data[i][7][0:8])) == \"Saturday\" or date_to_day(str(data[i][7][0:8])) == \"Sunday\":\r\n\t\t\t\tlist2.append(data[i][1])\r\n\r\n\tlist2.sort(reverse=True)\r\n\r\n\t#powerful function\r\n\r\n\tc = collections.Counter(list2)\r\n\r\n\tc = [key for key, _ in c.most_common(3)]\r\n\r\n\r\n\tnum1code = str(c[0])\r\n\tnum2code = str(c[1])\r\n\tnum3code = str(c[2])\r\n\r\n\ttopcodes = [num1code,num2code,num3code]\r\n\r\n\r\n\r\n## convert offense codes to offense code groups\r\n\r\n\tprintarray1 = []\r\n\tprintarray2 = []\r\n\tprintarray3 = []\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][1] == topcodes[0]:\r\n\t\t\tprintarray1.append(data[i][2])\r\n\t\telse:\r\n\t\t\tcontinue\r\n\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][1] == topcodes[1]:\r\n\t\t\tprintarray2.append(data[i][2])\r\n\t\telse:\r\n\t\t\tcontinue\r\n\t\t\r\n\tfor i in range(len(data)):\r\n\t\tif data[i][1] == topcodes[2]:\r\n\t\t\tprintarray3.append(data[i][2])\r\n\t\t\t\r\n\t\telse:\t\r\n\t\t\tcontinue\r\n\r\n\r\n\tprint(printarray1[0])\r\n\tprint(printarray2[0])\r\n\tprint(printarray3[0])\r\n\r\n\r\n\r\n\r\n########\r\n#cases\r\n#######\r\n\r\n#condition 0 - student number\r\ninput = sys.argv[1]\r\nif input == 'studentnumber':\r\n\tstudent_no = 3726450 \r\n\tprint(student_no) \r\n\r\n#condition 1 - number of crimes in 2015\r\nif input == '1': \r\n\tnum_2015()\r\n\r\n#condition 2 - number of shootings in 2018\r\nif input == '2':\r\n\tshootings_2018()\r\n\r\n#condition 3 - number of larcony\r\n\r\nif input == '3':\r\n\tlarceny_2017()\r\n\r\n#condition 4 - number of drug violations in district A and B\r\nif input == '4':\r\n\tdrugviolation_AB()\r\n\t\r\n\r\n#condition 5 - most common codes in 2016\r\nif input == '5':\r\n\tprint(common_codes())\r\n\r\n\r\n#condition 6 - two years with most robberies\r\n\r\nif input == '6':\r\n\tmost_robberies()\r\n\r\n\r\n#condition 7 - top three non null streets in terms of incidents reported\r\n\r\nif input == \"7\":\r\n\tcrime_streets()\r\n\r\n#condition 8 - \r\n\r\nif input == \"8\":\r\n\toffense_codes()\r\n########\r\n"},"directory_id":{"kind":"string","value":"7d4fcbc28d08de7359c16358d1de15f23e2e05c6"},"languages":{"kind":"list like","value":["Python"],"string":"[\n \"Python\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Python"},"repo_name":{"kind":"string","value":"therealjedeye98/Crime-Data-Assignment"},"revision_id":{"kind":"string","value":"41e46d489624ecc4a041a9d966a0ecd2e25ed9d0"},"snapshot_id":{"kind":"string","value":"8f76e339dba23f8ccbf75aa905e43ab09fb81e6b"}}},{"rowIdx":9948,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"# Learn Rust by Building Real Applications\n\nCoded (& improved) on the [Learn Rust by Building Real Applications](https://www.udemy.com/course/rust-fundamentals) course.\n\nSee [Repository](https://github.com/gavadinov/Learn-Rust-by-Building-Real-Applications).\nuse std::io::{BufRead, Write};\nuse std::num::ParseFloatError;\n\npub fn prompt(mut reader: R, mut writer: W, question: &str) -> String\nwhere\n R: BufRead,\n W: Write,\n{\n write!(&mut writer, \"{}\", question).expect(\"Unable to write\");\n writer.flush().expect(\"Unable to flush\");\n let mut s = String::new();\n reader.read_line(&mut s).expect(\"Unable to read\");\n s\n}\n\npub fn get_value(s: &String) -> Result {\n s.trim().parse::()\n}\n\n#[cfg(test)]\nmod tests {\n use super::{get_value, prompt};\n\n #[test]\n fn it_should_get_input() {\n let input = b\"100.0\";\n let mut output = Vec::new();\n\n let answer = prompt(&input[..], &mut output, \"Enter your weight (kg): \");\n\n let output = String::from_utf8(output).expect(\"Not UTF-8\");\n\n assert_eq!(\"Enter your weight (kg): \", output);\n assert_eq!(\"100.0\", answer);\n }\n\n #[test]\n fn it_should_get_value() {\n let result = get_value(&String::from(\"100.0\"));\n let expected = Ok(100.0);\n assert_eq!(result, expected);\n }\n\n #[test]\n fn it_should_not_get_value() {\n let result = get_value(&String::from(\"test\"));\n assert!(result.is_err());\n }\n}\nuse std::io;\nmod input;\nmod weight;\n\nfn main() {\n let stdio = io::stdin();\n let input = stdio.lock();\n\n let output = io::stdout();\n\n let user_input = input::prompt(input, output, \"Enter your weight (kg): \");\n\n let f = input::get_value(&user_input).expect(\"Failed to parse\");\n let mars_weight = weight::get_on_mars(f);\n\n println!(\"Weight on Mars : {}kg\", mars_weight);\n}\npub fn get_on_mars(weight: f32) -> f32 {\n (weight / 9.81) * 3.711\n}\n\n#[cfg(test)]\nmod tests {\n use super::get_on_mars;\n\n #[test]\n fn it_should_get_on_mars() {\n let result = get_on_mars(100.0);\n assert_eq!(result, 37.828747);\n }\n}\n"},"directory_id":{"kind":"string","value":"532c2e8e2ba4a24ca4b6a619aa91c63ee823f003"},"languages":{"kind":"list like","value":["Markdown","Rust"],"string":"[\n \"Markdown\",\n \"Rust\"\n]"},"num_files":{"kind":"number","value":4,"string":"4"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"qdelettre/Learn-Rust-by-Building-Real-Applications-Mars-Calc"},"revision_id":{"kind":"string","value":"9cf47c36bd553ffbb94cc88b1096f39a0d6c9afb"},"snapshot_id":{"kind":"string","value":"0686420362e68846084e17cb9c2123e5a043b723"}}},{"rowIdx":9949,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"#!/bin/bash\n\nCLONE_URL=:freechipsproject/chisel-template.git\nTEMP_NAME=$(cat /dev/urandom | tr -cd 'a-zA-Z0-9' | head -c 32)\nPROGNAME=$(basename $0)\n\nusage() {\n echo \"Usage: $PROGNAME [OPTIONS] DIR_NAME\"\n echo \n echo \"Options:\"\n echo \"-h, --help: show this\"\n echo \" --ssh: use ssh to clone chisel-template repository\"\n echo \" --https: use https to clone chisel-template repository\"\n echo \n exit 1\n}\n\nwhile (( $# > 0 ))\ndo\n case \"$1\" in\n \"-h\" | \"--help\" )\n usage\n exit 1\n ;;\n \"--ssh\" )\n CLONE_URL=:freechipsproject/chisel-template.git\n shift 1\n ;;\n \"--https\" )\n CLONE_URL=https://github.com/freechipsproject/chisel-template.git\n shift 1\n ;;\n *)\n TEMPLATE_NAME=\"$TEMPLATE_NAME $1\"\n shift 1\n ;;\n esac\ndone\n\nif [ -z \"$TEMPLATE_NAME\" ]; then\n echo \"specify project name\"\n exit 1\nelse\n git clone \"$CLONE_URL\" $TEMP_NAME\n \n if [ $? -ne 0 ]; then\n exit 1\n fi \nfi\n\nEXECUTE_DIR=$PWD\nfor NAME in $TEMPLATE_NAME; do\n cd $EXECUTE_DIR\n\n if [ -e \"$NAME\" ]; then\n echo \"$NAME has already existed\" \n else\n cp -rf ./$TEMP_NAME ./$NAME\n rm -rf ./$NAME/.git \n rm -rf ./$NAME/src/{main,test}/scala/gcd\n cd ./$NAME \n git init \n fi\ndone\n\ncd $EXECUTE_DIR\nrm -rf ./$TEMP_NAME\n\n\n\n\n# chisel-init\n\nThis shell script using [chisel-template](https://github.com/freechipsproject/chisel-template) to initialize chisel3 project\n\n## how to use\n\nYou can create project with project name directory\n\n```\nchisel-init \"project-name\"\n```\n\nIf you typed like above, project-name directory is created in your current directory\n"},"directory_id":{"kind":"string","value":"fb7335e0878857ec420fe69699151ad7a70f44b9"},"languages":{"kind":"list like","value":["Markdown","Shell"],"string":"[\n \"Markdown\",\n \"Shell\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"yxnan/chisel-init"},"revision_id":{"kind":"string","value":"8ef572c7c93be81c7ac68dc8aa99e21cfeac19d1"},"snapshot_id":{"kind":"string","value":"af2982287528c579b252e924296caf25f85b14d3"}}},{"rowIdx":9950,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"create index gnafid_idx on location_table(gnafid);\ncreate index unitnumber_idx on location_table(unitnumber);\ncreate index levelnumber_idx on location_table(levelnumber);\ncreate index lotnumber_idx on location_table(lotnumber);\ncreate index roadnumber1_idx on location_table(roadnumber1);\ncreate index roadnumber2_idx on location_table(roadnumber2);\ncreate index roadname_idx on location_table(roadname varchar_pattern_ops);\ncreate index localityname_idx on location_table(localityname varchar_pattern_ops);\ncreate index postcode_idx on location_table(postcode);\ncreate index state_idx on location_table(statecode);\ncreate index lat_idx on location_table(latitude);\ncreate index long_idx on location_table(longitude);\ncreate index addresssitename_idx on location_table(addresssitename varchar_pattern_ops);\n\n\n\ncreate table LOCATION_TABLE as select * from LOCATION_VIEW;\n\ncreate index POSTCODE_IDX on LOCATION_TABLE(postcode);\ncreate index LOCALITY_IDX on LOCATION_TABLE(localityname);\ncreate index GNAF_IDX on LOCATION_TABLE(gnafid);\ncreate index RDNUM1_IDX on LOCATION_TABLE(roadnumber1);\ncreate index RDNUM2_IDX on LOCATION_TABLE(roadnumber2);\ncreate index ROADNAME_IDX on LOCATION_TABLE(roadname);\ncreate index SITENAME_IDX on LOCATION_TABLE(addresssitename);\ncreate index LOTNUM_IDX on LOCATION_TABLE(lotnumber);\ncreate index UNITNUM_IDX on LOCATION_TABLE(unitnumber);\ncreate index LAT_IDX on LOCATION_TABLE(latitude);\ncreate index LONG_IDX on LOCATION_TABLE(longitude);\n#!/bin/bash\n\n############################################################\n#\t\t\t\t\t\t\t #\n# load-mysql.sh\t\t\t\t\t\t #\n#\t\t\t\t\t\t\t #\n# Loads GNAF data to a MySQL database\t\t\t #\n# 19/08/2020\t\t\t\t\t\t #\n#\t\t\t\t\t\t\t #\n############################################################\n\nMYSQL_HOST=\"10.0.1.208\"\nMYSQL_USER=\"rjk\"\nMYSQL_PASS=\"\"\nMYSQL_DB=\"gnaf\"\n\nAUT=$1\nAUT_REGEX=\"Authority_Code_([[:upper:]_]+)_psv\\.psv\"\nDAT=$2\nDAT_REGEX=\"(ACT|NSW|NT|QLD|SA|OT|TAS|VIC|WA)_([[:upper:][:digit:]_]+)_psv\\.psv\"\n\necho \"*** creating tables ***\"\nmysql --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB < create_tables_ansi.sql\n\necho \"\"\necho \"*** Working on Authority codes ***\"\necho \"Authority files in folder $AUT\"\necho \"\"\n\nif [[ -d \"$AUT\" ]]; then\n\techo \"Authority codes is a folder\"\n\tfor aut_file in $AUT/*.psv; do\n\t\techo \"Got AUT file: $aut_file\"\n\t\tif [[ \"$aut_file\" =~ $AUT_REGEX ]]; then\n\t\t\tTABLE_NAME=${BASH_REMATCH[1]}\n\t\t\techo \"Table name: $TABLE_NAME\"\n\t\t\techo \"LOAD DATA LOCAL INFILE '$aut_file' INTO TABLE $TABLE_NAME COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\\r\\n' IGNORE 1 LINES\" | mysql --local-infile=1 --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB\n\t\tfi\n\tdone\nelse\n\techo \"Authority codes is not a folder\"\n\texit -1\nfi\n\necho \"\"\necho \"*** Working on data files ***\"\necho \"Data files in folder $DAT\"\necho \"\"\n\nif [[ -d \"$DAT\" ]]; then\n\techo \"Data files is a folder\"\n\tfor dat_file in $DAT/*.psv; do\n\t\techo \"Got DAT file: $dat_file\"\n\t\tif [[ \"$dat_file\" =~ $DAT_REGEX ]]; then\n\t\t\tTABLE_NAME=${BASH_REMATCH[2]}\n\t\t\techo \"Table name: $TABLE_NAME\"\n\t\t\techo \"LOAD DATA LOCAL INFILE '$dat_file' INTO TABLE $TABLE_NAME COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\\r\\n' IGNORE 1 LINES\" | mysql --local-infile=1 --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB\n\t\tfi\n\tdone\nfi\n\necho \"\"\necho \"*** creating the PK indexes ***\"\n#mysql --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB < add_pk.sql\n\n#!/bin/bash\n\n############################################################\n#\t\t\t\t\t\t\t #\n# load-postgres.sh\t\t\t\t\t #\n#\t\t\t\t\t\t\t #\n# Loads GNAF data to a postgres database\t\t #\n# 21/08/2020\t\t\t\t\t\t #\n#\t\t\t\t\t\t\t #\n############################################################\n\nPG_HOST=\"127.0.0.1\"\nPG_USER=\"rjk\"\nPG_PASS=\"\"\nPG_DB=\"gnaf\"\n\nAUT=$1\nAUT_REGEX=\"Authority_Code_([[:upper:]_]+)_psv\\.psv\"\nDAT=$2\nDAT_REGEX=\"(ACT|NSW|NT|QLD|SA|OT|TAS|VIC|WA)_([[:upper:][:digit:]_]+)_psv\\.psv\"\n\necho \"*** creating tables ***\"\nPGPASSWORD=$PG_PASS psql -h $PG_HOST -U $PG_USER -d $PG_DB -a -f create_tables_ansi.sql\n\necho \"\"\necho \"*** Working on Authority codes ***\"\necho \"Authority files in folder $AUT\"\necho \"\"\n\nif [[ -d \"$AUT\" ]]; then\n\techo \"Authority codes is a folder\"\n\tfor aut_file in $AUT/*.psv; do\n\t\techo \"Got AUT file: $aut_file\"\n\t\tif [[ \"$aut_file\" =~ $AUT_REGEX ]]; then\n\t\t\tTABLE_NAME=${BASH_REMATCH[1]}\n\t\t\techo \"Table name: $TABLE_NAME\"\n\t\t\techo \"\\copy $TABLE_NAME FROM '$aut_file' DELIMITER '|' CSV HEADER\" | PGPASSWORD=$PG_PASS psql -h $PG_HOST -U $PG_USER -d $PG_DB \n\t\tfi\n\tdone\nelse\n\techo \"Authority codes is not a folder\"\n\texit -1\nfi\n\necho \"\"\necho \"*** Working on data files ***\"\necho \"Data files in folder $DAT\"\necho \"\"\n\nif [[ -d \"$DAT\" ]]; then\n\techo \"Data files is a folder\"\n\tfor dat_file in $DAT/*.psv; do\n\t\techo \"Got DAT file: $dat_file\"\n\t\tif [[ \"$dat_file\" =~ $DAT_REGEX ]]; then\n\t\t\tTABLE_NAME=${BASH_REMATCH[2]}\n\t\t\techo \"Table name: $TABLE_NAME\"\n\t\t\techo \"\\copy $TABLE_NAME FROM '$dat_file' DELIMITER '|' CSV HEADER\" | PGPASSWORD=$PG_PASS psql -h $PG_HOST -U $PG_USER -d $PG_DB\n\t\tfi\n\tdone\nfi\n\necho \"\"\necho \"*** creating the PK indexes ***\"\n#mysql --host=$MYSQL_HOST --user=$MYSQL_USER --password=$MYSQL_PASS $MYSQL_DB < add_pk.sql\n\nALTER TABLE ADDRESS_ALIAS ADD\n CONSTRAINT ADDRESS_ALIAS_PK PRIMARY KEY (address_alias_pid);\n\nALTER TABLE ADDRESS_ALIAS_TYPE_AUT ADD\n CONSTRAINT ADDRESS_ALIAS_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE ADDRESS_CHANGE_TYPE_AUT ADD\n CONSTRAINT ADDRESS_CHANGE_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE ADDRESS_DEFAULT_GEOCODE ADD\n CONSTRAINT ADDRESS_DEFAULT_GEOCODE_PK PRIMARY KEY (address_default_geocode_pid);\n\nALTER TABLE ADDRESS_DETAIL ADD\n CONSTRAINT ADDRESS_DETAIL_PK PRIMARY KEY (address_detail_pid);\n\nALTER TABLE ADDRESS_FEATURE ADD\n CONSTRAINT ADDRESS_FEATURE_PK PRIMARY KEY (address_feature_id);\n\nALTER TABLE ADDRESS_MESH_BLOCK_2011 ADD\n CONSTRAINT ADDRESS_MESH_BLOCK_2011_PK PRIMARY KEY (address_mesh_block_2011_pid);\n\nALTER TABLE ADDRESS_MESH_BLOCK_2016 ADD\n CONSTRAINT ADDRESS_MESH_BLOCK_2016_PK PRIMARY KEY (address_mesh_block_2016_pid);\n\nALTER TABLE ADDRESS_SITE ADD\n CONSTRAINT ADDRESS_SITE_PK PRIMARY KEY (address_site_pid);\n\nALTER TABLE ADDRESS_SITE_GEOCODE ADD\n CONSTRAINT ADDRESS_SITE_GEOCODE_PK PRIMARY KEY (address_site_geocode_pid);\n\nALTER TABLE ADDRESS_TYPE_AUT ADD\n CONSTRAINT ADDRESS_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE FLAT_TYPE_AUT ADD\n CONSTRAINT FLAT_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE GEOCODED_LEVEL_TYPE_AUT ADD\n CONSTRAINT GEOCODED_LEVEL_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE GEOCODE_RELIABILITY_AUT ADD\n CONSTRAINT GEOCODE_RELIABILITY_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE GEOCODE_TYPE_AUT ADD\n CONSTRAINT GEOCODE_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE LEVEL_TYPE_AUT ADD\n CONSTRAINT LEVEL_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE LOCALITY ADD\n CONSTRAINT LOCALITY_PK PRIMARY KEY (locality_pid);\n\nALTER TABLE LOCALITY_ALIAS ADD\n CONSTRAINT LOCALITY_ALIAS_PK PRIMARY KEY (locality_alias_pid);\n\nALTER TABLE LOCALITY_ALIAS_TYPE_AUT ADD\n CONSTRAINT LOCALITY_ALIAS_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE LOCALITY_CLASS_AUT ADD\n CONSTRAINT LOCALITY_CLASS_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE LOCALITY_NEIGHBOUR ADD\n CONSTRAINT LOCALITY_NEIGHBOUR_PK PRIMARY KEY (locality_neighbour_pid);\n\nALTER TABLE LOCALITY_POINT ADD\n CONSTRAINT LOCALITY_POINT_PK PRIMARY KEY (locality_point_pid);\n\nALTER TABLE MB_2011 ADD\n CONSTRAINT MB_2011_PK PRIMARY KEY (mb_2011_pid);\n\nALTER TABLE MB_2016 ADD\n CONSTRAINT MB_2016_PK PRIMARY KEY (mb_2016_pid);\n\nALTER TABLE MB_MATCH_CODE_AUT ADD\n CONSTRAINT MB_MATCH_CODE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE PRIMARY_SECONDARY ADD\n CONSTRAINT PRIMARY_SECONDARY_PK PRIMARY KEY (primary_secondary_pid);\n\nALTER TABLE PS_JOIN_TYPE_AUT ADD\n CONSTRAINT PS_JOIN_TYPE_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE STATE ADD\n CONSTRAINT STATE_PK PRIMARY KEY (state_pid);\n\nALTER TABLE STREET_CLASS_AUT ADD\n CONSTRAINT STREET_CLASS_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE STREET_LOCALITY ADD\n CONSTRAINT STREET_LOCALITY_PK PRIMARY KEY (street_locality_pid);\n\nALTER TABLE STREET_LOCALITY_ALIAS ADD\n CONSTRAINT STREET_LOCALITY_ALIAS_PK PRIMARY KEY (street_locality_alias_pid);\n\nALTER TABLE STREET_LOCALITY_ALIAS_TYPE_AUT ADD\n CONSTRAINT STREET_LOCALITY_ALIAS_TYPE__PK PRIMARY KEY (code);\n\nALTER TABLE STREET_LOCALITY_POINT ADD\n CONSTRAINT STREET_LOCALITY_POINT_PK PRIMARY KEY (street_locality_point_pid);\n\nALTER TABLE STREET_SUFFIX_AUT ADD\n CONSTRAINT STREET_SUFFIX_AUT_PK PRIMARY KEY (code);\n\nALTER TABLE STREET_TYPE_AUT ADD\n CONSTRAINT STREET_TYPE_AUT_PK PRIMARY KEY (code);\ncreate index ADDRESS_DETAIL_PID on ADDRESS_DETAIL(address_detail_pid);\ncreate index ADDRESS_DEFAULT_GEOCODE_PID on ADDRESS_DEFAULT_GEOCODE(address_detail_pid);\ncreate index STREET_LOCALITY_PID on STREET_LOCALITY(street_locality_pid);\ncreate index LOCALITY_PID on LOCALITY(locality_pid);\ncreate index STATE_PID on STATE(state_pid);\n\ncreate index FLAT_TYPE_AUT_CODE on FLAT_TYPE_AUT(code);\ncreate index LEVEL_TYPE_AUT_CODE on LEVEL_TYPE_AUT(code);\ncreate index STREET_SUFFIX_AUT_CODE on STREET_SUFFIX_AUT(code);\ncreate index STREET_CLASS_AUT_CODE on STREET_CLASS_AUT(code);\ncreate index STREET_TYPE_AUT_CODE on STREET_TYPE_AUT(code);\ncreate index GEOCODE_TYPE_AUT_CODE on GEOCODE_TYPE_AUT(code);\ncreate index GEOCODED_LEVEL_TYPE_AUT_CODE on GEOCODED_LEVEL_TYPE_AUT(code)\n# gnaf\nSome utilities for loading GNAF data into a database\n\nNot much order to this yet, it needs to be cleaned up.\n\nYou can find the GNAF dataset here https://data.gov.au/dataset/ds-dga-19432f89-dc3a-4ef3-b943-5326ef1dbecc/details\n\nYou can also find another of my projects which uses this data here: https://github.com/richardjkendall/location-service\ndrop view if exists LOCATION_VIEW;\n\ncreate or replace view LOCATION_VIEW\n\nas\n\nselect\n\nad.address_detail_pid as gnafid,\nad.building_name as addresssitename,\nad.flat_type_code as unittypecode,\nconcat(ad.flat_number, ad.flat_number_suffix) as unitnumber,\nad.level_type_code as leveltypecode,\nconcat(ad.level_number, ad.level_number_suffix) as levelnumber,\nconcat(ad.lot_number, ad.lot_number_suffix) as lotnumber,\nconcat(ad.number_first, ad.number_first_suffix) as roadnumber1,\nconcat(ad.number_last, ad.number_last_suffix) as roadnumber2,\nsl.street_name as roadname,\nsta.name as roadtypecode,\nl.locality_name as localityname,\nad.postcode as postcode,\nst.state_abbreviation as statecode,\nadg.latitude as latitude,\nadg.longitude as longitude\n\nfrom\n\nADDRESS_DETAIL ad\nleft join LOCALITY l on l.locality_pid = ad.locality_pid \nleft join STREET_LOCALITY sl on sl.street_locality_pid = ad.street_locality_pid \nleft join STREET_TYPE_AUT sta on sta.code = sl.street_type_code \nleft join STATE st on st.state_pid = l.state_pid \nleft join ADDRESS_DEFAULT_GEOCODE adg on adg.address_detail_pid = ad.address_detail_pid\n\nwhere \n\nad.confidence > -1;\n"},"directory_id":{"kind":"string","value":"e952bd7fb033997f2389db057a3ef0b8378fd6bf"},"languages":{"kind":"list like","value":["Markdown","SQL","Shell"],"string":"[\n \"Markdown\",\n \"SQL\",\n \"Shell\"\n]"},"num_files":{"kind":"number","value":8,"string":"8"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"richardjkendall/gnaf"},"revision_id":{"kind":"string","value":"b32ee1c6beb3e2a17f747d2c4e048b670762044b"},"snapshot_id":{"kind":"string","value":"b43cd69b2e2995c337d4f9e6ae070b936a34e608"}}},{"rowIdx":9951,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"## React Boilerplate\n\nThis is a react boilerplate codebase built off of [Create React App](https://github.com/facebook/create-react-app) to get you started quicker. It includes ESLint setup with recommended react settings and Prettier installed for correct automatic formatting along with SASS for SCSS.\n\nAdditionally, react-router has been added in for a more component driven implementation which will allow you to add multiple components/pages relatively easily and quickly should you so desire.\n\n### Getting Started\n\nIn order to get started, you must install all the dependencies locally by running\n\n#### `yarn install`\n\nOnce you have done this, you can get it started by running\n\n#### `yarn start`\n\nThis will run the app in the development mode (with hot reloading).\n\nYou can then view it at [http://localhost:3000](http://localhost:3000) in the browser.\n\n#### `yarn build`\n\nThis will create the static files needed in order to host the web app online\nimport React, { Component } from 'react';\n\nexport class Home extends Component {\n constructor(props) {\n super(props);\n this.state = {\n message: 'Click on the button'\n };\n this.updateText = this.updateText.bind(this);\n }\n\n updateText() {\n const thisContext = this;\n this.setState({ message: 'Thanks for clicking the button' });\n setTimeout(function () {\n thisContext.setState({ message: 'Click on the button' });\n }, 3000);\n }\n\n render() {\n return (\n
    \n

    {this.state.message}

    \n \n
    \n );\n }\n}\n\nexport default Home;\n"},"directory_id":{"kind":"string","value":"51e65475296930a5068deccc155d17fc047b92f2"},"languages":{"kind":"list like","value":["Markdown","JavaScript"],"string":"[\n \"Markdown\",\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":2,"string":"2"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"HazAnwar/React-Boilerplate"},"revision_id":{"kind":"string","value":"77029263023eb57324a9f9f28e6af971f7c8232b"},"snapshot_id":{"kind":"string","value":"d9df500224ef18ad412cb84504ba90058c14ac6c"}}},{"rowIdx":9952,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"/**\n * Created by hong-drmk on 2017/7/19.\n */\n\nimport React, { PureComponent, PropTypes } from 'react'\nimport {\n SectionList,\n Text,\n View,\n TouchableOpacity\n} from 'react-native'\nimport type { Props as FlatListProps } from 'FlatList'\n\ntype DataBase = {\n title: string,\n onPress: (info: {\n item: DataBase,\n index: number\n }) => void\n}\n\ntype RequiredProps = {\n sections: Array\n}\n\ntype Props = RequiredProps & FlatListProps\n\nclass List extends PureComponent {\n props: Props\n\n render() {\n return (\n index}\n sections={this.props.sections}\n renderItem={({ item, index }) => (\n \n {index} {item.title}\n \n )}\n renderSectionHeader={({ section }) => (\n \n {section.key}\n \n )}\n ItemSeparatorComponent={SeparatorComponent}\n {...this.props}\n />\n )\n }\n}\n\nclass SeparatorComponent extends React.PureComponent {\n render() {\n return \n }\n}\n\nexport default List## 笔记草稿\n\n```\n创建 project\nreact-native init AwesomeProject\ncd AwesomeProject\nreact-native run-ios\n```\n\n\n```\nnpm start 启动packager服务\nreact-native run-ios 启动应用\n```\n\n\n```\n\"Unable to resolve module\" 或者 缺少模块时\n1. watchman watch-del-all\n2. rm -rf node_modules && npm install\n3. npm start -- --reset-cache\n4. npm install @\n```\n\n\n```\nbabel-polyfill\nBabel默认只转换新的JavaScript句法(syntax),而不转换新的API,比如Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise等全局对象,以及一些定义在全局对象上的方法(比如Object.assign)都不会转码。\n举例来说,ES6在Array对象上新增了Array.from方法。Babel就不会转码这个方法。如果想让这个方法运行,必须使用babel-polyfill,为当前环境提供一个垫片。\nhttp://www.ruanyifeng.com/blog/2016/01/babel.html\n```\n\n\n```\nComponents\n- React.Component\n- React.PureComponent\n\nReact提出的组件的概念,把UI隔离独立出来,让它可重用、独立使用。React.Component 是一个抽象基类, 一般需要继承它来使用。\nReact.PureComponent 很像 React.Component ,但是实现了 shouldComponentUpdate()  方法来浅比较 props 和 state , 可以用它这个特性来提高性能。注意它是浅比较,适合简单数据结构的比较。如果是复杂数据结构发生了变化,默认实现会返回false,不会更新页面。\n\n有关组件更新的更多知识(https://segmentfault.com/a/1190000007811296)\n```\n\n\n```\n函数的prototype属性\n__proto__ 与 prototype Object.getPrototypeOf \n- {实例}.__proto__ \n- {函数}.prototype\n```\n\n\n```\nListView 源码\n- 渲染使用ScrollView.js\n- 懒加载item\n- 用xcode调试时发现,RCTView始终保持subview一个均衡的个数。(ScrollView 的 removeClippedSubviews 属性,移除看不见的子视图)\n- RCTView的subview不复用\n```\n\n\n```\nScrollView 源码\n- removeClippedSubviews 属性可以移除看不见的子视图,但是不能复用\n```\n\n\n```\nFlatList \n- 渲染可视区域的上下一部分视图\n- 设置 removeClippedSubviews 属性了才可以移除看不见的子视图\n```\n\n\n```\nSectionList\n- 同FlatList一样,渲染可视区域的上下一部分视图\n- 设置 removeClippedSubviews 属性了才可以移除看不见的子视图\n```\n\n\n```\n动画\n- requestAnimationFrame \n它接受一个函数作为唯一的参数,并且在下一次重绘之前调用此函数。\n\n- setNativeProps\nsetNativeProps方法可以使我们直接修改基于原生视图的组件的属性,而不需要使用setState来重新渲染整个组件树。\n\n- LayoutAnimation\n优点:\n1、效果非常的流畅,而且动画的过程很柔和,丝毫没有生硬的感觉。\n2、可以灵活的配置动画参数,基本能满足单个动画的需求。\n缺点:\n1、如果要实现‘组合顺序’动画,比如先缩小50%、再向左平移100像素,那么就比较麻烦了,需要监听上一个动画的结束事件,再进行下一个。那么问题来了,configureNext第二个参数是可以监听动画结束的,但是只在IOS平台有效!\n2、如果动画的效果更为复杂,比如同时执行动画,再顺序执行,对于编程来讲,需要做的事情很多,复杂度也大大提升。\n\n- Animated\n```\n\n\n```\n关于绑定this,为什么箭头函数不用绑定this? 继承的函数也不用绑定this?\n```\n\n\n```\n关于绑定this对象,call()、apply()、bind() 等方法\n\n/**\n@param {Object} [thisArg]\n@param {Array} [argArray]\n@return {*}\n*/\nFunction.prototype.apply = function(thisArg,argArray) {};\n/**\n@param {Object} [thisArg]\n@param {...*} [args]\n@return {*}\n*/\nFunction.prototype.call = function(thisArg,args) {};\nFunction = {};\n/**\n@param {T} thisArg\n@param {...*} [arg]\n@return {function(this:T)}\n@template T\n*/\nFunction.prototype.bind = function(thisArg,arg) {};\n\napply() 第二个参数是数组,\ncall() 第二个参数是reset参数,\nbind() 第二个参数是reset参数, 返回值是函数\n \n函数在哪里调用才决定了this到底引用的是啥\n\n箭头函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。\n```\n\n\n```\n获取屏幕尺寸\nimport { Dimensions } from ‘react-native’\nDimensions.get('window').height\n```\n\n\n```\n获取组件尺寸\nimport { UIManager, findNodeHandle } from ‘react-native’\nconst handle = findNodeHandle(this.textInput)\nUIManager.measure(handle, (x, y, width, height, pageX, pageY) => {\n //在这获取\n})\n```\n\n\n/**\n * Created by hong-drmk on 2017/8/18.\n */\n\nimport React, { Component } from 'react'\nimport {\n Animated,\n View,\n Button,\n} from 'react-native'\n\nclass Simple extends Component {\n constructor(props) {\n super(props)\n this.state = {\n /*\n 1. 初始化动画值\n * */\n fadeAnim: new Animated.Value(0)\n }\n }\n\n render() {\n return (\n \n \n Simple Animated Used Animated.timing\n \n \n
    \n
    Team Builder
    \n \n
    \n {mappedSelectedPlayer}\n
    \n
    \n \n
    \n {/*
    \n this.handleName (e.target.value)} value={this.state.playerName}>\n this.handlePosition (e.target.value)} value={this.state.playerPosition}>\n this.handleImage (e.target.value)} value={this.state.playerImage}>\n \n
    */}\n \n
    \n );\n }\n}\n \nexport default App;\n/src/components/Player.js\nimport React from 'react'\nimport axios from 'axios'\n\n// import './Player.css'\n// import PlayerSelected from './PlayerSelected';\n\n\n\nclass Player extends React.Component {\n constructor(){\n super()\n this.state={\n edit: false,\n editName: '',\n editPosition: '',\n editImage: '',\n }\n }\n\n handleToggle = () => {\n this.setState({\n edit: !this.state.edit\n })\n }\n \n handleInput=(val)=>{\n this.setState({\n editName: val\n })\n }\n \n handleUpdatePlayer=(id)=>{\n let updatedPlayer = {\n id,\n name: this.state.editName,\n position: this.props.selectedPlayer.position,\n image: this.props.selectedPlayer.image\n }\n \n \n axios.put(`/api/players/${id}`, updatedPlayer)\n .then(res =>{\n this.props.updatePlayer(res.data)\n // this.props.selectPlayer(this.props.players)\n this.handleToggle()\n })\n }\n\n render() {\n console.log(this.state.edit)\n const {id, name, position, image} = this.props.players\n const {deletePlayer} = this.props\n return (\n
    \n
    \n \n \n \n
    \n

    {name}

    \n

    {position}

    \n
    \n \"get\"\n
    \n \n )\n }\n}\n\n\n// const Player = (props) => {\n// const {id, name, position, image} = props.players\n// const {deletePlayer} = props\n// return (\n//
    \n//
    \n// \n//
    \n//

    {name}

    \n//

    {position}

    \n//
    \n// \n//
    \n \n// )\n// }\n\n//edit functionality for name input of players array\n\n// {this.state.edit ? (\n// \n// ) : (\n// \n// )}\n//
    \n\n// {this.state.edit ? (\n//
    \n// \n//

    {position}

    \n\n// \"get\"\n//
    \n// ) : (\n//
    \n//
    \n//

    {name}

    \n//

    {position}

    \n//
    \n// \"get\"\n//
    \n// )}\n// \n// );\n// }\n// }\n\n// https://pngimage.net/wp-content/uploads/2018/06/magic-johnson-png-5.png\n\nexport default Player"},"directory_id":{"kind":"string","value":"248fe54f4f7177f8772dcb16fa6e23227336179c"},"languages":{"kind":"list like","value":["JavaScript"],"string":"[\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":5,"string":"5"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"nnlawrence/NoDB-11"},"revision_id":{"kind":"string","value":"243663fdea5da58b0e9ecd0969f562c16bd7de02"},"snapshot_id":{"kind":"string","value":"543a81b3ee1f371a209618a92892cbd9ef98ad28"}}},{"rowIdx":9960,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"harrytran998/Docker-Beginer/Dockerfile\nFROM busybox\nRUN echo \"XXXX\"\nCMD echo \"WDA\""},"directory_id":{"kind":"string","value":"87f2116ca3d90689c1460e3df104217f322ce785"},"languages":{"kind":"list like","value":["Dockerfile"],"string":"[\n \"Dockerfile\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Dockerfile"},"repo_name":{"kind":"string","value":"harrytran998/Docker-Beginer"},"revision_id":{"kind":"string","value":"4f235c8b83dad7011bd6443fd548c12706f3d99e"},"snapshot_id":{"kind":"string","value":"77e3e4f22322ad34cab48342a0693b5b167603ca"}}},{"rowIdx":9961,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# victorsonde.github.io\nJournal of Digital Adventures\n"},"directory_id":{"kind":"string","value":"4c52e93e29d66a9ca1783a5562787f9a37eccb9b"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"victorsonde/victorsonde.github.io"},"revision_id":{"kind":"string","value":"9661ef9430b2b97b959bbdd2b3c44927138e0435"},"snapshot_id":{"kind":"string","value":"e71505a6b5342ced9f97938387b8863e30f77e6c"}}},{"rowIdx":9962,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"package gestioncv.web;\n\nimport java.io.Serializable;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.stream.Collectors;\n\nimport javax.annotation.PostConstruct;\nimport javax.enterprise.context.SessionScoped;\nimport javax.faces.context.ExternalContext;\nimport javax.faces.context.FacesContext;\nimport javax.inject.Inject;\nimport javax.inject.Named;\n\nimport gestioncv.model.Activity;\nimport gestioncv.model.Nature;\nimport gestioncv.model.Person;\nimport gestioncv.services.IPersonDao;\nimport lombok.Getter;\n\n@Named(\"cvView\")\n@SessionScoped\npublic class CvView implements Serializable {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\t@Inject\n\tprivate IPersonDao personDao;\n\n\t/* Donn�es utilis�es dans les vues */\n\tprivate @Getter Collection persons;\n\tprivate @Getter Person selectedPerson;\n\tprivate @Getter boolean showEditButtons;\n\n\tpublic Collection getSelectedPersonEducations() {\n\t\treturn filterActivitiesByNature(selectedPerson, Nature.EDUCATION);\n\t}\n\n\tpublic Collection getSelectedPersonProfessionalExperiences() {\n\t\treturn filterActivitiesByNature(selectedPerson, Nature.PROFESSIONAL_EXPERIENCE);\n\t}\n\n\tpublic Collection getSelectedPersonProjects() {\n\t\treturn filterActivitiesByNature(selectedPerson, Nature.PROJECT);\n\t}\n\n\tpublic Collection getSelectedPersonOtherActivities() {\n\t\treturn filterActivitiesByNature(selectedPerson, Nature.OTHER);\n\t}\n\n\tprivate Collection filterActivitiesByNature(Person person, Nature nature) {\n\t\tif (person != null) {\n\t\t\treturn person.getCv().stream()\n\t\t\t\t\t.filter(activity -> nature.equals(activity.getNature()))\n\t\t\t\t\t.collect(Collectors.toList());\n\t\t}\n\n\t\treturn new ArrayList();\n\t}\n\n\t@PostConstruct\n\tpublic void init() {\n\t\tthis.persons = personDao.findAll();\n\t}\n\n\t/**\n\t * Contrôleur responsable de gérer les accès à la page d'affichage des détails\n\t * d'un CV.\n\t * \n\t * @param id\n\t * @return\n\t */\n\tpublic String show(int id) {\n\t\tupdateSelectedPerson(personDao.find(id));\n\t\treturn \"cv-detail?faces-redirect=true\";\n\t}\n\n\tpublic String showEditPage() {\n\t\treturn \"person-form\";\n\t}\n\n\tpublic String savePerson(Person person) {\n\t\tif (person.getId() != 0) {\n\t\t\tupdateSelectedPerson(personDao.update(person));\n\t\t} else {\n\t\t\tupdateSelectedPerson(personDao.add(person));\n\t\t}\n\t\t// TODO: faire en sorte que la mise-�-jour soit visible au sein de la collection\n\t\treturn \"cv-detail\";\n\t}\n\n\t/**\n\t * La modification de selectedPerson doit être effectuée uniquement à l'aide de\n\t * cette méthode afin de pouvoir appliquer des effets secondaires comme, par\n\t * exemple, dicter l'affichage des boutons de modifications de CVs.\n\t * \n\t * @param newSelectedPerson\n\t */\n\tprivate void updateSelectedPerson(Person newSelectedPerson) {\n\t\tselectedPerson = newSelectedPerson;\n\n\t\tFacesContext context = FacesContext.getCurrentInstance();\n\t\tExternalContext externalContext = context.getExternalContext();\n\t\tPerson loggedInUser = (Person) externalContext.getSessionMap().get(\"user\");\n\n\t\t// Effets secondaires de la mise à jour de selectedPerson\n\t\tif (selectedPerson != null && loggedInUser != null && selectedPerson.getId() == loggedInUser.getId()) {\n\t\t\tshowEditButtons = true;\n\t\t} else {\n\t\t\tshowEditButtons = false;\n\t\t}\n\t}\n}DROP TABLE IF EXISTS `Activity`, `Person`;\n\n\n\n\t4.0.0\n\tAA_Gestion_de_CV\n\tAA_Gestion_de_CV\n\t0.0.1-SNAPSHOT\n\twar\n\t\n\t\tsrc\n\t\t\n\t\t\t\n\t\t\t\tmaven-compiler-plugin\n\t\t\t\t3.8.0\n\t\t\t\t\n\t\t\t\t\t14\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\tmaven-war-plugin\n\t\t\t\t3.2.3\n\t\t\t\t\n\t\t\t\t\tWebContent\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\torg.apache.maven.plugins\n\t\t\t\tmaven-surefire-plugin\n\t\t\t\t\n\t\t\t\t2.22.2\n\t\t\t\n\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\t\torg.junit.jupiter\n\t\t\tjunit-jupiter\n\t\t\t5.7.0-M1\n\t\t\ttest\n\t\t\n\t\t\n\t\t\n\t\t\torg.junit.platform\n\t\t\tjunit-platform-runner\n\t\t\t1.7.0\n\t\t\ttest\n\t\t\n\t\t\n\t\t\n\t\t org.mockito\n\t\t mockito-core\n\t\t 3.6.28\n\t\t test\n\t\t\n\t\t\n\t\t\n\t\t org.mockito\n\t\t mockito-junit-jupiter\n\t\t 3.6.28\n\t\t test\n\t\t\n\t\t\n\t\t\n\t\t\torg.projectlombok\n\t\t\tlombok\n\t\t\t1.16.20\n\t\t\tprovided\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\torg.hsqldb\n\t\t\thsqldb\n\t\t\t2.4.1\n\t\t\ttest\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\tmysql\n\t\t\tmysql-connector-java\n\t\t\t8.0.22\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\torg.hibernate\n\t\t\thibernate-core\n\t\t\t5.4.25.Final\n\t\t\n\t\t\n\t\t\n\t\t\torg.glassfish.jaxb\n\t\t\tjaxb-runtime\n\t\t\t2.4.0-b180830.0438\n\t\t\n\t\t\n\t\t\n\t\t\torg.apache.commons\n\t\t\tcommons-lang3\n\t\t\t3.11\n\t\t\n\n\t\t\n\t\t\n\t\t\torg.apache.myfaces.core\n\t\t\tmyfaces-impl\n\t\t\t2.3.6\n\t\t\tprovided\n\t\t\n\t\t\n\t\t\torg.apache.myfaces.core\n\t\t\tmyfaces-api\n\t\t\t2.3.6\n\t\t\tprovided\n\t\t\n\t\t\n\t\t\n\t\t\torg.primefaces\n\t\t\tprimefaces\n\t\t\t8.0\n\t\t\n\t\t\n\t\t\torg.webjars\n\t\t\tfont-awesome\n\t\t\t5.15.1\n\t\t\n\t\t\n\t\t\n\t\t\torg.hibernate\n\t\t\thibernate-entitymanager\n\t\t\t5.4.25.Final\n\t\t\n\t\t\n\t\t\tcom.sun.jersey\n\t\t\tjersey-client\n\t\t\t1.19\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\torg.apache.xbean\n\t\t\txbean-asm7-shaded\n\t\t\t4.16\n\t\t\n\t\t\n\t\t\n\t\t\torg.apache.tomee\n\t\t\topenejb-junit\n\t\t\t8.0.4\n\t\t\n\t\t\n\t\t\n\t\t\torg.apache.tomee\n\t\t\ttomee-myfaces\n\t\t\t8.0.3\n\t\t\tprovided\n\t\t\n\t\t\n\t\t\torg.apache.taglibs\n\t\t\ttaglibs-standard-impl\n\t\t\t1.2.5\n\t\t\n\t\t\n\t\t\torg.apache.taglibs\n\t\t\ttaglibs-standard-spec\n\t\t\t1.2.5\n\t\t\n\t\t\n\t\t\n\t\t\tcommons-validator\n\t\t\tcommons-validator\n\t\t\t1.6\n\t\t\n\t\npackage gestioncv.services;\n\nimport java.util.Collection;\n\npublic interface IDao {\n\n\tT find(Class clazz, Object id);\n\n\tCollection findAll(Class clazz);\n\n\t/**\n\t * Ajoute l'entité passée en paramètre en base de données.\n\t * \n\t * @param entity\n\t * @return\n\t */\n\tT add(T entity);\n\n\tT update(T entity);\n\n\tvoid remove(Class clazz, Object pk);\n}\npackage gestioncv.servicesTests;\nimport static org.junit.Assert.assertEquals;\nimport org.apache.commons.lang3.NotImplementedException;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertThrows;\n\nimport java.util.Collection;\nimport java.util.Collections;\n\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.extension.ExtendWith;\nimport org.mockito.InjectMocks;\nimport org.mockito.Mock;\nimport org.mockito.Spy;\nimport org.mockito.junit.jupiter.MockitoExtension;\nimport static org.mockito.Mockito.doReturn;\nimport static org.mockito.Mockito.doNothing;\n\nimport gestioncv.model.Person;\nimport gestioncv.services.IPersonDao;\nimport gestioncv.services.impl.Dao;\nimport gestioncv.services.impl.PersonDao;\nimport static org.mockito.Mockito.verify;\n\n@ExtendWith(MockitoExtension.class)\npublic class PersonDaoTest{\n\n\t@InjectMocks\n @Spy\n\tPersonDao personDao;\n\t\n\n\t@Test\n\tpublic void testFindAllSuccess() {\n\t\tCollection persons = Collections.singletonList(Person.builder().id(10).build());\n\t\tdoReturn(persons).when(personDao).findAll(Person.class);\n\t\tpersonDao.findAll();\n\t\tverify(personDao).findAll(Person.class);\n\t}\n\t\n\t@Test\n\tpublic void testFind() {\n\t\tint id = 10 ;\n\t\tPerson person = Person.builder().id(id).build();\n\t\tdoReturn(person).when(personDao).find(id);\n\t\tPerson foundedPerson = personDao.find(id);\n\t\tverify(personDao).find(id);\n\t\tassertEquals(id, foundedPerson.getId());\n\t}\n\t\n\t@Test\n\tpublic void testRemove() {\n\t\tint id = 10 ;\n\t\tdoNothing().when(personDao).remove(Person.class,id);\n\t\tpersonDao.remove(id);\n\t\tverify(personDao).remove(Person.class,id);\n\n\t}\n\t\n\t@Test\n\tpublic void testFindPersonsByActivityTitle() {\n\t\tString title = \"activity title\";\n\t\tassertThrows(NotImplementedException.class, () -> personDao.findPersonsByActivityTitle(title));\n\t}\n\n}package gestioncv.model;\n\nimport java.io.Serializable;\nimport java.time.LocalDate;\nimport java.util.Collection;\n\nimport javax.persistence.CascadeType;\nimport javax.persistence.Column;\nimport javax.persistence.Entity;\nimport javax.persistence.FetchType;\nimport javax.persistence.GeneratedValue;\nimport javax.persistence.GenerationType;\nimport javax.persistence.Id;\nimport javax.persistence.OneToMany;\nimport javax.validation.constraints.Email;\nimport javax.validation.constraints.Max;\nimport javax.validation.constraints.NotNull;\nimport javax.validation.constraints.Size;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Builder;\nimport lombok.Getter;\nimport lombok.NoArgsConstructor;\nimport lombok.Setter;\n\n@Getter\n@Setter\n@NoArgsConstructor\n@Entity\n@Builder\n@AllArgsConstructor\npublic class Person implements Serializable {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\t@Id\n\t@GeneratedValue(strategy = GenerationType.AUTO)\n\tprivate int id;\n\n\t@Size(min = 2, max = 255, message = \"le nom doit contenir entre 2 et 255 caractères\")\n\t@NotNull(message = \"le nom est requis\")\n\t@Column(nullable = false, length = 255)\n\tprivate String lastName;\n\n\t@Size(min = 2, max = 255, message = \"le prénom doit contenir entre 2 et 255 caractères\")\n\t@NotNull(message = \"le prénom est requis\")\n\t@Column(nullable = false, length = 255)\n\tprivate String firstName;\n\n\t@Max(value = 255, message = \"le site web ne doit pas contenir plus de 255 caractères\")\n\t@Column(length = 255)\n\t// TODO: valider le site web\n\tprivate String website;\n\n\t@NotNull(message = \"l'email est requis\")\n\t@Email(message = \"merci de saisir un email valide\")\n\t@Column(nullable = false, length = 255, unique = true)\n\tprivate String email;\n\n\t@NotNull(message = \"la date de naissance est requise\")\n\t@Column(nullable = false)\n\tprivate LocalDate dateOfBirth;\n\n\t// TODO: valider le mot de passe lorsque le hachage aura été défini\n\t@Column(nullable = false, length = 102)\n\tprivate String password;\n\n\t@OneToMany(cascade = {\n\t\t\tCascadeType.MERGE,\n\t\t\tCascadeType.PERSIST,\n\t\t\tCascadeType.REMOVE\n\t}, fetch = FetchType.LAZY, mappedBy = \"owner\")\n\tprivate Collection cv;\n}\npackage gestioncv.services.impl;\n\nimport java.util.Collection;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\nimport javax.persistence.criteria.CriteriaBuilder;\nimport javax.persistence.criteria.CriteriaQuery;\nimport javax.persistence.criteria.Root;\n\nimport gestioncv.services.IDao;\n\npublic abstract class Dao implements IDao {\n\n\t@PersistenceContext(unitName = \"myData\")\n\tprotected EntityManager em;\n\n\t@Override\n\tpublic T find(Class clazz, Object id) {\n\t\treturn em.find(clazz, id);\n\t}\n\n\t@Override\n\tpublic Collection findAll(Class clazz) {\n\n\t\tCriteriaBuilder builder = em.getCriteriaBuilder();\n\t\tCriteriaQuery cq = builder.createQuery(clazz);\n\n\t\tRoot root = cq.from(clazz);\n\t\tcq.select(root);\n\n\t\treturn em.createQuery(cq).getResultList();\n\t}\n\n\t@Override\n\tpublic T add(T entity) {\n\t\tem.persist(entity);\n\t\treturn entity;\n\t}\n\n\t@Override\n\tpublic T update(T entity) {\n\t\treturn em.merge(entity);\n\t}\n\n\t@Override\n\tpublic void remove(Class clazz, Object pk) {\n\t\tT entity = em.find(clazz, pk);\n\t\tif (entity != null) {\n\t\t\tem.remove(entity);\n\t\t}\n\t}\n}\nimport javax.ejb.embeddable.EJBContainer;\n\nimport org.junit.jupiter.api.BeforeAll;\nimport org.junit.jupiter.api.BeforeEach;\n\n/*\n * Cette classe regroupe les outils nécessaires afin de faciliter\n * l'écriture des tests unitaires sur les instances CDI et EJB. \n */\npublic class BaseJunit5 {\n\n\t/*\n\t * Le nom de votre application (en clair le nom de votre projet)\n\t */\n\tpublic final String BASE = \"java:global/gestion-de-cv\";\n\n\t/*\n\t * Le conteneur qui va regrouper à la fois les instances CDI et les EJB.\n\t */\n\tpublic static EJBContainer container;\n\n\t/*\n\t * Création du conteneur avant les tests.\n\t */\n\t@BeforeAll\n\tstatic public void beforeAll() throws Exception {\n\t\tif (container == null) {\n\t\t\tSystem.out.println(\"\\nSTARTING CONTAINER\\n\");\n\t\t\tcontainer = EJBContainer.createEJBContainer();\n\t\t\t// prevoir la fermeture\n\t\t\tThread t = new Thread(BaseJunit5::afterAll);\n\t\t\tRuntime.getRuntime().addShutdownHook(t);\n\t\t}\n\t}\n\n\tstatic public void afterAll() {\n\t\tSystem.out.println(\"\\nSTOPPING CONTAINER\\n\");\n\t\tcontainer.close();\n\t\tcontainer = null;\n\t}\n\n\t/*\n\t * Injecter dans le conteneur l'instance du test afin de réaliser les\n\t * initialisations et les injections nécessaires.\n\t */\n\t@BeforeEach\n\tpublic void before() throws Exception {\n\t\tcontainer.getContext().bind(\"inject\", this);\n\t}\n\n\t/*\n\t * Utiliser l'API JNDI (Java Naming and Directory Interface) pour trouver une\n\t * instance à partir de son nom.\n\t */\n\tpublic T lookup(String name, Class theClass) {\n\t\ttry {\n\t\t\tObject o = container.getContext().lookup(name);\n\t\t\treturn theClass.cast(o);\n\t\t} catch (Exception e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\n}/* Icarus Theme */\n/* pt-sans-regular */\n@font-face {\n font-family: 'PT_Sans';\n font-weight: normal;\n src: url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.eot']}\"); /* IE9 Compat Modes */\n src: url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.eot']}#iefix\") format('embedded-opentype'), /* IE6-IE8 */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.woff2']}\") format('woff2'), /* Super Modern Browsers */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.woff']}\") format('woff'), /* Modern Browsers */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.ttf']}\") format('truetype'), /* Safari, Android, iOS */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-regular.svg']}#PT_Sans\") format('svg'); /* Legacy iOS */\n}\n/* pt-sans-700 */\n@font-face {\n font-family: 'PT_Sans';\n font-weight: bold;\n src: url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.eot']}\"); /* IE9 Compat Modes */\n src: url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.eot']}#iefix\") format('embedded-opentype'), /* IE6-IE8 */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.woff2']}\") format('woff2'), /* Super Modern Browsers */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.woff']}\") format('woff'), /* Modern Browsers */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.ttf']}\") format('truetype'), /* Safari, Android, iOS */\n url(\"\\#{resource['primefaces-icarus:fonts/pt_sans-web-bold.svg']}#PT_Sans\") format('svg'); /* Legacy iOS */\n}\n\n@import \"../_variables\";\n@import \"../_icons\";\n\n/* Component containers\n----------------------------------*/\n.ui-widget {\n font-family: 'PT_Sans', sans-serif;\n font-size: 14px;\n}\n.ui-widget-content {\n border: 1px solid $grey;\n background: #fff;\n color: $blackLight;\n}\n.ui-widget-content a {\n color: $blackLight;\n}\n.ui-widget-header {\n border: 1px solid $blackLight;\n background: $blackLight;\n color: #fff;\n font-weight: bold;\n}\n.ui-widget-header a {\n color: #fff;\n}\n\n/* Interaction states\n----------------------------------*/\n.ui-state-default,\n.ui-widget-content .ui-state-default,\n.ui-widget-header .ui-state-default {\n border: 1px solid $grey;\n background: #fff;\n color: $blackLight;\n}\n.ui-state-default a,\n.ui-state-default a:link,\n.ui-state-default a:visited {\n color: $blackLight;\n text-decoration: none;\n}\n\n.ui-state-hover,\n.ui-widget-content .ui-state-hover,\n.ui-widget-header .ui-state-hover {\n border: 1px solid $greyDark;\n background-color: $grey;\n color: #fff;\n}\n.ui-state-hover a,\n.ui-state-hover a:hover {\n color: #fff;\n text-decoration: none;\n}\n\n.ui-state-focus,\n.ui-widget-content .ui-state-focus,\n.ui-widget-header .ui-state-focus {\n border: 1px solid $regularColor;\n color: $blackLight;\n \n -moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n -webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n outline: 0 none;\n}\n.ui-state-focus a,\n.ui-state-focus a:hover {\n color: $blackLight;\n text-decoration: none;\n}\n\n.ui-state-active,\n.ui-widget-content .ui-state-active,\n.ui-widget-header .ui-state-active {\n border: 1px solid $regularColor;\n background: $regularColor;\n color: #fff;\n}\n.ui-state-active a,\n.ui-state-active a:link,\n.ui-state-active a:visited {\n color: #fff;\n text-decoration: none;\n}\n\n.ui-widget:active {\n outline: none;\n}\n/* Interaction Cues\n----------------------------------*/\n\n.ui-state-highlight,\n.ui-widget-content .ui-state-highlight,\n.ui-widget-header .ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n color: #fff;\n}\n.ui-state-highlight a,\n.ui-widget-content .ui-state-highlight a,\n.ui-widget-header .ui-state-highlight a {\n color: #fff;\n}\n.ui-state-error,\n.ui-widget-content .ui-state-error,\n.ui-widget-header .ui-state-error {\n border: 1px solid $error;\n}\n.ui-state-disabled,\n.ui-widget-content .ui-state-disabled,\n.ui-widget-header .ui-state-disabled {\n opacity: .35;\n filter: Alpha(Opacity=35);\n background-image: none;\n}\n\n/* Misc visuals\n----------------------------------*/\n/* Corner radius */\n\n.ui-corner-tl {\n -moz-border-radius-topleft: 3px;\n -webkit-border-top-left-radius: 3px;\n border-top-left-radius: 3px;\n}\n.ui-corner-tr {\n -moz-border-radius-topright: 3px;\n -webkit-border-top-right-radius: 3px;\n border-top-right-radius: 3px;\n}\n.ui-corner-bl {\n -moz-border-radius-bottomleft: 3px;\n -webkit-border-bottom-left-radius: 3px;\n border-bottom-left-radius: 3px;\n}\n.ui-corner-br {\n -moz-border-radius-bottomright: 3px;\n -webkit-border-bottom-right-radius: 3px;\n border-bottom-right-radius: 3px;\n}\n.ui-corner-top {\n -moz-border-radius-topleft: 3px;\n -webkit-border-top-left-radius: 3px;\n border-top-left-radius: 3px;\n -moz-border-radius-topright: 3px;\n -webkit-border-top-right-radius: 3px;\n border-top-right-radius: 3px;\n}\n.ui-corner-bottom {\n -moz-border-radius-bottomleft: 3px;\n -webkit-border-bottom-left-radius: 3px;\n border-bottom-left-radius: 3px;\n -moz-border-radius-bottomright: 3px;\n -webkit-border-bottom-right-radius: 3px;\n border-bottom-right-radius: 3px;\n}\n.ui-corner-right {\n -moz-border-radius-topright: 3px;\n -webkit-border-top-right-radius: 3px;\n border-top-right-radius: 3px;\n -moz-border-radius-bottomright: 3px;\n -webkit-border-bottom-right-radius: 3px;\n border-bottom-right-radius: 3px;\n}\n.ui-corner-left {\n -moz-border-radius-topleft: 3px;\n -webkit-border-top-left-radius: 3px;\n border-top-left-radius: 3px;\n -moz-border-radius-bottomleft: 3px;\n -webkit-border-bottom-left-radius: 3px;\n border-bottom-left-radius: 3px;\n}\n.ui-corner-all {\n -moz-border-radius: 3px;\n -webkit-border-radius: 3px;\n border-radius: 3px;\n}\n/* Overlays */\n\n.ui-widget-overlay {\n background-color: #666666;\n opacity: .50;\n filter: Alpha(Opacity=50);\n}\n.ui-widget-shadow {\n margin: -5px 0 0 -5px;\n padding: 5px;\n background-color: #000000;\n opacity: .20;\n filter: Alpha(Opacity=20);\n -moz-border-radius: 5px;\n -webkit-border-radius: 5px;\n border-radius: 5px;\n}\n\n/* ThemeRoller Icons */\n.ui-icon {\n\twidth: 16px;\n\theight: 16px;\n}\n\n/* ====== Forms ====== */\n/* Inputs */\n.ui-inputfield,\n.ui-widget-content .ui-inputfield,\n.ui-widget-header .ui-inputfield {\n -webkit-transition: .2s;\n -moz-transition: .2s;\n -o-transition: .2s;\n transition: .2s;\n background: #fff;\n color: $blackLight;\n \n &.ui-state-focus {\n -moz-box-shadow: 0px 0px 5px $regularColor;\n -webkit-box-shadow: 0px 0px 5px $regularColor;\n box-shadow: 0px 0px 5px $regularColor;\n }\n \n &.ui-state-hover {\n color: $blackLight;\n }\n}\nbody {\n .ui-inputgroup {\n height: 100%;\n \n .ui-inputgroup-addon,\n .ui-inputgroup-addon-checkbox {\n padding: $inputPadding;\n border-color: $inputGroupBorderColor;\n background-color: $inputGroupBgColor;\n color: $inputGroupTextColor;\n min-width: $inputGroupAddonMinWidth;\n \n &:first-child {\n @include border-radius-left($borderRadius);\n }\n \n &:last-child {\n @include border-radius-right($borderRadius);\n }\n }\n\n .ui-button-text-only {\n margin: 0;\n }\n \n .ui-inputgroup-addon-checkbox {\n padding: 0;\n position: relative;\n \n .ui-chkbox {\n vertical-align: baseline;\n position: absolute;\n top: 50%;\n left: 50%;\n margin-top: -1 * $checkboxHeight / 2;\n margin-left: -1 * $checkboxWidth / 2;\n }\n }\n }\n}\n\n\n@media (max-width : 768px) {\n .ui-inputfield.ui-inputtextarea{\n -webkit-transition: none;\n -moz-transition: none;\n -o-transition: none;\n transition: none;\n }\n}\n\n/* Button */\n.ui-button {\n -webkit-transition: background-color .2s;\n -moz-transition: background-color .2s;\n -o-transition: background-color .2s;\n transition: background-color .2s;\n \n &.ui-state-default {\n background: $regularColor;\n border: none;\n border-bottom: 5px solid $darkColor;\n \n &.ui-widget {\n color: #fff;\n }\n }\n \n &.ui-state-hover {\n background: $lightColor;\n border-bottom: 5px solid $regularColor;\n }\n \n &.ui-state-active {\n background: $darkColor;\n border-bottom: 5px solid $darkColor;\n } \n \n &.ui-button-text-icon-left {\n .ui-button-text {\n color: #fff;\n padding-top: 5px;\n padding-bottom: 4px;\n }\n .ui-button-icon-left {\n &.ui-icon-check {\n color: #fff;\n &.ui-icon-check {\n @include icon-override(\"\\f00c\");\n }\n }\n }\n }\n \n &.ui-button-text-icon-right {\n .ui-button-icon-right {\n color: #fff;\n }\n .ui-button-text {\n color: #fff;\n }\n }\n \n &.ui-button-icon-only {\n .ui-button-icon-left {\n color: #fff;\n .ui-button-text {\n color: #fff;\n padding-top: 10px;\n padding-bottom: 10px;\n }\n }\n }\n \n &.ui-widget {\n &.ui-button-text-only {\n .ui-button-text {\n color: #fff;\n }\n }\n }\n}\n\n/* SelectButton */\n.ui-selectonebutton, .ui-selectmanybutton {\n &.ui-buttonset {\n .ui-button {\n border-bottom: 0 none;\n border-right: 1px solid $greyDark;\n \n &:last-child {\n border-right: 1px solid transparent;\n }\n \n &.ui-state-default {\n background: $grey;\n }\n \n &.ui-state-hover {\n background: $greyDark;\n }\n \n &.ui-state-active {\n background: $regularColor;\n border-right: 1px solid $darkColor;\n }\n }\n }\n}\n\n.ui-fluid { \n .ui-selectonebutton, .ui-selectmanybutton {\n &.ui-buttonset.ui-buttonset-3 {\n .ui-button {\n width: 33.33%;\n }\n }\n \n &.ui-buttonset.ui-buttonset-6 {\n .ui-button {\n width: 16.66%;\n }\n }\n }\n}\n\n@media (max-width : 640px) {\n .ui-fluid {\n .ui-selectonebutton, .ui-selectmanybutton {\n border: 1px solid $greyDark;\n\n &.ui-buttonset {\n .ui-button {\n border-bottom: 1px solid $greyDark;\n border-right: 0 none;\n border-radius: 3px;\n\n &:last-child {\n border-bottom: 1px solid transparent;\n }\n\n &.ui-state-default {\n background: $grey;\n }\n\n &.ui-state-hover {\n background: $greyDark;\n }\n\n &.ui-state-active {\n background: $regularColor;\n border-right: 0 none;\n border-bottom: 1px solid $darkColor;\n }\n }\n \n &.ui-buttonset-6, &.ui-buttonset-3 {\n .ui-button {\n width: 100%;\n }\n }\n }\n }\n }\n}\n\n.ui-selectbooleanbutton {\n &.ui-button {\n border-bottom: 0 none;\n \n &.ui-state-default {\n background: $grey;\n }\n \n &.ui-state-hover {\n background: $greyDark;\n }\n \n &.ui-state-active {\n background: $regularColor;\n }\n }\n}\n\n/* Colored Buttons */\n/*Green Button*/\n.ui-button {\n &.green-button {\n background-color: $greenButton;\n border-color: $greenButtonBorder;\n \n &.ui-state-hover {\n background-color: $greenButtonHover;\n }\n \n &.ui-state-active {\n background-color: $greenButtonActive;\n }\n }\n}\n\n/*Red Button*/\n.ui-button {\n &.red-button {\n background-color: $redButton;\n border-color: $redButtonBorder;\n \n &.ui-state-hover {\n background-color: $redButtonHover;\n }\n \n &.ui-state-active {\n background-color: $redButtonActive;\n }\n }\n}\n\n/*Blue Button */\n.ui-button {\n &.blue-button {\n background-color: $blue;\n border-color: $blueDark;\n \n &.ui-state-hover {\n background-color: $blueLight;\n }\n \n &.ui-state-active {\n background-color: $blueDark;\n }\n }\n}\n\n/*Aqua Button*/\n.ui-button {\n &.aqua-button {\n background-color: $aquaButton;\n border-color: $aquaButtonBorder;\n \n &.ui-state-hover {\n background-color: $aquaButtonHover;\n }\n \n &.ui-state-active {\n background-color: $aquaButtonActive;\n }\n }\n}\n\n/*Navy Button*/\n.ui-button {\n &.navy-button {\n background-color: $navyButton;\n border-color: $navyButtonBorder;\n \n &.ui-state-hover {\n background-color: $navyButtonHover;\n }\n \n &.ui-state-active {\n background-color: $navyButtonActive;\n }\n }\n}\n\n/*Black Button*/\n.ui-button {\n &.black-button {\n background-color: $blackButton;\n border-color: $blackButtonBorder;\n \n &.ui-state-hover {\n background-color: $blackButtonHover;\n }\n \n &.ui-state-active {\n background-color: $blackButtonActive;\n }\n }\n}\n\n/*Grey Button*/\n.ui-button {\n &.gray-button {\n background-color: $greyButton;\n border-color: $greyButtonBorder;\n \n &.ui-button {\n span.ui-button-text {\n color: $greyButtonText;\n }\n }\n \n &.ui-state-hover {\n background-color: $greyButtonHover;\n }\n \n &.ui-state-active {\n background-color: $greyButtonActive;\n }\n }\n}\n\n/* Password */\n.ui-password-panel {\n background: $lightColor;\n border-color: $regularColor;\n color: $blackLight;\n}\n\n/* Checkbox */\n.ui-chkbox {\n .ui-chkbox-icon {\n font-size: 12px;\n margin-left: 1px;\n @include icon-override(\"\\f00c\");\n visibility: hidden;\n }\n \n .ui-chkbox-box {\n cursor: pointer;\n \n .ui-icon-closethick {\n @include icon-override(\"\\f00d\");\n margin-left: 2px;\n }\n \n &.ui-state-hover {\n background-color: $bg-greyLight;\n }\n \n &.ui-state-active {\n background-color: $regularColor;\n .ui-chkbox-icon {\n @include icon-override(\"\\f00c\");\n color: #fff;\n visibility: visible;\n }\n \n .ui-icon-closethick {\n @include icon-override(\"\\f00d\");\n }\n }\n \n &.ui-state-focus {\n background-color: $lightColor;\n .ui-icon-check {\n @include icon-override(\"\\f00c\");\n color: #fff;\n visibility: visible;\n }\n \n .ui-icon-closethick {\n @include icon-override(\"\\f00d\");\n }\n }\n \n &[data-iconstates] {\n overflow: hidden;\n }\n }\n}\n\n.ui-chips {\n .ui-chips-container {\n width: 155px;\n padding: 0px;\n }\n}\n\n.ui-fluid {\n .ui-chips, .ui-chips-container {\n width: 100%;\n }\n}\n\n/* ManyCheckbox */\n.ui-selectmanycheckbox,\n.ui-selectoneradio {\n .ui-grid-row {\n > div {\n padding: 4px;\n }\n }\n}\n\n/* RadioButtons */\n.ui-radiobutton { \n .ui-radiobutton-icon {\n @include icon-override(\" \");\n margin-left: 4px;\n font-size: 10px;\n margin-top: 2.45px;\n }\n .ui-radiobutton-box {\n cursor: pointer;\n \n &.ui-state-hover {\n background-color: $bg-greyLight;\n }\n \n &.ui-state-active,&.ui-state-focus {\n background-color: $regularColor;\n \n .ui-icon-bullet {\n @include icon-override(\"\\f111\");\n color: #fff;\n font-size: 10px;\n }\n }\n }\n}\n\n/* Dropdown */\n.ui-selectonemenu {\n .ui-selectonemenu-trigger {\n &.ui-state-default {\n background: $grey;\n color: #fff;\n border-bottom: 5px solid $greyDark;\n box-sizing: border-box;\n width: 32px;\n padding: 0 6px;\n \n .ui-icon {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n padding-left: 2px;\n text-align: center;\n }\n } \n \n &.ui-state-hover {\n background: $greyDark;\n } \n \n &.ui-corner-right {\n @include border-radius-right(0);\n } \n }\n \n input.ui-selectonemenu-label {\n padding: 6.5px 4px;\n }\n}\n\n.ui-selectonemenu-panel {\n .ui-selectonemenu-items-wrapper {\n .ui-selectonemenu-items {\n padding: 0;\n .ui-selectonemenu-item {\n border-left: 5px solid transparent;\n padding: 8px 8px;\n border-radius: 0;\n margin: 0;\n \n &.ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n color: #fff;\n }\n \n &.ui-state-hover {\n background: $grey;\n border-color: $greyDark;\n color: #fff;\n \n }\n }\n \n .ui-selectonemenu-item-group {\n padding: 5px 0 0 12px;\n font-size: 16px;\n background: $greyDark;\n color: white;\n border-radius: 0;\n }\n }\n }\n}\n\n.ui-selectmanymenu, \n.ui-selectonelistbox {\n \n .ui-selectlistbox-filter-container {\n margin: .2em;\n \n .ui-selectlistbox-filter {\n width: 100%;\n box-sizing: border-box;\n }\n }\n\n &.ui-inputfield {\n padding: 0;\n \n .ui-selectlistbox-list {\n .ui-selectlistbox-item {\n margin: 0;\n padding: 5px;\n border-left: 5px solid transparent;\n border-radius: 0;\n \n &.ui-state-hover {\n border-left: 5px solid $greyDark;\n }\n \n &.ui-state-highlight {\n border-left: 5px solid $darkColor;\n \n .ui-chkbox { \n .ui-chkbox-box {\n border-color: $lightColor;\n }\n }\n }\n \n .ui-chkbox {\n vertical-align: middle;\n margin-right: 5px;\n }\n }\n }\n }\n \n}\n\n/* MultiSelectListBox */\n.ui-multiselectlistbox {\n .ui-multiselectlistbox-list {\n .ui-multiselectlistbox-item {\n border-left: 5px solid transparent;\n margin: 0;\n padding: 5px;\n \n &.ui-state-highlight {\n border-color: $darkColor;\n background: $regularColor;\n color: #fff;\n }\n \n &.ui-state-hover {\n border-color: $greyDark;\n background: $grey;\n color: #fff;\n }\n }\n }\n}\n\n\n/* AutoComplete */\n.ui-autocomplete {\n .ui-autocomplete-dropdown {\n &.ui-button {\n background-color: $grey;\n border-color: $greyDark;\n right: -4px;\n \n .ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n }\n \n &.ui-state-hover {\n background: $greyDark;\n }\n }\n }\n}\n\n.ui-autocomplete-panel {\n .ui-autocomplete-items {\n &.ui-autocomplete-list {\n padding: 0;\n line-height: 1.5;\n }\n \n .ui-autocomplete-item {\n border-left: 5px solid #ffffff;\n @include border-radius(0px);\n \n &.ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n }\n \n &:first-child {\n margin-top: 0;\n }\n \n &:last-child {\n margin-bottom: 0;\n }\n }\n }\n}\n/* SelectCheckBoxMenu */\n.ui-selectcheckboxmenu {\n .ui-selectcheckboxmenu-trigger {\n box-sizing: border-box; \n \n &.ui-state-default {\n width: 32px;\n background-color: $grey;\n border-bottom: 5px solid $greyDark;\n }\n \n &.ui-state-hover {\n background-color: $greyDark;\n }\n \n span {\n &.ui-icon {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n padding: 0 0 2px 8px;\n }\n }\n \n &.ui-corner-right {\n @include border-radius-right(0);\n } \n }\n \n label.ui-selectcheckboxmenu-label {\n padding: 4px 36px 4px 5px;\n background-color: #fff;\n color: $blackLight;\n }\n \n &.ui-selectcheckboxmenu-multiple {\n padding-top: 1px;\n padding-bottom: 1px;\n\n .ui-selectcheckboxmenu-multiple-container {\n &.ui-inputfield {\n border: 0 none;\n padding-right: 32px;\n }\n \n .ui-selectcheckboxmenu-token {\n margin: 1px 2px;\n }\n }\n\n .ui-selectcheckboxmenu-trigger {\n .ui-icon {\n top: auto;\n margin-top: 3px;\n }\n }\n }\n}\n\n.ui-selectcheckboxmenu-panel {\n .ui-selectcheckboxmenu-header {\n .ui-chkbox {\n margin-top: 2px;\n \n .ui-chkbox-icon {\n margin-top: 2px;\n }\n }\n \n .ui-selectcheckboxmenu-filter-container {\n .ui-icon {\n color: $blackLight;\n }\n }\n \n .ui-selectcheckboxmenu-close {\n text-align: center;\n font-size: 16px;\n margin-top: 2px;\n }\n }\n}\n\n/* Input Switch */\n.ui-inputswitch {\n .ui-inputswitch-off {\n background-color: $grey;\n \n span {\n color: #fff;\n padding: 0;\n }\n }\n .ui-inputswitch-on {\n &.ui-state-active {\n background-color: $regularColor;\n }\n \n span {\n color: #fff;\n }\n } \n}\n\n//toggleSwitch\nbody {\n .ui-toggleswitch {\n height: 26px;\n width: 3.5em;\n\n .ui-toggleswitch-slider {\n @include transition(background-color .3s);\n background-color: #a8acb1;\n color: #ffffff;\n border: 1px solid $greyBorder;\n @include border-radius(3px);\n overflow: hidden;\n\n &:before {\n background-color: #ffffff;\n border: 1px solid transparent;\n @include transition(.3s);\n @include border-radius(0);\n width: calc(3em / 2);\n height: 22px;\n left: auto;\n bottom: auto;\n }\n }\n\n &.ui-toggleswitch-checked {\n .ui-toggleswitch-slider {\n border: 1px solid $regularColor;\n background: $regularColor;\n color: #fff;\n\n &:before {\n @include translateX(calc(2em - 4px));\n @include translateXForIE(2em, -4px);\n }\n }\n }\n\n &.ui-toggleswitch-focus {\n .ui-toggleswitch-slider { \n &:before {\n border: 1px solid $regularColor;\n color: $blackLight;\n\n -moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n -webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n outline: 0 none;\n }\n } \n }\n }\n}\n\n/* Spinner */\n.ui-spinner {\n .ui-spinner-button {\n width: 22px;\n &.ui-spinner-up {\n background-color: $grey;\n border: 3px solid $grey;\n cursor: pointer;\n box-sizing: border-box;\n \n .ui-button-text {\n .ui-icon {\n left: 0;\n top: 4px;\n @include icon-override(\"\\f106\");\n font-size: 15px;\n color: #fff;\n }\n }\n \n &.ui-state-hover {\n background-color: $greyDark;\n border-color: $greyDark;\n }\n \n &.ui-state-active {\n background-color: $greyDark;\n border-color: $greyDark;\n }\n }\n \n &.ui-spinner-down {\n background-color: $grey;\n border: 3px solid $grey;\n cursor: pointer;\n box-sizing: border-box;\n \n .ui-button-text {\n .ui-icon {\n left: 0;\n @include icon-override(\"\\f107\");\n font-size: 15px;\n color: #fff;\n }\n }\n \n &.ui-state-hover {\n background-color: $greyDark;\n border-color: $greyDark;\n }\n \n &.ui-state-active {\n background-color: $greyDark;\n border-color: $greyDark;\n }\n }\n }\n .ui-spinner-input {\n &.ui-inputfield {\n &.ui-state-default {\n font-family: 'PT_Sans', sans-serif;\n font-size: 14px;\n padding-right: 28px;\n }\n }\n }\n}\n\n/* Slider */\n.ui-slider {\n background-color: $grey;\n \n .ui-slider-handle {\n border-radius: 100%;\n }\n}\n\n/* SelectOneListBox */\n.ui-selectonelistbox {\n &.ui-inputfield {\n padding: 0;\n \n .ui-selectlistbox-listcontainer {\n .ui-selectlistbox-list {\n .ui-selectlistbox-item {\n margin: 0;\n padding: 5px;\n border-left: 5px solid transparent;\n border-radius: 0;\n \n &.ui-state-hover {\n border-left: 5px solid $greyDark;\n }\n \n &.ui-state-highlight {\n border-left: 5px solid $darkColor;\n }\n }\n }\n }\n }\n}\n\n/* SplitButton */\n.ui-splitbutton {\n .ui-icon-disk {\n @include icon-override(\"\\f0c7\");\n }\n \n .ui-splitbutton-menubutton {\n height: 100%;\n box-sizing: border-box;\n \n .ui-icon {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n padding: 0 0 2px 0;\n }\n }\n}\n\n/* Calendar */\n.ui-datepicker {\n &.ui-widget-content {\n padding: 0;\n \n td {\n .ui-state-default {\n border: none;\n \n &.ui-state-hover {\n background: $greyLight;\n }\n \n &.ui-state-active {\n background: $regularColor;\n color: #fff;\n }\n }\n }\n .ui-datepicker-header {\n .ui-datepicker-prev {\n cursor: pointer;\n \n span {\n @include icon-override(\"\\f060\");\n font-size: 15px;\n color: #fff;\n overflow: hidden;\n width: 13px;\n padding-left: 1px;\n }\n }\n \n .ui-datepicker-next {\n cursor: pointer;\n \n span {\n @include icon-override(\"\\f061\");\n font-size: 15px;\n color: #fff;\n overflow: hidden;\n width: 13px;\n padding-left: 2px;\n }\n }\n }\n \n .ui-datepicker-calendar {\n td {\n &.ui-datepicker-today {\n a {\n background: $greyLight;\n color: $blackLight;\n }\n }\n \n a {\n font-size: 16px;\n text-align: center;\n }\n }\n }\n }\n}\n\n.ui-calendar {\n &.ui-trigger-calendar {\n .ui-datepicker-trigger {\n box-sizing: border-box;\n vertical-align: top;\n border-bottom-width: 2px;\n @include border-radius-left(0);\n \n .ui-icon-calendar {\n @include icon-override(\"\\f073\");\n font-size: 12px;\n color: #fff;\n padding-top: 2px;\n }\n }\n }\n \n .ui-inputfield {\n &.ui-corner-all {\n @include border-radius-right(0);\n }\n }\n}\n\n.ui-fluid {\n .ui-calendar {\n position:relative;\n \n input.hasDatepicker {\n padding-right: 2.4em;\n }\n \n .ui-datepicker-trigger {\n border-bottom-width: 3px;\n position: absolute;\n right: -2px;\n width: 2.4em;\n \n .ui-button-text {\n padding: 0.26em;\n }\n }\n \n .ui-inputfield {\n &.ui-corner-all {\n @include border-radius-right(3px);\n }\n }\n \n &.ui-trigger-calendar {\n .ui-button-icon-only {\n .ui-button-text {\n padding: 0.26em;\n }\n }\n }\n }\n}\n\n/* DatePicker */\n.p-datepicker-panel {\n @include border-radius(3px);\n overflow: hidden;\n \n &:not(.ui-datepicker-inline),\n .ui-datepicker-group {\n border: 0 none;\n @include border-radius(0);\n }\n \n .ui-datepicker-header { \n .ui-datepicker-prev,\n .ui-datepicker-next {\n outline: 0 none;\n\n &:hover {\n background-color: $grey;\n color: #fff;\n }\n }\n }\n \n table {\n td {\n a {\n &:hover {\n background: $greyLight;\n }\n \n &.ui-state-active {\n background: $regularColor;\n color: #fff;\n }\n }\n \n a,span {\n width: 100%;\n @include box-sizing(border-box);\n }\n \n &.ui-datepicker-today {\n a {\n background: $greyLight;\n color: $blackLight;\n }\n }\n }\n }\n\n &.ui-datepicker-multiple-month { \n .ui-datepicker-group {\n @include border-radius(0);\n width: 17em;\n \n .ui-datepicker-header {\n @include border-radius(0);\n }\n \n &:first-child {\n .ui-datepicker-header {\n @include border-radius-left(3px);\n }\n }\n \n &:last-child {\n .ui-datepicker-header {\n @include border-radius-right(3px);\n }\n }\n \n .ui-datepicker-calendar-container {\n padding: 0 5px;\n }\n }\n }\n \n &.ui-datepicker-monthpicker {\n .ui-monthpicker {\n .ui-monthpicker-month {\n color: $blackLight;\n @include box-sizing(border-box);\n \n &:hover {\n background: $greyLight;\n }\n \n &.ui-state-active {\n background: $regularColor;\n color: #fff;\n }\n }\n }\n }\n \n .ui-timepicker {\n font-weight: normal;\n border: 0 none;\n @include border-radius-top(0);\n \n .ui-picker-up {\n color: #ffffff;\n @include icon_override(\"\\f077\");\n display: block;\n margin-bottom: .2em;\n \n span {\n display: none;\n }\n \n &:hover {\n background-color: $grey;\n color: #fff;\n }\n }\n \n .ui-picker-down {\n color: #ffffff;\n @include icon_override(\"\\f078\");\n display: block;\n margin-top: .2em;\n \n span {\n display: none;\n }\n \n &:hover {\n background-color: $grey;\n color: #fff;\n }\n }\n }\n \n .ui-datepicker-buttonbar {\n border: 0 none;\n @include border-radius-top(0);\n \n .ui-button {\n width: auto;\n\n &:focus {\n border: 1px solid $regularColor;\n color: $blackLight;\n\n -moz-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n -webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);\n outline: 0 none;\n }\n\n &:hover {\n background: $lightColor;\n border-bottom: 5px solid $regularColor;\n }\n }\n }\n}\n\n/* ====== DATA ======*/\n/* Datatable */\n.ui-datatable {\n .ui-datatable-header {\n &.ui-widget-header {\n background: $blackLight;\n border: none;\n padding: 10px;\n }\n }\n \n thead {\n th {\n &.ui-state-default {\n background-color: $greyLight;\n border-color: $greyBorder;\n color: $blackLight;\n }\n \n .ui-selectonemenu-trigger, .ui-selectcheckboxmenu-trigger {\n background: $grey;\n border: none;\n border-bottom: 5px solid $greyDark;\n \n .ui-icon {\n padding: 0;\n }\n \n &.ui-state-hover {\n background: $greyDark;\n }\n }\n \n &.ui-sortable-column {\n &.ui-state-hover {\n background: $blackLight;\n color: #fff;\n \n .ui-sortable-column-icon {\n &.ui-icon {\n &.ui-icon-carat-2-n-s:before {\n color: #fff;\n }\n }\n }\n \n }\n \n &.ui-state-active {\n background: $regularColor;\n color: #fff;\n .ui-sortable-column-icon {\n &.ui-icon {\n &.ui-icon-triangle-1-n:before {\n color: #fff;\n }\n &.ui-icon-triangle-1-s:before {\n color: #fff;\n }\n }\n }\n }\n \n .ui-sortable-column-icon {\n &.ui-icon {\n &.ui-icon-carat-2-n-s {\n font-size: 13px;\n color: $grey;\n padding: 2px 0 0 2px;\n vertical-align: middle;\n }\n \n &.ui-icon-triangle-1-n {\n font-size: 13px;\n color: $grey;\n padding: 2px 0 0 2px;\n vertical-align: middle;\n }\n \n &.ui-icon-triangle-1-s {\n font-size: 13px;\n color: $grey;\n padding: 2px 0 0 2px;\n vertical-align: middle;\n }\n }\n }\n }\n }\n }\n \n tfoot {\n td {\n &.ui-state-default {\n background-color: $greyLight;\n border-color: $greyBorder;\n color: $blackLight;\n }\n }\n }\n \n tbody {\n &.ui-datatable-data {\n .ui-button {\n &.ui-state-default {\n background: $regularColor;\n border-bottom: 5px solid $darkColor;\n }\n \n &.ui-state-hover {\n background: $darkColor;\n }\n }\n \n tr.ui-widget-header {\n border-color: $greyBorder;\n \n > .ui-state-default {\n background-color: $greyLight;\n border-color: $greyBorder;\n color: $blackLight; \n }\n }\n\n tr.ui-widget-content {\n border-color: $greyBorder;\n \n &.ui-datatable-selectable {\n &.ui-state-hover {\n background-color: $grey;\n color: #fff;\n }\n \n &.ui-state-highlight {\n background: $regularColor;\n color: #fff;\n \n .ui-radiobutton-box {\n border-color: $lightColor;\n .ui-radiobutton-icon {\n margin-left: -0.2px;\n }\n }\n \n .ui-chkbox-box {\n border-color: $lightColor;\n }\n }\n }\n \n &.ui-datatable-odd {\n background-color: $bg-greyLight;\n }\n \n &.ui-row-editing {\n td {\n background: $orange;\n border-color: $orange;\n \n .ui-icon-check {\n @include icon-override('\\f00c');\n }\n \n .ui-icon-close {\n @include icon-override('\\f00d');\n }\n }\n .ui-inputfield {\n width: 100%!important;\n box-sizing: border-box;\n }\n }\n \n td {\n .ui-icon {\n &.ui-icon-pencil {\n @include icon-override('\\f040');\n }\n }\n &.ui-cell-editing {\n background: $orange;\n border-color: $orange;\n \n .ui-inputfield {\n width: 100%!important;\n box-sizing: border-box;\n }\n }\n }\n }\n }\n }\n \n &.ui-datatable-scrollable {\n .ui-datatable-scrollable-header,\n .ui-datatable-scrollable-footer {\n background-color: $greyLight;\n }\n }\n}\n\n/* DataGrid */\n.ui-datagrid {\n .ui-widget-header {\n &.ui-datagrid-header {\n background: $blackLight;\n }\n }\n \n .ui-paginator {\n &.ui-widget-header {\n border-color: $grey;\n }\n }\n \n .ui-datagrid-content {\n .ui-grid-row {\n .ui-datagrid-column {\n .ui-panel {\n .ui-widget-header {\n background: $blackLight;\n }\n }\n }\n }\n }\n}\n\n /* Paginator */\n.ui-paginator {\n &.ui-widget-header {\n background: #fff;\n border-color: $greyBorder;\n\n > .ui-state-default {\n vertical-align: middle;\n border: none;\n color: $greyDark;\n \n @include border-radius(0);\n \n &.ui-state-hover {\n border: none;\n background: none;\n border-bottom: 5px solid $grey;\n }\n &.ui-state-active {\n border: none;\n background: none;\n border-bottom: 5px solid $regularColor;\n }\n }\n \n .ui-icon {\n color: $greyDark;\n }\n \n .ui-paginator-first {\n border-bottom: 5px solid #fff;\n \n .ui-icon {\n &.ui-icon-seek-first {\n @include icon-override(\"\\f100\");\n width: 10px;\n overflow: hidden;\n font-size: 16px;\n font-weight: bold;\n padding-top: 0;\n height: 16px;\n }\n }\n }\n \n .ui-paginator-prev {\n border-bottom: 5px solid #fff;\n \n .ui-icon {\n &.ui-icon-seek-prev {\n @include icon-override(\"\\f104\");\n width: 6px;\n overflow: hidden;\n font-size: 16px;\n font-weight: bold;\n padding-top: 0;\n height: 16px;\n }\n }\n }\n \n .ui-paginator-next {\n border-bottom: 5px solid #fff;\n \n .ui-icon {\n &.ui-icon-seek-next {\n @include icon-override(\"\\f105\");\n width: 6px;\n overflow: hidden;\n font-size: 16px;\n font-weight: bold;\n height: 16px;\n }\n }\n }\n \n .ui-paginator-last {\n border-bottom: 5px solid #fff;\n \n .ui-icon {\n &.ui-icon-seek-end {\n @include icon-override(\"\\f101\");\n width: 10px;\n overflow: hidden;\n font-size: 16px;\n font-weight: bold;\n height: 16px;\n } \n }\n }\n\n .ui-paginator-current {\n color: $greyDark;\n }\n \n .ui-paginator-pages {\n vertical-align: middle;\n \n .ui-paginator-page {\n @include border-radius(0);\n \n &.ui-state-default {\n border: none;\n color: $greyDark;\n border-bottom: 5px solid transparent;\n }\n \n &.ui-state-hover {\n border: none;\n background: none;\n border-bottom: 5px solid $grey;\n }\n \n &.ui-state-active {\n border: none;\n background: none;\n border-bottom: 5px solid $regularColor;\n }\n }\n }\n \n > .ui-paginator-rpp-options {\n &.ui-state-hover {\n border: 0 none;\n }\n }\n }\n}\n\n/* DATALIST */\n.ui-datalist {\n .ui-paginator {\n &.ui-widget-header {\n border-color: $grey;\n }\n }\n .ui-datalist-header {\n &.ui-widget-header {\n background: $blackLight;\n }\n }\n}\n\n/* DataView */\n.ui-dataview {\n .ui-paginator {\n @include border-radius(0);\n \n &.ui-widget-header {\n border-color: $grey;\n }\n }\n \n .ui-dataview-header {\n background: $blackLight;\n \n .ui-dataview-layout-options {\n .ui-button-icon-only {\n width: 2.5em;\n }\n }\n }\n}\n \n/* PickList */\n.ui-picklist {\n .ui-picklist-list {\n .ui-picklist-item {\n border-left: 5px solid transparent;\n border-radius: 0;\n margin: 0;\n \n &.ui-state-hover {\n background-color: $grey;\n border-color: $greyDark;\n color: #fff;\n }\n \n &.ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n color: #fff;\n \n .ui-chkbox {\n .ui-chkbox-box {\n border-color: #f6bb4e;\n }\n }\n }\n }\n }\n .ui-picklist-buttons {\n .ui-icon {\n font-size: 16px;\n }\n .ui-icon-arrow-1-n {\n @include icon-override(\"\\f106\");\n }\n \n .ui-icon-arrowstop-1-n {\n @include icon-override(\"\\f102\");\n }\n \n .ui-icon-arrow-1-s {\n @include icon-override(\"\\f107\");\n }\n \n .ui-icon-arrowstop-1-s {\n @include icon-override(\"\\f103\");\n }\n \n .ui-icon-arrow-1-e {\n @include icon-override(\"\\f105\");\n }\n \n .ui-icon-arrowstop-1-e {\n @include icon-override(\"\\f101\");\n }\n \n .ui-icon-arrow-1-w {\n @include icon-override(\"\\f104\");\n }\n \n .ui-icon-arrowstop-1-w {\n @include icon-override(\"\\f100\");\n }\n }\n\n .ui-picklist-filter-container {\n .ui-icon {\n @include icon-override(\"\\f002\");\n font-size: 14px;\n color: $greyDark;\n padding-top: 2px;\n }\n \n .ui-picklist-caption {\n &.ui-widget-header {\n background: $blackLight;\n }\n }\n \n .ui-picklist-list {\n &.ui-widget-content {\n .ui-picklist-item {\n border-left: 3px solid transparent;\n border-radius: 0;\n margin: 0;\n \n &.ui-state-hover {\n background: $grey;\n color: #fff;\n border-color: $greyDark;\n }\n \n &.ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n color: #fff;\n }\n }\n }\n }\n }\n}\n\n@media (max-width : 640px) {\n .ui-picklist {\n .ui-picklist-buttons {\n .ui-icon-arrow-1-e {\n @include icon-override(\"\\f107\");\n }\n \n .ui-icon-arrowstop-1-e {\n @include icon-override(\"\\f103\");\n }\n \n .ui-icon-arrow-1-w {\n @include icon-override(\"\\f106\");\n }\n \n .ui-icon-arrowstop-1-w {\n @include icon-override(\"\\f102\");\n }\n }\n }\n}\n\n/* OrderList */\n.ui-orderlist {\n .ui-orderlist-controls { \n .ui-button {\n &.ui-button-icon-only {\n .ui-button-icon-left {\n &.ui-icon-arrow-1-n {\n @include icon-override(\"\\f106\");\n font-size: 16px;\n color: #fff;\n }\n \n &.ui-icon-arrowstop-1-n {\n @include icon-override(\"\\f102\");\n font-size: 16px;\n color: #fff;\n }\n \n &.ui-icon-arrow-1-s {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n }\n \n &.ui-icon-arrowstop-1-s {\n @include icon-override(\"\\f103\");\n font-size: 16px;\n color: #fff;\n }\n }\n }\n }\n }\n \n &.ui-grid-responsive {\n .ui-grid-row {\n .ui-orderlist-controls {\n margin-right: 0;\n padding-right: 10px;\n }\n }\n }\n \n .ui-orderlist-caption {\n &.ui-widget-header {\n background: $blackLight;\n width: 200px;\n }\n }\n .ui-orderlist-list {\n &.ui-widget-content {\n .ui-orderlist-item {\n border-left: 5px solid transparent;\n border-radius: 0;\n margin: 0;\n \n &.ui-state-hover {\n background-color: $grey;\n border-color: $greyDark;\n color: #fff;\n }\n \n &.ui-state-highlight {\n background: $regularColor;\n border-color: $darkColor;\n color: #fff;\n }\n }\n }\n }\n}\n\n/* Carousel */\n.ui-carousel {\n &.ui-widget {\n padding: 0;\n }\n .ui-carousel-header {\n &.ui-widget-header {\n background: $blackLight;\n border: none;\n margin: 0;\n border-radius: 0;\n \n .ui-carousel-button {\n &.ui-icon-circle-triangle-e {\n @include icon-override(\"\\f0a9\");\n font-size: 16px;\n color: #fff;\n padding: 0 0 2px 4px;\n }\n \n &.ui-icon-circle-triangle-w {\n @include icon-override(\"\\f0a8\");\n font-size: 16px;\n color: #fff;\n padding: 0 0 2px 4px;\n }\n }\n }\n .ui-carousel-page-links {\n margin-top: 3.4px;\n \n .ui-icon-radio-off {\n @include icon-override(\"\\f10c\");\n text-decoration: none;\n }\n \n .ui-icon-radio-on {\n @include icon-override(\"\\f111\");\n color: $regularColor;\n }\n }\n }\n .ui-carousel-viewport {\n .ui-carousel-items {\n .ui-carousel-item {\n &.ui-widget-content {\n border: 1px solid $greyBorder;\n padding-top: 35px;\n }\n }\n }\n }\n .ui-carousel-footer {\n &.ui-widget-header {\n margin: 0;\n @include border-radius(0);\n }\n }\n}\n\n/* Tree */\n.ui-tree {\n .ui-treenode {\n .ui-treenode-content {\n .ui-tree-toggler {\n &.ui-icon {\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n font-size: 14px;\n color: $blackLight;\n text-align: center;\n vertical-align: middle;\n }\n\n &.ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n font-size: 14px;\n color: $blackLight;\n text-align: center;\n vertical-align: middle;\n }\n }\n }\n\n .ui-treenode-icon {\n vertical-align: middle;\n margin-top: 2px;\n margin-left: 5px;\n }\n\n .ui-treenode-label {\n margin-top: 0px;\n vertical-align: middle;\n }\n\n .ui-chkbox {\n vertical-align: middle;\n\n .ui-icon-minus {\n @include icon-override(\"\\f068\");\n color: $regularColor;\n padding-left: 1px;\n visibility: visible;\n }\n\n .ui-icon-check {\n color: $regularColor;\n visibility: visible;\n }\n }\n }\n }\n}\n\n/* TreeTable */\n.ui-treetable {\n .ui-treetable-header {\n &.ui-widget-header {\n background: $blackLight;\n }\n }\n \n &.ui-treetable-scrollable {\n .ui-treetable-scrollable-header {\n background-color: $greyLight;\n }\n }\n \n th.ui-state-default {\n background: $greyLight;\n border-color: $greyBorder;\n color: $blackLight;\n \n &.ui-sortable-column {\n .ui-sortable-column-icon {\n &.ui-icon-carat-2-n-s {\n font-size: 12px;\n color: $grey;\n padding: 3px 0 0 3px;\n vertical-align: middle;\n }\n \n &.ui-icon-triangle-1-n {\n font-size: 12px;\n color: $grey;\n padding: 3px 0 0 3px;\n vertical-align: middle;\n }\n \n &.ui-icon-triangle-1-s {\n font-size: 12px;\n color: $grey;\n padding: 3px 0 0 3px;\n vertical-align: middle;\n }\n }\n \n &.ui-state-active {\n background: $regularColor;\n color: #fff;\n .ui-sortable-column-icon {\n &.ui-icon {\n &.ui-icon-carat-2-n-s {\n &:before {\n color: #fff;\n }\n }\n \n &.ui-icon-triangle-1-n:before {\n color: #fff;\n }\n \n &.ui-icon-triangle-1-s:before {\n color: #fff;\n }\n }\n }\n }\n }\n }\n \n tbody {\n &.ui-treetable-data {\n tr.ui-widget-content {\n box-sizing: border-box;\n border-color: $greyBorder;\n \n &.ui-treetable-selectable-node {\n .ui-chkbox {\n &.ui-selection {\n margin-left: 2px;\n margin-right: 4px;\n vertical-align: middle;\n \n .ui-chkbox-box {\n .ui-icon-check {\n visibility: visible;\n }\n \n .ui-icon-minus {\n @include icon-override(\"\\f068\");\n visibility: visible;\n color: $regularColor;\n padding-left: 2px;\n padding-top: 1px;\n }\n }\n }\n }\n \n .ui-treetable-toggler {\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n font-size: 14px;\n padding: 3px 0 0 5px;\n width: 10px;\n }\n \n &.ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n font-size: 14px;\n padding: 3px 0 0 5px;\n width: 10px;\n }\n }\n }\n \n &.ui-state-hover {\n background-color: $grey;\n color: #fff;\n }\n \n &.ui-state-highlight {\n .ui-chkbox-box {\n .ui-icon-check {\n color: $regularColor;\n }\n }\n }\n }\n }\n }\n \n .ui-paginator.ui-paginator-bottom {\n border-top: 1px solid $greyBorder;\n }\n}\n\n/* ====== PANELS ======*/\n/* Panel */\n.ui-panel {\n &.ui-widget-content {\n padding: 0px;\n }\n \n .ui-panel-titlebar {\n padding: 0px;\n -moz-border-radius-topleft: 2px;\n -webkit-border-top-left-radius: 2px;\n border-top-left-radius: 2px;\n -moz-border-radius-topright: 2px;\n -webkit-border-top-right-radius: 2px;\n border-top-right-radius: 2px;\n -moz-border-radius-bottomleft: 0px;\n -webkit-border-bottom-left-radius: 0px;\n border-bottom-left-radius: 0px;\n -moz-border-radius-bottomright: 0px;\n -webkit-border-bottom-right-radius: 0px;\n border-bottom-right-radius: 0px;\n \n .ui-panel-titlebar-icon {\n height: 16px;\n \n .ui-icon {\n text-align: center;\n display: inline-block;\n padding-top: 2px;\n }\n }\n }\n}\n\n/* Accordion */\n.ui-accordion {\n .ui-accordion-header {\n border-left: 5px solid transparent;\n &.ui-state-default {\n background: $greyLight;\n color: #fff;\n .ui-icon {\n margin-top: -10px;\n \n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n font-size: 16px;\n color: #fff;\n padding-left: 8px;\n }\n }\n }\n \n &.ui-state-hover {\n background: $darkColor;\n .ui-icon {\n background-image: none;\n }\n }\n \n &.ui-state-active {\n background: $regularColor;\n border-color: $darkColor;\n .ui-icon {\n &.ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n font-size: 16px;\n color: #fff;\n padding-left: 5px;\n }\n }\n }\n }\n}\n\n/* TabView */\n.ui-tabs {\n &.ui-tabs-scrollable {\n .ui-icon {\n &.ui-icon-carat-1-w {\n @include icon-override(\"\\f053\");\n margin: 7px 0 0 7px;\n }\n &.ui-icon-carat-1-e {\n @include icon-override(\"\\f054\");\n margin: 7px 0 0 7px;\n }\n }\n }\n \n &.ui-tabs-top {\n padding: 0;\n \n .ui-tabs-nav {\n &.ui-widget-header {\n padding: 0;\n \n .ui-state-default {\n top: 0;\n border: none;\n border-bottom: 5px solid $blackLight;\n background: $blackLight;\n margin: 0;\n border-radius: 0;\n \n .ui-icon-close {\n @include icon-override(\"\\f00d\");\n font-size: 12px;\n color: $grey;\n margin-top:2px;\n }\n \n a {\n outline: 0 none;\n color: #fff;\n }\n \n &.ui-tabs-selected {\n background: $regularColor;\n border-color: $darkColor;\n \n &.ui-state-hover {\n background: $regularColor;\n border-color: $darkColor;\n }\n .ui-icon {\n &:before {\n color: #fff;\n }\n }\n }\n \n &.ui-state-hover {\n background: $grey;\n border-color: $greyDark;\n \n .ui-icon {\n &:before {\n color: #fff;\n }\n }\n }\n }\n }\n }\n }\n \n &.ui-tabs-left {\n padding: 0;\n .ui-tabs-nav {\n padding: 0;\n .ui-state-default {\n margin: 0;\n background: $blackLight;\n border: none;\n border-bottom: 5px solid transparent; \n width: 100%;\n border-radius: 0;\n \n a {\n outline: 0 none;\n color: #fff;\n }\n \n &.ui-tabs-selected {\n &.ui-state-active {\n background: $regularColor;\n border-bottom: 5px solid $darkColor;\n }\n }\n \n &.ui-state-hover {\n background: $grey;\n border-color: $greyDark;\n }\n }\n }\n }\n \n &.ui-tabs-bottom {\n .ui-tabs-nav {\n &.ui-widget-header {\n .ui-state-default {\n background: $blackLight;\n margin: 0;\n border: none;\n border-bottom: 5px solid transparent;\n \n a {\n outline: 0 none;\n color: #fff;\n }\n \n &.ui-tabs-selected {\n &.ui-state-active {\n background: $regularColor;\n border-color: $darkColor;\n }\n }\n \n &.ui-state-hover {\n background: $grey;\n border-color: $greyDark;\n }\n }\n }\n }\n }\n}\n\n/* Ribbon */\n.ui-ribbon {\n .ui-button {\n &.ui-state-default {\n background: $regularColor;\n }\n }\n}\n\n/* ToolBar */\n.ui-toolbar {\n background: $blackLight;\n \n &.ui-widget-header {\n border-color: $greyLight;\n }\n \n .ui-separator {\n margin-right: 5px;\n }\n}\n\n/* FieldSet */\n.ui-fieldset {\n &.ui-widget-content {\n .ui-fieldset-legend {\n &.ui-state-default {\n background: $blackLight;\n color: #fff;\n }\n \n .ui-fieldset-toggler {\n margin-top: 0.1em;\n \n &.ui-icon-minusthick {\n @include icon-override(\"\\f068\");\n }\n \n &.ui-icon-plusthick {\n @include icon-override(\"\\f067\");\n }\n }\n }\n }\n}\n\n/* ====== MENUs ======*/\n/* Breadcrumb */\n.ui-breadcrumb {\n &.ui-widget-header {\n background: $blackLight;\n border-color: $black;\n color: #fff;\n \n ul {\n .ui-menuitem-link {\n text-decoration: none;\n margin-top: 5px;\n \n &.ui-icon-home {\n @include icon-override(\"\\f015\");\n font-size: 12px;\n color: $greyLight;\n text-align: center;\n margin-top: 7px;\n overflow: hidden;\n height: 12px;\n }\n \n .ui-menuitem-text {\n color: $greyLight;\n }\n }\n \n .ui-breadcrumb-chevron {\n @include icon-override(\"\\f054\");\n font-size: 12px;\n color: $greyLight;\n text-align: center;\n margin-top: 7px;\n }\n }\n }\n}\n\n/* MENU */\n.ui-menu {\n &.ui-widget {\n /* menu button specific */ \n .ui-menuitem {\n &.ui-state-hover {\n background: $greyLight;\n color: $blackLight;\n border-color: transparent;\n \n .ui-menuitem-link {\n color: $blackLight;\n }\n }\n }\n \n .ui-menuitem-link {\n width:100%;\n box-sizing: border-box;\n padding-left: 8px;\n @include border-radius(0);\n \n &.ui-state-hover {\n background: $greyLight;\n color: $blackLight;\n border-color: transparent;\n }\n }\n }\n\n .ui-menu-list {\n li.ui-widget-header {\n margin: 0;\n width: 100%;\n border-radius: 0;\n box-sizing: border-box;\n\n h3 {\n padding-left: 8px;\n }\n \n .ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n color: #fff;\n padding-left: 4px;\n }\n \n .ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n color: #fff;\n padding-left: 4px;\n }\n \n &.ui-state-hover {\n color: $regularColor;\n background-color: $blackLight;\n .ui-icon {\n &.ui-icon-triangle-1-s:before {\n color: $regularColor;\n }\n \n &.ui-icon-triangle-1-e:before {\n color: $regularColor;\n }\n }\n }\n }\n }\n \n &.ui-menubar {\n .ui-menuitem {\n &.ui-menubar-options {\n padding: 2px;\n }\n \n .ui-inputfield {\n &.ui-inputtext {\n width: inherit;\n }\n }\n \n .ui-menuitem-link {\n .ui-menuitem-icon {\n &.ui-icon:before {\n color: $regularColor;\n }\n }\n \n .ui-menuitem-icon {\n margin-right: 5px;\n }\n \n .ui-icon-triangle-1-e {\n @include icon-override(\"\\f054\");\n font-size: 12px;\n color: $grey;\n margin: 2px -5px 0 5px;\n }\n \n .ui-icon-triangle-1-s {\n @include icon-override(\"\\f078\");\n font-size: 12px;\n color: $grey;\n margin: 2px -5px 0 5px;\n }\n }\n }\n \n .ui-menu-list {\n &.ui-menu-child {\n .ui-menuitem-link {\n width:100%;\n box-sizing: border-box;\n padding: .3em 0 .3em .3em;\n }\n }\n }\n }\n \n &.ui-tieredmenu {\n .ui-menu-list {\n .ui-menuitem {\n &.ui-menu-parent {\n margin: 0;\n \n &.ui-menuitem-active {\n background: $regularColor;\n \n a {\n color: $blackLight;\n .ui-icon {\n &.ui-icon-triangle-1-e:before {\n color: $blackLight;\n }\n }\n }\n }\n .ui-icon {\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f054\");\n font-size: 12px;\n color: $grey;\n margin-right: -5px;\n margin-top: 2px;\n }\n }\n }\n }\n }\n }\n &.ui-slidemenu {\n .ui-slidemenu-wrapper {\n .ui-slidemenu-content {\n .ui-menu-list {\n .ui-menuitem {\n &.ui-menu-parent {\n .ui-icon {\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n font-size: 12px;\n color: $grey;\n padding-left: 4px;\n }\n }\n }\n }\n }\n }\n .ui-slidemenu-backward {\n width: 97.5%;\n border-radius: 0;\n margin-bottom: 0;\n }\n }\n }\n}\n\n/* MenuButton */\n.ui-menubutton {\n .ui-button {\n .ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n margin-top: -6px;\n }\n }\n}\n\n.ui-panelmenu {\n .ui-panelmenu-header {\n &.ui-state-default {\n background-color: $blackLight;\n a {\n color: #fff;\n padding-left: 2em;\n }\n \n .ui-icon {\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n font-size: 14px;\n color: #fff;\n margin-left: 4px;\n }\n \n &.ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n font-size: 14px;\n color: #fff;\n margin-left: 4px;\n }\n }\n }\n &.ui-state-hover {\n a {\n color: $regularColor;\n }\n \n .ui-icon {\n &.ui-icon-triangle-1-e {\n &:before {\n color: $regularColor;\n }\n }\n \n &.ui-icon-triangle-1-s {\n background-image: none;\n &:before {\n color: $regularColor;\n }\n }\n }\n }\n &.ui-state-active {\n background-color: $regularColor;\n \n .ui-icon {\n &.ui-icon-triangle-1-e {\n &:before {\n color: #fff;\n }\n }\n \n &.ui-icon-triangle-1-s {\n background-image: none;\n &:before {\n color: #fff;\n }\n }\n }\n }\n }\n \n .ui-panelmenu-icon {\n background-image: none;\n color: $blackLight;\n width:20px;\n padding-left:4px;\n\n &.ui-icon-triangle-1-e {\n @include icon-override(\"\\f105\");\n }\n \n &.ui-icon-triangle-1-s {\n @include icon-override(\"\\f107\");\n }\n }\n \n .ui-menuitem-link {\n width:100%;\n box-sizing: border-box;\n @include border-radius(0);\n padding: .3em 0em .3em .8em;\n \n &.ui-state-hover {\n color: $blackLight;\n background: $greyLight;\n border-color: transparent;\n }\n }\n}\n\n/* TabMenu */\n.ui-tabmenu {\n &.ui-widget-content {\n border: none;\n .ui-tabmenu-nav {\n &.ui-widget-header {\n padding: 0;\n background: transparent;\n \n li {\n background: transparent;\n border: none;\n border-bottom: 5px solid transparent;\n margin: 0;\n top: 0;\n \n a {\n padding: 0.7em 1em 0.5em 0.2em;\n }\n \n .ui-menuitem-text {\n color: $greyDark;\n margin-top: 13px;\n }\n \n .ui-menuitem-icon {\n color: $greyDark;\n }\n \n &.ui-state-active {\n border-color: $darkColor;\n }\n \n &.ui-state-hover {\n border-color: $grey;\n }\n }\n }\n }\n }\n}\n\n/* Steps */\n.ui-steps {\n &.ui-widget {\n margin-bottom: 30px;\n @include border-radius(3px);\n \n .ui-steps-item {\n \n .ui-menuitem-link {\n height: 10px;\n padding: 0 1em;\n }\n \n .ui-steps-number {\n background-color: $lightColor;\n color: #fff;\n display: inline-block;\n width: 30px;\n border-radius: 10px;\n margin-top: -14px;\n margin-bottom: 10px;\n }\n \n &.ui-state-highlight {\n .ui-steps-title {\n color: $blackLight;\n }\n }\n }\n }\n}\n\n/* MegaMenu */\n.ui-megamenu {\n \n &.ui-megamenu-vertical {\n .ui-menuitem {\n width: 100%; \n }\n \n .ui-submenu-link {\n &.ui-menuitem-link {\n width:100%;\n box-sizing: border-box;\n \n &.ui-state-hover {\n background: $greyLight;\n border-color: transparent;\n }\n }\n }\n }\n \n .ui-menu-list {\n .ui-widget-header { \n span {\n padding-left: 8px;\n }\n }\n }\n}\n\n/* Scroll Panel*/\n.ui-scrollpanel-container {\n .ui-scrollpanel-drag {\n &.ui-state-highlight {\n background: $regularColor;\n }\n }\n}\n\n/* FileUpload */\n.ui-fileupload {\n .ui-button-text-icon-left {\n .ui-icon {\n margin-top: -6px;\n }\n }\n \n .ui-icon-plusthick {\n @include icon-override(\"\\f067\");\n }\n \n .ui-icon-arrowreturnthick-1-n {\n @include icon-override(\"\\f093\");\n }\n \n .ui-icon-cancel {\n @include icon-override(\"\\f00d\");\n }\n \n .ui-icon-close {\n @include icon-override(\"\\f00d\");\n }\n}\n\n.ui-fileupload-simple {\n .ui-icon-plusthick {\n @include icon-override(\"\\f067\");\n }\n}\n\n/* ProgressBar */\n.ui-progressbar {\n .ui-progressbar-value {\n background-color: $lightColor;\n }\n}\n\n/* Messages */\n.ui-messages {\n &.ui-widget {\n ul {\n display: inline-block;\n margin-left: 0;\n }\n }\n}\n\n/* Info */\n.ui-messages .ui-messages-info, .ui-message.ui-message-info {\n color: #fff;\n background: $info;\n border-color: $info;\n}\n\n.ui-messages .ui-messages-info-icon,.ui-message .ui-message-info-icon {\n @include icon-override(\"\\f05a\");\n font-size: 20px;\n color: #fff;\n padding: 4px;\n}\n\n.ui-message .ui-message-info-icon {\n padding: 0px;\n font-size: 18px;\n}\n\n/* Error */\n.ui-messages .ui-messages-error, .ui-message.ui-message-error {\n color: #fff;\n background: $error;\n border-color: $error;\n}\n\n.ui-messages .ui-messages-error-icon,.ui-message .ui-message-error-icon {\n @include icon-override(\"\\f056\");\n font-size: 20px;\n color: #fff;\n padding: 4px;\n}\n\n.ui-message .ui-message-error-icon {\n padding: 0px;\n font-size: 18px;\n}\n\n/* Warn */\n.ui-messages .ui-messages-warn, .ui-message.ui-message-warn {\n color: #fff;\n background: $warning;\n border-color: $warning;\n}\n\n.ui-messages .ui-messages-warn-icon,.ui-message .ui-message-warn-icon {\n @include icon-override(\"\\f071\");\n font-size: 20px;\n color: #fff;\n padding: 4px;\n}\n\n.ui-message .ui-message-warn-icon {\n padding: 0px;\n font-size: 18px;\n}\n\n/* Fatal */\n.ui-messages .ui-messages-fatal, .ui-message.ui-message-fatal {\n color: #fff;\n background: $error;\n border-color: $error;\n}\n\n.ui-messages .ui-messages-fatal-icon,.ui-message .ui-message-fatal-icon {\n @include icon-override(\"\\f056\");\n font-size: 20px;\n color: #fff;\n padding: 4px;\n}\n\n.ui-message .ui-message-fatal-icon {\n padding: 0px;\n font-size: 18px;\n}\n\n.ui-messages-close {\n span {\n @include icon-override(\"\\f00d\");\n font-size: 14px;\n color: #fff;\n }\n}\n\n/* Growl */\n.ui-growl {\n .ui-state-highlight {\n &.ui-growl-info {\n color: #fff;\n background: $info;\n border-color: $info;\n \n .ui-growl-image-info {\n @include icon-override(\"\\f05a\");\n font-size: 36px;\n color: #fff;\n padding: 4px;\n }\n }\n \n &.ui-growl-error {\n color: #fff;\n background: $error;\n border-color: $error;\n \n .ui-growl-image-error {\n @include icon-override(\"\\f056\");\n font-size: 36px;\n color: #fff;\n padding: 4px;\n }\n }\n \n &.ui-growl-warn {\n color: #fff;\n background: $warning;\n border-color: $warning;\n \n .ui-growl-image-warn {\n @include icon-override(\"\\f071\");\n font-size: 36px;\n color: #fff;\n padding: 4px;\n }\n }\n \n &.ui-growl-fatal {\n color: #fff;\n background: $error;\n border-color: $error;\n \n .ui-growl-image-fatal {\n @include icon-override(\"\\f056\");\n font-size: 36px;\n color: #fff;\n padding: 4px;\n }\n }\n }\n \n .ui-growl-icon-close {\n @include icon-override(\"\\f00d\");\n font-size: 14px;\n color: #fff;\n }\n}\n\n/* Schedule */\n.fc {\n .ui-button {\n &.ui-state-default {\n width: auto;\n }\n }\n &.fc-ltr {\n .ui-widget-content {\n background-color: #ffffff;\n .ui-state-highlight {\n background: $lightColor;\n border-color: $regularColor;\n }\n }\n \n .fc-event {\n background: $greenLight;\n border-color: $greenLight;\n }\n \n .fc-view-container {\n .fc-view {\n .ui-widget-header {\n background: $lightColor;\n border-color: $greyLight;\n }\n }\n }\n \n .fc-toolbar {\n background: $blackLight;\n margin-bottom: 0;\n padding: 40px 0;\n color: #fff;\n .ui-button {\n &.ui-state-default {\n background: $blackLight;\n border-color: $blackLight;\n color: #fff;\n }\n \n &.ui-state-active {\n color: $regularColor;\n }\n }\n \n .fc-prev-button {\n .ui-icon {\n @include icon-override(\"\\f060\");\n font-size: 16px;\n color: #fff;\n }\n }\n \n .fc-next-button {\n .ui-icon {\n @include icon-override(\"\\f061\");\n font-size: 16px;\n color: #fff;\n }\n }\n }\n }\n td, th {\n border-color: $greyLight;\n }\n}\n\n/* Dialog */\n.ui-dialog {\n .ui-dialog-titlebar {\n @include border-radius-top(0);\n \n &.ui-widget-header {\n border-bottom: 5px solid $regularColor;\n }\n \n .ui-dialog-titlebar-icon {\n text-decoration: none;\n width: 16px;\n margin-top: .3em;\n \n &.ui-state-hover {\n color: $regularColor;\n border-color: transparent;\n background-color: transparent;\n }\n }\n \n .ui-dialog-titlebar-close {\n span {\n @include icon-override(\"\\f00d\");\n }\n }\n \n .ui-dialog-titlebar-maximize {\n .ui-icon-extlink {\n @include icon-override(\"\\f065\");\n }\n \n .ui-icon-newwin {\n @include icon-override(\"\\f066\");\n }\n }\n \n .ui-dialog-titlebar-minimize {\n .ui-icon-minus {\n @include icon-override(\"\\f068\");\n }\n \n .ui-icon-plus {\n @include icon-override(\"\\f067\");\n }\n }\n }\n \n > .ui-icon-gripsmall-diagonal-se {\n @include icon-override(\"\\f065\");\n opacity: .5;\n -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n -webkit-transform: rotate(90deg);\n -ms-transform: rotate(90deg);\n transform: rotate(90deg);\n }\n \n}\n\n.ui-confirm-dialog {\n .ui-confirm-dialog-severity {\n float: none;\n vertical-align: middle;\n margin-right: 10px;\n \n &.ui-icon-alert {\n @include icon-override(\"\\f071\");\n font-size: 20px;\n width: 20px;\n height: 20px;\n }\n }\n \n .ui-confirm-dialog-message {\n vertical-align: middle;\n margin-top: 0px;\n }\n}\n\n/*sidebar*/\n.ui-sidebar {\n .ui-sidebar-close {\n &:hover {\n padding: 1px;\n }\n }\n\n .ui-button {\n width: auto;\n }\n}\n\n/* Lightbox */\n.ui-lightbox {\n .ui-lightbox-nav-left {\n height: 30px;\n \n .ui-icon-carat-1-w {\n @include icon-override(\"\\f053\");\n width: 10px;\n margin-top: 8px;\n }\n }\n \n .ui-lightbox-nav-right {\n height: 30px;\n \n .ui-icon-carat-1-e {\n @include icon-override(\"\\f054\");\n width: 10px;\n margin-top: 8px;\n }\n }\n \n .ui-lightbox-caption {\n .ui-lightbox-close {\n .ui-icon-closethick {\n @include icon-override(\"\\f00d\");\n margin-top: 5px;\n }\n \n &.ui-state-hover {\n color: $regularColor;\n border-color: transparent;\n background-color: transparent;\n }\n }\n }\n}\n\n.ui-galleria {\n .ui-galleria-nav-prev {\n &.ui-icon-circle-triangle-w {\n @include icon-override(\"\\f0a8\");\n \n &:hover {\n color: $regularColor;\n }\n }\n }\n .ui-galleria-nav-next {\n &.ui-icon-circle-triangle-e {\n @include icon-override(\"\\f0a9\");\n \n &:hover {\n color: $regularColor;\n }\n }\n }\n}\n\n.ui-panelgrid {\n &.ui-panelgrid-blank {\n .ui-grid-responsive {\n .ui-grid-row {\n border: 0 none;\n }\n }\n }\n}\n\n.ui-overlaypanel {\n .ui-overlaypanel-close {\n height: 16px;\n \n .ui-icon {\n text-align: center;\n display: inline-block;\n }\n }\n}\n\n.ui-columntoggler {\n .ui-columntoggler-close {\n height: 16px;\n \n .ui-icon {\n text-align: center;\n display: inline-block;\n }\n }\n}\n\n.ui-fluid {\n .ui-wizard-navbar { \n .ui-button {\n width: auto;\n }\n }\n}\n\n@import '../_theme_styles.scss';package generator.model;\n\npublic enum Nature {\n\tPROFESSIONAL_EXPERIENCE,\n\tEDUCATION,\n\tPROJECT,\n\tOTHER;\n}\npackage generator.services;\n\nimport java.time.LocalDate;\n\nimport org.apache.commons.lang3.RandomUtils;\n\nimport com.thedeanda.lorem.Lorem;\nimport com.thedeanda.lorem.LoremIpsum;\n\nimport generator.model.Activity;\nimport generator.model.Nature;\nimport generator.model.Person;\n\npublic class RandomActivityFactory {\n\n\tprivate Lorem lorem = LoremIpsum.getInstance();\n\tprivate static int availableId = 1;\n\n\tprivate final static int MIN_AGE = 16;\n\n\tpublic Activity create(Person owner) {\n\t\tActivity activity = new Activity();\n\n\t\tactivity.setId(createId());\n\t\tactivity.setOwner(owner);\n\t\tactivity.setYear(createYear(owner));\n\t\tactivity.setTitle(createTitle());\n\t\tactivity.setDescription(createDescription());\n\t\tactivity.setWebAddress(createWebAddress(activity.getTitle()));\n\t\tactivity.setNature(createNature());\n\n\t\treturn activity;\n\t}\n\n\tprivate int createId() {\n\t\treturn availableId++;\n\t}\n\n\tpublic int createYear(Person owner) {\n\t\tint minYear = owner.getDateOfBirth().getYear() + MIN_AGE;\n\t\tint maxYear = LocalDate.now().getYear();\n\n\t\treturn RandomUtils.nextInt(minYear, maxYear - 1);\n\t}\n\n\tpublic String createTitle() {\n\t\treturn lorem.getTitle(2, 4);\n\t}\n\n\tpublic String createDescription() {\n\t\treturn lorem.getHtmlParagraphs(2, 3);\n\t}\n\n\tprivate String createWebAddress(String title) {\n\t\tString escapedTitle = title.replace(' ', '-').toLowerCase();\n\t\treturn \"https://www.\" + escapedTitle + \".com\";\n\t}\n\n\tprivate Nature createNature() {\n\t\tNature[] natures = Nature.values();\n\t\tint randomIndex = RandomUtils.nextInt(0, natures.length);\n\t\treturn natures[randomIndex];\n\t}\n}\npackage generator.model;\n\nimport java.io.Serializable;\n\nimport lombok.Getter;\nimport lombok.NoArgsConstructor;\nimport lombok.Setter;\n\n@Getter\n@Setter\n@NoArgsConstructor\n\npublic class Activity implements Serializable {\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate int id;\n\tprivate int year;\n\tprivate String title;\n\tprivate String description;\n\tprivate String webAddress;\n\tprivate Nature nature;\n\tprivate Person owner;\n}\n#------------------------------------------------------------\n# Script MySQL.\n#------------------------------------------------------------\n\n\n#------------------------------------------------------------\n# Table: Person\n#------------------------------------------------------------\n\nCREATE TABLE Person(\n id Int Auto_increment NOT NULL ,\n lastName Varchar (255) NOT NULL ,\n firstName Varchar (255) NOT NULL ,\n website Varchar (255) ,\n dateOfBirth Date NOT NULL ,\n password V (102) NOT NULL ,\n email Varchar (255) NOT NULL\n\t,CONSTRAINT Person_AK UNIQUE (email)\n\t,CONSTRAINT Person_PK PRIMARY KEY (id)\n)ENGINE=InnoDB;\n\n\n#------------------------------------------------------------\n# Table: Activity\n#------------------------------------------------------------\n\nCREATE TABLE Activity(\n id Int Auto_increment NOT NULL ,\n year Smallint NOT NULL ,\n title Varchar (255) NOT NULL ,\n description Varchar (10000) ,\n webAddress Varchar (255) ,\n nature Enum (\"PROFESSIONAL_EXPERIENCE\",\"EDUCATION\",\"PROJECT\",\"OTHER\") NOT NULL ,\n ownerId Int NOT NULL\n\t,CONSTRAINT Activity_PK PRIMARY KEY (id)\n\n\t,CONSTRAINT Activity_Person_FK FOREIGN KEY (ownerId) REFERENCES Person(id)\n)ENGINE=InnoDB;\n\npackage gestioncv.servicesTests;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.mockito.Mockito.doNothing;\nimport static org.mockito.Mockito.doReturn;\nimport static org.mockito.Mockito.verify;\n\nimport java.util.Collection;\nimport java.util.Collections;\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.extension.ExtendWith;\nimport org.mockito.InjectMocks;\nimport org.mockito.Spy;\nimport org.mockito.junit.jupiter.MockitoExtension;\n\nimport gestioncv.model.Activity;\nimport gestioncv.services.impl.ActivityDao;\n\n@ExtendWith(MockitoExtension.class)\npublic class ActivityDaoTest {\n\t\n\t@InjectMocks\n @Spy\n ActivityDao activityDao;\n\t\n\t@Test\n\tpublic void testFindAllSuccess() {\n\t\tCollection activities = Collections.singletonList(Activity.builder().id(10).build());\n\t\tdoReturn(activities).when(activityDao).findAll(Activity.class);\n\t\tactivityDao.findAll();\n\t\tverify(activityDao).findAll(Activity.class);\n\t}\n\t\n\t@Test\n\tpublic void testFind() {\n\t\tint id = 10 ;\n\t\tActivity activity = Activity.builder().id(id).build();\n\t\tdoReturn(activity).when(activityDao).find(id);\n\t\tActivity foundedActivity = activityDao.find(id);\n\t\tverify(activityDao).find(id);\n\t\tassertEquals(id, foundedActivity.getId());\n\t}\n\t\n\t@Test\n\tpublic void testRemove() {\n\t\tint id = 10 ;\n\t\tdoNothing().when(activityDao).remove(Activity.class,id);\n\t\tactivityDao.remove(id);\n\t\tverify(activityDao).remove(Activity.class,id);\n\n\t}\n\n\n}\n## Créer un compte administrateur et une BDD spécifiques au projet\n\nCréer un compte spécifique au projet permet d'éviter les fuites de mots de passe personnels et assure que chaque membre du projet partage la même version du fichier `persistence.xml`. \n\nLa procédure suivante indique comment créer une base de données pour le projet ainsi que son compte administrateur :\n\n1. Se connecter au CLI mysql\n\n ```bash\n $ sudo mysql\n ```\n\n2. Créer la base de données du projet\n\n ```mysql\n CREATE DATABASE Gestion-de-CVs;\n ```\n\n3. Créer l'utilisateur `gestion-cv-admin`\n\n ```mysql\n CREATE USER 'gestion-cv-admin'@'localhost' IDENTIFIED WITH caching_sha2_password BY '';\n ```\n\n > Il n'est pas nécessaire de modifier le mot de passe ``. Ce mot de passe n'est pas sensible, il est utilisé uniquement pour travailler temporairement en environnement de développement. Il peut donc être partagé sur Github sans problème.\n\n3. Attribuer à l'utilisateur tous les privilèges sur la base de données\n\n ```mysql\n GRANT ALL PRIVILEGES ON `Gestion-de-CVs`.* TO 'gestion-cv-admin'@'localhost';\n ```\n\n4. Appliquer les privilèges pour qu'ils soient fonctionnels immédiatement\n\n ```mysql\n FLUSH PRIVILEGES;\n ```\n\n## Préparer la base de données de développement\n\n### Créer le schéma des tables\n\nLe code SQL présent dans le fichier `database/databaseSetup.sql` décrit le schéma des tables de la base de données. Il a été généré à l'aide du logiciel JMerise et à partir du Modèle Conceptuel des Données suivant :\n\n\"MCD\"\n\nPour créer les tables en bases de données, se placer dans le dossier `database` et exécuter la commande suivante :\n\n```bash\n$ sudo mysql -p Gestion-de-CVs < databaseSetup.sql\n```\n\n### Peupler la base de données\n\nL'application à développer doit supporter environ 100 000 personnes (et leurs activités). Afin de vérifier cette contrainte, un générateur de personnes / activités a été développé et a permit de générer le fichier `database/insertQueries-0.sql`. La base de données peut ainsi être peuplée avec la commande suivante :\n\n```bash\n$ sudo mysql -p Gestion-de-CVs < insertQueries-0.sql\n```\n\n/** \n * PrimeFaces Icarus Layout\n */\nPrimeFaces.widget.Icarus = PrimeFaces.widget.BaseWidget.extend({\n \n init: function(cfg) {\n this._super(cfg);\n this.wrapper = $(document.body).children('.wrapper');\n this.menubar = $('#sidebar-wrapper');\n this.sidebarNav = this.menubar.children('.sidebar-nav');\n this.menubarElement = this.menubar.get(0);\n this.menubarContainer = this.menubar.find('ul.sidebar-nav-container');\n this.slimToggleButton = $('#slim-menu-button');\n this.content = $('#main-wrapper');\n this.menulinks = this.menubarContainer.find('a.menuLink');\n this.expandedMenuitems = this.expandedMenuitems || [];\n this.focusedItem = null;\n this.focusedTopItem = null;\n\n this.restoreMenuState();\n this.bindEvents();\n },\n \n toggleMenu: function() {\n if(this.isDesktop()) {\n this.wrapper.toggleClass('slim-menu');\n this.menubar.removeClass('normalize-menu');\n }\n else {\n this.menubar.toggleClass('normalize-menu');\n \n if(this.menubar.hasClass('normalize-menu'))\n this.wrapper.removeClass('slim-menu');\n else\n this.wrapper.addClass('slim-menu');\n }\n \n this.transitionControl();\n $(window).trigger('resize');\n },\n \n bindEvents: function() { \n var $this = this;\n \n this.sidebarNav.nanoScroller({flash: true});\n \n this.slimToggleButton.off('click.toggleButton').on('click.toggleButton', function(e) {\n $this.toggleMenu();\n e.preventDefault();\n });\n \n this.menulinks.off('click.menuLinks').on('click.menuLinks',function(e) {\n var menuitemLink = $(this),\n menuitem = menuitemLink.parent(),\n hasSubmenuContainer = menuitemLink.next().is('ul'),\n isActive = menuitem.hasClass('active-menu-parent');\n \n if($this.menubar.width() < 60) {\n $this.toggleMenu();\n \n if(!isActive) {\n $this.activateMenuitem(menuitem);\n }\n }\n else if(hasSubmenuContainer) {\n if(isActive)\n $this.deactivateMenuitem(menuitem);\n else\n $this.activateMenuitem(menuitem);\n }\n else if(!isActive) {\n $this.activateMenuitem(menuitem);\n }\n\n if(hasSubmenuContainer) {\n e.preventDefault();\n }\n\n $this.saveMenuState(); \n \n setTimeout(function() {\n $(\".nano\").nanoScroller();\n }, 750);\n });\n \n //remove transitions on IOS\n if(this.isIOS()) {\n this.menubar.find('a').addClass('notransition');\n }\n \n //workaround for firefox bug of not resetting scrolltop\n if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {\n $(window).on('resize', function() {\n $this.menubarElement.scrollTop = 0;\n });\n }\n \n $(document.body).on('click', function(e) {\n if(!$this.topbarLinkClick && $this.topbarItems) {\n $this.topbarItems.filter('.active').removeClass('active').children().removeClass('active-link');\n $this.profileImage.parent().removeClass('active');\n }\n $this.topbarLinkClick = false;\n \n });\n \n $(function() {\n $this.topbarItems = $('#top-bar').find('> .top-menu > .top-bar-icon');\n $this.topbarLinks = $this.topbarItems.find('> a');\n $this.topbarLinks.on('click', function(e) {\n $this.topbarLinkClick = true;\n var link = $(this),\n item = link.parent(),\n submenu = item.children('ul');\n \n item.siblings('.active').removeClass('active');\n $this.profileImage.parent().removeClass('active');\n \n if(submenu.length) {\n submenu.addClass('');\n item.toggleClass('active');\n link.toggleClass('active-link');\n e.preventDefault();\n }\n });\n \n $this.profileImage = $('#profile-image');\n $this.profileImageMobile = $('#profile-image-mobile');\n \n $this.profileImage.on('click', function(e) {\n $this.topbarLinkClick = true;\n var link = $(this);\n \n $this.topbarItems.filter('.active').removeClass('active').children().removeClass('active-link');\n \n link.parent().toggleClass('active');\n e.preventDefault();\n });\n \n $this.profileImageMobile.on('click', function(e) {\n $this.topbarLinkClick = true;\n var link = $(this);\n \n $this.topbarItems.filter('.active').removeClass('active').children().removeClass('active-link');\n \n link.parent().toggleClass('active');\n e.preventDefault();\n });\n });\n },\n \n deactivateSiblings: function(menuitem) {\n var activeSiblings = this.findActiveSiblings(menuitem),\n $this = this;\n \n for(var i = 0; i< activeSiblings.length; i++) {\n var activeSibling = activeSiblings[i];\n activeSibling.removeClass('active-menu-parent');\n this.removeMenuitem(activeSibling);\n\n activeSibling.find('ul.active-menu').slideUp(300, function() {\n $(this).removeClass('active-menu').removeAttr('style');\n });\n activeSibling.find('a.active-menu').removeClass('active-menu');\n activeSibling.find('li.active-menu-parent').each(function() {\n var menuitem = $(this);\n menuitem.removeClass('active-menu-parent');\n $this.removeMenuitem(menuitem);\n });\n }\n },\n \n activateMenuitem: function(menuitem) {\n this.deactivateSiblings(menuitem);\n menuitem.addClass('active-menu-parent').children('.menuLink').addClass('active-menu').next('ul').slideDown(300, function() {\n $(this).addClass('active-menu').removeAttr('style');\n });\n this.addMenuitem(menuitem.attr('id'));\n },\n \n deactivateMenuitem: function(menuitem) {\n menuitem.removeClass('active-menu-parent').children('.menuLink').removeClass('active-menu').next('ul').slideUp(300, function() {\n $(this).removeClass('active-menu').removeAttr('style');\n });\n this.removeMenuitem(menuitem);\n },\n \n findActiveSiblings: function(menuitem) {\n var $this = this,\n siblings = menuitem.siblings('li'),\n activeSiblings = [];\n \n siblings.each(function () {\n if ($.inArray($(this).attr('id'), $this.expandedMenuitems) !== -1 || $(this).hasClass('active-menu-parent')) {\n activeSiblings.push($(this));\n }\n });\n\n return activeSiblings;\n },\n \n restoreMenuState: function () {\n var menucookie = $.cookie('icarus_activemenuitem');\n if (menucookie) {\n this.expandedMenuitems = menucookie.split(',');\n for (var i = 0; i < this.expandedMenuitems.length; i++) {\n var id = this.expandedMenuitems[i];\n if (id) {\n var menuitem = $(\"#\" + this.expandedMenuitems[i].replace(/:/g, \"\\\\:\"));\n menuitem.addClass('active-menu-parent');\n menuitem.children('a').addClass('active-menu');\n menuitem.children('ul').addClass('active-menu');\n }\n }\n }\n },\n \n removeMenuitem: function (menuitem) {\n var id = menuitem.attr('id');\n this.expandedMenuitems = $.grep(this.expandedMenuitems, function (value) {\n return value !== id;\n });\n \n var submenu = menuitem.children('ul.sidebar-submenu-container');\n if(submenu && submenu.length) {\n var activeMenu = submenu.children('.active-menu-parent');\n if(activeMenu && activeMenu.length) {\n activeMenu.removeClass('active-menu-parent');\n activeMenu.children('a,ul').removeClass('active-menu');\n this.removeMenuitem(activeMenu);\n }\n }\n },\n \n addMenuitem: function (id) {\n if ($.inArray(id, this.expandedMenuitems) === -1) {\n this.expandedMenuitems.push(id);\n }\n },\n \n saveMenuState: function() {\n $.cookie('icarus_activemenuitem', this.expandedMenuitems.join(','), {path:'/'});\n },\n \n clearMenuState: function() {\n $.removeCookie('icarus_activemenuitem', {path:'/'});\n },\n \n isIOS: function() {\n return ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false );\n },\n \n closeMenu: function() {\n this.menubarContainer.find('.sidebar-submenu-container.active-menu').hide().removeClass('active-menu');\n this.menubarContainer.find('a.active-menu,li.active-menu-parent').removeClass('active-menu active-menu-parent');\n\n var nano = $(\".nano\");\n if(nano && nano.length) {\n $(\".nano\").nanoScroller({ stop: true });\n }\n },\n \n isTablet: function() {\n var width = window.innerWidth;\n return width <= 1024 && width > 640;\n },\n \n isDesktop: function() {\n return window.innerWidth > 1024;\n },\n \n isMobile: function() {\n return window.innerWidth <= 640;\n },\n \n transitionControl: function() {\n var $this = this;\n \n if(!this.isMobile()) {\n this.menubar.addClass('wrapperTransition');\n setTimeout(function(){\n $this.menubar.removeClass('wrapperTransition');\n },301);\n }\n }\n \n});\n\n/*!\n * jQuery Cookie Plugin v1.4.1\n * https://github.com/carhartl/jquery-cookie\n *\n * Copyright 2006, 2014 \n * Released under the MIT license\n */\n(function (factory) {\n\tif (typeof define === 'function' && define.amd) {\n\t\t// AMD (Register as an anonymous module)\n\t\tdefine(['jquery'], factory);\n\t} else if (typeof exports === 'object') {\n\t\t// Node/CommonJS\n\t\tmodule.exports = factory(require('jquery'));\n\t} else {\n\t\t// Browser globals\n\t\tfactory(jQuery);\n\t}\n}(function ($) {\n\n\tvar pluses = /\\+/g;\n\n\tfunction encode(s) {\n\t\treturn config.raw ? s : encodeURIComponent(s);\n\t}\n\n\tfunction decode(s) {\n\t\treturn config.raw ? s : decodeURIComponent(s);\n\t}\n\n\tfunction stringifyCookieValue(value) {\n\t\treturn encode(config.json ? JSON.stringify(value) : String(value));\n\t}\n\n\tfunction parseCookieValue(s) {\n\t\tif (s.indexOf('\"') === 0) {\n\t\t\t// This is a quoted cookie as according to RFC2068, unescape...\n\t\t\ts = s.slice(1, -1).replace(/\\\\\"/g, '\"').replace(/\\\\\\\\/g, '\\\\');\n\t\t}\n\n\t\ttry {\n\t\t\t// Replace server-side written pluses with spaces.\n\t\t\t// If we can't decode the cookie, ignore it, it's unusable.\n\t\t\t// If we can't parse the cookie, ignore it, it's unusable.\n\t\t\ts = decodeURIComponent(s.replace(pluses, ' '));\n\t\t\treturn config.json ? JSON.parse(s) : s;\n\t\t} catch(e) {}\n\t}\n\n\tfunction read(s, converter) {\n\t\tvar value = config.raw ? s : parseCookieValue(s);\n\t\treturn $.isFunction(converter) ? converter(value) : value;\n\t}\n\n\tvar config = $.cookie = function (key, value, options) {\n\n\t\t// Write\n\n\t\tif (arguments.length > 1 && !$.isFunction(value)) {\n\t\t\toptions = $.extend({}, config.defaults, options);\n\n\t\t\tif (typeof options.expires === 'number') {\n\t\t\t\tvar days = options.expires, t = options.expires = new Date();\n\t\t\t\tt.setMilliseconds(t.getMilliseconds() + days * 864e+5);\n\t\t\t}\n\n\t\t\treturn (document.cookie = [\n\t\t\t\tencode(key), '=', stringifyCookieValue(value),\n\t\t\t\toptions.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE\n\t\t\t\toptions.path ? '; path=' + options.path : '',\n\t\t\t\toptions.domain ? '; domain=' + options.domain : '',\n\t\t\t\toptions.secure ? '; secure' : ''\n\t\t\t].join(''));\n\t\t}\n\n\t\t// Read\n\n\t\tvar result = key ? undefined : {},\n\t\t\t// To prevent the for loop in the first place assign an empty array\n\t\t\t// in case there are no cookies at all. Also prevents odd result when\n\t\t\t// calling $.cookie().\n\t\t\tcookies = document.cookie ? document.cookie.split('; ') : [],\n\t\t\ti = 0,\n\t\t\tl = cookies.length;\n\n\t\tfor (; i < l; i++) {\n\t\t\tvar parts = cookies[i].split('='),\n\t\t\t\tname = decode(parts.shift()),\n\t\t\t\tcookie = parts.join('=');\n\n\t\t\tif (key === name) {\n\t\t\t\t// If second argument (value) is a function it's a converter...\n\t\t\t\tresult = read(cookie, value);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Prevent storing a cookie that we couldn't decode.\n\t\t\tif (!key && (cookie = read(cookie)) !== undefined) {\n\t\t\t\tresult[name] = cookie;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconfig.defaults = {};\n\n\t$.removeCookie = function (key, options) {\n\t\t// Must not alter options, thus extending a fresh object...\n\t\t$.cookie(key, '', $.extend({}, options, { expires: -1 }));\n\t\treturn !$.cookie(key);\n\t};\n\n}));\n\n/* Issue #924 is fixed for 5.3+ and 6.0. (compatibility with 5.3) */\nif(window['PrimeFaces'] && window['PrimeFaces'].widget.Dialog) {\n PrimeFaces.widget.Dialog = PrimeFaces.widget.Dialog.extend({\n \n enableModality: function() {\n this._super();\n $(document.body).children(this.jqId + '_modal').addClass('ui-dialog-mask');\n },\n \n syncWindowResize: function() {}\n });\n}\n \n\n"},"directory_id":{"kind":"string","value":"40c9d164c018417691299bbdccb217939f7161f3"},"languages":{"kind":"list like","value":["SCSS","Java","Markdown","SQL","JavaScript","Maven POM"],"string":"[\n \"SCSS\",\n \"Java\",\n \"Markdown\",\n \"SQL\",\n \"JavaScript\",\n \"Maven POM\"\n]"},"num_files":{"kind":"number","value":16,"string":"16"},"repo_language":{"kind":"string","value":"SCSS"},"repo_name":{"kind":"string","value":"VictoriaNiaba/AA-Gestion-de-CVs"},"revision_id":{"kind":"string","value":"b46344634f6ee24d35faf4ffac643beb17b766f8"},"snapshot_id":{"kind":"string","value":"afd99fb32a95dc38c668e8e5affcb27622ac9705"}}},{"rowIdx":9963,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"\n\n\n\t\n\t\t\n\t\tSuper Blog\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t
    \n\t\t\t\n\t\t\t

    Hello !

    \n\t\t\t\n\t\t\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\tclass=\"col-md-10\"\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\tclass=\"col-md-12\n\t\t\t\t
    \n\t\t\t
    \n\t\t\t\n\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\tMenu\n\t\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t
    \n\t\t\t\t\t\tНаши статьи\n\t\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t $article) {\n\t\t\t\t\t\t\t\tvar_dump($article);\n\t\t\t\t\t\t?>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t\t\tАвтор\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tСтатья\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tДата добавления\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tДействия\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tНазвание :
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\">
    \n\t\t\t\t\t\t\t\t\">\n\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\nregistry = $registry;\n }\n \n function auth($user_data){\n\t\t$user_data['name'] = trim($user_data['name']);\n\t\t$user_data['pass'] = trim($user_data['pass']);\n\n\t\t$query = $this->registry['db']->query(\"SELECT * FROM users WHERE login = '\". $user_data['name'] .\"' AND password = '\". $user_data['pass'] .\"' \");\n\t\t\n\t\t$auth = $query->fetch(PDO::FETCH_ASSOC);\n\t \n\t if ($user_data['remember'] == true) {\n\t \t$_SESSION['hash'] = $_COOKIE['PHPSESSID'];\n\t }else{\n\t \t$_SESSION['hash'] = '';\n\t }\n\t \n\t\t$data_execute[] = $_SESSION['hash'];\n\t\t$data_execute[] = $auth['id'];\n\t\t\n\t $up = $this->registry['db']->prepare(\"UPDATE `users` SET `hash` = ? WHERE `id` = ? \"); \n\t\t$up->execute($data_execute);\n\t\t\n\t\tunset($_SESSION['hash']);\n\t\t\n\t return $auth;\n\t}\n\t\n\tfunction user_get($param){\n\t\t\n\t\t$query = $this->registry['db']->query(\"SELECT * FROM users WHERE hash = '\". $param .\"' \");\n\t\t$result = $query->fetchAll();\n\t \n\t return $result;\n\t}\n\t\n\tfunction getArticles(){\n\t\t\n\t\t\n//\t\tДостаем статьи а автора\n\t\t$query = $this->registry['db']->query(\"SELECT *, u.login as users FROM article AS a\n\t\tLEFT JOIN users u \n\t\tON a.user_id = u.id \n\t\tORDER BY a.id DESC \n\t\t\");\n\t\t\n//\t\t$query = $this->registry['db']->query(\"SELECT * FROM super_blog.article sa \n//\t\tWHERE sa.user_id \n//\t\tIN (SELECT id FROM super_blog.users su WHERE su.id = sa.user_id)\");\n\t\t\n\t\t$query->setFetchMode(PDO::FETCH_ASSOC);\n\t\t$results = $query->fetchAll();\n\t\t\n\t\tif (empty($results)) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn $results;\n\t}\n\t\n//\tfunction getTags(){\n//\t\t\n////\t\tДостаем теги к статье\n//\t\t$query2 = $this->registry['db']->query(\"SELECT name FROM tags AS t\n//\t\tLEFT JOIN article_tags AS at \n//\t\tON t.id = at.tag_id\n//\t\t\");\n//\t\t$query2->setFetchMode(PDO::FETCH_ASSOC);\n//\t\t$results[] = $query2->fetchALl();\n//\t\t\n//\t\tif (empty($results)) {\n//\t\t\treturn false;\n//\t\t}\n//\t\t\n//\t\treturn $results;\n//\t}\n}\n?>\n\n\n\n\t\n\t\n\tАвторизация\n\t\n\t\n\t\t
    \n\t\t\tПожалуйста авторизуйтесь\n\t\t
    \n\t\t
    \n\t\t\t\">
    \n\t\t\t\">
    \n\t\t\t
    \n\t\t\t\n\t\t
    \n\t\t\n\t\t
    \n\t\t\t
    \n\t\t\t\t\n\t\t\t
    \n\t\t\n\t\nregistry['model']->get();'\n \t$this->registry['template']->show('index');\n \t\n \t\n }\n}\n\n\n?>set ('db', $db);\n\n//В этом примере мы сначала создаём новый экземпляр библиотеки PDO и соединяемся с нашей БД MySQL. Потом делаем переменную $db доступной глобально при помощи класса Registry.\n\n# Загружаем объект Template\n$template = new Template($registry);\n$registry->set ('template', $template);\n\n$model = new Model($registry);\n$registry->set ('model', $model);\n\n# Загружаем router\n$router = new Router($registry);\n$registry->set ('router', $router);\n\n\n$router->setPath (site_path . 'controllers');\n\n$router->delegate();\n\n?># php_level_2\nLessons GeekBrains at the php level 2\n\n\n\t\n\t\t\n\t\tSuper Blog\n\t\t\n\t\t\n\t\n\t\n\t\t
    \n\t\t\tAdmin-Panel\n\t\t
    \n\t\t\n\t\t
    \n\t\nregistry['model']->getArticles();\n// \t\t$data['tags'] = $this->registry['model']->getTags();\n \t\t\n// \t\tvar_dump($data);\n \t\t$this->registry['template']->set('data', $data);\n \t\t$this->registry['template']->set('user_data', $_SESSION);\n\t\t\t$this->registry['template']->show('admin');\n\t\n\t\t} else {\n\t\t\t\n\t\t\tif ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['send'])) {\n\t\t\t\t\n\t\t\t\tif (isset($_POST['name'])) {\n\t\t\t\t\t$name = $_POST['name'];\n\t\t\t\t}else{\n\t\t\t\t\t$name = '';\n\t\t\t\t}\n\t\t\t\tif (isset($_POST['pass'])) {\n\t\t\t\t\t$pass = $_POST['pass'];\n\t\t\t\t}else{\n\t\t\t\t\t$pass = '';\n\t\t\t\t}\n\t\t\t\tif (isset($_POST['remember'])) {\n\t\t\t\t\t$remember = $_POST['remember'];\n\t\t\t\t}else{\n\t\t\t\t\t$remember = '';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$user_data = array(\n\t\t\t\t\t'name'\t\t=> $name,\n\t\t\t\t\t'pass'\t\t=> $pass,\n\t\t\t\t\t'remember'\t=> $remember\n\t\t\t\t);\n\t\t\t\t\n\t\t\t\t$auth = $this->registry['model']->auth($user_data);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\tif (isset($auth) && $auth != NULL) {\n\t\t\t$_SESSION['true_auth'] = $auth;\n//\t\t\t$this->registry['template']->show('admin');\n\t\t\theader('Location: admin');\n\t\t\t}\n\t\t\n\t\t\t\t\t$_SESSION['user'] = $this->registry['model']->user_get($_COOKIE['PHPSESSID']);\n\t\t\t\t\t\n\t\t \t$this->registry['template']->set('user_data', $_SESSION['user']);\n\t\t \t$this->registry['template']->show('auth');\n\t\t \t\n\t\t }\n\t\t\t}\n\n}\n\n\n?>"},"directory_id":{"kind":"string","value":"3345f7953e0e1180331ad5656a03e7880ffce02e"},"languages":{"kind":"list like","value":["Markdown","Hack","PHP"],"string":"[\n \"Markdown\",\n \"Hack\",\n \"PHP\"\n]"},"num_files":{"kind":"number","value":8,"string":"8"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"Takagero/php_level_2"},"revision_id":{"kind":"string","value":"3e6b3dea2cddcabe715e2c62a0cc0830e3f4df2c"},"snapshot_id":{"kind":"string","value":"989fa0f3d5fd988e964bc72176df6b69835e78eb"}}},{"rowIdx":9964,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"#!/usr/bin/perl\n\nuse LWP::UserAgent;\nuse IO::Pipe;\nuse Getopt::Std;\nmy $agent = new LWP::UserAgent;\n\nmy $opt_string = 'c:u:z:s:p:r:C:h:H:vdt';\ngetopts($opt_string, \\%opt) or usage();\n\nsub usage()\n{\n print STDERR \"Usage: ./zabbix_haproxy [arguments]\\n\";\n print STDERR \"This program reads the HAProxy config file for special notations and uses this info\\n\";\n print STDERR \"to send data about certain hosts in haproxy to zabbix.\\n\";\n print STDERR \"\\n\";\n print STDERR \"The haproxy config has 'frontend' sections and 'server' lines. These lines are annotated\\n\";\n print STDERR \"with a special comment which tells this script that the frontend or server is tagged for\\n\";\n print STDERR \"zabbix.\\n\";\n print STDERR \"\\n\";\n print STDERR \"Example config line where the frontend named 'irc-galleria' (the former) is sent to zabbix\\n\";\n print STDERR \"host named 'irc-galleria' (the later).\\n\";\n print STDERR \"frontend irc-galleria # @zabbix_frontend(irc-galleria)\\n\";\n print STDERR \"\\n\";\n print STDERR \"Another example for a server where server named suomirock is sent to zabbix host named\\n\";\n print STDERR \"suomirock.web.pri\\n\";\n print STDERR \" server suomirock 10.3.0.24:80 check weight 16 maxconn 200 # @zabbix_server(suomirock.web.pri)\\n\";\n print STDERR \"\\n\";\n print STDERR \"All hosts in zabbix must be tagged to use Template_HAProxyItem\\n\";\n print STDERR \"\\n\";\n print STDERR \"Command line arguments: You need to supply at least -c, -u and -s arguments.\\n\";\n print STDERR \" -c HAProxy config file\\n\";\n print STDERR \" -u URL where the haproxy statistics are. ex: http://foobar.com/haproxy?stats;csv\\n\";\n print STDERR \" -s Zabbix server host.\\n\";\n print STDERR \" -p Zabbix trapper port. DEFAULT: 10051\\n\";\n print STDERR \" -z Path to zabbix_sender OPTIONAL\\n\";\n print STDERR \" -C : HTTP Authentication username and password OPTIONAL\\n\";\n print STDERR \" -H : Hostname where the realm is active if HTTP Authentication is to be used. Defaults to host in -u OPTIONAL\\n\";\n print STDERR \" -r HTTP Authentication basic realm, defaults to \\\"HAProxy Statistics\\\" OPTIONAL\\n\";\n print STDERR \" -h Optional Host: header parameter.\\n\";\n print STDERR \" -v turn verbose mode on.\\n\";\n print STDERR \" -d turn debug mode on (prints more than verbose).\\n\";\n print STDERR \" -t Just test, dont send anything to zabbix server.\\n\";\n exit;\n}\n\nmy $verbose = $opt{v} || $opt{d};\nmy $debug = $opt{d};\nmy $just_test = $opt{t};\n\n#\n# CONFIGURATION\n#\n\n# Location of the haproxy config file\n#my $haproxy_conf = '/tmp/galtsu.cfg';\nmy $haproxy_conf = $opt{c} or usage();\n\n# Url where the CVS haproxy stats can be fetched\nmy $url = $opt{u} or usage();;\n\n# Host header in the http request\nmy $host_header = $opt{h};\n\nmy $http_realm = $opt{r} ? $opt{r} : 'HAProxy Statistics';\n\nmy $http_host = $opt{H};\nif (!$http_host) {\n if ($url =~ m|^http://(.+?)(:\\d+)?/|) {\n\t$http_host = $1 . ($2 ? $2 : ':80');\n }\n}\n\nif ($http_host !~ /:\\d+/) {\n $http_host .= ':80';\n}\n\nif ($opt{C}) {\n # Setup basic authentication\n my ($user, $pass) = split(/:/, $opt{C});\n $verbose and print \"Using basic authentication: server: $http_host, realm \\\"$http_realm\\\", username: $user, password: $\";\n $agent->credentials($http_host, $http_realm, $user => $pass);\n}\n\n# Path to zabbix_sender command\nmy $zabbix_sender_path = $opt{z} ? $opt{z} : \"zabbix_sender\";\n\n# Zabbix server\nmy $zabbix_server = $opt{s} or usage();\n\n# Zabbix trapper port\nmy $zabbix_port = $opt{p} ? $opt{p} : 10051;\n$verbose and print \"Using zabbix server at $zabbix_server:$zabbix_port\\n\";\n\n# END OF CONFIGURATION\n\n# These are read from the haproxy config file. example from config where the frontend 'ircgalerie' (the former) will be mapped to zabbix host named 'ircgalerie' (the later)\n#frontend ircgalerie # @zabbix_frontend(ircgalerie)\n#\tbind\t\t172.16.31.10:80\n# .............\n\nmy %track_frontends = ();\n\nmy %track_servers = ();\n\nparse_haproxy_conf($haproxy_conf);\n\nmy $finished = 0;\nmy $timeout = 2;\n\n$SIG{CHLD} = sub { wait, $finished = 1 };\n\nmy $pipe = new IO::Pipe;\nmy $pid = fork;\n\nif($pid == 0) {\n $pipe->writer;\n my $response;\n if ($host_header) {\n\t$verbose and print \"Using host header: $host_header\\n\";\n\t$response = $agent->get($url, Host => $host_header);\n } else {\n\t$response = $agent->get($url);\n }\n if (!$response->is_success) {\n\t$pipe->print(\"FAILURE, response code: \" . $response->status_line);\n }\n $pipe->print($response->content);\n exit;\n}\n\n$pipe->reader;\n\nsleep($timeout);\n\nmy %proxies = ();\nmy %backends = ();\nmy %frontends = ();\nmy %nodes = ();\n\nif($finished) {\n my $first_line = 1;\n foreach my $line ($pipe->getlines) {\n\tif ($first_line and $line =~ /^FAILURE, response code:/) {\n\t print STDERR \"$line\";\n\t exit(1);\n\t}\n\t$first_line = 0;\n\t$debug and print \"Got line $line\";\n\tif ($line =~ /^#/) {\n\t next;\n\t}\n\tmy $data = parse_line($line);\n\t$proxies{$$data{pxname}}{$$data{svname}} = $data;\n }\n} \nelse {\n kill(9, $pid);\n print \"-1\\n\";\n die(\"Could not get data from url $url\");\n}\n\n# Parse out all backends and frontends\nwhile (($pxname, $nodes) = each(%proxies)) {\n #print \"proxy: $pxname\\n\";\n while (($svname, $data) = each (%$nodes)) {\n\t#print \"-- svname: \" . $$data{svname} . \"\\n\";\n\tif ($$data{svname} eq \"BACKEND\") {\n\t #print \"Found backend $pxname\\n\";\n\t $backends{$pxname} = $data;\n\t} elsif ($$data{svname} eq \"FRONTEND\") {\n\t #print \"Found frontend $pxname\\n\";\n\t $frontends{$pxname} = $data;\n\t} else {\n\t $nodes{$$data{svname}} = $data;\n\t}\n\n }\n}\n\n# Print out all backend aggregates\n#while (($pxname, $data) = each(%backends)) {\n# print \"Backend $pxname.\\n\";\n# print_data($data);\n#}\n\n# Send frontends\nwhile (($haproxy_name, $zabbix_name) = each(%track_frontends)) {\n $verbose and print \"Sending data for frontend $haproxy_name into zabbix host $zabbix_name\\n\";\n send_data($zabbix_name, $frontends{$haproxy_name});\n}\n\n# Send servers\nwhile (($haproxy_name, $data) = each(%nodes)) {\n if (exists $track_servers{$haproxy_name}) {\n\t$zabbix_name = $track_servers{$haproxy_name};\n\t$verbose and print \"Sending data for server $haproxy_name into zabbix host $zabbix_name\\n\";\n\tsend_data($zabbix_name, $data);\n }\n}\n\nsub print_data {\n my $data = shift;\n print \" Sessions, current : \" . $$data{scur} . \"\\n\";\n print \" Sessions, max : \" . $$data{smax} . \"\\n\";\n print \" Sessions, total : \" . $$data{stot} . \"\\n\";\n print \" Traffic, in : \" . $$data{bin} . \"\\n\";\n print \" Traffic, out : \" . $$data{bout} . \"\\n\";\n print \" Responses: 1xx : \" . $$data{hrsp_1xx} . \"\\n\";\n print \" Responses: 2xx : \" . $$data{hrsp_2xx} . \"\\n\";\n print \" Responses: 3xx : \" . $$data{hrsp_3xx} . \"\\n\";\n print \" Responses: 4xx : \" . $$data{hrsp_4xx} . \"\\n\";\n print \" Responses: 5xx : \" . $$data{hrsp_5xx} . \"\\n\";\n \n}\n\n# Sends tracked values to zabbix server from a single node\n# Argument: key which is used to get the node\nsub send_data {\n my $zabbix_name = shift;\n my $data = shift;\n #$verbose and print \"Sending data for zabbix name $zabbix_name. pxname: \" . $$data{pxname} . \", svname: \" . $$data{svname} . \"\\n\";\n send_data_item($zabbix_name, 'pxname', $$data{pxname});\n send_data_item($zabbix_name, 'svname', $$data{svname});\n send_data_item($zabbix_name, 'req_rate', $$data{req_rate});\n send_data_item($zabbix_name, 'hrsp_1xx', $$data{hrsp_1xx});\n send_data_item($zabbix_name, 'hrsp_2xx', $$data{hrsp_2xx});\n send_data_item($zabbix_name, 'hrsp_3xx', $$data{hrsp_3xx});\n send_data_item($zabbix_name, 'hrsp_4xx', $$data{hrsp_4xx});\n send_data_item($zabbix_name, 'hrsp_5xx', $$data{hrsp_5xx});\n send_data_item($zabbix_name, 'rate', $$data{rate});\n send_data_item($zabbix_name, 'wretr', $$data{wretr});\n send_data_item($zabbix_name, 'eresp', $$data{eresp});\n send_data_item($zabbix_name, 'econ', $$data{econ});\n send_data_item($zabbix_name, 'ereq', $$data{ereq});\n send_data_item($zabbix_name, 'bin', $$data{bin});\n send_data_item($zabbix_name, 'bout', $$data{bout});\n send_data_item($zabbix_name, 'stot', $$data{stot});\n send_data_item($zabbix_name, 'smax', $$data{smax});\n send_data_item($zabbix_name, 'scur', $$data{scur});\n}\n\n# Send a single data item to zabbix server.\n# Argument: server/host/node name in zabbix\n# Argument: name of the parameter (like svname, bin, bout etc)\n# Argument: value/data\nsub send_data_item {\n my $zabbix_name = shift;\n my $param = shift;\n my $value = shift;\n if ($value eq \"\") {\n\treturn;\n }\n my $var = 'haproxy.' . $param;\n my $cmd = \"$zabbix_sender_path -z $zabbix_server -p $zabbix_port -s \\\"$zabbix_name\\\" -k $var -o $value\";\n $debug and print \"Command: $cmd\\n\";\n if (!$just_test) {\n\t`$cmd`;\n }\n}\n\nsub parse_line {\n my $line = shift;\n chomp $line;\n\n my @raw = split(/,/, $line);\n\n my %data = ();\n my $i = 0;\n foreach $key (split(/,/, \"pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt\")) {\n\tmy $value = @raw[$i++];\n\t$data{$key} = $value;\n }\n\n return \\%data;\n}\n\nsub parse_haproxy_conf()\n{\n my $filename = shift;\n open (FILE, $filename) or die(\"Could not open haproxy config file at $filename\");\n while () {\n\tmy $line = $_;\n\tif ($line =~ /^(?:frontend|listen)[[:space:]]+([^[:space:]]+).+#.*@zabbix_frontend\\((.+)\\)/) {\n\t $debug and print \"found frontend mapping $1 to $2\\n\";\n\t $track_frontends{$1} = $2;\n\t}\n\n\tif ($line =~ /server[[:space:]]+([^[:space:]]+).+#.*@zabbix_server\\((.+)\\)/) {\n\t $debug and print \"found server mapping $1 to $2\\n\";\n\t $track_servers{$1} = $2;\n\t}\n\n\n }\n}\n"},"directory_id":{"kind":"string","value":"1c0b146f42bf0a63fbe60a45dffb8fb435c94b9d"},"languages":{"kind":"list like","value":["Perl"],"string":"[\n \"Perl\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Perl"},"repo_name":{"kind":"string","value":"garo/zabbix_haproxy"},"revision_id":{"kind":"string","value":"fae4bbe4d68930831a773de5f005cdeb24864800"},"snapshot_id":{"kind":"string","value":"28a6e8d2cd13818938a89cbd7cce0f80c63ea635"}}},{"rowIdx":9965,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"import random\n\nword_bank = ['bunny', 'hello', 'onomatopoeia', 'periodt']\n\n\ndef hangman_game(attempts):\n word = random.choice(word_bank)\n\n print('🎮 START ... 🎉🎉')\n\n guesses = ''\n wrong_guesses = 0\n correct_guesses = 0\n turns = attempts\n\n while turns > 0:\n guess = str(input(\"Enter guess:\"))\n guesses += guess\n print(word)\n # print([c for c in guesses if c in word])\n # print('wrong', [c for c in guesses if c not in word])\n correct = [c if c in guesses else '-' for c in word]\n print()\n print('👉', ''.join(correct))\n print()\n\n if guess in word:\n print('✔. # turns left: ', turns)\n # correct_guesses = len([[c for c in guesses if c in word]])\n correct_guesses += 1\n\n if guess not in word:\n turns -= 1\n print('❌. # turns left: ', turns)\n # wrong_guesses = len([c for c in guesses if c not in word])\n wrong_guesses += 1\n\n if word == ''.join(correct):\n print('🎉🎉🎉 YAY')\n break\n\n if turns == 0:\n return \"💀💀💀 TRY AGAIN\"\n\n\nprint('HANGMAN')\n\nattempts = int(input(\"# Wrong guesses you want:\"))\n\nprint(hangman_game(attempts))\n"},"directory_id":{"kind":"string","value":"18e8638e8903890326f2f29be8f598433886069e"},"languages":{"kind":"list like","value":["Python"],"string":"[\n \"Python\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Python"},"repo_name":{"kind":"string","value":"ruvvet/hman_challenge"},"revision_id":{"kind":"string","value":"14b0b22c9a4d8f248c3e5cf2a48062cb15ece4fd"},"snapshot_id":{"kind":"string","value":"9c42a7be4854ef141bf65cb7597fc36f522e623f"}}},{"rowIdx":9966,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# gnu-gdb-xpack\nA binary xPack with GNU GDB.\n"},"directory_id":{"kind":"string","value":"a409978cab0095121c4c2d14362b0b00ffbb611f"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"316792668/gnu-gdb-xpack"},"revision_id":{"kind":"string","value":"c2c08d8b83f88907a8a609c66402bea4908a40e2"},"snapshot_id":{"kind":"string","value":"e525a5f3daf740d9a9a48fb1dcc4f0f1677eab2a"}}},{"rowIdx":9967,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"# BC15-WaveRelease2\nBC Wave 2 Release development\nThis is for the development purpose only \nYou can check in and check out the code as and when you need,\nYes offcourse and this has been tested sucessfully.\n"},"directory_id":{"kind":"string","value":"fa8433cc6ce9398df32f900607107fa42aa89e14"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"subhashatCBR/BC15-WaveRelease2"},"revision_id":{"kind":"string","value":"af6e57c4a38d08f36ddf4fd1201cae96f8ae3c6f"},"snapshot_id":{"kind":"string","value":"82ed526817a742180a97eddfdf9fc23b2aa5ff83"}}},{"rowIdx":9968,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"armstrong0919/VRGame_RTS/Assets/_Script/UnitStates/Unit_StateManager.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic interface IMoveable\n{\n void Set_MoveTarget(Vector3 target_pos);\n}\n\npublic class Unit_StateManager : MonoBehaviour\n{\n\n public UnitProperties UnitProperties;\n\n [HideInInspector]\n public Vector3 TargetPosition;\n\n\n\n Base_UnitState currentstatus;\n UnitState_Retarget _retarget;\n public UnitState_Retarget Get_RetargetState { get { return _retarget; } }\n UnitState_Move _move;\n public UnitState_Move Get_MoveState { get { return _move; } }\n UnitState_Idle _idle;\n public UnitState_Idle Get_IdleState { get { return _idle; } }\n private void Start()\n {\n _retarget = new UnitState_Retarget(this);\n _move = new UnitState_Move(this);\n _idle = new UnitState_Idle(this);\n currentstatus = _idle;\n }\n\n public void Update() \n {\n\n currentstatus.UpdateState();\n }\n public void To_State(Base_UnitState nextstate) \n {\n Debug.Log(currentstatus.GetType() + \":\" + nextstate.GetType());\n currentstatus.EndState();\n currentstatus = nextstate;\n currentstatus.StartState();\n }\n\n\n public void Set_MoveTarget(Vector3 target_pos)\n {\n TargetPosition = target_pos;\n To_State(Get_RetargetState);\n\n }\n}\n/Assets/_Script/UnitStates/Base_UnitState.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic abstract class Base_UnitState \n{\n protected Unit_StateManager Owner;\n public Base_UnitState(Unit_StateManager _unit_ower) \n {\n Owner = _unit_ower;\n }\n public abstract void StartState();\n public abstract void UpdateState();\n public abstract void EndState();\n\n}\n/Assets/_Script/UnitStates/UnitState_Retarget.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class UnitState_Retarget : Base_UnitState\n{\n float timer;\n float dist;\n public UnitState_Retarget(Unit_StateManager _input_owner) : base(_input_owner)\n {\n\n }\n public override void EndState()\n {\n\n }\n Vector3 direction;\n Quaternion target_rot;\n float angle;\n public override void StartState()\n {\n timer = 0.0f;\n }\n\n public override void UpdateState()\n {\n Owner.transform.Translate(0, 0, Owner.UnitProperties.MovementSpeed * Time.deltaTime);\n timer += Time.deltaTime * Owner.UnitProperties.RotationSpeed;\n direction = Owner.TargetPosition - Owner.transform.position;\n target_rot = Quaternion.LookRotation(direction);\n Owner.transform.rotation = Quaternion.Lerp(Owner.transform.rotation, target_rot, timer);\n //Owner.transform.rotation = Quaternion.RotateTowards(Owner.transform.rotation, target_rot, Owner.UnitProperties.RotationSpeed * direction.magnitude * 2);\n\n if (target_rot == Owner.transform.rotation)\n Owner.To_State(Owner.Get_MoveState);\n\n if(Vector3.Distance(Owner.transform.position, Owner.TargetPosition) < Owner.transform.localScale.x / 2)\n Owner.To_State(Owner.Get_IdleState);\n\n }\n}/Assets/_Script/UnitStates/UnitState_Idle.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class UnitState_Idle : Base_UnitState\n{\n public UnitState_Idle(Unit_StateManager _input_owner) : base(_input_owner)\n {\n\n }\n public override void EndState()\n {\n\n }\n\n public override void StartState()\n {\n\n }\n\n public override void UpdateState()\n {\n\n }\n}/Assets/_Script/SetDestination.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing OVR;\n\n\npublic abstract class DestinationPointer\n{\n protected SetDestination _dest;\n public DestinationPointer(SetDestination _destination)\n {\n _dest = _destination;\n }\n public abstract Vector3 SetPointer();\n public abstract void UpdatePointer();\n}\npublic class BasicPointer : DestinationPointer\n{\n public BasicPointer(SetDestination _destination ) : base(_destination)\n {\n\n }\n public override Vector3 SetPointer()\n {\n return _dest.ControlObj.position;\n }\n public override void UpdatePointer()\n {\n#if UNITY_EDITOR\n if (Input.GetKeyDown(KeyCode.Space))\n _dest.Send_MoveOrder();\n#endif\n\n if(OVRInput.GetDown( OVRInput.Button.SecondaryIndexTrigger))\n _dest.Send_MoveOrder();\n }\n}\npublic class ExtensionPointer : DestinationPointer\n{\n public float PressSpeed = 3.0f;\n public ExtensionPointer(SetDestination _destination) : base(_destination)\n {\n\n }\n public override Vector3 SetPointer()\n {\n return destination;\n }\n float dist_extend;\n Vector3 destination;\n public override void UpdatePointer()\n {\n#if UNITY_EDITOR\n if (Input.GetKey(KeyCode.Space))\n {\n dist_extend += Time.deltaTime * PressSpeed;\n destination = _dest.ControlObj.TransformPoint(0,0,dist_extend);\n _dest.DebugObj.position = destination;\n }\n if(Input.GetKeyUp(KeyCode.Space))\n _dest.Send_MoveOrder();\n#endif\n\n if (OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger))\n {\n dist_extend += Time.deltaTime * PressSpeed;\n destination = _dest.ControlObj.TransformPoint(0, 0, dist_extend);\n _dest.DebugObj.position = destination;\n }\n if (OVRInput.GetUp(OVRInput.Button.SecondaryIndexTrigger))\n {\n _dest.Send_MoveOrder();\n destination = Vector3.zero;\n dist_extend = 0.0f;\n }\n\n }\n}\npublic class TwoStepPointer : DestinationPointer\n{\n bool has_hit;\n Vector3 return_val;\n Vector3 first_hit_point;\n \n public TwoStepPointer(SetDestination _destination) : base(_destination)\n {\n \n }\n public override Vector3 SetPointer()\n {\n return return_val;\n\n }\n public override void UpdatePointer()\n {\n#if UNITY_EDITOR\n if(Input.GetKeyDown(KeyCode.Space))\n {\n RaycastHit hit;\n Ray new_ray = new Ray(_dest.ControlObj.position, _dest.ControlObj.forward);\n if (Physics.Raycast(new_ray,out hit))\n {\n if (hit.collider.gameObject == HorizontalFloor.Singleton.gameObject)\n {\n first_hit_point = hit.point;\n _dest.DebugObj.position = first_hit_point;\n has_hit = true;\n }\n }\n }\n if(Input.GetKey(KeyCode.Space))\n {\n Vector3 hitpoint_noheight = new Vector3(first_hit_point.x, 0, first_hit_point.z);\n Vector3 controller_noheight = new Vector3(_dest.ControlObj.position.x, 0, _dest.ControlObj.position.z);\n float _distance = Vector3.Distance(hitpoint_noheight, controller_noheight);\n float euler_y = _dest.ControlObj.eulerAngles.x;\n float rad = euler_y * Mathf.Deg2Rad;\n float height = euler_y > 0 ? Mathf.Tan(rad) * _distance * -1 : Mathf.Tan(rad) * _distance;\n\n Debug.Log(_distance + \":\" + euler_y + \":\" + height + \":\" + _dest.ControlObj.position.y);\n return_val = new Vector3(first_hit_point.x, _dest.ControlObj.position.y + height, first_hit_point.z);\n\n _dest.DebugObj.position = return_val;\n //return_val = new Vector3(first_hit_point.x, _dest.DestinationObj.position.y, first_hit_point.z);\n }\n if (Input.GetKeyUp(KeyCode.Space) && has_hit)\n {\n _dest.DebugObj.position = return_val;\n _dest.Send_MoveOrder();\n has_hit = false;\n }\n#endif\n if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))\n {\n RaycastHit hit;\n Ray new_ray = new Ray(_dest.ControlObj.position, _dest.ControlObj.forward);\n if (Physics.Raycast(new_ray, out hit))\n {\n if (hit.collider.gameObject == HorizontalFloor.Singleton.gameObject)\n {\n first_hit_point = hit.point;\n _dest.DebugObj.position = first_hit_point;\n has_hit = true;\n }\n }\n }\n if (OVRInput.Get(OVRInput.Button.SecondaryIndexTrigger))\n {\n\n Vector3 hitpoint_noheight = new Vector3(first_hit_point.x, 0, first_hit_point.z);\n Vector3 controller_noheight = new Vector3(_dest.ControlObj.position.x, 0, _dest.ControlObj.position.z);\n float _distance = Vector3.Distance(hitpoint_noheight, controller_noheight);\n float euler_y = _dest.ControlObj.eulerAngles.x;\n float rad = euler_y * Mathf.Deg2Rad;\n float height = euler_y > 0 ? Mathf.Tan(rad) * _distance * -1 : Mathf.Tan(rad) * _distance;\n\n Debug.Log(_distance + \":\" + euler_y + \":\" + height + \":\" + _dest.ControlObj.position.y);\n return_val = new Vector3(first_hit_point.x, _dest.ControlObj.position.y + height, first_hit_point.z);\n\n _dest.DebugObj.position = return_val;\n //return_val = new Vector3(first_hit_point.x, _dest.DestinationObj.position.y, first_hit_point.z);\n }\n if (OVRInput.GetUp(OVRInput.Button.SecondaryIndexTrigger))\n {\n _dest.DebugObj.position = return_val;\n _dest.Send_MoveOrder();\n has_hit = false;\n }\n }\n}\npublic class SetDestination : MonoBehaviour\n{\n public Transform ControlObj;\n public Transform DebugObj;\n \n private DestinationPointer _movecontrol;\n private void Start()\n {\n _movecontrol = new TwoStepPointer(this);\n }\n\n // Update is called once per frame\n void Update()\n {\n Debug.DrawLine(ControlObj.position, ControlObj.forward * 100, Color.green);\n _movecontrol.UpdatePointer();\n }\n public void Send_MoveOrder() \n {\n foreach (Unit_StateManager _unit in OculusPlayerController.Singleton.Selected_MovableObject)\n _unit.Set_MoveTarget(_movecontrol.SetPointer());\n }\n}\n/Assets/_Script/UnitStates/UnitState_Move.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class UnitState_Move : Base_UnitState\n{\n public UnitState_Move(Unit_StateManager _input_owner) : base(_input_owner) \n {\n\n }\n public override void EndState()\n {\n\n }\n\n public override void StartState()\n {\n\n }\n\n public override void UpdateState()\n {\n Owner.transform.Translate(0, 0, Owner.UnitProperties.MovementSpeed * Time.deltaTime);\n Vector3 _relative_pos = Owner.transform.InverseTransformPoint( Owner.TargetPosition);\n if (_relative_pos.z < 0)\n Owner.To_State(Owner.Get_IdleState);\n }\n}\n/Assets/_Script/UnitProperties.cs\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\n[System.Serializable]\npublic class UnitProperties\n{\n public float MovementSpeed;\n public float RotationSpeed;\n\n}\n"},"directory_id":{"kind":"string","value":"6f529e99515e2a168d664bed9c5b68dcc7b71cb7"},"languages":{"kind":"list like","value":["C#"],"string":"[\n \"C#\"\n]"},"num_files":{"kind":"number","value":7,"string":"7"},"repo_language":{"kind":"string","value":"C#"},"repo_name":{"kind":"string","value":"armstrong0919/VRGame_RTS"},"revision_id":{"kind":"string","value":"1bd1d9f2c09ff8851395280ad2c40be66cbe1d33"},"snapshot_id":{"kind":"string","value":"44ecfe282bc9db21dfddb0e16b824505c1278a32"}}},{"rowIdx":9969,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"@font-face {\n font-family: 'Montserrat';\n font-style: normal;\n font-weight: 400;\n src: local('Montserrat Regular'), local('Montserrat-Regular'),\n url('../fonts/montserrat-v14-latin-regular.woff2') format('woff2'), \n url('../fonts/montserrat-v14-latin-regular.woff') format('woff'); \n }\n \n @font-face {\n font-family: 'Montserrat';\n font-style: normal;\n font-weight: 700;\n src: local('Montserrat Bold'), local('Montserrat-Bold'),\n url('../fonts/montserrat-v14-latin-700.woff2') format('woff2'), \n url('../fonts/montserrat-v14-latin-700.woff') format('woff'); \n }\n\n@font-face {\n font-family: 'Roboto';\n font-style: italic;\n font-weight: 300;\n src: local('Roboto Light Italic'), local('Roboto-LightItalic'),\n url('../fonts/roboto-v20-latin-300italic.woff2') format('woff2'), \n url('../fonts/roboto-v20-latin-300italic.woff') format('woff'); \n }\n\n @font-face {\n font-family: 'Roboto';\n font-style: normal;\n font-weight: 400;\n src: local('Roboto'), local('Roboto-Regular'),\n url('../fonts/roboto-v20-latin-regular.woff2') format('woff2'), \n url('../fonts/roboto-v20-latin-regular.woff') format('woff'); \n }\n\n\n@font-face {\n font-family: 'Kaushan Script';\n font-style: normal;\n font-weight: 400;\n src: url('../fonts/kaushan-script-v8-latin-regular.eot'); \n src: local('Kaushan Script'), local('KaushanScript-Regular'),\n url('../fonts/kaushan-script-v8-latin-regular.eot?#iefix') format('embedded-opentype'), \n url('../fonts/kaushan-script-v8-latin-regular.woff2') format('woff2'), \n url('../fonts/kaushan-script-v8-latin-regular.woff') format('woff'), \n url('../fonts/kaushan-script-v8-latin-regular.ttf') format('truetype'), \n url('../fonts/kaushan-script-v8-latin-regular.svg#KaushanScript') format('svg'); \n }\nbody, body * {\n margin: 0px;\n padding: 0px;\n}\n\nul,ol{\n list-style-type: none;\n}\n\n.main-wrapper{\n width:1200px;\n margin:0 auto;\n \n}\n\n.header{\n \n min-height: 1000px;\n background-image: -webkit-gradient(linear,left bottom, left top,from(rgba(251,227,137,0.9)) ,to(rgba(243,129,129,0.9)) ), url(\"../img/bg.jpg\");\n background-image: -o-linear-gradient(bottom,rgba(251,227,137,0.9) ,rgba(243,129,129,0.9) ), url(\"../img/bg.jpg\");\n background-image: linear-gradient(0deg,rgba(251,227,137,0.9) ,rgba(243,129,129,0.9) ), url(\"../img/bg.jpg\");\n background-size: cover;\n}\n\n@media(-webkit-min-device-pixel-ratio:2), (-o-min-device-pixel-ratio:2/1), (min-resolution:192dpi){\n .header{\n background-image: -webkit-gradient(linear,left bottom, left top,from(rgba(251,227,137,0.9)) ,to(rgba(243,129,129,0.9)) ), url(\"../img/bg@2x.jpg\");\n background-image: -o-linear-gradient(bottom,rgba(251,227,137,0.9) ,rgba(243,129,129,0.9) ), url(\"../img/bg@2x.jpg\");\n background-image: linear-gradient(0deg,rgba(251,227,137,0.9) ,rgba(243,129,129,0.9) ), url(\"../img/bg@2x.jpg\");\n }\n}\n\n\n.navigation{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n min-height:50px;\n -webkit-box-pack:justify;\n -ms-flex-pack:justify;\n justify-content:space-between;\n -webkit-box-align: baseline;\n -ms-flex-align: baseline;\n align-items: baseline;\n}\n\n.header__navigation-pos{\n margin-bottom: 120px;\n padding-top: 20px;\n}\n\n.logo{\n display:block;\n font-size: 30px;\n color: #ffffff;\n font-family: \"Montserrat\";\n font-weight: 700;\n}\n\n.navigation__menu{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n \n}\n\n.main-menu{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack:justify;\n -ms-flex-pack:justify;\n justify-content:space-between;\n width: 480px;\n margin-right: 50px;\n}\n\n.main-menu__item{\n font-size: 14px;\n font-family: \"Montserrat\";\n font-weight: 400;\n text-align: center;\n text-transform: uppercase;\n padding-bottom: 10px;\n border-bottom: 3px solid rgba(252, 227, 138, 0);\n -webkit-transition: border 0.2s linear ;\n -o-transition: border 0.2s linear ;\n transition: border 0.2s linear ;\n}\n\n.main-menu__item:hover{\n border-bottom: 3px solid rgba(252, 227, 138, 1);\n \n}\n.main-menu__link:hover{\n color: #fce38a;\n}\n\n.main-menu__link{\n text-decoration: none;\n color: #ffffff;\n}\n\n.add-search-menu{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n width: 80px;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n \n}\n\n.add-search-menu__item{\n width: 18px;\n height: 18px;\n\n}\n\n.button-cart{\n border: none;\n background: none;\n}\n\n.add-search-menu__item{\n fill: #ffffff;\n}\n\n.add-search-menu__item:hover{\n fill:#fce38a;\n cursor: pointer;\n}\n\n.header__title{\n width: 820px;\n font-size: 150px;\n line-height: 140px;\n color: #ffffff;\n font-family: \"Montserrat\";\n font-weight: 700;\n text-align: center;\n text-transform: uppercase;\n margin: 0 auto;\n letter-spacing: -5.4px;\n margin-bottom: 112px;\n \n}\n\n.header__pre-title{\n font-size: 72px;\n color: #ffffff;\n font-family: \"Kaushan Script\";\n font-weight: 400;\n text-align: center;\n display: block;\n text-transform: none;\n letter-spacing:0.2px;\n margin-bottom: 8px;\n}\n\n.load-more{\n width: 160px;\n height: 40px;\n background-color: rgba(0,0,0,0);\n border: 3px solid #ffffff;\n display: block;\n margin: 0 auto;\n font-size: 14px;\n color: #ffffff;\n font-family: \"Montserrat\";\n font-weight: 700;\n text-align: center;\n text-transform: uppercase;\n}\n\n.load-more:hover{\n cursor: pointer;\n border: 3px solid #f38181;\n color: #f38181;\n}\n\n.main-section{\n padding-top: 40px;\n}\n\n.main-title_pre{\n display: block;\n font-size: 24px;\n color: #333333;\n font-family: \"Kaushan Script\";\n font-weight: 400;\n text-align: center;\n margin-bottom: 10px;\n text-transform: none;\n}\n.main-title{\n text-align: center;\n margin-bottom:60px;\n font-size: 30px;\n color: #333333;\n font-family: \"Montserrat\";\n font-weight: 700;\n text-transform: uppercase;\n}\n\n.main-title::after{\n display: block;\n content:'';\n width: 60px;\n height: 3px;\n background-color: #f38181;\n margin: 0 auto;\n margin-top:34px;\n}\n\n.servises{\n padding: 40px 10px;\n}\n\n.servise-list{\n display:-webkit-box;\n display:-ms-flexbox;\n display:flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n list-style: none;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n\n.servise-list__item{\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n display: block;\n width:382px;\n padding-left: 82px;\n position:relative;\n}\n\n.servise-list__item:not(:nth-last-of-type(-n+3)){\n margin-bottom:92px;\n}\n\n.servise-list__title{\n text-transform: uppercase;\n font-size: 14px;\n color: #333333;\n font-family: \"Montserrat\";\n font-weight: 400;\n margin-bottom:15px;\n}\n\n.servise-list__descr{\n font-size: 15px;\n line-height: 24px;\n color: #999999;\n font-family: \"Roboto\";\n font-weight: 400;\n}\n\n.servise-list__item:before{\n display:block;\n content:\"\";\n width:32px;\n height:32px;\n position: absolute;\n left:22px;\n top:5px;\n background-position: center;\n background-repeat: no-repeat;\n}\n\n.servise-list__item_icon-clock:before{\n background-image: url(\"../img/icon-servises/icon-clock.svg\");\n}\n\n.servise-list__item_icon-wave:before{\n background-image: url(\"../img/icon-servises/icon-wave.svg\");\n}\n\n.servise-list__item_icon-monitor:before{\n background-image: url(\"../img/icon-servises/icon-monitor.svg\");\n}\n\n.servise-list__item_icon-book:before{\n background-image: url(\"../img/icon-servises/icon-book.svg\");\n}\n\n.servise-list__item_icon-house:before{\n background-image: url(\"../img/icon-servises/icon-house.svg\");\n}\n\n.servise-list__item_icon-focus:before{\n background-image: url(\"../img/icon-servises/icon-focus.svg\");\n}\n\n\n\n.team{\n padding-bottom:56px;\n}\n\n.team__description{\n width:980px;\n margin:0 auto;\n font-size: 15px;\n line-height: 24px;\n color: #999999;\n font-family: \"Roboto\";\n font-weight: 400;\n text-align: center;\n margin-bottom:74px;\n}\n\n.team-list{\n list-style-type: none;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack:justify;\n -ms-flex-pack:justify;\n justify-content:space-between;\n}\n\n\n.team-list__photo{\n width:380px;\n height:470px;\n margin-bottom:30px;\n}\n\n.team-list__item{\n position: relative;\n font-size: 14px;\n width:380px;\n color: #333333;\n font-family: \"Montserrat\";\n font-weight: 400;\n text-align: center;\n text-transform: uppercase;\n margin-bottom:13px;\n \n}\n\n.team-list__item-position{\n position:relative;\n font-size: 15px;\n line-height: 24px;\n color: #999999;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n text-align: center;\n}\n\n.team-list__overlay{\n position: absolute;\n width:380px;\n height:470px;\n /* background-color: #f38181; */\n left:0px;\n top:0px;\n opacity: 0;\n -webkit-transition: all 0.2s linear;\n -o-transition: all 0.2s linear;\n transition: all 0.2s linear;\n}\n\n.team-list__overlay_pavel{\n background-image: -webkit-gradient(linear,left top, left bottom,from(rgba(243,129,129,0.9)),to(rgba(251,227,137,0.9))), url(\"../img/team-pavel.png\");\n background-image: -o-linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-pavel.png\");\n background-image: linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-pavel.png\");\n}\n\n.team-list__overlay_artem{\n background-image: -webkit-gradient(linear,left top, left bottom,from(rgba(243,129,129,0.9)),to(rgba(251,227,137,0.9))), url(\"../img/team-artem.png\");\n background-image: -o-linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-artem.png\");\n background-image: linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-artem.png\");\n}\n\n.team-list__overlay_igor{\n background-image: -webkit-gradient(linear,left top, left bottom,from(rgba(243,129,129,0.9)),to(rgba(251,227,137,0.9))), url(\"../img/team-igor.png\");\n background-image: -o-linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-igor.png\");\n background-image: linear-gradient(rgba(243,129,129,0.9),rgba(251,227,137,0.9)), url(\"../img/team-igor.png\");\n}\n\n.team-list__overlay:hover{\n left:-10px;\n top:-10px;\n -webkit-box-shadow: 10px 10px 0 #95e1d3;\n box-shadow: 10px 10px 0 #95e1d3;\n opacity: 1;\n}\n\n.social-list{\n height: inherit;\n list-style-type: none;\n display:-webkit-box;\n display:-ms-flexbox;\n display:flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.social-list__link{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n width: 56px;\n height: 56px;\n background-color: #fce38a;\n margin-right: 1px;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-transition: background-color 0.2s linear;\n -o-transition: background-color 0.2s linear;\n transition: background-color 0.2s linear;\n}\n\n.social-list__link:hover{\n background-color: #f38181;\n fill:#fce38a;\n}\n\n.social-list__icon{\n width: 26px;\n height: 26px;\n fill:#f38181;\n}\n\n.social-list__link:hover .social-list__icon{\n fill:#ffffff;\n}\n\n.footer{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: justify;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n min-height: 62px;\n border-top: 1px solid #e5e5e5;;\n}\n\n.form-imail{\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n\n.copyright{\n font-size: 14px;\n color: #333333;\n font-family: \"Montserrat\";\n font-weight: 400;\n}\n\n.copyright span{\n color:#f38181;\n}\n\n.form-imail__input{\n width: 230px;\n height: 40px;\n border: 1px solid #e7e7e7;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding-left: 12px;\n}\n\n.form-imail__input::-webkit-input-placeholder{\n font-size: 15px;\n line-height: 24px;\n color: #cccccc;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n}\n\n.form-imail__input::-moz-placeholder{\n font-size: 15px;\n line-height: 24px;\n color: #cccccc;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n}\n\n.form-imail__input:-ms-input-placeholder{\n font-size: 15px;\n line-height: 24px;\n color: #cccccc;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n}\n\n.form-imail__input::-ms-input-placeholder{\n font-size: 15px;\n line-height: 24px;\n color: #cccccc;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n}\n\n.form-imail__input::placeholder{\n font-size: 15px;\n line-height: 24px;\n color: #cccccc;\n font-family: \"Roboto\";\n font-weight: 300;\n font-style: italic;\n}\n\n.form-imail__button{\n width: 150px;\n height: 40px;\n background-color: #95e1d3;\n font-size: 14px;\n color: #ffffff;\n font-family: \"Montserrat\";\n font-weight: 700;\n text-align: center;\n text-transform: uppercase;\n border:0;\n}\n\n.form-imail__button:hover{\n cursor:pointer;\n}"},"directory_id":{"kind":"string","value":"2cb5e343e287b4424a496a9de41ffe373b962b56"},"languages":{"kind":"list like","value":["CSS"],"string":"[\n \"CSS\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"CSS"},"repo_name":{"kind":"string","value":"LysakArtem/goit-html-css-module10"},"revision_id":{"kind":"string","value":"9da581eb40ba586027b264af9e16ba70fa286a51"},"snapshot_id":{"kind":"string","value":"86ebcf1f57c9e54c689a97c94801e04dc2020478"}}},{"rowIdx":9970,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"lightyblog/django-lightyblog/lightyblog/admin.py\n# -*- coding: utf-8 -*-\n\n#/////////////////////////////////////////////////////////////////\nfrom django.contrib import admin\n#-----------------------------------------------------------------\nfrom lightyblog.models import Article\n\n#/////////////////////////////////////////////////////////////////\n# Enalbed for easy debugging, while coding \nclass ArticleAdmin(admin.ModelAdmin):\n list_display = ('title', 'message', 'is_approved', 'created')\n ordering = ('-created',)\nadmin.site.register(Article, ArticleAdmin)\n\n/lightyblog/templates/adminpanel/delete.html\n{% extends \"theme.html\" %}\n{% load i18n %}\n\n{% block head %}\n {% if success %}\n \n {% endif %}\n{% endblock %}\n\n\n{% block adminIndex %}\n

    \n \"\"/\n Lightyblog &#187 \n {{post.title}}\n &#187 \n {% trans 'Deleted' %} \n

    \n \n
    \n \n {% if success %}\n
    \n \"\"/\n

    \n {% trans 'The article was deleted successfully!' %}\n
    \n {% endif %}\n \n{% endblock %}\n/lightyblog/templates/theme.html\n{% load i18n %}\n\n\n\n \n \n \n \n \">\n \n \n Lightyblog &#187; {% block themeTitle %} {% endblock %} \n \n \n \n \n \n {% block head %}{% endblock %} \n \n\n \n \n\n {% block presentationIndex %}{% endblock %}\n\n
    \n {% block coreIndex %}{% endblock %}\n {% block adminIndex %}{% endblock %}\n {% block loginIndex %}{% endblock %}\n
    \n \n
    \n
    \n

    Lightyblog &copy; 2014

    \n
    \n
    \n \n\n/lightyblog/templates/404.html\n{% extends \"theme.html\" %}\n{% load i18n %}\n\n{% block head %}{% endblock %}\n\n{% block coreIndex %}\n

    \n \n
    \n {% trans 'Sorry, page was not found!' %}\n

    \n{% endblock %}\n\n/lightyblog/urls.py\n#/////////////////////////////////////////////////////////////////\nfrom django.conf.urls import patterns, include, url\n\n#/////////////////////////////////////////////////////////////////\n# Django Admin \nfrom django.contrib import admin\nadmin.autodiscover()\n\n#/////////////////////////////////////////////////////////////////\n# Lightyblog - App urls\nurlpatterns = patterns('',\n url(r'^$', 'lightyblog.views.index',),\n url(r'^article/(?P\\d+)/$', 'lightyblog.views.article'),\n url(r'^latest-article/$', 'lightyblog.views.latest'),\n url(r'^admin/list-article/', 'lightyblog.views.list',),\n url(r'^admin/create-article/', 'lightyblog.views.create',),\n url(r'^admin/edit-article/(?P\\d+)/$', 'lightyblog.views.edit',),\n url(r'^admin/delete-article/(?P\\d+)/$', 'lightyblog.views.delete',),\n)\n\n#/////////////////////////////////////////////////////////////////\n# Django Admin urls\nurlpatterns += patterns('',\n url(r'^admin/', include(admin.site.urls)),\n url(r'^login/', 'django.contrib.auth.views.login'),\n)\n \n/lightyblog/forms.py\n# -*- coding: utf-8 -*-\n\nimport datetime\n#/////////////////////////////////////////////////////////////////\nfrom django import forms\nfrom django.conf import settings\nfrom django.utils.timezone import utc \n#-----------------------------------------------------------------\nfrom lightyblog.models import Article\n\n#/////////////////////////////////////////////////////////////////\nclass ArticleForm(forms.Form):\n \"\"\"\n Very basic form that will allow creation of new articles.\n \"\"\"\n\n # Article details\n # Captcha is recommended for avoiding muplitple entries being posted.\n title = forms.CharField(max_length=70, min_length=10, required=True)\n message = forms.CharField(widget=forms.Textarea) \n is_approved = forms.BooleanField(required=False)\n\n\n#/////////////////////////////////////////////////////////////////\ndef save_article(us,ti,me,ap):\n \"\"\"\n Basic method to save a new article. Error handling can be \n optimized to be more, user friendly. Logging for debugging.\n \"\"\"\n\n # Create django date for storing article \n cr = datetime.datetime.utcnow().replace(tzinfo=utc)\n \n # Advance error handing would be advised here.\n try: \n msg = Article(owner=us, title=ti, message=me, is_approved=ap, created=cr)\n msg.save()\n return True\n except:\n return False\n\n\n#/////////////////////////////////////////////////////////////////\n# Returns article's existing details\ndef get_article(articleid):\n \"\"\"\n Basic method to get data from database for editing an article.\n Error handling can be optimized further. Logging for debugging.\n \"\"\"\n \n # Initialize \n form = None\n\n # Get the article object based on id.\n try:\n article = Article.objects.get(id=articleid)\n \n # Generate form with database data\n form = ArticleForm(initial = {\n 'title': article.title,\n 'message': article.message,\n 'is_approved': article.is_approved, \n })\n\n except:\n # Loggin + correct error handling should be added. \n pass\n \n return form\n\n\n#/////////////////////////////////////////////////////////////////\n# Update the article.\ndef update_article(article,ti,me,ap):\n \"\"\"\n Basic method for applying changes / updating an article.\n Error handling can be optimized further. Logging for debugging.\n \"\"\"\n\n # Create django date for uddating article \n up = datetime.datetime.utcnow().replace(tzinfo=utc)\n \n # Apply changes and save \n try:\n article.title = ti\n article.message = me\n article.is_approved = ap\n article.created = up \n article.save()\n return True\n except:\n # Loggin + correct error handling should be added. \n return False\n\n\n#/////////////////////////////////////////////////////////////////\n# Delete the article.\ndef delete_article(article):\n \"\"\"\n Basic method for deleting an article.\n Logging for debugging.\n \"\"\"\n \n try:\n article.delete()\n return True\n except:\n # Loggin + correct error handling should be added. \n return False\n\n/lightyblog/settings.py\n#/////////////////////////////////////////////////////////////////\nimport os \n#-----------------------------------------------------------------\nfrom djangoappengine.settings_base import *\n#-----------------------------------------------------------------\n\n#/////////////////////////////////////////////////////////////////\nADMINS = (('Lightyblog', ''),)\nMANAGERS = ADMINS\n\n#/////////////////////////////////////////////////////////////////\n# Activate django-dbindexer for the default database\nDATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': DATABASES['default']}\nAUTOLOAD_SITECONF = 'indexes'\n\n#/////////////////////////////////////////////////////////////////\n# Get project directories\nROOT_DIR = os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]\nPROJECT_DIR = os.path.abspath(os.path.dirname(__file__))\n\n#/////////////////////////////////////////////////////////////////\n# Login/Admin settings\nLOGIN_REDIRECT_URL = '/admin/list-article'\nLOGIN_URL = '/login/'\nFORCE_SCRIPT_NAME = ''\n\n#/////////////////////////////////////////////////////////////////\nALLOWED_HOSTS = ['high-hue-532.appspot.com']\n\nTIME_ZONE = 'Europe/London'\n\n#/////////////////////////////////////////////////////////////////\nLANGUAGE_CODE = 'en-us'\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = False\nSITE_ID = 1\n\n#/////////////////////////////////////////////////////////////////\nMEDIA_ROOT = ''\nMEDIA_URL = ''\n\n#/////////////////////////////////////////////////////////////////\n# Static files and paths\nSTATIC_ROOT = PROJECT_DIR + '/static/'\nSTATIC_URL = '/static/'\n\nSTATICFILES_DIRS = (\n PROJECT_DIR + '/static/',\n)\n\nSTATICFILES_FINDERS = (\n 'django.contrib.staticfiles.finders.FileSystemFinder',\n 'django.contrib.staticfiles.finders.AppDirectoriesFinder',\n# 'django.contrib.staticfiles.finders.DefaultStorageFinder',\n)\n\n#/////////////////////////////////////////////////////////////////\n# Secret random key\nSECRET_KEY = ''\n\n#/////////////////////////////////////////////////////////////////\n# Template loaders\nTEMPLATE_LOADERS = (\n 'django.template.loaders.filesystem.Loader',\n 'django.template.loaders.app_directories.Loader',\n# 'django.template.loaders.eggs.Loader',\n)\n\n#/////////////////////////////////////////////////////////////////\n# Middlewares \nMIDDLEWARE_CLASSES = (\n # This loads the index definitions, so it has to come first\n 'autoload.middleware.AutoloadMiddleware',\n\n 'django.middleware.common.CommonMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.middleware.csrf.CsrfViewMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\n # 'django.middleware.clickjacking.XFrameOptionsMiddleware',\n)\n\n#/////////////////////////////////////////////////////////////////\nROOT_URLCONF = 'lightyblog.urls'\n\n#/////////////////////////////////////////////////////////////////\n# Template directories\nTEMPLATE_DIRS = (\n PROJECT_DIR + '/templates/',\n)\n\n#/////////////////////////////////////////////////////////////////\n# APPS\nINSTALLED_APPS = (\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n # 'django.contrib.sites',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n 'django.contrib.admin',\n 'djangotoolbox',\n 'autoload',\n 'dbindexer',\n 'lightyblog',\n\n # djangoappengine should come last, so it can override a few manage.py commands\n 'djangoappengine',\n)\n\n#/////////////////////////////////////////////////////////////////\n# logging \nLOGGING = {\n 'version': 1,\n 'disable_existing_loggers': False,\n 'filters': {\n 'require_debug_false': {\n '()': 'django.utils.log.RequireDebugFalse'\n }\n },\n 'handlers': {\n 'mail_admins': {\n 'level': 'ERROR',\n 'filters': ['require_debug_false'],\n 'class': 'django.utils.log.AdminEmailHandler'\n }\n },\n 'loggers': {\n 'django.request': {\n 'handlers': ['mail_admins'],\n 'level': 'ERROR',\n 'propagate': True,\n },\n }\n}\n/README.md\ndjango-lightyblog\n=================\n\nA django lightweight demo-app for running a minimalistic blog on google-app-engine\n\nLive demo\n------------------------------------\n\nGoogle App Engine: http://high-hue-532.appspot.com/\n\nUsername: admin | Password: >\n\nWeb goodies used:\n\nBootstrap 3.0 » templates\n
    \njmpress » presentation\n
    \ndjango-norel » collection of packages\n
    \n\nRepo contains the full project folder, at it was pushed on the appspot.com for the demo.\n\nScreenshots\n------------------------------------\n\n![Admin Listing Articles](https://github.com/lightyblog/django-lightyblog/blob/master/lightyblog/doc/screenshots/lightyblog-admin.png)\n\n![Bootstrap Login](https://github.com/lightyblog/django-lightyblog/blob/master/lightyblog/doc/screenshots/lightyblog-login.png)\n\n![Blog Published Articles](https://github.com/lightyblog/django-lightyblog/blob/master/lightyblog/doc/screenshots/lightyblog-articles.png)\n\n![Editing Articles](https://github.com/lightyblog/django-lightyblog/blob/master/lightyblog/doc/screenshots/lightyblog-editing.png)\n\n\n/lightyblog/models.py\n# -*- coding: utf-8 -*-\n\n#/////////////////////////////////////////////////////////////////\nfrom django.db import models\n#-----------------------------------------------------------------\nfrom django.contrib.auth.models import User\nfrom django.utils.translation import ugettext_lazy as _\n\n#/////////////////////////////////////////////////////////////////\n# Articles\nclass Article(models.Model):\n\n \"\"\"\n Minimalistic class that models a blogging article post.\n Only very basic fields were added, since it is just PoC. \n \"\"\"\n \n # Relate each article with a user \n owner = models.ForeignKey(User, verbose_name = _(u'User'), related_name='article_owner')\n \n # Article basic information\n title = models.CharField(max_length=70, verbose_name = _(u'Title'))\n message = models.TextField(verbose_name = _(u'Article text'))\n created = models.DateField(verbose_name = _(u'Creation date'), auto_now_add=True)\n\n # Only approved posts will be visible\n is_approved = models.BooleanField(default=False, verbose_name = _(u'Approve articles'))\n\n # Some naming\n class Meta:\n verbose_name = _(u'Lightyblog articles')\n verbose_name_plural = _(u'Lightyblog articles')\n \n def __unicode__(self):\n return self.title\n/lightyblog/views.py\n# -*- coding: UTF-8 -*-\n\n#///////////////////////////////////////////////////\nfrom django.shortcuts import render\nfrom django.http import Http404\nfrom django.conf import settings\nfrom django.contrib.auth.decorators import login_required\n#---------------------------------------------------\nfrom lightyblog.models import Article\nfrom lightyblog.forms import ArticleForm\nfrom lightyblog.forms import save_article, get_article\nfrom lightyblog.forms import delete_article, update_article\n\n\n#///////////////////////////////////////////////////\n# The presentation link template\ndef index(request):\n \"\"\"\n A view that was added only for presentation context, that aims\n to help the developers to understand the reason of creating the \n Lightyblog demo-app.\n \"\"\"\n\n return render(request, 'core/index.html')\n\n\n#///////////////////////////////////////////////////\n# Preview of articles based on id, sidebar indexing\ndef article(request, articleid):\n \"\"\"\n Articles view that returns the 10 latest articles.\n If an exception is raised, then it returns a 404 error (for now).\n Logging should be added in order to catch the exception errors.\n Preview item becomes, the chosen id.\n \"\"\"\n try:\n # Logic can be optimized, if it was production code (TODOs - use get(id) instead).\n articles = Article.objects.all().filter(is_approved=True).order_by('-created')[:10]\n preview = Article.objects.all().filter(id=articleid)[:1]\n return render(request, 'core/articles.html', { 'preview':preview, 'articles':articles },) \n except:\n raise Http404\n\n\n#///////////////////////////////////////////////////\n# Preview the latest article\ndef latest(request):\n \"\"\"\n Articles view that returns the 10 latest articles.\n If an exception is raised, then it returns a 404 error (for now).\n Logging should be added in order to catch the exception errors.\n Preview item becomes, the 3 latest articles.\n \"\"\"\n\n try:\n articles = Article.objects.all().filter(is_approved=True).order_by('-created')[:10]\n preview = Article.objects.all().filter(is_approved=True).order_by('-created')[:6]\n return render(request, 'core/articles.html', { 'preview':preview, 'articles':articles },) \n except:\n # It should be logging instead (404 debugging reasons)\n raise Http404\n\n\n#/////////////////////////////////////////////////////////////////\n@login_required\ndef create(request):\n \"\"\"\n Custom view that create a new article.\n \"\"\"\n\n # Initialize\n title = message = ''\n is_approved = False \n\n # Create the article form\n form = ArticleForm()\n \n # Check for post request\n if request.method == 'POST': \n \n form = ArticleForm(request.POST)\n if form.is_valid(): \n \n # Getting User's Input \n title = form.cleaned_data['title']\n message = form.cleaned_data['message']\n is_approved = form.cleaned_data['is_approved']\n \n # Save article\n success = save_article(request.user,title,message,is_approved) \n \n if success:\n return render(request, 'adminpanel/create.html', { 'form':form, 'success':success},)\n \n # Return initial form\n return render(request, 'adminpanel/create.html', {'form': form, })\n\n\n#/////////////////////////////////////////////////////////////////\n@login_required\ndef edit(request, articleid):\n \"\"\"\n Custom view that edits the article based on id.\n \"\"\"\n\n # Initialize \n post = form = None \n \n try:\n post = Article.objects.get(id=articleid)\n form = get_article(articleid)\n except:\n # It should be logging instead (debugging reasons)\n pass\n\n # The concept of restricting someone to edit, it not the owner\n # but get the article id by viewing the source.\n # Obviously, that's a fast way to do it\n if request.user.id != post.owner.id:\n raise Http404\n \n # Check for post request\n if request.method == 'POST': \n \n form = ArticleForm(request.POST)\n\n if form.is_valid(): \n \n # Getting User's Input \n title = form.cleaned_data['title']\n message = form.cleaned_data['message']\n is_approved = form.cleaned_data['is_approved']\n \n # Update article\n success = update_article(post,title,message,is_approved) \n \n if success:\n return render(request, 'adminpanel/edit.html', { 'form':form, 'post':post, 'success':success},)\n\n return render(request, 'adminpanel/edit.html', { 'form':form, 'post':post, })\n\n\n#/////////////////////////////////////////////////////////////////\n@login_required\ndef delete(request, articleid):\n \"\"\"\n Custom view that deletes the article based on id.\n Could add confirmation before deleting, but I just decided \n to keep it simple.\n \"\"\"\n \n # Initialize \n post = None \n success = False \n\n try:\n post = Article.objects.get(id=articleid)\n except:\n # It should be logging (debugging reasons)\n pass\n \n # The idea of restricting someone to edit, it not the owner\n # but get the article id by viewing the source.\n # Obviously, that's a fast way to do it.\n if request.user.id != post.owner.id:\n raise Http404\n else:\n success = delete_article(post)\n\n return render(request,'adminpanel/delete.html', { 'post':post, 'success':success, })\n\n\n#/////////////////////////////////////////////////////////////////\n@login_required\ndef list(request):\n \"\"\"\n Custom view that lists all user's articles.\n \"\"\"\n\n try:\n posts = Article.objects.all().filter(owner__id=request.user.id)\n except:\n # It should be logging instead (404 debugging reasons)\n raise Http404\n \n return render(request,'adminpanel/list.html', { 'posts':posts, })\n/lightyblog/templates/adminpanel/list.html\n{% extends \"theme.html\" %}\n{% load i18n %}\n\n{% block head %}{% endblock %}\n\n{% block adminIndex %}\n

    \n \"\"/\n Lightyblog &#187 {% trans 'My articles' %}\n

    \n \n {% if posts %}\n \n {% for post in posts %}\n \n \n \n \n \n \n {% endfor %}\n
    \n {{post.created}}\n \n \n {{post.title}}\n \n \n {% trans 'Edit' %}\n \n {% trans 'Delete' %}\n
    \n {% else %}\n
    \n

    \n {% trans 'You do not have any articles published!' %}\n

    \n \"\"/\n

    \n {% endif %}\n{% endblock %}\n/settings.py\nfrom lightyblog.settings import *\n"},"directory_id":{"kind":"string","value":"9e971ff79e2246aa1592e809b8b18601651e36cb"},"languages":{"kind":"list like","value":["Markdown","HTML","Python"],"string":"[\n \"Markdown\",\n \"HTML\",\n \"Python\"\n]"},"num_files":{"kind":"number","value":12,"string":"12"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"lightyblog/django-lightyblog"},"revision_id":{"kind":"string","value":"d1d6e102b2835043f4f9dd1ff6001d20b895a430"},"snapshot_id":{"kind":"string","value":"ce7544a3198a376b23649698c66349b75600d2f4"}}},{"rowIdx":9971,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"AhYunCH/MusicInd./login.php\n\r\n\r\n\";\r\n $password2 = \"\";\r\n $log = 0;\r\n\r\n if ($user == \"MARY\" && $pw == \"Aa123456\" || $user == \"PETER\" && $pw == \"Bb123456\"){\r\n echo \"

    Login successful

    \";\r\n echo(\"\");\r\n }else {\r\n echo \"

    Login failed. Invalid username or password.

    \";\r\n echo(\"\");\r\n }\r\n\t ?>\r\n"},"directory_id":{"kind":"string","value":"208f41c53fe72ceddc7327f80cf2d5231ae3051d"},"languages":{"kind":"list like","value":["PHP"],"string":"[\n \"PHP\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"PHP"},"repo_name":{"kind":"string","value":"AhYunCH/MusicInd."},"revision_id":{"kind":"string","value":"29cb9256ad84a9f0bfd2c1da95d72e35839f5d92"},"snapshot_id":{"kind":"string","value":"af039136a4354875d6faac8aace80b7430ea41a8"}}},{"rowIdx":9972,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"BenitezAxel/portfolio/confirmacion_envio.php\n\n\n\n\n \n \n Contacto\n \" crossorigin=\"anonymous\">\n \n \n \n \n \n \n\n\n\n
    \n \n
    \n
    \n
    \n
    \n
    \n

    ¡Gracias por
    contactarte!

    \n
    \n
    \n

    Te responderemos a la brevedad

    \n
    \n
    \n
    \n
    \n
    \n
    \n \n\n\n/css/estilos.css\nbody{\n font-family: 'Montserrat', sans-serif;\n background-color: #eeeeee;\n}\nnav{\n width: max-content;\n margin: auto;\n}\nnav .nav-link{\n color: #4b4b4b;\n text-transform:uppercase;\n font-size: 20px;\n text-align: center;\n margin-top: 15px;\n margin-left: 10px;\n}\nnav .nav-link:hover{\n color: #0056b3;\n text-decoration: none;\n}\nnav .active:hover{\n text-decoration: none;\n}\nnav .active{\n font-weight: bold;\n text-decoration: underline;\n}\nnav .nav-item{\n width: 250px;\n}\nh1{\n font-size: 55px;\n font-weight: 800;\n}\nh2{\n font-size: 30px;\n font-weight: 700;\n}\n.btn{\n background-color: black !important;\n color: #eeeeee;\n border-radius: 0;\n transition: color .15s;\n display: inline-block;\n line-height: 1.5;\n text-align: center;\n}\n.btn:hover{\n color: black;\n background-color: white !important;\n border: 1px solid black;\n}\n\n.form-control{\n background-color:#eeeeee;\n border: 0;\n border-bottom: 1px solid #4b4b4b;\n border-radius: 0;\n font-size: 18px;\n}\nfooter{\n background-color: white;\n}\nfooter a{\n color: black;\n text-decoration: underline;\n}\nfooter i{\n font-size: 35px;\n border: 1px solid;\n height: 55px;\n width: 55px;\n text-align: center;\n padding: 8px 0 0 0;\n border-radius: 80px;\n margin: 0 15px;\n}\n.text-left{\n text-decoration: underline;\n font-weight: bold;\n}\n.text-right a{\n font-weight: bold;\n}\n#proyectos h2{\n font-size: 22px;\n font-weight: 500;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n display: block;\n}\n#proyectos h3{\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n display: block;\n margin-bottom: .5rem;\n line-height: 1.2;\n \n}\n#proyectos p{\n font-size: 17px;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n display: block;\n \n}\n#proyectos img{\n height: 260px;\n width: 100%;\n}\n#proyectos .img-fluid{\n max-width: 100%;\n}\n#proyectos .btn{\n background-color: black;\n color: #eeeeee;\n border-radius: 0;\n transition: color .15s;\n display: inline-block;\n line-height: 1.5;\n text-align: center;\n}\n#proyectos .btn:hover{\n color: black;\n background-color: white;\n border: 1px solid black;\n}\n#sobre-mi h2{\n font-weight: 500;\n font-size: 22px;\n line-height: 40px;\n margin-bottom: .5rem;\n margin-block-start: 0.83em;\n margin-block-end: 0.83em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n}\n#sobre-mi h1{\n font-size: 55px;\n line-height: 40px;\n margin-block-start: 0.83em;\n margin-block-end: 0.83em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n padding-bottom: 10px;\n}\n#sobre-mi .btn{\n background-color: black;\n color: #eeeeee;\n border-radius: 0;\n transition: color .15s;\n display: inline-block;\n line-height: 1.5;\n text-align: center;\n}\n#sobre-mi .btn:hover{\n color: black;\n background-color: white;\n border: 1px solid black;\n}\n#sobre-mi .img-circle{\n margin: 1em auto;\n display: block;\n background-color: #fff;\n padding: 10px;\n border-radius: 50%;\n}\n#sobre-mi .img-fluid{\n max-width: 100%;\n height: auto;\n}\n#sobre-mi i{\n background-color: black;\n color: white;\n padding: 30px;\n font-size: 40px;\n}\n#sobre-mi .bg-white{\n min-height: 300px;\n background-color: white !important;\n color: #212529;\n text-align: left;\n font-size: 1rem;\n font-weight: 400;\n line-height: 1.5;\n}\n#experiencia{\n background-color: rgb(45, 45, 45);\n}\n#experiencia h2{\n color: white;\n font-size: 45px;\n line-height: 1.2;\n margin-bottom: 30px;\n}\n#experiencia h3{\n color: white;\n font-size: 20px;\n line-height: 1.2;\n margin-bottom: 50px;\n}\n#experiencia h4{\n color: white;\n font-size: 20px;\n line-height: 1.2;\n margin-bottom: 50px;\n}\n#home{\n background-image: url(../images/Fondos-06.png);\n background-repeat: repeat;\n background-size: 100%;\n height: 81vh;\n}\n#home .container-fluid{\n width: 100%;\n padding-left: 15px;\n padding-right: 15px;\n margin-left: auto;\n margin-right: auto;\n}\n#home h2{\n font-size: 22px;\n line-height: 40px;\n color: rgb(45, 45, 45);\n font-weight: 500;\n margin-top: 25px;\n}\n#home .btn{\n background-color: black;\n color: #eeeeee;\n border-radius: 0;\n transition: color .15s;\n display: inline-block;\n line-height: 1.5;\n text-align: center;\n margin-top: 25px;\n}\n#home .btn:hover{\n color: black;\n background-color: white;\n border: 1px solid black;\n}\n/sobre-mi.php\n\n\n\n\n\n \n \n Sobre Mi\n \" crossorigin=\"anonymous\">\n \n \n \n \n \n \n\n\n\n
    \n \n
    \n
    \n
    \n
    \n
    \n

    Sobre mi

    \n

    Apasionado por la tecnología y gestión de proyectos. Soy una persona en constante movimiento esforzandome y aprendiendo \n sobre nuevas tecnologías, para ofrecer un mejor rendimiento en las diferentes tareas que se me presenten.

    \n Descargar CV\n
    \n
    \n \"<NAME\" class=\"img-fluid img-circle\">\n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    PROGRAMACION

    \n
    \n
    \n
    \n
    \n

    HTML, CSS, Bootstrap, C#.

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    BASE DE DATOS

    \n
    \n
    \n
    \n
    \n

    MySQL.

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    SERVIDORES

    \n
    \n
    \n
    \n
    \n

    XAMPP.

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    IDIOMAS

    \n
    \n
    \n
    \n
    \n

    INGLES - Principiante A1

    \n
    \n \"ESPAÑOL - Nativo\"\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    SOFTWARE

    \n
    \n
    \n
    \n
    \n

    GitHub, Visual Code, Sublime, Filezilla, SSH Putty, MySQL Workbench, Adobe Photoshop, MS\n Office, Google Docs.

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n

    HOBBIES

    \n
    \n
    \n
    \n
    \n

    Escuchar musica, Armado de PC.

    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n

    Experiencia Laboral

    \n
    \n
    \n
    \n
    \n

    2019 - 2020 -
    La Rambla

    \n
    \n
    \n \"La\n
    \n
    \n

    \"Realice todo tipo de tareas relacionadas a la gastronomia, como limpieza del\n establecimiento, bachero, ayudante de cocina y delivery\"

    \n
    \n
    \n
    \n
    \n \n \n\n\n/index.php\n\n\n\n\n \n \n Inicio\n \" crossorigin=\"anonymous\">\n \n \n \n \n \n \n\n\n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n

    Hola!
    Bievenido a mi web

    \n

    \n Conoce mis proyectos\n
    \n
    \n
    \n
    \n
    \n \n\n/proyectos.php\n\n\n\n\n\n \n \n Proyectos\n \" crossorigin=\"anonymous\">\n \n \n \n \n \n \n\n\n\n
    \n \n
    \n
    \n
    \n
    \n
    \n

    Mis proyectos

    \n
    \n
    \n
    \n
    \n

    Estos son algunos de los trabajos que he realizado:

    \n
    \n
    \n
    \n
    \n
    \n \"abmclientes\"\n
    \n
    \n

    ABM Clientes

    \n
    \n
    \n
    \n
    \n

    Alta, Baja, modificación de un registro de clientes empleando:. Realizado en HTML,\n CSS, PHP, Bootstrap y Json.\n

    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n \"ABM\n
    \n
    \n

    Sistema de Gestion de ventas

    \n
    \n
    \n
    \n
    \n

    Sistema de gestión de clientes, productos y ventas. Realizado en HTML, CSS,\n PHP, MVC,\n Bootstrap, Js, Ajax, jQuery y MySQL de base de datos.\n

    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n \"sistema-admin\"\n
    \n
    \n

    Proyecto integrador

    \n
    \n
    \n
    \n
    \n

    Proyecto Full Stack desarrollado en PHP, Laravel, Javascript, jQuery, AJAX, HTML,\n CSS, con panel administrador, gestor de usuarios, módulo de permisos y\n funcionalidades a fines.

    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n \n\n\n/footer.php\n"},"directory_id":{"kind":"string","value":"7aa58900afde89aa644b8f79c157ba285e742324"},"languages":{"kind":"list like","value":["CSS","PHP"],"string":"[\n \"CSS\",\n \"PHP\"\n]"},"num_files":{"kind":"number","value":6,"string":"6"},"repo_language":{"kind":"string","value":"CSS"},"repo_name":{"kind":"string","value":"BenitezAxel/portfolio"},"revision_id":{"kind":"string","value":"725b8f5f3905a0d8981d1d463dff284d33fb8bc5"},"snapshot_id":{"kind":"string","value":"c73ed1b1c2ddc94d8f57cc8e461b980936cc4a26"}}},{"rowIdx":9973,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"pratyushjs/holofy/src/App.js\nimport React, { useEffect, useState } from \"react\";\nimport \"./App.css\";\n\nimport DragNDrop from \"./components/DragNDrop\";\n\nconst defaultData = [\n { title: \"group 1\", items: [1] },\n { title: \"group 2\", items: [] },\n { title: \"group 3\", items: [] },\n { title: \"group 4\", items: [] },\n];\n\nfunction App() {\n const [data, setData] = useState();\n\n useEffect(() => {\n if (localStorage.getItem(\"List\")) {\n console.log(localStorage.getItem(\"List\"));\n setData(JSON.parse(localStorage.getItem(\"List\")));\n } else {\n setData(defaultData);\n }\n }, [setData]);\n\n return (\n
    \n \n
    \n );\n}\n\nexport default App;\n"},"directory_id":{"kind":"string","value":"1fae89bf81ee1eb2b727acdedac4a492be98606c"},"languages":{"kind":"list like","value":["JavaScript"],"string":"[\n \"JavaScript\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"JavaScript"},"repo_name":{"kind":"string","value":"pratyushjs/holofy"},"revision_id":{"kind":"string","value":"d0d7f120c52f47440cb4c4425e68e5e146dc6fb7"},"snapshot_id":{"kind":"string","value":"692a84dac1a39253dfd556bab840d99684f67f61"}}},{"rowIdx":9974,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"# clean-node-api\nCurso Gratuito de NodeJS onde aprendi mais sobre TDD, Clean Architecture e Design Patterns.\n"},"directory_id":{"kind":"string","value":"0c3723c835dc8dc4cee17757008271cb0a8207ce"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"moutlender/clean-node-api"},"revision_id":{"kind":"string","value":"6e6b674505ecb685495da13fc61f26f93675ab98"},"snapshot_id":{"kind":"string","value":"28f5ff6ee1bfb05b014c23abfdbb36ef85b8fef1"}}},{"rowIdx":9975,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"package main\n\nimport (\n\t\"encoding/xml\"\n\t\"github.com/tlarsen7572/goalteryx/sdk\"\n)\n\ntype Configuration struct {\n\tText1 string\n\tText2 string\n\tOutputField string\n}\n\ntype DiceCoefficientPlugin struct {\n\tconfiguration Configuration\n\tprovider sdk.Provider\n\thasError bool\n\ttext1 sdk.IncomingStringField\n\ttext2 sdk.IncomingStringField\n\toutgoingInfo *sdk.OutgoingRecordInfo\n\tscoreField sdk.OutgoingFloatField\n\toutput sdk.OutputAnchor\n}\n\nfunc (p *DiceCoefficientPlugin) Init(provider sdk.Provider) {\n\tp.provider = provider\n\terr := xml.Unmarshal([]byte(provider.ToolConfig()), &p.configuration)\n\tif err != nil {\n\t\tp.sendError(err)\n\t\treturn\n\t}\n\tp.output = provider.GetOutputAnchor(`Output`)\n}\n\nfunc (p *DiceCoefficientPlugin) OnInputConnectionOpened(connection sdk.InputConnection) {\n\tvar err error\n\tincomingInfo := connection.Metadata()\n\tp.text1, err = incomingInfo.GetStringField(p.configuration.Text1)\n\tif err != nil {\n\t\tp.sendError(err)\n\t\treturn\n\t}\n\tp.text2, err = incomingInfo.GetStringField(p.configuration.Text2)\n\tif err != nil {\n\t\tp.sendError(err)\n\t\treturn\n\t}\n\teditor := incomingInfo.Clone()\n\toutgoingField := editor.AddDoubleField(p.configuration.OutputField, `Dice Coefficient (Go)`)\n\tp.outgoingInfo = editor.GenerateOutgoingRecordInfo()\n\tp.scoreField, _ = p.outgoingInfo.FloatFields[outgoingField]\n\tp.output.Open(p.outgoingInfo)\n}\n\nfunc (p *DiceCoefficientPlugin) OnRecordPacket(connection sdk.InputConnection) {\n\tpacket := connection.Read()\n\tfor packet.Next() {\n\t\tp.outgoingInfo.CopyFrom(packet.Record())\n\t\ttext1, isNull1 := p.text1.GetValue(packet.Record())\n\t\ttext2, isNull2 := p.text2.GetValue(packet.Record())\n\t\tif isNull1 || isNull2 {\n\t\t\tp.scoreField.SetFloat(0)\n\t\t\tp.output.Write()\n\t\t\tcontinue\n\t\t}\n\t\tscore := CalculateDiceCoefficient(text1, text2)\n\t\tp.scoreField.SetFloat(score)\n\t\tp.output.Write()\n\t}\n\tp.output.UpdateProgress(connection.Progress())\n}\n\nfunc (p *DiceCoefficientPlugin) OnComplete() {\n\n}\n\nfunc (p *DiceCoefficientPlugin) sendError(err error) {\n\tp.hasError = true\n\tp.provider.Io().Error(err.Error())\n}\n# Copyright (C) 2021 Alteryx, Inc. All rights reserved.\n#\n# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Example pass through tool.\"\"\"\nfrom ayx_plugin_sdk.core import (\n InputConnectionBase,\n Plugin,\n ProviderBase,\n register_plugin,\n FieldType,\n RecordPacket,\n)\n\n\ndef dice_coefficient(a, b):\n if a is None or b is None: return 0.0\n if not len(a) or not len(b): return 0.0\n \"\"\" quick case for true duplicates \"\"\"\n if a == b: return 1.0\n \"\"\" if a != b, and a or b are single chars, then they can't possibly match \"\"\"\n if len(a) == 1 or len(b) == 1: return 0.0\n\n \"\"\" use python list comprehension, preferred over list.append() \"\"\"\n a_bigram_list = [a[i:i + 2] for i in range(len(a) - 1)]\n b_bigram_list = [b[i:i + 2] for i in range(len(b) - 1)]\n\n a_bigram_list.sort()\n b_bigram_list.sort()\n\n # assignments to save function calls\n lena = len(a_bigram_list)\n lenb = len(b_bigram_list)\n # initialize match counters\n matches = i = j = 0\n while (i < lena and j < lenb):\n if a_bigram_list[i] == b_bigram_list[j]:\n matches += 1\n i += 1\n j += 1\n elif a_bigram_list[i] < b_bigram_list[j]:\n i += 1\n else:\n j += 1\n\n score = float(2 * matches) / float(lena + lenb)\n return score\n\n\nclass python_dice_coefficient(Plugin):\n \"\"\"A sample Plugin that passes data from an input connection to an output connection.\"\"\"\n\n def __init__(self, provider: ProviderBase):\n \"\"\"Construct the AyxRecordProcessor.\"\"\"\n self.name = \"Pass through\"\n self.provider = provider\n self.text1 = provider.tool_config['Text1']\n self.text2 = provider.tool_config['Text2']\n self.outputField = provider.tool_config['OutputField']\n self.output_anchor = self.provider.get_output_anchor(\"Output\")\n self.output_metadata = None\n\n def on_input_connection_opened(self, input_connection: InputConnectionBase) -> None:\n\n \"\"\"Initialize the Input Connections of this plugin.\"\"\"\n if input_connection.metadata is None:\n raise RuntimeError(\"Metadata must be set before setting containers.\")\n\n input_connection.max_packet_size = 1000\n self.output_metadata = input_connection.metadata.clone()\n self.output_metadata.add_field(self.outputField, FieldType.double, source=\"Dice Coefficient (Python)\")\n self.output_anchor.open(self.output_metadata)\n\n def on_record_packet(self, input_connection: InputConnectionBase) -> None:\n \"\"\"Handle the record packet received through the input connection.\"\"\"\n packet = input_connection.read()\n df = packet.to_dataframe()\n df[self.outputField] = df.apply(self.score_row, axis=1)\n out_packet = RecordPacket.from_dataframe(df=df, metadata=self.output_metadata)\n self.output_anchor.write(out_packet)\n\n def on_complete(self) -> None:\n \"\"\"Handle for when the plugin is complete.\"\"\"\n\n def score_row(self, row):\n return dice_coefficient(row[self.text1], row[self.text2])\n\n\nAyxPlugin = register_plugin(python_dice_coefficient)\nmodule go_dice_coefficient\n\ngo 1.15\n\nrequire github.com/tlarsen7572/goalteryx v0.5.6\npackage main_test\n\nimport (\n\t\"encoding/xml\"\n\t\"github.com/tlarsen7572/goalteryx/sdk\"\n\t\"math\"\n\t\"testing\"\n)\nimport dc \"go_dice_coefficient\"\n\nfunc TestConfigUnmarshal(t *testing.T) {\n\tconfigStr := `\n First\n Second\n Match Score\n`\n\tconfig := dc.Configuration{}\n\terr := xml.Unmarshal([]byte(configStr), &config)\n\tif err != nil {\n\t\tt.Fatalf(`expected no error but got: %v`, err.Error())\n\t}\n\tif config.Text1 != `First` {\n\t\tt.Fatalf(`expected 'First' but got '%v'`, config.Text1)\n\t}\n\tif config.Text2 != `Second` {\n\t\tt.Fatalf(`expected 'Second' but got '%v'`, config.Text1)\n\t}\n\tif config.OutputField != `Match Score` {\n\t\tt.Fatalf(`expected 'Match Score' but got '%v'`, config.Text1)\n\t}\n}\n\nfunc TestScoreCalc(t *testing.T) {\n\tscore := dc.CalculateDiceCoefficient(``, ``)\n\tif score != 1.0 {\n\t\tt.Fatalf(`expected 1 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(``, ``)\n\tif score != 0.0 {\n\t\tt.Fatalf(`expected 0 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(``, ``)\n\tif score != 0.0 {\n\t\tt.Fatalf(`expected 0 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(``, `a`)\n\tif score != 0.0 {\n\t\tt.Fatalf(`expected 0 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(``, ``)\n\tif math.Abs(score-0.83333) > 0.0001 {\n\t\tt.Fatalf(`expected 0.833333333333333 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(`Hello World`, `How are you`)\n\tif score != 0 {\n\t\tt.Fatalf(`expected 0 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(`night`, `nacht`)\n\tif math.Abs(score-0.25) > 0.0001 {\n\t\tt.Fatalf(`expected 0.25 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(`AA`, `AAAA`)\n\tif math.Abs(score-0.5) > 0.0001 {\n\t\tt.Fatalf(`expected 0.5 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(`AAAA`, `AAAAAA`)\n\tif math.Abs(score-0.75) > 0.0001 {\n\t\tt.Fatalf(`expected 0.75 but got %v`, score)\n\t}\n\tscore = dc.CalculateDiceCoefficient(`12121212`, `12345678`)\n\tif math.Abs(score-0.142857) > 0.0001 {\n\t\tt.Fatalf(`expected 0.142857 but got %v`, score)\n\t}\n}\n\nfunc TestEndToEnd(t *testing.T) {\n\tconfig := `\n Text1\n Text2\n Match Score\n`\n\tplugin := &dc.DiceCoefficientPlugin{}\n\trunner := sdk.RegisterToolTest(plugin, 1, config)\n\trunner.ConnectInput(`Input`, `testdata.txt`)\n\toutput := runner.CaptureOutgoingAnchor(`Output`)\n\trunner.SimulateLifecycle()\n\n\tscores, ok := output.Data[`Match Score`]\n\tif !ok {\n\t\tt.Fatalf(`expected a Match Score field but it did not exist`)\n\t}\n\n\tif len(scores) != 6 {\n\t\tt.Fatalf(`expected 6 rows but got %v`, len(scores))\n\t}\n\n\tif scores[0] != 0.25 {\n\t\tt.Fatalf(`expected first row score to be 0.25 but got %v`, scores[0])\n\t}\n\n\tif scores[3] != 0.0 {\n\t\tt.Fatalf(`expected fourth row score to be 0 but got %v`, scores[3])\n\t}\n}\npackage main\n\nimport \"sort\"\n\nfunc CalculateDiceCoefficient(text1 string, text2 string) float64 {\n\tif text1 == `` || text2 == `` {\n\t\treturn 0\n\t}\n\tif text1 == text2 {\n\t\treturn 1\n\t}\n\tif len(text1) == 0 || len(text2) == 0 {\n\t\treturn 0\n\t}\n\tbigrams1 := generateSortedBigrams(text1)\n\tbigrams2 := generateSortedBigrams(text2)\n\treturn scoreBigrams(bigrams1, bigrams2)\n}\n\ntype bigram struct {\n\tdigit1 rune\n\tdigit2 rune\n}\n\nfunc (b bigram) equals(other bigram) bool {\n\treturn b.digit1 == other.digit1 && b.digit2 == other.digit2\n}\n\nfunc (b bigram) lessThan(other bigram) bool {\n\treturn b.digit1 < other.digit1 ||\n\t\t(b.digit1 == other.digit1 && b.digit2 < other.digit2)\n}\n\nfunc generateSortedBigrams(text string) []bigram {\n\tstart := 0\n\trunes := []rune(text)\n\tbigrams := make([]bigram, len(runes)-1)\n\tfor end := 1; end < len(runes); end++ {\n\t\tbigrams[start] = bigram{runes[start], runes[end]}\n\t\tstart++\n\t}\n\tsort.Slice(bigrams, func(i int, j int) bool {\n\t\treturn bigrams[i].lessThan(bigrams[j])\n\t})\n\treturn bigrams\n}\n\nfunc scoreBigrams(bigrams1 []bigram, bigrams2 []bigram) float64 {\n\ti1 := 0\n\ti2 := 0\n\tmatches := 0\n\n\tfor i1 < len(bigrams1) && i2 < len(bigrams2) {\n\t\tif bigrams1[i1].equals(bigrams2[i2]) {\n\t\t\tmatches++\n\t\t\ti1++\n\t\t\ti2++\n\t\t\tcontinue\n\t\t}\n\t\tif bigrams1[i1].lessThan(bigrams2[i2]) {\n\t\t\ti1++\n\t\t\tcontinue\n\t\t}\n\t\ti2++\n\t}\n\n\treturn float64(matches*2) / float64(len(bigrams1)+len(bigrams2))\n}\npackage main\n\nimport \"C\"\nimport (\n\t\"github.com/tlarsen7572/goalteryx/sdk\"\n\t\"unsafe\"\n)\n\nfunc main() {}\n\n//export PluginEntry\nfunc PluginEntry(toolId C.int, xmlProperties unsafe.Pointer, engineInterface unsafe.Pointer, pluginInterface unsafe.Pointer) C.long {\n\tplugin := &DiceCoefficientPlugin{}\n\treturn C.long(sdk.RegisterTool(plugin, int(toolId), xmlProperties, engineInterface, pluginInterface))\n}\nimport AlteryxPythonSDK as Sdk\nimport xml.etree.ElementTree as Et\n\n\nclass AyxPlugin:\n def __init__(self, n_tool_id: int, alteryx_engine: object, output_anchor_mgr: object):\n # Default properties\n self.n_tool_id: int = n_tool_id\n self.alteryx_engine: Sdk.AlteryxEngine = alteryx_engine\n self.output_anchor_mgr: Sdk.OutputAnchorManager = output_anchor_mgr\n self.label = \"Dice Coefficient\"\n\n # Custom properties\n self.Output: Sdk.OutputAnchor = None\n self.OutputField: str = None\n self.Text1: str = None\n self.Text2: str = None\n\n def pi_init(self, str_xml: str):\n xml_parser = Et.fromstring(str_xml)\n self.OutputField = xml_parser.find(\"OutputField\").text if 'OutputField' in str_xml else ''\n self.Text1 = xml_parser.find(\"Text1\").text if 'Text1' in str_xml else ''\n self.Text2 = xml_parser.find(\"Text2\").text if 'Text2' in str_xml else ''\n\n # Getting the output anchor from Config.xml by the output connection name\n self.Output = self.output_anchor_mgr.get_output_anchor('Output')\n\n def pi_add_incoming_connection(self, str_type: str, str_name: str) -> object:\n return IncomingInterface(self)\n\n def pi_add_outgoing_connection(self, str_name: str) -> bool:\n return True\n\n def pi_push_all_records(self, n_record_limit: int) -> bool:\n return False\n\n def pi_close(self, b_has_errors: bool):\n return\n\n def display_error_msg(self, msg_string: str):\n self.alteryx_engine.output_message(self.n_tool_id, Sdk.EngineMessageType.error, msg_string)\n\n def display_info_msg(self, msg_string: str):\n self.alteryx_engine.output_message(self.n_tool_id, Sdk.EngineMessageType.info, msg_string)\n\n\nclass IncomingInterface:\n def __init__(self, parent: AyxPlugin):\n # Default properties\n self.parent: AyxPlugin = parent\n\n # Custom properties\n self.InInfo: Sdk.RecordInfo = None\n self.OutInfo: Sdk.RecordInfo = None\n self.Creator: Sdk.RecordCreator = None\n self.Copier: Sdk.RecordCopier = None\n self.ScoreField: Sdk.Field = None\n self.Text1Field: Sdk.Field = None\n self.Text2Field: Sdk.Field = None\n\n def ii_init(self, record_info_in: Sdk.RecordInfo) -> bool:\n self.InInfo = record_info_in\n self.Text1Field = record_info_in.get_field_by_name(self.parent.Text1)\n self.Text2Field = record_info_in.get_field_by_name(self.parent.Text2)\n self.OutInfo = self.InInfo.clone()\n self.ScoreField = self.OutInfo.add_field(self.parent.OutputField, Sdk.FieldType.double, source=self.parent.label)\n self.Creator = self.OutInfo.construct_record_creator()\n self.Copier = Sdk.RecordCopier(self.OutInfo, self.InInfo)\n\n index = 0\n while index < self.InInfo.num_fields:\n self.Copier.add(index, index)\n index += 1\n self.Copier.done_adding()\n self.parent.Output.init(self.OutInfo)\n return True\n\n def ii_push_record(self, in_record: Sdk.RecordRef) -> bool:\n self.Creator.reset()\n self.Copier.copy(self.Creator, in_record)\n text1 = self.Text1Field.get_as_string(in_record)\n text2 = self.Text2Field.get_as_string(in_record)\n self.ScoreField.set_from_double(self.Creator, dice_coefficient(text1, text2))\n out_record = self.Creator.finalize_record()\n self.parent.Output.push_record(out_record)\n return True\n\n def ii_update_progress(self, d_percent: float):\n # Inform the Alteryx engine of the tool's progress.\n self.parent.alteryx_engine.output_tool_progress(self.parent.n_tool_id, d_percent)\n\n def ii_close(self):\n self.parent.Output.assert_close()\n return\n\n\ndef dice_coefficient(a, b):\n if a is None or b is None: return 0.0\n if not len(a) or not len(b): return 0.0\n \"\"\" quick case for true duplicates \"\"\"\n if a == b: return 1.0\n \"\"\" if a != b, and a or b are single chars, then they can't possibly match \"\"\"\n if len(a) == 1 or len(b) == 1: return 0.0\n\n \"\"\" use python list comprehension, preferred over list.append() \"\"\"\n a_bigram_list = [a[i:i + 2] for i in range(len(a) - 1)]\n b_bigram_list = [b[i:i + 2] for i in range(len(b) - 1)]\n\n a_bigram_list.sort()\n b_bigram_list.sort()\n\n # assignments to save function calls\n lena = len(a_bigram_list)\n lenb = len(b_bigram_list)\n # initialize match counters\n matches = i = j = 0\n while (i < lena and j < lenb):\n if a_bigram_list[i] == b_bigram_list[j]:\n matches += 1\n i += 1\n j += 1\n elif a_bigram_list[i] < b_bigram_list[j]:\n i += 1\n else:\n j += 1\n\n score = float(2 * matches) / float(lena + lenb)\n return score\n"},"directory_id":{"kind":"string","value":"843e62e2b83047823d48947a505b402d6193a660"},"languages":{"kind":"list like","value":["Go Module","Python","Go"],"string":"[\n \"Go Module\",\n \"Python\",\n \"Go\"\n]"},"num_files":{"kind":"number","value":7,"string":"7"},"repo_language":{"kind":"string","value":"Go Module"},"repo_name":{"kind":"string","value":"tlarsen7572/ayx_dice_coefficient"},"revision_id":{"kind":"string","value":"8daee3e7f3709690bcba0e94d4eda43a783bf0da"},"snapshot_id":{"kind":"string","value":"3a8561ffc0abe5d5c5c809fdfa1952aaf31d3837"}}},{"rowIdx":9976,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"mplumer/book-search-engine/README.md\n# Book Search Engine \n\n## Description \nBook Search Engine is an Apollo and React based application that allows users to browse Google Books API and choose books to save and display in their own, unique account pages. \n\n ## Link to Deployed Application\n* [Book Search Engine](https://quiet-cliffs-01279.herokuapp.com/)\n### User Story\n* AS AN avid reader\n* I WANT to search for new books to read\n* SO THAT I can keep a list of books to purchase \n\n## Table of Contents\n* [Installation](#installation) \n* [Usage](#usage) \n* [License](#license) \n* [Contributing](#contributing)\n* [Questions](#questions)\n\n## Link to Github Repository\n* [Book Search Engine](https://github.com/mplumer/book-search-engine)\n\n![Screenshot](client/public/assets/images/Screenshot2.png)\n![Screenshot](client/public/assets/images/Screenshot1.png)\n \n### Installation\nFollow the deployed application link: https://quiet-cliffs-01279.herokuapp.com/. \n\n### Usage\nType the title of a book that interests you into the search bar field. After clicking the search button, click the save button of books you want to keep in your wishlist. \n\n### License\nMIT\n \n### Contributing\nBook Search Engine is an open source project that was built from cloned, front-end starter code at the University of Texas Web Development Bootcamp, and anyone is encouraged to contribute by cloning or forking the code and working to improve its function and versatility.\n\n### Questions\n \n##### Interested in other projects from this developer? Visit the following GitHub page:\nhttps://github.com/mplumer\n \n##### Send any questions to the following email address:\n\n"},"directory_id":{"kind":"string","value":"2004aa13416742cb16158e834ecf80cefb0a7d4f"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"mplumer/book-search-engine"},"revision_id":{"kind":"string","value":"67695c05b3557012291025799688049ca37417c3"},"snapshot_id":{"kind":"string","value":"12a4c63341da098887bc0692ea0c23767cd7b68e"}}},{"rowIdx":9977,"cells":{"branch_name":{"kind":"string","value":"refs/heads/master"},"content":{"kind":"string","value":"MehulKK/FirebaseImageUpload/app/src/main/java/com/firebaseimageupload/activity/UploadImageActivity.java\npackage com.firebaseimageupload.activity;\n\nimport android.Manifest;\nimport android.app.ProgressDialog;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.graphics.Bitmap;\nimport android.net.Uri;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.provider.MediaStore;\nimport android.support.annotation.NonNull;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.Toolbar;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.EditText;\nimport android.widget.ImageView;\nimport android.widget.TextView;\nimport android.widget.Toast;\n\nimport com.firebaseimageupload.R;\nimport com.firebaseimageupload.extras.Constants;\nimport com.firebaseimageupload.extras.Utils;\nimport com.firebaseimageupload.models.ImageUpload;\nimport com.google.android.gms.tasks.OnFailureListener;\nimport com.google.android.gms.tasks.OnSuccessListener;\nimport com.google.firebase.database.DatabaseReference;\nimport com.google.firebase.database.FirebaseDatabase;\nimport com.google.firebase.storage.FirebaseStorage;\nimport com.google.firebase.storage.OnProgressListener;\nimport com.google.firebase.storage.StorageReference;\nimport com.google.firebase.storage.UploadTask;\n\nimport java.io.IOException;\n\nimport butterknife.BindView;\nimport butterknife.ButterKnife;\n\n/**\n * Created by Mehul on 30-Apr-17.\n */\npublic class UploadImageActivity extends AppCompatActivity implements View.OnClickListener {\n\n //constant to track image chooser intent\n private static final int PICK_IMAGE_REQUEST = 234;\n private static final int REQUEST_READ_PERMISSION = 101;\n\n\n @BindView(R.id.imageView)\n ImageView imageView;\n @BindView(R.id.buttonUpload)\n Button buttonUpload;\n @BindView(R.id.textViewShow)\n TextView textViewShow;\n @BindView(R.id.buttonChoose)\n Button buttonChoose;\n @BindView(R.id.editText)\n EditText editText;\n @BindView(R.id.toolbar2)\n Toolbar toolbar;\n\n //uri to store file\n private Uri filePath;\n\n //firebase objects\n private StorageReference storageReference;\n private DatabaseReference mDatabase;\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_image_upload);\n ButterKnife.bind(this);\n init();\n }\n\n private void init(){\n storageReference = FirebaseStorage.getInstance().getReference();\n mDatabase = FirebaseDatabase.getInstance().getReference(Constants.DATABASE_PATH_UPLOADS);\n\n buttonChoose.setOnClickListener(this);\n buttonUpload.setOnClickListener(this);\n textViewShow.setOnClickListener(this);\n\n setSupportActionBar(toolbar);\n }\n\n private void showFileChooser() {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(Intent.createChooser(intent, \"Select Picture\"), PICK_IMAGE_REQUEST);\n }\n\n\n private void uploadFile() {\n //checking if file is available\n if (filePath != null) {\n //displaying progress dialog while image is uploading\n final ProgressDialog progressDialog = new ProgressDialog(this);\n progressDialog.setTitle(\"Uploading\");\n progressDialog.show();\n\n //getting the storage reference\n StorageReference sRef = storageReference.child(Constants.STORAGE_PATH_UPLOADS + System.currentTimeMillis() + \".\" + Utils.getFileExtension(UploadImageActivity.this,filePath));\n\n //adding the file to reference\n sRef.putFile(filePath)\n .addOnSuccessListener(new OnSuccessListener() {\n @Override\n public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {\n //dismissing the progress dialog\n progressDialog.dismiss();\n\n //displaying success toast\n Toast.makeText(getApplicationContext(), \"File Uploaded \", Toast.LENGTH_LONG).show();\n\n //creating the upload object to store uploaded image details\n ImageUpload upload = new ImageUpload(editText.getText().toString().trim(), taskSnapshot.getDownloadUrl().toString());\n\n //adding an upload to firebase database\n String uploadId = mDatabase.push().getKey();\n mDatabase.child(uploadId).setValue(upload);\n }\n })\n .addOnFailureListener(new OnFailureListener() {\n @Override\n public void onFailure(@NonNull Exception exception) {\n progressDialog.dismiss();\n Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_LONG).show();\n }\n })\n .addOnProgressListener(new OnProgressListener() {\n @Override\n public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {\n //displaying the upload progress\n double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();\n progressDialog.setMessage(\"Uploaded \" + ((int) progress) + \"%...\");\n }\n });\n } else {\n //display an error if no file is selected\n Toast.makeText(UploadImageActivity.this, \"Please select File\", Toast.LENGTH_LONG).show();\n }\n }\n\n @Override\n public void onClick(View view) {\n if (view == buttonChoose) {\n requestPermission();\n } else if (view == buttonUpload) {\n uploadFile();\n } else if (view == textViewShow) {\n startActivity(new Intent(UploadImageActivity.this, ShowImagesActivity.class));\n }\n }\n\n @Override\n protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {\n filePath = data.getData();\n try {\n Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);\n imageView.setImageBitmap(bitmap);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }\n\n private void requestPermission() {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_READ_PERMISSION);\n } else {\n showFileChooser();\n }\n }\n\n @Override\n public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {\n if (requestCode == REQUEST_READ_PERMISSION && grantResults[0] == PackageManager.PERMISSION_GRANTED) {\n showFileChooser();\n }\n }\n}"},"directory_id":{"kind":"string","value":"c7db219abd22eb2016a2b19177279bc9a1e3296a"},"languages":{"kind":"list like","value":["Java"],"string":"[\n \"Java\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Java"},"repo_name":{"kind":"string","value":"MehulKK/FirebaseImageUpload"},"revision_id":{"kind":"string","value":"050de22480c7dfeaf70bb4f8fc6c2cc9ac6ee908"},"snapshot_id":{"kind":"string","value":"7b9b61b8c11c276be9283fe0e814fbae433fc50c"}}},{"rowIdx":9978,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"nickgraffis/tomato-timer/README.md\n# tomato-timer\nFun Tomato timer\n"},"directory_id":{"kind":"string","value":"215d331740783894659f399138be1bdc126e8cc4"},"languages":{"kind":"list like","value":["Markdown"],"string":"[\n \"Markdown\"\n]"},"num_files":{"kind":"number","value":1,"string":"1"},"repo_language":{"kind":"string","value":"Markdown"},"repo_name":{"kind":"string","value":"nickgraffis/tomato-timer"},"revision_id":{"kind":"string","value":"c63fd359c1203b581377429751fd5f6d27e20958"},"snapshot_id":{"kind":"string","value":"e52ecdace03972858c04e48766679ce059e37e72"}}},{"rowIdx":9979,"cells":{"branch_name":{"kind":"string","value":"refs/heads/main"},"content":{"kind":"string","value":"\"\"\"\nThis file is for models creation, which consults options\nand creates each encoder and decoder accordingly.\n\"\"\"\nimport torch\nimport torch.nn as nn\n\nimport onmt\nimport onmt.io\nimport onmt.Models\nimport onmt.modules\nfrom onmt.Models import NMTModel, MeanEncoder, RNNEncoder, \\\n StdRNNDecoder, InputFeedRNNDecoder, MirrorModel, MirrorLight, Mirror_Encshare, MirrorLow_Encshare, Input_Z_FeedRNNDecoder, Input_Z_RNNDecoder, MirrorLow\nfrom onmt.modules import Embeddings, ImageEncoder, CopyGenerator, \\\n TransformerEncoder, TransformerDecoder, \\\n CNNEncoder, CNNDecoder, AudioEncoder\nfrom onmt.Utils import use_gpu\n\n\ndef make_embeddings(opt, word_dict, feature_dicts, for_encoder=True):\n \"\"\"\n Make an Embeddings instance.\n Args:\n opt: the option in current environment.\n word_dict(Vocab): words dictionary.\n feature_dicts([Vocab], optional): a list of feature dictionary.\n for_encoder(bool): make Embeddings for encoder or decoder?\n \"\"\"\n if for_encoder:\n embedding_dim = opt.src_word_vec_size\n else:\n embedding_dim = opt.tgt_word_vec_size\n\n word_padding_idx = word_dict.stoi[onmt.io.PAD_WORD]\n num_word_embeddings = len(word_dict)\n\n feats_padding_idx = [feat_dict.stoi[onmt.io.PAD_WORD]\n for feat_dict in feature_dicts]\n num_feat_embeddings = [len(feat_dict) for feat_dict in\n feature_dicts]\n\n return Embeddings(word_vec_size=embedding_dim,\n position_encoding=opt.position_encoding,\n feat_merge=opt.feat_merge,\n feat_vec_exponent=opt.feat_vec_exponent,\n feat_vec_size=opt.feat_vec_size,\n dropout=opt.dropout,\n word_padding_idx=word_padding_idx,\n feat_padding_idx=feats_padding_idx,\n word_vocab_size=num_word_embeddings,\n feat_vocab_sizes=num_feat_embeddings)\n\n\ndef make_encoder(opt, embeddings,ctx=False):\n \"\"\"\n Various encoder dispatcher function.\n Args:\n opt: the option in current environment.\n embeddings (Embeddings): vocab embeddings for this encoder.\n \"\"\"\n if opt.encoder_type == \"transformer\":\n return TransformerEncoder(opt.enc_layers, opt.rnn_size,\n opt.dropout, embeddings)\n elif opt.encoder_type == \"cnn\":\n return CNNEncoder(opt.enc_layers, opt.rnn_size,\n opt.cnn_kernel_width,\n opt.dropout, embeddings)\n elif opt.encoder_type == \"mean\":\n return MeanEncoder(opt.enc_layers, embeddings)\n else:\n # \"rnn\" or \"brnn\"\n if ctx:\n return RNNEncoder(opt.rnn_type, opt.ctx_bid, opt.enc_layers,\n opt.rnn_size, opt.dropout, embeddings)\n else:\n return RNNEncoder(opt.rnn_type, opt.brnn, opt.enc_layers,\n opt.rnn_size, opt.dropout, embeddings)\n\n\ndef make_decoder(opt, embeddings):\n \"\"\"\n Various decoder dispatcher function.\n Args:\n opt: the option in current environment.\n embeddings (Embeddings): vocab embeddings for this decoder.\n \"\"\"\n if opt.decoder_type == \"transformer\":\n return TransformerDecoder(opt.dec_layers, opt.rnn_size,\n opt.global_attention, opt.copy_attn,\n opt.dropout, embeddings)\n elif opt.decoder_type == \"cnn\":\n return CNNDecoder(opt.dec_layers, opt.rnn_size,\n opt.global_attention, opt.copy_attn,\n opt.cnn_kernel_width, opt.dropout,\n embeddings)\n elif opt.input_feed:\n if opt.input_feed_with_ctx:\n return Input_Z_FeedRNNDecoder(opt.rnn_type, opt.brnn,\n opt.dec_layers, opt.rnn_size,\n opt.global_attention,\n opt.coverage_attn,\n opt.context_gate,\n opt.copy_attn,\n opt.dropout,\n embeddings,\n opt.z_dim)\n else:\n return Input_Z_RNNDecoder(opt.rnn_type, opt.brnn,\n opt.dec_layers, opt.rnn_size,\n opt.global_attention,\n opt.coverage_attn,\n opt.context_gate,\n opt.copy_attn,\n opt.dropout,\n embeddings,\n opt.z_dim)\n\n else:\n return StdRNNDecoder(opt.rnn_type, opt.brnn,\n opt.dec_layers, opt.rnn_size,\n opt.global_attention,\n opt.coverage_attn,\n opt.context_gate,\n opt.copy_attn,\n opt.dropout,\n embeddings)\n\n\ndef load_test_model(opt, dummy_opt,):\n checkpoint = torch.load(opt.model,\n map_location=lambda storage, loc: storage)\n fields = onmt.io.load_fields_from_vocab(\n checkpoint['vocab'], data_type=opt.data_type)\n\n model_opt = checkpoint['opt']\n for arg in dummy_opt:\n if arg not in model_opt:\n model_opt.__dict__[arg] = dummy_opt[arg]\n\n model = make_mirror_model(model_opt, fields,\n use_gpu(opt), checkpoint, model_opt.mirror_type)\n\n model.eval()\n model.generator_cxz2y.eval()\n model.generator_cyz2x.eval()\n model.generator_cz2x.eval()\n model.generator_cz2y.eval()\n return fields, model, model_opt\n\ndef load_mmi_model(opt, dummy_opt):\n checkpoint = torch.load(opt.mmi_model,\n map_location=lambda storage, loc: storage)\n fields = onmt.io.load_fields_from_vocab(\n checkpoint['vocab'], data_type=opt.data_type)\n\n model_opt = checkpoint['opt']\n for arg in dummy_opt:\n if arg not in model_opt:\n model_opt.__dict__[arg] = dummy_opt[arg]\n\n model = make_base_model(model_opt, fields,\n use_gpu(opt), checkpoint)\n model.eval()\n model.generator.eval()\n return fields, model, model_opt\n\ndef make_base_model(model_opt, fields, gpu, checkpoint=None):\n \"\"\"\n Args:\n model_opt: the option loaded from checkpoint.\n fields: `Field` objects for the model.\n gpu(bool): whether to use gpu.\n checkpoint: the model gnerated by train phase, or a resumed snapshot\n model from a stopped training.\n Returns:\n the NMTModel.\n \"\"\"\n assert model_opt.model_type in [\"text\", \"img\", \"audio\"], \\\n (\"Unsupported model type %s\" % (model_opt.model_type))\n\n # Make encoder.\n if model_opt.model_type == \"text\":\n src_dict = fields[\"src\"].vocab\n feature_dicts = onmt.io.collect_feature_vocabs(fields, 'src')\n src_embeddings = make_embeddings(model_opt, src_dict,\n feature_dicts)\n encoder = make_encoder(model_opt, src_embeddings)\n elif model_opt.model_type == \"img\":\n encoder = ImageEncoder(model_opt.enc_layers,\n model_opt.brnn,\n model_opt.rnn_size,\n model_opt.dropout)\n elif model_opt.model_type == \"audio\":\n encoder = AudioEncoder(model_opt.enc_layers,\n model_opt.brnn,\n model_opt.rnn_size,\n model_opt.dropout,\n model_opt.sample_rate,\n model_opt.window_size)\n\n # Make decoder.\n tgt_dict = fields[\"tgt\"].vocab\n feature_dicts = onmt.io.collect_feature_vocabs(fields, 'tgt')\n tgt_embeddings = make_embeddings(model_opt, tgt_dict,\n feature_dicts, for_encoder=False)\n\n # Share the embedding matrix - preprocess with share_vocab required.\n if model_opt.share_embeddings:\n # src/tgt vocab should be the same if `-share_vocab` is specified.\n if src_dict != tgt_dict:\n raise AssertionError('The `-share_vocab` should be set during '\n 'preprocess if you use share_embeddings!')\n\n tgt_embeddings.word_lut.weight = src_embeddings.word_lut.weight\n\n decoder = make_decoder(model_opt, tgt_embeddings)\n\n # Make NMTModel(= encoder + decoder).\n model = NMTModel(encoder, decoder)\n model.model_type = model_opt.model_type\n\n # Make Generator.\n if not model_opt.copy_attn:\n generator = nn.Sequential(\n nn.Linear(model_opt.rnn_size, len(fields[\"tgt\"].vocab)),\n nn.LogSoftmax())\n if model_opt.share_decoder_embeddings:\n generator[0].weight = decoder.embeddings.word_lut.weight\n else:\n generator = CopyGenerator(model_opt.rnn_size,\n fields[\"tgt\"].vocab)\n\n # Load the model states from checkpoint or initialize them.\n if checkpoint is not None:\n print('Loading model parameters.')\n model.load_state_dict(checkpoint['model'])\n generator.load_state_dict(checkpoint['generator'])\n else:\n if model_opt.param_init != 0.0:\n print('Intializing model parameters.')\n for p in model.parameters():\n p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n for p in generator.parameters():\n p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n if hasattr(model.encoder, 'embeddings'):\n model.encoder.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_enc, model_opt.fix_word_vecs_enc)\n if hasattr(model.decoder, 'embeddings'):\n model.decoder.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_dec, model_opt.fix_word_vecs_dec)\n\n # Add generator to model (this registers it as parameter of model).\n model.generator = generator\n\n # Make the whole model leverage GPU if indicated to do so.\n if gpu:\n model.cuda()\n else:\n model.cpu()\n\n return model\n\n\n\n\ndef make_mirror_model(model_opt, fields, gpu, checkpoint=None, mirror_type='mirror'):\n \"\"\"\n Args:\n model_opt: the option loaded from checkpoint.\n fields: `Field` objects for the model.\n gpu(bool): whether to use gpu.\n checkpoint: the model gnerated by train phase, or a resumed snapshot\n model from a stopped training.\n Returns:\n the NMTModel.\n \"\"\"\n assert model_opt.model_type in [\"text\", \"img\", \"audio\"], \\\n (\"Unsupported model type %s\" % (model_opt.model_type))\n\n # Make encoder.\n # if model_opt.model_type == \"text\":\n src_dict = fields[\"src\"].vocab\n feature_dicts = onmt.io.collect_feature_vocabs(fields, 'src')\n src_embeddings = make_embeddings(model_opt, src_dict,\n feature_dicts)\n # src_embeddings_ctx = make_embeddings(model_opt, src_dict,\n # feature_dicts)\n src_embeddings_ctx = src_embeddings\n encoder_utt = make_encoder(model_opt, src_embeddings)\n # encoder_utt_y = make_encoder(model_opt, src_embeddings)\n encoder_utt_y = None\n encoder_ctx = make_encoder(model_opt, src_embeddings_ctx, ctx=True)\n\n\n # Make decoder.\n tgt_dict = fields[\"tgt\"].vocab\n feature_dicts = onmt.io.collect_feature_vocabs(fields, 'tgt')\n tgt_embeddings = make_embeddings(model_opt, tgt_dict,\n feature_dicts, for_encoder=False)\n tgt_embeddings_2 = make_embeddings(model_opt, tgt_dict,\n feature_dicts, for_encoder=False)\n tgt_embeddings_3 = make_embeddings(model_opt, tgt_dict,\n feature_dicts, for_encoder=False)\n tgt_embeddings_4 = make_embeddings(model_opt, tgt_dict,\n feature_dicts, for_encoder=False)\n \n # Share the embedding matrix - preprocess with share_vocab required.\n if model_opt.share_embeddings:\n # src/tgt vocab should be the same if `-share_vocab` is specified.\n print(\"encoder and decoder will share the embedding\")\n if src_dict != tgt_dict:\n raise AssertionError('The `-share_vocab` should be set during '\n 'preprocess if you use share_embeddings!')\n tgt_embeddings = src_embeddings\n tgt_embeddings.word_lut.weight = src_embeddings.word_lut.weight\n tgt_embeddings_2.word_lut.weight = src_embeddings.word_lut.weight\n tgt_embeddings_3.word_lut.weight = src_embeddings.word_lut.weight\n tgt_embeddings_4.word_lut.weight = src_embeddings.word_lut.weight\n src_embeddings_ctx.word_lut.weight = src_embeddings.word_lut.weight\n\n decoder_1 = make_decoder(model_opt, tgt_embeddings)\n decoder_2 = make_decoder(model_opt, tgt_embeddings_2)\n decoder_3 = make_decoder(model_opt, tgt_embeddings_3)\n decoder_4 = make_decoder(model_opt, tgt_embeddings_4)\n\n # Make NMTModel(= encoder + decoder).\n if mirror_type=='mirror':\n model = MirrorModel(encoder_utt, encoder_utt_y, encoder_ctx, decoder_1, decoder_2, decoder_3, decoder_4, opt=model_opt)\n elif mirror_type=='mirror_light':\n model = MirrorLight(encoder_utt, encoder_utt_y, encoder_ctx, decoder_1, decoder_2, decoder_3, decoder_4, opt=model_opt)\n elif mirror_type=='mirror_low':\n model = MirrorLow(encoder_utt, encoder_utt_y, encoder_ctx, decoder_1, decoder_2, decoder_3, decoder_4, opt=model_opt)\n elif mirror_type=='mirror_low_encshare':\n model = MirrorLow_Encshare(encoder_utt, decoder_1, decoder_2, decoder_3, decoder_4, opt=model_opt)\n else:\n raise ValueError(\"no such model type: {}\".format(mirror_type))\n model.model_type = model_opt.model_type\n\n # Make Generator.\n generator_cxz2y = make_generator(model_opt, model.decoder_cxz2y, fields, 'tgt')\n generator_cz2x = make_generator(model_opt, model.decoder_cz2x, fields, 'tgt_back')\n generator_cyz2x = make_generator(model_opt, model.decoder_cyz2x, fields, 'tgt_back')\n generator_cz2y = make_generator(model_opt, model.decoder_cz2y, fields, 'tgt')\n\n\n # Add generator to model (this registers it as parameter of model).\n model.generator_cxz2y = generator_cxz2y\n model.generator_cz2x = generator_cz2x\n model.generator_cyz2x = generator_cyz2x\n model.generator_cz2y = generator_cz2y\n\n # Load the model states from checkpoint or initialize them.\n # careful: fix the loading module later\n if checkpoint is not None:\n print('Loading model parameters.')\n model.load_state_dict(checkpoint['model'])\n # generator.load_state_dict(checkpoint['generator'])\n else:\n if model_opt.param_init != 0.0:\n print('Intializing model parameters.')\n for p in model.parameters():\n p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n # for p in generator_cxz2y.parameters():\n # p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n # for p in generator_cz2x.parameters():\n # p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n # for p in generator_cyz2x.parameters():\n # p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n # for p in generator_cz2y.parameters():\n # p.data.uniform_(-model_opt.param_init, model_opt.param_init)\n if hasattr(model.encoder, 'embeddings'):\n model.encoder.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_enc, model_opt.fix_word_vecs_enc)\n if hasattr(model.encoder_ctx, 'embeddings'):\n model.encoder_ctx.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_enc, model_opt.fix_word_vecs_enc)\n if hasattr(model.decoder_cxz2y, 'embeddings'):\n model.decoder_cxz2y.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_dec, model_opt.fix_word_vecs_dec)\n if hasattr(model.decoder_cz2x, 'embeddings'):\n model.decoder_cz2x.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_dec, model_opt.fix_word_vecs_dec)\n if hasattr(model.decoder_cyz2x, 'embeddings'):\n model.decoder_cyz2x.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_dec, model_opt.fix_word_vecs_dec)\n if hasattr(model.decoder_cz2y, 'embeddings'):\n model.decoder_cz2y.embeddings.load_pretrained_vectors(\n model_opt.pre_word_vecs_dec, model_opt.fix_word_vecs_dec)\n\n\n\n\n # Make the whole model leverage GPU if indicated to do so.\n if gpu:\n model.cuda()\n else:\n model.cpu()\n\n return model\n\ndef make_generator(model_opt, decoder, fields, des='tgt'):\n # Make Generator.\n if not model_opt.copy_attn:\n generator = nn.Sequential(\n nn.Linear(model_opt.rnn_size, len(fields[des].vocab)),\n nn.LogSoftmax(dim=-1))\n if model_opt.share_decoder_embeddings:\n generator[0].weight = decoder.embeddings.word_lut.weight\n else:\n generator = CopyGenerator(model_opt.rnn_size,\n fields[des].vocab)\n return generator\n\n\n\nimport onmt.io\nimport onmt.translate\nimport onmt.Models\nimport onmt.Loss\nfrom onmt.Trainer import Trainer, Statistics, MirrorStatistics\nfrom onmt.Optim import Optim\n\n# For flake8 compatibility\n__all__ = [onmt.Loss, onmt.Models,\n Trainer, Optim, Statistics, MirrorStatistics, onmt.io, onmt.translate]\nfrom __future__ import division\nimport torch\n\n# Beam decoding with KL divergence\nimport numpy as np\nfrom scipy.stats import entropy\n\nclass Beam(object):\n \"\"\"\n Class for managing the internals of the beam search process.\n\n Takes care of beams, back pointers, and scores.\n\n Args:\n size (int): beam size\n pad, bos, eos (int): indices of padding, beginning, and ending.\n vocab (vocab): vocab of the target\n syntax_topics_model (Syntax and Topics module): This is an object of the class which will have the topics \n and classes word probabilities\n source (list): list of source indices which will be the source sentence\n targets (list of list): list of taget sentences each of which is a list of indices of the full hypothesis generated till now\n n_best (int): nbest size to use\n cuda (bool): use gpu\n global_scorer (:obj:`GlobalScorer`)\n \"\"\"\n def __init__(self, size, pad, bos, eos,\n vocab, syntax_topics_model,\n source,\n n_best=1, cuda=False,\n global_scorer=None,\n min_length=0):\n self.use_cuda = cuda\n self.size = size\n # self.tt = torch.cuda if cuda else torch\n self.tt = torch\n\n # The score for each translation on the beam.\n self.scores = self.tt.FloatTensor(size).zero_()\n if self.use_cuda:\n self.scores = self.scores.cuda()\n self.all_scores = []\n\n # The backpointers at each time-step.\n self.prev_ks = []\n\n \n\n # The outputs at each time-step.\n self.next_ys = [self.tt.LongTensor(size)\n .fill_(pad)]\n if self.use_cuda:\n self.next_ys = [self.tt.LongTensor(size)\n .fill_(pad).cuda()]\n self.next_ys[0][0] = bos\n ##NOTE: speical marker which tells which class is the previous word from\n self.next_ys_topic_prior_sum = [] # Store the sum of the topic prior for the entire hypothesis\n self.next_ys_class_prior_sum = [] # Store the sum of the class prior for the entire hypothesis\n self.TOPIC_FLAG = 0\n self.CLASS_FLAG = 1\n\n\n # Has EOS topped the beam yet.\n self._eos = eos\n self.eos_top = False\n\n # The attentions (matrix) for each time.\n self.attn = []\n\n # Time and k pair for finished.\n self.finished = []\n self.n_best = n_best\n\n # Information for global scoring.\n self.global_scorer = global_scorer\n self.global_state = {}\n\n # Minimum prediction length\n self.min_length = min_length\n\n\n\n ##NOTE: Custom code\n self.vocab = vocab\n self.finished_marker = [-1]*size\n self.syntax_topics_model = syntax_topics_model\n self.source = [self.vocab.itos[word_id] for word_id in source]\n # Compute the topic prior probability for the source sentence\n self.source_topic_prior = np.zeros(self.syntax_topics_model.num_topics+1, dtype=np.float)\n print self.source\n self.src_topic_word_count = 0\n for word in self.source:\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n if word_topic_prior[self.syntax_topics_model.num_topics] != 1.0:\n print word\n self.src_topic_word_count += 1\n self.source_topic_prior += word_topic_prior\n self.source_class_prior = np.zeros(self.syntax_topics_model.num_classes, dtype=np.float)\n for word in self.source:\n self.source_class_prior += self.syntax_topics_model.get_class_prior_for_word(word)\n \n self.source_topic_prior /= len(self.source)\n self.source_class_prior /= len(self.source)\n self.beta = 0.0 # Additive smoothing\n self.source_topic_prior += self.beta\n self.source_class_prior += self.beta\n print(self.source_topic_prior)\n print(self.source_class_prior)\n self.L = 50 # Number of words to be chosen for the similarity consideration\n # temp = np.zeros_like(self.source_topic_prior) + self.beta\n # least_KL = entropy(self.source_topic_prior, temp)\n self.alpha = 1.5 # Multiplicative factor for topic KL divergence\n self.gamma = 1.5 # Multiplicative factor for class KL divergence\n # self.alpha = 8/least_KL # multiplicative factor for the KL divergence\n # print vocab.itos[0]\n # print vocab.itos[bos]\n # print vocab.itos[self._eos]\n # print vocab.__dict__.keys()\n # print vocab.unk_init\n # print type(vocab)\n self.topic_KL_flag = False\n self.class_KL_flag = True\n\n def print_hyp(self, hyp, class_or_topic = None):\n for i, word_id in enumerate(hyp):\n if class_or_topic:\n print \"{}_{} \".format(self.vocab.itos[word_id], class_or_topic[i]),\n else:\n print \"{} \".format(self.vocab.itos[word_id]),\n\n ##NOTE: Custom function for debugging\n def print_all_words_in_beam(self):\n # Uses the vocab and prints the list of next_ys\n for i in range(self.size):\n timestep = len(self.next_ys)\n # if self.finished_marker[i] != -1:\n # timestep = self.finished_marker[i]\n if timestep > 1:\n hyp, _ = self.get_hyp(timestep, i)\n # print hyp\n # print type(hyp)\n self.print_hyp(hyp)\n print \"$$$\"\n # print \"\"\n\n def print_received_targets(self):\n for i in range(len(self.targets)):\n self.print_hyp(self.targets[i])\n print \"\"\n print \"############### Received Targets ############\"\n\n def print_the_top_choices(self, best_choices):\n w, h = best_choices.size()\n for i in range(w):\n for j in range(h):\n print \"{} \".format(self.vocab.itos[best_choices[i,j]]),\n print \"\"\n\n\n def get_current_state(self):\n \"Get the outputs for the current timestep.\"\n return self.next_ys[-1]\n\n def get_current_origin(self):\n \"Get the backpointers for the current timestep.\"\n return self.prev_ks[-1]\n\n def advance(self, word_probs, attn_out):\n print \"Advancing beam\"\n \"\"\"\n Given prob over words for every last beam `wordLk` and attention\n `attn_out`: Compute and update the beam search.\n\n Parameters:\n\n * `word_probs`- probs of advancing from the last step (K x words)\n * `attn_out`- attention at the last step\n\n Returns: True if beam search is complete.\n \"\"\"\n num_words = word_probs.size(1)\n\n # force the output to be longer than self.min_length\n cur_len = len(self.next_ys)\n if cur_len < self.min_length:\n for k in range(len(word_probs)):\n word_probs[k][self._eos] = -1e20\n\n # Sum the previous scores.\n if len(self.prev_ks) > 0:\n beam_scores = word_probs + \\\n self.scores.unsqueeze(1).expand_as(word_probs)\n\n # Don't let EOS have children.\n for i in range(self.next_ys[-1].size(0)):\n if self.next_ys[-1][i] == self._eos:\n beam_scores[i] = -1e20\n else:\n beam_scores = word_probs[0]\n\n #TODO: 1) find the last word for each beam\n # 2) For each possible hypothesis find the Topic modeling probability\n # 3) Weighted add the syntax and topic scores to beam_scores and just calculate the next_ys and backpointers as normal\n \n if len(self.prev_ks) > 0:\n per_beam_words = self.next_ys[-1]\n if self.topic_KL_flag:\n per_beam_hyp_topic_prior_sum = self.next_ys_topic_prior_sum[-1]\n if self.class_KL_flag:\n per_beam_hyp_class_prior_sum = self.next_ys_class_prior_sum[-1]\n\n if self.topic_KL_flag:\n topic_KL_divergence_scores = self.tt.zeros_like(beam_scores)\n if self.class_KL_flag:\n class_KL_divergence_scores = self.tt.zeros_like(beam_scores)\n for i in range(self.size):\n if self.topic_KL_flag:\n hyp_topic_prior = per_beam_hyp_topic_prior_sum[i]\n if self.class_KL_flag:\n hyp_class_prior = per_beam_hyp_class_prior_sum[i]\n\n len_hyp = len(self.next_ys) # Includes current word because we want to skip the count added by the start word \n for j in range(num_words):\n word = self.vocab.itos[j]\n #KL divergence for Topic Priors\n if self.topic_KL_flag:\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n hyp_topic_prior_sum = (hyp_topic_prior + word_topic_prior) + self.beta\n # topic_KL_divergence_scores[i][j] = entropy(self.source_topic_prior, hyp_topic_prior_sum)\n topic_KL_divergence_scores[i][j] = self.syntax_topics_model.KL_divergence(self.source_topic_prior, hyp_topic_prior_sum)\n if topic_KL_divergence_scores[i][j] == float('Inf'):\n print word\n print topic_KL_divergence_scores[i][j]\n print self.source_topic_prior\n print hyp_topic_prior_sum\n #KL divergence for Class Priors\n if self.class_KL_flag:\n if \"\" in word:\n class_KL_divergence_scores[i][j] = 1000000.0\n continue\n word_class_prior = self.syntax_topics_model.get_class_prior_for_word(word)\n hyp_class_prior_sum = (hyp_class_prior + word_class_prior) + self.beta\n # class_KL_divergence_scores[i][j] = entropy(self.source_class_prior, hyp_class_prior_sum)\n class_KL_divergence_scores[i][j] = self.syntax_topics_model.KL_divergence(self.source_class_prior, hyp_class_prior_sum)\n if class_KL_divergence_scores[i][j] == float('Inf'):\n print word\n print class_KL_divergence_scores[i][j]\n print self.source_class_prior\n print hyp_class_prior_sum\n\n #TODO: Convert the zeros to max KL divergence\n if self.topic_KL_flag:\n max_topic_KL = topic_KL_divergence_scores.mean()\n for i in range(self.size):\n for j in range(num_words):\n word = self.vocab.itos[j]\n if \"\" in word:\n topic_KL_divergence_scores[i][j] = 1000000.0\n continue\n if topic_KL_divergence_scores[i][j] == 0.0:\n topic_KL_divergence_scores[i][j] = max_topic_KL\n print \"########\\n\", max_topic_KL, \"\\n#########\"\n # Manually discourage unk by setting large negative syntax_topic_probability\n # if \"\" in word:\n # syntax_topic_score, best_class_or_topic, class_or_topic = -1000000.0, -1, \"C\"\n # else:\n # syntax_topic_score, best_class_or_topic, class_or_topic = self.syntax_topics_model.get_log_prob(word, 0 if per_beam_words_class_or_topic[i] == self.TOPIC_FLAG else per_beam_words_class_or_topic_number[i])\n overall_scores = beam_scores - ((self.alpha * topic_KL_divergence_scores) if self.topic_KL_flag else 0.0) - ((self.gamma * class_KL_divergence_scores) if self.class_KL_flag else 0.0)\n # print \"Overall Score\"\n # print overall_scores\n # print overall_scores.size()\n \n\n size = int(overall_scores.size(1))\n # print \"Size of the overall_scores = \", size\n flat_beam_scores = overall_scores.view(-1)\n best_scores, best_scores_id = flat_beam_scores.topk(self.size, 0,\n True, True)\n\n # We will debug the individual scores of the best candidates\n word_prob_best_scores = self.tt.zeros_like(best_scores)\n for i in range(self.size):\n word_prob_best_scores[i] = beam_scores[int(best_scores_id[i] / size)][best_scores_id[i] - int(best_scores_id[i] / size) * size]\n if self.topic_KL_flag:\n topic_KL_divergence_best_scores = self.tt.zeros_like(best_scores)\n for i in range(self.size):\n topic_KL_divergence_best_scores[i] = topic_KL_divergence_scores[int(best_scores_id[i] / size)][best_scores_id[i] - int(best_scores_id[i] / size) * size]\n if self.class_KL_flag:\n class_KL_divergence_best_scores = self.tt.zeros_like(best_scores)\n for i in range(self.size):\n class_KL_divergence_best_scores[i] = class_KL_divergence_scores[int(best_scores_id[i] / size)][best_scores_id[i] - int(best_scores_id[i] / size) * size]\n print best_scores\n print word_prob_best_scores\n # print topic_KL_divergence_best_scores\n # print class_KL_divergence_best_scores\n if self.topic_KL_flag:\n print self.alpha\n print self.alpha * topic_KL_divergence_best_scores\n if self.class_KL_flag:\n print self.gamma\n print self.gamma * class_KL_divergence_best_scores\n\n if self.topic_KL_flag:\n KL_size = int(topic_KL_divergence_scores.size(1))\n # print \"Size of the overall_scores = \", size\n flat_beam_scores = topic_KL_divergence_scores.view(-1)\n debug_size = 25\n best_topic_KL_scores, best_topic_KL_scores_id = flat_beam_scores.topk(debug_size, 0,\n False, True)\n print \"Best words from topic KL\"\n for i in range(debug_size):\n # print best_topic_KL_scores_id[i], best_topic_KL_scores_id[i] - int(best_topic_KL_scores_id[i] / KL_size) * KL_size\n word = self.vocab.itos[best_topic_KL_scores_id[i] - int(best_topic_KL_scores_id[i] / KL_size) * KL_size]\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n # print word, word_topic_prior, entropy(self.source_topic_prior, word_topic_prior + self.beta), \\\n print word, \\\n overall_scores[int(best_topic_KL_scores_id[i] / KL_size)][best_topic_KL_scores_id[i] - int(best_topic_KL_scores_id[i] / KL_size) * KL_size], \\\n best_topic_KL_scores[i], \\\n topic_KL_divergence_scores[int(best_topic_KL_scores_id[i] / KL_size)][best_topic_KL_scores_id[i] - int(best_topic_KL_scores_id[i] / KL_size) * KL_size]\n # class_KL_divergence_scores[int(best_topic_KL_scores_id[i] / KL_size)][best_topic_KL_scores_id[i] - int(best_topic_KL_scores_id[i] / KL_size) * KL_size], \\\n # print word_prob_best_scores + self.alpha * syntax_topic_best_scores\n\n prev_k = best_scores_id / num_words\n # Update next_ys_topic_prior_sum for all beams\n if self.topic_KL_flag:\n best_hyp_topic_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i] - int(best_scores_id[i] / size) * size]\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n if word_topic_prior[self.syntax_topics_model.num_topics] != 1.0:\n best_hyp_topic_prior_sum.append(self.next_ys_topic_prior_sum[-1][int(best_scores_id[i] / size)] + word_topic_prior)\n else:\n # Add the word_topic_prior only if its a topic word\n best_hyp_topic_prior_sum.append(self.next_ys_topic_prior_sum[-1][int(best_scores_id[i] / size)])\n self.next_ys_topic_prior_sum.append(best_hyp_topic_prior_sum)\n # Update next_ys_class_prior_sum for all beams\n if self.class_KL_flag:\n best_hyp_class_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i] - int(best_scores_id[i] / size) * size]\n word_class_prior = self.syntax_topics_model.get_class_prior_for_word(word)\n best_hyp_class_prior_sum.append(self.next_ys_class_prior_sum[-1][int(best_scores_id[i] / size)] + word_class_prior)\n self.next_ys_class_prior_sum.append(best_hyp_class_prior_sum)\n self.prev_ks.append(prev_k)\n self.next_ys.append((best_scores_id - prev_k * num_words))\n self.attn.append(attn_out.index_select(0, prev_k))\n # exit()\n\n self.print_all_words_in_beam()\n print \"############## After new words chosen ###########\"\n else:\n # beam_scores is only V dimensional vector\n # Thus for every word add the KL divergence score to the beam score\n if self.topic_KL_flag:\n topic_KL_divergence_scores = self.tt.zeros_like(beam_scores)\n if self.class_KL_flag:\n class_KL_divergence_scores = self.tt.zeros_like(beam_scores)\n for i in range(num_words):\n word = self.vocab.itos[i]\n if \"\" in word:\n if self.topic_KL_flag:\n topic_KL_divergence_scores[i] = 1000000.0\n if self.class_KL_flag:\n class_KL_divergence_scores[i] = 1000000.0\n beam_scores[i] = -1000000.0\n continue\n # KL for Topic priors of the first word\n if self.topic_KL_flag:\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n word_topic_prior += self.beta\n # topic_KL_divergence_scores[i] = entropy(self.source_topic_prior, word_topic_prior)\n topic_KL_divergence_scores[i] = self.syntax_topics_model.KL_divergence(self.source_topic_prior, word_topic_prior)\n # KL for Class priors of the first word\n if self.class_KL_flag:\n word_class_prior = self.syntax_topics_model.get_class_prior_for_word(word)\n word_class_prior += self.beta\n # class_KL_divergence_scores[i] = entropy(self.source_class_prior, word_class_prior)\n class_KL_divergence_scores[i] = self.syntax_topics_model.KL_divergence(self.source_class_prior, word_class_prior)\n \n overall_scores = beam_scores - ((self.alpha * topic_KL_divergence_scores) if self.topic_KL_flag else 0.0) - ((self.gamma * class_KL_divergence_scores) if self.class_KL_flag else 0.0)\n # flat_beam_scores = overall_scores.view(-1)\n flat_beam_scores = beam_scores.view(-1) # For the first iteration use only the word probabilities\n best_scores, best_scores_id = flat_beam_scores.topk(self.size, 0,\n True, True)\n\n self.all_scores.append(self.scores)\n # self.scores = best_scores # will store the word_prob + the KL divergence for hypothesis\n self.scores = best_scores # will store the word_prob log prob for hypothesis\n\n # best_scores_id is flattened, beam * word array, so calculate which\n # word and beam each score came from\n size = int(overall_scores.size(0))\n prev_k = best_scores_id / num_words\n # Update next_ys_topic_prior_sum for all beams\n if self.topic_KL_flag:\n best_hyp_topic_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i]]\n word_topic_prior = self.syntax_topics_model.get_topic_prior_for_word(word)\n if word_topic_prior[self.syntax_topics_model.num_topics] != 1.0:\n best_hyp_topic_prior_sum.append(word_topic_prior)\n else:\n # starting word is a syntax word. Therefore we will set the prior to zeros\n best_hyp_topic_prior_sum.append(np.zeros((self.syntax_topics_model.num_topics+1), dtype=np.float))\n self.next_ys_topic_prior_sum.append(best_hyp_topic_prior_sum)\n\n # Update next_ys_class_prior_sum for all beams\n if self.class_KL_flag:\n best_hyp_class_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i]]\n word_class_prior = self.syntax_topics_model.get_class_prior_for_word(word)\n best_hyp_class_prior_sum.append(word_class_prior)\n self.next_ys_class_prior_sum.append(best_hyp_class_prior_sum)\n\n self.prev_ks.append(prev_k)\n self.next_ys.append((best_scores_id - prev_k * num_words))\n self.attn.append(attn_out.index_select(0, prev_k))\n\n if self.global_scorer is not None:\n self.global_scorer.update_global_state(self)\n\n for i in range(self.next_ys[-1].size(0)):\n if self.next_ys[-1][i] == self._eos:\n s = self.scores[i]\n timestep = len(self.next_ys)\n if self.global_scorer is not None:\n global_scores = self.global_scorer.score(self, self.scores)\n s = global_scores[i]\n self.finished.append((s, len(self.next_ys) - 1, i))\n # TODO: Experimental!! Dividing the finished scores by their lenghts to be fair\n # self.finished.append((s/float(len(self.next_ys) - 1), len(self.next_ys) - 1, i))\n\n\n ##NOTE: Custom code\n if self.finished_marker[i] == -1:\n # print \"SET AND FORGET FOR \", i, \"#$#$#$#$##$\"\n self.finished_marker[i] = len(self.next_ys) - 1\n\n\n\n # End condition is when top-of-beam is EOS and no global score.\n if self.next_ys[-1][0] == self._eos:\n # self.all_scores.append(self.scores)\n self.eos_top = True\n\n\n\n ##NOTE: Debugging\n # print word_probs, \"$$\"\n # print self.get_current_state(), \"$$\" \n # self.print_all_words_in_beam()\n # print \"############## Beam Advance ###########\"\n\n def done(self):\n return self.eos_top and len(self.finished) >= self.n_best\n\n def sort_finished(self, minimum=None):\n if minimum is not None:\n i = 0\n # Add from beam until we have minimum outputs.\n while len(self.finished) < minimum:\n s = self.scores[i]\n if self.global_scorer is not None:\n global_scores = self.global_scorer.score(self, self.scores)\n s = global_scores[i]\n self.finished.append((s, len(self.next_ys) - 1, i))\n\n # print self.finished\n # exit()\n\n self.finished.sort(key=lambda a: -a[0])\n scores = [sc for sc, _, _ in self.finished]\n ks = [(t, k) for _, t, k in self.finished]\n return scores, ks\n\n def get_hyp_with_class(self, timestep, k):\n \"\"\"\n Walk back to construct the full hypothesis while also storing the class/topic number\n \"\"\"\n hyp, class_or_topic = [], []\n # print len(self.next_ys), len(self.next_class_or_topics), len(self.next_class_or_topic_numbers)\n for j in range(len(self.prev_ks[:timestep]) - 1, -1, -1):\n hyp.append(self.next_ys[j+1][k])\n class_or_topic.append(\"{}{}\".format(\"C\" if self.next_class_or_topics[j][k] == 1 else \"T\", self.next_class_or_topic_numbers[j][k]))\n k = self.prev_ks[j][k]\n class_or_topic.reverse()\n return hyp[::-1], class_or_topic\n\n def get_hyp(self, timestep, k):\n \"\"\"\n Walk back to construct the full hypothesis.\n \"\"\"\n hyp, attn = [], []\n for j in range(len(self.prev_ks[:timestep]) - 1, -1, -1):\n hyp.append(self.next_ys[j+1][k])\n attn.append(self.attn[j][k])\n k = self.prev_ks[j][k]\n return hyp[::-1], torch.stack(attn[::-1])\n\n\nclass GNMTGlobalScorer(object):\n \"\"\"\n NMT re-ranking score from\n \"Google's Neural Machine Translation System\" :cite:`wu2016google`\n\n Args:\n alpha (float): length parameter\n beta (float): coverage parameter\n \"\"\"\n def __init__(self, alpha, beta):\n self.alpha = alpha\n self.beta = beta\n\n def score(self, beam, logprobs):\n \"Additional term add to log probability\"\n cov = beam.global_state[\"coverage\"]\n pen = self.beta * torch.min(cov, cov.clone().fill_(1.0)).log().sum(1)\n l_term = (((5 + len(beam.next_ys)) ** self.alpha) /\n ((5 + 1) ** self.alpha))\n return (logprobs / l_term) + pen\n\n def update_global_state(self, beam):\n \"Keeps the coverage vector as sum of attens\"\n if len(beam.prev_ks) == 1:\n beam.global_state[\"coverage\"] = beam.attn[-1]\n else:\n beam.global_state[\"coverage\"] = beam.global_state[\"coverage\"] \\\n .index_select(0, beam.prev_ks[-1]).add(beam.attn[-1])\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Improving Response Quality with Backward Reasoningin Open-domain Dialogue Systems\nThis is the codebase for paper: \"[Improving Response Quality with Backward Reasoningin Open-domain Dialogue Systems](https://arxiv.org/abs/2105.00079)\".\n\n\n## Requirements: \n* **Pytorch-1.1**\n* Python 2.7\n* CUDA 9.2+ (For GPU)\n\n#### The main function for training is in train.py\nTo process a new dataset, run:\n```\n$ python -u preprocess.py -train_src $train_src -train_tgt $train_tgt -train_ctx $train_ctx -valid_src $valid_src -valid_tgt $valid_tgt -valid_ctx $valid_ctx -save_data /daily_dialog/pair_daily -dynamic_dict -share_vocab -src_seq_length 45 -ctx_seq_length 100 -tgt_seq_length 45\n```\n$train_tgt is the path of target response in training set (utt at step t); $train_src is the path of source utteracne in training set (utt at step t-1); $train_ctx is the context utt (utt at step t-2).\n\nTo train a new model, just run:\n\n```\n$ python train.py -data data/mirror_dailydialog -save_model /model_dir/model_prefix -gpuid 0 -encoder_type rnn -param_init 0.08 -batch_size 128 -learning_rate 0.001 -optim adam -max_grad_norm 2 -word_vec_size 300 -enc_layers 2 -dec_layers 2 -rnn_size 1000 -epochs 65 -learning_rate_decay 0.98 -z_dim 100 -start_decay_at 3 -kl_balance 0.2 -mirror_type mirror -share_embeddings \n```\n\nMore hyper-parameter options can be found in file opts.py. Since this code is based on the open-nmt framework, you can go through the open-nmt instructions or the file README_OpenNMT.md if you want. \n\n\nTo generate the responses with a trained model, just run:\n```\npython -u translate.py -model $model -src $test_src -tgt $test_tgt -ctx $test_ctx -output $mirror_output_2 -attn_debug -beam_size 10 -n_best 1 -batch_size 1 -verbose -gpu 0 -use_dc -1\n```\n$mirror_output_2 is for the file to save generated dialogues.\n\nIf you use the code in this repository, feel free to cite our publication [Improving Response Quality with Backward Reasoningin Open-domain Dialogue Systems](https://arxiv.org/abs/2105.00079):\n``` \n@article{li2021mirror,\n title={Improving Response Quality with Backward Reasoningin Open-domain Dialogue Systems},\n author={ },\n journal={SIGIR 2021},\n year={2021}\n}\n\n```\nfrom __future__ import division\nimport torch\n\nimport numpy as np\n#Adding the topic and syntax probability scores to the scores from Decoder\n\nclass Beam(object):\n \"\"\"\n Class for managing the internals of the beam search process.\n\n Takes care of beams, back pointers, and scores.\n\n Args:\n size (int): beam size\n pad, bos, eos (int): indices of padding, beginning, and ending.\n vocab (vocab): vocab of the target\n syntax_topics_model (Syntax and Topics module): This is an object of the class which will have the topics \n and classes word probabilities\n source (list): list of source indices which will be the source sentence\n targets (list of list): list of taget sentences each of which is a list of indices of the full hypothesis generated till now\n n_best (int): nbest size to use\n cuda (bool): use gpu\n global_scorer (:obj:`GlobalScorer`)\n \"\"\"\n def __init__(self, size, pad, bos, eos,\n vocab, syntax_topics_model,\n source,\n n_best=1, cuda=False,\n global_scorer=None,\n min_length=0):\n\n self.size = size\n self.use_cuda = cuda\n # self.tt = torch.cuda if cuda else torch\n self.tt = torch\n\n # The score for each translation on the beam.\n self.scores = self.tt.FloatTensor(size).zero_()\n if self.use_cuda:\n self.scores = self.scores.cuda()\n self.all_scores = []\n\n # The backpointers at each time-step.\n self.prev_ks = []\n\n \n\n # The outputs at each time-step.\n self.next_ys = [self.tt.LongTensor(size)\n .fill_(pad)]\n if self.use_cuda:\n self.next_ys = [self.tt.LongTensor(size)\n .fill_(pad).cuda()]\n self.next_ys[0][0] = bos\n self.next_ys_topic_prior_sum = [] # Store the sum of the weighted topic prior for the entire hypothesis\n\n # Has EOS topped the beam yet.\n self._eos = eos\n self.eos_top = False\n\n # The attentions (matrix) for each time.\n self.attn = []\n\n # Time and k pair for finished.\n self.finished = []\n self.n_best = n_best\n\n # Information for global scoring.\n self.global_scorer = global_scorer\n self.global_state = {}\n\n # Minimum prediction length\n self.min_length = min_length\n\n\n\n ##NOTE: Custom code\n self.vocab = vocab\n self.finished_marker = [-1]*size\n self.syntax_topics_model = syntax_topics_model\n self.source = [self.vocab.itos[word_id] for word_id in source]\n print self.source\n self.source_topic_prior = np.zeros(self.syntax_topics_model.num_topics, dtype=np.float)\n word_prev = \"\"\n for word in self.source:\n self.source_topic_prior += self.syntax_topics_model.get_weighted_topic_word_probability(word, word_prev)\n word_prev = word\n print self.source_topic_prior\n self.L = 50 # Number of words to be chosen for the similarity consideration\n # Note: alpha 0.5 was used for the interpolation objective\n # self.alpha = 0.5 # multiplicative factor for the Syntax Topic log probability\n self.alpha = 2.5 # multiplicative factor for the Syntax Topic log probability\n self.iteration_multiplier = 0.25\n # print vocab.itos[0]\n # print vocab.itos[bos]\n # print vocab.itos[self._eos]\n # print vocab.__dict__.keys()\n # print vocab.unk_init\n # print type(vocab)\n\n def print_hyp(self, hyp, class_or_topic = None):\n for i, word_id in enumerate(hyp):\n if class_or_topic:\n print \"{}_{} \".format(self.vocab.itos[word_id], class_or_topic[i]),\n else:\n print \"{} \".format(self.vocab.itos[word_id]),\n\n ##NOTE: Custom function for debugging\n def print_all_words_in_beam(self):\n # Uses the vocab and prints the list of next_ys\n for i in range(self.size):\n timestep = len(self.next_ys)\n # if self.finished_marker[i] != -1:\n # timestep = self.finished_marker[i]\n if timestep > 1:\n hyp, _ = self.get_hyp(timestep, i)\n self.print_hyp(hyp)\n print \"$$$\"\n # print \"\"\n\n def print_received_targets(self):\n for i in range(len(self.targets)):\n self.print_hyp(self.targets[i])\n print \"\"\n print \"############### Received Targets ############\"\n\n def print_the_top_choices(self, best_choices):\n w, h = best_choices.size()\n for i in range(w):\n for j in range(h):\n print \"{} \".format(self.vocab.itos[best_choices[i,j]]),\n print \"\"\n\n\n def get_current_state(self):\n \"Get the outputs for the current timestep.\"\n return self.next_ys[-1]\n\n def get_current_origin(self):\n \"Get the backpointers for the current timestep.\"\n return self.prev_ks[-1]\n\n def advance(self, word_probs, attn_out):\n print \"Advancing beam\"\n \"\"\"\n Given prob over words for every last beam `wordLk` and attention\n `attn_out`: Compute and update the beam search.\n\n Parameters:\n\n * `word_probs`- probs of advancing from the last step (K x words)\n * `attn_out`- attention at the last step\n\n Returns: True if beam search is complete.\n \"\"\"\n num_words = word_probs.size(1)\n\n # force the output to be longer than self.min_length\n cur_len = len(self.next_ys)\n if cur_len < self.min_length:\n for k in range(len(word_probs)):\n word_probs[k][self._eos] = -1e20\n\n # Sum the previous scores.\n if len(self.prev_ks) > 0:\n beam_scores = word_probs + \\\n self.scores.unsqueeze(1).expand_as(word_probs)\n\n # Don't let EOS have children.\n for i in range(self.next_ys[-1].size(0)):\n if self.next_ys[-1][i] == self._eos:\n beam_scores[i] = -1e20\n else:\n beam_scores = word_probs[0]\n\n #TODO: 1) find the last word for each beam\n # 2) For each possible hypothesis find the Topic modeling probability as Source sentence weighted topic prior * current word weighted topic prior\n # 3) Weighted add the syntax and topic scores to beam_scores and just calculate the next_ys and backpointers as normal\n \n if len(self.prev_ks) > 0:\n per_beam_words = self.next_ys[-1]\n per_beam_prev_topic_probability = self.next_ys_topic_prior_sum[-1]\n # print \"Next iter\"\n\n syntax_topic_scores = self.tt.zeros_like(beam_scores)\n for i in range(self.size):\n word_prev = self.vocab.itos[per_beam_words[i]]\n hyp_topic_probability = per_beam_prev_topic_probability[i]\n for j in range(num_words):\n word = self.vocab.itos[j]\n # Manually discourage unk by setting large negative syntax_topic_probability\n if \"\" in word:\n unk_id = j\n syntax_topic_score = (self.syntax_topics_model.get_weighted_topic_word_probability(word, word_prev) + hyp_topic_probability).dot(self.source_topic_prior)\n syntax_topic_scores[i][j] = syntax_topic_score\n syntax_topic_scores /= float(len(self.source) + len(self.next_ys))\n # Note: Probability interpolation doesn't work because the model then chooses all the sentences mainly from the RNN and barely any words from the topic part are chosen\n # overall_scores = self.tt.log(self.tt.exp(beam_scores) + self.alpha * syntax_topic_scores)\n iteration = len(self.prev_ks)\n overall_scores = beam_scores + self.alpha * np.tanh(iteration * self.iteration_multiplier) * self.tt.log(syntax_topic_scores)\n # adaptive_alpha = beam_scores.max() / self.tt.log(syntax_topic_scores).max() * 0.5\n # overall_scores = beam_scores + adaptive_alpha * self.tt.log(syntax_topic_scores)\n\n beam_mean = beam_scores.topk(30)[0].mean()\n syntax_topic_scores_mean = self.tt.log(syntax_topic_scores.topk(30)[0]).mean()\n # print adaptive_alpha\n # print beam_mean, syntax_topic_scores_mean, beam_mean / syntax_topic_scores_mean\n # print beam_scores.max(), self.tt.log(syntax_topic_scores).max(), beam_scores.max() / self.tt.log(syntax_topic_scores).max()\n # print beam_scores.min(), self.tt.log(syntax_topic_scores).min(), beam_scores.min() / self.tt.log(syntax_topic_scores).min()\n for i in range(self.size):\n overall_scores[i][unk_id] = -100000.0\n # print \"Overall Score\"\n # print overall_scores\n # print overall_scores.size()\n \n # self.print_all_words_in_beam()\n # print \"############## Before new words chosen ###########\"\n\n size = int(overall_scores.size(1))\n # print \"Size of the overall_scores = \", size\n flat_beam_scores = overall_scores.view(-1)\n best_scores, best_scores_id = flat_beam_scores.topk(self.size, 0,\n True, True)\n\n # We will debug the individual scores of the best candidates\n word_prob_best_scores = self.tt.zeros_like(best_scores)\n for i in range(self.size):\n word_prob_best_scores[i] = beam_scores[int(best_scores_id[i] / size)][best_scores_id[i] - int(best_scores_id[i] / size) * size]\n syntax_topic_best_scores = self.tt.zeros_like(best_scores)\n for i in range(self.size):\n syntax_topic_best_scores[i] = syntax_topic_scores[int(best_scores_id[i] / size)][best_scores_id[i] - int(best_scores_id[i] / size) * size]\n print best_scores\n print word_prob_best_scores\n print syntax_topic_best_scores\n print self.alpha, self.alpha * np.tanh(iteration * self.iteration_multiplier)\n print self.alpha * np.tanh(iteration * self.iteration_multiplier) * self.tt.log(syntax_topic_best_scores)\n # print word_prob_best_scores + self.alpha * syntax_topic_best_scores\n\n size = int(overall_scores.size(1))\n prev_k = best_scores_id / num_words\n\n best_hyp_topic_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i] - int(best_scores_id[i] / size) * size]\n word_prev_id = self.next_ys[-1][int(best_scores_id[i] / size)]\n word_prev = self.vocab.itos[word_prev_id]\n word_topic_prior = self.syntax_topics_model.get_weighted_topic_word_probability(word, word_prev)\n best_hyp_topic_prior_sum.append(self.next_ys_topic_prior_sum[-1][int(best_scores_id[i] / size)] + word_topic_prior)\n self.next_ys_topic_prior_sum.append(best_hyp_topic_prior_sum)\n\n self.prev_ks.append(prev_k)\n self.next_ys.append((best_scores_id - prev_k * num_words))\n self.attn.append(attn_out.index_select(0, prev_k))\n # exit()\n\n self.print_all_words_in_beam()\n print \"############## After new words chosen ###########\"\n else:\n # beam_scores is only V dimensional vector\n # Thus for every word add the syntax_topic probability to the beam score\n syntax_topic_scores = self.tt.zeros_like(beam_scores)\n for i in range(num_words):\n word = self.vocab.itos[i]\n if \"\" in word:\n unk_id = i\n syntax_topic_score = self.syntax_topics_model.get_weighted_topic_word_probability(word, \"\").dot(self.source_topic_prior)\n syntax_topic_scores[i] = syntax_topic_score\n\n # overall_scores = beam_scores + self.alpha * self.tt.log(syntax_topic_scores)\n overall_scores = beam_scores\n print \"Unk id is\", unk_id\n overall_scores[unk_id] = -100000.0\n\n flat_beam_scores = overall_scores.view(-1)\n best_scores, best_scores_id = flat_beam_scores.topk(self.size, 0,\n True, True)\n\n self.all_scores.append(self.scores)\n self.scores = best_scores # will store the word_prob + the topic log prob for hypothesis\n\n # best_scores_id is flattened, beam * word array, so calculate which\n # word and beam each score came from\n size = int(overall_scores.size(0))\n prev_k = best_scores_id / num_words\n # next_class_or_topic = self.tt.zeros_like(prev_k)\n # for i in range(self.size):\n # next_class_or_topic[i] = int(class_or_topics[best_scores_id[i]])\n # print prev_k\n # print overall_scores\n # print next_class_or_topic\n # print next_class_or_topic_number\n # print best_scores_id\n\n best_hyp_topic_prior_sum = list()\n for i in range(self.size):\n word = self.vocab.itos[best_scores_id[i]]\n word_topic_prior = self.syntax_topics_model.get_weighted_topic_word_probability(word, \"\")\n best_hyp_topic_prior_sum.append(word_topic_prior)\n self.next_ys_topic_prior_sum.append(best_hyp_topic_prior_sum)\n\n self.prev_ks.append(prev_k)\n self.next_ys.append((best_scores_id - prev_k * num_words))\n self.attn.append(attn_out.index_select(0, prev_k))\n\n if self.global_scorer is not None:\n self.global_scorer.update_global_state(self)\n\n for i in range(self.next_ys[-1].size(0)):\n if self.next_ys[-1][i] == self._eos:\n s = self.scores[i]\n timestep = len(self.next_ys)\n if self.global_scorer is not None:\n global_scores = self.global_scorer.score(self, self.scores)\n s = global_scores[i]\n self.finished.append((s, len(self.next_ys) - 1, i))\n # TODO: Experimental!! Dividing the finished scores by their lenghts to be fair\n # self.finished.append((s/float(len(self.next_ys) - 1), len(self.next_ys) - 1, i))\n\n\n ##NOTE: Custom code\n if self.finished_marker[i] == -1:\n # print \"SET AND FORGET FOR \", i, \"#$#$#$#$##$\"\n self.finished_marker[i] = len(self.next_ys) - 1\n\n\n\n # End condition is when top-of-beam is EOS and no global score.\n if self.next_ys[-1][0] == self._eos:\n # self.all_scores.append(self.scores)\n self.eos_top = True\n\n\n\n ##NOTE: Debugging\n # print word_probs, \"$$\"\n # print self.get_current_state(), \"$$\" \n # self.print_all_words_in_beam()\n # print \"############## Beam Advance ###########\"\n\n def done(self):\n return self.eos_top and len(self.finished) >= self.n_best\n\n def sort_finished(self, minimum=None):\n if minimum is not None:\n i = 0\n # Add from beam until we have minimum outputs.\n while len(self.finished) < minimum:\n s = self.scores[i]\n if self.global_scorer is not None:\n global_scores = self.global_scorer.score(self, self.scores)\n s = global_scores[i]\n self.finished.append((s, len(self.next_ys) - 1, i))\n\n # print self.finished\n # exit()\n\n self.finished.sort(key=lambda a: -a[0])\n scores = [sc for sc, _, _ in self.finished]\n ks = [(t, k) for _, t, k in self.finished]\n return scores, ks\n\n def get_hyp_with_class(self, timestep, k):\n \"\"\"\n Walk back to construct the full hypothesis while also storing the class/topic number\n \"\"\"\n hyp, class_or_topic = [], []\n # print len(self.next_ys), len(self.next_class_or_topics), len(self.next_class_or_topic_numbers)\n for j in range(len(self.prev_ks[:timestep]) - 1, -1, -1):\n hyp.append(self.next_ys[j+1][k])\n class_or_topic.append(\"{}{}\".format(\"C\" if self.next_class_or_topics[j][k] == 1 else \"T\", self.next_class_or_topic_numbers[j][k]))\n k = self.prev_ks[j][k]\n class_or_topic.reverse()\n return hyp[::-1], class_or_topic\n\n def get_hyp(self, timestep, k):\n \"\"\"\n Walk back to construct the full hypothesis.\n \"\"\"\n hyp, attn = [], []\n for j in range(len(self.prev_ks[:timestep]) - 1, -1, -1):\n hyp.append(self.next_ys[j+1][k])\n attn.append(self.attn[j][k])\n k = self.prev_ks[j][k]\n return hyp[::-1], torch.stack(attn[::-1])\n\n\nclass GNMTGlobalScorer(object):\n \"\"\"\n NMT re-ranking score from\n \"Google's Neural Machine Translation System\" :cite:`wu2016google`\n\n Args:\n alpha (float): length parameter\n beta (float): coverage parameter\n \"\"\"\n def __init__(self, alpha, beta):\n self.alpha = alpha\n self.beta = beta\n\n def score(self, beam, logprobs):\n \"Additional term add to log probability\"\n cov = beam.global_state[\"coverage\"]\n pen = self.beta * torch.min(cov, cov.clone().fill_(1.0)).log().sum(1)\n l_term = (((5 + len(beam.next_ys)) ** self.alpha) /\n ((5 + 1) ** self.alpha))\n return (logprobs / l_term) + pen\n\n def update_global_state(self, beam):\n \"Keeps the coverage vector as sum of attens\"\n if len(beam.prev_ks) == 1:\n beam.global_state[\"coverage\"] = beam.attn[-1]\n else:\n beam.global_state[\"coverage\"] = beam.global_state[\"coverage\"] \\\n .index_select(0, beam.prev_ks[-1]).add(beam.attn[-1])\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport codecs\nimport numpy as np\nimport timeit\nimport math\n\nclass SyntaxTopicModel(object):\n\t\"\"\"This class is the partial implementation of \"Integrating Topics and Syntax\" et al.\n\tWe will only use the trained model to get the probabilities of different topics and classes\n\t\"\"\"\n\n\tdef read_vocabulary(self):\n\t\tself.vocab_itos = list()\n\t\tself.vocab_stoi = dict()\n\t\twith codecs.open(self.vocabulary_file, \"r\", \"utf-8\") as reader:\n\t\t\t# Each line is a word and its frequency\n\t\t\ti = 0\n\t\t\tfor line in reader:\n\t\t\t\tline = line.strip()\n\t\t\t\tline_spl = line.split()\n\t\t\t\tif line_spl[0] == \"UNknown\":\n\t\t\t\t\tline_spl[0] = \"\"\n\t\t\t\tself.vocab_itos.append(line_spl[0])\n\t\t\t\tself.vocab_stoi[line_spl[0]] = i\n\t\t\t\ti += 1\n\n\tdef read_documents(self, max_documents = None):\n\t\tself.documents = list()\n\t\twith open(self.documents_file, \"r\") as reader:\n\t\t\tfor i, line in enumerate(reader):\n\t\t\t\tif max_documents and i > max_documents:\n\t\t\t\t\tbreak\n\t\t\t\tself.documents.append(np.fromstring(line, dtype=np.int, sep=' '))\n\n\tdef read_assignments_file(self, filename, variable, t_or_c, max_documents = None):\n\t\t# First line is the number of documents and number of topics/classes\n\t\t# Then rest of the lines are word labels for each document\n\t\twith open(filename, \"r\") as reader:\n\t\t\tfirst_line = next(reader)\n\t\t\tself.n_docs, num_classes_or_topics = first_line.split()\n\t\t\tself.n_docs = int(self.n_docs)\n\t\t\tif t_or_c == 'T':\n\t\t\t\tself.num_topics = int(num_classes_or_topics)\n\t\t\telif t_or_c == 'C':\n\t\t\t\tself.num_classes = int(num_classes_or_topics)\n\t\t\telse:\n\t\t\t\tprint \"Incorrect T or C choice. Given parameter value =\", t_or_c\n\t\t\t\texit()\n\t\t\tfor i, line in enumerate(reader):\n\t\t\t\tif max_documents and i > max_documents:\n\t\t\t\t\tbreak\n\t\t\t\tvariable.append(np.fromstring(line.strip(), dtype=np.int, sep=' '))\n\n\tdef run_counts(self):\n\t\tself.n_docs = len(self.documents)\n\t\tself.vocab_size = len(self.vocab_itos)\n\t\t# We want the following probabilities\n\t\t# P(w|C) a V * n_C dimensional matrix which gives probability of word given the class count(word_class)/count(class)\n\t\t# P(w|T) a V * n_T dimensional matrix which gives probability of word given the topic count(word_topic)/count(topic)\n\t\t# P(T|w) a n_T * V dimensional matrix which gives probability of Topic given the word count(word_topic)/count(word in all topic)\n\t\t# P(C_|C) a n_C * n_C dimensional matrix which is the transition probability of going from a class to another class\n\n\t\t# Calculate counts\n\t\timport os\n\t\tCACHE_FOLDER = \"/your/folder/folder_dc_mmi/syntax_topic_cache\"\n\t\tself.num_word_in_class_cache_file = os.path.join(CACHE_FOLDER, \"num_word_in_class_cache.npy\")\n\t\tself.num_word_in_topic_cache_file = os.path.join(CACHE_FOLDER, \"num_word_in_topic_cache.npy\")\n\t\tself.num_transitions_cache_file = os.path.join(CACHE_FOLDER, \"num_transitions_cache.npy\")\n\n\t\tif not self.recount and os.path.isfile(self.num_word_in_class_cache_file) and os.path.isfile(self.num_word_in_topic_cache_file) and os.path.isfile(self.num_transitions_cache_file):\n\t\t\t# if possible load from cache\n\t\t\tprint \"WARNING: Reloading stuff from cache!!\"\n\t\t\tself.num_word_in_class = np.load(self.num_word_in_class_cache_file)\n\t\t\tself.num_word_in_topic = np.load(self.num_word_in_topic_cache_file)\n\t\t\tself.num_transitions = np.load(self.num_transitions_cache_file)\n\t\telse:\n\t\t\t# Compute from the data\n\t\t\tself.num_word_in_class = np.zeros((self.vocab_size, self.num_classes), dtype=np.float)\n\t\t\tself.num_word_in_topic = np.zeros((self.vocab_size, self.num_topics), dtype=np.float)\n\t\t\tself.num_transitions = np.zeros((self.num_classes, self.num_classes), dtype=np.float)\n\t\t\tfor doc_id, document in enumerate(self.documents):\n\t\t\t\tprev_class = -1\n\t\t\t\tfor i, word_id in enumerate(document):\n\t\t\t\t\tclass_assign = self.class_assignments[doc_id][i]\n\t\t\t\t\ttopic_assign = self.topic_assignments[doc_id][i]\n\t\t\t\t\tif class_assign == 0:\n\t\t\t\t\t\t# Topics class\n\t\t\t\t\t\tself.num_word_in_topic[word_id][topic_assign] += 1\n\t\t\t\t\tself.num_word_in_class[word_id][class_assign] += 1\n\t\t\t\t\tif prev_class != -1:\n\t\t\t\t\t\tself.num_transitions[prev_class][class_assign] += 1\n\t\t\t\t\tprev_class = class_assign\n\t\t\t# Save in cache\n\t\t\tnp.save(self.num_word_in_class_cache_file, self.num_word_in_class)\n\t\t\tnp.save(self.num_word_in_topic_cache_file, self.num_word_in_topic)\n\t\t\tnp.save(self.num_transitions_cache_file, self.num_transitions)\n\t\t# Smooth the word counts by additive smoothing\n\t\tself.num_word_in_class += self.alpha\n\t\tself.num_word_in_topic += self.alpha\n\t\t# self.num_transitions += self.alpha\n\t\t# Calculate the desired probabilities from counts\n\t\tself.P_w_given_c = np.nan_to_num(self.num_word_in_class / np.sum(self.num_word_in_class, axis=0))\n\t\tself.P_w_given_t = np.nan_to_num(self.num_word_in_topic / np.sum(self.num_word_in_topic, axis=0))\n\t\tself.P_t_given_w = np.nan_to_num(self.num_word_in_topic.T / np.sum(self.num_word_in_topic.T, axis=0))\n\t\tself.P_c_given_w = np.nan_to_num(self.num_word_in_class.T / np.sum(self.num_word_in_class.T, axis=0))\n\t\tself.P_c_given_prev_c = self.num_transitions.T / np.sum(self.num_transitions, axis=1)\n\n\t\t# Calcualte the probability of Topic class for the next word given previous word\n\t\t# Summation(P(C=0| C_prev) * P(C_prev|word))\n\t\tself.P_t_given_w_prev = self.P_c_given_prev_c[0,:].dot(self.P_c_given_w)\n\t\tprint(self.P_t_given_w_prev.shape)\n\t\tprint \"Transition probability matrix\"\n\t\tprint(self.P_c_given_prev_c)\n\t\tprint(np.sum(self.P_c_given_prev_c, axis=0))\n\t\tprint(np.sum(self.P_c_given_prev_c, axis=1))\n\n\tdef read_stop_words(self, stop_words_file):\n\t\tstop_words = set()\n\t\twith open(stop_words_file, \"r\") as reader:\n\t\t\tfor line in reader:\n\t\t\t\tline = line.strip()\n\t\t\t\tif line:\n\t\t\t\t\tline_spl = line.split(\"'\")\n\t\t\t\t\tif len(line_spl) == 2:\n\t\t\t\t\t\tstop_words.add(line_spl[0])\n\t\t\t\t\t\tstop_words.add(\"'\" + line_spl[1])\n\t\t\t\t\telse:\n\t\t\t\t\t\tstop_words.add(line)\n\t\treturn stop_words\n\n\tdef __init__(self, vocabulary_file, documents_file, class_assignment_file, topic_assignment_file, stop_words_file, max_documents = None, recount = False):\n\t\tstart = timeit.default_timer()\n\t\tself.max_documents = max_documents\n\t\tself.vocabulary_file = vocabulary_file\n\t\tself.read_vocabulary()\n\t\tself.documents_file = documents_file\n\t\tself.read_documents(self.max_documents)\n\t\tself.class_assignment_file = class_assignment_file\n\t\tself.topic_assignment_file = topic_assignment_file\n\t\tself.class_assignments = list()\n\t\tself.read_assignments_file(self.class_assignment_file, self.class_assignments, \"C\", self.max_documents)\n\t\tself.START_CLASS = self.num_classes - 2\n\t\tself.END_CLASS = self.num_classes - 1\n\t\tself.topic_assignments = list()\n\t\tself.read_assignments_file(self.topic_assignment_file, self.topic_assignments, \"T\", self.max_documents)\n\t\tself.stop_words_file = stop_words_file\n\t\tself.stop_words = self.read_stop_words(self.stop_words_file)\n\t\tself.cache = dict()\t\t\t# A dictionary of tuples which will cache the (word_id, prev_class) pair values\n\t\tself.recount = recount\t\t# Tells whether to recompute the counts from read data\n\t\tself.alpha = 0.01\t\t\t# Smoothing the word counts\n\t\tself.beta = 0.000001\t\t\t\t# Smoothing for the topic prior of the stop words\n\t\tself.run_counts()\n\t\tprint \"Total time taken for Syntax and Topics Model initialization = {}sec\".format(timeit.default_timer() - start)\n\n\tdef get_word_id(self, word):\n\t\t# Given a word check in vocabulary and return the correct word id if present\n\t\t# if the word is of the format word + _ + tag then change it to word\n\t\t# print word\n\t\tword = word.rsplit('_', 1)[0]\n\t\t# print word, \"$$\"\n\t\tif word in self.vocab_stoi:\n\t\t\t# print \"Hit\", word\n\t\t\treturn self.vocab_stoi[word]\n\t\treturn self.vocab_stoi[\"\"]\n\n\tdef clear_cache():\n\t\tself.cache = dict()\n\n\tdef get_class_prior_for_word(self, word):\n\t\tword_id = self.get_word_id(word)\n\t\treturn self.P_c_given_w[:, word_id]\n\n\tdef get_topic_prior_for_word(self, word):\n\t\tword_id = self.get_word_id(word)\n\t\t# class_probs = self.P_c_given_w[:, word_id]\n\t\t# if class_probs[0] == np.max(class_probs) and any(c.isalpha() for c in word) and \"\" not in word:\n\t\t# if word == \"handsomer\":\n\t\t# \tprint word not in self.stop_words \n\t\t# \tprint any(c.isalpha() for c in word)\n\t\t# \tprint \"\" not in word\n\t\t# \tprint np.array(self.P_t_given_w[:,word_id])\n\t\t# \tprint self.vocab_itos[word_id]\n\t\t# \tprint word_id\n\t\t# \tprint self.num_word_in_topic[word_id]\n\t\t# \tprint self.num_word_in_class[word_id]\n\t\tif word not in self.stop_words and any(c.isalpha() for c in word) and \"\" not in word and \"s>\" not in word:\n\t\t\tprior = list(self.P_t_given_w[:,word_id])\n\t\t\tprior.append(self.beta)\n\t\t\treturn np.array(prior)\n\t\telse:\n\t\t\tprior = np.full((self.num_topics+1), self.beta, dtype=np.float)\n\t\t\tprior[self.num_topics] = 1.0\n\t\t\treturn np.array(prior)\n\n\n\t# Return log probability and the chosen class/topic and type of return\n\tdef get_log_prob(self, word, prev_class):\n\t\t# retun log(P(w|C)*P(C|prev_class))\n\t\tword_id = self.get_word_id(word)\n\t\tif (word_id, prev_class) in self.cache:\n\t\t\treturn self.cache[(word_id, prev_class)]\n\t\tprobs_for_classes = self.P_w_given_c[word_id,:] * self.P_c_given_prev_c[:,prev_class]\n\t\tprobs_for_classes[0] = 0.0\n\t\tbest_class = np.argmax(probs_for_classes)\n\t\tbest_class_prob = probs_for_classes[best_class]\n\t\tprobs_for_topics = self.P_w_given_t[word_id,:] * self.P_c_given_prev_c[0,prev_class]\t\t\t# 0 is the topics class\n\t\tbest_topic = np.argmax(probs_for_topics)\n\t\tbest_topic_prob = self.beta * probs_for_topics[best_topic]\n\t\treturn_val = -1000000.0\n\t\tif best_topic_prob > best_class_prob:\n\t\t\ttry:\n\t\t\t\t# print \"Hit\", best_topic_prob, best_class_prob, word, prev_class\n\t\t\t\treturn_val = (math.log(best_topic_prob), best_topic, \"T\")\n\t\t\texcept ValueError:\n\t\t\t\tif best_topic_prob == 0.0:\n\t\t\t\t\treturn_val = (-1000000.0, -1, \"T\")\n\t\t\t\telse:\n\t\t\t\t\tprint \"Best topic prob is for word {} is topic{} and the value is {}\".format(word, best_topic, best_topic_prob)\n\t\t\t\t\tprint prev_class\n\t\t\t\t\tprint probs_for_classes\n\t\t\t\t\tprint probs_for_topics\n\t\t\t\t\texit()\n\t\telse:\n\t\t\ttry:\n\t\t\t\treturn_val = (math.log(best_class_prob), best_class, \"C\")\n\t\t\texcept ValueError:\n\t\t\t\tif best_class_prob == 0.0:\n\t\t\t\t\treturn_val = (-1000000.0, -1, \"C\")\n\t\t\t\telse:\n\t\t\t\t\tprint \"Best class prob is for word {} is class{} and the value is {}\".format(word, best_class, best_class_prob)\n\t\t\t\t\tprint prev_class\n\t\t\t\t\tprint probs_for_classes\n\t\t\t\t\tprint probs_for_topics\n\t\t\t\t\texit()\n\t\tself.cache[(word_id, prev_class)] = return_val\n\t\treturn return_val\n\n\tdef KL_divergence(self, P1, P2):\n\t\ta = np.asarray(P1, dtype=np.float)\n\t\tb = np.asarray(P2, dtype=np.float)\n\t\t# Want to do all the computations in 2 loops\n\t\tsum_a = 0.0\n\t\tsum_b = 0.0\n\t\tfor i in range(a.shape[0]):\n\t\t\tif a[i] != 0.0 and b[i] != 0.0:\n\t\t\t\tsum_a += a[i]\n\t\t\t\tsum_b += b[i]\n\t\tif sum_a == 0.0 or sum_b == 0.0:\n\t\t\treturn 0.0\n\n\n\t\tsum = 0.0\n\t\tfor i in range(a.shape[0]):\n\t\t\tif a[i] != 0.0 and b[i] != 0.0:\n\t\t\t\tsum += a[i]/sum_a * np.log((a[i] / sum_a) / (b[i] / sum_b))\n\t\treturn sum\n\n\t\t# return np.sum(np.where(a != 0, a * np.log(a / b), 0))\n\n\tdef get_weighted_topic_word_probability(self, word, word_prev):\n\t\tword_id = self.get_word_id(word)\n\t\tword_prev_id = self.get_word_id(word_prev)\n\t\t# We hope that this prior will be small for stop words automatically\n\t\t# prior = list(self.P_t_given_w[:,word_id] * self.P_c_given_w_prev[word_prev_id])\n\t\tprior = list(self.P_t_given_w[:,word_id] * self.P_c_given_w[0,word_id])\n\t\treturn np.array(prior)\nfrom __future__ import division\nimport torch\nimport numpy as np\nfrom scipy import spatial\n\n# Compute the weights for each word based on the formula in the paper\ndef getWordWeights(weightfile, a=1e-3):\n\tif a <=0: # when the parameter makes no sense, use unweighted\n\t\ta = 1.0\n\n\tword2weight = {}\n\tN = 0\n\twith open(weightfile, \"r\") as reader:\n\t\tfor line in reader:\n\t\t\tline = line.strip()\n\t\t\tif line:\n\t\t\t\tline = line.split()\n\t\t\t\tif(len(line) == 2):\n\t\t\t\t\tword2weight[line[0]] = float(line[1])\n\t\t\t\t\tN += float(line[1])\n\t\t\t\telse:\n\t\t\t\t\tprint(line)\n\tfor key, value in word2weight.iteritems():\n\t\tword2weight[key] = a / (a + value/N)\n\treturn word2weight\n\n# Gen the word embeddings\ndef getWordEmbeddings(embeddings_file):\n\tembeddings = {}\n\twith open(embeddings_file, \"r\") as reader:\n\t\tfor line in reader:\n\t\t\tline = line.strip()\n\t\t\tline = line.split(\" \", 1)\n\t\t\tembeddings[line[0].strip()] = np.fromstring(line[1], dtype=np.float, sep=\" \")\n\tprint(len(embeddings))\n\treturn embeddings\n\ndef lookupEmbedding(embeddings, w):\n\tw = w.lower()\n\t# convert hashtag to word\n\tif len(w) > 1 and w[0] == '#':\n\t\tw = w.replace(\"#\",\"\")\n\tif w in embeddings:\n\t\treturn embeddings[w]\n\telif 'UUUNKKK' in embeddings:\n\t\treturn embeddings['UUUNKKK']\n\telse:\n\t\treturn embeddings[-1]\n\nclass SIFEmbedding(object):\n\t\"\"\"\n\tSentence embedding generator class which implements the weighted averaging technique specified in https://openreview.net/pdf?id=SyK00v5xx\n\t\n\tArgs:\n\t\ttgt_vocab (Vocab): This is the target vocab. We want the reweighted embeddings for these words\n\t\tembeddings_file (string): String of the file which contains the original PSL word embeddings\n\t\tweights_file (string): wikipedia word frequencies which will help us estimate unigram probabilities\n\t\tpc_file (string): Numpy file which contains the first principal component of sentence embeddings of the sample of sentences from training data\n\n\t\"\"\"\n\tdef __init__(self, tgt_vocab, embeddings_file, weights_file, pc_file, pad_word_id, a=1e-3):\n\t\tself.vocab = tgt_vocab\n\t\tself.embeddings = getWordEmbeddings(embeddings_file)\n\t\tself.word2weight = getWordWeights(weights_file, a)\n\t\t# Initialize embeddings and weights for the target vocab\n\t\t# itov: index to embedding\n\t\tself.itov = list()\n\t\tfor i in range(len(self.vocab.itos)):\n\t\t\tself.itov.append(lookupEmbedding(self.embeddings, self.vocab.itos[i]))\n\t\t# itow: index to weight\n\t\tself.itow = list()\n\t\tfor i in range(len(self.vocab.itos)):\n\t\t\t# initialize the weight only if its corresponding embedding is present\n\t\t\tif self.vocab.itos[i] in self.embeddings and self.vocab.itos[i] in self.word2weight:\n\t\t\t\tself.itow.append(self.word2weight[self.vocab.itos[i]])\n\t\t\telse:\n\t\t\t\tself.itow.append(1.0) # no re weighting\n\t\tself.pc = np.load(pc_file) # pc in the shape of (1, 300)\n\t\t# print self.pc.shape\n\t\tself.dim = self.pc.shape[1]\n\t\tself.pad_word_id = pad_word_id\n\t\tself.cache = dict()\n\n\tdef clear_cache(self):\n\t\tself.cache = dict()\n\t\"\"\"\n\t\tArgs:\n\t\t\tword_ids (list): list of word indices of the sentence\n\t\"\"\"\n\tdef sentence_embedding(self, word_ids):\n\t\t# 1) Find the weighted average of the list of words given in the arguments\n\t\t# print word_ids\n\t\t# for word_id in word_ids.data:\n\t\t# print word_id\n\t\tword_embs = np.array([self.itov[word_id] for word_id in word_ids if word_id != self.pad_word_id])\n\t\tword_weights = [self.itow[word_id] for word_id in word_ids if word_id != self.pad_word_id]\n\t\temb = np.average(word_embs, axis=0, weights=word_weights)\n\n\t\t# 2) Remove the first principal component from this embedding\n\t\t# NOTE: futher code is shamefully copied from the SIF_embddings.py file. Don't complain if it looks ugly\n\t\tX = emb.reshape(1, self.dim)\n\t\tXX = X - X.dot(self.pc.transpose()) * self.pc\n\t\temb = XX.reshape(self.dim)\n\t\treturn emb\n\n\tdef remove_pad_word(self, sent):\n\t\treturn tuple([word_id for word_id in sent if word_id != self.pad_word_id])\n\n\t\"\"\"\n\t\tArgs:\n\t\t\tsent1 (list): List of word indices of the first sentence\n\t\t\tsent2 (list): List of word indices of the second sentence\n\t\"\"\"\n\tdef Similarity(self, sent1, sent2):\n\t\t# Cache the sent1 because it is repeating\n\t\tsent1 = self.remove_pad_word(sent1)\n\t\tsent2 = self.remove_pad_word(sent2)\n\t\tif len(sent1) == 0 or len(sent1) == 0:\n\t\t\treturn 0.0\n\t\tif sent1 in self.cache:\n\t\t\temb1 = self.cache[sent1]\n\t\telse:\n\t\t\temb1 = self.sentence_embedding(sent1)\n\t\t\tself.cache[sent1] = emb1\n\t\temb2 = self.sentence_embedding(sent2)\n\t\tcos_similarity = 1 - spatial.distance.cosine(emb1, emb2)\n\t\treturn cos_similarity\n\n\t\"\"\"\n\t\tArgs:\n\t\t\ttargets (list of list): List of target sentences (which are essentially list of word indices)\n\t\t\tsent (list): List of word indices\n\t\"\"\"\n\tdef Targets_Similarity(self, targets, sent, max_flag=True):\n\t\tsimilarity = list()\n\t\tif len(targets) == 0:\n\t\t\treturn 0.0\n\t\tfor i in range(len(targets)):\n\t\t\tsimilarity.append(self.Similarity(targets[i], sent))\n\t\tsimilarity = np.array(similarity)\n\t\tif max_flag:\n\t\t\treturn np.max(similarity)\n\t\telse:\n\t\t\treturn np.avg(similarity)\n\nfrom __future__ import division\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Variable\nfrom torch.nn.utils.rnn import pack_padded_sequence as pack\nfrom torch.nn.utils.rnn import pad_packed_sequence as unpack\nimport logging\nimport onmt\nfrom onmt.Utils import aeq\n\nclass Pack(dict):\n def __getattr__(self, name):\n return self[name]\n\n def add(self, **kwargs):\n for k, v in kwargs.items():\n self[k] = v\n\n def copy(self):\n pack = Pack()\n for k, v in self.items():\n if type(v) is list:\n pack[k] = list(v)\n else:\n pack[k] = v\n return pack\n\nclass EncoderBase(nn.Module):\n \"\"\"\n Base encoder class. Specifies the interface used by different encoder types\n and required by :obj:`onmt.Models.NMTModel`.\n\n .. mermaid::\n\n graph BT\n A[Input]\n subgraph RNN\n C[Pos 1]\n D[Pos 2]\n E[Pos N]\n end\n F[Context]\n G[Final]\n A-->C\n A-->D\n A-->E\n C-->F\n D-->F\n E-->F\n E-->G\n \"\"\"\n def _check_args(self, input, lengths=None, hidden=None):\n s_len, n_batch, n_feats = input.size()\n if lengths is not None:\n n_batch_, = lengths.size()\n aeq(n_batch, n_batch_)\n\n def forward(self, input, lengths=None, hidden=None):\n \"\"\"\n Args:\n input (:obj:`LongTensor`):\n padded sequences of sparse indices `[src_len x batch x nfeat]`\n lengths (:obj:`LongTensor`): length of each sequence `[batch]`\n hidden (class specific):\n initial hidden state.\n\n Returns:k\n (tuple of :obj:`FloatTensor`, :obj:`FloatTensor`):\n * final encoder state, used to initialize decoder\n `[layers x batch x hidden]`\n * contexts for attention, `[src_len x batch x hidden]`\n \"\"\"\n raise NotImplementedError\n\n\nclass MeanEncoder(EncoderBase):\n \"\"\"A trivial non-recurrent encoder. Simply applies mean pooling.\n\n Args:\n num_layers (int): number of replicated layers\n embeddings (:obj:`onmt.modules.Embeddings`): embedding module to use\n \"\"\"\n def __init__(self, num_layers, embeddings):\n super(MeanEncoder, self).__init__()\n self.num_layers = num_layers\n self.embeddings = embeddings\n\n def forward(self, input, lengths=None, hidden=None):\n \"See :obj:`EncoderBase.forward()`\"\n self._check_args(input, lengths, hidden)\n\n emb = self.embeddings(input)\n s_len, batch, emb_dim = emb.size()\n mean = emb.mean(0).expand(self.num_layers, batch, emb_dim)\n return (mean, mean), emb\n\n\nclass RNNEncoder(EncoderBase):\n \"\"\" A generic recurrent neural network encoder.\n\n Args:\n rnn_type (:obj:`str`):\n style of recurrent unit to use, one of [RNN, LSTM, GRU, SRU]\n bidirectional (bool) : use a bidirectional RNN\n num_layers (int) : number of stacked layers\n hidden_size (int) : hidden size of each layer\n dropout (float) : dropout value for :obj:`nn.Dropout`\n embeddings (:obj:`onmt.modules.Embeddings`): embedding module to use\n \"\"\"\n def __init__(self, rnn_type, bidirectional, num_layers,\n hidden_size, dropout=0.0, embeddings=None):\n super(RNNEncoder, self).__init__()\n assert embeddings is not None\n\n num_directions = 2 if bidirectional else 1\n assert hidden_size % num_directions == 0\n hidden_size = hidden_size // num_directions\n self.embeddings = embeddings\n self.no_pack_padded_seq = False\n\n # Use pytorch version when available.\n if rnn_type == \"SRU\":\n # SRU doesn't support PackedSequence.\n self.no_pack_padded_seq = True\n self.rnn = onmt.modules.SRU(\n input_size=embeddings.embedding_size,\n hidden_size=hidden_size,\n num_layers=num_layers,\n dropout=dropout,\n bidirectional=bidirectional)\n else:\n self.rnn = getattr(nn, rnn_type)(\n input_size=embeddings.embedding_size,\n hidden_size=hidden_size,\n num_layers=num_layers,\n dropout=dropout,\n bidirectional=bidirectional)\n\n def forward(self, input, lengths=None, hidden=None):\n \"See :obj:`EncoderBase.forward()`\"\n self._check_args(input, lengths, hidden)\n\n emb = self.embeddings(input)\n s_len, batch, emb_dim = emb.size()\n\n packed_emb = emb\n if lengths is not None and not self.no_pack_padded_seq:\n # Lengths data is wrapped inside a Variable.\n lengths = lengths.view(-1).tolist()\n packed_emb = pack(emb, lengths)\n\n outputs, hidden_t = self.rnn(packed_emb, hidden)\n\n if lengths is not None and not self.no_pack_padded_seq:\n outputs = unpack(outputs)[0]\n\n return hidden_t, outputs\n\n\nclass RNNDecoderBase(nn.Module):\n \"\"\"\n Base recurrent attention-based decoder class.\n Specifies the interface used by different decoder types\n and required by :obj:`onmt.Models.NMTModel`.\n\n\n .. mermaid::\n\n graph BT\n A[Input]\n subgraph RNN\n C[Pos 1]\n D[Pos 2]\n E[Pos N]\n end\n G[Decoder State]\n H[Decoder State]\n I[Outputs]\n F[Context]\n A--emb-->C\n A--emb-->D\n A--emb-->E\n H-->C\n C-- attn --- F\n D-- attn --- F\n E-- attn --- F\n C-->I\n D-->I\n E-->I\n E-->G\n F---I\n\n Args:\n rnn_type (:obj:`str`):\n style of recurrent unit to use, one of [RNN, LSTM, GRU, SRU]\n bidirectional_encoder (bool) : use with a bidirectional encoder\n num_layers (int) : number of stacked layers\n hidden_size (int) : hidden size of each layer\n attn_type (str) : see :obj:`onmt.modules.GlobalAttention`\n coverage_attn (str): see :obj:`onmt.modules.GlobalAttention`\n context_gate (str): see :obj:`onmt.modules.ContextGate`\n copy_attn (bool): setup a separate copy attention mechanism\n dropout (float) : dropout value for :obj:`nn.Dropout`\n embeddings (:obj:`onmt.modules.Embeddings`): embedding module to use\n \"\"\"\n def __init__(self, rnn_type, bidirectional_encoder, num_layers,\n hidden_size, attn_type=\"general\",\n coverage_attn=False, context_gate=None,\n copy_attn=False, dropout=0.0, embeddings=None):\n super(RNNDecoderBase, self).__init__()\n\n # Basic attributes.\n self.decoder_type = 'rnn'\n self.bidirectional_encoder = bidirectional_encoder\n self.num_layers = num_layers\n self.hidden_size = hidden_size\n self.embeddings = embeddings\n self.dropout = nn.Dropout(dropout)\n\n # Build the RNN.\n self.rnn = self._build_rnn(rnn_type, self._input_size, hidden_size,\n num_layers, dropout)\n\n # Set up the context gate.\n self.context_gate = None\n if context_gate is not None:\n self.context_gate = onmt.modules.context_gate_factory(\n context_gate, self._input_size,\n hidden_size, hidden_size, hidden_size\n )\n\n # Set up the standard attention.\n self._coverage = coverage_attn\n self.attn = onmt.modules.GlobalAttention(\n hidden_size, coverage=coverage_attn,\n attn_type=attn_type\n )\n\n # Set up a separated copy attention layer, if needed.\n self._copy = False\n if copy_attn:\n self.copy_attn = onmt.modules.GlobalAttention(\n hidden_size, attn_type=attn_type\n )\n self._copy = True\n\n def forward(self, input, context, state, context_lengths=None):\n \"\"\"\n Args:\n input (`LongTensor`): sequences of padded tokens\n `[tgt_len x batch x nfeats]`.\n context (`FloatTensor`): vectors from the encoder\n `[src_len x batch x hidden]`.\n state (:obj:`onmt.Models.DecoderState`):\n decoder state object to initialize the decoder\n context_lengths (`LongTensor`): the padded source lengths\n `[batch]`.\n Returns:\n (`FloatTensor`,:obj:`onmt.Models.DecoderState`,`FloatTensor`):\n * outputs: output from the decoder\n `[tgt_len x batch x hidden]`.\n * state: final hidden state from the decoder\n * attns: distribution over src at each tgt\n `[tgt_len x batch x src_len]`.\n \"\"\"\n # Args Check\n assert isinstance(state, RNNDecoderState)\n input_len, input_batch, _ = input.size()\n contxt_len, contxt_batch, _ = context.size()\n aeq(input_batch, contxt_batch)\n # END Args Check\n\n # Run the forward pass of the RNN.\n hidden, outputs, attns, coverage = self._run_forward_pass(\n input, context, state, context_lengths=context_lengths)\n\n # Update the state with the result.\n final_output = outputs[-1]\n state.update_state(hidden, final_output.unsqueeze(0),\n coverage.unsqueeze(0)\n if coverage is not None else None)\n\n # Concatenates sequence of tensors along a new dimension.\n outputs = torch.stack(outputs)\n for k in attns:\n attns[k] = torch.stack(attns[k])\n\n return outputs, state, attns\n\n def _fix_enc_hidden(self, h):\n \"\"\"\n The encoder hidden is (layers*directions) x batch x dim.\n We need to convert it to layers x batch x (directions*dim).\n \"\"\"\n # logging.info(\"hidden size: {}\".format(h.size()))\n #(8, 256, 500)\n if self.bidirectional_encoder:\n h = torch.cat([h[0:h.size(0):2], h[1:h.size(0):2]], 2)\n # logging.info(\"hidden size: {}\".format(h.size()))\n #(4, 256, 1000)\n\n return h\n\n def init_decoder_state(self, src, context, enc_hidden):\n if isinstance(enc_hidden, tuple): # LSTM\n return RNNDecoderState(context, self.hidden_size,\n tuple([self._fix_enc_hidden(enc_hidden[i])\n for i in range(len(enc_hidden))]))\n else: # GRU\n return RNNDecoderState(context, self.hidden_size,\n self._fix_enc_hidden(enc_hidden))\n\n\nclass StdRNNDecoder(RNNDecoderBase):\n \"\"\"\n Standard fully batched RNN decoder with attention.\n Faster implementation, uses CuDNN for implementation.\n See :obj:`RNNDecoderBase` for options.\n\n\n Based around the approach from\n \"Neural Machine Translation By Jointly Learning To Align and Translate\"\n :cite:`Bahdanau2015`\n\n\n Implemented without input_feeding and currently with no `coverage_attn`\n or `copy_attn` support.\n \"\"\"\n def _run_forward_pass(self, input, context, state, context_lengths=None):\n \"\"\"\n Private helper for running the specific RNN forward pass.\n Must be overriden by all subclasses.\n Args:\n input (LongTensor): a sequence of input tokens tensors\n of size (len x batch x nfeats).\n context (FloatTensor): output(tensor sequence) from the encoder\n RNN of size (src_len x batch x hidden_size).\n state (FloatTensor): hidden state from the encoder RNN for\n initializing the decoder.\n context_lengths (LongTensor): the source context lengths.\n Returns:\n hidden (Variable): final hidden state from the decoder.\n outputs ([FloatTensor]): an array of output of every time\n step from the decoder.\n attns (dict of (str, [FloatTensor]): a dictionary of different\n type of attention Tensor array of every time\n step from the decoder.\n coverage (FloatTensor, optional): coverage from the decoder.\n \"\"\"\n assert not self._copy # TODO, no support yet.\n assert not self._coverage # TODO, no support yet.\n\n # Initialize local and return variables.\n outputs = []\n attns = {\"std\": []}\n coverage = None\n\n emb = self.embeddings(input)\n\n # Run the forward pass of the RNN.\n if isinstance(self.rnn, nn.GRU):\n rnn_output, hidden = self.rnn(emb, state.hidden[0])\n else:\n rnn_output, hidden = self.rnn(emb, state.hidden)\n # Result Check\n input_len, input_batch, _ = input.size()\n output_len, output_batch, _ = rnn_output.size()\n aeq(input_len, output_len)\n aeq(input_batch, output_batch)\n # END Result Check\n\n # Calculate the attention.\n attn_outputs, attn_scores = self.attn(\n rnn_output.transpose(0, 1).contiguous(), # (output_len, batch, d)\n context.transpose(0, 1), # (contxt_len, batch, d)\n context_lengths=context_lengths\n )\n attns[\"std\"] = attn_scores\n\n # Calculate the context gate.\n if self.context_gate is not None:\n outputs = self.context_gate(\n emb.view(-1, emb.size(2)),\n rnn_output.view(-1, rnn_output.size(2)),\n attn_outputs.view(-1, attn_outputs.size(2))\n )\n outputs = outputs.view(input_len, input_batch, self.hidden_size)\n outputs = self.dropout(outputs)\n else:\n outputs = self.dropout(attn_outputs) # (input_len, batch, d)\n\n # Return result.\n return hidden, outputs, attns, coverage\n\n def _build_rnn(self, rnn_type, input_size,\n hidden_size, num_layers, dropout):\n \"\"\"\n Private helper for building standard decoder RNN.\n \"\"\"\n # Use pytorch version when available.\n if rnn_type == \"SRU\":\n return onmt.modules.SRU(\n input_size, hidden_size,\n num_layers=num_layers,\n dropout=dropout)\n\n return getattr(nn, rnn_type)(\n input_size, hidden_size,\n num_layers=num_layers,\n dropout=dropout)\n\n @property\n def _input_size(self):\n \"\"\"\n Private helper returning the number of expected features.\n \"\"\"\n return self.embeddings.embedding_size\n\n\nclass InputFeedRNNDecoder(RNNDecoderBase):\n \"\"\"\n Input feeding based decoder. See :obj:`RNNDecoderBase` for options.\n\n Based around the input feeding approach from\n \"Effective Approaches to Attention-based Neural Machine Translation\"\n :cite:`Luong2015`\n\n\n .. mermaid::\n\n graph BT\n A[Input n-1]\n AB[Input n]\n subgraph RNN\n E[Pos n-1]\n F[Pos n]\n E --> F\n end\n G[Encoder]\n H[Context n-1]\n A --> E\n AB --> F\n E --> H\n G --> H\n \"\"\"\n\n def _run_forward_pass(self, input, context, state, context_lengths=None):\n \"\"\"\n See StdRNNDecoder._run_forward_pass() for description\n of arguments and return values.\n \"\"\"\n # Additional args check.\n output = state.input_feed.squeeze(0)\n output_batch, _ = output.size()\n input_len, input_batch, _ = input.size()\n aeq(input_batch, output_batch)\n # END Additional args check.\n\n # Initialize local and return variables.\n outputs = []\n attns = {\"std\": []}\n if self._copy:\n attns[\"copy\"] = []\n if self._coverage:\n attns[\"coverage\"] = []\n\n emb = self.embeddings(input)\n assert emb.dim() == 3 # len x batch x embedding_dim\n\n hidden = state.hidden\n coverage = state.coverage.squeeze(0) \\\n if state.coverage is not None else None\n\n # Input feed concatenates hidden state with\n # input at every time step.\n for i, emb_t in enumerate(emb.split(1)):\n emb_t = emb_t.squeeze(0)\n emb_t = torch.cat([emb_t, output], 1)\n\n rnn_output, hidden = self.rnn(emb_t, hidden)\n attn_output, attn = self.attn(\n rnn_output,\n context.transpose(0, 1),\n context_lengths=context_lengths)\n if self.context_gate is not None:\n # TODO: context gate should be employed\n # instead of second RNN transform.\n output = self.context_gate(\n emb_t, rnn_output, attn_output\n )\n output = self.dropout(output)\n else:\n output = self.dropout(attn_output)\n outputs += [output]\n attns[\"std\"] += [attn]\n\n # Update the coverage attention.\n if self._coverage:\n coverage = coverage + attn \\\n if coverage is not None else attn\n attns[\"coverage\"] += [coverage]\n\n # Run the forward pass of the copy attention layer.\n if self._copy:\n _, copy_attn = self.copy_attn(output,\n context.transpose(0, 1))\n attns[\"copy\"] += [copy_attn]\n\n # Return result.\n return hidden, outputs, attns, coverage\n\n def _build_rnn(self, rnn_type, input_size,\n hidden_size, num_layers, dropout):\n assert not rnn_type == \"SRU\", \"SRU doesn't support input feed! \" \\\n \"Please set -input_feed 0!\"\n if rnn_type == \"LSTM\":\n stacked_cell = onmt.modules.StackedLSTM\n else:\n stacked_cell = onmt.modules.StackedGRU\n return stacked_cell(num_layers, input_size,\n hidden_size, dropout)\n\n @property\n def _input_size(self):\n \"\"\"\n Using input feed by concatenating input with attention vectors.\n \"\"\"\n return self.embeddings.embedding_size + self.hidden_size\n\n\nclass NMTModel(nn.Module):\n \"\"\"\n Core trainable object in OpenNMT. Implements a trainable interface\n for a simple, generic encoder + decoder model.\n\n Args:\n encoder (:obj:`EncoderBase`): an encoder object\n decoder (:obj:`RNNDecoderBase`): a decoder object\n multi